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 int global_backendsyncfreq = 0;
38 char *global_host = NULL;
39 char *global_realm = NULL;
40 char *ldap_srvtab = "";
41 char *default_passwd_hash;
42 char *default_search_base = NULL;
43 char *default_search_nbase = NULL;
45 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
46 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
48 char *slapd_pid_file = NULL;
49 char *slapd_args_file = NULL;
52 SaslRegexp_t *SaslRegexp = NULL;
53 int sasl_external_x509dn_convert;
55 static char *fp_getline(FILE *fp, int *lineno);
56 static void fp_getline_init(int *lineno);
57 static int fp_parse_line(char *line, int *argcp, char **argv);
59 static char *strtok_quote(char *line, char *sep);
60 static int load_ucdata(char *path);
63 read_config( const char *fname )
66 char *line, *savefname, *saveline;
67 int cargc, savelineno;
68 char *cargv[MAXARGS+1];
71 struct berval *vals[2];
74 static BackendInfo *bi = NULL;
75 static BackendDB *be = NULL;
80 if ( (fp = fopen( fname, "r" )) == NULL ) {
82 Debug( LDAP_DEBUG_ANY,
83 "could not open config file \"%s\" - absolute path?\n",
90 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
91 "read_config: reading config file %s\n", fname ));
93 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
97 fp_getline_init( &lineno );
99 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
100 /* skip comments and blank lines */
101 if ( line[0] == '#' || line[0] == '\0' ) {
106 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
107 "line %d (%s)\n", lineno, line ));
109 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
113 /* fp_parse_line is destructive, we save a copy */
114 saveline = ch_strdup( line );
116 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
122 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
123 "%s: line %d: bad config line (ignored)\n",
126 Debug( LDAP_DEBUG_ANY,
127 "%s: line %d: bad config line (ignored)\n",
134 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
137 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
138 "%s : line %d: missing type in \"backend\" line.\n",
141 Debug( LDAP_DEBUG_ANY,
142 "%s: line %d: missing type in \"backend <type>\" line\n",
151 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
152 "%s: line %d: backend line must appear before any "
153 "database definition.\n", fname, lineno ));
155 Debug( LDAP_DEBUG_ANY,
156 "%s: line %d: backend line must appear before any database definition\n",
163 bi = backend_info( cargv[1] );
167 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
168 "read_config: backend %s initialization failed.\n",
171 Debug( LDAP_DEBUG_ANY,
172 "backend %s initialization failed.\n",
178 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
181 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
182 "%s: line %d: missing type in \"database <type>\" line\n",
185 Debug( LDAP_DEBUG_ANY,
186 "%s: line %d: missing type in \"database <type>\" line\n",
194 be = backend_db_init( cargv[1] );
198 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
199 "database %s initialization failed.\n",
202 Debug( LDAP_DEBUG_ANY,
203 "database %s initialization failed.\n",
210 /* set thread concurrency */
211 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
215 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
216 "%s: line %d: missing level in \"concurrency <level\" line\n",
219 Debug( LDAP_DEBUG_ANY,
220 "%s: line %d: missing level in \"concurrency <level>\" line\n",
227 c = atoi( cargv[1] );
231 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
232 "%s: line %d: invalid level (%d) in "
233 "\"concurrency <level>\" line.\n",
236 Debug( LDAP_DEBUG_ANY,
237 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
244 ldap_pvt_thread_set_concurrency( c );
246 /* set sockbuf max */
247 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
251 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
252 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
255 Debug( LDAP_DEBUG_ANY,
256 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
263 max = atol( cargv[1] );
267 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
268 "%s: line %d: invalid max value (%ld) in "
269 "\"sockbuf_max_incoming <bytes>\" line.\n",
270 fname, lineno, max ));
272 Debug( LDAP_DEBUG_ANY,
273 "%s: line %d: invalid max value (%ld) in "
274 "\"sockbuf_max_incoming <bytes>\" line.\n",
275 fname, lineno, max );
281 sockbuf_max_incoming = max;
283 /* set sockbuf max authenticated */
284 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
288 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
289 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
292 Debug( LDAP_DEBUG_ANY,
293 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
300 max = atol( cargv[1] );
304 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
305 "%s: line %d: invalid max value (%ld) in "
306 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
307 fname, lineno, max ));
309 Debug( LDAP_DEBUG_ANY,
310 "%s: line %d: invalid max value (%ld) in "
311 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
312 fname, lineno, max );
318 sockbuf_max_incoming_auth = max;
320 /* default search base */
321 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
324 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
325 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
326 "line\n", fname, lineno ));
328 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
329 "missing dn in \"defaultSearchBase <dn>\" line\n",
335 } else if ( cargc > 2 ) {
337 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
338 "%s: line %d: extra cruft after <dn> in "
339 "\"defaultSearchBase %s\" line (ignored)\n",
340 fname, lineno, cargv[1] ));
342 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
343 "extra cruft after <dn> in \"defaultSearchBase %s\", "
345 fname, lineno, cargv[1] );
350 if ( bi != NULL || be != NULL ) {
352 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
353 "%s: line %d: defaultSearchBase line must appear "
354 "prior to any backend or database definitions\n",
357 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
358 "defaultSearchBaase line must appear prior to "
359 "any backend or database definition\n",
366 if ( default_search_nbase != NULL ) {
368 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
369 "%s: line %d: default search base \"%s\" already defined "
370 "(discarding old)\n", fname, lineno, default_search_base ));
372 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
373 "default search base \"%s\" already defined "
374 "(discarding old)\n",
375 fname, lineno, default_search_base );
378 free( default_search_base );
379 free( default_search_nbase );
382 default_search_base = ch_strdup( cargv[1] );
383 default_search_nbase = ch_strdup( cargv[1] );
385 if ( load_ucdata( NULL ) < 0 ) {
388 if( dn_normalize( default_search_nbase ) == NULL ) {
390 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
391 "%s: %d: invalid default search base \"%s\"\n",
392 fname, lineno, default_search_base ));
394 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
395 "invalid default search base \"%s\"\n",
396 fname, lineno, default_search_base );
402 /* set maximum threads in thread pool */
403 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
407 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
408 "%s: line %d: missing count in \"threads <count>\" line\n",
411 Debug( LDAP_DEBUG_ANY,
412 "%s: line %d: missing count in \"threads <count>\" line\n",
419 c = atoi( cargv[1] );
423 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
424 "%s: line %d: invalid level (%d) in \"threads <count>\""
425 "line\n",fname, lineno, c ));
427 Debug( LDAP_DEBUG_ANY,
428 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
435 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
437 /* get pid file name */
438 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
441 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
442 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
445 Debug( LDAP_DEBUG_ANY,
446 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
453 slapd_pid_file = ch_strdup( cargv[1] );
455 /* get args file name */
456 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
459 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
460 "%s: %d: missing file name in "
461 "\"argsfile <file>\" line.\n",
464 Debug( LDAP_DEBUG_ANY,
465 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
472 slapd_args_file = ch_strdup( cargv[1] );
474 /* default password hash */
475 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
478 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
479 "%s: line %d: missing hash in "
480 "\"password-hash <hash>\" line.\n",
483 Debug( LDAP_DEBUG_ANY,
484 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
490 if ( default_passwd_hash != NULL ) {
492 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
493 "%s: line %d: already set default password_hash!\n",
496 Debug( LDAP_DEBUG_ANY,
497 "%s: line %d: already set default password_hash!\n",
504 default_passwd_hash = ch_strdup( cargv[1] );
507 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
511 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
512 "%s: line %d: missing format in "
513 "\"password-crypt-salt-format <format>\" line\n",
516 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
517 "\"password-crypt-salt-format <format>\" line\n",
524 lutil_salt_format( cargv[1] );
527 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
530 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
531 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
534 Debug( LDAP_DEBUG_ANY,
535 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
542 if ( global_host != NULL ) {
544 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
545 "%s: line %d: already set sasl-host!\n",
548 Debug( LDAP_DEBUG_ANY,
549 "%s: line %d: already set sasl-host!\n",
556 global_host = ch_strdup( cargv[1] );
560 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
563 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
564 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
567 Debug( LDAP_DEBUG_ANY,
568 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
575 if ( global_realm != NULL ) {
577 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
578 "%s: line %d: already set sasl-realm!\n",
581 Debug( LDAP_DEBUG_ANY,
582 "%s: line %d: already set sasl-realm!\n",
589 global_realm = ch_strdup( cargv[1] );
592 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
593 || !strcasecmp( cargv[0], "saslregexp" ) )
598 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
599 "%s: line %d: need 2 args in "
600 "\"saslregexp <match> <replace>\"\n",
603 Debug( LDAP_DEBUG_ANY,
604 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
610 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
615 /* SASL security properties */
616 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
621 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
622 "%s: line %d: missing flags in "
623 "\"sasl-secprops <properties>\" line\n",
626 Debug( LDAP_DEBUG_ANY,
627 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
634 txt = slap_sasl_secprops( cargv[1] );
637 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
638 "%s: line %d sas-secprops: %s\n",
639 fname, lineno, txt ));
641 Debug( LDAP_DEBUG_ANY,
642 "%s: line %d: sasl-secprops: %s\n",
643 fname, lineno, txt );
649 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
650 sasl_external_x509dn_convert++;
652 /* set UCDATA path */
653 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
657 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
658 "%s: line %d: missing path in "
659 "\"ucdata-path <path>\" line.\n",
662 Debug( LDAP_DEBUG_ANY,
663 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
670 err = load_ucdata( cargv[1] );
674 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
675 "%s: line %d: ucdata already loaded, ucdata-path "
676 "must be set earlier in the file and/or be "
677 "specified only once!\n",
680 Debug( LDAP_DEBUG_ANY,
681 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
690 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
693 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
694 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
697 Debug( LDAP_DEBUG_ANY,
698 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
705 defsize = atoi( cargv[1] );
707 be->be_sizelimit = atoi( cargv[1] );
711 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
714 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
715 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
718 Debug( LDAP_DEBUG_ANY,
719 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
726 deftime = atoi( cargv[1] );
728 be->be_timelimit = atoi( cargv[1] );
731 /* set database suffix */
732 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
736 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
737 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
740 Debug( LDAP_DEBUG_ANY,
741 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
746 } else if ( cargc > 2 ) {
748 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
749 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
750 " line (ignored).\n", fname, lineno, cargv[1] ));
752 Debug( LDAP_DEBUG_ANY,
753 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
754 fname, lineno, cargv[1] );
760 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
761 "%s: line %d: suffix line must appear inside a database "
762 "definition (ignored).\n", fname, lineno ));
764 Debug( LDAP_DEBUG_ANY,
765 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
769 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
771 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
772 "%s: line %d: suffix already served by this backend "
773 "(ignored)\n", fname, lineno ));
775 Debug( LDAP_DEBUG_ANY,
776 "%s: line %d: suffix already served by this backend (ignored)\n",
780 } else if ( tmp_be != NULL ) {
782 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
783 "%s: line %d: suffix already served by a preceding "
784 "backend \"%s\" (ignored)\n", fname, lineno,
785 tmp_be->be_suffix[0] ));
787 Debug( LDAP_DEBUG_ANY,
788 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
789 fname, lineno, tmp_be->be_suffix[0] );
793 char *dn = ch_strdup( cargv[1] );
794 if ( load_ucdata( NULL ) < 0 ) {
797 if( dn_validate( dn ) == NULL ) {
799 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
800 "%s: line %d: suffix DN invalid\"%s\"\n",
801 fname, lineno, cargv[1] ));
803 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
804 "suffix DN invalid \"%s\"\n",
805 fname, lineno, cargv[1] );
810 } else if( *dn == '\0' && default_search_nbase != NULL ) {
812 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
813 "%s: line %d: suffix DN empty and default search "
814 "base provided \"%s\" (assuming okay).\n",
815 fname, lineno, default_search_base ));
817 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
818 "suffix DN empty and default "
819 "search base provided \"%s\" (assuming okay)\n",
820 fname, lineno, default_search_base );
824 charray_add( &be->be_suffix, dn );
825 (void) ldap_pvt_str2upper( dn );
826 charray_add( &be->be_nsuffix, dn );
830 /* set database suffixAlias */
831 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
835 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
836 "%s: line %d: missing alias and aliased_dn in "
837 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
840 Debug( LDAP_DEBUG_ANY,
841 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
846 } else if ( cargc < 3 ) {
848 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
849 "%s: line %d: missing aliased_dn in "
850 "\"suffixAlias <alias> <aliased_dn>\" line\n",
853 Debug( LDAP_DEBUG_ANY,
854 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
859 } else if ( cargc > 3 ) {
861 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
862 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
865 Debug( LDAP_DEBUG_ANY,
866 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
874 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
875 "%s: line %d: suffixAlias line must appear inside a "
876 "database definition (ignored).\n", fname, lineno ));
878 Debug( LDAP_DEBUG_ANY,
879 "%s: line %d: suffixAlias line"
880 " must appear inside a database definition (ignored)\n",
884 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
886 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
887 "%s: line %d: suffixAlias served by a preceeding "
888 "backend \"%s\" (ignored).\n", fname, lineno,
889 tmp_be->be_suffix[0] ));
891 Debug( LDAP_DEBUG_ANY,
892 "%s: line %d: suffixAlias served by"
893 " a preceeding backend \"%s\" (ignored)\n",
894 fname, lineno, tmp_be->be_suffix[0] );
898 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
900 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
901 "%s: line %d: suffixAlias derefs to a different backend "
902 "a preceeding backend \"%s\" (ignored)\n",
903 fname, lineno, tmp_be->be_suffix[0] ));
905 Debug( LDAP_DEBUG_ANY,
906 "%s: line %d: suffixAlias derefs to differnet backend"
907 " a preceeding backend \"%s\" (ignored)\n",
908 fname, lineno, tmp_be->be_suffix[0] );
913 char *alias, *aliased_dn;
915 alias = ch_strdup( cargv[1] );
916 if ( load_ucdata( NULL ) < 0 ) {
919 (void) dn_normalize( alias );
921 aliased_dn = ch_strdup( cargv[2] );
922 (void) dn_normalize( aliased_dn );
924 charray_add( &be->be_suffixAlias, alias );
925 charray_add( &be->be_suffixAlias, aliased_dn );
931 /* set max deref depth */
932 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
936 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
937 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
938 " line\n", fname, lineno ));
940 Debug( LDAP_DEBUG_ANY,
941 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
949 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
950 "%s: line %d: depth line must appear inside a database "
951 "definition (ignored)\n", fname, lineno ));
953 Debug( LDAP_DEBUG_ANY,
954 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
958 } else if ((i = atoi(cargv[1])) < 0) {
960 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
961 "%s: line %d: depth must be positive (ignored).\n",
964 Debug( LDAP_DEBUG_ANY,
965 "%s: line %d: depth must be positive (ignored)\n",
971 be->be_max_deref_depth = i;
975 /* set magic "root" dn for this database */
976 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
979 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
980 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
983 Debug( LDAP_DEBUG_ANY,
984 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
992 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
993 "%s: line %d: rootdn line must appear inside a database "
994 "definition (ignored).\n", fname, lineno ));
996 Debug( LDAP_DEBUG_ANY,
997 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1002 be->be_root_dn = ch_strdup( cargv[1] );
1003 be->be_root_ndn = ch_strdup( cargv[1] );
1005 if ( load_ucdata( NULL ) < 0 ) {
1008 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1009 free( be->be_root_dn );
1010 free( be->be_root_ndn );
1012 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1013 "%s: line %d: rootdn DN is invalid.\n",
1016 Debug( LDAP_DEBUG_ANY,
1017 "%s: line %d: rootdn DN is invalid\n",
1025 /* set super-secret magic database password */
1026 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1029 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1030 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1031 " line\n", fname, lineno ));
1033 Debug( LDAP_DEBUG_ANY,
1034 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1042 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1043 "%s: line %d: rootpw line must appear inside a database "
1044 "definition (ignored)\n", fname, lineno ));
1046 Debug( LDAP_DEBUG_ANY,
1047 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1052 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1053 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1056 /* make this database read-only */
1057 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1060 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1061 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1064 Debug( LDAP_DEBUG_ANY,
1065 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1072 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1073 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1075 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1078 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1079 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1081 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1086 /* allow these features */
1087 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1088 strcasecmp( cargv[0], "allow" ) == 0 )
1094 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1095 "%s: line %d: allow line must appear prior to "
1096 "database definitions.\n", fname, lineno ));
1098 Debug( LDAP_DEBUG_ANY,
1099 "%s: line %d: allow line must appear prior to database definitions\n",
1107 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1108 "%s: line %d: missing feature(s) in \"allow <features>\""
1109 " line\n", fname, lineno ));
1111 Debug( LDAP_DEBUG_ANY,
1112 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1121 for( i=1; i < cargc; i++ ) {
1122 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1123 allows |= SLAP_ALLOW_TLS_2_ANON;
1125 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1127 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1128 "%s: line %d: unknown feature %s in "
1129 "\"allow <features>\" line.\n",
1130 fname, lineno, cargv[1] ));
1132 Debug( LDAP_DEBUG_ANY,
1133 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1134 fname, lineno, cargv[i] );
1141 global_allows = allows;
1143 /* disallow these features */
1144 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1145 strcasecmp( cargv[0], "disallow" ) == 0 )
1147 slap_mask_t disallows;
1151 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1152 "%s: line %d: disallow line must appear prior to "
1153 "database definitions.\n", fname, lineno ));
1155 Debug( LDAP_DEBUG_ANY,
1156 "%s: line %d: disallow line must appear prior to database definitions\n",
1164 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1165 "%s: line %d: missing feature(s) in \"disallow <features>\""
1166 " line.\n", fname, lineno ));
1168 Debug( LDAP_DEBUG_ANY,
1169 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1178 for( i=1; i < cargc; i++ ) {
1179 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1180 disallows |= SLAP_DISALLOW_BIND_V2;
1182 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1183 disallows |= SLAP_DISALLOW_BIND_ANON;
1185 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1186 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1188 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1189 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1191 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1192 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1194 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1195 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1197 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1198 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1200 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1202 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1203 "%s: line %d: unknownfeature %s in "
1204 "\"disallow <features>\" line.\n",
1207 Debug( LDAP_DEBUG_ANY,
1208 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1209 fname, lineno, cargv[i] );
1216 global_disallows = disallows;
1218 /* require these features */
1219 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1220 strcasecmp( cargv[0], "require" ) == 0 )
1222 slap_mask_t requires;
1226 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1227 "%s: line %d: missing feature(s) in "
1228 "\"require <features>\" line.\n", fname, lineno ));
1230 Debug( LDAP_DEBUG_ANY,
1231 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1240 for( i=1; i < cargc; i++ ) {
1241 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1242 requires |= SLAP_REQUIRE_BIND;
1244 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1245 requires |= SLAP_REQUIRE_LDAP_V3;
1247 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1248 requires |= SLAP_REQUIRE_AUTHC;
1250 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1251 requires |= SLAP_REQUIRE_SASL;
1253 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1254 requires |= SLAP_REQUIRE_STRONG;
1256 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1258 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1259 "%s: line %d: unknown feature %s in "
1260 "\"require <features>\" line.\n",
1263 Debug( LDAP_DEBUG_ANY,
1264 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1265 fname, lineno, cargv[i] );
1273 global_requires = requires;
1275 be->be_requires = requires;
1278 /* required security factors */
1279 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1280 slap_ssf_set_t *set;
1284 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1285 "%s: line %d: missing factor(s) in \"security <factors>\""
1286 " line.\n", fname, lineno ));
1288 Debug( LDAP_DEBUG_ANY,
1289 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1297 set = &global_ssf_set;
1299 set = &be->be_ssf_set;
1302 for( i=1; i < cargc; i++ ) {
1303 if( strncasecmp( cargv[i], "ssf=",
1304 sizeof("ssf") ) == 0 )
1307 atoi( &cargv[i][sizeof("ssf")] );
1309 } else if( strncasecmp( cargv[i], "transport=",
1310 sizeof("transport") ) == 0 )
1312 set->sss_transport =
1313 atoi( &cargv[i][sizeof("transport")] );
1315 } else if( strncasecmp( cargv[i], "tls=",
1316 sizeof("tls") ) == 0 )
1319 atoi( &cargv[i][sizeof("tls")] );
1321 } else if( strncasecmp( cargv[i], "sasl=",
1322 sizeof("sasl") ) == 0 )
1325 atoi( &cargv[i][sizeof("sasl")] );
1327 } else if( strncasecmp( cargv[i], "update_ssf=",
1328 sizeof("update_ssf") ) == 0 )
1330 set->sss_update_ssf =
1331 atoi( &cargv[i][sizeof("update_ssf")] );
1333 } else if( strncasecmp( cargv[i], "update_transport=",
1334 sizeof("update_transport") ) == 0 )
1336 set->sss_update_transport =
1337 atoi( &cargv[i][sizeof("update_transport")] );
1339 } else if( strncasecmp( cargv[i], "update_tls=",
1340 sizeof("update_tls") ) == 0 )
1342 set->sss_update_tls =
1343 atoi( &cargv[i][sizeof("update_tls")] );
1345 } else if( strncasecmp( cargv[i], "update_sasl=",
1346 sizeof("update_sasl") ) == 0 )
1348 set->sss_update_sasl =
1349 atoi( &cargv[i][sizeof("update_sasl")] );
1353 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1354 "%s: line %d: unknown factor %S in "
1355 "\"security <factors>\" line.\n",
1356 fname, lineno, cargv[1] ));
1358 Debug( LDAP_DEBUG_ANY,
1359 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1360 fname, lineno, cargv[i] );
1366 /* where to send clients when we don't hold it */
1367 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1370 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1371 "%s: line %d: missing URL in \"referral <URL>\""
1372 " line.\n", fname, lineno ));
1374 Debug( LDAP_DEBUG_ANY,
1375 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1382 vals[0]->bv_val = cargv[1];
1383 vals[0]->bv_len = strlen( vals[0]->bv_val );
1384 value_add( &default_referral, vals );
1387 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1391 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1392 "%s: line %d: Error in logfile directive, "
1393 "\"logfile <filename>\"\n", fname, lineno ));
1395 Debug( LDAP_DEBUG_ANY,
1396 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1402 logfile = fopen( cargv[1], "w" );
1403 if ( logfile != NULL ) lutil_debug_file( logfile );
1406 /* start of a new database definition */
1407 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1411 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1412 "%s: line %d: Error in debug directive, "
1413 "\"debug <subsys> <level>\"\n", fname, lineno ));
1415 Debug( LDAP_DEBUG_ANY,
1416 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1422 level = atoi( cargv[2] );
1423 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1424 lutil_set_debug_level( cargv[1], level );
1425 /* specify an Object Identifier macro */
1426 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1427 rc = parse_oidm( fname, lineno, cargc, cargv );
1430 /* specify an objectclass */
1431 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1432 if ( *cargv[1] == '(' ) {
1434 p = strchr(saveline,'(');
1435 rc = parse_oc( fname, lineno, p, cargv );
1440 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1441 "%s: line %d: old objectclass format not supported\n",
1444 Debug( LDAP_DEBUG_ANY,
1445 "%s: line %d: old objectclass format not supported.\n",
1451 /* specify an attribute type */
1452 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1453 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1455 if ( *cargv[1] == '(' ) {
1457 p = strchr(saveline,'(');
1458 rc = parse_at( fname, lineno, p, cargv );
1463 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1464 "%s: line %d: old attribute type format not supported.\n",
1467 Debug( LDAP_DEBUG_ANY,
1468 "%s: line %d: old attribute type format not supported.\n",
1474 /* turn on/off schema checking */
1475 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1478 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1479 "%s: line %d: missing on|off in "
1480 "\"schemacheck <on|off>\" line.\n",
1483 Debug( LDAP_DEBUG_ANY,
1484 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1490 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1491 global_schemacheck = 0;
1493 global_schemacheck = 1;
1496 /* specify access control info */
1497 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1498 parse_acl( be, fname, lineno, cargc, cargv );
1500 /* debug level to log things to syslog */
1501 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1504 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1505 "%s: line %d: missing level in \"loglevel <level>\""
1506 " line.\n", fname, lineno ));
1508 Debug( LDAP_DEBUG_ANY,
1509 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1518 for( i=1; i < cargc; i++ ) {
1519 ldap_syslog += atoi( cargv[1] );
1522 /* list of replicas of the data in this backend (master only) */
1523 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1526 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1527 "%s: line %d: missing host in \"replica "
1528 " <host[:port]\" line\n", fname, lineno ));
1530 Debug( LDAP_DEBUG_ANY,
1531 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1539 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1540 "%s: line %d: replica line must appear inside "
1541 "a database definition (ignored).\n", fname, lineno ));
1543 Debug( LDAP_DEBUG_ANY,
1544 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1549 for ( i = 1; i < cargc; i++ ) {
1550 if ( strncasecmp( cargv[i], "host=", 5 )
1552 charray_add( &be->be_replica,
1559 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1560 "%s: line %d: missing host in \"replica\" "
1561 "line (ignored)\n", fname, lineno ));
1563 Debug( LDAP_DEBUG_ANY,
1564 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1571 /* dn of master entity allowed to write to replica */
1572 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1575 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1576 "%s: line %d: missing dn in \"updatedn <dn>\""
1577 " line.\n", fname, lineno ));
1579 Debug( LDAP_DEBUG_ANY,
1580 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1588 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1589 "%s: line %d: updatedn line must appear inside "
1590 "a database definition (ignored)\n",
1593 Debug( LDAP_DEBUG_ANY,
1594 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1599 be->be_update_ndn = ch_strdup( cargv[1] );
1600 if ( load_ucdata( NULL ) < 0 ) {
1603 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1605 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1606 "%s: line %d: updatedn DN is invalid.\n",
1609 Debug( LDAP_DEBUG_ANY,
1610 "%s: line %d: updatedn DN is invalid\n",
1618 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1621 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1622 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1623 "line.\n", fname, lineno ));
1625 Debug( LDAP_DEBUG_ANY,
1626 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1634 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1635 "%s: line %d: updateref line must appear inside "
1636 "a database definition (ignored)\n", fname, lineno ));
1638 Debug( LDAP_DEBUG_ANY,
1639 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1643 } else if ( be->be_update_ndn == NULL ) {
1645 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1646 "%s: line %d: updateref line must come after updatedn "
1647 "(ignored).\n", fname, lineno ));
1649 Debug( LDAP_DEBUG_ANY,
1650 "%s: line %d: updateref line must after updatedn (ignored)\n",
1655 vals[0]->bv_val = cargv[1];
1656 vals[0]->bv_len = strlen( vals[0]->bv_val );
1657 value_add( &be->be_update_refs, vals );
1660 /* replication log file to which changes are appended */
1661 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1664 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1665 "%s: line %d: missing filename in \"replogfile <filename>\""
1666 " line.\n", fname, lineno ));
1668 Debug( LDAP_DEBUG_ANY,
1669 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1676 be->be_replogfile = ch_strdup( cargv[1] );
1678 replogfile = ch_strdup( cargv[1] );
1681 /* maintain lastmodified{by,time} attributes */
1682 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1685 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1686 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1687 " line.\n", fname, lineno ));
1689 Debug( LDAP_DEBUG_ANY,
1690 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1696 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1698 be->be_lastmod = ON;
1700 global_lastmod = ON;
1703 be->be_lastmod = OFF;
1705 global_lastmod = OFF;
1708 /* set idle timeout value */
1709 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1713 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1714 "%s: line %d: missing timeout value in "
1715 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1717 Debug( LDAP_DEBUG_ANY,
1718 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1725 i = atoi( cargv[1] );
1729 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1730 "%s: line %d: timeout value (%d) invalid "
1731 "\"idletimeout <seconds>\" line.\n",
1732 fname, lineno, i ));
1734 Debug( LDAP_DEBUG_ANY,
1735 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1742 global_idletimeout = i;
1744 /* set backend sync frequency */
1745 } else if ( strcasecmp( cargv[0], "backendsyncfreq" ) == 0 ) {
1749 Debug( LDAP_DEBUG_ANY,
1750 "%s: line %d: missing frquency value in \"backendsyncfreq <seconds>\" line\n",
1755 i = atoi( cargv[1] );
1758 Debug( LDAP_DEBUG_ANY,
1759 "%s: line %d: frquency value (%d) invalid \"backendsyncfreq <seconds>\" line\n",
1764 global_backendsyncfreq = i;
1766 Debug( LDAP_DEBUG_ANY,
1767 "\"dbsyncfreq\" not supported in non-threaded environment\n");
1771 /* include another config file */
1772 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1775 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1776 "%s: line %d: missing filename in \"include "
1777 "<filename>\" line.\n", fname, lineno ));
1779 Debug( LDAP_DEBUG_ANY,
1780 "%s: line %d: missing filename in \"include <filename>\" line\n",
1786 savefname = ch_strdup( cargv[1] );
1787 savelineno = lineno;
1789 if ( read_config( savefname ) != 0 ) {
1794 lineno = savelineno - 1;
1796 /* location of kerberos srvtab file */
1797 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1800 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1801 "%s: line %d: missing filename in \"srvtab "
1802 "<filename>\" line.\n", fname, lineno ));
1804 Debug( LDAP_DEBUG_ANY,
1805 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1811 ldap_srvtab = ch_strdup( cargv[1] );
1813 #ifdef SLAPD_MODULES
1814 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1817 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1818 "%s: line %d: missing filename in \"moduleload "
1819 "<filename>\" line.\n", fname, lineno ));
1821 Debug( LDAP_DEBUG_ANY,
1822 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1826 exit( EXIT_FAILURE );
1828 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1830 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1831 "%s: line %d: failed to load or initialize module %s\n"<
1832 fname, lineno, cargv[1] ));
1834 Debug( LDAP_DEBUG_ANY,
1835 "%s: line %d: failed to load or initialize module %s\n",
1836 fname, lineno, cargv[1]);
1839 exit( EXIT_FAILURE );
1841 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1844 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1845 "%s: line %d: missing path in \"modulepath <path>\""
1846 " line\n", fname, lineno ));
1848 Debug( LDAP_DEBUG_ANY,
1849 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1853 exit( EXIT_FAILURE );
1855 if (module_path( cargv[1] )) {
1857 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1858 "%s: line %d: failed to set module search path to %s.\n",
1859 fname, lineno, cargv[1] ));
1861 Debug( LDAP_DEBUG_ANY,
1862 "%s: line %d: failed to set module search path to %s\n",
1863 fname, lineno, cargv[1]);
1866 exit( EXIT_FAILURE );
1869 #endif /*SLAPD_MODULES*/
1872 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1873 rc = ldap_pvt_tls_set_option( NULL,
1874 LDAP_OPT_X_TLS_PROTOCOL,
1879 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
1880 rc = ldap_pvt_tls_set_option( NULL,
1881 LDAP_OPT_X_TLS_RANDOM_FILE,
1886 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1887 rc = ldap_pvt_tls_set_option( NULL,
1888 LDAP_OPT_X_TLS_CIPHER_SUITE,
1893 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1894 rc = ldap_pvt_tls_set_option( NULL,
1895 LDAP_OPT_X_TLS_CERTFILE,
1900 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1901 rc = ldap_pvt_tls_set_option( NULL,
1902 LDAP_OPT_X_TLS_KEYFILE,
1907 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1908 rc = ldap_pvt_tls_set_option( NULL,
1909 LDAP_OPT_X_TLS_CACERTDIR,
1914 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1915 rc = ldap_pvt_tls_set_option( NULL,
1916 LDAP_OPT_X_TLS_CACERTFILE,
1920 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1922 rc = ldap_pvt_tls_set_option( NULL,
1923 LDAP_OPT_X_TLS_REQUIRE_CERT,
1930 /* pass anything else to the current backend info/db config routine */
1933 if ( bi->bi_config == 0 ) {
1935 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1936 "%s: line %d: unknown directive \"%s\" inside "
1937 "backend info definition (ignored).\n",
1938 fname, lineno, cargv[0] ));
1940 Debug( LDAP_DEBUG_ANY,
1941 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1942 fname, lineno, cargv[0] );
1946 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1952 } else if ( be != NULL ) {
1953 if ( be->be_config == 0 ) {
1955 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1956 "%s: line %d: uknown directive \"%s\" inside "
1957 "backend database definition (ignored).\n",
1958 fname, lineno, cargv[0] ));
1960 Debug( LDAP_DEBUG_ANY,
1961 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1962 fname, lineno, cargv[0] );
1966 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1974 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1975 "%s: line %d: unknown directive \"%s\" outside backend "
1976 "info and database definitions (ignored).\n",
1977 fname, lineno, cargv[0] ));
1979 Debug( LDAP_DEBUG_ANY,
1980 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1981 fname, lineno, cargv[0] );
1989 if ( load_ucdata( NULL ) < 0 ) {
2005 for ( token = strtok_quote( line, " \t" ); token != NULL;
2006 token = strtok_quote( NULL, " \t" ) ) {
2007 if ( *argcp == MAXARGS ) {
2009 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2010 "fp_parse_line: too many tokens (%d max).\n",
2013 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2019 argv[(*argcp)++] = token;
2021 argv[*argcp] = NULL;
2026 strtok_quote( char *line, char *sep )
2032 if ( line != NULL ) {
2035 while ( *next && strchr( sep, *next ) ) {
2039 if ( *next == '\0' ) {
2045 for ( inquote = 0; *next; ) {
2053 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2059 next + 1, strlen( next + 1 ) + 1 );
2060 next++; /* dont parse the escaped character */
2065 if ( strchr( sep, *next ) != NULL ) {
2078 static char buf[BUFSIZ];
2080 static int lmax, lcur;
2082 #define CATLINE( buf ) { \
2084 len = strlen( buf ); \
2085 while ( lcur + len + 1 > lmax ) { \
2087 line = (char *) ch_realloc( line, lmax ); \
2089 strcpy( line + lcur, buf ); \
2094 fp_getline( FILE *fp, int *lineno )
2102 /* hack attack - keeps us from having to keep a stack of bufs... */
2103 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2108 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2109 if ( (p = strchr( buf, '\n' )) != NULL ) {
2112 if ( ! isspace( (unsigned char) buf[0] ) ) {
2116 /* change leading whitespace to a space */
2124 return( line[0] ? line : NULL );
2128 fp_getline_init( int *lineno )
2134 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2136 load_ucdata( char *path )
2138 static int loaded = 0;
2144 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2147 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2148 "load_ucdata: Error %d loading ucdata.\n", err ));
2150 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",