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 int cargc = 0, cargv_size = 0;
50 struct berval default_search_base = { 0, NULL };
51 struct berval default_search_nbase = { 0, NULL };
52 unsigned num_subordinates = 0;
54 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
55 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
57 char *slapd_pid_file = NULL;
58 char *slapd_args_file = NULL;
60 char *strtok_quote_ptr;
63 SaslRegexp_t *SaslRegexp = NULL;
66 int use_reverse_lookup = 1;
67 #else /* !SLAPD_RLOOKUPS */
68 int use_reverse_lookup = 0;
69 #endif /* !SLAPD_RLOOKUPS */
71 static char *fp_getline(FILE *fp, int *lineno);
72 static void fp_getline_init(int *lineno);
73 static int fp_parse_line(int lineno, char *line);
75 static char *strtok_quote(char *line, char *sep);
76 static int load_ucdata(char *path);
79 read_config( const char *fname )
82 char *line, *savefname, *saveline;
86 struct berval vals[2];
88 static int lastmod = 1;
89 static BackendInfo *bi = NULL;
90 static BackendDB *be = NULL;
92 vals[1].bv_val = NULL;
94 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
95 cargv_size = ARGS_STEP + 1;
97 if ( (fp = fopen( fname, "r" )) == NULL ) {
100 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
101 "could not open config file \"%s\": %s (%d)\n",
102 fname, strerror(errno), errno ));
104 Debug( LDAP_DEBUG_ANY,
105 "could not open config file \"%s\": %s (%d)\n",
106 fname, strerror(errno), errno );
112 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
113 "read_config: reading config file %s\n", fname ));
115 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
119 fp_getline_init( &lineno );
121 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
122 /* skip comments and blank lines */
123 if ( line[0] == '#' || line[0] == '\0' ) {
127 /* fp_parse_line is destructive, we save a copy */
128 saveline = ch_strdup( line );
130 if ( fp_parse_line( lineno, line ) != 0 ) {
136 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
137 "%s: line %d: bad config line (ignored)\n",
140 Debug( LDAP_DEBUG_ANY,
141 "%s: line %d: bad config line (ignored)\n",
148 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
151 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
152 "%s : line %d: missing type in \"backend\" line.\n",
155 Debug( LDAP_DEBUG_ANY,
156 "%s: line %d: missing type in \"backend <type>\" line\n",
165 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
166 "%s: line %d: backend line must appear before any "
167 "database definition.\n", fname, lineno ));
169 Debug( LDAP_DEBUG_ANY,
170 "%s: line %d: backend line must appear before any database definition\n",
177 bi = backend_info( cargv[1] );
181 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
182 "read_config: backend %s initialization failed.\n",
185 Debug( LDAP_DEBUG_ANY,
186 "backend %s initialization failed.\n",
192 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
195 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
196 "%s: line %d: missing type in \"database <type>\" line\n",
199 Debug( LDAP_DEBUG_ANY,
200 "%s: line %d: missing type in \"database <type>\" line\n",
208 be = backend_db_init( cargv[1] );
212 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
213 "database %s initialization failed.\n",
216 Debug( LDAP_DEBUG_ANY,
217 "database %s initialization failed.\n",
224 /* set thread concurrency */
225 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
229 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
230 "%s: line %d: missing level in \"concurrency <level\" line\n",
233 Debug( LDAP_DEBUG_ANY,
234 "%s: line %d: missing level in \"concurrency <level>\" line\n",
241 c = atoi( cargv[1] );
245 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
246 "%s: line %d: invalid level (%d) in "
247 "\"concurrency <level>\" line.\n",
250 Debug( LDAP_DEBUG_ANY,
251 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
258 ldap_pvt_thread_set_concurrency( c );
260 /* set sockbuf max */
261 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
265 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
266 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
269 Debug( LDAP_DEBUG_ANY,
270 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
277 max = atol( cargv[1] );
281 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
282 "%s: line %d: invalid max value (%ld) in "
283 "\"sockbuf_max_incoming <bytes>\" line.\n",
284 fname, lineno, max ));
286 Debug( LDAP_DEBUG_ANY,
287 "%s: line %d: invalid max value (%ld) in "
288 "\"sockbuf_max_incoming <bytes>\" line.\n",
289 fname, lineno, max );
295 sockbuf_max_incoming = max;
297 /* set sockbuf max authenticated */
298 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
302 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
303 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
306 Debug( LDAP_DEBUG_ANY,
307 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
314 max = atol( cargv[1] );
318 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
319 "%s: line %d: invalid max value (%ld) in "
320 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
321 fname, lineno, max ));
323 Debug( LDAP_DEBUG_ANY,
324 "%s: line %d: invalid max value (%ld) in "
325 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
326 fname, lineno, max );
332 sockbuf_max_incoming_auth = max;
334 /* default search base */
335 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
338 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
339 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
340 "line\n", fname, lineno ));
342 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
343 "missing dn in \"defaultSearchBase <dn>\" line\n",
349 } else if ( cargc > 2 ) {
351 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
352 "%s: line %d: extra cruft after <dn> in "
353 "\"defaultSearchBase %s\" line (ignored)\n",
354 fname, lineno, cargv[1] ));
356 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
357 "extra cruft after <dn> in \"defaultSearchBase %s\", "
359 fname, lineno, cargv[1] );
363 if ( bi != NULL || be != NULL ) {
365 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
366 "%s: line %d: defaultSearchBase line must appear "
367 "prior to any backend or database definitions\n",
370 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
371 "defaultSearchBaase line must appear prior to "
372 "any backend or database definition\n",
379 if ( default_search_nbase.bv_len ) {
381 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
382 "default search base \"%s\" already defined "
383 "(discarding old)\n", fname, lineno,
384 default_search_base.bv_val ));
386 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
387 "default search base \"%s\" already defined "
388 "(discarding old)\n",
389 fname, lineno, default_search_base.bv_val );
392 free( default_search_base.bv_val );
393 free( default_search_nbase.bv_val );
396 if ( load_ucdata( NULL ) < 0 ) return 1;
401 dn.bv_val = cargv[1];
402 dn.bv_len = strlen( dn.bv_val );
404 rc = dnPrettyNormal( NULL, &dn,
405 &default_search_base,
406 &default_search_nbase );
408 if( rc != LDAP_SUCCESS ) {
410 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
411 "%s: line %d: defaultSearchBase DN is invalid.\n",
414 Debug( LDAP_DEBUG_ANY,
415 "%s: line %d: defaultSearchBase DN is invalid\n",
422 /* set maximum threads in thread pool */
423 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
427 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
428 "%s: line %d: missing count in \"threads <count>\" line\n",
431 Debug( LDAP_DEBUG_ANY,
432 "%s: line %d: missing count in \"threads <count>\" line\n",
439 c = atoi( cargv[1] );
443 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
444 "%s: line %d: invalid level (%d) in \"threads <count>\""
445 "line\n",fname, lineno, c ));
447 Debug( LDAP_DEBUG_ANY,
448 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
455 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
457 /* save for later use */
458 connection_pool_max = c;
460 /* get pid file name */
461 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
464 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
465 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
468 Debug( LDAP_DEBUG_ANY,
469 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
476 slapd_pid_file = ch_strdup( cargv[1] );
478 /* get args file name */
479 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
482 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
483 "%s: %d: missing file name in "
484 "\"argsfile <file>\" line.\n",
487 Debug( LDAP_DEBUG_ANY,
488 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
495 slapd_args_file = ch_strdup( cargv[1] );
497 /* default password hash */
498 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
501 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
502 "%s: line %d: missing hash in "
503 "\"password-hash <hash>\" line.\n",
506 Debug( LDAP_DEBUG_ANY,
507 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
513 if ( default_passwd_hash != NULL ) {
515 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
516 "%s: line %d: already set default password_hash!\n",
519 Debug( LDAP_DEBUG_ANY,
520 "%s: line %d: already set default password_hash!\n",
528 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
530 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
531 "%s: line %d: password scheme \"%s\" not available\n",
532 fname, lineno, cargv[1] ));
534 Debug( LDAP_DEBUG_ANY,
535 "%s: line %d: password scheme \"%s\" not available\n",
536 fname, lineno, cargv[1] );
541 default_passwd_hash = ch_strdup( cargv[1] );
543 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
547 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
548 "%s: line %d: missing format in "
549 "\"password-crypt-salt-format <format>\" line\n",
552 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
553 "\"password-crypt-salt-format <format>\" line\n",
560 lutil_salt_format( cargv[1] );
563 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
566 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
567 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
570 Debug( LDAP_DEBUG_ANY,
571 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
578 if ( global_host != NULL ) {
580 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
581 "%s: line %d: already set sasl-host!\n",
584 Debug( LDAP_DEBUG_ANY,
585 "%s: line %d: already set sasl-host!\n",
592 global_host = ch_strdup( cargv[1] );
596 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
599 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
600 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
603 Debug( LDAP_DEBUG_ANY,
604 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
611 if ( global_realm != NULL ) {
613 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
614 "%s: line %d: already set sasl-realm!\n",
617 Debug( LDAP_DEBUG_ANY,
618 "%s: line %d: already set sasl-realm!\n",
625 global_realm = ch_strdup( cargv[1] );
628 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
629 || !strcasecmp( cargv[0], "saslregexp" ) )
634 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
635 "%s: line %d: need 2 args in "
636 "\"saslregexp <match> <replace>\"\n",
639 Debug( LDAP_DEBUG_ANY,
640 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
646 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
651 /* SASL security properties */
652 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
657 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
658 "%s: line %d: missing flags in "
659 "\"sasl-secprops <properties>\" line\n",
662 Debug( LDAP_DEBUG_ANY,
663 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
670 txt = slap_sasl_secprops( cargv[1] );
673 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
674 "%s: line %d sas-secprops: %s\n",
675 fname, lineno, txt ));
677 Debug( LDAP_DEBUG_ANY,
678 "%s: line %d: sasl-secprops: %s\n",
679 fname, lineno, txt );
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 ) {
865 struct berval dn, pdn, ndn;
869 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
870 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
873 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
874 "missing dn in \"suffix <dn>\" line\n",
880 } else if ( cargc > 2 ) {
882 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
883 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
884 " line (ignored).\n", fname, lineno, cargv[1] ));
886 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
887 "after <dn> in \"suffix %s\" line (ignored)\n",
888 fname, lineno, cargv[1] );
894 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
895 "%s: line %d: suffix line must appear inside a database "
896 "definition.\n", fname, lineno ));
898 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
899 "must appear inside a database definition\n",
904 #if defined(SLAPD_MONITOR_DN)
905 /* "cn=Monitor" is reserved for monitoring slap */
906 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
908 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
909 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
912 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
913 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
917 #endif /* SLAPD_MONITOR_DN */
920 if ( load_ucdata( NULL ) < 0 ) return 1;
922 dn.bv_val = cargv[1];
923 dn.bv_len = strlen( cargv[1] );
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_bvarray_add( &be->be_suffix, &pdn );
983 ber_bvarray_add( &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] );
1050 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
1051 if( rc != LDAP_SUCCESS ) {
1053 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1054 "%s: line %d: alias DN is invalid.\n",
1057 Debug( LDAP_DEBUG_ANY,
1058 "%s: line %d: alias DN is invalid\n",
1064 tmp_be = select_backend( &nalias, 0, 0 );
1065 free( nalias.bv_val );
1066 if ( tmp_be && tmp_be != be ) {
1068 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1069 "%s: line %d: suffixAlias served by a preceeding "
1071 fname, lineno, tmp_be->be_suffix[0].bv_val ));
1073 Debug( LDAP_DEBUG_ANY,
1074 "%s: line %d: suffixAlias served by"
1075 " a preceeding backend \"%s\"\n",
1076 fname, lineno, tmp_be->be_suffix[0].bv_val );
1078 free( palias.bv_val );
1082 aliased.bv_val = cargv[2];
1083 aliased.bv_len = strlen( cargv[2] );
1085 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
1086 if( rc != LDAP_SUCCESS ) {
1088 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1089 "%s: line %d: aliased DN is invalid.\n",
1092 Debug( LDAP_DEBUG_ANY,
1093 "%s: line %d: aliased DN is invalid\n",
1096 free( palias.bv_val );
1100 tmp_be = select_backend( &naliased, 0, 0 );
1101 free( naliased.bv_val );
1102 if ( tmp_be && tmp_be != be ) {
1104 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1105 "%s: line %d: suffixAlias derefs to a different backend "
1106 "a preceeding backend \"%s\"\n",
1107 fname, lineno, tmp_be->be_suffix[0].bv_val ));
1109 Debug( LDAP_DEBUG_ANY,
1110 "%s: line %d: suffixAlias derefs to differnet backend"
1111 " a preceeding backend \"%s\"\n",
1112 fname, lineno, tmp_be->be_suffix[0].bv_val );
1114 free( palias.bv_val );
1115 free( paliased.bv_val );
1119 ber_bvarray_add( &be->be_suffixAlias, &palias );
1120 ber_bvarray_add( &be->be_suffixAlias, &paliased );
1122 /* set max deref depth */
1123 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1127 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1128 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1129 " line\n", fname, lineno ));
1131 Debug( LDAP_DEBUG_ANY,
1132 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1140 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1141 "%s: line %d: depth line must appear inside a database "
1142 "definition (ignored)\n", fname, lineno ));
1144 Debug( LDAP_DEBUG_ANY,
1145 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1149 } else if ((i = atoi(cargv[1])) < 0) {
1151 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1152 "%s: line %d: depth must be positive (ignored).\n",
1155 Debug( LDAP_DEBUG_ANY,
1156 "%s: line %d: depth must be positive (ignored)\n",
1162 be->be_max_deref_depth = i;
1166 /* set magic "root" dn for this database */
1167 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1170 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1171 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1174 Debug( LDAP_DEBUG_ANY,
1175 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1183 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1184 "%s: line %d: rootdn line must appear inside a database "
1185 "definition (ignored).\n", fname, lineno ));
1187 Debug( LDAP_DEBUG_ANY,
1188 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1195 if ( load_ucdata( NULL ) < 0 ) return 1;
1197 dn.bv_val = cargv[1];
1198 dn.bv_len = strlen( cargv[1] );
1200 rc = dnPrettyNormal( NULL, &dn,
1204 if( rc != LDAP_SUCCESS ) {
1206 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1207 "%s: line %d: rootdn DN is invalid.\n",
1210 Debug( LDAP_DEBUG_ANY,
1211 "%s: line %d: rootdn DN is invalid\n",
1218 /* set super-secret magic database password */
1219 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1222 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1223 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1224 " line\n", fname, lineno ));
1226 Debug( LDAP_DEBUG_ANY,
1227 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1235 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1236 "%s: line %d: rootpw line must appear inside a database "
1237 "definition (ignored)\n", fname, lineno ));
1239 Debug( LDAP_DEBUG_ANY,
1240 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1245 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1246 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1249 /* make this database read-only */
1250 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1253 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1254 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1257 Debug( LDAP_DEBUG_ANY,
1258 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1265 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1266 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1268 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1271 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1272 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1274 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1279 /* allow these features */
1280 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1281 strcasecmp( cargv[0], "allow" ) == 0 )
1287 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1288 "%s: line %d: allow line must appear prior to "
1289 "database definitions.\n", fname, lineno ));
1291 Debug( LDAP_DEBUG_ANY,
1292 "%s: line %d: allow line must appear prior to database definitions\n",
1300 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1301 "%s: line %d: missing feature(s) in \"allow <features>\""
1302 " line\n", fname, lineno ));
1304 Debug( LDAP_DEBUG_ANY,
1305 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1314 for( i=1; i < cargc; i++ ) {
1315 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1316 allows |= SLAP_ALLOW_BIND_V2;
1318 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1319 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1321 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1322 allows |= SLAP_ALLOW_BIND_ANON_DN;
1324 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1326 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1327 "%s: line %d: unknown feature %s in "
1328 "\"allow <features>\" line.\n",
1329 fname, lineno, cargv[1] ));
1331 Debug( LDAP_DEBUG_ANY,
1332 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1333 fname, lineno, cargv[i] );
1340 global_allows = allows;
1342 /* disallow these features */
1343 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1344 strcasecmp( cargv[0], "disallow" ) == 0 )
1346 slap_mask_t disallows;
1350 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1351 "%s: line %d: disallow line must appear prior to "
1352 "database definitions.\n", fname, lineno ));
1354 Debug( LDAP_DEBUG_ANY,
1355 "%s: line %d: disallow line must appear prior to database definitions\n",
1363 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1364 "%s: line %d: missing feature(s) in \"disallow <features>\""
1365 " line.\n", fname, lineno ));
1367 Debug( LDAP_DEBUG_ANY,
1368 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1377 for( i=1; i < cargc; i++ ) {
1378 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1379 disallows |= SLAP_DISALLOW_BIND_ANON;
1381 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1382 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1384 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1385 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1387 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1388 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1390 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1391 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1393 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1395 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1396 "%s: line %d: unknown feature %s in "
1397 "\"disallow <features>\" line.\n",
1398 fname, lineno, cargv[i] ));
1400 Debug( LDAP_DEBUG_ANY,
1401 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1402 fname, lineno, cargv[i] );
1409 global_disallows = disallows;
1411 /* require these features */
1412 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1413 strcasecmp( cargv[0], "require" ) == 0 )
1415 slap_mask_t requires;
1419 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1420 "%s: line %d: missing feature(s) in "
1421 "\"require <features>\" line.\n", fname, lineno ));
1423 Debug( LDAP_DEBUG_ANY,
1424 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1433 for( i=1; i < cargc; i++ ) {
1434 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1435 requires |= SLAP_REQUIRE_BIND;
1437 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1438 requires |= SLAP_REQUIRE_LDAP_V3;
1440 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1441 requires |= SLAP_REQUIRE_AUTHC;
1443 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1444 requires |= SLAP_REQUIRE_SASL;
1446 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1447 requires |= SLAP_REQUIRE_STRONG;
1449 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1451 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1452 "%s: line %d: unknown feature %s in "
1453 "\"require <features>\" line.\n",
1456 Debug( LDAP_DEBUG_ANY,
1457 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1458 fname, lineno, cargv[i] );
1466 global_requires = requires;
1468 be->be_requires = requires;
1471 /* required security factors */
1472 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1473 slap_ssf_set_t *set;
1477 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1478 "%s: line %d: missing factor(s) in \"security <factors>\""
1479 " line.\n", fname, lineno ));
1481 Debug( LDAP_DEBUG_ANY,
1482 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1490 set = &global_ssf_set;
1492 set = &be->be_ssf_set;
1495 for( i=1; i < cargc; i++ ) {
1496 if( strncasecmp( cargv[i], "ssf=",
1497 sizeof("ssf") ) == 0 )
1500 atoi( &cargv[i][sizeof("ssf")] );
1502 } else if( strncasecmp( cargv[i], "transport=",
1503 sizeof("transport") ) == 0 )
1505 set->sss_transport =
1506 atoi( &cargv[i][sizeof("transport")] );
1508 } else if( strncasecmp( cargv[i], "tls=",
1509 sizeof("tls") ) == 0 )
1512 atoi( &cargv[i][sizeof("tls")] );
1514 } else if( strncasecmp( cargv[i], "sasl=",
1515 sizeof("sasl") ) == 0 )
1518 atoi( &cargv[i][sizeof("sasl")] );
1520 } else if( strncasecmp( cargv[i], "update_ssf=",
1521 sizeof("update_ssf") ) == 0 )
1523 set->sss_update_ssf =
1524 atoi( &cargv[i][sizeof("update_ssf")] );
1526 } else if( strncasecmp( cargv[i], "update_transport=",
1527 sizeof("update_transport") ) == 0 )
1529 set->sss_update_transport =
1530 atoi( &cargv[i][sizeof("update_transport")] );
1532 } else if( strncasecmp( cargv[i], "update_tls=",
1533 sizeof("update_tls") ) == 0 )
1535 set->sss_update_tls =
1536 atoi( &cargv[i][sizeof("update_tls")] );
1538 } else if( strncasecmp( cargv[i], "update_sasl=",
1539 sizeof("update_sasl") ) == 0 )
1541 set->sss_update_sasl =
1542 atoi( &cargv[i][sizeof("update_sasl")] );
1546 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1547 "%s: line %d: unknown factor %S in "
1548 "\"security <factors>\" line.\n",
1549 fname, lineno, cargv[1] ));
1551 Debug( LDAP_DEBUG_ANY,
1552 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1553 fname, lineno, cargv[i] );
1559 /* where to send clients when we don't hold it */
1560 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1563 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1564 "%s: line %d: missing URL in \"referral <URL>\""
1565 " line.\n", fname, lineno ));
1567 Debug( LDAP_DEBUG_ANY,
1568 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1575 if( validate_global_referral( cargv[1] ) ) {
1577 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1578 "invalid URL (%s) in \"referral\" line.\n",
1579 fname, lineno, cargv[1] ));
1581 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1582 "invalid URL (%s) in \"referral\" line.\n",
1583 fname, lineno, cargv[1] );
1588 vals[0].bv_val = cargv[1];
1589 vals[0].bv_len = strlen( vals[0].bv_val );
1590 value_add( &default_referral, vals );
1593 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1597 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1598 "%s: line %d: Error in logfile directive, "
1599 "\"logfile <filename>\"\n", fname, lineno ));
1601 Debug( LDAP_DEBUG_ANY,
1602 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1608 logfile = fopen( cargv[1], "w" );
1609 if ( logfile != NULL ) lutil_debug_file( logfile );
1612 /* start of a new database definition */
1613 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1617 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1618 "%s: line %d: Error in debug directive, "
1619 "\"debug <subsys> <level>\"\n", fname, lineno ));
1621 Debug( LDAP_DEBUG_ANY,
1622 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1628 level = atoi( cargv[2] );
1629 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1630 lutil_set_debug_level( cargv[1], level );
1631 /* specify an Object Identifier macro */
1632 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1633 rc = parse_oidm( fname, lineno, cargc, cargv );
1636 /* specify an objectclass */
1637 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1638 if ( *cargv[1] == '(' ) {
1640 p = strchr(saveline,'(');
1641 rc = parse_oc( fname, lineno, p, cargv );
1646 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1647 "%s: line %d: old objectclass format not supported\n",
1650 Debug( LDAP_DEBUG_ANY,
1651 "%s: line %d: old objectclass format not supported.\n",
1657 /* specify an attribute type */
1658 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1659 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1661 if ( *cargv[1] == '(' ) {
1663 p = strchr(saveline,'(');
1664 rc = parse_at( fname, lineno, p, cargv );
1669 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1670 "%s: line %d: old attribute type format not supported.\n",
1673 Debug( LDAP_DEBUG_ANY,
1674 "%s: line %d: old attribute type format not supported.\n",
1680 /* turn on/off schema checking */
1681 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1684 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1685 "%s: line %d: missing on|off in "
1686 "\"schemacheck <on|off>\" line.\n",
1689 Debug( LDAP_DEBUG_ANY,
1690 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1696 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1698 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1699 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1702 Debug( LDAP_DEBUG_ANY,
1703 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1706 global_schemacheck = 0;
1708 global_schemacheck = 1;
1711 /* specify access control info */
1712 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1713 parse_acl( be, fname, lineno, cargc, cargv );
1715 /* debug level to log things to syslog */
1716 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1719 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1720 "%s: line %d: missing level in \"loglevel <level>\""
1721 " line.\n", fname, lineno ));
1723 Debug( LDAP_DEBUG_ANY,
1724 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1733 for( i=1; i < cargc; i++ ) {
1734 ldap_syslog += atoi( cargv[1] );
1737 /* list of replicas of the data in this backend (master only) */
1738 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1741 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1742 "%s: line %d: missing host in \"replica "
1743 " <host[:port]\" line\n", fname, lineno ));
1745 Debug( LDAP_DEBUG_ANY,
1746 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1754 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1755 "%s: line %d: replica line must appear inside "
1756 "a database definition (ignored).\n", fname, lineno ));
1758 Debug( LDAP_DEBUG_ANY,
1759 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1766 for ( i = 1; i < cargc; i++ ) {
1767 if ( strncasecmp( cargv[i], "host=", 5 )
1769 nr = add_replica_info( be,
1776 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1777 "%s: line %d: missing host in \"replica\" "
1778 "line (ignored)\n", fname, lineno ));
1780 Debug( LDAP_DEBUG_ANY,
1781 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1785 } else if ( nr == -1 ) {
1787 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1788 "%s: line %d: unable to add"
1794 Debug( LDAP_DEBUG_ANY,
1795 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1796 fname, lineno, cargv[i] + 5 );
1799 for ( i = 1; i < cargc; i++ ) {
1800 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1802 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1805 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1806 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1807 fname, lineno, cargv[i] + 7 ));
1809 Debug( LDAP_DEBUG_ANY,
1810 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1811 fname, lineno, cargv[i] + 7 );
1817 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1818 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1821 Debug( LDAP_DEBUG_ANY,
1822 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1828 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1830 char *arg = cargv[i] + 4;
1832 if ( arg[0] == '!' ) {
1837 if ( arg[0] != '=' ) {
1841 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1843 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1844 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1845 fname, lineno, arg + 1 ));
1847 Debug( LDAP_DEBUG_ANY,
1848 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1849 fname, lineno, arg + 1 );
1858 /* dn of master entity allowed to write to replica */
1859 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1862 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1863 "%s: line %d: missing dn in \"updatedn <dn>\""
1864 " line.\n", fname, lineno ));
1866 Debug( LDAP_DEBUG_ANY,
1867 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1875 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1876 "%s: line %d: updatedn line must appear inside "
1877 "a database definition (ignored)\n",
1880 Debug( LDAP_DEBUG_ANY,
1881 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1888 if ( load_ucdata( NULL ) < 0 ) return 1;
1890 dn.bv_val = cargv[1];
1891 dn.bv_len = strlen( cargv[1] );
1893 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1894 if( rc != LDAP_SUCCESS ) {
1896 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1897 "%s: line %d: updatedn DN is invalid.\n",
1900 Debug( LDAP_DEBUG_ANY,
1901 "%s: line %d: updatedn DN is invalid\n",
1908 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1911 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1912 "missing url in \"updateref <ldapurl>\" line.\n",
1915 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1916 "missing url in \"updateref <ldapurl>\" line\n",
1924 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1925 " line must appear inside a database definition\n",
1928 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1929 " line must appear inside a database definition\n",
1934 } else if ( !be->be_update_ndn.bv_len ) {
1936 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1937 "updateref line must come after updatedn.\n",
1940 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1941 "updateref line must after updatedn.\n",
1947 if( validate_global_referral( cargv[1] ) ) {
1949 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1950 "invalid URL (%s) in \"updateref\" line.\n",
1951 fname, lineno, cargv[1] ));
1953 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1954 "invalid URL (%s) in \"updateref\" line.\n",
1955 fname, lineno, cargv[1] );
1960 vals[0].bv_val = cargv[1];
1961 vals[0].bv_len = strlen( vals[0].bv_val );
1962 value_add( &be->be_update_refs, vals );
1964 /* replication log file to which changes are appended */
1965 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1968 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1969 "%s: line %d: missing filename in \"replogfile <filename>\""
1970 " line.\n", fname, lineno ));
1972 Debug( LDAP_DEBUG_ANY,
1973 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1980 be->be_replogfile = ch_strdup( cargv[1] );
1982 replogfile = ch_strdup( cargv[1] );
1985 /* file from which to read additional rootdse attrs */
1986 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1989 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1990 "missing filename in \"rootDSE <filename>\" line.\n",
1993 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1994 "missing filename in \"rootDSE <filename>\" line.\n",
2000 if( read_root_dse_file( cargv[1] ) ) {
2002 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2003 "could not read \"rootDSE <filename>\" line.\n",
2006 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2007 "could not read \"rootDSE <filename>\" line\n",
2013 /* maintain lastmodified{by,time} attributes */
2014 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2017 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2018 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2019 " line.\n", fname, lineno ));
2021 Debug( LDAP_DEBUG_ANY,
2022 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2028 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2030 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2036 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2042 /* set idle timeout value */
2043 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2047 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2048 "%s: line %d: missing timeout value in "
2049 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2051 Debug( LDAP_DEBUG_ANY,
2052 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2059 i = atoi( cargv[1] );
2063 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2064 "%s: line %d: timeout value (%d) invalid "
2065 "\"idletimeout <seconds>\" line.\n",
2066 fname, lineno, i ));
2068 Debug( LDAP_DEBUG_ANY,
2069 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2076 global_idletimeout = i;
2078 /* include another config file */
2079 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2082 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2083 "%s: line %d: missing filename in \"include "
2084 "<filename>\" line.\n", fname, lineno ));
2086 Debug( LDAP_DEBUG_ANY,
2087 "%s: line %d: missing filename in \"include <filename>\" line\n",
2093 savefname = ch_strdup( cargv[1] );
2094 savelineno = lineno;
2096 if ( read_config( savefname ) != 0 ) {
2101 lineno = savelineno - 1;
2103 /* location of kerberos srvtab file */
2104 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2107 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2108 "%s: line %d: missing filename in \"srvtab "
2109 "<filename>\" line.\n", fname, lineno ));
2111 Debug( LDAP_DEBUG_ANY,
2112 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2118 ldap_srvtab = ch_strdup( cargv[1] );
2120 #ifdef SLAPD_MODULES
2121 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2124 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2125 "%s: line %d: missing filename in \"moduleload "
2126 "<filename>\" line.\n", fname, lineno ));
2128 Debug( LDAP_DEBUG_ANY,
2129 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2133 exit( EXIT_FAILURE );
2135 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2137 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2138 "%s: line %d: failed to load or initialize module %s\n",
2139 fname, lineno, cargv[1] ));
2141 Debug( LDAP_DEBUG_ANY,
2142 "%s: line %d: failed to load or initialize module %s\n",
2143 fname, lineno, cargv[1]);
2146 exit( EXIT_FAILURE );
2148 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2151 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2152 "%s: line %d: missing path in \"modulepath <path>\""
2153 " line\n", fname, lineno ));
2155 Debug( LDAP_DEBUG_ANY,
2156 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2160 exit( EXIT_FAILURE );
2162 if (module_path( cargv[1] )) {
2164 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2165 "%s: line %d: failed to set module search path to %s.\n",
2166 fname, lineno, cargv[1] ));
2168 Debug( LDAP_DEBUG_ANY,
2169 "%s: line %d: failed to set module search path to %s\n",
2170 fname, lineno, cargv[1]);
2173 exit( EXIT_FAILURE );
2176 #endif /*SLAPD_MODULES*/
2179 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2180 rc = ldap_pvt_tls_set_option( NULL,
2181 LDAP_OPT_X_TLS_RANDOM_FILE,
2186 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2187 rc = ldap_pvt_tls_set_option( NULL,
2188 LDAP_OPT_X_TLS_CIPHER_SUITE,
2193 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2194 rc = ldap_pvt_tls_set_option( NULL,
2195 LDAP_OPT_X_TLS_CERTFILE,
2200 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2201 rc = ldap_pvt_tls_set_option( NULL,
2202 LDAP_OPT_X_TLS_KEYFILE,
2207 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2208 rc = ldap_pvt_tls_set_option( NULL,
2209 LDAP_OPT_X_TLS_CACERTDIR,
2214 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2215 rc = ldap_pvt_tls_set_option( NULL,
2216 LDAP_OPT_X_TLS_CACERTFILE,
2220 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2221 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2223 rc = ldap_pvt_tls_set_option( NULL,
2224 LDAP_OPT_X_TLS_REQUIRE_CERT,
2227 rc = ldap_int_tls_config( NULL,
2228 LDAP_OPT_X_TLS_REQUIRE_CERT,
2237 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2238 #ifdef SLAPD_RLOOKUPS
2241 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2242 "%s: line %d: reverse-lookup: "
2243 "missing \"on\" or \"off\"\n",
2246 Debug( LDAP_DEBUG_ANY,
2247 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2253 if ( !strcasecmp( cargv[1], "on" ) ) {
2254 use_reverse_lookup = 1;
2255 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2256 use_reverse_lookup = 0;
2259 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2260 "%s: line %d: reverse-lookup: "
2261 "must be \"on\" (default) "
2265 Debug( LDAP_DEBUG_ANY,
2266 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2272 #else /* !SLAPD_RLOOKUPS */
2274 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2275 "%s: line %d: reverse lookups "
2276 "are not configured (ignored).\n",
2279 Debug( LDAP_DEBUG_ANY,
2280 "%s: line %d: reverse lookups are not configured (ignored).\n",
2283 #endif /* !SLAPD_RLOOKUPS */
2285 /* pass anything else to the current backend info/db config routine */
2288 if ( bi->bi_config == 0 ) {
2290 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2291 "%s: line %d: unknown directive \"%s\" inside "
2292 "backend info definition (ignored).\n",
2293 fname, lineno, cargv[0] ));
2295 Debug( LDAP_DEBUG_ANY,
2296 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2297 fname, lineno, cargv[0] );
2301 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2307 } else if ( be != NULL ) {
2308 if ( be->be_config == 0 ) {
2310 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2311 "%s: line %d: uknown directive \"%s\" inside "
2312 "backend database definition (ignored).\n",
2313 fname, lineno, cargv[0] ));
2315 Debug( LDAP_DEBUG_ANY,
2316 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2317 fname, lineno, cargv[0] );
2321 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2329 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2330 "%s: line %d: unknown directive \"%s\" outside backend "
2331 "info and database definitions (ignored).\n",
2332 fname, lineno, cargv[0] ));
2334 Debug( LDAP_DEBUG_ANY,
2335 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2336 fname, lineno, cargv[0] );
2345 if ( load_ucdata( NULL ) < 0 ) return 1;
2357 char logbuf[sizeof("pseudorootpw ***")];
2360 token = strtok_quote( line, " \t" );
2364 (strcasecmp( token, "rootpw" ) == 0 ||
2365 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2366 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2367 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2368 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2369 sprintf( logline = logbuf, "%s ***", token );
2370 if ( strtok_quote_ptr )
2371 *strtok_quote_ptr = ' ';
2373 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2374 "line %d (%s)\n", lineno, logline ));
2376 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2378 if ( strtok_quote_ptr )
2379 *strtok_quote_ptr = '\0';
2381 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2382 if ( cargc == cargv_size - 1 ) {
2384 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2386 if ( tmp == NULL ) {
2388 LDAP_LOG(( "config", LDAP_LEVEL_ERR,
2389 "line %d: out of memory\n",
2392 Debug( LDAP_DEBUG_ANY,
2393 "line %d: out of memory\n",
2399 cargv_size += ARGS_STEP;
2401 cargv[cargc++] = token;
2403 cargv[cargc] = NULL;
2408 strtok_quote( char *line, char *sep )
2414 strtok_quote_ptr = NULL;
2415 if ( line != NULL ) {
2418 while ( *next && strchr( sep, *next ) ) {
2422 if ( *next == '\0' ) {
2428 for ( inquote = 0; *next; ) {
2436 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2442 next + 1, strlen( next + 1 ) + 1 );
2443 next++; /* dont parse the escaped character */
2448 if ( strchr( sep, *next ) != NULL ) {
2449 strtok_quote_ptr = next;
2462 static char buf[BUFSIZ];
2464 static int lmax, lcur;
2466 #define CATLINE( buf ) { \
2468 len = strlen( buf ); \
2469 while ( lcur + len + 1 > lmax ) { \
2471 line = (char *) ch_realloc( line, lmax ); \
2473 strcpy( line + lcur, buf ); \
2478 fp_getline( FILE *fp, int *lineno )
2486 /* hack attack - keeps us from having to keep a stack of bufs... */
2487 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2492 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2493 /* trim off \r\n or \n */
2494 if ( (p = strchr( buf, '\n' )) != NULL ) {
2495 if( p > buf && p[-1] == '\r' ) --p;
2499 /* trim off trailing \ and append the next line */
2500 if ( line[ 0 ] != '\0'
2501 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2502 && p[ -1 ] != '\\' ) {
2507 if ( ! isspace( (unsigned char) buf[0] ) ) {
2511 /* change leading whitespace to a space */
2520 return( line[0] ? line : NULL );
2524 fp_getline_init( int *lineno )
2530 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2532 load_ucdata( char *path )
2534 static int loaded = 0;
2540 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2543 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2544 "load_ucdata: Error %d loading ucdata.\n", err ));
2546 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2559 ucdata_unload( UCDATA_ALL );
2561 if ( slapd_args_file )
2562 free ( slapd_args_file );
2563 if ( slapd_pid_file )
2564 free ( slapd_pid_file );
2565 acl_destroy( global_acl, NULL );