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,
1229 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1237 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1238 "%s: line %d: rootpw line must appear inside a database "
1239 "definition (ignored)\n", fname, lineno ));
1241 Debug( LDAP_DEBUG_ANY,
1242 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1247 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1248 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1251 /* make this database read-only */
1252 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1255 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1256 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1259 Debug( LDAP_DEBUG_ANY,
1260 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1267 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1268 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1270 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1273 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1274 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1276 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1281 /* allow these features */
1282 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1283 strcasecmp( cargv[0], "allow" ) == 0 )
1289 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1290 "%s: line %d: allow line must appear prior to "
1291 "database definitions.\n", fname, lineno ));
1293 Debug( LDAP_DEBUG_ANY,
1294 "%s: line %d: allow line must appear prior to database definitions\n",
1302 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1303 "%s: line %d: missing feature(s) in \"allow <features>\""
1304 " line\n", fname, lineno ));
1306 Debug( LDAP_DEBUG_ANY,
1307 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1316 for( i=1; i < cargc; i++ ) {
1317 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1318 allows |= SLAP_ALLOW_BIND_V2;
1320 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1321 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1323 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1324 allows |= SLAP_ALLOW_BIND_ANON_DN;
1326 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1328 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1329 "%s: line %d: unknown feature %s in "
1330 "\"allow <features>\" line.\n",
1331 fname, lineno, cargv[1] ));
1333 Debug( LDAP_DEBUG_ANY,
1334 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1335 fname, lineno, cargv[i] );
1342 global_allows = allows;
1344 /* disallow these features */
1345 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1346 strcasecmp( cargv[0], "disallow" ) == 0 )
1348 slap_mask_t disallows;
1352 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1353 "%s: line %d: disallow line must appear prior to "
1354 "database definitions.\n", fname, lineno ));
1356 Debug( LDAP_DEBUG_ANY,
1357 "%s: line %d: disallow line must appear prior to database definitions\n",
1365 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1366 "%s: line %d: missing feature(s) in \"disallow <features>\""
1367 " line.\n", fname, lineno ));
1369 Debug( LDAP_DEBUG_ANY,
1370 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1379 for( i=1; i < cargc; i++ ) {
1380 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1381 disallows |= SLAP_DISALLOW_BIND_ANON;
1383 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1384 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1386 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1387 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1389 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1390 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1392 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1393 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1395 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1397 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1398 "%s: line %d: unknown feature %s in "
1399 "\"disallow <features>\" line.\n",
1400 fname, lineno, cargv[i] ));
1402 Debug( LDAP_DEBUG_ANY,
1403 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1404 fname, lineno, cargv[i] );
1411 global_disallows = disallows;
1413 /* require these features */
1414 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1415 strcasecmp( cargv[0], "require" ) == 0 )
1417 slap_mask_t requires;
1421 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1422 "%s: line %d: missing feature(s) in "
1423 "\"require <features>\" line.\n", fname, lineno ));
1425 Debug( LDAP_DEBUG_ANY,
1426 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1435 for( i=1; i < cargc; i++ ) {
1436 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1437 requires |= SLAP_REQUIRE_BIND;
1439 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1440 requires |= SLAP_REQUIRE_LDAP_V3;
1442 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1443 requires |= SLAP_REQUIRE_AUTHC;
1445 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1446 requires |= SLAP_REQUIRE_SASL;
1448 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1449 requires |= SLAP_REQUIRE_STRONG;
1451 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1453 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1454 "%s: line %d: unknown feature %s in "
1455 "\"require <features>\" line.\n",
1458 Debug( LDAP_DEBUG_ANY,
1459 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1460 fname, lineno, cargv[i] );
1468 global_requires = requires;
1470 be->be_requires = requires;
1473 /* required security factors */
1474 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1475 slap_ssf_set_t *set;
1479 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1480 "%s: line %d: missing factor(s) in \"security <factors>\""
1481 " line.\n", fname, lineno ));
1483 Debug( LDAP_DEBUG_ANY,
1484 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1492 set = &global_ssf_set;
1494 set = &be->be_ssf_set;
1497 for( i=1; i < cargc; i++ ) {
1498 if( strncasecmp( cargv[i], "ssf=",
1499 sizeof("ssf") ) == 0 )
1502 atoi( &cargv[i][sizeof("ssf")] );
1504 } else if( strncasecmp( cargv[i], "transport=",
1505 sizeof("transport") ) == 0 )
1507 set->sss_transport =
1508 atoi( &cargv[i][sizeof("transport")] );
1510 } else if( strncasecmp( cargv[i], "tls=",
1511 sizeof("tls") ) == 0 )
1514 atoi( &cargv[i][sizeof("tls")] );
1516 } else if( strncasecmp( cargv[i], "sasl=",
1517 sizeof("sasl") ) == 0 )
1520 atoi( &cargv[i][sizeof("sasl")] );
1522 } else if( strncasecmp( cargv[i], "update_ssf=",
1523 sizeof("update_ssf") ) == 0 )
1525 set->sss_update_ssf =
1526 atoi( &cargv[i][sizeof("update_ssf")] );
1528 } else if( strncasecmp( cargv[i], "update_transport=",
1529 sizeof("update_transport") ) == 0 )
1531 set->sss_update_transport =
1532 atoi( &cargv[i][sizeof("update_transport")] );
1534 } else if( strncasecmp( cargv[i], "update_tls=",
1535 sizeof("update_tls") ) == 0 )
1537 set->sss_update_tls =
1538 atoi( &cargv[i][sizeof("update_tls")] );
1540 } else if( strncasecmp( cargv[i], "update_sasl=",
1541 sizeof("update_sasl") ) == 0 )
1543 set->sss_update_sasl =
1544 atoi( &cargv[i][sizeof("update_sasl")] );
1548 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1549 "%s: line %d: unknown factor %S in "
1550 "\"security <factors>\" line.\n",
1551 fname, lineno, cargv[1] ));
1553 Debug( LDAP_DEBUG_ANY,
1554 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1555 fname, lineno, cargv[i] );
1561 /* where to send clients when we don't hold it */
1562 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1565 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1566 "%s: line %d: missing URL in \"referral <URL>\""
1567 " line.\n", fname, lineno ));
1569 Debug( LDAP_DEBUG_ANY,
1570 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1577 if( validate_global_referral( cargv[1] ) ) {
1579 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1580 "invalid URL (%s) in \"referral\" line.\n",
1581 fname, lineno, cargv[1] ));
1583 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1584 "invalid URL (%s) in \"referral\" line.\n",
1585 fname, lineno, cargv[1] );
1590 vals[0].bv_val = cargv[1];
1591 vals[0].bv_len = strlen( vals[0].bv_val );
1592 value_add( &default_referral, vals );
1595 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1599 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1600 "%s: line %d: Error in logfile directive, "
1601 "\"logfile <filename>\"\n", fname, lineno ));
1603 Debug( LDAP_DEBUG_ANY,
1604 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1610 logfile = fopen( cargv[1], "w" );
1611 if ( logfile != NULL ) lutil_debug_file( logfile );
1614 /* start of a new database definition */
1615 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1619 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1620 "%s: line %d: Error in debug directive, "
1621 "\"debug <subsys> <level>\"\n", fname, lineno ));
1623 Debug( LDAP_DEBUG_ANY,
1624 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1630 level = atoi( cargv[2] );
1631 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1632 lutil_set_debug_level( cargv[1], level );
1633 /* specify an Object Identifier macro */
1634 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1635 rc = parse_oidm( fname, lineno, cargc, cargv );
1638 /* specify an objectclass */
1639 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1640 if ( *cargv[1] == '(' ) {
1642 p = strchr(saveline,'(');
1643 rc = parse_oc( fname, lineno, p, cargv );
1648 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1649 "%s: line %d: old objectclass format not supported\n",
1652 Debug( LDAP_DEBUG_ANY,
1653 "%s: line %d: old objectclass format not supported.\n",
1658 /* specify an attribute type */
1659 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1660 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1662 if ( *cargv[1] == '(' ) {
1664 p = strchr(saveline,'(');
1665 rc = parse_at( fname, lineno, p, cargv );
1670 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1671 "%s: line %d: old attribute type format not supported.\n",
1674 Debug( LDAP_DEBUG_ANY,
1675 "%s: line %d: old attribute type format not supported.\n",
1681 /* turn on/off schema checking */
1682 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1685 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1686 "%s: line %d: missing on|off in "
1687 "\"schemacheck <on|off>\" line.\n",
1690 Debug( LDAP_DEBUG_ANY,
1691 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1697 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1699 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1700 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1703 Debug( LDAP_DEBUG_ANY,
1704 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1707 global_schemacheck = 0;
1709 global_schemacheck = 1;
1712 /* specify access control info */
1713 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1714 parse_acl( be, fname, lineno, cargc, cargv );
1716 /* debug level to log things to syslog */
1717 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1720 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1721 "%s: line %d: missing level in \"loglevel <level>\""
1722 " line.\n", fname, lineno ));
1724 Debug( LDAP_DEBUG_ANY,
1725 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1734 for( i=1; i < cargc; i++ ) {
1735 ldap_syslog += atoi( cargv[1] );
1738 /* list of replicas of the data in this backend (master only) */
1739 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1742 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1743 "%s: line %d: missing host in \"replica "
1744 " <host[:port]\" line\n", fname, lineno ));
1746 Debug( LDAP_DEBUG_ANY,
1747 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1755 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1756 "%s: line %d: replica line must appear inside "
1757 "a database definition (ignored).\n", fname, lineno ));
1759 Debug( LDAP_DEBUG_ANY,
1760 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1767 for ( i = 1; i < cargc; i++ ) {
1768 if ( strncasecmp( cargv[i], "host=", 5 )
1770 nr = add_replica_info( be,
1777 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1778 "%s: line %d: missing host in \"replica\" "
1779 "line (ignored)\n", fname, lineno ));
1781 Debug( LDAP_DEBUG_ANY,
1782 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1786 } else if ( nr == -1 ) {
1788 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1789 "%s: line %d: unable to add"
1795 Debug( LDAP_DEBUG_ANY,
1796 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1797 fname, lineno, cargv[i] + 5 );
1800 for ( i = 1; i < cargc; i++ ) {
1801 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1803 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1806 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1807 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1808 fname, lineno, cargv[i] + 7 ));
1810 Debug( LDAP_DEBUG_ANY,
1811 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1812 fname, lineno, cargv[i] + 7 );
1818 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1819 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1822 Debug( LDAP_DEBUG_ANY,
1823 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1829 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1831 char *arg = cargv[i] + 4;
1833 if ( arg[0] == '!' ) {
1838 if ( arg[0] != '=' ) {
1842 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1844 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1845 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1846 fname, lineno, arg + 1 ));
1848 Debug( LDAP_DEBUG_ANY,
1849 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1850 fname, lineno, arg + 1 );
1859 /* dn of master entity allowed to write to replica */
1860 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1863 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1864 "%s: line %d: missing dn in \"updatedn <dn>\""
1865 " line.\n", fname, lineno ));
1867 Debug( LDAP_DEBUG_ANY,
1868 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1876 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1877 "%s: line %d: updatedn line must appear inside "
1878 "a database definition (ignored)\n",
1881 Debug( LDAP_DEBUG_ANY,
1882 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1889 if ( load_ucdata( NULL ) < 0 ) return 1;
1891 dn.bv_val = cargv[1];
1892 dn.bv_len = strlen( cargv[1] );
1894 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1895 if( rc != LDAP_SUCCESS ) {
1897 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1898 "%s: line %d: updatedn DN is invalid.\n",
1901 Debug( LDAP_DEBUG_ANY,
1902 "%s: line %d: updatedn DN is invalid\n",
1909 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1912 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1913 "missing url in \"updateref <ldapurl>\" line.\n",
1916 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1917 "missing url in \"updateref <ldapurl>\" line\n",
1925 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1926 " line must appear inside a database definition\n",
1929 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1930 " line must appear inside a database definition\n",
1935 } else if ( !be->be_update_ndn.bv_len ) {
1937 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1938 "updateref line must come after updatedn.\n",
1941 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1942 "updateref line must after updatedn.\n",
1948 if( validate_global_referral( cargv[1] ) ) {
1950 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1951 "invalid URL (%s) in \"updateref\" line.\n",
1952 fname, lineno, cargv[1] ));
1954 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1955 "invalid URL (%s) in \"updateref\" line.\n",
1956 fname, lineno, cargv[1] );
1961 vals[0].bv_val = cargv[1];
1962 vals[0].bv_len = strlen( vals[0].bv_val );
1963 value_add( &be->be_update_refs, vals );
1965 /* replication log file to which changes are appended */
1966 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1969 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1970 "%s: line %d: missing filename in \"replogfile <filename>\""
1971 " line.\n", fname, lineno ));
1973 Debug( LDAP_DEBUG_ANY,
1974 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1981 be->be_replogfile = ch_strdup( cargv[1] );
1983 replogfile = ch_strdup( cargv[1] );
1986 /* file from which to read additional rootdse attrs */
1987 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1990 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1991 "missing filename in \"rootDSE <filename>\" line.\n",
1994 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1995 "missing filename in \"rootDSE <filename>\" line.\n",
2001 if( read_root_dse_file( cargv[1] ) ) {
2003 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2004 "could not read \"rootDSE <filename>\" line.\n",
2007 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2008 "could not read \"rootDSE <filename>\" line\n",
2014 /* maintain lastmodified{by,time} attributes */
2015 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2018 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2019 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2020 " line.\n", fname, lineno ));
2022 Debug( LDAP_DEBUG_ANY,
2023 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2029 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2031 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2037 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2044 /* turn on/off gentle SIGHUP handling */
2045 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2047 Debug( LDAP_DEBUG_ANY,
2048 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2052 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2053 global_gentlehup = 0;
2055 global_gentlehup = 1;
2059 /* set idle timeout value */
2060 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2064 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2065 "%s: line %d: missing timeout value in "
2066 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2068 Debug( LDAP_DEBUG_ANY,
2069 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2076 i = atoi( cargv[1] );
2080 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2081 "%s: line %d: timeout value (%d) invalid "
2082 "\"idletimeout <seconds>\" line.\n",
2083 fname, lineno, i ));
2085 Debug( LDAP_DEBUG_ANY,
2086 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2093 global_idletimeout = i;
2095 /* include another config file */
2096 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2099 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2100 "%s: line %d: missing filename in \"include "
2101 "<filename>\" line.\n", fname, lineno ));
2103 Debug( LDAP_DEBUG_ANY,
2104 "%s: line %d: missing filename in \"include <filename>\" line\n",
2110 savefname = ch_strdup( cargv[1] );
2111 savelineno = lineno;
2113 if ( read_config( savefname ) != 0 ) {
2118 lineno = savelineno - 1;
2120 /* location of kerberos srvtab file */
2121 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2124 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2125 "%s: line %d: missing filename in \"srvtab "
2126 "<filename>\" line.\n", fname, lineno ));
2128 Debug( LDAP_DEBUG_ANY,
2129 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2135 ldap_srvtab = ch_strdup( cargv[1] );
2137 #ifdef SLAPD_MODULES
2138 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2141 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2142 "%s: line %d: missing filename in \"moduleload "
2143 "<filename>\" line.\n", fname, lineno ));
2145 Debug( LDAP_DEBUG_ANY,
2146 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2150 exit( EXIT_FAILURE );
2152 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2154 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2155 "%s: line %d: failed to load or initialize module %s\n",
2156 fname, lineno, cargv[1] ));
2158 Debug( LDAP_DEBUG_ANY,
2159 "%s: line %d: failed to load or initialize module %s\n",
2160 fname, lineno, cargv[1]);
2163 exit( EXIT_FAILURE );
2165 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2168 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2169 "%s: line %d: missing path in \"modulepath <path>\""
2170 " line\n", fname, lineno ));
2172 Debug( LDAP_DEBUG_ANY,
2173 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2177 exit( EXIT_FAILURE );
2179 if (module_path( cargv[1] )) {
2181 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2182 "%s: line %d: failed to set module search path to %s.\n",
2183 fname, lineno, cargv[1] ));
2185 Debug( LDAP_DEBUG_ANY,
2186 "%s: line %d: failed to set module search path to %s\n",
2187 fname, lineno, cargv[1]);
2190 exit( EXIT_FAILURE );
2193 #endif /*SLAPD_MODULES*/
2196 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2197 rc = ldap_pvt_tls_set_option( NULL,
2198 LDAP_OPT_X_TLS_RANDOM_FILE,
2203 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2204 rc = ldap_pvt_tls_set_option( NULL,
2205 LDAP_OPT_X_TLS_CIPHER_SUITE,
2210 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2211 rc = ldap_pvt_tls_set_option( NULL,
2212 LDAP_OPT_X_TLS_CERTFILE,
2217 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2218 rc = ldap_pvt_tls_set_option( NULL,
2219 LDAP_OPT_X_TLS_KEYFILE,
2224 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2225 rc = ldap_pvt_tls_set_option( NULL,
2226 LDAP_OPT_X_TLS_CACERTDIR,
2231 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2232 rc = ldap_pvt_tls_set_option( NULL,
2233 LDAP_OPT_X_TLS_CACERTFILE,
2237 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2238 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2240 rc = ldap_pvt_tls_set_option( NULL,
2241 LDAP_OPT_X_TLS_REQUIRE_CERT,
2244 rc = ldap_int_tls_config( NULL,
2245 LDAP_OPT_X_TLS_REQUIRE_CERT,
2254 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2255 #ifdef SLAPD_RLOOKUPS
2258 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2259 "%s: line %d: reverse-lookup: "
2260 "missing \"on\" or \"off\"\n",
2263 Debug( LDAP_DEBUG_ANY,
2264 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2270 if ( !strcasecmp( cargv[1], "on" ) ) {
2271 use_reverse_lookup = 1;
2272 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2273 use_reverse_lookup = 0;
2276 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2277 "%s: line %d: reverse-lookup: "
2278 "must be \"on\" (default) "
2282 Debug( LDAP_DEBUG_ANY,
2283 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2289 #else /* !SLAPD_RLOOKUPS */
2291 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2292 "%s: line %d: reverse lookups "
2293 "are not configured (ignored).\n",
2296 Debug( LDAP_DEBUG_ANY,
2297 "%s: line %d: reverse lookups are not configured (ignored).\n",
2300 #endif /* !SLAPD_RLOOKUPS */
2302 /* pass anything else to the current backend info/db config routine */
2305 if ( bi->bi_config == 0 ) {
2307 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2308 "%s: line %d: unknown directive \"%s\" inside "
2309 "backend info definition (ignored).\n",
2310 fname, lineno, cargv[0] ));
2312 Debug( LDAP_DEBUG_ANY,
2313 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2314 fname, lineno, cargv[0] );
2318 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2324 } else if ( be != NULL ) {
2325 if ( be->be_config == 0 ) {
2327 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2328 "%s: line %d: uknown directive \"%s\" inside "
2329 "backend database definition (ignored).\n",
2330 fname, lineno, cargv[0] ));
2332 Debug( LDAP_DEBUG_ANY,
2333 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2334 fname, lineno, cargv[0] );
2338 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2346 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2347 "%s: line %d: unknown directive \"%s\" outside backend "
2348 "info and database definitions (ignored).\n",
2349 fname, lineno, cargv[0] ));
2351 Debug( LDAP_DEBUG_ANY,
2352 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2353 fname, lineno, cargv[0] );
2362 if ( load_ucdata( NULL ) < 0 ) return 1;
2374 char logbuf[sizeof("pseudorootpw ***")];
2377 token = strtok_quote( line, " \t" );
2381 (strcasecmp( token, "rootpw" ) == 0 ||
2382 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2383 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2384 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2385 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2386 sprintf( logline = logbuf, "%s ***", token );
2387 if ( strtok_quote_ptr )
2388 *strtok_quote_ptr = ' ';
2390 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2391 "line %d (%s)\n", lineno, logline ));
2393 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2395 if ( strtok_quote_ptr )
2396 *strtok_quote_ptr = '\0';
2398 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2399 if ( cargc == cargv_size - 1 ) {
2401 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2403 if ( tmp == NULL ) {
2405 LDAP_LOG(( "config", LDAP_LEVEL_ERR,
2406 "line %d: out of memory\n",
2409 Debug( LDAP_DEBUG_ANY,
2410 "line %d: out of memory\n",
2416 cargv_size += ARGS_STEP;
2418 cargv[cargc++] = token;
2420 cargv[cargc] = NULL;
2425 strtok_quote( char *line, char *sep )
2431 strtok_quote_ptr = NULL;
2432 if ( line != NULL ) {
2435 while ( *next && strchr( sep, *next ) ) {
2439 if ( *next == '\0' ) {
2445 for ( inquote = 0; *next; ) {
2453 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2459 next + 1, strlen( next + 1 ) + 1 );
2460 next++; /* dont parse the escaped character */
2465 if ( strchr( sep, *next ) != NULL ) {
2466 strtok_quote_ptr = next;
2479 static char buf[BUFSIZ];
2481 static int lmax, lcur;
2483 #define CATLINE( buf ) { \
2485 len = strlen( buf ); \
2486 while ( lcur + len + 1 > lmax ) { \
2488 line = (char *) ch_realloc( line, lmax ); \
2490 strcpy( line + lcur, buf ); \
2495 fp_getline( FILE *fp, int *lineno )
2503 /* hack attack - keeps us from having to keep a stack of bufs... */
2504 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2509 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2510 /* trim off \r\n or \n */
2511 if ( (p = strchr( buf, '\n' )) != NULL ) {
2512 if( p > buf && p[-1] == '\r' ) --p;
2516 /* trim off trailing \ and append the next line */
2517 if ( line[ 0 ] != '\0'
2518 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2519 && p[ -1 ] != '\\' ) {
2524 if ( ! isspace( (unsigned char) buf[0] ) ) {
2528 /* change leading whitespace to a space */
2537 return( line[0] ? line : NULL );
2541 fp_getline_init( int *lineno )
2547 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2549 load_ucdata( char *path )
2551 static int loaded = 0;
2557 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2560 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2561 "load_ucdata: Error %d loading ucdata.\n", err ));
2563 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2576 ucdata_unload( UCDATA_ALL );
2578 if ( slapd_args_file )
2579 free ( slapd_args_file );
2580 if ( slapd_pid_file )
2581 free ( slapd_pid_file );
2582 acl_destroy( global_acl, NULL );