1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
14 #include <ac/signal.h>
15 #include <ac/socket.h>
25 * defaults for various global variables
27 struct slap_limits_set deflimit = {
28 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
31 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
33 -1 /* no limit on unchecked size */
36 AccessControl *global_acl = NULL;
37 slap_access_t global_default_access = ACL_READ;
38 slap_mask_t global_restrictops = 0;
39 slap_mask_t global_allows = 0;
40 slap_mask_t global_disallows = 0;
41 slap_mask_t global_requires = 0;
42 slap_ssf_set_t global_ssf_set;
44 int global_gentlehup = 0;
45 int global_idletimeout = 0;
46 char *global_host = NULL;
47 char *global_realm = NULL;
48 char *ldap_srvtab = "";
49 char *default_passwd_hash = NULL;
50 int cargc = 0, cargv_size = 0;
52 struct berval default_search_base = { 0, NULL };
53 struct berval default_search_nbase = { 0, NULL };
54 unsigned num_subordinates = 0;
56 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
57 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
59 char *slapd_pid_file = NULL;
60 char *slapd_args_file = NULL;
62 char *strtok_quote_ptr;
65 int use_reverse_lookup = 1;
66 #else /* !SLAPD_RLOOKUPS */
67 int use_reverse_lookup = 0;
68 #endif /* !SLAPD_RLOOKUPS */
70 static char *fp_getline(FILE *fp, int *lineno);
71 static void fp_getline_init(int *lineno);
72 static int fp_parse_line(int lineno, char *line);
74 static char *strtok_quote(char *line, char *sep);
75 static int load_ucdata(char *path);
78 read_config( const char *fname )
81 char *line, *savefname, *saveline;
85 struct berval vals[2];
87 static int lastmod = 1;
88 static BackendInfo *bi = NULL;
89 static BackendDB *be = NULL;
91 vals[1].bv_val = NULL;
93 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
94 cargv_size = ARGS_STEP + 1;
96 if ( (fp = fopen( fname, "r" )) == NULL ) {
99 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
100 "could not open config file \"%s\": %s (%d)\n",
101 fname, strerror(errno), errno ));
103 Debug( LDAP_DEBUG_ANY,
104 "could not open config file \"%s\": %s (%d)\n",
105 fname, strerror(errno), errno );
111 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
112 "read_config: reading config file %s\n", fname ));
114 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
118 fp_getline_init( &lineno );
120 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
121 /* skip comments and blank lines */
122 if ( line[0] == '#' || line[0] == '\0' ) {
126 /* fp_parse_line is destructive, we save a copy */
127 saveline = ch_strdup( line );
129 if ( fp_parse_line( lineno, line ) != 0 ) {
135 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
136 "%s: line %d: bad config line (ignored)\n",
139 Debug( LDAP_DEBUG_ANY,
140 "%s: line %d: bad config line (ignored)\n",
147 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
150 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
151 "%s : line %d: missing type in \"backend\" line.\n",
154 Debug( LDAP_DEBUG_ANY,
155 "%s: line %d: missing type in \"backend <type>\" line\n",
164 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
165 "%s: line %d: backend line must appear before any "
166 "database definition.\n", fname, lineno ));
168 Debug( LDAP_DEBUG_ANY,
169 "%s: line %d: backend line must appear before any database definition\n",
176 bi = backend_info( cargv[1] );
180 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
181 "read_config: backend %s initialization failed.\n",
184 Debug( LDAP_DEBUG_ANY,
185 "backend %s initialization failed.\n",
191 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
194 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
195 "%s: line %d: missing type in \"database <type>\" line\n",
198 Debug( LDAP_DEBUG_ANY,
199 "%s: line %d: missing type in \"database <type>\" line\n",
207 be = backend_db_init( cargv[1] );
211 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
212 "database %s initialization failed.\n",
215 Debug( LDAP_DEBUG_ANY,
216 "database %s initialization failed.\n",
223 /* set thread concurrency */
224 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
228 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
229 "%s: line %d: missing level in \"concurrency <level\" line\n",
232 Debug( LDAP_DEBUG_ANY,
233 "%s: line %d: missing level in \"concurrency <level>\" line\n",
240 c = atoi( cargv[1] );
244 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
245 "%s: line %d: invalid level (%d) in "
246 "\"concurrency <level>\" line.\n",
249 Debug( LDAP_DEBUG_ANY,
250 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
257 ldap_pvt_thread_set_concurrency( c );
259 /* set sockbuf max */
260 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
264 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
265 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
268 Debug( LDAP_DEBUG_ANY,
269 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
276 max = atol( cargv[1] );
280 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
281 "%s: line %d: invalid max value (%ld) in "
282 "\"sockbuf_max_incoming <bytes>\" line.\n",
283 fname, lineno, max ));
285 Debug( LDAP_DEBUG_ANY,
286 "%s: line %d: invalid max value (%ld) in "
287 "\"sockbuf_max_incoming <bytes>\" line.\n",
288 fname, lineno, max );
294 sockbuf_max_incoming = max;
296 /* set sockbuf max authenticated */
297 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
301 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
302 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
305 Debug( LDAP_DEBUG_ANY,
306 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
313 max = atol( cargv[1] );
317 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
318 "%s: line %d: invalid max value (%ld) in "
319 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
320 fname, lineno, max ));
322 Debug( LDAP_DEBUG_ANY,
323 "%s: line %d: invalid max value (%ld) in "
324 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
325 fname, lineno, max );
331 sockbuf_max_incoming_auth = max;
333 /* default search base */
334 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
337 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
338 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
339 "line\n", fname, lineno ));
341 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
342 "missing dn in \"defaultSearchBase <dn>\" line\n",
348 } else if ( cargc > 2 ) {
350 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
351 "%s: line %d: extra cruft after <dn> in "
352 "\"defaultSearchBase %s\" line (ignored)\n",
353 fname, lineno, cargv[1] ));
355 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
356 "extra cruft after <dn> in \"defaultSearchBase %s\", "
358 fname, lineno, cargv[1] );
362 if ( bi != NULL || be != NULL ) {
364 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
365 "%s: line %d: defaultSearchBase line must appear "
366 "prior to any backend or database definitions\n",
369 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
370 "defaultSearchBaase line must appear prior to "
371 "any backend or database definition\n",
378 if ( default_search_nbase.bv_len ) {
380 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
381 "default search base \"%s\" already defined "
382 "(discarding old)\n", fname, lineno,
383 default_search_base.bv_val ));
385 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
386 "default search base \"%s\" already defined "
387 "(discarding old)\n",
388 fname, lineno, default_search_base.bv_val );
391 free( default_search_base.bv_val );
392 free( default_search_nbase.bv_val );
395 if ( load_ucdata( NULL ) < 0 ) return 1;
400 dn.bv_val = cargv[1];
401 dn.bv_len = strlen( dn.bv_val );
403 rc = dnPrettyNormal( NULL, &dn,
404 &default_search_base,
405 &default_search_nbase );
407 if( rc != LDAP_SUCCESS ) {
409 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
410 "%s: line %d: defaultSearchBase DN is invalid.\n",
413 Debug( LDAP_DEBUG_ANY,
414 "%s: line %d: defaultSearchBase DN is invalid\n",
421 /* set maximum threads in thread pool */
422 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
426 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
427 "%s: line %d: missing count in \"threads <count>\" line\n",
430 Debug( LDAP_DEBUG_ANY,
431 "%s: line %d: missing count in \"threads <count>\" line\n",
438 c = atoi( cargv[1] );
442 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
443 "%s: line %d: invalid level (%d) in \"threads <count>\""
444 "line\n",fname, lineno, c ));
446 Debug( LDAP_DEBUG_ANY,
447 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
454 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
456 /* save for later use */
457 connection_pool_max = c;
459 /* get pid file name */
460 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
463 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
464 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
467 Debug( LDAP_DEBUG_ANY,
468 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
475 slapd_pid_file = ch_strdup( cargv[1] );
477 /* get args file name */
478 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
481 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
482 "%s: %d: missing file name in "
483 "\"argsfile <file>\" line.\n",
486 Debug( LDAP_DEBUG_ANY,
487 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
494 slapd_args_file = ch_strdup( cargv[1] );
496 /* default password hash */
497 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
500 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
501 "%s: line %d: missing hash in "
502 "\"password-hash <hash>\" line.\n",
505 Debug( LDAP_DEBUG_ANY,
506 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
512 if ( default_passwd_hash != NULL ) {
514 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
515 "%s: line %d: already set default password_hash!\n",
518 Debug( LDAP_DEBUG_ANY,
519 "%s: line %d: already set default password_hash!\n",
527 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
529 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
530 "%s: line %d: password scheme \"%s\" not available\n",
531 fname, lineno, cargv[1] ));
533 Debug( LDAP_DEBUG_ANY,
534 "%s: line %d: password scheme \"%s\" not available\n",
535 fname, lineno, cargv[1] );
540 default_passwd_hash = ch_strdup( cargv[1] );
542 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
546 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
547 "%s: line %d: missing format in "
548 "\"password-crypt-salt-format <format>\" line\n",
551 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
552 "\"password-crypt-salt-format <format>\" line\n",
559 lutil_salt_format( cargv[1] );
561 /* SASL config options */
562 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
563 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
566 /* set UCDATA path */
567 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
571 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
572 "%s: line %d: missing path in "
573 "\"ucdata-path <path>\" line.\n",
576 Debug( LDAP_DEBUG_ANY,
577 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
584 err = load_ucdata( cargv[1] );
588 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
589 "%s: line %d: ucdata already loaded, ucdata-path "
590 "must be set earlier in the file and/or be "
591 "specified only once!\n",
594 Debug( LDAP_DEBUG_ANY,
595 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
604 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
606 struct slap_limits_set *lim;
610 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
611 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
614 Debug( LDAP_DEBUG_ANY,
615 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
625 lim = &be->be_def_limit;
628 for ( i = 1; i < cargc; i++ ) {
629 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
630 rc = parse_limit( cargv[i], lim );
632 lim->lms_s_soft = atoi( cargv[i] );
638 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
639 "%s: line %d: unable "
640 "to parse value \"%s\" "
643 fname, lineno, cargv[i] ));
645 Debug( LDAP_DEBUG_ANY,
646 "%s: line %d: unable "
647 "to parse value \"%s\" "
650 fname, lineno, cargv[i] );
656 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
658 struct slap_limits_set *lim;
662 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
663 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
666 Debug( LDAP_DEBUG_ANY,
667 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
677 lim = &be->be_def_limit;
680 for ( i = 1; i < cargc; i++ ) {
681 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
682 rc = parse_limit( cargv[i], lim );
684 lim->lms_t_soft = atoi( cargv[i] );
690 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
691 "%s: line %d: unable "
692 "to parse value \"%s\" "
695 fname, lineno, cargv[i] ));
697 Debug( LDAP_DEBUG_ANY,
698 "%s: line %d: unable "
699 "to parse value \"%s\" "
702 fname, lineno, cargv[i] );
707 /* set regex-based limits */
708 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
711 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
712 "%s: line %d \"limits\" allowed only in database environment.\n",
715 Debug( LDAP_DEBUG_ANY,
716 "%s: line %d \"limits\" allowed only in database environment.\n%s",
722 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
726 /* mark this as a subordinate database */
727 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
730 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
731 "subordinate keyword must appear inside a database "
732 "definition.\n", fname, lineno ));
734 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
735 "must appear inside a database definition.\n",
741 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
745 /* set database suffix */
746 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
748 struct berval dn, pdn, ndn;
752 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
753 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
756 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
757 "missing dn in \"suffix <dn>\" line\n",
763 } else if ( cargc > 2 ) {
765 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
766 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
767 " line (ignored).\n", fname, lineno, cargv[1] ));
769 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
770 "after <dn> in \"suffix %s\" line (ignored)\n",
771 fname, lineno, cargv[1] );
777 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
778 "%s: line %d: suffix line must appear inside a database "
779 "definition.\n", fname, lineno ));
781 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
782 "must appear inside a database definition\n",
787 #if defined(SLAPD_MONITOR_DN)
788 /* "cn=Monitor" is reserved for monitoring slap */
789 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
791 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
792 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
795 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
796 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
800 #endif /* SLAPD_MONITOR_DN */
803 if ( load_ucdata( NULL ) < 0 ) return 1;
805 dn.bv_val = cargv[1];
806 dn.bv_len = strlen( cargv[1] );
808 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
809 if( rc != LDAP_SUCCESS ) {
811 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
812 "%s: line %d: suffix DN is invalid.\n",
815 Debug( LDAP_DEBUG_ANY,
816 "%s: line %d: suffix DN is invalid\n",
822 tmp_be = select_backend( &ndn, 0, 0 );
823 if ( tmp_be == be ) {
825 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
826 "%s: line %d: suffix already served by this backend "
827 "(ignored)\n", fname, lineno ));
829 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
830 "already served by this backend (ignored)\n",
836 } else if ( tmp_be != NULL ) {
838 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
839 "%s: line %d: suffix already served by a preceding "
840 "backend \"%s\"\n", fname, lineno,
841 tmp_be->be_suffix[0].bv_val ));
843 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
844 "already served by a preceeding backend \"%s\"\n",
845 fname, lineno, tmp_be->be_suffix[0].bv_val );
851 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
853 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
854 "%s: line %d: suffix DN empty and default search "
855 "base provided \"%s\" (assuming okay).\n",
856 fname, lineno, default_search_base.bv_val ));
858 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
859 "suffix DN empty and default "
860 "search base provided \"%s\" (assuming okay)\n",
861 fname, lineno, default_search_base.bv_val );
865 ber_bvarray_add( &be->be_suffix, &pdn );
866 ber_bvarray_add( &be->be_nsuffix, &ndn );
868 /* set database suffixAlias */
869 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
871 struct berval alias, palias, nalias;
872 struct berval aliased, paliased, naliased;
876 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
877 "%s: line %d: missing alias and aliased_dn in "
878 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
881 Debug( LDAP_DEBUG_ANY,
882 "%s: line %d: missing alias and aliased_dn in "
883 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
888 } else if ( cargc < 3 ) {
890 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
891 "%s: line %d: missing aliased_dn in "
892 "\"suffixAlias <alias> <aliased_dn>\" line\n",
895 Debug( LDAP_DEBUG_ANY,
896 "%s: line %d: missing aliased_dn in "
897 "\"suffixAlias <alias> <aliased_dn>\" line\n",
902 } else if ( cargc > 3 ) {
904 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
905 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
908 Debug( LDAP_DEBUG_ANY,
909 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
916 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
917 "%s: line %d: suffixAlias line must appear inside a "
918 "database definition.\n", fname, lineno ));
920 Debug( LDAP_DEBUG_ANY,
921 "%s: line %d: suffixAlias line"
922 " must appear inside a database definition.\n",
928 if ( load_ucdata( NULL ) < 0 ) return 1;
930 alias.bv_val = cargv[1];
931 alias.bv_len = strlen( cargv[1] );
933 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
934 if( rc != LDAP_SUCCESS ) {
936 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
937 "%s: line %d: alias DN is invalid.\n",
940 Debug( LDAP_DEBUG_ANY,
941 "%s: line %d: alias DN is invalid\n",
947 tmp_be = select_backend( &nalias, 0, 0 );
948 free( nalias.bv_val );
949 if ( tmp_be && tmp_be != be ) {
951 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
952 "%s: line %d: suffixAlias served by a preceeding "
954 fname, lineno, tmp_be->be_suffix[0].bv_val ));
956 Debug( LDAP_DEBUG_ANY,
957 "%s: line %d: suffixAlias served by"
958 " a preceeding backend \"%s\"\n",
959 fname, lineno, tmp_be->be_suffix[0].bv_val );
961 free( palias.bv_val );
965 aliased.bv_val = cargv[2];
966 aliased.bv_len = strlen( cargv[2] );
968 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
969 if( rc != LDAP_SUCCESS ) {
971 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
972 "%s: line %d: aliased DN is invalid.\n",
975 Debug( LDAP_DEBUG_ANY,
976 "%s: line %d: aliased DN is invalid\n",
979 free( palias.bv_val );
983 tmp_be = select_backend( &naliased, 0, 0 );
984 free( naliased.bv_val );
985 if ( tmp_be && tmp_be != be ) {
987 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
988 "%s: line %d: suffixAlias derefs to a different backend "
989 "a preceeding backend \"%s\"\n",
990 fname, lineno, tmp_be->be_suffix[0].bv_val ));
992 Debug( LDAP_DEBUG_ANY,
993 "%s: line %d: suffixAlias derefs to differnet backend"
994 " a preceeding backend \"%s\"\n",
995 fname, lineno, tmp_be->be_suffix[0].bv_val );
997 free( palias.bv_val );
998 free( paliased.bv_val );
1002 ber_bvarray_add( &be->be_suffixAlias, &palias );
1003 ber_bvarray_add( &be->be_suffixAlias, &paliased );
1005 /* set max deref depth */
1006 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1010 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1011 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1012 " line\n", fname, lineno ));
1014 Debug( LDAP_DEBUG_ANY,
1015 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1023 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1024 "%s: line %d: depth line must appear inside a database "
1025 "definition.\n", fname, lineno ));
1027 Debug( LDAP_DEBUG_ANY,
1028 "%s: line %d: depth line must appear inside a database definition.\n",
1033 } else if ((i = atoi(cargv[1])) < 0) {
1035 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1036 "%s: line %d: depth must be positive.\n",
1039 Debug( LDAP_DEBUG_ANY,
1040 "%s: line %d: depth must be positive.\n",
1047 be->be_max_deref_depth = i;
1051 /* set magic "root" dn for this database */
1052 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1055 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1056 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1059 Debug( LDAP_DEBUG_ANY,
1060 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1069 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1070 "%s: line %d: rootdn line must appear inside a database "
1071 "definition.\n", fname, lineno ));
1073 Debug( LDAP_DEBUG_ANY,
1074 "%s: line %d: rootdn line must appear inside a database definition.\n",
1082 if ( load_ucdata( NULL ) < 0 ) return 1;
1084 dn.bv_val = cargv[1];
1085 dn.bv_len = strlen( cargv[1] );
1087 rc = dnPrettyNormal( NULL, &dn,
1091 if( rc != LDAP_SUCCESS ) {
1093 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1094 "%s: line %d: rootdn DN is invalid.\n",
1097 Debug( LDAP_DEBUG_ANY,
1098 "%s: line %d: rootdn DN is invalid\n",
1105 /* set super-secret magic database password */
1106 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1109 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1110 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1111 " line\n", fname, lineno ));
1113 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1114 "missing passwd in \"rootpw <passwd>\" line\n",
1123 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1124 "rootpw line must appear inside a database "
1125 "definition.\n", fname, lineno ));
1127 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1128 "rootpw line must appear inside a database "
1135 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1137 if( tmp_be != be ) {
1139 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1141 "rootpw can only be set when rootdn is under suffix\n"
1144 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1145 "rootpw can only be set when rootdn is under suffix\n",
1151 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1152 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1155 /* make this database read-only */
1156 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1159 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1160 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1163 Debug( LDAP_DEBUG_ANY,
1164 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1171 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1172 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1174 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1177 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1178 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1180 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1185 /* allow these features */
1186 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1187 strcasecmp( cargv[0], "allow" ) == 0 )
1193 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1194 "%s: line %d: allow line must appear prior to "
1195 "database definitions.\n", fname, lineno ));
1197 Debug( LDAP_DEBUG_ANY,
1198 "%s: line %d: allow line must appear prior to database definitions\n",
1206 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1207 "%s: line %d: missing feature(s) in \"allow <features>\""
1208 " line\n", fname, lineno ));
1210 Debug( LDAP_DEBUG_ANY,
1211 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1220 for( i=1; i < cargc; i++ ) {
1221 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1222 allows |= SLAP_ALLOW_BIND_V2;
1224 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1225 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1227 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1228 allows |= SLAP_ALLOW_BIND_ANON_DN;
1230 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1232 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1233 "%s: line %d: unknown feature %s in "
1234 "\"allow <features>\" line.\n",
1235 fname, lineno, cargv[1] ));
1237 Debug( LDAP_DEBUG_ANY,
1238 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1239 fname, lineno, cargv[i] );
1246 global_allows = allows;
1248 /* disallow these features */
1249 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1250 strcasecmp( cargv[0], "disallow" ) == 0 )
1252 slap_mask_t disallows;
1256 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1257 "%s: line %d: disallow line must appear prior to "
1258 "database definitions.\n", fname, lineno ));
1260 Debug( LDAP_DEBUG_ANY,
1261 "%s: line %d: disallow line must appear prior to database definitions\n",
1269 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1270 "%s: line %d: missing feature(s) in \"disallow <features>\""
1271 " line.\n", fname, lineno ));
1273 Debug( LDAP_DEBUG_ANY,
1274 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1283 for( i=1; i < cargc; i++ ) {
1284 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1285 disallows |= SLAP_DISALLOW_BIND_ANON;
1287 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1288 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1290 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1291 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1293 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1294 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1296 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1297 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1299 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1301 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1302 "%s: line %d: unknown feature %s in "
1303 "\"disallow <features>\" line.\n",
1304 fname, lineno, cargv[i] ));
1306 Debug( LDAP_DEBUG_ANY,
1307 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1308 fname, lineno, cargv[i] );
1315 global_disallows = disallows;
1317 /* require these features */
1318 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1319 strcasecmp( cargv[0], "require" ) == 0 )
1321 slap_mask_t requires;
1325 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1326 "%s: line %d: missing feature(s) in "
1327 "\"require <features>\" line.\n", fname, lineno ));
1329 Debug( LDAP_DEBUG_ANY,
1330 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1339 for( i=1; i < cargc; i++ ) {
1340 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1341 requires |= SLAP_REQUIRE_BIND;
1343 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1344 requires |= SLAP_REQUIRE_LDAP_V3;
1346 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1347 requires |= SLAP_REQUIRE_AUTHC;
1349 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1350 requires |= SLAP_REQUIRE_SASL;
1352 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1353 requires |= SLAP_REQUIRE_STRONG;
1355 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1357 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1358 "%s: line %d: unknown feature %s in "
1359 "\"require <features>\" line.\n",
1362 Debug( LDAP_DEBUG_ANY,
1363 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1364 fname, lineno, cargv[i] );
1372 global_requires = requires;
1374 be->be_requires = requires;
1377 /* required security factors */
1378 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1379 slap_ssf_set_t *set;
1383 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1384 "%s: line %d: missing factor(s) in \"security <factors>\""
1385 " line.\n", fname, lineno ));
1387 Debug( LDAP_DEBUG_ANY,
1388 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1396 set = &global_ssf_set;
1398 set = &be->be_ssf_set;
1401 for( i=1; i < cargc; i++ ) {
1402 if( strncasecmp( cargv[i], "ssf=",
1403 sizeof("ssf") ) == 0 )
1406 atoi( &cargv[i][sizeof("ssf")] );
1408 } else if( strncasecmp( cargv[i], "transport=",
1409 sizeof("transport") ) == 0 )
1411 set->sss_transport =
1412 atoi( &cargv[i][sizeof("transport")] );
1414 } else if( strncasecmp( cargv[i], "tls=",
1415 sizeof("tls") ) == 0 )
1418 atoi( &cargv[i][sizeof("tls")] );
1420 } else if( strncasecmp( cargv[i], "sasl=",
1421 sizeof("sasl") ) == 0 )
1424 atoi( &cargv[i][sizeof("sasl")] );
1426 } else if( strncasecmp( cargv[i], "update_ssf=",
1427 sizeof("update_ssf") ) == 0 )
1429 set->sss_update_ssf =
1430 atoi( &cargv[i][sizeof("update_ssf")] );
1432 } else if( strncasecmp( cargv[i], "update_transport=",
1433 sizeof("update_transport") ) == 0 )
1435 set->sss_update_transport =
1436 atoi( &cargv[i][sizeof("update_transport")] );
1438 } else if( strncasecmp( cargv[i], "update_tls=",
1439 sizeof("update_tls") ) == 0 )
1441 set->sss_update_tls =
1442 atoi( &cargv[i][sizeof("update_tls")] );
1444 } else if( strncasecmp( cargv[i], "update_sasl=",
1445 sizeof("update_sasl") ) == 0 )
1447 set->sss_update_sasl =
1448 atoi( &cargv[i][sizeof("update_sasl")] );
1452 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1453 "%s: line %d: unknown factor %S in "
1454 "\"security <factors>\" line.\n",
1455 fname, lineno, cargv[1] ));
1457 Debug( LDAP_DEBUG_ANY,
1458 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1459 fname, lineno, cargv[i] );
1465 /* where to send clients when we don't hold it */
1466 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1469 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1470 "%s: line %d: missing URL in \"referral <URL>\""
1471 " line.\n", fname, lineno ));
1473 Debug( LDAP_DEBUG_ANY,
1474 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1481 if( validate_global_referral( cargv[1] ) ) {
1483 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1484 "invalid URL (%s) in \"referral\" line.\n",
1485 fname, lineno, cargv[1] ));
1487 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1488 "invalid URL (%s) in \"referral\" line.\n",
1489 fname, lineno, cargv[1] );
1494 vals[0].bv_val = cargv[1];
1495 vals[0].bv_len = strlen( vals[0].bv_val );
1496 value_add( &default_referral, vals );
1499 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1503 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1504 "%s: line %d: Error in logfile directive, "
1505 "\"logfile <filename>\"\n", fname, lineno ));
1507 Debug( LDAP_DEBUG_ANY,
1508 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1514 logfile = fopen( cargv[1], "w" );
1515 if ( logfile != NULL ) lutil_debug_file( logfile );
1518 /* start of a new database definition */
1519 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1523 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1524 "%s: line %d: Error in debug directive, "
1525 "\"debug <subsys> <level>\"\n", fname, lineno ));
1527 Debug( LDAP_DEBUG_ANY,
1528 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1534 level = atoi( cargv[2] );
1535 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1536 lutil_set_debug_level( cargv[1], level );
1537 /* specify an Object Identifier macro */
1538 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1539 rc = parse_oidm( fname, lineno, cargc, cargv );
1542 /* specify an objectclass */
1543 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1544 if ( *cargv[1] == '(' ) {
1546 p = strchr(saveline,'(');
1547 rc = parse_oc( fname, lineno, p, cargv );
1552 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1553 "%s: line %d: old objectclass format not supported\n",
1556 Debug( LDAP_DEBUG_ANY,
1557 "%s: line %d: old objectclass format not supported.\n",
1562 /* specify an attribute type */
1563 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1564 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1566 if ( *cargv[1] == '(' ) {
1568 p = strchr(saveline,'(');
1569 rc = parse_at( fname, lineno, p, cargv );
1574 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1575 "%s: line %d: old attribute type format not supported.\n",
1578 Debug( LDAP_DEBUG_ANY,
1579 "%s: line %d: old attribute type format not supported.\n",
1585 /* turn on/off schema checking */
1586 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1589 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1590 "%s: line %d: missing on|off in "
1591 "\"schemacheck <on|off>\" line.\n",
1594 Debug( LDAP_DEBUG_ANY,
1595 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1601 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1603 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1604 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1607 Debug( LDAP_DEBUG_ANY,
1608 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1611 global_schemacheck = 0;
1613 global_schemacheck = 1;
1616 /* specify access control info */
1617 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1618 parse_acl( be, fname, lineno, cargc, cargv );
1620 /* debug level to log things to syslog */
1621 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1624 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1625 "%s: line %d: missing level in \"loglevel <level>\""
1626 " line.\n", fname, lineno ));
1628 Debug( LDAP_DEBUG_ANY,
1629 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1638 for( i=1; i < cargc; i++ ) {
1639 ldap_syslog += atoi( cargv[1] );
1642 /* list of replicas of the data in this backend (master only) */
1643 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1646 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1647 "%s: line %d: missing host in \"replica "
1648 " <host[:port]\" line\n", fname, lineno ));
1650 Debug( LDAP_DEBUG_ANY,
1651 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1659 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1660 "%s: line %d: replica line must appear inside "
1661 "a database definition.\n", fname, lineno ));
1663 Debug( LDAP_DEBUG_ANY,
1664 "%s: line %d: replica line must appear inside a database definition\n",
1672 for ( i = 1; i < cargc; i++ ) {
1673 if ( strncasecmp( cargv[i], "host=", 5 )
1675 nr = add_replica_info( be,
1682 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1683 "%s: line %d: missing host in \"replica\" line\n",
1686 Debug( LDAP_DEBUG_ANY,
1687 "%s: line %d: missing host in \"replica\" line\n",
1692 } else if ( nr == -1 ) {
1694 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1695 "%s: line %d: unable to add"
1696 " replica \"%s\"\n",
1700 Debug( LDAP_DEBUG_ANY,
1701 "%s: line %d: unable to add replica \"%s\"\n",
1702 fname, lineno, cargv[i] + 5 );
1706 for ( i = 1; i < cargc; i++ ) {
1707 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1709 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1712 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1713 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1714 fname, lineno, cargv[i] + 7 ));
1716 Debug( LDAP_DEBUG_ANY,
1717 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1718 fname, lineno, cargv[i] + 7 );
1724 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1725 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1728 Debug( LDAP_DEBUG_ANY,
1729 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1735 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1737 char *arg = cargv[i] + 4;
1739 if ( arg[0] == '!' ) {
1744 if ( arg[0] != '=' ) {
1748 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1750 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1751 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1752 fname, lineno, arg + 1 ));
1754 Debug( LDAP_DEBUG_ANY,
1755 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1756 fname, lineno, arg + 1 );
1765 /* dn of master entity allowed to write to replica */
1766 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1769 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1770 "%s: line %d: missing dn in \"updatedn <dn>\""
1771 " line.\n", fname, lineno ));
1773 Debug( LDAP_DEBUG_ANY,
1774 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1782 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1783 "%s: line %d: updatedn line must appear inside "
1784 "a database definition\n",
1787 Debug( LDAP_DEBUG_ANY,
1788 "%s: line %d: updatedn line must appear inside a database definition\n",
1796 if ( load_ucdata( NULL ) < 0 ) return 1;
1798 dn.bv_val = cargv[1];
1799 dn.bv_len = strlen( cargv[1] );
1801 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1802 if( rc != LDAP_SUCCESS ) {
1804 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1805 "%s: line %d: updatedn DN is invalid.\n",
1808 Debug( LDAP_DEBUG_ANY,
1809 "%s: line %d: updatedn DN is invalid\n",
1816 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1819 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1820 "missing url in \"updateref <ldapurl>\" line.\n",
1823 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1824 "missing url in \"updateref <ldapurl>\" line\n",
1832 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1833 " line must appear inside a database definition\n",
1836 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1837 " line must appear inside a database definition\n",
1842 } else if ( !be->be_update_ndn.bv_len ) {
1844 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1845 "updateref line must come after updatedn.\n",
1848 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1849 "updateref line must after updatedn.\n",
1855 if( validate_global_referral( cargv[1] ) ) {
1857 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1858 "invalid URL (%s) in \"updateref\" line.\n",
1859 fname, lineno, cargv[1] ));
1861 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1862 "invalid URL (%s) in \"updateref\" line.\n",
1863 fname, lineno, cargv[1] );
1868 vals[0].bv_val = cargv[1];
1869 vals[0].bv_len = strlen( vals[0].bv_val );
1870 value_add( &be->be_update_refs, vals );
1872 /* replication log file to which changes are appended */
1873 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1876 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1877 "%s: line %d: missing filename in \"replogfile <filename>\""
1878 " line.\n", fname, lineno ));
1880 Debug( LDAP_DEBUG_ANY,
1881 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1888 be->be_replogfile = ch_strdup( cargv[1] );
1890 replogfile = ch_strdup( cargv[1] );
1893 /* file from which to read additional rootdse attrs */
1894 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1897 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1898 "missing filename in \"rootDSE <filename>\" line.\n",
1901 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1902 "missing filename in \"rootDSE <filename>\" line.\n",
1908 if( read_root_dse_file( cargv[1] ) ) {
1910 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1911 "could not read \"rootDSE <filename>\" line.\n",
1914 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1915 "could not read \"rootDSE <filename>\" line\n",
1921 /* maintain lastmodified{by,time} attributes */
1922 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1925 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1926 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1927 " line.\n", fname, lineno ));
1929 Debug( LDAP_DEBUG_ANY,
1930 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1936 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1938 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
1944 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
1951 /* turn on/off gentle SIGHUP handling */
1952 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
1954 Debug( LDAP_DEBUG_ANY,
1955 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
1959 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1960 global_gentlehup = 0;
1962 global_gentlehup = 1;
1966 /* set idle timeout value */
1967 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1971 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1972 "%s: line %d: missing timeout value in "
1973 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1975 Debug( LDAP_DEBUG_ANY,
1976 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1983 i = atoi( cargv[1] );
1987 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1988 "%s: line %d: timeout value (%d) invalid "
1989 "\"idletimeout <seconds>\" line.\n",
1990 fname, lineno, i ));
1992 Debug( LDAP_DEBUG_ANY,
1993 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2000 global_idletimeout = i;
2002 /* include another config file */
2003 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2006 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2007 "%s: line %d: missing filename in \"include "
2008 "<filename>\" line.\n", fname, lineno ));
2010 Debug( LDAP_DEBUG_ANY,
2011 "%s: line %d: missing filename in \"include <filename>\" line\n",
2017 savefname = ch_strdup( cargv[1] );
2018 savelineno = lineno;
2020 if ( read_config( savefname ) != 0 ) {
2025 lineno = savelineno - 1;
2027 /* location of kerberos srvtab file */
2028 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2031 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2032 "%s: line %d: missing filename in \"srvtab "
2033 "<filename>\" line.\n", fname, lineno ));
2035 Debug( LDAP_DEBUG_ANY,
2036 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2042 ldap_srvtab = ch_strdup( cargv[1] );
2044 #ifdef SLAPD_MODULES
2045 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2048 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2049 "%s: line %d: missing filename in \"moduleload "
2050 "<filename>\" line.\n", fname, lineno ));
2052 Debug( LDAP_DEBUG_ANY,
2053 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2057 exit( EXIT_FAILURE );
2059 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2061 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2062 "%s: line %d: failed to load or initialize module %s\n",
2063 fname, lineno, cargv[1] ));
2065 Debug( LDAP_DEBUG_ANY,
2066 "%s: line %d: failed to load or initialize module %s\n",
2067 fname, lineno, cargv[1]);
2070 exit( EXIT_FAILURE );
2072 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2075 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2076 "%s: line %d: missing path in \"modulepath <path>\""
2077 " line\n", fname, lineno ));
2079 Debug( LDAP_DEBUG_ANY,
2080 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2084 exit( EXIT_FAILURE );
2086 if (module_path( cargv[1] )) {
2088 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2089 "%s: line %d: failed to set module search path to %s.\n",
2090 fname, lineno, cargv[1] ));
2092 Debug( LDAP_DEBUG_ANY,
2093 "%s: line %d: failed to set module search path to %s\n",
2094 fname, lineno, cargv[1]);
2097 exit( EXIT_FAILURE );
2100 #endif /*SLAPD_MODULES*/
2103 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2104 rc = ldap_pvt_tls_set_option( NULL,
2105 LDAP_OPT_X_TLS_RANDOM_FILE,
2110 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2111 rc = ldap_pvt_tls_set_option( NULL,
2112 LDAP_OPT_X_TLS_CIPHER_SUITE,
2117 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2118 rc = ldap_pvt_tls_set_option( NULL,
2119 LDAP_OPT_X_TLS_CERTFILE,
2124 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2125 rc = ldap_pvt_tls_set_option( NULL,
2126 LDAP_OPT_X_TLS_KEYFILE,
2131 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2132 rc = ldap_pvt_tls_set_option( NULL,
2133 LDAP_OPT_X_TLS_CACERTDIR,
2138 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2139 rc = ldap_pvt_tls_set_option( NULL,
2140 LDAP_OPT_X_TLS_CACERTFILE,
2144 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2145 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2147 rc = ldap_pvt_tls_set_option( NULL,
2148 LDAP_OPT_X_TLS_REQUIRE_CERT,
2151 rc = ldap_int_tls_config( NULL,
2152 LDAP_OPT_X_TLS_REQUIRE_CERT,
2161 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2162 #ifdef SLAPD_RLOOKUPS
2165 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2166 "%s: line %d: reverse-lookup: "
2167 "missing \"on\" or \"off\"\n",
2170 Debug( LDAP_DEBUG_ANY,
2171 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2177 if ( !strcasecmp( cargv[1], "on" ) ) {
2178 use_reverse_lookup = 1;
2179 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2180 use_reverse_lookup = 0;
2183 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2184 "%s: line %d: reverse-lookup: "
2185 "must be \"on\" (default) "
2189 Debug( LDAP_DEBUG_ANY,
2190 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2196 #else /* !SLAPD_RLOOKUPS */
2198 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2199 "%s: line %d: reverse lookups "
2200 "are not configured (ignored).\n",
2203 Debug( LDAP_DEBUG_ANY,
2204 "%s: line %d: reverse lookups are not configured (ignored).\n",
2207 #endif /* !SLAPD_RLOOKUPS */
2209 /* pass anything else to the current backend info/db config routine */
2212 if ( bi->bi_config == 0 ) {
2214 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2215 "%s: line %d: unknown directive \"%s\" inside "
2216 "backend info definition (ignored).\n",
2217 fname, lineno, cargv[0] ));
2219 Debug( LDAP_DEBUG_ANY,
2220 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2221 fname, lineno, cargv[0] );
2225 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2231 } else if ( be != NULL ) {
2232 if ( be->be_config == 0 ) {
2234 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2235 "%s: line %d: uknown directive \"%s\" inside "
2236 "backend database definition (ignored).\n",
2237 fname, lineno, cargv[0] ));
2239 Debug( LDAP_DEBUG_ANY,
2240 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2241 fname, lineno, cargv[0] );
2245 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2253 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2254 "%s: line %d: unknown directive \"%s\" outside backend "
2255 "info and database definitions (ignored).\n",
2256 fname, lineno, cargv[0] ));
2258 Debug( LDAP_DEBUG_ANY,
2259 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2260 fname, lineno, cargv[0] );
2269 if ( load_ucdata( NULL ) < 0 ) return 1;
2281 char logbuf[sizeof("pseudorootpw ***")];
2284 token = strtok_quote( line, " \t" );
2288 (strcasecmp( token, "rootpw" ) == 0 ||
2289 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2290 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2291 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2292 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2293 sprintf( logline = logbuf, "%s ***", token );
2294 if ( strtok_quote_ptr )
2295 *strtok_quote_ptr = ' ';
2297 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2298 "line %d (%s)\n", lineno, logline ));
2300 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2302 if ( strtok_quote_ptr )
2303 *strtok_quote_ptr = '\0';
2305 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2306 if ( cargc == cargv_size - 1 ) {
2308 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2310 if ( tmp == NULL ) {
2312 LDAP_LOG(( "config", LDAP_LEVEL_ERR,
2313 "line %d: out of memory\n",
2316 Debug( LDAP_DEBUG_ANY,
2317 "line %d: out of memory\n",
2323 cargv_size += ARGS_STEP;
2325 cargv[cargc++] = token;
2327 cargv[cargc] = NULL;
2332 strtok_quote( char *line, char *sep )
2338 strtok_quote_ptr = NULL;
2339 if ( line != NULL ) {
2342 while ( *next && strchr( sep, *next ) ) {
2346 if ( *next == '\0' ) {
2352 for ( inquote = 0; *next; ) {
2360 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2366 next + 1, strlen( next + 1 ) + 1 );
2367 next++; /* dont parse the escaped character */
2372 if ( strchr( sep, *next ) != NULL ) {
2373 strtok_quote_ptr = next;
2386 static char buf[BUFSIZ];
2388 static int lmax, lcur;
2390 #define CATLINE( buf ) { \
2392 len = strlen( buf ); \
2393 while ( lcur + len + 1 > lmax ) { \
2395 line = (char *) ch_realloc( line, lmax ); \
2397 strcpy( line + lcur, buf ); \
2402 fp_getline( FILE *fp, int *lineno )
2410 /* hack attack - keeps us from having to keep a stack of bufs... */
2411 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2416 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2417 /* trim off \r\n or \n */
2418 if ( (p = strchr( buf, '\n' )) != NULL ) {
2419 if( p > buf && p[-1] == '\r' ) --p;
2423 /* trim off trailing \ and append the next line */
2424 if ( line[ 0 ] != '\0'
2425 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2426 && p[ -1 ] != '\\' ) {
2431 if ( ! isspace( (unsigned char) buf[0] ) ) {
2435 /* change leading whitespace to a space */
2444 return( line[0] ? line : NULL );
2448 fp_getline_init( int *lineno )
2454 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2456 load_ucdata( char *path )
2458 static int loaded = 0;
2464 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2467 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2468 "load_ucdata: Error %d loading ucdata.\n", err ));
2470 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2483 ucdata_unload( UCDATA_ALL );
2485 if ( slapd_args_file )
2486 free ( slapd_args_file );
2487 if ( slapd_pid_file )
2488 free ( slapd_pid_file );
2489 acl_destroy( global_acl, NULL );