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 (ignored).\n", fname, lineno ));
855 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
856 "must appear inside a database definition (ignored)\n",
860 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
864 /* set database suffix */
865 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
867 struct berval dn, pdn, ndn;
871 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
872 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
875 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
876 "missing dn in \"suffix <dn>\" line\n",
882 } else if ( cargc > 2 ) {
884 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
885 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
886 " line (ignored).\n", fname, lineno, cargv[1] ));
888 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
889 "after <dn> in \"suffix %s\" line (ignored)\n",
890 fname, lineno, cargv[1] );
896 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
897 "%s: line %d: suffix line must appear inside a database "
898 "definition.\n", fname, lineno ));
900 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
901 "must appear inside a database definition\n",
906 #if defined(SLAPD_MONITOR_DN)
907 /* "cn=Monitor" is reserved for monitoring slap */
908 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
910 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
911 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
914 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
915 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
919 #endif /* SLAPD_MONITOR_DN */
922 if ( load_ucdata( NULL ) < 0 ) return 1;
924 dn.bv_val = cargv[1];
925 dn.bv_len = strlen( cargv[1] );
927 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
928 if( rc != LDAP_SUCCESS ) {
930 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
931 "%s: line %d: suffix DN is invalid.\n",
934 Debug( LDAP_DEBUG_ANY,
935 "%s: line %d: suffix DN is invalid\n",
941 tmp_be = select_backend( &ndn, 0, 0 );
942 if ( tmp_be == be ) {
944 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
945 "%s: line %d: suffix already served by this backend "
946 "(ignored)\n", fname, lineno ));
948 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
949 "already served by this backend (ignored)\n",
955 } else if ( tmp_be != NULL ) {
957 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
958 "%s: line %d: suffix already served by a preceding "
959 "backend \"%s\"\n", fname, lineno,
960 tmp_be->be_suffix[0].bv_val ));
962 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
963 "already served by a preceeding backend \"%s\"\n",
964 fname, lineno, tmp_be->be_suffix[0].bv_val );
970 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
972 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
973 "%s: line %d: suffix DN empty and default search "
974 "base provided \"%s\" (assuming okay).\n",
975 fname, lineno, default_search_base.bv_val ));
977 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
978 "suffix DN empty and default "
979 "search base provided \"%s\" (assuming okay)\n",
980 fname, lineno, default_search_base.bv_val );
984 ber_bvarray_add( &be->be_suffix, &pdn );
985 ber_bvarray_add( &be->be_nsuffix, &ndn );
987 /* set database suffixAlias */
988 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
990 struct berval alias, palias, nalias;
991 struct berval aliased, paliased, naliased;
995 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
996 "%s: line %d: missing alias and aliased_dn in "
997 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1000 Debug( LDAP_DEBUG_ANY,
1001 "%s: line %d: missing alias and aliased_dn in "
1002 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1007 } else if ( cargc < 3 ) {
1009 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1010 "%s: line %d: missing aliased_dn in "
1011 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1014 Debug( LDAP_DEBUG_ANY,
1015 "%s: line %d: missing aliased_dn in "
1016 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1021 } else if ( cargc > 3 ) {
1023 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1024 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1027 Debug( LDAP_DEBUG_ANY,
1028 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1036 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1037 "%s: line %d: suffixAlias line must appear inside a "
1038 "database definition (ignored).\n", fname, lineno ));
1040 Debug( LDAP_DEBUG_ANY,
1041 "%s: line %d: suffixAlias line"
1042 " must appear inside a database definition (ignored)\n",
1047 if ( load_ucdata( NULL ) < 0 ) return 1;
1049 alias.bv_val = cargv[1];
1050 alias.bv_len = strlen( cargv[1] );
1052 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
1053 if( rc != LDAP_SUCCESS ) {
1055 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1056 "%s: line %d: alias DN is invalid.\n",
1059 Debug( LDAP_DEBUG_ANY,
1060 "%s: line %d: alias DN is invalid\n",
1066 tmp_be = select_backend( &nalias, 0, 0 );
1067 free( nalias.bv_val );
1068 if ( tmp_be && tmp_be != be ) {
1070 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1071 "%s: line %d: suffixAlias served by a preceeding "
1073 fname, lineno, tmp_be->be_suffix[0].bv_val ));
1075 Debug( LDAP_DEBUG_ANY,
1076 "%s: line %d: suffixAlias served by"
1077 " a preceeding backend \"%s\"\n",
1078 fname, lineno, tmp_be->be_suffix[0].bv_val );
1080 free( palias.bv_val );
1084 aliased.bv_val = cargv[2];
1085 aliased.bv_len = strlen( cargv[2] );
1087 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
1088 if( rc != LDAP_SUCCESS ) {
1090 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1091 "%s: line %d: aliased DN is invalid.\n",
1094 Debug( LDAP_DEBUG_ANY,
1095 "%s: line %d: aliased DN is invalid\n",
1098 free( palias.bv_val );
1102 tmp_be = select_backend( &naliased, 0, 0 );
1103 free( naliased.bv_val );
1104 if ( tmp_be && tmp_be != be ) {
1106 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1107 "%s: line %d: suffixAlias derefs to a different backend "
1108 "a preceeding backend \"%s\"\n",
1109 fname, lineno, tmp_be->be_suffix[0].bv_val ));
1111 Debug( LDAP_DEBUG_ANY,
1112 "%s: line %d: suffixAlias derefs to differnet backend"
1113 " a preceeding backend \"%s\"\n",
1114 fname, lineno, tmp_be->be_suffix[0].bv_val );
1116 free( palias.bv_val );
1117 free( paliased.bv_val );
1121 ber_bvarray_add( &be->be_suffixAlias, &palias );
1122 ber_bvarray_add( &be->be_suffixAlias, &paliased );
1124 /* set max deref depth */
1125 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1129 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1130 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1131 " line\n", fname, lineno ));
1133 Debug( LDAP_DEBUG_ANY,
1134 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1142 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1143 "%s: line %d: depth line must appear inside a database "
1144 "definition (ignored)\n", fname, lineno ));
1146 Debug( LDAP_DEBUG_ANY,
1147 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1151 } else if ((i = atoi(cargv[1])) < 0) {
1153 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1154 "%s: line %d: depth must be positive (ignored).\n",
1157 Debug( LDAP_DEBUG_ANY,
1158 "%s: line %d: depth must be positive (ignored)\n",
1164 be->be_max_deref_depth = i;
1168 /* set magic "root" dn for this database */
1169 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1172 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1173 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1176 Debug( LDAP_DEBUG_ANY,
1177 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1185 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1186 "%s: line %d: rootdn line must appear inside a database "
1187 "definition (ignored).\n", fname, lineno ));
1189 Debug( LDAP_DEBUG_ANY,
1190 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1197 if ( load_ucdata( NULL ) < 0 ) return 1;
1199 dn.bv_val = cargv[1];
1200 dn.bv_len = strlen( cargv[1] );
1202 rc = dnPrettyNormal( NULL, &dn,
1206 if( rc != LDAP_SUCCESS ) {
1208 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1209 "%s: line %d: rootdn DN is invalid.\n",
1212 Debug( LDAP_DEBUG_ANY,
1213 "%s: line %d: rootdn DN is invalid\n",
1220 /* set super-secret magic database password */
1221 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1224 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1225 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1226 " line\n", fname, lineno ));
1228 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1229 "missing passwd in \"rootpw <passwd>\" line\n",
1238 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1239 "rootpw line must appear inside a database "
1240 "definition (ignored)\n", fname, lineno ));
1242 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1243 "rootpw line must appear inside a database "
1244 "definition (ignored)\n",
1249 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1251 if( tmp_be != be ) {
1253 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1255 "rootpw cannot be set when rootdn not under suffix "
1259 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1260 "rootpw cannot be set when rootdn not under suffix"
1266 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1267 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1271 /* make this database read-only */
1272 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1275 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1276 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1279 Debug( LDAP_DEBUG_ANY,
1280 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1287 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1288 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1290 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1293 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1294 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1296 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1301 /* allow these features */
1302 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1303 strcasecmp( cargv[0], "allow" ) == 0 )
1309 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1310 "%s: line %d: allow line must appear prior to "
1311 "database definitions.\n", fname, lineno ));
1313 Debug( LDAP_DEBUG_ANY,
1314 "%s: line %d: allow line must appear prior to database definitions\n",
1322 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1323 "%s: line %d: missing feature(s) in \"allow <features>\""
1324 " line\n", fname, lineno ));
1326 Debug( LDAP_DEBUG_ANY,
1327 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1336 for( i=1; i < cargc; i++ ) {
1337 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1338 allows |= SLAP_ALLOW_BIND_V2;
1340 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1341 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1343 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1344 allows |= SLAP_ALLOW_BIND_ANON_DN;
1346 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1348 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1349 "%s: line %d: unknown feature %s in "
1350 "\"allow <features>\" line.\n",
1351 fname, lineno, cargv[1] ));
1353 Debug( LDAP_DEBUG_ANY,
1354 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1355 fname, lineno, cargv[i] );
1362 global_allows = allows;
1364 /* disallow these features */
1365 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1366 strcasecmp( cargv[0], "disallow" ) == 0 )
1368 slap_mask_t disallows;
1372 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1373 "%s: line %d: disallow line must appear prior to "
1374 "database definitions.\n", fname, lineno ));
1376 Debug( LDAP_DEBUG_ANY,
1377 "%s: line %d: disallow line must appear prior to database definitions\n",
1385 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1386 "%s: line %d: missing feature(s) in \"disallow <features>\""
1387 " line.\n", fname, lineno ));
1389 Debug( LDAP_DEBUG_ANY,
1390 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1399 for( i=1; i < cargc; i++ ) {
1400 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1401 disallows |= SLAP_DISALLOW_BIND_ANON;
1403 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1404 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1406 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1407 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1409 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1410 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1412 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1413 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1415 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1417 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1418 "%s: line %d: unknown feature %s in "
1419 "\"disallow <features>\" line.\n",
1420 fname, lineno, cargv[i] ));
1422 Debug( LDAP_DEBUG_ANY,
1423 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1424 fname, lineno, cargv[i] );
1431 global_disallows = disallows;
1433 /* require these features */
1434 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1435 strcasecmp( cargv[0], "require" ) == 0 )
1437 slap_mask_t requires;
1441 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1442 "%s: line %d: missing feature(s) in "
1443 "\"require <features>\" line.\n", fname, lineno ));
1445 Debug( LDAP_DEBUG_ANY,
1446 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1455 for( i=1; i < cargc; i++ ) {
1456 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1457 requires |= SLAP_REQUIRE_BIND;
1459 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1460 requires |= SLAP_REQUIRE_LDAP_V3;
1462 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1463 requires |= SLAP_REQUIRE_AUTHC;
1465 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1466 requires |= SLAP_REQUIRE_SASL;
1468 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1469 requires |= SLAP_REQUIRE_STRONG;
1471 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1473 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1474 "%s: line %d: unknown feature %s in "
1475 "\"require <features>\" line.\n",
1478 Debug( LDAP_DEBUG_ANY,
1479 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1480 fname, lineno, cargv[i] );
1488 global_requires = requires;
1490 be->be_requires = requires;
1493 /* required security factors */
1494 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1495 slap_ssf_set_t *set;
1499 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1500 "%s: line %d: missing factor(s) in \"security <factors>\""
1501 " line.\n", fname, lineno ));
1503 Debug( LDAP_DEBUG_ANY,
1504 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1512 set = &global_ssf_set;
1514 set = &be->be_ssf_set;
1517 for( i=1; i < cargc; i++ ) {
1518 if( strncasecmp( cargv[i], "ssf=",
1519 sizeof("ssf") ) == 0 )
1522 atoi( &cargv[i][sizeof("ssf")] );
1524 } else if( strncasecmp( cargv[i], "transport=",
1525 sizeof("transport") ) == 0 )
1527 set->sss_transport =
1528 atoi( &cargv[i][sizeof("transport")] );
1530 } else if( strncasecmp( cargv[i], "tls=",
1531 sizeof("tls") ) == 0 )
1534 atoi( &cargv[i][sizeof("tls")] );
1536 } else if( strncasecmp( cargv[i], "sasl=",
1537 sizeof("sasl") ) == 0 )
1540 atoi( &cargv[i][sizeof("sasl")] );
1542 } else if( strncasecmp( cargv[i], "update_ssf=",
1543 sizeof("update_ssf") ) == 0 )
1545 set->sss_update_ssf =
1546 atoi( &cargv[i][sizeof("update_ssf")] );
1548 } else if( strncasecmp( cargv[i], "update_transport=",
1549 sizeof("update_transport") ) == 0 )
1551 set->sss_update_transport =
1552 atoi( &cargv[i][sizeof("update_transport")] );
1554 } else if( strncasecmp( cargv[i], "update_tls=",
1555 sizeof("update_tls") ) == 0 )
1557 set->sss_update_tls =
1558 atoi( &cargv[i][sizeof("update_tls")] );
1560 } else if( strncasecmp( cargv[i], "update_sasl=",
1561 sizeof("update_sasl") ) == 0 )
1563 set->sss_update_sasl =
1564 atoi( &cargv[i][sizeof("update_sasl")] );
1568 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1569 "%s: line %d: unknown factor %S in "
1570 "\"security <factors>\" line.\n",
1571 fname, lineno, cargv[1] ));
1573 Debug( LDAP_DEBUG_ANY,
1574 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1575 fname, lineno, cargv[i] );
1581 /* where to send clients when we don't hold it */
1582 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1585 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1586 "%s: line %d: missing URL in \"referral <URL>\""
1587 " line.\n", fname, lineno ));
1589 Debug( LDAP_DEBUG_ANY,
1590 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1597 if( validate_global_referral( cargv[1] ) ) {
1599 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1600 "invalid URL (%s) in \"referral\" line.\n",
1601 fname, lineno, cargv[1] ));
1603 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1604 "invalid URL (%s) in \"referral\" line.\n",
1605 fname, lineno, cargv[1] );
1610 vals[0].bv_val = cargv[1];
1611 vals[0].bv_len = strlen( vals[0].bv_val );
1612 value_add( &default_referral, vals );
1615 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1619 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1620 "%s: line %d: Error in logfile directive, "
1621 "\"logfile <filename>\"\n", fname, lineno ));
1623 Debug( LDAP_DEBUG_ANY,
1624 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1630 logfile = fopen( cargv[1], "w" );
1631 if ( logfile != NULL ) lutil_debug_file( logfile );
1634 /* start of a new database definition */
1635 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1639 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1640 "%s: line %d: Error in debug directive, "
1641 "\"debug <subsys> <level>\"\n", fname, lineno ));
1643 Debug( LDAP_DEBUG_ANY,
1644 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1650 level = atoi( cargv[2] );
1651 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1652 lutil_set_debug_level( cargv[1], level );
1653 /* specify an Object Identifier macro */
1654 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1655 rc = parse_oidm( fname, lineno, cargc, cargv );
1658 /* specify an objectclass */
1659 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1660 if ( *cargv[1] == '(' ) {
1662 p = strchr(saveline,'(');
1663 rc = parse_oc( fname, lineno, p, cargv );
1668 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1669 "%s: line %d: old objectclass format not supported\n",
1672 Debug( LDAP_DEBUG_ANY,
1673 "%s: line %d: old objectclass format not supported.\n",
1678 /* specify an attribute type */
1679 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1680 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1682 if ( *cargv[1] == '(' ) {
1684 p = strchr(saveline,'(');
1685 rc = parse_at( fname, lineno, p, cargv );
1690 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1691 "%s: line %d: old attribute type format not supported.\n",
1694 Debug( LDAP_DEBUG_ANY,
1695 "%s: line %d: old attribute type format not supported.\n",
1701 /* turn on/off schema checking */
1702 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1705 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1706 "%s: line %d: missing on|off in "
1707 "\"schemacheck <on|off>\" line.\n",
1710 Debug( LDAP_DEBUG_ANY,
1711 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1717 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1719 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1720 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1723 Debug( LDAP_DEBUG_ANY,
1724 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1727 global_schemacheck = 0;
1729 global_schemacheck = 1;
1732 /* specify access control info */
1733 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1734 parse_acl( be, fname, lineno, cargc, cargv );
1736 /* debug level to log things to syslog */
1737 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1740 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1741 "%s: line %d: missing level in \"loglevel <level>\""
1742 " line.\n", fname, lineno ));
1744 Debug( LDAP_DEBUG_ANY,
1745 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1754 for( i=1; i < cargc; i++ ) {
1755 ldap_syslog += atoi( cargv[1] );
1758 /* list of replicas of the data in this backend (master only) */
1759 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1762 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1763 "%s: line %d: missing host in \"replica "
1764 " <host[:port]\" line\n", fname, lineno ));
1766 Debug( LDAP_DEBUG_ANY,
1767 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1775 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1776 "%s: line %d: replica line must appear inside "
1777 "a database definition (ignored).\n", fname, lineno ));
1779 Debug( LDAP_DEBUG_ANY,
1780 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1787 for ( i = 1; i < cargc; i++ ) {
1788 if ( strncasecmp( cargv[i], "host=", 5 )
1790 nr = add_replica_info( be,
1797 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1798 "%s: line %d: missing host in \"replica\" "
1799 "line (ignored)\n", fname, lineno ));
1801 Debug( LDAP_DEBUG_ANY,
1802 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1806 } else if ( nr == -1 ) {
1808 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1809 "%s: line %d: unable to add"
1815 Debug( LDAP_DEBUG_ANY,
1816 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1817 fname, lineno, cargv[i] + 5 );
1820 for ( i = 1; i < cargc; i++ ) {
1821 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1823 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1826 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1827 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1828 fname, lineno, cargv[i] + 7 ));
1830 Debug( LDAP_DEBUG_ANY,
1831 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1832 fname, lineno, cargv[i] + 7 );
1838 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1839 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1842 Debug( LDAP_DEBUG_ANY,
1843 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1849 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1851 char *arg = cargv[i] + 4;
1853 if ( arg[0] == '!' ) {
1858 if ( arg[0] != '=' ) {
1862 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1864 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1865 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1866 fname, lineno, arg + 1 ));
1868 Debug( LDAP_DEBUG_ANY,
1869 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1870 fname, lineno, arg + 1 );
1879 /* dn of master entity allowed to write to replica */
1880 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1883 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1884 "%s: line %d: missing dn in \"updatedn <dn>\""
1885 " line.\n", fname, lineno ));
1887 Debug( LDAP_DEBUG_ANY,
1888 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1896 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1897 "%s: line %d: updatedn line must appear inside "
1898 "a database definition (ignored)\n",
1901 Debug( LDAP_DEBUG_ANY,
1902 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1909 if ( load_ucdata( NULL ) < 0 ) return 1;
1911 dn.bv_val = cargv[1];
1912 dn.bv_len = strlen( cargv[1] );
1914 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1915 if( rc != LDAP_SUCCESS ) {
1917 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1918 "%s: line %d: updatedn DN is invalid.\n",
1921 Debug( LDAP_DEBUG_ANY,
1922 "%s: line %d: updatedn DN is invalid\n",
1929 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1932 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1933 "missing url in \"updateref <ldapurl>\" line.\n",
1936 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1937 "missing url in \"updateref <ldapurl>\" line\n",
1945 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1946 " line must appear inside a database definition\n",
1949 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1950 " line must appear inside a database definition\n",
1955 } else if ( !be->be_update_ndn.bv_len ) {
1957 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1958 "updateref line must come after updatedn.\n",
1961 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1962 "updateref line must after updatedn.\n",
1968 if( validate_global_referral( cargv[1] ) ) {
1970 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1971 "invalid URL (%s) in \"updateref\" line.\n",
1972 fname, lineno, cargv[1] ));
1974 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1975 "invalid URL (%s) in \"updateref\" line.\n",
1976 fname, lineno, cargv[1] );
1981 vals[0].bv_val = cargv[1];
1982 vals[0].bv_len = strlen( vals[0].bv_val );
1983 value_add( &be->be_update_refs, vals );
1985 /* replication log file to which changes are appended */
1986 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1989 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1990 "%s: line %d: missing filename in \"replogfile <filename>\""
1991 " line.\n", fname, lineno ));
1993 Debug( LDAP_DEBUG_ANY,
1994 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2001 be->be_replogfile = ch_strdup( cargv[1] );
2003 replogfile = ch_strdup( cargv[1] );
2006 /* file from which to read additional rootdse attrs */
2007 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2010 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2011 "missing filename in \"rootDSE <filename>\" line.\n",
2014 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2015 "missing filename in \"rootDSE <filename>\" line.\n",
2021 if( read_root_dse_file( cargv[1] ) ) {
2023 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2024 "could not read \"rootDSE <filename>\" line.\n",
2027 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2028 "could not read \"rootDSE <filename>\" line\n",
2034 /* maintain lastmodified{by,time} attributes */
2035 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2038 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2039 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2040 " line.\n", fname, lineno ));
2042 Debug( LDAP_DEBUG_ANY,
2043 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2049 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2051 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2057 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2064 /* turn on/off gentle SIGHUP handling */
2065 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2067 Debug( LDAP_DEBUG_ANY,
2068 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2072 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2073 global_gentlehup = 0;
2075 global_gentlehup = 1;
2079 /* set idle timeout value */
2080 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2084 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2085 "%s: line %d: missing timeout value in "
2086 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2088 Debug( LDAP_DEBUG_ANY,
2089 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2096 i = atoi( cargv[1] );
2100 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2101 "%s: line %d: timeout value (%d) invalid "
2102 "\"idletimeout <seconds>\" line.\n",
2103 fname, lineno, i ));
2105 Debug( LDAP_DEBUG_ANY,
2106 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2113 global_idletimeout = i;
2115 /* include another config file */
2116 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2119 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2120 "%s: line %d: missing filename in \"include "
2121 "<filename>\" line.\n", fname, lineno ));
2123 Debug( LDAP_DEBUG_ANY,
2124 "%s: line %d: missing filename in \"include <filename>\" line\n",
2130 savefname = ch_strdup( cargv[1] );
2131 savelineno = lineno;
2133 if ( read_config( savefname ) != 0 ) {
2138 lineno = savelineno - 1;
2140 /* location of kerberos srvtab file */
2141 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2144 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2145 "%s: line %d: missing filename in \"srvtab "
2146 "<filename>\" line.\n", fname, lineno ));
2148 Debug( LDAP_DEBUG_ANY,
2149 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2155 ldap_srvtab = ch_strdup( cargv[1] );
2157 #ifdef SLAPD_MODULES
2158 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2161 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2162 "%s: line %d: missing filename in \"moduleload "
2163 "<filename>\" line.\n", fname, lineno ));
2165 Debug( LDAP_DEBUG_ANY,
2166 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2170 exit( EXIT_FAILURE );
2172 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2174 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2175 "%s: line %d: failed to load or initialize module %s\n",
2176 fname, lineno, cargv[1] ));
2178 Debug( LDAP_DEBUG_ANY,
2179 "%s: line %d: failed to load or initialize module %s\n",
2180 fname, lineno, cargv[1]);
2183 exit( EXIT_FAILURE );
2185 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2188 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2189 "%s: line %d: missing path in \"modulepath <path>\""
2190 " line\n", fname, lineno ));
2192 Debug( LDAP_DEBUG_ANY,
2193 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2197 exit( EXIT_FAILURE );
2199 if (module_path( cargv[1] )) {
2201 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2202 "%s: line %d: failed to set module search path to %s.\n",
2203 fname, lineno, cargv[1] ));
2205 Debug( LDAP_DEBUG_ANY,
2206 "%s: line %d: failed to set module search path to %s\n",
2207 fname, lineno, cargv[1]);
2210 exit( EXIT_FAILURE );
2213 #endif /*SLAPD_MODULES*/
2216 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2217 rc = ldap_pvt_tls_set_option( NULL,
2218 LDAP_OPT_X_TLS_RANDOM_FILE,
2223 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2224 rc = ldap_pvt_tls_set_option( NULL,
2225 LDAP_OPT_X_TLS_CIPHER_SUITE,
2230 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2231 rc = ldap_pvt_tls_set_option( NULL,
2232 LDAP_OPT_X_TLS_CERTFILE,
2237 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2238 rc = ldap_pvt_tls_set_option( NULL,
2239 LDAP_OPT_X_TLS_KEYFILE,
2244 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2245 rc = ldap_pvt_tls_set_option( NULL,
2246 LDAP_OPT_X_TLS_CACERTDIR,
2251 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2252 rc = ldap_pvt_tls_set_option( NULL,
2253 LDAP_OPT_X_TLS_CACERTFILE,
2257 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2258 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2260 rc = ldap_pvt_tls_set_option( NULL,
2261 LDAP_OPT_X_TLS_REQUIRE_CERT,
2264 rc = ldap_int_tls_config( NULL,
2265 LDAP_OPT_X_TLS_REQUIRE_CERT,
2274 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2275 #ifdef SLAPD_RLOOKUPS
2278 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2279 "%s: line %d: reverse-lookup: "
2280 "missing \"on\" or \"off\"\n",
2283 Debug( LDAP_DEBUG_ANY,
2284 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2290 if ( !strcasecmp( cargv[1], "on" ) ) {
2291 use_reverse_lookup = 1;
2292 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2293 use_reverse_lookup = 0;
2296 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2297 "%s: line %d: reverse-lookup: "
2298 "must be \"on\" (default) "
2302 Debug( LDAP_DEBUG_ANY,
2303 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2309 #else /* !SLAPD_RLOOKUPS */
2311 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2312 "%s: line %d: reverse lookups "
2313 "are not configured (ignored).\n",
2316 Debug( LDAP_DEBUG_ANY,
2317 "%s: line %d: reverse lookups are not configured (ignored).\n",
2320 #endif /* !SLAPD_RLOOKUPS */
2322 /* pass anything else to the current backend info/db config routine */
2325 if ( bi->bi_config == 0 ) {
2327 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2328 "%s: line %d: unknown directive \"%s\" inside "
2329 "backend info definition (ignored).\n",
2330 fname, lineno, cargv[0] ));
2332 Debug( LDAP_DEBUG_ANY,
2333 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2334 fname, lineno, cargv[0] );
2338 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2344 } else if ( be != NULL ) {
2345 if ( be->be_config == 0 ) {
2347 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2348 "%s: line %d: uknown directive \"%s\" inside "
2349 "backend database definition (ignored).\n",
2350 fname, lineno, cargv[0] ));
2352 Debug( LDAP_DEBUG_ANY,
2353 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2354 fname, lineno, cargv[0] );
2358 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2366 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2367 "%s: line %d: unknown directive \"%s\" outside backend "
2368 "info and database definitions (ignored).\n",
2369 fname, lineno, cargv[0] ));
2371 Debug( LDAP_DEBUG_ANY,
2372 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2373 fname, lineno, cargv[0] );
2382 if ( load_ucdata( NULL ) < 0 ) return 1;
2394 char logbuf[sizeof("pseudorootpw ***")];
2397 token = strtok_quote( line, " \t" );
2401 (strcasecmp( token, "rootpw" ) == 0 ||
2402 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2403 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2404 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2405 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2406 sprintf( logline = logbuf, "%s ***", token );
2407 if ( strtok_quote_ptr )
2408 *strtok_quote_ptr = ' ';
2410 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2411 "line %d (%s)\n", lineno, logline ));
2413 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2415 if ( strtok_quote_ptr )
2416 *strtok_quote_ptr = '\0';
2418 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2419 if ( cargc == cargv_size - 1 ) {
2421 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2423 if ( tmp == NULL ) {
2425 LDAP_LOG(( "config", LDAP_LEVEL_ERR,
2426 "line %d: out of memory\n",
2429 Debug( LDAP_DEBUG_ANY,
2430 "line %d: out of memory\n",
2436 cargv_size += ARGS_STEP;
2438 cargv[cargc++] = token;
2440 cargv[cargc] = NULL;
2445 strtok_quote( char *line, char *sep )
2451 strtok_quote_ptr = NULL;
2452 if ( line != NULL ) {
2455 while ( *next && strchr( sep, *next ) ) {
2459 if ( *next == '\0' ) {
2465 for ( inquote = 0; *next; ) {
2473 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2479 next + 1, strlen( next + 1 ) + 1 );
2480 next++; /* dont parse the escaped character */
2485 if ( strchr( sep, *next ) != NULL ) {
2486 strtok_quote_ptr = next;
2499 static char buf[BUFSIZ];
2501 static int lmax, lcur;
2503 #define CATLINE( buf ) { \
2505 len = strlen( buf ); \
2506 while ( lcur + len + 1 > lmax ) { \
2508 line = (char *) ch_realloc( line, lmax ); \
2510 strcpy( line + lcur, buf ); \
2515 fp_getline( FILE *fp, int *lineno )
2523 /* hack attack - keeps us from having to keep a stack of bufs... */
2524 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2529 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2530 /* trim off \r\n or \n */
2531 if ( (p = strchr( buf, '\n' )) != NULL ) {
2532 if( p > buf && p[-1] == '\r' ) --p;
2536 /* trim off trailing \ and append the next line */
2537 if ( line[ 0 ] != '\0'
2538 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2539 && p[ -1 ] != '\\' ) {
2544 if ( ! isspace( (unsigned char) buf[0] ) ) {
2548 /* change leading whitespace to a space */
2557 return( line[0] ? line : NULL );
2561 fp_getline_init( int *lineno )
2567 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2569 load_ucdata( char *path )
2571 static int loaded = 0;
2577 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2580 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2581 "load_ucdata: Error %d loading ucdata.\n", err ));
2583 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2596 ucdata_unload( UCDATA_ALL );
2598 if ( slapd_args_file )
2599 free ( slapd_args_file );
2600 if ( slapd_pid_file )
2601 free ( slapd_pid_file );
2602 acl_destroy( global_acl, NULL );