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>
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_lastmod = ON;
44 int global_idletimeout = 0;
45 char *global_host = NULL;
46 char *global_realm = NULL;
47 char *ldap_srvtab = "";
48 char *default_passwd_hash;
49 struct berval default_search_base = { 0, NULL };
50 struct berval default_search_nbase = { 0, NULL };
53 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
54 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
56 char *slapd_pid_file = NULL;
57 char *slapd_args_file = NULL;
60 SaslRegexp_t *SaslRegexp = NULL;
61 int sasl_external_x509dn_convert;
63 static char *fp_getline(FILE *fp, int *lineno);
64 static void fp_getline_init(int *lineno);
65 static int fp_parse_line(char *line, int *argcp, char **argv);
67 static char *strtok_quote(char *line, char *sep);
68 static int load_ucdata(char *path);
71 read_config( const char *fname )
74 char *line, *savefname, *saveline;
75 int cargc, savelineno;
76 char *cargv[MAXARGS+1];
79 struct berval *vals[2];
82 static BackendInfo *bi = NULL;
83 static BackendDB *be = NULL;
88 if ( (fp = fopen( fname, "r" )) == NULL ) {
91 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
92 "could not open config file \"%s\": %s (%d)\n",
93 fname, strerror(errno), errno ));
95 Debug( LDAP_DEBUG_ANY,
96 "could not open config file \"%s\": %s (%d)\n",
97 fname, strerror(errno), errno );
103 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
104 "read_config: reading config file %s\n", fname ));
106 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
110 fp_getline_init( &lineno );
112 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
113 /* skip comments and blank lines */
114 if ( line[0] == '#' || line[0] == '\0' ) {
119 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
120 "line %d (%s)\n", lineno, line ));
122 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
126 /* fp_parse_line is destructive, we save a copy */
127 saveline = ch_strdup( line );
129 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
135 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
136 "%s: line %d: bad config line (ignored)\n",
139 Debug( LDAP_DEBUG_ANY,
140 "%s: line %d: bad config line (ignored)\n",
147 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
150 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
151 "%s : line %d: missing type in \"backend\" line.\n",
154 Debug( LDAP_DEBUG_ANY,
155 "%s: line %d: missing type in \"backend <type>\" line\n",
164 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
165 "%s: line %d: backend line must appear before any "
166 "database definition.\n", fname, lineno ));
168 Debug( LDAP_DEBUG_ANY,
169 "%s: line %d: backend line must appear before any database definition\n",
176 bi = backend_info( cargv[1] );
180 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
181 "read_config: backend %s initialization failed.\n",
184 Debug( LDAP_DEBUG_ANY,
185 "backend %s initialization failed.\n",
191 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
194 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
195 "%s: line %d: missing type in \"database <type>\" line\n",
198 Debug( LDAP_DEBUG_ANY,
199 "%s: line %d: missing type in \"database <type>\" line\n",
207 be = backend_db_init( cargv[1] );
211 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
212 "database %s initialization failed.\n",
215 Debug( LDAP_DEBUG_ANY,
216 "database %s initialization failed.\n",
223 /* set thread concurrency */
224 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
228 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
229 "%s: line %d: missing level in \"concurrency <level\" line\n",
232 Debug( LDAP_DEBUG_ANY,
233 "%s: line %d: missing level in \"concurrency <level>\" line\n",
240 c = atoi( cargv[1] );
244 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
245 "%s: line %d: invalid level (%d) in "
246 "\"concurrency <level>\" line.\n",
249 Debug( LDAP_DEBUG_ANY,
250 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
257 ldap_pvt_thread_set_concurrency( c );
259 /* set sockbuf max */
260 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
264 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
265 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
268 Debug( LDAP_DEBUG_ANY,
269 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
276 max = atol( cargv[1] );
280 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
281 "%s: line %d: invalid max value (%ld) in "
282 "\"sockbuf_max_incoming <bytes>\" line.\n",
283 fname, lineno, max ));
285 Debug( LDAP_DEBUG_ANY,
286 "%s: line %d: invalid max value (%ld) in "
287 "\"sockbuf_max_incoming <bytes>\" line.\n",
288 fname, lineno, max );
294 sockbuf_max_incoming = max;
296 /* set sockbuf max authenticated */
297 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
301 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
302 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
305 Debug( LDAP_DEBUG_ANY,
306 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
313 max = atol( cargv[1] );
317 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
318 "%s: line %d: invalid max value (%ld) in "
319 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
320 fname, lineno, max ));
322 Debug( LDAP_DEBUG_ANY,
323 "%s: line %d: invalid max value (%ld) in "
324 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
325 fname, lineno, max );
331 sockbuf_max_incoming_auth = max;
333 /* default search base */
334 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
337 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
338 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
339 "line\n", fname, lineno ));
341 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
342 "missing dn in \"defaultSearchBase <dn>\" line\n",
348 } else if ( cargc > 2 ) {
350 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
351 "%s: line %d: extra cruft after <dn> in "
352 "\"defaultSearchBase %s\" line (ignored)\n",
353 fname, lineno, cargv[1] ));
355 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
356 "extra cruft after <dn> in \"defaultSearchBase %s\", "
358 fname, lineno, cargv[1] );
362 if ( bi != NULL || be != NULL ) {
364 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
365 "%s: line %d: defaultSearchBase line must appear "
366 "prior to any backend or database definitions\n",
369 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
370 "defaultSearchBaase line must appear prior to "
371 "any backend or database definition\n",
378 if ( default_search_nbase.bv_len ) {
380 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
381 "default search base \"%s\" already defined "
382 "(discarding old)\n", fname, lineno,
383 default_search_base->bv_val ));
385 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
386 "default search base \"%s\" already defined "
387 "(discarding old)\n",
388 fname, lineno, default_search_base.bv_val );
391 free( default_search_base.bv_val );
392 free( default_search_nbase.bv_val );
395 if ( load_ucdata( NULL ) < 0 ) return 1;
398 struct berval dn, *pdn, *ndn;
400 dn.bv_val = cargv[1];
401 dn.bv_len = strlen( dn.bv_val );
403 rc = dnPretty( NULL, &dn, &pdn );
404 if( rc != LDAP_SUCCESS ) {
406 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
407 "%s: line %d: defaultSearchBase DN is invalid.\n",
410 Debug( LDAP_DEBUG_ANY,
411 "%s: line %d: defaultSearchBase DN is invalid\n",
417 rc = dnNormalize( NULL, &dn, &ndn );
418 if( rc != LDAP_SUCCESS ) {
420 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
421 "%s: line %d: defaultSearchBase DN is invalid.\n",
424 Debug( LDAP_DEBUG_ANY,
425 "%s: line %d: defaultSearchBase DN is invalid\n",
432 default_search_base = *pdn;
433 default_search_nbase = *ndn;
439 /* set maximum threads in thread pool */
440 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
444 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
445 "%s: line %d: missing count in \"threads <count>\" line\n",
448 Debug( LDAP_DEBUG_ANY,
449 "%s: line %d: missing count in \"threads <count>\" line\n",
456 c = atoi( cargv[1] );
460 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
461 "%s: line %d: invalid level (%d) in \"threads <count>\""
462 "line\n",fname, lineno, c ));
464 Debug( LDAP_DEBUG_ANY,
465 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
472 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
474 /* save for later use */
475 connection_pool_max = c;
477 /* get pid file name */
478 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
481 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
482 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
485 Debug( LDAP_DEBUG_ANY,
486 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
493 slapd_pid_file = ch_strdup( cargv[1] );
495 /* get args file name */
496 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
499 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
500 "%s: %d: missing file name in "
501 "\"argsfile <file>\" line.\n",
504 Debug( LDAP_DEBUG_ANY,
505 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
512 slapd_args_file = ch_strdup( cargv[1] );
514 /* default password hash */
515 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
518 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
519 "%s: line %d: missing hash in "
520 "\"password-hash <hash>\" line.\n",
523 Debug( LDAP_DEBUG_ANY,
524 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
530 if ( default_passwd_hash != NULL ) {
532 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
533 "%s: line %d: already set default password_hash!\n",
536 Debug( LDAP_DEBUG_ANY,
537 "%s: line %d: already set default password_hash!\n",
544 default_passwd_hash = ch_strdup( cargv[1] );
547 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
551 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
552 "%s: line %d: missing format in "
553 "\"password-crypt-salt-format <format>\" line\n",
556 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
557 "\"password-crypt-salt-format <format>\" line\n",
564 lutil_salt_format( cargv[1] );
567 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
570 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
571 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
574 Debug( LDAP_DEBUG_ANY,
575 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
582 if ( global_host != NULL ) {
584 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
585 "%s: line %d: already set sasl-host!\n",
588 Debug( LDAP_DEBUG_ANY,
589 "%s: line %d: already set sasl-host!\n",
596 global_host = ch_strdup( cargv[1] );
600 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
603 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
604 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
607 Debug( LDAP_DEBUG_ANY,
608 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
615 if ( global_realm != NULL ) {
617 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
618 "%s: line %d: already set sasl-realm!\n",
621 Debug( LDAP_DEBUG_ANY,
622 "%s: line %d: already set sasl-realm!\n",
629 global_realm = ch_strdup( cargv[1] );
632 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
633 || !strcasecmp( cargv[0], "saslregexp" ) )
638 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
639 "%s: line %d: need 2 args in "
640 "\"saslregexp <match> <replace>\"\n",
643 Debug( LDAP_DEBUG_ANY,
644 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
650 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
655 /* SASL security properties */
656 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
661 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
662 "%s: line %d: missing flags in "
663 "\"sasl-secprops <properties>\" line\n",
666 Debug( LDAP_DEBUG_ANY,
667 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
674 txt = slap_sasl_secprops( cargv[1] );
677 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
678 "%s: line %d sas-secprops: %s\n",
679 fname, lineno, txt ));
681 Debug( LDAP_DEBUG_ANY,
682 "%s: line %d: sasl-secprops: %s\n",
683 fname, lineno, txt );
689 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
690 sasl_external_x509dn_convert++;
692 /* set UCDATA path */
693 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
697 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
698 "%s: line %d: missing path in "
699 "\"ucdata-path <path>\" line.\n",
702 Debug( LDAP_DEBUG_ANY,
703 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
710 err = load_ucdata( cargv[1] );
714 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
715 "%s: line %d: ucdata already loaded, ucdata-path "
716 "must be set earlier in the file and/or be "
717 "specified only once!\n",
720 Debug( LDAP_DEBUG_ANY,
721 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
730 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
732 struct slap_limits_set *lim;
736 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
737 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
740 Debug( LDAP_DEBUG_ANY,
741 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
751 lim = &be->be_def_limit;
754 for ( i = 1; i < cargc; i++ ) {
755 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
756 rc = parse_limit( cargv[i], lim );
758 lim->lms_s_soft = atoi( cargv[i] );
764 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
765 "%s: line %d: unable "
766 "to parse value \"%s\" "
769 fname, lineno, cargv[i] ));
771 Debug( LDAP_DEBUG_ANY,
772 "%s: line %d: unable "
773 "to parse value \"%s\" "
776 fname, lineno, cargv[i] );
782 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
784 struct slap_limits_set *lim;
788 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
789 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
792 Debug( LDAP_DEBUG_ANY,
793 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
803 lim = &be->be_def_limit;
806 for ( i = 1; i < cargc; i++ ) {
807 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
808 rc = parse_limit( cargv[i], lim );
810 lim->lms_t_soft = atoi( cargv[i] );
816 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
817 "%s: line %d: unable "
818 "to parse value \"%s\" "
821 fname, lineno, cargv[i] ));
823 Debug( LDAP_DEBUG_ANY,
824 "%s: line %d: unable "
825 "to parse value \"%s\" "
828 fname, lineno, cargv[i] );
833 /* set regex-based limits */
834 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
837 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
838 "%s: line %d \"limits\" allowed only in database environment.\n",
841 Debug( LDAP_DEBUG_ANY,
842 "%s: line %d \"limits\" allowed only in database environment.\n%s",
848 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
852 /* mark this as a subordinate database */
853 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
856 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
857 "subordinate keyword must appear inside a database "
858 "definition (ignored).\n", fname, lineno ));
860 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
861 "must appear inside a database definition (ignored)\n",
865 be->be_glueflags |= SLAP_GLUE_SUBORDINATE;
869 /* set database suffix */
870 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
873 struct berval *pdn = NULL;
874 struct berval *ndn = NULL;
878 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
879 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
882 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
883 "missing dn in \"suffix <dn>\" line\n",
889 } else if ( cargc > 2 ) {
891 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
892 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
893 " line (ignored).\n", fname, lineno, cargv[1] ));
895 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
896 "after <dn> in \"suffix %s\" line (ignored)\n",
897 fname, lineno, cargv[1] );
903 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
904 "%s: line %d: suffix line must appear inside a database "
905 "definition.\n", fname, lineno ));
907 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
908 "must appear inside a database definition\n",
913 #if defined(SLAPD_MONITOR_DN)
914 /* "cn=Monitor" is reserved for monitoring slap */
915 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
917 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
918 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
921 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
922 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
926 #endif /* SLAPD_MONITOR_DN */
929 if ( load_ucdata( NULL ) < 0 ) return 1;
931 dn.bv_val = cargv[1];
932 dn.bv_len = strlen( cargv[1] );
934 rc = dnPretty( NULL, &dn, &pdn );
935 if( rc != LDAP_SUCCESS ) {
937 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
938 "%s: line %d: suffix DN is invalid.\n",
941 Debug( LDAP_DEBUG_ANY,
942 "%s: line %d: suffix DN is invalid\n",
948 rc = dnNormalize( NULL, &dn, &ndn );
949 if( rc != LDAP_SUCCESS ) {
951 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
952 "%s: line %d: suffix DN is invalid.\n",
955 Debug( LDAP_DEBUG_ANY,
956 "%s: line %d: suffix DN is invalid\n",
963 tmp_be = select_backend( ndn, 0, 0 );
964 if ( tmp_be == be ) {
966 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
967 "%s: line %d: suffix already served by this backend "
968 "(ignored)\n", fname, lineno ));
970 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
971 "already served by this backend (ignored)\n",
977 } else if ( tmp_be != NULL ) {
979 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
980 "%s: line %d: suffix already served by a preceding "
981 "backend \"%s\"\n", fname, lineno,
982 tmp_be->be_suffix[0]->bv_val ));
984 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
985 "already served by a preceeding backend \"%s\"\n",
986 fname, lineno, tmp_be->be_suffix[0]->bv_val );
992 } else if( pdn->bv_len == 0 && default_search_nbase.bv_len ) {
994 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
995 "%s: line %d: suffix DN empty and default search "
996 "base provided \"%s\" (assuming okay).\n",
997 fname, lineno, default_search_base.bv_val ));
999 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1000 "suffix DN empty and default "
1001 "search base provided \"%s\" (assuming okay)\n",
1002 fname, lineno, default_search_base.bv_val );
1006 ber_bvecadd( &be->be_suffix, pdn );
1007 ber_bvecadd( &be->be_nsuffix, ndn );
1009 /* set database suffixAlias */
1010 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
1012 struct berval alias, *palias, *nalias;
1013 struct berval aliased, *paliased, *naliased;
1017 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1018 "%s: line %d: missing alias and aliased_dn in "
1019 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1022 Debug( LDAP_DEBUG_ANY,
1023 "%s: line %d: missing alias and aliased_dn in "
1024 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
1029 } else if ( cargc < 3 ) {
1031 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1032 "%s: line %d: missing aliased_dn in "
1033 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1036 Debug( LDAP_DEBUG_ANY,
1037 "%s: line %d: missing aliased_dn in "
1038 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1043 } else if ( cargc > 3 ) {
1045 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1046 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1049 Debug( LDAP_DEBUG_ANY,
1050 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1058 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1059 "%s: line %d: suffixAlias line must appear inside a "
1060 "database definition (ignored).\n", fname, lineno ));
1062 Debug( LDAP_DEBUG_ANY,
1063 "%s: line %d: suffixAlias line"
1064 " must appear inside a database definition (ignored)\n",
1069 if ( load_ucdata( NULL ) < 0 ) return 1;
1071 alias.bv_val = cargv[1];
1072 alias.bv_len = strlen( cargv[1] );
1074 rc = dnPretty( NULL, &alias, &palias );
1075 if( rc != LDAP_SUCCESS ) {
1077 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1078 "%s: line %d: alias DN is invalid.\n",
1081 Debug( LDAP_DEBUG_ANY,
1082 "%s: line %d: alias DN is invalid\n",
1088 rc = dnNormalize( NULL, &alias, &nalias );
1089 if( rc != LDAP_SUCCESS ) {
1091 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1092 "%s: line %d: alias DN is invalid.\n",
1095 Debug( LDAP_DEBUG_ANY,
1096 "%s: line %d: alias DN is invalid\n",
1099 ber_bvfree( palias );
1103 tmp_be = select_backend( nalias, 0, 0 );
1104 ber_bvfree( nalias );
1105 if ( tmp_be != be ) {
1107 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1108 "%s: line %d: suffixAlias served by a preceeding "
1110 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1112 Debug( LDAP_DEBUG_ANY,
1113 "%s: line %d: suffixAlias served by"
1114 " a preceeding backend \"%s\"\n",
1115 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1117 ber_bvfree( palias );
1121 aliased.bv_val = cargv[2];
1122 aliased.bv_len = strlen( cargv[2] );
1124 rc = dnPretty( NULL, &aliased, &paliased );
1125 if( rc != LDAP_SUCCESS ) {
1127 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1128 "%s: line %d: aliased DN is invalid.\n",
1131 Debug( LDAP_DEBUG_ANY,
1132 "%s: line %d: aliased DN is invalid\n",
1135 ber_bvfree( palias );
1139 rc = dnNormalize( NULL, &aliased, &naliased );
1140 if( rc != LDAP_SUCCESS ) {
1142 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1143 "%s: line %d: aliased DN is invalid.\n",
1146 Debug( LDAP_DEBUG_ANY,
1147 "%s: line %d: aliased DN is invalid\n",
1150 ber_bvfree( palias );
1151 ber_bvfree( paliased );
1155 tmp_be = select_backend( naliased, 0, 0 );
1156 ber_bvfree( naliased );
1157 if ( tmp_be != be ) {
1159 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1160 "%s: line %d: suffixAlias derefs to a different backend "
1161 "a preceeding backend \"%s\"\n",
1162 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1164 Debug( LDAP_DEBUG_ANY,
1165 "%s: line %d: suffixAlias derefs to differnet backend"
1166 " a preceeding backend \"%s\"\n",
1167 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1169 ber_bvfree( palias );
1170 ber_bvfree( paliased );
1174 ber_bvecadd( &be->be_suffixAlias, palias );
1175 ber_bvecadd( &be->be_suffixAlias, paliased );
1177 /* set max deref depth */
1178 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1182 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1183 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1184 " line\n", fname, lineno ));
1186 Debug( LDAP_DEBUG_ANY,
1187 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1195 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1196 "%s: line %d: depth line must appear inside a database "
1197 "definition (ignored)\n", fname, lineno ));
1199 Debug( LDAP_DEBUG_ANY,
1200 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1204 } else if ((i = atoi(cargv[1])) < 0) {
1206 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1207 "%s: line %d: depth must be positive (ignored).\n",
1210 Debug( LDAP_DEBUG_ANY,
1211 "%s: line %d: depth must be positive (ignored)\n",
1217 be->be_max_deref_depth = i;
1221 /* set magic "root" dn for this database */
1222 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1225 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1226 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1229 Debug( LDAP_DEBUG_ANY,
1230 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1238 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1239 "%s: line %d: rootdn line must appear inside a database "
1240 "definition (ignored).\n", fname, lineno ));
1242 Debug( LDAP_DEBUG_ANY,
1243 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1248 struct berval dn, *pdn = NULL, *ndn = NULL;
1250 if ( load_ucdata( NULL ) < 0 ) return 1;
1252 dn.bv_val = cargv[1];
1253 dn.bv_len = strlen( cargv[1] );
1255 rc = dnPretty( NULL, &dn, &pdn );
1256 if( rc != LDAP_SUCCESS ) {
1258 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1259 "%s: line %d: rootdn DN is invalid.\n",
1262 Debug( LDAP_DEBUG_ANY,
1263 "%s: line %d: rootdn DN is invalid\n",
1269 rc = dnNormalize( NULL, &dn, &ndn );
1270 if( rc != LDAP_SUCCESS ) {
1272 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1273 "%s: line %d: rootdn DN is invalid.\n",
1276 Debug( LDAP_DEBUG_ANY,
1277 "%s: line %d: rootdn DN is invalid\n",
1284 be->be_rootdn = *pdn;
1285 be->be_rootndn = *ndn;
1291 /* set super-secret magic database password */
1292 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1295 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1296 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1297 " line\n", fname, lineno ));
1299 Debug( LDAP_DEBUG_ANY,
1300 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1308 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1309 "%s: line %d: rootpw line must appear inside a database "
1310 "definition (ignored)\n", fname, lineno ));
1312 Debug( LDAP_DEBUG_ANY,
1313 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1318 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1319 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1322 /* make this database read-only */
1323 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1326 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1327 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1330 Debug( LDAP_DEBUG_ANY,
1331 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1338 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1339 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1341 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1344 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1345 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1347 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1352 /* allow these features */
1353 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1354 strcasecmp( cargv[0], "allow" ) == 0 )
1360 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1361 "%s: line %d: allow line must appear prior to "
1362 "database definitions.\n", fname, lineno ));
1364 Debug( LDAP_DEBUG_ANY,
1365 "%s: line %d: allow line must appear prior to database definitions\n",
1373 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1374 "%s: line %d: missing feature(s) in \"allow <features>\""
1375 " line\n", fname, lineno ));
1377 Debug( LDAP_DEBUG_ANY,
1378 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1387 for( i=1; i < cargc; i++ ) {
1388 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1389 allows |= SLAP_ALLOW_BIND_V2;
1391 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1392 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1394 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1395 allows |= SLAP_ALLOW_BIND_ANON_DN;
1397 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1399 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1400 "%s: line %d: unknown feature %s in "
1401 "\"allow <features>\" line.\n",
1402 fname, lineno, cargv[1] ));
1404 Debug( LDAP_DEBUG_ANY,
1405 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1406 fname, lineno, cargv[i] );
1413 global_allows = allows;
1415 /* disallow these features */
1416 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1417 strcasecmp( cargv[0], "disallow" ) == 0 )
1419 slap_mask_t disallows;
1423 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1424 "%s: line %d: disallow line must appear prior to "
1425 "database definitions.\n", fname, lineno ));
1427 Debug( LDAP_DEBUG_ANY,
1428 "%s: line %d: disallow line must appear prior to database definitions\n",
1436 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1437 "%s: line %d: missing feature(s) in \"disallow <features>\""
1438 " line.\n", fname, lineno ));
1440 Debug( LDAP_DEBUG_ANY,
1441 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1450 for( i=1; i < cargc; i++ ) {
1451 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1452 disallows |= SLAP_DISALLOW_BIND_ANON;
1454 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1455 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1457 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1458 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1460 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1461 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1463 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1464 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1466 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1468 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1469 "%s: line %d: unknown feature %s in "
1470 "\"disallow <features>\" line.\n",
1471 fname, lineno, cargv[i] ));
1473 Debug( LDAP_DEBUG_ANY,
1474 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1475 fname, lineno, cargv[i] );
1482 global_disallows = disallows;
1484 /* require these features */
1485 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1486 strcasecmp( cargv[0], "require" ) == 0 )
1488 slap_mask_t requires;
1492 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1493 "%s: line %d: missing feature(s) in "
1494 "\"require <features>\" line.\n", fname, lineno ));
1496 Debug( LDAP_DEBUG_ANY,
1497 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1506 for( i=1; i < cargc; i++ ) {
1507 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1508 requires |= SLAP_REQUIRE_BIND;
1510 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1511 requires |= SLAP_REQUIRE_LDAP_V3;
1513 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1514 requires |= SLAP_REQUIRE_AUTHC;
1516 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1517 requires |= SLAP_REQUIRE_SASL;
1519 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1520 requires |= SLAP_REQUIRE_STRONG;
1522 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1524 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1525 "%s: line %d: unknown feature %s in "
1526 "\"require <features>\" line.\n",
1529 Debug( LDAP_DEBUG_ANY,
1530 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1531 fname, lineno, cargv[i] );
1539 global_requires = requires;
1541 be->be_requires = requires;
1544 /* required security factors */
1545 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1546 slap_ssf_set_t *set;
1550 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1551 "%s: line %d: missing factor(s) in \"security <factors>\""
1552 " line.\n", fname, lineno ));
1554 Debug( LDAP_DEBUG_ANY,
1555 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1563 set = &global_ssf_set;
1565 set = &be->be_ssf_set;
1568 for( i=1; i < cargc; i++ ) {
1569 if( strncasecmp( cargv[i], "ssf=",
1570 sizeof("ssf") ) == 0 )
1573 atoi( &cargv[i][sizeof("ssf")] );
1575 } else if( strncasecmp( cargv[i], "transport=",
1576 sizeof("transport") ) == 0 )
1578 set->sss_transport =
1579 atoi( &cargv[i][sizeof("transport")] );
1581 } else if( strncasecmp( cargv[i], "tls=",
1582 sizeof("tls") ) == 0 )
1585 atoi( &cargv[i][sizeof("tls")] );
1587 } else if( strncasecmp( cargv[i], "sasl=",
1588 sizeof("sasl") ) == 0 )
1591 atoi( &cargv[i][sizeof("sasl")] );
1593 } else if( strncasecmp( cargv[i], "update_ssf=",
1594 sizeof("update_ssf") ) == 0 )
1596 set->sss_update_ssf =
1597 atoi( &cargv[i][sizeof("update_ssf")] );
1599 } else if( strncasecmp( cargv[i], "update_transport=",
1600 sizeof("update_transport") ) == 0 )
1602 set->sss_update_transport =
1603 atoi( &cargv[i][sizeof("update_transport")] );
1605 } else if( strncasecmp( cargv[i], "update_tls=",
1606 sizeof("update_tls") ) == 0 )
1608 set->sss_update_tls =
1609 atoi( &cargv[i][sizeof("update_tls")] );
1611 } else if( strncasecmp( cargv[i], "update_sasl=",
1612 sizeof("update_sasl") ) == 0 )
1614 set->sss_update_sasl =
1615 atoi( &cargv[i][sizeof("update_sasl")] );
1619 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1620 "%s: line %d: unknown factor %S in "
1621 "\"security <factors>\" line.\n",
1622 fname, lineno, cargv[1] ));
1624 Debug( LDAP_DEBUG_ANY,
1625 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1626 fname, lineno, cargv[i] );
1632 /* where to send clients when we don't hold it */
1633 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1636 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1637 "%s: line %d: missing URL in \"referral <URL>\""
1638 " line.\n", fname, lineno ));
1640 Debug( LDAP_DEBUG_ANY,
1641 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1648 if( validate_global_referral( cargv[1] ) ) {
1650 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1651 "invalid URL (%s) in \"referral\" line.\n",
1652 fname, lineno, cargv[1] ));
1654 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1655 "invalid URL (%s) in \"referral\" line.\n",
1656 fname, lineno, cargv[1] );
1661 vals[0]->bv_val = cargv[1];
1662 vals[0]->bv_len = strlen( vals[0]->bv_val );
1663 value_add( &default_referral, vals );
1666 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1670 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1671 "%s: line %d: Error in logfile directive, "
1672 "\"logfile <filename>\"\n", fname, lineno ));
1674 Debug( LDAP_DEBUG_ANY,
1675 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1681 logfile = fopen( cargv[1], "w" );
1682 if ( logfile != NULL ) lutil_debug_file( logfile );
1685 /* start of a new database definition */
1686 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1690 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1691 "%s: line %d: Error in debug directive, "
1692 "\"debug <subsys> <level>\"\n", fname, lineno ));
1694 Debug( LDAP_DEBUG_ANY,
1695 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1701 level = atoi( cargv[2] );
1702 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1703 lutil_set_debug_level( cargv[1], level );
1704 /* specify an Object Identifier macro */
1705 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1706 rc = parse_oidm( fname, lineno, cargc, cargv );
1709 /* specify an objectclass */
1710 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1711 if ( *cargv[1] == '(' ) {
1713 p = strchr(saveline,'(');
1714 rc = parse_oc( fname, lineno, p, cargv );
1719 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1720 "%s: line %d: old objectclass format not supported\n",
1723 Debug( LDAP_DEBUG_ANY,
1724 "%s: line %d: old objectclass format not supported.\n",
1730 /* specify an attribute type */
1731 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1732 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1734 if ( *cargv[1] == '(' ) {
1736 p = strchr(saveline,'(');
1737 rc = parse_at( fname, lineno, p, cargv );
1742 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1743 "%s: line %d: old attribute type format not supported.\n",
1746 Debug( LDAP_DEBUG_ANY,
1747 "%s: line %d: old attribute type format not supported.\n",
1753 /* turn on/off schema checking */
1754 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1757 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1758 "%s: line %d: missing on|off in "
1759 "\"schemacheck <on|off>\" line.\n",
1762 Debug( LDAP_DEBUG_ANY,
1763 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1769 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1770 global_schemacheck = 0;
1772 global_schemacheck = 1;
1775 /* specify access control info */
1776 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1777 parse_acl( be, fname, lineno, cargc, cargv );
1779 /* debug level to log things to syslog */
1780 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1783 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1784 "%s: line %d: missing level in \"loglevel <level>\""
1785 " line.\n", fname, lineno ));
1787 Debug( LDAP_DEBUG_ANY,
1788 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1797 for( i=1; i < cargc; i++ ) {
1798 ldap_syslog += atoi( cargv[1] );
1801 /* list of replicas of the data in this backend (master only) */
1802 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1805 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1806 "%s: line %d: missing host in \"replica "
1807 " <host[:port]\" line\n", fname, lineno ));
1809 Debug( LDAP_DEBUG_ANY,
1810 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1818 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1819 "%s: line %d: replica line must appear inside "
1820 "a database definition (ignored).\n", fname, lineno ));
1822 Debug( LDAP_DEBUG_ANY,
1823 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1830 for ( i = 1; i < cargc; i++ ) {
1831 if ( strncasecmp( cargv[i], "host=", 5 )
1833 nr = add_replica_info( be,
1840 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1841 "%s: line %d: missing host in \"replica\" "
1842 "line (ignored)\n", fname, lineno ));
1844 Debug( LDAP_DEBUG_ANY,
1845 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1849 } else if ( nr == -1 ) {
1851 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1852 "%s: line %d: unable to add"
1858 Debug( LDAP_DEBUG_ANY,
1859 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1860 fname, lineno, cargv[i] + 5 );
1863 for ( i = 1; i < cargc; i++ ) {
1864 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1866 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1869 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1870 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1871 fname, lineno, cargv[i] + 7 ));
1873 Debug( LDAP_DEBUG_ANY,
1874 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1875 fname, lineno, cargv[i] + 7 );
1881 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1882 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1885 Debug( LDAP_DEBUG_ANY,
1886 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1896 /* dn of master entity allowed to write to replica */
1897 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1900 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1901 "%s: line %d: missing dn in \"updatedn <dn>\""
1902 " line.\n", fname, lineno ));
1904 Debug( LDAP_DEBUG_ANY,
1905 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1913 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1914 "%s: line %d: updatedn line must appear inside "
1915 "a database definition (ignored)\n",
1918 Debug( LDAP_DEBUG_ANY,
1919 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1924 struct berval dn, *ndn = NULL;
1926 if ( load_ucdata( NULL ) < 0 ) return 1;
1928 dn.bv_val = cargv[1];
1929 dn.bv_len = strlen( cargv[1] );
1931 rc = dnNormalize( NULL, &dn, &ndn );
1932 if( rc != LDAP_SUCCESS ) {
1934 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1935 "%s: line %d: updatedn DN is invalid.\n",
1938 Debug( LDAP_DEBUG_ANY,
1939 "%s: line %d: updatedn DN is invalid\n",
1945 be->be_update_ndn = *ndn;
1949 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1952 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1953 "missing url in \"updateref <ldapurl>\" line.\n",
1956 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1957 "missing url in \"updateref <ldapurl>\" line\n",
1965 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1966 " line must appear inside a database definition\n",
1969 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1970 " line must appear inside a database definition\n",
1975 } else if ( !be->be_update_ndn.bv_len ) {
1977 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1978 "updateref line must come after updatedn.\n",
1981 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1982 "updateref line must after updatedn.\n",
1988 if( validate_global_referral( cargv[1] ) ) {
1990 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1991 "invalid URL (%s) in \"updateref\" line.\n",
1992 fname, lineno, cargv[1] ));
1994 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1995 "invalid URL (%s) in \"updateref\" line.\n",
1996 fname, lineno, cargv[1] );
2001 vals[0]->bv_val = cargv[1];
2002 vals[0]->bv_len = strlen( vals[0]->bv_val );
2003 value_add( &be->be_update_refs, vals );
2005 /* replication log file to which changes are appended */
2006 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2009 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2010 "%s: line %d: missing filename in \"replogfile <filename>\""
2011 " line.\n", fname, lineno ));
2013 Debug( LDAP_DEBUG_ANY,
2014 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2021 be->be_replogfile = ch_strdup( cargv[1] );
2023 replogfile = ch_strdup( cargv[1] );
2026 /* file from which to read additional rootdse attrs */
2027 } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
2030 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2031 "missing filename in \"rootDSEfile <filename>\" line.\n",
2034 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2035 "missing filename in \"rootDSEfile <filename>\" line.\n",
2041 if( read_root_dse_file( cargv[1] ) ) {
2043 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
2044 "could not read \"rootDSEfile <filename>\" line.\n",
2047 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2048 "could not read \"rootDSEfile <filename>\" line\n",
2054 /* maintain lastmodified{by,time} attributes */
2055 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2058 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2059 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2060 " line.\n", fname, lineno ));
2062 Debug( LDAP_DEBUG_ANY,
2063 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2069 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2071 be->be_lastmod = ON;
2073 global_lastmod = ON;
2076 be->be_lastmod = OFF;
2078 global_lastmod = OFF;
2081 /* set idle timeout value */
2082 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2086 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2087 "%s: line %d: missing timeout value in "
2088 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2090 Debug( LDAP_DEBUG_ANY,
2091 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2098 i = atoi( cargv[1] );
2102 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2103 "%s: line %d: timeout value (%d) invalid "
2104 "\"idletimeout <seconds>\" line.\n",
2105 fname, lineno, i ));
2107 Debug( LDAP_DEBUG_ANY,
2108 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2115 global_idletimeout = i;
2117 /* include another config file */
2118 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2121 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2122 "%s: line %d: missing filename in \"include "
2123 "<filename>\" line.\n", fname, lineno ));
2125 Debug( LDAP_DEBUG_ANY,
2126 "%s: line %d: missing filename in \"include <filename>\" line\n",
2132 savefname = ch_strdup( cargv[1] );
2133 savelineno = lineno;
2135 if ( read_config( savefname ) != 0 ) {
2140 lineno = savelineno - 1;
2142 /* location of kerberos srvtab file */
2143 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2146 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2147 "%s: line %d: missing filename in \"srvtab "
2148 "<filename>\" line.\n", fname, lineno ));
2150 Debug( LDAP_DEBUG_ANY,
2151 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2157 ldap_srvtab = ch_strdup( cargv[1] );
2159 #ifdef SLAPD_MODULES
2160 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2163 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2164 "%s: line %d: missing filename in \"moduleload "
2165 "<filename>\" line.\n", fname, lineno ));
2167 Debug( LDAP_DEBUG_ANY,
2168 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2172 exit( EXIT_FAILURE );
2174 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2176 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2177 "%s: line %d: failed to load or initialize module %s\n"<
2178 fname, lineno, cargv[1] ));
2180 Debug( LDAP_DEBUG_ANY,
2181 "%s: line %d: failed to load or initialize module %s\n",
2182 fname, lineno, cargv[1]);
2185 exit( EXIT_FAILURE );
2187 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2190 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2191 "%s: line %d: missing path in \"modulepath <path>\""
2192 " line\n", fname, lineno ));
2194 Debug( LDAP_DEBUG_ANY,
2195 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2199 exit( EXIT_FAILURE );
2201 if (module_path( cargv[1] )) {
2203 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2204 "%s: line %d: failed to set module search path to %s.\n",
2205 fname, lineno, cargv[1] ));
2207 Debug( LDAP_DEBUG_ANY,
2208 "%s: line %d: failed to set module search path to %s\n",
2209 fname, lineno, cargv[1]);
2212 exit( EXIT_FAILURE );
2215 #endif /*SLAPD_MODULES*/
2218 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2219 rc = ldap_pvt_tls_set_option( NULL,
2220 LDAP_OPT_X_TLS_RANDOM_FILE,
2225 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2226 rc = ldap_pvt_tls_set_option( NULL,
2227 LDAP_OPT_X_TLS_CIPHER_SUITE,
2232 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2233 rc = ldap_pvt_tls_set_option( NULL,
2234 LDAP_OPT_X_TLS_CERTFILE,
2239 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2240 rc = ldap_pvt_tls_set_option( NULL,
2241 LDAP_OPT_X_TLS_KEYFILE,
2246 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2247 rc = ldap_pvt_tls_set_option( NULL,
2248 LDAP_OPT_X_TLS_CACERTDIR,
2253 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2254 rc = ldap_pvt_tls_set_option( NULL,
2255 LDAP_OPT_X_TLS_CACERTFILE,
2259 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2261 rc = ldap_pvt_tls_set_option( NULL,
2262 LDAP_OPT_X_TLS_REQUIRE_CERT,
2269 /* pass anything else to the current backend info/db config routine */
2272 if ( bi->bi_config == 0 ) {
2274 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2275 "%s: line %d: unknown directive \"%s\" inside "
2276 "backend info definition (ignored).\n",
2277 fname, lineno, cargv[0] ));
2279 Debug( LDAP_DEBUG_ANY,
2280 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2281 fname, lineno, cargv[0] );
2285 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2291 } else if ( be != NULL ) {
2292 if ( be->be_config == 0 ) {
2294 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2295 "%s: line %d: uknown directive \"%s\" inside "
2296 "backend database definition (ignored).\n",
2297 fname, lineno, cargv[0] ));
2299 Debug( LDAP_DEBUG_ANY,
2300 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2301 fname, lineno, cargv[0] );
2305 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2313 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2314 "%s: line %d: unknown directive \"%s\" outside backend "
2315 "info and database definitions (ignored).\n",
2316 fname, lineno, cargv[0] ));
2318 Debug( LDAP_DEBUG_ANY,
2319 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2320 fname, lineno, cargv[0] );
2329 if ( load_ucdata( NULL ) < 0 ) return 1;
2343 for ( token = strtok_quote( line, " \t" ); token != NULL;
2344 token = strtok_quote( NULL, " \t" ) ) {
2345 if ( *argcp == MAXARGS ) {
2347 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2348 "fp_parse_line: too many tokens (%d max).\n",
2351 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2357 argv[(*argcp)++] = token;
2359 argv[*argcp] = NULL;
2364 strtok_quote( char *line, char *sep )
2370 if ( line != NULL ) {
2373 while ( *next && strchr( sep, *next ) ) {
2377 if ( *next == '\0' ) {
2383 for ( inquote = 0; *next; ) {
2391 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2397 next + 1, strlen( next + 1 ) + 1 );
2398 next++; /* dont parse the escaped character */
2403 if ( strchr( sep, *next ) != NULL ) {
2416 static char buf[BUFSIZ];
2418 static int lmax, lcur;
2420 #define CATLINE( buf ) { \
2422 len = strlen( buf ); \
2423 while ( lcur + len + 1 > lmax ) { \
2425 line = (char *) ch_realloc( line, lmax ); \
2427 strcpy( line + lcur, buf ); \
2432 fp_getline( FILE *fp, int *lineno )
2440 /* hack attack - keeps us from having to keep a stack of bufs... */
2441 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2446 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2447 /* trim off \r\n or \n */
2448 if ( (p = strchr( buf, '\n' )) != NULL ) {
2449 if( p > buf && p[-1] == '\r' ) --p;
2452 if ( ! isspace( (unsigned char) buf[0] ) ) {
2456 /* change leading whitespace to a space */
2464 return( line[0] ? line : NULL );
2468 fp_getline_init( int *lineno )
2474 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2476 load_ucdata( char *path )
2478 static int loaded = 0;
2484 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2487 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2488 "load_ucdata: Error %d loading ucdata.\n", err ));
2490 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2503 ucdata_unload( UCDATA_ALL );
2505 if ( slapd_args_file )
2506 free ( slapd_args_file );
2507 if ( slapd_pid_file )
2508 free ( slapd_pid_file );
2509 acl_destroy( global_acl, NULL );