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 if ( strncasecmp( cargv[1], "size", 4 ) == 0 ) {
721 rc = parse_limit( cargv[1], lim );
723 lim->lms_s_soft = atoi( cargv[1] );
729 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
730 "%s: line %d: unable to parse value"
731 " \"%s\" in \"sizelimit <limit>\""
733 fname, lineno, cargv[1] ));
735 Debug( LDAP_DEBUG_ANY,
736 "%s: line %d: unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
737 fname, lineno, cargv[1] );
742 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
744 struct slap_limits_set *lim;
748 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
749 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
752 Debug( LDAP_DEBUG_ANY,
753 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
763 lim = &be->be_def_limit;
766 if ( strncasecmp( cargv[1], "time", 4 ) == 0 ) {
767 rc = parse_limit( cargv[1], lim );
769 lim->lms_t_soft = atoi( cargv[1] );
775 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
776 "%s: line %d: unable to parse value"
777 " \"%s\" in \"timelimit <limit>\""
779 fname, lineno, cargv[1] ));
781 Debug( LDAP_DEBUG_ANY,
782 "%s: line %d: unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
783 fname, lineno, cargv[1] );
787 /* set regex-based limits */
788 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
791 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
792 "%s: line %d \"limits\" allowed only in database environment.\n",
795 Debug( LDAP_DEBUG_ANY,
796 "%s: line %d \"limits\" allowed only in database environment.\n%s",
802 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
806 /* set database suffix */
807 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
811 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
812 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
815 Debug( LDAP_DEBUG_ANY,
816 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
821 } else if ( cargc > 2 ) {
823 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
824 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
825 " line (ignored).\n", fname, lineno, cargv[1] ));
827 Debug( LDAP_DEBUG_ANY,
828 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
829 fname, lineno, cargv[1] );
835 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
836 "%s: line %d: suffix line must appear inside a database "
837 "definition (ignored).\n", fname, lineno ));
839 Debug( LDAP_DEBUG_ANY,
840 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
844 #if defined(SLAPD_MONITOR_DN)
845 /* "cn=Monitor" is reserved for monitoring slap */
846 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
848 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
849 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
850 SLAPD_MONITOR_DN, fname, lineno ));
852 Debug( LDAP_DEBUG_ANY,
853 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
854 SLAPD_MONITOR_DN, fname, lineno );
857 #endif /* SLAPD_MONITOR_DN */
859 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
861 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
862 "%s: line %d: suffix already served by this backend "
863 "(ignored)\n", fname, lineno ));
865 Debug( LDAP_DEBUG_ANY,
866 "%s: line %d: suffix already served by this backend (ignored)\n",
870 } else if ( tmp_be != NULL ) {
872 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
873 "%s: line %d: suffix already served by a preceding "
874 "backend \"%s\" (ignored)\n", fname, lineno,
875 tmp_be->be_suffix[0] ));
877 Debug( LDAP_DEBUG_ANY,
878 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
879 fname, lineno, tmp_be->be_suffix[0] );
883 char *dn = ch_strdup( cargv[1] );
884 if ( load_ucdata( NULL ) < 0 ) {
887 if( dn_validate( dn ) == NULL ) {
889 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
890 "%s: line %d: suffix DN invalid\"%s\"\n",
891 fname, lineno, cargv[1] ));
893 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
894 "suffix DN invalid \"%s\"\n",
895 fname, lineno, cargv[1] );
900 } else if( *dn == '\0' && default_search_nbase != NULL ) {
902 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
903 "%s: line %d: suffix DN empty and default search "
904 "base provided \"%s\" (assuming okay).\n",
905 fname, lineno, default_search_base ));
907 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
908 "suffix DN empty and default "
909 "search base provided \"%s\" (assuming okay)\n",
910 fname, lineno, default_search_base );
914 charray_add( &be->be_suffix, dn );
915 (void) ldap_pvt_str2upper( dn );
916 charray_add( &be->be_nsuffix, dn );
920 /* set database suffixAlias */
921 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
925 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
926 "%s: line %d: missing alias and aliased_dn in "
927 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
930 Debug( LDAP_DEBUG_ANY,
931 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
936 } else if ( cargc < 3 ) {
938 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
939 "%s: line %d: missing aliased_dn in "
940 "\"suffixAlias <alias> <aliased_dn>\" line\n",
943 Debug( LDAP_DEBUG_ANY,
944 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
949 } else if ( cargc > 3 ) {
951 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
952 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
955 Debug( LDAP_DEBUG_ANY,
956 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
964 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
965 "%s: line %d: suffixAlias line must appear inside a "
966 "database definition (ignored).\n", fname, lineno ));
968 Debug( LDAP_DEBUG_ANY,
969 "%s: line %d: suffixAlias line"
970 " must appear inside a database definition (ignored)\n",
974 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
976 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
977 "%s: line %d: suffixAlias served by a preceeding "
978 "backend \"%s\" (ignored).\n", fname, lineno,
979 tmp_be->be_suffix[0] ));
981 Debug( LDAP_DEBUG_ANY,
982 "%s: line %d: suffixAlias served by"
983 " a preceeding backend \"%s\" (ignored)\n",
984 fname, lineno, tmp_be->be_suffix[0] );
988 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
990 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
991 "%s: line %d: suffixAlias derefs to a different backend "
992 "a preceeding backend \"%s\" (ignored)\n",
993 fname, lineno, tmp_be->be_suffix[0] ));
995 Debug( LDAP_DEBUG_ANY,
996 "%s: line %d: suffixAlias derefs to differnet backend"
997 " a preceeding backend \"%s\" (ignored)\n",
998 fname, lineno, tmp_be->be_suffix[0] );
1003 char *alias, *aliased_dn;
1005 alias = ch_strdup( cargv[1] );
1006 if ( load_ucdata( NULL ) < 0 ) {
1009 (void) dn_normalize( alias );
1011 aliased_dn = ch_strdup( cargv[2] );
1012 (void) dn_normalize( aliased_dn );
1014 charray_add( &be->be_suffixAlias, alias );
1015 charray_add( &be->be_suffixAlias, aliased_dn );
1021 /* set max deref depth */
1022 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1026 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1027 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1028 " line\n", fname, lineno ));
1030 Debug( LDAP_DEBUG_ANY,
1031 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1039 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1040 "%s: line %d: depth line must appear inside a database "
1041 "definition (ignored)\n", fname, lineno ));
1043 Debug( LDAP_DEBUG_ANY,
1044 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1048 } else if ((i = atoi(cargv[1])) < 0) {
1050 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1051 "%s: line %d: depth must be positive (ignored).\n",
1054 Debug( LDAP_DEBUG_ANY,
1055 "%s: line %d: depth must be positive (ignored)\n",
1061 be->be_max_deref_depth = i;
1065 /* set magic "root" dn for this database */
1066 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1069 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1070 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1073 Debug( LDAP_DEBUG_ANY,
1074 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1082 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1083 "%s: line %d: rootdn line must appear inside a database "
1084 "definition (ignored).\n", fname, lineno ));
1086 Debug( LDAP_DEBUG_ANY,
1087 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1092 be->be_root_dn = ch_strdup( cargv[1] );
1093 be->be_root_ndn = ch_strdup( cargv[1] );
1095 if ( load_ucdata( NULL ) < 0 ) {
1098 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1099 free( be->be_root_dn );
1100 free( be->be_root_ndn );
1102 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1103 "%s: line %d: rootdn DN is invalid.\n",
1106 Debug( LDAP_DEBUG_ANY,
1107 "%s: line %d: rootdn DN is invalid\n",
1115 /* set super-secret magic database password */
1116 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1119 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1120 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1121 " line\n", fname, lineno ));
1123 Debug( LDAP_DEBUG_ANY,
1124 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1132 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1133 "%s: line %d: rootpw line must appear inside a database "
1134 "definition (ignored)\n", fname, lineno ));
1136 Debug( LDAP_DEBUG_ANY,
1137 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1142 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1143 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1146 /* make this database read-only */
1147 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1150 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1151 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1154 Debug( LDAP_DEBUG_ANY,
1155 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1162 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1163 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1165 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1168 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1169 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1171 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1176 /* allow these features */
1177 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1178 strcasecmp( cargv[0], "allow" ) == 0 )
1184 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1185 "%s: line %d: allow line must appear prior to "
1186 "database definitions.\n", fname, lineno ));
1188 Debug( LDAP_DEBUG_ANY,
1189 "%s: line %d: allow line must appear prior to database definitions\n",
1197 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1198 "%s: line %d: missing feature(s) in \"allow <features>\""
1199 " line\n", fname, lineno ));
1201 Debug( LDAP_DEBUG_ANY,
1202 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1211 for( i=1; i < cargc; i++ ) {
1212 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1213 allows |= SLAP_ALLOW_TLS_2_ANON;
1215 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1217 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1218 "%s: line %d: unknown feature %s in "
1219 "\"allow <features>\" line.\n",
1220 fname, lineno, cargv[1] ));
1222 Debug( LDAP_DEBUG_ANY,
1223 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1224 fname, lineno, cargv[i] );
1231 global_allows = allows;
1233 /* disallow these features */
1234 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1235 strcasecmp( cargv[0], "disallow" ) == 0 )
1237 slap_mask_t disallows;
1241 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1242 "%s: line %d: disallow line must appear prior to "
1243 "database definitions.\n", fname, lineno ));
1245 Debug( LDAP_DEBUG_ANY,
1246 "%s: line %d: disallow line must appear prior to database definitions\n",
1254 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1255 "%s: line %d: missing feature(s) in \"disallow <features>\""
1256 " line.\n", fname, lineno ));
1258 Debug( LDAP_DEBUG_ANY,
1259 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1268 for( i=1; i < cargc; i++ ) {
1269 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1270 disallows |= SLAP_DISALLOW_BIND_V2;
1272 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1273 disallows |= SLAP_DISALLOW_BIND_ANON;
1275 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1276 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1278 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1279 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1281 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1282 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1284 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1285 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1287 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1288 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1290 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1292 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1293 "%s: line %d: unknown feature %s in "
1294 "\"disallow <features>\" line.\n",
1295 fname, lineno, cargv[i] ));
1297 Debug( LDAP_DEBUG_ANY,
1298 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1299 fname, lineno, cargv[i] );
1306 global_disallows = disallows;
1308 /* require these features */
1309 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1310 strcasecmp( cargv[0], "require" ) == 0 )
1312 slap_mask_t requires;
1316 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1317 "%s: line %d: missing feature(s) in "
1318 "\"require <features>\" line.\n", fname, lineno ));
1320 Debug( LDAP_DEBUG_ANY,
1321 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1330 for( i=1; i < cargc; i++ ) {
1331 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1332 requires |= SLAP_REQUIRE_BIND;
1334 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1335 requires |= SLAP_REQUIRE_LDAP_V3;
1337 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1338 requires |= SLAP_REQUIRE_AUTHC;
1340 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1341 requires |= SLAP_REQUIRE_SASL;
1343 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1344 requires |= SLAP_REQUIRE_STRONG;
1346 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1348 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1349 "%s: line %d: unknown feature %s in "
1350 "\"require <features>\" line.\n",
1353 Debug( LDAP_DEBUG_ANY,
1354 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1355 fname, lineno, cargv[i] );
1363 global_requires = requires;
1365 be->be_requires = requires;
1368 /* required security factors */
1369 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1370 slap_ssf_set_t *set;
1374 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1375 "%s: line %d: missing factor(s) in \"security <factors>\""
1376 " line.\n", fname, lineno ));
1378 Debug( LDAP_DEBUG_ANY,
1379 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1387 set = &global_ssf_set;
1389 set = &be->be_ssf_set;
1392 for( i=1; i < cargc; i++ ) {
1393 if( strncasecmp( cargv[i], "ssf=",
1394 sizeof("ssf") ) == 0 )
1397 atoi( &cargv[i][sizeof("ssf")] );
1399 } else if( strncasecmp( cargv[i], "transport=",
1400 sizeof("transport") ) == 0 )
1402 set->sss_transport =
1403 atoi( &cargv[i][sizeof("transport")] );
1405 } else if( strncasecmp( cargv[i], "tls=",
1406 sizeof("tls") ) == 0 )
1409 atoi( &cargv[i][sizeof("tls")] );
1411 } else if( strncasecmp( cargv[i], "sasl=",
1412 sizeof("sasl") ) == 0 )
1415 atoi( &cargv[i][sizeof("sasl")] );
1417 } else if( strncasecmp( cargv[i], "update_ssf=",
1418 sizeof("update_ssf") ) == 0 )
1420 set->sss_update_ssf =
1421 atoi( &cargv[i][sizeof("update_ssf")] );
1423 } else if( strncasecmp( cargv[i], "update_transport=",
1424 sizeof("update_transport") ) == 0 )
1426 set->sss_update_transport =
1427 atoi( &cargv[i][sizeof("update_transport")] );
1429 } else if( strncasecmp( cargv[i], "update_tls=",
1430 sizeof("update_tls") ) == 0 )
1432 set->sss_update_tls =
1433 atoi( &cargv[i][sizeof("update_tls")] );
1435 } else if( strncasecmp( cargv[i], "update_sasl=",
1436 sizeof("update_sasl") ) == 0 )
1438 set->sss_update_sasl =
1439 atoi( &cargv[i][sizeof("update_sasl")] );
1443 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1444 "%s: line %d: unknown factor %S in "
1445 "\"security <factors>\" line.\n",
1446 fname, lineno, cargv[1] ));
1448 Debug( LDAP_DEBUG_ANY,
1449 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1450 fname, lineno, cargv[i] );
1456 /* where to send clients when we don't hold it */
1457 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1460 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1461 "%s: line %d: missing URL in \"referral <URL>\""
1462 " line.\n", fname, lineno ));
1464 Debug( LDAP_DEBUG_ANY,
1465 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1472 vals[0]->bv_val = cargv[1];
1473 vals[0]->bv_len = strlen( vals[0]->bv_val );
1474 value_add( &default_referral, vals );
1477 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1481 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1482 "%s: line %d: Error in logfile directive, "
1483 "\"logfile <filename>\"\n", fname, lineno ));
1485 Debug( LDAP_DEBUG_ANY,
1486 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1492 logfile = fopen( cargv[1], "w" );
1493 if ( logfile != NULL ) lutil_debug_file( logfile );
1496 /* start of a new database definition */
1497 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1501 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1502 "%s: line %d: Error in debug directive, "
1503 "\"debug <subsys> <level>\"\n", fname, lineno ));
1505 Debug( LDAP_DEBUG_ANY,
1506 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1512 level = atoi( cargv[2] );
1513 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1514 lutil_set_debug_level( cargv[1], level );
1515 /* specify an Object Identifier macro */
1516 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1517 rc = parse_oidm( fname, lineno, cargc, cargv );
1520 /* specify an objectclass */
1521 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1522 if ( *cargv[1] == '(' ) {
1524 p = strchr(saveline,'(');
1525 rc = parse_oc( fname, lineno, p, cargv );
1530 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1531 "%s: line %d: old objectclass format not supported\n",
1534 Debug( LDAP_DEBUG_ANY,
1535 "%s: line %d: old objectclass format not supported.\n",
1541 /* specify an attribute type */
1542 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1543 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1545 if ( *cargv[1] == '(' ) {
1547 p = strchr(saveline,'(');
1548 rc = parse_at( fname, lineno, p, cargv );
1553 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1554 "%s: line %d: old attribute type format not supported.\n",
1557 Debug( LDAP_DEBUG_ANY,
1558 "%s: line %d: old attribute type format not supported.\n",
1564 /* turn on/off schema checking */
1565 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1568 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1569 "%s: line %d: missing on|off in "
1570 "\"schemacheck <on|off>\" line.\n",
1573 Debug( LDAP_DEBUG_ANY,
1574 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1580 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1581 global_schemacheck = 0;
1583 global_schemacheck = 1;
1586 /* specify access control info */
1587 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1588 parse_acl( be, fname, lineno, cargc, cargv );
1590 /* debug level to log things to syslog */
1591 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1594 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1595 "%s: line %d: missing level in \"loglevel <level>\""
1596 " line.\n", fname, lineno ));
1598 Debug( LDAP_DEBUG_ANY,
1599 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1608 for( i=1; i < cargc; i++ ) {
1609 ldap_syslog += atoi( cargv[1] );
1612 /* list of replicas of the data in this backend (master only) */
1613 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1616 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1617 "%s: line %d: missing host in \"replica "
1618 " <host[:port]\" line\n", fname, lineno ));
1620 Debug( LDAP_DEBUG_ANY,
1621 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1629 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1630 "%s: line %d: replica line must appear inside "
1631 "a database definition (ignored).\n", fname, lineno ));
1633 Debug( LDAP_DEBUG_ANY,
1634 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1641 for ( i = 1; i < cargc; i++ ) {
1642 if ( strncasecmp( cargv[i], "host=", 5 )
1644 nr = add_replica_info( be,
1651 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1652 "%s: line %d: missing host in \"replica\" "
1653 "line (ignored)\n", fname, lineno ));
1655 Debug( LDAP_DEBUG_ANY,
1656 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1660 } else if ( nr == -1 ) {
1662 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1663 "%s: line %d: unable to add"
1669 Debug( LDAP_DEBUG_ANY,
1670 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1671 fname, lineno, cargv[i] + 5 );
1674 for ( i = 1; i < cargc; i++ ) {
1675 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1676 char *nsuffix = ch_strdup( cargv[i] + 7 );
1677 if ( dn_normalize( nsuffix ) != NULL ) {
1678 if ( be_issuffix( be, nsuffix ) ) {
1679 charray_add( &be->be_replica[nr]->ri_nsuffix, nsuffix );
1682 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1683 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1684 fname, lineno, cargv[i] + 7 ));
1686 Debug( LDAP_DEBUG_ANY,
1687 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1688 fname, lineno, cargv[i] + 7 );
1693 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1694 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1697 Debug( LDAP_DEBUG_ANY,
1698 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1708 /* dn of master entity allowed to write to replica */
1709 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1712 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1713 "%s: line %d: missing dn in \"updatedn <dn>\""
1714 " line.\n", fname, lineno ));
1716 Debug( LDAP_DEBUG_ANY,
1717 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1725 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1726 "%s: line %d: updatedn line must appear inside "
1727 "a database definition (ignored)\n",
1730 Debug( LDAP_DEBUG_ANY,
1731 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1736 be->be_update_ndn = ch_strdup( cargv[1] );
1737 if ( load_ucdata( NULL ) < 0 ) {
1740 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1742 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1743 "%s: line %d: updatedn DN is invalid.\n",
1746 Debug( LDAP_DEBUG_ANY,
1747 "%s: line %d: updatedn DN is invalid\n",
1755 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1758 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1759 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1760 "line.\n", fname, lineno ));
1762 Debug( LDAP_DEBUG_ANY,
1763 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1771 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1772 "%s: line %d: updateref line must appear inside "
1773 "a database definition (ignored)\n", fname, lineno ));
1775 Debug( LDAP_DEBUG_ANY,
1776 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1780 } else if ( be->be_update_ndn == NULL ) {
1782 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1783 "%s: line %d: updateref line must come after updatedn "
1784 "(ignored).\n", fname, lineno ));
1786 Debug( LDAP_DEBUG_ANY,
1787 "%s: line %d: updateref line must after updatedn (ignored)\n",
1792 vals[0]->bv_val = cargv[1];
1793 vals[0]->bv_len = strlen( vals[0]->bv_val );
1794 value_add( &be->be_update_refs, vals );
1797 /* replication log file to which changes are appended */
1798 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1801 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1802 "%s: line %d: missing filename in \"replogfile <filename>\""
1803 " line.\n", fname, lineno ));
1805 Debug( LDAP_DEBUG_ANY,
1806 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1813 be->be_replogfile = ch_strdup( cargv[1] );
1815 replogfile = ch_strdup( cargv[1] );
1818 /* maintain lastmodified{by,time} attributes */
1819 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1822 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1823 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1824 " line.\n", fname, lineno ));
1826 Debug( LDAP_DEBUG_ANY,
1827 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1833 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1835 be->be_lastmod = ON;
1837 global_lastmod = ON;
1840 be->be_lastmod = OFF;
1842 global_lastmod = OFF;
1845 /* set idle timeout value */
1846 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1850 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1851 "%s: line %d: missing timeout value in "
1852 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1854 Debug( LDAP_DEBUG_ANY,
1855 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1862 i = atoi( cargv[1] );
1866 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1867 "%s: line %d: timeout value (%d) invalid "
1868 "\"idletimeout <seconds>\" line.\n",
1869 fname, lineno, i ));
1871 Debug( LDAP_DEBUG_ANY,
1872 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1879 global_idletimeout = i;
1881 /* include another config file */
1882 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1885 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1886 "%s: line %d: missing filename in \"include "
1887 "<filename>\" line.\n", fname, lineno ));
1889 Debug( LDAP_DEBUG_ANY,
1890 "%s: line %d: missing filename in \"include <filename>\" line\n",
1896 savefname = ch_strdup( cargv[1] );
1897 savelineno = lineno;
1899 if ( read_config( savefname ) != 0 ) {
1904 lineno = savelineno - 1;
1906 /* location of kerberos srvtab file */
1907 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1910 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1911 "%s: line %d: missing filename in \"srvtab "
1912 "<filename>\" line.\n", fname, lineno ));
1914 Debug( LDAP_DEBUG_ANY,
1915 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1921 ldap_srvtab = ch_strdup( cargv[1] );
1923 #ifdef SLAPD_MODULES
1924 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1927 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1928 "%s: line %d: missing filename in \"moduleload "
1929 "<filename>\" line.\n", fname, lineno ));
1931 Debug( LDAP_DEBUG_ANY,
1932 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1936 exit( EXIT_FAILURE );
1938 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1940 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1941 "%s: line %d: failed to load or initialize module %s\n"<
1942 fname, lineno, cargv[1] ));
1944 Debug( LDAP_DEBUG_ANY,
1945 "%s: line %d: failed to load or initialize module %s\n",
1946 fname, lineno, cargv[1]);
1949 exit( EXIT_FAILURE );
1951 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1954 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1955 "%s: line %d: missing path in \"modulepath <path>\""
1956 " line\n", fname, lineno ));
1958 Debug( LDAP_DEBUG_ANY,
1959 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1963 exit( EXIT_FAILURE );
1965 if (module_path( cargv[1] )) {
1967 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1968 "%s: line %d: failed to set module search path to %s.\n",
1969 fname, lineno, cargv[1] ));
1971 Debug( LDAP_DEBUG_ANY,
1972 "%s: line %d: failed to set module search path to %s\n",
1973 fname, lineno, cargv[1]);
1976 exit( EXIT_FAILURE );
1979 #endif /*SLAPD_MODULES*/
1982 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1983 rc = ldap_pvt_tls_set_option( NULL,
1984 LDAP_OPT_X_TLS_PROTOCOL,
1989 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
1990 rc = ldap_pvt_tls_set_option( NULL,
1991 LDAP_OPT_X_TLS_RANDOM_FILE,
1996 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1997 rc = ldap_pvt_tls_set_option( NULL,
1998 LDAP_OPT_X_TLS_CIPHER_SUITE,
2003 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2004 rc = ldap_pvt_tls_set_option( NULL,
2005 LDAP_OPT_X_TLS_CERTFILE,
2010 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2011 rc = ldap_pvt_tls_set_option( NULL,
2012 LDAP_OPT_X_TLS_KEYFILE,
2017 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2018 rc = ldap_pvt_tls_set_option( NULL,
2019 LDAP_OPT_X_TLS_CACERTDIR,
2024 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2025 rc = ldap_pvt_tls_set_option( NULL,
2026 LDAP_OPT_X_TLS_CACERTFILE,
2030 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2032 rc = ldap_pvt_tls_set_option( NULL,
2033 LDAP_OPT_X_TLS_REQUIRE_CERT,
2040 /* pass anything else to the current backend info/db config routine */
2043 if ( bi->bi_config == 0 ) {
2045 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2046 "%s: line %d: unknown directive \"%s\" inside "
2047 "backend info definition (ignored).\n",
2048 fname, lineno, cargv[0] ));
2050 Debug( LDAP_DEBUG_ANY,
2051 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2052 fname, lineno, cargv[0] );
2056 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2062 } else if ( be != NULL ) {
2063 if ( be->be_config == 0 ) {
2065 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2066 "%s: line %d: uknown directive \"%s\" inside "
2067 "backend database definition (ignored).\n",
2068 fname, lineno, cargv[0] ));
2070 Debug( LDAP_DEBUG_ANY,
2071 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2072 fname, lineno, cargv[0] );
2076 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2084 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2085 "%s: line %d: unknown directive \"%s\" outside backend "
2086 "info and database definitions (ignored).\n",
2087 fname, lineno, cargv[0] ));
2089 Debug( LDAP_DEBUG_ANY,
2090 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2091 fname, lineno, cargv[0] );
2099 if ( load_ucdata( NULL ) < 0 ) {
2115 for ( token = strtok_quote( line, " \t" ); token != NULL;
2116 token = strtok_quote( NULL, " \t" ) ) {
2117 if ( *argcp == MAXARGS ) {
2119 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2120 "fp_parse_line: too many tokens (%d max).\n",
2123 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2129 argv[(*argcp)++] = token;
2131 argv[*argcp] = NULL;
2136 strtok_quote( char *line, char *sep )
2142 if ( line != NULL ) {
2145 while ( *next && strchr( sep, *next ) ) {
2149 if ( *next == '\0' ) {
2155 for ( inquote = 0; *next; ) {
2163 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2169 next + 1, strlen( next + 1 ) + 1 );
2170 next++; /* dont parse the escaped character */
2175 if ( strchr( sep, *next ) != NULL ) {
2188 static char buf[BUFSIZ];
2190 static int lmax, lcur;
2192 #define CATLINE( buf ) { \
2194 len = strlen( buf ); \
2195 while ( lcur + len + 1 > lmax ) { \
2197 line = (char *) ch_realloc( line, lmax ); \
2199 strcpy( line + lcur, buf ); \
2204 fp_getline( FILE *fp, int *lineno )
2212 /* hack attack - keeps us from having to keep a stack of bufs... */
2213 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2218 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2219 if ( (p = strchr( buf, '\n' )) != NULL ) {
2222 if ( ! isspace( (unsigned char) buf[0] ) ) {
2226 /* change leading whitespace to a space */
2234 return( line[0] ? line : NULL );
2238 fp_getline_init( int *lineno )
2244 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2246 load_ucdata( char *path )
2248 static int loaded = 0;
2254 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2257 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2258 "load_ucdata: Error %d loading ucdata.\n", err ));
2260 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",