]> git.sur5r.net Git - openldap/blob - servers/slapd/config.c
Coverted LDAP_LOG macro to use subsystem ID int values instead of string values
[openldap] / servers / slapd / config.c
1 /* config.c - configuration file handling routines */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include <ac/string.h>
13 #include <ac/ctype.h>
14 #include <ac/signal.h>
15 #include <ac/socket.h>
16 #include <ac/errno.h>
17
18 #include "lutil.h"
19 #include "ldap_pvt.h"
20 #include "slap.h"
21
22 #define ARGS_STEP       512
23
24 /*
25  * defaults for various global variables
26  */
27 struct slap_limits_set deflimit = {
28         SLAPD_DEFAULT_TIMELIMIT,        /* backward compatible limits */
29         0,
30
31         SLAPD_DEFAULT_SIZELIMIT,        /* backward compatible limits */
32         0,
33         -1                              /* no limit on unchecked size */
34 };
35
36 AccessControl   *global_acl = NULL;
37 slap_access_t           global_default_access = ACL_READ;
38 slap_mask_t             global_restrictops = 0;
39 slap_mask_t             global_allows = 0;
40 slap_mask_t             global_disallows = 0;
41 slap_mask_t             global_requires = 0;
42 slap_ssf_set_t  global_ssf_set;
43 char            *replogfile;
44 int             global_gentlehup = 0;
45 int             global_idletimeout = 0;
46 char    *global_host = NULL;
47 char    *global_realm = NULL;
48 char            *ldap_srvtab = "";
49 char            *default_passwd_hash = NULL;
50 int             cargc = 0, cargv_size = 0;
51 char    **cargv;
52 struct berval default_search_base = { 0, NULL };
53 struct berval default_search_nbase = { 0, NULL };
54 unsigned                num_subordinates = 0;
55
56 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
57 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
58
59 char   *slapd_pid_file  = NULL;
60 char   *slapd_args_file = NULL;
61
62 char   *strtok_quote_ptr;
63
64 #ifdef SLAPD_RLOOKUPS
65 int use_reverse_lookup = 1;
66 #else /* !SLAPD_RLOOKUPS */
67 int use_reverse_lookup = 0;
68 #endif /* !SLAPD_RLOOKUPS */
69
70 static char     *fp_getline(FILE *fp, int *lineno);
71 static void     fp_getline_init(int *lineno);
72 static int      fp_parse_line(int lineno, char *line);
73
74 static char     *strtok_quote(char *line, char *sep);
75 static int      load_ucdata(char *path);
76
77 int
78 read_config( const char *fname )
79 {
80         FILE    *fp;
81         char    *line, *savefname, *saveline;
82         int savelineno;
83         int     lineno, i;
84         int rc;
85         struct berval vals[2];
86
87         static int lastmod = 1;
88         static BackendInfo *bi = NULL;
89         static BackendDB        *be = NULL;
90
91         vals[1].bv_val = NULL;
92
93         cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
94         cargv_size = ARGS_STEP + 1;
95
96         if ( (fp = fopen( fname, "r" )) == NULL ) {
97                 ldap_syslog = 1;
98 #ifdef NEW_LOGGING
99                 LDAP_LOG( CONFIG, ENTRY, 
100                         "read_config: " "could not open config file \"%s\": %s (%d)\n",
101                     fname, strerror(errno), errno );
102 #else
103                 Debug( LDAP_DEBUG_ANY,
104                     "could not open config file \"%s\": %s (%d)\n",
105                     fname, strerror(errno), errno );
106 #endif
107                 return 1;
108         }
109
110 #ifdef NEW_LOGGING
111         LDAP_LOG( CONFIG, ENTRY, 
112                 "read_config: reading config file %s\n", fname, 0, 0 );
113 #else
114         Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
115 #endif
116
117
118         fp_getline_init( &lineno );
119
120         while ( (line = fp_getline( fp, &lineno )) != NULL ) {
121                 /* skip comments and blank lines */
122                 if ( line[0] == '#' || line[0] == '\0' ) {
123                         continue;
124                 }
125
126                 /* fp_parse_line is destructive, we save a copy */
127                 saveline = ch_strdup( line );
128
129                 if ( fp_parse_line( lineno, line ) != 0 ) {
130                         return( 1 );
131                 }
132
133                 if ( cargc < 1 ) {
134 #ifdef NEW_LOGGING
135                         LDAP_LOG( CONFIG, INFO, 
136                                 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
137 #else
138                         Debug( LDAP_DEBUG_ANY,
139                             "%s: line %d: bad config line (ignored)\n",
140                             fname, lineno, 0 );
141 #endif
142
143                         continue;
144                 }
145
146                 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
147                         if ( cargc < 2 ) {
148 #ifdef NEW_LOGGING
149                                 LDAP_LOG( CONFIG, CRIT, 
150                                            "%s : line %d: missing type in \"backend\" line.\n",
151                                            fname, lineno, 0 );
152 #else
153                                 Debug( LDAP_DEBUG_ANY,
154                 "%s: line %d: missing type in \"backend <type>\" line\n",
155                                     fname, lineno, 0 );
156 #endif
157
158                                 return( 1 );
159                         }
160
161                         if( be != NULL ) {
162 #ifdef NEW_LOGGING
163                                 LDAP_LOG( CONFIG, CRIT, 
164                                            "%s: line %d: backend line must appear before any "
165                                            "database definition.\n", fname, lineno , 0 );
166 #else
167                                 Debug( LDAP_DEBUG_ANY,
168 "%s: line %d: backend line must appear before any database definition\n",
169                                     fname, lineno, 0 );
170 #endif
171
172                                 return( 1 );
173                         }
174
175                         bi = backend_info( cargv[1] );
176
177                         if( bi == NULL ) {
178 #ifdef NEW_LOGGING
179                                 LDAP_LOG( CONFIG, CRIT, 
180                                            "read_config: backend %s initialization failed.\n",
181                                            cargv[1], 0, 0 );
182 #else
183                                 Debug( LDAP_DEBUG_ANY,
184                                         "backend %s initialization failed.\n",
185                                     cargv[1], 0, 0 );
186 #endif
187
188                                 return( 1 );
189                         }
190                 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
191                         if ( cargc < 2 ) {
192 #ifdef NEW_LOGGING
193                                 LDAP_LOG( CONFIG, CRIT, 
194                                         "%s: line %d: missing type in \"database <type>\" line\n",
195                                         fname, lineno, 0 );
196 #else
197                                 Debug( LDAP_DEBUG_ANY,
198                 "%s: line %d: missing type in \"database <type>\" line\n",
199                                     fname, lineno, 0 );
200 #endif
201
202                                 return( 1 );
203                         }
204
205                         bi = NULL;
206                         be = backend_db_init( cargv[1] );
207
208                         if( be == NULL ) {
209 #ifdef NEW_LOGGING
210                                 LDAP_LOG( CONFIG, CRIT, 
211                                         "database %s initialization failed.\n", cargv[1], 0, 0 );
212 #else
213                                 Debug( LDAP_DEBUG_ANY,
214                                         "database %s initialization failed.\n",
215                                     cargv[1], 0, 0 );
216 #endif
217
218                                 return( 1 );
219                         }
220
221                 /* set thread concurrency */
222                 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
223                         int c;
224                         if ( cargc < 2 ) {
225 #ifdef NEW_LOGGING
226                                 LDAP_LOG( CONFIG, CRIT, 
227                                         "%s: line %d: missing level in \"concurrency <level\" "
228                                         " line\n", fname, lineno, 0 );
229 #else
230                                 Debug( LDAP_DEBUG_ANY,
231             "%s: line %d: missing level in \"concurrency <level>\" line\n",
232                                     fname, lineno, 0 );
233 #endif
234
235                                 return( 1 );
236                         }
237
238                         c = atoi( cargv[1] );
239
240                         if( c < 1 ) {
241 #ifdef NEW_LOGGING
242                                 LDAP_LOG( CONFIG, CRIT, 
243                                         "%s: line %d: invalid level (%d) in "
244                                         "\"concurrency <level>\" line.\n", fname, lineno, c );
245 #else
246                                 Debug( LDAP_DEBUG_ANY,
247             "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
248                                     fname, lineno, c );
249 #endif
250
251                                 return( 1 );
252                         }
253
254                         ldap_pvt_thread_set_concurrency( c );
255
256                 /* set sockbuf max */
257                 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
258                         long max;
259                         if ( cargc < 2 ) {
260 #ifdef NEW_LOGGING
261                                 LDAP_LOG( CONFIG, CRIT, 
262                                    "%s: line %d: missing max in \"sockbuf_max_incoming "
263                                    "<bytes>\" line\n", fname, lineno, 0 );
264 #else
265                                 Debug( LDAP_DEBUG_ANY,
266                                            "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
267                                     fname, lineno, 0 );
268 #endif
269
270                                 return( 1 );
271                         }
272
273                         max = atol( cargv[1] );
274
275                         if( max < 0 ) {
276 #ifdef NEW_LOGGING
277                                 LDAP_LOG( CONFIG, CRIT, 
278                                            "%s: line %d: invalid max value (%ld) in "
279                                            "\"sockbuf_max_incoming <bytes>\" line.\n",
280                                            fname, lineno, max );
281 #else
282                                 Debug( LDAP_DEBUG_ANY,
283                                         "%s: line %d: invalid max value (%ld) in "
284                                         "\"sockbuf_max_incoming <bytes>\" line.\n",
285                                     fname, lineno, max );
286 #endif
287
288                                 return( 1 );
289                         }
290
291                         sockbuf_max_incoming = max;
292
293                 /* set sockbuf max authenticated */
294                 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
295                         long max;
296                         if ( cargc < 2 ) {
297 #ifdef NEW_LOGGING
298                                 LDAP_LOG( CONFIG, CRIT, 
299                                    "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
300                                    "<bytes>\" line\n", fname, lineno, 0 );
301 #else
302                                 Debug( LDAP_DEBUG_ANY,
303                                            "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
304                                     fname, lineno, 0 );
305 #endif
306
307                                 return( 1 );
308                         }
309
310                         max = atol( cargv[1] );
311
312                         if( max < 0 ) {
313 #ifdef NEW_LOGGING
314                                 LDAP_LOG( CONFIG, CRIT, 
315                                            "%s: line %d: invalid max value (%ld) in "
316                                            "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
317                                            fname, lineno, max );
318 #else
319                                 Debug( LDAP_DEBUG_ANY,
320                                         "%s: line %d: invalid max value (%ld) in "
321                                         "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
322                                     fname, lineno, max );
323 #endif
324
325                                 return( 1 );
326                         }
327
328                         sockbuf_max_incoming_auth = max;
329
330                 /* default search base */
331                 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
332                         if ( cargc < 2 ) {
333 #ifdef NEW_LOGGING
334                                 LDAP_LOG( CONFIG, CRIT, 
335                                         "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
336                                         "line\n", fname, lineno, 0 );
337 #else
338                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
339                                         "missing dn in \"defaultSearchBase <dn>\" line\n",
340                                         fname, lineno, 0 );
341 #endif
342
343                                 return 1;
344
345                         } else if ( cargc > 2 ) {
346 #ifdef NEW_LOGGING
347                                 LDAP_LOG( CONFIG, INFO, 
348                                         "%s: line %d: extra cruft after <dn> in "
349                                         "\"defaultSearchBase %s\" line (ignored)\n",
350                                         fname, lineno, cargv[1] );
351 #else
352                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
353                                         "extra cruft after <dn> in \"defaultSearchBase %s\", "
354                                         "line (ignored)\n",
355                                         fname, lineno, cargv[1] );
356 #endif
357                         }
358
359                         if ( bi != NULL || be != NULL ) {
360 #ifdef NEW_LOGGING
361                                 LDAP_LOG( CONFIG, CRIT, 
362                                         "%s: line %d: defaultSearchBase line must appear "
363                                         "prior to any backend or database definitions\n",
364                                         fname, lineno, 0 );
365 #else
366                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
367                                         "defaultSearchBaase line must appear prior to "
368                                         "any backend or database definition\n",
369                                     fname, lineno, 0 );
370 #endif
371
372                                 return 1;
373                         }
374
375                         if ( default_search_nbase.bv_len ) {
376 #ifdef NEW_LOGGING
377                                 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
378                                         "default search base \"%s\" already defined "
379                                         "(discarding old)\n", fname, lineno,
380                                         default_search_base.bv_val );
381 #else
382                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
383                                         "default search base \"%s\" already defined "
384                                         "(discarding old)\n",
385                                         fname, lineno, default_search_base.bv_val );
386 #endif
387
388                                 free( default_search_base.bv_val );
389                                 free( default_search_nbase.bv_val );
390                         }
391
392                         if ( load_ucdata( NULL ) < 0 ) return 1;
393
394                         {
395                                 struct berval dn;
396
397                                 dn.bv_val = cargv[1];
398                                 dn.bv_len = strlen( dn.bv_val );
399
400                                 rc = dnPrettyNormal( NULL, &dn,
401                                         &default_search_base,
402                                         &default_search_nbase );
403
404                                 if( rc != LDAP_SUCCESS ) {
405 #ifdef NEW_LOGGING
406                                         LDAP_LOG( CONFIG, CRIT, 
407                                                 "%s: line %d: defaultSearchBase DN is invalid.\n",
408                                                 fname, lineno, 0 );
409 #else
410                                         Debug( LDAP_DEBUG_ANY,
411                                                 "%s: line %d: defaultSearchBase DN is invalid\n",
412                                            fname, lineno, 0 );
413 #endif
414                                         return( 1 );
415                                 }
416                         }
417
418                 /* set maximum threads in thread pool */
419                 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
420                         int c;
421                         if ( cargc < 2 ) {
422 #ifdef NEW_LOGGING
423                                 LDAP_LOG( CONFIG, CRIT, 
424                                         "%s: line %d: missing count in \"threads <count>\" line\n",
425                                         fname, lineno, 0 );
426 #else
427                                 Debug( LDAP_DEBUG_ANY,
428             "%s: line %d: missing count in \"threads <count>\" line\n",
429                                     fname, lineno, 0 );
430 #endif
431
432                                 return( 1 );
433                         }
434
435                         c = atoi( cargv[1] );
436
437                         if( c < 0 ) {
438 #ifdef NEW_LOGGING
439                                 LDAP_LOG( CONFIG, CRIT, 
440                                            "%s: line %d: invalid level (%d) in \"threads <count>\""
441                                            "line\n", fname, lineno, c );
442 #else
443                                 Debug( LDAP_DEBUG_ANY,
444             "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
445                                     fname, lineno, c );
446 #endif
447
448                                 return( 1 );
449                         }
450
451                         ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
452
453                         /* save for later use */
454                         connection_pool_max = c;
455
456                 /* get pid file name */
457                 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
458                         if ( cargc < 2 ) {
459 #ifdef NEW_LOGGING
460                                 LDAP_LOG( CONFIG, CRIT, 
461                                         "%s: line %d missing file name in \"pidfile <file>\" "
462                                         "line.\n", fname, lineno, 0 );
463 #else
464                                 Debug( LDAP_DEBUG_ANY,
465             "%s: line %d: missing file name in \"pidfile <file>\" line\n",
466                                     fname, lineno, 0 );
467 #endif
468
469                                 return( 1 );
470                         }
471
472                         slapd_pid_file = ch_strdup( cargv[1] );
473
474                 /* get args file name */
475                 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
476                         if ( cargc < 2 ) {
477 #ifdef NEW_LOGGING
478                                 LDAP_LOG( CONFIG, CRIT, 
479                                            "%s: %d: missing file name in "
480                                            "\"argsfile <file>\" line.\n",
481                                            fname, lineno, 0 );
482 #else
483                                 Debug( LDAP_DEBUG_ANY,
484             "%s: line %d: missing file name in \"argsfile <file>\" line\n",
485                                     fname, lineno, 0 );
486 #endif
487
488                                 return( 1 );
489                         }
490
491                         slapd_args_file = ch_strdup( cargv[1] );
492
493                 /* default password hash */
494                 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
495                         if ( cargc < 2 ) {
496 #ifdef NEW_LOGGING
497                                 LDAP_LOG( CONFIG, CRIT, 
498                                            "%s: line %d: missing hash in "
499                                            "\"password-hash <hash>\" line.\n",
500                                            fname, lineno, 0 );
501 #else
502                                 Debug( LDAP_DEBUG_ANY,
503             "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
504                                     fname, lineno, 0 );
505 #endif
506
507                                 return( 1 );
508                         }
509                         if ( default_passwd_hash != NULL ) {
510 #ifdef NEW_LOGGING
511                                 LDAP_LOG( CONFIG, CRIT, 
512                                            "%s: line %d: already set default password_hash!\n",
513                                            fname, lineno, 0 );
514 #else
515                                 Debug( LDAP_DEBUG_ANY,
516                                         "%s: line %d: already set default password_hash!\n",
517                                         fname, lineno, 0 );
518 #endif
519
520                                 return 1;
521
522                         }
523
524                         if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
525 #ifdef NEW_LOGGING
526                                 LDAP_LOG( CONFIG, CRIT, 
527                                            "%s: line %d: password scheme \"%s\" not available\n",
528                                            fname, lineno, cargv[1] );
529 #else
530                                 Debug( LDAP_DEBUG_ANY,
531                                         "%s: line %d: password scheme \"%s\" not available\n",
532                                         fname, lineno, cargv[1] );
533 #endif
534                                 return 1;
535                         }
536
537                         default_passwd_hash = ch_strdup( cargv[1] );
538
539                 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 ) 
540                 {
541                         if ( cargc < 2 ) {
542 #ifdef NEW_LOGGING
543                                 LDAP_LOG( CONFIG, CRIT, 
544                                         "%s: line %d: missing format in "
545                                         "\"password-crypt-salt-format <format>\" line\n",
546                                         fname, lineno, 0 );
547 #else
548                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
549                                         "\"password-crypt-salt-format <format>\" line\n",
550                                     fname, lineno, 0 );
551 #endif
552
553                                 return 1;
554                         }
555
556                         lutil_salt_format( cargv[1] );
557
558 #ifdef HAVE_CYRUS_SASL
559                 /* SASL config options */
560                 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
561                         if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
562                                 return 1;
563 #endif /* HAVE_CYRUS_SASL */
564
565                 /* set UCDATA path */
566                 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
567                         int err;
568                         if ( cargc < 2 ) {
569 #ifdef NEW_LOGGING
570                                 LDAP_LOG( CONFIG, CRIT, 
571                                            "%s: line %d: missing path in "
572                                            "\"ucdata-path <path>\" line.\n", fname, lineno, 0  );
573 #else
574                                 Debug( LDAP_DEBUG_ANY,
575             "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
576                                     fname, lineno, 0 );
577 #endif
578
579                                 return( 1 );
580                         }
581
582                         err = load_ucdata( cargv[1] );
583                         if ( err <= 0 ) {
584                                 if ( err == 0 ) {
585 #ifdef NEW_LOGGING
586                                         LDAP_LOG( CONFIG, CRIT, 
587                                                    "%s: line %d: ucdata already loaded, ucdata-path "
588                                                    "must be set earlier in the file and/or be "
589                                                    "specified only once!\n", fname, lineno, 0 );
590 #else
591                                         Debug( LDAP_DEBUG_ANY,
592                                                "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
593                                                fname, lineno, 0 );
594 #endif
595
596                                 }
597                                 return( 1 );
598                         }
599
600                 /* set size limit */
601                 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
602                         int rc = 0, i;
603                         struct slap_limits_set *lim;
604                         
605                         if ( cargc < 2 ) {
606 #ifdef NEW_LOGGING
607                                 LDAP_LOG( CONFIG, CRIT, 
608                                    "%s: line %d: missing limit in \"sizelimit <limit>\" "
609                                    "line.\n", fname, lineno, 0 );
610 #else
611                                 Debug( LDAP_DEBUG_ANY,
612             "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
613                                     fname, lineno, 0 );
614 #endif
615
616                                 return( 1 );
617                         }
618
619                         if ( be == NULL ) {
620                                 lim = &deflimit;
621                         } else {
622                                 lim = &be->be_def_limit;
623                         }
624
625                         for ( i = 1; i < cargc; i++ ) {
626                                 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
627                                         rc = parse_limit( cargv[i], lim );
628                                 } else {
629                                         lim->lms_s_soft = atoi( cargv[i] );
630                                         lim->lms_s_hard = 0;
631                                 }
632
633                                 if ( rc ) {
634 #ifdef NEW_LOGGING
635                                         LDAP_LOG( CONFIG, CRIT, 
636                                                 "%s: line %d: unable "
637                                                    "to parse value \"%s\" in \"sizelimit "
638                                                    "<limit>\" line.\n", fname, lineno, cargv[i] );
639 #else
640                                         Debug( LDAP_DEBUG_ANY,
641                                                 "%s: line %d: unable "
642                                                 "to parse value \"%s\" "
643                                                 "in \"sizelimit "
644                                                 "<limit>\" line\n",
645                                                 fname, lineno, cargv[i] );
646 #endif
647                                 }
648                         }
649
650                 /* set time limit */
651                 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
652                         int rc = 0, i;
653                         struct slap_limits_set *lim;
654                         
655                         if ( cargc < 2 ) {
656 #ifdef NEW_LOGGING
657                                 LDAP_LOG( CONFIG, CRIT, 
658                                         "%s: line %d missing limit in \"timelimit <limit>\" "
659                                         "line.\n", fname, lineno, 0 );
660 #else
661                                 Debug( LDAP_DEBUG_ANY,
662             "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
663                                     fname, lineno, 0 );
664 #endif
665
666                                 return( 1 );
667                         }
668                         
669                         if ( be == NULL ) {
670                                 lim = &deflimit;
671                         } else {
672                                 lim = &be->be_def_limit;
673                         }
674
675                         for ( i = 1; i < cargc; i++ ) {
676                                 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
677                                         rc = parse_limit( cargv[i], lim );
678                                 } else {
679                                         lim->lms_t_soft = atoi( cargv[i] );
680                                         lim->lms_t_hard = 0;
681                                 }
682
683                                 if ( rc ) {
684 #ifdef NEW_LOGGING
685                                         LDAP_LOG( CONFIG, CRIT, 
686                                                     "%s: line %d: unable to parse value \"%s\" "
687                                                    "in \"timelimit <limit>\" line.\n",
688                                                    fname, lineno, cargv[i] );
689 #else
690                                         Debug( LDAP_DEBUG_ANY,
691                                                 "%s: line %d: unable "
692                                                 "to parse value \"%s\" "
693                                                 "in \"timelimit "
694                                                 "<limit>\" line\n",
695                                                 fname, lineno, cargv[i] );
696 #endif
697                                 }
698                         }
699
700                 /* set regex-based limits */
701                 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
702                         if ( be == NULL ) {
703 #ifdef NEW_LOGGING
704                                 LDAP_LOG( CONFIG, WARNING, 
705                                            "%s: line %d \"limits\" allowed only in database "
706                                            "environment.\n", fname, lineno, 0 );
707 #else
708                                 Debug( LDAP_DEBUG_ANY,
709         "%s: line %d \"limits\" allowed only in database environment.\n%s",
710                                         fname, lineno, "" );
711 #endif
712                                 return( 1 );
713                         }
714
715                         if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
716                                 return( 1 );
717                         }
718
719                 /* mark this as a subordinate database */
720                 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
721                         if ( be == NULL ) {
722 #ifdef NEW_LOGGING
723                                 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
724                                         "subordinate keyword must appear inside a database "
725                                         "definition.\n", fname, lineno, 0 );
726 #else
727                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
728                                         "must appear inside a database definition.\n",
729                                     fname, lineno, 0 );
730 #endif
731                                 return 1;
732
733                         } else {
734                                 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
735                                 num_subordinates++;
736                         }
737
738                 /* set database suffix */
739                 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
740                         Backend *tmp_be;
741                         struct berval dn, pdn, ndn;
742
743                         if ( cargc < 2 ) {
744 #ifdef NEW_LOGGING
745                                 LDAP_LOG( CONFIG, CRIT, 
746                                         "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
747                                         fname, lineno, 0 );
748 #else
749                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
750                                         "missing dn in \"suffix <dn>\" line\n",
751                                     fname, lineno, 0 );
752 #endif
753
754                                 return( 1 );
755
756                         } else if ( cargc > 2 ) {
757 #ifdef NEW_LOGGING
758                                 LDAP_LOG( CONFIG, INFO, 
759                                         "%s: line %d: extra cruft after <dn> in \"suffix %s\""
760                                         " line (ignored).\n", fname, lineno, cargv[1] );
761 #else
762                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
763                                         "after <dn> in \"suffix %s\" line (ignored)\n",
764                                     fname, lineno, cargv[1] );
765 #endif
766                         }
767
768                         if ( be == NULL ) {
769 #ifdef NEW_LOGGING
770                                 LDAP_LOG( CONFIG, INFO, 
771                                         "%s: line %d: suffix line must appear inside a database "
772                                         "definition.\n", fname, lineno, 0 );
773 #else
774                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
775                                         "must appear inside a database definition\n",
776                                     fname, lineno, 0 );
777 #endif
778                                 return( 1 );
779
780 #if defined(SLAPD_MONITOR_DN)
781                         /* "cn=Monitor" is reserved for monitoring slap */
782                         } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
783 #ifdef NEW_LOGGING
784                                 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
785                                         SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n", 
786                                         fname, lineno, 0 );
787 #else
788                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
789                                         SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n", 
790                                         fname, lineno, 0 );
791 #endif
792                                 return( 1 );
793 #endif /* SLAPD_MONITOR_DN */
794                         }
795
796                         if ( load_ucdata( NULL ) < 0 ) return 1;
797
798                         dn.bv_val = cargv[1];
799                         dn.bv_len = strlen( cargv[1] );
800
801                         rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
802                         if( rc != LDAP_SUCCESS ) {
803 #ifdef NEW_LOGGING
804                                 LDAP_LOG( CONFIG, CRIT, 
805                                         "%s: line %d: suffix DN is invalid.\n",
806                                         fname, lineno, 0 );
807 #else
808                                 Debug( LDAP_DEBUG_ANY,
809                                         "%s: line %d: suffix DN is invalid\n",
810                                    fname, lineno, 0 );
811 #endif
812                                 return( 1 );
813                         }
814
815                         tmp_be = select_backend( &ndn, 0, 0 );
816                         if ( tmp_be == be ) {
817 #ifdef NEW_LOGGING
818                                 LDAP_LOG( CONFIG, INFO, 
819                                         "%s: line %d: suffix already served by this backend "
820                                         "(ignored)\n", fname, lineno, 0 );
821 #else
822                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
823                                         "already served by this backend (ignored)\n",
824                                     fname, lineno, 0 );
825 #endif
826                                 free( pdn.bv_val );
827                                 free( ndn.bv_val );
828
829                         } else if ( tmp_be  != NULL ) {
830 #ifdef NEW_LOGGING
831                                 LDAP_LOG( CONFIG, INFO, 
832                                         "%s: line %d: suffix already served by a preceding "
833                                         "backend \"%s\"\n", fname, lineno,
834                                         tmp_be->be_suffix[0].bv_val );
835 #else
836                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
837                                         "already served by a preceeding backend \"%s\"\n",
838                                     fname, lineno, tmp_be->be_suffix[0].bv_val );
839 #endif
840                                 free( pdn.bv_val );
841                                 free( ndn.bv_val );
842                                 return( 1 );
843
844                         } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
845 #ifdef NEW_LOGGING
846                                         LDAP_LOG( CONFIG, INFO, 
847                                                 "%s: line %d: suffix DN empty and default search "
848                                                 "base provided \"%s\" (assuming okay).\n",
849                                                 fname, lineno, default_search_base.bv_val );
850 #else
851                                         Debug( LDAP_DEBUG_ANY, "%s: line %d: "
852                                                 "suffix DN empty and default "
853                                                 "search base provided \"%s\" (assuming okay)\n",
854                                         fname, lineno, default_search_base.bv_val );
855 #endif
856                         }
857
858                         ber_bvarray_add( &be->be_suffix, &pdn );
859                         ber_bvarray_add( &be->be_nsuffix, &ndn );
860
861                 /* set database suffixAlias */
862                 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
863                         Backend *tmp_be;
864                         struct berval alias, palias, nalias;
865                         struct berval aliased, paliased, naliased;
866
867                         if ( cargc < 2 ) {
868 #ifdef NEW_LOGGING
869                                 LDAP_LOG( CONFIG, CRIT, 
870                                         "%s: line %d: missing alias and aliased_dn in "
871                                         "\"suffixAlias <alias> <aliased_dn>\" line.\n",
872                                         fname, lineno, 0 );
873 #else
874                                 Debug( LDAP_DEBUG_ANY,
875                                         "%s: line %d: missing alias and aliased_dn in "
876                                         "\"suffixAlias <alias> <aliased_dn>\" line.\n",
877                                         fname, lineno, 0 );
878 #endif
879
880                                 return( 1 );
881                         } else if ( cargc < 3 ) {
882 #ifdef NEW_LOGGING
883                                 LDAP_LOG( CONFIG, CRIT, 
884                                         "%s: line %d: missing aliased_dn in "
885                                         "\"suffixAlias <alias> <aliased_dn>\" line\n",
886                                         fname, lineno, 0 );
887 #else
888                                 Debug( LDAP_DEBUG_ANY,
889                                         "%s: line %d: missing aliased_dn in "
890                                         "\"suffixAlias <alias> <aliased_dn>\" line\n",
891                                         fname, lineno, 0 );
892 #endif
893                                 return( 1 );
894
895                         } else if ( cargc > 3 ) {
896 #ifdef NEW_LOGGING
897                                 LDAP_LOG( CONFIG, CRIT, 
898                                         "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
899                                         fname, lineno, 0 );
900 #else
901                                 Debug( LDAP_DEBUG_ANY,
902                                         "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
903                                         fname, lineno, 0 );
904 #endif
905                         }
906
907                         if ( be == NULL ) {
908 #ifdef NEW_LOGGING
909                                 LDAP_LOG( CONFIG, INFO, 
910                                         "%s: line %d: suffix line must appear inside a database "
911                                         "definition.\n", fname, lineno, 0 );
912 #else
913                                 Debug( LDAP_DEBUG_ANY,
914                                         "%s: line %d: suffixAlias line"
915                                         " must appear inside a database definition.\n",
916                                         fname, lineno, 0 );
917 #endif
918                                 return 1;
919                         }
920
921                         if ( load_ucdata( NULL ) < 0 ) return 1;
922                         
923                         alias.bv_val = cargv[1];
924                         alias.bv_len = strlen( cargv[1] );
925
926                         rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
927                         if( rc != LDAP_SUCCESS ) {
928 #ifdef NEW_LOGGING
929                                 LDAP_LOG( CONFIG, CRIT, 
930                                         "%s: line %d: alias DN is invalid.\n", fname, lineno, 0 );
931 #else
932                                 Debug( LDAP_DEBUG_ANY,
933                                         "%s: line %d: alias DN is invalid\n",
934                                    fname, lineno, 0 );
935 #endif
936                                 return( 1 );
937                         }
938
939                         tmp_be = select_backend( &nalias, 0, 0 );
940                         free( nalias.bv_val );
941                         if ( tmp_be && tmp_be != be ) {
942 #ifdef NEW_LOGGING
943                                 LDAP_LOG( CONFIG, INFO, 
944                                         "%s: line %d: suffixAlias served by a preceeding "
945                                         "backend \"%s\"\n", fname, lineno, 
946                                         tmp_be->be_suffix[0].bv_val );
947 #else
948                                 Debug( LDAP_DEBUG_ANY,
949                                         "%s: line %d: suffixAlias served by"
950                                         "  a preceeding backend \"%s\"\n",
951                                         fname, lineno, tmp_be->be_suffix[0].bv_val );
952 #endif
953                                 free( palias.bv_val );
954                                 return -1;
955                         }
956
957                         aliased.bv_val = cargv[2];
958                         aliased.bv_len = strlen( cargv[2] );
959
960                         rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
961                         if( rc != LDAP_SUCCESS ) {
962 #ifdef NEW_LOGGING
963                                 LDAP_LOG( CONFIG, CRIT, 
964                                         "%s: line %d: aliased DN is invalid.\n", fname, lineno,0 );
965 #else
966                                 Debug( LDAP_DEBUG_ANY,
967                                         "%s: line %d: aliased DN is invalid\n",
968                                    fname, lineno, 0 );
969 #endif
970                                 free( palias.bv_val );
971                                 return( 1 );
972                         }
973
974                         tmp_be = select_backend( &naliased, 0, 0 );
975                         free( naliased.bv_val );
976                         if ( tmp_be && tmp_be != be ) {
977 #ifdef NEW_LOGGING
978                                 LDAP_LOG( CONFIG, INFO, 
979                                         "%s: line %d: suffixAlias derefs to a different backend "
980                                         "a preceeding backend \"%s\"\n",
981                                         fname, lineno, tmp_be->be_suffix[0].bv_val );
982 #else
983                                 Debug( LDAP_DEBUG_ANY,
984                                         "%s: line %d: suffixAlias derefs to differnet backend"
985                                         "  a preceeding backend \"%s\"\n",
986                                         fname, lineno, tmp_be->be_suffix[0].bv_val );
987 #endif
988                                 free( palias.bv_val );
989                                 free( paliased.bv_val );
990                                 return -1;
991                         }
992
993                         ber_bvarray_add( &be->be_suffixAlias, &palias ); 
994                         ber_bvarray_add( &be->be_suffixAlias, &paliased );
995
996                /* set max deref depth */
997                } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
998                                         int i;
999                        if ( cargc < 2 ) {
1000 #ifdef NEW_LOGGING
1001                                LDAP_LOG( CONFIG, CRIT, 
1002                                           "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1003                                           " line\n", fname, lineno, 0 );
1004 #else
1005                                Debug( LDAP_DEBUG_ANY,
1006                    "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1007                                    fname, lineno, 0 );
1008 #endif
1009
1010                                return( 1 );
1011                        }
1012                        if ( be == NULL ) {
1013 #ifdef NEW_LOGGING
1014                                LDAP_LOG( CONFIG, INFO, 
1015                                           "%s: line %d: depth line must appear inside a database "
1016                                           "definition.\n", fname, lineno ,0 );
1017 #else
1018                                Debug( LDAP_DEBUG_ANY,
1019 "%s: line %d: depth line must appear inside a database definition.\n",
1020                                    fname, lineno, 0 );
1021 #endif
1022                                                         return 1;
1023
1024                        } else if ((i = atoi(cargv[1])) < 0) {
1025 #ifdef NEW_LOGGING
1026                                LDAP_LOG( CONFIG, INFO, 
1027                                           "%s: line %d: depth must be positive.\n",
1028                                           fname, lineno ,0 );
1029 #else
1030                                Debug( LDAP_DEBUG_ANY,
1031 "%s: line %d: depth must be positive.\n",
1032                                    fname, lineno, 0 );
1033 #endif
1034                                                         return 1;
1035
1036
1037                        } else {
1038                            be->be_max_deref_depth = i;
1039                                            }
1040
1041
1042                 /* set magic "root" dn for this database */
1043                 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1044                         if ( cargc < 2 ) {
1045 #ifdef NEW_LOGGING
1046                                 LDAP_LOG( CONFIG, INFO, 
1047                                            "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1048                                            fname, lineno ,0 );
1049 #else
1050                                 Debug( LDAP_DEBUG_ANY,
1051                     "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1052                                     fname, lineno, 0 );
1053 #endif
1054
1055                                 return( 1 );
1056                         }
1057
1058                         if ( be == NULL ) {
1059 #ifdef NEW_LOGGING
1060                                 LDAP_LOG( CONFIG, INFO, 
1061                                            "%s: line %d: rootdn line must appear inside a database "
1062                                            "definition.\n", fname, lineno ,0 );
1063 #else
1064                                 Debug( LDAP_DEBUG_ANY,
1065 "%s: line %d: rootdn line must appear inside a database definition.\n",
1066                                     fname, lineno, 0 );
1067 #endif
1068                                 return 1;
1069
1070                         } else {
1071                                 struct berval dn;
1072                                 
1073                                 if ( load_ucdata( NULL ) < 0 ) return 1;
1074
1075                                 dn.bv_val = cargv[1];
1076                                 dn.bv_len = strlen( cargv[1] );
1077
1078                                 rc = dnPrettyNormal( NULL, &dn,
1079                                         &be->be_rootdn,
1080                                         &be->be_rootndn );
1081
1082                                 if( rc != LDAP_SUCCESS ) {
1083 #ifdef NEW_LOGGING
1084                                         LDAP_LOG( CONFIG, CRIT, 
1085                                                 "%s: line %d: rootdn DN is invalid.\n", 
1086                                                 fname, lineno ,0 );
1087 #else
1088                                         Debug( LDAP_DEBUG_ANY,
1089                                                 "%s: line %d: rootdn DN is invalid\n",
1090                                            fname, lineno, 0 );
1091 #endif
1092                                         return( 1 );
1093                                 }
1094                         }
1095
1096                 /* set super-secret magic database password */
1097                 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1098                         if ( cargc < 2 ) {
1099 #ifdef NEW_LOGGING
1100                                 LDAP_LOG( CONFIG, CRIT, 
1101                                         "%s: line %d: missing passwd in \"rootpw <passwd>\""
1102                                         " line\n", fname, lineno ,0 );
1103 #else
1104                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1105                                         "missing passwd in \"rootpw <passwd>\" line\n",
1106                                     fname, lineno, 0 );
1107 #endif
1108
1109                                 return( 1 );
1110                         }
1111
1112                         if ( be == NULL ) {
1113 #ifdef NEW_LOGGING
1114                                 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1115                                         "rootpw line must appear inside a database "
1116                                         "definition.\n", fname, lineno ,0 );
1117 #else
1118                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1119                                         "rootpw line must appear inside a database "
1120                                         "definition.\n",
1121                                     fname, lineno, 0 );
1122 #endif
1123                                 return 1;
1124
1125                         } else {
1126                                 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1127
1128                                 if( tmp_be != be ) {
1129 #ifdef NEW_LOGGING
1130                                         LDAP_LOG( CONFIG, INFO,
1131                                                 "%s: line %d: "
1132                                                 "rootpw can only be set when rootdn is under suffix\n",
1133                                                 fname, lineno, "" );
1134 #else
1135                                         Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1136                                                 "rootpw can only be set when rootdn is under suffix\n",
1137                                         fname, lineno, 0 );
1138 #endif
1139                                         return 1;
1140                                 }
1141
1142                                 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1143                                 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1144                         }
1145
1146                 /* make this database read-only */
1147                 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1148                         if ( cargc < 2 ) {
1149 #ifdef NEW_LOGGING
1150                                 LDAP_LOG( CONFIG, CRIT, 
1151                                         "%s: line %d: missing on|off in \"readonly <on|off>\" "
1152                                         "line.\n", fname, lineno ,0 );
1153 #else
1154                                 Debug( LDAP_DEBUG_ANY,
1155             "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1156                                     fname, lineno, 0 );
1157 #endif
1158
1159                                 return( 1 );
1160                         }
1161                         if ( be == NULL ) {
1162                                 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1163                                         global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1164                                 } else {
1165                                         global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1166                                 }
1167                         } else {
1168                                 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1169                                         be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1170                                 } else {
1171                                         be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1172                                 }
1173                         }
1174
1175
1176                 /* allow these features */
1177                 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1178                         strcasecmp( cargv[0], "allow" ) == 0 )
1179                 {
1180                         slap_mask_t     allows;
1181
1182                         if ( be != NULL ) {
1183 #ifdef NEW_LOGGING
1184                                 LDAP_LOG( CONFIG, INFO, 
1185                                            "%s: line %d: allow line must appear prior to "
1186                                            "database definitions.\n", fname, lineno ,0 );
1187 #else
1188                                 Debug( LDAP_DEBUG_ANY,
1189 "%s: line %d: allow line must appear prior to database definitions\n",
1190                                     fname, lineno, 0 );
1191 #endif
1192
1193                         }
1194
1195                         if ( cargc < 2 ) {
1196 #ifdef NEW_LOGGING
1197                                 LDAP_LOG( CONFIG, CRIT, 
1198                                            "%s: line %d: missing feature(s) in \"allow <features>\""
1199                                            " line\n", fname, lineno ,0 );
1200 #else
1201                                 Debug( LDAP_DEBUG_ANY,
1202             "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1203                                     fname, lineno, 0 );
1204 #endif
1205
1206                                 return( 1 );
1207                         }
1208
1209                         allows = 0;
1210
1211                         for( i=1; i < cargc; i++ ) {
1212                                 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1213                                         allows |= SLAP_ALLOW_BIND_V2;
1214
1215                                 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1216                                         allows |= SLAP_ALLOW_BIND_ANON_CRED;
1217
1218                                 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1219                                         allows |= SLAP_ALLOW_BIND_ANON_DN;
1220
1221                                 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1222 #ifdef NEW_LOGGING
1223                                         LDAP_LOG( CONFIG, CRIT, 
1224                                                    "%s: line %d: unknown feature %s in "
1225                                                    "\"allow <features>\" line.\n",
1226                                                    fname, lineno, cargv[1] );
1227 #else
1228                                         Debug( LDAP_DEBUG_ANY,
1229                     "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1230                                             fname, lineno, cargv[i] );
1231 #endif
1232
1233                                         return( 1 );
1234                                 }
1235                         }
1236
1237                         global_allows = allows;
1238
1239                 /* disallow these features */
1240                 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1241                         strcasecmp( cargv[0], "disallow" ) == 0 )
1242                 {
1243                         slap_mask_t     disallows;
1244
1245                         if ( be != NULL ) {
1246 #ifdef NEW_LOGGING
1247                                 LDAP_LOG( CONFIG, INFO, 
1248                                            "%s: line %d: disallow line must appear prior to "
1249                                            "database definitions.\n", fname, lineno ,0 );
1250 #else
1251                                 Debug( LDAP_DEBUG_ANY,
1252 "%s: line %d: disallow line must appear prior to database definitions\n",
1253                                     fname, lineno, 0 );
1254 #endif
1255
1256                         }
1257
1258                         if ( cargc < 2 ) {
1259 #ifdef NEW_LOGGING
1260                                 LDAP_LOG( CONFIG, CRIT, 
1261                                         "%s: line %d: missing feature(s) in \"disallow <features>\""
1262                                         " line.\n", fname, lineno ,0 );
1263 #else
1264                                 Debug( LDAP_DEBUG_ANY,
1265             "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1266                                     fname, lineno, 0 );
1267 #endif
1268
1269                                 return( 1 );
1270                         }
1271
1272                         disallows = 0;
1273
1274                         for( i=1; i < cargc; i++ ) {
1275                                 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1276                                         disallows |= SLAP_DISALLOW_BIND_ANON;
1277
1278                                 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1279                                         disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1280
1281                                 } else if( strcasecmp( cargv[i], "bind_simple_unprotected" ) == 0 ) {
1282                                         disallows |= SLAP_DISALLOW_BIND_SIMPLE_UNPROTECTED;
1283
1284                                 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1285                                         disallows |= SLAP_DISALLOW_BIND_KRBV4;
1286
1287                                 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1288                                         disallows |= SLAP_DISALLOW_TLS_2_ANON;
1289
1290                                 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1291                                         disallows |= SLAP_DISALLOW_TLS_AUTHC;
1292
1293                                 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1294 #ifdef NEW_LOGGING
1295                                         LDAP_LOG( CONFIG, CRIT, 
1296                                                 "%s: line %d: unknown feature %s in "
1297                                                 "\"disallow <features>\" line.\n",
1298                                                 fname, lineno, cargv[i] );
1299 #else
1300                                         Debug( LDAP_DEBUG_ANY,
1301                     "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1302                                             fname, lineno, cargv[i] );
1303 #endif
1304
1305                                         return( 1 );
1306                                 }
1307                         }
1308
1309                         global_disallows = disallows;
1310
1311                 /* require these features */
1312                 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1313                         strcasecmp( cargv[0], "require" ) == 0 )
1314                 {
1315                         slap_mask_t     requires;
1316
1317                         if ( cargc < 2 ) {
1318 #ifdef NEW_LOGGING
1319                                 LDAP_LOG( CONFIG, CRIT, 
1320                                            "%s: line %d: missing feature(s) in "
1321                                            "\"require <features>\" line.\n", fname, lineno ,0 );
1322 #else
1323                                 Debug( LDAP_DEBUG_ANY,
1324             "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1325                                     fname, lineno, 0 );
1326 #endif
1327
1328                                 return( 1 );
1329                         }
1330
1331                         requires = 0;
1332
1333                         for( i=1; i < cargc; i++ ) {
1334                                 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1335                                         requires |= SLAP_REQUIRE_BIND;
1336
1337                                 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1338                                         requires |= SLAP_REQUIRE_LDAP_V3;
1339
1340                                 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1341                                         requires |= SLAP_REQUIRE_AUTHC;
1342
1343                                 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1344                                         requires |= SLAP_REQUIRE_SASL;
1345
1346                                 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1347                                         requires |= SLAP_REQUIRE_STRONG;
1348
1349                                 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1350 #ifdef NEW_LOGGING
1351                                         LDAP_LOG( CONFIG, CRIT, 
1352                                                    "%s: line %d: unknown feature %s in "
1353                                                    "\"require <features>\" line.\n", 
1354                                                    fname, lineno , cargv[i] );
1355 #else
1356                                         Debug( LDAP_DEBUG_ANY,
1357                     "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1358                                             fname, lineno, cargv[i] );
1359 #endif
1360
1361                                         return( 1 );
1362                                 }
1363                         }
1364
1365                         if ( be == NULL ) {
1366                                 global_requires = requires;
1367                         } else {
1368                                 be->be_requires = requires;
1369                         }
1370
1371                 /* required security factors */
1372                 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1373                         slap_ssf_set_t *set;
1374
1375                         if ( cargc < 2 ) {
1376 #ifdef NEW_LOGGING
1377                                 LDAP_LOG( CONFIG, CRIT, 
1378                                         "%s: line %d: missing factor(s) in \"security <factors>\""
1379                                         " line.\n", fname, lineno ,0 );
1380 #else
1381                                 Debug( LDAP_DEBUG_ANY,
1382             "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1383                                     fname, lineno, 0 );
1384 #endif
1385
1386                                 return( 1 );
1387                         }
1388
1389                         if ( be == NULL ) {
1390                                 set = &global_ssf_set;
1391                         } else {
1392                                 set = &be->be_ssf_set;
1393                         }
1394
1395                         for( i=1; i < cargc; i++ ) {
1396                                 if( strncasecmp( cargv[i], "ssf=",
1397                                         sizeof("ssf") ) == 0 )
1398                                 {
1399                                         set->sss_ssf =
1400                                                 atoi( &cargv[i][sizeof("ssf")] );
1401
1402                                 } else if( strncasecmp( cargv[i], "transport=",
1403                                         sizeof("transport") ) == 0 )
1404                                 {
1405                                         set->sss_transport =
1406                                                 atoi( &cargv[i][sizeof("transport")] );
1407
1408                                 } else if( strncasecmp( cargv[i], "tls=",
1409                                         sizeof("tls") ) == 0 )
1410                                 {
1411                                         set->sss_tls =
1412                                                 atoi( &cargv[i][sizeof("tls")] );
1413
1414                                 } else if( strncasecmp( cargv[i], "sasl=",
1415                                         sizeof("sasl") ) == 0 )
1416                                 {
1417                                         set->sss_sasl =
1418                                                 atoi( &cargv[i][sizeof("sasl")] );
1419
1420                                 } else if( strncasecmp( cargv[i], "update_ssf=",
1421                                         sizeof("update_ssf") ) == 0 )
1422                                 {
1423                                         set->sss_update_ssf =
1424                                                 atoi( &cargv[i][sizeof("update_ssf")] );
1425
1426                                 } else if( strncasecmp( cargv[i], "update_transport=",
1427                                         sizeof("update_transport") ) == 0 )
1428                                 {
1429                                         set->sss_update_transport =
1430                                                 atoi( &cargv[i][sizeof("update_transport")] );
1431
1432                                 } else if( strncasecmp( cargv[i], "update_tls=",
1433                                         sizeof("update_tls") ) == 0 )
1434                                 {
1435                                         set->sss_update_tls =
1436                                                 atoi( &cargv[i][sizeof("update_tls")] );
1437
1438                                 } else if( strncasecmp( cargv[i], "update_sasl=",
1439                                         sizeof("update_sasl") ) == 0 )
1440                                 {
1441                                         set->sss_update_sasl =
1442                                                 atoi( &cargv[i][sizeof("update_sasl")] );
1443
1444                                 } else {
1445 #ifdef NEW_LOGGING
1446                                         LDAP_LOG( CONFIG, CRIT, 
1447                                                    "%s: line %d: unknown factor %S in "
1448                                                    "\"security <factors>\" line.\n",
1449                                                    fname, lineno, cargv[1] );
1450 #else
1451                                         Debug( LDAP_DEBUG_ANY,
1452                     "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1453                                             fname, lineno, cargv[i] );
1454 #endif
1455
1456                                         return( 1 );
1457                                 }
1458                         }
1459                 /* where to send clients when we don't hold it */
1460                 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1461                         if ( cargc < 2 ) {
1462 #ifdef NEW_LOGGING
1463                                 LDAP_LOG( CONFIG, CRIT, 
1464                                         "%s: line %d: missing URL in \"referral <URL>\""
1465                                         " line.\n", fname, lineno , 0 );
1466 #else
1467                                 Debug( LDAP_DEBUG_ANY,
1468                     "%s: line %d: missing URL in \"referral <URL>\" line\n",
1469                                     fname, lineno, 0 );
1470 #endif
1471
1472                                 return( 1 );
1473                         }
1474
1475                         if( validate_global_referral( cargv[1] ) ) {
1476 #ifdef NEW_LOGGING
1477                                 LDAP_LOG( CONFIG, CRIT, 
1478                                         "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1479                                         fname, lineno, cargv[1]  );
1480 #else
1481                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1482                                         "invalid URL (%s) in \"referral\" line.\n",
1483                                     fname, lineno, cargv[1] );
1484 #endif
1485                                 return 1;
1486                         }
1487
1488                         vals[0].bv_val = cargv[1];
1489                         vals[0].bv_len = strlen( vals[0].bv_val );
1490                         value_add( &default_referral, vals );
1491
1492 #ifdef NEW_LOGGING
1493                 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1494                         FILE *logfile;
1495                         if ( cargc < 2 ) {
1496 #ifdef NEW_LOGGING
1497                                 LDAP_LOG( CONFIG, CRIT, 
1498                                         "%s: line %d: Error in logfile directive, "
1499                                         "\"logfile <filename>\"\n", fname, lineno , 0 );
1500 #else
1501                                 Debug( LDAP_DEBUG_ANY,
1502                                        "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1503                                        fname, lineno, 0 );
1504 #endif
1505
1506                                 return( 1 );
1507                         }
1508                         logfile = fopen( cargv[1], "w" );
1509                         if ( logfile != NULL ) lutil_debug_file( logfile  );
1510
1511 #endif
1512                 /* start of a new database definition */
1513                 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1514                         int level;
1515                         if ( cargc < 3 ) {
1516 #ifdef NEW_LOGGING
1517                                 LDAP_LOG( CONFIG, CRIT, 
1518                                            "%s: line %d: Error in debug directive, "
1519                                            "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1520 #else
1521                                 Debug( LDAP_DEBUG_ANY,
1522                                         "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1523                                         fname, lineno, 0 );
1524 #endif
1525
1526                                 return( 1 );
1527                         }
1528                         level = atoi( cargv[2] );
1529                         if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1530                         lutil_set_debug_level( cargv[1], level );
1531                 /* specify an Object Identifier macro */
1532                 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1533                         rc = parse_oidm( fname, lineno, cargc, cargv );
1534                         if( rc ) return rc;
1535
1536                 /* specify an objectclass */
1537                 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1538                         if ( *cargv[1] == '(' ) {
1539                                 char * p;
1540                                 p = strchr(saveline,'(');
1541                                 rc = parse_oc( fname, lineno, p, cargv );
1542                                 if( rc ) return rc;
1543
1544                         } else {
1545 #ifdef NEW_LOGGING
1546                                 LDAP_LOG( CONFIG, INFO, 
1547                                         "%s: line %d: old objectclass format not supported\n",
1548                                         fname, lineno , 0 );
1549 #else
1550                                 Debug( LDAP_DEBUG_ANY,
1551                                        "%s: line %d: old objectclass format not supported.\n",
1552                                        fname, lineno, 0 );
1553 #endif
1554                         }
1555
1556                 /* specify an attribute type */
1557                 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1558                         || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1559                 {
1560                         if ( *cargv[1] == '(' ) {
1561                                 char * p;
1562                                 p = strchr(saveline,'(');
1563                                 rc = parse_at( fname, lineno, p, cargv );
1564                                 if( rc ) return rc;
1565
1566                         } else {
1567 #ifdef NEW_LOGGING
1568                                 LDAP_LOG( CONFIG, INFO, 
1569                                         "%s: line %d: old attribute type format not supported.\n",
1570                                         fname, lineno , 0 );
1571 #else
1572                                 Debug( LDAP_DEBUG_ANY,
1573     "%s: line %d: old attribute type format not supported.\n",
1574                                     fname, lineno, 0 );
1575 #endif
1576
1577                         }
1578
1579                 /* turn on/off schema checking */
1580                 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1581                         if ( cargc < 2 ) {
1582 #ifdef NEW_LOGGING
1583                                 LDAP_LOG( CONFIG, CRIT, 
1584                                         "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1585                                         " line.\n", fname, lineno , 0 );
1586 #else
1587                                 Debug( LDAP_DEBUG_ANY,
1588     "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1589                                     fname, lineno, 0 );
1590 #endif
1591
1592                                 return( 1 );
1593                         }
1594                         if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1595 #ifdef NEW_LOGGING
1596                                 LDAP_LOG( CONFIG, CRIT, 
1597                                         "%s: line %d: schema checking disabled! your mileage may "
1598                                         "vary!\n", fname, lineno , 0 );
1599 #else
1600                                 Debug( LDAP_DEBUG_ANY,
1601                                         "%s: line %d: schema checking disabled! your mileage may vary!\n",
1602                                     fname, lineno, 0 );
1603 #endif
1604                                 global_schemacheck = 0;
1605                         } else {
1606                                 global_schemacheck = 1;
1607                         }
1608
1609                 /* specify access control info */
1610                 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1611                         parse_acl( be, fname, lineno, cargc, cargv );
1612
1613                 /* debug level to log things to syslog */
1614                 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1615                         if ( cargc < 2 ) {
1616 #ifdef NEW_LOGGING
1617                                 LDAP_LOG( CONFIG, CRIT, 
1618                                         "%s: line %d: missing level in \"loglevel <level>\""
1619                                         " line.\n", fname, lineno , 0 );
1620 #else
1621                                 Debug( LDAP_DEBUG_ANY,
1622                     "%s: line %d: missing level in \"loglevel <level>\" line\n",
1623                                     fname, lineno, 0 );
1624 #endif
1625
1626                                 return( 1 );
1627                         }
1628
1629                         ldap_syslog = 0;
1630
1631                         for( i=1; i < cargc; i++ ) {
1632                                 ldap_syslog += atoi( cargv[1] );
1633                         }
1634
1635                 /* list of replicas of the data in this backend (master only) */
1636                 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1637                         if ( cargc < 2 ) {
1638 #ifdef NEW_LOGGING
1639                                 LDAP_LOG( CONFIG, CRIT, 
1640                                         "%s: line %d: missing host in \"replica "
1641                                         " <host[:port]\" line\n", fname, lineno , 0 );
1642 #else
1643                                 Debug( LDAP_DEBUG_ANY,
1644             "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1645                                     fname, lineno, 0 );
1646 #endif
1647
1648                                 return( 1 );
1649                         }
1650                         if ( be == NULL ) {
1651 #ifdef NEW_LOGGING
1652                                 LDAP_LOG( CONFIG, INFO, 
1653                                             "%s: line %d: replica line must appear inside "
1654                                             "a database definition.\n", fname, lineno, 0);
1655 #else
1656                                 Debug( LDAP_DEBUG_ANY,
1657 "%s: line %d: replica line must appear inside a database definition\n",
1658                                     fname, lineno, 0 );
1659 #endif
1660                                 return 1;
1661
1662                         } else {
1663                                 int nr = -1;
1664
1665                                 for ( i = 1; i < cargc; i++ ) {
1666                                         if ( strncasecmp( cargv[i], "host=", 5 )
1667                                             == 0 ) {
1668                                                 nr = add_replica_info( be, 
1669                                                         cargv[i] + 5 );
1670                                                 break;
1671                                         }
1672                                 }
1673                                 if ( i == cargc ) {
1674 #ifdef NEW_LOGGING
1675                                         LDAP_LOG( CONFIG, INFO, 
1676                                                 "%s: line %d: missing host in \"replica\" line\n", 
1677                                                 fname, lineno , 0 );
1678 #else
1679                                         Debug( LDAP_DEBUG_ANY,
1680                     "%s: line %d: missing host in \"replica\" line\n",
1681                                             fname, lineno, 0 );
1682 #endif
1683                                         return 1;
1684
1685                                 } else if ( nr == -1 ) {
1686 #ifdef NEW_LOGGING
1687                                         LDAP_LOG( CONFIG, INFO, 
1688                                                    "%s: line %d: unable to add"
1689                                                    " replica \"%s\"\n",
1690                                                    fname, lineno, 
1691                                                    cargv[i] + 5 );
1692 #else
1693                                         Debug( LDAP_DEBUG_ANY,
1694                 "%s: line %d: unable to add replica \"%s\"\n",
1695                                                 fname, lineno, cargv[i] + 5 );
1696 #endif
1697                                         return 1;
1698                                 } else {
1699                                         for ( i = 1; i < cargc; i++ ) {
1700                                                 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1701
1702                                                         switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1703                                                         case 1:
1704 #ifdef NEW_LOGGING
1705                                                                 LDAP_LOG( CONFIG, INFO, 
1706                                                                         "%s: line %d: suffix \"%s\" in \"replica\""
1707                                                                         " line is not valid for backend(ignored)\n",
1708                                                                         fname, lineno, cargv[i] + 7 );
1709 #else
1710                                                                 Debug( LDAP_DEBUG_ANY,
1711                                                                                 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1712                                                                                 fname, lineno, cargv[i] + 7 );
1713 #endif
1714                                                                 break;
1715
1716                                                         case 2:
1717 #ifdef NEW_LOGGING
1718                                                                 LDAP_LOG( CONFIG, INFO, 
1719                                                                         "%s: line %d: unable to normalize suffix"
1720                                                                         " in \"replica\" line (ignored)\n",
1721                                                                         fname, lineno , 0 );
1722 #else
1723                                                                 Debug( LDAP_DEBUG_ANY,
1724                                                                                  "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1725                                                                                  fname, lineno, 0 );
1726 #endif
1727                                                                 break;
1728                                                         }
1729
1730                                                 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1731                                                         int exclude = 0;
1732                                                         char *arg = cargv[i] + 4;
1733
1734                                                         if ( arg[0] == '!' ) {
1735                                                                 arg++;
1736                                                                 exclude = 1;
1737                                                         }
1738
1739                                                         if ( arg[0] != '=' ) {
1740                                                                 continue;
1741                                                         }
1742
1743                                                         if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1744 #ifdef NEW_LOGGING
1745                                                                 LDAP_LOG( CONFIG, INFO, 
1746                                                                         "%s: line %d: attribute \"%s\" in "
1747                                                                         "\"replica\" line is unknown\n",
1748                                                                         fname, lineno, arg + 1 ); 
1749 #else
1750                                                                 Debug( LDAP_DEBUG_ANY,
1751                                                                                 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1752                                                                                 fname, lineno, arg + 1 );
1753 #endif
1754                                                                 return( 1 );
1755                                                         }
1756                                                 }
1757                                         }
1758                                 }
1759                         }
1760
1761                 /* dn of master entity allowed to write to replica */
1762                 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1763                         if ( cargc < 2 ) {
1764 #ifdef NEW_LOGGING
1765                                 LDAP_LOG( CONFIG, CRIT, 
1766                                         "%s: line %d: missing dn in \"updatedn <dn>\""
1767                                         " line.\n", fname, lineno , 0 );
1768 #else
1769                                 Debug( LDAP_DEBUG_ANY,
1770                     "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1771                                     fname, lineno, 0 );
1772 #endif
1773
1774                                 return( 1 );
1775                         }
1776                         if ( be == NULL ) {
1777 #ifdef NEW_LOGGING
1778                                 LDAP_LOG( CONFIG, INFO, 
1779                                         "%s: line %d: updatedn line must appear inside "
1780                                         "a database definition\n", 
1781                                         fname, lineno , 0 );
1782 #else
1783                                 Debug( LDAP_DEBUG_ANY,
1784 "%s: line %d: updatedn line must appear inside a database definition\n",
1785                                     fname, lineno, 0 );
1786 #endif
1787                                 return 1;
1788
1789                         } else {
1790                                 struct berval dn;
1791
1792                                 if ( load_ucdata( NULL ) < 0 ) return 1;
1793
1794                                 dn.bv_val = cargv[1];
1795                                 dn.bv_len = strlen( cargv[1] );
1796
1797                                 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1798                                 if( rc != LDAP_SUCCESS ) {
1799 #ifdef NEW_LOGGING
1800                                         LDAP_LOG( CONFIG, CRIT, 
1801                                                 "%s: line %d: updatedn DN is invalid.\n",
1802                                                 fname, lineno , 0 );
1803 #else
1804                                         Debug( LDAP_DEBUG_ANY,
1805                                                 "%s: line %d: updatedn DN is invalid\n",
1806                                             fname, lineno, 0 );
1807 #endif
1808                                         return 1;
1809                                 }
1810                         }
1811
1812                 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1813                         if ( cargc < 2 ) {
1814 #ifdef NEW_LOGGING
1815                                 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1816                                         "missing url in \"updateref <ldapurl>\" line.\n",
1817                                         fname, lineno , 0 );
1818 #else
1819                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1820                                         "missing url in \"updateref <ldapurl>\" line\n",
1821                                     fname, lineno, 0 );
1822 #endif
1823
1824                                 return( 1 );
1825                         }
1826                         if ( be == NULL ) {
1827 #ifdef NEW_LOGGING
1828                                 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
1829                                         " line must appear inside a database definition\n",
1830                                         fname, lineno , 0 );
1831 #else
1832                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1833                                         " line must appear inside a database definition\n",
1834                                         fname, lineno, 0 );
1835 #endif
1836                                 return 1;
1837
1838                         } else if ( !be->be_update_ndn.bv_len ) {
1839 #ifdef NEW_LOGGING
1840                                 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1841                                         "updateref line must come after updatedn.\n",
1842                                         fname, lineno , 0 );
1843 #else
1844                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1845                                         "updateref line must after updatedn.\n",
1846                                     fname, lineno, 0 );
1847 #endif
1848                                 return 1;
1849                         }
1850
1851                         if( validate_global_referral( cargv[1] ) ) {
1852 #ifdef NEW_LOGGING
1853                                 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1854                                         "invalid URL (%s) in \"updateref\" line.\n",
1855                                         fname, lineno, cargv[1] );
1856 #else
1857                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1858                                         "invalid URL (%s) in \"updateref\" line.\n",
1859                                     fname, lineno, cargv[1] );
1860 #endif
1861                                 return 1;
1862                         }
1863
1864                         vals[0].bv_val = cargv[1];
1865                         vals[0].bv_len = strlen( vals[0].bv_val );
1866                         value_add( &be->be_update_refs, vals );
1867
1868                 /* replication log file to which changes are appended */
1869                 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1870                         if ( cargc < 2 ) {
1871 #ifdef NEW_LOGGING
1872                                 LDAP_LOG( CONFIG, CRIT, 
1873                                         "%s: line %d: missing filename in \"replogfile <filename>\""
1874                                         " line.\n", fname, lineno , 0 );
1875 #else
1876                                 Debug( LDAP_DEBUG_ANY,
1877             "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1878                                     fname, lineno, 0 );
1879 #endif
1880
1881                                 return( 1 );
1882                         }
1883                         if ( be ) {
1884                                 be->be_replogfile = ch_strdup( cargv[1] );
1885                         } else {
1886                                 replogfile = ch_strdup( cargv[1] );
1887                         }
1888
1889                 /* file from which to read additional rootdse attrs */
1890                 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1891                         if ( cargc < 2 ) {
1892 #ifdef NEW_LOGGING
1893                                 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1894                                         "missing filename in \"rootDSE <filename>\" line.\n",
1895                                         fname, lineno , 0 );
1896 #else
1897                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1898                                         "missing filename in \"rootDSE <filename>\" line.\n",
1899                                     fname, lineno, 0 );
1900 #endif
1901                                 return 1;
1902                         }
1903
1904                         if( read_root_dse_file( cargv[1] ) ) {
1905 #ifdef NEW_LOGGING
1906                                 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1907                                         "could not read \"rootDSE <filename>\" line.\n",
1908                                         fname, lineno , 0 );
1909 #else
1910                                 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1911                                         "could not read \"rootDSE <filename>\" line\n",
1912                                     fname, lineno, 0 );
1913 #endif
1914                                 return 1;
1915                         }
1916
1917                 /* maintain lastmodified{by,time} attributes */
1918                 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1919                         if ( cargc < 2 ) {
1920 #ifdef NEW_LOGGING
1921                                 LDAP_LOG( CONFIG, CRIT, 
1922                                            "%s: line %d: missing on|off in \"lastmod <on|off>\""
1923                                            " line.\n", fname, lineno , 0 );
1924 #else
1925                                 Debug( LDAP_DEBUG_ANY,
1926             "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1927                                     fname, lineno, 0 );
1928 #endif
1929
1930                                 return( 1 );
1931                         }
1932                         if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1933                                 if ( be ) {
1934                                         be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
1935                                 } else {
1936                                         lastmod = 1;
1937                                 }
1938                         } else {
1939                                 if ( be ) {
1940                                         be->be_flags |= SLAP_BFLAG_NOLASTMOD;
1941                                 } else {
1942                                         lastmod = 0;
1943                                 }
1944                         }
1945
1946 #ifdef SIGHUP
1947                 /* turn on/off gentle SIGHUP handling */
1948                 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
1949                         if ( cargc < 2 ) {
1950                                 Debug( LDAP_DEBUG_ANY,
1951     "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
1952                                     fname, lineno, 0 );
1953                                 return( 1 );
1954                         }
1955                         if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1956                                 global_gentlehup = 0;
1957                         } else {
1958                                 global_gentlehup = 1;
1959                         }
1960 #endif
1961
1962                 /* set idle timeout value */
1963                 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1964                         int i;
1965                         if ( cargc < 2 ) {
1966 #ifdef NEW_LOGGING
1967                                 LDAP_LOG( CONFIG, CRIT, 
1968                                         "%s: line %d: missing timeout value in "
1969                                         "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
1970 #else
1971                                 Debug( LDAP_DEBUG_ANY,
1972             "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1973                                     fname, lineno, 0 );
1974 #endif
1975
1976                                 return( 1 );
1977                         }
1978
1979                         i = atoi( cargv[1] );
1980
1981                         if( i < 0 ) {
1982 #ifdef NEW_LOGGING
1983                                 LDAP_LOG( CONFIG, CRIT, 
1984                                         "%s: line %d: timeout value (%d) invalid "
1985                                         "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
1986 #else
1987                                 Debug( LDAP_DEBUG_ANY,
1988             "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1989                                     fname, lineno, i );
1990 #endif
1991
1992                                 return( 1 );
1993                         }
1994
1995                         global_idletimeout = i;
1996
1997                 /* include another config file */
1998                 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1999                         if ( cargc < 2 ) {
2000 #ifdef NEW_LOGGING
2001                                 LDAP_LOG( CONFIG, CRIT, 
2002                                         "%s: line %d: missing filename in \"include "
2003                                         "<filename>\" line.\n", fname, lineno , 0 );
2004 #else
2005                                 Debug( LDAP_DEBUG_ANY,
2006     "%s: line %d: missing filename in \"include <filename>\" line\n",
2007                                     fname, lineno, 0 );
2008 #endif
2009
2010                                 return( 1 );
2011                         }
2012                         savefname = ch_strdup( cargv[1] );
2013                         savelineno = lineno;
2014
2015                         if ( read_config( savefname ) != 0 ) {
2016                                 return( 1 );
2017                         }
2018
2019                         free( savefname );
2020                         lineno = savelineno - 1;
2021
2022                 /* location of kerberos srvtab file */
2023                 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2024                         if ( cargc < 2 ) {
2025 #ifdef NEW_LOGGING
2026                                 LDAP_LOG( CONFIG, CRIT, 
2027                                         "%s: line %d: missing filename in \"srvtab "
2028                                         "<filename>\" line.\n", fname, lineno , 0 );
2029 #else
2030                                 Debug( LDAP_DEBUG_ANY,
2031             "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2032                                     fname, lineno, 0 );
2033 #endif
2034
2035                                 return( 1 );
2036                         }
2037                         ldap_srvtab = ch_strdup( cargv[1] );
2038
2039 #ifdef SLAPD_MODULES
2040                 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2041                    if ( cargc < 2 ) {
2042 #ifdef NEW_LOGGING
2043                            LDAP_LOG( CONFIG, INFO, 
2044                                    "%s: line %d: missing filename in \"moduleload "
2045                                    "<filename>\" line.\n", fname, lineno , 0 );
2046 #else
2047                       Debug( LDAP_DEBUG_ANY,
2048                              "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2049                              fname, lineno, 0 );
2050 #endif
2051
2052                       exit( EXIT_FAILURE );
2053                    }
2054                    if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2055 #ifdef NEW_LOGGING
2056                            LDAP_LOG( CONFIG, CRIT, 
2057                                    "%s: line %d: failed to load or initialize module %s\n",
2058                                    fname, lineno, cargv[1] );
2059 #else
2060                       Debug( LDAP_DEBUG_ANY,
2061                              "%s: line %d: failed to load or initialize module %s\n",
2062                              fname, lineno, cargv[1]);
2063 #endif
2064
2065                       exit( EXIT_FAILURE );
2066                    }
2067                 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2068                    if ( cargc != 2 ) {
2069 #ifdef NEW_LOGGING
2070                            LDAP_LOG( CONFIG, INFO, 
2071                                   "%s: line %d: missing path in \"modulepath <path>\""
2072                                   " line\n", fname, lineno , 0 );
2073 #else
2074                       Debug( LDAP_DEBUG_ANY,
2075                              "%s: line %d: missing path in \"modulepath <path>\" line\n",
2076                              fname, lineno, 0 );
2077 #endif
2078
2079                       exit( EXIT_FAILURE );
2080                    }
2081                    if (module_path( cargv[1] )) {
2082 #ifdef NEW_LOGGING
2083                            LDAP_LOG( CONFIG, CRIT, 
2084                                   "%s: line %d: failed to set module search path to %s.\n",
2085                                   fname, lineno, cargv[1] );
2086 #else
2087                            Debug( LDAP_DEBUG_ANY,
2088                                   "%s: line %d: failed to set module search path to %s\n",
2089                                   fname, lineno, cargv[1]);
2090 #endif
2091
2092                       exit( EXIT_FAILURE );
2093                    }
2094                    
2095 #endif /*SLAPD_MODULES*/
2096
2097 #ifdef HAVE_TLS
2098                 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2099                         rc = ldap_pvt_tls_set_option( NULL,
2100                                                       LDAP_OPT_X_TLS_RANDOM_FILE,
2101                                                       cargv[1] );
2102                         if ( rc )
2103                                 return rc;
2104
2105                 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2106                         rc = ldap_pvt_tls_set_option( NULL,
2107                                                       LDAP_OPT_X_TLS_CIPHER_SUITE,
2108                                                       cargv[1] );
2109                         if ( rc )
2110                                 return rc;
2111
2112                 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2113                         rc = ldap_pvt_tls_set_option( NULL,
2114                                                       LDAP_OPT_X_TLS_CERTFILE,
2115                                                       cargv[1] );
2116                         if ( rc )
2117                                 return rc;
2118
2119                 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2120                         rc = ldap_pvt_tls_set_option( NULL,
2121                                                       LDAP_OPT_X_TLS_KEYFILE,
2122                                                       cargv[1] );
2123                         if ( rc )
2124                                 return rc;
2125
2126                 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2127                         rc = ldap_pvt_tls_set_option( NULL,
2128                                                       LDAP_OPT_X_TLS_CACERTDIR,
2129                                                       cargv[1] );
2130                         if ( rc )
2131                                 return rc;
2132
2133                 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2134                         rc = ldap_pvt_tls_set_option( NULL,
2135                                                       LDAP_OPT_X_TLS_CACERTFILE,
2136                                                       cargv[1] );
2137                         if ( rc )
2138                                 return rc;
2139                 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2140                         if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2141                                 i = atoi(cargv[1]);
2142                                 rc = ldap_pvt_tls_set_option( NULL,
2143                                                       LDAP_OPT_X_TLS_REQUIRE_CERT,
2144                                                       &i );
2145                         } else {
2146                                 rc = ldap_int_tls_config( NULL,
2147                                                       LDAP_OPT_X_TLS_REQUIRE_CERT,
2148                                                       cargv[1] );
2149                         }
2150
2151                         if ( rc )
2152                                 return rc;
2153
2154 #endif
2155
2156                 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2157 #ifdef SLAPD_RLOOKUPS
2158                         if ( cargc < 2 ) {
2159 #ifdef NEW_LOGGING
2160                                 LDAP_LOG( CONFIG, INFO, 
2161                                         "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2162                                         fname, lineno , 0 );
2163 #else
2164                                 Debug( LDAP_DEBUG_ANY,
2165 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2166                                         fname, lineno, 0 );
2167 #endif
2168                                 return( 1 );
2169                         }
2170
2171                         if ( !strcasecmp( cargv[1], "on" ) ) {
2172                                 use_reverse_lookup = 1;
2173                         } else if ( !strcasecmp( cargv[1], "off" ) ) {
2174                                 use_reverse_lookup = 0;
2175                         } else {
2176 #ifdef NEW_LOGGING
2177                                 LDAP_LOG( CONFIG, INFO, 
2178                                         "%s: line %d: reverse-lookup: "
2179                                         "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2180 #else
2181                                 Debug( LDAP_DEBUG_ANY,
2182 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2183                                         fname, lineno, 0 );
2184 #endif
2185                                 return( 1 );
2186                         }
2187
2188 #else /* !SLAPD_RLOOKUPS */
2189 #ifdef NEW_LOGGING
2190                         LDAP_LOG( CONFIG, INFO, 
2191                                 "%s: line %d: reverse lookups "
2192                                 "are not configured (ignored).\n", fname, lineno , 0 );
2193 #else
2194                         Debug( LDAP_DEBUG_ANY,
2195 "%s: line %d: reverse lookups are not configured (ignored).\n",
2196                                 fname, lineno, 0 );
2197 #endif
2198 #endif /* !SLAPD_RLOOKUPS */
2199
2200                 /* pass anything else to the current backend info/db config routine */
2201                 } else {
2202                         if ( bi != NULL ) {
2203                                 if ( bi->bi_config == 0 ) {
2204 #ifdef NEW_LOGGING
2205                                         LDAP_LOG( CONFIG, INFO, 
2206                                                 "%s: line %d: unknown directive \"%s\" inside "
2207                                                 "backend info definition (ignored).\n",
2208                                                 fname, lineno, cargv[0] );
2209 #else
2210                                         Debug( LDAP_DEBUG_ANY,
2211 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2212                                                 fname, lineno, cargv[0] );
2213 #endif
2214
2215                                 } else {
2216                                         if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2217                                                 != 0 )
2218                                         {
2219                                                 return( 1 );
2220                                         }
2221                                 }
2222                         } else if ( be != NULL ) {
2223                                 if ( be->be_config == 0 ) {
2224 #ifdef NEW_LOGGING
2225                                         LDAP_LOG( CONFIG, INFO, 
2226                                                 "%s: line %d: uknown directive \"%s\" inside "
2227                                                 "backend database definition (ignored).\n",
2228                                                 fname, lineno, cargv[0] );
2229 #else
2230                                         Debug( LDAP_DEBUG_ANY,
2231 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2232                                         fname, lineno, cargv[0] );
2233 #endif
2234
2235                                 } else {
2236                                         if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2237                                                 != 0 )
2238                                         {
2239                                                 return( 1 );
2240                                         }
2241                                 }
2242                         } else {
2243 #ifdef NEW_LOGGING
2244                                 LDAP_LOG( CONFIG, INFO, 
2245                                         "%s: line %d: unknown directive \"%s\" outside backend "
2246                                         "info and database definitions (ignored).\n",
2247                                         fname, lineno, cargv[0] );
2248 #else
2249                                 Debug( LDAP_DEBUG_ANY,
2250 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2251                                     fname, lineno, cargv[0] );
2252 #endif
2253
2254                         }
2255                 }
2256                 free( saveline );
2257         }
2258         fclose( fp );
2259
2260         if ( load_ucdata( NULL ) < 0 ) return 1;
2261         return( 0 );
2262 }
2263
2264 static int
2265 fp_parse_line(
2266     int         lineno,
2267     char        *line
2268 )
2269 {
2270         char *  token;
2271         char *  logline;
2272         char    logbuf[sizeof("pseudorootpw ***")];
2273
2274         cargc = 0;
2275         token = strtok_quote( line, " \t" );
2276
2277         logline = line;
2278         if ( token &&
2279              (strcasecmp( token, "rootpw" ) == 0 ||
2280               strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2281               strcasecmp( token, "bindpw" ) == 0 ||       /* used in back-ldap */
2282               strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2283                   strcasecmp( token, "dbpasswd" ) == 0 ) )    /* used in back-sql */
2284                 sprintf( logline = logbuf, "%s ***", token );
2285         if ( strtok_quote_ptr )
2286                 *strtok_quote_ptr = ' ';
2287 #ifdef NEW_LOGGING
2288         LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2289 #else
2290         Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2291 #endif
2292         if ( strtok_quote_ptr )
2293                 *strtok_quote_ptr = '\0';
2294
2295         for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2296                 if ( cargc == cargv_size - 1 ) {
2297                         char **tmp;
2298                         tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2299                                             sizeof(*cargv) );
2300                         if ( tmp == NULL ) {
2301 #ifdef NEW_LOGGING
2302                                 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2303 #else
2304                                 Debug( LDAP_DEBUG_ANY, 
2305                                                 "line %d: out of memory\n", 
2306                                                 lineno, 0, 0 );
2307 #endif
2308                                 return -1;
2309                         }
2310                         cargv = tmp;
2311                         cargv_size += ARGS_STEP;
2312                 }
2313                 cargv[cargc++] = token;
2314         }
2315         cargv[cargc] = NULL;
2316         return 0;
2317 }
2318
2319 static char *
2320 strtok_quote( char *line, char *sep )
2321 {
2322         int             inquote;
2323         char            *tmp;
2324         static char     *next;
2325
2326         strtok_quote_ptr = NULL;
2327         if ( line != NULL ) {
2328                 next = line;
2329         }
2330         while ( *next && strchr( sep, *next ) ) {
2331                 next++;
2332         }
2333
2334         if ( *next == '\0' ) {
2335                 next = NULL;
2336                 return( NULL );
2337         }
2338         tmp = next;
2339
2340         for ( inquote = 0; *next; ) {
2341                 switch ( *next ) {
2342                 case '"':
2343                         if ( inquote ) {
2344                                 inquote = 0;
2345                         } else {
2346                                 inquote = 1;
2347                         }
2348                         AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2349                         break;
2350
2351                 case '\\':
2352                         if ( next[1] )
2353                                 AC_MEMCPY( next,
2354                                             next + 1, strlen( next + 1 ) + 1 );
2355                         next++;         /* dont parse the escaped character */
2356                         break;
2357
2358                 default:
2359                         if ( ! inquote ) {
2360                                 if ( strchr( sep, *next ) != NULL ) {
2361                                         strtok_quote_ptr = next;
2362                                         *next++ = '\0';
2363                                         return( tmp );
2364                                 }
2365                         }
2366                         next++;
2367                         break;
2368                 }
2369         }
2370
2371         return( tmp );
2372 }
2373
2374 static char     buf[BUFSIZ];
2375 static char     *line;
2376 static int      lmax, lcur;
2377
2378 #define CATLINE( buf )  { \
2379         int     len; \
2380         len = strlen( buf ); \
2381         while ( lcur + len + 1 > lmax ) { \
2382                 lmax += BUFSIZ; \
2383                 line = (char *) ch_realloc( line, lmax ); \
2384         } \
2385         strcpy( line + lcur, buf ); \
2386         lcur += len; \
2387 }
2388
2389 static char *
2390 fp_getline( FILE *fp, int *lineno )
2391 {
2392         char            *p;
2393
2394         lcur = 0;
2395         CATLINE( buf );
2396         (*lineno)++;
2397
2398         /* hack attack - keeps us from having to keep a stack of bufs... */
2399         if ( strncasecmp( line, "include", 7 ) == 0 ) {
2400                 buf[0] = '\0';
2401                 return( line );
2402         }
2403
2404         while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2405                 /* trim off \r\n or \n */
2406                 if ( (p = strchr( buf, '\n' )) != NULL ) {
2407                         if( p > buf && p[-1] == '\r' ) --p;
2408                         *p = '\0';
2409                 }
2410                 
2411                 /* trim off trailing \ and append the next line */
2412                 if ( line[ 0 ] != '\0' 
2413                                 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2414                                 && p[ -1 ] != '\\' ) {
2415                         p[ 0 ] = '\0';
2416                         lcur--;
2417
2418                 } else {
2419                         if ( ! isspace( (unsigned char) buf[0] ) ) {
2420                                 return( line );
2421                         }
2422
2423                         /* change leading whitespace to a space */
2424                         buf[0] = ' ';
2425                 }
2426
2427                 CATLINE( buf );
2428                 (*lineno)++;
2429         }
2430         buf[0] = '\0';
2431
2432         return( line[0] ? line : NULL );
2433 }
2434
2435 static void
2436 fp_getline_init( int *lineno )
2437 {
2438         *lineno = -1;
2439         buf[0] = '\0';
2440 }
2441
2442 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2443 static int
2444 load_ucdata( char *path )
2445 {
2446         static int loaded = 0;
2447         int err;
2448         
2449         if ( loaded ) {
2450                 return( 0 );
2451         }
2452         err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2453         if ( err ) {
2454 #ifdef NEW_LOGGING
2455                 LDAP_LOG( CONFIG, CRIT, 
2456                         "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2457 #else
2458                 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2459                        err, 0, 0 );
2460 #endif
2461
2462                 return( -1 );
2463         }
2464         loaded = 1;
2465         return( 1 );
2466 }
2467
2468 void
2469 config_destroy( )
2470 {
2471         ucdata_unload( UCDATA_ALL );
2472         free( line );
2473         if ( slapd_args_file )
2474                 free ( slapd_args_file );
2475         if ( slapd_pid_file )
2476                 free ( slapd_pid_file );
2477         acl_destroy( global_acl, NULL );
2478 }