constraint.c 30.2 KB
Newer Older
1
/* $OpenLDAP$ */
Howard Chu's avatar
Howard Chu committed
2
3
4
/* constraint.c - Overlay to constrain attributes to certain values */
/* 
 * Copyright 2003-2004 Hewlett-Packard Company
5
 * Copyright 2007 Emmanuel Dreyfus
Howard Chu's avatar
Howard Chu committed
6
7
8
9
10
11
12
13
14
15
16
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted only as authorized by the OpenLDAP
 * Public License.
 *
 * A copy of this license is available in the file LICENSE in the
 * top-level directory of the distribution or, alternatively, at
 * <http://www.OpenLDAP.org/license.html>.
 */
/*
17
 * Authors: Neil Dunbar <neil.dunbar@hp.com>
Josh Soref's avatar
Josh Soref committed
18
 *			Emmanuel Dreyfus <manu@netbsd.org>
Howard Chu's avatar
Howard Chu committed
19
20
21
22
23
24
25
26
27
28
29
 */
#include "portable.h"

#ifdef SLAPD_OVER_CONSTRAINT

#include <stdio.h>

#include <ac/string.h>
#include <ac/socket.h>
#include <ac/regex.h>

30
#include "lutil.h"
Howard Chu's avatar
Howard Chu committed
31
#include "slap.h"
32
#include "config.h"
Howard Chu's avatar
Howard Chu committed
33
34
35
36
37
38
39
40
41

/*
 * This overlay limits the values which can be placed into an
 * attribute, over and above the limits placed by the schema.
 *
 * It traps only LDAP adds and modify commands (and only seeks to
 * control the add and modify value mods of a modify)
 */

42
#define REGEX_STR "regex"
43
#define URI_STR "uri"
44
#define SET_STR "set"
45
46
#define SIZE_STR "size"
#define COUNT_STR "count"
47

Howard Chu's avatar
Howard Chu committed
48
49
50
/*
 * Linked list of attribute constraints which we should enforce.
 * This is probably a sub optimal structure - some form of sorted
Josh Soref's avatar
Josh Soref committed
51
 * array would be better if the number of attributes constrained is
Howard Chu's avatar
Howard Chu committed
52
53
54
 * likely to be much bigger than 4 or 5. We stick with a list for
 * the moment.
 */
55

Howard Chu's avatar
Howard Chu committed
56
typedef struct constraint {
57
	struct constraint *ap_next;
58
	AttributeDescription **ap;
59
60
61
62
63
64

	LDAPURLDesc *restrict_lud;
	struct berval restrict_ndn;
	Filter *restrict_filter;
	struct berval restrict_val;

65
	int type;
66
67
	regex_t *re;
	LDAPURLDesc *lud;
68
	int set;
69
70
	size_t size;
	size_t count;
71
72
73
74
	AttributeDescription **attrs;
	struct berval val; /* constraint value */
	struct berval dn;
	struct berval filter;
Howard Chu's avatar
Howard Chu committed
75
76
} constraint;

77
enum {
78
79
80
81
82
83
	CONSTRAINT_ATTRIBUTE = 1,
	CONSTRAINT_COUNT,
	CONSTRAINT_SIZE,
	CONSTRAINT_REGEX,
	CONSTRAINT_SET,
	CONSTRAINT_URI,
84
85
86
87
88
};

static ConfigDriver constraint_cf_gen;

static ConfigTable constraintcfg[] = {
89
90
	{ "constraint_attribute", "attribute[list]> (regex|uri|set|size|count) <value> [<restrict URI>]",
	  4, 0, 0, ARG_MAGIC | CONSTRAINT_ATTRIBUTE, constraint_cf_gen,
91
	  "( OLcfgOvAt:13.1 NAME 'olcConstraintAttribute' "
92
	  "DESC 'constraint for list of attributes' "
93
	  "EQUALITY caseIgnoreMatch "
94
95
	  "SYNTAX OMsDirectoryString )", NULL, NULL },
	{ NULL, NULL, 0, 0, 0, ARG_IGNORED }
96
97
98
};

static ConfigOCs constraintocs[] = {
99
100
101
102
103
104
105
	{ "( OLcfgOvOc:13.1 "
	  "NAME 'olcConstraintConfig' "
	  "DESC 'Constraint overlay configuration' "
	  "SUP olcOverlayConfig "
	  "MAY ( olcConstraintAttribute ) )",
	  Cft_Overlay, constraintcfg },
	{ NULL, 0, NULL }
106
107
};

108
static void
109
constraint_free( constraint *cp, int freeme )
110
{
111
112
113
114
115
116
117
118
	if (cp->restrict_lud)
		ldap_free_urldesc(cp->restrict_lud);
	if (!BER_BVISNULL(&cp->restrict_ndn))
		ch_free(cp->restrict_ndn.bv_val);
	if (cp->restrict_filter != NULL && cp->restrict_filter != slap_filter_objectClass_pres)
		filter_free(cp->restrict_filter);
	if (!BER_BVISNULL(&cp->restrict_val))
		ch_free(cp->restrict_val.bv_val);
119
120
121
122
123
124
125
126
127
128
	if (cp->re) {
		regfree(cp->re);
		ch_free(cp->re);
	}
	if (!BER_BVISNULL(&cp->val))
		ch_free(cp->val.bv_val);
	if (cp->lud)
		ldap_free_urldesc(cp->lud);
	if (cp->attrs)
		ch_free(cp->attrs);
129
130
	if (cp->ap)
		ch_free(cp->ap);
131
132
	if (freeme)
		ch_free(cp);
133
134
}

135
136
137
static int
constraint_cf_gen( ConfigArgs *c )
{
138
139
140
141
	slap_overinst *on = (slap_overinst *)(c->bi);
	constraint *cn = on->on_bi.bi_private, *cp;
	struct berval bv;
	int i, rc = 0;
142
	constraint ap = { NULL };
143
144
145
146
147
148
149
150
151
	const char *text = NULL;
	
	switch ( c->op ) {
	case SLAP_CONFIG_EMIT:
		switch (c->type) {
		case CONSTRAINT_ATTRIBUTE:
			for (cp=cn; cp; cp=cp->ap_next) {
				char *s;
				char *tstr = NULL;
152
				int quotes = 0, numeric = 0;
153
				int j;
154
155
				size_t val;
				char val_buf[SLAP_TEXT_BUFLEN] = { '\0' };
156
157
158
159
160
161
162
163

				bv.bv_len = STRLENOF("  ");
				for (j = 0; cp->ap[j]; j++) {
					bv.bv_len += cp->ap[j]->ad_cname.bv_len;
				}

				/* room for commas */
				bv.bv_len += j - 1;
164

165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
				switch (cp->type) {
					case CONSTRAINT_COUNT:
						tstr = COUNT_STR;
						val = cp->count;
						numeric = 1;
						break;
					case CONSTRAINT_SIZE:
						tstr = SIZE_STR;
						val = cp->size;
						numeric = 1;
						break;
					case CONSTRAINT_REGEX:
						tstr = REGEX_STR;
						quotes = 1;
						break;
					case CONSTRAINT_SET:
						tstr = SET_STR;
						quotes = 1;
						break;
					case CONSTRAINT_URI:
						tstr = URI_STR;
						quotes = 1;
						break;
					default:
						abort();
190
191
				}

192
193
194
				bv.bv_len += strlen(tstr);
				bv.bv_len += cp->val.bv_len + 2*quotes;

195
196
197
198
				if (cp->restrict_lud != NULL) {
					bv.bv_len += cp->restrict_val.bv_len + STRLENOF(" restrict=\"\"");
				}

199
200
				if (numeric) {
					int len = snprintf(val_buf, sizeof(val_buf), "%zu", val);
201
202
203
204
205
206
207
					if (len <= 0) {
						/* error */
						return -1;
					}
					bv.bv_len += len;
				}

208
209
210
211
212
213
214
215
216
217
				s = bv.bv_val = ch_malloc(bv.bv_len + 1);

				s = lutil_strncopy( s, cp->ap[0]->ad_cname.bv_val, cp->ap[0]->ad_cname.bv_len );
				for (j = 1; cp->ap[j]; j++) {
					*s++ = ',';
					s = lutil_strncopy( s, cp->ap[j]->ad_cname.bv_val, cp->ap[j]->ad_cname.bv_len );
				}
				*s++ = ' ';
				s = lutil_strcopy( s, tstr );
				*s++ = ' ';
218
				if (numeric) {
219
220
221
222
223
224
					s = lutil_strcopy( s, val_buf );
				} else {
					if ( quotes ) *s++ = '"';
					s = lutil_strncopy( s, cp->val.bv_val, cp->val.bv_len );
					if ( quotes ) *s++ = '"';
				}
225
226
227
228
229
				if (cp->restrict_lud != NULL) {
					s = lutil_strcopy( s, " restrict=\"" );
					s = lutil_strncopy( s, cp->restrict_val.bv_val, cp->restrict_val.bv_len );
					*s++ = '"';
				}
230
				*s = '\0';
231
232

				rc = value_add_one( &c->rvalue_vals, &bv );
233
234
235
				if (rc == LDAP_SUCCESS)
					rc = value_add_one( &c->rvalue_nvals, &bv );
				ch_free(bv.bv_val);
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
				if (rc) return rc;
			}
			break;
		default:
			abort();
			break;
		}
		break;
	case LDAP_MOD_DELETE:
		switch (c->type) {
		case CONSTRAINT_ATTRIBUTE:
			if (!cn) break; /* nothing to do */
					
			if (c->valx < 0) {
				/* zap all constraints */
				while (cn) {
					cp = cn->ap_next;
253
					constraint_free( cn, 1 );
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
					cn = cp;
				}
						
				on->on_bi.bi_private = NULL;
			} else {
				constraint **cpp;
						
				/* zap constraint numbered 'valx' */
				for(i=0, cp = cn, cpp = &cn;
					(cp) && (i<c->valx);
					i++, cpp = &cp->ap_next, cp = *cpp);

				if (cp) {
					/* zap cp, and join cpp to cp->ap_next */
					*cpp = cp->ap_next;
269
					constraint_free( cp, 1 );
270
271
272
273
274
275
276
277
278
279
280
281
282
				}
				on->on_bi.bi_private = cn;
			}
			break;

		default:
			abort();
			break;
		}
		break;
	case SLAP_CONFIG_ADD:
	case LDAP_MOD_ADD:
		switch (c->type) {
283
284
285
286
287
288
289
290
291
292
293
		case CONSTRAINT_ATTRIBUTE: {
			int j;
			char **attrs = ldap_str2charray( c->argv[1], "," );

			for ( j = 0; attrs[j]; j++)
				/* just count */ ;
			ap.ap = ch_calloc( sizeof(AttributeDescription*), j + 1 );
			for ( j = 0; attrs[j]; j++) {
				if ( slap_str2ad( attrs[j], &ap.ap[j], &text ) ) {
					snprintf( c->cr_msg, sizeof( c->cr_msg ),
						"%s <%s>: %s\n", c->argv[0], attrs[j], text );
294
295
					rc = ARG_BAD_CONF;
					goto done;
296
				}
297
298
299
300
301
			}

			if ( strcasecmp( c->argv[2], REGEX_STR ) == 0) {
				int err;
			
302
				ap.type = CONSTRAINT_REGEX;
303
304
305
306
307
308
309
310
				ap.re = ch_malloc( sizeof(regex_t) );
				if ((err = regcomp( ap.re,
					c->argv[3], REG_EXTENDED )) != 0) {
					char errmsg[1024];
							
					regerror( err, ap.re, errmsg, sizeof(errmsg) );
					ch_free(ap.re);
					snprintf( c->cr_msg, sizeof( c->cr_msg ),
311
312
						"%s %s: Illegal regular expression \"%s\": Error %s",
						c->argv[0], c->argv[1], c->argv[3], errmsg);
313
					ap.re = NULL;
314
315
					rc = ARG_BAD_CONF;
					goto done;
316
317
				}
				ber_str2bv( c->argv[3], 0, 1, &ap.val );
318
319
			} else if ( strcasecmp( c->argv[2], SIZE_STR ) == 0 ) {
				size_t size;
320
				char *endptr;
321

322
323
324
325
				ap.type = CONSTRAINT_SIZE;
				ap.size = strtoull(c->argv[3], &endptr, 10);
				if ( *endptr )
					rc = ARG_BAD_CONF;
326
327
			} else if ( strcasecmp( c->argv[2], COUNT_STR ) == 0 ) {
				size_t count;
328
				char *endptr;
329

330
331
332
333
				ap.type = CONSTRAINT_COUNT;
				ap.count = strtoull(c->argv[3], &endptr, 10);
				if ( *endptr )
					rc = ARG_BAD_CONF;
334
			} else if ( strcasecmp( c->argv[2], URI_STR ) == 0 ) {
335
336
				int err;
			
337
				ap.type = CONSTRAINT_URI;
338
339
340
341
342
				err = ldap_url_parse(c->argv[3], &ap.lud);
				if ( err != LDAP_URL_SUCCESS ) {
					snprintf( c->cr_msg, sizeof( c->cr_msg ),
						"%s %s: Invalid URI \"%s\"",
						c->argv[0], c->argv[1], c->argv[3]);
343
344
					rc = ARG_BAD_CONF;
					goto done;
345
346
347
348
349
350
351
				}

				if (ap.lud->lud_host != NULL) {
					snprintf( c->cr_msg, sizeof( c->cr_msg ),
						"%s %s: unsupported hostname in URI \"%s\"",
						c->argv[0], c->argv[1], c->argv[3]);
					ldap_free_urldesc(ap.lud);
352
353
					rc = ARG_BAD_CONF;
					goto done;
354
355
356
357
358
359
360
361
362
363
				}

				for ( i=0; ap.lud->lud_attrs[i]; i++);
				/* FIXME: This is worthless without at least one attr */
				if ( i ) {
					ap.attrs = ch_malloc( (i+1)*sizeof(AttributeDescription *));
					for ( i=0; ap.lud->lud_attrs[i]; i++) {
						ap.attrs[i] = NULL;
						if ( slap_str2ad( ap.lud->lud_attrs[i], &ap.attrs[i], &text ) ) {
							ch_free( ap.attrs );
364
							snprintf( c->cr_msg, sizeof( c->cr_msg ),
365
								"%s <%s>: %s\n", c->argv[0], ap.lud->lud_attrs[i], text );
366
367
							rc = ARG_BAD_CONF;
							goto done;
368
369
370
371
372
						}
					}
					ap.attrs[i] = NULL;
				}

373
				if (ap.lud->lud_dn == NULL) {
374
					ap.lud->lud_dn = ch_strdup("");
375
376
377
378
379
380
381
382
383
384
				} else {
					struct berval dn, ndn;

					ber_str2bv( ap.lud->lud_dn, 0, 0, &dn );
					if (dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL ) ) {
						/* cleanup */
						snprintf( c->cr_msg, sizeof( c->cr_msg ),
							"%s %s: URI %s DN normalization failed",
							c->argv[0], c->argv[1], c->argv[3] );
						Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
385
							   "%s: %s\n", c->log, c->cr_msg );
386
387
388
389
390
391
						rc = ARG_BAD_CONF;
						goto done;
					}
					ldap_memfree( ap.lud->lud_dn );
					ap.lud->lud_dn = ndn.bv_val;
				}
392

393
				if (ap.lud->lud_filter == NULL) {
394
					ap.lud->lud_filter = ch_strdup("objectClass=*");
395
396
397
				} else if ( ap.lud->lud_filter[0] == '(' ) {
					ber_len_t len = strlen( ap.lud->lud_filter );
					if ( ap.lud->lud_filter[len - 1] != ')' ) {
398
399
400
401
402
						snprintf( c->cr_msg, sizeof( c->cr_msg ),
							"%s %s: invalid URI filter: %s",
							c->argv[0], c->argv[1], ap.lud->lud_filter );
						rc = ARG_BAD_CONF;
						goto done;
403
404
405
406
					}
					AC_MEMCPY( &ap.lud->lud_filter[0], &ap.lud->lud_filter[1], len - 2 );
					ap.lud->lud_filter[len - 2] = '\0';
				}
407
408

				ber_str2bv( c->argv[3], 0, 1, &ap.val );
409
410
411
412

			} else if ( strcasecmp( c->argv[2], SET_STR ) == 0 ) {
				ap.set = 1;
				ber_str2bv( c->argv[3], 0, 1, &ap.val );
413
				ap.type = CONSTRAINT_SET;
414

415
416
			} else {
				snprintf( c->cr_msg, sizeof( c->cr_msg ),
417
418
419
420
					"%s %s: Unknown constraint type: %s",
					c->argv[0], c->argv[1], c->argv[2] );
				rc = ARG_BAD_CONF;
				goto done;
421
422
			}

423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
			if ( c->argc > 4 ) {
				int argidx;

				for ( argidx = 4; argidx < c->argc; argidx++ ) {
					if ( strncasecmp( c->argv[argidx], "restrict=", STRLENOF("restrict=") ) == 0 ) {
						int err;
						char *arg = c->argv[argidx] + STRLENOF("restrict=");

						err = ldap_url_parse(arg, &ap.restrict_lud);
						if ( err != LDAP_URL_SUCCESS ) {
							snprintf( c->cr_msg, sizeof( c->cr_msg ),
								"%s %s: Invalid restrict URI \"%s\"",
								c->argv[0], c->argv[1], arg);
							rc = ARG_BAD_CONF;
							goto done;
						}

						if (ap.restrict_lud->lud_host != NULL) {
							snprintf( c->cr_msg, sizeof( c->cr_msg ),
								"%s %s: unsupported hostname in restrict URI \"%s\"",
								c->argv[0], c->argv[1], arg);
							rc = ARG_BAD_CONF;
							goto done;
						}

						if ( ap.restrict_lud->lud_attrs != NULL ) {
Thorsten Glaser's avatar
Thorsten Glaser committed
449
							if ( ap.restrict_lud->lud_attrs[0] != NULL ) {
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
								snprintf( c->cr_msg, sizeof( c->cr_msg ),
									"%s %s: attrs not allowed in restrict URI %s\n",
									c->argv[0], c->argv[1], arg);
								rc = ARG_BAD_CONF;
								goto done;
							}
							ldap_memvfree((void *)ap.restrict_lud->lud_attrs);
							ap.restrict_lud->lud_attrs = NULL;
						}

						if (ap.restrict_lud->lud_dn != NULL) {
							if (ap.restrict_lud->lud_dn[0] == '\0') {
								ldap_memfree(ap.restrict_lud->lud_dn);
								ap.restrict_lud->lud_dn = NULL;

							} else {
								struct berval dn, ndn;
								int j;

								ber_str2bv(ap.restrict_lud->lud_dn, 0, 0, &dn);
								if (dnNormalize(0, NULL, NULL, &dn, &ndn, NULL)) {
									/* cleanup */
									snprintf( c->cr_msg, sizeof( c->cr_msg ),
										"%s %s: restrict URI %s DN normalization failed",
										c->argv[0], c->argv[1], arg );
									rc = ARG_BAD_CONF;
									goto done;
								}

								assert(c->be != NULL);
								if (c->be->be_nsuffix == NULL) {
									snprintf( c->cr_msg, sizeof( c->cr_msg ),
										"%s %s: restrict URI requires suffix",
										c->argv[0], c->argv[1] );
									rc = ARG_BAD_CONF;
									goto done;
								}

								for ( j = 0; !BER_BVISNULL(&c->be->be_nsuffix[j]); j++) {
									if (dnIsSuffix(&ndn, &c->be->be_nsuffix[j])) break;
								}

								if (BER_BVISNULL(&c->be->be_nsuffix[j])) {
									/* error */
									snprintf( c->cr_msg, sizeof( c->cr_msg ),
										"%s %s: restrict URI DN %s not within database naming context(s)",
										c->argv[0], c->argv[1], dn.bv_val );
									rc = ARG_BAD_CONF;
									goto done;
								}

								ap.restrict_ndn = ndn;
							}
						}

						if (ap.restrict_lud->lud_filter != NULL) {
							ap.restrict_filter = str2filter(ap.restrict_lud->lud_filter);
							if (ap.restrict_filter == NULL) {
								/* error */
								snprintf( c->cr_msg, sizeof( c->cr_msg ),
									"%s %s: restrict URI filter %s invalid",
									c->argv[0], c->argv[1], ap.restrict_lud->lud_filter );
								rc = ARG_BAD_CONF;
								goto done;
							}
						}

517
						ber_str2bv(c->argv[argidx] + STRLENOF("restrict="), 0, 1, &ap.restrict_val);
518
519
520
521
522
523
524
525
526
527

					} else {
						/* cleanup */
						snprintf( c->cr_msg, sizeof( c->cr_msg ),
							"%s %s: unrecognized arg #%d (%s)",
							c->argv[0], c->argv[1], argidx, c->argv[argidx] );
						rc = ARG_BAD_CONF;
						goto done;
					}
				}
Pierangelo Masarati's avatar
Pierangelo Masarati committed
528
			}
529
530
531
532
533
534

done:;
			if ( rc == LDAP_SUCCESS ) {
				constraint *a2 = ch_calloc( sizeof(constraint), 1 );
				a2->ap_next = on->on_bi.bi_private;
				a2->ap = ap.ap;
535
				a2->type = ap.type;
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
				a2->re = ap.re;
				a2->val = ap.val;
				a2->lud = ap.lud;
				a2->set = ap.set;
				a2->size = ap.size;
				a2->count = ap.count;
				if ( a2->lud ) {
					ber_str2bv(a2->lud->lud_dn, 0, 0, &a2->dn);
					ber_str2bv(a2->lud->lud_filter, 0, 0, &a2->filter);
				}
				a2->attrs = ap.attrs;
				a2->restrict_lud = ap.restrict_lud;
				a2->restrict_ndn = ap.restrict_ndn;
				a2->restrict_filter = ap.restrict_filter;
				a2->restrict_val = ap.restrict_val;
				on->on_bi.bi_private = a2;

			} else {
				Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
555
					   "%s: %s\n", c->log, c->cr_msg );
556
557
558
559
				constraint_free( &ap, 0 );
			}

			ldap_memvfree((void**)attrs);
560
			} break;
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
		default:
			abort();
			break;
		}
		break;
	default:
		abort();
	}

	return rc;
}

static int
constraint_uri_cb( Operation *op, SlapReply *rs ) 
{
	if(rs->sr_type == REP_SEARCH) {
		int *foundp = op->o_callback->sc_private;

		*foundp = 1;

		Debug(LDAP_DEBUG_TRACE, "==> constraint_uri_cb <%s>\n",
582
			rs->sr_entry ? rs->sr_entry->e_name.bv_val : "UNKNOWN_DN" );
583
584
	}
	return 0;
585
586
}

Howard Chu's avatar
Howard Chu committed
587
static int
588
constraint_violation( constraint *c, struct berval *bv, Operation *op )
Howard Chu's avatar
Howard Chu committed
589
{
Pierangelo Masarati's avatar
Pierangelo Masarati committed
590
	if ((!c) || (!bv)) return LDAP_SUCCESS;
591
	
592
593
594
595
596
597
598
599
600
601
602
603
	switch (c->type) {
		case CONSTRAINT_SIZE:
			if (bv->bv_len > c->size)
				return LDAP_CONSTRAINT_VIOLATION; /* size violation */
			break;
		case CONSTRAINT_REGEX:
			if (regexec(c->re, bv->bv_val, 0, NULL, 0) == REG_NOMATCH)
				return LDAP_CONSTRAINT_VIOLATION; /* regular expression violation */
			break;
		case CONSTRAINT_URI: {
			Operation nop = *op;
			slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
604
			slap_callback cb = { 0 };
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
			int i;
			int found = 0;
			int rc;
			size_t len;
			struct berval filterstr;
			char *ptr;

			cb.sc_response = constraint_uri_cb;
			cb.sc_private = &found;

			nop.o_protocol = LDAP_VERSION3;
			nop.o_tag = LDAP_REQ_SEARCH;
			nop.o_time = slap_get_time();
			if (c->lud->lud_dn) {
				struct berval dn;

				ber_str2bv(c->lud->lud_dn, 0, 0, &dn);
				nop.o_req_dn = dn;
				nop.o_req_ndn = dn;
				nop.o_bd = select_backend(&nop.o_req_ndn, 1 );
				if (!nop.o_bd) {
					return LDAP_NO_SUCH_OBJECT; /* unexpected error */
				}
				if (!nop.o_bd->be_search) {
					return LDAP_OTHER; /* unexpected error */
				}
			} else {
				nop.o_req_dn = nop.o_bd->be_nsuffix[0];
				nop.o_req_ndn = nop.o_bd->be_nsuffix[0];
				nop.o_bd = on->on_info->oi_origdb;
Pierangelo Masarati's avatar
Pierangelo Masarati committed
635
			}
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
			nop.o_do_not_cache = 1;
			nop.o_callback = &cb;

			nop.ors_scope = c->lud->lud_scope;
			nop.ors_deref = LDAP_DEREF_NEVER;
			nop.ors_slimit = SLAP_NO_LIMIT;
			nop.ors_tlimit = SLAP_NO_LIMIT;
			nop.ors_limit = NULL;

			nop.ors_attrsonly = 0;
			nop.ors_attrs = slap_anlist_no_attrs;

			len = STRLENOF("(&(") +
				  c->filter.bv_len +
				  STRLENOF(")(|");

			for (i = 0; c->attrs[i]; i++) {
				len += STRLENOF("(") +
					   c->attrs[i]->ad_cname.bv_len +
					   STRLENOF("=") +
					   bv->bv_len +
					   STRLENOF(")");
658
659
			}

660
661
662
663
664
665
666
667
668
669
670
671
672
			len += STRLENOF("))");
			filterstr.bv_len = len;
			filterstr.bv_val = op->o_tmpalloc(len + 1, op->o_tmpmemctx);

			ptr = filterstr.bv_val +
				snprintf(filterstr.bv_val, len, "(&(%s)(|", c->lud->lud_filter);
			for (i = 0; c->attrs[i]; i++) {
				*ptr++ = '(';
				ptr = lutil_strcopy( ptr, c->attrs[i]->ad_cname.bv_val );
				*ptr++ = '=';
				ptr = lutil_strcopy( ptr, bv->bv_val );
				*ptr++ = ')';
			}
673
			*ptr++ = ')';
674
675
			*ptr++ = ')';
			*ptr++ = '\0';
676

677
678
679
680
681
			nop.ors_filterstr = filterstr;
			nop.ors_filter = str2filter_x(&nop, filterstr.bv_val);
			if ( nop.ors_filter == NULL ) {
				Debug( LDAP_DEBUG_ANY,
					"%s constraint_violation uri filter=\"%s\" invalid\n",
682
					op->o_log_prefix, filterstr.bv_val );
683
				rc = LDAP_OTHER;
Pierangelo Masarati's avatar
Pierangelo Masarati committed
684

685
686
			} else {
				SlapReply nrs = { REP_RESULT };
687

688
689
				Debug(LDAP_DEBUG_TRACE,
					"==> constraint_violation uri filter = %s\n",
690
					filterstr.bv_val );
691

692
				rc = nop.o_bd->be_search( &nop, &nrs );
693

694
695
				Debug(LDAP_DEBUG_TRACE,
					"==> constraint_violation uri rc = %d, found = %d\n",
696
					rc, found );
697
698
			}
			op->o_tmpfree(filterstr.bv_val, op->o_tmpmemctx);
699

700
701
702
703
704
705
706
707
			if ((rc != LDAP_SUCCESS) && (rc != LDAP_NO_SUCH_OBJECT)) {
				return rc; /* unexpected error */
			}

			if (!found)
				return LDAP_CONSTRAINT_VIOLATION; /* constraint violation */
			break;
		}
708
	}
709

Pierangelo Masarati's avatar
Pierangelo Masarati committed
710
	return LDAP_SUCCESS;
Howard Chu's avatar
Howard Chu committed
711
712
713
}

static char *
714
print_message( struct berval *errtext, AttributeDescription *a )
Howard Chu's avatar
Howard Chu committed
715
{
716
717
718
719
720
721
722
	char *ret;
	int sz;
	
	sz = errtext->bv_len + sizeof(" on ") + a->ad_cname.bv_len;
	ret = ch_malloc(sz);
	snprintf( ret, sz, "%s on %s", errtext->bv_val, a->ad_cname.bv_val );
	return ret;
Howard Chu's avatar
Howard Chu committed
723
724
}

725
726
727
728
729
730
731
732
733
734
static unsigned
constraint_count_attr(Entry *e, AttributeDescription *ad)
{
	struct Attribute *a;

	if ((a = attr_find(e->e_attrs, ad)) != NULL)
		return a->a_numvals;
	return 0;
}

735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
static int
constraint_check_restrict( Operation *op, constraint *c, Entry *e )
{
	assert( c->restrict_lud != NULL );

	if ( c->restrict_lud->lud_dn != NULL ) {
		int diff = e->e_nname.bv_len - c->restrict_ndn.bv_len;

		if ( diff < 0 ) {
			return 0;
		}

		if ( c->restrict_lud->lud_scope == LDAP_SCOPE_BASE ) {
			return bvmatch( &e->e_nname, &c->restrict_ndn );
		}

		if ( !dnIsSuffix( &e->e_nname, &c->restrict_ndn ) ) {
			return 0;
		}

		if ( c->restrict_lud->lud_scope != LDAP_SCOPE_SUBTREE ) {
			struct berval pdn;

			if ( diff == 0 ) {
				return 0;
			}

			dnParent( &e->e_nname, &pdn );

			if ( c->restrict_lud->lud_scope == LDAP_SCOPE_ONELEVEL
				&& pdn.bv_len != c->restrict_ndn.bv_len )
			{
				return 0;
			}
		}
	}

	if ( c->restrict_filter != NULL ) {
		int rc;
		struct berval save_dn = op->o_dn, save_ndn = op->o_ndn;

		op->o_dn = op->o_bd->be_rootdn;
		op->o_ndn = op->o_bd->be_rootndn;
		rc = test_filter( op, e, c->restrict_filter );
		op->o_dn = save_dn;
		op->o_ndn = save_ndn;

		if ( rc != LDAP_COMPARE_TRUE ) {
			return 0;
		}
	}

	return 1;
}

Howard Chu's avatar
Howard Chu committed
790
791
792
static int
constraint_add( Operation *op, SlapReply *rs )
{
793
794
795
796
797
798
	slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
	Attribute *a;
	constraint *c = on->on_bi.bi_private, *cp;
	BerVarray b = NULL;
	int i;
	struct berval rsv = BER_BVC("add breaks constraint");
Howard Chu's avatar
Howard Chu committed
799
	int rc = 0;
Pierangelo Masarati's avatar
Pierangelo Masarati committed
800
	char *msg = NULL;
801

Howard Chu's avatar
Howard Chu committed
802
	if (get_relax(op) || SLAPD_SYNC_IS_SYNCCONN( op->o_connid )) {
803
804
805
		return SLAP_CB_CONTINUE;
	}

806
807
808
	if ((a = op->ora_e->e_attrs) == NULL) {
		op->o_bd->bd_info = (BackendInfo *)(on->on_info);
		send_ldap_error(op, rs, LDAP_INVALID_SYNTAX,
Pierangelo Masarati's avatar
Pierangelo Masarati committed
809
			"constraint_add: no attrs");
810
811
812
813
814
815
816
817
		return(rs->sr_err);
	}

	for(; a; a = a->a_next ) {
		/* we don't constrain operational attributes */
		if (is_at_operational(a->a_desc->ad_type)) continue;

		for(cp = c; cp; cp = cp->ap_next) {
818
819
820
821
822
			int j;
			for (j = 0; cp->ap[j]; j++) {
				if (cp->ap[j] == a->a_desc) break;
			}
			if (cp->ap[j] == NULL) continue;
823
			if ((b = a->a_vals) == NULL) continue;
824
825
826
827
828

			if (cp->restrict_lud != NULL && constraint_check_restrict(op, cp, op->ora_e) == 0) {
				continue;
			}

829
830
			Debug(LDAP_DEBUG_TRACE, 
				"==> constraint_add, "
831
				"a->a_numvals = %u, cp->count = %lu\n",
832
				a->a_numvals, (unsigned long) cp->count );
833

834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
			switch (cp->type) {
				case CONSTRAINT_COUNT:
					if (a->a_numvals > cp->count)
						rc = LDAP_CONSTRAINT_VIOLATION;
					break;
				case CONSTRAINT_SET:
					if (acl_match_set(&cp->val, op, op->ora_e, NULL) == 0)
						rc = LDAP_CONSTRAINT_VIOLATION;
					break;
				default:
					for ( i = 0; b[i].bv_val; i++ ) {
						rc = constraint_violation( cp, &b[i], op );
						if ( rc ) {
							goto add_violation;
						}
					}
Pierangelo Masarati's avatar
Pierangelo Masarati committed
850
				}
851
852
			if ( rc )
				goto add_violation;
853

854
855
		}
	}
856

Howard Chu's avatar
Howard Chu committed
857
	/* Default is to just fall through to the normal processing */
858
	return SLAP_CB_CONTINUE;
859
860
861

add_violation:
	op->o_bd->bd_info = (BackendInfo *)(on->on_info);
Pierangelo Masarati's avatar
Pierangelo Masarati committed
862
863
864
865
	if (rc == LDAP_CONSTRAINT_VIOLATION ) {
		msg = print_message( &rsv, a->a_desc );
	}
	send_ldap_error(op, rs, rc, msg );
866
867
	ch_free(msg);
	return (rs->sr_err);
Howard Chu's avatar
Howard Chu committed
868
869
}

870

871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
static int
constraint_check_count_violation( Modifications *m, Entry *target_entry, constraint *cp )
{
	BerVarray b = NULL;
	unsigned ce = 0;
	unsigned ca;
	int j;

	for ( j = 0; cp->ap[j]; j++ ) {
		/* Get this attribute count */
		if ( target_entry )
			ce = constraint_count_attr( target_entry, cp->ap[j] );

		for( ; m; m = m->sml_next ) {
			if ( cp->ap[j] == m->sml_desc ) {
Howard Chu's avatar
Howard Chu committed
886
				ca = m->sml_numvals;
887
888
				switch ( m->sml_op ) {
				case LDAP_MOD_DELETE:
889
				case SLAP_MOD_SOFTDEL:
Howard Chu's avatar
Howard Chu committed
890
					if ( !ca || ca > ce ) {
891
						ce = 0;
Howard Chu's avatar
Howard Chu committed
892
					} else {
893
894
895
896
897
898
899
						/* No need to check for values' validity. Invalid values
						 * cause the whole transaction to die anyway. */
						ce -= ca;
					}
					break;

				case LDAP_MOD_ADD:
900
				case SLAP_MOD_SOFTADD:
901
902
903
904
905
906
907
					ce += ca;
					break;

				case LDAP_MOD_REPLACE:
					ce = ca;
					break;

908
909
910
911
912
#if 0
				/* TODO */
				case handle SLAP_MOD_ADD_IF_NOT_PRESENT:
#endif

913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
				default:
					/* impossible! assert? */
					return 1;
				}

				Debug(LDAP_DEBUG_TRACE,
					"==> constraint_check_count_violation ce = %u, "
					"ca = %u, cp->count = %lu\n",
					ce, ca, (unsigned long) cp->count);
			}
		}
	}

	return ( ce > cp->count );
}

Howard Chu's avatar
Howard Chu committed
929
static int
930
constraint_update( Operation *op, SlapReply *rs )
Howard Chu's avatar
Howard Chu committed
931
{
932
	slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
933
	Backend *be = op->o_bd;
934
	constraint *c = on->on_bi.bi_private, *cp;
935
	Entry *target_entry = NULL, *target_entry_copy = NULL;
936
	Modifications *modlist, *m;
937
938
939
	BerVarray b = NULL;
	int i;
	struct berval rsv = BER_BVC("modify breaks constraint");
Pierangelo Masarati's avatar
Pierangelo Masarati committed
940
941
	int rc;
	char *msg = NULL;
942
	int is_v;
943

Howard Chu's avatar
Howard Chu committed
944
	if (get_relax(op) || SLAPD_SYNC_IS_SYNCCONN( op->o_connid )) {
945
946
947
		return SLAP_CB_CONTINUE;
	}

948
949
950
951
952
953
954
955
956
957
958
959
960
	switch ( op->o_tag ) {
	case LDAP_REQ_MODIFY:
		modlist = op->orm_modlist;
		break;

	case LDAP_REQ_MODRDN:
		modlist = op->orr_modlist;
		break;

	default:
		/* impossible! assert? */
		return LDAP_OTHER;
	}
961
	
962
	Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, "constraint_update()\n" );
963
	if ((m = modlist) == NULL) {
964
965
		op->o_bd->bd_info = (BackendInfo *)(on->on_info);
		send_ldap_error(op, rs, LDAP_INVALID_SYNTAX,
966
						"constraint_update() got null modlist");
967
968
969
		return(rs->sr_err);
	}

970
971
972
973
	op->o_bd = on->on_info->oi_origdb;
	rc = be_entry_get_rw( op, &op->o_req_ndn, NULL, NULL, 0, &target_entry );
	op->o_bd = be;

974
975
976
977
	/* let the backend send the error */
	if ( target_entry == NULL )
		return SLAP_CB_CONTINUE;

978
979
	/* Do we need to count attributes? */
	for(cp = c; cp; cp = cp->ap_next) {
980
		if (cp->type == CONSTRAINT_COUNT) {
981
982
983
984
			if (cp->restrict_lud && constraint_check_restrict(op, cp, target_entry) == 0) {
				continue;
			}

985
986
987
			is_v = constraint_check_count_violation(m, target_entry, cp);

			Debug(LDAP_DEBUG_TRACE,
988
				"==> constraint_update is_v: %d\n", is_v );
989
990
991
992
993

			if (is_v) {
				rc = LDAP_CONSTRAINT_VIOLATION;
				goto mod_violation;
			}
994
995
		}
	}
Pierangelo Masarati's avatar
Pierangelo Masarati committed
996
997

	rc = LDAP_CONSTRAINT_VIOLATION;
998
	for(;m; m = m->sml_next) {
999
		unsigned ce = 0;
1000

1001
		if (is_at_operational( m->sml_desc->ad_type )) continue;
1002

1003
		if ((( m->sml_op & LDAP_MOD_OP ) != LDAP_MOD_ADD) &&
1004
1005
			(( m->sml_op & LDAP_MOD_OP ) != LDAP_MOD_REPLACE) &&
			(( m->sml_op & LDAP_MOD_OP ) != LDAP_MOD_DELETE))
1006
1007
			continue;
		/* we only care about ADD and REPLACE modifications */
1008
		/* and DELETE are used to track attribute count */
1009
1010
1011
1012
		if ((( b = m->sml_values ) == NULL ) || (b[0].bv_val == NULL))
			continue;

		for(cp = c; cp; cp = cp->ap_next) {
1013
1014
1015
1016
1017
1018
1019
			int j;
			for (j = 0; cp->ap[j]; j++) {
				if (cp->ap[j] == m->sml_desc) {
					break;
				}
			}
			if (cp->ap[j] == NULL) continue;
1020
1021
1022
1023
1024

			if (cp->restrict_lud != NULL && constraint_check_restrict(op, cp, target_entry) == 0) {
				continue;
			}

1025
1026
1027
1028
			/* DELETE are to be ignored beyond this point */
			if (( m->sml_op & LDAP_MOD_OP ) == LDAP_MOD_DELETE)
				continue;

Pierangelo Masarati's avatar
Pierangelo Masarati committed
1029
			for ( i = 0; b[i].bv_val; i++ ) {
1030
				rc = constraint_violation( cp, &b[i], op );
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1031
				if ( rc ) {
1032
					goto mod_violation;
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1033
1034
				}
			}
1035

1036
			if (cp->type == CONSTRAINT_SET && target_entry) {
1037
1038
1039
1040
1041
				if (target_entry_copy == NULL) {
					Modifications *ml;

					target_entry_copy = entry_dup(target_entry);

1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
					/* if rename, set the new entry's name
					 * (in normalized form only) */
					if ( op->o_tag == LDAP_REQ_MODRDN ) {
						struct berval pdn, ndn = BER_BVNULL;

						if ( op->orr_nnewSup ) {
							pdn = *op->orr_nnewSup;

						} else {
							dnParent( &target_entry_copy->e_nname, &pdn );
						}

						build_new_dn( &ndn, &pdn, &op->orr_nnewrdn, NULL ); 

						ber_memfree( target_entry_copy->e_nname.bv_val );
						target_entry_copy->e_nname = ndn;
						ber_bvreplace( &target_entry_copy->e_name, &ndn );
					}

1061
1062
1063
1064
					/* apply modifications, in an attempt
					 * to estimate what the entry would
					 * look like in case all modifications
					 * pass */
1065
					for ( ml = modlist; ml; ml = ml->sml_next ) {
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
						Modification *mod = &ml->sml_mod;
						const char *text;
						char textbuf[SLAP_TEXT_BUFLEN];
						size_t textlen = sizeof(textbuf);
						int err;

						switch ( mod->sm_op ) {
						case LDAP_MOD_ADD:
							err = modify_add_values( target_entry_copy,
								mod, get_permissiveModify(op),
								&text, textbuf, textlen );
							break;

						case LDAP_MOD_DELETE:
							err = modify_delete_values( target_entry_copy,
								mod, get_permissiveModify(op),
								&text, textbuf, textlen );
							break;

						case LDAP_MOD_REPLACE:
							err = modify_replace_values( target_entry_copy,
								mod, get_permissiveModify(op),
								&text, textbuf, textlen );
							break;

						case LDAP_MOD_INCREMENT:
							err = modify_increment_values( target_entry_copy,
								mod, get_permissiveModify(op),
								&text, textbuf, textlen );
							break;

						case SLAP_MOD_SOFTADD:
 							mod->sm_op = LDAP_MOD_ADD;
							err = modify_add_values( target_entry_copy,
								mod, get_permissiveModify(op),
								&text, textbuf, textlen );
 							mod->sm_op = SLAP_MOD_SOFTADD;
 							if ( err == LDAP_TYPE_OR_VALUE_EXISTS ) {
 								err = LDAP_SUCCESS;
 							}
							break;
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129

						case SLAP_MOD_SOFTDEL:
 							mod->sm_op = LDAP_MOD_ADD;
							err = modify_delete_values( target_entry_copy,
								mod, get_permissiveModify(op),
								&text, textbuf, textlen );
 							mod->sm_op = SLAP_MOD_SOFTDEL;
 							if ( err == LDAP_NO_SUCH_ATTRIBUTE ) {
 								err = LDAP_SUCCESS;
 							}
							break;

						case SLAP_MOD_ADD_IF_NOT_PRESENT:
							if ( attr_find( target_entry_copy->e_attrs, mod->sm_desc ) ) {
								err = LDAP_SUCCESS;
								break;
							}
 							mod->sm_op = LDAP_MOD_ADD;
							err = modify_add_values( target_entry_copy,
								mod, get_permissiveModify(op),
								&text, textbuf, textlen );
 							mod->sm_op = SLAP_MOD_ADD_IF_NOT_PRESENT;
							break;
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147

						default:
							err = LDAP_OTHER;
							break;
						}

						if ( err != LDAP_SUCCESS ) {
							rc = err;
							goto mod_violation;
						}
					}
				}

				if ( acl_match_set(&cp->val, op, target_entry_copy, NULL) == 0) {
					rc = LDAP_CONSTRAINT_VIOLATION;
					goto mod_violation;
				}
			}
1148
1149
		}
	}
1150

1151
1152
1153
1154
1155
	if (target_entry) {
		op->o_bd = on->on_info->oi_origdb;
		be_entry_release_r(op, target_entry);
		op->o_bd = be;
	}
1156
1157
1158
1159
1160

	if (target_entry_copy) {
		entry_free(target_entry_copy);
	}

1161
	return SLAP_CB_CONTINUE;
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1162

1163
1164
1165
1166
1167
1168
1169
mod_violation:
	/* violation */
	if (target_entry) {
		op->o_bd = on->on_info->oi_origdb;
		be_entry_release_r(op, target_entry);
		op->o_bd = be;
	}
1170
1171
1172
1173
1174

	if (target_entry_copy) {
		entry_free(target_entry_copy);
	}

1175
	op->o_bd->bd_info = (BackendInfo *)(on->on_info);
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1176
1177
1178
1179
	if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
		msg = print_message( &rsv, m->sml_desc );
	}
	send_ldap_error( op, rs, LDAP_CONSTRAINT_VIOLATION, msg );
1180
1181
	ch_free(msg);
	return (rs->sr_err);
Howard Chu's avatar
Howard Chu committed
1182
1183
1184
}

static int
1185
constraint_destroy(
1186
	BackendDB *be,
1187
	ConfigReply *cr )
Howard Chu's avatar
Howard Chu committed
1188
{
1189
1190
1191
1192
1193
	slap_overinst *on = (slap_overinst *) be->bd_info;
	constraint *ap, *a2;

	for ( ap = on->on_bi.bi_private; ap; ap = a2 ) {
		a2 = ap->ap_next;
1194
		constraint_free( ap, 1 );
1195
1196
1197
	}

	return 0;
Howard Chu's avatar
Howard Chu committed
1198
1199
1200
1201
}

static slap_overinst constraint_ovl;

1202
1203
1204
1205
1206
#if SLAPD_OVER_CONSTRAINT == SLAPD_MOD_DYNAMIC
static
#endif
int
constraint_initialize( void ) {
1207
1208
1209
	int rc;

	constraint_ovl.on_bi.bi_type = "constraint";
1210
	constraint_ovl.on_bi.bi_flags = SLAPO_BFLAG_SINGLE;
1211
	constraint_ovl.on_bi.bi_db_destroy = constraint_destroy;
1212
	constraint_ovl.on_bi.bi_op_add = constraint_add;
1213
1214
	constraint_ovl.on_bi.bi_op_modify = constraint_update;
	constraint_ovl.on_bi.bi_op_modrdn = constraint_update;
1215
1216
1217
1218
1219
1220
1221
1222

	constraint_ovl.on_bi.bi_private = NULL;
	
	constraint_ovl.on_bi.bi_cf_ocs = constraintocs;
	rc = config_register_schema( constraintcfg, constraintocs );
	if (rc) return rc;
	
	return overlay_register( &constraint_ovl );
Howard Chu's avatar
Howard Chu committed
1223
1224
1225
1226
}

#if SLAPD_OVER_CONSTRAINT == SLAPD_MOD_DYNAMIC
int init_module(int argc, char *argv[]) {
1227
	return constraint_initialize();
Howard Chu's avatar
Howard Chu committed
1228
1229
1230
1231
1232
}
#endif

#endif /* defined(SLAPD_OVER_CONSTRAINT) */