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/signal.h>
15 #include <ac/socket.h>
25 * defaults for various global variables
27 struct slap_limits_set deflimit = {
28 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
31 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
33 -1 /* no limit on unchecked size */
36 AccessControl *global_acl = NULL;
37 slap_access_t global_default_access = ACL_READ;
38 slap_mask_t global_restrictops = 0;
39 slap_mask_t global_allows = 0;
40 slap_mask_t global_disallows = 0;
41 slap_mask_t global_requires = 0;
42 slap_ssf_set_t global_ssf_set;
44 int global_gentlehup = 0;
45 int global_idletimeout = 0;
46 char *global_host = NULL;
47 char *global_realm = NULL;
48 char *ldap_srvtab = "";
49 char *default_passwd_hash = NULL;
50 int cargc = 0, cargv_size = 0;
52 struct berval default_search_base = { 0, NULL };
53 struct berval default_search_nbase = { 0, NULL };
54 unsigned num_subordinates = 0;
56 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
57 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
59 char *slapd_pid_file = NULL;
60 char *slapd_args_file = NULL;
62 char *strtok_quote_ptr;
65 SaslRegexp_t *SaslRegexp = NULL;
68 int use_reverse_lookup = 1;
69 #else /* !SLAPD_RLOOKUPS */
70 int use_reverse_lookup = 0;
71 #endif /* !SLAPD_RLOOKUPS */
73 static char *fp_getline(FILE *fp, int *lineno);
74 static void fp_getline_init(int *lineno);
75 static int fp_parse_line(int lineno, char *line);
77 static char *strtok_quote(char *line, char *sep);
78 static int load_ucdata(char *path);
81 read_config( const char *fname )
84 char *line, *savefname, *saveline;
88 struct berval vals[2];
90 static int lastmod = 1;
91 static BackendInfo *bi = NULL;
92 static BackendDB *be = NULL;
94 vals[1].bv_val = NULL;
96 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
97 cargv_size = ARGS_STEP + 1;
99 if ( (fp = fopen( fname, "r" )) == NULL ) {
102 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
103 "could not open config file \"%s\": %s (%d)\n",
104 fname, strerror(errno), errno ));
106 Debug( LDAP_DEBUG_ANY,
107 "could not open config file \"%s\": %s (%d)\n",
108 fname, strerror(errno), errno );
114 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
115 "read_config: reading config file %s\n", fname ));
117 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
121 fp_getline_init( &lineno );
123 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
124 /* skip comments and blank lines */
125 if ( line[0] == '#' || line[0] == '\0' ) {
129 /* fp_parse_line is destructive, we save a copy */
130 saveline = ch_strdup( line );
132 if ( fp_parse_line( lineno, line ) != 0 ) {
138 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
139 "%s: line %d: bad config line (ignored)\n",
142 Debug( LDAP_DEBUG_ANY,
143 "%s: line %d: bad config line (ignored)\n",
150 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
153 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
154 "%s : line %d: missing type in \"backend\" line.\n",
157 Debug( LDAP_DEBUG_ANY,
158 "%s: line %d: missing type in \"backend <type>\" line\n",
167 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
168 "%s: line %d: backend line must appear before any "
169 "database definition.\n", fname, lineno ));
171 Debug( LDAP_DEBUG_ANY,
172 "%s: line %d: backend line must appear before any database definition\n",
179 bi = backend_info( cargv[1] );
183 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
184 "read_config: backend %s initialization failed.\n",
187 Debug( LDAP_DEBUG_ANY,
188 "backend %s initialization failed.\n",
194 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
197 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
198 "%s: line %d: missing type in \"database <type>\" line\n",
201 Debug( LDAP_DEBUG_ANY,
202 "%s: line %d: missing type in \"database <type>\" line\n",
210 be = backend_db_init( cargv[1] );
214 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
215 "database %s initialization failed.\n",
218 Debug( LDAP_DEBUG_ANY,
219 "database %s initialization failed.\n",
226 /* set thread concurrency */
227 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
231 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
232 "%s: line %d: missing level in \"concurrency <level\" line\n",
235 Debug( LDAP_DEBUG_ANY,
236 "%s: line %d: missing level in \"concurrency <level>\" line\n",
243 c = atoi( cargv[1] );
247 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
248 "%s: line %d: invalid level (%d) in "
249 "\"concurrency <level>\" line.\n",
252 Debug( LDAP_DEBUG_ANY,
253 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
260 ldap_pvt_thread_set_concurrency( c );
262 /* set sockbuf max */
263 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
267 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
268 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
271 Debug( LDAP_DEBUG_ANY,
272 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
279 max = atol( cargv[1] );
283 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
284 "%s: line %d: invalid max value (%ld) in "
285 "\"sockbuf_max_incoming <bytes>\" line.\n",
286 fname, lineno, max ));
288 Debug( LDAP_DEBUG_ANY,
289 "%s: line %d: invalid max value (%ld) in "
290 "\"sockbuf_max_incoming <bytes>\" line.\n",
291 fname, lineno, max );
297 sockbuf_max_incoming = max;
299 /* set sockbuf max authenticated */
300 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
304 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
305 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
308 Debug( LDAP_DEBUG_ANY,
309 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
316 max = atol( cargv[1] );
320 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
321 "%s: line %d: invalid max value (%ld) in "
322 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
323 fname, lineno, max ));
325 Debug( LDAP_DEBUG_ANY,
326 "%s: line %d: invalid max value (%ld) in "
327 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
328 fname, lineno, max );
334 sockbuf_max_incoming_auth = max;
336 /* default search base */
337 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
340 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
341 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
342 "line\n", fname, lineno ));
344 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
345 "missing dn in \"defaultSearchBase <dn>\" line\n",
351 } else if ( cargc > 2 ) {
353 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
354 "%s: line %d: extra cruft after <dn> in "
355 "\"defaultSearchBase %s\" line (ignored)\n",
356 fname, lineno, cargv[1] ));
358 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
359 "extra cruft after <dn> in \"defaultSearchBase %s\", "
361 fname, lineno, cargv[1] );
365 if ( bi != NULL || be != NULL ) {
367 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
368 "%s: line %d: defaultSearchBase line must appear "
369 "prior to any backend or database definitions\n",
372 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
373 "defaultSearchBaase line must appear prior to "
374 "any backend or database definition\n",
381 if ( default_search_nbase.bv_len ) {
383 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
384 "default search base \"%s\" already defined "
385 "(discarding old)\n", fname, lineno,
386 default_search_base.bv_val ));
388 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
389 "default search base \"%s\" already defined "
390 "(discarding old)\n",
391 fname, lineno, default_search_base.bv_val );
394 free( default_search_base.bv_val );
395 free( default_search_nbase.bv_val );
398 if ( load_ucdata( NULL ) < 0 ) return 1;
403 dn.bv_val = cargv[1];
404 dn.bv_len = strlen( dn.bv_val );
406 rc = dnPrettyNormal( NULL, &dn,
407 &default_search_base,
408 &default_search_nbase );
410 if( rc != LDAP_SUCCESS ) {
412 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
413 "%s: line %d: defaultSearchBase DN is invalid.\n",
416 Debug( LDAP_DEBUG_ANY,
417 "%s: line %d: defaultSearchBase DN is invalid\n",
424 /* set maximum threads in thread pool */
425 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
429 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
430 "%s: line %d: missing count in \"threads <count>\" line\n",
433 Debug( LDAP_DEBUG_ANY,
434 "%s: line %d: missing count in \"threads <count>\" line\n",
441 c = atoi( cargv[1] );
445 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
446 "%s: line %d: invalid level (%d) in \"threads <count>\""
447 "line\n",fname, lineno, c ));
449 Debug( LDAP_DEBUG_ANY,
450 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
457 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
459 /* save for later use */
460 connection_pool_max = c;
462 /* get pid file name */
463 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
466 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
467 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
470 Debug( LDAP_DEBUG_ANY,
471 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
478 slapd_pid_file = ch_strdup( cargv[1] );
480 /* get args file name */
481 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
484 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
485 "%s: %d: missing file name in "
486 "\"argsfile <file>\" line.\n",
489 Debug( LDAP_DEBUG_ANY,
490 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
497 slapd_args_file = ch_strdup( cargv[1] );
499 /* default password hash */
500 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
503 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
504 "%s: line %d: missing hash in "
505 "\"password-hash <hash>\" line.\n",
508 Debug( LDAP_DEBUG_ANY,
509 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
515 if ( default_passwd_hash != NULL ) {
517 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
518 "%s: line %d: already set default password_hash!\n",
521 Debug( LDAP_DEBUG_ANY,
522 "%s: line %d: already set default password_hash!\n",
530 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
532 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
533 "%s: line %d: password scheme \"%s\" not available\n",
534 fname, lineno, cargv[1] ));
536 Debug( LDAP_DEBUG_ANY,
537 "%s: line %d: password scheme \"%s\" not available\n",
538 fname, lineno, cargv[1] );
543 default_passwd_hash = ch_strdup( cargv[1] );
545 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
549 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
550 "%s: line %d: missing format in "
551 "\"password-crypt-salt-format <format>\" line\n",
554 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
555 "\"password-crypt-salt-format <format>\" line\n",
562 lutil_salt_format( cargv[1] );
565 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
568 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
569 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
572 Debug( LDAP_DEBUG_ANY,
573 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
580 if ( global_host != NULL ) {
582 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
583 "%s: line %d: already set sasl-host!\n",
586 Debug( LDAP_DEBUG_ANY,
587 "%s: line %d: already set sasl-host!\n",
594 global_host = ch_strdup( cargv[1] );
598 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
601 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
602 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
605 Debug( LDAP_DEBUG_ANY,
606 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
613 if ( global_realm != NULL ) {
615 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
616 "%s: line %d: already set sasl-realm!\n",
619 Debug( LDAP_DEBUG_ANY,
620 "%s: line %d: already set sasl-realm!\n",
627 global_realm = ch_strdup( cargv[1] );
630 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
631 || !strcasecmp( cargv[0], "saslregexp" ) )
636 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
637 "%s: line %d: need 2 args in "
638 "\"saslregexp <match> <replace>\"\n",
641 Debug( LDAP_DEBUG_ANY,
642 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
648 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
653 /* SASL security properties */
654 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
659 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
660 "%s: line %d: missing flags in "
661 "\"sasl-secprops <properties>\" line\n",
664 Debug( LDAP_DEBUG_ANY,
665 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
672 txt = slap_sasl_secprops( cargv[1] );
675 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
676 "%s: line %d sas-secprops: %s\n",
677 fname, lineno, txt ));
679 Debug( LDAP_DEBUG_ANY,
680 "%s: line %d: sasl-secprops: %s\n",
681 fname, lineno, txt );
687 /* set UCDATA path */
688 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
692 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
693 "%s: line %d: missing path in "
694 "\"ucdata-path <path>\" line.\n",
697 Debug( LDAP_DEBUG_ANY,
698 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
705 err = load_ucdata( cargv[1] );
709 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
710 "%s: line %d: ucdata already loaded, ucdata-path "
711 "must be set earlier in the file and/or be "
712 "specified only once!\n",
715 Debug( LDAP_DEBUG_ANY,
716 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
725 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
727 struct slap_limits_set *lim;
731 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
732 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
735 Debug( LDAP_DEBUG_ANY,
736 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
746 lim = &be->be_def_limit;
749 for ( i = 1; i < cargc; i++ ) {
750 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
751 rc = parse_limit( cargv[i], lim );
753 lim->lms_s_soft = atoi( cargv[i] );
759 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
760 "%s: line %d: unable "
761 "to parse value \"%s\" "
764 fname, lineno, cargv[i] ));
766 Debug( LDAP_DEBUG_ANY,
767 "%s: line %d: unable "
768 "to parse value \"%s\" "
771 fname, lineno, cargv[i] );
777 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
779 struct slap_limits_set *lim;
783 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
784 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
787 Debug( LDAP_DEBUG_ANY,
788 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
798 lim = &be->be_def_limit;
801 for ( i = 1; i < cargc; i++ ) {
802 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
803 rc = parse_limit( cargv[i], lim );
805 lim->lms_t_soft = atoi( cargv[i] );
811 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
812 "%s: line %d: unable "
813 "to parse value \"%s\" "
816 fname, lineno, cargv[i] ));
818 Debug( LDAP_DEBUG_ANY,
819 "%s: line %d: unable "
820 "to parse value \"%s\" "
823 fname, lineno, cargv[i] );
828 /* set regex-based limits */
829 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
832 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
833 "%s: line %d \"limits\" allowed only in database environment.\n",
836 Debug( LDAP_DEBUG_ANY,
837 "%s: line %d \"limits\" allowed only in database environment.\n%s",
843 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
847 /* mark this as a subordinate database */
848 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
851 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
852 "subordinate keyword must appear inside a database "
853 "definition.\n", fname, lineno ));
855 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
856 "must appear inside a database definition.\n",
862 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
866 /* set database suffix */
867 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
869 struct berval dn, pdn, ndn;
873 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
874 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
877 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
878 "missing dn in \"suffix <dn>\" line\n",
884 } else if ( cargc > 2 ) {
886 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
887 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
888 " line (ignored).\n", fname, lineno, cargv[1] ));
890 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
891 "after <dn> in \"suffix %s\" line (ignored)\n",
892 fname, lineno, cargv[1] );
898 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
899 "%s: line %d: suffix line must appear inside a database "
900 "definition.\n", fname, lineno ));
902 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
903 "must appear inside a database definition\n",
908 #if defined(SLAPD_MONITOR_DN)
909 /* "cn=Monitor" is reserved for monitoring slap */
910 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
912 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
913 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
916 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
917 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
921 #endif /* SLAPD_MONITOR_DN */
924 if ( load_ucdata( NULL ) < 0 ) return 1;
926 dn.bv_val = cargv[1];
927 dn.bv_len = strlen( cargv[1] );
929 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
930 if( rc != LDAP_SUCCESS ) {
932 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
933 "%s: line %d: suffix DN is invalid.\n",
936 Debug( LDAP_DEBUG_ANY,
937 "%s: line %d: suffix DN is invalid\n",
943 tmp_be = select_backend( &ndn, 0, 0 );
944 if ( tmp_be == be ) {
946 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
947 "%s: line %d: suffix already served by this backend "
948 "(ignored)\n", fname, lineno ));
950 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
951 "already served by this backend (ignored)\n",
957 } else if ( tmp_be != NULL ) {
959 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
960 "%s: line %d: suffix already served by a preceding "
961 "backend \"%s\"\n", fname, lineno,
962 tmp_be->be_suffix[0].bv_val ));
964 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
965 "already served by a preceeding backend \"%s\"\n",
966 fname, lineno, tmp_be->be_suffix[0].bv_val );
972 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
974 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
975 "%s: line %d: suffix DN empty and default search "
976 "base provided \"%s\" (assuming okay).\n",
977 fname, lineno, default_search_base.bv_val ));
979 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
980 "suffix DN empty and default "
981 "search base provided \"%s\" (assuming okay)\n",
982 fname, lineno, default_search_base.bv_val );
986 ber_bvarray_add( &be->be_suffix, &pdn );
987 ber_bvarray_add( &be->be_nsuffix, &ndn );
989 /* set database suffixAlias */
990 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
992 struct berval alias, palias, nalias;
993 struct berval aliased, paliased, naliased;
997 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
998 "%s: line %d: missing alias and aliased_dn in "
999 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1002 Debug( LDAP_DEBUG_ANY,
1003 "%s: line %d: missing alias and aliased_dn in "
1004 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1009 } else if ( cargc < 3 ) {
1011 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1012 "%s: line %d: missing aliased_dn in "
1013 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1016 Debug( LDAP_DEBUG_ANY,
1017 "%s: line %d: missing aliased_dn in "
1018 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1023 } else if ( cargc > 3 ) {
1025 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1026 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1029 Debug( LDAP_DEBUG_ANY,
1030 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1037 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1038 "%s: line %d: suffixAlias line must appear inside a "
1039 "database definition.\n", fname, lineno ));
1041 Debug( LDAP_DEBUG_ANY,
1042 "%s: line %d: suffixAlias line"
1043 " must appear inside a database definition.\n",
1049 if ( load_ucdata( NULL ) < 0 ) return 1;
1051 alias.bv_val = cargv[1];
1052 alias.bv_len = strlen( cargv[1] );
1054 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
1055 if( rc != LDAP_SUCCESS ) {
1057 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1058 "%s: line %d: alias DN is invalid.\n",
1061 Debug( LDAP_DEBUG_ANY,
1062 "%s: line %d: alias DN is invalid\n",
1068 tmp_be = select_backend( &nalias, 0, 0 );
1069 free( nalias.bv_val );
1070 if ( tmp_be && tmp_be != be ) {
1072 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1073 "%s: line %d: suffixAlias served by a preceeding "
1075 fname, lineno, tmp_be->be_suffix[0].bv_val ));
1077 Debug( LDAP_DEBUG_ANY,
1078 "%s: line %d: suffixAlias served by"
1079 " a preceeding backend \"%s\"\n",
1080 fname, lineno, tmp_be->be_suffix[0].bv_val );
1082 free( palias.bv_val );
1086 aliased.bv_val = cargv[2];
1087 aliased.bv_len = strlen( cargv[2] );
1089 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
1090 if( rc != LDAP_SUCCESS ) {
1092 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1093 "%s: line %d: aliased DN is invalid.\n",
1096 Debug( LDAP_DEBUG_ANY,
1097 "%s: line %d: aliased DN is invalid\n",
1100 free( palias.bv_val );
1104 tmp_be = select_backend( &naliased, 0, 0 );
1105 free( naliased.bv_val );
1106 if ( tmp_be && tmp_be != be ) {
1108 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1109 "%s: line %d: suffixAlias derefs to a different backend "
1110 "a preceeding backend \"%s\"\n",
1111 fname, lineno, tmp_be->be_suffix[0].bv_val ));
1113 Debug( LDAP_DEBUG_ANY,
1114 "%s: line %d: suffixAlias derefs to differnet backend"
1115 " a preceeding backend \"%s\"\n",
1116 fname, lineno, tmp_be->be_suffix[0].bv_val );
1118 free( palias.bv_val );
1119 free( paliased.bv_val );
1123 ber_bvarray_add( &be->be_suffixAlias, &palias );
1124 ber_bvarray_add( &be->be_suffixAlias, &paliased );
1126 /* set max deref depth */
1127 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1131 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1132 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1133 " line\n", fname, lineno ));
1135 Debug( LDAP_DEBUG_ANY,
1136 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1144 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1145 "%s: line %d: depth line must appear inside a database "
1146 "definition.\n", fname, lineno ));
1148 Debug( LDAP_DEBUG_ANY,
1149 "%s: line %d: depth line must appear inside a database definition.\n",
1154 } else if ((i = atoi(cargv[1])) < 0) {
1156 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1157 "%s: line %d: depth must be positive.\n",
1160 Debug( LDAP_DEBUG_ANY,
1161 "%s: line %d: depth must be positive.\n",
1168 be->be_max_deref_depth = i;
1172 /* set magic "root" dn for this database */
1173 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1176 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1177 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1180 Debug( LDAP_DEBUG_ANY,
1181 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1190 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1191 "%s: line %d: rootdn line must appear inside a database "
1192 "definition.\n", fname, lineno ));
1194 Debug( LDAP_DEBUG_ANY,
1195 "%s: line %d: rootdn line must appear inside a database definition.\n",
1203 if ( load_ucdata( NULL ) < 0 ) return 1;
1205 dn.bv_val = cargv[1];
1206 dn.bv_len = strlen( cargv[1] );
1208 rc = dnPrettyNormal( NULL, &dn,
1212 if( rc != LDAP_SUCCESS ) {
1214 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1215 "%s: line %d: rootdn DN is invalid.\n",
1218 Debug( LDAP_DEBUG_ANY,
1219 "%s: line %d: rootdn DN is invalid\n",
1226 /* set super-secret magic database password */
1227 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1230 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1231 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1232 " line\n", fname, lineno ));
1234 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1235 "missing passwd in \"rootpw <passwd>\" line\n",
1244 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1245 "rootpw line must appear inside a database "
1246 "definition.\n", fname, lineno ));
1248 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1249 "rootpw line must appear inside a database "
1256 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1258 if( tmp_be != be ) {
1260 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1262 "rootpw can only be set when rootdn is under suffix\n"
1265 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1266 "rootpw can only be set when rootdn is under suffix\n",
1272 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1273 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1276 /* make this database read-only */
1277 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1280 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1281 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1284 Debug( LDAP_DEBUG_ANY,
1285 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1292 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1293 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1295 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1298 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1299 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1301 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1306 /* allow these features */
1307 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1308 strcasecmp( cargv[0], "allow" ) == 0 )
1314 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1315 "%s: line %d: allow line must appear prior to "
1316 "database definitions.\n", fname, lineno ));
1318 Debug( LDAP_DEBUG_ANY,
1319 "%s: line %d: allow line must appear prior to database definitions\n",
1327 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1328 "%s: line %d: missing feature(s) in \"allow <features>\""
1329 " line\n", fname, lineno ));
1331 Debug( LDAP_DEBUG_ANY,
1332 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1341 for( i=1; i < cargc; i++ ) {
1342 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1343 allows |= SLAP_ALLOW_BIND_V2;
1345 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1346 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1348 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1349 allows |= SLAP_ALLOW_BIND_ANON_DN;
1351 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1353 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1354 "%s: line %d: unknown feature %s in "
1355 "\"allow <features>\" line.\n",
1356 fname, lineno, cargv[1] ));
1358 Debug( LDAP_DEBUG_ANY,
1359 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1360 fname, lineno, cargv[i] );
1367 global_allows = allows;
1369 /* disallow these features */
1370 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1371 strcasecmp( cargv[0], "disallow" ) == 0 )
1373 slap_mask_t disallows;
1377 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1378 "%s: line %d: disallow line must appear prior to "
1379 "database definitions.\n", fname, lineno ));
1381 Debug( LDAP_DEBUG_ANY,
1382 "%s: line %d: disallow line must appear prior to database definitions\n",
1390 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1391 "%s: line %d: missing feature(s) in \"disallow <features>\""
1392 " line.\n", fname, lineno ));
1394 Debug( LDAP_DEBUG_ANY,
1395 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1404 for( i=1; i < cargc; i++ ) {
1405 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1406 disallows |= SLAP_DISALLOW_BIND_ANON;
1408 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1409 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1411 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1412 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1414 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1415 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1417 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1418 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1420 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1422 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1423 "%s: line %d: unknown feature %s in "
1424 "\"disallow <features>\" line.\n",
1425 fname, lineno, cargv[i] ));
1427 Debug( LDAP_DEBUG_ANY,
1428 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1429 fname, lineno, cargv[i] );
1436 global_disallows = disallows;
1438 /* require these features */
1439 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1440 strcasecmp( cargv[0], "require" ) == 0 )
1442 slap_mask_t requires;
1446 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1447 "%s: line %d: missing feature(s) in "
1448 "\"require <features>\" line.\n", fname, lineno ));
1450 Debug( LDAP_DEBUG_ANY,
1451 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1460 for( i=1; i < cargc; i++ ) {
1461 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1462 requires |= SLAP_REQUIRE_BIND;
1464 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1465 requires |= SLAP_REQUIRE_LDAP_V3;
1467 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1468 requires |= SLAP_REQUIRE_AUTHC;
1470 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1471 requires |= SLAP_REQUIRE_SASL;
1473 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1474 requires |= SLAP_REQUIRE_STRONG;
1476 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1478 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1479 "%s: line %d: unknown feature %s in "
1480 "\"require <features>\" line.\n",
1483 Debug( LDAP_DEBUG_ANY,
1484 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1485 fname, lineno, cargv[i] );
1493 global_requires = requires;
1495 be->be_requires = requires;
1498 /* required security factors */
1499 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1500 slap_ssf_set_t *set;
1504 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1505 "%s: line %d: missing factor(s) in \"security <factors>\""
1506 " line.\n", fname, lineno ));
1508 Debug( LDAP_DEBUG_ANY,
1509 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1517 set = &global_ssf_set;
1519 set = &be->be_ssf_set;
1522 for( i=1; i < cargc; i++ ) {
1523 if( strncasecmp( cargv[i], "ssf=",
1524 sizeof("ssf") ) == 0 )
1527 atoi( &cargv[i][sizeof("ssf")] );
1529 } else if( strncasecmp( cargv[i], "transport=",
1530 sizeof("transport") ) == 0 )
1532 set->sss_transport =
1533 atoi( &cargv[i][sizeof("transport")] );
1535 } else if( strncasecmp( cargv[i], "tls=",
1536 sizeof("tls") ) == 0 )
1539 atoi( &cargv[i][sizeof("tls")] );
1541 } else if( strncasecmp( cargv[i], "sasl=",
1542 sizeof("sasl") ) == 0 )
1545 atoi( &cargv[i][sizeof("sasl")] );
1547 } else if( strncasecmp( cargv[i], "update_ssf=",
1548 sizeof("update_ssf") ) == 0 )
1550 set->sss_update_ssf =
1551 atoi( &cargv[i][sizeof("update_ssf")] );
1553 } else if( strncasecmp( cargv[i], "update_transport=",
1554 sizeof("update_transport") ) == 0 )
1556 set->sss_update_transport =
1557 atoi( &cargv[i][sizeof("update_transport")] );
1559 } else if( strncasecmp( cargv[i], "update_tls=",
1560 sizeof("update_tls") ) == 0 )
1562 set->sss_update_tls =
1563 atoi( &cargv[i][sizeof("update_tls")] );
1565 } else if( strncasecmp( cargv[i], "update_sasl=",
1566 sizeof("update_sasl") ) == 0 )
1568 set->sss_update_sasl =
1569 atoi( &cargv[i][sizeof("update_sasl")] );
1573 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1574 "%s: line %d: unknown factor %S in "
1575 "\"security <factors>\" line.\n",
1576 fname, lineno, cargv[1] ));
1578 Debug( LDAP_DEBUG_ANY,
1579 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1580 fname, lineno, cargv[i] );
1586 /* where to send clients when we don't hold it */
1587 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1590 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1591 "%s: line %d: missing URL in \"referral <URL>\""
1592 " line.\n", fname, lineno ));
1594 Debug( LDAP_DEBUG_ANY,
1595 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1602 if( validate_global_referral( cargv[1] ) ) {
1604 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1605 "invalid URL (%s) in \"referral\" line.\n",
1606 fname, lineno, cargv[1] ));
1608 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1609 "invalid URL (%s) in \"referral\" line.\n",
1610 fname, lineno, cargv[1] );
1615 vals[0].bv_val = cargv[1];
1616 vals[0].bv_len = strlen( vals[0].bv_val );
1617 value_add( &default_referral, vals );
1620 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1624 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1625 "%s: line %d: Error in logfile directive, "
1626 "\"logfile <filename>\"\n", fname, lineno ));
1628 Debug( LDAP_DEBUG_ANY,
1629 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1635 logfile = fopen( cargv[1], "w" );
1636 if ( logfile != NULL ) lutil_debug_file( logfile );
1639 /* start of a new database definition */
1640 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1644 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1645 "%s: line %d: Error in debug directive, "
1646 "\"debug <subsys> <level>\"\n", fname, lineno ));
1648 Debug( LDAP_DEBUG_ANY,
1649 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1655 level = atoi( cargv[2] );
1656 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1657 lutil_set_debug_level( cargv[1], level );
1658 /* specify an Object Identifier macro */
1659 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1660 rc = parse_oidm( fname, lineno, cargc, cargv );
1663 /* specify an objectclass */
1664 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1665 if ( *cargv[1] == '(' ) {
1667 p = strchr(saveline,'(');
1668 rc = parse_oc( fname, lineno, p, cargv );
1673 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1674 "%s: line %d: old objectclass format not supported\n",
1677 Debug( LDAP_DEBUG_ANY,
1678 "%s: line %d: old objectclass format not supported.\n",
1683 /* specify an attribute type */
1684 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1685 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1687 if ( *cargv[1] == '(' ) {
1689 p = strchr(saveline,'(');
1690 rc = parse_at( fname, lineno, p, cargv );
1695 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1696 "%s: line %d: old attribute type format not supported.\n",
1699 Debug( LDAP_DEBUG_ANY,
1700 "%s: line %d: old attribute type format not supported.\n",
1706 /* turn on/off schema checking */
1707 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1710 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1711 "%s: line %d: missing on|off in "
1712 "\"schemacheck <on|off>\" line.\n",
1715 Debug( LDAP_DEBUG_ANY,
1716 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1722 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1724 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1725 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1728 Debug( LDAP_DEBUG_ANY,
1729 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1732 global_schemacheck = 0;
1734 global_schemacheck = 1;
1737 /* specify access control info */
1738 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1739 parse_acl( be, fname, lineno, cargc, cargv );
1741 /* debug level to log things to syslog */
1742 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1745 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1746 "%s: line %d: missing level in \"loglevel <level>\""
1747 " line.\n", fname, lineno ));
1749 Debug( LDAP_DEBUG_ANY,
1750 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1759 for( i=1; i < cargc; i++ ) {
1760 ldap_syslog += atoi( cargv[1] );
1763 /* list of replicas of the data in this backend (master only) */
1764 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1767 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1768 "%s: line %d: missing host in \"replica "
1769 " <host[:port]\" line\n", fname, lineno ));
1771 Debug( LDAP_DEBUG_ANY,
1772 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1780 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1781 "%s: line %d: replica line must appear inside "
1782 "a database definition.\n", fname, lineno ));
1784 Debug( LDAP_DEBUG_ANY,
1785 "%s: line %d: replica line must appear inside a database definition\n",
1793 for ( i = 1; i < cargc; i++ ) {
1794 if ( strncasecmp( cargv[i], "host=", 5 )
1796 nr = add_replica_info( be,
1803 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1804 "%s: line %d: missing host in \"replica\" line\n",
1807 Debug( LDAP_DEBUG_ANY,
1808 "%s: line %d: missing host in \"replica\" line\n",
1813 } else if ( nr == -1 ) {
1815 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1816 "%s: line %d: unable to add"
1817 " replica \"%s\"\n",
1821 Debug( LDAP_DEBUG_ANY,
1822 "%s: line %d: unable to add replica \"%s\"\n",
1823 fname, lineno, cargv[i] + 5 );
1827 for ( i = 1; i < cargc; i++ ) {
1828 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1830 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1833 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1834 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1835 fname, lineno, cargv[i] + 7 ));
1837 Debug( LDAP_DEBUG_ANY,
1838 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1839 fname, lineno, cargv[i] + 7 );
1845 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1846 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1849 Debug( LDAP_DEBUG_ANY,
1850 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1856 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1858 char *arg = cargv[i] + 4;
1860 if ( arg[0] == '!' ) {
1865 if ( arg[0] != '=' ) {
1869 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1871 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1872 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1873 fname, lineno, arg + 1 ));
1875 Debug( LDAP_DEBUG_ANY,
1876 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1877 fname, lineno, arg + 1 );
1886 /* dn of master entity allowed to write to replica */
1887 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1890 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1891 "%s: line %d: missing dn in \"updatedn <dn>\""
1892 " line.\n", fname, lineno ));
1894 Debug( LDAP_DEBUG_ANY,
1895 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1903 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1904 "%s: line %d: updatedn line must appear inside "
1905 "a database definition\n",
1908 Debug( LDAP_DEBUG_ANY,
1909 "%s: line %d: updatedn line must appear inside a database definition\n",
1917 if ( load_ucdata( NULL ) < 0 ) return 1;
1919 dn.bv_val = cargv[1];
1920 dn.bv_len = strlen( cargv[1] );
1922 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1923 if( rc != LDAP_SUCCESS ) {
1925 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1926 "%s: line %d: updatedn DN is invalid.\n",
1929 Debug( LDAP_DEBUG_ANY,
1930 "%s: line %d: updatedn DN is invalid\n",
1937 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1940 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1941 "missing url in \"updateref <ldapurl>\" line.\n",
1944 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1945 "missing url in \"updateref <ldapurl>\" line\n",
1953 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1954 " line must appear inside a database definition\n",
1957 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1958 " line must appear inside a database definition\n",
1963 } else if ( !be->be_update_ndn.bv_len ) {
1965 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1966 "updateref line must come after updatedn.\n",
1969 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1970 "updateref line must after updatedn.\n",
1976 if( validate_global_referral( cargv[1] ) ) {
1978 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1979 "invalid URL (%s) in \"updateref\" line.\n",
1980 fname, lineno, cargv[1] ));
1982 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1983 "invalid URL (%s) in \"updateref\" line.\n",
1984 fname, lineno, cargv[1] );
1989 vals[0].bv_val = cargv[1];
1990 vals[0].bv_len = strlen( vals[0].bv_val );
1991 value_add( &be->be_update_refs, vals );
1993 /* replication log file to which changes are appended */
1994 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1997 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1998 "%s: line %d: missing filename in \"replogfile <filename>\""
1999 " line.\n", fname, lineno ));
2001 Debug( LDAP_DEBUG_ANY,
2002 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2009 be->be_replogfile = ch_strdup( cargv[1] );
2011 replogfile = ch_strdup( cargv[1] );
2014 /* file from which to read additional rootdse attrs */
2015 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2018 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2019 "missing filename in \"rootDSE <filename>\" line.\n",
2022 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2023 "missing filename in \"rootDSE <filename>\" line.\n",
2029 if( read_root_dse_file( cargv[1] ) ) {
2031 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2032 "could not read \"rootDSE <filename>\" line.\n",
2035 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2036 "could not read \"rootDSE <filename>\" line\n",
2042 /* maintain lastmodified{by,time} attributes */
2043 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2046 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2047 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2048 " line.\n", fname, lineno ));
2050 Debug( LDAP_DEBUG_ANY,
2051 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2057 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2059 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2065 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2072 /* turn on/off gentle SIGHUP handling */
2073 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2075 Debug( LDAP_DEBUG_ANY,
2076 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2080 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2081 global_gentlehup = 0;
2083 global_gentlehup = 1;
2087 /* set idle timeout value */
2088 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2092 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2093 "%s: line %d: missing timeout value in "
2094 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2096 Debug( LDAP_DEBUG_ANY,
2097 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2104 i = atoi( cargv[1] );
2108 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2109 "%s: line %d: timeout value (%d) invalid "
2110 "\"idletimeout <seconds>\" line.\n",
2111 fname, lineno, i ));
2113 Debug( LDAP_DEBUG_ANY,
2114 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2121 global_idletimeout = i;
2123 /* include another config file */
2124 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2127 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2128 "%s: line %d: missing filename in \"include "
2129 "<filename>\" line.\n", fname, lineno ));
2131 Debug( LDAP_DEBUG_ANY,
2132 "%s: line %d: missing filename in \"include <filename>\" line\n",
2138 savefname = ch_strdup( cargv[1] );
2139 savelineno = lineno;
2141 if ( read_config( savefname ) != 0 ) {
2146 lineno = savelineno - 1;
2148 /* location of kerberos srvtab file */
2149 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2152 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2153 "%s: line %d: missing filename in \"srvtab "
2154 "<filename>\" line.\n", fname, lineno ));
2156 Debug( LDAP_DEBUG_ANY,
2157 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2163 ldap_srvtab = ch_strdup( cargv[1] );
2165 #ifdef SLAPD_MODULES
2166 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2169 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2170 "%s: line %d: missing filename in \"moduleload "
2171 "<filename>\" line.\n", fname, lineno ));
2173 Debug( LDAP_DEBUG_ANY,
2174 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2178 exit( EXIT_FAILURE );
2180 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2182 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2183 "%s: line %d: failed to load or initialize module %s\n",
2184 fname, lineno, cargv[1] ));
2186 Debug( LDAP_DEBUG_ANY,
2187 "%s: line %d: failed to load or initialize module %s\n",
2188 fname, lineno, cargv[1]);
2191 exit( EXIT_FAILURE );
2193 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2196 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2197 "%s: line %d: missing path in \"modulepath <path>\""
2198 " line\n", fname, lineno ));
2200 Debug( LDAP_DEBUG_ANY,
2201 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2205 exit( EXIT_FAILURE );
2207 if (module_path( cargv[1] )) {
2209 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2210 "%s: line %d: failed to set module search path to %s.\n",
2211 fname, lineno, cargv[1] ));
2213 Debug( LDAP_DEBUG_ANY,
2214 "%s: line %d: failed to set module search path to %s\n",
2215 fname, lineno, cargv[1]);
2218 exit( EXIT_FAILURE );
2221 #endif /*SLAPD_MODULES*/
2224 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2225 rc = ldap_pvt_tls_set_option( NULL,
2226 LDAP_OPT_X_TLS_RANDOM_FILE,
2231 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2232 rc = ldap_pvt_tls_set_option( NULL,
2233 LDAP_OPT_X_TLS_CIPHER_SUITE,
2238 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2239 rc = ldap_pvt_tls_set_option( NULL,
2240 LDAP_OPT_X_TLS_CERTFILE,
2245 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2246 rc = ldap_pvt_tls_set_option( NULL,
2247 LDAP_OPT_X_TLS_KEYFILE,
2252 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2253 rc = ldap_pvt_tls_set_option( NULL,
2254 LDAP_OPT_X_TLS_CACERTDIR,
2259 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2260 rc = ldap_pvt_tls_set_option( NULL,
2261 LDAP_OPT_X_TLS_CACERTFILE,
2265 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2266 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2268 rc = ldap_pvt_tls_set_option( NULL,
2269 LDAP_OPT_X_TLS_REQUIRE_CERT,
2272 rc = ldap_int_tls_config( NULL,
2273 LDAP_OPT_X_TLS_REQUIRE_CERT,
2282 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2283 #ifdef SLAPD_RLOOKUPS
2286 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2287 "%s: line %d: reverse-lookup: "
2288 "missing \"on\" or \"off\"\n",
2291 Debug( LDAP_DEBUG_ANY,
2292 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2298 if ( !strcasecmp( cargv[1], "on" ) ) {
2299 use_reverse_lookup = 1;
2300 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2301 use_reverse_lookup = 0;
2304 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2305 "%s: line %d: reverse-lookup: "
2306 "must be \"on\" (default) "
2310 Debug( LDAP_DEBUG_ANY,
2311 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2317 #else /* !SLAPD_RLOOKUPS */
2319 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2320 "%s: line %d: reverse lookups "
2321 "are not configured (ignored).\n",
2324 Debug( LDAP_DEBUG_ANY,
2325 "%s: line %d: reverse lookups are not configured (ignored).\n",
2328 #endif /* !SLAPD_RLOOKUPS */
2330 /* pass anything else to the current backend info/db config routine */
2333 if ( bi->bi_config == 0 ) {
2335 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2336 "%s: line %d: unknown directive \"%s\" inside "
2337 "backend info definition (ignored).\n",
2338 fname, lineno, cargv[0] ));
2340 Debug( LDAP_DEBUG_ANY,
2341 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2342 fname, lineno, cargv[0] );
2346 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2352 } else if ( be != NULL ) {
2353 if ( be->be_config == 0 ) {
2355 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2356 "%s: line %d: uknown directive \"%s\" inside "
2357 "backend database definition (ignored).\n",
2358 fname, lineno, cargv[0] ));
2360 Debug( LDAP_DEBUG_ANY,
2361 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2362 fname, lineno, cargv[0] );
2366 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2374 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2375 "%s: line %d: unknown directive \"%s\" outside backend "
2376 "info and database definitions (ignored).\n",
2377 fname, lineno, cargv[0] ));
2379 Debug( LDAP_DEBUG_ANY,
2380 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2381 fname, lineno, cargv[0] );
2390 if ( load_ucdata( NULL ) < 0 ) return 1;
2402 char logbuf[sizeof("pseudorootpw ***")];
2405 token = strtok_quote( line, " \t" );
2409 (strcasecmp( token, "rootpw" ) == 0 ||
2410 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2411 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2412 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2413 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2414 sprintf( logline = logbuf, "%s ***", token );
2415 if ( strtok_quote_ptr )
2416 *strtok_quote_ptr = ' ';
2418 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2419 "line %d (%s)\n", lineno, logline ));
2421 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2423 if ( strtok_quote_ptr )
2424 *strtok_quote_ptr = '\0';
2426 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2427 if ( cargc == cargv_size - 1 ) {
2429 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2431 if ( tmp == NULL ) {
2433 LDAP_LOG(( "config", LDAP_LEVEL_ERR,
2434 "line %d: out of memory\n",
2437 Debug( LDAP_DEBUG_ANY,
2438 "line %d: out of memory\n",
2444 cargv_size += ARGS_STEP;
2446 cargv[cargc++] = token;
2448 cargv[cargc] = NULL;
2453 strtok_quote( char *line, char *sep )
2459 strtok_quote_ptr = NULL;
2460 if ( line != NULL ) {
2463 while ( *next && strchr( sep, *next ) ) {
2467 if ( *next == '\0' ) {
2473 for ( inquote = 0; *next; ) {
2481 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2487 next + 1, strlen( next + 1 ) + 1 );
2488 next++; /* dont parse the escaped character */
2493 if ( strchr( sep, *next ) != NULL ) {
2494 strtok_quote_ptr = next;
2507 static char buf[BUFSIZ];
2509 static int lmax, lcur;
2511 #define CATLINE( buf ) { \
2513 len = strlen( buf ); \
2514 while ( lcur + len + 1 > lmax ) { \
2516 line = (char *) ch_realloc( line, lmax ); \
2518 strcpy( line + lcur, buf ); \
2523 fp_getline( FILE *fp, int *lineno )
2531 /* hack attack - keeps us from having to keep a stack of bufs... */
2532 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2537 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2538 /* trim off \r\n or \n */
2539 if ( (p = strchr( buf, '\n' )) != NULL ) {
2540 if( p > buf && p[-1] == '\r' ) --p;
2544 /* trim off trailing \ and append the next line */
2545 if ( line[ 0 ] != '\0'
2546 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2547 && p[ -1 ] != '\\' ) {
2552 if ( ! isspace( (unsigned char) buf[0] ) ) {
2556 /* change leading whitespace to a space */
2565 return( line[0] ? line : NULL );
2569 fp_getline_init( int *lineno )
2575 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2577 load_ucdata( char *path )
2579 static int loaded = 0;
2585 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2588 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2589 "load_ucdata: Error %d loading ucdata.\n", err ));
2591 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2604 ucdata_unload( UCDATA_ALL );
2606 if ( slapd_args_file )
2607 free ( slapd_args_file );
2608 if ( slapd_pid_file )
2609 free ( slapd_pid_file );
2610 acl_destroy( global_acl, NULL );