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 #ifdef HAVE_CYRUS_SASL
562 /* SASL config options */
563 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
564 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
566 #endif /* HAVE_CYRUS_SASL */
568 /* set UCDATA path */
569 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
573 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
574 "%s: line %d: missing path in "
575 "\"ucdata-path <path>\" line.\n",
578 Debug( LDAP_DEBUG_ANY,
579 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
586 err = load_ucdata( cargv[1] );
590 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
591 "%s: line %d: ucdata already loaded, ucdata-path "
592 "must be set earlier in the file and/or be "
593 "specified only once!\n",
596 Debug( LDAP_DEBUG_ANY,
597 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
606 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
608 struct slap_limits_set *lim;
612 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
613 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
616 Debug( LDAP_DEBUG_ANY,
617 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
627 lim = &be->be_def_limit;
630 for ( i = 1; i < cargc; i++ ) {
631 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
632 rc = parse_limit( cargv[i], lim );
634 lim->lms_s_soft = atoi( cargv[i] );
640 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
641 "%s: line %d: unable "
642 "to parse value \"%s\" "
645 fname, lineno, cargv[i] ));
647 Debug( LDAP_DEBUG_ANY,
648 "%s: line %d: unable "
649 "to parse value \"%s\" "
652 fname, lineno, cargv[i] );
658 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
660 struct slap_limits_set *lim;
664 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
665 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
668 Debug( LDAP_DEBUG_ANY,
669 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
679 lim = &be->be_def_limit;
682 for ( i = 1; i < cargc; i++ ) {
683 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
684 rc = parse_limit( cargv[i], lim );
686 lim->lms_t_soft = atoi( cargv[i] );
692 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
693 "%s: line %d: unable "
694 "to parse value \"%s\" "
697 fname, lineno, cargv[i] ));
699 Debug( LDAP_DEBUG_ANY,
700 "%s: line %d: unable "
701 "to parse value \"%s\" "
704 fname, lineno, cargv[i] );
709 /* set regex-based limits */
710 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
713 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
714 "%s: line %d \"limits\" allowed only in database environment.\n",
717 Debug( LDAP_DEBUG_ANY,
718 "%s: line %d \"limits\" allowed only in database environment.\n%s",
724 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
728 /* mark this as a subordinate database */
729 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
732 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
733 "subordinate keyword must appear inside a database "
734 "definition.\n", fname, lineno ));
736 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
737 "must appear inside a database definition.\n",
743 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
747 /* set database suffix */
748 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
750 struct berval dn, pdn, ndn;
754 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
755 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
758 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
759 "missing dn in \"suffix <dn>\" line\n",
765 } else if ( cargc > 2 ) {
767 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
768 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
769 " line (ignored).\n", fname, lineno, cargv[1] ));
771 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
772 "after <dn> in \"suffix %s\" line (ignored)\n",
773 fname, lineno, cargv[1] );
779 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
780 "%s: line %d: suffix line must appear inside a database "
781 "definition.\n", fname, lineno ));
783 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
784 "must appear inside a database definition\n",
789 #if defined(SLAPD_MONITOR_DN)
790 /* "cn=Monitor" is reserved for monitoring slap */
791 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
793 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
794 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
797 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
798 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
802 #endif /* SLAPD_MONITOR_DN */
805 if ( load_ucdata( NULL ) < 0 ) return 1;
807 dn.bv_val = cargv[1];
808 dn.bv_len = strlen( cargv[1] );
810 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
811 if( rc != LDAP_SUCCESS ) {
813 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
814 "%s: line %d: suffix DN is invalid.\n",
817 Debug( LDAP_DEBUG_ANY,
818 "%s: line %d: suffix DN is invalid\n",
824 tmp_be = select_backend( &ndn, 0, 0 );
825 if ( tmp_be == be ) {
827 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
828 "%s: line %d: suffix already served by this backend "
829 "(ignored)\n", fname, lineno ));
831 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
832 "already served by this backend (ignored)\n",
838 } else if ( tmp_be != NULL ) {
840 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
841 "%s: line %d: suffix already served by a preceding "
842 "backend \"%s\"\n", fname, lineno,
843 tmp_be->be_suffix[0].bv_val ));
845 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
846 "already served by a preceeding backend \"%s\"\n",
847 fname, lineno, tmp_be->be_suffix[0].bv_val );
853 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
855 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
856 "%s: line %d: suffix DN empty and default search "
857 "base provided \"%s\" (assuming okay).\n",
858 fname, lineno, default_search_base.bv_val ));
860 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
861 "suffix DN empty and default "
862 "search base provided \"%s\" (assuming okay)\n",
863 fname, lineno, default_search_base.bv_val );
867 ber_bvarray_add( &be->be_suffix, &pdn );
868 ber_bvarray_add( &be->be_nsuffix, &ndn );
870 /* set database suffixAlias */
871 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
873 struct berval alias, palias, nalias;
874 struct berval aliased, paliased, naliased;
878 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
879 "%s: line %d: missing alias and aliased_dn in "
880 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
883 Debug( LDAP_DEBUG_ANY,
884 "%s: line %d: missing alias and aliased_dn in "
885 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
890 } else if ( cargc < 3 ) {
892 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
893 "%s: line %d: missing aliased_dn in "
894 "\"suffixAlias <alias> <aliased_dn>\" line\n",
897 Debug( LDAP_DEBUG_ANY,
898 "%s: line %d: missing aliased_dn in "
899 "\"suffixAlias <alias> <aliased_dn>\" line\n",
904 } else if ( cargc > 3 ) {
906 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
907 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
910 Debug( LDAP_DEBUG_ANY,
911 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
918 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
919 "%s: line %d: suffixAlias line must appear inside a "
920 "database definition.\n", fname, lineno ));
922 Debug( LDAP_DEBUG_ANY,
923 "%s: line %d: suffixAlias line"
924 " must appear inside a database definition.\n",
930 if ( load_ucdata( NULL ) < 0 ) return 1;
932 alias.bv_val = cargv[1];
933 alias.bv_len = strlen( cargv[1] );
935 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
936 if( rc != LDAP_SUCCESS ) {
938 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
939 "%s: line %d: alias DN is invalid.\n",
942 Debug( LDAP_DEBUG_ANY,
943 "%s: line %d: alias DN is invalid\n",
949 tmp_be = select_backend( &nalias, 0, 0 );
950 free( nalias.bv_val );
951 if ( tmp_be && tmp_be != be ) {
953 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
954 "%s: line %d: suffixAlias served by a preceeding "
956 fname, lineno, tmp_be->be_suffix[0].bv_val ));
958 Debug( LDAP_DEBUG_ANY,
959 "%s: line %d: suffixAlias served by"
960 " a preceeding backend \"%s\"\n",
961 fname, lineno, tmp_be->be_suffix[0].bv_val );
963 free( palias.bv_val );
967 aliased.bv_val = cargv[2];
968 aliased.bv_len = strlen( cargv[2] );
970 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
971 if( rc != LDAP_SUCCESS ) {
973 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
974 "%s: line %d: aliased DN is invalid.\n",
977 Debug( LDAP_DEBUG_ANY,
978 "%s: line %d: aliased DN is invalid\n",
981 free( palias.bv_val );
985 tmp_be = select_backend( &naliased, 0, 0 );
986 free( naliased.bv_val );
987 if ( tmp_be && tmp_be != be ) {
989 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
990 "%s: line %d: suffixAlias derefs to a different backend "
991 "a preceeding backend \"%s\"\n",
992 fname, lineno, tmp_be->be_suffix[0].bv_val ));
994 Debug( LDAP_DEBUG_ANY,
995 "%s: line %d: suffixAlias derefs to differnet backend"
996 " a preceeding backend \"%s\"\n",
997 fname, lineno, tmp_be->be_suffix[0].bv_val );
999 free( palias.bv_val );
1000 free( paliased.bv_val );
1004 ber_bvarray_add( &be->be_suffixAlias, &palias );
1005 ber_bvarray_add( &be->be_suffixAlias, &paliased );
1007 /* set max deref depth */
1008 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1012 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1013 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1014 " line\n", fname, lineno ));
1016 Debug( LDAP_DEBUG_ANY,
1017 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1025 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1026 "%s: line %d: depth line must appear inside a database "
1027 "definition.\n", fname, lineno ));
1029 Debug( LDAP_DEBUG_ANY,
1030 "%s: line %d: depth line must appear inside a database definition.\n",
1035 } else if ((i = atoi(cargv[1])) < 0) {
1037 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1038 "%s: line %d: depth must be positive.\n",
1041 Debug( LDAP_DEBUG_ANY,
1042 "%s: line %d: depth must be positive.\n",
1049 be->be_max_deref_depth = i;
1053 /* set magic "root" dn for this database */
1054 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1057 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1058 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1061 Debug( LDAP_DEBUG_ANY,
1062 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1071 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1072 "%s: line %d: rootdn line must appear inside a database "
1073 "definition.\n", fname, lineno ));
1075 Debug( LDAP_DEBUG_ANY,
1076 "%s: line %d: rootdn line must appear inside a database definition.\n",
1084 if ( load_ucdata( NULL ) < 0 ) return 1;
1086 dn.bv_val = cargv[1];
1087 dn.bv_len = strlen( cargv[1] );
1089 rc = dnPrettyNormal( NULL, &dn,
1093 if( rc != LDAP_SUCCESS ) {
1095 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1096 "%s: line %d: rootdn DN is invalid.\n",
1099 Debug( LDAP_DEBUG_ANY,
1100 "%s: line %d: rootdn DN is invalid\n",
1107 /* set super-secret magic database password */
1108 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1111 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1112 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1113 " line\n", fname, lineno ));
1115 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1116 "missing passwd in \"rootpw <passwd>\" line\n",
1125 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1126 "rootpw line must appear inside a database "
1127 "definition.\n", fname, lineno ));
1129 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1130 "rootpw line must appear inside a database "
1137 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1139 if( tmp_be != be ) {
1141 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1143 "rootpw can only be set when rootdn is under suffix\n"
1146 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1147 "rootpw can only be set when rootdn is under suffix\n",
1153 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1154 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1157 /* make this database read-only */
1158 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1161 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1162 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1165 Debug( LDAP_DEBUG_ANY,
1166 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1173 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1174 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1176 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1179 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1180 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1182 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1187 /* allow these features */
1188 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1189 strcasecmp( cargv[0], "allow" ) == 0 )
1195 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1196 "%s: line %d: allow line must appear prior to "
1197 "database definitions.\n", fname, lineno ));
1199 Debug( LDAP_DEBUG_ANY,
1200 "%s: line %d: allow line must appear prior to database definitions\n",
1208 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1209 "%s: line %d: missing feature(s) in \"allow <features>\""
1210 " line\n", fname, lineno ));
1212 Debug( LDAP_DEBUG_ANY,
1213 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1222 for( i=1; i < cargc; i++ ) {
1223 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1224 allows |= SLAP_ALLOW_BIND_V2;
1226 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1227 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1229 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1230 allows |= SLAP_ALLOW_BIND_ANON_DN;
1232 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1234 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1235 "%s: line %d: unknown feature %s in "
1236 "\"allow <features>\" line.\n",
1237 fname, lineno, cargv[1] ));
1239 Debug( LDAP_DEBUG_ANY,
1240 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1241 fname, lineno, cargv[i] );
1248 global_allows = allows;
1250 /* disallow these features */
1251 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1252 strcasecmp( cargv[0], "disallow" ) == 0 )
1254 slap_mask_t disallows;
1258 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1259 "%s: line %d: disallow line must appear prior to "
1260 "database definitions.\n", fname, lineno ));
1262 Debug( LDAP_DEBUG_ANY,
1263 "%s: line %d: disallow line must appear prior to database definitions\n",
1271 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1272 "%s: line %d: missing feature(s) in \"disallow <features>\""
1273 " line.\n", fname, lineno ));
1275 Debug( LDAP_DEBUG_ANY,
1276 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1285 for( i=1; i < cargc; i++ ) {
1286 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1287 disallows |= SLAP_DISALLOW_BIND_ANON;
1289 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1290 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1292 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1293 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1295 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1296 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1298 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1299 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1301 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1303 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1304 "%s: line %d: unknown feature %s in "
1305 "\"disallow <features>\" line.\n",
1306 fname, lineno, cargv[i] ));
1308 Debug( LDAP_DEBUG_ANY,
1309 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1310 fname, lineno, cargv[i] );
1317 global_disallows = disallows;
1319 /* require these features */
1320 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1321 strcasecmp( cargv[0], "require" ) == 0 )
1323 slap_mask_t requires;
1327 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1328 "%s: line %d: missing feature(s) in "
1329 "\"require <features>\" line.\n", fname, lineno ));
1331 Debug( LDAP_DEBUG_ANY,
1332 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1341 for( i=1; i < cargc; i++ ) {
1342 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1343 requires |= SLAP_REQUIRE_BIND;
1345 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1346 requires |= SLAP_REQUIRE_LDAP_V3;
1348 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1349 requires |= SLAP_REQUIRE_AUTHC;
1351 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1352 requires |= SLAP_REQUIRE_SASL;
1354 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1355 requires |= SLAP_REQUIRE_STRONG;
1357 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1359 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1360 "%s: line %d: unknown feature %s in "
1361 "\"require <features>\" line.\n",
1364 Debug( LDAP_DEBUG_ANY,
1365 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1366 fname, lineno, cargv[i] );
1374 global_requires = requires;
1376 be->be_requires = requires;
1379 /* required security factors */
1380 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1381 slap_ssf_set_t *set;
1385 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1386 "%s: line %d: missing factor(s) in \"security <factors>\""
1387 " line.\n", fname, lineno ));
1389 Debug( LDAP_DEBUG_ANY,
1390 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1398 set = &global_ssf_set;
1400 set = &be->be_ssf_set;
1403 for( i=1; i < cargc; i++ ) {
1404 if( strncasecmp( cargv[i], "ssf=",
1405 sizeof("ssf") ) == 0 )
1408 atoi( &cargv[i][sizeof("ssf")] );
1410 } else if( strncasecmp( cargv[i], "transport=",
1411 sizeof("transport") ) == 0 )
1413 set->sss_transport =
1414 atoi( &cargv[i][sizeof("transport")] );
1416 } else if( strncasecmp( cargv[i], "tls=",
1417 sizeof("tls") ) == 0 )
1420 atoi( &cargv[i][sizeof("tls")] );
1422 } else if( strncasecmp( cargv[i], "sasl=",
1423 sizeof("sasl") ) == 0 )
1426 atoi( &cargv[i][sizeof("sasl")] );
1428 } else if( strncasecmp( cargv[i], "update_ssf=",
1429 sizeof("update_ssf") ) == 0 )
1431 set->sss_update_ssf =
1432 atoi( &cargv[i][sizeof("update_ssf")] );
1434 } else if( strncasecmp( cargv[i], "update_transport=",
1435 sizeof("update_transport") ) == 0 )
1437 set->sss_update_transport =
1438 atoi( &cargv[i][sizeof("update_transport")] );
1440 } else if( strncasecmp( cargv[i], "update_tls=",
1441 sizeof("update_tls") ) == 0 )
1443 set->sss_update_tls =
1444 atoi( &cargv[i][sizeof("update_tls")] );
1446 } else if( strncasecmp( cargv[i], "update_sasl=",
1447 sizeof("update_sasl") ) == 0 )
1449 set->sss_update_sasl =
1450 atoi( &cargv[i][sizeof("update_sasl")] );
1454 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1455 "%s: line %d: unknown factor %S in "
1456 "\"security <factors>\" line.\n",
1457 fname, lineno, cargv[1] ));
1459 Debug( LDAP_DEBUG_ANY,
1460 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1461 fname, lineno, cargv[i] );
1467 /* where to send clients when we don't hold it */
1468 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1471 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1472 "%s: line %d: missing URL in \"referral <URL>\""
1473 " line.\n", fname, lineno ));
1475 Debug( LDAP_DEBUG_ANY,
1476 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1483 if( validate_global_referral( cargv[1] ) ) {
1485 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1486 "invalid URL (%s) in \"referral\" line.\n",
1487 fname, lineno, cargv[1] ));
1489 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1490 "invalid URL (%s) in \"referral\" line.\n",
1491 fname, lineno, cargv[1] );
1496 vals[0].bv_val = cargv[1];
1497 vals[0].bv_len = strlen( vals[0].bv_val );
1498 value_add( &default_referral, vals );
1501 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1505 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1506 "%s: line %d: Error in logfile directive, "
1507 "\"logfile <filename>\"\n", fname, lineno ));
1509 Debug( LDAP_DEBUG_ANY,
1510 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1516 logfile = fopen( cargv[1], "w" );
1517 if ( logfile != NULL ) lutil_debug_file( logfile );
1520 /* start of a new database definition */
1521 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1525 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1526 "%s: line %d: Error in debug directive, "
1527 "\"debug <subsys> <level>\"\n", fname, lineno ));
1529 Debug( LDAP_DEBUG_ANY,
1530 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1536 level = atoi( cargv[2] );
1537 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1538 lutil_set_debug_level( cargv[1], level );
1539 /* specify an Object Identifier macro */
1540 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1541 rc = parse_oidm( fname, lineno, cargc, cargv );
1544 /* specify an objectclass */
1545 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1546 if ( *cargv[1] == '(' ) {
1548 p = strchr(saveline,'(');
1549 rc = parse_oc( fname, lineno, p, cargv );
1554 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1555 "%s: line %d: old objectclass format not supported\n",
1558 Debug( LDAP_DEBUG_ANY,
1559 "%s: line %d: old objectclass format not supported.\n",
1564 /* specify an attribute type */
1565 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1566 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1568 if ( *cargv[1] == '(' ) {
1570 p = strchr(saveline,'(');
1571 rc = parse_at( fname, lineno, p, cargv );
1576 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1577 "%s: line %d: old attribute type format not supported.\n",
1580 Debug( LDAP_DEBUG_ANY,
1581 "%s: line %d: old attribute type format not supported.\n",
1587 /* turn on/off schema checking */
1588 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1591 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1592 "%s: line %d: missing on|off in "
1593 "\"schemacheck <on|off>\" line.\n",
1596 Debug( LDAP_DEBUG_ANY,
1597 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1603 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1605 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1606 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1609 Debug( LDAP_DEBUG_ANY,
1610 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1613 global_schemacheck = 0;
1615 global_schemacheck = 1;
1618 /* specify access control info */
1619 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1620 parse_acl( be, fname, lineno, cargc, cargv );
1622 /* debug level to log things to syslog */
1623 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1626 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1627 "%s: line %d: missing level in \"loglevel <level>\""
1628 " line.\n", fname, lineno ));
1630 Debug( LDAP_DEBUG_ANY,
1631 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1640 for( i=1; i < cargc; i++ ) {
1641 ldap_syslog += atoi( cargv[1] );
1644 /* list of replicas of the data in this backend (master only) */
1645 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1648 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1649 "%s: line %d: missing host in \"replica "
1650 " <host[:port]\" line\n", fname, lineno ));
1652 Debug( LDAP_DEBUG_ANY,
1653 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1661 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1662 "%s: line %d: replica line must appear inside "
1663 "a database definition.\n", fname, lineno ));
1665 Debug( LDAP_DEBUG_ANY,
1666 "%s: line %d: replica line must appear inside a database definition\n",
1674 for ( i = 1; i < cargc; i++ ) {
1675 if ( strncasecmp( cargv[i], "host=", 5 )
1677 nr = add_replica_info( be,
1684 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1685 "%s: line %d: missing host in \"replica\" line\n",
1688 Debug( LDAP_DEBUG_ANY,
1689 "%s: line %d: missing host in \"replica\" line\n",
1694 } else if ( nr == -1 ) {
1696 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1697 "%s: line %d: unable to add"
1698 " replica \"%s\"\n",
1702 Debug( LDAP_DEBUG_ANY,
1703 "%s: line %d: unable to add replica \"%s\"\n",
1704 fname, lineno, cargv[i] + 5 );
1708 for ( i = 1; i < cargc; i++ ) {
1709 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1711 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1714 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1715 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1716 fname, lineno, cargv[i] + 7 ));
1718 Debug( LDAP_DEBUG_ANY,
1719 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1720 fname, lineno, cargv[i] + 7 );
1726 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1727 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1730 Debug( LDAP_DEBUG_ANY,
1731 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1737 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1739 char *arg = cargv[i] + 4;
1741 if ( arg[0] == '!' ) {
1746 if ( arg[0] != '=' ) {
1750 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1752 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1753 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1754 fname, lineno, arg + 1 ));
1756 Debug( LDAP_DEBUG_ANY,
1757 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1758 fname, lineno, arg + 1 );
1767 /* dn of master entity allowed to write to replica */
1768 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1771 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1772 "%s: line %d: missing dn in \"updatedn <dn>\""
1773 " line.\n", fname, lineno ));
1775 Debug( LDAP_DEBUG_ANY,
1776 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1784 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1785 "%s: line %d: updatedn line must appear inside "
1786 "a database definition\n",
1789 Debug( LDAP_DEBUG_ANY,
1790 "%s: line %d: updatedn line must appear inside a database definition\n",
1798 if ( load_ucdata( NULL ) < 0 ) return 1;
1800 dn.bv_val = cargv[1];
1801 dn.bv_len = strlen( cargv[1] );
1803 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1804 if( rc != LDAP_SUCCESS ) {
1806 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1807 "%s: line %d: updatedn DN is invalid.\n",
1810 Debug( LDAP_DEBUG_ANY,
1811 "%s: line %d: updatedn DN is invalid\n",
1818 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1821 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1822 "missing url in \"updateref <ldapurl>\" line.\n",
1825 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1826 "missing url in \"updateref <ldapurl>\" line\n",
1834 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1835 " line must appear inside a database definition\n",
1838 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1839 " line must appear inside a database definition\n",
1844 } else if ( !be->be_update_ndn.bv_len ) {
1846 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1847 "updateref line must come after updatedn.\n",
1850 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1851 "updateref line must after updatedn.\n",
1857 if( validate_global_referral( cargv[1] ) ) {
1859 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1860 "invalid URL (%s) in \"updateref\" line.\n",
1861 fname, lineno, cargv[1] ));
1863 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1864 "invalid URL (%s) in \"updateref\" line.\n",
1865 fname, lineno, cargv[1] );
1870 vals[0].bv_val = cargv[1];
1871 vals[0].bv_len = strlen( vals[0].bv_val );
1872 value_add( &be->be_update_refs, vals );
1874 /* replication log file to which changes are appended */
1875 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1878 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1879 "%s: line %d: missing filename in \"replogfile <filename>\""
1880 " line.\n", fname, lineno ));
1882 Debug( LDAP_DEBUG_ANY,
1883 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1890 be->be_replogfile = ch_strdup( cargv[1] );
1892 replogfile = ch_strdup( cargv[1] );
1895 /* file from which to read additional rootdse attrs */
1896 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1899 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1900 "missing filename in \"rootDSE <filename>\" line.\n",
1903 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1904 "missing filename in \"rootDSE <filename>\" line.\n",
1910 if( read_root_dse_file( cargv[1] ) ) {
1912 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1913 "could not read \"rootDSE <filename>\" line.\n",
1916 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1917 "could not read \"rootDSE <filename>\" line\n",
1923 /* maintain lastmodified{by,time} attributes */
1924 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1927 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1928 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1929 " line.\n", fname, lineno ));
1931 Debug( LDAP_DEBUG_ANY,
1932 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1938 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1940 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
1946 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
1953 /* turn on/off gentle SIGHUP handling */
1954 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
1956 Debug( LDAP_DEBUG_ANY,
1957 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
1961 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1962 global_gentlehup = 0;
1964 global_gentlehup = 1;
1968 /* set idle timeout value */
1969 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1973 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1974 "%s: line %d: missing timeout value in "
1975 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1977 Debug( LDAP_DEBUG_ANY,
1978 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1985 i = atoi( cargv[1] );
1989 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1990 "%s: line %d: timeout value (%d) invalid "
1991 "\"idletimeout <seconds>\" line.\n",
1992 fname, lineno, i ));
1994 Debug( LDAP_DEBUG_ANY,
1995 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2002 global_idletimeout = i;
2004 /* include another config file */
2005 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2008 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2009 "%s: line %d: missing filename in \"include "
2010 "<filename>\" line.\n", fname, lineno ));
2012 Debug( LDAP_DEBUG_ANY,
2013 "%s: line %d: missing filename in \"include <filename>\" line\n",
2019 savefname = ch_strdup( cargv[1] );
2020 savelineno = lineno;
2022 if ( read_config( savefname ) != 0 ) {
2027 lineno = savelineno - 1;
2029 /* location of kerberos srvtab file */
2030 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2033 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2034 "%s: line %d: missing filename in \"srvtab "
2035 "<filename>\" line.\n", fname, lineno ));
2037 Debug( LDAP_DEBUG_ANY,
2038 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2044 ldap_srvtab = ch_strdup( cargv[1] );
2046 #ifdef SLAPD_MODULES
2047 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2050 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2051 "%s: line %d: missing filename in \"moduleload "
2052 "<filename>\" line.\n", fname, lineno ));
2054 Debug( LDAP_DEBUG_ANY,
2055 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2059 exit( EXIT_FAILURE );
2061 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2063 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2064 "%s: line %d: failed to load or initialize module %s\n",
2065 fname, lineno, cargv[1] ));
2067 Debug( LDAP_DEBUG_ANY,
2068 "%s: line %d: failed to load or initialize module %s\n",
2069 fname, lineno, cargv[1]);
2072 exit( EXIT_FAILURE );
2074 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2077 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2078 "%s: line %d: missing path in \"modulepath <path>\""
2079 " line\n", fname, lineno ));
2081 Debug( LDAP_DEBUG_ANY,
2082 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2086 exit( EXIT_FAILURE );
2088 if (module_path( cargv[1] )) {
2090 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2091 "%s: line %d: failed to set module search path to %s.\n",
2092 fname, lineno, cargv[1] ));
2094 Debug( LDAP_DEBUG_ANY,
2095 "%s: line %d: failed to set module search path to %s\n",
2096 fname, lineno, cargv[1]);
2099 exit( EXIT_FAILURE );
2102 #endif /*SLAPD_MODULES*/
2105 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2106 rc = ldap_pvt_tls_set_option( NULL,
2107 LDAP_OPT_X_TLS_RANDOM_FILE,
2112 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2113 rc = ldap_pvt_tls_set_option( NULL,
2114 LDAP_OPT_X_TLS_CIPHER_SUITE,
2119 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2120 rc = ldap_pvt_tls_set_option( NULL,
2121 LDAP_OPT_X_TLS_CERTFILE,
2126 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2127 rc = ldap_pvt_tls_set_option( NULL,
2128 LDAP_OPT_X_TLS_KEYFILE,
2133 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2134 rc = ldap_pvt_tls_set_option( NULL,
2135 LDAP_OPT_X_TLS_CACERTDIR,
2140 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2141 rc = ldap_pvt_tls_set_option( NULL,
2142 LDAP_OPT_X_TLS_CACERTFILE,
2146 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2147 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2149 rc = ldap_pvt_tls_set_option( NULL,
2150 LDAP_OPT_X_TLS_REQUIRE_CERT,
2153 rc = ldap_int_tls_config( NULL,
2154 LDAP_OPT_X_TLS_REQUIRE_CERT,
2163 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2164 #ifdef SLAPD_RLOOKUPS
2167 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2168 "%s: line %d: reverse-lookup: "
2169 "missing \"on\" or \"off\"\n",
2172 Debug( LDAP_DEBUG_ANY,
2173 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2179 if ( !strcasecmp( cargv[1], "on" ) ) {
2180 use_reverse_lookup = 1;
2181 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2182 use_reverse_lookup = 0;
2185 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2186 "%s: line %d: reverse-lookup: "
2187 "must be \"on\" (default) "
2191 Debug( LDAP_DEBUG_ANY,
2192 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2198 #else /* !SLAPD_RLOOKUPS */
2200 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2201 "%s: line %d: reverse lookups "
2202 "are not configured (ignored).\n",
2205 Debug( LDAP_DEBUG_ANY,
2206 "%s: line %d: reverse lookups are not configured (ignored).\n",
2209 #endif /* !SLAPD_RLOOKUPS */
2211 /* pass anything else to the current backend info/db config routine */
2214 if ( bi->bi_config == 0 ) {
2216 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2217 "%s: line %d: unknown directive \"%s\" inside "
2218 "backend info definition (ignored).\n",
2219 fname, lineno, cargv[0] ));
2221 Debug( LDAP_DEBUG_ANY,
2222 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2223 fname, lineno, cargv[0] );
2227 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2233 } else if ( be != NULL ) {
2234 if ( be->be_config == 0 ) {
2236 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2237 "%s: line %d: uknown directive \"%s\" inside "
2238 "backend database definition (ignored).\n",
2239 fname, lineno, cargv[0] ));
2241 Debug( LDAP_DEBUG_ANY,
2242 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2243 fname, lineno, cargv[0] );
2247 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2255 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2256 "%s: line %d: unknown directive \"%s\" outside backend "
2257 "info and database definitions (ignored).\n",
2258 fname, lineno, cargv[0] ));
2260 Debug( LDAP_DEBUG_ANY,
2261 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2262 fname, lineno, cargv[0] );
2271 if ( load_ucdata( NULL ) < 0 ) return 1;
2283 char logbuf[sizeof("pseudorootpw ***")];
2286 token = strtok_quote( line, " \t" );
2290 (strcasecmp( token, "rootpw" ) == 0 ||
2291 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2292 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2293 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2294 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2295 sprintf( logline = logbuf, "%s ***", token );
2296 if ( strtok_quote_ptr )
2297 *strtok_quote_ptr = ' ';
2299 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2300 "line %d (%s)\n", lineno, logline ));
2302 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2304 if ( strtok_quote_ptr )
2305 *strtok_quote_ptr = '\0';
2307 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2308 if ( cargc == cargv_size - 1 ) {
2310 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2312 if ( tmp == NULL ) {
2314 LDAP_LOG(( "config", LDAP_LEVEL_ERR,
2315 "line %d: out of memory\n",
2318 Debug( LDAP_DEBUG_ANY,
2319 "line %d: out of memory\n",
2325 cargv_size += ARGS_STEP;
2327 cargv[cargc++] = token;
2329 cargv[cargc] = NULL;
2334 strtok_quote( char *line, char *sep )
2340 strtok_quote_ptr = NULL;
2341 if ( line != NULL ) {
2344 while ( *next && strchr( sep, *next ) ) {
2348 if ( *next == '\0' ) {
2354 for ( inquote = 0; *next; ) {
2362 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2368 next + 1, strlen( next + 1 ) + 1 );
2369 next++; /* dont parse the escaped character */
2374 if ( strchr( sep, *next ) != NULL ) {
2375 strtok_quote_ptr = next;
2388 static char buf[BUFSIZ];
2390 static int lmax, lcur;
2392 #define CATLINE( buf ) { \
2394 len = strlen( buf ); \
2395 while ( lcur + len + 1 > lmax ) { \
2397 line = (char *) ch_realloc( line, lmax ); \
2399 strcpy( line + lcur, buf ); \
2404 fp_getline( FILE *fp, int *lineno )
2412 /* hack attack - keeps us from having to keep a stack of bufs... */
2413 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2418 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2419 /* trim off \r\n or \n */
2420 if ( (p = strchr( buf, '\n' )) != NULL ) {
2421 if( p > buf && p[-1] == '\r' ) --p;
2425 /* trim off trailing \ and append the next line */
2426 if ( line[ 0 ] != '\0'
2427 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2428 && p[ -1 ] != '\\' ) {
2433 if ( ! isspace( (unsigned char) buf[0] ) ) {
2437 /* change leading whitespace to a space */
2446 return( line[0] ? line : NULL );
2450 fp_getline_init( int *lineno )
2456 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2458 load_ucdata( char *path )
2460 static int loaded = 0;
2466 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2469 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2470 "load_ucdata: Error %d loading ucdata.\n", err ));
2472 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2485 ucdata_unload( UCDATA_ALL );
2487 if ( slapd_args_file )
2488 free ( slapd_args_file );
2489 if ( slapd_pid_file )
2490 free ( slapd_pid_file );
2491 acl_destroy( global_acl, NULL );