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 database suffix */
731 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
735 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
736 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
739 Debug( LDAP_DEBUG_ANY,
740 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
745 } else if ( cargc > 2 ) {
747 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
748 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
749 " line (ignored).\n", fname, lineno, cargv[1] ));
751 Debug( LDAP_DEBUG_ANY,
752 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
753 fname, lineno, cargv[1] );
759 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
760 "%s: line %d: suffix line must appear inside a database "
761 "definition (ignored).\n", fname, lineno ));
763 Debug( LDAP_DEBUG_ANY,
764 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
768 #if defined(SLAPD_MONITOR_DN)
769 /* "cn=Monitor" is reserved for monitoring slap */
770 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
772 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
773 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
774 SLAPD_MONITOR_DN, fname, lineno ));
776 Debug( LDAP_DEBUG_ANY,
777 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
778 SLAPD_MONITOR_DN, fname, lineno );
781 #endif /* SLAPD_MONITOR_DN */
783 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
785 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
786 "%s: line %d: suffix already served by this backend "
787 "(ignored)\n", fname, lineno ));
789 Debug( LDAP_DEBUG_ANY,
790 "%s: line %d: suffix already served by this backend (ignored)\n",
794 } else if ( tmp_be != NULL ) {
796 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
797 "%s: line %d: suffix already served by a preceding "
798 "backend \"%s\" (ignored)\n", fname, lineno,
799 tmp_be->be_suffix[0] ));
801 Debug( LDAP_DEBUG_ANY,
802 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
803 fname, lineno, tmp_be->be_suffix[0] );
807 char *dn = ch_strdup( cargv[1] );
808 if ( load_ucdata( NULL ) < 0 ) {
811 if( dn_validate( dn ) == NULL ) {
813 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
814 "%s: line %d: suffix DN invalid\"%s\"\n",
815 fname, lineno, cargv[1] ));
817 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
818 "suffix DN invalid \"%s\"\n",
819 fname, lineno, cargv[1] );
824 } else if( *dn == '\0' && default_search_nbase != NULL ) {
826 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
827 "%s: line %d: suffix DN empty and default search "
828 "base provided \"%s\" (assuming okay).\n",
829 fname, lineno, default_search_base ));
831 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
832 "suffix DN empty and default "
833 "search base provided \"%s\" (assuming okay)\n",
834 fname, lineno, default_search_base );
838 charray_add( &be->be_suffix, dn );
839 (void) ldap_pvt_str2upper( dn );
840 charray_add( &be->be_nsuffix, dn );
844 /* set database suffixAlias */
845 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
849 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
850 "%s: line %d: missing alias and aliased_dn in "
851 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
854 Debug( LDAP_DEBUG_ANY,
855 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
860 } else if ( cargc < 3 ) {
862 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
863 "%s: line %d: missing aliased_dn in "
864 "\"suffixAlias <alias> <aliased_dn>\" line\n",
867 Debug( LDAP_DEBUG_ANY,
868 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
873 } else if ( cargc > 3 ) {
875 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
876 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
879 Debug( LDAP_DEBUG_ANY,
880 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
888 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
889 "%s: line %d: suffixAlias line must appear inside a "
890 "database definition (ignored).\n", fname, lineno ));
892 Debug( LDAP_DEBUG_ANY,
893 "%s: line %d: suffixAlias line"
894 " must appear inside a database definition (ignored)\n",
898 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
900 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
901 "%s: line %d: suffixAlias served by a preceeding "
902 "backend \"%s\" (ignored).\n", fname, lineno,
903 tmp_be->be_suffix[0] ));
905 Debug( LDAP_DEBUG_ANY,
906 "%s: line %d: suffixAlias served by"
907 " a preceeding backend \"%s\" (ignored)\n",
908 fname, lineno, tmp_be->be_suffix[0] );
912 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
914 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
915 "%s: line %d: suffixAlias derefs to a different backend "
916 "a preceeding backend \"%s\" (ignored)\n",
917 fname, lineno, tmp_be->be_suffix[0] ));
919 Debug( LDAP_DEBUG_ANY,
920 "%s: line %d: suffixAlias derefs to differnet backend"
921 " a preceeding backend \"%s\" (ignored)\n",
922 fname, lineno, tmp_be->be_suffix[0] );
927 char *alias, *aliased_dn;
929 alias = ch_strdup( cargv[1] );
930 if ( load_ucdata( NULL ) < 0 ) {
933 (void) dn_normalize( alias );
935 aliased_dn = ch_strdup( cargv[2] );
936 (void) dn_normalize( aliased_dn );
938 charray_add( &be->be_suffixAlias, alias );
939 charray_add( &be->be_suffixAlias, aliased_dn );
945 /* set max deref depth */
946 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
950 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
951 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
952 " line\n", fname, lineno ));
954 Debug( LDAP_DEBUG_ANY,
955 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
963 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
964 "%s: line %d: depth line must appear inside a database "
965 "definition (ignored)\n", fname, lineno ));
967 Debug( LDAP_DEBUG_ANY,
968 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
972 } else if ((i = atoi(cargv[1])) < 0) {
974 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
975 "%s: line %d: depth must be positive (ignored).\n",
978 Debug( LDAP_DEBUG_ANY,
979 "%s: line %d: depth must be positive (ignored)\n",
985 be->be_max_deref_depth = i;
989 /* set magic "root" dn for this database */
990 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
993 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
994 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
997 Debug( LDAP_DEBUG_ANY,
998 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1006 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1007 "%s: line %d: rootdn line must appear inside a database "
1008 "definition (ignored).\n", fname, lineno ));
1010 Debug( LDAP_DEBUG_ANY,
1011 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1016 be->be_root_dn = ch_strdup( cargv[1] );
1017 be->be_root_ndn = ch_strdup( cargv[1] );
1019 if ( load_ucdata( NULL ) < 0 ) {
1022 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1023 free( be->be_root_dn );
1024 free( be->be_root_ndn );
1026 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1027 "%s: line %d: rootdn DN is invalid.\n",
1030 Debug( LDAP_DEBUG_ANY,
1031 "%s: line %d: rootdn DN is invalid\n",
1039 /* set super-secret magic database password */
1040 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1043 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1044 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1045 " line\n", fname, lineno ));
1047 Debug( LDAP_DEBUG_ANY,
1048 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1056 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1057 "%s: line %d: rootpw line must appear inside a database "
1058 "definition (ignored)\n", fname, lineno ));
1060 Debug( LDAP_DEBUG_ANY,
1061 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1066 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1067 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1070 /* make this database read-only */
1071 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1074 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1075 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1078 Debug( LDAP_DEBUG_ANY,
1079 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1086 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1087 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1089 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1092 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1093 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1095 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1100 /* allow these features */
1101 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1102 strcasecmp( cargv[0], "allow" ) == 0 )
1108 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1109 "%s: line %d: allow line must appear prior to "
1110 "database definitions.\n", fname, lineno ));
1112 Debug( LDAP_DEBUG_ANY,
1113 "%s: line %d: allow line must appear prior to database definitions\n",
1121 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1122 "%s: line %d: missing feature(s) in \"allow <features>\""
1123 " line\n", fname, lineno ));
1125 Debug( LDAP_DEBUG_ANY,
1126 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1135 for( i=1; i < cargc; i++ ) {
1136 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1137 allows |= SLAP_ALLOW_TLS_2_ANON;
1139 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1141 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1142 "%s: line %d: unknown feature %s in "
1143 "\"allow <features>\" line.\n",
1144 fname, lineno, cargv[1] ));
1146 Debug( LDAP_DEBUG_ANY,
1147 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1148 fname, lineno, cargv[i] );
1155 global_allows = allows;
1157 /* disallow these features */
1158 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1159 strcasecmp( cargv[0], "disallow" ) == 0 )
1161 slap_mask_t disallows;
1165 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1166 "%s: line %d: disallow line must appear prior to "
1167 "database definitions.\n", fname, lineno ));
1169 Debug( LDAP_DEBUG_ANY,
1170 "%s: line %d: disallow line must appear prior to database definitions\n",
1178 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1179 "%s: line %d: missing feature(s) in \"disallow <features>\""
1180 " line.\n", fname, lineno ));
1182 Debug( LDAP_DEBUG_ANY,
1183 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1192 for( i=1; i < cargc; i++ ) {
1193 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1194 disallows |= SLAP_DISALLOW_BIND_V2;
1196 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1197 disallows |= SLAP_DISALLOW_BIND_ANON;
1199 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1200 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1202 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1203 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1205 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1206 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1208 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1209 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1211 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1212 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1214 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1216 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1217 "%s: line %d: unknown feature %s in "
1218 "\"disallow <features>\" line.\n",
1219 fname, lineno, cargv[i] ));
1221 Debug( LDAP_DEBUG_ANY,
1222 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1223 fname, lineno, cargv[i] );
1230 global_disallows = disallows;
1232 /* require these features */
1233 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1234 strcasecmp( cargv[0], "require" ) == 0 )
1236 slap_mask_t requires;
1240 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1241 "%s: line %d: missing feature(s) in "
1242 "\"require <features>\" line.\n", fname, lineno ));
1244 Debug( LDAP_DEBUG_ANY,
1245 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1254 for( i=1; i < cargc; i++ ) {
1255 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1256 requires |= SLAP_REQUIRE_BIND;
1258 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1259 requires |= SLAP_REQUIRE_LDAP_V3;
1261 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1262 requires |= SLAP_REQUIRE_AUTHC;
1264 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1265 requires |= SLAP_REQUIRE_SASL;
1267 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1268 requires |= SLAP_REQUIRE_STRONG;
1270 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1272 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1273 "%s: line %d: unknown feature %s in "
1274 "\"require <features>\" line.\n",
1277 Debug( LDAP_DEBUG_ANY,
1278 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1279 fname, lineno, cargv[i] );
1287 global_requires = requires;
1289 be->be_requires = requires;
1292 /* required security factors */
1293 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1294 slap_ssf_set_t *set;
1298 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1299 "%s: line %d: missing factor(s) in \"security <factors>\""
1300 " line.\n", fname, lineno ));
1302 Debug( LDAP_DEBUG_ANY,
1303 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1311 set = &global_ssf_set;
1313 set = &be->be_ssf_set;
1316 for( i=1; i < cargc; i++ ) {
1317 if( strncasecmp( cargv[i], "ssf=",
1318 sizeof("ssf") ) == 0 )
1321 atoi( &cargv[i][sizeof("ssf")] );
1323 } else if( strncasecmp( cargv[i], "transport=",
1324 sizeof("transport") ) == 0 )
1326 set->sss_transport =
1327 atoi( &cargv[i][sizeof("transport")] );
1329 } else if( strncasecmp( cargv[i], "tls=",
1330 sizeof("tls") ) == 0 )
1333 atoi( &cargv[i][sizeof("tls")] );
1335 } else if( strncasecmp( cargv[i], "sasl=",
1336 sizeof("sasl") ) == 0 )
1339 atoi( &cargv[i][sizeof("sasl")] );
1341 } else if( strncasecmp( cargv[i], "update_ssf=",
1342 sizeof("update_ssf") ) == 0 )
1344 set->sss_update_ssf =
1345 atoi( &cargv[i][sizeof("update_ssf")] );
1347 } else if( strncasecmp( cargv[i], "update_transport=",
1348 sizeof("update_transport") ) == 0 )
1350 set->sss_update_transport =
1351 atoi( &cargv[i][sizeof("update_transport")] );
1353 } else if( strncasecmp( cargv[i], "update_tls=",
1354 sizeof("update_tls") ) == 0 )
1356 set->sss_update_tls =
1357 atoi( &cargv[i][sizeof("update_tls")] );
1359 } else if( strncasecmp( cargv[i], "update_sasl=",
1360 sizeof("update_sasl") ) == 0 )
1362 set->sss_update_sasl =
1363 atoi( &cargv[i][sizeof("update_sasl")] );
1367 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1368 "%s: line %d: unknown factor %S in "
1369 "\"security <factors>\" line.\n",
1370 fname, lineno, cargv[1] ));
1372 Debug( LDAP_DEBUG_ANY,
1373 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1374 fname, lineno, cargv[i] );
1380 /* where to send clients when we don't hold it */
1381 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1384 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1385 "%s: line %d: missing URL in \"referral <URL>\""
1386 " line.\n", fname, lineno ));
1388 Debug( LDAP_DEBUG_ANY,
1389 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1396 vals[0]->bv_val = cargv[1];
1397 vals[0]->bv_len = strlen( vals[0]->bv_val );
1398 value_add( &default_referral, vals );
1401 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1405 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1406 "%s: line %d: Error in logfile directive, "
1407 "\"logfile <filename>\"\n", fname, lineno ));
1409 Debug( LDAP_DEBUG_ANY,
1410 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1416 logfile = fopen( cargv[1], "w" );
1417 if ( logfile != NULL ) lutil_debug_file( logfile );
1420 /* start of a new database definition */
1421 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1425 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1426 "%s: line %d: Error in debug directive, "
1427 "\"debug <subsys> <level>\"\n", fname, lineno ));
1429 Debug( LDAP_DEBUG_ANY,
1430 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1436 level = atoi( cargv[2] );
1437 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1438 lutil_set_debug_level( cargv[1], level );
1439 /* specify an Object Identifier macro */
1440 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1441 rc = parse_oidm( fname, lineno, cargc, cargv );
1444 /* specify an objectclass */
1445 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1446 if ( *cargv[1] == '(' ) {
1448 p = strchr(saveline,'(');
1449 rc = parse_oc( fname, lineno, p, cargv );
1454 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1455 "%s: line %d: old objectclass format not supported\n",
1458 Debug( LDAP_DEBUG_ANY,
1459 "%s: line %d: old objectclass format not supported.\n",
1465 /* specify an attribute type */
1466 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1467 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1469 if ( *cargv[1] == '(' ) {
1471 p = strchr(saveline,'(');
1472 rc = parse_at( fname, lineno, p, cargv );
1477 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1478 "%s: line %d: old attribute type format not supported.\n",
1481 Debug( LDAP_DEBUG_ANY,
1482 "%s: line %d: old attribute type format not supported.\n",
1488 /* turn on/off schema checking */
1489 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1492 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1493 "%s: line %d: missing on|off in "
1494 "\"schemacheck <on|off>\" line.\n",
1497 Debug( LDAP_DEBUG_ANY,
1498 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1504 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1505 global_schemacheck = 0;
1507 global_schemacheck = 1;
1510 /* specify access control info */
1511 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1512 parse_acl( be, fname, lineno, cargc, cargv );
1514 /* debug level to log things to syslog */
1515 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1518 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1519 "%s: line %d: missing level in \"loglevel <level>\""
1520 " line.\n", fname, lineno ));
1522 Debug( LDAP_DEBUG_ANY,
1523 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1532 for( i=1; i < cargc; i++ ) {
1533 ldap_syslog += atoi( cargv[1] );
1536 /* list of replicas of the data in this backend (master only) */
1537 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1540 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1541 "%s: line %d: missing host in \"replica "
1542 " <host[:port]\" line\n", fname, lineno ));
1544 Debug( LDAP_DEBUG_ANY,
1545 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1553 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1554 "%s: line %d: replica line must appear inside "
1555 "a database definition (ignored).\n", fname, lineno ));
1557 Debug( LDAP_DEBUG_ANY,
1558 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1565 for ( i = 1; i < cargc; i++ ) {
1566 if ( strncasecmp( cargv[i], "host=", 5 )
1568 nr = add_replica_info( be,
1575 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1576 "%s: line %d: missing host in \"replica\" "
1577 "line (ignored)\n", fname, lineno ));
1579 Debug( LDAP_DEBUG_ANY,
1580 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1584 } else if ( nr == -1 ) {
1586 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1587 "%s: line %d: unable to add"
1593 Debug( LDAP_DEBUG_ANY,
1594 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1595 fname, lineno, cargv[i] + 5 );
1598 for ( i = 1; i < cargc; i++ ) {
1599 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1600 char *nsuffix = ch_strdup( cargv[i] + 7 );
1601 if ( dn_normalize( nsuffix ) != NULL ) {
1602 charray_add( &be->be_replica[nr]->ri_nsuffix, nsuffix );
1605 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1606 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1609 Debug( LDAP_DEBUG_ANY,
1610 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1620 /* dn of master entity allowed to write to replica */
1621 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1624 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1625 "%s: line %d: missing dn in \"updatedn <dn>\""
1626 " line.\n", fname, lineno ));
1628 Debug( LDAP_DEBUG_ANY,
1629 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1637 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1638 "%s: line %d: updatedn line must appear inside "
1639 "a database definition (ignored)\n",
1642 Debug( LDAP_DEBUG_ANY,
1643 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1648 be->be_update_ndn = ch_strdup( cargv[1] );
1649 if ( load_ucdata( NULL ) < 0 ) {
1652 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1654 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1655 "%s: line %d: updatedn DN is invalid.\n",
1658 Debug( LDAP_DEBUG_ANY,
1659 "%s: line %d: updatedn DN is invalid\n",
1667 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1670 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1671 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1672 "line.\n", fname, lineno ));
1674 Debug( LDAP_DEBUG_ANY,
1675 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1683 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1684 "%s: line %d: updateref line must appear inside "
1685 "a database definition (ignored)\n", fname, lineno ));
1687 Debug( LDAP_DEBUG_ANY,
1688 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1692 } else if ( be->be_update_ndn == NULL ) {
1694 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1695 "%s: line %d: updateref line must come after updatedn "
1696 "(ignored).\n", fname, lineno ));
1698 Debug( LDAP_DEBUG_ANY,
1699 "%s: line %d: updateref line must after updatedn (ignored)\n",
1704 vals[0]->bv_val = cargv[1];
1705 vals[0]->bv_len = strlen( vals[0]->bv_val );
1706 value_add( &be->be_update_refs, vals );
1709 /* replication log file to which changes are appended */
1710 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1713 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1714 "%s: line %d: missing filename in \"replogfile <filename>\""
1715 " line.\n", fname, lineno ));
1717 Debug( LDAP_DEBUG_ANY,
1718 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1725 be->be_replogfile = ch_strdup( cargv[1] );
1727 replogfile = ch_strdup( cargv[1] );
1730 /* maintain lastmodified{by,time} attributes */
1731 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1734 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1735 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1736 " line.\n", fname, lineno ));
1738 Debug( LDAP_DEBUG_ANY,
1739 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1745 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1747 be->be_lastmod = ON;
1749 global_lastmod = ON;
1752 be->be_lastmod = OFF;
1754 global_lastmod = OFF;
1757 /* set idle timeout value */
1758 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1762 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1763 "%s: line %d: missing timeout value in "
1764 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1766 Debug( LDAP_DEBUG_ANY,
1767 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1774 i = atoi( cargv[1] );
1778 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1779 "%s: line %d: timeout value (%d) invalid "
1780 "\"idletimeout <seconds>\" line.\n",
1781 fname, lineno, i ));
1783 Debug( LDAP_DEBUG_ANY,
1784 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1791 global_idletimeout = i;
1793 /* include another config file */
1794 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1797 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1798 "%s: line %d: missing filename in \"include "
1799 "<filename>\" line.\n", fname, lineno ));
1801 Debug( LDAP_DEBUG_ANY,
1802 "%s: line %d: missing filename in \"include <filename>\" line\n",
1808 savefname = ch_strdup( cargv[1] );
1809 savelineno = lineno;
1811 if ( read_config( savefname ) != 0 ) {
1816 lineno = savelineno - 1;
1818 /* location of kerberos srvtab file */
1819 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1822 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1823 "%s: line %d: missing filename in \"srvtab "
1824 "<filename>\" line.\n", fname, lineno ));
1826 Debug( LDAP_DEBUG_ANY,
1827 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1833 ldap_srvtab = ch_strdup( cargv[1] );
1835 #ifdef SLAPD_MODULES
1836 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1839 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1840 "%s: line %d: missing filename in \"moduleload "
1841 "<filename>\" line.\n", fname, lineno ));
1843 Debug( LDAP_DEBUG_ANY,
1844 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1848 exit( EXIT_FAILURE );
1850 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1852 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1853 "%s: line %d: failed to load or initialize module %s\n"<
1854 fname, lineno, cargv[1] ));
1856 Debug( LDAP_DEBUG_ANY,
1857 "%s: line %d: failed to load or initialize module %s\n",
1858 fname, lineno, cargv[1]);
1861 exit( EXIT_FAILURE );
1863 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1866 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1867 "%s: line %d: missing path in \"modulepath <path>\""
1868 " line\n", fname, lineno ));
1870 Debug( LDAP_DEBUG_ANY,
1871 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1875 exit( EXIT_FAILURE );
1877 if (module_path( cargv[1] )) {
1879 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1880 "%s: line %d: failed to set module search path to %s.\n",
1881 fname, lineno, cargv[1] ));
1883 Debug( LDAP_DEBUG_ANY,
1884 "%s: line %d: failed to set module search path to %s\n",
1885 fname, lineno, cargv[1]);
1888 exit( EXIT_FAILURE );
1891 #endif /*SLAPD_MODULES*/
1894 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1895 rc = ldap_pvt_tls_set_option( NULL,
1896 LDAP_OPT_X_TLS_PROTOCOL,
1901 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
1902 rc = ldap_pvt_tls_set_option( NULL,
1903 LDAP_OPT_X_TLS_RANDOM_FILE,
1908 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1909 rc = ldap_pvt_tls_set_option( NULL,
1910 LDAP_OPT_X_TLS_CIPHER_SUITE,
1915 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1916 rc = ldap_pvt_tls_set_option( NULL,
1917 LDAP_OPT_X_TLS_CERTFILE,
1922 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1923 rc = ldap_pvt_tls_set_option( NULL,
1924 LDAP_OPT_X_TLS_KEYFILE,
1929 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1930 rc = ldap_pvt_tls_set_option( NULL,
1931 LDAP_OPT_X_TLS_CACERTDIR,
1936 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1937 rc = ldap_pvt_tls_set_option( NULL,
1938 LDAP_OPT_X_TLS_CACERTFILE,
1942 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1944 rc = ldap_pvt_tls_set_option( NULL,
1945 LDAP_OPT_X_TLS_REQUIRE_CERT,
1952 /* pass anything else to the current backend info/db config routine */
1955 if ( bi->bi_config == 0 ) {
1957 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1958 "%s: line %d: unknown directive \"%s\" inside "
1959 "backend info definition (ignored).\n",
1960 fname, lineno, cargv[0] ));
1962 Debug( LDAP_DEBUG_ANY,
1963 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1964 fname, lineno, cargv[0] );
1968 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1974 } else if ( be != NULL ) {
1975 if ( be->be_config == 0 ) {
1977 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1978 "%s: line %d: uknown directive \"%s\" inside "
1979 "backend database definition (ignored).\n",
1980 fname, lineno, cargv[0] ));
1982 Debug( LDAP_DEBUG_ANY,
1983 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1984 fname, lineno, cargv[0] );
1988 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1996 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1997 "%s: line %d: unknown directive \"%s\" outside backend "
1998 "info and database definitions (ignored).\n",
1999 fname, lineno, cargv[0] ));
2001 Debug( LDAP_DEBUG_ANY,
2002 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2003 fname, lineno, cargv[0] );
2011 if ( load_ucdata( NULL ) < 0 ) {
2027 for ( token = strtok_quote( line, " \t" ); token != NULL;
2028 token = strtok_quote( NULL, " \t" ) ) {
2029 if ( *argcp == MAXARGS ) {
2031 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2032 "fp_parse_line: too many tokens (%d max).\n",
2035 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2041 argv[(*argcp)++] = token;
2043 argv[*argcp] = NULL;
2048 strtok_quote( char *line, char *sep )
2054 if ( line != NULL ) {
2057 while ( *next && strchr( sep, *next ) ) {
2061 if ( *next == '\0' ) {
2067 for ( inquote = 0; *next; ) {
2075 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2081 next + 1, strlen( next + 1 ) + 1 );
2082 next++; /* dont parse the escaped character */
2087 if ( strchr( sep, *next ) != NULL ) {
2100 static char buf[BUFSIZ];
2102 static int lmax, lcur;
2104 #define CATLINE( buf ) { \
2106 len = strlen( buf ); \
2107 while ( lcur + len + 1 > lmax ) { \
2109 line = (char *) ch_realloc( line, lmax ); \
2111 strcpy( line + lcur, buf ); \
2116 fp_getline( FILE *fp, int *lineno )
2124 /* hack attack - keeps us from having to keep a stack of bufs... */
2125 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2130 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2131 if ( (p = strchr( buf, '\n' )) != NULL ) {
2134 if ( ! isspace( (unsigned char) buf[0] ) ) {
2138 /* change leading whitespace to a space */
2146 return( line[0] ? line : NULL );
2150 fp_getline_init( int *lineno )
2156 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2158 load_ucdata( char *path )
2160 static int loaded = 0;
2166 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2169 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2170 "load_ucdata: Error %d loading ucdata.\n", err ));
2172 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",