1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
14 #include <ac/socket.h>
24 * defaults for various global variables
26 struct slap_limits_set deflimit = {
27 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
30 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
32 -1 /* no limit on unchecked size */
35 AccessControl *global_acl = NULL;
36 slap_access_t global_default_access = ACL_READ;
37 slap_mask_t global_restrictops = 0;
38 slap_mask_t global_allows = 0;
39 slap_mask_t global_disallows = 0;
40 slap_mask_t global_requires = 0;
41 slap_ssf_set_t global_ssf_set;
43 int global_idletimeout = 0;
44 char *global_host = NULL;
45 char *global_realm = NULL;
46 char *ldap_srvtab = "";
47 char *default_passwd_hash = NULL;
48 struct berval default_search_base = { 0, NULL };
49 struct berval default_search_nbase = { 0, NULL };
50 unsigned num_subordinates = 0;
52 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
53 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
55 char *slapd_pid_file = NULL;
56 char *slapd_args_file = NULL;
59 SaslRegexp_t *SaslRegexp = NULL;
60 int sasl_external_x509dn_convert;
63 int use_reverse_lookup = 1;
64 #else /* !SLAPD_RLOOKUPS */
65 int use_reverse_lookup = 0;
66 #endif /* !SLAPD_RLOOKUPS */
68 static char *fp_getline(FILE *fp, int *lineno);
69 static void fp_getline_init(int *lineno);
70 static int fp_parse_line(int lineno, char *line, int *argcp, char **argv);
72 static char *strtok_quote(char *line, char *sep);
73 static int load_ucdata(char *path);
76 read_config( const char *fname )
79 char *line, *savefname, *saveline;
80 int cargc, savelineno;
81 char *cargv[MAXARGS+1];
84 struct berval vals[2];
86 static int lastmod = 1;
87 static BackendInfo *bi = NULL;
88 static BackendDB *be = NULL;
90 vals[1].bv_val = NULL;
92 if ( (fp = fopen( fname, "r" )) == NULL ) {
95 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
96 "could not open config file \"%s\": %s (%d)\n",
97 fname, strerror(errno), errno ));
99 Debug( LDAP_DEBUG_ANY,
100 "could not open config file \"%s\": %s (%d)\n",
101 fname, strerror(errno), errno );
107 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
108 "read_config: reading config file %s\n", fname ));
110 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
114 fp_getline_init( &lineno );
116 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
117 /* skip comments and blank lines */
118 if ( line[0] == '#' || line[0] == '\0' ) {
122 /* fp_parse_line is destructive, we save a copy */
123 saveline = ch_strdup( line );
125 if ( fp_parse_line( lineno, line, &cargc, cargv ) != 0 ) {
131 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
132 "%s: line %d: bad config line (ignored)\n",
135 Debug( LDAP_DEBUG_ANY,
136 "%s: line %d: bad config line (ignored)\n",
143 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
146 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
147 "%s : line %d: missing type in \"backend\" line.\n",
150 Debug( LDAP_DEBUG_ANY,
151 "%s: line %d: missing type in \"backend <type>\" line\n",
160 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
161 "%s: line %d: backend line must appear before any "
162 "database definition.\n", fname, lineno ));
164 Debug( LDAP_DEBUG_ANY,
165 "%s: line %d: backend line must appear before any database definition\n",
172 bi = backend_info( cargv[1] );
176 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
177 "read_config: backend %s initialization failed.\n",
180 Debug( LDAP_DEBUG_ANY,
181 "backend %s initialization failed.\n",
187 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
190 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
191 "%s: line %d: missing type in \"database <type>\" line\n",
194 Debug( LDAP_DEBUG_ANY,
195 "%s: line %d: missing type in \"database <type>\" line\n",
203 be = backend_db_init( cargv[1] );
207 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
208 "database %s initialization failed.\n",
211 Debug( LDAP_DEBUG_ANY,
212 "database %s initialization failed.\n",
219 /* set thread concurrency */
220 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
224 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
225 "%s: line %d: missing level in \"concurrency <level\" line\n",
228 Debug( LDAP_DEBUG_ANY,
229 "%s: line %d: missing level in \"concurrency <level>\" line\n",
236 c = atoi( cargv[1] );
240 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
241 "%s: line %d: invalid level (%d) in "
242 "\"concurrency <level>\" line.\n",
245 Debug( LDAP_DEBUG_ANY,
246 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
253 ldap_pvt_thread_set_concurrency( c );
255 /* set sockbuf max */
256 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
260 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
261 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
264 Debug( LDAP_DEBUG_ANY,
265 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
272 max = atol( cargv[1] );
276 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
277 "%s: line %d: invalid max value (%ld) in "
278 "\"sockbuf_max_incoming <bytes>\" line.\n",
279 fname, lineno, max ));
281 Debug( LDAP_DEBUG_ANY,
282 "%s: line %d: invalid max value (%ld) in "
283 "\"sockbuf_max_incoming <bytes>\" line.\n",
284 fname, lineno, max );
290 sockbuf_max_incoming = max;
292 /* set sockbuf max authenticated */
293 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
297 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
298 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
301 Debug( LDAP_DEBUG_ANY,
302 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
309 max = atol( cargv[1] );
313 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
314 "%s: line %d: invalid max value (%ld) in "
315 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
316 fname, lineno, max ));
318 Debug( LDAP_DEBUG_ANY,
319 "%s: line %d: invalid max value (%ld) in "
320 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
321 fname, lineno, max );
327 sockbuf_max_incoming_auth = max;
329 /* default search base */
330 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
333 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
334 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
335 "line\n", fname, lineno ));
337 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
338 "missing dn in \"defaultSearchBase <dn>\" line\n",
344 } else if ( cargc > 2 ) {
346 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
347 "%s: line %d: extra cruft after <dn> in "
348 "\"defaultSearchBase %s\" line (ignored)\n",
349 fname, lineno, cargv[1] ));
351 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
352 "extra cruft after <dn> in \"defaultSearchBase %s\", "
354 fname, lineno, cargv[1] );
358 if ( bi != NULL || be != NULL ) {
360 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
361 "%s: line %d: defaultSearchBase line must appear "
362 "prior to any backend or database definitions\n",
365 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
366 "defaultSearchBaase line must appear prior to "
367 "any backend or database definition\n",
374 if ( default_search_nbase.bv_len ) {
376 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
377 "default search base \"%s\" already defined "
378 "(discarding old)\n", fname, lineno,
379 default_search_base.bv_val ));
381 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
382 "default search base \"%s\" already defined "
383 "(discarding old)\n",
384 fname, lineno, default_search_base.bv_val );
387 free( default_search_base.bv_val );
388 free( default_search_nbase.bv_val );
391 if ( load_ucdata( NULL ) < 0 ) return 1;
396 dn.bv_val = cargv[1];
397 dn.bv_len = strlen( dn.bv_val );
399 rc = dnPrettyNormal( NULL, &dn,
400 &default_search_base,
401 &default_search_nbase );
403 if( rc != LDAP_SUCCESS ) {
405 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
406 "%s: line %d: defaultSearchBase DN is invalid.\n",
409 Debug( LDAP_DEBUG_ANY,
410 "%s: line %d: defaultSearchBase DN is invalid\n",
417 /* set maximum threads in thread pool */
418 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
422 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
423 "%s: line %d: missing count in \"threads <count>\" line\n",
426 Debug( LDAP_DEBUG_ANY,
427 "%s: line %d: missing count in \"threads <count>\" line\n",
434 c = atoi( cargv[1] );
438 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
439 "%s: line %d: invalid level (%d) in \"threads <count>\""
440 "line\n",fname, lineno, c ));
442 Debug( LDAP_DEBUG_ANY,
443 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
450 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
452 /* save for later use */
453 connection_pool_max = c;
455 /* get pid file name */
456 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
459 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
460 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
463 Debug( LDAP_DEBUG_ANY,
464 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
471 slapd_pid_file = ch_strdup( cargv[1] );
473 /* get args file name */
474 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
477 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
478 "%s: %d: missing file name in "
479 "\"argsfile <file>\" line.\n",
482 Debug( LDAP_DEBUG_ANY,
483 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
490 slapd_args_file = ch_strdup( cargv[1] );
492 /* default password hash */
493 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
496 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
497 "%s: line %d: missing hash in "
498 "\"password-hash <hash>\" line.\n",
501 Debug( LDAP_DEBUG_ANY,
502 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
508 if ( default_passwd_hash != NULL ) {
510 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
511 "%s: line %d: already set default password_hash!\n",
514 Debug( LDAP_DEBUG_ANY,
515 "%s: line %d: already set default password_hash!\n",
523 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
525 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
526 "%s: line %d: password scheme \"%s\" not available\n",
527 fname, lineno, cargv[1] ));
529 Debug( LDAP_DEBUG_ANY,
530 "%s: line %d: password scheme \"%s\" not available\n",
531 fname, lineno, cargv[1] );
536 default_passwd_hash = ch_strdup( cargv[1] );
538 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
542 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
543 "%s: line %d: missing format in "
544 "\"password-crypt-salt-format <format>\" line\n",
547 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
548 "\"password-crypt-salt-format <format>\" line\n",
555 lutil_salt_format( cargv[1] );
558 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
561 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
562 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
565 Debug( LDAP_DEBUG_ANY,
566 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
573 if ( global_host != NULL ) {
575 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
576 "%s: line %d: already set sasl-host!\n",
579 Debug( LDAP_DEBUG_ANY,
580 "%s: line %d: already set sasl-host!\n",
587 global_host = ch_strdup( cargv[1] );
591 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
594 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
595 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
598 Debug( LDAP_DEBUG_ANY,
599 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
606 if ( global_realm != NULL ) {
608 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
609 "%s: line %d: already set sasl-realm!\n",
612 Debug( LDAP_DEBUG_ANY,
613 "%s: line %d: already set sasl-realm!\n",
620 global_realm = ch_strdup( cargv[1] );
623 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
624 || !strcasecmp( cargv[0], "saslregexp" ) )
629 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
630 "%s: line %d: need 2 args in "
631 "\"saslregexp <match> <replace>\"\n",
634 Debug( LDAP_DEBUG_ANY,
635 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
641 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
646 /* SASL security properties */
647 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
652 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
653 "%s: line %d: missing flags in "
654 "\"sasl-secprops <properties>\" line\n",
657 Debug( LDAP_DEBUG_ANY,
658 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
665 txt = slap_sasl_secprops( cargv[1] );
668 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
669 "%s: line %d sas-secprops: %s\n",
670 fname, lineno, txt ));
672 Debug( LDAP_DEBUG_ANY,
673 "%s: line %d: sasl-secprops: %s\n",
674 fname, lineno, txt );
680 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
681 sasl_external_x509dn_convert++;
683 /* set UCDATA path */
684 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
688 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
689 "%s: line %d: missing path in "
690 "\"ucdata-path <path>\" line.\n",
693 Debug( LDAP_DEBUG_ANY,
694 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
701 err = load_ucdata( cargv[1] );
705 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
706 "%s: line %d: ucdata already loaded, ucdata-path "
707 "must be set earlier in the file and/or be "
708 "specified only once!\n",
711 Debug( LDAP_DEBUG_ANY,
712 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
721 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
723 struct slap_limits_set *lim;
727 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
728 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
731 Debug( LDAP_DEBUG_ANY,
732 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
742 lim = &be->be_def_limit;
745 for ( i = 1; i < cargc; i++ ) {
746 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
747 rc = parse_limit( cargv[i], lim );
749 lim->lms_s_soft = atoi( cargv[i] );
755 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
756 "%s: line %d: unable "
757 "to parse value \"%s\" "
760 fname, lineno, cargv[i] ));
762 Debug( LDAP_DEBUG_ANY,
763 "%s: line %d: unable "
764 "to parse value \"%s\" "
767 fname, lineno, cargv[i] );
773 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
775 struct slap_limits_set *lim;
779 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
780 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
783 Debug( LDAP_DEBUG_ANY,
784 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
794 lim = &be->be_def_limit;
797 for ( i = 1; i < cargc; i++ ) {
798 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
799 rc = parse_limit( cargv[i], lim );
801 lim->lms_t_soft = atoi( cargv[i] );
807 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
808 "%s: line %d: unable "
809 "to parse value \"%s\" "
812 fname, lineno, cargv[i] ));
814 Debug( LDAP_DEBUG_ANY,
815 "%s: line %d: unable "
816 "to parse value \"%s\" "
819 fname, lineno, cargv[i] );
824 /* set regex-based limits */
825 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
828 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
829 "%s: line %d \"limits\" allowed only in database environment.\n",
832 Debug( LDAP_DEBUG_ANY,
833 "%s: line %d \"limits\" allowed only in database environment.\n%s",
839 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
843 /* mark this as a subordinate database */
844 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
847 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
848 "subordinate keyword must appear inside a database "
849 "definition (ignored).\n", fname, lineno ));
851 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
852 "must appear inside a database definition (ignored)\n",
856 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
860 /* set database suffix */
861 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
864 struct berval *pdn = NULL;
865 struct berval *ndn = NULL;
869 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
870 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
873 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
874 "missing dn in \"suffix <dn>\" line\n",
880 } else if ( cargc > 2 ) {
882 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
883 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
884 " line (ignored).\n", fname, lineno, cargv[1] ));
886 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
887 "after <dn> in \"suffix %s\" line (ignored)\n",
888 fname, lineno, cargv[1] );
894 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
895 "%s: line %d: suffix line must appear inside a database "
896 "definition.\n", fname, lineno ));
898 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
899 "must appear inside a database definition\n",
904 #if defined(SLAPD_MONITOR_DN)
905 /* "cn=Monitor" is reserved for monitoring slap */
906 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
908 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
909 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
912 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
913 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
917 #endif /* SLAPD_MONITOR_DN */
920 if ( load_ucdata( NULL ) < 0 ) return 1;
922 dn.bv_val = cargv[1];
923 dn.bv_len = strlen( cargv[1] );
924 pdn = ch_malloc( sizeof( struct berval ));
925 ndn = ch_malloc( sizeof( struct berval ));
927 rc = dnPrettyNormal( NULL, &dn, pdn, ndn );
928 if( rc != LDAP_SUCCESS ) {
930 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
931 "%s: line %d: suffix DN is invalid.\n",
934 Debug( LDAP_DEBUG_ANY,
935 "%s: line %d: suffix DN is invalid\n",
941 tmp_be = select_backend( ndn, 0, 0 );
942 if ( tmp_be == be ) {
944 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
945 "%s: line %d: suffix already served by this backend "
946 "(ignored)\n", fname, lineno ));
948 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
949 "already served by this backend (ignored)\n",
955 } else if ( tmp_be != NULL ) {
957 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
958 "%s: line %d: suffix already served by a preceding "
959 "backend \"%s\"\n", fname, lineno,
960 tmp_be->be_suffix[0]->bv_val ));
962 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
963 "already served by a preceeding backend \"%s\"\n",
964 fname, lineno, tmp_be->be_suffix[0]->bv_val );
970 } else if( pdn->bv_len == 0 && default_search_nbase.bv_len ) {
972 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
973 "%s: line %d: suffix DN empty and default search "
974 "base provided \"%s\" (assuming okay).\n",
975 fname, lineno, default_search_base.bv_val ));
977 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
978 "suffix DN empty and default "
979 "search base provided \"%s\" (assuming okay)\n",
980 fname, lineno, default_search_base.bv_val );
984 ber_bvecadd( &be->be_suffix, pdn );
985 ber_bvecadd( &be->be_nsuffix, ndn );
987 /* set database suffixAlias */
988 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
990 struct berval alias, *palias, nalias;
991 struct berval aliased, *paliased, naliased;
995 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
996 "%s: line %d: missing alias and aliased_dn in "
997 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1000 Debug( LDAP_DEBUG_ANY,
1001 "%s: line %d: missing alias and aliased_dn in "
1002 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1007 } else if ( cargc < 3 ) {
1009 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1010 "%s: line %d: missing aliased_dn in "
1011 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1014 Debug( LDAP_DEBUG_ANY,
1015 "%s: line %d: missing aliased_dn in "
1016 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1021 } else if ( cargc > 3 ) {
1023 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1024 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1027 Debug( LDAP_DEBUG_ANY,
1028 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1036 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1037 "%s: line %d: suffixAlias line must appear inside a "
1038 "database definition (ignored).\n", fname, lineno ));
1040 Debug( LDAP_DEBUG_ANY,
1041 "%s: line %d: suffixAlias line"
1042 " must appear inside a database definition (ignored)\n",
1047 if ( load_ucdata( NULL ) < 0 ) return 1;
1049 alias.bv_val = cargv[1];
1050 alias.bv_len = strlen( cargv[1] );
1051 palias = ch_malloc(sizeof(struct berval));
1053 rc = dnPrettyNormal( NULL, &alias, palias, &nalias );
1054 if( rc != LDAP_SUCCESS ) {
1056 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1057 "%s: line %d: alias DN is invalid.\n",
1060 Debug( LDAP_DEBUG_ANY,
1061 "%s: line %d: alias DN is invalid\n",
1067 tmp_be = select_backend( &nalias, 0, 0 );
1068 free( nalias.bv_val );
1069 if ( tmp_be && tmp_be != be ) {
1071 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1072 "%s: line %d: suffixAlias served by a preceeding "
1074 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1076 Debug( LDAP_DEBUG_ANY,
1077 "%s: line %d: suffixAlias served by"
1078 " a preceeding backend \"%s\"\n",
1079 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1081 ber_bvfree( palias );
1085 aliased.bv_val = cargv[2];
1086 aliased.bv_len = strlen( cargv[2] );
1087 paliased = ch_malloc(sizeof(struct berval));
1089 rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased );
1090 if( rc != LDAP_SUCCESS ) {
1092 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1093 "%s: line %d: aliased DN is invalid.\n",
1096 Debug( LDAP_DEBUG_ANY,
1097 "%s: line %d: aliased DN is invalid\n",
1100 ber_bvfree( palias );
1104 tmp_be = select_backend( &naliased, 0, 0 );
1105 free( naliased.bv_val );
1106 if ( tmp_be && tmp_be != be ) {
1108 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1109 "%s: line %d: suffixAlias derefs to a different backend "
1110 "a preceeding backend \"%s\"\n",
1111 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1113 Debug( LDAP_DEBUG_ANY,
1114 "%s: line %d: suffixAlias derefs to differnet backend"
1115 " a preceeding backend \"%s\"\n",
1116 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1118 ber_bvfree( palias );
1119 ber_bvfree( paliased );
1123 ber_bvecadd( &be->be_suffixAlias, palias );
1124 ber_bvecadd( &be->be_suffixAlias, paliased );
1126 /* set max deref depth */
1127 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1131 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1132 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1133 " line\n", fname, lineno ));
1135 Debug( LDAP_DEBUG_ANY,
1136 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1144 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1145 "%s: line %d: depth line must appear inside a database "
1146 "definition (ignored)\n", fname, lineno ));
1148 Debug( LDAP_DEBUG_ANY,
1149 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1153 } else if ((i = atoi(cargv[1])) < 0) {
1155 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1156 "%s: line %d: depth must be positive (ignored).\n",
1159 Debug( LDAP_DEBUG_ANY,
1160 "%s: line %d: depth must be positive (ignored)\n",
1166 be->be_max_deref_depth = i;
1170 /* set magic "root" dn for this database */
1171 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1174 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1175 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1178 Debug( LDAP_DEBUG_ANY,
1179 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1187 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1188 "%s: line %d: rootdn line must appear inside a database "
1189 "definition (ignored).\n", fname, lineno ));
1191 Debug( LDAP_DEBUG_ANY,
1192 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1199 if ( load_ucdata( NULL ) < 0 ) return 1;
1201 dn.bv_val = cargv[1];
1202 dn.bv_len = strlen( cargv[1] );
1204 rc = dnPrettyNormal( NULL, &dn,
1208 if( rc != LDAP_SUCCESS ) {
1210 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1211 "%s: line %d: rootdn DN is invalid.\n",
1214 Debug( LDAP_DEBUG_ANY,
1215 "%s: line %d: rootdn DN is invalid\n",
1222 /* set super-secret magic database password */
1223 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1226 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1227 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1228 " line\n", fname, lineno ));
1230 Debug( LDAP_DEBUG_ANY,
1231 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1239 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1240 "%s: line %d: rootpw line must appear inside a database "
1241 "definition (ignored)\n", fname, lineno ));
1243 Debug( LDAP_DEBUG_ANY,
1244 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1249 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1250 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1253 /* make this database read-only */
1254 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1257 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1258 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1261 Debug( LDAP_DEBUG_ANY,
1262 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1269 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1270 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1272 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1275 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1276 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1278 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1283 /* allow these features */
1284 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1285 strcasecmp( cargv[0], "allow" ) == 0 )
1291 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1292 "%s: line %d: allow line must appear prior to "
1293 "database definitions.\n", fname, lineno ));
1295 Debug( LDAP_DEBUG_ANY,
1296 "%s: line %d: allow line must appear prior to database definitions\n",
1304 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1305 "%s: line %d: missing feature(s) in \"allow <features>\""
1306 " line\n", fname, lineno ));
1308 Debug( LDAP_DEBUG_ANY,
1309 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1318 for( i=1; i < cargc; i++ ) {
1319 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1320 allows |= SLAP_ALLOW_BIND_V2;
1322 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1323 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1325 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1326 allows |= SLAP_ALLOW_BIND_ANON_DN;
1328 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1330 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1331 "%s: line %d: unknown feature %s in "
1332 "\"allow <features>\" line.\n",
1333 fname, lineno, cargv[1] ));
1335 Debug( LDAP_DEBUG_ANY,
1336 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1337 fname, lineno, cargv[i] );
1344 global_allows = allows;
1346 /* disallow these features */
1347 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1348 strcasecmp( cargv[0], "disallow" ) == 0 )
1350 slap_mask_t disallows;
1354 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1355 "%s: line %d: disallow line must appear prior to "
1356 "database definitions.\n", fname, lineno ));
1358 Debug( LDAP_DEBUG_ANY,
1359 "%s: line %d: disallow line must appear prior to database definitions\n",
1367 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1368 "%s: line %d: missing feature(s) in \"disallow <features>\""
1369 " line.\n", fname, lineno ));
1371 Debug( LDAP_DEBUG_ANY,
1372 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1381 for( i=1; i < cargc; i++ ) {
1382 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1383 disallows |= SLAP_DISALLOW_BIND_ANON;
1385 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1386 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1388 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1389 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1391 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1392 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1394 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1395 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1397 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1399 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1400 "%s: line %d: unknown feature %s in "
1401 "\"disallow <features>\" line.\n",
1402 fname, lineno, cargv[i] ));
1404 Debug( LDAP_DEBUG_ANY,
1405 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1406 fname, lineno, cargv[i] );
1413 global_disallows = disallows;
1415 /* require these features */
1416 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1417 strcasecmp( cargv[0], "require" ) == 0 )
1419 slap_mask_t requires;
1423 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1424 "%s: line %d: missing feature(s) in "
1425 "\"require <features>\" line.\n", fname, lineno ));
1427 Debug( LDAP_DEBUG_ANY,
1428 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1437 for( i=1; i < cargc; i++ ) {
1438 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1439 requires |= SLAP_REQUIRE_BIND;
1441 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1442 requires |= SLAP_REQUIRE_LDAP_V3;
1444 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1445 requires |= SLAP_REQUIRE_AUTHC;
1447 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1448 requires |= SLAP_REQUIRE_SASL;
1450 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1451 requires |= SLAP_REQUIRE_STRONG;
1453 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1455 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1456 "%s: line %d: unknown feature %s in "
1457 "\"require <features>\" line.\n",
1460 Debug( LDAP_DEBUG_ANY,
1461 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1462 fname, lineno, cargv[i] );
1470 global_requires = requires;
1472 be->be_requires = requires;
1475 /* required security factors */
1476 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1477 slap_ssf_set_t *set;
1481 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1482 "%s: line %d: missing factor(s) in \"security <factors>\""
1483 " line.\n", fname, lineno ));
1485 Debug( LDAP_DEBUG_ANY,
1486 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1494 set = &global_ssf_set;
1496 set = &be->be_ssf_set;
1499 for( i=1; i < cargc; i++ ) {
1500 if( strncasecmp( cargv[i], "ssf=",
1501 sizeof("ssf") ) == 0 )
1504 atoi( &cargv[i][sizeof("ssf")] );
1506 } else if( strncasecmp( cargv[i], "transport=",
1507 sizeof("transport") ) == 0 )
1509 set->sss_transport =
1510 atoi( &cargv[i][sizeof("transport")] );
1512 } else if( strncasecmp( cargv[i], "tls=",
1513 sizeof("tls") ) == 0 )
1516 atoi( &cargv[i][sizeof("tls")] );
1518 } else if( strncasecmp( cargv[i], "sasl=",
1519 sizeof("sasl") ) == 0 )
1522 atoi( &cargv[i][sizeof("sasl")] );
1524 } else if( strncasecmp( cargv[i], "update_ssf=",
1525 sizeof("update_ssf") ) == 0 )
1527 set->sss_update_ssf =
1528 atoi( &cargv[i][sizeof("update_ssf")] );
1530 } else if( strncasecmp( cargv[i], "update_transport=",
1531 sizeof("update_transport") ) == 0 )
1533 set->sss_update_transport =
1534 atoi( &cargv[i][sizeof("update_transport")] );
1536 } else if( strncasecmp( cargv[i], "update_tls=",
1537 sizeof("update_tls") ) == 0 )
1539 set->sss_update_tls =
1540 atoi( &cargv[i][sizeof("update_tls")] );
1542 } else if( strncasecmp( cargv[i], "update_sasl=",
1543 sizeof("update_sasl") ) == 0 )
1545 set->sss_update_sasl =
1546 atoi( &cargv[i][sizeof("update_sasl")] );
1550 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1551 "%s: line %d: unknown factor %S in "
1552 "\"security <factors>\" line.\n",
1553 fname, lineno, cargv[1] ));
1555 Debug( LDAP_DEBUG_ANY,
1556 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1557 fname, lineno, cargv[i] );
1563 /* where to send clients when we don't hold it */
1564 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1567 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1568 "%s: line %d: missing URL in \"referral <URL>\""
1569 " line.\n", fname, lineno ));
1571 Debug( LDAP_DEBUG_ANY,
1572 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1579 if( validate_global_referral( cargv[1] ) ) {
1581 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1582 "invalid URL (%s) in \"referral\" line.\n",
1583 fname, lineno, cargv[1] ));
1585 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1586 "invalid URL (%s) in \"referral\" line.\n",
1587 fname, lineno, cargv[1] );
1592 vals[0].bv_val = cargv[1];
1593 vals[0].bv_len = strlen( vals[0].bv_val );
1594 value_add( &default_referral, vals );
1597 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1601 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1602 "%s: line %d: Error in logfile directive, "
1603 "\"logfile <filename>\"\n", fname, lineno ));
1605 Debug( LDAP_DEBUG_ANY,
1606 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1612 logfile = fopen( cargv[1], "w" );
1613 if ( logfile != NULL ) lutil_debug_file( logfile );
1616 /* start of a new database definition */
1617 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1621 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1622 "%s: line %d: Error in debug directive, "
1623 "\"debug <subsys> <level>\"\n", fname, lineno ));
1625 Debug( LDAP_DEBUG_ANY,
1626 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1632 level = atoi( cargv[2] );
1633 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1634 lutil_set_debug_level( cargv[1], level );
1635 /* specify an Object Identifier macro */
1636 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1637 rc = parse_oidm( fname, lineno, cargc, cargv );
1640 /* specify an objectclass */
1641 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1642 if ( *cargv[1] == '(' ) {
1644 p = strchr(saveline,'(');
1645 rc = parse_oc( fname, lineno, p, cargv );
1650 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1651 "%s: line %d: old objectclass format not supported\n",
1654 Debug( LDAP_DEBUG_ANY,
1655 "%s: line %d: old objectclass format not supported.\n",
1661 /* specify an attribute type */
1662 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1663 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1665 if ( *cargv[1] == '(' ) {
1667 p = strchr(saveline,'(');
1668 rc = parse_at( fname, lineno, p, cargv );
1673 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1674 "%s: line %d: old attribute type format not supported.\n",
1677 Debug( LDAP_DEBUG_ANY,
1678 "%s: line %d: old attribute type format not supported.\n",
1684 /* turn on/off schema checking */
1685 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1688 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1689 "%s: line %d: missing on|off in "
1690 "\"schemacheck <on|off>\" line.\n",
1693 Debug( LDAP_DEBUG_ANY,
1694 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1700 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1702 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1703 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1706 Debug( LDAP_DEBUG_ANY,
1707 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1710 global_schemacheck = 0;
1712 global_schemacheck = 1;
1715 /* specify access control info */
1716 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1717 parse_acl( be, fname, lineno, cargc, cargv );
1719 /* debug level to log things to syslog */
1720 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1723 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1724 "%s: line %d: missing level in \"loglevel <level>\""
1725 " line.\n", fname, lineno ));
1727 Debug( LDAP_DEBUG_ANY,
1728 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1737 for( i=1; i < cargc; i++ ) {
1738 ldap_syslog += atoi( cargv[1] );
1741 /* list of replicas of the data in this backend (master only) */
1742 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1745 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1746 "%s: line %d: missing host in \"replica "
1747 " <host[:port]\" line\n", fname, lineno ));
1749 Debug( LDAP_DEBUG_ANY,
1750 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1758 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1759 "%s: line %d: replica line must appear inside "
1760 "a database definition (ignored).\n", fname, lineno ));
1762 Debug( LDAP_DEBUG_ANY,
1763 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1770 for ( i = 1; i < cargc; i++ ) {
1771 if ( strncasecmp( cargv[i], "host=", 5 )
1773 nr = add_replica_info( be,
1780 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1781 "%s: line %d: missing host in \"replica\" "
1782 "line (ignored)\n", fname, lineno ));
1784 Debug( LDAP_DEBUG_ANY,
1785 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1789 } else if ( nr == -1 ) {
1791 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1792 "%s: line %d: unable to add"
1798 Debug( LDAP_DEBUG_ANY,
1799 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1800 fname, lineno, cargv[i] + 5 );
1803 for ( i = 1; i < cargc; i++ ) {
1804 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1806 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1809 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1810 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1811 fname, lineno, cargv[i] + 7 ));
1813 Debug( LDAP_DEBUG_ANY,
1814 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1815 fname, lineno, cargv[i] + 7 );
1821 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1822 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1825 Debug( LDAP_DEBUG_ANY,
1826 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1832 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1834 char *arg = cargv[i] + 4;
1836 if ( arg[0] == '!' ) {
1841 if ( arg[0] != '=' ) {
1845 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1847 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1848 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1849 fname, lineno, arg + 1 ));
1851 Debug( LDAP_DEBUG_ANY,
1852 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1853 fname, lineno, arg + 1 );
1862 /* dn of master entity allowed to write to replica */
1863 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1866 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1867 "%s: line %d: missing dn in \"updatedn <dn>\""
1868 " line.\n", fname, lineno ));
1870 Debug( LDAP_DEBUG_ANY,
1871 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1879 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1880 "%s: line %d: updatedn line must appear inside "
1881 "a database definition (ignored)\n",
1884 Debug( LDAP_DEBUG_ANY,
1885 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1892 if ( load_ucdata( NULL ) < 0 ) return 1;
1894 dn.bv_val = cargv[1];
1895 dn.bv_len = strlen( cargv[1] );
1897 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1898 if( rc != LDAP_SUCCESS ) {
1900 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1901 "%s: line %d: updatedn DN is invalid.\n",
1904 Debug( LDAP_DEBUG_ANY,
1905 "%s: line %d: updatedn DN is invalid\n",
1912 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1915 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1916 "missing url in \"updateref <ldapurl>\" line.\n",
1919 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1920 "missing url in \"updateref <ldapurl>\" line\n",
1928 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1929 " line must appear inside a database definition\n",
1932 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1933 " line must appear inside a database definition\n",
1938 } else if ( !be->be_update_ndn.bv_len ) {
1940 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1941 "updateref line must come after updatedn.\n",
1944 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1945 "updateref line must after updatedn.\n",
1951 if( validate_global_referral( cargv[1] ) ) {
1953 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1954 "invalid URL (%s) in \"updateref\" line.\n",
1955 fname, lineno, cargv[1] ));
1957 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1958 "invalid URL (%s) in \"updateref\" line.\n",
1959 fname, lineno, cargv[1] );
1964 vals[0].bv_val = cargv[1];
1965 vals[0].bv_len = strlen( vals[0].bv_val );
1966 value_add( &be->be_update_refs, vals );
1968 /* replication log file to which changes are appended */
1969 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1972 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1973 "%s: line %d: missing filename in \"replogfile <filename>\""
1974 " line.\n", fname, lineno ));
1976 Debug( LDAP_DEBUG_ANY,
1977 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1984 be->be_replogfile = ch_strdup( cargv[1] );
1986 replogfile = ch_strdup( cargv[1] );
1989 /* file from which to read additional rootdse attrs */
1990 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1993 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1994 "missing filename in \"rootDSE <filename>\" line.\n",
1997 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1998 "missing filename in \"rootDSE <filename>\" line.\n",
2004 if( read_root_dse_file( cargv[1] ) ) {
2006 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2007 "could not read \"rootDSE <filename>\" line.\n",
2010 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2011 "could not read \"rootDSE <filename>\" line\n",
2017 /* maintain lastmodified{by,time} attributes */
2018 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2021 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2022 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2023 " line.\n", fname, lineno ));
2025 Debug( LDAP_DEBUG_ANY,
2026 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2032 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2034 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2040 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2046 /* set idle timeout value */
2047 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2051 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2052 "%s: line %d: missing timeout value in "
2053 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2055 Debug( LDAP_DEBUG_ANY,
2056 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2063 i = atoi( cargv[1] );
2067 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2068 "%s: line %d: timeout value (%d) invalid "
2069 "\"idletimeout <seconds>\" line.\n",
2070 fname, lineno, i ));
2072 Debug( LDAP_DEBUG_ANY,
2073 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2080 global_idletimeout = i;
2082 /* include another config file */
2083 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2086 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2087 "%s: line %d: missing filename in \"include "
2088 "<filename>\" line.\n", fname, lineno ));
2090 Debug( LDAP_DEBUG_ANY,
2091 "%s: line %d: missing filename in \"include <filename>\" line\n",
2097 savefname = ch_strdup( cargv[1] );
2098 savelineno = lineno;
2100 if ( read_config( savefname ) != 0 ) {
2105 lineno = savelineno - 1;
2107 /* location of kerberos srvtab file */
2108 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2111 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2112 "%s: line %d: missing filename in \"srvtab "
2113 "<filename>\" line.\n", fname, lineno ));
2115 Debug( LDAP_DEBUG_ANY,
2116 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2122 ldap_srvtab = ch_strdup( cargv[1] );
2124 #ifdef SLAPD_MODULES
2125 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2128 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2129 "%s: line %d: missing filename in \"moduleload "
2130 "<filename>\" line.\n", fname, lineno ));
2132 Debug( LDAP_DEBUG_ANY,
2133 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2137 exit( EXIT_FAILURE );
2139 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2141 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2142 "%s: line %d: failed to load or initialize module %s\n",
2143 fname, lineno, cargv[1] ));
2145 Debug( LDAP_DEBUG_ANY,
2146 "%s: line %d: failed to load or initialize module %s\n",
2147 fname, lineno, cargv[1]);
2150 exit( EXIT_FAILURE );
2152 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2155 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2156 "%s: line %d: missing path in \"modulepath <path>\""
2157 " line\n", fname, lineno ));
2159 Debug( LDAP_DEBUG_ANY,
2160 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2164 exit( EXIT_FAILURE );
2166 if (module_path( cargv[1] )) {
2168 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2169 "%s: line %d: failed to set module search path to %s.\n",
2170 fname, lineno, cargv[1] ));
2172 Debug( LDAP_DEBUG_ANY,
2173 "%s: line %d: failed to set module search path to %s\n",
2174 fname, lineno, cargv[1]);
2177 exit( EXIT_FAILURE );
2180 #endif /*SLAPD_MODULES*/
2183 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2184 rc = ldap_pvt_tls_set_option( NULL,
2185 LDAP_OPT_X_TLS_RANDOM_FILE,
2190 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2191 rc = ldap_pvt_tls_set_option( NULL,
2192 LDAP_OPT_X_TLS_CIPHER_SUITE,
2197 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2198 rc = ldap_pvt_tls_set_option( NULL,
2199 LDAP_OPT_X_TLS_CERTFILE,
2204 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2205 rc = ldap_pvt_tls_set_option( NULL,
2206 LDAP_OPT_X_TLS_KEYFILE,
2211 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2212 rc = ldap_pvt_tls_set_option( NULL,
2213 LDAP_OPT_X_TLS_CACERTDIR,
2218 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2219 rc = ldap_pvt_tls_set_option( NULL,
2220 LDAP_OPT_X_TLS_CACERTFILE,
2224 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2225 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2227 rc = ldap_pvt_tls_set_option( NULL,
2228 LDAP_OPT_X_TLS_REQUIRE_CERT,
2231 rc = ldap_int_tls_config( NULL,
2232 LDAP_OPT_X_TLS_REQUIRE_CERT,
2241 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2242 #ifdef SLAPD_RLOOKUPS
2245 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2246 "%s: line %d: reverse-lookup: "
2247 "missing \"on\" or \"off\"\n",
2250 Debug( LDAP_DEBUG_ANY,
2251 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2257 if ( !strcasecmp( cargv[1], "on" ) ) {
2258 use_reverse_lookup = 1;
2259 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2260 use_reverse_lookup = 0;
2263 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2264 "%s: line %d: reverse-lookup: "
2265 "must be \"on\" (default) "
2269 Debug( LDAP_DEBUG_ANY,
2270 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2276 #else /* !SLAPD_RLOOKUPS */
2278 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2279 "%s: line %d: reverse lookups "
2280 "are not configured (ignored).\n",
2283 Debug( LDAP_DEBUG_ANY,
2284 "%s: line %d: reverse lookups are not configured (ignored).\n",
2287 #endif /* !SLAPD_RLOOKUPS */
2289 /* pass anything else to the current backend info/db config routine */
2292 if ( bi->bi_config == 0 ) {
2294 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2295 "%s: line %d: unknown directive \"%s\" inside "
2296 "backend info definition (ignored).\n",
2297 fname, lineno, cargv[0] ));
2299 Debug( LDAP_DEBUG_ANY,
2300 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2301 fname, lineno, cargv[0] );
2305 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2311 } else if ( be != NULL ) {
2312 if ( be->be_config == 0 ) {
2314 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2315 "%s: line %d: uknown directive \"%s\" inside "
2316 "backend database definition (ignored).\n",
2317 fname, lineno, cargv[0] ));
2319 Debug( LDAP_DEBUG_ANY,
2320 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2321 fname, lineno, cargv[0] );
2325 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2333 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2334 "%s: line %d: unknown directive \"%s\" outside backend "
2335 "info and database definitions (ignored).\n",
2336 fname, lineno, cargv[0] ));
2338 Debug( LDAP_DEBUG_ANY,
2339 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2340 fname, lineno, cargv[0] );
2349 if ( load_ucdata( NULL ) < 0 ) return 1;
2365 token = strtok_quote( line, " \t" );
2367 logline = (!token || strcasecmp(token, "rootpw") ? line : "rootpw *");
2369 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
2370 "line %d (%s)\n", lineno, logline ));
2372 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2375 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2376 if ( *argcp == MAXARGS ) {
2378 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2379 "fp_parse_line: too many tokens (%d max).\n",
2382 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2388 argv[(*argcp)++] = token;
2390 argv[*argcp] = NULL;
2395 strtok_quote( char *line, char *sep )
2401 if ( line != NULL ) {
2404 while ( *next && strchr( sep, *next ) ) {
2408 if ( *next == '\0' ) {
2414 for ( inquote = 0; *next; ) {
2422 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2428 next + 1, strlen( next + 1 ) + 1 );
2429 next++; /* dont parse the escaped character */
2434 if ( strchr( sep, *next ) != NULL ) {
2447 static char buf[BUFSIZ];
2449 static int lmax, lcur;
2451 #define CATLINE( buf ) { \
2453 len = strlen( buf ); \
2454 while ( lcur + len + 1 > lmax ) { \
2456 line = (char *) ch_realloc( line, lmax ); \
2458 strcpy( line + lcur, buf ); \
2463 fp_getline( FILE *fp, int *lineno )
2471 /* hack attack - keeps us from having to keep a stack of bufs... */
2472 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2477 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2478 /* trim off \r\n or \n */
2479 if ( (p = strchr( buf, '\n' )) != NULL ) {
2480 if( p > buf && p[-1] == '\r' ) --p;
2484 /* trim off trailing \ and append the next line */
2485 if ( line[ 0 ] != '\0'
2486 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2487 && p[ -1 ] != '\\' ) {
2492 if ( ! isspace( (unsigned char) buf[0] ) ) {
2496 /* change leading whitespace to a space */
2505 return( line[0] ? line : NULL );
2509 fp_getline_init( int *lineno )
2515 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2517 load_ucdata( char *path )
2519 static int loaded = 0;
2525 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2528 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2529 "load_ucdata: Error %d loading ucdata.\n", err ));
2531 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2544 ucdata_unload( UCDATA_ALL );
2546 if ( slapd_args_file )
2547 free ( slapd_args_file );
2548 if ( slapd_pid_file )
2549 free ( slapd_pid_file );
2550 acl_destroy( global_acl, NULL );