1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
14 #include <ac/socket.h>
23 * defaults for various global variables
25 int defsize = SLAPD_DEFAULT_SIZELIMIT;
26 int deftime = SLAPD_DEFAULT_TIMELIMIT;
27 AccessControl *global_acl = NULL;
28 slap_access_t global_default_access = ACL_READ;
29 slap_mask_t global_restrictops = 0;
30 slap_mask_t global_allows = 0;
31 slap_mask_t global_disallows = 0;
32 slap_mask_t global_requires = 0;
33 slap_ssf_set_t global_ssf_set;
35 int global_lastmod = ON;
36 int global_idletimeout = 0;
37 char *global_host = NULL;
38 char *global_realm = NULL;
39 char *ldap_srvtab = "";
40 char *default_passwd_hash;
41 char *default_search_base = NULL;
42 char *default_search_nbase = NULL;
44 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
46 char *slapd_pid_file = NULL;
47 char *slapd_args_file = NULL;
50 SaslRegexp_t *SaslRegexp = NULL;
51 int sasl_external_x509dn_convert;
53 static char *fp_getline(FILE *fp, int *lineno);
54 static void fp_getline_init(int *lineno);
55 static int fp_parse_line(char *line, int *argcp, char **argv);
57 static char *strtok_quote(char *line, char *sep);
58 static int load_ucdata(char *path);
61 read_config( const char *fname )
64 char *line, *savefname, *saveline;
65 int cargc, savelineno;
66 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 /* default search base */
284 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
287 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
288 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
289 "line\n", fname, lineno ));
291 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
292 "missing dn in \"defaultSearchBase <dn>\" line\n",
298 } else if ( cargc > 2 ) {
300 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
301 "%s: line %d: extra cruft after <dn> in "
302 "\"defaultSearchBase %s\" line (ignored)\n",
303 fname, lineno, cargv[1] ));
305 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
306 "extra cruft after <dn> in \"defaultSearchBase %s\", "
308 fname, lineno, cargv[1] );
313 if ( bi != NULL || be != NULL ) {
315 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
316 "%s: line %d: defaultSearchBase line must appear "
317 "prior to any backend or database definitions\n",
320 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
321 "defaultSearchBaase line must appear prior to "
322 "any backend or database definition\n",
329 if ( default_search_nbase != NULL ) {
331 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
332 "%s: line %d: default search base \"%s\" already defined "
333 "(discarding old)\n", fname, lineno, default_search_base ));
335 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
336 "default search base \"%s\" already defined "
337 "(discarding old)\n",
338 fname, lineno, default_search_base );
341 free( default_search_base );
342 free( default_search_nbase );
345 default_search_base = ch_strdup( cargv[1] );
346 default_search_nbase = ch_strdup( cargv[1] );
348 if ( load_ucdata( NULL ) < 0 ) {
351 if( dn_normalize( default_search_nbase ) == NULL ) {
353 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
354 "%s: %d: invalid default search base \"%s\"\n",
355 fname, lineno, default_search_base ));
357 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
358 "invalid default search base \"%s\"\n",
359 fname, lineno, default_search_base );
365 /* set maximum threads in thread pool */
366 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
370 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
371 "%s: line %d: missing count in \"threads <count>\" line\n",
374 Debug( LDAP_DEBUG_ANY,
375 "%s: line %d: missing count in \"threads <count>\" line\n",
382 c = atoi( cargv[1] );
386 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
387 "%s: line %d: invalid level (%d) in \"threads <count>\""
388 "line\n",fname, lineno, c ));
390 Debug( LDAP_DEBUG_ANY,
391 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
398 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
400 /* get pid file name */
401 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
404 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
405 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
408 Debug( LDAP_DEBUG_ANY,
409 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
416 slapd_pid_file = ch_strdup( cargv[1] );
418 /* get args file name */
419 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
422 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
423 "%s: %d: missing file name in "
424 "\"argsfile <file>\" line.\n",
427 Debug( LDAP_DEBUG_ANY,
428 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
435 slapd_args_file = ch_strdup( cargv[1] );
437 /* default password hash */
438 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
441 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
442 "%s: line %d: missing hash in "
443 "\"password-hash <hash>\" line.\n",
446 Debug( LDAP_DEBUG_ANY,
447 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
453 if ( default_passwd_hash != NULL ) {
455 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
456 "%s: line %d: already set default password_hash!\n",
459 Debug( LDAP_DEBUG_ANY,
460 "%s: line %d: already set default password_hash!\n",
467 default_passwd_hash = ch_strdup( cargv[1] );
471 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
474 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
475 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
478 Debug( LDAP_DEBUG_ANY,
479 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
486 if ( global_host != NULL ) {
488 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
489 "%s: line %d: already set sasl-host!\n",
492 Debug( LDAP_DEBUG_ANY,
493 "%s: line %d: already set sasl-host!\n",
500 global_host = ch_strdup( cargv[1] );
504 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
507 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
508 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
511 Debug( LDAP_DEBUG_ANY,
512 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
519 if ( global_realm != NULL ) {
521 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
522 "%s: line %d: already set sasl-realm!\n",
525 Debug( LDAP_DEBUG_ANY,
526 "%s: line %d: already set sasl-realm!\n",
533 global_realm = ch_strdup( cargv[1] );
536 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
537 || !strcasecmp( cargv[0], "saslregexp" ) )
542 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
543 "%s: line %d: need 2 args in "
544 "\"saslregexp <match> <replace>\"\n",
547 Debug( LDAP_DEBUG_ANY,
548 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
554 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
559 /* SASL security properties */
560 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
565 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
566 "%s: line %d: missing flags in "
567 "\"sasl-secprops <properties>\" line\n",
570 Debug( LDAP_DEBUG_ANY,
571 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
578 txt = slap_sasl_secprops( cargv[1] );
581 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
582 "%s: line %d sas-secprops: %s\n",
583 fname, lineno, txt ));
585 Debug( LDAP_DEBUG_ANY,
586 "%s: line %d: sasl-secprops: %s\n",
587 fname, lineno, txt );
593 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
594 sasl_external_x509dn_convert++;
596 /* set UCDATA path */
597 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
601 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
602 "%s: line %d: missing path in "
603 "\"ucdata-path <path>\" line.\n",
606 Debug( LDAP_DEBUG_ANY,
607 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
614 err = load_ucdata( cargv[1] );
618 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
619 "%s: line %d: ucdata already loaded, ucdata-path "
620 "must be set earlier in the file and/or be "
621 "specified only once!\n",
624 Debug( LDAP_DEBUG_ANY,
625 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
634 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
637 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
638 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
641 Debug( LDAP_DEBUG_ANY,
642 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
649 defsize = atoi( cargv[1] );
651 be->be_sizelimit = atoi( cargv[1] );
655 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
658 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
659 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
662 Debug( LDAP_DEBUG_ANY,
663 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
670 deftime = atoi( cargv[1] );
672 be->be_timelimit = atoi( cargv[1] );
675 /* set database suffix */
676 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
680 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
681 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
684 Debug( LDAP_DEBUG_ANY,
685 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
690 } else if ( cargc > 2 ) {
692 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
693 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
694 " line (ignored).\n", fname, lineno, cargv[1] ));
696 Debug( LDAP_DEBUG_ANY,
697 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
698 fname, lineno, cargv[1] );
704 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
705 "%s: line %d: suffix line must appear inside a database "
706 "definition (ignored).\n", fname, lineno ));
708 Debug( LDAP_DEBUG_ANY,
709 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
713 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
715 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
716 "%s: line %d: suffix already served by this backend "
717 "(ignored)\n", fname, lineno ));
719 Debug( LDAP_DEBUG_ANY,
720 "%s: line %d: suffix already served by this backend (ignored)\n",
724 } else if ( tmp_be != NULL ) {
726 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
727 "%s: line %d: suffix already served by a preceding "
728 "backend \"%s\" (ignored)\n", fname, lineno,
729 tmp_be->be_suffix[0] ));
731 Debug( LDAP_DEBUG_ANY,
732 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
733 fname, lineno, tmp_be->be_suffix[0] );
737 char *dn = ch_strdup( cargv[1] );
738 if ( load_ucdata( NULL ) < 0 ) {
741 if( dn_validate( dn ) == NULL ) {
743 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
744 "%s: line %d: suffix DN invalid\"%s\"\n",
745 fname, lineno, cargv[1] ));
747 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
748 "suffix DN invalid \"%s\"\n",
749 fname, lineno, cargv[1] );
754 } else if( *dn == '\0' && default_search_nbase != NULL ) {
756 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
757 "%s: line %d: suffix DN empty and default search "
758 "base provided \"%s\" (assuming okay).\n",
759 fname, lineno, default_search_base ));
761 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
762 "suffix DN empty and default "
763 "search base provided \"%s\" (assuming okay)\n",
764 fname, lineno, default_search_base );
768 charray_add( &be->be_suffix, dn );
769 (void) ldap_pvt_str2upper( dn );
770 charray_add( &be->be_nsuffix, dn );
774 /* set database suffixAlias */
775 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
779 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
780 "%s: line %d: missing alias and aliased_dn in "
781 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
784 Debug( LDAP_DEBUG_ANY,
785 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
790 } else if ( cargc < 3 ) {
792 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
793 "%s: line %d: missing aliased_dn in "
794 "\"suffixAlias <alias> <aliased_dn>\" line\n",
797 Debug( LDAP_DEBUG_ANY,
798 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
803 } else if ( cargc > 3 ) {
805 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
806 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
809 Debug( LDAP_DEBUG_ANY,
810 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
818 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
819 "%s: line %d: suffixAlias line must appear inside a "
820 "database definition (ignored).\n", fname, lineno ));
822 Debug( LDAP_DEBUG_ANY,
823 "%s: line %d: suffixAlias line"
824 " must appear inside a database definition (ignored)\n",
828 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
830 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
831 "%s: line %d: suffixAlias served by a preceeding "
832 "backend \"%s\" (ignored).\n", fname, lineno,
833 tmp_be->be_suffix[0] ));
835 Debug( LDAP_DEBUG_ANY,
836 "%s: line %d: suffixAlias served by"
837 " a preceeding backend \"%s\" (ignored)\n",
838 fname, lineno, tmp_be->be_suffix[0] );
842 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
844 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
845 "%s: line %d: suffixAlias derefs to a different backend "
846 "a preceeding backend \"%s\" (ignored)\n",
847 fname, lineno, tmp_be->be_suffix[0] ));
849 Debug( LDAP_DEBUG_ANY,
850 "%s: line %d: suffixAlias derefs to differnet backend"
851 " a preceeding backend \"%s\" (ignored)\n",
852 fname, lineno, tmp_be->be_suffix[0] );
857 char *alias, *aliased_dn;
859 alias = ch_strdup( cargv[1] );
860 if ( load_ucdata( NULL ) < 0 ) {
863 (void) dn_normalize( alias );
865 aliased_dn = ch_strdup( cargv[2] );
866 (void) dn_normalize( aliased_dn );
868 charray_add( &be->be_suffixAlias, alias );
869 charray_add( &be->be_suffixAlias, aliased_dn );
875 /* set max deref depth */
876 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
880 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
881 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
882 " line\n", fname, lineno ));
884 Debug( LDAP_DEBUG_ANY,
885 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
893 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
894 "%s: line %d: depth line must appear inside a database "
895 "definition (ignored)\n", fname, lineno ));
897 Debug( LDAP_DEBUG_ANY,
898 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
902 } else if ((i = atoi(cargv[1])) < 0) {
904 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
905 "%s: line %d: depth must be positive (ignored).\n",
908 Debug( LDAP_DEBUG_ANY,
909 "%s: line %d: depth must be positive (ignored)\n",
915 be->be_max_deref_depth = i;
919 /* set magic "root" dn for this database */
920 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
923 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
924 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
927 Debug( LDAP_DEBUG_ANY,
928 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
936 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
937 "%s: line %d: rootdn line must appear inside a database "
938 "definition (ignored).\n", fname, lineno ));
940 Debug( LDAP_DEBUG_ANY,
941 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
946 be->be_root_dn = ch_strdup( cargv[1] );
947 be->be_root_ndn = ch_strdup( cargv[1] );
949 if ( load_ucdata( NULL ) < 0 ) {
952 if( dn_normalize( be->be_root_ndn ) == NULL ) {
953 free( be->be_root_dn );
954 free( be->be_root_ndn );
956 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
957 "%s: line %d: rootdn DN is invalid.\n",
960 Debug( LDAP_DEBUG_ANY,
961 "%s: line %d: rootdn DN is invalid\n",
969 /* set super-secret magic database password */
970 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
973 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
974 "%s: line %d: missing passwd in \"rootpw <passwd>\""
975 " line\n", fname, lineno ));
977 Debug( LDAP_DEBUG_ANY,
978 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
986 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
987 "%s: line %d: rootpw line must appear inside a database "
988 "definition (ignored)\n", fname, lineno ));
990 Debug( LDAP_DEBUG_ANY,
991 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
996 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
997 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1000 /* make this database read-only */
1001 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1004 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1005 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1008 Debug( LDAP_DEBUG_ANY,
1009 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1016 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1017 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1019 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1022 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1023 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1025 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1030 /* allow these features */
1031 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1032 strcasecmp( cargv[0], "allow" ) == 0 )
1038 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1039 "%s: line %d: allow line must appear prior to "
1040 "database definitions.\n", fname, lineno ));
1042 Debug( LDAP_DEBUG_ANY,
1043 "%s: line %d: allow line must appear prior to database definitions\n",
1051 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1052 "%s: line %d: missing feature(s) in \"allow <features>\""
1053 " line\n", fname, lineno ));
1055 Debug( LDAP_DEBUG_ANY,
1056 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1065 for( i=1; i < cargc; i++ ) {
1066 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1067 allows |= SLAP_ALLOW_TLS_2_ANON;
1069 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1071 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1072 "%s: line %d: unknown feature %s in "
1073 "\"allow <features>\" line.\n",
1074 fname, lineno, cargv[1] ));
1076 Debug( LDAP_DEBUG_ANY,
1077 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1078 fname, lineno, cargv[i] );
1085 global_allows = allows;
1087 /* disallow these features */
1088 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1089 strcasecmp( cargv[0], "disallow" ) == 0 )
1091 slap_mask_t disallows;
1095 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1096 "%s: line %d: disallow line must appear prior to "
1097 "database definitions.\n", fname, lineno ));
1099 Debug( LDAP_DEBUG_ANY,
1100 "%s: line %d: disallow line must appear prior to database definitions\n",
1108 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1109 "%s: line %d: missing feature(s) in \"disallow <features>\""
1110 " line.\n", fname, lineno ));
1112 Debug( LDAP_DEBUG_ANY,
1113 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1122 for( i=1; i < cargc; i++ ) {
1123 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1124 disallows |= SLAP_DISALLOW_BIND_V2;
1126 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1127 disallows |= SLAP_DISALLOW_BIND_ANON;
1129 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1130 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1132 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1133 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1135 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1136 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1138 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1139 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1141 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1142 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1144 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1146 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1147 "%s: line %d: unknownfeature %s in "
1148 "\"disallow <features>\" line.\n",
1151 Debug( LDAP_DEBUG_ANY,
1152 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1153 fname, lineno, cargv[i] );
1160 global_disallows = disallows;
1162 /* require these features */
1163 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1164 strcasecmp( cargv[0], "require" ) == 0 )
1166 slap_mask_t requires;
1170 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1171 "%s: line %d: missing feature(s) in "
1172 "\"require <features>\" line.\n", fname, lineno ));
1174 Debug( LDAP_DEBUG_ANY,
1175 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1184 for( i=1; i < cargc; i++ ) {
1185 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1186 requires |= SLAP_REQUIRE_BIND;
1188 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1189 requires |= SLAP_REQUIRE_LDAP_V3;
1191 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1192 requires |= SLAP_REQUIRE_AUTHC;
1194 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1195 requires |= SLAP_REQUIRE_SASL;
1197 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1198 requires |= SLAP_REQUIRE_STRONG;
1200 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1202 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1203 "%s: line %d: unknown feature %s in "
1204 "\"require <features>\" line.\n",
1207 Debug( LDAP_DEBUG_ANY,
1208 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1209 fname, lineno, cargv[i] );
1217 global_requires = requires;
1219 be->be_requires = requires;
1222 /* required security factors */
1223 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1224 slap_ssf_set_t *set;
1228 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1229 "%s: line %d: missing factor(s) in \"security <factors>\""
1230 " line.\n", fname, lineno ));
1232 Debug( LDAP_DEBUG_ANY,
1233 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1241 set = &global_ssf_set;
1243 set = &be->be_ssf_set;
1246 for( i=1; i < cargc; i++ ) {
1247 if( strncasecmp( cargv[i], "ssf=",
1248 sizeof("ssf") ) == 0 )
1251 atoi( &cargv[i][sizeof("ssf")] );
1253 } else if( strncasecmp( cargv[i], "transport=",
1254 sizeof("transport") ) == 0 )
1256 set->sss_transport =
1257 atoi( &cargv[i][sizeof("transport")] );
1259 } else if( strncasecmp( cargv[i], "tls=",
1260 sizeof("tls") ) == 0 )
1263 atoi( &cargv[i][sizeof("tls")] );
1265 } else if( strncasecmp( cargv[i], "sasl=",
1266 sizeof("sasl") ) == 0 )
1269 atoi( &cargv[i][sizeof("sasl")] );
1271 } else if( strncasecmp( cargv[i], "update_ssf=",
1272 sizeof("update_ssf") ) == 0 )
1274 set->sss_update_ssf =
1275 atoi( &cargv[i][sizeof("update_ssf")] );
1277 } else if( strncasecmp( cargv[i], "update_transport=",
1278 sizeof("update_transport") ) == 0 )
1280 set->sss_update_transport =
1281 atoi( &cargv[i][sizeof("update_transport")] );
1283 } else if( strncasecmp( cargv[i], "update_tls=",
1284 sizeof("update_tls") ) == 0 )
1286 set->sss_update_tls =
1287 atoi( &cargv[i][sizeof("update_tls")] );
1289 } else if( strncasecmp( cargv[i], "update_sasl=",
1290 sizeof("update_sasl") ) == 0 )
1292 set->sss_update_sasl =
1293 atoi( &cargv[i][sizeof("update_sasl")] );
1297 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1298 "%s: line %d: unknown factor %S in "
1299 "\"security <factors>\" line.\n",
1300 fname, lineno, cargv[1] ));
1302 Debug( LDAP_DEBUG_ANY,
1303 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1304 fname, lineno, cargv[i] );
1310 /* where to send clients when we don't hold it */
1311 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1314 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1315 "%s: line %d: missing URL in \"referral <URL>\""
1316 " line.\n", fname, lineno ));
1318 Debug( LDAP_DEBUG_ANY,
1319 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1326 vals[0]->bv_val = cargv[1];
1327 vals[0]->bv_len = strlen( vals[0]->bv_val );
1328 value_add( &default_referral, vals );
1331 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1335 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1336 "%s: line %d: Error in logfile directive, "
1337 "\"logfile <filename>\"\n", fname, lineno ));
1339 Debug( LDAP_DEBUG_ANY,
1340 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1346 logfile = fopen( cargv[1], "w" );
1347 if ( logfile != NULL ) lutil_debug_file( logfile );
1350 /* start of a new database definition */
1351 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1355 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1356 "%s: line %d: Error in debug directive, "
1357 "\"debug <subsys> <level>\"\n", fname, lineno ));
1359 Debug( LDAP_DEBUG_ANY,
1360 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1366 level = atoi( cargv[2] );
1367 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1368 lutil_set_debug_level( cargv[1], level );
1369 /* specify an Object Identifier macro */
1370 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1371 rc = parse_oidm( fname, lineno, cargc, cargv );
1374 /* specify an objectclass */
1375 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1376 if ( *cargv[1] == '(' ) {
1378 p = strchr(saveline,'(');
1379 rc = parse_oc( fname, lineno, p, cargv );
1384 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1385 "%s: line %d: old objectclass format not supported\n",
1388 Debug( LDAP_DEBUG_ANY,
1389 "%s: line %d: old objectclass format not supported.\n",
1395 /* specify an attribute type */
1396 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1397 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1399 if ( *cargv[1] == '(' ) {
1401 p = strchr(saveline,'(');
1402 rc = parse_at( fname, lineno, p, cargv );
1407 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1408 "%s: line %d: old attribute type format not supported.\n",
1411 Debug( LDAP_DEBUG_ANY,
1412 "%s: line %d: old attribute type format not supported.\n",
1418 /* turn on/off schema checking */
1419 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1422 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1423 "%s: line %d: missing on|off in "
1424 "\"schemacheck <on|off>\" line.\n",
1427 Debug( LDAP_DEBUG_ANY,
1428 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1434 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1435 global_schemacheck = 0;
1437 global_schemacheck = 1;
1440 /* specify access control info */
1441 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1442 parse_acl( be, fname, lineno, cargc, cargv );
1444 /* debug level to log things to syslog */
1445 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1448 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1449 "%s: line %d: missing level in \"loglevel <level>\""
1450 " line.\n", fname, lineno ));
1452 Debug( LDAP_DEBUG_ANY,
1453 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1462 for( i=1; i < cargc; i++ ) {
1463 ldap_syslog += atoi( cargv[1] );
1466 /* list of replicas of the data in this backend (master only) */
1467 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1470 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1471 "%s: line %d: missing host in \"replica "
1472 " <host[:port]\" line\n", fname, lineno ));
1474 Debug( LDAP_DEBUG_ANY,
1475 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1483 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1484 "%s: line %d: replica line must appear inside "
1485 "a database definition (ignored).\n", fname, lineno ));
1487 Debug( LDAP_DEBUG_ANY,
1488 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1493 for ( i = 1; i < cargc; i++ ) {
1494 if ( strncasecmp( cargv[i], "host=", 5 )
1496 charray_add( &be->be_replica,
1503 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1504 "%s: line %d: missing host in \"replica\" "
1505 "line (ignored)\n", fname, lineno ));
1507 Debug( LDAP_DEBUG_ANY,
1508 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1515 /* dn of master entity allowed to write to replica */
1516 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1519 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1520 "%s: line %d: missing dn in \"updatedn <dn>\""
1521 " line.\n", fname, lineno ));
1523 Debug( LDAP_DEBUG_ANY,
1524 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1532 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1533 "%s: line %d: updatedn line must appear inside "
1534 "a database definition (ignored)\n",
1537 Debug( LDAP_DEBUG_ANY,
1538 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1543 be->be_update_ndn = ch_strdup( cargv[1] );
1544 if ( load_ucdata( NULL ) < 0 ) {
1547 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1549 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1550 "%s: line %d: updatedn DN is invalid.\n",
1553 Debug( LDAP_DEBUG_ANY,
1554 "%s: line %d: updatedn DN is invalid\n",
1562 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1565 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1566 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1567 "line.\n", fname, lineno ));
1569 Debug( LDAP_DEBUG_ANY,
1570 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1578 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1579 "%s: line %d: updateref line must appear inside "
1580 "a database definition (ignored)\n", fname, lineno ));
1582 Debug( LDAP_DEBUG_ANY,
1583 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1587 } else if ( be->be_update_ndn == NULL ) {
1589 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1590 "%s: line %d: updateref line must come after updatedn "
1591 "(ignored).\n", fname, lineno ));
1593 Debug( LDAP_DEBUG_ANY,
1594 "%s: line %d: updateref line must after updatedn (ignored)\n",
1599 vals[0]->bv_val = cargv[1];
1600 vals[0]->bv_len = strlen( vals[0]->bv_val );
1601 value_add( &be->be_update_refs, vals );
1604 /* replication log file to which changes are appended */
1605 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1608 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1609 "%s: line %d: missing filename in \"replogfile <filename>\""
1610 " line.\n", fname, lineno ));
1612 Debug( LDAP_DEBUG_ANY,
1613 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1620 be->be_replogfile = ch_strdup( cargv[1] );
1622 replogfile = ch_strdup( cargv[1] );
1625 /* maintain lastmodified{by,time} attributes */
1626 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1629 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1630 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1631 " line.\n", fname, lineno ));
1633 Debug( LDAP_DEBUG_ANY,
1634 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1640 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1642 be->be_lastmod = ON;
1644 global_lastmod = ON;
1647 be->be_lastmod = OFF;
1649 global_lastmod = OFF;
1652 /* set idle timeout value */
1653 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1657 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1658 "%s: line %d: missing timeout value in "
1659 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1661 Debug( LDAP_DEBUG_ANY,
1662 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1669 i = atoi( cargv[1] );
1673 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1674 "%s: line %d: timeout value (%d) invalid "
1675 "\"idletimeout <seconds>\" line.\n",
1676 fname, lineno, i ));
1678 Debug( LDAP_DEBUG_ANY,
1679 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1686 global_idletimeout = i;
1688 /* include another config file */
1689 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1692 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1693 "%s: line %d: missing filename in \"include "
1694 "<filename>\" line.\n", fname, lineno ));
1696 Debug( LDAP_DEBUG_ANY,
1697 "%s: line %d: missing filename in \"include <filename>\" line\n",
1703 savefname = ch_strdup( cargv[1] );
1704 savelineno = lineno;
1706 if ( read_config( savefname ) != 0 ) {
1711 lineno = savelineno - 1;
1713 /* location of kerberos srvtab file */
1714 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1717 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1718 "%s: line %d: missing filename in \"srvtab "
1719 "<filename>\" line.\n", fname, lineno ));
1721 Debug( LDAP_DEBUG_ANY,
1722 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1728 ldap_srvtab = ch_strdup( cargv[1] );
1730 #ifdef SLAPD_MODULES
1731 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1734 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1735 "%s: line %d: missing filename in \"moduleload "
1736 "<filename>\" line.\n", fname, lineno ));
1738 Debug( LDAP_DEBUG_ANY,
1739 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1743 exit( EXIT_FAILURE );
1745 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1747 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1748 "%s: line %d: failed to load or initialize module %s\n"<
1749 fname, lineno, cargv[1] ));
1751 Debug( LDAP_DEBUG_ANY,
1752 "%s: line %d: failed to load or initialize module %s\n",
1753 fname, lineno, cargv[1]);
1756 exit( EXIT_FAILURE );
1758 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1761 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1762 "%s: line %d: missing path in \"modulepath <path>\""
1763 " line\n", fname, lineno ));
1765 Debug( LDAP_DEBUG_ANY,
1766 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1770 exit( EXIT_FAILURE );
1772 if (module_path( cargv[1] )) {
1774 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1775 "%s: line %d: failed to set module search path to %s.\n",
1776 fname, lineno, cargv[1] ));
1778 Debug( LDAP_DEBUG_ANY,
1779 "%s: line %d: failed to set module search path to %s\n",
1780 fname, lineno, cargv[1]);
1783 exit( EXIT_FAILURE );
1786 #endif /*SLAPD_MODULES*/
1789 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1790 rc = ldap_pvt_tls_set_option( NULL,
1791 LDAP_OPT_X_TLS_PROTOCOL,
1796 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
1797 rc = ldap_pvt_tls_set_option( NULL,
1798 LDAP_OPT_X_TLS_RANDOM_FILE,
1803 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1804 rc = ldap_pvt_tls_set_option( NULL,
1805 LDAP_OPT_X_TLS_CIPHER_SUITE,
1810 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1811 rc = ldap_pvt_tls_set_option( NULL,
1812 LDAP_OPT_X_TLS_CERTFILE,
1817 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1818 rc = ldap_pvt_tls_set_option( NULL,
1819 LDAP_OPT_X_TLS_KEYFILE,
1824 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1825 rc = ldap_pvt_tls_set_option( NULL,
1826 LDAP_OPT_X_TLS_CACERTDIR,
1831 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1832 rc = ldap_pvt_tls_set_option( NULL,
1833 LDAP_OPT_X_TLS_CACERTFILE,
1837 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1839 rc = ldap_pvt_tls_set_option( NULL,
1840 LDAP_OPT_X_TLS_REQUIRE_CERT,
1847 /* pass anything else to the current backend info/db config routine */
1850 if ( bi->bi_config == 0 ) {
1852 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1853 "%s: line %d: unknown directive \"%s\" inside "
1854 "backend info definition (ignored).\n",
1855 fname, lineno, cargv[0] ));
1857 Debug( LDAP_DEBUG_ANY,
1858 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1859 fname, lineno, cargv[0] );
1863 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1869 } else if ( be != NULL ) {
1870 if ( be->be_config == 0 ) {
1872 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1873 "%s: line %d: uknown directive \"%s\" inside "
1874 "backend database definition (ignored).\n",
1875 fname, lineno, cargv[0] ));
1877 Debug( LDAP_DEBUG_ANY,
1878 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1879 fname, lineno, cargv[0] );
1883 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1891 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1892 "%s: line %d: unknown directive \"%s\" outside backend "
1893 "info and database definitions (ignored).\n",
1894 fname, lineno, cargv[0] ));
1896 Debug( LDAP_DEBUG_ANY,
1897 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1898 fname, lineno, cargv[0] );
1906 if ( load_ucdata( NULL ) < 0 ) {
1922 for ( token = strtok_quote( line, " \t" ); token != NULL;
1923 token = strtok_quote( NULL, " \t" ) ) {
1924 if ( *argcp == MAXARGS ) {
1926 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1927 "fp_parse_line: too many tokens (%d max).\n",
1930 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1936 argv[(*argcp)++] = token;
1938 argv[*argcp] = NULL;
1943 strtok_quote( char *line, char *sep )
1949 if ( line != NULL ) {
1952 while ( *next && strchr( sep, *next ) ) {
1956 if ( *next == '\0' ) {
1962 for ( inquote = 0; *next; ) {
1970 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1976 next + 1, strlen( next + 1 ) + 1 );
1977 next++; /* dont parse the escaped character */
1982 if ( strchr( sep, *next ) != NULL ) {
1995 static char buf[BUFSIZ];
1997 static int lmax, lcur;
1999 #define CATLINE( buf ) { \
2001 len = strlen( buf ); \
2002 while ( lcur + len + 1 > lmax ) { \
2004 line = (char *) ch_realloc( line, lmax ); \
2006 strcpy( line + lcur, buf ); \
2011 fp_getline( FILE *fp, int *lineno )
2019 /* hack attack - keeps us from having to keep a stack of bufs... */
2020 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2025 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2026 if ( (p = strchr( buf, '\n' )) != NULL ) {
2029 if ( ! isspace( (unsigned char) buf[0] ) ) {
2033 /* change leading whitespace to a space */
2041 return( line[0] ? line : NULL );
2045 fp_getline_init( int *lineno )
2051 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2053 load_ucdata( char *path )
2055 static int loaded = 0;
2061 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2064 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2065 "load_ucdata: Error %d loading ucdata.\n", err ));
2067 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",