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 */
34 #ifdef LDAP_CONTROL_PAGEDRESULTS
37 0 /* hide number of entries left */
38 #endif /* LDAP_CONTROL_PAGEDRESULTS */
41 AccessControl *global_acl = NULL;
42 slap_access_t global_default_access = ACL_READ;
43 slap_mask_t global_restrictops = 0;
44 slap_mask_t global_allows = 0;
45 slap_mask_t global_disallows = 0;
46 slap_mask_t global_requires = 0;
47 slap_ssf_set_t global_ssf_set;
49 int global_gentlehup = 0;
50 int global_idletimeout = 0;
51 char *global_host = NULL;
52 char *global_realm = NULL;
53 char *ldap_srvtab = "";
54 char *default_passwd_hash = NULL;
55 int cargc = 0, cargv_size = 0;
57 struct berval default_search_base = { 0, NULL };
58 struct berval default_search_nbase = { 0, NULL };
59 unsigned num_subordinates = 0;
60 struct berval global_schemadn = { 0, NULL };
61 struct berval global_schemandn = { 0, NULL };
63 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
64 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
66 char *slapd_pid_file = NULL;
67 char *slapd_args_file = NULL;
69 char *strtok_quote_ptr;
72 int use_reverse_lookup = 1;
73 #else /* !SLAPD_RLOOKUPS */
74 int use_reverse_lookup = 0;
75 #endif /* !SLAPD_RLOOKUPS */
77 static char *fp_getline(FILE *fp, int *lineno);
78 static void fp_getline_init(int *lineno);
79 static int fp_parse_line(int lineno, char *line);
81 static char *strtok_quote(char *line, char *sep);
82 static int load_ucdata(char *path);
85 read_config( const char *fname, int depth )
88 char *line, *savefname, *saveline;
92 struct berval vals[2];
94 static int lastmod = 1;
95 static BackendInfo *bi = NULL;
96 static BackendDB *be = NULL;
98 vals[1].bv_val = NULL;
101 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
102 cargv_size = ARGS_STEP + 1;
105 if ( (fp = fopen( fname, "r" )) == NULL ) {
108 LDAP_LOG( CONFIG, ENTRY,
109 "read_config: " "could not open config file \"%s\": %s (%d)\n",
110 fname, strerror(errno), errno );
112 Debug( LDAP_DEBUG_ANY,
113 "could not open config file \"%s\": %s (%d)\n",
114 fname, strerror(errno), errno );
120 LDAP_LOG( CONFIG, ENTRY,
121 "read_config: reading config file %s\n", fname, 0, 0 );
123 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
127 fp_getline_init( &lineno );
129 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
130 /* skip comments and blank lines */
131 if ( line[0] == '#' || line[0] == '\0' ) {
135 /* fp_parse_line is destructive, we save a copy */
136 saveline = ch_strdup( line );
138 if ( fp_parse_line( lineno, line ) != 0 ) {
144 LDAP_LOG( CONFIG, INFO,
145 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
147 Debug( LDAP_DEBUG_ANY,
148 "%s: line %d: bad config line (ignored)\n",
155 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
158 LDAP_LOG( CONFIG, CRIT,
159 "%s : line %d: missing type in \"backend\" line.\n",
162 Debug( LDAP_DEBUG_ANY,
163 "%s: line %d: missing type in \"backend <type>\" line\n",
172 LDAP_LOG( CONFIG, CRIT,
173 "%s: line %d: backend line must appear before any "
174 "database definition.\n", fname, lineno , 0 );
176 Debug( LDAP_DEBUG_ANY,
177 "%s: line %d: backend line must appear before any database definition\n",
184 bi = backend_info( cargv[1] );
188 LDAP_LOG( CONFIG, CRIT,
189 "read_config: backend %s initialization failed.\n",
192 Debug( LDAP_DEBUG_ANY,
193 "backend %s initialization failed.\n",
199 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
202 LDAP_LOG( CONFIG, CRIT,
203 "%s: line %d: missing type in \"database <type>\" line\n",
206 Debug( LDAP_DEBUG_ANY,
207 "%s: line %d: missing type in \"database <type>\" line\n",
215 be = backend_db_init( cargv[1] );
219 LDAP_LOG( CONFIG, CRIT,
220 "database %s initialization failed.\n", cargv[1], 0, 0 );
222 Debug( LDAP_DEBUG_ANY,
223 "database %s initialization failed.\n",
230 /* set thread concurrency */
231 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
235 LDAP_LOG( CONFIG, CRIT,
236 "%s: line %d: missing level in \"concurrency <level\" "
237 " line\n", fname, lineno, 0 );
239 Debug( LDAP_DEBUG_ANY,
240 "%s: line %d: missing level in \"concurrency <level>\" line\n",
247 c = atoi( cargv[1] );
251 LDAP_LOG( CONFIG, CRIT,
252 "%s: line %d: invalid level (%d) in "
253 "\"concurrency <level>\" line.\n", fname, lineno, c );
255 Debug( LDAP_DEBUG_ANY,
256 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
263 ldap_pvt_thread_set_concurrency( c );
265 /* set sockbuf max */
266 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
270 LDAP_LOG( CONFIG, CRIT,
271 "%s: line %d: missing max in \"sockbuf_max_incoming "
272 "<bytes>\" line\n", fname, lineno, 0 );
274 Debug( LDAP_DEBUG_ANY,
275 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
282 max = atol( cargv[1] );
286 LDAP_LOG( CONFIG, CRIT,
287 "%s: line %d: invalid max value (%ld) in "
288 "\"sockbuf_max_incoming <bytes>\" line.\n",
289 fname, lineno, max );
291 Debug( LDAP_DEBUG_ANY,
292 "%s: line %d: invalid max value (%ld) in "
293 "\"sockbuf_max_incoming <bytes>\" line.\n",
294 fname, lineno, max );
300 sockbuf_max_incoming = max;
302 /* set sockbuf max authenticated */
303 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
307 LDAP_LOG( CONFIG, CRIT,
308 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
309 "<bytes>\" line\n", fname, lineno, 0 );
311 Debug( LDAP_DEBUG_ANY,
312 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
319 max = atol( cargv[1] );
323 LDAP_LOG( CONFIG, CRIT,
324 "%s: line %d: invalid max value (%ld) in "
325 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
326 fname, lineno, max );
328 Debug( LDAP_DEBUG_ANY,
329 "%s: line %d: invalid max value (%ld) in "
330 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
331 fname, lineno, max );
337 sockbuf_max_incoming_auth = max;
339 /* default search base */
340 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
343 LDAP_LOG( CONFIG, CRIT,
344 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
345 "line\n", fname, lineno, 0 );
347 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
348 "missing dn in \"defaultSearchBase <dn>\" line\n",
354 } else if ( cargc > 2 ) {
356 LDAP_LOG( CONFIG, INFO,
357 "%s: line %d: extra cruft after <dn> in "
358 "\"defaultSearchBase %s\" line (ignored)\n",
359 fname, lineno, cargv[1] );
361 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
362 "extra cruft after <dn> in \"defaultSearchBase %s\", "
364 fname, lineno, cargv[1] );
368 if ( bi != NULL || be != NULL ) {
370 LDAP_LOG( CONFIG, CRIT,
371 "%s: line %d: defaultSearchBase line must appear "
372 "prior to any backend or database definitions\n",
375 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
376 "defaultSearchBaase line must appear prior to "
377 "any backend or database definition\n",
384 if ( default_search_nbase.bv_len ) {
386 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
387 "default search base \"%s\" already defined "
388 "(discarding old)\n", fname, lineno,
389 default_search_base.bv_val );
391 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
392 "default search base \"%s\" already defined "
393 "(discarding old)\n",
394 fname, lineno, default_search_base.bv_val );
397 free( default_search_base.bv_val );
398 free( default_search_nbase.bv_val );
401 if ( load_ucdata( NULL ) < 0 ) return 1;
406 dn.bv_val = cargv[1];
407 dn.bv_len = strlen( dn.bv_val );
409 rc = dnPrettyNormal( NULL, &dn,
410 &default_search_base,
411 &default_search_nbase );
413 if( rc != LDAP_SUCCESS ) {
415 LDAP_LOG( CONFIG, CRIT,
416 "%s: line %d: defaultSearchBase DN is invalid.\n",
419 Debug( LDAP_DEBUG_ANY,
420 "%s: line %d: defaultSearchBase DN is invalid\n",
427 /* set maximum threads in thread pool */
428 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
432 LDAP_LOG( CONFIG, CRIT,
433 "%s: line %d: missing count in \"threads <count>\" line\n",
436 Debug( LDAP_DEBUG_ANY,
437 "%s: line %d: missing count in \"threads <count>\" line\n",
444 c = atoi( cargv[1] );
448 LDAP_LOG( CONFIG, CRIT,
449 "%s: line %d: invalid level (%d) in \"threads <count>\""
450 "line\n", fname, lineno, c );
452 Debug( LDAP_DEBUG_ANY,
453 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
460 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
462 /* save for later use */
463 connection_pool_max = c;
465 /* get pid file name */
466 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
469 LDAP_LOG( CONFIG, CRIT,
470 "%s: line %d missing file name in \"pidfile <file>\" "
471 "line.\n", fname, lineno, 0 );
473 Debug( LDAP_DEBUG_ANY,
474 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
481 slapd_pid_file = ch_strdup( cargv[1] );
483 /* get args file name */
484 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
487 LDAP_LOG( CONFIG, CRIT,
488 "%s: %d: missing file name in "
489 "\"argsfile <file>\" line.\n",
492 Debug( LDAP_DEBUG_ANY,
493 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
500 slapd_args_file = ch_strdup( cargv[1] );
502 /* default password hash */
503 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
506 LDAP_LOG( CONFIG, CRIT,
507 "%s: line %d: missing hash in "
508 "\"password-hash <hash>\" line.\n",
511 Debug( LDAP_DEBUG_ANY,
512 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
518 if ( default_passwd_hash != NULL ) {
520 LDAP_LOG( CONFIG, CRIT,
521 "%s: line %d: already set default password_hash!\n",
524 Debug( LDAP_DEBUG_ANY,
525 "%s: line %d: already set default password_hash!\n",
533 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
535 LDAP_LOG( CONFIG, CRIT,
536 "%s: line %d: password scheme \"%s\" not available\n",
537 fname, lineno, cargv[1] );
539 Debug( LDAP_DEBUG_ANY,
540 "%s: line %d: password scheme \"%s\" not available\n",
541 fname, lineno, cargv[1] );
546 default_passwd_hash = ch_strdup( cargv[1] );
548 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
552 LDAP_LOG( CONFIG, CRIT,
553 "%s: line %d: missing format in "
554 "\"password-crypt-salt-format <format>\" line\n",
557 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
558 "\"password-crypt-salt-format <format>\" line\n",
565 lutil_salt_format( cargv[1] );
567 #ifdef HAVE_CYRUS_SASL
568 /* SASL config options */
569 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
570 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
572 #endif /* HAVE_CYRUS_SASL */
574 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
578 LDAP_LOG( CONFIG, CRIT,
579 "%s: line %d: missing dn in "
580 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
582 Debug( LDAP_DEBUG_ANY,
583 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
588 ber_str2bv( cargv[1], 0, 0, &dn );
590 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
593 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
596 if ( rc != LDAP_SUCCESS ) {
598 LDAP_LOG( CONFIG, CRIT,
599 "%s: line %d: schemadn DN is invalid.\n",
602 Debug( LDAP_DEBUG_ANY,
603 "%s: line %d: schemadn DN is invalid\n",
609 /* set UCDATA path */
610 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
614 LDAP_LOG( CONFIG, CRIT,
615 "%s: line %d: missing path in "
616 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
618 Debug( LDAP_DEBUG_ANY,
619 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
626 err = load_ucdata( cargv[1] );
630 LDAP_LOG( CONFIG, CRIT,
631 "%s: line %d: ucdata already loaded, ucdata-path "
632 "must be set earlier in the file and/or be "
633 "specified only once!\n", fname, lineno, 0 );
635 Debug( LDAP_DEBUG_ANY,
636 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
645 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
647 struct slap_limits_set *lim;
651 LDAP_LOG( CONFIG, CRIT,
652 "%s: line %d: missing limit in \"sizelimit <limit>\" "
653 "line.\n", fname, lineno, 0 );
655 Debug( LDAP_DEBUG_ANY,
656 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
666 lim = &be->be_def_limit;
669 for ( i = 1; i < cargc; i++ ) {
670 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
671 rc = parse_limit( cargv[i], lim );
674 LDAP_LOG( CONFIG, CRIT,
675 "%s: line %d: unable "
676 "to parse value \"%s\" in \"sizelimit "
677 "<limit>\" line.\n", fname, lineno, cargv[i] );
679 Debug( LDAP_DEBUG_ANY,
680 "%s: line %d: unable "
681 "to parse value \"%s\" "
684 fname, lineno, cargv[i] );
690 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
691 lim->lms_s_soft = -1;
695 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
696 if ( next == cargv[i] ) {
698 LDAP_LOG( CONFIG, CRIT,
699 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
700 "line.\n", fname, lineno, cargv[i] );
702 Debug( LDAP_DEBUG_ANY,
703 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
704 fname, lineno, cargv[i] );
708 } else if ( next[0] != '\0' ) {
710 LDAP_LOG( CONFIG, CRIT,
711 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
712 "line ignored.\n", fname, lineno, next );
714 Debug( LDAP_DEBUG_ANY,
715 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
716 fname, lineno, next );
725 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
727 struct slap_limits_set *lim;
731 LDAP_LOG( CONFIG, CRIT,
732 "%s: line %d missing limit in \"timelimit <limit>\" "
733 "line.\n", fname, lineno, 0 );
735 Debug( LDAP_DEBUG_ANY,
736 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
746 lim = &be->be_def_limit;
749 for ( i = 1; i < cargc; i++ ) {
750 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
751 rc = parse_limit( cargv[i], lim );
754 LDAP_LOG( CONFIG, CRIT,
755 "%s: line %d: unable to parse value \"%s\" "
756 "in \"timelimit <limit>\" line.\n",
757 fname, lineno, cargv[i] );
759 Debug( LDAP_DEBUG_ANY,
760 "%s: line %d: unable "
761 "to parse value \"%s\" "
764 fname, lineno, cargv[i] );
770 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
771 lim->lms_t_soft = -1;
775 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
776 if ( next == cargv[i] ) {
778 LDAP_LOG( CONFIG, CRIT,
779 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
780 "line.\n", fname, lineno, cargv[i] );
782 Debug( LDAP_DEBUG_ANY,
783 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
784 fname, lineno, cargv[i] );
788 } else if ( next[0] != '\0' ) {
790 LDAP_LOG( CONFIG, CRIT,
791 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
792 "line ignored.\n", fname, lineno, next );
794 Debug( LDAP_DEBUG_ANY,
795 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
796 fname, lineno, next );
804 /* set regex-based limits */
805 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
808 LDAP_LOG( CONFIG, WARNING,
809 "%s: line %d \"limits\" allowed only in database "
810 "environment.\n", fname, lineno, 0 );
812 Debug( LDAP_DEBUG_ANY,
813 "%s: line %d \"limits\" allowed only in database environment.\n%s",
819 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
823 /* mark this as a subordinate database */
824 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
827 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
828 "subordinate keyword must appear inside a database "
829 "definition.\n", fname, lineno, 0 );
831 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
832 "must appear inside a database definition.\n",
838 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
842 /* set database suffix */
843 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
845 struct berval dn, pdn, ndn;
849 LDAP_LOG( CONFIG, CRIT,
850 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
853 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
854 "missing dn in \"suffix <dn>\" line\n",
860 } else if ( cargc > 2 ) {
862 LDAP_LOG( CONFIG, INFO,
863 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
864 " line (ignored).\n", fname, lineno, cargv[1] );
866 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
867 "after <dn> in \"suffix %s\" line (ignored)\n",
868 fname, lineno, cargv[1] );
874 LDAP_LOG( CONFIG, INFO,
875 "%s: line %d: suffix line must appear inside a database "
876 "definition.\n", fname, lineno, 0 );
878 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
879 "must appear inside a database definition\n",
884 #if defined(SLAPD_MONITOR_DN)
885 /* "cn=Monitor" is reserved for monitoring slap */
886 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
888 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
889 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
892 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
893 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
897 #endif /* SLAPD_MONITOR_DN */
900 if ( load_ucdata( NULL ) < 0 ) return 1;
902 dn.bv_val = cargv[1];
903 dn.bv_len = strlen( cargv[1] );
905 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
906 if( rc != LDAP_SUCCESS ) {
908 LDAP_LOG( CONFIG, CRIT,
909 "%s: line %d: suffix DN is invalid.\n",
912 Debug( LDAP_DEBUG_ANY,
913 "%s: line %d: suffix DN is invalid\n",
919 tmp_be = select_backend( &ndn, 0, 0 );
920 if ( tmp_be == be ) {
922 LDAP_LOG( CONFIG, INFO,
923 "%s: line %d: suffix already served by this backend "
924 "(ignored)\n", fname, lineno, 0 );
926 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
927 "already served by this backend (ignored)\n",
933 } else if ( tmp_be != NULL ) {
935 LDAP_LOG( CONFIG, INFO,
936 "%s: line %d: suffix already served by a preceding "
937 "backend \"%s\"\n", fname, lineno,
938 tmp_be->be_suffix[0].bv_val );
940 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
941 "already served by a preceeding backend \"%s\"\n",
942 fname, lineno, tmp_be->be_suffix[0].bv_val );
948 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
950 LDAP_LOG( CONFIG, INFO,
951 "%s: line %d: suffix DN empty and default search "
952 "base provided \"%s\" (assuming okay).\n",
953 fname, lineno, default_search_base.bv_val );
955 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
956 "suffix DN empty and default "
957 "search base provided \"%s\" (assuming okay)\n",
958 fname, lineno, default_search_base.bv_val );
962 ber_bvarray_add( &be->be_suffix, &pdn );
963 ber_bvarray_add( &be->be_nsuffix, &ndn );
965 /* set database suffixAlias */
966 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
968 struct berval alias, palias, nalias;
969 struct berval aliased, paliased, naliased;
973 LDAP_LOG( CONFIG, CRIT,
974 "%s: line %d: missing alias and aliased_dn in "
975 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
978 Debug( LDAP_DEBUG_ANY,
979 "%s: line %d: missing alias and aliased_dn in "
980 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
985 } else if ( cargc < 3 ) {
987 LDAP_LOG( CONFIG, CRIT,
988 "%s: line %d: missing aliased_dn in "
989 "\"suffixAlias <alias> <aliased_dn>\" line\n",
992 Debug( LDAP_DEBUG_ANY,
993 "%s: line %d: missing aliased_dn in "
994 "\"suffixAlias <alias> <aliased_dn>\" line\n",
999 } else if ( cargc > 3 ) {
1001 LDAP_LOG( CONFIG, CRIT,
1002 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1005 Debug( LDAP_DEBUG_ANY,
1006 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1013 LDAP_LOG( CONFIG, INFO,
1014 "%s: line %d: suffix line must appear inside a database "
1015 "definition.\n", fname, lineno, 0 );
1017 Debug( LDAP_DEBUG_ANY,
1018 "%s: line %d: suffixAlias line"
1019 " must appear inside a database definition.\n",
1025 if ( load_ucdata( NULL ) < 0 ) return 1;
1027 alias.bv_val = cargv[1];
1028 alias.bv_len = strlen( cargv[1] );
1030 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
1031 if( rc != LDAP_SUCCESS ) {
1033 LDAP_LOG( CONFIG, CRIT,
1034 "%s: line %d: alias DN is invalid.\n", fname, lineno, 0 );
1036 Debug( LDAP_DEBUG_ANY,
1037 "%s: line %d: alias DN is invalid\n",
1043 tmp_be = select_backend( &nalias, 0, 0 );
1044 free( nalias.bv_val );
1045 if ( tmp_be && tmp_be != be ) {
1047 LDAP_LOG( CONFIG, INFO,
1048 "%s: line %d: suffixAlias served by a preceeding "
1049 "backend \"%s\"\n", fname, lineno,
1050 tmp_be->be_suffix[0].bv_val );
1052 Debug( LDAP_DEBUG_ANY,
1053 "%s: line %d: suffixAlias served by"
1054 " a preceeding backend \"%s\"\n",
1055 fname, lineno, tmp_be->be_suffix[0].bv_val );
1057 free( palias.bv_val );
1061 aliased.bv_val = cargv[2];
1062 aliased.bv_len = strlen( cargv[2] );
1064 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
1065 if( rc != LDAP_SUCCESS ) {
1067 LDAP_LOG( CONFIG, CRIT,
1068 "%s: line %d: aliased DN is invalid.\n", fname, lineno,0 );
1070 Debug( LDAP_DEBUG_ANY,
1071 "%s: line %d: aliased DN is invalid\n",
1074 free( palias.bv_val );
1078 tmp_be = select_backend( &naliased, 0, 0 );
1079 free( naliased.bv_val );
1080 if ( tmp_be && tmp_be != be ) {
1082 LDAP_LOG( CONFIG, INFO,
1083 "%s: line %d: suffixAlias derefs to a different backend "
1084 "a preceeding backend \"%s\"\n",
1085 fname, lineno, tmp_be->be_suffix[0].bv_val );
1087 Debug( LDAP_DEBUG_ANY,
1088 "%s: line %d: suffixAlias derefs to differnet backend"
1089 " a preceeding backend \"%s\"\n",
1090 fname, lineno, tmp_be->be_suffix[0].bv_val );
1092 free( palias.bv_val );
1093 free( paliased.bv_val );
1097 ber_bvarray_add( &be->be_suffixAlias, &palias );
1098 ber_bvarray_add( &be->be_suffixAlias, &paliased );
1100 /* set max deref depth */
1101 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1105 LDAP_LOG( CONFIG, CRIT,
1106 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1107 " line\n", fname, lineno, 0 );
1109 Debug( LDAP_DEBUG_ANY,
1110 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1118 LDAP_LOG( CONFIG, INFO,
1119 "%s: line %d: depth line must appear inside a database "
1120 "definition.\n", fname, lineno ,0 );
1122 Debug( LDAP_DEBUG_ANY,
1123 "%s: line %d: depth line must appear inside a database definition.\n",
1128 } else if ((i = atoi(cargv[1])) < 0) {
1130 LDAP_LOG( CONFIG, INFO,
1131 "%s: line %d: depth must be positive.\n",
1134 Debug( LDAP_DEBUG_ANY,
1135 "%s: line %d: depth must be positive.\n",
1142 be->be_max_deref_depth = i;
1146 /* set magic "root" dn for this database */
1147 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1150 LDAP_LOG( CONFIG, INFO,
1151 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1154 Debug( LDAP_DEBUG_ANY,
1155 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1164 LDAP_LOG( CONFIG, INFO,
1165 "%s: line %d: rootdn line must appear inside a database "
1166 "definition.\n", fname, lineno ,0 );
1168 Debug( LDAP_DEBUG_ANY,
1169 "%s: line %d: rootdn line must appear inside a database definition.\n",
1177 if ( load_ucdata( NULL ) < 0 ) return 1;
1179 dn.bv_val = cargv[1];
1180 dn.bv_len = strlen( cargv[1] );
1182 rc = dnPrettyNormal( NULL, &dn,
1186 if( rc != LDAP_SUCCESS ) {
1188 LDAP_LOG( CONFIG, CRIT,
1189 "%s: line %d: rootdn DN is invalid.\n",
1192 Debug( LDAP_DEBUG_ANY,
1193 "%s: line %d: rootdn DN is invalid\n",
1200 /* set super-secret magic database password */
1201 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1204 LDAP_LOG( CONFIG, CRIT,
1205 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1206 " line\n", fname, lineno ,0 );
1208 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1209 "missing passwd in \"rootpw <passwd>\" line\n",
1218 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1219 "rootpw line must appear inside a database "
1220 "definition.\n", fname, lineno ,0 );
1222 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1223 "rootpw line must appear inside a database "
1230 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1232 if( tmp_be != be ) {
1234 LDAP_LOG( CONFIG, INFO,
1236 "rootpw can only be set when rootdn is under suffix\n",
1237 fname, lineno, "" );
1239 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1240 "rootpw can only be set when rootdn is under suffix\n",
1246 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1247 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1250 /* make this database read-only */
1251 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1254 LDAP_LOG( CONFIG, CRIT,
1255 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1256 "line.\n", fname, lineno ,0 );
1258 Debug( LDAP_DEBUG_ANY,
1259 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1266 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1267 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1269 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1272 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1273 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1275 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1280 /* allow these features */
1281 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1282 strcasecmp( cargv[0], "allow" ) == 0 )
1288 LDAP_LOG( CONFIG, INFO,
1289 "%s: line %d: allow line must appear prior to "
1290 "database definitions.\n", fname, lineno ,0 );
1292 Debug( LDAP_DEBUG_ANY,
1293 "%s: line %d: allow line must appear prior to database definitions\n",
1301 LDAP_LOG( CONFIG, CRIT,
1302 "%s: line %d: missing feature(s) in \"allow <features>\""
1303 " line\n", fname, lineno ,0 );
1305 Debug( LDAP_DEBUG_ANY,
1306 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1315 for( i=1; i < cargc; i++ ) {
1316 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1317 allows |= SLAP_ALLOW_BIND_V2;
1319 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1320 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1322 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1323 allows |= SLAP_ALLOW_BIND_ANON_DN;
1325 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1326 allows |= SLAP_ALLOW_UPDATE_ANON;
1328 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1330 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1331 "unknown feature %s in \"allow <features>\" line.\n",
1332 fname, lineno, cargv[1] );
1334 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1335 "unknown feature %s in \"allow <features>\" line\n",
1336 fname, lineno, cargv[i] );
1343 global_allows = allows;
1345 /* disallow these features */
1346 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1347 strcasecmp( cargv[0], "disallow" ) == 0 )
1349 slap_mask_t disallows;
1353 LDAP_LOG( CONFIG, INFO,
1354 "%s: line %d: disallow line must appear prior to "
1355 "database definitions.\n", fname, lineno ,0 );
1357 Debug( LDAP_DEBUG_ANY,
1358 "%s: line %d: disallow line must appear prior to database definitions\n",
1366 LDAP_LOG( CONFIG, CRIT,
1367 "%s: line %d: missing feature(s) in \"disallow <features>\""
1368 " line.\n", fname, lineno ,0 );
1370 Debug( LDAP_DEBUG_ANY,
1371 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1380 for( i=1; i < cargc; i++ ) {
1381 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1382 disallows |= SLAP_DISALLOW_BIND_ANON;
1384 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1385 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1387 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1388 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1390 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1391 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1393 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1394 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1396 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1398 LDAP_LOG( CONFIG, CRIT,
1399 "%s: line %d: unknown feature %s in "
1400 "\"disallow <features>\" line.\n",
1401 fname, lineno, cargv[i] );
1403 Debug( LDAP_DEBUG_ANY,
1404 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1405 fname, lineno, cargv[i] );
1412 global_disallows = disallows;
1414 /* require these features */
1415 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1416 strcasecmp( cargv[0], "require" ) == 0 )
1418 slap_mask_t requires;
1422 LDAP_LOG( CONFIG, CRIT,
1423 "%s: line %d: missing feature(s) in "
1424 "\"require <features>\" line.\n", fname, lineno ,0 );
1426 Debug( LDAP_DEBUG_ANY,
1427 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1436 for( i=1; i < cargc; i++ ) {
1437 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1438 requires |= SLAP_REQUIRE_BIND;
1440 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1441 requires |= SLAP_REQUIRE_LDAP_V3;
1443 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1444 requires |= SLAP_REQUIRE_AUTHC;
1446 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1447 requires |= SLAP_REQUIRE_SASL;
1449 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1450 requires |= SLAP_REQUIRE_STRONG;
1452 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1454 LDAP_LOG( CONFIG, CRIT,
1455 "%s: line %d: unknown feature %s in "
1456 "\"require <features>\" line.\n",
1457 fname, lineno , cargv[i] );
1459 Debug( LDAP_DEBUG_ANY,
1460 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1461 fname, lineno, cargv[i] );
1469 global_requires = requires;
1471 be->be_requires = requires;
1474 /* required security factors */
1475 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1476 slap_ssf_set_t *set;
1480 LDAP_LOG( CONFIG, CRIT,
1481 "%s: line %d: missing factor(s) in \"security <factors>\""
1482 " line.\n", fname, lineno ,0 );
1484 Debug( LDAP_DEBUG_ANY,
1485 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1493 set = &global_ssf_set;
1495 set = &be->be_ssf_set;
1498 for( i=1; i < cargc; i++ ) {
1499 if( strncasecmp( cargv[i], "ssf=",
1500 sizeof("ssf") ) == 0 )
1503 atoi( &cargv[i][sizeof("ssf")] );
1505 } else if( strncasecmp( cargv[i], "transport=",
1506 sizeof("transport") ) == 0 )
1508 set->sss_transport =
1509 atoi( &cargv[i][sizeof("transport")] );
1511 } else if( strncasecmp( cargv[i], "tls=",
1512 sizeof("tls") ) == 0 )
1515 atoi( &cargv[i][sizeof("tls")] );
1517 } else if( strncasecmp( cargv[i], "sasl=",
1518 sizeof("sasl") ) == 0 )
1521 atoi( &cargv[i][sizeof("sasl")] );
1523 } else if( strncasecmp( cargv[i], "update_ssf=",
1524 sizeof("update_ssf") ) == 0 )
1526 set->sss_update_ssf =
1527 atoi( &cargv[i][sizeof("update_ssf")] );
1529 } else if( strncasecmp( cargv[i], "update_transport=",
1530 sizeof("update_transport") ) == 0 )
1532 set->sss_update_transport =
1533 atoi( &cargv[i][sizeof("update_transport")] );
1535 } else if( strncasecmp( cargv[i], "update_tls=",
1536 sizeof("update_tls") ) == 0 )
1538 set->sss_update_tls =
1539 atoi( &cargv[i][sizeof("update_tls")] );
1541 } else if( strncasecmp( cargv[i], "update_sasl=",
1542 sizeof("update_sasl") ) == 0 )
1544 set->sss_update_sasl =
1545 atoi( &cargv[i][sizeof("update_sasl")] );
1547 } else if( strncasecmp( cargv[i], "simple_bind=",
1548 sizeof("simple_bind") ) == 0 )
1550 set->sss_simple_bind =
1551 atoi( &cargv[i][sizeof("simple_bind")] );
1555 LDAP_LOG( CONFIG, CRIT,
1556 "%s: line %d: unknown factor %S in "
1557 "\"security <factors>\" line.\n",
1558 fname, lineno, cargv[1] );
1560 Debug( LDAP_DEBUG_ANY,
1561 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1562 fname, lineno, cargv[i] );
1568 /* where to send clients when we don't hold it */
1569 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1572 LDAP_LOG( CONFIG, CRIT,
1573 "%s: line %d: missing URL in \"referral <URL>\""
1574 " line.\n", fname, lineno , 0 );
1576 Debug( LDAP_DEBUG_ANY,
1577 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1584 if( validate_global_referral( cargv[1] ) ) {
1586 LDAP_LOG( CONFIG, CRIT,
1587 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1588 fname, lineno, cargv[1] );
1590 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1591 "invalid URL (%s) in \"referral\" line.\n",
1592 fname, lineno, cargv[1] );
1597 vals[0].bv_val = cargv[1];
1598 vals[0].bv_len = strlen( vals[0].bv_val );
1599 if( value_add( &default_referral, vals ) )
1603 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1607 LDAP_LOG( CONFIG, CRIT,
1608 "%s: line %d: Error in logfile directive, "
1609 "\"logfile <filename>\"\n", fname, lineno , 0 );
1611 Debug( LDAP_DEBUG_ANY,
1612 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1618 logfile = fopen( cargv[1], "w" );
1619 if ( logfile != NULL ) lutil_debug_file( logfile );
1622 /* start of a new database definition */
1623 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1627 LDAP_LOG( CONFIG, CRIT,
1628 "%s: line %d: Error in debug directive, "
1629 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1631 Debug( LDAP_DEBUG_ANY,
1632 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1638 level = atoi( cargv[2] );
1639 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1640 lutil_set_debug_level( cargv[1], level );
1641 /* specify an Object Identifier macro */
1642 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1643 rc = parse_oidm( fname, lineno, cargc, cargv );
1646 /* specify an objectclass */
1647 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1648 if ( *cargv[1] == '(' /*')'*/) {
1650 p = strchr(saveline,'(' /*')'*/);
1651 rc = parse_oc( fname, lineno, p, cargv );
1656 LDAP_LOG( CONFIG, INFO,
1657 "%s: line %d: old objectclass format not supported\n",
1658 fname, lineno , 0 );
1660 Debug( LDAP_DEBUG_ANY,
1661 "%s: line %d: old objectclass format not supported.\n",
1666 #ifdef SLAP_EXTENDED_SCHEMA
1667 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1669 p = strchr(saveline,'(' /*')'*/);
1670 rc = parse_cr( fname, lineno, p, cargv );
1674 /* specify an attribute type */
1675 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1676 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1678 if ( *cargv[1] == '(' /*')'*/) {
1680 p = strchr(saveline,'(' /*')'*/);
1681 rc = parse_at( fname, lineno, p, cargv );
1686 LDAP_LOG( CONFIG, INFO,
1687 "%s: line %d: old attribute type format not supported.\n",
1688 fname, lineno , 0 );
1690 Debug( LDAP_DEBUG_ANY,
1691 "%s: line %d: old attribute type format not supported.\n",
1697 /* turn on/off schema checking */
1698 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1701 LDAP_LOG( CONFIG, CRIT,
1702 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1703 " line.\n", fname, lineno , 0 );
1705 Debug( LDAP_DEBUG_ANY,
1706 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1712 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1714 LDAP_LOG( CONFIG, CRIT,
1715 "%s: line %d: schema checking disabled! your mileage may "
1716 "vary!\n", fname, lineno , 0 );
1718 Debug( LDAP_DEBUG_ANY,
1719 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1722 global_schemacheck = 0;
1724 global_schemacheck = 1;
1727 /* specify access control info */
1728 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1729 parse_acl( be, fname, lineno, cargc, cargv );
1731 /* debug level to log things to syslog */
1732 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1735 LDAP_LOG( CONFIG, CRIT,
1736 "%s: line %d: missing level in \"loglevel <level>\""
1737 " line.\n", fname, lineno , 0 );
1739 Debug( LDAP_DEBUG_ANY,
1740 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1749 for( i=1; i < cargc; i++ ) {
1750 ldap_syslog += atoi( cargv[1] );
1753 /* list of replicas of the data in this backend (master only) */
1754 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1757 LDAP_LOG( CONFIG, CRIT,
1758 "%s: line %d: missing host in \"replica "
1759 " <host[:port]\" line\n", fname, lineno , 0 );
1761 Debug( LDAP_DEBUG_ANY,
1762 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1770 LDAP_LOG( CONFIG, INFO,
1771 "%s: line %d: replica line must appear inside "
1772 "a database definition.\n", fname, lineno, 0);
1774 Debug( LDAP_DEBUG_ANY,
1775 "%s: line %d: replica line must appear inside a database definition\n",
1783 for ( i = 1; i < cargc; i++ ) {
1784 if ( strncasecmp( cargv[i], "host=", 5 )
1786 nr = add_replica_info( be,
1793 LDAP_LOG( CONFIG, INFO,
1794 "%s: line %d: missing host in \"replica\" line\n",
1795 fname, lineno , 0 );
1797 Debug( LDAP_DEBUG_ANY,
1798 "%s: line %d: missing host in \"replica\" line\n",
1803 } else if ( nr == -1 ) {
1805 LDAP_LOG( CONFIG, INFO,
1806 "%s: line %d: unable to add"
1807 " replica \"%s\"\n",
1811 Debug( LDAP_DEBUG_ANY,
1812 "%s: line %d: unable to add replica \"%s\"\n",
1813 fname, lineno, cargv[i] + 5 );
1817 for ( i = 1; i < cargc; i++ ) {
1818 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1820 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1823 LDAP_LOG( CONFIG, INFO,
1824 "%s: line %d: suffix \"%s\" in \"replica\""
1825 " line is not valid for backend(ignored)\n",
1826 fname, lineno, cargv[i] + 7 );
1828 Debug( LDAP_DEBUG_ANY,
1829 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1830 fname, lineno, cargv[i] + 7 );
1836 LDAP_LOG( CONFIG, INFO,
1837 "%s: line %d: unable to normalize suffix"
1838 " in \"replica\" line (ignored)\n",
1839 fname, lineno , 0 );
1841 Debug( LDAP_DEBUG_ANY,
1842 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1848 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1850 char *arg = cargv[i] + 4;
1852 if ( arg[0] == '!' ) {
1857 if ( arg[0] != '=' ) {
1861 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1863 LDAP_LOG( CONFIG, INFO,
1864 "%s: line %d: attribute \"%s\" in "
1865 "\"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, CRIT,
1884 "%s: line %d: missing dn in \"updatedn <dn>\""
1885 " line.\n", fname, lineno , 0 );
1887 Debug( LDAP_DEBUG_ANY,
1888 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1896 LDAP_LOG( CONFIG, INFO,
1897 "%s: line %d: updatedn line must appear inside "
1898 "a database definition\n",
1899 fname, lineno , 0 );
1901 Debug( LDAP_DEBUG_ANY,
1902 "%s: line %d: updatedn line must appear inside a database definition\n",
1910 if ( load_ucdata( NULL ) < 0 ) return 1;
1912 dn.bv_val = cargv[1];
1913 dn.bv_len = strlen( cargv[1] );
1915 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1916 if( rc != LDAP_SUCCESS ) {
1918 LDAP_LOG( CONFIG, CRIT,
1919 "%s: line %d: updatedn DN is invalid.\n",
1920 fname, lineno , 0 );
1922 Debug( LDAP_DEBUG_ANY,
1923 "%s: line %d: updatedn DN is invalid\n",
1930 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1933 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1934 "missing url in \"updateref <ldapurl>\" line.\n",
1935 fname, lineno , 0 );
1937 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1938 "missing url in \"updateref <ldapurl>\" line\n",
1946 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
1947 " line must appear inside a database definition\n",
1948 fname, lineno , 0 );
1950 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1951 " line must appear inside a database definition\n",
1956 } else if ( !be->be_update_ndn.bv_len ) {
1958 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1959 "updateref line must come after updatedn.\n",
1960 fname, lineno , 0 );
1962 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1963 "updateref line must after updatedn.\n",
1969 if( validate_global_referral( cargv[1] ) ) {
1971 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1972 "invalid URL (%s) in \"updateref\" line.\n",
1973 fname, lineno, cargv[1] );
1975 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1976 "invalid URL (%s) in \"updateref\" line.\n",
1977 fname, lineno, cargv[1] );
1982 vals[0].bv_val = cargv[1];
1983 vals[0].bv_len = strlen( vals[0].bv_val );
1984 if( value_add( &be->be_update_refs, vals ) )
1987 /* replication log file to which changes are appended */
1988 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1991 LDAP_LOG( CONFIG, CRIT,
1992 "%s: line %d: missing filename in \"replogfile <filename>\""
1993 " line.\n", fname, lineno , 0 );
1995 Debug( LDAP_DEBUG_ANY,
1996 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2003 be->be_replogfile = ch_strdup( cargv[1] );
2005 replogfile = ch_strdup( cargv[1] );
2008 /* file from which to read additional rootdse attrs */
2009 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2012 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2013 "missing filename in \"rootDSE <filename>\" line.\n",
2014 fname, lineno , 0 );
2016 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2017 "missing filename in \"rootDSE <filename>\" line.\n",
2023 if( read_root_dse_file( cargv[1] ) ) {
2025 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2026 "could not read \"rootDSE <filename>\" line.\n",
2027 fname, lineno , 0 );
2029 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2030 "could not read \"rootDSE <filename>\" line\n",
2036 /* maintain lastmodified{by,time} attributes */
2037 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2040 LDAP_LOG( CONFIG, CRIT,
2041 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2042 " line.\n", fname, lineno , 0 );
2044 Debug( LDAP_DEBUG_ANY,
2045 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2051 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2053 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2059 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2066 /* turn on/off gentle SIGHUP handling */
2067 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2069 Debug( LDAP_DEBUG_ANY,
2070 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2074 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2075 global_gentlehup = 0;
2077 global_gentlehup = 1;
2081 /* set idle timeout value */
2082 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2086 LDAP_LOG( CONFIG, CRIT,
2087 "%s: line %d: missing timeout value in "
2088 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2090 Debug( LDAP_DEBUG_ANY,
2091 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2098 i = atoi( cargv[1] );
2102 LDAP_LOG( CONFIG, CRIT,
2103 "%s: line %d: timeout value (%d) invalid "
2104 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2106 Debug( LDAP_DEBUG_ANY,
2107 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2114 global_idletimeout = i;
2116 /* include another config file */
2117 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2120 LDAP_LOG( CONFIG, CRIT,
2121 "%s: line %d: missing filename in \"include "
2122 "<filename>\" line.\n", fname, lineno , 0 );
2124 Debug( LDAP_DEBUG_ANY,
2125 "%s: line %d: missing filename in \"include <filename>\" line\n",
2131 savefname = ch_strdup( cargv[1] );
2132 savelineno = lineno;
2134 if ( read_config( savefname, depth+1 ) != 0 ) {
2139 lineno = savelineno - 1;
2141 /* location of kerberos srvtab file */
2142 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2145 LDAP_LOG( CONFIG, CRIT,
2146 "%s: line %d: missing filename in \"srvtab "
2147 "<filename>\" line.\n", fname, lineno , 0 );
2149 Debug( LDAP_DEBUG_ANY,
2150 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2156 ldap_srvtab = ch_strdup( cargv[1] );
2158 #ifdef SLAPD_MODULES
2159 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2162 LDAP_LOG( CONFIG, INFO,
2163 "%s: line %d: missing filename in \"moduleload "
2164 "<filename>\" line.\n", fname, lineno , 0 );
2166 Debug( LDAP_DEBUG_ANY,
2167 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2171 exit( EXIT_FAILURE );
2173 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2175 LDAP_LOG( CONFIG, CRIT,
2176 "%s: line %d: failed to load or initialize module %s\n",
2177 fname, lineno, cargv[1] );
2179 Debug( LDAP_DEBUG_ANY,
2180 "%s: line %d: failed to load or initialize module %s\n",
2181 fname, lineno, cargv[1]);
2184 exit( EXIT_FAILURE );
2186 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2189 LDAP_LOG( CONFIG, INFO,
2190 "%s: line %d: missing path in \"modulepath <path>\""
2191 " line\n", fname, lineno , 0 );
2193 Debug( LDAP_DEBUG_ANY,
2194 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2198 exit( EXIT_FAILURE );
2200 if (module_path( cargv[1] )) {
2202 LDAP_LOG( CONFIG, CRIT,
2203 "%s: line %d: failed to set module search path to %s.\n",
2204 fname, lineno, cargv[1] );
2206 Debug( LDAP_DEBUG_ANY,
2207 "%s: line %d: failed to set module search path to %s\n",
2208 fname, lineno, cargv[1]);
2211 exit( EXIT_FAILURE );
2214 #endif /*SLAPD_MODULES*/
2217 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2218 rc = ldap_pvt_tls_set_option( NULL,
2219 LDAP_OPT_X_TLS_RANDOM_FILE,
2224 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2225 rc = ldap_pvt_tls_set_option( NULL,
2226 LDAP_OPT_X_TLS_CIPHER_SUITE,
2231 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2232 rc = ldap_pvt_tls_set_option( NULL,
2233 LDAP_OPT_X_TLS_CERTFILE,
2238 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2239 rc = ldap_pvt_tls_set_option( NULL,
2240 LDAP_OPT_X_TLS_KEYFILE,
2245 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2246 rc = ldap_pvt_tls_set_option( NULL,
2247 LDAP_OPT_X_TLS_CACERTDIR,
2252 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2253 rc = ldap_pvt_tls_set_option( NULL,
2254 LDAP_OPT_X_TLS_CACERTFILE,
2258 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2259 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2261 rc = ldap_pvt_tls_set_option( NULL,
2262 LDAP_OPT_X_TLS_REQUIRE_CERT,
2265 rc = ldap_int_tls_config( NULL,
2266 LDAP_OPT_X_TLS_REQUIRE_CERT,
2275 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2276 #ifdef SLAPD_RLOOKUPS
2279 LDAP_LOG( CONFIG, INFO,
2280 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2281 fname, lineno , 0 );
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, INFO,
2297 "%s: line %d: reverse-lookup: "
2298 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2300 Debug( LDAP_DEBUG_ANY,
2301 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2307 #else /* !SLAPD_RLOOKUPS */
2309 LDAP_LOG( CONFIG, INFO,
2310 "%s: line %d: reverse lookups "
2311 "are not configured (ignored).\n", fname, lineno , 0 );
2313 Debug( LDAP_DEBUG_ANY,
2314 "%s: line %d: reverse lookups are not configured (ignored).\n",
2317 #endif /* !SLAPD_RLOOKUPS */
2319 /* pass anything else to the current backend info/db config routine */
2322 if ( bi->bi_config == 0 ) {
2324 LDAP_LOG( CONFIG, INFO,
2325 "%s: line %d: unknown directive \"%s\" inside "
2326 "backend info definition (ignored).\n",
2327 fname, lineno, cargv[0] );
2329 Debug( LDAP_DEBUG_ANY,
2330 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2331 fname, lineno, cargv[0] );
2335 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2341 } else if ( be != NULL ) {
2342 if ( be->be_config == 0 ) {
2344 LDAP_LOG( CONFIG, INFO,
2345 "%s: line %d: uknown directive \"%s\" inside "
2346 "backend database definition (ignored).\n",
2347 fname, lineno, cargv[0] );
2349 Debug( LDAP_DEBUG_ANY,
2350 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2351 fname, lineno, cargv[0] );
2355 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2363 LDAP_LOG( CONFIG, INFO,
2364 "%s: line %d: unknown directive \"%s\" outside backend "
2365 "info and database definitions (ignored).\n",
2366 fname, lineno, cargv[0] );
2368 Debug( LDAP_DEBUG_ANY,
2369 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2370 fname, lineno, cargv[0] );
2379 if ( depth == 0 ) ch_free( cargv );
2381 if ( !global_schemadn.bv_val ) {
2382 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2384 dnNormalize2( NULL, &global_schemadn, &global_schemandn );
2387 if ( load_ucdata( NULL ) < 0 ) return 1;
2399 char logbuf[sizeof("pseudorootpw ***")];
2402 token = strtok_quote( line, " \t" );
2406 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2407 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2408 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2409 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2410 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2412 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2415 if ( strtok_quote_ptr ) {
2416 *strtok_quote_ptr = ' ';
2420 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2422 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2425 if ( strtok_quote_ptr ) {
2426 *strtok_quote_ptr = '\0';
2429 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2430 if ( cargc == cargv_size - 1 ) {
2432 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2434 if ( tmp == NULL ) {
2436 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2438 Debug( LDAP_DEBUG_ANY,
2439 "line %d: out of memory\n",
2445 cargv_size += ARGS_STEP;
2447 cargv[cargc++] = token;
2449 cargv[cargc] = NULL;
2454 strtok_quote( char *line, char *sep )
2460 strtok_quote_ptr = NULL;
2461 if ( line != NULL ) {
2464 while ( *next && strchr( sep, *next ) ) {
2468 if ( *next == '\0' ) {
2474 for ( inquote = 0; *next; ) {
2482 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2488 next + 1, strlen( next + 1 ) + 1 );
2489 next++; /* dont parse the escaped character */
2494 if ( strchr( sep, *next ) != NULL ) {
2495 strtok_quote_ptr = next;
2508 static char buf[BUFSIZ];
2510 static size_t lmax, lcur;
2512 #define CATLINE( buf ) \
2514 size_t len = strlen( buf ); \
2515 while ( lcur + len + 1 > lmax ) { \
2517 line = (char *) ch_realloc( line, lmax ); \
2519 strcpy( line + lcur, buf ); \
2524 fp_getline( FILE *fp, int *lineno )
2532 /* hack attack - keeps us from having to keep a stack of bufs... */
2533 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2538 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2539 /* trim off \r\n or \n */
2540 if ( (p = strchr( buf, '\n' )) != NULL ) {
2541 if( p > buf && p[-1] == '\r' ) --p;
2545 /* trim off trailing \ and append the next line */
2546 if ( line[ 0 ] != '\0'
2547 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2548 && p[ -1 ] != '\\' ) {
2553 if ( ! isspace( (unsigned char) buf[0] ) ) {
2557 /* change leading whitespace to a space */
2566 return( line[0] ? line : NULL );
2570 fp_getline_init( int *lineno )
2576 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2578 load_ucdata( char *path )
2580 static int loaded = 0;
2586 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2589 LDAP_LOG( CONFIG, CRIT,
2590 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2592 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2605 ucdata_unload( UCDATA_ALL );
2606 free( global_schemandn.bv_val );
2607 free( global_schemadn.bv_val );
2609 if ( slapd_args_file )
2610 free ( slapd_args_file );
2611 if ( slapd_pid_file )
2612 free ( slapd_pid_file );
2613 acl_destroy( global_acl, NULL );