1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2003 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>
26 * defaults for various global variables
28 struct slap_limits_set deflimit = {
29 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
32 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
34 -1, /* no limit on unchecked size */
36 0 /* hide number of entries left */
39 AccessControl *global_acl = NULL;
40 slap_access_t global_default_access = ACL_READ;
41 slap_mask_t global_restrictops = 0;
42 slap_mask_t global_allows = 0;
43 slap_mask_t global_disallows = 0;
44 slap_mask_t global_requires = 0;
45 slap_ssf_set_t global_ssf_set;
47 int global_gentlehup = 0;
48 int global_idletimeout = 0;
49 char *global_host = NULL;
50 char *global_realm = NULL;
51 char *ldap_srvtab = "";
52 char *default_passwd_hash = NULL;
53 int cargc = 0, cargv_size = 0;
55 struct berval default_search_base = { 0, NULL };
56 struct berval default_search_nbase = { 0, NULL };
57 unsigned num_subordinates = 0;
58 struct berval global_schemadn = { 0, NULL };
59 struct berval global_schemandn = { 0, NULL };
61 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
62 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
64 char *slapd_pid_file = NULL;
65 char *slapd_args_file = NULL;
67 char *strtok_quote_ptr;
69 int use_reverse_lookup = 0;
71 static char *fp_getline(FILE *fp, int *lineno);
72 static void fp_getline_init(int *lineno);
73 static int fp_parse_line(int lineno, char *line);
75 static char *strtok_quote(char *line, char *sep);
76 static int load_ucdata(char *path);
79 read_config( const char *fname, int depth )
82 char *line, *savefname, *saveline;
86 struct berval vals[2];
88 static int lastmod = 1;
89 static BackendInfo *bi = NULL;
90 static BackendDB *be = NULL;
92 vals[1].bv_val = NULL;
95 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
96 cargv_size = ARGS_STEP + 1;
99 if ( (fp = fopen( fname, "r" )) == NULL ) {
102 LDAP_LOG( CONFIG, ENTRY,
103 "read_config: " "could not open config file \"%s\": %s (%d)\n",
104 fname, strerror(errno), errno );
106 Debug( LDAP_DEBUG_ANY,
107 "could not open config file \"%s\": %s (%d)\n",
108 fname, strerror(errno), errno );
114 LDAP_LOG( CONFIG, ENTRY,
115 "read_config: reading config file %s\n", fname, 0, 0 );
117 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
121 fp_getline_init( &lineno );
123 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
124 /* skip comments and blank lines */
125 if ( line[0] == '#' || line[0] == '\0' ) {
129 /* fp_parse_line is destructive, we save a copy */
130 saveline = ch_strdup( line );
132 if ( fp_parse_line( lineno, line ) != 0 ) {
138 LDAP_LOG( CONFIG, INFO,
139 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
141 Debug( LDAP_DEBUG_ANY,
142 "%s: line %d: bad config line (ignored)\n",
149 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
152 LDAP_LOG( CONFIG, CRIT,
153 "%s : line %d: missing type in \"backend\" line.\n",
156 Debug( LDAP_DEBUG_ANY,
157 "%s: line %d: missing type in \"backend <type>\" line\n",
166 LDAP_LOG( CONFIG, CRIT,
167 "%s: line %d: backend line must appear before any "
168 "database definition.\n", fname, lineno , 0 );
170 Debug( LDAP_DEBUG_ANY,
171 "%s: line %d: backend line must appear before any database definition\n",
178 bi = backend_info( cargv[1] );
182 LDAP_LOG( CONFIG, CRIT,
183 "read_config: backend %s initialization failed.\n",
186 Debug( LDAP_DEBUG_ANY,
187 "backend %s initialization failed.\n",
193 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
196 LDAP_LOG( CONFIG, CRIT,
197 "%s: line %d: missing type in \"database <type>\" line\n",
200 Debug( LDAP_DEBUG_ANY,
201 "%s: line %d: missing type in \"database <type>\" line\n",
209 be = backend_db_init( cargv[1] );
213 LDAP_LOG( CONFIG, CRIT,
214 "database %s initialization failed.\n", cargv[1], 0, 0 );
216 Debug( LDAP_DEBUG_ANY,
217 "database %s initialization failed.\n",
224 /* set thread concurrency */
225 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
229 LDAP_LOG( CONFIG, CRIT,
230 "%s: line %d: missing level in \"concurrency <level\" "
231 " line\n", fname, lineno, 0 );
233 Debug( LDAP_DEBUG_ANY,
234 "%s: line %d: missing level in \"concurrency <level>\" line\n",
241 c = atoi( cargv[1] );
245 LDAP_LOG( CONFIG, CRIT,
246 "%s: line %d: invalid level (%d) in "
247 "\"concurrency <level>\" line.\n", fname, lineno, c );
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, CRIT,
265 "%s: line %d: missing max in \"sockbuf_max_incoming "
266 "<bytes>\" line\n", fname, lineno, 0 );
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, 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, CRIT,
302 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
303 "<bytes>\" line\n", fname, lineno, 0 );
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, 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, CRIT,
338 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
339 "line\n", fname, lineno, 0 );
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, 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, 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, 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, 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, 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, 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, CRIT,
464 "%s: line %d missing file name in \"pidfile <file>\" "
465 "line.\n", fname, lineno, 0 );
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, 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, 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, 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, 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, CRIT,
547 "%s: line %d: missing format in "
548 "\"password-crypt-salt-format <format>\" line\n",
551 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
552 "\"password-crypt-salt-format <format>\" line\n",
559 lutil_salt_format( cargv[1] );
561 /* SASL config options */
562 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
563 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
566 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
570 LDAP_LOG( CONFIG, CRIT,
571 "%s: line %d: missing dn in "
572 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
574 Debug( LDAP_DEBUG_ANY,
575 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
580 ber_str2bv( cargv[1], 0, 0, &dn );
582 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
585 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
588 if ( rc != LDAP_SUCCESS ) {
590 LDAP_LOG( CONFIG, CRIT,
591 "%s: line %d: schemadn DN is invalid.\n",
594 Debug( LDAP_DEBUG_ANY,
595 "%s: line %d: schemadn DN is invalid\n",
601 /* set UCDATA path */
602 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
606 LDAP_LOG( CONFIG, CRIT,
607 "%s: line %d: missing path in "
608 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
610 Debug( LDAP_DEBUG_ANY,
611 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
618 err = load_ucdata( cargv[1] );
622 LDAP_LOG( CONFIG, CRIT,
623 "%s: line %d: ucdata already loaded, ucdata-path "
624 "must be set earlier in the file and/or be "
625 "specified only once!\n", fname, lineno, 0 );
627 Debug( LDAP_DEBUG_ANY,
628 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
637 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
639 struct slap_limits_set *lim;
643 LDAP_LOG( CONFIG, CRIT,
644 "%s: line %d: missing limit in \"sizelimit <limit>\" "
645 "line.\n", fname, lineno, 0 );
647 Debug( LDAP_DEBUG_ANY,
648 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
658 lim = &be->be_def_limit;
661 for ( i = 1; i < cargc; i++ ) {
662 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
663 rc = parse_limit( cargv[i], lim );
666 LDAP_LOG( CONFIG, CRIT,
667 "%s: line %d: unable "
668 "to parse value \"%s\" in \"sizelimit "
669 "<limit>\" line.\n", fname, lineno, cargv[i] );
671 Debug( LDAP_DEBUG_ANY,
672 "%s: line %d: unable "
673 "to parse value \"%s\" "
676 fname, lineno, cargv[i] );
682 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
683 lim->lms_s_soft = -1;
687 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
688 if ( next == cargv[i] ) {
690 LDAP_LOG( CONFIG, CRIT,
691 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
692 "line.\n", fname, lineno, cargv[i] );
694 Debug( LDAP_DEBUG_ANY,
695 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
696 fname, lineno, cargv[i] );
700 } else if ( next[0] != '\0' ) {
702 LDAP_LOG( CONFIG, CRIT,
703 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
704 "line ignored.\n", fname, lineno, next );
706 Debug( LDAP_DEBUG_ANY,
707 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
708 fname, lineno, next );
717 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
719 struct slap_limits_set *lim;
723 LDAP_LOG( CONFIG, CRIT,
724 "%s: line %d missing limit in \"timelimit <limit>\" "
725 "line.\n", fname, lineno, 0 );
727 Debug( LDAP_DEBUG_ANY,
728 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
738 lim = &be->be_def_limit;
741 for ( i = 1; i < cargc; i++ ) {
742 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
743 rc = parse_limit( cargv[i], lim );
746 LDAP_LOG( CONFIG, CRIT,
747 "%s: line %d: unable to parse value \"%s\" "
748 "in \"timelimit <limit>\" line.\n",
749 fname, lineno, cargv[i] );
751 Debug( LDAP_DEBUG_ANY,
752 "%s: line %d: unable "
753 "to parse value \"%s\" "
756 fname, lineno, cargv[i] );
762 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
763 lim->lms_t_soft = -1;
767 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
768 if ( next == cargv[i] ) {
770 LDAP_LOG( CONFIG, CRIT,
771 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
772 "line.\n", fname, lineno, cargv[i] );
774 Debug( LDAP_DEBUG_ANY,
775 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
776 fname, lineno, cargv[i] );
780 } else if ( next[0] != '\0' ) {
782 LDAP_LOG( CONFIG, CRIT,
783 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
784 "line ignored.\n", fname, lineno, next );
786 Debug( LDAP_DEBUG_ANY,
787 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
788 fname, lineno, next );
796 /* set regex-based limits */
797 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
800 LDAP_LOG( CONFIG, WARNING,
801 "%s: line %d \"limits\" allowed only in database "
802 "environment.\n", fname, lineno, 0 );
804 Debug( LDAP_DEBUG_ANY,
805 "%s: line %d \"limits\" allowed only in database environment.\n%s",
811 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
815 /* mark this as a subordinate database */
816 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
819 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
820 "subordinate keyword must appear inside a database "
821 "definition.\n", fname, lineno, 0 );
823 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
824 "must appear inside a database definition.\n",
830 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
834 /* set database suffix */
835 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
837 struct berval dn, pdn, ndn;
841 LDAP_LOG( CONFIG, CRIT,
842 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
845 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
846 "missing dn in \"suffix <dn>\" line\n",
852 } else if ( cargc > 2 ) {
854 LDAP_LOG( CONFIG, INFO,
855 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
856 " line (ignored).\n", fname, lineno, cargv[1] );
858 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
859 "after <dn> in \"suffix %s\" line (ignored)\n",
860 fname, lineno, cargv[1] );
866 LDAP_LOG( CONFIG, INFO,
867 "%s: line %d: suffix line must appear inside a database "
868 "definition.\n", fname, lineno, 0 );
870 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
871 "must appear inside a database definition\n",
876 #if defined(SLAPD_MONITOR_DN)
877 /* "cn=Monitor" is reserved for monitoring slap */
878 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
880 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
881 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
884 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
885 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
889 #endif /* SLAPD_MONITOR_DN */
892 if ( load_ucdata( NULL ) < 0 ) return 1;
894 dn.bv_val = cargv[1];
895 dn.bv_len = strlen( cargv[1] );
897 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
898 if( rc != LDAP_SUCCESS ) {
900 LDAP_LOG( CONFIG, CRIT,
901 "%s: line %d: suffix DN is invalid.\n",
904 Debug( LDAP_DEBUG_ANY,
905 "%s: line %d: suffix DN is invalid\n",
911 tmp_be = select_backend( &ndn, 0, 0 );
912 if ( tmp_be == be ) {
914 LDAP_LOG( CONFIG, INFO,
915 "%s: line %d: suffix already served by this backend "
916 "(ignored)\n", fname, lineno, 0 );
918 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
919 "already served by this backend (ignored)\n",
925 } else if ( tmp_be != NULL ) {
927 LDAP_LOG( CONFIG, INFO,
928 "%s: line %d: suffix already served by a preceding "
929 "backend \"%s\"\n", fname, lineno,
930 tmp_be->be_suffix[0].bv_val );
932 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
933 "already served by a preceeding backend \"%s\"\n",
934 fname, lineno, tmp_be->be_suffix[0].bv_val );
940 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
942 LDAP_LOG( CONFIG, INFO,
943 "%s: line %d: suffix DN empty and default search "
944 "base provided \"%s\" (assuming okay).\n",
945 fname, lineno, default_search_base.bv_val );
947 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
948 "suffix DN empty and default "
949 "search base provided \"%s\" (assuming okay)\n",
950 fname, lineno, default_search_base.bv_val );
954 ber_bvarray_add( &be->be_suffix, &pdn );
955 ber_bvarray_add( &be->be_nsuffix, &ndn );
957 /* set max deref depth */
958 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
962 LDAP_LOG( CONFIG, CRIT,
963 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
964 " line\n", fname, lineno, 0 );
966 Debug( LDAP_DEBUG_ANY,
967 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
975 LDAP_LOG( CONFIG, INFO,
976 "%s: line %d: depth line must appear inside a database "
977 "definition.\n", fname, lineno ,0 );
979 Debug( LDAP_DEBUG_ANY,
980 "%s: line %d: depth line must appear inside a database definition.\n",
985 } else if ((i = atoi(cargv[1])) < 0) {
987 LDAP_LOG( CONFIG, INFO,
988 "%s: line %d: depth must be positive.\n",
991 Debug( LDAP_DEBUG_ANY,
992 "%s: line %d: depth must be positive.\n",
999 be->be_max_deref_depth = i;
1003 /* set magic "root" dn for this database */
1004 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1007 LDAP_LOG( CONFIG, INFO,
1008 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1011 Debug( LDAP_DEBUG_ANY,
1012 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1021 LDAP_LOG( CONFIG, INFO,
1022 "%s: line %d: rootdn line must appear inside a database "
1023 "definition.\n", fname, lineno ,0 );
1025 Debug( LDAP_DEBUG_ANY,
1026 "%s: line %d: rootdn line must appear inside a database definition.\n",
1034 if ( load_ucdata( NULL ) < 0 ) return 1;
1036 dn.bv_val = cargv[1];
1037 dn.bv_len = strlen( cargv[1] );
1039 rc = dnPrettyNormal( NULL, &dn,
1043 if( rc != LDAP_SUCCESS ) {
1045 LDAP_LOG( CONFIG, CRIT,
1046 "%s: line %d: rootdn DN is invalid.\n",
1049 Debug( LDAP_DEBUG_ANY,
1050 "%s: line %d: rootdn DN is invalid\n",
1057 /* set super-secret magic database password */
1058 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1061 LDAP_LOG( CONFIG, CRIT,
1062 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1063 " line\n", fname, lineno ,0 );
1065 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1066 "missing passwd in \"rootpw <passwd>\" line\n",
1075 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1076 "rootpw line must appear inside a database "
1077 "definition.\n", fname, lineno ,0 );
1079 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1080 "rootpw line must appear inside a database "
1087 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1089 if( tmp_be != be ) {
1091 LDAP_LOG( CONFIG, INFO,
1093 "rootpw can only be set when rootdn is under suffix\n",
1094 fname, lineno, "" );
1096 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1097 "rootpw can only be set when rootdn is under suffix\n",
1103 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1104 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1107 /* make this database read-only */
1108 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1111 LDAP_LOG( CONFIG, CRIT,
1112 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1113 "line.\n", fname, lineno ,0 );
1115 Debug( LDAP_DEBUG_ANY,
1116 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1123 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1124 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1126 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1129 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1130 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1132 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1137 /* allow these features */
1138 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1139 strcasecmp( cargv[0], "allow" ) == 0 )
1145 LDAP_LOG( CONFIG, INFO,
1146 "%s: line %d: allow line must appear prior to "
1147 "database definitions.\n", fname, lineno ,0 );
1149 Debug( LDAP_DEBUG_ANY,
1150 "%s: line %d: allow line must appear prior to database definitions\n",
1158 LDAP_LOG( CONFIG, CRIT,
1159 "%s: line %d: missing feature(s) in \"allow <features>\""
1160 " line\n", fname, lineno ,0 );
1162 Debug( LDAP_DEBUG_ANY,
1163 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1172 for( i=1; i < cargc; i++ ) {
1173 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1174 allows |= SLAP_ALLOW_BIND_V2;
1176 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1177 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1179 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1180 allows |= SLAP_ALLOW_BIND_ANON_DN;
1182 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1183 allows |= SLAP_ALLOW_UPDATE_ANON;
1185 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1187 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1188 "unknown feature %s in \"allow <features>\" line.\n",
1189 fname, lineno, cargv[1] );
1191 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1192 "unknown feature %s in \"allow <features>\" line\n",
1193 fname, lineno, cargv[i] );
1200 global_allows = allows;
1202 /* disallow these features */
1203 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1204 strcasecmp( cargv[0], "disallow" ) == 0 )
1206 slap_mask_t disallows;
1210 LDAP_LOG( CONFIG, INFO,
1211 "%s: line %d: disallow line must appear prior to "
1212 "database definitions.\n", fname, lineno ,0 );
1214 Debug( LDAP_DEBUG_ANY,
1215 "%s: line %d: disallow line must appear prior to database definitions\n",
1223 LDAP_LOG( CONFIG, CRIT,
1224 "%s: line %d: missing feature(s) in \"disallow <features>\""
1225 " line.\n", fname, lineno ,0 );
1227 Debug( LDAP_DEBUG_ANY,
1228 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1237 for( i=1; i < cargc; i++ ) {
1238 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1239 disallows |= SLAP_DISALLOW_BIND_ANON;
1241 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1242 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1244 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1245 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1247 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1248 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1250 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1251 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1253 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1255 LDAP_LOG( CONFIG, CRIT,
1256 "%s: line %d: unknown feature %s in "
1257 "\"disallow <features>\" line.\n",
1258 fname, lineno, cargv[i] );
1260 Debug( LDAP_DEBUG_ANY,
1261 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1262 fname, lineno, cargv[i] );
1269 global_disallows = disallows;
1271 /* require these features */
1272 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1273 strcasecmp( cargv[0], "require" ) == 0 )
1275 slap_mask_t requires;
1279 LDAP_LOG( CONFIG, CRIT,
1280 "%s: line %d: missing feature(s) in "
1281 "\"require <features>\" line.\n", fname, lineno ,0 );
1283 Debug( LDAP_DEBUG_ANY,
1284 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1293 for( i=1; i < cargc; i++ ) {
1294 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1295 requires |= SLAP_REQUIRE_BIND;
1297 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1298 requires |= SLAP_REQUIRE_LDAP_V3;
1300 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1301 requires |= SLAP_REQUIRE_AUTHC;
1303 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1304 requires |= SLAP_REQUIRE_SASL;
1306 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1307 requires |= SLAP_REQUIRE_STRONG;
1309 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1311 LDAP_LOG( CONFIG, CRIT,
1312 "%s: line %d: unknown feature %s in "
1313 "\"require <features>\" line.\n",
1314 fname, lineno , cargv[i] );
1316 Debug( LDAP_DEBUG_ANY,
1317 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1318 fname, lineno, cargv[i] );
1326 global_requires = requires;
1328 be->be_requires = requires;
1331 /* required security factors */
1332 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1333 slap_ssf_set_t *set;
1337 LDAP_LOG( CONFIG, CRIT,
1338 "%s: line %d: missing factor(s) in \"security <factors>\""
1339 " line.\n", fname, lineno ,0 );
1341 Debug( LDAP_DEBUG_ANY,
1342 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1350 set = &global_ssf_set;
1352 set = &be->be_ssf_set;
1355 for( i=1; i < cargc; i++ ) {
1356 if( strncasecmp( cargv[i], "ssf=",
1357 sizeof("ssf") ) == 0 )
1360 atoi( &cargv[i][sizeof("ssf")] );
1362 } else if( strncasecmp( cargv[i], "transport=",
1363 sizeof("transport") ) == 0 )
1365 set->sss_transport =
1366 atoi( &cargv[i][sizeof("transport")] );
1368 } else if( strncasecmp( cargv[i], "tls=",
1369 sizeof("tls") ) == 0 )
1372 atoi( &cargv[i][sizeof("tls")] );
1374 } else if( strncasecmp( cargv[i], "sasl=",
1375 sizeof("sasl") ) == 0 )
1378 atoi( &cargv[i][sizeof("sasl")] );
1380 } else if( strncasecmp( cargv[i], "update_ssf=",
1381 sizeof("update_ssf") ) == 0 )
1383 set->sss_update_ssf =
1384 atoi( &cargv[i][sizeof("update_ssf")] );
1386 } else if( strncasecmp( cargv[i], "update_transport=",
1387 sizeof("update_transport") ) == 0 )
1389 set->sss_update_transport =
1390 atoi( &cargv[i][sizeof("update_transport")] );
1392 } else if( strncasecmp( cargv[i], "update_tls=",
1393 sizeof("update_tls") ) == 0 )
1395 set->sss_update_tls =
1396 atoi( &cargv[i][sizeof("update_tls")] );
1398 } else if( strncasecmp( cargv[i], "update_sasl=",
1399 sizeof("update_sasl") ) == 0 )
1401 set->sss_update_sasl =
1402 atoi( &cargv[i][sizeof("update_sasl")] );
1404 } else if( strncasecmp( cargv[i], "simple_bind=",
1405 sizeof("simple_bind") ) == 0 )
1407 set->sss_simple_bind =
1408 atoi( &cargv[i][sizeof("simple_bind")] );
1412 LDAP_LOG( CONFIG, CRIT,
1413 "%s: line %d: unknown factor %S in "
1414 "\"security <factors>\" line.\n",
1415 fname, lineno, cargv[1] );
1417 Debug( LDAP_DEBUG_ANY,
1418 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1419 fname, lineno, cargv[i] );
1425 /* where to send clients when we don't hold it */
1426 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1429 LDAP_LOG( CONFIG, CRIT,
1430 "%s: line %d: missing URL in \"referral <URL>\""
1431 " line.\n", fname, lineno , 0 );
1433 Debug( LDAP_DEBUG_ANY,
1434 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1441 if( validate_global_referral( cargv[1] ) ) {
1443 LDAP_LOG( CONFIG, CRIT,
1444 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1445 fname, lineno, cargv[1] );
1447 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1448 "invalid URL (%s) in \"referral\" line.\n",
1449 fname, lineno, cargv[1] );
1454 vals[0].bv_val = cargv[1];
1455 vals[0].bv_len = strlen( vals[0].bv_val );
1456 if( value_add( &default_referral, vals ) )
1460 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1464 LDAP_LOG( CONFIG, CRIT,
1465 "%s: line %d: Error in logfile directive, "
1466 "\"logfile <filename>\"\n", fname, lineno , 0 );
1468 Debug( LDAP_DEBUG_ANY,
1469 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1475 logfile = fopen( cargv[1], "w" );
1476 if ( logfile != NULL ) lutil_debug_file( logfile );
1479 /* start of a new database definition */
1480 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1484 LDAP_LOG( CONFIG, CRIT,
1485 "%s: line %d: Error in debug directive, "
1486 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1488 Debug( LDAP_DEBUG_ANY,
1489 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1495 level = atoi( cargv[2] );
1496 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1497 lutil_set_debug_level( cargv[1], level );
1498 /* specify an Object Identifier macro */
1499 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1500 rc = parse_oidm( fname, lineno, cargc, cargv );
1503 /* specify an objectclass */
1504 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1505 if ( *cargv[1] == '(' /*')'*/) {
1507 p = strchr(saveline,'(' /*')'*/);
1508 rc = parse_oc( fname, lineno, p, cargv );
1513 LDAP_LOG( CONFIG, INFO,
1514 "%s: line %d: old objectclass format not supported\n",
1515 fname, lineno , 0 );
1517 Debug( LDAP_DEBUG_ANY,
1518 "%s: line %d: old objectclass format not supported.\n",
1523 #ifdef SLAP_EXTENDED_SCHEMA
1524 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1526 p = strchr(saveline,'(' /*')'*/);
1527 rc = parse_cr( fname, lineno, p, cargv );
1531 /* specify an attribute type */
1532 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1533 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1535 if ( *cargv[1] == '(' /*')'*/) {
1537 p = strchr(saveline,'(' /*')'*/);
1538 rc = parse_at( fname, lineno, p, cargv );
1543 LDAP_LOG( CONFIG, INFO,
1544 "%s: line %d: old attribute type format not supported.\n",
1545 fname, lineno , 0 );
1547 Debug( LDAP_DEBUG_ANY,
1548 "%s: line %d: old attribute type format not supported.\n",
1554 /* define attribute option(s) */
1555 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1556 ad_define_option( NULL, NULL, 0 );
1557 for ( i = 1; i < cargc; i++ )
1558 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1561 /* turn on/off schema checking */
1562 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1565 LDAP_LOG( CONFIG, CRIT,
1566 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1567 " line.\n", fname, lineno , 0 );
1569 Debug( LDAP_DEBUG_ANY,
1570 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1576 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1578 LDAP_LOG( CONFIG, CRIT,
1579 "%s: line %d: schema checking disabled! your mileage may "
1580 "vary!\n", fname, lineno , 0 );
1582 Debug( LDAP_DEBUG_ANY,
1583 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1586 global_schemacheck = 0;
1588 global_schemacheck = 1;
1591 /* specify access control info */
1592 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1593 parse_acl( be, fname, lineno, cargc, cargv );
1595 /* debug level to log things to syslog */
1596 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1599 LDAP_LOG( CONFIG, CRIT,
1600 "%s: line %d: missing level in \"loglevel <level>\""
1601 " line.\n", fname, lineno , 0 );
1603 Debug( LDAP_DEBUG_ANY,
1604 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1613 for( i=1; i < cargc; i++ ) {
1614 ldap_syslog += atoi( cargv[1] );
1617 /* list of replicas of the data in this backend (master only) */
1618 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1621 LDAP_LOG( CONFIG, CRIT,
1622 "%s: line %d: missing host in \"replica "
1623 " <host[:port]\" line\n", fname, lineno , 0 );
1625 Debug( LDAP_DEBUG_ANY,
1626 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1634 LDAP_LOG( CONFIG, INFO,
1635 "%s: line %d: replica line must appear inside "
1636 "a database definition.\n", fname, lineno, 0);
1638 Debug( LDAP_DEBUG_ANY,
1639 "%s: line %d: replica line must appear inside a database definition\n",
1647 for ( i = 1; i < cargc; i++ ) {
1648 if ( strncasecmp( cargv[i], "host=", 5 )
1650 nr = add_replica_info( be,
1657 LDAP_LOG( CONFIG, INFO,
1658 "%s: line %d: missing host in \"replica\" line\n",
1659 fname, lineno , 0 );
1661 Debug( LDAP_DEBUG_ANY,
1662 "%s: line %d: missing host in \"replica\" line\n",
1667 } else if ( nr == -1 ) {
1669 LDAP_LOG( CONFIG, INFO,
1670 "%s: line %d: unable to add"
1671 " replica \"%s\"\n",
1675 Debug( LDAP_DEBUG_ANY,
1676 "%s: line %d: unable to add replica \"%s\"\n",
1677 fname, lineno, cargv[i] + 5 );
1681 for ( i = 1; i < cargc; i++ ) {
1682 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1684 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1687 LDAP_LOG( CONFIG, INFO,
1688 "%s: line %d: suffix \"%s\" in \"replica\""
1689 " line is not valid for backend(ignored)\n",
1690 fname, lineno, cargv[i] + 7 );
1692 Debug( LDAP_DEBUG_ANY,
1693 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1694 fname, lineno, cargv[i] + 7 );
1700 LDAP_LOG( CONFIG, INFO,
1701 "%s: line %d: unable to normalize suffix"
1702 " in \"replica\" line (ignored)\n",
1703 fname, lineno , 0 );
1705 Debug( LDAP_DEBUG_ANY,
1706 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1712 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1714 char *arg = cargv[i] + 4;
1716 if ( arg[0] == '!' ) {
1721 if ( arg[0] != '=' ) {
1725 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1727 LDAP_LOG( CONFIG, INFO,
1728 "%s: line %d: attribute \"%s\" in "
1729 "\"replica\" line is unknown\n",
1730 fname, lineno, arg + 1 );
1732 Debug( LDAP_DEBUG_ANY,
1733 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1734 fname, lineno, arg + 1 );
1743 /* dn of master entity allowed to write to replica */
1744 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1747 LDAP_LOG( CONFIG, CRIT,
1748 "%s: line %d: missing dn in \"updatedn <dn>\""
1749 " line.\n", fname, lineno , 0 );
1751 Debug( LDAP_DEBUG_ANY,
1752 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1760 LDAP_LOG( CONFIG, INFO,
1761 "%s: line %d: updatedn line must appear inside "
1762 "a database definition\n",
1763 fname, lineno , 0 );
1765 Debug( LDAP_DEBUG_ANY,
1766 "%s: line %d: updatedn line must appear inside a database definition\n",
1774 if ( load_ucdata( NULL ) < 0 ) return 1;
1776 dn.bv_val = cargv[1];
1777 dn.bv_len = strlen( cargv[1] );
1779 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1780 if( rc != LDAP_SUCCESS ) {
1782 LDAP_LOG( CONFIG, CRIT,
1783 "%s: line %d: updatedn DN is invalid.\n",
1784 fname, lineno , 0 );
1786 Debug( LDAP_DEBUG_ANY,
1787 "%s: line %d: updatedn DN is invalid\n",
1794 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1797 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1798 "missing url in \"updateref <ldapurl>\" line.\n",
1799 fname, lineno , 0 );
1801 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1802 "missing url in \"updateref <ldapurl>\" line\n",
1810 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
1811 " line must appear inside a database definition\n",
1812 fname, lineno , 0 );
1814 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1815 " line must appear inside a database definition\n",
1820 } else if ( !be->be_update_ndn.bv_len ) {
1822 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1823 "updateref line must come after updatedn.\n",
1824 fname, lineno , 0 );
1826 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1827 "updateref line must after updatedn.\n",
1833 if( validate_global_referral( cargv[1] ) ) {
1835 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1836 "invalid URL (%s) in \"updateref\" line.\n",
1837 fname, lineno, cargv[1] );
1839 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1840 "invalid URL (%s) in \"updateref\" line.\n",
1841 fname, lineno, cargv[1] );
1846 vals[0].bv_val = cargv[1];
1847 vals[0].bv_len = strlen( vals[0].bv_val );
1848 if( value_add( &be->be_update_refs, vals ) )
1851 /* replication log file to which changes are appended */
1852 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1855 LDAP_LOG( CONFIG, CRIT,
1856 "%s: line %d: missing filename in \"replogfile <filename>\""
1857 " line.\n", fname, lineno , 0 );
1859 Debug( LDAP_DEBUG_ANY,
1860 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1867 be->be_replogfile = ch_strdup( cargv[1] );
1869 replogfile = ch_strdup( cargv[1] );
1872 /* file from which to read additional rootdse attrs */
1873 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1876 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1877 "missing filename in \"rootDSE <filename>\" line.\n",
1878 fname, lineno , 0 );
1880 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1881 "missing filename in \"rootDSE <filename>\" line.\n",
1887 if( read_root_dse_file( cargv[1] ) ) {
1889 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1890 "could not read \"rootDSE <filename>\" line.\n",
1891 fname, lineno , 0 );
1893 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1894 "could not read \"rootDSE <filename>\" line\n",
1900 /* maintain lastmodified{by,time} attributes */
1901 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1904 LDAP_LOG( CONFIG, CRIT,
1905 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1906 " line.\n", fname, lineno , 0 );
1908 Debug( LDAP_DEBUG_ANY,
1909 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1915 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1917 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
1923 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
1930 /* turn on/off gentle SIGHUP handling */
1931 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
1933 Debug( LDAP_DEBUG_ANY,
1934 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
1938 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1939 global_gentlehup = 0;
1941 global_gentlehup = 1;
1945 /* set idle timeout value */
1946 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1950 LDAP_LOG( CONFIG, CRIT,
1951 "%s: line %d: missing timeout value in "
1952 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
1954 Debug( LDAP_DEBUG_ANY,
1955 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1962 i = atoi( cargv[1] );
1966 LDAP_LOG( CONFIG, CRIT,
1967 "%s: line %d: timeout value (%d) invalid "
1968 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
1970 Debug( LDAP_DEBUG_ANY,
1971 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1978 global_idletimeout = i;
1980 /* include another config file */
1981 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1984 LDAP_LOG( CONFIG, CRIT,
1985 "%s: line %d: missing filename in \"include "
1986 "<filename>\" line.\n", fname, lineno , 0 );
1988 Debug( LDAP_DEBUG_ANY,
1989 "%s: line %d: missing filename in \"include <filename>\" line\n",
1995 savefname = ch_strdup( cargv[1] );
1996 savelineno = lineno;
1998 if ( read_config( savefname, depth+1 ) != 0 ) {
2003 lineno = savelineno - 1;
2005 /* location of kerberos srvtab file */
2006 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2009 LDAP_LOG( CONFIG, CRIT,
2010 "%s: line %d: missing filename in \"srvtab "
2011 "<filename>\" line.\n", fname, lineno , 0 );
2013 Debug( LDAP_DEBUG_ANY,
2014 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2020 ldap_srvtab = ch_strdup( cargv[1] );
2022 #ifdef SLAPD_MODULES
2023 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2026 LDAP_LOG( CONFIG, INFO,
2027 "%s: line %d: missing filename in \"moduleload "
2028 "<filename>\" line.\n", fname, lineno , 0 );
2030 Debug( LDAP_DEBUG_ANY,
2031 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2035 exit( EXIT_FAILURE );
2037 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2039 LDAP_LOG( CONFIG, CRIT,
2040 "%s: line %d: failed to load or initialize module %s\n",
2041 fname, lineno, cargv[1] );
2043 Debug( LDAP_DEBUG_ANY,
2044 "%s: line %d: failed to load or initialize module %s\n",
2045 fname, lineno, cargv[1]);
2048 exit( EXIT_FAILURE );
2050 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2053 LDAP_LOG( CONFIG, INFO,
2054 "%s: line %d: missing path in \"modulepath <path>\""
2055 " line\n", fname, lineno , 0 );
2057 Debug( LDAP_DEBUG_ANY,
2058 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2062 exit( EXIT_FAILURE );
2064 if (module_path( cargv[1] )) {
2066 LDAP_LOG( CONFIG, CRIT,
2067 "%s: line %d: failed to set module search path to %s.\n",
2068 fname, lineno, cargv[1] );
2070 Debug( LDAP_DEBUG_ANY,
2071 "%s: line %d: failed to set module search path to %s\n",
2072 fname, lineno, cargv[1]);
2075 exit( EXIT_FAILURE );
2078 #endif /*SLAPD_MODULES*/
2081 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2082 rc = ldap_pvt_tls_set_option( NULL,
2083 LDAP_OPT_X_TLS_RANDOM_FILE,
2088 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2089 rc = ldap_pvt_tls_set_option( NULL,
2090 LDAP_OPT_X_TLS_CIPHER_SUITE,
2095 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2096 rc = ldap_pvt_tls_set_option( NULL,
2097 LDAP_OPT_X_TLS_CERTFILE,
2102 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2103 rc = ldap_pvt_tls_set_option( NULL,
2104 LDAP_OPT_X_TLS_KEYFILE,
2109 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2110 rc = ldap_pvt_tls_set_option( NULL,
2111 LDAP_OPT_X_TLS_CACERTDIR,
2116 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2117 rc = ldap_pvt_tls_set_option( NULL,
2118 LDAP_OPT_X_TLS_CACERTFILE,
2122 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2123 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2125 rc = ldap_pvt_tls_set_option( NULL,
2126 LDAP_OPT_X_TLS_REQUIRE_CERT,
2129 rc = ldap_int_tls_config( NULL,
2130 LDAP_OPT_X_TLS_REQUIRE_CERT,
2139 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2140 #ifdef SLAPD_RLOOKUPS
2143 LDAP_LOG( CONFIG, INFO,
2144 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2145 fname, lineno , 0 );
2147 Debug( LDAP_DEBUG_ANY,
2148 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2154 if ( !strcasecmp( cargv[1], "on" ) ) {
2155 use_reverse_lookup = 1;
2156 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2157 use_reverse_lookup = 0;
2160 LDAP_LOG( CONFIG, INFO,
2161 "%s: line %d: reverse-lookup: "
2162 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2164 Debug( LDAP_DEBUG_ANY,
2165 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2171 #else /* !SLAPD_RLOOKUPS */
2173 LDAP_LOG( CONFIG, INFO,
2174 "%s: line %d: reverse lookups "
2175 "are not configured (ignored).\n", fname, lineno , 0 );
2177 Debug( LDAP_DEBUG_ANY,
2178 "%s: line %d: reverse lookups are not configured (ignored).\n",
2181 #endif /* !SLAPD_RLOOKUPS */
2183 /* Netscape plugins */
2184 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2185 #if defined( LDAP_SLAPI )
2187 #ifdef notdef /* allow global plugins, too */
2189 * a "plugin" line must be inside a database
2190 * definition, since we implement pre-,post-
2191 * and extended operation plugins
2195 LDAP_LOG( CONFIG, INFO,
2196 "%s: line %d: plugin line must appear "
2197 "inside a database definition.\n",
2200 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2201 "line must appear inside a database "
2202 "definition\n", fname, lineno, 0 );
2208 if ( netscape_plugin( be, fname, lineno, cargc, cargv )
2213 #else /* !defined( LDAP_SLAPI ) */
2215 LDAP_LOG( CONFIG, INFO,
2216 "%s: line %d: SLAPI not supported.\n",
2219 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2220 "not supported.\n", fname, lineno, 0 );
2224 #endif /* !defined( LDAP_SLAPI ) */
2226 /* Netscape plugins */
2227 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2228 #if defined( LDAP_SLAPI )
2231 LDAP_LOG( CONFIG, INFO,
2232 "%s: line %d: missing file name "
2233 "in pluginlog <filename> line.\n",
2236 Debug( LDAP_DEBUG_ANY,
2237 "%s: line %d: missing file name "
2238 "in pluginlog <filename> line.\n",
2244 if ( slapi_log_file != NULL ) {
2245 ch_free( slapi_log_file );
2248 slapi_log_file = ch_strdup( cargv[1] );
2249 #endif /* !defined( LDAP_SLAPI ) */
2251 /* pass anything else to the current backend info/db config routine */
2254 if ( bi->bi_config == 0 ) {
2256 LDAP_LOG( CONFIG, INFO,
2257 "%s: line %d: unknown directive \"%s\" inside "
2258 "backend info definition (ignored).\n",
2259 fname, lineno, cargv[0] );
2261 Debug( LDAP_DEBUG_ANY,
2262 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2263 fname, lineno, cargv[0] );
2267 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2273 } else if ( be != NULL ) {
2274 if ( be->be_config == 0 ) {
2276 LDAP_LOG( CONFIG, INFO,
2277 "%s: line %d: uknown directive \"%s\" inside "
2278 "backend database definition (ignored).\n",
2279 fname, lineno, cargv[0] );
2281 Debug( LDAP_DEBUG_ANY,
2282 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2283 fname, lineno, cargv[0] );
2287 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2295 LDAP_LOG( CONFIG, INFO,
2296 "%s: line %d: unknown directive \"%s\" outside backend "
2297 "info and database definitions (ignored).\n",
2298 fname, lineno, cargv[0] );
2300 Debug( LDAP_DEBUG_ANY,
2301 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2302 fname, lineno, cargv[0] );
2311 if ( depth == 0 ) ch_free( cargv );
2313 if ( !global_schemadn.bv_val ) {
2314 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2316 dnNormalize2( NULL, &global_schemadn, &global_schemandn );
2319 if ( load_ucdata( NULL ) < 0 ) return 1;
2331 char logbuf[sizeof("pseudorootpw ***")];
2334 token = strtok_quote( line, " \t" );
2338 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2339 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2340 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2341 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2342 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2344 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2347 if ( strtok_quote_ptr ) {
2348 *strtok_quote_ptr = ' ';
2352 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2354 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2357 if ( strtok_quote_ptr ) {
2358 *strtok_quote_ptr = '\0';
2361 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2362 if ( cargc == cargv_size - 1 ) {
2364 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2366 if ( tmp == NULL ) {
2368 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2370 Debug( LDAP_DEBUG_ANY,
2371 "line %d: out of memory\n",
2377 cargv_size += ARGS_STEP;
2379 cargv[cargc++] = token;
2381 cargv[cargc] = NULL;
2386 strtok_quote( char *line, char *sep )
2392 strtok_quote_ptr = NULL;
2393 if ( line != NULL ) {
2396 while ( *next && strchr( sep, *next ) ) {
2400 if ( *next == '\0' ) {
2406 for ( inquote = 0; *next; ) {
2414 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2420 next + 1, strlen( next + 1 ) + 1 );
2421 next++; /* dont parse the escaped character */
2426 if ( strchr( sep, *next ) != NULL ) {
2427 strtok_quote_ptr = next;
2440 static char buf[BUFSIZ];
2442 static size_t lmax, lcur;
2444 #define CATLINE( buf ) \
2446 size_t len = strlen( buf ); \
2447 while ( lcur + len + 1 > lmax ) { \
2449 line = (char *) ch_realloc( line, lmax ); \
2451 strcpy( line + lcur, buf ); \
2456 fp_getline( FILE *fp, int *lineno )
2464 /* hack attack - keeps us from having to keep a stack of bufs... */
2465 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2470 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2471 /* trim off \r\n or \n */
2472 if ( (p = strchr( buf, '\n' )) != NULL ) {
2473 if( p > buf && p[-1] == '\r' ) --p;
2477 /* trim off trailing \ and append the next line */
2478 if ( line[ 0 ] != '\0'
2479 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2480 && p[ -1 ] != '\\' ) {
2485 if ( ! isspace( (unsigned char) buf[0] ) ) {
2489 /* change leading whitespace to a space */
2498 return( line[0] ? line : NULL );
2502 fp_getline_init( int *lineno )
2508 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2510 load_ucdata( char *path )
2512 static int loaded = 0;
2518 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2521 LDAP_LOG( CONFIG, CRIT,
2522 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2524 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2537 ucdata_unload( UCDATA_ALL );
2538 free( global_schemandn.bv_val );
2539 free( global_schemadn.bv_val );
2541 if ( slapd_args_file )
2542 free ( slapd_args_file );
2543 if ( slapd_pid_file )
2544 free ( slapd_pid_file );
2545 acl_destroy( global_acl, NULL );