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, int depth )
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;
94 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
95 cargv_size = ARGS_STEP + 1;
98 if ( (fp = fopen( fname, "r" )) == NULL ) {
101 LDAP_LOG( CONFIG, ENTRY,
102 "read_config: " "could not open config file \"%s\": %s (%d)\n",
103 fname, strerror(errno), errno );
105 Debug( LDAP_DEBUG_ANY,
106 "could not open config file \"%s\": %s (%d)\n",
107 fname, strerror(errno), errno );
113 LDAP_LOG( CONFIG, ENTRY,
114 "read_config: reading config file %s\n", fname, 0, 0 );
116 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
120 fp_getline_init( &lineno );
122 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
123 /* skip comments and blank lines */
124 if ( line[0] == '#' || line[0] == '\0' ) {
128 /* fp_parse_line is destructive, we save a copy */
129 saveline = ch_strdup( line );
131 if ( fp_parse_line( lineno, line ) != 0 ) {
137 LDAP_LOG( CONFIG, INFO,
138 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
140 Debug( LDAP_DEBUG_ANY,
141 "%s: line %d: bad config line (ignored)\n",
148 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
151 LDAP_LOG( CONFIG, CRIT,
152 "%s : line %d: missing type in \"backend\" line.\n",
155 Debug( LDAP_DEBUG_ANY,
156 "%s: line %d: missing type in \"backend <type>\" line\n",
165 LDAP_LOG( CONFIG, CRIT,
166 "%s: line %d: backend line must appear before any "
167 "database definition.\n", fname, lineno , 0 );
169 Debug( LDAP_DEBUG_ANY,
170 "%s: line %d: backend line must appear before any database definition\n",
177 bi = backend_info( cargv[1] );
181 LDAP_LOG( CONFIG, CRIT,
182 "read_config: backend %s initialization failed.\n",
185 Debug( LDAP_DEBUG_ANY,
186 "backend %s initialization failed.\n",
192 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
195 LDAP_LOG( CONFIG, CRIT,
196 "%s: line %d: missing type in \"database <type>\" line\n",
199 Debug( LDAP_DEBUG_ANY,
200 "%s: line %d: missing type in \"database <type>\" line\n",
208 be = backend_db_init( cargv[1] );
212 LDAP_LOG( CONFIG, CRIT,
213 "database %s initialization failed.\n", cargv[1], 0, 0 );
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, CRIT,
229 "%s: line %d: missing level in \"concurrency <level\" "
230 " line\n", fname, lineno, 0 );
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, CRIT,
245 "%s: line %d: invalid level (%d) in "
246 "\"concurrency <level>\" line.\n", fname, lineno, c );
248 Debug( LDAP_DEBUG_ANY,
249 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
256 ldap_pvt_thread_set_concurrency( c );
258 /* set sockbuf max */
259 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
263 LDAP_LOG( CONFIG, CRIT,
264 "%s: line %d: missing max in \"sockbuf_max_incoming "
265 "<bytes>\" line\n", fname, lineno, 0 );
267 Debug( LDAP_DEBUG_ANY,
268 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
275 max = atol( cargv[1] );
279 LDAP_LOG( CONFIG, CRIT,
280 "%s: line %d: invalid max value (%ld) in "
281 "\"sockbuf_max_incoming <bytes>\" line.\n",
282 fname, lineno, max );
284 Debug( LDAP_DEBUG_ANY,
285 "%s: line %d: invalid max value (%ld) in "
286 "\"sockbuf_max_incoming <bytes>\" line.\n",
287 fname, lineno, max );
293 sockbuf_max_incoming = max;
295 /* set sockbuf max authenticated */
296 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
300 LDAP_LOG( CONFIG, CRIT,
301 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
302 "<bytes>\" line\n", fname, lineno, 0 );
304 Debug( LDAP_DEBUG_ANY,
305 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
312 max = atol( cargv[1] );
316 LDAP_LOG( CONFIG, CRIT,
317 "%s: line %d: invalid max value (%ld) in "
318 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
319 fname, lineno, max );
321 Debug( LDAP_DEBUG_ANY,
322 "%s: line %d: invalid max value (%ld) in "
323 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
324 fname, lineno, max );
330 sockbuf_max_incoming_auth = max;
332 /* default search base */
333 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
336 LDAP_LOG( CONFIG, CRIT,
337 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
338 "line\n", fname, lineno, 0 );
340 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
341 "missing dn in \"defaultSearchBase <dn>\" line\n",
347 } else if ( cargc > 2 ) {
349 LDAP_LOG( CONFIG, INFO,
350 "%s: line %d: extra cruft after <dn> in "
351 "\"defaultSearchBase %s\" line (ignored)\n",
352 fname, lineno, cargv[1] );
354 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
355 "extra cruft after <dn> in \"defaultSearchBase %s\", "
357 fname, lineno, cargv[1] );
361 if ( bi != NULL || be != NULL ) {
363 LDAP_LOG( CONFIG, CRIT,
364 "%s: line %d: defaultSearchBase line must appear "
365 "prior to any backend or database definitions\n",
368 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
369 "defaultSearchBaase line must appear prior to "
370 "any backend or database definition\n",
377 if ( default_search_nbase.bv_len ) {
379 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
380 "default search base \"%s\" already defined "
381 "(discarding old)\n", fname, lineno,
382 default_search_base.bv_val );
384 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
385 "default search base \"%s\" already defined "
386 "(discarding old)\n",
387 fname, lineno, default_search_base.bv_val );
390 free( default_search_base.bv_val );
391 free( default_search_nbase.bv_val );
394 if ( load_ucdata( NULL ) < 0 ) return 1;
399 dn.bv_val = cargv[1];
400 dn.bv_len = strlen( dn.bv_val );
402 rc = dnPrettyNormal( NULL, &dn,
403 &default_search_base,
404 &default_search_nbase );
406 if( rc != LDAP_SUCCESS ) {
408 LDAP_LOG( CONFIG, CRIT,
409 "%s: line %d: defaultSearchBase DN is invalid.\n",
412 Debug( LDAP_DEBUG_ANY,
413 "%s: line %d: defaultSearchBase DN is invalid\n",
420 /* set maximum threads in thread pool */
421 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
425 LDAP_LOG( CONFIG, CRIT,
426 "%s: line %d: missing count in \"threads <count>\" line\n",
429 Debug( LDAP_DEBUG_ANY,
430 "%s: line %d: missing count in \"threads <count>\" line\n",
437 c = atoi( cargv[1] );
441 LDAP_LOG( CONFIG, CRIT,
442 "%s: line %d: invalid level (%d) in \"threads <count>\""
443 "line\n", fname, lineno, c );
445 Debug( LDAP_DEBUG_ANY,
446 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
453 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
455 /* save for later use */
456 connection_pool_max = c;
458 /* get pid file name */
459 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
462 LDAP_LOG( CONFIG, CRIT,
463 "%s: line %d missing file name in \"pidfile <file>\" "
464 "line.\n", fname, lineno, 0 );
466 Debug( LDAP_DEBUG_ANY,
467 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
474 slapd_pid_file = ch_strdup( cargv[1] );
476 /* get args file name */
477 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
480 LDAP_LOG( CONFIG, CRIT,
481 "%s: %d: missing file name in "
482 "\"argsfile <file>\" line.\n",
485 Debug( LDAP_DEBUG_ANY,
486 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
493 slapd_args_file = ch_strdup( cargv[1] );
495 /* default password hash */
496 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
499 LDAP_LOG( CONFIG, CRIT,
500 "%s: line %d: missing hash in "
501 "\"password-hash <hash>\" line.\n",
504 Debug( LDAP_DEBUG_ANY,
505 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
511 if ( default_passwd_hash != NULL ) {
513 LDAP_LOG( CONFIG, CRIT,
514 "%s: line %d: already set default password_hash!\n",
517 Debug( LDAP_DEBUG_ANY,
518 "%s: line %d: already set default password_hash!\n",
526 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
528 LDAP_LOG( CONFIG, CRIT,
529 "%s: line %d: password scheme \"%s\" not available\n",
530 fname, lineno, cargv[1] );
532 Debug( LDAP_DEBUG_ANY,
533 "%s: line %d: password scheme \"%s\" not available\n",
534 fname, lineno, cargv[1] );
539 default_passwd_hash = ch_strdup( cargv[1] );
541 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
545 LDAP_LOG( CONFIG, CRIT,
546 "%s: line %d: missing format in "
547 "\"password-crypt-salt-format <format>\" line\n",
550 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
551 "\"password-crypt-salt-format <format>\" line\n",
558 lutil_salt_format( cargv[1] );
560 #ifdef HAVE_CYRUS_SASL
561 /* SASL config options */
562 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
563 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
565 #endif /* HAVE_CYRUS_SASL */
567 /* set UCDATA path */
568 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
572 LDAP_LOG( CONFIG, CRIT,
573 "%s: line %d: missing path in "
574 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
576 Debug( LDAP_DEBUG_ANY,
577 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
584 err = load_ucdata( cargv[1] );
588 LDAP_LOG( CONFIG, CRIT,
589 "%s: line %d: ucdata already loaded, ucdata-path "
590 "must be set earlier in the file and/or be "
591 "specified only once!\n", fname, lineno, 0 );
593 Debug( LDAP_DEBUG_ANY,
594 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
603 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
605 struct slap_limits_set *lim;
609 LDAP_LOG( CONFIG, CRIT,
610 "%s: line %d: missing limit in \"sizelimit <limit>\" "
611 "line.\n", fname, lineno, 0 );
613 Debug( LDAP_DEBUG_ANY,
614 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
624 lim = &be->be_def_limit;
627 for ( i = 1; i < cargc; i++ ) {
628 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
629 rc = parse_limit( cargv[i], lim );
631 lim->lms_s_soft = atoi( cargv[i] );
637 LDAP_LOG( CONFIG, CRIT,
638 "%s: line %d: unable "
639 "to parse value \"%s\" in \"sizelimit "
640 "<limit>\" line.\n", fname, lineno, cargv[i] );
642 Debug( LDAP_DEBUG_ANY,
643 "%s: line %d: unable "
644 "to parse value \"%s\" "
647 fname, lineno, cargv[i] );
653 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
655 struct slap_limits_set *lim;
659 LDAP_LOG( CONFIG, CRIT,
660 "%s: line %d missing limit in \"timelimit <limit>\" "
661 "line.\n", fname, lineno, 0 );
663 Debug( LDAP_DEBUG_ANY,
664 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
674 lim = &be->be_def_limit;
677 for ( i = 1; i < cargc; i++ ) {
678 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
679 rc = parse_limit( cargv[i], lim );
681 lim->lms_t_soft = atoi( cargv[i] );
687 LDAP_LOG( CONFIG, CRIT,
688 "%s: line %d: unable to parse value \"%s\" "
689 "in \"timelimit <limit>\" line.\n",
690 fname, lineno, cargv[i] );
692 Debug( LDAP_DEBUG_ANY,
693 "%s: line %d: unable "
694 "to parse value \"%s\" "
697 fname, lineno, cargv[i] );
702 /* set regex-based limits */
703 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
706 LDAP_LOG( CONFIG, WARNING,
707 "%s: line %d \"limits\" allowed only in database "
708 "environment.\n", fname, lineno, 0 );
710 Debug( LDAP_DEBUG_ANY,
711 "%s: line %d \"limits\" allowed only in database environment.\n%s",
717 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
721 /* mark this as a subordinate database */
722 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
725 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
726 "subordinate keyword must appear inside a database "
727 "definition.\n", fname, lineno, 0 );
729 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
730 "must appear inside a database definition.\n",
736 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
740 /* set database suffix */
741 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
743 struct berval dn, pdn, ndn;
747 LDAP_LOG( CONFIG, CRIT,
748 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
751 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
752 "missing dn in \"suffix <dn>\" line\n",
758 } else if ( cargc > 2 ) {
760 LDAP_LOG( CONFIG, INFO,
761 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
762 " line (ignored).\n", fname, lineno, cargv[1] );
764 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
765 "after <dn> in \"suffix %s\" line (ignored)\n",
766 fname, lineno, cargv[1] );
772 LDAP_LOG( CONFIG, INFO,
773 "%s: line %d: suffix line must appear inside a database "
774 "definition.\n", fname, lineno, 0 );
776 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
777 "must appear inside a database definition\n",
782 #if defined(SLAPD_MONITOR_DN)
783 /* "cn=Monitor" is reserved for monitoring slap */
784 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
786 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
787 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
790 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
791 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
795 #endif /* SLAPD_MONITOR_DN */
798 if ( load_ucdata( NULL ) < 0 ) return 1;
800 dn.bv_val = cargv[1];
801 dn.bv_len = strlen( cargv[1] );
803 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
804 if( rc != LDAP_SUCCESS ) {
806 LDAP_LOG( CONFIG, CRIT,
807 "%s: line %d: suffix DN is invalid.\n",
810 Debug( LDAP_DEBUG_ANY,
811 "%s: line %d: suffix DN is invalid\n",
817 tmp_be = select_backend( &ndn, 0, 0 );
818 if ( tmp_be == be ) {
820 LDAP_LOG( CONFIG, INFO,
821 "%s: line %d: suffix already served by this backend "
822 "(ignored)\n", fname, lineno, 0 );
824 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
825 "already served by this backend (ignored)\n",
831 } else if ( tmp_be != NULL ) {
833 LDAP_LOG( CONFIG, INFO,
834 "%s: line %d: suffix already served by a preceding "
835 "backend \"%s\"\n", fname, lineno,
836 tmp_be->be_suffix[0].bv_val );
838 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
839 "already served by a preceeding backend \"%s\"\n",
840 fname, lineno, tmp_be->be_suffix[0].bv_val );
846 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
848 LDAP_LOG( CONFIG, INFO,
849 "%s: line %d: suffix DN empty and default search "
850 "base provided \"%s\" (assuming okay).\n",
851 fname, lineno, default_search_base.bv_val );
853 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
854 "suffix DN empty and default "
855 "search base provided \"%s\" (assuming okay)\n",
856 fname, lineno, default_search_base.bv_val );
860 ber_bvarray_add( &be->be_suffix, &pdn );
861 ber_bvarray_add( &be->be_nsuffix, &ndn );
863 /* set database suffixAlias */
864 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
866 struct berval alias, palias, nalias;
867 struct berval aliased, paliased, naliased;
871 LDAP_LOG( CONFIG, CRIT,
872 "%s: line %d: missing alias and aliased_dn in "
873 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
876 Debug( LDAP_DEBUG_ANY,
877 "%s: line %d: missing alias and aliased_dn in "
878 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
883 } else if ( cargc < 3 ) {
885 LDAP_LOG( CONFIG, CRIT,
886 "%s: line %d: missing aliased_dn in "
887 "\"suffixAlias <alias> <aliased_dn>\" line\n",
890 Debug( LDAP_DEBUG_ANY,
891 "%s: line %d: missing aliased_dn in "
892 "\"suffixAlias <alias> <aliased_dn>\" line\n",
897 } else if ( cargc > 3 ) {
899 LDAP_LOG( CONFIG, CRIT,
900 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
903 Debug( LDAP_DEBUG_ANY,
904 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
911 LDAP_LOG( CONFIG, INFO,
912 "%s: line %d: suffix line must appear inside a database "
913 "definition.\n", fname, lineno, 0 );
915 Debug( LDAP_DEBUG_ANY,
916 "%s: line %d: suffixAlias line"
917 " must appear inside a database definition.\n",
923 if ( load_ucdata( NULL ) < 0 ) return 1;
925 alias.bv_val = cargv[1];
926 alias.bv_len = strlen( cargv[1] );
928 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
929 if( rc != LDAP_SUCCESS ) {
931 LDAP_LOG( CONFIG, CRIT,
932 "%s: line %d: alias DN is invalid.\n", fname, lineno, 0 );
934 Debug( LDAP_DEBUG_ANY,
935 "%s: line %d: alias DN is invalid\n",
941 tmp_be = select_backend( &nalias, 0, 0 );
942 free( nalias.bv_val );
943 if ( tmp_be && tmp_be != be ) {
945 LDAP_LOG( CONFIG, INFO,
946 "%s: line %d: suffixAlias served by a preceeding "
947 "backend \"%s\"\n", fname, lineno,
948 tmp_be->be_suffix[0].bv_val );
950 Debug( LDAP_DEBUG_ANY,
951 "%s: line %d: suffixAlias served by"
952 " a preceeding backend \"%s\"\n",
953 fname, lineno, tmp_be->be_suffix[0].bv_val );
955 free( palias.bv_val );
959 aliased.bv_val = cargv[2];
960 aliased.bv_len = strlen( cargv[2] );
962 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
963 if( rc != LDAP_SUCCESS ) {
965 LDAP_LOG( CONFIG, CRIT,
966 "%s: line %d: aliased DN is invalid.\n", fname, lineno,0 );
968 Debug( LDAP_DEBUG_ANY,
969 "%s: line %d: aliased DN is invalid\n",
972 free( palias.bv_val );
976 tmp_be = select_backend( &naliased, 0, 0 );
977 free( naliased.bv_val );
978 if ( tmp_be && tmp_be != be ) {
980 LDAP_LOG( CONFIG, INFO,
981 "%s: line %d: suffixAlias derefs to a different backend "
982 "a preceeding backend \"%s\"\n",
983 fname, lineno, tmp_be->be_suffix[0].bv_val );
985 Debug( LDAP_DEBUG_ANY,
986 "%s: line %d: suffixAlias derefs to differnet backend"
987 " a preceeding backend \"%s\"\n",
988 fname, lineno, tmp_be->be_suffix[0].bv_val );
990 free( palias.bv_val );
991 free( paliased.bv_val );
995 ber_bvarray_add( &be->be_suffixAlias, &palias );
996 ber_bvarray_add( &be->be_suffixAlias, &paliased );
998 /* set max deref depth */
999 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1003 LDAP_LOG( CONFIG, CRIT,
1004 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1005 " line\n", fname, lineno, 0 );
1007 Debug( LDAP_DEBUG_ANY,
1008 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1016 LDAP_LOG( CONFIG, INFO,
1017 "%s: line %d: depth line must appear inside a database "
1018 "definition.\n", fname, lineno ,0 );
1020 Debug( LDAP_DEBUG_ANY,
1021 "%s: line %d: depth line must appear inside a database definition.\n",
1026 } else if ((i = atoi(cargv[1])) < 0) {
1028 LDAP_LOG( CONFIG, INFO,
1029 "%s: line %d: depth must be positive.\n",
1032 Debug( LDAP_DEBUG_ANY,
1033 "%s: line %d: depth must be positive.\n",
1040 be->be_max_deref_depth = i;
1044 /* set magic "root" dn for this database */
1045 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1048 LDAP_LOG( CONFIG, INFO,
1049 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1052 Debug( LDAP_DEBUG_ANY,
1053 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1062 LDAP_LOG( CONFIG, INFO,
1063 "%s: line %d: rootdn line must appear inside a database "
1064 "definition.\n", fname, lineno ,0 );
1066 Debug( LDAP_DEBUG_ANY,
1067 "%s: line %d: rootdn line must appear inside a database definition.\n",
1075 if ( load_ucdata( NULL ) < 0 ) return 1;
1077 dn.bv_val = cargv[1];
1078 dn.bv_len = strlen( cargv[1] );
1080 rc = dnPrettyNormal( NULL, &dn,
1084 if( rc != LDAP_SUCCESS ) {
1086 LDAP_LOG( CONFIG, CRIT,
1087 "%s: line %d: rootdn DN is invalid.\n",
1090 Debug( LDAP_DEBUG_ANY,
1091 "%s: line %d: rootdn DN is invalid\n",
1098 /* set super-secret magic database password */
1099 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1102 LDAP_LOG( CONFIG, CRIT,
1103 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1104 " line\n", fname, lineno ,0 );
1106 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1107 "missing passwd in \"rootpw <passwd>\" line\n",
1116 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1117 "rootpw line must appear inside a database "
1118 "definition.\n", fname, lineno ,0 );
1120 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1121 "rootpw line must appear inside a database "
1128 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1130 if( tmp_be != be ) {
1132 LDAP_LOG( CONFIG, INFO,
1134 "rootpw can only be set when rootdn is under suffix\n",
1135 fname, lineno, "" );
1137 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1138 "rootpw can only be set when rootdn is under suffix\n",
1144 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1145 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1148 /* make this database read-only */
1149 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1152 LDAP_LOG( CONFIG, CRIT,
1153 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1154 "line.\n", fname, lineno ,0 );
1156 Debug( LDAP_DEBUG_ANY,
1157 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1164 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1165 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1167 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1170 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1171 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1173 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1178 /* allow these features */
1179 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1180 strcasecmp( cargv[0], "allow" ) == 0 )
1186 LDAP_LOG( CONFIG, INFO,
1187 "%s: line %d: allow line must appear prior to "
1188 "database definitions.\n", fname, lineno ,0 );
1190 Debug( LDAP_DEBUG_ANY,
1191 "%s: line %d: allow line must appear prior to database definitions\n",
1199 LDAP_LOG( CONFIG, CRIT,
1200 "%s: line %d: missing feature(s) in \"allow <features>\""
1201 " line\n", fname, lineno ,0 );
1203 Debug( LDAP_DEBUG_ANY,
1204 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1213 for( i=1; i < cargc; i++ ) {
1214 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1215 allows |= SLAP_ALLOW_BIND_V2;
1217 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1218 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1220 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1221 allows |= SLAP_ALLOW_BIND_ANON_DN;
1223 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1225 LDAP_LOG( CONFIG, CRIT,
1226 "%s: line %d: unknown feature %s in "
1227 "\"allow <features>\" line.\n",
1228 fname, lineno, cargv[1] );
1230 Debug( LDAP_DEBUG_ANY,
1231 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1232 fname, lineno, cargv[i] );
1239 global_allows = allows;
1241 /* disallow these features */
1242 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1243 strcasecmp( cargv[0], "disallow" ) == 0 )
1245 slap_mask_t disallows;
1249 LDAP_LOG( CONFIG, INFO,
1250 "%s: line %d: disallow line must appear prior to "
1251 "database definitions.\n", fname, lineno ,0 );
1253 Debug( LDAP_DEBUG_ANY,
1254 "%s: line %d: disallow line must appear prior to database definitions\n",
1262 LDAP_LOG( CONFIG, CRIT,
1263 "%s: line %d: missing feature(s) in \"disallow <features>\""
1264 " line.\n", fname, lineno ,0 );
1266 Debug( LDAP_DEBUG_ANY,
1267 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1276 for( i=1; i < cargc; i++ ) {
1277 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1278 disallows |= SLAP_DISALLOW_BIND_ANON;
1280 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1281 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1283 } else if( strcasecmp( cargv[i], "bind_simple_unprotected" ) == 0 ) {
1284 disallows |= SLAP_DISALLOW_BIND_SIMPLE_UNPROTECTED;
1286 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1287 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1289 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1290 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1292 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1293 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1295 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1297 LDAP_LOG( CONFIG, CRIT,
1298 "%s: line %d: unknown feature %s in "
1299 "\"disallow <features>\" line.\n",
1300 fname, lineno, cargv[i] );
1302 Debug( LDAP_DEBUG_ANY,
1303 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1304 fname, lineno, cargv[i] );
1311 global_disallows = disallows;
1313 /* require these features */
1314 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1315 strcasecmp( cargv[0], "require" ) == 0 )
1317 slap_mask_t requires;
1321 LDAP_LOG( CONFIG, CRIT,
1322 "%s: line %d: missing feature(s) in "
1323 "\"require <features>\" line.\n", fname, lineno ,0 );
1325 Debug( LDAP_DEBUG_ANY,
1326 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1335 for( i=1; i < cargc; i++ ) {
1336 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1337 requires |= SLAP_REQUIRE_BIND;
1339 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1340 requires |= SLAP_REQUIRE_LDAP_V3;
1342 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1343 requires |= SLAP_REQUIRE_AUTHC;
1345 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1346 requires |= SLAP_REQUIRE_SASL;
1348 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1349 requires |= SLAP_REQUIRE_STRONG;
1351 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1353 LDAP_LOG( CONFIG, CRIT,
1354 "%s: line %d: unknown feature %s in "
1355 "\"require <features>\" line.\n",
1356 fname, lineno , cargv[i] );
1358 Debug( LDAP_DEBUG_ANY,
1359 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1360 fname, lineno, cargv[i] );
1368 global_requires = requires;
1370 be->be_requires = requires;
1373 /* required security factors */
1374 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1375 slap_ssf_set_t *set;
1379 LDAP_LOG( CONFIG, CRIT,
1380 "%s: line %d: missing factor(s) in \"security <factors>\""
1381 " line.\n", fname, lineno ,0 );
1383 Debug( LDAP_DEBUG_ANY,
1384 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1392 set = &global_ssf_set;
1394 set = &be->be_ssf_set;
1397 for( i=1; i < cargc; i++ ) {
1398 if( strncasecmp( cargv[i], "ssf=",
1399 sizeof("ssf") ) == 0 )
1402 atoi( &cargv[i][sizeof("ssf")] );
1404 } else if( strncasecmp( cargv[i], "transport=",
1405 sizeof("transport") ) == 0 )
1407 set->sss_transport =
1408 atoi( &cargv[i][sizeof("transport")] );
1410 } else if( strncasecmp( cargv[i], "tls=",
1411 sizeof("tls") ) == 0 )
1414 atoi( &cargv[i][sizeof("tls")] );
1416 } else if( strncasecmp( cargv[i], "sasl=",
1417 sizeof("sasl") ) == 0 )
1420 atoi( &cargv[i][sizeof("sasl")] );
1422 } else if( strncasecmp( cargv[i], "update_ssf=",
1423 sizeof("update_ssf") ) == 0 )
1425 set->sss_update_ssf =
1426 atoi( &cargv[i][sizeof("update_ssf")] );
1428 } else if( strncasecmp( cargv[i], "update_transport=",
1429 sizeof("update_transport") ) == 0 )
1431 set->sss_update_transport =
1432 atoi( &cargv[i][sizeof("update_transport")] );
1434 } else if( strncasecmp( cargv[i], "update_tls=",
1435 sizeof("update_tls") ) == 0 )
1437 set->sss_update_tls =
1438 atoi( &cargv[i][sizeof("update_tls")] );
1440 } else if( strncasecmp( cargv[i], "update_sasl=",
1441 sizeof("update_sasl") ) == 0 )
1443 set->sss_update_sasl =
1444 atoi( &cargv[i][sizeof("update_sasl")] );
1448 LDAP_LOG( CONFIG, CRIT,
1449 "%s: line %d: unknown factor %S in "
1450 "\"security <factors>\" line.\n",
1451 fname, lineno, cargv[1] );
1453 Debug( LDAP_DEBUG_ANY,
1454 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1455 fname, lineno, cargv[i] );
1461 /* where to send clients when we don't hold it */
1462 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1465 LDAP_LOG( CONFIG, CRIT,
1466 "%s: line %d: missing URL in \"referral <URL>\""
1467 " line.\n", fname, lineno , 0 );
1469 Debug( LDAP_DEBUG_ANY,
1470 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1477 if( validate_global_referral( cargv[1] ) ) {
1479 LDAP_LOG( CONFIG, CRIT,
1480 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1481 fname, lineno, cargv[1] );
1483 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1484 "invalid URL (%s) in \"referral\" line.\n",
1485 fname, lineno, cargv[1] );
1490 vals[0].bv_val = cargv[1];
1491 vals[0].bv_len = strlen( vals[0].bv_val );
1492 value_add( &default_referral, vals );
1495 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1499 LDAP_LOG( CONFIG, CRIT,
1500 "%s: line %d: Error in logfile directive, "
1501 "\"logfile <filename>\"\n", fname, lineno , 0 );
1503 Debug( LDAP_DEBUG_ANY,
1504 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1510 logfile = fopen( cargv[1], "w" );
1511 if ( logfile != NULL ) lutil_debug_file( logfile );
1514 /* start of a new database definition */
1515 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1519 LDAP_LOG( CONFIG, CRIT,
1520 "%s: line %d: Error in debug directive, "
1521 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1523 Debug( LDAP_DEBUG_ANY,
1524 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1530 level = atoi( cargv[2] );
1531 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1532 lutil_set_debug_level( cargv[1], level );
1533 /* specify an Object Identifier macro */
1534 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1535 rc = parse_oidm( fname, lineno, cargc, cargv );
1538 /* specify an objectclass */
1539 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1540 if ( *cargv[1] == '(' ) {
1542 p = strchr(saveline,'(');
1543 rc = parse_oc( fname, lineno, p, cargv );
1548 LDAP_LOG( CONFIG, INFO,
1549 "%s: line %d: old objectclass format not supported\n",
1550 fname, lineno , 0 );
1552 Debug( LDAP_DEBUG_ANY,
1553 "%s: line %d: old objectclass format not supported.\n",
1558 /* specify an attribute type */
1559 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1560 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1562 if ( *cargv[1] == '(' ) {
1564 p = strchr(saveline,'(');
1565 rc = parse_at( fname, lineno, p, cargv );
1570 LDAP_LOG( CONFIG, INFO,
1571 "%s: line %d: old attribute type format not supported.\n",
1572 fname, lineno , 0 );
1574 Debug( LDAP_DEBUG_ANY,
1575 "%s: line %d: old attribute type format not supported.\n",
1581 /* turn on/off schema checking */
1582 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1585 LDAP_LOG( CONFIG, CRIT,
1586 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1587 " line.\n", fname, lineno , 0 );
1589 Debug( LDAP_DEBUG_ANY,
1590 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1596 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1598 LDAP_LOG( CONFIG, CRIT,
1599 "%s: line %d: schema checking disabled! your mileage may "
1600 "vary!\n", fname, lineno , 0 );
1602 Debug( LDAP_DEBUG_ANY,
1603 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1606 global_schemacheck = 0;
1608 global_schemacheck = 1;
1611 /* specify access control info */
1612 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1613 parse_acl( be, fname, lineno, cargc, cargv );
1615 /* debug level to log things to syslog */
1616 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1619 LDAP_LOG( CONFIG, CRIT,
1620 "%s: line %d: missing level in \"loglevel <level>\""
1621 " line.\n", fname, lineno , 0 );
1623 Debug( LDAP_DEBUG_ANY,
1624 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1633 for( i=1; i < cargc; i++ ) {
1634 ldap_syslog += atoi( cargv[1] );
1637 /* list of replicas of the data in this backend (master only) */
1638 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1641 LDAP_LOG( CONFIG, CRIT,
1642 "%s: line %d: missing host in \"replica "
1643 " <host[:port]\" line\n", fname, lineno , 0 );
1645 Debug( LDAP_DEBUG_ANY,
1646 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1654 LDAP_LOG( CONFIG, INFO,
1655 "%s: line %d: replica line must appear inside "
1656 "a database definition.\n", fname, lineno, 0);
1658 Debug( LDAP_DEBUG_ANY,
1659 "%s: line %d: replica line must appear inside a database definition\n",
1667 for ( i = 1; i < cargc; i++ ) {
1668 if ( strncasecmp( cargv[i], "host=", 5 )
1670 nr = add_replica_info( be,
1677 LDAP_LOG( CONFIG, INFO,
1678 "%s: line %d: missing host in \"replica\" line\n",
1679 fname, lineno , 0 );
1681 Debug( LDAP_DEBUG_ANY,
1682 "%s: line %d: missing host in \"replica\" line\n",
1687 } else if ( nr == -1 ) {
1689 LDAP_LOG( CONFIG, INFO,
1690 "%s: line %d: unable to add"
1691 " replica \"%s\"\n",
1695 Debug( LDAP_DEBUG_ANY,
1696 "%s: line %d: unable to add replica \"%s\"\n",
1697 fname, lineno, cargv[i] + 5 );
1701 for ( i = 1; i < cargc; i++ ) {
1702 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1704 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1707 LDAP_LOG( CONFIG, INFO,
1708 "%s: line %d: suffix \"%s\" in \"replica\""
1709 " line is not valid for backend(ignored)\n",
1710 fname, lineno, cargv[i] + 7 );
1712 Debug( LDAP_DEBUG_ANY,
1713 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1714 fname, lineno, cargv[i] + 7 );
1720 LDAP_LOG( CONFIG, INFO,
1721 "%s: line %d: unable to normalize suffix"
1722 " in \"replica\" line (ignored)\n",
1723 fname, lineno , 0 );
1725 Debug( LDAP_DEBUG_ANY,
1726 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1732 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1734 char *arg = cargv[i] + 4;
1736 if ( arg[0] == '!' ) {
1741 if ( arg[0] != '=' ) {
1745 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1747 LDAP_LOG( CONFIG, INFO,
1748 "%s: line %d: attribute \"%s\" in "
1749 "\"replica\" line is unknown\n",
1750 fname, lineno, arg + 1 );
1752 Debug( LDAP_DEBUG_ANY,
1753 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1754 fname, lineno, arg + 1 );
1763 /* dn of master entity allowed to write to replica */
1764 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1767 LDAP_LOG( CONFIG, CRIT,
1768 "%s: line %d: missing dn in \"updatedn <dn>\""
1769 " line.\n", fname, lineno , 0 );
1771 Debug( LDAP_DEBUG_ANY,
1772 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1780 LDAP_LOG( CONFIG, INFO,
1781 "%s: line %d: updatedn line must appear inside "
1782 "a database definition\n",
1783 fname, lineno , 0 );
1785 Debug( LDAP_DEBUG_ANY,
1786 "%s: line %d: updatedn line must appear inside a database definition\n",
1794 if ( load_ucdata( NULL ) < 0 ) return 1;
1796 dn.bv_val = cargv[1];
1797 dn.bv_len = strlen( cargv[1] );
1799 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1800 if( rc != LDAP_SUCCESS ) {
1802 LDAP_LOG( CONFIG, CRIT,
1803 "%s: line %d: updatedn DN is invalid.\n",
1804 fname, lineno , 0 );
1806 Debug( LDAP_DEBUG_ANY,
1807 "%s: line %d: updatedn DN is invalid\n",
1814 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1817 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1818 "missing url in \"updateref <ldapurl>\" line.\n",
1819 fname, lineno , 0 );
1821 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1822 "missing url in \"updateref <ldapurl>\" line\n",
1830 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
1831 " line must appear inside a database definition\n",
1832 fname, lineno , 0 );
1834 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1835 " line must appear inside a database definition\n",
1840 } else if ( !be->be_update_ndn.bv_len ) {
1842 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1843 "updateref line must come after updatedn.\n",
1844 fname, lineno , 0 );
1846 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1847 "updateref line must after updatedn.\n",
1853 if( validate_global_referral( cargv[1] ) ) {
1855 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1856 "invalid URL (%s) in \"updateref\" line.\n",
1857 fname, lineno, cargv[1] );
1859 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1860 "invalid URL (%s) in \"updateref\" line.\n",
1861 fname, lineno, cargv[1] );
1866 vals[0].bv_val = cargv[1];
1867 vals[0].bv_len = strlen( vals[0].bv_val );
1868 value_add( &be->be_update_refs, vals );
1870 /* replication log file to which changes are appended */
1871 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1874 LDAP_LOG( CONFIG, CRIT,
1875 "%s: line %d: missing filename in \"replogfile <filename>\""
1876 " line.\n", fname, lineno , 0 );
1878 Debug( LDAP_DEBUG_ANY,
1879 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1886 be->be_replogfile = ch_strdup( cargv[1] );
1888 replogfile = ch_strdup( cargv[1] );
1891 /* file from which to read additional rootdse attrs */
1892 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1895 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1896 "missing filename in \"rootDSE <filename>\" line.\n",
1897 fname, lineno , 0 );
1899 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1900 "missing filename in \"rootDSE <filename>\" line.\n",
1906 if( read_root_dse_file( cargv[1] ) ) {
1908 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1909 "could not read \"rootDSE <filename>\" line.\n",
1910 fname, lineno , 0 );
1912 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1913 "could not read \"rootDSE <filename>\" line\n",
1919 /* maintain lastmodified{by,time} attributes */
1920 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1923 LDAP_LOG( CONFIG, CRIT,
1924 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1925 " line.\n", fname, lineno , 0 );
1927 Debug( LDAP_DEBUG_ANY,
1928 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1934 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1936 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
1942 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
1949 /* turn on/off gentle SIGHUP handling */
1950 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
1952 Debug( LDAP_DEBUG_ANY,
1953 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
1957 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1958 global_gentlehup = 0;
1960 global_gentlehup = 1;
1964 /* set idle timeout value */
1965 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1969 LDAP_LOG( CONFIG, CRIT,
1970 "%s: line %d: missing timeout value in "
1971 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
1973 Debug( LDAP_DEBUG_ANY,
1974 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1981 i = atoi( cargv[1] );
1985 LDAP_LOG( CONFIG, CRIT,
1986 "%s: line %d: timeout value (%d) invalid "
1987 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
1989 Debug( LDAP_DEBUG_ANY,
1990 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1997 global_idletimeout = i;
1999 /* include another config file */
2000 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2003 LDAP_LOG( CONFIG, CRIT,
2004 "%s: line %d: missing filename in \"include "
2005 "<filename>\" line.\n", fname, lineno , 0 );
2007 Debug( LDAP_DEBUG_ANY,
2008 "%s: line %d: missing filename in \"include <filename>\" line\n",
2014 savefname = ch_strdup( cargv[1] );
2015 savelineno = lineno;
2017 if ( read_config( savefname, depth+1 ) != 0 ) {
2022 lineno = savelineno - 1;
2024 /* location of kerberos srvtab file */
2025 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2028 LDAP_LOG( CONFIG, CRIT,
2029 "%s: line %d: missing filename in \"srvtab "
2030 "<filename>\" line.\n", fname, lineno , 0 );
2032 Debug( LDAP_DEBUG_ANY,
2033 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2039 ldap_srvtab = ch_strdup( cargv[1] );
2041 #ifdef SLAPD_MODULES
2042 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2045 LDAP_LOG( CONFIG, INFO,
2046 "%s: line %d: missing filename in \"moduleload "
2047 "<filename>\" line.\n", fname, lineno , 0 );
2049 Debug( LDAP_DEBUG_ANY,
2050 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2054 exit( EXIT_FAILURE );
2056 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2058 LDAP_LOG( CONFIG, CRIT,
2059 "%s: line %d: failed to load or initialize module %s\n",
2060 fname, lineno, cargv[1] );
2062 Debug( LDAP_DEBUG_ANY,
2063 "%s: line %d: failed to load or initialize module %s\n",
2064 fname, lineno, cargv[1]);
2067 exit( EXIT_FAILURE );
2069 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2072 LDAP_LOG( CONFIG, INFO,
2073 "%s: line %d: missing path in \"modulepath <path>\""
2074 " line\n", fname, lineno , 0 );
2076 Debug( LDAP_DEBUG_ANY,
2077 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2081 exit( EXIT_FAILURE );
2083 if (module_path( cargv[1] )) {
2085 LDAP_LOG( CONFIG, CRIT,
2086 "%s: line %d: failed to set module search path to %s.\n",
2087 fname, lineno, cargv[1] );
2089 Debug( LDAP_DEBUG_ANY,
2090 "%s: line %d: failed to set module search path to %s\n",
2091 fname, lineno, cargv[1]);
2094 exit( EXIT_FAILURE );
2097 #endif /*SLAPD_MODULES*/
2100 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2101 rc = ldap_pvt_tls_set_option( NULL,
2102 LDAP_OPT_X_TLS_RANDOM_FILE,
2107 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2108 rc = ldap_pvt_tls_set_option( NULL,
2109 LDAP_OPT_X_TLS_CIPHER_SUITE,
2114 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2115 rc = ldap_pvt_tls_set_option( NULL,
2116 LDAP_OPT_X_TLS_CERTFILE,
2121 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2122 rc = ldap_pvt_tls_set_option( NULL,
2123 LDAP_OPT_X_TLS_KEYFILE,
2128 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2129 rc = ldap_pvt_tls_set_option( NULL,
2130 LDAP_OPT_X_TLS_CACERTDIR,
2135 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2136 rc = ldap_pvt_tls_set_option( NULL,
2137 LDAP_OPT_X_TLS_CACERTFILE,
2141 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2142 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2144 rc = ldap_pvt_tls_set_option( NULL,
2145 LDAP_OPT_X_TLS_REQUIRE_CERT,
2148 rc = ldap_int_tls_config( NULL,
2149 LDAP_OPT_X_TLS_REQUIRE_CERT,
2158 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2159 #ifdef SLAPD_RLOOKUPS
2162 LDAP_LOG( CONFIG, INFO,
2163 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2164 fname, lineno , 0 );
2166 Debug( LDAP_DEBUG_ANY,
2167 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2173 if ( !strcasecmp( cargv[1], "on" ) ) {
2174 use_reverse_lookup = 1;
2175 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2176 use_reverse_lookup = 0;
2179 LDAP_LOG( CONFIG, INFO,
2180 "%s: line %d: reverse-lookup: "
2181 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2183 Debug( LDAP_DEBUG_ANY,
2184 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2190 #else /* !SLAPD_RLOOKUPS */
2192 LDAP_LOG( CONFIG, INFO,
2193 "%s: line %d: reverse lookups "
2194 "are not configured (ignored).\n", fname, lineno , 0 );
2196 Debug( LDAP_DEBUG_ANY,
2197 "%s: line %d: reverse lookups are not configured (ignored).\n",
2200 #endif /* !SLAPD_RLOOKUPS */
2202 /* pass anything else to the current backend info/db config routine */
2205 if ( bi->bi_config == 0 ) {
2207 LDAP_LOG( CONFIG, INFO,
2208 "%s: line %d: unknown directive \"%s\" inside "
2209 "backend info definition (ignored).\n",
2210 fname, lineno, cargv[0] );
2212 Debug( LDAP_DEBUG_ANY,
2213 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2214 fname, lineno, cargv[0] );
2218 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2224 } else if ( be != NULL ) {
2225 if ( be->be_config == 0 ) {
2227 LDAP_LOG( CONFIG, INFO,
2228 "%s: line %d: uknown directive \"%s\" inside "
2229 "backend database definition (ignored).\n",
2230 fname, lineno, cargv[0] );
2232 Debug( LDAP_DEBUG_ANY,
2233 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2234 fname, lineno, cargv[0] );
2238 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2246 LDAP_LOG( CONFIG, INFO,
2247 "%s: line %d: unknown directive \"%s\" outside backend "
2248 "info and database definitions (ignored).\n",
2249 fname, lineno, cargv[0] );
2251 Debug( LDAP_DEBUG_ANY,
2252 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2253 fname, lineno, cargv[0] );
2262 if ( depth == 0 ) ch_free( cargv );
2264 if ( load_ucdata( NULL ) < 0 ) return 1;
2276 char logbuf[sizeof("pseudorootpw ***")];
2279 token = strtok_quote( line, " \t" );
2283 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2284 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2285 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2286 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2287 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2289 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2292 if ( strtok_quote_ptr ) {
2293 *strtok_quote_ptr = ' ';
2297 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2299 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2302 if ( strtok_quote_ptr ) {
2303 *strtok_quote_ptr = '\0';
2306 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2307 if ( cargc == cargv_size - 1 ) {
2309 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2311 if ( tmp == NULL ) {
2313 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2315 Debug( LDAP_DEBUG_ANY,
2316 "line %d: out of memory\n",
2322 cargv_size += ARGS_STEP;
2324 cargv[cargc++] = token;
2326 cargv[cargc] = NULL;
2331 strtok_quote( char *line, char *sep )
2337 strtok_quote_ptr = NULL;
2338 if ( line != NULL ) {
2341 while ( *next && strchr( sep, *next ) ) {
2345 if ( *next == '\0' ) {
2351 for ( inquote = 0; *next; ) {
2359 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2365 next + 1, strlen( next + 1 ) + 1 );
2366 next++; /* dont parse the escaped character */
2371 if ( strchr( sep, *next ) != NULL ) {
2372 strtok_quote_ptr = next;
2385 static char buf[BUFSIZ];
2387 static size_t lmax, lcur;
2389 #define CATLINE( buf ) \
2391 size_t len = strlen( buf ); \
2392 while ( lcur + len + 1 > lmax ) { \
2394 line = (char *) ch_realloc( line, lmax ); \
2396 strcpy( line + lcur, buf ); \
2401 fp_getline( FILE *fp, int *lineno )
2409 /* hack attack - keeps us from having to keep a stack of bufs... */
2410 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2415 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2416 /* trim off \r\n or \n */
2417 if ( (p = strchr( buf, '\n' )) != NULL ) {
2418 if( p > buf && p[-1] == '\r' ) --p;
2422 /* trim off trailing \ and append the next line */
2423 if ( line[ 0 ] != '\0'
2424 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2425 && p[ -1 ] != '\\' ) {
2430 if ( ! isspace( (unsigned char) buf[0] ) ) {
2434 /* change leading whitespace to a space */
2443 return( line[0] ? line : NULL );
2447 fp_getline_init( int *lineno )
2453 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2455 load_ucdata( char *path )
2457 static int loaded = 0;
2463 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2466 LDAP_LOG( CONFIG, CRIT,
2467 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2469 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2482 ucdata_unload( UCDATA_ALL );
2484 if ( slapd_args_file )
2485 free ( slapd_args_file );
2486 if ( slapd_pid_file )
2487 free ( slapd_pid_file );
2488 acl_destroy( global_acl, NULL );