1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
14 #include <ac/socket.h>
24 * defaults for various global variables
26 struct slap_limits_set deflimit = {
27 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
30 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
32 -1 /* no limit on unchecked size */
35 AccessControl *global_acl = NULL;
36 slap_access_t global_default_access = ACL_READ;
37 slap_mask_t global_restrictops = 0;
38 slap_mask_t global_allows = 0;
39 slap_mask_t global_disallows = 0;
40 slap_mask_t global_requires = 0;
41 slap_ssf_set_t global_ssf_set;
43 int global_idletimeout = 0;
44 char *global_host = NULL;
45 char *global_realm = NULL;
46 char *ldap_srvtab = "";
47 char *default_passwd_hash = NULL;
48 struct berval default_search_base = { 0, NULL };
49 struct berval default_search_nbase = { 0, NULL };
50 unsigned num_subordinates = 0;
52 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
53 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
55 char *slapd_pid_file = NULL;
56 char *slapd_args_file = NULL;
59 SaslRegexp_t *SaslRegexp = NULL;
60 int sasl_external_x509dn_convert;
62 static char *fp_getline(FILE *fp, int *lineno);
63 static void fp_getline_init(int *lineno);
64 static int fp_parse_line(char *line, int *argcp, char **argv);
66 static char *strtok_quote(char *line, char *sep);
67 static int load_ucdata(char *path);
70 read_config( const char *fname )
73 char *line, *savefname, *saveline;
74 int cargc, savelineno;
75 char *cargv[MAXARGS+1];
78 struct berval vals[2];
80 static int lastmod = 1;
81 static BackendInfo *bi = NULL;
82 static BackendDB *be = NULL;
84 vals[1].bv_val = NULL;
86 if ( (fp = fopen( fname, "r" )) == NULL ) {
89 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
90 "could not open config file \"%s\": %s (%d)\n",
91 fname, strerror(errno), errno ));
93 Debug( LDAP_DEBUG_ANY,
94 "could not open config file \"%s\": %s (%d)\n",
95 fname, strerror(errno), errno );
101 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
102 "read_config: reading config file %s\n", fname ));
104 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
108 fp_getline_init( &lineno );
110 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
111 /* skip comments and blank lines */
112 if ( line[0] == '#' || line[0] == '\0' ) {
117 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
118 "line %d (%s)\n", lineno, line ));
120 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
124 /* fp_parse_line is destructive, we save a copy */
125 saveline = ch_strdup( line );
127 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
133 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
134 "%s: line %d: bad config line (ignored)\n",
137 Debug( LDAP_DEBUG_ANY,
138 "%s: line %d: bad config line (ignored)\n",
145 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
148 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
149 "%s : line %d: missing type in \"backend\" line.\n",
152 Debug( LDAP_DEBUG_ANY,
153 "%s: line %d: missing type in \"backend <type>\" line\n",
162 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
163 "%s: line %d: backend line must appear before any "
164 "database definition.\n", fname, lineno ));
166 Debug( LDAP_DEBUG_ANY,
167 "%s: line %d: backend line must appear before any database definition\n",
174 bi = backend_info( cargv[1] );
178 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
179 "read_config: backend %s initialization failed.\n",
182 Debug( LDAP_DEBUG_ANY,
183 "backend %s initialization failed.\n",
189 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
192 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
193 "%s: line %d: missing type in \"database <type>\" line\n",
196 Debug( LDAP_DEBUG_ANY,
197 "%s: line %d: missing type in \"database <type>\" line\n",
205 be = backend_db_init( cargv[1] );
209 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
210 "database %s initialization failed.\n",
213 Debug( LDAP_DEBUG_ANY,
214 "database %s initialization failed.\n",
221 /* set thread concurrency */
222 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
226 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
227 "%s: line %d: missing level in \"concurrency <level\" line\n",
230 Debug( LDAP_DEBUG_ANY,
231 "%s: line %d: missing level in \"concurrency <level>\" line\n",
238 c = atoi( cargv[1] );
242 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
243 "%s: line %d: invalid level (%d) in "
244 "\"concurrency <level>\" line.\n",
247 Debug( LDAP_DEBUG_ANY,
248 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
255 ldap_pvt_thread_set_concurrency( c );
257 /* set sockbuf max */
258 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
262 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
263 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
266 Debug( LDAP_DEBUG_ANY,
267 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
274 max = atol( cargv[1] );
278 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
279 "%s: line %d: invalid max value (%ld) in "
280 "\"sockbuf_max_incoming <bytes>\" line.\n",
281 fname, lineno, max ));
283 Debug( LDAP_DEBUG_ANY,
284 "%s: line %d: invalid max value (%ld) in "
285 "\"sockbuf_max_incoming <bytes>\" line.\n",
286 fname, lineno, max );
292 sockbuf_max_incoming = max;
294 /* set sockbuf max authenticated */
295 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
299 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
300 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
303 Debug( LDAP_DEBUG_ANY,
304 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
311 max = atol( cargv[1] );
315 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
316 "%s: line %d: invalid max value (%ld) in "
317 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
318 fname, lineno, max ));
320 Debug( LDAP_DEBUG_ANY,
321 "%s: line %d: invalid max value (%ld) in "
322 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
323 fname, lineno, max );
329 sockbuf_max_incoming_auth = max;
331 /* default search base */
332 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
335 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
336 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
337 "line\n", fname, lineno ));
339 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
340 "missing dn in \"defaultSearchBase <dn>\" line\n",
346 } else if ( cargc > 2 ) {
348 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
349 "%s: line %d: extra cruft after <dn> in "
350 "\"defaultSearchBase %s\" line (ignored)\n",
351 fname, lineno, cargv[1] ));
353 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
354 "extra cruft after <dn> in \"defaultSearchBase %s\", "
356 fname, lineno, cargv[1] );
360 if ( bi != NULL || be != NULL ) {
362 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
363 "%s: line %d: defaultSearchBase line must appear "
364 "prior to any backend or database definitions\n",
367 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
368 "defaultSearchBaase line must appear prior to "
369 "any backend or database definition\n",
376 if ( default_search_nbase.bv_len ) {
378 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
379 "default search base \"%s\" already defined "
380 "(discarding old)\n", fname, lineno,
381 default_search_base.bv_val ));
383 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
384 "default search base \"%s\" already defined "
385 "(discarding old)\n",
386 fname, lineno, default_search_base.bv_val );
389 free( default_search_base.bv_val );
390 free( default_search_nbase.bv_val );
393 if ( load_ucdata( NULL ) < 0 ) return 1;
398 dn.bv_val = cargv[1];
399 dn.bv_len = strlen( dn.bv_val );
401 rc = dnPrettyNormal( NULL, &dn,
402 &default_search_base,
403 &default_search_nbase );
405 if( rc != LDAP_SUCCESS ) {
407 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
408 "%s: line %d: defaultSearchBase DN is invalid.\n",
411 Debug( LDAP_DEBUG_ANY,
412 "%s: line %d: defaultSearchBase DN is invalid\n",
419 /* set maximum threads in thread pool */
420 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
424 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
425 "%s: line %d: missing count in \"threads <count>\" line\n",
428 Debug( LDAP_DEBUG_ANY,
429 "%s: line %d: missing count in \"threads <count>\" line\n",
436 c = atoi( cargv[1] );
440 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
441 "%s: line %d: invalid level (%d) in \"threads <count>\""
442 "line\n",fname, lineno, c ));
444 Debug( LDAP_DEBUG_ANY,
445 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
452 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
454 /* save for later use */
455 connection_pool_max = c;
457 /* get pid file name */
458 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
461 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
462 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
465 Debug( LDAP_DEBUG_ANY,
466 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
473 slapd_pid_file = ch_strdup( cargv[1] );
475 /* get args file name */
476 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
479 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
480 "%s: %d: missing file name in "
481 "\"argsfile <file>\" line.\n",
484 Debug( LDAP_DEBUG_ANY,
485 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
492 slapd_args_file = ch_strdup( cargv[1] );
494 /* default password hash */
495 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
498 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
499 "%s: line %d: missing hash in "
500 "\"password-hash <hash>\" line.\n",
503 Debug( LDAP_DEBUG_ANY,
504 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
510 if ( default_passwd_hash != NULL ) {
512 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
513 "%s: line %d: already set default password_hash!\n",
516 Debug( LDAP_DEBUG_ANY,
517 "%s: line %d: already set default password_hash!\n",
525 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
527 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
528 "%s: line %d: password scheme \"%s\" not available\n",
529 fname, lineno, cargv[1] ));
531 Debug( LDAP_DEBUG_ANY,
532 "%s: line %d: password scheme \"%s\" not available\n",
533 fname, lineno, cargv[1] );
538 default_passwd_hash = ch_strdup( cargv[1] );
540 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
544 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
545 "%s: line %d: missing format in "
546 "\"password-crypt-salt-format <format>\" line\n",
549 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
550 "\"password-crypt-salt-format <format>\" line\n",
557 lutil_salt_format( cargv[1] );
560 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
563 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
564 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
567 Debug( LDAP_DEBUG_ANY,
568 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
575 if ( global_host != NULL ) {
577 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
578 "%s: line %d: already set sasl-host!\n",
581 Debug( LDAP_DEBUG_ANY,
582 "%s: line %d: already set sasl-host!\n",
589 global_host = ch_strdup( cargv[1] );
593 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
596 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
597 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
600 Debug( LDAP_DEBUG_ANY,
601 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
608 if ( global_realm != NULL ) {
610 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
611 "%s: line %d: already set sasl-realm!\n",
614 Debug( LDAP_DEBUG_ANY,
615 "%s: line %d: already set sasl-realm!\n",
622 global_realm = ch_strdup( cargv[1] );
625 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
626 || !strcasecmp( cargv[0], "saslregexp" ) )
631 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
632 "%s: line %d: need 2 args in "
633 "\"saslregexp <match> <replace>\"\n",
636 Debug( LDAP_DEBUG_ANY,
637 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
643 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
648 /* SASL security properties */
649 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
654 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
655 "%s: line %d: missing flags in "
656 "\"sasl-secprops <properties>\" line\n",
659 Debug( LDAP_DEBUG_ANY,
660 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
667 txt = slap_sasl_secprops( cargv[1] );
670 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
671 "%s: line %d sas-secprops: %s\n",
672 fname, lineno, txt ));
674 Debug( LDAP_DEBUG_ANY,
675 "%s: line %d: sasl-secprops: %s\n",
676 fname, lineno, txt );
682 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
683 sasl_external_x509dn_convert++;
685 /* set UCDATA path */
686 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
690 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
691 "%s: line %d: missing path in "
692 "\"ucdata-path <path>\" line.\n",
695 Debug( LDAP_DEBUG_ANY,
696 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
703 err = load_ucdata( cargv[1] );
707 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
708 "%s: line %d: ucdata already loaded, ucdata-path "
709 "must be set earlier in the file and/or be "
710 "specified only once!\n",
713 Debug( LDAP_DEBUG_ANY,
714 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
723 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
725 struct slap_limits_set *lim;
729 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
730 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
733 Debug( LDAP_DEBUG_ANY,
734 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
744 lim = &be->be_def_limit;
747 for ( i = 1; i < cargc; i++ ) {
748 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
749 rc = parse_limit( cargv[i], lim );
751 lim->lms_s_soft = atoi( cargv[i] );
757 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
758 "%s: line %d: unable "
759 "to parse value \"%s\" "
762 fname, lineno, cargv[i] ));
764 Debug( LDAP_DEBUG_ANY,
765 "%s: line %d: unable "
766 "to parse value \"%s\" "
769 fname, lineno, cargv[i] );
775 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
777 struct slap_limits_set *lim;
781 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
782 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
785 Debug( LDAP_DEBUG_ANY,
786 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
796 lim = &be->be_def_limit;
799 for ( i = 1; i < cargc; i++ ) {
800 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
801 rc = parse_limit( cargv[i], lim );
803 lim->lms_t_soft = atoi( cargv[i] );
809 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
810 "%s: line %d: unable "
811 "to parse value \"%s\" "
814 fname, lineno, cargv[i] ));
816 Debug( LDAP_DEBUG_ANY,
817 "%s: line %d: unable "
818 "to parse value \"%s\" "
821 fname, lineno, cargv[i] );
826 /* set regex-based limits */
827 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
830 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
831 "%s: line %d \"limits\" allowed only in database environment.\n",
834 Debug( LDAP_DEBUG_ANY,
835 "%s: line %d \"limits\" allowed only in database environment.\n%s",
841 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
845 /* mark this as a subordinate database */
846 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
849 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
850 "subordinate keyword must appear inside a database "
851 "definition (ignored).\n", fname, lineno ));
853 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
854 "must appear inside a database definition (ignored)\n",
858 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
862 /* set database suffix */
863 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
866 struct berval *pdn = NULL;
867 struct berval *ndn = NULL;
871 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
872 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
875 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
876 "missing dn in \"suffix <dn>\" line\n",
882 } else if ( cargc > 2 ) {
884 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
885 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
886 " line (ignored).\n", fname, lineno, cargv[1] ));
888 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
889 "after <dn> in \"suffix %s\" line (ignored)\n",
890 fname, lineno, cargv[1] );
896 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
897 "%s: line %d: suffix line must appear inside a database "
898 "definition.\n", fname, lineno ));
900 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
901 "must appear inside a database definition\n",
906 #if defined(SLAPD_MONITOR_DN)
907 /* "cn=Monitor" is reserved for monitoring slap */
908 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
910 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
911 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
914 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
915 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
919 #endif /* SLAPD_MONITOR_DN */
922 if ( load_ucdata( NULL ) < 0 ) return 1;
924 dn.bv_val = cargv[1];
925 dn.bv_len = strlen( cargv[1] );
926 pdn = ch_malloc( sizeof( struct berval ));
927 ndn = ch_malloc( sizeof( struct berval ));
929 rc = dnPrettyNormal( NULL, &dn, pdn, ndn );
930 if( rc != LDAP_SUCCESS ) {
932 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
933 "%s: line %d: suffix DN is invalid.\n",
936 Debug( LDAP_DEBUG_ANY,
937 "%s: line %d: suffix DN is invalid\n",
943 tmp_be = select_backend( ndn, 0, 0 );
944 if ( tmp_be == be ) {
946 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
947 "%s: line %d: suffix already served by this backend "
948 "(ignored)\n", fname, lineno ));
950 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
951 "already served by this backend (ignored)\n",
957 } else if ( tmp_be != NULL ) {
959 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
960 "%s: line %d: suffix already served by a preceding "
961 "backend \"%s\"\n", fname, lineno,
962 tmp_be->be_suffix[0]->bv_val ));
964 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
965 "already served by a preceeding backend \"%s\"\n",
966 fname, lineno, tmp_be->be_suffix[0]->bv_val );
972 } else if( pdn->bv_len == 0 && default_search_nbase.bv_len ) {
974 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
975 "%s: line %d: suffix DN empty and default search "
976 "base provided \"%s\" (assuming okay).\n",
977 fname, lineno, default_search_base.bv_val ));
979 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
980 "suffix DN empty and default "
981 "search base provided \"%s\" (assuming okay)\n",
982 fname, lineno, default_search_base.bv_val );
986 ber_bvecadd( &be->be_suffix, pdn );
987 ber_bvecadd( &be->be_nsuffix, ndn );
989 /* set database suffixAlias */
990 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
992 struct berval alias, *palias, nalias;
993 struct berval aliased, *paliased, naliased;
997 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
998 "%s: line %d: missing alias and aliased_dn in "
999 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1002 Debug( LDAP_DEBUG_ANY,
1003 "%s: line %d: missing alias and aliased_dn in "
1004 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1009 } else if ( cargc < 3 ) {
1011 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1012 "%s: line %d: missing aliased_dn in "
1013 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1016 Debug( LDAP_DEBUG_ANY,
1017 "%s: line %d: missing aliased_dn in "
1018 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1023 } else if ( cargc > 3 ) {
1025 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1026 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1029 Debug( LDAP_DEBUG_ANY,
1030 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1038 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1039 "%s: line %d: suffixAlias line must appear inside a "
1040 "database definition (ignored).\n", fname, lineno ));
1042 Debug( LDAP_DEBUG_ANY,
1043 "%s: line %d: suffixAlias line"
1044 " must appear inside a database definition (ignored)\n",
1049 if ( load_ucdata( NULL ) < 0 ) return 1;
1051 alias.bv_val = cargv[1];
1052 alias.bv_len = strlen( cargv[1] );
1053 palias = ch_malloc(sizeof(struct berval));
1055 rc = dnPrettyNormal( NULL, &alias, palias, &nalias );
1056 if( rc != LDAP_SUCCESS ) {
1058 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1059 "%s: line %d: alias DN is invalid.\n",
1062 Debug( LDAP_DEBUG_ANY,
1063 "%s: line %d: alias DN is invalid\n",
1069 tmp_be = select_backend( &nalias, 0, 0 );
1070 free( nalias.bv_val );
1071 if ( tmp_be && tmp_be != be ) {
1073 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1074 "%s: line %d: suffixAlias served by a preceeding "
1076 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1078 Debug( LDAP_DEBUG_ANY,
1079 "%s: line %d: suffixAlias served by"
1080 " a preceeding backend \"%s\"\n",
1081 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1083 ber_bvfree( palias );
1087 aliased.bv_val = cargv[2];
1088 aliased.bv_len = strlen( cargv[2] );
1089 paliased = ch_malloc(sizeof(struct berval));
1091 rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased );
1092 if( rc != LDAP_SUCCESS ) {
1094 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1095 "%s: line %d: aliased DN is invalid.\n",
1098 Debug( LDAP_DEBUG_ANY,
1099 "%s: line %d: aliased DN is invalid\n",
1102 ber_bvfree( palias );
1106 tmp_be = select_backend( &naliased, 0, 0 );
1107 free( naliased.bv_val );
1108 if ( tmp_be && tmp_be != be ) {
1110 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1111 "%s: line %d: suffixAlias derefs to a different backend "
1112 "a preceeding backend \"%s\"\n",
1113 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1115 Debug( LDAP_DEBUG_ANY,
1116 "%s: line %d: suffixAlias derefs to differnet backend"
1117 " a preceeding backend \"%s\"\n",
1118 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1120 ber_bvfree( palias );
1121 ber_bvfree( paliased );
1125 ber_bvecadd( &be->be_suffixAlias, palias );
1126 ber_bvecadd( &be->be_suffixAlias, paliased );
1128 /* set max deref depth */
1129 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1133 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1134 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1135 " line\n", fname, lineno ));
1137 Debug( LDAP_DEBUG_ANY,
1138 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1146 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1147 "%s: line %d: depth line must appear inside a database "
1148 "definition (ignored)\n", fname, lineno ));
1150 Debug( LDAP_DEBUG_ANY,
1151 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1155 } else if ((i = atoi(cargv[1])) < 0) {
1157 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1158 "%s: line %d: depth must be positive (ignored).\n",
1161 Debug( LDAP_DEBUG_ANY,
1162 "%s: line %d: depth must be positive (ignored)\n",
1168 be->be_max_deref_depth = i;
1172 /* set magic "root" dn for this database */
1173 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1176 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1177 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1180 Debug( LDAP_DEBUG_ANY,
1181 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1189 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1190 "%s: line %d: rootdn line must appear inside a database "
1191 "definition (ignored).\n", fname, lineno ));
1193 Debug( LDAP_DEBUG_ANY,
1194 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1201 if ( load_ucdata( NULL ) < 0 ) return 1;
1203 dn.bv_val = cargv[1];
1204 dn.bv_len = strlen( cargv[1] );
1206 rc = dnPrettyNormal( NULL, &dn,
1210 if( rc != LDAP_SUCCESS ) {
1212 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1213 "%s: line %d: rootdn DN is invalid.\n",
1216 Debug( LDAP_DEBUG_ANY,
1217 "%s: line %d: rootdn DN is invalid\n",
1224 /* set super-secret magic database password */
1225 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1228 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1229 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1230 " line\n", fname, lineno ));
1232 Debug( LDAP_DEBUG_ANY,
1233 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1241 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1242 "%s: line %d: rootpw line must appear inside a database "
1243 "definition (ignored)\n", fname, lineno ));
1245 Debug( LDAP_DEBUG_ANY,
1246 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1251 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1252 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1255 /* make this database read-only */
1256 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1259 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1260 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1263 Debug( LDAP_DEBUG_ANY,
1264 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1271 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1272 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1274 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1277 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1278 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1280 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1285 /* allow these features */
1286 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1287 strcasecmp( cargv[0], "allow" ) == 0 )
1293 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1294 "%s: line %d: allow line must appear prior to "
1295 "database definitions.\n", fname, lineno ));
1297 Debug( LDAP_DEBUG_ANY,
1298 "%s: line %d: allow line must appear prior to database definitions\n",
1306 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1307 "%s: line %d: missing feature(s) in \"allow <features>\""
1308 " line\n", fname, lineno ));
1310 Debug( LDAP_DEBUG_ANY,
1311 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1320 for( i=1; i < cargc; i++ ) {
1321 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1322 allows |= SLAP_ALLOW_BIND_V2;
1324 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1325 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1327 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1328 allows |= SLAP_ALLOW_BIND_ANON_DN;
1330 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1332 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1333 "%s: line %d: unknown feature %s in "
1334 "\"allow <features>\" line.\n",
1335 fname, lineno, cargv[1] ));
1337 Debug( LDAP_DEBUG_ANY,
1338 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1339 fname, lineno, cargv[i] );
1346 global_allows = allows;
1348 /* disallow these features */
1349 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1350 strcasecmp( cargv[0], "disallow" ) == 0 )
1352 slap_mask_t disallows;
1356 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1357 "%s: line %d: disallow line must appear prior to "
1358 "database definitions.\n", fname, lineno ));
1360 Debug( LDAP_DEBUG_ANY,
1361 "%s: line %d: disallow line must appear prior to database definitions\n",
1369 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1370 "%s: line %d: missing feature(s) in \"disallow <features>\""
1371 " line.\n", fname, lineno ));
1373 Debug( LDAP_DEBUG_ANY,
1374 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1383 for( i=1; i < cargc; i++ ) {
1384 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1385 disallows |= SLAP_DISALLOW_BIND_ANON;
1387 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1388 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1390 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1391 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1393 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1394 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1396 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1397 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1399 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1401 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1402 "%s: line %d: unknown feature %s in "
1403 "\"disallow <features>\" line.\n",
1404 fname, lineno, cargv[i] ));
1406 Debug( LDAP_DEBUG_ANY,
1407 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1408 fname, lineno, cargv[i] );
1415 global_disallows = disallows;
1417 /* require these features */
1418 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1419 strcasecmp( cargv[0], "require" ) == 0 )
1421 slap_mask_t requires;
1425 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1426 "%s: line %d: missing feature(s) in "
1427 "\"require <features>\" line.\n", fname, lineno ));
1429 Debug( LDAP_DEBUG_ANY,
1430 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1439 for( i=1; i < cargc; i++ ) {
1440 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1441 requires |= SLAP_REQUIRE_BIND;
1443 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1444 requires |= SLAP_REQUIRE_LDAP_V3;
1446 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1447 requires |= SLAP_REQUIRE_AUTHC;
1449 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1450 requires |= SLAP_REQUIRE_SASL;
1452 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1453 requires |= SLAP_REQUIRE_STRONG;
1455 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1457 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1458 "%s: line %d: unknown feature %s in "
1459 "\"require <features>\" line.\n",
1462 Debug( LDAP_DEBUG_ANY,
1463 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1464 fname, lineno, cargv[i] );
1472 global_requires = requires;
1474 be->be_requires = requires;
1477 /* required security factors */
1478 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1479 slap_ssf_set_t *set;
1483 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1484 "%s: line %d: missing factor(s) in \"security <factors>\""
1485 " line.\n", fname, lineno ));
1487 Debug( LDAP_DEBUG_ANY,
1488 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1496 set = &global_ssf_set;
1498 set = &be->be_ssf_set;
1501 for( i=1; i < cargc; i++ ) {
1502 if( strncasecmp( cargv[i], "ssf=",
1503 sizeof("ssf") ) == 0 )
1506 atoi( &cargv[i][sizeof("ssf")] );
1508 } else if( strncasecmp( cargv[i], "transport=",
1509 sizeof("transport") ) == 0 )
1511 set->sss_transport =
1512 atoi( &cargv[i][sizeof("transport")] );
1514 } else if( strncasecmp( cargv[i], "tls=",
1515 sizeof("tls") ) == 0 )
1518 atoi( &cargv[i][sizeof("tls")] );
1520 } else if( strncasecmp( cargv[i], "sasl=",
1521 sizeof("sasl") ) == 0 )
1524 atoi( &cargv[i][sizeof("sasl")] );
1526 } else if( strncasecmp( cargv[i], "update_ssf=",
1527 sizeof("update_ssf") ) == 0 )
1529 set->sss_update_ssf =
1530 atoi( &cargv[i][sizeof("update_ssf")] );
1532 } else if( strncasecmp( cargv[i], "update_transport=",
1533 sizeof("update_transport") ) == 0 )
1535 set->sss_update_transport =
1536 atoi( &cargv[i][sizeof("update_transport")] );
1538 } else if( strncasecmp( cargv[i], "update_tls=",
1539 sizeof("update_tls") ) == 0 )
1541 set->sss_update_tls =
1542 atoi( &cargv[i][sizeof("update_tls")] );
1544 } else if( strncasecmp( cargv[i], "update_sasl=",
1545 sizeof("update_sasl") ) == 0 )
1547 set->sss_update_sasl =
1548 atoi( &cargv[i][sizeof("update_sasl")] );
1552 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1553 "%s: line %d: unknown factor %S in "
1554 "\"security <factors>\" line.\n",
1555 fname, lineno, cargv[1] ));
1557 Debug( LDAP_DEBUG_ANY,
1558 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1559 fname, lineno, cargv[i] );
1565 /* where to send clients when we don't hold it */
1566 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1569 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1570 "%s: line %d: missing URL in \"referral <URL>\""
1571 " line.\n", fname, lineno ));
1573 Debug( LDAP_DEBUG_ANY,
1574 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1581 if( validate_global_referral( cargv[1] ) ) {
1583 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1584 "invalid URL (%s) in \"referral\" line.\n",
1585 fname, lineno, cargv[1] ));
1587 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1588 "invalid URL (%s) in \"referral\" line.\n",
1589 fname, lineno, cargv[1] );
1594 vals[0].bv_val = cargv[1];
1595 vals[0].bv_len = strlen( vals[0].bv_val );
1596 value_add( &default_referral, vals );
1599 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1603 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1604 "%s: line %d: Error in logfile directive, "
1605 "\"logfile <filename>\"\n", fname, lineno ));
1607 Debug( LDAP_DEBUG_ANY,
1608 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1614 logfile = fopen( cargv[1], "w" );
1615 if ( logfile != NULL ) lutil_debug_file( logfile );
1618 /* start of a new database definition */
1619 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1623 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1624 "%s: line %d: Error in debug directive, "
1625 "\"debug <subsys> <level>\"\n", fname, lineno ));
1627 Debug( LDAP_DEBUG_ANY,
1628 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1634 level = atoi( cargv[2] );
1635 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1636 lutil_set_debug_level( cargv[1], level );
1637 /* specify an Object Identifier macro */
1638 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1639 rc = parse_oidm( fname, lineno, cargc, cargv );
1642 /* specify an objectclass */
1643 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1644 if ( *cargv[1] == '(' ) {
1646 p = strchr(saveline,'(');
1647 rc = parse_oc( fname, lineno, p, cargv );
1652 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1653 "%s: line %d: old objectclass format not supported\n",
1656 Debug( LDAP_DEBUG_ANY,
1657 "%s: line %d: old objectclass format not supported.\n",
1663 /* specify an attribute type */
1664 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1665 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1667 if ( *cargv[1] == '(' ) {
1669 p = strchr(saveline,'(');
1670 rc = parse_at( fname, lineno, p, cargv );
1675 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1676 "%s: line %d: old attribute type format not supported.\n",
1679 Debug( LDAP_DEBUG_ANY,
1680 "%s: line %d: old attribute type format not supported.\n",
1686 /* turn on/off schema checking */
1687 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1690 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1691 "%s: line %d: missing on|off in "
1692 "\"schemacheck <on|off>\" line.\n",
1695 Debug( LDAP_DEBUG_ANY,
1696 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1702 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1704 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1705 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1708 Debug( LDAP_DEBUG_ANY,
1709 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1712 global_schemacheck = 0;
1714 global_schemacheck = 1;
1717 /* specify access control info */
1718 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1719 parse_acl( be, fname, lineno, cargc, cargv );
1721 /* debug level to log things to syslog */
1722 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1725 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1726 "%s: line %d: missing level in \"loglevel <level>\""
1727 " line.\n", fname, lineno ));
1729 Debug( LDAP_DEBUG_ANY,
1730 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1739 for( i=1; i < cargc; i++ ) {
1740 ldap_syslog += atoi( cargv[1] );
1743 /* list of replicas of the data in this backend (master only) */
1744 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1747 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1748 "%s: line %d: missing host in \"replica "
1749 " <host[:port]\" line\n", fname, lineno ));
1751 Debug( LDAP_DEBUG_ANY,
1752 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1760 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1761 "%s: line %d: replica line must appear inside "
1762 "a database definition (ignored).\n", fname, lineno ));
1764 Debug( LDAP_DEBUG_ANY,
1765 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1772 for ( i = 1; i < cargc; i++ ) {
1773 if ( strncasecmp( cargv[i], "host=", 5 )
1775 nr = add_replica_info( be,
1782 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1783 "%s: line %d: missing host in \"replica\" "
1784 "line (ignored)\n", fname, lineno ));
1786 Debug( LDAP_DEBUG_ANY,
1787 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1791 } else if ( nr == -1 ) {
1793 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1794 "%s: line %d: unable to add"
1800 Debug( LDAP_DEBUG_ANY,
1801 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1802 fname, lineno, cargv[i] + 5 );
1805 for ( i = 1; i < cargc; i++ ) {
1806 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1808 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1811 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1812 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1813 fname, lineno, cargv[i] + 7 ));
1815 Debug( LDAP_DEBUG_ANY,
1816 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1817 fname, lineno, cargv[i] + 7 );
1823 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1824 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1827 Debug( LDAP_DEBUG_ANY,
1828 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1834 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1836 char *arg = cargv[i] + 4;
1838 if ( arg[0] == '!' ) {
1843 if ( arg[0] != '=' ) {
1847 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1849 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1850 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1851 fname, lineno, arg + 1 ));
1853 Debug( LDAP_DEBUG_ANY,
1854 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1855 fname, lineno, arg + 1 );
1864 /* dn of master entity allowed to write to replica */
1865 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1868 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1869 "%s: line %d: missing dn in \"updatedn <dn>\""
1870 " line.\n", fname, lineno ));
1872 Debug( LDAP_DEBUG_ANY,
1873 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1881 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1882 "%s: line %d: updatedn line must appear inside "
1883 "a database definition (ignored)\n",
1886 Debug( LDAP_DEBUG_ANY,
1887 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1894 if ( load_ucdata( NULL ) < 0 ) return 1;
1896 dn.bv_val = cargv[1];
1897 dn.bv_len = strlen( cargv[1] );
1899 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1900 if( rc != LDAP_SUCCESS ) {
1902 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1903 "%s: line %d: updatedn DN is invalid.\n",
1906 Debug( LDAP_DEBUG_ANY,
1907 "%s: line %d: updatedn DN is invalid\n",
1914 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1917 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1918 "missing url in \"updateref <ldapurl>\" line.\n",
1921 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1922 "missing url in \"updateref <ldapurl>\" line\n",
1930 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1931 " line must appear inside a database definition\n",
1934 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1935 " line must appear inside a database definition\n",
1940 } else if ( !be->be_update_ndn.bv_len ) {
1942 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1943 "updateref line must come after updatedn.\n",
1946 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1947 "updateref line must after updatedn.\n",
1953 if( validate_global_referral( cargv[1] ) ) {
1955 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1956 "invalid URL (%s) in \"updateref\" line.\n",
1957 fname, lineno, cargv[1] ));
1959 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1960 "invalid URL (%s) in \"updateref\" line.\n",
1961 fname, lineno, cargv[1] );
1966 vals[0].bv_val = cargv[1];
1967 vals[0].bv_len = strlen( vals[0].bv_val );
1968 value_add( &be->be_update_refs, vals );
1970 /* replication log file to which changes are appended */
1971 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1974 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1975 "%s: line %d: missing filename in \"replogfile <filename>\""
1976 " line.\n", fname, lineno ));
1978 Debug( LDAP_DEBUG_ANY,
1979 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1986 be->be_replogfile = ch_strdup( cargv[1] );
1988 replogfile = ch_strdup( cargv[1] );
1991 /* file from which to read additional rootdse attrs */
1992 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1995 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1996 "missing filename in \"rootDSE <filename>\" line.\n",
1999 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2000 "missing filename in \"rootDSE <filename>\" line.\n",
2006 if( read_root_dse_file( cargv[1] ) ) {
2008 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2009 "could not read \"rootDSE <filename>\" line.\n",
2012 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2013 "could not read \"rootDSE <filename>\" line\n",
2019 /* maintain lastmodified{by,time} attributes */
2020 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2023 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2024 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2025 " line.\n", fname, lineno ));
2027 Debug( LDAP_DEBUG_ANY,
2028 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2034 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2036 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2042 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2048 /* set idle timeout value */
2049 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2053 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2054 "%s: line %d: missing timeout value in "
2055 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2057 Debug( LDAP_DEBUG_ANY,
2058 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2065 i = atoi( cargv[1] );
2069 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2070 "%s: line %d: timeout value (%d) invalid "
2071 "\"idletimeout <seconds>\" line.\n",
2072 fname, lineno, i ));
2074 Debug( LDAP_DEBUG_ANY,
2075 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2082 global_idletimeout = i;
2084 /* include another config file */
2085 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2088 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2089 "%s: line %d: missing filename in \"include "
2090 "<filename>\" line.\n", fname, lineno ));
2092 Debug( LDAP_DEBUG_ANY,
2093 "%s: line %d: missing filename in \"include <filename>\" line\n",
2099 savefname = ch_strdup( cargv[1] );
2100 savelineno = lineno;
2102 if ( read_config( savefname ) != 0 ) {
2107 lineno = savelineno - 1;
2109 /* location of kerberos srvtab file */
2110 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2113 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2114 "%s: line %d: missing filename in \"srvtab "
2115 "<filename>\" line.\n", fname, lineno ));
2117 Debug( LDAP_DEBUG_ANY,
2118 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2124 ldap_srvtab = ch_strdup( cargv[1] );
2126 #ifdef SLAPD_MODULES
2127 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2130 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2131 "%s: line %d: missing filename in \"moduleload "
2132 "<filename>\" line.\n", fname, lineno ));
2134 Debug( LDAP_DEBUG_ANY,
2135 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2139 exit( EXIT_FAILURE );
2141 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2143 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2144 "%s: line %d: failed to load or initialize module %s\n"<
2145 fname, lineno, cargv[1] ));
2147 Debug( LDAP_DEBUG_ANY,
2148 "%s: line %d: failed to load or initialize module %s\n",
2149 fname, lineno, cargv[1]);
2152 exit( EXIT_FAILURE );
2154 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2157 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2158 "%s: line %d: missing path in \"modulepath <path>\""
2159 " line\n", fname, lineno ));
2161 Debug( LDAP_DEBUG_ANY,
2162 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2166 exit( EXIT_FAILURE );
2168 if (module_path( cargv[1] )) {
2170 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2171 "%s: line %d: failed to set module search path to %s.\n",
2172 fname, lineno, cargv[1] ));
2174 Debug( LDAP_DEBUG_ANY,
2175 "%s: line %d: failed to set module search path to %s\n",
2176 fname, lineno, cargv[1]);
2179 exit( EXIT_FAILURE );
2182 #endif /*SLAPD_MODULES*/
2185 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2186 rc = ldap_pvt_tls_set_option( NULL,
2187 LDAP_OPT_X_TLS_RANDOM_FILE,
2192 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2193 rc = ldap_pvt_tls_set_option( NULL,
2194 LDAP_OPT_X_TLS_CIPHER_SUITE,
2199 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2200 rc = ldap_pvt_tls_set_option( NULL,
2201 LDAP_OPT_X_TLS_CERTFILE,
2206 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2207 rc = ldap_pvt_tls_set_option( NULL,
2208 LDAP_OPT_X_TLS_KEYFILE,
2213 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2214 rc = ldap_pvt_tls_set_option( NULL,
2215 LDAP_OPT_X_TLS_CACERTDIR,
2220 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2221 rc = ldap_pvt_tls_set_option( NULL,
2222 LDAP_OPT_X_TLS_CACERTFILE,
2226 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2227 if ( isdigit( cargv[1][0] ) ) {
2229 rc = ldap_pvt_tls_set_option( NULL,
2230 LDAP_OPT_X_TLS_REQUIRE_CERT,
2233 rc = ldap_int_tls_config( NULL,
2234 LDAP_OPT_X_TLS_REQUIRE_CERT,
2243 /* pass anything else to the current backend info/db config routine */
2246 if ( bi->bi_config == 0 ) {
2248 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2249 "%s: line %d: unknown directive \"%s\" inside "
2250 "backend info definition (ignored).\n",
2251 fname, lineno, cargv[0] ));
2253 Debug( LDAP_DEBUG_ANY,
2254 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2255 fname, lineno, cargv[0] );
2259 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2265 } else if ( be != NULL ) {
2266 if ( be->be_config == 0 ) {
2268 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2269 "%s: line %d: uknown directive \"%s\" inside "
2270 "backend database definition (ignored).\n",
2271 fname, lineno, cargv[0] ));
2273 Debug( LDAP_DEBUG_ANY,
2274 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2275 fname, lineno, cargv[0] );
2279 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2287 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2288 "%s: line %d: unknown directive \"%s\" outside backend "
2289 "info and database definitions (ignored).\n",
2290 fname, lineno, cargv[0] ));
2292 Debug( LDAP_DEBUG_ANY,
2293 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2294 fname, lineno, cargv[0] );
2303 if ( load_ucdata( NULL ) < 0 ) return 1;
2317 for ( token = strtok_quote( line, " \t" ); token != NULL;
2318 token = strtok_quote( NULL, " \t" ) ) {
2319 if ( *argcp == MAXARGS ) {
2321 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2322 "fp_parse_line: too many tokens (%d max).\n",
2325 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2331 argv[(*argcp)++] = token;
2333 argv[*argcp] = NULL;
2338 strtok_quote( char *line, char *sep )
2344 if ( line != NULL ) {
2347 while ( *next && strchr( sep, *next ) ) {
2351 if ( *next == '\0' ) {
2357 for ( inquote = 0; *next; ) {
2365 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2371 next + 1, strlen( next + 1 ) + 1 );
2372 next++; /* dont parse the escaped character */
2377 if ( strchr( sep, *next ) != NULL ) {
2390 static char buf[BUFSIZ];
2392 static int lmax, lcur;
2394 #define CATLINE( buf ) { \
2396 len = strlen( buf ); \
2397 while ( lcur + len + 1 > lmax ) { \
2399 line = (char *) ch_realloc( line, lmax ); \
2401 strcpy( line + lcur, buf ); \
2406 fp_getline( FILE *fp, int *lineno )
2414 /* hack attack - keeps us from having to keep a stack of bufs... */
2415 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2420 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2421 /* trim off \r\n or \n */
2422 if ( (p = strchr( buf, '\n' )) != NULL ) {
2423 if( p > buf && p[-1] == '\r' ) --p;
2427 /* trim off trailing \ and append the next line */
2428 if ( line[ 0 ] != '\0'
2429 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2430 && p[ -1 ] != '\\' ) {
2435 if ( ! isspace( (unsigned char) buf[0] ) ) {
2439 /* change leading whitespace to a space */
2448 return( line[0] ? line : NULL );
2452 fp_getline_init( int *lineno )
2458 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2460 load_ucdata( char *path )
2462 static int loaded = 0;
2468 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2471 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2472 "load_ucdata: Error %d loading ucdata.\n", err ));
2474 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2487 ucdata_unload( UCDATA_ALL );
2489 if ( slapd_args_file )
2490 free ( slapd_args_file );
2491 if ( slapd_pid_file )
2492 free ( slapd_pid_file );
2493 acl_destroy( global_acl, NULL );