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/socket.h>
24 * defaults for various global variables
26 struct slap_limits_set deflimit = {
27 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
30 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
32 -1 /* no limit on unchecked size */
35 AccessControl *global_acl = NULL;
36 slap_access_t global_default_access = ACL_READ;
37 slap_mask_t global_restrictops = 0;
38 slap_mask_t global_allows = 0;
39 slap_mask_t global_disallows = 0;
40 slap_mask_t global_requires = 0;
41 slap_ssf_set_t global_ssf_set;
43 int global_idletimeout = 0;
44 char *global_host = NULL;
45 char *global_realm = NULL;
46 char *ldap_srvtab = "";
47 char *default_passwd_hash;
48 struct berval default_search_base = { 0, NULL };
49 struct berval default_search_nbase = { 0, NULL };
50 unsigned num_subordinates = 0;
52 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
53 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
55 char *slapd_pid_file = NULL;
56 char *slapd_args_file = NULL;
59 SaslRegexp_t *SaslRegexp = NULL;
60 int sasl_external_x509dn_convert;
62 static char *fp_getline(FILE *fp, int *lineno);
63 static void fp_getline_init(int *lineno);
64 static int fp_parse_line(char *line, int *argcp, char **argv);
66 static char *strtok_quote(char *line, char *sep);
67 static int load_ucdata(char *path);
70 read_config( const char *fname )
73 char *line, *savefname, *saveline;
74 int cargc, savelineno;
75 char *cargv[MAXARGS+1];
78 struct berval vals[2];
80 static int lastmod = 1;
81 static BackendInfo *bi = NULL;
82 static BackendDB *be = NULL;
84 vals[1].bv_val = NULL;
86 if ( (fp = fopen( fname, "r" )) == NULL ) {
89 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
90 "could not open config file \"%s\": %s (%d)\n",
91 fname, strerror(errno), errno ));
93 Debug( LDAP_DEBUG_ANY,
94 "could not open config file \"%s\": %s (%d)\n",
95 fname, strerror(errno), errno );
101 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
102 "read_config: reading config file %s\n", fname ));
104 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
108 fp_getline_init( &lineno );
110 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
111 /* skip comments and blank lines */
112 if ( line[0] == '#' || line[0] == '\0' ) {
117 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
118 "line %d (%s)\n", lineno, line ));
120 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
124 /* fp_parse_line is destructive, we save a copy */
125 saveline = ch_strdup( line );
127 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
133 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
134 "%s: line %d: bad config line (ignored)\n",
137 Debug( LDAP_DEBUG_ANY,
138 "%s: line %d: bad config line (ignored)\n",
145 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
148 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
149 "%s : line %d: missing type in \"backend\" line.\n",
152 Debug( LDAP_DEBUG_ANY,
153 "%s: line %d: missing type in \"backend <type>\" line\n",
162 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
163 "%s: line %d: backend line must appear before any "
164 "database definition.\n", fname, lineno ));
166 Debug( LDAP_DEBUG_ANY,
167 "%s: line %d: backend line must appear before any database definition\n",
174 bi = backend_info( cargv[1] );
178 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
179 "read_config: backend %s initialization failed.\n",
182 Debug( LDAP_DEBUG_ANY,
183 "backend %s initialization failed.\n",
189 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
192 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
193 "%s: line %d: missing type in \"database <type>\" line\n",
196 Debug( LDAP_DEBUG_ANY,
197 "%s: line %d: missing type in \"database <type>\" line\n",
205 be = backend_db_init( cargv[1] );
209 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
210 "database %s initialization failed.\n",
213 Debug( LDAP_DEBUG_ANY,
214 "database %s initialization failed.\n",
221 /* set thread concurrency */
222 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
226 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
227 "%s: line %d: missing level in \"concurrency <level\" line\n",
230 Debug( LDAP_DEBUG_ANY,
231 "%s: line %d: missing level in \"concurrency <level>\" line\n",
238 c = atoi( cargv[1] );
242 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
243 "%s: line %d: invalid level (%d) in "
244 "\"concurrency <level>\" line.\n",
247 Debug( LDAP_DEBUG_ANY,
248 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
255 ldap_pvt_thread_set_concurrency( c );
257 /* set sockbuf max */
258 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
262 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
263 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
266 Debug( LDAP_DEBUG_ANY,
267 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
274 max = atol( cargv[1] );
278 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
279 "%s: line %d: invalid max value (%ld) in "
280 "\"sockbuf_max_incoming <bytes>\" line.\n",
281 fname, lineno, max ));
283 Debug( LDAP_DEBUG_ANY,
284 "%s: line %d: invalid max value (%ld) in "
285 "\"sockbuf_max_incoming <bytes>\" line.\n",
286 fname, lineno, max );
292 sockbuf_max_incoming = max;
294 /* set sockbuf max authenticated */
295 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
299 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
300 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
303 Debug( LDAP_DEBUG_ANY,
304 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
311 max = atol( cargv[1] );
315 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
316 "%s: line %d: invalid max value (%ld) in "
317 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
318 fname, lineno, max ));
320 Debug( LDAP_DEBUG_ANY,
321 "%s: line %d: invalid max value (%ld) in "
322 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
323 fname, lineno, max );
329 sockbuf_max_incoming_auth = max;
331 /* default search base */
332 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
335 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
336 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
337 "line\n", fname, lineno ));
339 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
340 "missing dn in \"defaultSearchBase <dn>\" line\n",
346 } else if ( cargc > 2 ) {
348 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
349 "%s: line %d: extra cruft after <dn> in "
350 "\"defaultSearchBase %s\" line (ignored)\n",
351 fname, lineno, cargv[1] ));
353 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
354 "extra cruft after <dn> in \"defaultSearchBase %s\", "
356 fname, lineno, cargv[1] );
360 if ( bi != NULL || be != NULL ) {
362 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
363 "%s: line %d: defaultSearchBase line must appear "
364 "prior to any backend or database definitions\n",
367 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
368 "defaultSearchBaase line must appear prior to "
369 "any backend or database definition\n",
376 if ( default_search_nbase.bv_len ) {
378 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
379 "default search base \"%s\" already defined "
380 "(discarding old)\n", fname, lineno,
381 default_search_base->bv_val ));
383 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
384 "default search base \"%s\" already defined "
385 "(discarding old)\n",
386 fname, lineno, default_search_base.bv_val );
389 free( default_search_base.bv_val );
390 free( default_search_nbase.bv_val );
393 if ( load_ucdata( NULL ) < 0 ) return 1;
398 dn.bv_val = cargv[1];
399 dn.bv_len = strlen( dn.bv_val );
401 rc = dnPrettyNormal( NULL, &dn,
402 &default_search_base,
403 &default_search_nbase );
405 if( rc != LDAP_SUCCESS ) {
407 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
408 "%s: line %d: defaultSearchBase DN is invalid.\n",
411 Debug( LDAP_DEBUG_ANY,
412 "%s: line %d: defaultSearchBase DN is invalid\n",
419 /* set maximum threads in thread pool */
420 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
424 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
425 "%s: line %d: missing count in \"threads <count>\" line\n",
428 Debug( LDAP_DEBUG_ANY,
429 "%s: line %d: missing count in \"threads <count>\" line\n",
436 c = atoi( cargv[1] );
440 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
441 "%s: line %d: invalid level (%d) in \"threads <count>\""
442 "line\n",fname, lineno, c ));
444 Debug( LDAP_DEBUG_ANY,
445 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
452 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
454 /* save for later use */
455 connection_pool_max = c;
457 /* get pid file name */
458 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
461 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
462 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
465 Debug( LDAP_DEBUG_ANY,
466 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
473 slapd_pid_file = ch_strdup( cargv[1] );
475 /* get args file name */
476 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
479 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
480 "%s: %d: missing file name in "
481 "\"argsfile <file>\" line.\n",
484 Debug( LDAP_DEBUG_ANY,
485 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
492 slapd_args_file = ch_strdup( cargv[1] );
494 /* default password hash */
495 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
498 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
499 "%s: line %d: missing hash in "
500 "\"password-hash <hash>\" line.\n",
503 Debug( LDAP_DEBUG_ANY,
504 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
510 if ( default_passwd_hash != NULL ) {
512 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
513 "%s: line %d: already set default password_hash!\n",
516 Debug( LDAP_DEBUG_ANY,
517 "%s: line %d: already set default password_hash!\n",
524 default_passwd_hash = ch_strdup( cargv[1] );
527 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
531 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
532 "%s: line %d: missing format in "
533 "\"password-crypt-salt-format <format>\" line\n",
536 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
537 "\"password-crypt-salt-format <format>\" line\n",
544 lutil_salt_format( cargv[1] );
547 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
550 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
551 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
554 Debug( LDAP_DEBUG_ANY,
555 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
562 if ( global_host != NULL ) {
564 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
565 "%s: line %d: already set sasl-host!\n",
568 Debug( LDAP_DEBUG_ANY,
569 "%s: line %d: already set sasl-host!\n",
576 global_host = ch_strdup( cargv[1] );
580 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
583 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
584 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
587 Debug( LDAP_DEBUG_ANY,
588 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
595 if ( global_realm != NULL ) {
597 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
598 "%s: line %d: already set sasl-realm!\n",
601 Debug( LDAP_DEBUG_ANY,
602 "%s: line %d: already set sasl-realm!\n",
609 global_realm = ch_strdup( cargv[1] );
612 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
613 || !strcasecmp( cargv[0], "saslregexp" ) )
618 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
619 "%s: line %d: need 2 args in "
620 "\"saslregexp <match> <replace>\"\n",
623 Debug( LDAP_DEBUG_ANY,
624 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
630 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
635 /* SASL security properties */
636 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
641 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
642 "%s: line %d: missing flags in "
643 "\"sasl-secprops <properties>\" line\n",
646 Debug( LDAP_DEBUG_ANY,
647 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
654 txt = slap_sasl_secprops( cargv[1] );
657 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
658 "%s: line %d sas-secprops: %s\n",
659 fname, lineno, txt ));
661 Debug( LDAP_DEBUG_ANY,
662 "%s: line %d: sasl-secprops: %s\n",
663 fname, lineno, txt );
669 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
670 sasl_external_x509dn_convert++;
672 /* set UCDATA path */
673 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
677 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
678 "%s: line %d: missing path in "
679 "\"ucdata-path <path>\" line.\n",
682 Debug( LDAP_DEBUG_ANY,
683 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
690 err = load_ucdata( cargv[1] );
694 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
695 "%s: line %d: ucdata already loaded, ucdata-path "
696 "must be set earlier in the file and/or be "
697 "specified only once!\n",
700 Debug( LDAP_DEBUG_ANY,
701 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
710 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
712 struct slap_limits_set *lim;
716 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
717 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
720 Debug( LDAP_DEBUG_ANY,
721 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
731 lim = &be->be_def_limit;
734 for ( i = 1; i < cargc; i++ ) {
735 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
736 rc = parse_limit( cargv[i], lim );
738 lim->lms_s_soft = atoi( cargv[i] );
744 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
745 "%s: line %d: unable "
746 "to parse value \"%s\" "
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 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
764 struct slap_limits_set *lim;
768 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
769 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
772 Debug( LDAP_DEBUG_ANY,
773 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
783 lim = &be->be_def_limit;
786 for ( i = 1; i < cargc; i++ ) {
787 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
788 rc = parse_limit( cargv[i], lim );
790 lim->lms_t_soft = atoi( cargv[i] );
796 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
797 "%s: line %d: unable "
798 "to parse value \"%s\" "
801 fname, lineno, cargv[i] ));
803 Debug( LDAP_DEBUG_ANY,
804 "%s: line %d: unable "
805 "to parse value \"%s\" "
808 fname, lineno, cargv[i] );
813 /* set regex-based limits */
814 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
817 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
818 "%s: line %d \"limits\" allowed only in database environment.\n",
821 Debug( LDAP_DEBUG_ANY,
822 "%s: line %d \"limits\" allowed only in database environment.\n%s",
828 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
832 /* mark this as a subordinate database */
833 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
836 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
837 "subordinate keyword must appear inside a database "
838 "definition (ignored).\n", fname, lineno ));
840 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
841 "must appear inside a database definition (ignored)\n",
845 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
849 /* set database suffix */
850 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
853 struct berval *pdn = NULL;
854 struct berval *ndn = NULL;
858 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
859 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
862 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
863 "missing dn in \"suffix <dn>\" line\n",
869 } else if ( cargc > 2 ) {
871 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
872 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
873 " line (ignored).\n", fname, lineno, cargv[1] ));
875 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
876 "after <dn> in \"suffix %s\" line (ignored)\n",
877 fname, lineno, cargv[1] );
883 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
884 "%s: line %d: suffix line must appear inside a database "
885 "definition.\n", fname, lineno ));
887 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
888 "must appear inside a database definition\n",
893 #if defined(SLAPD_MONITOR_DN)
894 /* "cn=Monitor" is reserved for monitoring slap */
895 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
897 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
898 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
901 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
902 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
906 #endif /* SLAPD_MONITOR_DN */
909 if ( load_ucdata( NULL ) < 0 ) return 1;
911 dn.bv_val = cargv[1];
912 dn.bv_len = strlen( cargv[1] );
913 pdn = ch_malloc( sizeof( struct berval ));
914 ndn = ch_malloc( sizeof( struct berval ));
916 rc = dnPrettyNormal( NULL, &dn, pdn, ndn );
917 if( rc != LDAP_SUCCESS ) {
919 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
920 "%s: line %d: suffix DN is invalid.\n",
923 Debug( LDAP_DEBUG_ANY,
924 "%s: line %d: suffix DN is invalid\n",
930 tmp_be = select_backend( ndn, 0, 0 );
931 if ( tmp_be == be ) {
933 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
934 "%s: line %d: suffix already served by this backend "
935 "(ignored)\n", fname, lineno ));
937 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
938 "already served by this backend (ignored)\n",
944 } else if ( tmp_be != NULL ) {
946 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
947 "%s: line %d: suffix already served by a preceding "
948 "backend \"%s\"\n", fname, lineno,
949 tmp_be->be_suffix[0]->bv_val ));
951 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
952 "already served by a preceeding backend \"%s\"\n",
953 fname, lineno, tmp_be->be_suffix[0]->bv_val );
959 } else if( pdn->bv_len == 0 && default_search_nbase.bv_len ) {
961 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
962 "%s: line %d: suffix DN empty and default search "
963 "base provided \"%s\" (assuming okay).\n",
964 fname, lineno, default_search_base.bv_val ));
966 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
967 "suffix DN empty and default "
968 "search base provided \"%s\" (assuming okay)\n",
969 fname, lineno, default_search_base.bv_val );
973 ber_bvecadd( &be->be_suffix, pdn );
974 ber_bvecadd( &be->be_nsuffix, ndn );
976 /* set database suffixAlias */
977 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
979 struct berval alias, *palias, nalias;
980 struct berval aliased, *paliased, naliased;
984 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
985 "%s: line %d: missing alias and aliased_dn in "
986 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
989 Debug( LDAP_DEBUG_ANY,
990 "%s: line %d: missing alias and aliased_dn in "
991 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
996 } else if ( cargc < 3 ) {
998 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
999 "%s: line %d: missing aliased_dn in "
1000 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1003 Debug( LDAP_DEBUG_ANY,
1004 "%s: line %d: missing aliased_dn in "
1005 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1010 } else if ( cargc > 3 ) {
1012 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1013 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1016 Debug( LDAP_DEBUG_ANY,
1017 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1025 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1026 "%s: line %d: suffixAlias line must appear inside a "
1027 "database definition (ignored).\n", fname, lineno ));
1029 Debug( LDAP_DEBUG_ANY,
1030 "%s: line %d: suffixAlias line"
1031 " must appear inside a database definition (ignored)\n",
1036 if ( load_ucdata( NULL ) < 0 ) return 1;
1038 alias.bv_val = cargv[1];
1039 alias.bv_len = strlen( cargv[1] );
1040 palias = ch_malloc(sizeof(struct berval));
1042 rc = dnPrettyNormal( NULL, &alias, palias, &nalias );
1043 if( rc != LDAP_SUCCESS ) {
1045 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1046 "%s: line %d: alias DN is invalid.\n",
1049 Debug( LDAP_DEBUG_ANY,
1050 "%s: line %d: alias DN is invalid\n",
1056 tmp_be = select_backend( &nalias, 0, 0 );
1057 free( nalias.bv_val );
1058 if ( tmp_be && tmp_be != be ) {
1060 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1061 "%s: line %d: suffixAlias served by a preceeding "
1063 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1065 Debug( LDAP_DEBUG_ANY,
1066 "%s: line %d: suffixAlias served by"
1067 " a preceeding backend \"%s\"\n",
1068 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1070 ber_bvfree( palias );
1074 aliased.bv_val = cargv[2];
1075 aliased.bv_len = strlen( cargv[2] );
1076 paliased = ch_malloc(sizeof(struct berval));
1078 rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased );
1079 if( rc != LDAP_SUCCESS ) {
1081 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1082 "%s: line %d: aliased DN is invalid.\n",
1085 Debug( LDAP_DEBUG_ANY,
1086 "%s: line %d: aliased DN is invalid\n",
1089 ber_bvfree( palias );
1093 tmp_be = select_backend( &naliased, 0, 0 );
1094 free( naliased.bv_val );
1095 if ( tmp_be && tmp_be != be ) {
1097 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1098 "%s: line %d: suffixAlias derefs to a different backend "
1099 "a preceeding backend \"%s\"\n",
1100 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1102 Debug( LDAP_DEBUG_ANY,
1103 "%s: line %d: suffixAlias derefs to differnet backend"
1104 " a preceeding backend \"%s\"\n",
1105 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1107 ber_bvfree( palias );
1108 ber_bvfree( paliased );
1112 ber_bvecadd( &be->be_suffixAlias, palias );
1113 ber_bvecadd( &be->be_suffixAlias, paliased );
1115 /* set max deref depth */
1116 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1120 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1121 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1122 " line\n", fname, lineno ));
1124 Debug( LDAP_DEBUG_ANY,
1125 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1133 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1134 "%s: line %d: depth line must appear inside a database "
1135 "definition (ignored)\n", fname, lineno ));
1137 Debug( LDAP_DEBUG_ANY,
1138 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1142 } else if ((i = atoi(cargv[1])) < 0) {
1144 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1145 "%s: line %d: depth must be positive (ignored).\n",
1148 Debug( LDAP_DEBUG_ANY,
1149 "%s: line %d: depth must be positive (ignored)\n",
1155 be->be_max_deref_depth = i;
1159 /* set magic "root" dn for this database */
1160 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1163 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1164 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1167 Debug( LDAP_DEBUG_ANY,
1168 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1176 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1177 "%s: line %d: rootdn line must appear inside a database "
1178 "definition (ignored).\n", fname, lineno ));
1180 Debug( LDAP_DEBUG_ANY,
1181 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1188 if ( load_ucdata( NULL ) < 0 ) return 1;
1190 dn.bv_val = cargv[1];
1191 dn.bv_len = strlen( cargv[1] );
1193 rc = dnPrettyNormal( NULL, &dn,
1197 if( rc != LDAP_SUCCESS ) {
1199 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1200 "%s: line %d: rootdn DN is invalid.\n",
1203 Debug( LDAP_DEBUG_ANY,
1204 "%s: line %d: rootdn DN is invalid\n",
1211 /* set super-secret magic database password */
1212 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1215 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1216 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1217 " line\n", fname, lineno ));
1219 Debug( LDAP_DEBUG_ANY,
1220 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1228 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1229 "%s: line %d: rootpw line must appear inside a database "
1230 "definition (ignored)\n", fname, lineno ));
1232 Debug( LDAP_DEBUG_ANY,
1233 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1238 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1239 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1242 /* make this database read-only */
1243 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1246 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1247 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1250 Debug( LDAP_DEBUG_ANY,
1251 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1258 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1259 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1261 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1264 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1265 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1267 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1272 /* allow these features */
1273 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1274 strcasecmp( cargv[0], "allow" ) == 0 )
1280 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1281 "%s: line %d: allow line must appear prior to "
1282 "database definitions.\n", fname, lineno ));
1284 Debug( LDAP_DEBUG_ANY,
1285 "%s: line %d: allow line must appear prior to database definitions\n",
1293 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1294 "%s: line %d: missing feature(s) in \"allow <features>\""
1295 " line\n", fname, lineno ));
1297 Debug( LDAP_DEBUG_ANY,
1298 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1307 for( i=1; i < cargc; i++ ) {
1308 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1309 allows |= SLAP_ALLOW_BIND_V2;
1311 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1312 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1314 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1315 allows |= SLAP_ALLOW_BIND_ANON_DN;
1317 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1319 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1320 "%s: line %d: unknown feature %s in "
1321 "\"allow <features>\" line.\n",
1322 fname, lineno, cargv[1] ));
1324 Debug( LDAP_DEBUG_ANY,
1325 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1326 fname, lineno, cargv[i] );
1333 global_allows = allows;
1335 /* disallow these features */
1336 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1337 strcasecmp( cargv[0], "disallow" ) == 0 )
1339 slap_mask_t disallows;
1343 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1344 "%s: line %d: disallow line must appear prior to "
1345 "database definitions.\n", fname, lineno ));
1347 Debug( LDAP_DEBUG_ANY,
1348 "%s: line %d: disallow line must appear prior to database definitions\n",
1356 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1357 "%s: line %d: missing feature(s) in \"disallow <features>\""
1358 " line.\n", fname, lineno ));
1360 Debug( LDAP_DEBUG_ANY,
1361 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1370 for( i=1; i < cargc; i++ ) {
1371 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1372 disallows |= SLAP_DISALLOW_BIND_ANON;
1374 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1375 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1377 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1378 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1380 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1381 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1383 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1384 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1386 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1388 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1389 "%s: line %d: unknown feature %s in "
1390 "\"disallow <features>\" line.\n",
1391 fname, lineno, cargv[i] ));
1393 Debug( LDAP_DEBUG_ANY,
1394 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1395 fname, lineno, cargv[i] );
1402 global_disallows = disallows;
1404 /* require these features */
1405 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1406 strcasecmp( cargv[0], "require" ) == 0 )
1408 slap_mask_t requires;
1412 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1413 "%s: line %d: missing feature(s) in "
1414 "\"require <features>\" line.\n", fname, lineno ));
1416 Debug( LDAP_DEBUG_ANY,
1417 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1426 for( i=1; i < cargc; i++ ) {
1427 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1428 requires |= SLAP_REQUIRE_BIND;
1430 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1431 requires |= SLAP_REQUIRE_LDAP_V3;
1433 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1434 requires |= SLAP_REQUIRE_AUTHC;
1436 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1437 requires |= SLAP_REQUIRE_SASL;
1439 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1440 requires |= SLAP_REQUIRE_STRONG;
1442 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1444 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1445 "%s: line %d: unknown feature %s in "
1446 "\"require <features>\" line.\n",
1449 Debug( LDAP_DEBUG_ANY,
1450 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1451 fname, lineno, cargv[i] );
1459 global_requires = requires;
1461 be->be_requires = requires;
1464 /* required security factors */
1465 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1466 slap_ssf_set_t *set;
1470 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1471 "%s: line %d: missing factor(s) in \"security <factors>\""
1472 " line.\n", fname, lineno ));
1474 Debug( LDAP_DEBUG_ANY,
1475 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1483 set = &global_ssf_set;
1485 set = &be->be_ssf_set;
1488 for( i=1; i < cargc; i++ ) {
1489 if( strncasecmp( cargv[i], "ssf=",
1490 sizeof("ssf") ) == 0 )
1493 atoi( &cargv[i][sizeof("ssf")] );
1495 } else if( strncasecmp( cargv[i], "transport=",
1496 sizeof("transport") ) == 0 )
1498 set->sss_transport =
1499 atoi( &cargv[i][sizeof("transport")] );
1501 } else if( strncasecmp( cargv[i], "tls=",
1502 sizeof("tls") ) == 0 )
1505 atoi( &cargv[i][sizeof("tls")] );
1507 } else if( strncasecmp( cargv[i], "sasl=",
1508 sizeof("sasl") ) == 0 )
1511 atoi( &cargv[i][sizeof("sasl")] );
1513 } else if( strncasecmp( cargv[i], "update_ssf=",
1514 sizeof("update_ssf") ) == 0 )
1516 set->sss_update_ssf =
1517 atoi( &cargv[i][sizeof("update_ssf")] );
1519 } else if( strncasecmp( cargv[i], "update_transport=",
1520 sizeof("update_transport") ) == 0 )
1522 set->sss_update_transport =
1523 atoi( &cargv[i][sizeof("update_transport")] );
1525 } else if( strncasecmp( cargv[i], "update_tls=",
1526 sizeof("update_tls") ) == 0 )
1528 set->sss_update_tls =
1529 atoi( &cargv[i][sizeof("update_tls")] );
1531 } else if( strncasecmp( cargv[i], "update_sasl=",
1532 sizeof("update_sasl") ) == 0 )
1534 set->sss_update_sasl =
1535 atoi( &cargv[i][sizeof("update_sasl")] );
1539 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1540 "%s: line %d: unknown factor %S in "
1541 "\"security <factors>\" line.\n",
1542 fname, lineno, cargv[1] ));
1544 Debug( LDAP_DEBUG_ANY,
1545 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1546 fname, lineno, cargv[i] );
1552 /* where to send clients when we don't hold it */
1553 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1556 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1557 "%s: line %d: missing URL in \"referral <URL>\""
1558 " line.\n", fname, lineno ));
1560 Debug( LDAP_DEBUG_ANY,
1561 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1568 if( validate_global_referral( cargv[1] ) ) {
1570 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1571 "invalid URL (%s) in \"referral\" line.\n",
1572 fname, lineno, cargv[1] ));
1574 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1575 "invalid URL (%s) in \"referral\" line.\n",
1576 fname, lineno, cargv[1] );
1581 vals[0].bv_val = cargv[1];
1582 vals[0].bv_len = strlen( vals[0].bv_val );
1583 value_add( &default_referral, vals );
1586 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1590 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1591 "%s: line %d: Error in logfile directive, "
1592 "\"logfile <filename>\"\n", fname, lineno ));
1594 Debug( LDAP_DEBUG_ANY,
1595 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1601 logfile = fopen( cargv[1], "w" );
1602 if ( logfile != NULL ) lutil_debug_file( logfile );
1605 /* start of a new database definition */
1606 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1610 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1611 "%s: line %d: Error in debug directive, "
1612 "\"debug <subsys> <level>\"\n", fname, lineno ));
1614 Debug( LDAP_DEBUG_ANY,
1615 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1621 level = atoi( cargv[2] );
1622 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1623 lutil_set_debug_level( cargv[1], level );
1624 /* specify an Object Identifier macro */
1625 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1626 rc = parse_oidm( fname, lineno, cargc, cargv );
1629 /* specify an objectclass */
1630 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1631 if ( *cargv[1] == '(' ) {
1633 p = strchr(saveline,'(');
1634 rc = parse_oc( fname, lineno, p, cargv );
1639 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1640 "%s: line %d: old objectclass format not supported\n",
1643 Debug( LDAP_DEBUG_ANY,
1644 "%s: line %d: old objectclass format not supported.\n",
1650 /* specify an attribute type */
1651 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1652 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1654 if ( *cargv[1] == '(' ) {
1656 p = strchr(saveline,'(');
1657 rc = parse_at( fname, lineno, p, cargv );
1662 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1663 "%s: line %d: old attribute type format not supported.\n",
1666 Debug( LDAP_DEBUG_ANY,
1667 "%s: line %d: old attribute type format not supported.\n",
1673 /* turn on/off schema checking */
1674 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1677 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1678 "%s: line %d: missing on|off in "
1679 "\"schemacheck <on|off>\" line.\n",
1682 Debug( LDAP_DEBUG_ANY,
1683 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1689 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1691 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1692 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1695 Debug( LDAP_DEBUG_ANY,
1696 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1699 global_schemacheck = 0;
1701 global_schemacheck = 1;
1704 /* specify access control info */
1705 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1706 parse_acl( be, fname, lineno, cargc, cargv );
1708 /* debug level to log things to syslog */
1709 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1712 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1713 "%s: line %d: missing level in \"loglevel <level>\""
1714 " line.\n", fname, lineno ));
1716 Debug( LDAP_DEBUG_ANY,
1717 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1726 for( i=1; i < cargc; i++ ) {
1727 ldap_syslog += atoi( cargv[1] );
1730 /* list of replicas of the data in this backend (master only) */
1731 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1734 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1735 "%s: line %d: missing host in \"replica "
1736 " <host[:port]\" line\n", fname, lineno ));
1738 Debug( LDAP_DEBUG_ANY,
1739 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1747 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1748 "%s: line %d: replica line must appear inside "
1749 "a database definition (ignored).\n", fname, lineno ));
1751 Debug( LDAP_DEBUG_ANY,
1752 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1759 for ( i = 1; i < cargc; i++ ) {
1760 if ( strncasecmp( cargv[i], "host=", 5 )
1762 nr = add_replica_info( be,
1769 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1770 "%s: line %d: missing host in \"replica\" "
1771 "line (ignored)\n", fname, lineno ));
1773 Debug( LDAP_DEBUG_ANY,
1774 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1778 } else if ( nr == -1 ) {
1780 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1781 "%s: line %d: unable to add"
1787 Debug( LDAP_DEBUG_ANY,
1788 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1789 fname, lineno, cargv[i] + 5 );
1792 for ( i = 1; i < cargc; i++ ) {
1793 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1795 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1798 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1799 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1800 fname, lineno, cargv[i] + 7 ));
1802 Debug( LDAP_DEBUG_ANY,
1803 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1804 fname, lineno, cargv[i] + 7 );
1810 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1811 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1814 Debug( LDAP_DEBUG_ANY,
1815 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1825 /* dn of master entity allowed to write to replica */
1826 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1829 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1830 "%s: line %d: missing dn in \"updatedn <dn>\""
1831 " line.\n", fname, lineno ));
1833 Debug( LDAP_DEBUG_ANY,
1834 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1842 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1843 "%s: line %d: updatedn line must appear inside "
1844 "a database definition (ignored)\n",
1847 Debug( LDAP_DEBUG_ANY,
1848 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1855 if ( load_ucdata( NULL ) < 0 ) return 1;
1857 dn.bv_val = cargv[1];
1858 dn.bv_len = strlen( cargv[1] );
1860 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1861 if( rc != LDAP_SUCCESS ) {
1863 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1864 "%s: line %d: updatedn DN is invalid.\n",
1867 Debug( LDAP_DEBUG_ANY,
1868 "%s: line %d: updatedn DN is invalid\n",
1875 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1878 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1879 "missing url in \"updateref <ldapurl>\" line.\n",
1882 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1883 "missing url in \"updateref <ldapurl>\" line\n",
1891 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1892 " line must appear inside a database definition\n",
1895 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1896 " line must appear inside a database definition\n",
1901 } else if ( !be->be_update_ndn.bv_len ) {
1903 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1904 "updateref line must come after updatedn.\n",
1907 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1908 "updateref line must after updatedn.\n",
1914 if( validate_global_referral( cargv[1] ) ) {
1916 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1917 "invalid URL (%s) in \"updateref\" line.\n",
1918 fname, lineno, cargv[1] ));
1920 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1921 "invalid URL (%s) in \"updateref\" line.\n",
1922 fname, lineno, cargv[1] );
1927 vals[0].bv_val = cargv[1];
1928 vals[0].bv_len = strlen( vals[0].bv_val );
1929 value_add( &be->be_update_refs, vals );
1931 /* replication log file to which changes are appended */
1932 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1935 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1936 "%s: line %d: missing filename in \"replogfile <filename>\""
1937 " line.\n", fname, lineno ));
1939 Debug( LDAP_DEBUG_ANY,
1940 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1947 be->be_replogfile = ch_strdup( cargv[1] );
1949 replogfile = ch_strdup( cargv[1] );
1952 /* file from which to read additional rootdse attrs */
1953 } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
1956 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1957 "missing filename in \"rootDSE <filename>\" line.\n",
1960 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1961 "missing filename in \"rootDSE <filename>\" line.\n",
1967 if( read_root_dse_file( cargv[1] ) ) {
1969 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1970 "could not read \"rootDSE <filename>\" line.\n",
1973 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1974 "could not read \"rootDSE <filename>\" line\n",
1980 /* maintain lastmodified{by,time} attributes */
1981 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1984 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1985 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1986 " line.\n", fname, lineno ));
1988 Debug( LDAP_DEBUG_ANY,
1989 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1995 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1997 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2003 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2009 /* set idle timeout value */
2010 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2014 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2015 "%s: line %d: missing timeout value in "
2016 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2018 Debug( LDAP_DEBUG_ANY,
2019 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2026 i = atoi( cargv[1] );
2030 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2031 "%s: line %d: timeout value (%d) invalid "
2032 "\"idletimeout <seconds>\" line.\n",
2033 fname, lineno, i ));
2035 Debug( LDAP_DEBUG_ANY,
2036 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2043 global_idletimeout = i;
2045 /* include another config file */
2046 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2049 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2050 "%s: line %d: missing filename in \"include "
2051 "<filename>\" line.\n", fname, lineno ));
2053 Debug( LDAP_DEBUG_ANY,
2054 "%s: line %d: missing filename in \"include <filename>\" line\n",
2060 savefname = ch_strdup( cargv[1] );
2061 savelineno = lineno;
2063 if ( read_config( savefname ) != 0 ) {
2068 lineno = savelineno - 1;
2070 /* location of kerberos srvtab file */
2071 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2074 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2075 "%s: line %d: missing filename in \"srvtab "
2076 "<filename>\" line.\n", fname, lineno ));
2078 Debug( LDAP_DEBUG_ANY,
2079 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2085 ldap_srvtab = ch_strdup( cargv[1] );
2087 #ifdef SLAPD_MODULES
2088 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2091 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2092 "%s: line %d: missing filename in \"moduleload "
2093 "<filename>\" line.\n", fname, lineno ));
2095 Debug( LDAP_DEBUG_ANY,
2096 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2100 exit( EXIT_FAILURE );
2102 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2104 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2105 "%s: line %d: failed to load or initialize module %s\n"<
2106 fname, lineno, cargv[1] ));
2108 Debug( LDAP_DEBUG_ANY,
2109 "%s: line %d: failed to load or initialize module %s\n",
2110 fname, lineno, cargv[1]);
2113 exit( EXIT_FAILURE );
2115 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2118 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2119 "%s: line %d: missing path in \"modulepath <path>\""
2120 " line\n", fname, lineno ));
2122 Debug( LDAP_DEBUG_ANY,
2123 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2127 exit( EXIT_FAILURE );
2129 if (module_path( cargv[1] )) {
2131 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2132 "%s: line %d: failed to set module search path to %s.\n",
2133 fname, lineno, cargv[1] ));
2135 Debug( LDAP_DEBUG_ANY,
2136 "%s: line %d: failed to set module search path to %s\n",
2137 fname, lineno, cargv[1]);
2140 exit( EXIT_FAILURE );
2143 #endif /*SLAPD_MODULES*/
2146 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2147 rc = ldap_pvt_tls_set_option( NULL,
2148 LDAP_OPT_X_TLS_RANDOM_FILE,
2153 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2154 rc = ldap_pvt_tls_set_option( NULL,
2155 LDAP_OPT_X_TLS_CIPHER_SUITE,
2160 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2161 rc = ldap_pvt_tls_set_option( NULL,
2162 LDAP_OPT_X_TLS_CERTFILE,
2167 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2168 rc = ldap_pvt_tls_set_option( NULL,
2169 LDAP_OPT_X_TLS_KEYFILE,
2174 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2175 rc = ldap_pvt_tls_set_option( NULL,
2176 LDAP_OPT_X_TLS_CACERTDIR,
2181 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2182 rc = ldap_pvt_tls_set_option( NULL,
2183 LDAP_OPT_X_TLS_CACERTFILE,
2187 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2188 if ( isdigit( cargv[1][0] ) ) {
2190 rc = ldap_pvt_tls_set_option( NULL,
2191 LDAP_OPT_X_TLS_REQUIRE_CERT,
2194 rc = ldap_int_tls_config( NULL,
2195 LDAP_OPT_X_TLS_REQUIRE_CERT,
2204 /* pass anything else to the current backend info/db config routine */
2207 if ( bi->bi_config == 0 ) {
2209 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2210 "%s: line %d: unknown directive \"%s\" inside "
2211 "backend info definition (ignored).\n",
2212 fname, lineno, cargv[0] ));
2214 Debug( LDAP_DEBUG_ANY,
2215 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2216 fname, lineno, cargv[0] );
2220 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2226 } else if ( be != NULL ) {
2227 if ( be->be_config == 0 ) {
2229 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2230 "%s: line %d: uknown directive \"%s\" inside "
2231 "backend database definition (ignored).\n",
2232 fname, lineno, cargv[0] ));
2234 Debug( LDAP_DEBUG_ANY,
2235 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2236 fname, lineno, cargv[0] );
2240 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2248 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2249 "%s: line %d: unknown directive \"%s\" outside backend "
2250 "info and database definitions (ignored).\n",
2251 fname, lineno, cargv[0] ));
2253 Debug( LDAP_DEBUG_ANY,
2254 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2255 fname, lineno, cargv[0] );
2264 if ( load_ucdata( NULL ) < 0 ) return 1;
2278 for ( token = strtok_quote( line, " \t" ); token != NULL;
2279 token = strtok_quote( NULL, " \t" ) ) {
2280 if ( *argcp == MAXARGS ) {
2282 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2283 "fp_parse_line: too many tokens (%d max).\n",
2286 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2292 argv[(*argcp)++] = token;
2294 argv[*argcp] = NULL;
2299 strtok_quote( char *line, char *sep )
2305 if ( line != NULL ) {
2308 while ( *next && strchr( sep, *next ) ) {
2312 if ( *next == '\0' ) {
2318 for ( inquote = 0; *next; ) {
2326 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2332 next + 1, strlen( next + 1 ) + 1 );
2333 next++; /* dont parse the escaped character */
2338 if ( strchr( sep, *next ) != NULL ) {
2351 static char buf[BUFSIZ];
2353 static int lmax, lcur;
2355 #define CATLINE( buf ) { \
2357 len = strlen( buf ); \
2358 while ( lcur + len + 1 > lmax ) { \
2360 line = (char *) ch_realloc( line, lmax ); \
2362 strcpy( line + lcur, buf ); \
2367 fp_getline( FILE *fp, int *lineno )
2375 /* hack attack - keeps us from having to keep a stack of bufs... */
2376 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2381 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2382 /* trim off \r\n or \n */
2383 if ( (p = strchr( buf, '\n' )) != NULL ) {
2384 if( p > buf && p[-1] == '\r' ) --p;
2388 /* trim off trailing \ and append the next line */
2389 if ( line[ 0 ] != '\0'
2390 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2391 && p[ -1 ] != '\\' ) {
2396 if ( ! isspace( (unsigned char) buf[0] ) ) {
2400 /* change leading whitespace to a space */
2409 return( line[0] ? line : NULL );
2413 fp_getline_init( int *lineno )
2419 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2421 load_ucdata( char *path )
2423 static int loaded = 0;
2429 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2432 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2433 "load_ucdata: Error %d loading ucdata.\n", err ));
2435 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2448 ucdata_unload( UCDATA_ALL );
2450 if ( slapd_args_file )
2451 free ( slapd_args_file );
2452 if ( slapd_pid_file )
2453 free ( slapd_pid_file );
2454 acl_destroy( global_acl, NULL );