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;
55 struct berval global_schemadn = { 0, NULL };
56 struct berval global_schemandn = { 0, NULL };
58 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
59 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
61 char *slapd_pid_file = NULL;
62 char *slapd_args_file = NULL;
64 char *strtok_quote_ptr;
67 int use_reverse_lookup = 1;
68 #else /* !SLAPD_RLOOKUPS */
69 int use_reverse_lookup = 0;
70 #endif /* !SLAPD_RLOOKUPS */
72 static char *fp_getline(FILE *fp, int *lineno);
73 static void fp_getline_init(int *lineno);
74 static int fp_parse_line(int lineno, char *line);
76 static char *strtok_quote(char *line, char *sep);
77 static int load_ucdata(char *path);
80 read_config( const char *fname, int depth )
83 char *line, *savefname, *saveline;
87 struct berval vals[2];
89 static int lastmod = 1;
90 static BackendInfo *bi = NULL;
91 static BackendDB *be = NULL;
93 vals[1].bv_val = NULL;
96 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
97 cargv_size = ARGS_STEP + 1;
100 if ( (fp = fopen( fname, "r" )) == NULL ) {
103 LDAP_LOG( CONFIG, ENTRY,
104 "read_config: " "could not open config file \"%s\": %s (%d)\n",
105 fname, strerror(errno), errno );
107 Debug( LDAP_DEBUG_ANY,
108 "could not open config file \"%s\": %s (%d)\n",
109 fname, strerror(errno), errno );
115 LDAP_LOG( CONFIG, ENTRY,
116 "read_config: reading config file %s\n", fname, 0, 0 );
118 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
122 fp_getline_init( &lineno );
124 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
125 /* skip comments and blank lines */
126 if ( line[0] == '#' || line[0] == '\0' ) {
130 /* fp_parse_line is destructive, we save a copy */
131 saveline = ch_strdup( line );
133 if ( fp_parse_line( lineno, line ) != 0 ) {
139 LDAP_LOG( CONFIG, INFO,
140 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
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, 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, CRIT,
168 "%s: line %d: backend line must appear before any "
169 "database definition.\n", fname, lineno , 0 );
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, 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, 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, CRIT,
215 "database %s initialization failed.\n", cargv[1], 0, 0 );
217 Debug( LDAP_DEBUG_ANY,
218 "database %s initialization failed.\n",
225 /* set thread concurrency */
226 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
230 LDAP_LOG( CONFIG, CRIT,
231 "%s: line %d: missing level in \"concurrency <level\" "
232 " line\n", fname, lineno, 0 );
234 Debug( LDAP_DEBUG_ANY,
235 "%s: line %d: missing level in \"concurrency <level>\" line\n",
242 c = atoi( cargv[1] );
246 LDAP_LOG( CONFIG, CRIT,
247 "%s: line %d: invalid level (%d) in "
248 "\"concurrency <level>\" line.\n", fname, lineno, c );
250 Debug( LDAP_DEBUG_ANY,
251 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
258 ldap_pvt_thread_set_concurrency( c );
260 /* set sockbuf max */
261 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
265 LDAP_LOG( CONFIG, CRIT,
266 "%s: line %d: missing max in \"sockbuf_max_incoming "
267 "<bytes>\" line\n", fname, lineno, 0 );
269 Debug( LDAP_DEBUG_ANY,
270 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
277 max = atol( cargv[1] );
281 LDAP_LOG( CONFIG, CRIT,
282 "%s: line %d: invalid max value (%ld) in "
283 "\"sockbuf_max_incoming <bytes>\" line.\n",
284 fname, lineno, max );
286 Debug( LDAP_DEBUG_ANY,
287 "%s: line %d: invalid max value (%ld) in "
288 "\"sockbuf_max_incoming <bytes>\" line.\n",
289 fname, lineno, max );
295 sockbuf_max_incoming = max;
297 /* set sockbuf max authenticated */
298 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
302 LDAP_LOG( CONFIG, CRIT,
303 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
304 "<bytes>\" line\n", fname, lineno, 0 );
306 Debug( LDAP_DEBUG_ANY,
307 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
314 max = atol( cargv[1] );
318 LDAP_LOG( CONFIG, CRIT,
319 "%s: line %d: invalid max value (%ld) in "
320 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
321 fname, lineno, max );
323 Debug( LDAP_DEBUG_ANY,
324 "%s: line %d: invalid max value (%ld) in "
325 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
326 fname, lineno, max );
332 sockbuf_max_incoming_auth = max;
334 /* default search base */
335 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
338 LDAP_LOG( CONFIG, CRIT,
339 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
340 "line\n", fname, lineno, 0 );
342 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
343 "missing dn in \"defaultSearchBase <dn>\" line\n",
349 } else if ( cargc > 2 ) {
351 LDAP_LOG( CONFIG, INFO,
352 "%s: line %d: extra cruft after <dn> in "
353 "\"defaultSearchBase %s\" line (ignored)\n",
354 fname, lineno, cargv[1] );
356 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
357 "extra cruft after <dn> in \"defaultSearchBase %s\", "
359 fname, lineno, cargv[1] );
363 if ( bi != NULL || be != NULL ) {
365 LDAP_LOG( CONFIG, CRIT,
366 "%s: line %d: defaultSearchBase line must appear "
367 "prior to any backend or database definitions\n",
370 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
371 "defaultSearchBaase line must appear prior to "
372 "any backend or database definition\n",
379 if ( default_search_nbase.bv_len ) {
381 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
382 "default search base \"%s\" already defined "
383 "(discarding old)\n", fname, lineno,
384 default_search_base.bv_val );
386 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
387 "default search base \"%s\" already defined "
388 "(discarding old)\n",
389 fname, lineno, default_search_base.bv_val );
392 free( default_search_base.bv_val );
393 free( default_search_nbase.bv_val );
396 if ( load_ucdata( NULL ) < 0 ) return 1;
401 dn.bv_val = cargv[1];
402 dn.bv_len = strlen( dn.bv_val );
404 rc = dnPrettyNormal( NULL, &dn,
405 &default_search_base,
406 &default_search_nbase );
408 if( rc != LDAP_SUCCESS ) {
410 LDAP_LOG( CONFIG, CRIT,
411 "%s: line %d: defaultSearchBase DN is invalid.\n",
414 Debug( LDAP_DEBUG_ANY,
415 "%s: line %d: defaultSearchBase DN is invalid\n",
422 /* set maximum threads in thread pool */
423 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
427 LDAP_LOG( CONFIG, CRIT,
428 "%s: line %d: missing count in \"threads <count>\" line\n",
431 Debug( LDAP_DEBUG_ANY,
432 "%s: line %d: missing count in \"threads <count>\" line\n",
439 c = atoi( cargv[1] );
443 LDAP_LOG( CONFIG, CRIT,
444 "%s: line %d: invalid level (%d) in \"threads <count>\""
445 "line\n", fname, lineno, c );
447 Debug( LDAP_DEBUG_ANY,
448 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
455 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
457 /* save for later use */
458 connection_pool_max = c;
460 /* get pid file name */
461 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
464 LDAP_LOG( CONFIG, CRIT,
465 "%s: line %d missing file name in \"pidfile <file>\" "
466 "line.\n", fname, lineno, 0 );
468 Debug( LDAP_DEBUG_ANY,
469 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
476 slapd_pid_file = ch_strdup( cargv[1] );
478 /* get args file name */
479 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
482 LDAP_LOG( CONFIG, CRIT,
483 "%s: %d: missing file name in "
484 "\"argsfile <file>\" line.\n",
487 Debug( LDAP_DEBUG_ANY,
488 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
495 slapd_args_file = ch_strdup( cargv[1] );
497 /* default password hash */
498 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
501 LDAP_LOG( CONFIG, CRIT,
502 "%s: line %d: missing hash in "
503 "\"password-hash <hash>\" line.\n",
506 Debug( LDAP_DEBUG_ANY,
507 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
513 if ( default_passwd_hash != NULL ) {
515 LDAP_LOG( CONFIG, CRIT,
516 "%s: line %d: already set default password_hash!\n",
519 Debug( LDAP_DEBUG_ANY,
520 "%s: line %d: already set default password_hash!\n",
528 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
530 LDAP_LOG( CONFIG, CRIT,
531 "%s: line %d: password scheme \"%s\" not available\n",
532 fname, lineno, cargv[1] );
534 Debug( LDAP_DEBUG_ANY,
535 "%s: line %d: password scheme \"%s\" not available\n",
536 fname, lineno, cargv[1] );
541 default_passwd_hash = ch_strdup( cargv[1] );
543 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
547 LDAP_LOG( CONFIG, CRIT,
548 "%s: line %d: missing format in "
549 "\"password-crypt-salt-format <format>\" line\n",
552 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
553 "\"password-crypt-salt-format <format>\" line\n",
560 lutil_salt_format( cargv[1] );
562 #ifdef HAVE_CYRUS_SASL
563 /* SASL config options */
564 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
565 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
567 #endif /* HAVE_CYRUS_SASL */
569 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
573 LDAP_LOG( CONFIG, CRIT,
574 "%s: line %d: missing dn in "
575 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
577 Debug( LDAP_DEBUG_ANY,
578 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
583 ber_str2bv( cargv[1], 0, 0, &dn );
585 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
588 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
591 if ( rc != LDAP_SUCCESS ) {
593 LDAP_LOG( CONFIG, CRIT,
594 "%s: line %d: schemadn DN is invalid.\n",
597 Debug( LDAP_DEBUG_ANY,
598 "%s: line %d: schemadn DN is invalid\n",
604 /* set UCDATA path */
605 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
609 LDAP_LOG( CONFIG, CRIT,
610 "%s: line %d: missing path in "
611 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
613 Debug( LDAP_DEBUG_ANY,
614 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
621 err = load_ucdata( cargv[1] );
625 LDAP_LOG( CONFIG, CRIT,
626 "%s: line %d: ucdata already loaded, ucdata-path "
627 "must be set earlier in the file and/or be "
628 "specified only once!\n", fname, lineno, 0 );
630 Debug( LDAP_DEBUG_ANY,
631 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
640 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
642 struct slap_limits_set *lim;
646 LDAP_LOG( CONFIG, CRIT,
647 "%s: line %d: missing limit in \"sizelimit <limit>\" "
648 "line.\n", fname, lineno, 0 );
650 Debug( LDAP_DEBUG_ANY,
651 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
661 lim = &be->be_def_limit;
664 for ( i = 1; i < cargc; i++ ) {
665 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
666 rc = parse_limit( cargv[i], lim );
668 lim->lms_s_soft = atoi( cargv[i] );
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 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
692 struct slap_limits_set *lim;
696 LDAP_LOG( CONFIG, CRIT,
697 "%s: line %d missing limit in \"timelimit <limit>\" "
698 "line.\n", fname, lineno, 0 );
700 Debug( LDAP_DEBUG_ANY,
701 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
711 lim = &be->be_def_limit;
714 for ( i = 1; i < cargc; i++ ) {
715 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
716 rc = parse_limit( cargv[i], lim );
718 lim->lms_t_soft = atoi( cargv[i] );
724 LDAP_LOG( CONFIG, CRIT,
725 "%s: line %d: unable to parse value \"%s\" "
726 "in \"timelimit <limit>\" line.\n",
727 fname, lineno, cargv[i] );
729 Debug( LDAP_DEBUG_ANY,
730 "%s: line %d: unable "
731 "to parse value \"%s\" "
734 fname, lineno, cargv[i] );
739 /* set regex-based limits */
740 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
743 LDAP_LOG( CONFIG, WARNING,
744 "%s: line %d \"limits\" allowed only in database "
745 "environment.\n", fname, lineno, 0 );
747 Debug( LDAP_DEBUG_ANY,
748 "%s: line %d \"limits\" allowed only in database environment.\n%s",
754 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
758 /* mark this as a subordinate database */
759 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
762 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
763 "subordinate keyword must appear inside a database "
764 "definition.\n", fname, lineno, 0 );
766 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
767 "must appear inside a database definition.\n",
773 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
777 /* set database suffix */
778 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
780 struct berval dn, pdn, ndn;
784 LDAP_LOG( CONFIG, CRIT,
785 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
788 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
789 "missing dn in \"suffix <dn>\" line\n",
795 } else if ( cargc > 2 ) {
797 LDAP_LOG( CONFIG, INFO,
798 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
799 " line (ignored).\n", fname, lineno, cargv[1] );
801 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
802 "after <dn> in \"suffix %s\" line (ignored)\n",
803 fname, lineno, cargv[1] );
809 LDAP_LOG( CONFIG, INFO,
810 "%s: line %d: suffix line must appear inside a database "
811 "definition.\n", fname, lineno, 0 );
813 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
814 "must appear inside a database definition\n",
819 #if defined(SLAPD_MONITOR_DN)
820 /* "cn=Monitor" is reserved for monitoring slap */
821 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
823 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
824 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
827 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
828 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
832 #endif /* SLAPD_MONITOR_DN */
835 if ( load_ucdata( NULL ) < 0 ) return 1;
837 dn.bv_val = cargv[1];
838 dn.bv_len = strlen( cargv[1] );
840 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
841 if( rc != LDAP_SUCCESS ) {
843 LDAP_LOG( CONFIG, CRIT,
844 "%s: line %d: suffix DN is invalid.\n",
847 Debug( LDAP_DEBUG_ANY,
848 "%s: line %d: suffix DN is invalid\n",
854 tmp_be = select_backend( &ndn, 0, 0 );
855 if ( tmp_be == be ) {
857 LDAP_LOG( CONFIG, INFO,
858 "%s: line %d: suffix already served by this backend "
859 "(ignored)\n", fname, lineno, 0 );
861 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
862 "already served by this backend (ignored)\n",
868 } else if ( tmp_be != NULL ) {
870 LDAP_LOG( CONFIG, INFO,
871 "%s: line %d: suffix already served by a preceding "
872 "backend \"%s\"\n", fname, lineno,
873 tmp_be->be_suffix[0].bv_val );
875 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
876 "already served by a preceeding backend \"%s\"\n",
877 fname, lineno, tmp_be->be_suffix[0].bv_val );
883 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
885 LDAP_LOG( CONFIG, INFO,
886 "%s: line %d: suffix DN empty and default search "
887 "base provided \"%s\" (assuming okay).\n",
888 fname, lineno, default_search_base.bv_val );
890 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
891 "suffix DN empty and default "
892 "search base provided \"%s\" (assuming okay)\n",
893 fname, lineno, default_search_base.bv_val );
897 ber_bvarray_add( &be->be_suffix, &pdn );
898 ber_bvarray_add( &be->be_nsuffix, &ndn );
900 /* set database suffixAlias */
901 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
903 struct berval alias, palias, nalias;
904 struct berval aliased, paliased, naliased;
908 LDAP_LOG( CONFIG, CRIT,
909 "%s: line %d: missing alias and aliased_dn in "
910 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
913 Debug( LDAP_DEBUG_ANY,
914 "%s: line %d: missing alias and aliased_dn in "
915 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
920 } else if ( cargc < 3 ) {
922 LDAP_LOG( CONFIG, CRIT,
923 "%s: line %d: missing aliased_dn in "
924 "\"suffixAlias <alias> <aliased_dn>\" line\n",
927 Debug( LDAP_DEBUG_ANY,
928 "%s: line %d: missing aliased_dn in "
929 "\"suffixAlias <alias> <aliased_dn>\" line\n",
934 } else if ( cargc > 3 ) {
936 LDAP_LOG( CONFIG, CRIT,
937 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
940 Debug( LDAP_DEBUG_ANY,
941 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
948 LDAP_LOG( CONFIG, INFO,
949 "%s: line %d: suffix line must appear inside a database "
950 "definition.\n", fname, lineno, 0 );
952 Debug( LDAP_DEBUG_ANY,
953 "%s: line %d: suffixAlias line"
954 " must appear inside a database definition.\n",
960 if ( load_ucdata( NULL ) < 0 ) return 1;
962 alias.bv_val = cargv[1];
963 alias.bv_len = strlen( cargv[1] );
965 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
966 if( rc != LDAP_SUCCESS ) {
968 LDAP_LOG( CONFIG, CRIT,
969 "%s: line %d: alias DN is invalid.\n", fname, lineno, 0 );
971 Debug( LDAP_DEBUG_ANY,
972 "%s: line %d: alias DN is invalid\n",
978 tmp_be = select_backend( &nalias, 0, 0 );
979 free( nalias.bv_val );
980 if ( tmp_be && tmp_be != be ) {
982 LDAP_LOG( CONFIG, INFO,
983 "%s: line %d: suffixAlias served by a preceeding "
984 "backend \"%s\"\n", fname, lineno,
985 tmp_be->be_suffix[0].bv_val );
987 Debug( LDAP_DEBUG_ANY,
988 "%s: line %d: suffixAlias served by"
989 " a preceeding backend \"%s\"\n",
990 fname, lineno, tmp_be->be_suffix[0].bv_val );
992 free( palias.bv_val );
996 aliased.bv_val = cargv[2];
997 aliased.bv_len = strlen( cargv[2] );
999 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
1000 if( rc != LDAP_SUCCESS ) {
1002 LDAP_LOG( CONFIG, CRIT,
1003 "%s: line %d: aliased DN is invalid.\n", fname, lineno,0 );
1005 Debug( LDAP_DEBUG_ANY,
1006 "%s: line %d: aliased DN is invalid\n",
1009 free( palias.bv_val );
1013 tmp_be = select_backend( &naliased, 0, 0 );
1014 free( naliased.bv_val );
1015 if ( tmp_be && tmp_be != be ) {
1017 LDAP_LOG( CONFIG, INFO,
1018 "%s: line %d: suffixAlias derefs to a different backend "
1019 "a preceeding backend \"%s\"\n",
1020 fname, lineno, tmp_be->be_suffix[0].bv_val );
1022 Debug( LDAP_DEBUG_ANY,
1023 "%s: line %d: suffixAlias derefs to differnet backend"
1024 " a preceeding backend \"%s\"\n",
1025 fname, lineno, tmp_be->be_suffix[0].bv_val );
1027 free( palias.bv_val );
1028 free( paliased.bv_val );
1032 ber_bvarray_add( &be->be_suffixAlias, &palias );
1033 ber_bvarray_add( &be->be_suffixAlias, &paliased );
1035 /* set max deref depth */
1036 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1040 LDAP_LOG( CONFIG, CRIT,
1041 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1042 " line\n", fname, lineno, 0 );
1044 Debug( LDAP_DEBUG_ANY,
1045 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1053 LDAP_LOG( CONFIG, INFO,
1054 "%s: line %d: depth line must appear inside a database "
1055 "definition.\n", fname, lineno ,0 );
1057 Debug( LDAP_DEBUG_ANY,
1058 "%s: line %d: depth line must appear inside a database definition.\n",
1063 } else if ((i = atoi(cargv[1])) < 0) {
1065 LDAP_LOG( CONFIG, INFO,
1066 "%s: line %d: depth must be positive.\n",
1069 Debug( LDAP_DEBUG_ANY,
1070 "%s: line %d: depth must be positive.\n",
1077 be->be_max_deref_depth = i;
1081 /* set magic "root" dn for this database */
1082 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1085 LDAP_LOG( CONFIG, INFO,
1086 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1089 Debug( LDAP_DEBUG_ANY,
1090 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1099 LDAP_LOG( CONFIG, INFO,
1100 "%s: line %d: rootdn line must appear inside a database "
1101 "definition.\n", fname, lineno ,0 );
1103 Debug( LDAP_DEBUG_ANY,
1104 "%s: line %d: rootdn line must appear inside a database definition.\n",
1112 if ( load_ucdata( NULL ) < 0 ) return 1;
1114 dn.bv_val = cargv[1];
1115 dn.bv_len = strlen( cargv[1] );
1117 rc = dnPrettyNormal( NULL, &dn,
1121 if( rc != LDAP_SUCCESS ) {
1123 LDAP_LOG( CONFIG, CRIT,
1124 "%s: line %d: rootdn DN is invalid.\n",
1127 Debug( LDAP_DEBUG_ANY,
1128 "%s: line %d: rootdn DN is invalid\n",
1135 /* set super-secret magic database password */
1136 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1139 LDAP_LOG( CONFIG, CRIT,
1140 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1141 " line\n", fname, lineno ,0 );
1143 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1144 "missing passwd in \"rootpw <passwd>\" line\n",
1153 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1154 "rootpw line must appear inside a database "
1155 "definition.\n", fname, lineno ,0 );
1157 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1158 "rootpw line must appear inside a database "
1165 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1167 if( tmp_be != be ) {
1169 LDAP_LOG( CONFIG, INFO,
1171 "rootpw can only be set when rootdn is under suffix\n",
1172 fname, lineno, "" );
1174 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1175 "rootpw can only be set when rootdn is under suffix\n",
1181 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1182 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1185 /* make this database read-only */
1186 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1189 LDAP_LOG( CONFIG, CRIT,
1190 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1191 "line.\n", fname, lineno ,0 );
1193 Debug( LDAP_DEBUG_ANY,
1194 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1201 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1202 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1204 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1207 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1208 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1210 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1215 /* allow these features */
1216 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1217 strcasecmp( cargv[0], "allow" ) == 0 )
1223 LDAP_LOG( CONFIG, INFO,
1224 "%s: line %d: allow line must appear prior to "
1225 "database definitions.\n", fname, lineno ,0 );
1227 Debug( LDAP_DEBUG_ANY,
1228 "%s: line %d: allow line must appear prior to database definitions\n",
1236 LDAP_LOG( CONFIG, CRIT,
1237 "%s: line %d: missing feature(s) in \"allow <features>\""
1238 " line\n", fname, lineno ,0 );
1240 Debug( LDAP_DEBUG_ANY,
1241 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1250 for( i=1; i < cargc; i++ ) {
1251 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1252 allows |= SLAP_ALLOW_BIND_V2;
1254 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1255 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1257 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1258 allows |= SLAP_ALLOW_BIND_ANON_DN;
1260 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1261 allows |= SLAP_ALLOW_UPDATE_ANON;
1263 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1265 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1266 "unknown feature %s in \"allow <features>\" line.\n",
1267 fname, lineno, cargv[1] );
1269 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1270 "unknown feature %s in \"allow <features>\" line\n",
1271 fname, lineno, cargv[i] );
1278 global_allows = allows;
1280 /* disallow these features */
1281 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1282 strcasecmp( cargv[0], "disallow" ) == 0 )
1284 slap_mask_t disallows;
1288 LDAP_LOG( CONFIG, INFO,
1289 "%s: line %d: disallow line must appear prior to "
1290 "database definitions.\n", fname, lineno ,0 );
1292 Debug( LDAP_DEBUG_ANY,
1293 "%s: line %d: disallow line must appear prior to database definitions\n",
1301 LDAP_LOG( CONFIG, CRIT,
1302 "%s: line %d: missing feature(s) in \"disallow <features>\""
1303 " line.\n", fname, lineno ,0 );
1305 Debug( LDAP_DEBUG_ANY,
1306 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1315 for( i=1; i < cargc; i++ ) {
1316 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1317 disallows |= SLAP_DISALLOW_BIND_ANON;
1319 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1320 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1322 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1323 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1325 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1326 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1328 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1329 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1331 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1333 LDAP_LOG( CONFIG, CRIT,
1334 "%s: line %d: unknown feature %s in "
1335 "\"disallow <features>\" line.\n",
1336 fname, lineno, cargv[i] );
1338 Debug( LDAP_DEBUG_ANY,
1339 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1340 fname, lineno, cargv[i] );
1347 global_disallows = disallows;
1349 /* require these features */
1350 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1351 strcasecmp( cargv[0], "require" ) == 0 )
1353 slap_mask_t requires;
1357 LDAP_LOG( CONFIG, CRIT,
1358 "%s: line %d: missing feature(s) in "
1359 "\"require <features>\" line.\n", fname, lineno ,0 );
1361 Debug( LDAP_DEBUG_ANY,
1362 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1371 for( i=1; i < cargc; i++ ) {
1372 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1373 requires |= SLAP_REQUIRE_BIND;
1375 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1376 requires |= SLAP_REQUIRE_LDAP_V3;
1378 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1379 requires |= SLAP_REQUIRE_AUTHC;
1381 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1382 requires |= SLAP_REQUIRE_SASL;
1384 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1385 requires |= SLAP_REQUIRE_STRONG;
1387 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1389 LDAP_LOG( CONFIG, CRIT,
1390 "%s: line %d: unknown feature %s in "
1391 "\"require <features>\" line.\n",
1392 fname, lineno , cargv[i] );
1394 Debug( LDAP_DEBUG_ANY,
1395 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1396 fname, lineno, cargv[i] );
1404 global_requires = requires;
1406 be->be_requires = requires;
1409 /* required security factors */
1410 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1411 slap_ssf_set_t *set;
1415 LDAP_LOG( CONFIG, CRIT,
1416 "%s: line %d: missing factor(s) in \"security <factors>\""
1417 " line.\n", fname, lineno ,0 );
1419 Debug( LDAP_DEBUG_ANY,
1420 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1428 set = &global_ssf_set;
1430 set = &be->be_ssf_set;
1433 for( i=1; i < cargc; i++ ) {
1434 if( strncasecmp( cargv[i], "ssf=",
1435 sizeof("ssf") ) == 0 )
1438 atoi( &cargv[i][sizeof("ssf")] );
1440 } else if( strncasecmp( cargv[i], "transport=",
1441 sizeof("transport") ) == 0 )
1443 set->sss_transport =
1444 atoi( &cargv[i][sizeof("transport")] );
1446 } else if( strncasecmp( cargv[i], "tls=",
1447 sizeof("tls") ) == 0 )
1450 atoi( &cargv[i][sizeof("tls")] );
1452 } else if( strncasecmp( cargv[i], "sasl=",
1453 sizeof("sasl") ) == 0 )
1456 atoi( &cargv[i][sizeof("sasl")] );
1458 } else if( strncasecmp( cargv[i], "update_ssf=",
1459 sizeof("update_ssf") ) == 0 )
1461 set->sss_update_ssf =
1462 atoi( &cargv[i][sizeof("update_ssf")] );
1464 } else if( strncasecmp( cargv[i], "update_transport=",
1465 sizeof("update_transport") ) == 0 )
1467 set->sss_update_transport =
1468 atoi( &cargv[i][sizeof("update_transport")] );
1470 } else if( strncasecmp( cargv[i], "update_tls=",
1471 sizeof("update_tls") ) == 0 )
1473 set->sss_update_tls =
1474 atoi( &cargv[i][sizeof("update_tls")] );
1476 } else if( strncasecmp( cargv[i], "update_sasl=",
1477 sizeof("update_sasl") ) == 0 )
1479 set->sss_update_sasl =
1480 atoi( &cargv[i][sizeof("update_sasl")] );
1482 } else if( strncasecmp( cargv[i], "simple_bind=",
1483 sizeof("simple_bind") ) == 0 )
1485 set->sss_simple_bind =
1486 atoi( &cargv[i][sizeof("simple_bind")] );
1490 LDAP_LOG( CONFIG, CRIT,
1491 "%s: line %d: unknown factor %S in "
1492 "\"security <factors>\" line.\n",
1493 fname, lineno, cargv[1] );
1495 Debug( LDAP_DEBUG_ANY,
1496 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1497 fname, lineno, cargv[i] );
1503 /* where to send clients when we don't hold it */
1504 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1507 LDAP_LOG( CONFIG, CRIT,
1508 "%s: line %d: missing URL in \"referral <URL>\""
1509 " line.\n", fname, lineno , 0 );
1511 Debug( LDAP_DEBUG_ANY,
1512 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1519 if( validate_global_referral( cargv[1] ) ) {
1521 LDAP_LOG( CONFIG, CRIT,
1522 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1523 fname, lineno, cargv[1] );
1525 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1526 "invalid URL (%s) in \"referral\" line.\n",
1527 fname, lineno, cargv[1] );
1532 vals[0].bv_val = cargv[1];
1533 vals[0].bv_len = strlen( vals[0].bv_val );
1534 value_add( &default_referral, vals );
1537 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1541 LDAP_LOG( CONFIG, CRIT,
1542 "%s: line %d: Error in logfile directive, "
1543 "\"logfile <filename>\"\n", fname, lineno , 0 );
1545 Debug( LDAP_DEBUG_ANY,
1546 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1552 logfile = fopen( cargv[1], "w" );
1553 if ( logfile != NULL ) lutil_debug_file( logfile );
1556 /* start of a new database definition */
1557 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1561 LDAP_LOG( CONFIG, CRIT,
1562 "%s: line %d: Error in debug directive, "
1563 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1565 Debug( LDAP_DEBUG_ANY,
1566 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1572 level = atoi( cargv[2] );
1573 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1574 lutil_set_debug_level( cargv[1], level );
1575 /* specify an Object Identifier macro */
1576 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1577 rc = parse_oidm( fname, lineno, cargc, cargv );
1580 /* specify an objectclass */
1581 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1582 if ( *cargv[1] == '(' /*')'*/) {
1584 p = strchr(saveline,'(' /*')'*/);
1585 rc = parse_oc( fname, lineno, p, cargv );
1590 LDAP_LOG( CONFIG, INFO,
1591 "%s: line %d: old objectclass format not supported\n",
1592 fname, lineno , 0 );
1594 Debug( LDAP_DEBUG_ANY,
1595 "%s: line %d: old objectclass format not supported.\n",
1600 #ifdef SLAP_EXTENDED_SCHEMA
1601 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1603 p = strchr(saveline,'(' /*')'*/);
1604 rc = parse_cr( fname, lineno, p, cargv );
1608 /* specify an attribute type */
1609 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1610 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1612 if ( *cargv[1] == '(' /*')'*/) {
1614 p = strchr(saveline,'(' /*')'*/);
1615 rc = parse_at( fname, lineno, p, cargv );
1620 LDAP_LOG( CONFIG, INFO,
1621 "%s: line %d: old attribute type format not supported.\n",
1622 fname, lineno , 0 );
1624 Debug( LDAP_DEBUG_ANY,
1625 "%s: line %d: old attribute type format not supported.\n",
1631 /* turn on/off schema checking */
1632 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1635 LDAP_LOG( CONFIG, CRIT,
1636 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1637 " line.\n", fname, lineno , 0 );
1639 Debug( LDAP_DEBUG_ANY,
1640 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1646 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1648 LDAP_LOG( CONFIG, CRIT,
1649 "%s: line %d: schema checking disabled! your mileage may "
1650 "vary!\n", fname, lineno , 0 );
1652 Debug( LDAP_DEBUG_ANY,
1653 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1656 global_schemacheck = 0;
1658 global_schemacheck = 1;
1661 /* specify access control info */
1662 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1663 parse_acl( be, fname, lineno, cargc, cargv );
1665 /* debug level to log things to syslog */
1666 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1669 LDAP_LOG( CONFIG, CRIT,
1670 "%s: line %d: missing level in \"loglevel <level>\""
1671 " line.\n", fname, lineno , 0 );
1673 Debug( LDAP_DEBUG_ANY,
1674 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1683 for( i=1; i < cargc; i++ ) {
1684 ldap_syslog += atoi( cargv[1] );
1687 /* list of replicas of the data in this backend (master only) */
1688 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1691 LDAP_LOG( CONFIG, CRIT,
1692 "%s: line %d: missing host in \"replica "
1693 " <host[:port]\" line\n", fname, lineno , 0 );
1695 Debug( LDAP_DEBUG_ANY,
1696 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1704 LDAP_LOG( CONFIG, INFO,
1705 "%s: line %d: replica line must appear inside "
1706 "a database definition.\n", fname, lineno, 0);
1708 Debug( LDAP_DEBUG_ANY,
1709 "%s: line %d: replica line must appear inside a database definition\n",
1717 for ( i = 1; i < cargc; i++ ) {
1718 if ( strncasecmp( cargv[i], "host=", 5 )
1720 nr = add_replica_info( be,
1727 LDAP_LOG( CONFIG, INFO,
1728 "%s: line %d: missing host in \"replica\" line\n",
1729 fname, lineno , 0 );
1731 Debug( LDAP_DEBUG_ANY,
1732 "%s: line %d: missing host in \"replica\" line\n",
1737 } else if ( nr == -1 ) {
1739 LDAP_LOG( CONFIG, INFO,
1740 "%s: line %d: unable to add"
1741 " replica \"%s\"\n",
1745 Debug( LDAP_DEBUG_ANY,
1746 "%s: line %d: unable to add replica \"%s\"\n",
1747 fname, lineno, cargv[i] + 5 );
1751 for ( i = 1; i < cargc; i++ ) {
1752 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1754 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1757 LDAP_LOG( CONFIG, INFO,
1758 "%s: line %d: suffix \"%s\" in \"replica\""
1759 " line is not valid for backend(ignored)\n",
1760 fname, lineno, cargv[i] + 7 );
1762 Debug( LDAP_DEBUG_ANY,
1763 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1764 fname, lineno, cargv[i] + 7 );
1770 LDAP_LOG( CONFIG, INFO,
1771 "%s: line %d: unable to normalize suffix"
1772 " in \"replica\" line (ignored)\n",
1773 fname, lineno , 0 );
1775 Debug( LDAP_DEBUG_ANY,
1776 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1782 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1784 char *arg = cargv[i] + 4;
1786 if ( arg[0] == '!' ) {
1791 if ( arg[0] != '=' ) {
1795 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1797 LDAP_LOG( CONFIG, INFO,
1798 "%s: line %d: attribute \"%s\" in "
1799 "\"replica\" line is unknown\n",
1800 fname, lineno, arg + 1 );
1802 Debug( LDAP_DEBUG_ANY,
1803 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1804 fname, lineno, arg + 1 );
1813 /* dn of master entity allowed to write to replica */
1814 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1817 LDAP_LOG( CONFIG, CRIT,
1818 "%s: line %d: missing dn in \"updatedn <dn>\""
1819 " line.\n", fname, lineno , 0 );
1821 Debug( LDAP_DEBUG_ANY,
1822 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1830 LDAP_LOG( CONFIG, INFO,
1831 "%s: line %d: updatedn line must appear inside "
1832 "a database definition\n",
1833 fname, lineno , 0 );
1835 Debug( LDAP_DEBUG_ANY,
1836 "%s: line %d: updatedn line must appear inside a database definition\n",
1844 if ( load_ucdata( NULL ) < 0 ) return 1;
1846 dn.bv_val = cargv[1];
1847 dn.bv_len = strlen( cargv[1] );
1849 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1850 if( rc != LDAP_SUCCESS ) {
1852 LDAP_LOG( CONFIG, CRIT,
1853 "%s: line %d: updatedn DN is invalid.\n",
1854 fname, lineno , 0 );
1856 Debug( LDAP_DEBUG_ANY,
1857 "%s: line %d: updatedn DN is invalid\n",
1864 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1867 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1868 "missing url in \"updateref <ldapurl>\" line.\n",
1869 fname, lineno , 0 );
1871 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1872 "missing url in \"updateref <ldapurl>\" line\n",
1880 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
1881 " line must appear inside a database definition\n",
1882 fname, lineno , 0 );
1884 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1885 " line must appear inside a database definition\n",
1890 } else if ( !be->be_update_ndn.bv_len ) {
1892 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1893 "updateref line must come after updatedn.\n",
1894 fname, lineno , 0 );
1896 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1897 "updateref line must after updatedn.\n",
1903 if( validate_global_referral( cargv[1] ) ) {
1905 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1906 "invalid URL (%s) in \"updateref\" line.\n",
1907 fname, lineno, cargv[1] );
1909 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1910 "invalid URL (%s) in \"updateref\" line.\n",
1911 fname, lineno, cargv[1] );
1916 vals[0].bv_val = cargv[1];
1917 vals[0].bv_len = strlen( vals[0].bv_val );
1918 value_add( &be->be_update_refs, vals );
1920 /* replication log file to which changes are appended */
1921 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1924 LDAP_LOG( CONFIG, CRIT,
1925 "%s: line %d: missing filename in \"replogfile <filename>\""
1926 " line.\n", fname, lineno , 0 );
1928 Debug( LDAP_DEBUG_ANY,
1929 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1936 be->be_replogfile = ch_strdup( cargv[1] );
1938 replogfile = ch_strdup( cargv[1] );
1941 /* file from which to read additional rootdse attrs */
1942 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1945 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1946 "missing filename in \"rootDSE <filename>\" line.\n",
1947 fname, lineno , 0 );
1949 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1950 "missing filename in \"rootDSE <filename>\" line.\n",
1956 if( read_root_dse_file( cargv[1] ) ) {
1958 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1959 "could not read \"rootDSE <filename>\" line.\n",
1960 fname, lineno , 0 );
1962 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1963 "could not read \"rootDSE <filename>\" line\n",
1969 /* maintain lastmodified{by,time} attributes */
1970 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1973 LDAP_LOG( CONFIG, CRIT,
1974 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1975 " line.\n", fname, lineno , 0 );
1977 Debug( LDAP_DEBUG_ANY,
1978 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1984 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1986 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
1992 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
1999 /* turn on/off gentle SIGHUP handling */
2000 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2002 Debug( LDAP_DEBUG_ANY,
2003 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2007 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2008 global_gentlehup = 0;
2010 global_gentlehup = 1;
2014 /* set idle timeout value */
2015 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2019 LDAP_LOG( CONFIG, CRIT,
2020 "%s: line %d: missing timeout value in "
2021 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2023 Debug( LDAP_DEBUG_ANY,
2024 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2031 i = atoi( cargv[1] );
2035 LDAP_LOG( CONFIG, CRIT,
2036 "%s: line %d: timeout value (%d) invalid "
2037 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2039 Debug( LDAP_DEBUG_ANY,
2040 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2047 global_idletimeout = i;
2049 /* include another config file */
2050 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2053 LDAP_LOG( CONFIG, CRIT,
2054 "%s: line %d: missing filename in \"include "
2055 "<filename>\" line.\n", fname, lineno , 0 );
2057 Debug( LDAP_DEBUG_ANY,
2058 "%s: line %d: missing filename in \"include <filename>\" line\n",
2064 savefname = ch_strdup( cargv[1] );
2065 savelineno = lineno;
2067 if ( read_config( savefname, depth+1 ) != 0 ) {
2072 lineno = savelineno - 1;
2074 /* location of kerberos srvtab file */
2075 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2078 LDAP_LOG( CONFIG, CRIT,
2079 "%s: line %d: missing filename in \"srvtab "
2080 "<filename>\" line.\n", fname, lineno , 0 );
2082 Debug( LDAP_DEBUG_ANY,
2083 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2089 ldap_srvtab = ch_strdup( cargv[1] );
2091 #ifdef SLAPD_MODULES
2092 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2095 LDAP_LOG( CONFIG, INFO,
2096 "%s: line %d: missing filename in \"moduleload "
2097 "<filename>\" line.\n", fname, lineno , 0 );
2099 Debug( LDAP_DEBUG_ANY,
2100 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2104 exit( EXIT_FAILURE );
2106 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2108 LDAP_LOG( CONFIG, CRIT,
2109 "%s: line %d: failed to load or initialize module %s\n",
2110 fname, lineno, cargv[1] );
2112 Debug( LDAP_DEBUG_ANY,
2113 "%s: line %d: failed to load or initialize module %s\n",
2114 fname, lineno, cargv[1]);
2117 exit( EXIT_FAILURE );
2119 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2122 LDAP_LOG( CONFIG, INFO,
2123 "%s: line %d: missing path in \"modulepath <path>\""
2124 " line\n", fname, lineno , 0 );
2126 Debug( LDAP_DEBUG_ANY,
2127 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2131 exit( EXIT_FAILURE );
2133 if (module_path( cargv[1] )) {
2135 LDAP_LOG( CONFIG, CRIT,
2136 "%s: line %d: failed to set module search path to %s.\n",
2137 fname, lineno, cargv[1] );
2139 Debug( LDAP_DEBUG_ANY,
2140 "%s: line %d: failed to set module search path to %s\n",
2141 fname, lineno, cargv[1]);
2144 exit( EXIT_FAILURE );
2147 #endif /*SLAPD_MODULES*/
2150 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2151 rc = ldap_pvt_tls_set_option( NULL,
2152 LDAP_OPT_X_TLS_RANDOM_FILE,
2157 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2158 rc = ldap_pvt_tls_set_option( NULL,
2159 LDAP_OPT_X_TLS_CIPHER_SUITE,
2164 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2165 rc = ldap_pvt_tls_set_option( NULL,
2166 LDAP_OPT_X_TLS_CERTFILE,
2171 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2172 rc = ldap_pvt_tls_set_option( NULL,
2173 LDAP_OPT_X_TLS_KEYFILE,
2178 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2179 rc = ldap_pvt_tls_set_option( NULL,
2180 LDAP_OPT_X_TLS_CACERTDIR,
2185 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2186 rc = ldap_pvt_tls_set_option( NULL,
2187 LDAP_OPT_X_TLS_CACERTFILE,
2191 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2192 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2194 rc = ldap_pvt_tls_set_option( NULL,
2195 LDAP_OPT_X_TLS_REQUIRE_CERT,
2198 rc = ldap_int_tls_config( NULL,
2199 LDAP_OPT_X_TLS_REQUIRE_CERT,
2208 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2209 #ifdef SLAPD_RLOOKUPS
2212 LDAP_LOG( CONFIG, INFO,
2213 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2214 fname, lineno , 0 );
2216 Debug( LDAP_DEBUG_ANY,
2217 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2223 if ( !strcasecmp( cargv[1], "on" ) ) {
2224 use_reverse_lookup = 1;
2225 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2226 use_reverse_lookup = 0;
2229 LDAP_LOG( CONFIG, INFO,
2230 "%s: line %d: reverse-lookup: "
2231 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2233 Debug( LDAP_DEBUG_ANY,
2234 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2240 #else /* !SLAPD_RLOOKUPS */
2242 LDAP_LOG( CONFIG, INFO,
2243 "%s: line %d: reverse lookups "
2244 "are not configured (ignored).\n", fname, lineno , 0 );
2246 Debug( LDAP_DEBUG_ANY,
2247 "%s: line %d: reverse lookups are not configured (ignored).\n",
2250 #endif /* !SLAPD_RLOOKUPS */
2252 /* pass anything else to the current backend info/db config routine */
2255 if ( bi->bi_config == 0 ) {
2257 LDAP_LOG( CONFIG, INFO,
2258 "%s: line %d: unknown directive \"%s\" inside "
2259 "backend info definition (ignored).\n",
2260 fname, lineno, cargv[0] );
2262 Debug( LDAP_DEBUG_ANY,
2263 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2264 fname, lineno, cargv[0] );
2268 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2274 } else if ( be != NULL ) {
2275 if ( be->be_config == 0 ) {
2277 LDAP_LOG( CONFIG, INFO,
2278 "%s: line %d: uknown directive \"%s\" inside "
2279 "backend database definition (ignored).\n",
2280 fname, lineno, cargv[0] );
2282 Debug( LDAP_DEBUG_ANY,
2283 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2284 fname, lineno, cargv[0] );
2288 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2296 LDAP_LOG( CONFIG, INFO,
2297 "%s: line %d: unknown directive \"%s\" outside backend "
2298 "info and database definitions (ignored).\n",
2299 fname, lineno, cargv[0] );
2301 Debug( LDAP_DEBUG_ANY,
2302 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2303 fname, lineno, cargv[0] );
2312 if ( depth == 0 ) ch_free( cargv );
2314 if ( !global_schemadn.bv_val ) {
2315 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2317 dnNormalize2( NULL, &global_schemadn, &global_schemandn );
2320 if ( load_ucdata( NULL ) < 0 ) return 1;
2332 char logbuf[sizeof("pseudorootpw ***")];
2335 token = strtok_quote( line, " \t" );
2339 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2340 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2341 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2342 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2343 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2345 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2348 if ( strtok_quote_ptr ) {
2349 *strtok_quote_ptr = ' ';
2353 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2355 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2358 if ( strtok_quote_ptr ) {
2359 *strtok_quote_ptr = '\0';
2362 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2363 if ( cargc == cargv_size - 1 ) {
2365 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2367 if ( tmp == NULL ) {
2369 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2371 Debug( LDAP_DEBUG_ANY,
2372 "line %d: out of memory\n",
2378 cargv_size += ARGS_STEP;
2380 cargv[cargc++] = token;
2382 cargv[cargc] = NULL;
2387 strtok_quote( char *line, char *sep )
2393 strtok_quote_ptr = NULL;
2394 if ( line != NULL ) {
2397 while ( *next && strchr( sep, *next ) ) {
2401 if ( *next == '\0' ) {
2407 for ( inquote = 0; *next; ) {
2415 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2421 next + 1, strlen( next + 1 ) + 1 );
2422 next++; /* dont parse the escaped character */
2427 if ( strchr( sep, *next ) != NULL ) {
2428 strtok_quote_ptr = next;
2441 static char buf[BUFSIZ];
2443 static size_t lmax, lcur;
2445 #define CATLINE( buf ) \
2447 size_t len = strlen( buf ); \
2448 while ( lcur + len + 1 > lmax ) { \
2450 line = (char *) ch_realloc( line, lmax ); \
2452 strcpy( line + lcur, buf ); \
2457 fp_getline( FILE *fp, int *lineno )
2465 /* hack attack - keeps us from having to keep a stack of bufs... */
2466 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2471 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2472 /* trim off \r\n or \n */
2473 if ( (p = strchr( buf, '\n' )) != NULL ) {
2474 if( p > buf && p[-1] == '\r' ) --p;
2478 /* trim off trailing \ and append the next line */
2479 if ( line[ 0 ] != '\0'
2480 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2481 && p[ -1 ] != '\\' ) {
2486 if ( ! isspace( (unsigned char) buf[0] ) ) {
2490 /* change leading whitespace to a space */
2499 return( line[0] ? line : NULL );
2503 fp_getline_init( int *lineno )
2509 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2511 load_ucdata( char *path )
2513 static int loaded = 0;
2519 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2522 LDAP_LOG( CONFIG, CRIT,
2523 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2525 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2538 ucdata_unload( UCDATA_ALL );
2539 free( global_schemandn.bv_val );
2540 free( global_schemadn.bv_val );
2542 if ( slapd_args_file )
2543 free ( slapd_args_file );
2544 if ( slapd_pid_file )
2545 free ( slapd_pid_file );
2546 acl_destroy( global_acl, NULL );