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>
23 * defaults for various global variables
25 struct slap_limits_set deflimit = {
26 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
29 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
31 -1 /* no limit on unchecked size */
34 AccessControl *global_acl = NULL;
35 slap_access_t global_default_access = ACL_READ;
36 slap_mask_t global_restrictops = 0;
37 slap_mask_t global_allows = 0;
38 slap_mask_t global_disallows = 0;
39 slap_mask_t global_requires = 0;
40 slap_ssf_set_t global_ssf_set;
42 int global_lastmod = ON;
43 int global_idletimeout = 0;
44 char *global_host = NULL;
45 char *global_realm = NULL;
46 char *ldap_srvtab = "";
47 char *default_passwd_hash;
48 char *default_search_base = NULL;
49 char *default_search_nbase = NULL;
51 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
52 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
54 char *slapd_pid_file = NULL;
55 char *slapd_args_file = NULL;
58 SaslRegexp_t *SaslRegexp = NULL;
59 int sasl_external_x509dn_convert;
61 static char *fp_getline(FILE *fp, int *lineno);
62 static void fp_getline_init(int *lineno);
63 static int fp_parse_line(char *line, int *argcp, char **argv);
65 static char *strtok_quote(char *line, char *sep);
66 static int load_ucdata(char *path);
69 read_config( const char *fname )
72 char *line, *savefname, *saveline;
73 int cargc, savelineno;
74 char *cargv[MAXARGS+1];
77 struct berval *vals[2];
80 static BackendInfo *bi = NULL;
81 static BackendDB *be = NULL;
86 if ( (fp = fopen( fname, "r" )) == NULL ) {
88 Debug( LDAP_DEBUG_ANY,
89 "could not open config file \"%s\" - absolute path?\n",
96 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
97 "read_config: reading config file %s\n", fname ));
99 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
103 fp_getline_init( &lineno );
105 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
106 /* skip comments and blank lines */
107 if ( line[0] == '#' || line[0] == '\0' ) {
112 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
113 "line %d (%s)\n", lineno, line ));
115 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
119 /* fp_parse_line is destructive, we save a copy */
120 saveline = ch_strdup( line );
122 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
128 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
129 "%s: line %d: bad config line (ignored)\n",
132 Debug( LDAP_DEBUG_ANY,
133 "%s: line %d: bad config line (ignored)\n",
140 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
143 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
144 "%s : line %d: missing type in \"backend\" line.\n",
147 Debug( LDAP_DEBUG_ANY,
148 "%s: line %d: missing type in \"backend <type>\" line\n",
157 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
158 "%s: line %d: backend line must appear before any "
159 "database definition.\n", fname, lineno ));
161 Debug( LDAP_DEBUG_ANY,
162 "%s: line %d: backend line must appear before any database definition\n",
169 bi = backend_info( cargv[1] );
173 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
174 "read_config: backend %s initialization failed.\n",
177 Debug( LDAP_DEBUG_ANY,
178 "backend %s initialization failed.\n",
184 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
187 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
188 "%s: line %d: missing type in \"database <type>\" line\n",
191 Debug( LDAP_DEBUG_ANY,
192 "%s: line %d: missing type in \"database <type>\" line\n",
200 be = backend_db_init( cargv[1] );
204 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
205 "database %s initialization failed.\n",
208 Debug( LDAP_DEBUG_ANY,
209 "database %s initialization failed.\n",
216 /* set thread concurrency */
217 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
221 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
222 "%s: line %d: missing level in \"concurrency <level\" line\n",
225 Debug( LDAP_DEBUG_ANY,
226 "%s: line %d: missing level in \"concurrency <level>\" line\n",
233 c = atoi( cargv[1] );
237 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
238 "%s: line %d: invalid level (%d) in "
239 "\"concurrency <level>\" line.\n",
242 Debug( LDAP_DEBUG_ANY,
243 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
250 ldap_pvt_thread_set_concurrency( c );
252 /* set sockbuf max */
253 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
257 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
258 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
261 Debug( LDAP_DEBUG_ANY,
262 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
269 max = atol( cargv[1] );
273 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
274 "%s: line %d: invalid max value (%ld) in "
275 "\"sockbuf_max_incoming <bytes>\" line.\n",
276 fname, lineno, max ));
278 Debug( LDAP_DEBUG_ANY,
279 "%s: line %d: invalid max value (%ld) in "
280 "\"sockbuf_max_incoming <bytes>\" line.\n",
281 fname, lineno, max );
287 sockbuf_max_incoming = max;
289 /* set sockbuf max authenticated */
290 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
294 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
295 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
298 Debug( LDAP_DEBUG_ANY,
299 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
306 max = atol( cargv[1] );
310 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
311 "%s: line %d: invalid max value (%ld) in "
312 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
313 fname, lineno, max ));
315 Debug( LDAP_DEBUG_ANY,
316 "%s: line %d: invalid max value (%ld) in "
317 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
318 fname, lineno, max );
324 sockbuf_max_incoming_auth = max;
326 /* default search base */
327 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
330 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
331 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
332 "line\n", fname, lineno ));
334 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
335 "missing dn in \"defaultSearchBase <dn>\" line\n",
341 } else if ( cargc > 2 ) {
343 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
344 "%s: line %d: extra cruft after <dn> in "
345 "\"defaultSearchBase %s\" line (ignored)\n",
346 fname, lineno, cargv[1] ));
348 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
349 "extra cruft after <dn> in \"defaultSearchBase %s\", "
351 fname, lineno, cargv[1] );
356 if ( bi != NULL || be != NULL ) {
358 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
359 "%s: line %d: defaultSearchBase line must appear "
360 "prior to any backend or database definitions\n",
363 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
364 "defaultSearchBaase line must appear prior to "
365 "any backend or database definition\n",
372 if ( default_search_nbase != NULL ) {
374 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
375 "%s: line %d: default search base \"%s\" already defined "
376 "(discarding old)\n", fname, lineno, default_search_base ));
378 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
379 "default search base \"%s\" already defined "
380 "(discarding old)\n",
381 fname, lineno, default_search_base );
384 free( default_search_base );
385 free( default_search_nbase );
388 default_search_base = ch_strdup( cargv[1] );
389 default_search_nbase = ch_strdup( cargv[1] );
391 if ( load_ucdata( NULL ) < 0 ) {
394 if( dn_normalize( default_search_nbase ) == NULL ) {
396 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
397 "%s: %d: invalid default search base \"%s\"\n",
398 fname, lineno, default_search_base ));
400 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
401 "invalid default search base \"%s\"\n",
402 fname, lineno, default_search_base );
408 /* set maximum threads in thread pool */
409 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
413 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
414 "%s: line %d: missing count in \"threads <count>\" line\n",
417 Debug( LDAP_DEBUG_ANY,
418 "%s: line %d: missing count in \"threads <count>\" line\n",
425 c = atoi( cargv[1] );
429 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
430 "%s: line %d: invalid level (%d) in \"threads <count>\""
431 "line\n",fname, lineno, c ));
433 Debug( LDAP_DEBUG_ANY,
434 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
441 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
443 /* get pid file name */
444 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
447 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
448 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
451 Debug( LDAP_DEBUG_ANY,
452 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
459 slapd_pid_file = ch_strdup( cargv[1] );
461 /* get args file name */
462 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
465 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
466 "%s: %d: missing file name in "
467 "\"argsfile <file>\" line.\n",
470 Debug( LDAP_DEBUG_ANY,
471 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
478 slapd_args_file = ch_strdup( cargv[1] );
480 /* default password hash */
481 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
484 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
485 "%s: line %d: missing hash in "
486 "\"password-hash <hash>\" line.\n",
489 Debug( LDAP_DEBUG_ANY,
490 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
496 if ( default_passwd_hash != NULL ) {
498 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
499 "%s: line %d: already set default password_hash!\n",
502 Debug( LDAP_DEBUG_ANY,
503 "%s: line %d: already set default password_hash!\n",
510 default_passwd_hash = ch_strdup( cargv[1] );
513 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
517 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
518 "%s: line %d: missing format in "
519 "\"password-crypt-salt-format <format>\" line\n",
522 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
523 "\"password-crypt-salt-format <format>\" line\n",
530 lutil_salt_format( cargv[1] );
533 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
536 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
537 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
540 Debug( LDAP_DEBUG_ANY,
541 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
548 if ( global_host != NULL ) {
550 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
551 "%s: line %d: already set sasl-host!\n",
554 Debug( LDAP_DEBUG_ANY,
555 "%s: line %d: already set sasl-host!\n",
562 global_host = ch_strdup( cargv[1] );
566 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
569 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
570 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
573 Debug( LDAP_DEBUG_ANY,
574 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
581 if ( global_realm != NULL ) {
583 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
584 "%s: line %d: already set sasl-realm!\n",
587 Debug( LDAP_DEBUG_ANY,
588 "%s: line %d: already set sasl-realm!\n",
595 global_realm = ch_strdup( cargv[1] );
598 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
599 || !strcasecmp( cargv[0], "saslregexp" ) )
604 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
605 "%s: line %d: need 2 args in "
606 "\"saslregexp <match> <replace>\"\n",
609 Debug( LDAP_DEBUG_ANY,
610 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
616 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
621 /* SASL security properties */
622 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
627 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
628 "%s: line %d: missing flags in "
629 "\"sasl-secprops <properties>\" line\n",
632 Debug( LDAP_DEBUG_ANY,
633 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
640 txt = slap_sasl_secprops( cargv[1] );
643 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
644 "%s: line %d sas-secprops: %s\n",
645 fname, lineno, txt ));
647 Debug( LDAP_DEBUG_ANY,
648 "%s: line %d: sasl-secprops: %s\n",
649 fname, lineno, txt );
655 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
656 sasl_external_x509dn_convert++;
658 /* set UCDATA path */
659 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
663 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
664 "%s: line %d: missing path in "
665 "\"ucdata-path <path>\" line.\n",
668 Debug( LDAP_DEBUG_ANY,
669 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
676 err = load_ucdata( cargv[1] );
680 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
681 "%s: line %d: ucdata already loaded, ucdata-path "
682 "must be set earlier in the file and/or be "
683 "specified only once!\n",
686 Debug( LDAP_DEBUG_ANY,
687 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
696 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
698 struct slap_limits_set *lim;
702 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
703 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
706 Debug( LDAP_DEBUG_ANY,
707 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
717 lim = &be->be_def_limit;
720 for ( i = 1; i < cargc; i++ ) {
721 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
722 rc = parse_limit( cargv[i], lim );
724 lim->lms_s_soft = atoi( cargv[i] );
730 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
731 "%s: line %d: unable "
732 "to parse value \"%s\" "
735 fname, lineno, cargv[i] ));
737 Debug( LDAP_DEBUG_ANY,
738 "%s: line %d: unable "
739 "to parse value \"%s\" "
742 fname, lineno, cargv[i] );
748 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
750 struct slap_limits_set *lim;
754 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
755 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
758 Debug( LDAP_DEBUG_ANY,
759 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
769 lim = &be->be_def_limit;
772 for ( i = 1; i < cargc; i++ ) {
773 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
774 rc = parse_limit( cargv[i], lim );
776 lim->lms_t_soft = atoi( cargv[i] );
782 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
783 "%s: line %d: unable "
784 "to parse value \"%s\" "
787 fname, lineno, cargv[i] ));
789 Debug( LDAP_DEBUG_ANY,
790 "%s: line %d: unable "
791 "to parse value \"%s\" "
794 fname, lineno, cargv[i] );
799 /* set regex-based limits */
800 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
803 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
804 "%s: line %d \"limits\" allowed only in database environment.\n",
807 Debug( LDAP_DEBUG_ANY,
808 "%s: line %d \"limits\" allowed only in database environment.\n%s",
814 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
818 /* set database suffix */
819 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
823 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
824 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
827 Debug( LDAP_DEBUG_ANY,
828 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
833 } else if ( cargc > 2 ) {
835 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
836 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
837 " line (ignored).\n", fname, lineno, cargv[1] ));
839 Debug( LDAP_DEBUG_ANY,
840 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
841 fname, lineno, cargv[1] );
847 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
848 "%s: line %d: suffix line must appear inside a database "
849 "definition (ignored).\n", fname, lineno ));
851 Debug( LDAP_DEBUG_ANY,
852 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
856 #if defined(SLAPD_MONITOR_DN)
857 /* "cn=Monitor" is reserved for monitoring slap */
858 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
860 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
861 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
862 SLAPD_MONITOR_DN, fname, lineno ));
864 Debug( LDAP_DEBUG_ANY,
865 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
866 SLAPD_MONITOR_DN, fname, lineno );
869 #endif /* SLAPD_MONITOR_DN */
871 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
873 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
874 "%s: line %d: suffix already served by this backend "
875 "(ignored)\n", fname, lineno ));
877 Debug( LDAP_DEBUG_ANY,
878 "%s: line %d: suffix already served by this backend (ignored)\n",
882 } else if ( tmp_be != NULL ) {
884 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
885 "%s: line %d: suffix already served by a preceding "
886 "backend \"%s\" (ignored)\n", fname, lineno,
887 tmp_be->be_suffix[0] ));
889 Debug( LDAP_DEBUG_ANY,
890 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
891 fname, lineno, tmp_be->be_suffix[0] );
895 char *dn = ch_strdup( cargv[1] );
896 if ( load_ucdata( NULL ) < 0 ) {
899 if( dn_validate( dn ) == NULL ) {
901 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
902 "%s: line %d: suffix DN invalid\"%s\"\n",
903 fname, lineno, cargv[1] ));
905 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
906 "suffix DN invalid \"%s\"\n",
907 fname, lineno, cargv[1] );
912 } else if( *dn == '\0' && default_search_nbase != NULL ) {
914 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
915 "%s: line %d: suffix DN empty and default search "
916 "base provided \"%s\" (assuming okay).\n",
917 fname, lineno, default_search_base ));
919 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
920 "suffix DN empty and default "
921 "search base provided \"%s\" (assuming okay)\n",
922 fname, lineno, default_search_base );
926 charray_add( &be->be_suffix, dn );
927 (void) ldap_pvt_str2upper( dn );
928 charray_add( &be->be_nsuffix, dn );
932 /* set database suffixAlias */
933 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
937 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
938 "%s: line %d: missing alias and aliased_dn in "
939 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
942 Debug( LDAP_DEBUG_ANY,
943 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
948 } else if ( cargc < 3 ) {
950 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
951 "%s: line %d: missing aliased_dn in "
952 "\"suffixAlias <alias> <aliased_dn>\" line\n",
955 Debug( LDAP_DEBUG_ANY,
956 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
961 } else if ( cargc > 3 ) {
963 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
964 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
967 Debug( LDAP_DEBUG_ANY,
968 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
976 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
977 "%s: line %d: suffixAlias line must appear inside a "
978 "database definition (ignored).\n", fname, lineno ));
980 Debug( LDAP_DEBUG_ANY,
981 "%s: line %d: suffixAlias line"
982 " must appear inside a database definition (ignored)\n",
986 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
988 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
989 "%s: line %d: suffixAlias served by a preceeding "
990 "backend \"%s\" (ignored).\n", fname, lineno,
991 tmp_be->be_suffix[0] ));
993 Debug( LDAP_DEBUG_ANY,
994 "%s: line %d: suffixAlias served by"
995 " a preceeding backend \"%s\" (ignored)\n",
996 fname, lineno, tmp_be->be_suffix[0] );
1000 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
1002 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1003 "%s: line %d: suffixAlias derefs to a different backend "
1004 "a preceeding backend \"%s\" (ignored)\n",
1005 fname, lineno, tmp_be->be_suffix[0] ));
1007 Debug( LDAP_DEBUG_ANY,
1008 "%s: line %d: suffixAlias derefs to differnet backend"
1009 " a preceeding backend \"%s\" (ignored)\n",
1010 fname, lineno, tmp_be->be_suffix[0] );
1015 char *alias, *aliased_dn;
1017 alias = ch_strdup( cargv[1] );
1018 if ( load_ucdata( NULL ) < 0 ) {
1021 (void) dn_normalize( alias );
1023 aliased_dn = ch_strdup( cargv[2] );
1024 (void) dn_normalize( aliased_dn );
1026 charray_add( &be->be_suffixAlias, alias );
1027 charray_add( &be->be_suffixAlias, aliased_dn );
1033 /* set max deref depth */
1034 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1038 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1039 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1040 " line\n", fname, lineno ));
1042 Debug( LDAP_DEBUG_ANY,
1043 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1051 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1052 "%s: line %d: depth line must appear inside a database "
1053 "definition (ignored)\n", fname, lineno ));
1055 Debug( LDAP_DEBUG_ANY,
1056 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1060 } else if ((i = atoi(cargv[1])) < 0) {
1062 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1063 "%s: line %d: depth must be positive (ignored).\n",
1066 Debug( LDAP_DEBUG_ANY,
1067 "%s: line %d: depth must be positive (ignored)\n",
1073 be->be_max_deref_depth = i;
1077 /* set magic "root" dn for this database */
1078 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1081 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1082 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1085 Debug( LDAP_DEBUG_ANY,
1086 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1094 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1095 "%s: line %d: rootdn line must appear inside a database "
1096 "definition (ignored).\n", fname, lineno ));
1098 Debug( LDAP_DEBUG_ANY,
1099 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1104 be->be_root_dn = ch_strdup( cargv[1] );
1105 be->be_root_ndn = ch_strdup( cargv[1] );
1107 if ( load_ucdata( NULL ) < 0 ) {
1110 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1111 free( be->be_root_dn );
1112 free( be->be_root_ndn );
1114 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1115 "%s: line %d: rootdn DN is invalid.\n",
1118 Debug( LDAP_DEBUG_ANY,
1119 "%s: line %d: rootdn DN is invalid\n",
1127 /* set super-secret magic database password */
1128 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1131 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1132 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1133 " line\n", fname, lineno ));
1135 Debug( LDAP_DEBUG_ANY,
1136 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1144 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1145 "%s: line %d: rootpw line must appear inside a database "
1146 "definition (ignored)\n", fname, lineno ));
1148 Debug( LDAP_DEBUG_ANY,
1149 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1154 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1155 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1158 /* make this database read-only */
1159 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1162 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1163 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1166 Debug( LDAP_DEBUG_ANY,
1167 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1174 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1175 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1177 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1180 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1181 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1183 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1188 /* allow these features */
1189 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1190 strcasecmp( cargv[0], "allow" ) == 0 )
1196 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1197 "%s: line %d: allow line must appear prior to "
1198 "database definitions.\n", fname, lineno ));
1200 Debug( LDAP_DEBUG_ANY,
1201 "%s: line %d: allow line must appear prior to database definitions\n",
1209 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1210 "%s: line %d: missing feature(s) in \"allow <features>\""
1211 " line\n", fname, lineno ));
1213 Debug( LDAP_DEBUG_ANY,
1214 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1223 for( i=1; i < cargc; i++ ) {
1224 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1225 allows |= SLAP_ALLOW_TLS_2_ANON;
1227 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1229 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1230 "%s: line %d: unknown feature %s in "
1231 "\"allow <features>\" line.\n",
1232 fname, lineno, cargv[1] ));
1234 Debug( LDAP_DEBUG_ANY,
1235 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1236 fname, lineno, cargv[i] );
1243 global_allows = allows;
1245 /* disallow these features */
1246 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1247 strcasecmp( cargv[0], "disallow" ) == 0 )
1249 slap_mask_t disallows;
1253 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1254 "%s: line %d: disallow line must appear prior to "
1255 "database definitions.\n", fname, lineno ));
1257 Debug( LDAP_DEBUG_ANY,
1258 "%s: line %d: disallow line must appear prior to database definitions\n",
1266 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1267 "%s: line %d: missing feature(s) in \"disallow <features>\""
1268 " line.\n", fname, lineno ));
1270 Debug( LDAP_DEBUG_ANY,
1271 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1280 for( i=1; i < cargc; i++ ) {
1281 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1282 disallows |= SLAP_DISALLOW_BIND_V2;
1284 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1285 disallows |= SLAP_DISALLOW_BIND_ANON;
1287 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1288 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1290 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1291 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1293 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1294 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1296 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1297 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1299 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1300 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1302 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1304 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1305 "%s: line %d: unknown feature %s in "
1306 "\"disallow <features>\" line.\n",
1307 fname, lineno, cargv[i] ));
1309 Debug( LDAP_DEBUG_ANY,
1310 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1311 fname, lineno, cargv[i] );
1318 global_disallows = disallows;
1320 /* require these features */
1321 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1322 strcasecmp( cargv[0], "require" ) == 0 )
1324 slap_mask_t requires;
1328 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1329 "%s: line %d: missing feature(s) in "
1330 "\"require <features>\" line.\n", fname, lineno ));
1332 Debug( LDAP_DEBUG_ANY,
1333 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1342 for( i=1; i < cargc; i++ ) {
1343 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1344 requires |= SLAP_REQUIRE_BIND;
1346 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1347 requires |= SLAP_REQUIRE_LDAP_V3;
1349 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1350 requires |= SLAP_REQUIRE_AUTHC;
1352 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1353 requires |= SLAP_REQUIRE_SASL;
1355 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1356 requires |= SLAP_REQUIRE_STRONG;
1358 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1360 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1361 "%s: line %d: unknown feature %s in "
1362 "\"require <features>\" line.\n",
1365 Debug( LDAP_DEBUG_ANY,
1366 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1367 fname, lineno, cargv[i] );
1375 global_requires = requires;
1377 be->be_requires = requires;
1380 /* required security factors */
1381 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1382 slap_ssf_set_t *set;
1386 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1387 "%s: line %d: missing factor(s) in \"security <factors>\""
1388 " line.\n", fname, lineno ));
1390 Debug( LDAP_DEBUG_ANY,
1391 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1399 set = &global_ssf_set;
1401 set = &be->be_ssf_set;
1404 for( i=1; i < cargc; i++ ) {
1405 if( strncasecmp( cargv[i], "ssf=",
1406 sizeof("ssf") ) == 0 )
1409 atoi( &cargv[i][sizeof("ssf")] );
1411 } else if( strncasecmp( cargv[i], "transport=",
1412 sizeof("transport") ) == 0 )
1414 set->sss_transport =
1415 atoi( &cargv[i][sizeof("transport")] );
1417 } else if( strncasecmp( cargv[i], "tls=",
1418 sizeof("tls") ) == 0 )
1421 atoi( &cargv[i][sizeof("tls")] );
1423 } else if( strncasecmp( cargv[i], "sasl=",
1424 sizeof("sasl") ) == 0 )
1427 atoi( &cargv[i][sizeof("sasl")] );
1429 } else if( strncasecmp( cargv[i], "update_ssf=",
1430 sizeof("update_ssf") ) == 0 )
1432 set->sss_update_ssf =
1433 atoi( &cargv[i][sizeof("update_ssf")] );
1435 } else if( strncasecmp( cargv[i], "update_transport=",
1436 sizeof("update_transport") ) == 0 )
1438 set->sss_update_transport =
1439 atoi( &cargv[i][sizeof("update_transport")] );
1441 } else if( strncasecmp( cargv[i], "update_tls=",
1442 sizeof("update_tls") ) == 0 )
1444 set->sss_update_tls =
1445 atoi( &cargv[i][sizeof("update_tls")] );
1447 } else if( strncasecmp( cargv[i], "update_sasl=",
1448 sizeof("update_sasl") ) == 0 )
1450 set->sss_update_sasl =
1451 atoi( &cargv[i][sizeof("update_sasl")] );
1455 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1456 "%s: line %d: unknown factor %S in "
1457 "\"security <factors>\" line.\n",
1458 fname, lineno, cargv[1] ));
1460 Debug( LDAP_DEBUG_ANY,
1461 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1462 fname, lineno, cargv[i] );
1468 /* where to send clients when we don't hold it */
1469 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1472 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1473 "%s: line %d: missing URL in \"referral <URL>\""
1474 " line.\n", fname, lineno ));
1476 Debug( LDAP_DEBUG_ANY,
1477 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1484 vals[0]->bv_val = cargv[1];
1485 vals[0]->bv_len = strlen( vals[0]->bv_val );
1486 value_add( &default_referral, vals );
1489 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1493 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1494 "%s: line %d: Error in logfile directive, "
1495 "\"logfile <filename>\"\n", fname, lineno ));
1497 Debug( LDAP_DEBUG_ANY,
1498 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1504 logfile = fopen( cargv[1], "w" );
1505 if ( logfile != NULL ) lutil_debug_file( logfile );
1508 /* start of a new database definition */
1509 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1513 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1514 "%s: line %d: Error in debug directive, "
1515 "\"debug <subsys> <level>\"\n", fname, lineno ));
1517 Debug( LDAP_DEBUG_ANY,
1518 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1524 level = atoi( cargv[2] );
1525 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1526 lutil_set_debug_level( cargv[1], level );
1527 /* specify an Object Identifier macro */
1528 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1529 rc = parse_oidm( fname, lineno, cargc, cargv );
1532 /* specify an objectclass */
1533 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1534 if ( *cargv[1] == '(' ) {
1536 p = strchr(saveline,'(');
1537 rc = parse_oc( fname, lineno, p, cargv );
1542 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1543 "%s: line %d: old objectclass format not supported\n",
1546 Debug( LDAP_DEBUG_ANY,
1547 "%s: line %d: old objectclass format not supported.\n",
1553 /* specify an attribute type */
1554 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1555 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1557 if ( *cargv[1] == '(' ) {
1559 p = strchr(saveline,'(');
1560 rc = parse_at( fname, lineno, p, cargv );
1565 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1566 "%s: line %d: old attribute type format not supported.\n",
1569 Debug( LDAP_DEBUG_ANY,
1570 "%s: line %d: old attribute type format not supported.\n",
1576 /* turn on/off schema checking */
1577 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1580 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1581 "%s: line %d: missing on|off in "
1582 "\"schemacheck <on|off>\" line.\n",
1585 Debug( LDAP_DEBUG_ANY,
1586 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1592 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1593 global_schemacheck = 0;
1595 global_schemacheck = 1;
1598 /* specify access control info */
1599 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1600 parse_acl( be, fname, lineno, cargc, cargv );
1602 /* debug level to log things to syslog */
1603 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1606 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1607 "%s: line %d: missing level in \"loglevel <level>\""
1608 " line.\n", fname, lineno ));
1610 Debug( LDAP_DEBUG_ANY,
1611 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1620 for( i=1; i < cargc; i++ ) {
1621 ldap_syslog += atoi( cargv[1] );
1624 /* list of replicas of the data in this backend (master only) */
1625 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1628 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1629 "%s: line %d: missing host in \"replica "
1630 " <host[:port]\" line\n", fname, lineno ));
1632 Debug( LDAP_DEBUG_ANY,
1633 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1641 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1642 "%s: line %d: replica line must appear inside "
1643 "a database definition (ignored).\n", fname, lineno ));
1645 Debug( LDAP_DEBUG_ANY,
1646 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1653 for ( i = 1; i < cargc; i++ ) {
1654 if ( strncasecmp( cargv[i], "host=", 5 )
1656 nr = add_replica_info( be,
1663 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1664 "%s: line %d: missing host in \"replica\" "
1665 "line (ignored)\n", fname, lineno ));
1667 Debug( LDAP_DEBUG_ANY,
1668 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1672 } else if ( nr == -1 ) {
1674 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1675 "%s: line %d: unable to add"
1681 Debug( LDAP_DEBUG_ANY,
1682 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1683 fname, lineno, cargv[i] + 5 );
1686 for ( i = 1; i < cargc; i++ ) {
1687 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1688 char *nsuffix = ch_strdup( cargv[i] + 7 );
1689 if ( dn_normalize( nsuffix ) != NULL ) {
1690 if ( select_backend( nsuffix, 0 ) == be ) {
1691 charray_add( &be->be_replica[nr]->ri_nsuffix, nsuffix );
1694 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1695 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1696 fname, lineno, cargv[i] + 7 ));
1698 Debug( LDAP_DEBUG_ANY,
1699 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1700 fname, lineno, cargv[i] + 7 );
1705 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1706 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1709 Debug( LDAP_DEBUG_ANY,
1710 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1720 /* dn of master entity allowed to write to replica */
1721 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1724 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1725 "%s: line %d: missing dn in \"updatedn <dn>\""
1726 " line.\n", fname, lineno ));
1728 Debug( LDAP_DEBUG_ANY,
1729 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1737 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1738 "%s: line %d: updatedn line must appear inside "
1739 "a database definition (ignored)\n",
1742 Debug( LDAP_DEBUG_ANY,
1743 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1748 be->be_update_ndn = ch_strdup( cargv[1] );
1749 if ( load_ucdata( NULL ) < 0 ) {
1752 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1754 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1755 "%s: line %d: updatedn DN is invalid.\n",
1758 Debug( LDAP_DEBUG_ANY,
1759 "%s: line %d: updatedn DN is invalid\n",
1767 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1770 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1771 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1772 "line.\n", fname, lineno ));
1774 Debug( LDAP_DEBUG_ANY,
1775 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1783 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1784 "%s: line %d: updateref line must appear inside "
1785 "a database definition (ignored)\n", fname, lineno ));
1787 Debug( LDAP_DEBUG_ANY,
1788 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1792 } else if ( be->be_update_ndn == NULL ) {
1794 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1795 "%s: line %d: updateref line must come after updatedn "
1796 "(ignored).\n", fname, lineno ));
1798 Debug( LDAP_DEBUG_ANY,
1799 "%s: line %d: updateref line must after updatedn (ignored)\n",
1804 vals[0]->bv_val = cargv[1];
1805 vals[0]->bv_len = strlen( vals[0]->bv_val );
1806 value_add( &be->be_update_refs, vals );
1809 /* replication log file to which changes are appended */
1810 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1813 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1814 "%s: line %d: missing filename in \"replogfile <filename>\""
1815 " line.\n", fname, lineno ));
1817 Debug( LDAP_DEBUG_ANY,
1818 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1825 be->be_replogfile = ch_strdup( cargv[1] );
1827 replogfile = ch_strdup( cargv[1] );
1830 /* maintain lastmodified{by,time} attributes */
1831 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1834 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1835 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1836 " line.\n", fname, lineno ));
1838 Debug( LDAP_DEBUG_ANY,
1839 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1845 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1847 be->be_lastmod = ON;
1849 global_lastmod = ON;
1852 be->be_lastmod = OFF;
1854 global_lastmod = OFF;
1857 /* set idle timeout value */
1858 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1862 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1863 "%s: line %d: missing timeout value in "
1864 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1866 Debug( LDAP_DEBUG_ANY,
1867 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1874 i = atoi( cargv[1] );
1878 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1879 "%s: line %d: timeout value (%d) invalid "
1880 "\"idletimeout <seconds>\" line.\n",
1881 fname, lineno, i ));
1883 Debug( LDAP_DEBUG_ANY,
1884 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1891 global_idletimeout = i;
1893 /* include another config file */
1894 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1897 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1898 "%s: line %d: missing filename in \"include "
1899 "<filename>\" line.\n", fname, lineno ));
1901 Debug( LDAP_DEBUG_ANY,
1902 "%s: line %d: missing filename in \"include <filename>\" line\n",
1908 savefname = ch_strdup( cargv[1] );
1909 savelineno = lineno;
1911 if ( read_config( savefname ) != 0 ) {
1916 lineno = savelineno - 1;
1918 /* location of kerberos srvtab file */
1919 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1922 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1923 "%s: line %d: missing filename in \"srvtab "
1924 "<filename>\" line.\n", fname, lineno ));
1926 Debug( LDAP_DEBUG_ANY,
1927 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1933 ldap_srvtab = ch_strdup( cargv[1] );
1935 #ifdef SLAPD_MODULES
1936 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1939 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1940 "%s: line %d: missing filename in \"moduleload "
1941 "<filename>\" line.\n", fname, lineno ));
1943 Debug( LDAP_DEBUG_ANY,
1944 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1948 exit( EXIT_FAILURE );
1950 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1952 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1953 "%s: line %d: failed to load or initialize module %s\n"<
1954 fname, lineno, cargv[1] ));
1956 Debug( LDAP_DEBUG_ANY,
1957 "%s: line %d: failed to load or initialize module %s\n",
1958 fname, lineno, cargv[1]);
1961 exit( EXIT_FAILURE );
1963 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1966 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1967 "%s: line %d: missing path in \"modulepath <path>\""
1968 " line\n", fname, lineno ));
1970 Debug( LDAP_DEBUG_ANY,
1971 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1975 exit( EXIT_FAILURE );
1977 if (module_path( cargv[1] )) {
1979 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1980 "%s: line %d: failed to set module search path to %s.\n",
1981 fname, lineno, cargv[1] ));
1983 Debug( LDAP_DEBUG_ANY,
1984 "%s: line %d: failed to set module search path to %s\n",
1985 fname, lineno, cargv[1]);
1988 exit( EXIT_FAILURE );
1991 #endif /*SLAPD_MODULES*/
1994 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
1995 rc = ldap_pvt_tls_set_option( NULL,
1996 LDAP_OPT_X_TLS_RANDOM_FILE,
2001 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2002 rc = ldap_pvt_tls_set_option( NULL,
2003 LDAP_OPT_X_TLS_CIPHER_SUITE,
2008 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2009 rc = ldap_pvt_tls_set_option( NULL,
2010 LDAP_OPT_X_TLS_CERTFILE,
2015 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2016 rc = ldap_pvt_tls_set_option( NULL,
2017 LDAP_OPT_X_TLS_KEYFILE,
2022 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2023 rc = ldap_pvt_tls_set_option( NULL,
2024 LDAP_OPT_X_TLS_CACERTDIR,
2029 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2030 rc = ldap_pvt_tls_set_option( NULL,
2031 LDAP_OPT_X_TLS_CACERTFILE,
2035 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2037 rc = ldap_pvt_tls_set_option( NULL,
2038 LDAP_OPT_X_TLS_REQUIRE_CERT,
2045 /* pass anything else to the current backend info/db config routine */
2048 if ( bi->bi_config == 0 ) {
2050 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2051 "%s: line %d: unknown directive \"%s\" inside "
2052 "backend info definition (ignored).\n",
2053 fname, lineno, cargv[0] ));
2055 Debug( LDAP_DEBUG_ANY,
2056 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2057 fname, lineno, cargv[0] );
2061 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2067 } else if ( be != NULL ) {
2068 if ( be->be_config == 0 ) {
2070 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2071 "%s: line %d: uknown directive \"%s\" inside "
2072 "backend database definition (ignored).\n",
2073 fname, lineno, cargv[0] ));
2075 Debug( LDAP_DEBUG_ANY,
2076 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2077 fname, lineno, cargv[0] );
2081 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2089 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2090 "%s: line %d: unknown directive \"%s\" outside backend "
2091 "info and database definitions (ignored).\n",
2092 fname, lineno, cargv[0] ));
2094 Debug( LDAP_DEBUG_ANY,
2095 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2096 fname, lineno, cargv[0] );
2104 if ( load_ucdata( NULL ) < 0 ) {
2120 for ( token = strtok_quote( line, " \t" ); token != NULL;
2121 token = strtok_quote( NULL, " \t" ) ) {
2122 if ( *argcp == MAXARGS ) {
2124 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2125 "fp_parse_line: too many tokens (%d max).\n",
2128 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2134 argv[(*argcp)++] = token;
2136 argv[*argcp] = NULL;
2141 strtok_quote( char *line, char *sep )
2147 if ( line != NULL ) {
2150 while ( *next && strchr( sep, *next ) ) {
2154 if ( *next == '\0' ) {
2160 for ( inquote = 0; *next; ) {
2168 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2174 next + 1, strlen( next + 1 ) + 1 );
2175 next++; /* dont parse the escaped character */
2180 if ( strchr( sep, *next ) != NULL ) {
2193 static char buf[BUFSIZ];
2195 static int lmax, lcur;
2197 #define CATLINE( buf ) { \
2199 len = strlen( buf ); \
2200 while ( lcur + len + 1 > lmax ) { \
2202 line = (char *) ch_realloc( line, lmax ); \
2204 strcpy( line + lcur, buf ); \
2209 fp_getline( FILE *fp, int *lineno )
2217 /* hack attack - keeps us from having to keep a stack of bufs... */
2218 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2223 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2224 if ( (p = strchr( buf, '\n' )) != NULL ) {
2227 if ( ! isspace( (unsigned char) buf[0] ) ) {
2231 /* change leading whitespace to a space */
2239 return( line[0] ? line : NULL );
2243 fp_getline_init( int *lineno )
2249 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2251 load_ucdata( char *path )
2253 static int loaded = 0;
2259 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2262 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2263 "load_ucdata: Error %d loading ucdata.\n", err ));
2265 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",