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 parse_oidm( fname, lineno, cargc, cargv );
1373 /* specify an objectclass */
1374 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1375 if ( *cargv[1] == '(' ) {
1377 p = strchr(saveline,'(');
1378 parse_oc( fname, lineno, p, cargv );
1381 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1382 "%s: line %d: old objectclass format not supported\n",
1385 Debug( LDAP_DEBUG_ANY,
1386 "%s: line %d: old objectclass format not supported.\n",
1392 /* specify an attribute type */
1393 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1394 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1396 if ( *cargv[1] == '(' ) {
1398 p = strchr(saveline,'(');
1399 parse_at( fname, lineno, p, cargv );
1402 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1403 "%s: line %d: old attribute type format not supported.\n",
1406 Debug( LDAP_DEBUG_ANY,
1407 "%s: line %d: old attribute type format not supported.\n",
1413 /* turn on/off schema checking */
1414 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1417 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1418 "%s: line %d: missing on|off in "
1419 "\"schemacheck <on|off>\" line.\n",
1422 Debug( LDAP_DEBUG_ANY,
1423 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1429 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1430 global_schemacheck = 0;
1432 global_schemacheck = 1;
1435 /* specify access control info */
1436 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1437 parse_acl( be, fname, lineno, cargc, cargv );
1439 /* debug level to log things to syslog */
1440 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1443 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1444 "%s: line %d: missing level in \"loglevel <level>\""
1445 " line.\n", fname, lineno ));
1447 Debug( LDAP_DEBUG_ANY,
1448 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1457 for( i=1; i < cargc; i++ ) {
1458 ldap_syslog += atoi( cargv[1] );
1461 /* list of replicas of the data in this backend (master only) */
1462 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1465 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1466 "%s: line %d: missing host in \"replica "
1467 " <host[:port]\" line\n", fname, lineno ));
1469 Debug( LDAP_DEBUG_ANY,
1470 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1478 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1479 "%s: line %d: replica line must appear inside "
1480 "a database definition (ignored).\n", fname, lineno ));
1482 Debug( LDAP_DEBUG_ANY,
1483 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1488 for ( i = 1; i < cargc; i++ ) {
1489 if ( strncasecmp( cargv[i], "host=", 5 )
1491 charray_add( &be->be_replica,
1498 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1499 "%s: line %d: missing host in \"replica\" "
1500 "line (ignored)\n", fname, lineno ));
1502 Debug( LDAP_DEBUG_ANY,
1503 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1510 /* dn of master entity allowed to write to replica */
1511 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1514 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1515 "%s: line %d: missing dn in \"updatedn <dn>\""
1516 " line.\n", fname, lineno ));
1518 Debug( LDAP_DEBUG_ANY,
1519 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1527 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1528 "%s: line %d: updatedn line must appear inside "
1529 "a database definition (ignored)\n",
1532 Debug( LDAP_DEBUG_ANY,
1533 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1538 be->be_update_ndn = ch_strdup( cargv[1] );
1539 if ( load_ucdata( NULL ) < 0 ) {
1542 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1544 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1545 "%s: line %d: updatedn DN is invalid.\n",
1548 Debug( LDAP_DEBUG_ANY,
1549 "%s: line %d: updatedn DN is invalid\n",
1557 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1560 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1561 "%s: line %d: missing dn in \"updateref <ldapurl>\" "
1562 "line.\n", fname, lineno ));
1564 Debug( LDAP_DEBUG_ANY,
1565 "%s: line %d: missing dn in \"updateref <ldapurl>\" line\n",
1573 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1574 "%s: line %d: updateref line must appear inside "
1575 "a database definition (ignored)\n", fname, lineno ));
1577 Debug( LDAP_DEBUG_ANY,
1578 "%s: line %d: updateref line must appear inside a database definition (ignored)\n",
1582 } else if ( be->be_update_ndn == NULL ) {
1584 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1585 "%s: line %d: updateref line must come after updatedn "
1586 "(ignored).\n", fname, lineno ));
1588 Debug( LDAP_DEBUG_ANY,
1589 "%s: line %d: updateref line must after updatedn (ignored)\n",
1594 vals[0]->bv_val = cargv[1];
1595 vals[0]->bv_len = strlen( vals[0]->bv_val );
1596 value_add( &be->be_update_refs, vals );
1599 /* replication log file to which changes are appended */
1600 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1603 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1604 "%s: line %d: missing filename in \"replogfile <filename>\""
1605 " line.\n", fname, lineno ));
1607 Debug( LDAP_DEBUG_ANY,
1608 "%s: line %d: missing dn in \"replogfile <filename>\" line\n",
1615 be->be_replogfile = ch_strdup( cargv[1] );
1617 replogfile = ch_strdup( cargv[1] );
1620 /* maintain lastmodified{by,time} attributes */
1621 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1624 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1625 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1626 " line.\n", fname, lineno ));
1628 Debug( LDAP_DEBUG_ANY,
1629 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1635 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1637 be->be_lastmod = ON;
1639 global_lastmod = ON;
1642 be->be_lastmod = OFF;
1644 global_lastmod = OFF;
1647 /* set idle timeout value */
1648 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1652 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1653 "%s: line %d: missing timeout value in "
1654 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1656 Debug( LDAP_DEBUG_ANY,
1657 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1664 i = atoi( cargv[1] );
1668 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1669 "%s: line %d: timeout value (%d) invalid "
1670 "\"idletimeout <seconds>\" line.\n",
1671 fname, lineno, i ));
1673 Debug( LDAP_DEBUG_ANY,
1674 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1681 global_idletimeout = i;
1683 /* include another config file */
1684 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1687 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1688 "%s: line %d: missing filename in \"include "
1689 "<filename>\" line.\n", fname, lineno ));
1691 Debug( LDAP_DEBUG_ANY,
1692 "%s: line %d: missing filename in \"include <filename>\" line\n",
1698 savefname = ch_strdup( cargv[1] );
1699 savelineno = lineno;
1701 if ( read_config( savefname ) != 0 ) {
1706 lineno = savelineno - 1;
1708 /* location of kerberos srvtab file */
1709 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1712 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1713 "%s: line %d: missing filename in \"srvtab "
1714 "<filename>\" line.\n", fname, lineno ));
1716 Debug( LDAP_DEBUG_ANY,
1717 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1723 ldap_srvtab = ch_strdup( cargv[1] );
1725 #ifdef SLAPD_MODULES
1726 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1729 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1730 "%s: line %d: missing filename in \"moduleload "
1731 "<filename>\" line.\n", fname, lineno ));
1733 Debug( LDAP_DEBUG_ANY,
1734 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1738 exit( EXIT_FAILURE );
1740 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1742 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1743 "%s: line %d: failed to load or initialize module %s\n"<
1744 fname, lineno, cargv[1] ));
1746 Debug( LDAP_DEBUG_ANY,
1747 "%s: line %d: failed to load or initialize module %s\n",
1748 fname, lineno, cargv[1]);
1751 exit( EXIT_FAILURE );
1753 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1756 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1757 "%s: line %d: missing path in \"modulepath <path>\""
1758 " line\n", fname, lineno ));
1760 Debug( LDAP_DEBUG_ANY,
1761 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1765 exit( EXIT_FAILURE );
1767 if (module_path( cargv[1] )) {
1769 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
1770 "%s: line %d: failed to set module search path to %s.\n",
1771 fname, lineno, cargv[1] ));
1773 Debug( LDAP_DEBUG_ANY,
1774 "%s: line %d: failed to set module search path to %s\n",
1775 fname, lineno, cargv[1]);
1778 exit( EXIT_FAILURE );
1781 #endif /*SLAPD_MODULES*/
1784 } else if ( !strcasecmp( cargv[0], "TLSProtocol" ) ) {
1785 rc = ldap_pvt_tls_set_option( NULL,
1786 LDAP_OPT_X_TLS_PROTOCOL,
1791 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
1792 rc = ldap_pvt_tls_set_option( NULL,
1793 LDAP_OPT_X_TLS_RANDOM_FILE,
1798 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1799 rc = ldap_pvt_tls_set_option( NULL,
1800 LDAP_OPT_X_TLS_CIPHER_SUITE,
1805 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1806 rc = ldap_pvt_tls_set_option( NULL,
1807 LDAP_OPT_X_TLS_CERTFILE,
1812 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1813 rc = ldap_pvt_tls_set_option( NULL,
1814 LDAP_OPT_X_TLS_KEYFILE,
1819 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1820 rc = ldap_pvt_tls_set_option( NULL,
1821 LDAP_OPT_X_TLS_CACERTDIR,
1826 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1827 rc = ldap_pvt_tls_set_option( NULL,
1828 LDAP_OPT_X_TLS_CACERTFILE,
1832 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1834 rc = ldap_pvt_tls_set_option( NULL,
1835 LDAP_OPT_X_TLS_REQUIRE_CERT,
1842 /* pass anything else to the current backend info/db config routine */
1845 if ( bi->bi_config == 0 ) {
1847 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1848 "%s: line %d: unknown directive \"%s\" inside "
1849 "backend info definition (ignored).\n",
1850 fname, lineno, cargv[0] ));
1852 Debug( LDAP_DEBUG_ANY,
1853 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1854 fname, lineno, cargv[0] );
1858 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
1864 } else if ( be != NULL ) {
1865 if ( be->be_config == 0 ) {
1867 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1868 "%s: line %d: uknown directive \"%s\" inside "
1869 "backend database definition (ignored).\n",
1870 fname, lineno, cargv[0] ));
1872 Debug( LDAP_DEBUG_ANY,
1873 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1874 fname, lineno, cargv[0] );
1878 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
1886 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1887 "%s: line %d: unknown directive \"%s\" outside backend "
1888 "info and database definitions (ignored).\n",
1889 fname, lineno, cargv[0] ));
1891 Debug( LDAP_DEBUG_ANY,
1892 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
1893 fname, lineno, cargv[0] );
1901 if ( load_ucdata( NULL ) < 0 ) {
1917 for ( token = strtok_quote( line, " \t" ); token != NULL;
1918 token = strtok_quote( NULL, " \t" ) ) {
1919 if ( *argcp == MAXARGS ) {
1921 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1922 "fp_parse_line: too many tokens (%d max).\n",
1925 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
1931 argv[(*argcp)++] = token;
1933 argv[*argcp] = NULL;
1938 strtok_quote( char *line, char *sep )
1944 if ( line != NULL ) {
1947 while ( *next && strchr( sep, *next ) ) {
1951 if ( *next == '\0' ) {
1957 for ( inquote = 0; *next; ) {
1965 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1971 next + 1, strlen( next + 1 ) + 1 );
1972 next++; /* dont parse the escaped character */
1977 if ( strchr( sep, *next ) != NULL ) {
1990 static char buf[BUFSIZ];
1992 static int lmax, lcur;
1994 #define CATLINE( buf ) { \
1996 len = strlen( buf ); \
1997 while ( lcur + len + 1 > lmax ) { \
1999 line = (char *) ch_realloc( line, lmax ); \
2001 strcpy( line + lcur, buf ); \
2006 fp_getline( FILE *fp, int *lineno )
2014 /* hack attack - keeps us from having to keep a stack of bufs... */
2015 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2020 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2021 if ( (p = strchr( buf, '\n' )) != NULL ) {
2024 if ( ! isspace( (unsigned char) buf[0] ) ) {
2033 return( line[0] ? line : NULL );
2037 fp_getline_init( int *lineno )
2043 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2045 load_ucdata( char *path )
2047 static int loaded = 0;
2053 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2056 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2057 "load_ucdata: Error %d loading ucdata.\n", err ));
2059 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",