1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2000 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_lastmod = ON;
44 int global_idletimeout = 0;
45 char *global_host = NULL;
46 char *global_realm = NULL;
47 char *ldap_srvtab = "";
48 char *default_passwd_hash;
49 char *default_search_base = NULL;
50 char *default_search_nbase = NULL;
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];
81 static BackendInfo *bi = NULL;
82 static BackendDB *be = NULL;
87 if ( (fp = fopen( fname, "r" )) == NULL ) {
90 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
91 "could not open config file \"%s\": %s (%d)\n",
92 fname, strerror(errno), errno ));
94 Debug( LDAP_DEBUG_ANY,
95 "could not open config file \"%s\": %s (%d)\n",
96 fname, strerror(errno), errno );
102 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
103 "read_config: reading config file %s\n", fname ));
105 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
109 fp_getline_init( &lineno );
111 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
112 /* skip comments and blank lines */
113 if ( line[0] == '#' || line[0] == '\0' ) {
118 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
119 "line %d (%s)\n", lineno, line ));
121 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
125 /* fp_parse_line is destructive, we save a copy */
126 saveline = ch_strdup( line );
128 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
134 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
135 "%s: line %d: bad config line (ignored)\n",
138 Debug( LDAP_DEBUG_ANY,
139 "%s: line %d: bad config line (ignored)\n",
146 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
149 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
150 "%s : line %d: missing type in \"backend\" line.\n",
153 Debug( LDAP_DEBUG_ANY,
154 "%s: line %d: missing type in \"backend <type>\" line\n",
163 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
164 "%s: line %d: backend line must appear before any "
165 "database definition.\n", fname, lineno ));
167 Debug( LDAP_DEBUG_ANY,
168 "%s: line %d: backend line must appear before any database definition\n",
175 bi = backend_info( cargv[1] );
179 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
180 "read_config: backend %s initialization failed.\n",
183 Debug( LDAP_DEBUG_ANY,
184 "backend %s initialization failed.\n",
190 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
193 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
194 "%s: line %d: missing type in \"database <type>\" line\n",
197 Debug( LDAP_DEBUG_ANY,
198 "%s: line %d: missing type in \"database <type>\" line\n",
206 be = backend_db_init( cargv[1] );
210 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
211 "database %s initialization failed.\n",
214 Debug( LDAP_DEBUG_ANY,
215 "database %s initialization failed.\n",
222 /* set thread concurrency */
223 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
227 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
228 "%s: line %d: missing level in \"concurrency <level\" line\n",
231 Debug( LDAP_DEBUG_ANY,
232 "%s: line %d: missing level in \"concurrency <level>\" line\n",
239 c = atoi( cargv[1] );
243 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
244 "%s: line %d: invalid level (%d) in "
245 "\"concurrency <level>\" line.\n",
248 Debug( LDAP_DEBUG_ANY,
249 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
256 ldap_pvt_thread_set_concurrency( c );
258 /* set sockbuf max */
259 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
263 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
264 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
267 Debug( LDAP_DEBUG_ANY,
268 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
275 max = atol( cargv[1] );
279 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
280 "%s: line %d: invalid max value (%ld) in "
281 "\"sockbuf_max_incoming <bytes>\" line.\n",
282 fname, lineno, max ));
284 Debug( LDAP_DEBUG_ANY,
285 "%s: line %d: invalid max value (%ld) in "
286 "\"sockbuf_max_incoming <bytes>\" line.\n",
287 fname, lineno, max );
293 sockbuf_max_incoming = max;
295 /* set sockbuf max authenticated */
296 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
300 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
301 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
304 Debug( LDAP_DEBUG_ANY,
305 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
312 max = atol( cargv[1] );
316 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
317 "%s: line %d: invalid max value (%ld) in "
318 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
319 fname, lineno, max ));
321 Debug( LDAP_DEBUG_ANY,
322 "%s: line %d: invalid max value (%ld) in "
323 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
324 fname, lineno, max );
330 sockbuf_max_incoming_auth = max;
332 /* default search base */
333 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
336 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
337 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
338 "line\n", fname, lineno ));
340 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
341 "missing dn in \"defaultSearchBase <dn>\" line\n",
347 } else if ( cargc > 2 ) {
349 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
350 "%s: line %d: extra cruft after <dn> in "
351 "\"defaultSearchBase %s\" line (ignored)\n",
352 fname, lineno, cargv[1] ));
354 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
355 "extra cruft after <dn> in \"defaultSearchBase %s\", "
357 fname, lineno, cargv[1] );
362 if ( bi != NULL || be != NULL ) {
364 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
365 "%s: line %d: defaultSearchBase line must appear "
366 "prior to any backend or database definitions\n",
369 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
370 "defaultSearchBaase line must appear prior to "
371 "any backend or database definition\n",
378 if ( default_search_nbase != NULL ) {
380 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
381 "%s: line %d: default search base \"%s\" already defined "
382 "(discarding old)\n", fname, lineno, default_search_base ));
384 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
385 "default search base \"%s\" already defined "
386 "(discarding old)\n",
387 fname, lineno, default_search_base );
390 free( default_search_base );
391 free( default_search_nbase );
394 default_search_base = ch_strdup( cargv[1] );
395 default_search_nbase = ch_strdup( cargv[1] );
397 if ( load_ucdata( NULL ) < 0 ) {
400 if( dn_normalize( default_search_nbase ) == NULL ) {
402 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
403 "%s: %d: invalid default search base \"%s\"\n",
404 fname, lineno, default_search_base ));
406 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
407 "invalid default search base \"%s\"\n",
408 fname, lineno, default_search_base );
414 /* set maximum threads in thread pool */
415 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
419 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
420 "%s: line %d: missing count in \"threads <count>\" line\n",
423 Debug( LDAP_DEBUG_ANY,
424 "%s: line %d: missing count in \"threads <count>\" line\n",
431 c = atoi( cargv[1] );
435 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
436 "%s: line %d: invalid level (%d) in \"threads <count>\""
437 "line\n",fname, lineno, c ));
439 Debug( LDAP_DEBUG_ANY,
440 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
447 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
449 /* get pid file name */
450 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
453 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
454 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
457 Debug( LDAP_DEBUG_ANY,
458 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
465 slapd_pid_file = ch_strdup( cargv[1] );
467 /* get args file name */
468 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
471 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
472 "%s: %d: missing file name in "
473 "\"argsfile <file>\" line.\n",
476 Debug( LDAP_DEBUG_ANY,
477 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
484 slapd_args_file = ch_strdup( cargv[1] );
486 /* default password hash */
487 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
490 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
491 "%s: line %d: missing hash in "
492 "\"password-hash <hash>\" line.\n",
495 Debug( LDAP_DEBUG_ANY,
496 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
502 if ( default_passwd_hash != NULL ) {
504 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
505 "%s: line %d: already set default password_hash!\n",
508 Debug( LDAP_DEBUG_ANY,
509 "%s: line %d: already set default password_hash!\n",
516 default_passwd_hash = ch_strdup( cargv[1] );
519 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
523 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
524 "%s: line %d: missing format in "
525 "\"password-crypt-salt-format <format>\" line\n",
528 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
529 "\"password-crypt-salt-format <format>\" line\n",
536 lutil_salt_format( cargv[1] );
539 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
542 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
543 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
546 Debug( LDAP_DEBUG_ANY,
547 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
554 if ( global_host != NULL ) {
556 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
557 "%s: line %d: already set sasl-host!\n",
560 Debug( LDAP_DEBUG_ANY,
561 "%s: line %d: already set sasl-host!\n",
568 global_host = ch_strdup( cargv[1] );
572 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
575 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
576 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
579 Debug( LDAP_DEBUG_ANY,
580 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
587 if ( global_realm != NULL ) {
589 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
590 "%s: line %d: already set sasl-realm!\n",
593 Debug( LDAP_DEBUG_ANY,
594 "%s: line %d: already set sasl-realm!\n",
601 global_realm = ch_strdup( cargv[1] );
604 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
605 || !strcasecmp( cargv[0], "saslregexp" ) )
610 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
611 "%s: line %d: need 2 args in "
612 "\"saslregexp <match> <replace>\"\n",
615 Debug( LDAP_DEBUG_ANY,
616 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
622 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
627 /* SASL security properties */
628 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
633 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
634 "%s: line %d: missing flags in "
635 "\"sasl-secprops <properties>\" line\n",
638 Debug( LDAP_DEBUG_ANY,
639 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
646 txt = slap_sasl_secprops( cargv[1] );
649 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
650 "%s: line %d sas-secprops: %s\n",
651 fname, lineno, txt ));
653 Debug( LDAP_DEBUG_ANY,
654 "%s: line %d: sasl-secprops: %s\n",
655 fname, lineno, txt );
661 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
662 sasl_external_x509dn_convert++;
664 /* set UCDATA path */
665 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
669 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
670 "%s: line %d: missing path in "
671 "\"ucdata-path <path>\" line.\n",
674 Debug( LDAP_DEBUG_ANY,
675 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
682 err = load_ucdata( cargv[1] );
686 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
687 "%s: line %d: ucdata already loaded, ucdata-path "
688 "must be set earlier in the file and/or be "
689 "specified only once!\n",
692 Debug( LDAP_DEBUG_ANY,
693 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
702 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
704 struct slap_limits_set *lim;
708 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
709 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
712 Debug( LDAP_DEBUG_ANY,
713 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
723 lim = &be->be_def_limit;
726 for ( i = 1; i < cargc; i++ ) {
727 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
728 rc = parse_limit( cargv[i], lim );
730 lim->lms_s_soft = atoi( cargv[i] );
736 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
737 "%s: line %d: unable "
738 "to parse value \"%s\" "
741 fname, lineno, cargv[i] ));
743 Debug( LDAP_DEBUG_ANY,
744 "%s: line %d: unable "
745 "to parse value \"%s\" "
748 fname, lineno, cargv[i] );
754 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
756 struct slap_limits_set *lim;
760 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
761 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
764 Debug( LDAP_DEBUG_ANY,
765 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
775 lim = &be->be_def_limit;
778 for ( i = 1; i < cargc; i++ ) {
779 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
780 rc = parse_limit( cargv[i], lim );
782 lim->lms_t_soft = atoi( cargv[i] );
788 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
789 "%s: line %d: unable "
790 "to parse value \"%s\" "
793 fname, lineno, cargv[i] ));
795 Debug( LDAP_DEBUG_ANY,
796 "%s: line %d: unable "
797 "to parse value \"%s\" "
800 fname, lineno, cargv[i] );
805 /* set regex-based limits */
806 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
809 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
810 "%s: line %d \"limits\" allowed only in database environment.\n",
813 Debug( LDAP_DEBUG_ANY,
814 "%s: line %d \"limits\" allowed only in database environment.\n%s",
820 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
824 /* set database suffix */
825 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
829 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
830 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
833 Debug( LDAP_DEBUG_ANY,
834 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
839 } else if ( cargc > 2 ) {
841 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
842 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
843 " line (ignored).\n", fname, lineno, cargv[1] ));
845 Debug( LDAP_DEBUG_ANY,
846 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
847 fname, lineno, cargv[1] );
853 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
854 "%s: line %d: suffix line must appear inside a database "
855 "definition (ignored).\n", fname, lineno ));
857 Debug( LDAP_DEBUG_ANY,
858 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
862 #if defined(SLAPD_MONITOR_DN)
863 /* "cn=Monitor" is reserved for monitoring slap */
864 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
866 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
867 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
868 fname, lineno, SLAPD_MONITOR_DN ));
870 Debug( LDAP_DEBUG_ANY,
871 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
872 fname, lineno, SLAPD_MONITOR_DN );
875 #endif /* SLAPD_MONITOR_DN */
877 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
879 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
880 "%s: line %d: suffix already served by this backend "
881 "(ignored)\n", fname, lineno ));
883 Debug( LDAP_DEBUG_ANY,
884 "%s: line %d: suffix already served by this backend (ignored)\n",
888 } else if ( tmp_be != NULL ) {
890 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
891 "%s: line %d: suffix already served by a preceding "
892 "backend \"%s\" (ignored)\n", fname, lineno,
893 tmp_be->be_suffix[0] ));
895 Debug( LDAP_DEBUG_ANY,
896 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
897 fname, lineno, tmp_be->be_suffix[0] );
901 char *dn = ch_strdup( cargv[1] );
903 if ( load_ucdata( NULL ) < 0 ) {
906 if( dn_validate( dn ) == NULL ) {
908 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
909 "%s: line %d: suffix DN invalid\"%s\"\n",
910 fname, lineno, cargv[1] ));
912 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
913 "suffix DN invalid \"%s\"\n",
914 fname, lineno, cargv[1] );
919 } else if( *dn == '\0' && default_search_nbase != NULL ) {
921 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
922 "%s: line %d: suffix DN empty and default search "
923 "base provided \"%s\" (assuming okay).\n",
924 fname, lineno, default_search_base ));
926 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
927 "suffix DN empty and default "
928 "search base provided \"%s\" (assuming okay)\n",
929 fname, lineno, default_search_base );
933 charray_add( &be->be_suffix, dn );
934 #ifndef USE_LDAP_DN_PARSING
935 (void) ldap_pvt_str2upper( dn );
936 #else /* USE_LDAP_DN_PARSING */
937 if ( dn_normalize( dn ) == NULL ) {
939 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
941 "unable to normalize suffix "
944 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
945 "unable to normalize suffix "
946 "\"%s\"\n", dn, NULL, NULL );
950 #endif /* USE_LDAP_DN_PARSING */
951 ber_bvecadd( &be->be_nsuffix, ber_bvstr( dn ));
954 /* set database suffixAlias */
955 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
959 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
960 "%s: line %d: missing alias and aliased_dn in "
961 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
964 Debug( LDAP_DEBUG_ANY,
965 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
970 } else if ( cargc < 3 ) {
972 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
973 "%s: line %d: missing aliased_dn in "
974 "\"suffixAlias <alias> <aliased_dn>\" line\n",
977 Debug( LDAP_DEBUG_ANY,
978 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
983 } else if ( cargc > 3 ) {
985 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
986 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
989 Debug( LDAP_DEBUG_ANY,
990 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
998 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
999 "%s: line %d: suffixAlias line must appear inside a "
1000 "database definition (ignored).\n", fname, lineno ));
1002 Debug( LDAP_DEBUG_ANY,
1003 "%s: line %d: suffixAlias line"
1004 " must appear inside a database definition (ignored)\n",
1008 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
1010 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1011 "%s: line %d: suffixAlias served by a preceeding "
1012 "backend \"%s\" (ignored).\n", fname, lineno,
1013 tmp_be->be_suffix[0] ));
1015 Debug( LDAP_DEBUG_ANY,
1016 "%s: line %d: suffixAlias served by"
1017 " a preceeding backend \"%s\" (ignored)\n",
1018 fname, lineno, tmp_be->be_suffix[0] );
1022 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
1024 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1025 "%s: line %d: suffixAlias derefs to a different backend "
1026 "a preceeding backend \"%s\" (ignored)\n",
1027 fname, lineno, tmp_be->be_suffix[0] ));
1029 Debug( LDAP_DEBUG_ANY,
1030 "%s: line %d: suffixAlias derefs to differnet backend"
1031 " a preceeding backend \"%s\" (ignored)\n",
1032 fname, lineno, tmp_be->be_suffix[0] );
1037 char *alias, *aliased_dn;
1039 alias = ch_strdup( cargv[1] );
1040 if ( load_ucdata( NULL ) < 0 ) {
1043 (void) dn_normalize( alias );
1045 aliased_dn = ch_strdup( cargv[2] );
1046 (void) dn_normalize( aliased_dn );
1048 ber_bvecadd( &be->be_suffixAlias,
1049 ber_bvstr( alias ) );
1050 ber_bvecadd( &be->be_suffixAlias,
1051 ber_bvstr( aliased_dn ) );
1054 /* set max deref depth */
1055 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1059 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1060 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1061 " line\n", fname, lineno ));
1063 Debug( LDAP_DEBUG_ANY,
1064 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1072 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1073 "%s: line %d: depth line must appear inside a database "
1074 "definition (ignored)\n", fname, lineno ));
1076 Debug( LDAP_DEBUG_ANY,
1077 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1081 } else if ((i = atoi(cargv[1])) < 0) {
1083 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1084 "%s: line %d: depth must be positive (ignored).\n",
1087 Debug( LDAP_DEBUG_ANY,
1088 "%s: line %d: depth must be positive (ignored)\n",
1094 be->be_max_deref_depth = i;
1098 /* set magic "root" dn for this database */
1099 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1102 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1103 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1106 Debug( LDAP_DEBUG_ANY,
1107 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1115 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1116 "%s: line %d: rootdn line must appear inside a database "
1117 "definition (ignored).\n", fname, lineno ));
1119 Debug( LDAP_DEBUG_ANY,
1120 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1125 be->be_root_dn = ch_strdup( cargv[1] );
1126 be->be_root_ndn = ch_strdup( cargv[1] );
1128 if ( load_ucdata( NULL ) < 0 ) {
1131 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1132 free( be->be_root_dn );
1133 free( be->be_root_ndn );
1135 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1136 "%s: line %d: rootdn DN is invalid.\n",
1139 Debug( LDAP_DEBUG_ANY,
1140 "%s: line %d: rootdn DN is invalid\n",
1148 /* set super-secret magic database password */
1149 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1152 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1153 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1154 " line\n", fname, lineno ));
1156 Debug( LDAP_DEBUG_ANY,
1157 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1165 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1166 "%s: line %d: rootpw line must appear inside a database "
1167 "definition (ignored)\n", fname, lineno ));
1169 Debug( LDAP_DEBUG_ANY,
1170 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1175 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1176 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1179 /* make this database read-only */
1180 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1183 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1184 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1187 Debug( LDAP_DEBUG_ANY,
1188 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1195 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1196 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1198 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1201 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1202 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1204 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1209 /* allow these features */
1210 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1211 strcasecmp( cargv[0], "allow" ) == 0 )
1217 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1218 "%s: line %d: allow line must appear prior to "
1219 "database definitions.\n", fname, lineno ));
1221 Debug( LDAP_DEBUG_ANY,
1222 "%s: line %d: allow line must appear prior to database definitions\n",
1230 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1231 "%s: line %d: missing feature(s) in \"allow <features>\""
1232 " line\n", fname, lineno ));
1234 Debug( LDAP_DEBUG_ANY,
1235 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1244 for( i=1; i < cargc; i++ ) {
1245 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1246 allows |= SLAP_ALLOW_TLS_2_ANON;
1248 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1250 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1251 "%s: line %d: unknown feature %s in "
1252 "\"allow <features>\" line.\n",
1253 fname, lineno, cargv[1] ));
1255 Debug( LDAP_DEBUG_ANY,
1256 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1257 fname, lineno, cargv[i] );
1264 global_allows = allows;
1266 /* disallow these features */
1267 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1268 strcasecmp( cargv[0], "disallow" ) == 0 )
1270 slap_mask_t disallows;
1274 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1275 "%s: line %d: disallow line must appear prior to "
1276 "database definitions.\n", fname, lineno ));
1278 Debug( LDAP_DEBUG_ANY,
1279 "%s: line %d: disallow line must appear prior to database definitions\n",
1287 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1288 "%s: line %d: missing feature(s) in \"disallow <features>\""
1289 " line.\n", fname, lineno ));
1291 Debug( LDAP_DEBUG_ANY,
1292 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1301 for( i=1; i < cargc; i++ ) {
1302 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1303 disallows |= SLAP_DISALLOW_BIND_V2;
1305 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1306 disallows |= SLAP_DISALLOW_BIND_ANON;
1308 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1309 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1311 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1312 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1314 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1315 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1317 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1318 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1320 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1321 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1323 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1325 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1326 "%s: line %d: unknown feature %s in "
1327 "\"disallow <features>\" line.\n",
1328 fname, lineno, cargv[i] ));
1330 Debug( LDAP_DEBUG_ANY,
1331 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1332 fname, lineno, cargv[i] );
1339 global_disallows = disallows;
1341 /* require these features */
1342 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1343 strcasecmp( cargv[0], "require" ) == 0 )
1345 slap_mask_t requires;
1349 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1350 "%s: line %d: missing feature(s) in "
1351 "\"require <features>\" line.\n", fname, lineno ));
1353 Debug( LDAP_DEBUG_ANY,
1354 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1363 for( i=1; i < cargc; i++ ) {
1364 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1365 requires |= SLAP_REQUIRE_BIND;
1367 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1368 requires |= SLAP_REQUIRE_LDAP_V3;
1370 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1371 requires |= SLAP_REQUIRE_AUTHC;
1373 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1374 requires |= SLAP_REQUIRE_SASL;
1376 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1377 requires |= SLAP_REQUIRE_STRONG;
1379 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1381 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1382 "%s: line %d: unknown feature %s in "
1383 "\"require <features>\" line.\n",
1386 Debug( LDAP_DEBUG_ANY,
1387 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1388 fname, lineno, cargv[i] );
1396 global_requires = requires;
1398 be->be_requires = requires;
1401 /* required security factors */
1402 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1403 slap_ssf_set_t *set;
1407 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1408 "%s: line %d: missing factor(s) in \"security <factors>\""
1409 " line.\n", fname, lineno ));
1411 Debug( LDAP_DEBUG_ANY,
1412 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1420 set = &global_ssf_set;
1422 set = &be->be_ssf_set;
1425 for( i=1; i < cargc; i++ ) {
1426 if( strncasecmp( cargv[i], "ssf=",
1427 sizeof("ssf") ) == 0 )
1430 atoi( &cargv[i][sizeof("ssf")] );
1432 } else if( strncasecmp( cargv[i], "transport=",
1433 sizeof("transport") ) == 0 )
1435 set->sss_transport =
1436 atoi( &cargv[i][sizeof("transport")] );
1438 } else if( strncasecmp( cargv[i], "tls=",
1439 sizeof("tls") ) == 0 )
1442 atoi( &cargv[i][sizeof("tls")] );
1444 } else if( strncasecmp( cargv[i], "sasl=",
1445 sizeof("sasl") ) == 0 )
1448 atoi( &cargv[i][sizeof("sasl")] );
1450 } else if( strncasecmp( cargv[i], "update_ssf=",
1451 sizeof("update_ssf") ) == 0 )
1453 set->sss_update_ssf =
1454 atoi( &cargv[i][sizeof("update_ssf")] );
1456 } else if( strncasecmp( cargv[i], "update_transport=",
1457 sizeof("update_transport") ) == 0 )
1459 set->sss_update_transport =
1460 atoi( &cargv[i][sizeof("update_transport")] );
1462 } else if( strncasecmp( cargv[i], "update_tls=",
1463 sizeof("update_tls") ) == 0 )
1465 set->sss_update_tls =
1466 atoi( &cargv[i][sizeof("update_tls")] );
1468 } else if( strncasecmp( cargv[i], "update_sasl=",
1469 sizeof("update_sasl") ) == 0 )
1471 set->sss_update_sasl =
1472 atoi( &cargv[i][sizeof("update_sasl")] );
1476 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1477 "%s: line %d: unknown factor %S in "
1478 "\"security <factors>\" line.\n",
1479 fname, lineno, cargv[1] ));
1481 Debug( LDAP_DEBUG_ANY,
1482 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1483 fname, lineno, cargv[i] );
1489 /* where to send clients when we don't hold it */
1490 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1493 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1494 "%s: line %d: missing URL in \"referral <URL>\""
1495 " line.\n", fname, lineno ));
1497 Debug( LDAP_DEBUG_ANY,
1498 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1505 if( validate_global_referral( cargv[1] ) ) {
1507 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1508 "invalid URL (%s) in \"referral\" line.\n",
1509 fname, lineno, cargv[1] ));
1511 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1512 "invalid URL (%s) in \"referral\" line.\n",
1513 fname, lineno, cargv[1] );
1518 vals[0]->bv_val = cargv[1];
1519 vals[0]->bv_len = strlen( vals[0]->bv_val );
1520 value_add( &default_referral, vals );
1523 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1527 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1528 "%s: line %d: Error in logfile directive, "
1529 "\"logfile <filename>\"\n", fname, lineno ));
1531 Debug( LDAP_DEBUG_ANY,
1532 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1538 logfile = fopen( cargv[1], "w" );
1539 if ( logfile != NULL ) lutil_debug_file( logfile );
1542 /* start of a new database definition */
1543 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1547 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1548 "%s: line %d: Error in debug directive, "
1549 "\"debug <subsys> <level>\"\n", fname, lineno ));
1551 Debug( LDAP_DEBUG_ANY,
1552 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1558 level = atoi( cargv[2] );
1559 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1560 lutil_set_debug_level( cargv[1], level );
1561 /* specify an Object Identifier macro */
1562 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1563 rc = parse_oidm( fname, lineno, cargc, cargv );
1566 /* specify an objectclass */
1567 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1568 if ( *cargv[1] == '(' ) {
1570 p = strchr(saveline,'(');
1571 rc = parse_oc( fname, lineno, p, cargv );
1576 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1577 "%s: line %d: old objectclass format not supported\n",
1580 Debug( LDAP_DEBUG_ANY,
1581 "%s: line %d: old objectclass format not supported.\n",
1587 /* specify an attribute type */
1588 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1589 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1591 if ( *cargv[1] == '(' ) {
1593 p = strchr(saveline,'(');
1594 rc = parse_at( fname, lineno, p, cargv );
1599 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1600 "%s: line %d: old attribute type format not supported.\n",
1603 Debug( LDAP_DEBUG_ANY,
1604 "%s: line %d: old attribute type format not supported.\n",
1610 /* turn on/off schema checking */
1611 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1614 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1615 "%s: line %d: missing on|off in "
1616 "\"schemacheck <on|off>\" line.\n",
1619 Debug( LDAP_DEBUG_ANY,
1620 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1626 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1627 global_schemacheck = 0;
1629 global_schemacheck = 1;
1632 /* specify access control info */
1633 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1634 parse_acl( be, fname, lineno, cargc, cargv );
1636 /* debug level to log things to syslog */
1637 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1640 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1641 "%s: line %d: missing level in \"loglevel <level>\""
1642 " line.\n", fname, lineno ));
1644 Debug( LDAP_DEBUG_ANY,
1645 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1654 for( i=1; i < cargc; i++ ) {
1655 ldap_syslog += atoi( cargv[1] );
1658 /* list of replicas of the data in this backend (master only) */
1659 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1662 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1663 "%s: line %d: missing host in \"replica "
1664 " <host[:port]\" line\n", fname, lineno ));
1666 Debug( LDAP_DEBUG_ANY,
1667 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1675 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1676 "%s: line %d: replica line must appear inside "
1677 "a database definition (ignored).\n", fname, lineno ));
1679 Debug( LDAP_DEBUG_ANY,
1680 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1687 for ( i = 1; i < cargc; i++ ) {
1688 if ( strncasecmp( cargv[i], "host=", 5 )
1690 nr = add_replica_info( be,
1697 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1698 "%s: line %d: missing host in \"replica\" "
1699 "line (ignored)\n", fname, lineno ));
1701 Debug( LDAP_DEBUG_ANY,
1702 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1706 } else if ( nr == -1 ) {
1708 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1709 "%s: line %d: unable to add"
1715 Debug( LDAP_DEBUG_ANY,
1716 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1717 fname, lineno, cargv[i] + 5 );
1720 for ( i = 1; i < cargc; i++ ) {
1721 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1723 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1726 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1727 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1728 fname, lineno, cargv[i] + 7 ));
1730 Debug( LDAP_DEBUG_ANY,
1731 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1732 fname, lineno, cargv[i] + 7 );
1738 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1739 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1742 Debug( LDAP_DEBUG_ANY,
1743 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1753 /* dn of master entity allowed to write to replica */
1754 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1757 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1758 "%s: line %d: missing dn in \"updatedn <dn>\""
1759 " line.\n", fname, lineno ));
1761 Debug( LDAP_DEBUG_ANY,
1762 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1770 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1771 "%s: line %d: updatedn line must appear inside "
1772 "a database definition (ignored)\n",
1775 Debug( LDAP_DEBUG_ANY,
1776 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1781 be->be_update_ndn = ch_strdup( cargv[1] );
1782 if ( load_ucdata( NULL ) < 0 ) {
1785 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1787 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1788 "%s: line %d: updatedn DN is invalid.\n",
1791 Debug( LDAP_DEBUG_ANY,
1792 "%s: line %d: updatedn DN is invalid\n",
1800 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1803 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1804 "missing url in \"updateref <ldapurl>\" line.\n",
1807 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1808 "missing url in \"updateref <ldapurl>\" line\n",
1816 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1817 "updateref line must appear inside a database definition "
1818 "(ignored)\n", fname, lineno ));
1820 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1821 "updateref line must appear inside a database definition "
1822 "(ignored)\n", fname, lineno, 0 );
1826 } else if ( be->be_update_ndn == NULL ) {
1828 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1829 "updateref line must come after updatedn (ignored).\n",
1832 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1833 "updateref line must after updatedn (ignored)\n",
1839 if( validate_global_referral( cargv[1] ) ) {
1841 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1842 "invalid URL (%s) in \"updateref\" line.\n",
1843 fname, lineno, cargv[1] ));
1845 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1846 "invalid URL (%s) in \"updateref\" line.\n",
1847 fname, lineno, cargv[1] );
1852 vals[0]->bv_val = cargv[1];
1853 vals[0]->bv_len = strlen( vals[0]->bv_val );
1854 value_add( &be->be_update_refs, vals );
1856 /* replication log file to which changes are appended */
1857 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1860 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1861 "%s: line %d: missing filename in \"replogfile <filename>\""
1862 " line.\n", fname, lineno ));
1864 Debug( LDAP_DEBUG_ANY,
1865 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1872 be->be_replogfile = ch_strdup( cargv[1] );
1874 replogfile = ch_strdup( cargv[1] );
1877 /* file from which to read additional rootdse attrs */
1878 } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
1881 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1882 "missing filename in \"rootDSEfile <filename>\" line.\n",
1885 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1886 "missing filename in \"rootDSEfile <filename>\" line.\n",
1892 if( read_root_dse_file( cargv[1] ) ) {
1894 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1895 "could not read \"rootDSEfile <filename>\" line.\n",
1898 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1899 "could not read \"rootDSEfile <filename>\" line\n",
1905 /* maintain lastmodified{by,time} attributes */
1906 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1909 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1910 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1911 " line.\n", fname, lineno ));
1913 Debug( LDAP_DEBUG_ANY,
1914 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1920 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1922 be->be_lastmod = ON;
1924 global_lastmod = ON;
1927 be->be_lastmod = OFF;
1929 global_lastmod = OFF;
1932 /* set idle timeout value */
1933 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1937 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1938 "%s: line %d: missing timeout value in "
1939 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1941 Debug( LDAP_DEBUG_ANY,
1942 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1949 i = atoi( cargv[1] );
1953 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1954 "%s: line %d: timeout value (%d) invalid "
1955 "\"idletimeout <seconds>\" line.\n",
1956 fname, lineno, i ));
1958 Debug( LDAP_DEBUG_ANY,
1959 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1966 global_idletimeout = i;
1968 /* include another config file */
1969 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1972 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1973 "%s: line %d: missing filename in \"include "
1974 "<filename>\" line.\n", fname, lineno ));
1976 Debug( LDAP_DEBUG_ANY,
1977 "%s: line %d: missing filename in \"include <filename>\" line\n",
1983 savefname = ch_strdup( cargv[1] );
1984 savelineno = lineno;
1986 if ( read_config( savefname ) != 0 ) {
1991 lineno = savelineno - 1;
1993 /* location of kerberos srvtab file */
1994 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1997 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1998 "%s: line %d: missing filename in \"srvtab "
1999 "<filename>\" line.\n", fname, lineno ));
2001 Debug( LDAP_DEBUG_ANY,
2002 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2008 ldap_srvtab = ch_strdup( cargv[1] );
2010 #ifdef SLAPD_MODULES
2011 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2014 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2015 "%s: line %d: missing filename in \"moduleload "
2016 "<filename>\" line.\n", fname, lineno ));
2018 Debug( LDAP_DEBUG_ANY,
2019 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2023 exit( EXIT_FAILURE );
2025 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2027 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2028 "%s: line %d: failed to load or initialize module %s\n"<
2029 fname, lineno, cargv[1] ));
2031 Debug( LDAP_DEBUG_ANY,
2032 "%s: line %d: failed to load or initialize module %s\n",
2033 fname, lineno, cargv[1]);
2036 exit( EXIT_FAILURE );
2038 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2041 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2042 "%s: line %d: missing path in \"modulepath <path>\""
2043 " line\n", fname, lineno ));
2045 Debug( LDAP_DEBUG_ANY,
2046 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2050 exit( EXIT_FAILURE );
2052 if (module_path( cargv[1] )) {
2054 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2055 "%s: line %d: failed to set module search path to %s.\n",
2056 fname, lineno, cargv[1] ));
2058 Debug( LDAP_DEBUG_ANY,
2059 "%s: line %d: failed to set module search path to %s\n",
2060 fname, lineno, cargv[1]);
2063 exit( EXIT_FAILURE );
2066 #endif /*SLAPD_MODULES*/
2069 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2070 rc = ldap_pvt_tls_set_option( NULL,
2071 LDAP_OPT_X_TLS_RANDOM_FILE,
2076 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2077 rc = ldap_pvt_tls_set_option( NULL,
2078 LDAP_OPT_X_TLS_CIPHER_SUITE,
2083 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2084 rc = ldap_pvt_tls_set_option( NULL,
2085 LDAP_OPT_X_TLS_CERTFILE,
2090 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2091 rc = ldap_pvt_tls_set_option( NULL,
2092 LDAP_OPT_X_TLS_KEYFILE,
2097 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2098 rc = ldap_pvt_tls_set_option( NULL,
2099 LDAP_OPT_X_TLS_CACERTDIR,
2104 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2105 rc = ldap_pvt_tls_set_option( NULL,
2106 LDAP_OPT_X_TLS_CACERTFILE,
2110 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2112 rc = ldap_pvt_tls_set_option( NULL,
2113 LDAP_OPT_X_TLS_REQUIRE_CERT,
2120 /* pass anything else to the current backend info/db config routine */
2123 if ( bi->bi_config == 0 ) {
2125 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2126 "%s: line %d: unknown directive \"%s\" inside "
2127 "backend info definition (ignored).\n",
2128 fname, lineno, cargv[0] ));
2130 Debug( LDAP_DEBUG_ANY,
2131 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2132 fname, lineno, cargv[0] );
2136 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2142 } else if ( be != NULL ) {
2143 if ( be->be_config == 0 ) {
2145 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2146 "%s: line %d: uknown directive \"%s\" inside "
2147 "backend database definition (ignored).\n",
2148 fname, lineno, cargv[0] ));
2150 Debug( LDAP_DEBUG_ANY,
2151 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2152 fname, lineno, cargv[0] );
2156 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2164 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2165 "%s: line %d: unknown directive \"%s\" outside backend "
2166 "info and database definitions (ignored).\n",
2167 fname, lineno, cargv[0] ));
2169 Debug( LDAP_DEBUG_ANY,
2170 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2171 fname, lineno, cargv[0] );
2179 if ( load_ucdata( NULL ) < 0 ) {
2195 for ( token = strtok_quote( line, " \t" ); token != NULL;
2196 token = strtok_quote( NULL, " \t" ) ) {
2197 if ( *argcp == MAXARGS ) {
2199 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2200 "fp_parse_line: too many tokens (%d max).\n",
2203 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2209 argv[(*argcp)++] = token;
2211 argv[*argcp] = NULL;
2216 strtok_quote( char *line, char *sep )
2222 if ( line != NULL ) {
2225 while ( *next && strchr( sep, *next ) ) {
2229 if ( *next == '\0' ) {
2235 for ( inquote = 0; *next; ) {
2243 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2249 next + 1, strlen( next + 1 ) + 1 );
2250 next++; /* dont parse the escaped character */
2255 if ( strchr( sep, *next ) != NULL ) {
2268 static char buf[BUFSIZ];
2270 static int lmax, lcur;
2272 #define CATLINE( buf ) { \
2274 len = strlen( buf ); \
2275 while ( lcur + len + 1 > lmax ) { \
2277 line = (char *) ch_realloc( line, lmax ); \
2279 strcpy( line + lcur, buf ); \
2284 fp_getline( FILE *fp, int *lineno )
2292 /* hack attack - keeps us from having to keep a stack of bufs... */
2293 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2298 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2299 /* trim off \r\n or \n */
2300 if ( (p = strchr( buf, '\n' )) != NULL ) {
2301 if( p > buf && p[-1] == '\r' ) --p;
2304 if ( ! isspace( (unsigned char) buf[0] ) ) {
2308 /* change leading whitespace to a space */
2316 return( line[0] ? line : NULL );
2320 fp_getline_init( int *lineno )
2326 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2328 load_ucdata( char *path )
2330 static int loaded = 0;
2336 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2339 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2340 "load_ucdata: Error %d loading ucdata.\n", err ));
2342 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",