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_simple_unprotected" ) == 0 ) {
1293 disallows |= SLAP_DISALLOW_BIND_SIMPLE_UNPROTECTED;
1295 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1296 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1298 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1299 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1301 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1302 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1304 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1306 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1307 "%s: line %d: unknown feature %s in "
1308 "\"disallow <features>\" line.\n",
1309 fname, lineno, cargv[i] ));
1311 Debug( LDAP_DEBUG_ANY,
1312 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1313 fname, lineno, cargv[i] );
1320 global_disallows = disallows;
1322 /* require these features */
1323 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1324 strcasecmp( cargv[0], "require" ) == 0 )
1326 slap_mask_t requires;
1330 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1331 "%s: line %d: missing feature(s) in "
1332 "\"require <features>\" line.\n", fname, lineno ));
1334 Debug( LDAP_DEBUG_ANY,
1335 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1344 for( i=1; i < cargc; i++ ) {
1345 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1346 requires |= SLAP_REQUIRE_BIND;
1348 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1349 requires |= SLAP_REQUIRE_LDAP_V3;
1351 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1352 requires |= SLAP_REQUIRE_AUTHC;
1354 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1355 requires |= SLAP_REQUIRE_SASL;
1357 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1358 requires |= SLAP_REQUIRE_STRONG;
1360 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1362 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1363 "%s: line %d: unknown feature %s in "
1364 "\"require <features>\" line.\n",
1367 Debug( LDAP_DEBUG_ANY,
1368 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1369 fname, lineno, cargv[i] );
1377 global_requires = requires;
1379 be->be_requires = requires;
1382 /* required security factors */
1383 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1384 slap_ssf_set_t *set;
1388 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1389 "%s: line %d: missing factor(s) in \"security <factors>\""
1390 " line.\n", fname, lineno ));
1392 Debug( LDAP_DEBUG_ANY,
1393 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1401 set = &global_ssf_set;
1403 set = &be->be_ssf_set;
1406 for( i=1; i < cargc; i++ ) {
1407 if( strncasecmp( cargv[i], "ssf=",
1408 sizeof("ssf") ) == 0 )
1411 atoi( &cargv[i][sizeof("ssf")] );
1413 } else if( strncasecmp( cargv[i], "transport=",
1414 sizeof("transport") ) == 0 )
1416 set->sss_transport =
1417 atoi( &cargv[i][sizeof("transport")] );
1419 } else if( strncasecmp( cargv[i], "tls=",
1420 sizeof("tls") ) == 0 )
1423 atoi( &cargv[i][sizeof("tls")] );
1425 } else if( strncasecmp( cargv[i], "sasl=",
1426 sizeof("sasl") ) == 0 )
1429 atoi( &cargv[i][sizeof("sasl")] );
1431 } else if( strncasecmp( cargv[i], "update_ssf=",
1432 sizeof("update_ssf") ) == 0 )
1434 set->sss_update_ssf =
1435 atoi( &cargv[i][sizeof("update_ssf")] );
1437 } else if( strncasecmp( cargv[i], "update_transport=",
1438 sizeof("update_transport") ) == 0 )
1440 set->sss_update_transport =
1441 atoi( &cargv[i][sizeof("update_transport")] );
1443 } else if( strncasecmp( cargv[i], "update_tls=",
1444 sizeof("update_tls") ) == 0 )
1446 set->sss_update_tls =
1447 atoi( &cargv[i][sizeof("update_tls")] );
1449 } else if( strncasecmp( cargv[i], "update_sasl=",
1450 sizeof("update_sasl") ) == 0 )
1452 set->sss_update_sasl =
1453 atoi( &cargv[i][sizeof("update_sasl")] );
1457 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1458 "%s: line %d: unknown factor %S in "
1459 "\"security <factors>\" line.\n",
1460 fname, lineno, cargv[1] ));
1462 Debug( LDAP_DEBUG_ANY,
1463 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1464 fname, lineno, cargv[i] );
1470 /* where to send clients when we don't hold it */
1471 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1474 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1475 "%s: line %d: missing URL in \"referral <URL>\""
1476 " line.\n", fname, lineno ));
1478 Debug( LDAP_DEBUG_ANY,
1479 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1486 if( validate_global_referral( cargv[1] ) ) {
1488 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1489 "invalid URL (%s) in \"referral\" line.\n",
1490 fname, lineno, cargv[1] ));
1492 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1493 "invalid URL (%s) in \"referral\" line.\n",
1494 fname, lineno, cargv[1] );
1499 vals[0].bv_val = cargv[1];
1500 vals[0].bv_len = strlen( vals[0].bv_val );
1501 value_add( &default_referral, vals );
1504 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1508 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1509 "%s: line %d: Error in logfile directive, "
1510 "\"logfile <filename>\"\n", fname, lineno ));
1512 Debug( LDAP_DEBUG_ANY,
1513 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1519 logfile = fopen( cargv[1], "w" );
1520 if ( logfile != NULL ) lutil_debug_file( logfile );
1523 /* start of a new database definition */
1524 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1528 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1529 "%s: line %d: Error in debug directive, "
1530 "\"debug <subsys> <level>\"\n", fname, lineno ));
1532 Debug( LDAP_DEBUG_ANY,
1533 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1539 level = atoi( cargv[2] );
1540 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1541 lutil_set_debug_level( cargv[1], level );
1542 /* specify an Object Identifier macro */
1543 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1544 rc = parse_oidm( fname, lineno, cargc, cargv );
1547 /* specify an objectclass */
1548 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1549 if ( *cargv[1] == '(' ) {
1551 p = strchr(saveline,'(');
1552 rc = parse_oc( fname, lineno, p, cargv );
1557 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1558 "%s: line %d: old objectclass format not supported\n",
1561 Debug( LDAP_DEBUG_ANY,
1562 "%s: line %d: old objectclass format not supported.\n",
1567 /* specify an attribute type */
1568 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1569 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1571 if ( *cargv[1] == '(' ) {
1573 p = strchr(saveline,'(');
1574 rc = parse_at( fname, lineno, p, cargv );
1579 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1580 "%s: line %d: old attribute type format not supported.\n",
1583 Debug( LDAP_DEBUG_ANY,
1584 "%s: line %d: old attribute type format not supported.\n",
1590 /* turn on/off schema checking */
1591 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1594 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1595 "%s: line %d: missing on|off in "
1596 "\"schemacheck <on|off>\" line.\n",
1599 Debug( LDAP_DEBUG_ANY,
1600 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1606 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1608 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1609 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1612 Debug( LDAP_DEBUG_ANY,
1613 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1616 global_schemacheck = 0;
1618 global_schemacheck = 1;
1621 /* specify access control info */
1622 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1623 parse_acl( be, fname, lineno, cargc, cargv );
1625 /* debug level to log things to syslog */
1626 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1629 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1630 "%s: line %d: missing level in \"loglevel <level>\""
1631 " line.\n", fname, lineno ));
1633 Debug( LDAP_DEBUG_ANY,
1634 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1643 for( i=1; i < cargc; i++ ) {
1644 ldap_syslog += atoi( cargv[1] );
1647 /* list of replicas of the data in this backend (master only) */
1648 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1651 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1652 "%s: line %d: missing host in \"replica "
1653 " <host[:port]\" line\n", fname, lineno ));
1655 Debug( LDAP_DEBUG_ANY,
1656 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1664 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1665 "%s: line %d: replica line must appear inside "
1666 "a database definition.\n", fname, lineno ));
1668 Debug( LDAP_DEBUG_ANY,
1669 "%s: line %d: replica line must appear inside a database definition\n",
1677 for ( i = 1; i < cargc; i++ ) {
1678 if ( strncasecmp( cargv[i], "host=", 5 )
1680 nr = add_replica_info( be,
1687 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1688 "%s: line %d: missing host in \"replica\" line\n",
1691 Debug( LDAP_DEBUG_ANY,
1692 "%s: line %d: missing host in \"replica\" line\n",
1697 } else if ( nr == -1 ) {
1699 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1700 "%s: line %d: unable to add"
1701 " replica \"%s\"\n",
1705 Debug( LDAP_DEBUG_ANY,
1706 "%s: line %d: unable to add replica \"%s\"\n",
1707 fname, lineno, cargv[i] + 5 );
1711 for ( i = 1; i < cargc; i++ ) {
1712 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1714 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1717 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1718 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1719 fname, lineno, cargv[i] + 7 ));
1721 Debug( LDAP_DEBUG_ANY,
1722 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1723 fname, lineno, cargv[i] + 7 );
1729 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1730 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1733 Debug( LDAP_DEBUG_ANY,
1734 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1740 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1742 char *arg = cargv[i] + 4;
1744 if ( arg[0] == '!' ) {
1749 if ( arg[0] != '=' ) {
1753 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1755 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1756 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1757 fname, lineno, arg + 1 ));
1759 Debug( LDAP_DEBUG_ANY,
1760 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1761 fname, lineno, arg + 1 );
1770 /* dn of master entity allowed to write to replica */
1771 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1774 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1775 "%s: line %d: missing dn in \"updatedn <dn>\""
1776 " line.\n", fname, lineno ));
1778 Debug( LDAP_DEBUG_ANY,
1779 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1787 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1788 "%s: line %d: updatedn line must appear inside "
1789 "a database definition\n",
1792 Debug( LDAP_DEBUG_ANY,
1793 "%s: line %d: updatedn line must appear inside a database definition\n",
1801 if ( load_ucdata( NULL ) < 0 ) return 1;
1803 dn.bv_val = cargv[1];
1804 dn.bv_len = strlen( cargv[1] );
1806 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1807 if( rc != LDAP_SUCCESS ) {
1809 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1810 "%s: line %d: updatedn DN is invalid.\n",
1813 Debug( LDAP_DEBUG_ANY,
1814 "%s: line %d: updatedn DN is invalid\n",
1821 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1824 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1825 "missing url in \"updateref <ldapurl>\" line.\n",
1828 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1829 "missing url in \"updateref <ldapurl>\" line\n",
1837 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1838 " line must appear inside a database definition\n",
1841 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1842 " line must appear inside a database definition\n",
1847 } else if ( !be->be_update_ndn.bv_len ) {
1849 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1850 "updateref line must come after updatedn.\n",
1853 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1854 "updateref line must after updatedn.\n",
1860 if( validate_global_referral( cargv[1] ) ) {
1862 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1863 "invalid URL (%s) in \"updateref\" line.\n",
1864 fname, lineno, cargv[1] ));
1866 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1867 "invalid URL (%s) in \"updateref\" line.\n",
1868 fname, lineno, cargv[1] );
1873 vals[0].bv_val = cargv[1];
1874 vals[0].bv_len = strlen( vals[0].bv_val );
1875 value_add( &be->be_update_refs, vals );
1877 /* replication log file to which changes are appended */
1878 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1881 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1882 "%s: line %d: missing filename in \"replogfile <filename>\""
1883 " line.\n", fname, lineno ));
1885 Debug( LDAP_DEBUG_ANY,
1886 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1893 be->be_replogfile = ch_strdup( cargv[1] );
1895 replogfile = ch_strdup( cargv[1] );
1898 /* file from which to read additional rootdse attrs */
1899 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1902 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1903 "missing filename in \"rootDSE <filename>\" line.\n",
1906 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1907 "missing filename in \"rootDSE <filename>\" line.\n",
1913 if( read_root_dse_file( cargv[1] ) ) {
1915 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1916 "could not read \"rootDSE <filename>\" line.\n",
1919 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1920 "could not read \"rootDSE <filename>\" line\n",
1926 /* maintain lastmodified{by,time} attributes */
1927 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1930 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1931 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1932 " line.\n", fname, lineno ));
1934 Debug( LDAP_DEBUG_ANY,
1935 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1941 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1943 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
1949 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
1956 /* turn on/off gentle SIGHUP handling */
1957 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
1959 Debug( LDAP_DEBUG_ANY,
1960 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
1964 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1965 global_gentlehup = 0;
1967 global_gentlehup = 1;
1971 /* set idle timeout value */
1972 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1976 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1977 "%s: line %d: missing timeout value in "
1978 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1980 Debug( LDAP_DEBUG_ANY,
1981 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1988 i = atoi( cargv[1] );
1992 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1993 "%s: line %d: timeout value (%d) invalid "
1994 "\"idletimeout <seconds>\" line.\n",
1995 fname, lineno, i ));
1997 Debug( LDAP_DEBUG_ANY,
1998 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2005 global_idletimeout = i;
2007 /* include another config file */
2008 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2011 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2012 "%s: line %d: missing filename in \"include "
2013 "<filename>\" line.\n", fname, lineno ));
2015 Debug( LDAP_DEBUG_ANY,
2016 "%s: line %d: missing filename in \"include <filename>\" line\n",
2022 savefname = ch_strdup( cargv[1] );
2023 savelineno = lineno;
2025 if ( read_config( savefname ) != 0 ) {
2030 lineno = savelineno - 1;
2032 /* location of kerberos srvtab file */
2033 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2036 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2037 "%s: line %d: missing filename in \"srvtab "
2038 "<filename>\" line.\n", fname, lineno ));
2040 Debug( LDAP_DEBUG_ANY,
2041 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2047 ldap_srvtab = ch_strdup( cargv[1] );
2049 #ifdef SLAPD_MODULES
2050 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2053 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2054 "%s: line %d: missing filename in \"moduleload "
2055 "<filename>\" line.\n", fname, lineno ));
2057 Debug( LDAP_DEBUG_ANY,
2058 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2062 exit( EXIT_FAILURE );
2064 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2066 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2067 "%s: line %d: failed to load or initialize module %s\n",
2068 fname, lineno, cargv[1] ));
2070 Debug( LDAP_DEBUG_ANY,
2071 "%s: line %d: failed to load or initialize module %s\n",
2072 fname, lineno, cargv[1]);
2075 exit( EXIT_FAILURE );
2077 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2080 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2081 "%s: line %d: missing path in \"modulepath <path>\""
2082 " line\n", fname, lineno ));
2084 Debug( LDAP_DEBUG_ANY,
2085 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2089 exit( EXIT_FAILURE );
2091 if (module_path( cargv[1] )) {
2093 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2094 "%s: line %d: failed to set module search path to %s.\n",
2095 fname, lineno, cargv[1] ));
2097 Debug( LDAP_DEBUG_ANY,
2098 "%s: line %d: failed to set module search path to %s\n",
2099 fname, lineno, cargv[1]);
2102 exit( EXIT_FAILURE );
2105 #endif /*SLAPD_MODULES*/
2108 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2109 rc = ldap_pvt_tls_set_option( NULL,
2110 LDAP_OPT_X_TLS_RANDOM_FILE,
2115 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2116 rc = ldap_pvt_tls_set_option( NULL,
2117 LDAP_OPT_X_TLS_CIPHER_SUITE,
2122 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2123 rc = ldap_pvt_tls_set_option( NULL,
2124 LDAP_OPT_X_TLS_CERTFILE,
2129 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2130 rc = ldap_pvt_tls_set_option( NULL,
2131 LDAP_OPT_X_TLS_KEYFILE,
2136 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2137 rc = ldap_pvt_tls_set_option( NULL,
2138 LDAP_OPT_X_TLS_CACERTDIR,
2143 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2144 rc = ldap_pvt_tls_set_option( NULL,
2145 LDAP_OPT_X_TLS_CACERTFILE,
2149 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2150 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2152 rc = ldap_pvt_tls_set_option( NULL,
2153 LDAP_OPT_X_TLS_REQUIRE_CERT,
2156 rc = ldap_int_tls_config( NULL,
2157 LDAP_OPT_X_TLS_REQUIRE_CERT,
2166 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2167 #ifdef SLAPD_RLOOKUPS
2170 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2171 "%s: line %d: reverse-lookup: "
2172 "missing \"on\" or \"off\"\n",
2175 Debug( LDAP_DEBUG_ANY,
2176 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2182 if ( !strcasecmp( cargv[1], "on" ) ) {
2183 use_reverse_lookup = 1;
2184 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2185 use_reverse_lookup = 0;
2188 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2189 "%s: line %d: reverse-lookup: "
2190 "must be \"on\" (default) "
2194 Debug( LDAP_DEBUG_ANY,
2195 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2201 #else /* !SLAPD_RLOOKUPS */
2203 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2204 "%s: line %d: reverse lookups "
2205 "are not configured (ignored).\n",
2208 Debug( LDAP_DEBUG_ANY,
2209 "%s: line %d: reverse lookups are not configured (ignored).\n",
2212 #endif /* !SLAPD_RLOOKUPS */
2214 /* pass anything else to the current backend info/db config routine */
2217 if ( bi->bi_config == 0 ) {
2219 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2220 "%s: line %d: unknown directive \"%s\" inside "
2221 "backend info definition (ignored).\n",
2222 fname, lineno, cargv[0] ));
2224 Debug( LDAP_DEBUG_ANY,
2225 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2226 fname, lineno, cargv[0] );
2230 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2236 } else if ( be != NULL ) {
2237 if ( be->be_config == 0 ) {
2239 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2240 "%s: line %d: uknown directive \"%s\" inside "
2241 "backend database definition (ignored).\n",
2242 fname, lineno, cargv[0] ));
2244 Debug( LDAP_DEBUG_ANY,
2245 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2246 fname, lineno, cargv[0] );
2250 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2258 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2259 "%s: line %d: unknown directive \"%s\" outside backend "
2260 "info and database definitions (ignored).\n",
2261 fname, lineno, cargv[0] ));
2263 Debug( LDAP_DEBUG_ANY,
2264 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2265 fname, lineno, cargv[0] );
2274 if ( load_ucdata( NULL ) < 0 ) return 1;
2286 char logbuf[sizeof("pseudorootpw ***")];
2289 token = strtok_quote( line, " \t" );
2293 (strcasecmp( token, "rootpw" ) == 0 ||
2294 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2295 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2296 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2297 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2298 sprintf( logline = logbuf, "%s ***", token );
2299 if ( strtok_quote_ptr )
2300 *strtok_quote_ptr = ' ';
2302 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2303 "line %d (%s)\n", lineno, logline ));
2305 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2307 if ( strtok_quote_ptr )
2308 *strtok_quote_ptr = '\0';
2310 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2311 if ( cargc == cargv_size - 1 ) {
2313 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2315 if ( tmp == NULL ) {
2317 LDAP_LOG(( "config", LDAP_LEVEL_ERR,
2318 "line %d: out of memory\n",
2321 Debug( LDAP_DEBUG_ANY,
2322 "line %d: out of memory\n",
2328 cargv_size += ARGS_STEP;
2330 cargv[cargc++] = token;
2332 cargv[cargc] = NULL;
2337 strtok_quote( char *line, char *sep )
2343 strtok_quote_ptr = NULL;
2344 if ( line != NULL ) {
2347 while ( *next && strchr( sep, *next ) ) {
2351 if ( *next == '\0' ) {
2357 for ( inquote = 0; *next; ) {
2365 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2371 next + 1, strlen( next + 1 ) + 1 );
2372 next++; /* dont parse the escaped character */
2377 if ( strchr( sep, *next ) != NULL ) {
2378 strtok_quote_ptr = next;
2391 static char buf[BUFSIZ];
2393 static int lmax, lcur;
2395 #define CATLINE( buf ) { \
2397 len = strlen( buf ); \
2398 while ( lcur + len + 1 > lmax ) { \
2400 line = (char *) ch_realloc( line, lmax ); \
2402 strcpy( line + lcur, buf ); \
2407 fp_getline( FILE *fp, int *lineno )
2415 /* hack attack - keeps us from having to keep a stack of bufs... */
2416 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2421 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2422 /* trim off \r\n or \n */
2423 if ( (p = strchr( buf, '\n' )) != NULL ) {
2424 if( p > buf && p[-1] == '\r' ) --p;
2428 /* trim off trailing \ and append the next line */
2429 if ( line[ 0 ] != '\0'
2430 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2431 && p[ -1 ] != '\\' ) {
2436 if ( ! isspace( (unsigned char) buf[0] ) ) {
2440 /* change leading whitespace to a space */
2449 return( line[0] ? line : NULL );
2453 fp_getline_init( int *lineno )
2459 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2461 load_ucdata( char *path )
2463 static int loaded = 0;
2469 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2472 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2473 "load_ucdata: Error %d loading ucdata.\n", err ));
2475 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2488 ucdata_unload( UCDATA_ALL );
2490 if ( slapd_args_file )
2491 free ( slapd_args_file );
2492 if ( slapd_pid_file )
2493 free ( slapd_pid_file );
2494 acl_destroy( global_acl, NULL );