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 char *slapd_pid_file = NULL;
45 char *slapd_args_file = NULL;
48 SaslRegexp_t *SaslRegexp = NULL;
49 int sasl_external_x509dn_convert;
51 static char *fp_getline(FILE *fp, int *lineno);
52 static void fp_getline_init(int *lineno);
53 static int fp_parse_line(char *line, int *argcp, char **argv);
55 static char *strtok_quote(char *line, char *sep);
56 static int load_ucdata(char *path);
59 read_config( const char *fname )
62 char *line, *savefname, *saveline;
63 int cargc, savelineno;
64 char *cargv[MAXARGS+1];
69 struct berval *vals[2];
72 static BackendInfo *bi = NULL;
73 static BackendDB *be = NULL;
78 if ( (fp = fopen( fname, "r" )) == NULL ) {
80 Debug( LDAP_DEBUG_ANY,
81 "could not open config file \"%s\" - absolute path?\n",
88 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
89 "read_config: reading config file %s\n", fname ));
91 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
95 fp_getline_init( &lineno );
97 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
98 /* skip comments and blank lines */
99 if ( line[0] == '#' || line[0] == '\0' ) {
104 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
105 "line %d (%s)\n", lineno, line ));
107 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
111 /* fp_parse_line is destructive, we save a copy */
112 saveline = ch_strdup( line );
114 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
120 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
121 "%s: line %d: bad config line (ignored)\n",
124 Debug( LDAP_DEBUG_ANY,
125 "%s: line %d: bad config line (ignored)\n",
132 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
135 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
136 "%s : line %d: missing type in \"backend\" line.\n",
139 Debug( LDAP_DEBUG_ANY,
140 "%s: line %d: missing type in \"backend <type>\" line\n",
149 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
150 "%s: line %d: backend line must appear before any "
151 "database definition.\n", fname, lineno ));
153 Debug( LDAP_DEBUG_ANY,
154 "%s: line %d: backend line must appear before any database definition\n",
161 bi = backend_info( cargv[1] );
165 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
166 "read_config: backend %s initialization failed.\n",
169 Debug( LDAP_DEBUG_ANY,
170 "backend %s initialization failed.\n",
176 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
179 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
180 "%s: line %d: missing type in \"database <type>\" line\n",
183 Debug( LDAP_DEBUG_ANY,
184 "%s: line %d: missing type in \"database <type>\" line\n",
192 be = backend_db_init( cargv[1] );
196 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
197 "database %s initialization failed.\n",
200 Debug( LDAP_DEBUG_ANY,
201 "database %s initialization failed.\n",
208 /* set thread concurrency */
209 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
213 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
214 "%s: line %d: missing level in \"concurrency <level\" line\n",
217 Debug( LDAP_DEBUG_ANY,
218 "%s: line %d: missing level in \"concurrency <level>\" line\n",
225 c = atoi( cargv[1] );
229 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
230 "%s: line %d: invalid level (%d) in "
231 "\"concurrency <level>\" line.\n",
234 Debug( LDAP_DEBUG_ANY,
235 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
242 ldap_pvt_thread_set_concurrency( c );
244 /* default search base */
245 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
248 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
249 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
250 "line\n", fname, lineno ));
252 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
253 "missing dn in \"defaultSearchBase <dn>\" line\n",
259 } else if ( cargc > 2 ) {
261 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
262 "%s: line %d: extra cruft after <dn> in "
263 "\"defaultSearchBase %s\" line (ignored)\n",
264 fname, lineno, cargv[1] ));
266 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
267 "extra cruft after <dn> in \"defaultSearchBase %s\", "
269 fname, lineno, cargv[1] );
274 if ( bi != NULL || be != NULL ) {
276 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
277 "%s: line %d: defaultSearchBase line must appear "
278 "prior to any backend or database definitions\n",
281 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
282 "defaultSearchBaase line must appear prior to "
283 "any backend or database definition\n",
290 if ( default_search_nbase != NULL ) {
292 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
293 "%s: line %d: default search base \"%s\" already defined "
294 "(discarding old)\n", fname, lineno, default_search_base ));
296 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
297 "default search base \"%s\" already defined "
298 "(discarding old)\n",
299 fname, lineno, default_search_base );
302 free( default_search_base );
303 free( default_search_nbase );
306 default_search_base = ch_strdup( cargv[1] );
307 default_search_nbase = ch_strdup( cargv[1] );
309 if ( load_ucdata( NULL ) < 0 ) {
312 if( dn_normalize( default_search_nbase ) == NULL ) {
314 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
315 "%s: %d: invalid default search base \"%s\"\n",
316 fname, lineno, default_search_base ));
318 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
319 "invalid default search base \"%s\"\n",
320 fname, lineno, default_search_base );
326 /* set maximum threads in thread pool */
327 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
331 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
332 "%s: line %d: missing count in \"threads <count>\" line\n",
335 Debug( LDAP_DEBUG_ANY,
336 "%s: line %d: missing count in \"threads <count>\" line\n",
343 c = atoi( cargv[1] );
347 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
348 "%s: line %d: invalid level (%d) in \"threads <count>\""
349 "line\n",fname, lineno, c ));
351 Debug( LDAP_DEBUG_ANY,
352 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
359 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
361 /* get pid file name */
362 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
365 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
366 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
369 Debug( LDAP_DEBUG_ANY,
370 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
377 slapd_pid_file = ch_strdup( cargv[1] );
379 /* get args file name */
380 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
383 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
384 "%s: %d: missing file name in "
385 "\"argsfile <file>\" line.\n",
388 Debug( LDAP_DEBUG_ANY,
389 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
396 slapd_args_file = ch_strdup( cargv[1] );
398 /* default password hash */
399 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
402 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
403 "%s: line %d: missing hash in "
404 "\"password-hash <hash>\" line.\n",
407 Debug( LDAP_DEBUG_ANY,
408 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
414 if ( default_passwd_hash != NULL ) {
416 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
417 "%s: line %d: already set default password_hash!\n",
420 Debug( LDAP_DEBUG_ANY,
421 "%s: line %d: already set default password_hash!\n",
428 default_passwd_hash = ch_strdup( cargv[1] );
432 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
435 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
436 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
439 Debug( LDAP_DEBUG_ANY,
440 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
447 if ( global_host != NULL ) {
449 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
450 "%s: line %d: already set sasl-host!\n",
453 Debug( LDAP_DEBUG_ANY,
454 "%s: line %d: already set sasl-host!\n",
461 global_host = ch_strdup( cargv[1] );
465 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
468 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
469 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
472 Debug( LDAP_DEBUG_ANY,
473 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
480 if ( global_realm != NULL ) {
482 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
483 "%s: line %d: already set sasl-realm!\n",
486 Debug( LDAP_DEBUG_ANY,
487 "%s: line %d: already set sasl-realm!\n",
494 global_realm = ch_strdup( cargv[1] );
497 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
498 || !strcasecmp( cargv[0], "saslregexp" ) )
503 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
504 "%s: line %d: need 2 args in "
505 "\"saslregexp <match> <replace>\"\n",
508 Debug( LDAP_DEBUG_ANY,
509 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
515 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
520 /* SASL security properties */
521 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
526 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
527 "%s: line %d: missing flags in "
528 "\"sasl-secprops <properties>\" line\n",
531 Debug( LDAP_DEBUG_ANY,
532 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
539 txt = slap_sasl_secprops( cargv[1] );
542 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
543 "%s: line %d sas-secprops: %s\n",
544 fname, lineno, txt ));
546 Debug( LDAP_DEBUG_ANY,
547 "%s: line %d: sasl-secprops: %s\n",
548 fname, lineno, txt );
554 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
555 sasl_external_x509dn_convert++;
557 /* set UCDATA path */
558 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
562 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
563 "%s: line %d: missing path in "
564 "\"ucdata-path <path>\" line.\n",
567 Debug( LDAP_DEBUG_ANY,
568 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
575 err = load_ucdata( cargv[1] );
579 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
580 "%s: line %d: ucdata already loaded, ucdata-path "
581 "must be set earlier in the file and/or be "
582 "specified only once!\n",
585 Debug( LDAP_DEBUG_ANY,
586 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
595 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
598 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
599 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
602 Debug( LDAP_DEBUG_ANY,
603 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
610 defsize = atoi( cargv[1] );
612 be->be_sizelimit = atoi( cargv[1] );
616 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
619 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
620 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
623 Debug( LDAP_DEBUG_ANY,
624 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
631 deftime = atoi( cargv[1] );
633 be->be_timelimit = atoi( cargv[1] );
636 /* set database suffix */
637 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
641 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
642 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
645 Debug( LDAP_DEBUG_ANY,
646 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
651 } else if ( cargc > 2 ) {
653 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
654 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
655 " line (ignored).\n", fname, lineno, cargv[1] ));
657 Debug( LDAP_DEBUG_ANY,
658 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
659 fname, lineno, cargv[1] );
665 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
666 "%s: line %d: suffix line must appear inside a database "
667 "definition (ignored).\n", fname, lineno ));
669 Debug( LDAP_DEBUG_ANY,
670 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
674 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
676 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
677 "%s: line %d: suffix already served by this backend "
678 "(ignored)\n", fname, lineno ));
680 Debug( LDAP_DEBUG_ANY,
681 "%s: line %d: suffix already served by this backend (ignored)\n",
685 } else if ( tmp_be != NULL ) {
687 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
688 "%s: line %d: suffix already served by a preceding "
689 "backend \"%s\" (ignored)\n", fname, lineno,
690 tmp_be->be_suffix[0] ));
692 Debug( LDAP_DEBUG_ANY,
693 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
694 fname, lineno, tmp_be->be_suffix[0] );
698 char *dn = ch_strdup( cargv[1] );
699 if ( load_ucdata( NULL ) < 0 ) {
702 if( dn_validate( dn ) == NULL ) {
704 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
705 "%s: line %d: suffix DN invalid\"%s\"\n",
706 fname, lineno, cargv[1] ));
708 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
709 "suffix DN invalid \"%s\"\n",
710 fname, lineno, cargv[1] );
715 } else if( *dn == '\0' && default_search_nbase != NULL ) {
717 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
718 "%s: line %d: suffix DN empty and default search "
719 "base provided \"%s\" (assuming okay).\n",
720 fname, lineno, default_search_base ));
722 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
723 "suffix DN empty and default "
724 "search base provided \"%s\" (assuming okay)\n",
725 fname, lineno, default_search_base );
729 charray_add( &be->be_suffix, dn );
730 (void) ldap_pvt_str2upper( dn );
731 charray_add( &be->be_nsuffix, dn );
735 /* set database suffixAlias */
736 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
740 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
741 "%s: line %d: missing alias and aliased_dn in "
742 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
745 Debug( LDAP_DEBUG_ANY,
746 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
751 } else if ( cargc < 3 ) {
753 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
754 "%s: line %d: missing aliased_dn in "
755 "\"suffixAlias <alias> <aliased_dn>\" line\n",
758 Debug( LDAP_DEBUG_ANY,
759 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
764 } else if ( cargc > 3 ) {
766 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
767 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
770 Debug( LDAP_DEBUG_ANY,
771 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
779 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
780 "%s: line %d: suffixAlias line must appear inside a "
781 "database definition (ignored).\n", fname, lineno ));
783 Debug( LDAP_DEBUG_ANY,
784 "%s: line %d: suffixAlias line"
785 " must appear inside a database definition (ignored)\n",
789 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
791 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
792 "%s: line %d: suffixAlias served by a preceeding "
793 "backend \"%s\" (ignored).\n", fname, lineno,
794 tmp_be->be_suffix[0] ));
796 Debug( LDAP_DEBUG_ANY,
797 "%s: line %d: suffixAlias served by"
798 " a preceeding backend \"%s\" (ignored)\n",
799 fname, lineno, tmp_be->be_suffix[0] );
803 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
805 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
806 "%s: line %d: suffixAlias derefs to a different backend "
807 "a preceeding backend \"%s\" (ignored)\n",
808 fname, lineno, tmp_be->be_suffix[0] ));
810 Debug( LDAP_DEBUG_ANY,
811 "%s: line %d: suffixAlias derefs to differnet backend"
812 " a preceeding backend \"%s\" (ignored)\n",
813 fname, lineno, tmp_be->be_suffix[0] );
818 char *alias, *aliased_dn;
820 alias = ch_strdup( cargv[1] );
821 if ( load_ucdata( NULL ) < 0 ) {
824 (void) dn_normalize( alias );
826 aliased_dn = ch_strdup( cargv[2] );
827 (void) dn_normalize( aliased_dn );
829 charray_add( &be->be_suffixAlias, alias );
830 charray_add( &be->be_suffixAlias, aliased_dn );
836 /* set max deref depth */
837 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
841 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
842 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
843 " line\n", fname, lineno ));
845 Debug( LDAP_DEBUG_ANY,
846 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
854 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
855 "%s: line %d: depth line must appear inside a database "
856 "definition (ignored)\n", fname, lineno ));
858 Debug( LDAP_DEBUG_ANY,
859 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
863 } else if ((i = atoi(cargv[1])) < 0) {
865 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
866 "%s: line %d: depth must be positive (ignored).\n",
869 Debug( LDAP_DEBUG_ANY,
870 "%s: line %d: depth must be positive (ignored)\n",
876 be->be_max_deref_depth = i;
880 /* set magic "root" dn for this database */
881 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
884 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
885 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
888 Debug( LDAP_DEBUG_ANY,
889 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
897 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
898 "%s: line %d: rootdn line must appear inside a database "
899 "definition (ignored).\n", fname, lineno ));
901 Debug( LDAP_DEBUG_ANY,
902 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
907 be->be_root_dn = ch_strdup( cargv[1] );
908 be->be_root_ndn = ch_strdup( cargv[1] );
910 if ( load_ucdata( NULL ) < 0 ) {
913 if( dn_normalize( be->be_root_ndn ) == NULL ) {
914 free( be->be_root_dn );
915 free( be->be_root_ndn );
917 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
918 "%s: line %d: rootdn DN is invalid.\n",
921 Debug( LDAP_DEBUG_ANY,
922 "%s: line %d: rootdn DN is invalid\n",
930 /* set super-secret magic database password */
931 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
934 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
935 "%s: line %d: missing passwd in \"rootpw <passwd>\""
936 " line\n", fname, lineno ));
938 Debug( LDAP_DEBUG_ANY,
939 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
947 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
948 "%s: line %d: rootpw line must appear inside a database "
949 "definition (ignored)\n", fname, lineno ));
951 Debug( LDAP_DEBUG_ANY,
952 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
957 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
958 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
961 /* make this database read-only */
962 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
965 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
966 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
969 Debug( LDAP_DEBUG_ANY,
970 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
977 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
978 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
980 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
983 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
984 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
986 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
991 /* allow these features */
992 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
993 strcasecmp( cargv[0], "allow" ) == 0 )
999 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1000 "%s: line %d: allow line must appear prior to "
1001 "database definitions.\n", fname, lineno ));
1003 Debug( LDAP_DEBUG_ANY,
1004 "%s: line %d: allow line must appear prior to database definitions\n",
1012 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1013 "%s: line %d: missing feature(s) in \"allow <features>\""
1014 " line\n", fname, lineno ));
1016 Debug( LDAP_DEBUG_ANY,
1017 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1026 for( i=1; i < cargc; i++ ) {
1027 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1028 allows |= SLAP_ALLOW_TLS_2_ANON;
1030 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1032 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1033 "%s: line %d: unknown feature %s in "
1034 "\"allow <features>\" line.\n",
1035 fname, lineno, cargv[1] ));
1037 Debug( LDAP_DEBUG_ANY,
1038 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1039 fname, lineno, cargv[i] );
1046 global_allows = allows;
1048 /* disallow these features */
1049 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1050 strcasecmp( cargv[0], "disallow" ) == 0 )
1052 slap_mask_t disallows;
1056 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1057 "%s: line %d: disallow line must appear prior to "
1058 "database definitions.\n", fname, lineno ));
1060 Debug( LDAP_DEBUG_ANY,
1061 "%s: line %d: disallow line must appear prior to database definitions\n",
1069 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1070 "%s: line %d: missing feature(s) in \"disallow <features>\""
1071 " line.\n", fname, lineno ));
1073 Debug( LDAP_DEBUG_ANY,
1074 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1083 for( i=1; i < cargc; i++ ) {
1084 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1085 disallows |= SLAP_DISALLOW_BIND_V2;
1087 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1088 disallows |= SLAP_DISALLOW_BIND_ANON;
1090 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1091 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1093 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1094 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1096 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1097 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1099 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1100 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1102 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1103 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1105 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1107 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1108 "%s: line %d: unknownfeature %s in "
1109 "\"disallow <features>\" line.\n",
1112 Debug( LDAP_DEBUG_ANY,
1113 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1114 fname, lineno, cargv[i] );
1121 global_disallows = disallows;
1123 /* require these features */
1124 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1125 strcasecmp( cargv[0], "require" ) == 0 )
1127 slap_mask_t requires;
1131 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1132 "%s: line %d: missing feature(s) in "
1133 "\"require <features>\" line.\n", fname, lineno ));
1135 Debug( LDAP_DEBUG_ANY,
1136 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1145 for( i=1; i < cargc; i++ ) {
1146 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1147 requires |= SLAP_REQUIRE_BIND;
1149 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1150 requires |= SLAP_REQUIRE_LDAP_V3;
1152 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1153 requires |= SLAP_REQUIRE_AUTHC;
1155 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1156 requires |= SLAP_REQUIRE_SASL;
1158 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1159 requires |= SLAP_REQUIRE_STRONG;
1161 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1163 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1164 "%s: line %d: unknown feature %s in "
1165 "\"require <features>\" line.\n",
1168 Debug( LDAP_DEBUG_ANY,
1169 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1170 fname, lineno, cargv[i] );
1178 global_requires = requires;
1180 be->be_requires = requires;
1183 /* required security factors */
1184 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1185 slap_ssf_set_t *set;
1189 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1190 "%s: line %d: missing factor(s) in \"security <factors>\""
1191 " line.\n", fname, lineno ));
1193 Debug( LDAP_DEBUG_ANY,
1194 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1202 set = &global_ssf_set;
1204 set = &be->be_ssf_set;
1207 for( i=1; i < cargc; i++ ) {
1208 if( strncasecmp( cargv[i], "ssf=",
1209 sizeof("ssf") ) == 0 )
1212 atoi( &cargv[i][sizeof("ssf")] );
1214 } else if( strncasecmp( cargv[i], "transport=",
1215 sizeof("transport") ) == 0 )
1217 set->sss_transport =
1218 atoi( &cargv[i][sizeof("transport")] );
1220 } else if( strncasecmp( cargv[i], "tls=",
1221 sizeof("tls") ) == 0 )
1224 atoi( &cargv[i][sizeof("tls")] );
1226 } else if( strncasecmp( cargv[i], "sasl=",
1227 sizeof("sasl") ) == 0 )
1230 atoi( &cargv[i][sizeof("sasl")] );
1232 } else if( strncasecmp( cargv[i], "update_ssf=",
1233 sizeof("update_ssf") ) == 0 )
1235 set->sss_update_ssf =
1236 atoi( &cargv[i][sizeof("update_ssf")] );
1238 } else if( strncasecmp( cargv[i], "update_transport=",
1239 sizeof("update_transport") ) == 0 )
1241 set->sss_update_transport =
1242 atoi( &cargv[i][sizeof("update_transport")] );
1244 } else if( strncasecmp( cargv[i], "update_tls=",
1245 sizeof("update_tls") ) == 0 )
1247 set->sss_update_tls =
1248 atoi( &cargv[i][sizeof("update_tls")] );
1250 } else if( strncasecmp( cargv[i], "update_sasl=",
1251 sizeof("update_sasl") ) == 0 )
1253 set->sss_update_sasl =
1254 atoi( &cargv[i][sizeof("update_sasl")] );
1258 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1259 "%s: line %d: unknown factor %S in "
1260 "\"security <factors>\" line.\n",
1261 fname, lineno, cargv[1] ));
1263 Debug( LDAP_DEBUG_ANY,
1264 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1265 fname, lineno, cargv[i] );
1271 /* where to send clients when we don't hold it */
1272 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1275 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1276 "%s: line %d: missing URL in \"referral <URL>\""
1277 " line.\n", fname, lineno ));
1279 Debug( LDAP_DEBUG_ANY,
1280 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1287 vals[0]->bv_val = cargv[1];
1288 vals[0]->bv_len = strlen( vals[0]->bv_val );
1289 value_add( &default_referral, vals );
1292 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1296 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1297 "%s: line %d: Error in logfile directive, "
1298 "\"logfile <filename>\"\n", fname, lineno ));
1300 Debug( LDAP_DEBUG_ANY,
1301 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1307 logfile = fopen( cargv[1], "w" );
1308 if ( logfile != NULL ) lutil_debug_file( logfile );
1311 /* start of a new database definition */
1312 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1316 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1317 "%s: line %d: Error in debug directive, "
1318 "\"debug <subsys> <level>\"\n", fname, lineno ));
1320 Debug( LDAP_DEBUG_ANY,
1321 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1327 level = atoi( cargv[2] );
1328 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1329 lutil_set_debug_level( cargv[1], level );
1330 /* specify an Object Identifier macro */
1331 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1332 parse_oidm( fname, lineno, cargc, cargv );
1334 /* specify an objectclass */
1335 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1336 if ( *cargv[1] == '(' ) {
1338 p = strchr(saveline,'(');
1339 parse_oc( fname, lineno, p, cargv );
1342 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1343 "%s: line %d: old objectclass format not supported\n",
1346 Debug( LDAP_DEBUG_ANY,
1347 "%s: line %d: old objectclass format not supported.\n",
1353 /* specify an attribute type */
1354 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1355 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1357 if ( *cargv[1] == '(' ) {
1359 p = strchr(saveline,'(');
1360 parse_at( fname, lineno, p, cargv );
1363 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1364 "%s: line %d: old attribute type format not supported.\n",
1367 Debug( LDAP_DEBUG_ANY,
1368 "%s: line %d: old attribute type format not supported.\n",
1374 /* turn on/off schema checking */
1375 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1378 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1379 "%s: line %d: missing on|off in "
1380 "\"schemacheck <on|off>\" line.\n",
1383 Debug( LDAP_DEBUG_ANY,
1384 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1390 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1391 global_schemacheck = 0;
1393 global_schemacheck = 1;
1396 /* specify access control info */
1397 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1398 parse_acl( be, fname, lineno, cargc, cargv );
1400 /* debug level to log things to syslog */
1401 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1404 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1405 "%s: line %d: missing level in \"loglevel <level>\""
1406 " line.\n", fname, lineno ));
1408 Debug( LDAP_DEBUG_ANY,
1409 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1418 for( i=1; i < cargc; i++ ) {
1419 ldap_syslog += atoi( cargv[1] );
1422 /* list of replicas of the data in this backend (master only) */
1423 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1426 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1427 "%s: line %d: missing host in \"replica "
1428 " <host[:port]\" line\n", fname, lineno ));
1430 Debug( LDAP_DEBUG_ANY,
1431 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1439 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1440 "%s: line %d: replica line must appear inside "
1441 "a database definition (ignored).\n", fname, lineno ));
1443 Debug( LDAP_DEBUG_ANY,
1444 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1449 for ( i = 1; i < cargc; i++ ) {
1450 if ( strncasecmp( cargv[i], "host=", 5 )
1452 charray_add( &be->be_replica,
1459 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1460 "%s: line %d: missing host in \"replica\" "
1461 "line (ignored)\n", fname, lineno ));
1463 Debug( LDAP_DEBUG_ANY,
1464 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1471 /* dn of master entity allowed to write to replica */
1472 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1475 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1476 "%s: line %d: missing dn in \"updatedn <dn>\""
1477 " line.\n", fname, lineno ));
1479 Debug( LDAP_DEBUG_ANY,
1480 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1488 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1489 "%s: line %d: updatedn line must appear inside "
1490 "a database definition (ignored)\n",
1493 Debug( LDAP_DEBUG_ANY,
1494 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1499 be->be_update_ndn = ch_strdup( cargv[1] );
1500 if ( load_ucdata( NULL ) < 0 ) {
1503 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1505 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1506 "%s: line %d: updatedn DN is invalid.\n",
1509 Debug( LDAP_DEBUG_ANY,
1510 "%s: line %d: updatedn DN is invalid\n",
1518 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1521 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1522 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1523 "line.\n", fname, lineno ));
1525 Debug( LDAP_DEBUG_ANY,
1526 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1534 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1535 "%s: line %d: updateref line must appear inside "
1536 "a database definition (ignored)\n", fname, lineno ));
1538 Debug( LDAP_DEBUG_ANY,
1539 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1543 } else if ( be->be_update_ndn == NULL ) {
1545 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1546 "%s: line %d: updateref line must come after updatedn "
1547 "(ignored).\n", fname, lineno ));
1549 Debug( LDAP_DEBUG_ANY,
1550 "%s: line %d: updateref line must after updatedn (ignored)\n",
1555 vals[0]->bv_val = cargv[1];
1556 vals[0]->bv_len = strlen( vals[0]->bv_val );
1557 value_add( &be->be_update_refs, vals );
1560 /* replication log file to which changes are appended */
1561 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1564 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1565 "%s: line %d: missing filename in \"replogfile <filename>\""
1566 " line.\n", fname, lineno ));
1568 Debug( LDAP_DEBUG_ANY,
1569 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1576 be->be_replogfile = ch_strdup( cargv[1] );
1578 replogfile = ch_strdup( cargv[1] );
1581 /* maintain lastmodified{by,time} attributes */
1582 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1585 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1586 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1587 " line.\n", fname, lineno ));
1589 Debug( LDAP_DEBUG_ANY,
1590 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1596 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1598 be->be_lastmod = ON;
1600 global_lastmod = ON;
1603 be->be_lastmod = OFF;
1605 global_lastmod = OFF;
1608 /* set idle timeout value */
1609 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1613 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1614 "%s: line %d: missing timeout value in "
1615 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1617 Debug( LDAP_DEBUG_ANY,
1618 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1625 i = atoi( cargv[1] );
1629 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1630 "%s: line %d: timeout value (%d) invalid "
1631 "\"idletimeout <seconds>\" line.\n",
1632 fname, lineno, i ));
1634 Debug( LDAP_DEBUG_ANY,
1635 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1642 global_idletimeout = i;
1644 /* include another config file */
1645 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1648 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1649 "%s: line %d: missing filename in \"include "
1650 "<filename>\" line.\n", fname, lineno ));
1652 Debug( LDAP_DEBUG_ANY,
1653 "%s: line %d: missing filename in \"include <filename>\" line\n",
1659 savefname = ch_strdup( cargv[1] );
1660 savelineno = lineno;
1662 if ( read_config( savefname ) != 0 ) {
1667 lineno = savelineno - 1;
1669 /* location of kerberos srvtab file */
1670 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1673 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1674 "%s: line %d: missing filename in \"srvtab "
1675 "<filename>\" line.\n", fname, lineno ));
1677 Debug( LDAP_DEBUG_ANY,
1678 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1684 ldap_srvtab = ch_strdup( cargv[1] );
1686 #ifdef SLAPD_MODULES
1687 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1690 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1691 "%s: line %d: missing filename in \"moduleload "
1692 "<filename>\" line.\n", fname, lineno ));
1694 Debug( LDAP_DEBUG_ANY,
1695 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1699 exit( EXIT_FAILURE );
1701 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1703 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1704 "%s: line %d: failed to load or initialize module %s\n"<
1705 fname, lineno, cargv[1] ));
1707 Debug( LDAP_DEBUG_ANY,
1708 "%s: line %d: failed to load or initialize module %s\n",
1709 fname, lineno, cargv[1]);
1712 exit( EXIT_FAILURE );
1714 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1717 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1718 "%s: line %d: missing path in \"modulepath <path>\""
1719 " line\n", fname, lineno ));
1721 Debug( LDAP_DEBUG_ANY,
1722 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1726 exit( EXIT_FAILURE );
1728 if (module_path( cargv[1] )) {
1730 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1731 "%s: line %d: failed to set module search path to %s.\n",
1732 fname, lineno, cargv[1] ));
1734 Debug( LDAP_DEBUG_ANY,
1735 "%s: line %d: failed to set module search path to %s\n",
1736 fname, lineno, cargv[1]);
1739 exit( EXIT_FAILURE );
1742 #endif /*SLAPD_MODULES*/
1745 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1746 rc = ldap_pvt_tls_set_option( NULL,
1747 LDAP_OPT_X_TLS_PROTOCOL,
1752 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1753 rc = ldap_pvt_tls_set_option( NULL,
1754 LDAP_OPT_X_TLS_CIPHER_SUITE,
1759 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1760 rc = ldap_pvt_tls_set_option( NULL,
1761 LDAP_OPT_X_TLS_CERTFILE,
1766 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1767 rc = ldap_pvt_tls_set_option( NULL,
1768 LDAP_OPT_X_TLS_KEYFILE,
1773 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1774 rc = ldap_pvt_tls_set_option( NULL,
1775 LDAP_OPT_X_TLS_CACERTDIR,
1780 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1781 rc = ldap_pvt_tls_set_option( NULL,
1782 LDAP_OPT_X_TLS_CACERTFILE,
1786 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1788 rc = ldap_pvt_tls_set_option( NULL,
1789 LDAP_OPT_X_TLS_REQUIRE_CERT,
1796 /* pass anything else to the current backend info/db config routine */
1799 if ( bi->bi_config == 0 ) {
1801 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1802 "%s: line %d: unknown directive \"%s\" inside "
1803 "backend info definition (ignored).\n",
1804 fname, lineno, cargv[0] ));
1806 Debug( LDAP_DEBUG_ANY,
1807 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1808 fname, lineno, cargv[0] );
1812 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1818 } else if ( be != NULL ) {
1819 if ( be->be_config == 0 ) {
1821 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1822 "%s: line %d: uknown directive \"%s\" inside "
1823 "backend database definition (ignored).\n",
1824 fname, lineno, cargv[0] ));
1826 Debug( LDAP_DEBUG_ANY,
1827 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1828 fname, lineno, cargv[0] );
1832 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1840 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1841 "%s: line %d: unknown directive \"%s\" outside backend "
1842 "info and database definitions (ignored).\n",
1843 fname, lineno, cargv[0] ));
1845 Debug( LDAP_DEBUG_ANY,
1846 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1847 fname, lineno, cargv[0] );
1855 if ( load_ucdata( NULL ) < 0 ) {
1871 for ( token = strtok_quote( line, " \t" ); token != NULL;
1872 token = strtok_quote( NULL, " \t" ) ) {
1873 if ( *argcp == MAXARGS ) {
1875 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1876 "fp_parse_line: too many tokens (%d max).\n",
1879 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1885 argv[(*argcp)++] = token;
1887 argv[*argcp] = NULL;
1892 strtok_quote( char *line, char *sep )
1898 if ( line != NULL ) {
1901 while ( *next && strchr( sep, *next ) ) {
1905 if ( *next == '\0' ) {
1911 for ( inquote = 0; *next; ) {
1919 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1925 next + 1, strlen( next + 1 ) + 1 );
1926 next++; /* dont parse the escaped character */
1931 if ( strchr( sep, *next ) != NULL ) {
1944 static char buf[BUFSIZ];
1946 static int lmax, lcur;
1948 #define CATLINE( buf ) { \
1950 len = strlen( buf ); \
1951 while ( lcur + len + 1 > lmax ) { \
1953 line = (char *) ch_realloc( line, lmax ); \
1955 strcpy( line + lcur, buf ); \
1960 fp_getline( FILE *fp, int *lineno )
1968 /* hack attack - keeps us from having to keep a stack of bufs... */
1969 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1974 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1975 if ( (p = strchr( buf, '\n' )) != NULL ) {
1978 if ( ! isspace( (unsigned char) buf[0] ) ) {
1987 return( line[0] ? line : NULL );
1991 fp_getline_init( int *lineno )
1997 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1999 load_ucdata( char *path )
2001 static int loaded = 0;
2007 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA,
2008 UCDATA_CASE|UCDATA_CTYPE|UCDATA_NUM|UCDATA_COMP );
2011 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2012 "load_ucdata: Error %d loading ucdata.\n", err ));
2014 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",