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;
58 char *strtok_quote_ptr;
61 SaslRegexp_t *SaslRegexp = NULL;
64 int use_reverse_lookup = 1;
65 #else /* !SLAPD_RLOOKUPS */
66 int use_reverse_lookup = 0;
67 #endif /* !SLAPD_RLOOKUPS */
69 static char *fp_getline(FILE *fp, int *lineno);
70 static void fp_getline_init(int *lineno);
71 static int fp_parse_line(int lineno, char *line, int *argcp, char **argv);
73 static char *strtok_quote(char *line, char *sep);
74 static int load_ucdata(char *path);
77 read_config( const char *fname )
80 char *line, *savefname, *saveline;
81 int cargc, savelineno;
82 char *cargv[MAXARGS+1];
85 struct berval vals[2];
87 static int lastmod = 1;
88 static BackendInfo *bi = NULL;
89 static BackendDB *be = NULL;
91 vals[1].bv_val = NULL;
93 if ( (fp = fopen( fname, "r" )) == NULL ) {
96 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
97 "could not open config file \"%s\": %s (%d)\n",
98 fname, strerror(errno), errno ));
100 Debug( LDAP_DEBUG_ANY,
101 "could not open config file \"%s\": %s (%d)\n",
102 fname, strerror(errno), errno );
108 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
109 "read_config: reading config file %s\n", fname ));
111 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
115 fp_getline_init( &lineno );
117 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
118 /* skip comments and blank lines */
119 if ( line[0] == '#' || line[0] == '\0' ) {
123 /* fp_parse_line is destructive, we save a copy */
124 saveline = ch_strdup( line );
126 if ( fp_parse_line( lineno, line, &cargc, cargv ) != 0 ) {
132 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
133 "%s: line %d: bad config line (ignored)\n",
136 Debug( LDAP_DEBUG_ANY,
137 "%s: line %d: bad config line (ignored)\n",
144 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
147 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
148 "%s : line %d: missing type in \"backend\" line.\n",
151 Debug( LDAP_DEBUG_ANY,
152 "%s: line %d: missing type in \"backend <type>\" line\n",
161 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
162 "%s: line %d: backend line must appear before any "
163 "database definition.\n", fname, lineno ));
165 Debug( LDAP_DEBUG_ANY,
166 "%s: line %d: backend line must appear before any database definition\n",
173 bi = backend_info( cargv[1] );
177 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
178 "read_config: backend %s initialization failed.\n",
181 Debug( LDAP_DEBUG_ANY,
182 "backend %s initialization failed.\n",
188 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
191 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
192 "%s: line %d: missing type in \"database <type>\" line\n",
195 Debug( LDAP_DEBUG_ANY,
196 "%s: line %d: missing type in \"database <type>\" line\n",
204 be = backend_db_init( cargv[1] );
208 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
209 "database %s initialization failed.\n",
212 Debug( LDAP_DEBUG_ANY,
213 "database %s initialization failed.\n",
220 /* set thread concurrency */
221 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
225 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
226 "%s: line %d: missing level in \"concurrency <level\" line\n",
229 Debug( LDAP_DEBUG_ANY,
230 "%s: line %d: missing level in \"concurrency <level>\" line\n",
237 c = atoi( cargv[1] );
241 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
242 "%s: line %d: invalid level (%d) in "
243 "\"concurrency <level>\" line.\n",
246 Debug( LDAP_DEBUG_ANY,
247 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
254 ldap_pvt_thread_set_concurrency( c );
256 /* set sockbuf max */
257 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
261 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
262 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
265 Debug( LDAP_DEBUG_ANY,
266 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
273 max = atol( cargv[1] );
277 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
278 "%s: line %d: invalid max value (%ld) in "
279 "\"sockbuf_max_incoming <bytes>\" line.\n",
280 fname, lineno, max ));
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 );
291 sockbuf_max_incoming = max;
293 /* set sockbuf max authenticated */
294 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
298 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
299 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
302 Debug( LDAP_DEBUG_ANY,
303 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
310 max = atol( cargv[1] );
314 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
315 "%s: line %d: invalid max value (%ld) in "
316 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
317 fname, lineno, max ));
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 );
328 sockbuf_max_incoming_auth = max;
330 /* default search base */
331 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
334 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
335 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
336 "line\n", fname, lineno ));
338 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
339 "missing dn in \"defaultSearchBase <dn>\" line\n",
345 } else if ( cargc > 2 ) {
347 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
348 "%s: line %d: extra cruft after <dn> in "
349 "\"defaultSearchBase %s\" line (ignored)\n",
350 fname, lineno, cargv[1] ));
352 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
353 "extra cruft after <dn> in \"defaultSearchBase %s\", "
355 fname, lineno, cargv[1] );
359 if ( bi != NULL || be != NULL ) {
361 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
362 "%s: line %d: defaultSearchBase line must appear "
363 "prior to any backend or database definitions\n",
366 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
367 "defaultSearchBaase line must appear prior to "
368 "any backend or database definition\n",
375 if ( default_search_nbase.bv_len ) {
377 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
378 "default search base \"%s\" already defined "
379 "(discarding old)\n", fname, lineno,
380 default_search_base.bv_val ));
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 );
388 free( default_search_base.bv_val );
389 free( default_search_nbase.bv_val );
392 if ( load_ucdata( NULL ) < 0 ) return 1;
397 dn.bv_val = cargv[1];
398 dn.bv_len = strlen( dn.bv_val );
400 rc = dnPrettyNormal( NULL, &dn,
401 &default_search_base,
402 &default_search_nbase );
404 if( rc != LDAP_SUCCESS ) {
406 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
407 "%s: line %d: defaultSearchBase DN is invalid.\n",
410 Debug( LDAP_DEBUG_ANY,
411 "%s: line %d: defaultSearchBase DN is invalid\n",
418 /* set maximum threads in thread pool */
419 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
423 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
424 "%s: line %d: missing count in \"threads <count>\" line\n",
427 Debug( LDAP_DEBUG_ANY,
428 "%s: line %d: missing count in \"threads <count>\" line\n",
435 c = atoi( cargv[1] );
439 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
440 "%s: line %d: invalid level (%d) in \"threads <count>\""
441 "line\n",fname, lineno, c ));
443 Debug( LDAP_DEBUG_ANY,
444 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
451 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
453 /* save for later use */
454 connection_pool_max = c;
456 /* get pid file name */
457 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
460 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
461 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
464 Debug( LDAP_DEBUG_ANY,
465 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
472 slapd_pid_file = ch_strdup( cargv[1] );
474 /* get args file name */
475 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
478 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
479 "%s: %d: missing file name in "
480 "\"argsfile <file>\" line.\n",
483 Debug( LDAP_DEBUG_ANY,
484 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
491 slapd_args_file = ch_strdup( cargv[1] );
493 /* default password hash */
494 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
497 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
498 "%s: line %d: missing hash in "
499 "\"password-hash <hash>\" line.\n",
502 Debug( LDAP_DEBUG_ANY,
503 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
509 if ( default_passwd_hash != NULL ) {
511 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
512 "%s: line %d: already set default password_hash!\n",
515 Debug( LDAP_DEBUG_ANY,
516 "%s: line %d: already set default password_hash!\n",
524 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
526 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
527 "%s: line %d: password scheme \"%s\" not available\n",
528 fname, lineno, cargv[1] ));
530 Debug( LDAP_DEBUG_ANY,
531 "%s: line %d: password scheme \"%s\" not available\n",
532 fname, lineno, cargv[1] );
537 default_passwd_hash = ch_strdup( cargv[1] );
539 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
543 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
544 "%s: line %d: missing format in "
545 "\"password-crypt-salt-format <format>\" line\n",
548 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
549 "\"password-crypt-salt-format <format>\" line\n",
556 lutil_salt_format( cargv[1] );
559 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
562 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
563 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
566 Debug( LDAP_DEBUG_ANY,
567 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
574 if ( global_host != NULL ) {
576 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
577 "%s: line %d: already set sasl-host!\n",
580 Debug( LDAP_DEBUG_ANY,
581 "%s: line %d: already set sasl-host!\n",
588 global_host = ch_strdup( cargv[1] );
592 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
595 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
596 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
599 Debug( LDAP_DEBUG_ANY,
600 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
607 if ( global_realm != NULL ) {
609 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
610 "%s: line %d: already set sasl-realm!\n",
613 Debug( LDAP_DEBUG_ANY,
614 "%s: line %d: already set sasl-realm!\n",
621 global_realm = ch_strdup( cargv[1] );
624 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
625 || !strcasecmp( cargv[0], "saslregexp" ) )
630 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
631 "%s: line %d: need 2 args in "
632 "\"saslregexp <match> <replace>\"\n",
635 Debug( LDAP_DEBUG_ANY,
636 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
642 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
647 /* SASL security properties */
648 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
653 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
654 "%s: line %d: missing flags in "
655 "\"sasl-secprops <properties>\" line\n",
658 Debug( LDAP_DEBUG_ANY,
659 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
666 txt = slap_sasl_secprops( cargv[1] );
669 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
670 "%s: line %d sas-secprops: %s\n",
671 fname, lineno, txt ));
673 Debug( LDAP_DEBUG_ANY,
674 "%s: line %d: sasl-secprops: %s\n",
675 fname, lineno, txt );
681 /* set UCDATA path */
682 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
686 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
687 "%s: line %d: missing path in "
688 "\"ucdata-path <path>\" line.\n",
691 Debug( LDAP_DEBUG_ANY,
692 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
699 err = load_ucdata( cargv[1] );
703 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
704 "%s: line %d: ucdata already loaded, ucdata-path "
705 "must be set earlier in the file and/or be "
706 "specified only once!\n",
709 Debug( LDAP_DEBUG_ANY,
710 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
719 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
721 struct slap_limits_set *lim;
725 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
726 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
729 Debug( LDAP_DEBUG_ANY,
730 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
740 lim = &be->be_def_limit;
743 for ( i = 1; i < cargc; i++ ) {
744 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
745 rc = parse_limit( cargv[i], lim );
747 lim->lms_s_soft = atoi( cargv[i] );
753 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
754 "%s: line %d: unable "
755 "to parse value \"%s\" "
758 fname, lineno, cargv[i] ));
760 Debug( LDAP_DEBUG_ANY,
761 "%s: line %d: unable "
762 "to parse value \"%s\" "
765 fname, lineno, cargv[i] );
771 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
773 struct slap_limits_set *lim;
777 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
778 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
781 Debug( LDAP_DEBUG_ANY,
782 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
792 lim = &be->be_def_limit;
795 for ( i = 1; i < cargc; i++ ) {
796 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
797 rc = parse_limit( cargv[i], lim );
799 lim->lms_t_soft = atoi( cargv[i] );
805 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
806 "%s: line %d: unable "
807 "to parse value \"%s\" "
810 fname, lineno, cargv[i] ));
812 Debug( LDAP_DEBUG_ANY,
813 "%s: line %d: unable "
814 "to parse value \"%s\" "
817 fname, lineno, cargv[i] );
822 /* set regex-based limits */
823 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
826 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
827 "%s: line %d \"limits\" allowed only in database environment.\n",
830 Debug( LDAP_DEBUG_ANY,
831 "%s: line %d \"limits\" allowed only in database environment.\n%s",
837 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
841 /* mark this as a subordinate database */
842 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
845 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
846 "subordinate keyword must appear inside a database "
847 "definition (ignored).\n", fname, lineno ));
849 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
850 "must appear inside a database definition (ignored)\n",
854 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
858 /* set database suffix */
859 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
862 struct berval *pdn = NULL;
863 struct berval *ndn = NULL;
867 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
868 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
871 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
872 "missing dn in \"suffix <dn>\" line\n",
878 } else if ( cargc > 2 ) {
880 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
881 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
882 " line (ignored).\n", fname, lineno, cargv[1] ));
884 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
885 "after <dn> in \"suffix %s\" line (ignored)\n",
886 fname, lineno, cargv[1] );
892 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
893 "%s: line %d: suffix line must appear inside a database "
894 "definition.\n", fname, lineno ));
896 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
897 "must appear inside a database definition\n",
902 #if defined(SLAPD_MONITOR_DN)
903 /* "cn=Monitor" is reserved for monitoring slap */
904 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
906 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
907 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
910 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
911 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
915 #endif /* SLAPD_MONITOR_DN */
918 if ( load_ucdata( NULL ) < 0 ) return 1;
920 dn.bv_val = cargv[1];
921 dn.bv_len = strlen( cargv[1] );
922 pdn = ch_malloc( sizeof( struct berval ));
923 ndn = ch_malloc( sizeof( struct berval ));
925 rc = dnPrettyNormal( NULL, &dn, pdn, ndn );
926 if( rc != LDAP_SUCCESS ) {
928 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
929 "%s: line %d: suffix DN is invalid.\n",
932 Debug( LDAP_DEBUG_ANY,
933 "%s: line %d: suffix DN is invalid\n",
939 tmp_be = select_backend( ndn, 0, 0 );
940 if ( tmp_be == be ) {
942 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
943 "%s: line %d: suffix already served by this backend "
944 "(ignored)\n", fname, lineno ));
946 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
947 "already served by this backend (ignored)\n",
953 } else if ( tmp_be != NULL ) {
955 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
956 "%s: line %d: suffix already served by a preceding "
957 "backend \"%s\"\n", fname, lineno,
958 tmp_be->be_suffix[0]->bv_val ));
960 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
961 "already served by a preceeding backend \"%s\"\n",
962 fname, lineno, tmp_be->be_suffix[0]->bv_val );
968 } else if( pdn->bv_len == 0 && default_search_nbase.bv_len ) {
970 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
971 "%s: line %d: suffix DN empty and default search "
972 "base provided \"%s\" (assuming okay).\n",
973 fname, lineno, default_search_base.bv_val ));
975 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
976 "suffix DN empty and default "
977 "search base provided \"%s\" (assuming okay)\n",
978 fname, lineno, default_search_base.bv_val );
982 ber_bvecadd( &be->be_suffix, pdn );
983 ber_bvecadd( &be->be_nsuffix, ndn );
985 /* set database suffixAlias */
986 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
988 struct berval alias, *palias, nalias;
989 struct berval aliased, *paliased, naliased;
993 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
994 "%s: line %d: missing alias and aliased_dn in "
995 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
998 Debug( LDAP_DEBUG_ANY,
999 "%s: line %d: missing alias and aliased_dn in "
1000 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1005 } else if ( cargc < 3 ) {
1007 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1008 "%s: line %d: missing aliased_dn in "
1009 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1012 Debug( LDAP_DEBUG_ANY,
1013 "%s: line %d: missing aliased_dn in "
1014 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1019 } else if ( cargc > 3 ) {
1021 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1022 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1025 Debug( LDAP_DEBUG_ANY,
1026 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1034 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1035 "%s: line %d: suffixAlias line must appear inside a "
1036 "database definition (ignored).\n", fname, lineno ));
1038 Debug( LDAP_DEBUG_ANY,
1039 "%s: line %d: suffixAlias line"
1040 " must appear inside a database definition (ignored)\n",
1045 if ( load_ucdata( NULL ) < 0 ) return 1;
1047 alias.bv_val = cargv[1];
1048 alias.bv_len = strlen( cargv[1] );
1049 palias = ch_malloc(sizeof(struct berval));
1051 rc = dnPrettyNormal( NULL, &alias, palias, &nalias );
1052 if( rc != LDAP_SUCCESS ) {
1054 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1055 "%s: line %d: alias DN is invalid.\n",
1058 Debug( LDAP_DEBUG_ANY,
1059 "%s: line %d: alias DN is invalid\n",
1065 tmp_be = select_backend( &nalias, 0, 0 );
1066 free( nalias.bv_val );
1067 if ( tmp_be && tmp_be != be ) {
1069 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1070 "%s: line %d: suffixAlias served by a preceeding "
1072 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1074 Debug( LDAP_DEBUG_ANY,
1075 "%s: line %d: suffixAlias served by"
1076 " a preceeding backend \"%s\"\n",
1077 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1079 ber_bvfree( palias );
1083 aliased.bv_val = cargv[2];
1084 aliased.bv_len = strlen( cargv[2] );
1085 paliased = ch_malloc(sizeof(struct berval));
1087 rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased );
1088 if( rc != LDAP_SUCCESS ) {
1090 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1091 "%s: line %d: aliased DN is invalid.\n",
1094 Debug( LDAP_DEBUG_ANY,
1095 "%s: line %d: aliased DN is invalid\n",
1098 ber_bvfree( palias );
1102 tmp_be = select_backend( &naliased, 0, 0 );
1103 free( naliased.bv_val );
1104 if ( tmp_be && tmp_be != be ) {
1106 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1107 "%s: line %d: suffixAlias derefs to a different backend "
1108 "a preceeding backend \"%s\"\n",
1109 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1111 Debug( LDAP_DEBUG_ANY,
1112 "%s: line %d: suffixAlias derefs to differnet backend"
1113 " a preceeding backend \"%s\"\n",
1114 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1116 ber_bvfree( palias );
1117 ber_bvfree( paliased );
1121 ber_bvecadd( &be->be_suffixAlias, palias );
1122 ber_bvecadd( &be->be_suffixAlias, paliased );
1124 /* set max deref depth */
1125 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1129 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1130 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1131 " line\n", fname, lineno ));
1133 Debug( LDAP_DEBUG_ANY,
1134 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1142 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1143 "%s: line %d: depth line must appear inside a database "
1144 "definition (ignored)\n", fname, lineno ));
1146 Debug( LDAP_DEBUG_ANY,
1147 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1151 } else if ((i = atoi(cargv[1])) < 0) {
1153 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1154 "%s: line %d: depth must be positive (ignored).\n",
1157 Debug( LDAP_DEBUG_ANY,
1158 "%s: line %d: depth must be positive (ignored)\n",
1164 be->be_max_deref_depth = i;
1168 /* set magic "root" dn for this database */
1169 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1172 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1173 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1176 Debug( LDAP_DEBUG_ANY,
1177 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1185 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1186 "%s: line %d: rootdn line must appear inside a database "
1187 "definition (ignored).\n", fname, lineno ));
1189 Debug( LDAP_DEBUG_ANY,
1190 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1197 if ( load_ucdata( NULL ) < 0 ) return 1;
1199 dn.bv_val = cargv[1];
1200 dn.bv_len = strlen( cargv[1] );
1202 rc = dnPrettyNormal( NULL, &dn,
1206 if( rc != LDAP_SUCCESS ) {
1208 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1209 "%s: line %d: rootdn DN is invalid.\n",
1212 Debug( LDAP_DEBUG_ANY,
1213 "%s: line %d: rootdn DN is invalid\n",
1220 /* set super-secret magic database password */
1221 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1224 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1225 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1226 " line\n", fname, lineno ));
1228 Debug( LDAP_DEBUG_ANY,
1229 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1237 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1238 "%s: line %d: rootpw line must appear inside a database "
1239 "definition (ignored)\n", fname, lineno ));
1241 Debug( LDAP_DEBUG_ANY,
1242 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1247 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1248 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1251 /* make this database read-only */
1252 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1255 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1256 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1259 Debug( LDAP_DEBUG_ANY,
1260 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1267 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1268 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1270 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1273 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1274 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1276 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1281 /* allow these features */
1282 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1283 strcasecmp( cargv[0], "allow" ) == 0 )
1289 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1290 "%s: line %d: allow line must appear prior to "
1291 "database definitions.\n", fname, lineno ));
1293 Debug( LDAP_DEBUG_ANY,
1294 "%s: line %d: allow line must appear prior to database definitions\n",
1302 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1303 "%s: line %d: missing feature(s) in \"allow <features>\""
1304 " line\n", fname, lineno ));
1306 Debug( LDAP_DEBUG_ANY,
1307 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1316 for( i=1; i < cargc; i++ ) {
1317 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1318 allows |= SLAP_ALLOW_BIND_V2;
1320 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1321 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1323 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1324 allows |= SLAP_ALLOW_BIND_ANON_DN;
1326 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1328 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1329 "%s: line %d: unknown feature %s in "
1330 "\"allow <features>\" line.\n",
1331 fname, lineno, cargv[1] ));
1333 Debug( LDAP_DEBUG_ANY,
1334 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1335 fname, lineno, cargv[i] );
1342 global_allows = allows;
1344 /* disallow these features */
1345 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1346 strcasecmp( cargv[0], "disallow" ) == 0 )
1348 slap_mask_t disallows;
1352 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1353 "%s: line %d: disallow line must appear prior to "
1354 "database definitions.\n", fname, lineno ));
1356 Debug( LDAP_DEBUG_ANY,
1357 "%s: line %d: disallow line must appear prior to database definitions\n",
1365 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1366 "%s: line %d: missing feature(s) in \"disallow <features>\""
1367 " line.\n", fname, lineno ));
1369 Debug( LDAP_DEBUG_ANY,
1370 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1379 for( i=1; i < cargc; i++ ) {
1380 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1381 disallows |= SLAP_DISALLOW_BIND_ANON;
1383 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1384 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1386 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1387 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1389 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1390 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1392 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1393 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1395 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1397 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1398 "%s: line %d: unknown feature %s in "
1399 "\"disallow <features>\" line.\n",
1400 fname, lineno, cargv[i] ));
1402 Debug( LDAP_DEBUG_ANY,
1403 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1404 fname, lineno, cargv[i] );
1411 global_disallows = disallows;
1413 /* require these features */
1414 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1415 strcasecmp( cargv[0], "require" ) == 0 )
1417 slap_mask_t requires;
1421 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1422 "%s: line %d: missing feature(s) in "
1423 "\"require <features>\" line.\n", fname, lineno ));
1425 Debug( LDAP_DEBUG_ANY,
1426 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1435 for( i=1; i < cargc; i++ ) {
1436 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1437 requires |= SLAP_REQUIRE_BIND;
1439 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1440 requires |= SLAP_REQUIRE_LDAP_V3;
1442 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1443 requires |= SLAP_REQUIRE_AUTHC;
1445 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1446 requires |= SLAP_REQUIRE_SASL;
1448 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1449 requires |= SLAP_REQUIRE_STRONG;
1451 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1453 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1454 "%s: line %d: unknown feature %s in "
1455 "\"require <features>\" line.\n",
1458 Debug( LDAP_DEBUG_ANY,
1459 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1460 fname, lineno, cargv[i] );
1468 global_requires = requires;
1470 be->be_requires = requires;
1473 /* required security factors */
1474 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1475 slap_ssf_set_t *set;
1479 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1480 "%s: line %d: missing factor(s) in \"security <factors>\""
1481 " line.\n", fname, lineno ));
1483 Debug( LDAP_DEBUG_ANY,
1484 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1492 set = &global_ssf_set;
1494 set = &be->be_ssf_set;
1497 for( i=1; i < cargc; i++ ) {
1498 if( strncasecmp( cargv[i], "ssf=",
1499 sizeof("ssf") ) == 0 )
1502 atoi( &cargv[i][sizeof("ssf")] );
1504 } else if( strncasecmp( cargv[i], "transport=",
1505 sizeof("transport") ) == 0 )
1507 set->sss_transport =
1508 atoi( &cargv[i][sizeof("transport")] );
1510 } else if( strncasecmp( cargv[i], "tls=",
1511 sizeof("tls") ) == 0 )
1514 atoi( &cargv[i][sizeof("tls")] );
1516 } else if( strncasecmp( cargv[i], "sasl=",
1517 sizeof("sasl") ) == 0 )
1520 atoi( &cargv[i][sizeof("sasl")] );
1522 } else if( strncasecmp( cargv[i], "update_ssf=",
1523 sizeof("update_ssf") ) == 0 )
1525 set->sss_update_ssf =
1526 atoi( &cargv[i][sizeof("update_ssf")] );
1528 } else if( strncasecmp( cargv[i], "update_transport=",
1529 sizeof("update_transport") ) == 0 )
1531 set->sss_update_transport =
1532 atoi( &cargv[i][sizeof("update_transport")] );
1534 } else if( strncasecmp( cargv[i], "update_tls=",
1535 sizeof("update_tls") ) == 0 )
1537 set->sss_update_tls =
1538 atoi( &cargv[i][sizeof("update_tls")] );
1540 } else if( strncasecmp( cargv[i], "update_sasl=",
1541 sizeof("update_sasl") ) == 0 )
1543 set->sss_update_sasl =
1544 atoi( &cargv[i][sizeof("update_sasl")] );
1548 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1549 "%s: line %d: unknown factor %S in "
1550 "\"security <factors>\" line.\n",
1551 fname, lineno, cargv[1] ));
1553 Debug( LDAP_DEBUG_ANY,
1554 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1555 fname, lineno, cargv[i] );
1561 /* where to send clients when we don't hold it */
1562 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1565 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1566 "%s: line %d: missing URL in \"referral <URL>\""
1567 " line.\n", fname, lineno ));
1569 Debug( LDAP_DEBUG_ANY,
1570 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1577 if( validate_global_referral( cargv[1] ) ) {
1579 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1580 "invalid URL (%s) in \"referral\" line.\n",
1581 fname, lineno, cargv[1] ));
1583 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1584 "invalid URL (%s) in \"referral\" line.\n",
1585 fname, lineno, cargv[1] );
1590 vals[0].bv_val = cargv[1];
1591 vals[0].bv_len = strlen( vals[0].bv_val );
1592 value_add( &default_referral, vals );
1595 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1599 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1600 "%s: line %d: Error in logfile directive, "
1601 "\"logfile <filename>\"\n", fname, lineno ));
1603 Debug( LDAP_DEBUG_ANY,
1604 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1610 logfile = fopen( cargv[1], "w" );
1611 if ( logfile != NULL ) lutil_debug_file( logfile );
1614 /* start of a new database definition */
1615 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1619 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1620 "%s: line %d: Error in debug directive, "
1621 "\"debug <subsys> <level>\"\n", fname, lineno ));
1623 Debug( LDAP_DEBUG_ANY,
1624 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1630 level = atoi( cargv[2] );
1631 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1632 lutil_set_debug_level( cargv[1], level );
1633 /* specify an Object Identifier macro */
1634 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1635 rc = parse_oidm( fname, lineno, cargc, cargv );
1638 /* specify an objectclass */
1639 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1640 if ( *cargv[1] == '(' ) {
1642 p = strchr(saveline,'(');
1643 rc = parse_oc( fname, lineno, p, cargv );
1648 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1649 "%s: line %d: old objectclass format not supported\n",
1652 Debug( LDAP_DEBUG_ANY,
1653 "%s: line %d: old objectclass format not supported.\n",
1659 /* specify an attribute type */
1660 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1661 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1663 if ( *cargv[1] == '(' ) {
1665 p = strchr(saveline,'(');
1666 rc = parse_at( fname, lineno, p, cargv );
1671 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1672 "%s: line %d: old attribute type format not supported.\n",
1675 Debug( LDAP_DEBUG_ANY,
1676 "%s: line %d: old attribute type format not supported.\n",
1682 /* turn on/off schema checking */
1683 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1686 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1687 "%s: line %d: missing on|off in "
1688 "\"schemacheck <on|off>\" line.\n",
1691 Debug( LDAP_DEBUG_ANY,
1692 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1698 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1700 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1701 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1704 Debug( LDAP_DEBUG_ANY,
1705 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1708 global_schemacheck = 0;
1710 global_schemacheck = 1;
1713 /* specify access control info */
1714 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1715 parse_acl( be, fname, lineno, cargc, cargv );
1717 /* debug level to log things to syslog */
1718 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1721 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1722 "%s: line %d: missing level in \"loglevel <level>\""
1723 " line.\n", fname, lineno ));
1725 Debug( LDAP_DEBUG_ANY,
1726 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1735 for( i=1; i < cargc; i++ ) {
1736 ldap_syslog += atoi( cargv[1] );
1739 /* list of replicas of the data in this backend (master only) */
1740 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1743 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1744 "%s: line %d: missing host in \"replica "
1745 " <host[:port]\" line\n", fname, lineno ));
1747 Debug( LDAP_DEBUG_ANY,
1748 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1756 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1757 "%s: line %d: replica line must appear inside "
1758 "a database definition (ignored).\n", fname, lineno ));
1760 Debug( LDAP_DEBUG_ANY,
1761 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1768 for ( i = 1; i < cargc; i++ ) {
1769 if ( strncasecmp( cargv[i], "host=", 5 )
1771 nr = add_replica_info( be,
1778 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1779 "%s: line %d: missing host in \"replica\" "
1780 "line (ignored)\n", fname, lineno ));
1782 Debug( LDAP_DEBUG_ANY,
1783 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1787 } else if ( nr == -1 ) {
1789 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1790 "%s: line %d: unable to add"
1796 Debug( LDAP_DEBUG_ANY,
1797 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1798 fname, lineno, cargv[i] + 5 );
1801 for ( i = 1; i < cargc; i++ ) {
1802 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1804 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1807 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1808 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1809 fname, lineno, cargv[i] + 7 ));
1811 Debug( LDAP_DEBUG_ANY,
1812 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1813 fname, lineno, cargv[i] + 7 );
1819 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1820 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1823 Debug( LDAP_DEBUG_ANY,
1824 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1830 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1832 char *arg = cargv[i] + 4;
1834 if ( arg[0] == '!' ) {
1839 if ( arg[0] != '=' ) {
1843 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1845 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1846 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1847 fname, lineno, arg + 1 ));
1849 Debug( LDAP_DEBUG_ANY,
1850 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1851 fname, lineno, arg + 1 );
1860 /* dn of master entity allowed to write to replica */
1861 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1864 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1865 "%s: line %d: missing dn in \"updatedn <dn>\""
1866 " line.\n", fname, lineno ));
1868 Debug( LDAP_DEBUG_ANY,
1869 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1877 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1878 "%s: line %d: updatedn line must appear inside "
1879 "a database definition (ignored)\n",
1882 Debug( LDAP_DEBUG_ANY,
1883 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1890 if ( load_ucdata( NULL ) < 0 ) return 1;
1892 dn.bv_val = cargv[1];
1893 dn.bv_len = strlen( cargv[1] );
1895 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1896 if( rc != LDAP_SUCCESS ) {
1898 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1899 "%s: line %d: updatedn DN is invalid.\n",
1902 Debug( LDAP_DEBUG_ANY,
1903 "%s: line %d: updatedn DN is invalid\n",
1910 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1913 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1914 "missing url in \"updateref <ldapurl>\" line.\n",
1917 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1918 "missing url in \"updateref <ldapurl>\" line\n",
1926 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1927 " line must appear inside a database definition\n",
1930 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1931 " line must appear inside a database definition\n",
1936 } else if ( !be->be_update_ndn.bv_len ) {
1938 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1939 "updateref line must come after updatedn.\n",
1942 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1943 "updateref line must after updatedn.\n",
1949 if( validate_global_referral( cargv[1] ) ) {
1951 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1952 "invalid URL (%s) in \"updateref\" line.\n",
1953 fname, lineno, cargv[1] ));
1955 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1956 "invalid URL (%s) in \"updateref\" line.\n",
1957 fname, lineno, cargv[1] );
1962 vals[0].bv_val = cargv[1];
1963 vals[0].bv_len = strlen( vals[0].bv_val );
1964 value_add( &be->be_update_refs, vals );
1966 /* replication log file to which changes are appended */
1967 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1970 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1971 "%s: line %d: missing filename in \"replogfile <filename>\""
1972 " line.\n", fname, lineno ));
1974 Debug( LDAP_DEBUG_ANY,
1975 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1982 be->be_replogfile = ch_strdup( cargv[1] );
1984 replogfile = ch_strdup( cargv[1] );
1987 /* file from which to read additional rootdse attrs */
1988 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1991 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1992 "missing filename in \"rootDSE <filename>\" line.\n",
1995 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1996 "missing filename in \"rootDSE <filename>\" line.\n",
2002 if( read_root_dse_file( cargv[1] ) ) {
2004 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2005 "could not read \"rootDSE <filename>\" line.\n",
2008 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2009 "could not read \"rootDSE <filename>\" line\n",
2015 /* maintain lastmodified{by,time} attributes */
2016 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2019 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2020 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2021 " line.\n", fname, lineno ));
2023 Debug( LDAP_DEBUG_ANY,
2024 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2030 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2032 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2038 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2044 /* set idle timeout value */
2045 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2049 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2050 "%s: line %d: missing timeout value in "
2051 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2053 Debug( LDAP_DEBUG_ANY,
2054 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2061 i = atoi( cargv[1] );
2065 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2066 "%s: line %d: timeout value (%d) invalid "
2067 "\"idletimeout <seconds>\" line.\n",
2068 fname, lineno, i ));
2070 Debug( LDAP_DEBUG_ANY,
2071 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2078 global_idletimeout = i;
2080 /* include another config file */
2081 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2084 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2085 "%s: line %d: missing filename in \"include "
2086 "<filename>\" line.\n", fname, lineno ));
2088 Debug( LDAP_DEBUG_ANY,
2089 "%s: line %d: missing filename in \"include <filename>\" line\n",
2095 savefname = ch_strdup( cargv[1] );
2096 savelineno = lineno;
2098 if ( read_config( savefname ) != 0 ) {
2103 lineno = savelineno - 1;
2105 /* location of kerberos srvtab file */
2106 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2109 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2110 "%s: line %d: missing filename in \"srvtab "
2111 "<filename>\" line.\n", fname, lineno ));
2113 Debug( LDAP_DEBUG_ANY,
2114 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2120 ldap_srvtab = ch_strdup( cargv[1] );
2122 #ifdef SLAPD_MODULES
2123 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2126 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2127 "%s: line %d: missing filename in \"moduleload "
2128 "<filename>\" line.\n", fname, lineno ));
2130 Debug( LDAP_DEBUG_ANY,
2131 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2135 exit( EXIT_FAILURE );
2137 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2139 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2140 "%s: line %d: failed to load or initialize module %s\n",
2141 fname, lineno, cargv[1] ));
2143 Debug( LDAP_DEBUG_ANY,
2144 "%s: line %d: failed to load or initialize module %s\n",
2145 fname, lineno, cargv[1]);
2148 exit( EXIT_FAILURE );
2150 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2153 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2154 "%s: line %d: missing path in \"modulepath <path>\""
2155 " line\n", fname, lineno ));
2157 Debug( LDAP_DEBUG_ANY,
2158 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2162 exit( EXIT_FAILURE );
2164 if (module_path( cargv[1] )) {
2166 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2167 "%s: line %d: failed to set module search path to %s.\n",
2168 fname, lineno, cargv[1] ));
2170 Debug( LDAP_DEBUG_ANY,
2171 "%s: line %d: failed to set module search path to %s\n",
2172 fname, lineno, cargv[1]);
2175 exit( EXIT_FAILURE );
2178 #endif /*SLAPD_MODULES*/
2181 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2182 rc = ldap_pvt_tls_set_option( NULL,
2183 LDAP_OPT_X_TLS_RANDOM_FILE,
2188 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2189 rc = ldap_pvt_tls_set_option( NULL,
2190 LDAP_OPT_X_TLS_CIPHER_SUITE,
2195 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2196 rc = ldap_pvt_tls_set_option( NULL,
2197 LDAP_OPT_X_TLS_CERTFILE,
2202 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2203 rc = ldap_pvt_tls_set_option( NULL,
2204 LDAP_OPT_X_TLS_KEYFILE,
2209 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2210 rc = ldap_pvt_tls_set_option( NULL,
2211 LDAP_OPT_X_TLS_CACERTDIR,
2216 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2217 rc = ldap_pvt_tls_set_option( NULL,
2218 LDAP_OPT_X_TLS_CACERTFILE,
2222 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2223 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2225 rc = ldap_pvt_tls_set_option( NULL,
2226 LDAP_OPT_X_TLS_REQUIRE_CERT,
2229 rc = ldap_int_tls_config( NULL,
2230 LDAP_OPT_X_TLS_REQUIRE_CERT,
2239 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2240 #ifdef SLAPD_RLOOKUPS
2243 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2244 "%s: line %d: reverse-lookup: "
2245 "missing \"on\" or \"off\"\n",
2248 Debug( LDAP_DEBUG_ANY,
2249 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2255 if ( !strcasecmp( cargv[1], "on" ) ) {
2256 use_reverse_lookup = 1;
2257 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2258 use_reverse_lookup = 0;
2261 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2262 "%s: line %d: reverse-lookup: "
2263 "must be \"on\" (default) "
2267 Debug( LDAP_DEBUG_ANY,
2268 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2274 #else /* !SLAPD_RLOOKUPS */
2276 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2277 "%s: line %d: reverse lookups "
2278 "are not configured (ignored).\n",
2281 Debug( LDAP_DEBUG_ANY,
2282 "%s: line %d: reverse lookups are not configured (ignored).\n",
2285 #endif /* !SLAPD_RLOOKUPS */
2287 /* pass anything else to the current backend info/db config routine */
2290 if ( bi->bi_config == 0 ) {
2292 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2293 "%s: line %d: unknown directive \"%s\" inside "
2294 "backend info definition (ignored).\n",
2295 fname, lineno, cargv[0] ));
2297 Debug( LDAP_DEBUG_ANY,
2298 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2299 fname, lineno, cargv[0] );
2303 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2309 } else if ( be != NULL ) {
2310 if ( be->be_config == 0 ) {
2312 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2313 "%s: line %d: uknown directive \"%s\" inside "
2314 "backend database definition (ignored).\n",
2315 fname, lineno, cargv[0] ));
2317 Debug( LDAP_DEBUG_ANY,
2318 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2319 fname, lineno, cargv[0] );
2323 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2331 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2332 "%s: line %d: unknown directive \"%s\" outside backend "
2333 "info and database definitions (ignored).\n",
2334 fname, lineno, cargv[0] ));
2336 Debug( LDAP_DEBUG_ANY,
2337 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2338 fname, lineno, cargv[0] );
2347 if ( load_ucdata( NULL ) < 0 ) return 1;
2361 char logbuf[sizeof("pseudorootpw ***")];
2364 token = strtok_quote( line, " \t" );
2368 (strcasecmp( token, "rootpw" ) == 0 ||
2369 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2370 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2371 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2372 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2373 sprintf( logline = logbuf, "%s ***", token );
2374 if ( strtok_quote_ptr )
2375 *strtok_quote_ptr = ' ';
2377 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2378 "line %d (%s)\n", lineno, logline ));
2380 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2382 if ( strtok_quote_ptr )
2383 *strtok_quote_ptr = '\0';
2385 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2386 if ( *argcp == MAXARGS ) {
2388 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2389 "fp_parse_line: too many tokens (%d max).\n",
2392 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2398 argv[(*argcp)++] = token;
2400 argv[*argcp] = NULL;
2405 strtok_quote( char *line, char *sep )
2411 strtok_quote_ptr = NULL;
2412 if ( line != NULL ) {
2415 while ( *next && strchr( sep, *next ) ) {
2419 if ( *next == '\0' ) {
2425 for ( inquote = 0; *next; ) {
2433 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2439 next + 1, strlen( next + 1 ) + 1 );
2440 next++; /* dont parse the escaped character */
2445 if ( strchr( sep, *next ) != NULL ) {
2446 strtok_quote_ptr = next;
2459 static char buf[BUFSIZ];
2461 static int lmax, lcur;
2463 #define CATLINE( buf ) { \
2465 len = strlen( buf ); \
2466 while ( lcur + len + 1 > lmax ) { \
2468 line = (char *) ch_realloc( line, lmax ); \
2470 strcpy( line + lcur, buf ); \
2475 fp_getline( FILE *fp, int *lineno )
2483 /* hack attack - keeps us from having to keep a stack of bufs... */
2484 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2489 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2490 /* trim off \r\n or \n */
2491 if ( (p = strchr( buf, '\n' )) != NULL ) {
2492 if( p > buf && p[-1] == '\r' ) --p;
2496 /* trim off trailing \ and append the next line */
2497 if ( line[ 0 ] != '\0'
2498 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2499 && p[ -1 ] != '\\' ) {
2504 if ( ! isspace( (unsigned char) buf[0] ) ) {
2508 /* change leading whitespace to a space */
2517 return( line[0] ? line : NULL );
2521 fp_getline_init( int *lineno )
2527 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2529 load_ucdata( char *path )
2531 static int loaded = 0;
2537 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2540 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2541 "load_ucdata: Error %d loading ucdata.\n", err ));
2543 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2556 ucdata_unload( UCDATA_ALL );
2558 if ( slapd_args_file )
2559 free ( slapd_args_file );
2560 if ( slapd_pid_file )
2561 free ( slapd_pid_file );
2562 acl_destroy( global_acl, NULL );