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",
1656 /* specify an attribute type */
1657 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1658 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1660 if ( *cargv[1] == '(' ) {
1662 p = strchr(saveline,'(');
1663 rc = parse_at( fname, lineno, p, cargv );
1668 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1669 "%s: line %d: old attribute type format not supported.\n",
1672 Debug( LDAP_DEBUG_ANY,
1673 "%s: line %d: old attribute type format not supported.\n",
1679 /* turn on/off schema checking */
1680 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1683 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1684 "%s: line %d: missing on|off in "
1685 "\"schemacheck <on|off>\" line.\n",
1688 Debug( LDAP_DEBUG_ANY,
1689 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1695 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1697 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1698 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1701 Debug( LDAP_DEBUG_ANY,
1702 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1705 global_schemacheck = 0;
1707 global_schemacheck = 1;
1710 /* specify access control info */
1711 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1712 parse_acl( be, fname, lineno, cargc, cargv );
1714 /* debug level to log things to syslog */
1715 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1718 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1719 "%s: line %d: missing level in \"loglevel <level>\""
1720 " line.\n", fname, lineno ));
1722 Debug( LDAP_DEBUG_ANY,
1723 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1732 for( i=1; i < cargc; i++ ) {
1733 ldap_syslog += atoi( cargv[1] );
1736 /* list of replicas of the data in this backend (master only) */
1737 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1740 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1741 "%s: line %d: missing host in \"replica "
1742 " <host[:port]\" line\n", fname, lineno ));
1744 Debug( LDAP_DEBUG_ANY,
1745 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1753 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1754 "%s: line %d: replica line must appear inside "
1755 "a database definition (ignored).\n", fname, lineno ));
1757 Debug( LDAP_DEBUG_ANY,
1758 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1765 for ( i = 1; i < cargc; i++ ) {
1766 if ( strncasecmp( cargv[i], "host=", 5 )
1768 nr = add_replica_info( be,
1775 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1776 "%s: line %d: missing host in \"replica\" "
1777 "line (ignored)\n", fname, lineno ));
1779 Debug( LDAP_DEBUG_ANY,
1780 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1784 } else if ( nr == -1 ) {
1786 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1787 "%s: line %d: unable to add"
1793 Debug( LDAP_DEBUG_ANY,
1794 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1795 fname, lineno, cargv[i] + 5 );
1798 for ( i = 1; i < cargc; i++ ) {
1799 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1801 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1804 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1805 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1806 fname, lineno, cargv[i] + 7 ));
1808 Debug( LDAP_DEBUG_ANY,
1809 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1810 fname, lineno, cargv[i] + 7 );
1816 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1817 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1820 Debug( LDAP_DEBUG_ANY,
1821 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1827 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1829 char *arg = cargv[i] + 4;
1831 if ( arg[0] == '!' ) {
1836 if ( arg[0] != '=' ) {
1840 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1842 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1843 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1844 fname, lineno, arg + 1 ));
1846 Debug( LDAP_DEBUG_ANY,
1847 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1848 fname, lineno, arg + 1 );
1857 /* dn of master entity allowed to write to replica */
1858 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1861 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1862 "%s: line %d: missing dn in \"updatedn <dn>\""
1863 " line.\n", fname, lineno ));
1865 Debug( LDAP_DEBUG_ANY,
1866 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1874 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1875 "%s: line %d: updatedn line must appear inside "
1876 "a database definition (ignored)\n",
1879 Debug( LDAP_DEBUG_ANY,
1880 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1887 if ( load_ucdata( NULL ) < 0 ) return 1;
1889 dn.bv_val = cargv[1];
1890 dn.bv_len = strlen( cargv[1] );
1892 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1893 if( rc != LDAP_SUCCESS ) {
1895 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1896 "%s: line %d: updatedn DN is invalid.\n",
1899 Debug( LDAP_DEBUG_ANY,
1900 "%s: line %d: updatedn DN is invalid\n",
1907 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1910 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1911 "missing url in \"updateref <ldapurl>\" line.\n",
1914 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1915 "missing url in \"updateref <ldapurl>\" line\n",
1923 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1924 " line must appear inside a database definition\n",
1927 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1928 " line must appear inside a database definition\n",
1933 } else if ( !be->be_update_ndn.bv_len ) {
1935 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1936 "updateref line must come after updatedn.\n",
1939 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1940 "updateref line must after updatedn.\n",
1946 if( validate_global_referral( cargv[1] ) ) {
1948 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1949 "invalid URL (%s) in \"updateref\" line.\n",
1950 fname, lineno, cargv[1] ));
1952 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1953 "invalid URL (%s) in \"updateref\" line.\n",
1954 fname, lineno, cargv[1] );
1959 vals[0].bv_val = cargv[1];
1960 vals[0].bv_len = strlen( vals[0].bv_val );
1961 value_add( &be->be_update_refs, vals );
1963 /* replication log file to which changes are appended */
1964 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1967 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1968 "%s: line %d: missing filename in \"replogfile <filename>\""
1969 " line.\n", fname, lineno ));
1971 Debug( LDAP_DEBUG_ANY,
1972 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1979 be->be_replogfile = ch_strdup( cargv[1] );
1981 replogfile = ch_strdup( cargv[1] );
1984 /* file from which to read additional rootdse attrs */
1985 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1988 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1989 "missing filename in \"rootDSE <filename>\" line.\n",
1992 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1993 "missing filename in \"rootDSE <filename>\" line.\n",
1999 if( read_root_dse_file( cargv[1] ) ) {
2001 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2002 "could not read \"rootDSE <filename>\" line.\n",
2005 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2006 "could not read \"rootDSE <filename>\" line\n",
2012 /* maintain lastmodified{by,time} attributes */
2013 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2016 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2017 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2018 " line.\n", fname, lineno ));
2020 Debug( LDAP_DEBUG_ANY,
2021 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2027 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2029 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2035 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2041 /* set idle timeout value */
2042 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2046 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2047 "%s: line %d: missing timeout value in "
2048 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2050 Debug( LDAP_DEBUG_ANY,
2051 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2058 i = atoi( cargv[1] );
2062 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2063 "%s: line %d: timeout value (%d) invalid "
2064 "\"idletimeout <seconds>\" line.\n",
2065 fname, lineno, i ));
2067 Debug( LDAP_DEBUG_ANY,
2068 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2075 global_idletimeout = i;
2077 /* include another config file */
2078 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2081 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2082 "%s: line %d: missing filename in \"include "
2083 "<filename>\" line.\n", fname, lineno ));
2085 Debug( LDAP_DEBUG_ANY,
2086 "%s: line %d: missing filename in \"include <filename>\" line\n",
2092 savefname = ch_strdup( cargv[1] );
2093 savelineno = lineno;
2095 if ( read_config( savefname ) != 0 ) {
2100 lineno = savelineno - 1;
2102 /* location of kerberos srvtab file */
2103 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2106 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2107 "%s: line %d: missing filename in \"srvtab "
2108 "<filename>\" line.\n", fname, lineno ));
2110 Debug( LDAP_DEBUG_ANY,
2111 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2117 ldap_srvtab = ch_strdup( cargv[1] );
2119 #ifdef SLAPD_MODULES
2120 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2123 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2124 "%s: line %d: missing filename in \"moduleload "
2125 "<filename>\" line.\n", fname, lineno ));
2127 Debug( LDAP_DEBUG_ANY,
2128 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2132 exit( EXIT_FAILURE );
2134 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2136 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2137 "%s: line %d: failed to load or initialize module %s\n",
2138 fname, lineno, cargv[1] ));
2140 Debug( LDAP_DEBUG_ANY,
2141 "%s: line %d: failed to load or initialize module %s\n",
2142 fname, lineno, cargv[1]);
2145 exit( EXIT_FAILURE );
2147 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2150 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2151 "%s: line %d: missing path in \"modulepath <path>\""
2152 " line\n", fname, lineno ));
2154 Debug( LDAP_DEBUG_ANY,
2155 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2159 exit( EXIT_FAILURE );
2161 if (module_path( cargv[1] )) {
2163 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2164 "%s: line %d: failed to set module search path to %s.\n",
2165 fname, lineno, cargv[1] ));
2167 Debug( LDAP_DEBUG_ANY,
2168 "%s: line %d: failed to set module search path to %s\n",
2169 fname, lineno, cargv[1]);
2172 exit( EXIT_FAILURE );
2175 #endif /*SLAPD_MODULES*/
2178 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2179 rc = ldap_pvt_tls_set_option( NULL,
2180 LDAP_OPT_X_TLS_RANDOM_FILE,
2185 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2186 rc = ldap_pvt_tls_set_option( NULL,
2187 LDAP_OPT_X_TLS_CIPHER_SUITE,
2192 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2193 rc = ldap_pvt_tls_set_option( NULL,
2194 LDAP_OPT_X_TLS_CERTFILE,
2199 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2200 rc = ldap_pvt_tls_set_option( NULL,
2201 LDAP_OPT_X_TLS_KEYFILE,
2206 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2207 rc = ldap_pvt_tls_set_option( NULL,
2208 LDAP_OPT_X_TLS_CACERTDIR,
2213 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2214 rc = ldap_pvt_tls_set_option( NULL,
2215 LDAP_OPT_X_TLS_CACERTFILE,
2219 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2220 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2222 rc = ldap_pvt_tls_set_option( NULL,
2223 LDAP_OPT_X_TLS_REQUIRE_CERT,
2226 rc = ldap_int_tls_config( NULL,
2227 LDAP_OPT_X_TLS_REQUIRE_CERT,
2236 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2237 #ifdef SLAPD_RLOOKUPS
2240 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2241 "%s: line %d: reverse-lookup: "
2242 "missing \"on\" or \"off\"\n",
2245 Debug( LDAP_DEBUG_ANY,
2246 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2252 if ( !strcasecmp( cargv[1], "on" ) ) {
2253 use_reverse_lookup = 1;
2254 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2255 use_reverse_lookup = 0;
2258 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2259 "%s: line %d: reverse-lookup: "
2260 "must be \"on\" (default) "
2264 Debug( LDAP_DEBUG_ANY,
2265 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2271 #else /* !SLAPD_RLOOKUPS */
2273 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2274 "%s: line %d: reverse lookups "
2275 "are not configured (ignored).\n",
2278 Debug( LDAP_DEBUG_ANY,
2279 "%s: line %d: reverse lookups are not configured (ignored).\n",
2282 #endif /* !SLAPD_RLOOKUPS */
2284 /* pass anything else to the current backend info/db config routine */
2287 if ( bi->bi_config == 0 ) {
2289 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2290 "%s: line %d: unknown directive \"%s\" inside "
2291 "backend info definition (ignored).\n",
2292 fname, lineno, cargv[0] ));
2294 Debug( LDAP_DEBUG_ANY,
2295 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2296 fname, lineno, cargv[0] );
2300 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2306 } else if ( be != NULL ) {
2307 if ( be->be_config == 0 ) {
2309 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2310 "%s: line %d: uknown directive \"%s\" inside "
2311 "backend database definition (ignored).\n",
2312 fname, lineno, cargv[0] ));
2314 Debug( LDAP_DEBUG_ANY,
2315 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2316 fname, lineno, cargv[0] );
2320 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2328 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2329 "%s: line %d: unknown directive \"%s\" outside backend "
2330 "info and database definitions (ignored).\n",
2331 fname, lineno, cargv[0] ));
2333 Debug( LDAP_DEBUG_ANY,
2334 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2335 fname, lineno, cargv[0] );
2344 if ( load_ucdata( NULL ) < 0 ) return 1;
2356 char logbuf[sizeof("pseudorootpw ***")];
2359 token = strtok_quote( line, " \t" );
2363 (strcasecmp( token, "rootpw" ) == 0 ||
2364 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2365 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2366 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2367 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2368 sprintf( logline = logbuf, "%s ***", token );
2369 if ( strtok_quote_ptr )
2370 *strtok_quote_ptr = ' ';
2372 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2373 "line %d (%s)\n", lineno, logline ));
2375 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2377 if ( strtok_quote_ptr )
2378 *strtok_quote_ptr = '\0';
2380 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2381 if ( cargc == cargv_size - 1 ) {
2383 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2385 if ( tmp == NULL ) {
2387 LDAP_LOG(( "config", LDAP_LEVEL_ERR,
2388 "line %d: out of memory\n",
2391 Debug( LDAP_DEBUG_ANY,
2392 "line %d: out of memory\n",
2398 cargv_size += ARGS_STEP;
2400 cargv[cargc++] = token;
2402 cargv[cargc] = NULL;
2407 strtok_quote( char *line, char *sep )
2413 strtok_quote_ptr = NULL;
2414 if ( line != NULL ) {
2417 while ( *next && strchr( sep, *next ) ) {
2421 if ( *next == '\0' ) {
2427 for ( inquote = 0; *next; ) {
2435 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2441 next + 1, strlen( next + 1 ) + 1 );
2442 next++; /* dont parse the escaped character */
2447 if ( strchr( sep, *next ) != NULL ) {
2448 strtok_quote_ptr = next;
2461 static char buf[BUFSIZ];
2463 static int lmax, lcur;
2465 #define CATLINE( buf ) { \
2467 len = strlen( buf ); \
2468 while ( lcur + len + 1 > lmax ) { \
2470 line = (char *) ch_realloc( line, lmax ); \
2472 strcpy( line + lcur, buf ); \
2477 fp_getline( FILE *fp, int *lineno )
2485 /* hack attack - keeps us from having to keep a stack of bufs... */
2486 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2491 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2492 /* trim off \r\n or \n */
2493 if ( (p = strchr( buf, '\n' )) != NULL ) {
2494 if( p > buf && p[-1] == '\r' ) --p;
2498 /* trim off trailing \ and append the next line */
2499 if ( line[ 0 ] != '\0'
2500 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2501 && p[ -1 ] != '\\' ) {
2506 if ( ! isspace( (unsigned char) buf[0] ) ) {
2510 /* change leading whitespace to a space */
2519 return( line[0] ? line : NULL );
2523 fp_getline_init( int *lineno )
2529 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2531 load_ucdata( char *path )
2533 static int loaded = 0;
2539 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2542 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2543 "load_ucdata: Error %d loading ucdata.\n", err ));
2545 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2558 ucdata_unload( UCDATA_ALL );
2560 if ( slapd_args_file )
2561 free ( slapd_args_file );
2562 if ( slapd_pid_file )
2563 free ( slapd_pid_file );
2564 acl_destroy( global_acl, NULL );