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 int defsize = SLAPD_DEFAULT_SIZELIMIT;
26 int deftime = SLAPD_DEFAULT_TIMELIMIT;
27 AccessControl *global_acl = NULL;
28 slap_access_t global_default_access = ACL_READ;
29 slap_mask_t global_restrictops = 0;
30 slap_mask_t global_allows = 0;
31 slap_mask_t global_disallows = 0;
32 slap_mask_t global_requires = 0;
33 slap_ssf_set_t global_ssf_set;
35 int global_lastmod = ON;
36 int global_idletimeout = 0;
37 char *global_host = NULL;
38 char *global_realm = NULL;
39 char *ldap_srvtab = "";
40 char *default_passwd_hash;
41 char *default_search_base = NULL;
42 char *default_search_nbase = NULL;
44 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
45 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
47 char *slapd_pid_file = NULL;
48 char *slapd_args_file = NULL;
51 SaslRegexp_t *SaslRegexp = NULL;
52 int sasl_external_x509dn_convert;
54 static char *fp_getline(FILE *fp, int *lineno);
55 static void fp_getline_init(int *lineno);
56 static int fp_parse_line(char *line, int *argcp, char **argv);
58 static char *strtok_quote(char *line, char *sep);
59 static int load_ucdata(char *path);
62 read_config( const char *fname )
65 char *line, *savefname, *saveline;
66 int cargc, savelineno;
67 char *cargv[MAXARGS+1];
70 struct berval *vals[2];
73 static BackendInfo *bi = NULL;
74 static BackendDB *be = NULL;
79 if ( (fp = fopen( fname, "r" )) == NULL ) {
81 Debug( LDAP_DEBUG_ANY,
82 "could not open config file \"%s\" - absolute path?\n",
89 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
90 "read_config: reading config file %s\n", fname ));
92 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
96 fp_getline_init( &lineno );
98 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
99 /* skip comments and blank lines */
100 if ( line[0] == '#' || line[0] == '\0' ) {
105 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
106 "line %d (%s)\n", lineno, line ));
108 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
112 /* fp_parse_line is destructive, we save a copy */
113 saveline = ch_strdup( line );
115 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
121 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
122 "%s: line %d: bad config line (ignored)\n",
125 Debug( LDAP_DEBUG_ANY,
126 "%s: line %d: bad config line (ignored)\n",
133 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
136 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
137 "%s : line %d: missing type in \"backend\" line.\n",
140 Debug( LDAP_DEBUG_ANY,
141 "%s: line %d: missing type in \"backend <type>\" line\n",
150 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
151 "%s: line %d: backend line must appear before any "
152 "database definition.\n", fname, lineno ));
154 Debug( LDAP_DEBUG_ANY,
155 "%s: line %d: backend line must appear before any database definition\n",
162 bi = backend_info( cargv[1] );
166 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
167 "read_config: backend %s initialization failed.\n",
170 Debug( LDAP_DEBUG_ANY,
171 "backend %s initialization failed.\n",
177 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
180 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
181 "%s: line %d: missing type in \"database <type>\" line\n",
184 Debug( LDAP_DEBUG_ANY,
185 "%s: line %d: missing type in \"database <type>\" line\n",
193 be = backend_db_init( cargv[1] );
197 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
198 "database %s initialization failed.\n",
201 Debug( LDAP_DEBUG_ANY,
202 "database %s initialization failed.\n",
209 /* set thread concurrency */
210 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
214 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
215 "%s: line %d: missing level in \"concurrency <level\" line\n",
218 Debug( LDAP_DEBUG_ANY,
219 "%s: line %d: missing level in \"concurrency <level>\" line\n",
226 c = atoi( cargv[1] );
230 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
231 "%s: line %d: invalid level (%d) in "
232 "\"concurrency <level>\" line.\n",
235 Debug( LDAP_DEBUG_ANY,
236 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
243 ldap_pvt_thread_set_concurrency( c );
245 /* set sockbuf max */
246 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
250 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
251 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
254 Debug( LDAP_DEBUG_ANY,
255 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
262 max = atol( cargv[1] );
266 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
267 "%s: line %d: invalid max value (%ld) in "
268 "\"sockbuf_max_incoming <bytes>\" line.\n",
269 fname, lineno, max ));
271 Debug( LDAP_DEBUG_ANY,
272 "%s: line %d: invalid max value (%ld) in "
273 "\"sockbuf_max_incoming <bytes>\" line.\n",
274 fname, lineno, max );
280 sockbuf_max_incoming = max;
282 /* set sockbuf max authenticated */
283 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
287 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
288 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
291 Debug( LDAP_DEBUG_ANY,
292 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
299 max = atol( cargv[1] );
303 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
304 "%s: line %d: invalid max value (%ld) in "
305 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
306 fname, lineno, max ));
308 Debug( LDAP_DEBUG_ANY,
309 "%s: line %d: invalid max value (%ld) in "
310 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
311 fname, lineno, max );
317 sockbuf_max_incoming_auth = max;
319 /* default search base */
320 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
323 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
324 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
325 "line\n", fname, lineno ));
327 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
328 "missing dn in \"defaultSearchBase <dn>\" line\n",
334 } else if ( cargc > 2 ) {
336 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
337 "%s: line %d: extra cruft after <dn> in "
338 "\"defaultSearchBase %s\" line (ignored)\n",
339 fname, lineno, cargv[1] ));
341 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
342 "extra cruft after <dn> in \"defaultSearchBase %s\", "
344 fname, lineno, cargv[1] );
349 if ( bi != NULL || be != NULL ) {
351 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
352 "%s: line %d: defaultSearchBase line must appear "
353 "prior to any backend or database definitions\n",
356 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
357 "defaultSearchBaase line must appear prior to "
358 "any backend or database definition\n",
365 if ( default_search_nbase != NULL ) {
367 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
368 "%s: line %d: default search base \"%s\" already defined "
369 "(discarding old)\n", fname, lineno, default_search_base ));
371 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
372 "default search base \"%s\" already defined "
373 "(discarding old)\n",
374 fname, lineno, default_search_base );
377 free( default_search_base );
378 free( default_search_nbase );
381 default_search_base = ch_strdup( cargv[1] );
382 default_search_nbase = ch_strdup( cargv[1] );
384 if ( load_ucdata( NULL ) < 0 ) {
387 if( dn_normalize( default_search_nbase ) == NULL ) {
389 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
390 "%s: %d: invalid default search base \"%s\"\n",
391 fname, lineno, default_search_base ));
393 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
394 "invalid default search base \"%s\"\n",
395 fname, lineno, default_search_base );
401 /* set maximum threads in thread pool */
402 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
406 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
407 "%s: line %d: missing count in \"threads <count>\" line\n",
410 Debug( LDAP_DEBUG_ANY,
411 "%s: line %d: missing count in \"threads <count>\" line\n",
418 c = atoi( cargv[1] );
422 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
423 "%s: line %d: invalid level (%d) in \"threads <count>\""
424 "line\n",fname, lineno, c ));
426 Debug( LDAP_DEBUG_ANY,
427 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
434 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
436 /* get pid file name */
437 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
440 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
441 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
444 Debug( LDAP_DEBUG_ANY,
445 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
452 slapd_pid_file = ch_strdup( cargv[1] );
454 /* get args file name */
455 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
458 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
459 "%s: %d: missing file name in "
460 "\"argsfile <file>\" line.\n",
463 Debug( LDAP_DEBUG_ANY,
464 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
471 slapd_args_file = ch_strdup( cargv[1] );
473 /* default password hash */
474 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
477 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
478 "%s: line %d: missing hash in "
479 "\"password-hash <hash>\" line.\n",
482 Debug( LDAP_DEBUG_ANY,
483 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
489 if ( default_passwd_hash != NULL ) {
491 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
492 "%s: line %d: already set default password_hash!\n",
495 Debug( LDAP_DEBUG_ANY,
496 "%s: line %d: already set default password_hash!\n",
503 default_passwd_hash = ch_strdup( cargv[1] );
506 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
510 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
511 "%s: line %d: missing format in "
512 "\"password-crypt-salt-format <format>\" line\n",
515 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
516 "\"password-crypt-salt-format <format>\" line\n",
523 lutil_salt_format( cargv[1] );
526 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
529 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
530 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
533 Debug( LDAP_DEBUG_ANY,
534 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
541 if ( global_host != NULL ) {
543 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
544 "%s: line %d: already set sasl-host!\n",
547 Debug( LDAP_DEBUG_ANY,
548 "%s: line %d: already set sasl-host!\n",
555 global_host = ch_strdup( cargv[1] );
559 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
562 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
563 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
566 Debug( LDAP_DEBUG_ANY,
567 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
574 if ( global_realm != NULL ) {
576 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
577 "%s: line %d: already set sasl-realm!\n",
580 Debug( LDAP_DEBUG_ANY,
581 "%s: line %d: already set sasl-realm!\n",
588 global_realm = ch_strdup( cargv[1] );
591 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
592 || !strcasecmp( cargv[0], "saslregexp" ) )
597 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
598 "%s: line %d: need 2 args in "
599 "\"saslregexp <match> <replace>\"\n",
602 Debug( LDAP_DEBUG_ANY,
603 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
609 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
614 /* SASL security properties */
615 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
620 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
621 "%s: line %d: missing flags in "
622 "\"sasl-secprops <properties>\" line\n",
625 Debug( LDAP_DEBUG_ANY,
626 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
633 txt = slap_sasl_secprops( cargv[1] );
636 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
637 "%s: line %d sas-secprops: %s\n",
638 fname, lineno, txt ));
640 Debug( LDAP_DEBUG_ANY,
641 "%s: line %d: sasl-secprops: %s\n",
642 fname, lineno, txt );
648 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
649 sasl_external_x509dn_convert++;
651 /* set UCDATA path */
652 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
656 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
657 "%s: line %d: missing path in "
658 "\"ucdata-path <path>\" line.\n",
661 Debug( LDAP_DEBUG_ANY,
662 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
669 err = load_ucdata( cargv[1] );
673 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
674 "%s: line %d: ucdata already loaded, ucdata-path "
675 "must be set earlier in the file and/or be "
676 "specified only once!\n",
679 Debug( LDAP_DEBUG_ANY,
680 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
689 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
692 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
693 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
696 Debug( LDAP_DEBUG_ANY,
697 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
704 defsize = atoi( cargv[1] );
706 be->be_sizelimit = atoi( cargv[1] );
710 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
713 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
714 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
717 Debug( LDAP_DEBUG_ANY,
718 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
725 deftime = atoi( cargv[1] );
727 be->be_timelimit = atoi( cargv[1] );
730 /* set regex-based limits */
731 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
734 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
735 "%s: line %d \"limits\" allowed only in database environment.\n",
738 Debug( LDAP_DEBUG_ANY,
739 "%s: line %d \"limits\" allowed only in database environment.\n%s",
745 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
749 /* set database suffix */
750 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
754 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
755 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
758 Debug( LDAP_DEBUG_ANY,
759 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
764 } else if ( cargc > 2 ) {
766 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
767 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
768 " line (ignored).\n", fname, lineno, cargv[1] ));
770 Debug( LDAP_DEBUG_ANY,
771 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
772 fname, lineno, cargv[1] );
778 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
779 "%s: line %d: suffix line must appear inside a database "
780 "definition (ignored).\n", fname, lineno ));
782 Debug( LDAP_DEBUG_ANY,
783 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
787 #if defined(SLAPD_MONITOR_DN)
788 /* "cn=Monitor" is reserved for monitoring slap */
789 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
791 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
792 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
793 SLAPD_MONITOR_DN, fname, lineno ));
795 Debug( LDAP_DEBUG_ANY,
796 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
797 SLAPD_MONITOR_DN, fname, lineno );
800 #endif /* SLAPD_MONITOR_DN */
802 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
804 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
805 "%s: line %d: suffix already served by this backend "
806 "(ignored)\n", fname, lineno ));
808 Debug( LDAP_DEBUG_ANY,
809 "%s: line %d: suffix already served by this backend (ignored)\n",
813 } else if ( tmp_be != NULL ) {
815 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
816 "%s: line %d: suffix already served by a preceding "
817 "backend \"%s\" (ignored)\n", fname, lineno,
818 tmp_be->be_suffix[0] ));
820 Debug( LDAP_DEBUG_ANY,
821 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
822 fname, lineno, tmp_be->be_suffix[0] );
826 char *dn = ch_strdup( cargv[1] );
827 if ( load_ucdata( NULL ) < 0 ) {
830 if( dn_validate( dn ) == NULL ) {
832 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
833 "%s: line %d: suffix DN invalid\"%s\"\n",
834 fname, lineno, cargv[1] ));
836 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
837 "suffix DN invalid \"%s\"\n",
838 fname, lineno, cargv[1] );
843 } else if( *dn == '\0' && default_search_nbase != NULL ) {
845 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
846 "%s: line %d: suffix DN empty and default search "
847 "base provided \"%s\" (assuming okay).\n",
848 fname, lineno, default_search_base ));
850 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
851 "suffix DN empty and default "
852 "search base provided \"%s\" (assuming okay)\n",
853 fname, lineno, default_search_base );
857 charray_add( &be->be_suffix, dn );
858 (void) ldap_pvt_str2upper( dn );
859 charray_add( &be->be_nsuffix, dn );
863 /* set database suffixAlias */
864 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
868 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
869 "%s: line %d: missing alias and aliased_dn in "
870 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
873 Debug( LDAP_DEBUG_ANY,
874 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
879 } else if ( cargc < 3 ) {
881 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
882 "%s: line %d: missing aliased_dn in "
883 "\"suffixAlias <alias> <aliased_dn>\" line\n",
886 Debug( LDAP_DEBUG_ANY,
887 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
892 } else if ( cargc > 3 ) {
894 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
895 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
898 Debug( LDAP_DEBUG_ANY,
899 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
907 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
908 "%s: line %d: suffixAlias line must appear inside a "
909 "database definition (ignored).\n", fname, lineno ));
911 Debug( LDAP_DEBUG_ANY,
912 "%s: line %d: suffixAlias line"
913 " must appear inside a database definition (ignored)\n",
917 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
919 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
920 "%s: line %d: suffixAlias served by a preceeding "
921 "backend \"%s\" (ignored).\n", fname, lineno,
922 tmp_be->be_suffix[0] ));
924 Debug( LDAP_DEBUG_ANY,
925 "%s: line %d: suffixAlias served by"
926 " a preceeding backend \"%s\" (ignored)\n",
927 fname, lineno, tmp_be->be_suffix[0] );
931 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
933 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
934 "%s: line %d: suffixAlias derefs to a different backend "
935 "a preceeding backend \"%s\" (ignored)\n",
936 fname, lineno, tmp_be->be_suffix[0] ));
938 Debug( LDAP_DEBUG_ANY,
939 "%s: line %d: suffixAlias derefs to differnet backend"
940 " a preceeding backend \"%s\" (ignored)\n",
941 fname, lineno, tmp_be->be_suffix[0] );
946 char *alias, *aliased_dn;
948 alias = ch_strdup( cargv[1] );
949 if ( load_ucdata( NULL ) < 0 ) {
952 (void) dn_normalize( alias );
954 aliased_dn = ch_strdup( cargv[2] );
955 (void) dn_normalize( aliased_dn );
957 charray_add( &be->be_suffixAlias, alias );
958 charray_add( &be->be_suffixAlias, aliased_dn );
964 /* set max deref depth */
965 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
969 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
970 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
971 " line\n", fname, lineno ));
973 Debug( LDAP_DEBUG_ANY,
974 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
982 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
983 "%s: line %d: depth line must appear inside a database "
984 "definition (ignored)\n", fname, lineno ));
986 Debug( LDAP_DEBUG_ANY,
987 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
991 } else if ((i = atoi(cargv[1])) < 0) {
993 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
994 "%s: line %d: depth must be positive (ignored).\n",
997 Debug( LDAP_DEBUG_ANY,
998 "%s: line %d: depth must be positive (ignored)\n",
1004 be->be_max_deref_depth = i;
1008 /* set magic "root" dn for this database */
1009 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1012 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1013 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1016 Debug( LDAP_DEBUG_ANY,
1017 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1025 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1026 "%s: line %d: rootdn line must appear inside a database "
1027 "definition (ignored).\n", fname, lineno ));
1029 Debug( LDAP_DEBUG_ANY,
1030 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1035 be->be_root_dn = ch_strdup( cargv[1] );
1036 be->be_root_ndn = ch_strdup( cargv[1] );
1038 if ( load_ucdata( NULL ) < 0 ) {
1041 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1042 free( be->be_root_dn );
1043 free( be->be_root_ndn );
1045 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1046 "%s: line %d: rootdn DN is invalid.\n",
1049 Debug( LDAP_DEBUG_ANY,
1050 "%s: line %d: rootdn DN is invalid\n",
1058 /* set super-secret magic database password */
1059 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1062 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1063 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1064 " line\n", fname, lineno ));
1066 Debug( LDAP_DEBUG_ANY,
1067 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1075 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1076 "%s: line %d: rootpw line must appear inside a database "
1077 "definition (ignored)\n", fname, lineno ));
1079 Debug( LDAP_DEBUG_ANY,
1080 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1085 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1086 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1089 /* make this database read-only */
1090 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1093 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1094 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1097 Debug( LDAP_DEBUG_ANY,
1098 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1105 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1106 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1108 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1111 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1112 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1114 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1119 /* allow these features */
1120 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1121 strcasecmp( cargv[0], "allow" ) == 0 )
1127 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1128 "%s: line %d: allow line must appear prior to "
1129 "database definitions.\n", fname, lineno ));
1131 Debug( LDAP_DEBUG_ANY,
1132 "%s: line %d: allow line must appear prior to database definitions\n",
1140 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1141 "%s: line %d: missing feature(s) in \"allow <features>\""
1142 " line\n", fname, lineno ));
1144 Debug( LDAP_DEBUG_ANY,
1145 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1154 for( i=1; i < cargc; i++ ) {
1155 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1156 allows |= SLAP_ALLOW_TLS_2_ANON;
1158 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1160 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1161 "%s: line %d: unknown feature %s in "
1162 "\"allow <features>\" line.\n",
1163 fname, lineno, cargv[1] ));
1165 Debug( LDAP_DEBUG_ANY,
1166 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1167 fname, lineno, cargv[i] );
1174 global_allows = allows;
1176 /* disallow these features */
1177 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1178 strcasecmp( cargv[0], "disallow" ) == 0 )
1180 slap_mask_t disallows;
1184 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1185 "%s: line %d: disallow line must appear prior to "
1186 "database definitions.\n", fname, lineno ));
1188 Debug( LDAP_DEBUG_ANY,
1189 "%s: line %d: disallow line must appear prior to database definitions\n",
1197 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1198 "%s: line %d: missing feature(s) in \"disallow <features>\""
1199 " line.\n", fname, lineno ));
1201 Debug( LDAP_DEBUG_ANY,
1202 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1211 for( i=1; i < cargc; i++ ) {
1212 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1213 disallows |= SLAP_DISALLOW_BIND_V2;
1215 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1216 disallows |= SLAP_DISALLOW_BIND_ANON;
1218 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1219 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1221 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1222 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1224 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1225 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1227 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1228 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1230 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1231 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1233 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1235 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1236 "%s: line %d: unknown feature %s in "
1237 "\"disallow <features>\" line.\n",
1238 fname, lineno, cargv[i] ));
1240 Debug( LDAP_DEBUG_ANY,
1241 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1242 fname, lineno, cargv[i] );
1249 global_disallows = disallows;
1251 /* require these features */
1252 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1253 strcasecmp( cargv[0], "require" ) == 0 )
1255 slap_mask_t requires;
1259 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1260 "%s: line %d: missing feature(s) in "
1261 "\"require <features>\" line.\n", fname, lineno ));
1263 Debug( LDAP_DEBUG_ANY,
1264 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1273 for( i=1; i < cargc; i++ ) {
1274 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1275 requires |= SLAP_REQUIRE_BIND;
1277 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1278 requires |= SLAP_REQUIRE_LDAP_V3;
1280 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1281 requires |= SLAP_REQUIRE_AUTHC;
1283 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1284 requires |= SLAP_REQUIRE_SASL;
1286 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1287 requires |= SLAP_REQUIRE_STRONG;
1289 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1291 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1292 "%s: line %d: unknown feature %s in "
1293 "\"require <features>\" line.\n",
1296 Debug( LDAP_DEBUG_ANY,
1297 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1298 fname, lineno, cargv[i] );
1306 global_requires = requires;
1308 be->be_requires = requires;
1311 /* required security factors */
1312 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1313 slap_ssf_set_t *set;
1317 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1318 "%s: line %d: missing factor(s) in \"security <factors>\""
1319 " line.\n", fname, lineno ));
1321 Debug( LDAP_DEBUG_ANY,
1322 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1330 set = &global_ssf_set;
1332 set = &be->be_ssf_set;
1335 for( i=1; i < cargc; i++ ) {
1336 if( strncasecmp( cargv[i], "ssf=",
1337 sizeof("ssf") ) == 0 )
1340 atoi( &cargv[i][sizeof("ssf")] );
1342 } else if( strncasecmp( cargv[i], "transport=",
1343 sizeof("transport") ) == 0 )
1345 set->sss_transport =
1346 atoi( &cargv[i][sizeof("transport")] );
1348 } else if( strncasecmp( cargv[i], "tls=",
1349 sizeof("tls") ) == 0 )
1352 atoi( &cargv[i][sizeof("tls")] );
1354 } else if( strncasecmp( cargv[i], "sasl=",
1355 sizeof("sasl") ) == 0 )
1358 atoi( &cargv[i][sizeof("sasl")] );
1360 } else if( strncasecmp( cargv[i], "update_ssf=",
1361 sizeof("update_ssf") ) == 0 )
1363 set->sss_update_ssf =
1364 atoi( &cargv[i][sizeof("update_ssf")] );
1366 } else if( strncasecmp( cargv[i], "update_transport=",
1367 sizeof("update_transport") ) == 0 )
1369 set->sss_update_transport =
1370 atoi( &cargv[i][sizeof("update_transport")] );
1372 } else if( strncasecmp( cargv[i], "update_tls=",
1373 sizeof("update_tls") ) == 0 )
1375 set->sss_update_tls =
1376 atoi( &cargv[i][sizeof("update_tls")] );
1378 } else if( strncasecmp( cargv[i], "update_sasl=",
1379 sizeof("update_sasl") ) == 0 )
1381 set->sss_update_sasl =
1382 atoi( &cargv[i][sizeof("update_sasl")] );
1386 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1387 "%s: line %d: unknown factor %S in "
1388 "\"security <factors>\" line.\n",
1389 fname, lineno, cargv[1] ));
1391 Debug( LDAP_DEBUG_ANY,
1392 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1393 fname, lineno, cargv[i] );
1399 /* where to send clients when we don't hold it */
1400 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1403 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1404 "%s: line %d: missing URL in \"referral <URL>\""
1405 " line.\n", fname, lineno ));
1407 Debug( LDAP_DEBUG_ANY,
1408 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1415 vals[0]->bv_val = cargv[1];
1416 vals[0]->bv_len = strlen( vals[0]->bv_val );
1417 value_add( &default_referral, vals );
1420 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1424 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1425 "%s: line %d: Error in logfile directive, "
1426 "\"logfile <filename>\"\n", fname, lineno ));
1428 Debug( LDAP_DEBUG_ANY,
1429 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1435 logfile = fopen( cargv[1], "w" );
1436 if ( logfile != NULL ) lutil_debug_file( logfile );
1439 /* start of a new database definition */
1440 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1444 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1445 "%s: line %d: Error in debug directive, "
1446 "\"debug <subsys> <level>\"\n", fname, lineno ));
1448 Debug( LDAP_DEBUG_ANY,
1449 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1455 level = atoi( cargv[2] );
1456 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1457 lutil_set_debug_level( cargv[1], level );
1458 /* specify an Object Identifier macro */
1459 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1460 rc = parse_oidm( fname, lineno, cargc, cargv );
1463 /* specify an objectclass */
1464 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1465 if ( *cargv[1] == '(' ) {
1467 p = strchr(saveline,'(');
1468 rc = parse_oc( fname, lineno, p, cargv );
1473 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1474 "%s: line %d: old objectclass format not supported\n",
1477 Debug( LDAP_DEBUG_ANY,
1478 "%s: line %d: old objectclass format not supported.\n",
1484 /* specify an attribute type */
1485 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1486 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1488 if ( *cargv[1] == '(' ) {
1490 p = strchr(saveline,'(');
1491 rc = parse_at( fname, lineno, p, cargv );
1496 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1497 "%s: line %d: old attribute type format not supported.\n",
1500 Debug( LDAP_DEBUG_ANY,
1501 "%s: line %d: old attribute type format not supported.\n",
1507 /* turn on/off schema checking */
1508 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1511 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1512 "%s: line %d: missing on|off in "
1513 "\"schemacheck <on|off>\" line.\n",
1516 Debug( LDAP_DEBUG_ANY,
1517 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1523 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1524 global_schemacheck = 0;
1526 global_schemacheck = 1;
1529 /* specify access control info */
1530 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1531 parse_acl( be, fname, lineno, cargc, cargv );
1533 /* debug level to log things to syslog */
1534 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1537 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1538 "%s: line %d: missing level in \"loglevel <level>\""
1539 " line.\n", fname, lineno ));
1541 Debug( LDAP_DEBUG_ANY,
1542 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1551 for( i=1; i < cargc; i++ ) {
1552 ldap_syslog += atoi( cargv[1] );
1555 /* list of replicas of the data in this backend (master only) */
1556 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1559 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1560 "%s: line %d: missing host in \"replica "
1561 " <host[:port]\" line\n", fname, lineno ));
1563 Debug( LDAP_DEBUG_ANY,
1564 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1572 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1573 "%s: line %d: replica line must appear inside "
1574 "a database definition (ignored).\n", fname, lineno ));
1576 Debug( LDAP_DEBUG_ANY,
1577 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1584 for ( i = 1; i < cargc; i++ ) {
1585 if ( strncasecmp( cargv[i], "host=", 5 )
1587 nr = add_replica_info( be,
1594 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1595 "%s: line %d: missing host in \"replica\" "
1596 "line (ignored)\n", fname, lineno ));
1598 Debug( LDAP_DEBUG_ANY,
1599 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1603 } else if ( nr == -1 ) {
1605 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1606 "%s: line %d: unable to add"
1612 Debug( LDAP_DEBUG_ANY,
1613 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1614 fname, lineno, cargv[i] + 5 );
1617 for ( i = 1; i < cargc; i++ ) {
1618 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1619 char *nsuffix = ch_strdup( cargv[i] + 7 );
1620 if ( dn_normalize( nsuffix ) != NULL ) {
1621 if ( be_issuffix( be, nsuffix ) ) {
1622 charray_add( &be->be_replica[nr]->ri_nsuffix, nsuffix );
1625 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1626 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1627 fname, lineno, cargv[i] + 7 ));
1629 Debug( LDAP_DEBUG_ANY,
1630 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1631 fname, lineno, cargv[i] + 7 );
1636 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1637 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1640 Debug( LDAP_DEBUG_ANY,
1641 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1651 /* dn of master entity allowed to write to replica */
1652 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1655 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1656 "%s: line %d: missing dn in \"updatedn <dn>\""
1657 " line.\n", fname, lineno ));
1659 Debug( LDAP_DEBUG_ANY,
1660 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1668 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1669 "%s: line %d: updatedn line must appear inside "
1670 "a database definition (ignored)\n",
1673 Debug( LDAP_DEBUG_ANY,
1674 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1679 be->be_update_ndn = ch_strdup( cargv[1] );
1680 if ( load_ucdata( NULL ) < 0 ) {
1683 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1685 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1686 "%s: line %d: updatedn DN is invalid.\n",
1689 Debug( LDAP_DEBUG_ANY,
1690 "%s: line %d: updatedn DN is invalid\n",
1698 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1701 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1702 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1703 "line.\n", fname, lineno ));
1705 Debug( LDAP_DEBUG_ANY,
1706 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1714 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1715 "%s: line %d: updateref line must appear inside "
1716 "a database definition (ignored)\n", fname, lineno ));
1718 Debug( LDAP_DEBUG_ANY,
1719 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1723 } else if ( be->be_update_ndn == NULL ) {
1725 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1726 "%s: line %d: updateref line must come after updatedn "
1727 "(ignored).\n", fname, lineno ));
1729 Debug( LDAP_DEBUG_ANY,
1730 "%s: line %d: updateref line must after updatedn (ignored)\n",
1735 vals[0]->bv_val = cargv[1];
1736 vals[0]->bv_len = strlen( vals[0]->bv_val );
1737 value_add( &be->be_update_refs, vals );
1740 /* replication log file to which changes are appended */
1741 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1744 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1745 "%s: line %d: missing filename in \"replogfile <filename>\""
1746 " line.\n", fname, lineno ));
1748 Debug( LDAP_DEBUG_ANY,
1749 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1756 be->be_replogfile = ch_strdup( cargv[1] );
1758 replogfile = ch_strdup( cargv[1] );
1761 /* maintain lastmodified{by,time} attributes */
1762 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1765 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1766 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1767 " line.\n", fname, lineno ));
1769 Debug( LDAP_DEBUG_ANY,
1770 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1776 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1778 be->be_lastmod = ON;
1780 global_lastmod = ON;
1783 be->be_lastmod = OFF;
1785 global_lastmod = OFF;
1788 /* set idle timeout value */
1789 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1793 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1794 "%s: line %d: missing timeout value in "
1795 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1797 Debug( LDAP_DEBUG_ANY,
1798 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1805 i = atoi( cargv[1] );
1809 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1810 "%s: line %d: timeout value (%d) invalid "
1811 "\"idletimeout <seconds>\" line.\n",
1812 fname, lineno, i ));
1814 Debug( LDAP_DEBUG_ANY,
1815 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1822 global_idletimeout = i;
1824 /* include another config file */
1825 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1828 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1829 "%s: line %d: missing filename in \"include "
1830 "<filename>\" line.\n", fname, lineno ));
1832 Debug( LDAP_DEBUG_ANY,
1833 "%s: line %d: missing filename in \"include <filename>\" line\n",
1839 savefname = ch_strdup( cargv[1] );
1840 savelineno = lineno;
1842 if ( read_config( savefname ) != 0 ) {
1847 lineno = savelineno - 1;
1849 /* location of kerberos srvtab file */
1850 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1853 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1854 "%s: line %d: missing filename in \"srvtab "
1855 "<filename>\" line.\n", fname, lineno ));
1857 Debug( LDAP_DEBUG_ANY,
1858 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1864 ldap_srvtab = ch_strdup( cargv[1] );
1866 #ifdef SLAPD_MODULES
1867 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1870 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1871 "%s: line %d: missing filename in \"moduleload "
1872 "<filename>\" line.\n", fname, lineno ));
1874 Debug( LDAP_DEBUG_ANY,
1875 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1879 exit( EXIT_FAILURE );
1881 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1883 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1884 "%s: line %d: failed to load or initialize module %s\n"<
1885 fname, lineno, cargv[1] ));
1887 Debug( LDAP_DEBUG_ANY,
1888 "%s: line %d: failed to load or initialize module %s\n",
1889 fname, lineno, cargv[1]);
1892 exit( EXIT_FAILURE );
1894 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1897 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1898 "%s: line %d: missing path in \"modulepath <path>\""
1899 " line\n", fname, lineno ));
1901 Debug( LDAP_DEBUG_ANY,
1902 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1906 exit( EXIT_FAILURE );
1908 if (module_path( cargv[1] )) {
1910 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1911 "%s: line %d: failed to set module search path to %s.\n",
1912 fname, lineno, cargv[1] ));
1914 Debug( LDAP_DEBUG_ANY,
1915 "%s: line %d: failed to set module search path to %s\n",
1916 fname, lineno, cargv[1]);
1919 exit( EXIT_FAILURE );
1922 #endif /*SLAPD_MODULES*/
1925 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1926 rc = ldap_pvt_tls_set_option( NULL,
1927 LDAP_OPT_X_TLS_PROTOCOL,
1932 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
1933 rc = ldap_pvt_tls_set_option( NULL,
1934 LDAP_OPT_X_TLS_RANDOM_FILE,
1939 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1940 rc = ldap_pvt_tls_set_option( NULL,
1941 LDAP_OPT_X_TLS_CIPHER_SUITE,
1946 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1947 rc = ldap_pvt_tls_set_option( NULL,
1948 LDAP_OPT_X_TLS_CERTFILE,
1953 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1954 rc = ldap_pvt_tls_set_option( NULL,
1955 LDAP_OPT_X_TLS_KEYFILE,
1960 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1961 rc = ldap_pvt_tls_set_option( NULL,
1962 LDAP_OPT_X_TLS_CACERTDIR,
1967 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1968 rc = ldap_pvt_tls_set_option( NULL,
1969 LDAP_OPT_X_TLS_CACERTFILE,
1973 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1975 rc = ldap_pvt_tls_set_option( NULL,
1976 LDAP_OPT_X_TLS_REQUIRE_CERT,
1983 /* pass anything else to the current backend info/db config routine */
1986 if ( bi->bi_config == 0 ) {
1988 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1989 "%s: line %d: unknown directive \"%s\" inside "
1990 "backend info definition (ignored).\n",
1991 fname, lineno, cargv[0] ));
1993 Debug( LDAP_DEBUG_ANY,
1994 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1995 fname, lineno, cargv[0] );
1999 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2005 } else if ( be != NULL ) {
2006 if ( be->be_config == 0 ) {
2008 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2009 "%s: line %d: uknown directive \"%s\" inside "
2010 "backend database definition (ignored).\n",
2011 fname, lineno, cargv[0] ));
2013 Debug( LDAP_DEBUG_ANY,
2014 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2015 fname, lineno, cargv[0] );
2019 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2027 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2028 "%s: line %d: unknown directive \"%s\" outside backend "
2029 "info and database definitions (ignored).\n",
2030 fname, lineno, cargv[0] ));
2032 Debug( LDAP_DEBUG_ANY,
2033 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2034 fname, lineno, cargv[0] );
2042 if ( load_ucdata( NULL ) < 0 ) {
2058 for ( token = strtok_quote( line, " \t" ); token != NULL;
2059 token = strtok_quote( NULL, " \t" ) ) {
2060 if ( *argcp == MAXARGS ) {
2062 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2063 "fp_parse_line: too many tokens (%d max).\n",
2066 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2072 argv[(*argcp)++] = token;
2074 argv[*argcp] = NULL;
2079 strtok_quote( char *line, char *sep )
2085 if ( line != NULL ) {
2088 while ( *next && strchr( sep, *next ) ) {
2092 if ( *next == '\0' ) {
2098 for ( inquote = 0; *next; ) {
2106 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2112 next + 1, strlen( next + 1 ) + 1 );
2113 next++; /* dont parse the escaped character */
2118 if ( strchr( sep, *next ) != NULL ) {
2131 static char buf[BUFSIZ];
2133 static int lmax, lcur;
2135 #define CATLINE( buf ) { \
2137 len = strlen( buf ); \
2138 while ( lcur + len + 1 > lmax ) { \
2140 line = (char *) ch_realloc( line, lmax ); \
2142 strcpy( line + lcur, buf ); \
2147 fp_getline( FILE *fp, int *lineno )
2155 /* hack attack - keeps us from having to keep a stack of bufs... */
2156 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2161 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2162 if ( (p = strchr( buf, '\n' )) != NULL ) {
2165 if ( ! isspace( (unsigned char) buf[0] ) ) {
2169 /* change leading whitespace to a space */
2177 return( line[0] ? line : NULL );
2181 fp_getline_init( int *lineno )
2187 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2189 load_ucdata( char *path )
2191 static int loaded = 0;
2197 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2200 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2201 "load_ucdata: Error %d loading ucdata.\n", err ));
2203 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",