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;
50 static char *fp_getline(FILE *fp, int *lineno);
51 static void fp_getline_init(int *lineno);
52 static int fp_parse_line(char *line, int *argcp, char **argv);
54 static char *strtok_quote(char *line, char *sep);
55 static int load_ucdata(char *path);
58 read_config( const char *fname )
61 char *line, *savefname, *saveline;
62 int cargc, savelineno;
63 char *cargv[MAXARGS+1];
68 struct berval *vals[2];
71 static BackendInfo *bi = NULL;
72 static BackendDB *be = NULL;
77 if ( (fp = fopen( fname, "r" )) == NULL ) {
79 Debug( LDAP_DEBUG_ANY,
80 "could not open config file \"%s\" - absolute path?\n",
87 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
88 "read_config: reading config file %s\n", fname ));
90 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
94 fp_getline_init( &lineno );
96 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
97 /* skip comments and blank lines */
98 if ( line[0] == '#' || line[0] == '\0' ) {
103 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
104 "line %d (%s)\n", lineno, line ));
106 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
110 /* fp_parse_line is destructive, we save a copy */
111 saveline = ch_strdup( line );
113 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
119 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
120 "%s: line %d: bad config line (ignored)\n",
123 Debug( LDAP_DEBUG_ANY,
124 "%s: line %d: bad config line (ignored)\n",
131 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
134 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
135 "%s : line %d: missing type in \"backend\" line.\n",
138 Debug( LDAP_DEBUG_ANY,
139 "%s: line %d: missing type in \"backend <type>\" line\n",
148 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
149 "%s: line %d: backend line must appear before any "
150 "database definition.\n", fname, lineno ));
152 Debug( LDAP_DEBUG_ANY,
153 "%s: line %d: backend line must appear before any database definition\n",
160 bi = backend_info( cargv[1] );
164 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
165 "read_config: backend %s initialization failed.\n",
168 Debug( LDAP_DEBUG_ANY,
169 "backend %s initialization failed.\n",
175 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
178 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
179 "%s: line %d: missing type in \"database <type>\" line\n",
182 Debug( LDAP_DEBUG_ANY,
183 "%s: line %d: missing type in \"database <type>\" line\n",
191 be = backend_db_init( cargv[1] );
195 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
196 "database %s initialization failed.\n",
199 Debug( LDAP_DEBUG_ANY,
200 "database %s initialization failed.\n",
207 /* set thread concurrency */
208 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
212 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
213 "%s: line %d: missing level in \"concurrency <level\" line\n",
216 Debug( LDAP_DEBUG_ANY,
217 "%s: line %d: missing level in \"concurrency <level>\" line\n",
224 c = atoi( cargv[1] );
228 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
229 "%s: line %d: invalid level (%d) in "
230 "\"concurrency <level>\" line.\n",
233 Debug( LDAP_DEBUG_ANY,
234 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
241 ldap_pvt_thread_set_concurrency( c );
243 /* default search base */
244 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
247 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
248 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
249 "line\n", fname, lineno ));
251 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
252 "missing dn in \"defaultSearchBase <dn>\" line\n",
258 } else if ( cargc > 2 ) {
260 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
261 "%s: line %d: extra cruft after <dn> in "
262 "\"defaultSearchBase %s\" line (ignored)\n",
263 fname, lineno, cargv[1] ));
265 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
266 "extra cruft after <dn> in \"defaultSearchBase %s\", "
268 fname, lineno, cargv[1] );
273 if ( bi != NULL || be != NULL ) {
275 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
276 "%s: line %d: defaultSearchBase line must appear "
277 "prior to any backend or database definitions\n",
280 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
281 "defaultSearchBaase line must appear prior to "
282 "any backend or database definition\n",
289 if ( default_search_nbase != NULL ) {
291 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
292 "%s: line %d: default search base \"%s\" already defined "
293 "(discarding old)\n", fname, lineno, default_search_base ));
295 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
296 "default search base \"%s\" already defined "
297 "(discarding old)\n",
298 fname, lineno, default_search_base );
301 free( default_search_base );
302 free( default_search_nbase );
305 default_search_base = ch_strdup( cargv[1] );
306 default_search_nbase = ch_strdup( cargv[1] );
308 if ( load_ucdata( NULL ) < 0 ) {
311 if( dn_normalize( default_search_nbase ) == NULL ) {
313 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
314 "%s: %d: invalid default search base \"%s\"\n",
315 fname, lineno, default_search_base ));
317 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
318 "invalid default search base \"%s\"\n",
319 fname, lineno, default_search_base );
325 /* set maximum threads in thread pool */
326 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
330 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
331 "%s: line %d: missing count in \"threads <count>\" line\n",
334 Debug( LDAP_DEBUG_ANY,
335 "%s: line %d: missing count in \"threads <count>\" line\n",
342 c = atoi( cargv[1] );
346 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
347 "%s: line %d: invalid level (%d) in \"threads <count>\""
348 "line\n",fname, lineno, c ));
350 Debug( LDAP_DEBUG_ANY,
351 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
358 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
360 /* get pid file name */
361 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
364 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
365 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
368 Debug( LDAP_DEBUG_ANY,
369 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
376 slapd_pid_file = ch_strdup( cargv[1] );
378 /* get args file name */
379 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
382 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
383 "%s: %d: missing file name in "
384 "\"argsfile <file>\" line.\n",
387 Debug( LDAP_DEBUG_ANY,
388 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
395 slapd_args_file = ch_strdup( cargv[1] );
397 /* default password hash */
398 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
401 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
402 "%s: line %d: missing hash in "
403 "\"password-hash <hash>\" line.\n",
406 Debug( LDAP_DEBUG_ANY,
407 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
413 if ( default_passwd_hash != NULL ) {
415 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
416 "%s: line %d: already set default password_hash!\n",
419 Debug( LDAP_DEBUG_ANY,
420 "%s: line %d: already set default password_hash!\n",
427 default_passwd_hash = ch_strdup( cargv[1] );
431 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
434 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
435 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
438 Debug( LDAP_DEBUG_ANY,
439 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
446 if ( global_host != NULL ) {
448 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
449 "%s: line %d: already set sasl-host!\n",
452 Debug( LDAP_DEBUG_ANY,
453 "%s: line %d: already set sasl-host!\n",
460 global_host = ch_strdup( cargv[1] );
464 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
467 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
468 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
471 Debug( LDAP_DEBUG_ANY,
472 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
479 if ( global_realm != NULL ) {
481 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
482 "%s: line %d: already set sasl-realm!\n",
485 Debug( LDAP_DEBUG_ANY,
486 "%s: line %d: already set sasl-realm!\n",
493 global_realm = ch_strdup( cargv[1] );
496 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
497 || !strcasecmp( cargv[0], "saslregexp" ) )
502 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
503 "%s: line %d: need 2 args in "
504 "\"saslregexp <match> <replace>\"\n",
507 Debug( LDAP_DEBUG_ANY,
508 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
514 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
519 /* SASL security properties */
520 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
525 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
526 "%s: line %d: missing flags in "
527 "\"sasl-secprops <properties>\" line\n",
530 Debug( LDAP_DEBUG_ANY,
531 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
538 txt = slap_sasl_secprops( cargv[1] );
541 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
542 "%s: line %d sas-secprops: %s\n",
543 fname, lineno, txt ));
545 Debug( LDAP_DEBUG_ANY,
546 "%s: line %d: sasl-secprops: %s\n",
547 fname, lineno, txt );
553 /* set UCDATA path */
554 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
558 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
559 "%s: line %d: missing path in "
560 "\"ucdata-path <path>\" line.\n",
563 Debug( LDAP_DEBUG_ANY,
564 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
571 err = load_ucdata( cargv[1] );
575 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
576 "%s: line %d: ucdata already loaded, ucdata-path "
577 "must be set earlier in the file and/or be "
578 "specified only once!\n",
581 Debug( LDAP_DEBUG_ANY,
582 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
591 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
594 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
595 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
598 Debug( LDAP_DEBUG_ANY,
599 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
606 defsize = atoi( cargv[1] );
608 be->be_sizelimit = atoi( cargv[1] );
612 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
615 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
616 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
619 Debug( LDAP_DEBUG_ANY,
620 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
627 deftime = atoi( cargv[1] );
629 be->be_timelimit = atoi( cargv[1] );
632 /* set database suffix */
633 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
637 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
638 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
641 Debug( LDAP_DEBUG_ANY,
642 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
647 } else if ( cargc > 2 ) {
649 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
650 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
651 " line (ignored).\n", fname, lineno, cargv[1] ));
653 Debug( LDAP_DEBUG_ANY,
654 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
655 fname, lineno, cargv[1] );
661 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
662 "%s: line %d: suffix line must appear inside a database "
663 "definition (ignored).\n", fname, lineno ));
665 Debug( LDAP_DEBUG_ANY,
666 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
670 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
672 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
673 "%s: line %d: suffix already served by this backend "
674 "(ignored)\n", fname, lineno ));
676 Debug( LDAP_DEBUG_ANY,
677 "%s: line %d: suffix already served by this backend (ignored)\n",
681 } else if ( tmp_be != NULL ) {
683 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
684 "%s: line %d: suffix already served by a preceding "
685 "backend \"%s\" (ignored)\n", fname, lineno,
686 tmp_be->be_suffix[0] ));
688 Debug( LDAP_DEBUG_ANY,
689 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
690 fname, lineno, tmp_be->be_suffix[0] );
694 char *dn = ch_strdup( cargv[1] );
695 if ( load_ucdata( NULL ) < 0 ) {
698 if( dn_validate( dn ) == NULL ) {
700 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
701 "%s: line %d: suffix DN invalid\"%s\"\n",
702 fname, lineno, cargv[1] ));
704 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
705 "suffix DN invalid \"%s\"\n",
706 fname, lineno, cargv[1] );
711 } else if( *dn == '\0' && default_search_nbase != NULL ) {
713 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
714 "%s: line %d: suffix DN empty and default search "
715 "base provided \"%s\" (assuming okay).\n",
716 fname, lineno, default_search_base ));
718 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
719 "suffix DN empty and default "
720 "search base provided \"%s\" (assuming okay)\n",
721 fname, lineno, default_search_base );
725 charray_add( &be->be_suffix, dn );
726 (void) ldap_pvt_str2upper( dn );
727 charray_add( &be->be_nsuffix, dn );
731 /* set database suffixAlias */
732 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
736 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
737 "%s: line %d: missing alias and aliased_dn in "
738 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
741 Debug( LDAP_DEBUG_ANY,
742 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
747 } else if ( cargc < 3 ) {
749 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
750 "%s: line %d: missing aliased_dn in "
751 "\"suffixAlias <alias> <aliased_dn>\" line\n",
754 Debug( LDAP_DEBUG_ANY,
755 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
760 } else if ( cargc > 3 ) {
762 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
763 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
766 Debug( LDAP_DEBUG_ANY,
767 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
775 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
776 "%s: line %d: suffixAlias line must appear inside a "
777 "database definition (ignored).\n", fname, lineno ));
779 Debug( LDAP_DEBUG_ANY,
780 "%s: line %d: suffixAlias line"
781 " must appear inside a database definition (ignored)\n",
785 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
787 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
788 "%s: line %d: suffixAlias served by a preceeding "
789 "backend \"%s\" (ignored).\n", fname, lineno,
790 tmp_be->be_suffix[0] ));
792 Debug( LDAP_DEBUG_ANY,
793 "%s: line %d: suffixAlias served by"
794 " a preceeding backend \"%s\" (ignored)\n",
795 fname, lineno, tmp_be->be_suffix[0] );
799 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
801 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
802 "%s: line %d: suffixAlias derefs to a different backend "
803 "a preceeding backend \"%s\" (ignored)\n",
804 fname, lineno, tmp_be->be_suffix[0] ));
806 Debug( LDAP_DEBUG_ANY,
807 "%s: line %d: suffixAlias derefs to differnet backend"
808 " a preceeding backend \"%s\" (ignored)\n",
809 fname, lineno, tmp_be->be_suffix[0] );
814 char *alias, *aliased_dn;
816 alias = ch_strdup( cargv[1] );
817 if ( load_ucdata( NULL ) < 0 ) {
820 (void) dn_normalize( alias );
822 aliased_dn = ch_strdup( cargv[2] );
823 (void) dn_normalize( aliased_dn );
825 charray_add( &be->be_suffixAlias, alias );
826 charray_add( &be->be_suffixAlias, aliased_dn );
832 /* set max deref depth */
833 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
837 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
838 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
839 " line\n", fname, lineno ));
841 Debug( LDAP_DEBUG_ANY,
842 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
850 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
851 "%s: line %d: depth line must appear inside a database "
852 "definition (ignored)\n", fname, lineno ));
854 Debug( LDAP_DEBUG_ANY,
855 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
859 } else if ((i = atoi(cargv[1])) < 0) {
861 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
862 "%s: line %d: depth must be positive (ignored).\n",
865 Debug( LDAP_DEBUG_ANY,
866 "%s: line %d: depth must be positive (ignored)\n",
872 be->be_max_deref_depth = i;
876 /* set magic "root" dn for this database */
877 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
880 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
881 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
884 Debug( LDAP_DEBUG_ANY,
885 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
893 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
894 "%s: line %d: rootdn line must appear inside a database "
895 "definition (ignored).\n", fname, lineno ));
897 Debug( LDAP_DEBUG_ANY,
898 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
903 be->be_root_dn = ch_strdup( cargv[1] );
904 be->be_root_ndn = ch_strdup( cargv[1] );
906 if ( load_ucdata( NULL ) < 0 ) {
909 if( dn_normalize( be->be_root_ndn ) == NULL ) {
910 free( be->be_root_dn );
911 free( be->be_root_ndn );
913 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
914 "%s: line %d: rootdn DN is invalid.\n",
917 Debug( LDAP_DEBUG_ANY,
918 "%s: line %d: rootdn DN is invalid\n",
926 /* set super-secret magic database password */
927 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
930 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
931 "%s: line %d: missing passwd in \"rootpw <passwd>\""
932 " line\n", fname, lineno ));
934 Debug( LDAP_DEBUG_ANY,
935 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
943 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
944 "%s: line %d: rootpw line must appear inside a database "
945 "definition (ignored)\n", fname, lineno ));
947 Debug( LDAP_DEBUG_ANY,
948 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
953 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
954 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
957 /* make this database read-only */
958 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
961 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
962 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
965 Debug( LDAP_DEBUG_ANY,
966 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
973 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
974 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
976 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
979 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
980 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
982 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
987 /* allow these features */
988 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
989 strcasecmp( cargv[0], "allow" ) == 0 )
995 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
996 "%s: line %d: allow line must appear prior to "
997 "database definitions.\n", fname, lineno ));
999 Debug( LDAP_DEBUG_ANY,
1000 "%s: line %d: allow line must appear prior to database definitions\n",
1008 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1009 "%s: line %d: missing feature(s) in \"allow <features>\""
1010 " line\n", fname, lineno ));
1012 Debug( LDAP_DEBUG_ANY,
1013 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1022 for( i=1; i < cargc; i++ ) {
1023 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1024 allows |= SLAP_ALLOW_TLS_2_ANON;
1026 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1028 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1029 "%s: line %d: unknown feature %s in "
1030 "\"allow <features>\" line.\n",
1031 fname, lineno, cargv[1] ));
1033 Debug( LDAP_DEBUG_ANY,
1034 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1035 fname, lineno, cargv[i] );
1042 global_allows = allows;
1044 /* disallow these features */
1045 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1046 strcasecmp( cargv[0], "disallow" ) == 0 )
1048 slap_mask_t disallows;
1052 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1053 "%s: line %d: disallow line must appear prior to "
1054 "database definitions.\n", fname, lineno ));
1056 Debug( LDAP_DEBUG_ANY,
1057 "%s: line %d: disallow line must appear prior to database definitions\n",
1065 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1066 "%s: line %d: missing feature(s) in \"disallow <features>\""
1067 " line.\n", fname, lineno ));
1069 Debug( LDAP_DEBUG_ANY,
1070 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1079 for( i=1; i < cargc; i++ ) {
1080 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1081 disallows |= SLAP_DISALLOW_BIND_V2;
1083 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1084 disallows |= SLAP_DISALLOW_BIND_ANON;
1086 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1087 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1089 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1090 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1092 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1093 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1095 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1096 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1098 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1099 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1101 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1103 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1104 "%s: line %d: unknownfeature %s in "
1105 "\"disallow <features>\" line.\n",
1108 Debug( LDAP_DEBUG_ANY,
1109 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1110 fname, lineno, cargv[i] );
1117 global_disallows = disallows;
1119 /* require these features */
1120 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1121 strcasecmp( cargv[0], "require" ) == 0 )
1123 slap_mask_t requires;
1127 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1128 "%s: line %d: missing feature(s) in "
1129 "\"require <features>\" line.\n", fname, lineno ));
1131 Debug( LDAP_DEBUG_ANY,
1132 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1141 for( i=1; i < cargc; i++ ) {
1142 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1143 requires |= SLAP_REQUIRE_BIND;
1145 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1146 requires |= SLAP_REQUIRE_LDAP_V3;
1148 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1149 requires |= SLAP_REQUIRE_AUTHC;
1151 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1152 requires |= SLAP_REQUIRE_SASL;
1154 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1155 requires |= SLAP_REQUIRE_STRONG;
1157 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1159 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1160 "%s: line %d: unknown feature %s in "
1161 "\"require <features>\" line.\n",
1164 Debug( LDAP_DEBUG_ANY,
1165 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1166 fname, lineno, cargv[i] );
1174 global_requires = requires;
1176 be->be_requires = requires;
1179 /* required security factors */
1180 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1181 slap_ssf_set_t *set;
1185 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1186 "%s: line %d: missing factor(s) in \"security <factors>\""
1187 " line.\n", fname, lineno ));
1189 Debug( LDAP_DEBUG_ANY,
1190 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1198 set = &global_ssf_set;
1200 set = &be->be_ssf_set;
1203 for( i=1; i < cargc; i++ ) {
1204 if( strncasecmp( cargv[i], "ssf=",
1205 sizeof("ssf") ) == 0 )
1208 atoi( &cargv[i][sizeof("ssf")] );
1210 } else if( strncasecmp( cargv[i], "transport=",
1211 sizeof("transport") ) == 0 )
1213 set->sss_transport =
1214 atoi( &cargv[i][sizeof("transport")] );
1216 } else if( strncasecmp( cargv[i], "tls=",
1217 sizeof("tls") ) == 0 )
1220 atoi( &cargv[i][sizeof("tls")] );
1222 } else if( strncasecmp( cargv[i], "sasl=",
1223 sizeof("sasl") ) == 0 )
1226 atoi( &cargv[i][sizeof("sasl")] );
1228 } else if( strncasecmp( cargv[i], "update_ssf=",
1229 sizeof("update_ssf") ) == 0 )
1231 set->sss_update_ssf =
1232 atoi( &cargv[i][sizeof("update_ssf")] );
1234 } else if( strncasecmp( cargv[i], "update_transport=",
1235 sizeof("update_transport") ) == 0 )
1237 set->sss_update_transport =
1238 atoi( &cargv[i][sizeof("update_transport")] );
1240 } else if( strncasecmp( cargv[i], "update_tls=",
1241 sizeof("update_tls") ) == 0 )
1243 set->sss_update_tls =
1244 atoi( &cargv[i][sizeof("update_tls")] );
1246 } else if( strncasecmp( cargv[i], "update_sasl=",
1247 sizeof("update_sasl") ) == 0 )
1249 set->sss_update_sasl =
1250 atoi( &cargv[i][sizeof("update_sasl")] );
1254 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1255 "%s: line %d: unknown factor %S in "
1256 "\"security <factors>\" line.\n",
1257 fname, lineno, cargv[1] ));
1259 Debug( LDAP_DEBUG_ANY,
1260 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1261 fname, lineno, cargv[i] );
1267 /* where to send clients when we don't hold it */
1268 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1271 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1272 "%s: line %d: missing URL in \"referral <URL>\""
1273 " line.\n", fname, lineno ));
1275 Debug( LDAP_DEBUG_ANY,
1276 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1283 vals[0]->bv_val = cargv[1];
1284 vals[0]->bv_len = strlen( vals[0]->bv_val );
1285 value_add( &default_referral, vals );
1288 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1292 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1293 "%s: line %d: Error in logfile directive, "
1294 "\"logfile <filename>\"\n", fname, lineno ));
1296 Debug( LDAP_DEBUG_ANY,
1297 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1303 logfile = fopen( cargv[1], "w" );
1304 if ( logfile != NULL ) lutil_debug_file( logfile );
1307 /* start of a new database definition */
1308 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1312 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1313 "%s: line %d: Error in debug directive, "
1314 "\"debug <subsys> <level>\"\n", fname, lineno ));
1316 Debug( LDAP_DEBUG_ANY,
1317 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1323 level = atoi( cargv[2] );
1324 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1325 lutil_set_debug_level( cargv[1], level );
1326 /* specify an Object Identifier macro */
1327 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1328 parse_oidm( fname, lineno, cargc, cargv );
1330 /* specify an objectclass */
1331 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1332 if ( *cargv[1] == '(' ) {
1334 p = strchr(saveline,'(');
1335 parse_oc( fname, lineno, p, cargv );
1338 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1339 "%s: line %d: old objectclass format not supported\n",
1342 Debug( LDAP_DEBUG_ANY,
1343 "%s: line %d: old objectclass format not supported.\n",
1349 /* specify an attribute type */
1350 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1351 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1353 if ( *cargv[1] == '(' ) {
1355 p = strchr(saveline,'(');
1356 parse_at( fname, lineno, p, cargv );
1359 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1360 "%s: line %d: old attribute type format not supported.\n",
1363 Debug( LDAP_DEBUG_ANY,
1364 "%s: line %d: old attribute type format not supported.\n",
1370 /* turn on/off schema checking */
1371 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1374 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1375 "%s: line %d: missing on|off in "
1376 "\"schemacheck <on|off>\" line.\n",
1379 Debug( LDAP_DEBUG_ANY,
1380 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1386 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1387 global_schemacheck = 0;
1389 global_schemacheck = 1;
1392 /* specify access control info */
1393 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1394 parse_acl( be, fname, lineno, cargc, cargv );
1396 /* debug level to log things to syslog */
1397 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1400 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1401 "%s: line %d: missing level in \"loglevel <level>\""
1402 " line.\n", fname, lineno ));
1404 Debug( LDAP_DEBUG_ANY,
1405 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1414 for( i=1; i < cargc; i++ ) {
1415 ldap_syslog += atoi( cargv[1] );
1418 /* list of replicas of the data in this backend (master only) */
1419 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1422 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1423 "%s: line %d: missing host in \"replica "
1424 " <host[:port]\" line\n", fname, lineno ));
1426 Debug( LDAP_DEBUG_ANY,
1427 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1435 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1436 "%s: line %d: replica line must appear inside "
1437 "a database definition (ignored).\n", fname, lineno ));
1439 Debug( LDAP_DEBUG_ANY,
1440 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1445 for ( i = 1; i < cargc; i++ ) {
1446 if ( strncasecmp( cargv[i], "host=", 5 )
1448 charray_add( &be->be_replica,
1455 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1456 "%s: line %d: missing host in \"replica\" "
1457 "line (ignored)\n", fname, lineno ));
1459 Debug( LDAP_DEBUG_ANY,
1460 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1467 /* dn of master entity allowed to write to replica */
1468 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1471 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1472 "%s: line %d: missing dn in \"updatedn <dn>\""
1473 " line.\n", fname, lineno ));
1475 Debug( LDAP_DEBUG_ANY,
1476 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1484 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1485 "%s: line %d: updatedn line must appear inside "
1486 "a database definition (ignored)\n",
1489 Debug( LDAP_DEBUG_ANY,
1490 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1495 be->be_update_ndn = ch_strdup( cargv[1] );
1496 if ( load_ucdata( NULL ) < 0 ) {
1499 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1501 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1502 "%s: line %d: updatedn DN is invalid.\n",
1505 Debug( LDAP_DEBUG_ANY,
1506 "%s: line %d: updatedn DN is invalid\n",
1514 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1517 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1518 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1519 "line.\n", fname, lineno ));
1521 Debug( LDAP_DEBUG_ANY,
1522 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1530 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1531 "%s: line %d: updateref line must appear inside "
1532 "a database definition (ignored)\n", fname, lineno ));
1534 Debug( LDAP_DEBUG_ANY,
1535 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1539 } else if ( be->be_update_ndn == NULL ) {
1541 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1542 "%s: line %d: updateref line must come after updatedn "
1543 "(ignored).\n", fname, lineno ));
1545 Debug( LDAP_DEBUG_ANY,
1546 "%s: line %d: updateref line must after updatedn (ignored)\n",
1551 vals[0]->bv_val = cargv[1];
1552 vals[0]->bv_len = strlen( vals[0]->bv_val );
1553 value_add( &be->be_update_refs, vals );
1556 /* replication log file to which changes are appended */
1557 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1560 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1561 "%s: line %d: missing filename in \"replogfile <filename>\""
1562 " line.\n", fname, lineno ));
1564 Debug( LDAP_DEBUG_ANY,
1565 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1572 be->be_replogfile = ch_strdup( cargv[1] );
1574 replogfile = ch_strdup( cargv[1] );
1577 /* maintain lastmodified{by,time} attributes */
1578 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1581 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1582 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1583 " line.\n", fname, lineno ));
1585 Debug( LDAP_DEBUG_ANY,
1586 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1592 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1594 be->be_lastmod = ON;
1596 global_lastmod = ON;
1599 be->be_lastmod = OFF;
1601 global_lastmod = OFF;
1604 /* set idle timeout value */
1605 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1609 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1610 "%s: line %d: missing timeout value in "
1611 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1613 Debug( LDAP_DEBUG_ANY,
1614 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1621 i = atoi( cargv[1] );
1625 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1626 "%s: line %d: timeout value (%d) invalid "
1627 "\"idletimeout <seconds>\" line.\n",
1628 fname, lineno, i ));
1630 Debug( LDAP_DEBUG_ANY,
1631 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1638 global_idletimeout = i;
1640 /* include another config file */
1641 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1644 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1645 "%s: line %d: missing filename in \"include "
1646 "<filename>\" line.\n", fname, lineno ));
1648 Debug( LDAP_DEBUG_ANY,
1649 "%s: line %d: missing filename in \"include <filename>\" line\n",
1655 savefname = ch_strdup( cargv[1] );
1656 savelineno = lineno;
1658 if ( read_config( savefname ) != 0 ) {
1663 lineno = savelineno - 1;
1665 /* location of kerberos srvtab file */
1666 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1669 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1670 "%s: line %d: missing filename in \"srvtab "
1671 "<filename>\" line.\n", fname, lineno ));
1673 Debug( LDAP_DEBUG_ANY,
1674 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1680 ldap_srvtab = ch_strdup( cargv[1] );
1682 #ifdef SLAPD_MODULES
1683 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1686 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1687 "%s: line %d: missing filename in \"moduleload "
1688 "<filename>\" line.\n", fname, lineno ));
1690 Debug( LDAP_DEBUG_ANY,
1691 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1695 exit( EXIT_FAILURE );
1697 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1699 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1700 "%s: line %d: failed to load or initialize module %s\n"<
1701 fname, lineno, cargv[1] ));
1703 Debug( LDAP_DEBUG_ANY,
1704 "%s: line %d: failed to load or initialize module %s\n",
1705 fname, lineno, cargv[1]);
1708 exit( EXIT_FAILURE );
1710 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1713 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1714 "%s: line %d: missing path in \"modulepath <path>\""
1715 " line\n", fname, lineno ));
1717 Debug( LDAP_DEBUG_ANY,
1718 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1722 exit( EXIT_FAILURE );
1724 if (module_path( cargv[1] )) {
1726 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1727 "%s: line %d: failed to set module search path to %s.\n",
1728 fname, lineno, cargv[1] ));
1730 Debug( LDAP_DEBUG_ANY,
1731 "%s: line %d: failed to set module search path to %s\n",
1732 fname, lineno, cargv[1]);
1735 exit( EXIT_FAILURE );
1738 #endif /*SLAPD_MODULES*/
1741 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1742 rc = ldap_pvt_tls_set_option( NULL,
1743 LDAP_OPT_X_TLS_PROTOCOL,
1748 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1749 rc = ldap_pvt_tls_set_option( NULL,
1750 LDAP_OPT_X_TLS_CIPHER_SUITE,
1755 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1756 rc = ldap_pvt_tls_set_option( NULL,
1757 LDAP_OPT_X_TLS_CERTFILE,
1762 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1763 rc = ldap_pvt_tls_set_option( NULL,
1764 LDAP_OPT_X_TLS_KEYFILE,
1769 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1770 rc = ldap_pvt_tls_set_option( NULL,
1771 LDAP_OPT_X_TLS_CACERTDIR,
1776 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1777 rc = ldap_pvt_tls_set_option( NULL,
1778 LDAP_OPT_X_TLS_CACERTFILE,
1782 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1784 rc = ldap_pvt_tls_set_option( NULL,
1785 LDAP_OPT_X_TLS_REQUIRE_CERT,
1792 /* pass anything else to the current backend info/db config routine */
1795 if ( bi->bi_config == 0 ) {
1797 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1798 "%s: line %d: unknown directive \"%s\" inside "
1799 "backend info definition (ignored).\n",
1800 fname, lineno, cargv[0] ));
1802 Debug( LDAP_DEBUG_ANY,
1803 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1804 fname, lineno, cargv[0] );
1808 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1814 } else if ( be != NULL ) {
1815 if ( be->be_config == 0 ) {
1817 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1818 "%s: line %d: uknown directive \"%s\" inside "
1819 "backend database definition (ignored).\n",
1820 fname, lineno, cargv[0] ));
1822 Debug( LDAP_DEBUG_ANY,
1823 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1824 fname, lineno, cargv[0] );
1828 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1836 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1837 "%s: line %d: unknown directive \"%s\" outside backend "
1838 "info and database definitions (ignored).\n",
1839 fname, lineno, cargv[0] ));
1841 Debug( LDAP_DEBUG_ANY,
1842 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1843 fname, lineno, cargv[0] );
1851 if ( load_ucdata( NULL ) < 0 ) {
1867 for ( token = strtok_quote( line, " \t" ); token != NULL;
1868 token = strtok_quote( NULL, " \t" ) ) {
1869 if ( *argcp == MAXARGS ) {
1871 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1872 "fp_parse_line: too many tokens (%d max).\n",
1875 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1881 argv[(*argcp)++] = token;
1883 argv[*argcp] = NULL;
1888 strtok_quote( char *line, char *sep )
1894 if ( line != NULL ) {
1897 while ( *next && strchr( sep, *next ) ) {
1901 if ( *next == '\0' ) {
1907 for ( inquote = 0; *next; ) {
1915 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1921 next + 1, strlen( next + 1 ) + 1 );
1922 next++; /* dont parse the escaped character */
1927 if ( strchr( sep, *next ) != NULL ) {
1940 static char buf[BUFSIZ];
1942 static int lmax, lcur;
1944 #define CATLINE( buf ) { \
1946 len = strlen( buf ); \
1947 while ( lcur + len + 1 > lmax ) { \
1949 line = (char *) ch_realloc( line, lmax ); \
1951 strcpy( line + lcur, buf ); \
1956 fp_getline( FILE *fp, int *lineno )
1964 /* hack attack - keeps us from having to keep a stack of bufs... */
1965 if ( strncasecmp( line, "include", 7 ) == 0 ) {
1970 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
1971 if ( (p = strchr( buf, '\n' )) != NULL ) {
1974 if ( ! isspace( (unsigned char) buf[0] ) ) {
1983 return( line[0] ? line : NULL );
1987 fp_getline_init( int *lineno )
1993 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1995 load_ucdata( char *path )
1997 static int loaded = 0;
2003 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA,
2004 UCDATA_CASE|UCDATA_CTYPE|UCDATA_NUM );
2007 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2008 "load_ucdata: Error %d loading ucdata.\n", err ));
2010 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",