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 = NULL;
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;
62 int use_reverse_lookup = 1;
63 #else /* !SLAPD_RLOOKUPS */
64 int use_reverse_lookup = 0;
65 #endif /* !SLAPD_RLOOKUPS */
67 static char *fp_getline(FILE *fp, int *lineno);
68 static void fp_getline_init(int *lineno);
69 static int fp_parse_line(int lineno, char *line, int *argcp, char **argv);
71 static char *strtok_quote(char *line, char *sep);
72 static int load_ucdata(char *path);
75 read_config( const char *fname )
78 char *line, *savefname, *saveline;
79 int cargc, savelineno;
80 char *cargv[MAXARGS+1];
83 struct berval vals[2];
85 static int lastmod = 1;
86 static BackendInfo *bi = NULL;
87 static BackendDB *be = NULL;
89 vals[1].bv_val = NULL;
91 if ( (fp = fopen( fname, "r" )) == NULL ) {
94 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
95 "could not open config file \"%s\": %s (%d)\n",
96 fname, strerror(errno), errno ));
98 Debug( LDAP_DEBUG_ANY,
99 "could not open config file \"%s\": %s (%d)\n",
100 fname, strerror(errno), errno );
106 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
107 "read_config: reading config file %s\n", fname ));
109 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
113 fp_getline_init( &lineno );
115 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
116 /* skip comments and blank lines */
117 if ( line[0] == '#' || line[0] == '\0' ) {
121 /* fp_parse_line is destructive, we save a copy */
122 saveline = ch_strdup( line );
124 if ( fp_parse_line( lineno, line, &cargc, cargv ) != 0 ) {
130 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
131 "%s: line %d: bad config line (ignored)\n",
134 Debug( LDAP_DEBUG_ANY,
135 "%s: line %d: bad config line (ignored)\n",
142 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
145 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
146 "%s : line %d: missing type in \"backend\" line.\n",
149 Debug( LDAP_DEBUG_ANY,
150 "%s: line %d: missing type in \"backend <type>\" line\n",
159 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
160 "%s: line %d: backend line must appear before any "
161 "database definition.\n", fname, lineno ));
163 Debug( LDAP_DEBUG_ANY,
164 "%s: line %d: backend line must appear before any database definition\n",
171 bi = backend_info( cargv[1] );
175 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
176 "read_config: backend %s initialization failed.\n",
179 Debug( LDAP_DEBUG_ANY,
180 "backend %s initialization failed.\n",
186 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
189 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
190 "%s: line %d: missing type in \"database <type>\" line\n",
193 Debug( LDAP_DEBUG_ANY,
194 "%s: line %d: missing type in \"database <type>\" line\n",
202 be = backend_db_init( cargv[1] );
206 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
207 "database %s initialization failed.\n",
210 Debug( LDAP_DEBUG_ANY,
211 "database %s initialization failed.\n",
218 /* set thread concurrency */
219 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
223 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
224 "%s: line %d: missing level in \"concurrency <level\" line\n",
227 Debug( LDAP_DEBUG_ANY,
228 "%s: line %d: missing level in \"concurrency <level>\" line\n",
235 c = atoi( cargv[1] );
239 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
240 "%s: line %d: invalid level (%d) in "
241 "\"concurrency <level>\" line.\n",
244 Debug( LDAP_DEBUG_ANY,
245 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
252 ldap_pvt_thread_set_concurrency( c );
254 /* set sockbuf max */
255 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
259 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
260 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
263 Debug( LDAP_DEBUG_ANY,
264 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
271 max = atol( cargv[1] );
275 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
276 "%s: line %d: invalid max value (%ld) in "
277 "\"sockbuf_max_incoming <bytes>\" line.\n",
278 fname, lineno, max ));
280 Debug( LDAP_DEBUG_ANY,
281 "%s: line %d: invalid max value (%ld) in "
282 "\"sockbuf_max_incoming <bytes>\" line.\n",
283 fname, lineno, max );
289 sockbuf_max_incoming = max;
291 /* set sockbuf max authenticated */
292 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
296 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
297 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
300 Debug( LDAP_DEBUG_ANY,
301 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
308 max = atol( cargv[1] );
312 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
313 "%s: line %d: invalid max value (%ld) in "
314 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
315 fname, lineno, max ));
317 Debug( LDAP_DEBUG_ANY,
318 "%s: line %d: invalid max value (%ld) in "
319 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
320 fname, lineno, max );
326 sockbuf_max_incoming_auth = max;
328 /* default search base */
329 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
332 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
333 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
334 "line\n", fname, lineno ));
336 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
337 "missing dn in \"defaultSearchBase <dn>\" line\n",
343 } else if ( cargc > 2 ) {
345 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
346 "%s: line %d: extra cruft after <dn> in "
347 "\"defaultSearchBase %s\" line (ignored)\n",
348 fname, lineno, cargv[1] ));
350 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
351 "extra cruft after <dn> in \"defaultSearchBase %s\", "
353 fname, lineno, cargv[1] );
357 if ( bi != NULL || be != NULL ) {
359 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
360 "%s: line %d: defaultSearchBase line must appear "
361 "prior to any backend or database definitions\n",
364 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
365 "defaultSearchBaase line must appear prior to "
366 "any backend or database definition\n",
373 if ( default_search_nbase.bv_len ) {
375 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
376 "default search base \"%s\" already defined "
377 "(discarding old)\n", fname, lineno,
378 default_search_base.bv_val ));
380 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
381 "default search base \"%s\" already defined "
382 "(discarding old)\n",
383 fname, lineno, default_search_base.bv_val );
386 free( default_search_base.bv_val );
387 free( default_search_nbase.bv_val );
390 if ( load_ucdata( NULL ) < 0 ) return 1;
395 dn.bv_val = cargv[1];
396 dn.bv_len = strlen( dn.bv_val );
398 rc = dnPrettyNormal( NULL, &dn,
399 &default_search_base,
400 &default_search_nbase );
402 if( rc != LDAP_SUCCESS ) {
404 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
405 "%s: line %d: defaultSearchBase DN is invalid.\n",
408 Debug( LDAP_DEBUG_ANY,
409 "%s: line %d: defaultSearchBase DN is invalid\n",
416 /* set maximum threads in thread pool */
417 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
421 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
422 "%s: line %d: missing count in \"threads <count>\" line\n",
425 Debug( LDAP_DEBUG_ANY,
426 "%s: line %d: missing count in \"threads <count>\" line\n",
433 c = atoi( cargv[1] );
437 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
438 "%s: line %d: invalid level (%d) in \"threads <count>\""
439 "line\n",fname, lineno, c ));
441 Debug( LDAP_DEBUG_ANY,
442 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
449 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
451 /* save for later use */
452 connection_pool_max = c;
454 /* get pid file name */
455 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
458 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
459 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
462 Debug( LDAP_DEBUG_ANY,
463 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
470 slapd_pid_file = ch_strdup( cargv[1] );
472 /* get args file name */
473 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
476 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
477 "%s: %d: missing file name in "
478 "\"argsfile <file>\" line.\n",
481 Debug( LDAP_DEBUG_ANY,
482 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
489 slapd_args_file = ch_strdup( cargv[1] );
491 /* default password hash */
492 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
495 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
496 "%s: line %d: missing hash in "
497 "\"password-hash <hash>\" line.\n",
500 Debug( LDAP_DEBUG_ANY,
501 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
507 if ( default_passwd_hash != NULL ) {
509 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
510 "%s: line %d: already set default password_hash!\n",
513 Debug( LDAP_DEBUG_ANY,
514 "%s: line %d: already set default password_hash!\n",
522 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
524 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
525 "%s: line %d: password scheme \"%s\" not available\n",
526 fname, lineno, cargv[1] ));
528 Debug( LDAP_DEBUG_ANY,
529 "%s: line %d: password scheme \"%s\" not available\n",
530 fname, lineno, cargv[1] );
535 default_passwd_hash = ch_strdup( cargv[1] );
537 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
541 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
542 "%s: line %d: missing format in "
543 "\"password-crypt-salt-format <format>\" line\n",
546 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
547 "\"password-crypt-salt-format <format>\" line\n",
554 lutil_salt_format( cargv[1] );
557 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
560 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
561 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
564 Debug( LDAP_DEBUG_ANY,
565 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
572 if ( global_host != NULL ) {
574 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
575 "%s: line %d: already set sasl-host!\n",
578 Debug( LDAP_DEBUG_ANY,
579 "%s: line %d: already set sasl-host!\n",
586 global_host = ch_strdup( cargv[1] );
590 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
593 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
594 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
597 Debug( LDAP_DEBUG_ANY,
598 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
605 if ( global_realm != NULL ) {
607 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
608 "%s: line %d: already set sasl-realm!\n",
611 Debug( LDAP_DEBUG_ANY,
612 "%s: line %d: already set sasl-realm!\n",
619 global_realm = ch_strdup( cargv[1] );
622 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
623 || !strcasecmp( cargv[0], "saslregexp" ) )
628 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
629 "%s: line %d: need 2 args in "
630 "\"saslregexp <match> <replace>\"\n",
633 Debug( LDAP_DEBUG_ANY,
634 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
640 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
645 /* SASL security properties */
646 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
651 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
652 "%s: line %d: missing flags in "
653 "\"sasl-secprops <properties>\" line\n",
656 Debug( LDAP_DEBUG_ANY,
657 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
664 txt = slap_sasl_secprops( cargv[1] );
667 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
668 "%s: line %d sas-secprops: %s\n",
669 fname, lineno, txt ));
671 Debug( LDAP_DEBUG_ANY,
672 "%s: line %d: sasl-secprops: %s\n",
673 fname, lineno, txt );
679 /* set UCDATA path */
680 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
684 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
685 "%s: line %d: missing path in "
686 "\"ucdata-path <path>\" line.\n",
689 Debug( LDAP_DEBUG_ANY,
690 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
697 err = load_ucdata( cargv[1] );
701 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
702 "%s: line %d: ucdata already loaded, ucdata-path "
703 "must be set earlier in the file and/or be "
704 "specified only once!\n",
707 Debug( LDAP_DEBUG_ANY,
708 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
717 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
719 struct slap_limits_set *lim;
723 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
724 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
727 Debug( LDAP_DEBUG_ANY,
728 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
738 lim = &be->be_def_limit;
741 for ( i = 1; i < cargc; i++ ) {
742 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
743 rc = parse_limit( cargv[i], lim );
745 lim->lms_s_soft = atoi( cargv[i] );
751 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
752 "%s: line %d: unable "
753 "to parse value \"%s\" "
756 fname, lineno, cargv[i] ));
758 Debug( LDAP_DEBUG_ANY,
759 "%s: line %d: unable "
760 "to parse value \"%s\" "
763 fname, lineno, cargv[i] );
769 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
771 struct slap_limits_set *lim;
775 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
776 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
779 Debug( LDAP_DEBUG_ANY,
780 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
790 lim = &be->be_def_limit;
793 for ( i = 1; i < cargc; i++ ) {
794 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
795 rc = parse_limit( cargv[i], lim );
797 lim->lms_t_soft = atoi( cargv[i] );
803 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
804 "%s: line %d: unable "
805 "to parse value \"%s\" "
808 fname, lineno, cargv[i] ));
810 Debug( LDAP_DEBUG_ANY,
811 "%s: line %d: unable "
812 "to parse value \"%s\" "
815 fname, lineno, cargv[i] );
820 /* set regex-based limits */
821 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
824 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
825 "%s: line %d \"limits\" allowed only in database environment.\n",
828 Debug( LDAP_DEBUG_ANY,
829 "%s: line %d \"limits\" allowed only in database environment.\n%s",
835 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
839 /* mark this as a subordinate database */
840 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
843 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
844 "subordinate keyword must appear inside a database "
845 "definition (ignored).\n", fname, lineno ));
847 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
848 "must appear inside a database definition (ignored)\n",
852 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
856 /* set database suffix */
857 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
860 struct berval *pdn = NULL;
861 struct berval *ndn = NULL;
865 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
866 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
869 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
870 "missing dn in \"suffix <dn>\" line\n",
876 } else if ( cargc > 2 ) {
878 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
879 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
880 " line (ignored).\n", fname, lineno, cargv[1] ));
882 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
883 "after <dn> in \"suffix %s\" line (ignored)\n",
884 fname, lineno, cargv[1] );
890 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
891 "%s: line %d: suffix line must appear inside a database "
892 "definition.\n", fname, lineno ));
894 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
895 "must appear inside a database definition\n",
900 #if defined(SLAPD_MONITOR_DN)
901 /* "cn=Monitor" is reserved for monitoring slap */
902 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
904 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
905 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
908 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
909 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
913 #endif /* SLAPD_MONITOR_DN */
916 if ( load_ucdata( NULL ) < 0 ) return 1;
918 dn.bv_val = cargv[1];
919 dn.bv_len = strlen( cargv[1] );
920 pdn = ch_malloc( sizeof( struct berval ));
921 ndn = ch_malloc( sizeof( struct berval ));
923 rc = dnPrettyNormal( NULL, &dn, pdn, ndn );
924 if( rc != LDAP_SUCCESS ) {
926 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
927 "%s: line %d: suffix DN is invalid.\n",
930 Debug( LDAP_DEBUG_ANY,
931 "%s: line %d: suffix DN is invalid\n",
937 tmp_be = select_backend( ndn, 0, 0 );
938 if ( tmp_be == be ) {
940 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
941 "%s: line %d: suffix already served by this backend "
942 "(ignored)\n", fname, lineno ));
944 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
945 "already served by this backend (ignored)\n",
951 } else if ( tmp_be != NULL ) {
953 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
954 "%s: line %d: suffix already served by a preceding "
955 "backend \"%s\"\n", fname, lineno,
956 tmp_be->be_suffix[0]->bv_val ));
958 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
959 "already served by a preceeding backend \"%s\"\n",
960 fname, lineno, tmp_be->be_suffix[0]->bv_val );
966 } else if( pdn->bv_len == 0 && default_search_nbase.bv_len ) {
968 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
969 "%s: line %d: suffix DN empty and default search "
970 "base provided \"%s\" (assuming okay).\n",
971 fname, lineno, default_search_base.bv_val ));
973 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
974 "suffix DN empty and default "
975 "search base provided \"%s\" (assuming okay)\n",
976 fname, lineno, default_search_base.bv_val );
980 ber_bvecadd( &be->be_suffix, pdn );
981 ber_bvecadd( &be->be_nsuffix, ndn );
983 /* set database suffixAlias */
984 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
986 struct berval alias, *palias, nalias;
987 struct berval aliased, *paliased, naliased;
991 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
992 "%s: line %d: missing alias and aliased_dn in "
993 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
996 Debug( LDAP_DEBUG_ANY,
997 "%s: line %d: missing alias and aliased_dn in "
998 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1003 } else if ( cargc < 3 ) {
1005 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1006 "%s: line %d: missing aliased_dn in "
1007 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1010 Debug( LDAP_DEBUG_ANY,
1011 "%s: line %d: missing aliased_dn in "
1012 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1017 } else if ( cargc > 3 ) {
1019 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1020 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1023 Debug( LDAP_DEBUG_ANY,
1024 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1032 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1033 "%s: line %d: suffixAlias line must appear inside a "
1034 "database definition (ignored).\n", fname, lineno ));
1036 Debug( LDAP_DEBUG_ANY,
1037 "%s: line %d: suffixAlias line"
1038 " must appear inside a database definition (ignored)\n",
1043 if ( load_ucdata( NULL ) < 0 ) return 1;
1045 alias.bv_val = cargv[1];
1046 alias.bv_len = strlen( cargv[1] );
1047 palias = ch_malloc(sizeof(struct berval));
1049 rc = dnPrettyNormal( NULL, &alias, palias, &nalias );
1050 if( rc != LDAP_SUCCESS ) {
1052 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1053 "%s: line %d: alias DN is invalid.\n",
1056 Debug( LDAP_DEBUG_ANY,
1057 "%s: line %d: alias DN is invalid\n",
1063 tmp_be = select_backend( &nalias, 0, 0 );
1064 free( nalias.bv_val );
1065 if ( tmp_be && tmp_be != be ) {
1067 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1068 "%s: line %d: suffixAlias served by a preceeding "
1070 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1072 Debug( LDAP_DEBUG_ANY,
1073 "%s: line %d: suffixAlias served by"
1074 " a preceeding backend \"%s\"\n",
1075 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1077 ber_bvfree( palias );
1081 aliased.bv_val = cargv[2];
1082 aliased.bv_len = strlen( cargv[2] );
1083 paliased = ch_malloc(sizeof(struct berval));
1085 rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased );
1086 if( rc != LDAP_SUCCESS ) {
1088 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1089 "%s: line %d: aliased DN is invalid.\n",
1092 Debug( LDAP_DEBUG_ANY,
1093 "%s: line %d: aliased DN is invalid\n",
1096 ber_bvfree( palias );
1100 tmp_be = select_backend( &naliased, 0, 0 );
1101 free( naliased.bv_val );
1102 if ( tmp_be && tmp_be != be ) {
1104 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1105 "%s: line %d: suffixAlias derefs to a different backend "
1106 "a preceeding backend \"%s\"\n",
1107 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1109 Debug( LDAP_DEBUG_ANY,
1110 "%s: line %d: suffixAlias derefs to differnet backend"
1111 " a preceeding backend \"%s\"\n",
1112 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1114 ber_bvfree( palias );
1115 ber_bvfree( paliased );
1119 ber_bvecadd( &be->be_suffixAlias, palias );
1120 ber_bvecadd( &be->be_suffixAlias, paliased );
1122 /* set max deref depth */
1123 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1127 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1128 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1129 " line\n", fname, lineno ));
1131 Debug( LDAP_DEBUG_ANY,
1132 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1140 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1141 "%s: line %d: depth line must appear inside a database "
1142 "definition (ignored)\n", fname, lineno ));
1144 Debug( LDAP_DEBUG_ANY,
1145 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1149 } else if ((i = atoi(cargv[1])) < 0) {
1151 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1152 "%s: line %d: depth must be positive (ignored).\n",
1155 Debug( LDAP_DEBUG_ANY,
1156 "%s: line %d: depth must be positive (ignored)\n",
1162 be->be_max_deref_depth = i;
1166 /* set magic "root" dn for this database */
1167 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1170 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1171 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1174 Debug( LDAP_DEBUG_ANY,
1175 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1183 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1184 "%s: line %d: rootdn line must appear inside a database "
1185 "definition (ignored).\n", fname, lineno ));
1187 Debug( LDAP_DEBUG_ANY,
1188 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1195 if ( load_ucdata( NULL ) < 0 ) return 1;
1197 dn.bv_val = cargv[1];
1198 dn.bv_len = strlen( cargv[1] );
1200 rc = dnPrettyNormal( NULL, &dn,
1204 if( rc != LDAP_SUCCESS ) {
1206 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1207 "%s: line %d: rootdn DN is invalid.\n",
1210 Debug( LDAP_DEBUG_ANY,
1211 "%s: line %d: rootdn DN is invalid\n",
1218 /* set super-secret magic database password */
1219 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1222 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1223 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1224 " line\n", fname, lineno ));
1226 Debug( LDAP_DEBUG_ANY,
1227 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1235 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1236 "%s: line %d: rootpw line must appear inside a database "
1237 "definition (ignored)\n", fname, lineno ));
1239 Debug( LDAP_DEBUG_ANY,
1240 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1245 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1246 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1249 /* make this database read-only */
1250 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1253 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1254 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1257 Debug( LDAP_DEBUG_ANY,
1258 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1265 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1266 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1268 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1271 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1272 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1274 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1279 /* allow these features */
1280 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1281 strcasecmp( cargv[0], "allow" ) == 0 )
1287 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1288 "%s: line %d: allow line must appear prior to "
1289 "database definitions.\n", fname, lineno ));
1291 Debug( LDAP_DEBUG_ANY,
1292 "%s: line %d: allow line must appear prior to database definitions\n",
1300 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1301 "%s: line %d: missing feature(s) in \"allow <features>\""
1302 " line\n", fname, lineno ));
1304 Debug( LDAP_DEBUG_ANY,
1305 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1314 for( i=1; i < cargc; i++ ) {
1315 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1316 allows |= SLAP_ALLOW_BIND_V2;
1318 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1319 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1321 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1322 allows |= SLAP_ALLOW_BIND_ANON_DN;
1324 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1326 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1327 "%s: line %d: unknown feature %s in "
1328 "\"allow <features>\" line.\n",
1329 fname, lineno, cargv[1] ));
1331 Debug( LDAP_DEBUG_ANY,
1332 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1333 fname, lineno, cargv[i] );
1340 global_allows = allows;
1342 /* disallow these features */
1343 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1344 strcasecmp( cargv[0], "disallow" ) == 0 )
1346 slap_mask_t disallows;
1350 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1351 "%s: line %d: disallow line must appear prior to "
1352 "database definitions.\n", fname, lineno ));
1354 Debug( LDAP_DEBUG_ANY,
1355 "%s: line %d: disallow line must appear prior to database definitions\n",
1363 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1364 "%s: line %d: missing feature(s) in \"disallow <features>\""
1365 " line.\n", fname, lineno ));
1367 Debug( LDAP_DEBUG_ANY,
1368 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1377 for( i=1; i < cargc; i++ ) {
1378 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1379 disallows |= SLAP_DISALLOW_BIND_ANON;
1381 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1382 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1384 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1385 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1387 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1388 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1390 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1391 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1393 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1395 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1396 "%s: line %d: unknown feature %s in "
1397 "\"disallow <features>\" line.\n",
1398 fname, lineno, cargv[i] ));
1400 Debug( LDAP_DEBUG_ANY,
1401 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1402 fname, lineno, cargv[i] );
1409 global_disallows = disallows;
1411 /* require these features */
1412 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1413 strcasecmp( cargv[0], "require" ) == 0 )
1415 slap_mask_t requires;
1419 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1420 "%s: line %d: missing feature(s) in "
1421 "\"require <features>\" line.\n", fname, lineno ));
1423 Debug( LDAP_DEBUG_ANY,
1424 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1433 for( i=1; i < cargc; i++ ) {
1434 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1435 requires |= SLAP_REQUIRE_BIND;
1437 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1438 requires |= SLAP_REQUIRE_LDAP_V3;
1440 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1441 requires |= SLAP_REQUIRE_AUTHC;
1443 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1444 requires |= SLAP_REQUIRE_SASL;
1446 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1447 requires |= SLAP_REQUIRE_STRONG;
1449 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1451 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1452 "%s: line %d: unknown feature %s in "
1453 "\"require <features>\" line.\n",
1456 Debug( LDAP_DEBUG_ANY,
1457 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1458 fname, lineno, cargv[i] );
1466 global_requires = requires;
1468 be->be_requires = requires;
1471 /* required security factors */
1472 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1473 slap_ssf_set_t *set;
1477 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1478 "%s: line %d: missing factor(s) in \"security <factors>\""
1479 " line.\n", fname, lineno ));
1481 Debug( LDAP_DEBUG_ANY,
1482 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1490 set = &global_ssf_set;
1492 set = &be->be_ssf_set;
1495 for( i=1; i < cargc; i++ ) {
1496 if( strncasecmp( cargv[i], "ssf=",
1497 sizeof("ssf") ) == 0 )
1500 atoi( &cargv[i][sizeof("ssf")] );
1502 } else if( strncasecmp( cargv[i], "transport=",
1503 sizeof("transport") ) == 0 )
1505 set->sss_transport =
1506 atoi( &cargv[i][sizeof("transport")] );
1508 } else if( strncasecmp( cargv[i], "tls=",
1509 sizeof("tls") ) == 0 )
1512 atoi( &cargv[i][sizeof("tls")] );
1514 } else if( strncasecmp( cargv[i], "sasl=",
1515 sizeof("sasl") ) == 0 )
1518 atoi( &cargv[i][sizeof("sasl")] );
1520 } else if( strncasecmp( cargv[i], "update_ssf=",
1521 sizeof("update_ssf") ) == 0 )
1523 set->sss_update_ssf =
1524 atoi( &cargv[i][sizeof("update_ssf")] );
1526 } else if( strncasecmp( cargv[i], "update_transport=",
1527 sizeof("update_transport") ) == 0 )
1529 set->sss_update_transport =
1530 atoi( &cargv[i][sizeof("update_transport")] );
1532 } else if( strncasecmp( cargv[i], "update_tls=",
1533 sizeof("update_tls") ) == 0 )
1535 set->sss_update_tls =
1536 atoi( &cargv[i][sizeof("update_tls")] );
1538 } else if( strncasecmp( cargv[i], "update_sasl=",
1539 sizeof("update_sasl") ) == 0 )
1541 set->sss_update_sasl =
1542 atoi( &cargv[i][sizeof("update_sasl")] );
1546 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1547 "%s: line %d: unknown factor %S in "
1548 "\"security <factors>\" line.\n",
1549 fname, lineno, cargv[1] ));
1551 Debug( LDAP_DEBUG_ANY,
1552 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1553 fname, lineno, cargv[i] );
1559 /* where to send clients when we don't hold it */
1560 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1563 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1564 "%s: line %d: missing URL in \"referral <URL>\""
1565 " line.\n", fname, lineno ));
1567 Debug( LDAP_DEBUG_ANY,
1568 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1575 if( validate_global_referral( cargv[1] ) ) {
1577 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1578 "invalid URL (%s) in \"referral\" line.\n",
1579 fname, lineno, cargv[1] ));
1581 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1582 "invalid URL (%s) in \"referral\" line.\n",
1583 fname, lineno, cargv[1] );
1588 vals[0].bv_val = cargv[1];
1589 vals[0].bv_len = strlen( vals[0].bv_val );
1590 value_add( &default_referral, vals );
1593 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1597 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1598 "%s: line %d: Error in logfile directive, "
1599 "\"logfile <filename>\"\n", fname, lineno ));
1601 Debug( LDAP_DEBUG_ANY,
1602 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1608 logfile = fopen( cargv[1], "w" );
1609 if ( logfile != NULL ) lutil_debug_file( logfile );
1612 /* start of a new database definition */
1613 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1617 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1618 "%s: line %d: Error in debug directive, "
1619 "\"debug <subsys> <level>\"\n", fname, lineno ));
1621 Debug( LDAP_DEBUG_ANY,
1622 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1628 level = atoi( cargv[2] );
1629 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1630 lutil_set_debug_level( cargv[1], level );
1631 /* specify an Object Identifier macro */
1632 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1633 rc = parse_oidm( fname, lineno, cargc, cargv );
1636 /* specify an objectclass */
1637 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1638 if ( *cargv[1] == '(' ) {
1640 p = strchr(saveline,'(');
1641 rc = parse_oc( fname, lineno, p, cargv );
1646 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1647 "%s: line %d: old objectclass format not supported\n",
1650 Debug( LDAP_DEBUG_ANY,
1651 "%s: line %d: old objectclass format not supported.\n",
1657 /* specify an attribute type */
1658 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1659 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1661 if ( *cargv[1] == '(' ) {
1663 p = strchr(saveline,'(');
1664 rc = parse_at( fname, lineno, p, cargv );
1669 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1670 "%s: line %d: old attribute type format not supported.\n",
1673 Debug( LDAP_DEBUG_ANY,
1674 "%s: line %d: old attribute type format not supported.\n",
1680 /* turn on/off schema checking */
1681 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1684 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1685 "%s: line %d: missing on|off in "
1686 "\"schemacheck <on|off>\" line.\n",
1689 Debug( LDAP_DEBUG_ANY,
1690 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1696 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1698 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1699 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1702 Debug( LDAP_DEBUG_ANY,
1703 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1706 global_schemacheck = 0;
1708 global_schemacheck = 1;
1711 /* specify access control info */
1712 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1713 parse_acl( be, fname, lineno, cargc, cargv );
1715 /* debug level to log things to syslog */
1716 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1719 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1720 "%s: line %d: missing level in \"loglevel <level>\""
1721 " line.\n", fname, lineno ));
1723 Debug( LDAP_DEBUG_ANY,
1724 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1733 for( i=1; i < cargc; i++ ) {
1734 ldap_syslog += atoi( cargv[1] );
1737 /* list of replicas of the data in this backend (master only) */
1738 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1741 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1742 "%s: line %d: missing host in \"replica "
1743 " <host[:port]\" line\n", fname, lineno ));
1745 Debug( LDAP_DEBUG_ANY,
1746 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1754 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1755 "%s: line %d: replica line must appear inside "
1756 "a database definition (ignored).\n", fname, lineno ));
1758 Debug( LDAP_DEBUG_ANY,
1759 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1766 for ( i = 1; i < cargc; i++ ) {
1767 if ( strncasecmp( cargv[i], "host=", 5 )
1769 nr = add_replica_info( be,
1776 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1777 "%s: line %d: missing host in \"replica\" "
1778 "line (ignored)\n", fname, lineno ));
1780 Debug( LDAP_DEBUG_ANY,
1781 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1785 } else if ( nr == -1 ) {
1787 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1788 "%s: line %d: unable to add"
1794 Debug( LDAP_DEBUG_ANY,
1795 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1796 fname, lineno, cargv[i] + 5 );
1799 for ( i = 1; i < cargc; i++ ) {
1800 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1802 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1805 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1806 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1807 fname, lineno, cargv[i] + 7 ));
1809 Debug( LDAP_DEBUG_ANY,
1810 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1811 fname, lineno, cargv[i] + 7 );
1817 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1818 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1821 Debug( LDAP_DEBUG_ANY,
1822 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1828 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1830 char *arg = cargv[i] + 4;
1832 if ( arg[0] == '!' ) {
1837 if ( arg[0] != '=' ) {
1841 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1843 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1844 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1845 fname, lineno, arg + 1 ));
1847 Debug( LDAP_DEBUG_ANY,
1848 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1849 fname, lineno, arg + 1 );
1858 /* dn of master entity allowed to write to replica */
1859 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1862 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1863 "%s: line %d: missing dn in \"updatedn <dn>\""
1864 " line.\n", fname, lineno ));
1866 Debug( LDAP_DEBUG_ANY,
1867 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1875 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1876 "%s: line %d: updatedn line must appear inside "
1877 "a database definition (ignored)\n",
1880 Debug( LDAP_DEBUG_ANY,
1881 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1888 if ( load_ucdata( NULL ) < 0 ) return 1;
1890 dn.bv_val = cargv[1];
1891 dn.bv_len = strlen( cargv[1] );
1893 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1894 if( rc != LDAP_SUCCESS ) {
1896 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1897 "%s: line %d: updatedn DN is invalid.\n",
1900 Debug( LDAP_DEBUG_ANY,
1901 "%s: line %d: updatedn DN is invalid\n",
1908 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1911 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1912 "missing url in \"updateref <ldapurl>\" line.\n",
1915 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1916 "missing url in \"updateref <ldapurl>\" line\n",
1924 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1925 " line must appear inside a database definition\n",
1928 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1929 " line must appear inside a database definition\n",
1934 } else if ( !be->be_update_ndn.bv_len ) {
1936 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1937 "updateref line must come after updatedn.\n",
1940 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1941 "updateref line must after updatedn.\n",
1947 if( validate_global_referral( cargv[1] ) ) {
1949 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1950 "invalid URL (%s) in \"updateref\" line.\n",
1951 fname, lineno, cargv[1] ));
1953 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1954 "invalid URL (%s) in \"updateref\" line.\n",
1955 fname, lineno, cargv[1] );
1960 vals[0].bv_val = cargv[1];
1961 vals[0].bv_len = strlen( vals[0].bv_val );
1962 value_add( &be->be_update_refs, vals );
1964 /* replication log file to which changes are appended */
1965 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1968 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1969 "%s: line %d: missing filename in \"replogfile <filename>\""
1970 " line.\n", fname, lineno ));
1972 Debug( LDAP_DEBUG_ANY,
1973 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1980 be->be_replogfile = ch_strdup( cargv[1] );
1982 replogfile = ch_strdup( cargv[1] );
1985 /* file from which to read additional rootdse attrs */
1986 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1989 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1990 "missing filename in \"rootDSE <filename>\" line.\n",
1993 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1994 "missing filename in \"rootDSE <filename>\" line.\n",
2000 if( read_root_dse_file( cargv[1] ) ) {
2002 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2003 "could not read \"rootDSE <filename>\" line.\n",
2006 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2007 "could not read \"rootDSE <filename>\" line\n",
2013 /* maintain lastmodified{by,time} attributes */
2014 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2017 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2018 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2019 " line.\n", fname, lineno ));
2021 Debug( LDAP_DEBUG_ANY,
2022 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2028 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2030 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2036 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2042 /* set idle timeout value */
2043 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2047 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2048 "%s: line %d: missing timeout value in "
2049 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2051 Debug( LDAP_DEBUG_ANY,
2052 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2059 i = atoi( cargv[1] );
2063 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2064 "%s: line %d: timeout value (%d) invalid "
2065 "\"idletimeout <seconds>\" line.\n",
2066 fname, lineno, i ));
2068 Debug( LDAP_DEBUG_ANY,
2069 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2076 global_idletimeout = i;
2078 /* include another config file */
2079 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2082 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2083 "%s: line %d: missing filename in \"include "
2084 "<filename>\" line.\n", fname, lineno ));
2086 Debug( LDAP_DEBUG_ANY,
2087 "%s: line %d: missing filename in \"include <filename>\" line\n",
2093 savefname = ch_strdup( cargv[1] );
2094 savelineno = lineno;
2096 if ( read_config( savefname ) != 0 ) {
2101 lineno = savelineno - 1;
2103 /* location of kerberos srvtab file */
2104 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2107 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2108 "%s: line %d: missing filename in \"srvtab "
2109 "<filename>\" line.\n", fname, lineno ));
2111 Debug( LDAP_DEBUG_ANY,
2112 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2118 ldap_srvtab = ch_strdup( cargv[1] );
2120 #ifdef SLAPD_MODULES
2121 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2124 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2125 "%s: line %d: missing filename in \"moduleload "
2126 "<filename>\" line.\n", fname, lineno ));
2128 Debug( LDAP_DEBUG_ANY,
2129 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2133 exit( EXIT_FAILURE );
2135 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2137 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2138 "%s: line %d: failed to load or initialize module %s\n",
2139 fname, lineno, cargv[1] ));
2141 Debug( LDAP_DEBUG_ANY,
2142 "%s: line %d: failed to load or initialize module %s\n",
2143 fname, lineno, cargv[1]);
2146 exit( EXIT_FAILURE );
2148 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2151 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2152 "%s: line %d: missing path in \"modulepath <path>\""
2153 " line\n", fname, lineno ));
2155 Debug( LDAP_DEBUG_ANY,
2156 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2160 exit( EXIT_FAILURE );
2162 if (module_path( cargv[1] )) {
2164 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2165 "%s: line %d: failed to set module search path to %s.\n",
2166 fname, lineno, cargv[1] ));
2168 Debug( LDAP_DEBUG_ANY,
2169 "%s: line %d: failed to set module search path to %s\n",
2170 fname, lineno, cargv[1]);
2173 exit( EXIT_FAILURE );
2176 #endif /*SLAPD_MODULES*/
2179 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2180 rc = ldap_pvt_tls_set_option( NULL,
2181 LDAP_OPT_X_TLS_RANDOM_FILE,
2186 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2187 rc = ldap_pvt_tls_set_option( NULL,
2188 LDAP_OPT_X_TLS_CIPHER_SUITE,
2193 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2194 rc = ldap_pvt_tls_set_option( NULL,
2195 LDAP_OPT_X_TLS_CERTFILE,
2200 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2201 rc = ldap_pvt_tls_set_option( NULL,
2202 LDAP_OPT_X_TLS_KEYFILE,
2207 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2208 rc = ldap_pvt_tls_set_option( NULL,
2209 LDAP_OPT_X_TLS_CACERTDIR,
2214 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2215 rc = ldap_pvt_tls_set_option( NULL,
2216 LDAP_OPT_X_TLS_CACERTFILE,
2220 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2221 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2223 rc = ldap_pvt_tls_set_option( NULL,
2224 LDAP_OPT_X_TLS_REQUIRE_CERT,
2227 rc = ldap_int_tls_config( NULL,
2228 LDAP_OPT_X_TLS_REQUIRE_CERT,
2237 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2238 #ifdef SLAPD_RLOOKUPS
2241 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2242 "%s: line %d: reverse-lookup: "
2243 "missing \"on\" or \"off\"\n",
2246 Debug( LDAP_DEBUG_ANY,
2247 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2253 if ( !strcasecmp( cargv[1], "on" ) ) {
2254 use_reverse_lookup = 1;
2255 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2256 use_reverse_lookup = 0;
2259 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2260 "%s: line %d: reverse-lookup: "
2261 "must be \"on\" (default) "
2265 Debug( LDAP_DEBUG_ANY,
2266 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2272 #else /* !SLAPD_RLOOKUPS */
2274 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2275 "%s: line %d: reverse lookups "
2276 "are not configured (ignored).\n",
2279 Debug( LDAP_DEBUG_ANY,
2280 "%s: line %d: reverse lookups are not configured (ignored).\n",
2283 #endif /* !SLAPD_RLOOKUPS */
2285 /* pass anything else to the current backend info/db config routine */
2288 if ( bi->bi_config == 0 ) {
2290 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2291 "%s: line %d: unknown directive \"%s\" inside "
2292 "backend info definition (ignored).\n",
2293 fname, lineno, cargv[0] ));
2295 Debug( LDAP_DEBUG_ANY,
2296 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2297 fname, lineno, cargv[0] );
2301 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2307 } else if ( be != NULL ) {
2308 if ( be->be_config == 0 ) {
2310 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2311 "%s: line %d: uknown directive \"%s\" inside "
2312 "backend database definition (ignored).\n",
2313 fname, lineno, cargv[0] ));
2315 Debug( LDAP_DEBUG_ANY,
2316 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2317 fname, lineno, cargv[0] );
2321 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2329 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2330 "%s: line %d: unknown directive \"%s\" outside backend "
2331 "info and database definitions (ignored).\n",
2332 fname, lineno, cargv[0] ));
2334 Debug( LDAP_DEBUG_ANY,
2335 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2336 fname, lineno, cargv[0] );
2345 if ( load_ucdata( NULL ) < 0 ) return 1;
2361 token = strtok_quote( line, " \t" );
2363 logline = (!token || strcasecmp(token, "rootpw") ? line : "rootpw *");
2365 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2366 "line %d (%s)\n", lineno, logline ));
2368 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2371 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2372 if ( *argcp == MAXARGS ) {
2374 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2375 "fp_parse_line: too many tokens (%d max).\n",
2378 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2384 argv[(*argcp)++] = token;
2386 argv[*argcp] = NULL;
2391 strtok_quote( char *line, char *sep )
2397 if ( line != NULL ) {
2400 while ( *next && strchr( sep, *next ) ) {
2404 if ( *next == '\0' ) {
2410 for ( inquote = 0; *next; ) {
2418 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2424 next + 1, strlen( next + 1 ) + 1 );
2425 next++; /* dont parse the escaped character */
2430 if ( strchr( sep, *next ) != NULL ) {
2443 static char buf[BUFSIZ];
2445 static int lmax, lcur;
2447 #define CATLINE( buf ) { \
2449 len = strlen( buf ); \
2450 while ( lcur + len + 1 > lmax ) { \
2452 line = (char *) ch_realloc( line, lmax ); \
2454 strcpy( line + lcur, buf ); \
2459 fp_getline( FILE *fp, int *lineno )
2467 /* hack attack - keeps us from having to keep a stack of bufs... */
2468 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2473 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2474 /* trim off \r\n or \n */
2475 if ( (p = strchr( buf, '\n' )) != NULL ) {
2476 if( p > buf && p[-1] == '\r' ) --p;
2480 /* trim off trailing \ and append the next line */
2481 if ( line[ 0 ] != '\0'
2482 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2483 && p[ -1 ] != '\\' ) {
2488 if ( ! isspace( (unsigned char) buf[0] ) ) {
2492 /* change leading whitespace to a space */
2501 return( line[0] ? line : NULL );
2505 fp_getline_init( int *lineno )
2511 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2513 load_ucdata( char *path )
2515 static int loaded = 0;
2521 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2524 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2525 "load_ucdata: Error %d loading ucdata.\n", err ));
2527 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2540 ucdata_unload( UCDATA_ALL );
2542 if ( slapd_args_file )
2543 free ( slapd_args_file );
2544 if ( slapd_pid_file )
2545 free ( slapd_pid_file );
2546 acl_destroy( global_acl, NULL );