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 char *default_search_base = NULL;
50 char *default_search_nbase = 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] );
363 if ( bi != NULL || be != NULL ) {
365 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
366 "%s: line %d: defaultSearchBase line must appear "
367 "prior to any backend or database definitions\n",
370 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
371 "defaultSearchBaase line must appear prior to "
372 "any backend or database definition\n",
379 if ( default_search_nbase != NULL ) {
381 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
382 "%s: line %d: default search base \"%s\" already defined "
383 "(discarding old)\n", fname, lineno, default_search_base ));
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 );
391 free( default_search_base );
392 free( default_search_nbase );
395 default_search_base = ch_strdup( cargv[1] );
396 default_search_nbase = ch_strdup( cargv[1] );
398 if ( load_ucdata( NULL ) < 0 ) {
401 if( dn_normalize( default_search_nbase ) == NULL ) {
403 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
404 "%s: %d: invalid default search base \"%s\"\n",
405 fname, lineno, default_search_base ));
407 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
408 "invalid default search base \"%s\"\n",
409 fname, lineno, default_search_base );
415 /* set maximum threads in thread pool */
416 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
420 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
421 "%s: line %d: missing count in \"threads <count>\" line\n",
424 Debug( LDAP_DEBUG_ANY,
425 "%s: line %d: missing count in \"threads <count>\" line\n",
432 c = atoi( cargv[1] );
436 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
437 "%s: line %d: invalid level (%d) in \"threads <count>\""
438 "line\n",fname, lineno, c ));
440 Debug( LDAP_DEBUG_ANY,
441 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
448 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
450 /* save for later use */
451 connection_pool_max = c;
453 /* get pid file name */
454 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
457 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
458 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
461 Debug( LDAP_DEBUG_ANY,
462 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
469 slapd_pid_file = ch_strdup( cargv[1] );
471 /* get args file name */
472 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
475 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
476 "%s: %d: missing file name in "
477 "\"argsfile <file>\" line.\n",
480 Debug( LDAP_DEBUG_ANY,
481 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
488 slapd_args_file = ch_strdup( cargv[1] );
490 /* default password hash */
491 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
494 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
495 "%s: line %d: missing hash in "
496 "\"password-hash <hash>\" line.\n",
499 Debug( LDAP_DEBUG_ANY,
500 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
506 if ( default_passwd_hash != NULL ) {
508 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
509 "%s: line %d: already set default password_hash!\n",
512 Debug( LDAP_DEBUG_ANY,
513 "%s: line %d: already set default password_hash!\n",
520 default_passwd_hash = ch_strdup( cargv[1] );
523 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
527 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
528 "%s: line %d: missing format in "
529 "\"password-crypt-salt-format <format>\" line\n",
532 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
533 "\"password-crypt-salt-format <format>\" line\n",
540 lutil_salt_format( cargv[1] );
543 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
546 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
547 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
550 Debug( LDAP_DEBUG_ANY,
551 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
558 if ( global_host != NULL ) {
560 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
561 "%s: line %d: already set sasl-host!\n",
564 Debug( LDAP_DEBUG_ANY,
565 "%s: line %d: already set sasl-host!\n",
572 global_host = ch_strdup( cargv[1] );
576 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
579 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
580 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
583 Debug( LDAP_DEBUG_ANY,
584 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
591 if ( global_realm != NULL ) {
593 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
594 "%s: line %d: already set sasl-realm!\n",
597 Debug( LDAP_DEBUG_ANY,
598 "%s: line %d: already set sasl-realm!\n",
605 global_realm = ch_strdup( cargv[1] );
608 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
609 || !strcasecmp( cargv[0], "saslregexp" ) )
614 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
615 "%s: line %d: need 2 args in "
616 "\"saslregexp <match> <replace>\"\n",
619 Debug( LDAP_DEBUG_ANY,
620 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
626 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
631 /* SASL security properties */
632 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
637 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
638 "%s: line %d: missing flags in "
639 "\"sasl-secprops <properties>\" line\n",
642 Debug( LDAP_DEBUG_ANY,
643 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
650 txt = slap_sasl_secprops( cargv[1] );
653 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
654 "%s: line %d sas-secprops: %s\n",
655 fname, lineno, txt ));
657 Debug( LDAP_DEBUG_ANY,
658 "%s: line %d: sasl-secprops: %s\n",
659 fname, lineno, txt );
665 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
666 sasl_external_x509dn_convert++;
668 /* set UCDATA path */
669 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
673 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
674 "%s: line %d: missing path in "
675 "\"ucdata-path <path>\" line.\n",
678 Debug( LDAP_DEBUG_ANY,
679 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
686 err = load_ucdata( cargv[1] );
690 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
691 "%s: line %d: ucdata already loaded, ucdata-path "
692 "must be set earlier in the file and/or be "
693 "specified only once!\n",
696 Debug( LDAP_DEBUG_ANY,
697 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
706 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
708 struct slap_limits_set *lim;
712 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
713 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
716 Debug( LDAP_DEBUG_ANY,
717 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
727 lim = &be->be_def_limit;
730 for ( i = 1; i < cargc; i++ ) {
731 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
732 rc = parse_limit( cargv[i], lim );
734 lim->lms_s_soft = atoi( cargv[i] );
740 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
741 "%s: line %d: unable "
742 "to parse value \"%s\" "
745 fname, lineno, cargv[i] ));
747 Debug( LDAP_DEBUG_ANY,
748 "%s: line %d: unable "
749 "to parse value \"%s\" "
752 fname, lineno, cargv[i] );
758 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
760 struct slap_limits_set *lim;
764 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
765 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
768 Debug( LDAP_DEBUG_ANY,
769 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
779 lim = &be->be_def_limit;
782 for ( i = 1; i < cargc; i++ ) {
783 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
784 rc = parse_limit( cargv[i], lim );
786 lim->lms_t_soft = atoi( cargv[i] );
792 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
793 "%s: line %d: unable "
794 "to parse value \"%s\" "
797 fname, lineno, cargv[i] ));
799 Debug( LDAP_DEBUG_ANY,
800 "%s: line %d: unable "
801 "to parse value \"%s\" "
804 fname, lineno, cargv[i] );
809 /* set regex-based limits */
810 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
813 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
814 "%s: line %d \"limits\" allowed only in database environment.\n",
817 Debug( LDAP_DEBUG_ANY,
818 "%s: line %d \"limits\" allowed only in database environment.\n%s",
824 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
828 /* mark this as a subordinate database */
829 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
832 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
833 "%s: line %d: subordinate keyword must appear inside a database "
834 "definition (ignored).\n", fname, lineno ));
836 Debug( LDAP_DEBUG_ANY,
837 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
841 be->be_glueflags |= SLAP_GLUE_SUBORDINATE;
845 /* set database suffix */
846 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
850 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
851 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
854 Debug( LDAP_DEBUG_ANY,
855 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
860 } else if ( cargc > 2 ) {
862 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
863 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
864 " line (ignored).\n", fname, lineno, cargv[1] ));
866 Debug( LDAP_DEBUG_ANY,
867 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
868 fname, lineno, cargv[1] );
874 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
875 "%s: line %d: suffix line must appear inside a database "
876 "definition (ignored).\n", fname, lineno ));
878 Debug( LDAP_DEBUG_ANY,
879 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
883 #if defined(SLAPD_MONITOR_DN)
884 /* "cn=Monitor" is reserved for monitoring slap */
885 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
887 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
888 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
889 fname, lineno, SLAPD_MONITOR_DN ));
891 Debug( LDAP_DEBUG_ANY,
892 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
893 fname, lineno, SLAPD_MONITOR_DN );
896 #endif /* SLAPD_MONITOR_DN */
898 } else if ( ( tmp_be = select_backend( cargv[1], 0, 0 ) ) == be ) {
900 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
901 "%s: line %d: suffix already served by this backend "
902 "(ignored)\n", fname, lineno ));
904 Debug( LDAP_DEBUG_ANY,
905 "%s: line %d: suffix already served by this backend (ignored)\n",
909 } else if ( tmp_be != NULL ) {
911 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
912 "%s: line %d: suffix already served by a preceding "
913 "backend \"%s\" (ignored)\n", fname, lineno,
914 tmp_be->be_suffix[0] ));
916 Debug( LDAP_DEBUG_ANY,
917 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
918 fname, lineno, tmp_be->be_suffix[0] );
924 if ( load_ucdata( NULL ) < 0 ) {
927 dn = ch_strdup( cargv[1] );
928 if( dn_validate( dn ) == NULL ) {
930 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
931 "%s: line %d: suffix DN invalid\"%s\"\n",
932 fname, lineno, cargv[1] ));
934 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
935 "suffix DN invalid \"%s\"\n",
936 fname, lineno, cargv[1] );
941 } else if( *dn == '\0' && default_search_nbase != NULL ) {
943 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
944 "%s: line %d: suffix DN empty and default search "
945 "base provided \"%s\" (assuming okay).\n",
946 fname, lineno, default_search_base ));
948 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
949 "suffix DN empty and default "
950 "search base provided \"%s\" (assuming okay)\n",
951 fname, lineno, default_search_base );
955 charray_add( &be->be_suffix, dn );
956 #ifndef USE_LDAP_DN_PARSING
957 (void) ldap_pvt_str2upper( dn );
958 #else /* USE_LDAP_DN_PARSING */
959 if ( dn_normalize( dn ) == NULL ) {
961 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
963 "unable to normalize suffix "
966 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
967 "unable to normalize suffix "
968 "\"%s\"\n", dn, NULL, NULL );
973 #endif /* USE_LDAP_DN_PARSING */
974 ber_bvecadd( &be->be_nsuffix, ber_bvstr( dn ) );
977 /* set database suffixAlias */
978 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
982 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
983 "%s: line %d: missing alias and aliased_dn in "
984 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
987 Debug( LDAP_DEBUG_ANY,
988 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
993 } else if ( cargc < 3 ) {
995 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
996 "%s: line %d: missing aliased_dn in "
997 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1000 Debug( LDAP_DEBUG_ANY,
1001 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
1006 } else if ( cargc > 3 ) {
1008 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1009 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1012 Debug( LDAP_DEBUG_ANY,
1013 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1021 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1022 "%s: line %d: suffixAlias line must appear inside a "
1023 "database definition (ignored).\n", fname, lineno ));
1025 Debug( LDAP_DEBUG_ANY,
1026 "%s: line %d: suffixAlias line"
1027 " must appear inside a database definition (ignored)\n",
1031 } else if ( (tmp_be = select_backend( cargv[1], 0, 0 )) != NULL ) {
1033 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1034 "%s: line %d: suffixAlias served by a preceeding "
1035 "backend \"%s\" (ignored).\n", fname, lineno,
1036 tmp_be->be_suffix[0] ));
1038 Debug( LDAP_DEBUG_ANY,
1039 "%s: line %d: suffixAlias served by"
1040 " a preceeding backend \"%s\" (ignored)\n",
1041 fname, lineno, tmp_be->be_suffix[0] );
1045 } else if ( (tmp_be = select_backend( cargv[2], 0, 0 )) != NULL ) {
1047 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1048 "%s: line %d: suffixAlias derefs to a different backend "
1049 "a preceeding backend \"%s\" (ignored)\n",
1050 fname, lineno, tmp_be->be_suffix[0] ));
1052 Debug( LDAP_DEBUG_ANY,
1053 "%s: line %d: suffixAlias derefs to differnet backend"
1054 " a preceeding backend \"%s\" (ignored)\n",
1055 fname, lineno, tmp_be->be_suffix[0] );
1060 char *alias, *aliased_dn;
1062 if ( load_ucdata( NULL ) < 0 ) {
1066 alias = ch_strdup( cargv[1] );
1067 (void) dn_normalize( alias );
1069 aliased_dn = ch_strdup( cargv[2] );
1070 (void) dn_normalize( aliased_dn );
1072 ber_bvecadd( &be->be_suffixAlias,
1073 ber_bvstr( alias ) );
1074 ber_bvecadd( &be->be_suffixAlias,
1075 ber_bvstr( aliased_dn ) );
1078 /* set max deref depth */
1079 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1083 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1084 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1085 " line\n", fname, lineno ));
1087 Debug( LDAP_DEBUG_ANY,
1088 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1096 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1097 "%s: line %d: depth line must appear inside a database "
1098 "definition (ignored)\n", fname, lineno ));
1100 Debug( LDAP_DEBUG_ANY,
1101 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1105 } else if ((i = atoi(cargv[1])) < 0) {
1107 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1108 "%s: line %d: depth must be positive (ignored).\n",
1111 Debug( LDAP_DEBUG_ANY,
1112 "%s: line %d: depth must be positive (ignored)\n",
1118 be->be_max_deref_depth = i;
1122 /* set magic "root" dn for this database */
1123 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1126 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1127 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1130 Debug( LDAP_DEBUG_ANY,
1131 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1139 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1140 "%s: line %d: rootdn line must appear inside a database "
1141 "definition (ignored).\n", fname, lineno ));
1143 Debug( LDAP_DEBUG_ANY,
1144 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1149 be->be_root_dn = ch_strdup( cargv[1] );
1150 be->be_root_ndn = ch_strdup( cargv[1] );
1152 if ( load_ucdata( NULL ) < 0 ) {
1155 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1156 free( be->be_root_dn );
1157 free( be->be_root_ndn );
1159 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1160 "%s: line %d: rootdn DN is invalid.\n",
1163 Debug( LDAP_DEBUG_ANY,
1164 "%s: line %d: rootdn DN is invalid\n",
1172 /* set super-secret magic database password */
1173 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1176 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1177 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1178 " line\n", fname, lineno ));
1180 Debug( LDAP_DEBUG_ANY,
1181 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1189 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1190 "%s: line %d: rootpw line must appear inside a database "
1191 "definition (ignored)\n", fname, lineno ));
1193 Debug( LDAP_DEBUG_ANY,
1194 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1199 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1200 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1203 /* make this database read-only */
1204 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1207 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1208 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1211 Debug( LDAP_DEBUG_ANY,
1212 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1219 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1220 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1222 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1225 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1226 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1228 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1233 /* allow these features */
1234 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1235 strcasecmp( cargv[0], "allow" ) == 0 )
1241 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1242 "%s: line %d: allow line must appear prior to "
1243 "database definitions.\n", fname, lineno ));
1245 Debug( LDAP_DEBUG_ANY,
1246 "%s: line %d: allow line must appear prior to database definitions\n",
1254 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1255 "%s: line %d: missing feature(s) in \"allow <features>\""
1256 " line\n", fname, lineno ));
1258 Debug( LDAP_DEBUG_ANY,
1259 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1268 for( i=1; i < cargc; i++ ) {
1269 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1270 allows |= SLAP_ALLOW_TLS_2_ANON;
1272 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1274 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1275 "%s: line %d: unknown feature %s in "
1276 "\"allow <features>\" line.\n",
1277 fname, lineno, cargv[1] ));
1279 Debug( LDAP_DEBUG_ANY,
1280 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1281 fname, lineno, cargv[i] );
1288 global_allows = allows;
1290 /* disallow these features */
1291 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1292 strcasecmp( cargv[0], "disallow" ) == 0 )
1294 slap_mask_t disallows;
1298 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1299 "%s: line %d: disallow line must appear prior to "
1300 "database definitions.\n", fname, lineno ));
1302 Debug( LDAP_DEBUG_ANY,
1303 "%s: line %d: disallow line must appear prior to database definitions\n",
1311 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1312 "%s: line %d: missing feature(s) in \"disallow <features>\""
1313 " line.\n", fname, lineno ));
1315 Debug( LDAP_DEBUG_ANY,
1316 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1325 for( i=1; i < cargc; i++ ) {
1326 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1327 disallows |= SLAP_DISALLOW_BIND_V2;
1329 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1330 disallows |= SLAP_DISALLOW_BIND_ANON;
1332 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1333 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1335 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1336 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1338 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1339 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1341 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1342 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1344 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1345 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1347 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1349 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1350 "%s: line %d: unknown feature %s in "
1351 "\"disallow <features>\" line.\n",
1352 fname, lineno, cargv[i] ));
1354 Debug( LDAP_DEBUG_ANY,
1355 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1356 fname, lineno, cargv[i] );
1363 global_disallows = disallows;
1365 /* require these features */
1366 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1367 strcasecmp( cargv[0], "require" ) == 0 )
1369 slap_mask_t requires;
1373 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1374 "%s: line %d: missing feature(s) in "
1375 "\"require <features>\" line.\n", fname, lineno ));
1377 Debug( LDAP_DEBUG_ANY,
1378 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1387 for( i=1; i < cargc; i++ ) {
1388 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1389 requires |= SLAP_REQUIRE_BIND;
1391 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1392 requires |= SLAP_REQUIRE_LDAP_V3;
1394 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1395 requires |= SLAP_REQUIRE_AUTHC;
1397 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1398 requires |= SLAP_REQUIRE_SASL;
1400 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1401 requires |= SLAP_REQUIRE_STRONG;
1403 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1405 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1406 "%s: line %d: unknown feature %s in "
1407 "\"require <features>\" line.\n",
1410 Debug( LDAP_DEBUG_ANY,
1411 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1412 fname, lineno, cargv[i] );
1420 global_requires = requires;
1422 be->be_requires = requires;
1425 /* required security factors */
1426 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1427 slap_ssf_set_t *set;
1431 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1432 "%s: line %d: missing factor(s) in \"security <factors>\""
1433 " line.\n", fname, lineno ));
1435 Debug( LDAP_DEBUG_ANY,
1436 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1444 set = &global_ssf_set;
1446 set = &be->be_ssf_set;
1449 for( i=1; i < cargc; i++ ) {
1450 if( strncasecmp( cargv[i], "ssf=",
1451 sizeof("ssf") ) == 0 )
1454 atoi( &cargv[i][sizeof("ssf")] );
1456 } else if( strncasecmp( cargv[i], "transport=",
1457 sizeof("transport") ) == 0 )
1459 set->sss_transport =
1460 atoi( &cargv[i][sizeof("transport")] );
1462 } else if( strncasecmp( cargv[i], "tls=",
1463 sizeof("tls") ) == 0 )
1466 atoi( &cargv[i][sizeof("tls")] );
1468 } else if( strncasecmp( cargv[i], "sasl=",
1469 sizeof("sasl") ) == 0 )
1472 atoi( &cargv[i][sizeof("sasl")] );
1474 } else if( strncasecmp( cargv[i], "update_ssf=",
1475 sizeof("update_ssf") ) == 0 )
1477 set->sss_update_ssf =
1478 atoi( &cargv[i][sizeof("update_ssf")] );
1480 } else if( strncasecmp( cargv[i], "update_transport=",
1481 sizeof("update_transport") ) == 0 )
1483 set->sss_update_transport =
1484 atoi( &cargv[i][sizeof("update_transport")] );
1486 } else if( strncasecmp( cargv[i], "update_tls=",
1487 sizeof("update_tls") ) == 0 )
1489 set->sss_update_tls =
1490 atoi( &cargv[i][sizeof("update_tls")] );
1492 } else if( strncasecmp( cargv[i], "update_sasl=",
1493 sizeof("update_sasl") ) == 0 )
1495 set->sss_update_sasl =
1496 atoi( &cargv[i][sizeof("update_sasl")] );
1500 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1501 "%s: line %d: unknown factor %S in "
1502 "\"security <factors>\" line.\n",
1503 fname, lineno, cargv[1] ));
1505 Debug( LDAP_DEBUG_ANY,
1506 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1507 fname, lineno, cargv[i] );
1513 /* where to send clients when we don't hold it */
1514 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1517 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1518 "%s: line %d: missing URL in \"referral <URL>\""
1519 " line.\n", fname, lineno ));
1521 Debug( LDAP_DEBUG_ANY,
1522 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1529 if( validate_global_referral( cargv[1] ) ) {
1531 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1532 "invalid URL (%s) in \"referral\" line.\n",
1533 fname, lineno, cargv[1] ));
1535 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1536 "invalid URL (%s) in \"referral\" line.\n",
1537 fname, lineno, cargv[1] );
1542 vals[0]->bv_val = cargv[1];
1543 vals[0]->bv_len = strlen( vals[0]->bv_val );
1544 value_add( &default_referral, vals );
1547 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1551 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1552 "%s: line %d: Error in logfile directive, "
1553 "\"logfile <filename>\"\n", fname, lineno ));
1555 Debug( LDAP_DEBUG_ANY,
1556 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1562 logfile = fopen( cargv[1], "w" );
1563 if ( logfile != NULL ) lutil_debug_file( logfile );
1566 /* start of a new database definition */
1567 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1571 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1572 "%s: line %d: Error in debug directive, "
1573 "\"debug <subsys> <level>\"\n", fname, lineno ));
1575 Debug( LDAP_DEBUG_ANY,
1576 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1582 level = atoi( cargv[2] );
1583 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1584 lutil_set_debug_level( cargv[1], level );
1585 /* specify an Object Identifier macro */
1586 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1587 rc = parse_oidm( fname, lineno, cargc, cargv );
1590 /* specify an objectclass */
1591 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1592 if ( *cargv[1] == '(' ) {
1594 p = strchr(saveline,'(');
1595 rc = parse_oc( fname, lineno, p, cargv );
1600 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1601 "%s: line %d: old objectclass format not supported\n",
1604 Debug( LDAP_DEBUG_ANY,
1605 "%s: line %d: old objectclass format not supported.\n",
1611 /* specify an attribute type */
1612 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1613 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1615 if ( *cargv[1] == '(' ) {
1617 p = strchr(saveline,'(');
1618 rc = parse_at( fname, lineno, p, cargv );
1623 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1624 "%s: line %d: old attribute type format not supported.\n",
1627 Debug( LDAP_DEBUG_ANY,
1628 "%s: line %d: old attribute type format not supported.\n",
1634 /* turn on/off schema checking */
1635 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1638 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1639 "%s: line %d: missing on|off in "
1640 "\"schemacheck <on|off>\" line.\n",
1643 Debug( LDAP_DEBUG_ANY,
1644 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1650 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1651 global_schemacheck = 0;
1653 global_schemacheck = 1;
1656 /* specify access control info */
1657 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1658 parse_acl( be, fname, lineno, cargc, cargv );
1660 /* debug level to log things to syslog */
1661 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1664 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1665 "%s: line %d: missing level in \"loglevel <level>\""
1666 " line.\n", fname, lineno ));
1668 Debug( LDAP_DEBUG_ANY,
1669 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1678 for( i=1; i < cargc; i++ ) {
1679 ldap_syslog += atoi( cargv[1] );
1682 /* list of replicas of the data in this backend (master only) */
1683 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1686 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1687 "%s: line %d: missing host in \"replica "
1688 " <host[:port]\" line\n", fname, lineno ));
1690 Debug( LDAP_DEBUG_ANY,
1691 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1699 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1700 "%s: line %d: replica line must appear inside "
1701 "a database definition (ignored).\n", fname, lineno ));
1703 Debug( LDAP_DEBUG_ANY,
1704 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1711 for ( i = 1; i < cargc; i++ ) {
1712 if ( strncasecmp( cargv[i], "host=", 5 )
1714 nr = add_replica_info( be,
1721 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1722 "%s: line %d: missing host in \"replica\" "
1723 "line (ignored)\n", fname, lineno ));
1725 Debug( LDAP_DEBUG_ANY,
1726 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1730 } else if ( nr == -1 ) {
1732 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1733 "%s: line %d: unable to add"
1739 Debug( LDAP_DEBUG_ANY,
1740 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1741 fname, lineno, cargv[i] + 5 );
1744 for ( i = 1; i < cargc; i++ ) {
1745 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1747 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1750 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1751 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1752 fname, lineno, cargv[i] + 7 ));
1754 Debug( LDAP_DEBUG_ANY,
1755 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1756 fname, lineno, cargv[i] + 7 );
1762 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1763 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1766 Debug( LDAP_DEBUG_ANY,
1767 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1777 /* dn of master entity allowed to write to replica */
1778 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1781 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1782 "%s: line %d: missing dn in \"updatedn <dn>\""
1783 " line.\n", fname, lineno ));
1785 Debug( LDAP_DEBUG_ANY,
1786 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1794 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1795 "%s: line %d: updatedn line must appear inside "
1796 "a database definition (ignored)\n",
1799 Debug( LDAP_DEBUG_ANY,
1800 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1805 be->be_update_ndn = ch_strdup( cargv[1] );
1806 if ( load_ucdata( NULL ) < 0 ) {
1809 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1811 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1812 "%s: line %d: updatedn DN is invalid.\n",
1815 Debug( LDAP_DEBUG_ANY,
1816 "%s: line %d: updatedn DN is invalid\n",
1824 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1827 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1828 "missing url in \"updateref <ldapurl>\" line.\n",
1831 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1832 "missing url in \"updateref <ldapurl>\" line\n",
1840 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1841 "updateref line must appear inside a database definition "
1842 "(ignored)\n", fname, lineno ));
1844 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1845 "updateref line must appear inside a database definition "
1846 "(ignored)\n", fname, lineno, 0 );
1850 } else if ( be->be_update_ndn == NULL ) {
1852 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1853 "updateref line must come after updatedn (ignored).\n",
1856 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1857 "updateref line must after updatedn (ignored)\n",
1863 if( validate_global_referral( cargv[1] ) ) {
1865 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1866 "invalid URL (%s) in \"updateref\" line.\n",
1867 fname, lineno, cargv[1] ));
1869 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1870 "invalid URL (%s) in \"updateref\" line.\n",
1871 fname, lineno, cargv[1] );
1876 vals[0]->bv_val = cargv[1];
1877 vals[0]->bv_len = strlen( vals[0]->bv_val );
1878 value_add( &be->be_update_refs, vals );
1880 /* replication log file to which changes are appended */
1881 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1884 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1885 "%s: line %d: missing filename in \"replogfile <filename>\""
1886 " line.\n", fname, lineno ));
1888 Debug( LDAP_DEBUG_ANY,
1889 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1896 be->be_replogfile = ch_strdup( cargv[1] );
1898 replogfile = ch_strdup( cargv[1] );
1901 /* file from which to read additional rootdse attrs */
1902 } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
1905 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1906 "missing filename in \"rootDSEfile <filename>\" line.\n",
1909 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1910 "missing filename in \"rootDSEfile <filename>\" line.\n",
1916 if( read_root_dse_file( cargv[1] ) ) {
1918 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1919 "could not read \"rootDSEfile <filename>\" line.\n",
1922 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1923 "could not read \"rootDSEfile <filename>\" line\n",
1929 /* maintain lastmodified{by,time} attributes */
1930 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1933 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1934 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1935 " line.\n", fname, lineno ));
1937 Debug( LDAP_DEBUG_ANY,
1938 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1944 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1946 be->be_lastmod = ON;
1948 global_lastmod = ON;
1951 be->be_lastmod = OFF;
1953 global_lastmod = OFF;
1956 /* set idle timeout value */
1957 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1961 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1962 "%s: line %d: missing timeout value in "
1963 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1965 Debug( LDAP_DEBUG_ANY,
1966 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1973 i = atoi( cargv[1] );
1977 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1978 "%s: line %d: timeout value (%d) invalid "
1979 "\"idletimeout <seconds>\" line.\n",
1980 fname, lineno, i ));
1982 Debug( LDAP_DEBUG_ANY,
1983 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1990 global_idletimeout = i;
1992 /* include another config file */
1993 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1996 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1997 "%s: line %d: missing filename in \"include "
1998 "<filename>\" line.\n", fname, lineno ));
2000 Debug( LDAP_DEBUG_ANY,
2001 "%s: line %d: missing filename in \"include <filename>\" line\n",
2007 savefname = ch_strdup( cargv[1] );
2008 savelineno = lineno;
2010 if ( read_config( savefname ) != 0 ) {
2015 lineno = savelineno - 1;
2017 /* location of kerberos srvtab file */
2018 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2021 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2022 "%s: line %d: missing filename in \"srvtab "
2023 "<filename>\" line.\n", fname, lineno ));
2025 Debug( LDAP_DEBUG_ANY,
2026 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2032 ldap_srvtab = ch_strdup( cargv[1] );
2034 #ifdef SLAPD_MODULES
2035 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2038 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2039 "%s: line %d: missing filename in \"moduleload "
2040 "<filename>\" line.\n", fname, lineno ));
2042 Debug( LDAP_DEBUG_ANY,
2043 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2047 exit( EXIT_FAILURE );
2049 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2051 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2052 "%s: line %d: failed to load or initialize module %s\n"<
2053 fname, lineno, cargv[1] ));
2055 Debug( LDAP_DEBUG_ANY,
2056 "%s: line %d: failed to load or initialize module %s\n",
2057 fname, lineno, cargv[1]);
2060 exit( EXIT_FAILURE );
2062 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2065 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2066 "%s: line %d: missing path in \"modulepath <path>\""
2067 " line\n", fname, lineno ));
2069 Debug( LDAP_DEBUG_ANY,
2070 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2074 exit( EXIT_FAILURE );
2076 if (module_path( cargv[1] )) {
2078 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2079 "%s: line %d: failed to set module search path to %s.\n",
2080 fname, lineno, cargv[1] ));
2082 Debug( LDAP_DEBUG_ANY,
2083 "%s: line %d: failed to set module search path to %s\n",
2084 fname, lineno, cargv[1]);
2087 exit( EXIT_FAILURE );
2090 #endif /*SLAPD_MODULES*/
2093 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2094 rc = ldap_pvt_tls_set_option( NULL,
2095 LDAP_OPT_X_TLS_RANDOM_FILE,
2100 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2101 rc = ldap_pvt_tls_set_option( NULL,
2102 LDAP_OPT_X_TLS_CIPHER_SUITE,
2107 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2108 rc = ldap_pvt_tls_set_option( NULL,
2109 LDAP_OPT_X_TLS_CERTFILE,
2114 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2115 rc = ldap_pvt_tls_set_option( NULL,
2116 LDAP_OPT_X_TLS_KEYFILE,
2121 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2122 rc = ldap_pvt_tls_set_option( NULL,
2123 LDAP_OPT_X_TLS_CACERTDIR,
2128 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2129 rc = ldap_pvt_tls_set_option( NULL,
2130 LDAP_OPT_X_TLS_CACERTFILE,
2134 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2136 rc = ldap_pvt_tls_set_option( NULL,
2137 LDAP_OPT_X_TLS_REQUIRE_CERT,
2144 /* pass anything else to the current backend info/db config routine */
2147 if ( bi->bi_config == 0 ) {
2149 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2150 "%s: line %d: unknown directive \"%s\" inside "
2151 "backend info definition (ignored).\n",
2152 fname, lineno, cargv[0] ));
2154 Debug( LDAP_DEBUG_ANY,
2155 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2156 fname, lineno, cargv[0] );
2160 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2166 } else if ( be != NULL ) {
2167 if ( be->be_config == 0 ) {
2169 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2170 "%s: line %d: uknown directive \"%s\" inside "
2171 "backend database definition (ignored).\n",
2172 fname, lineno, cargv[0] ));
2174 Debug( LDAP_DEBUG_ANY,
2175 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2176 fname, lineno, cargv[0] );
2180 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2188 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2189 "%s: line %d: unknown directive \"%s\" outside backend "
2190 "info and database definitions (ignored).\n",
2191 fname, lineno, cargv[0] ));
2193 Debug( LDAP_DEBUG_ANY,
2194 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2195 fname, lineno, cargv[0] );
2203 if ( load_ucdata( NULL ) < 0 ) {
2219 for ( token = strtok_quote( line, " \t" ); token != NULL;
2220 token = strtok_quote( NULL, " \t" ) ) {
2221 if ( *argcp == MAXARGS ) {
2223 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2224 "fp_parse_line: too many tokens (%d max).\n",
2227 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2233 argv[(*argcp)++] = token;
2235 argv[*argcp] = NULL;
2240 strtok_quote( char *line, char *sep )
2246 if ( line != NULL ) {
2249 while ( *next && strchr( sep, *next ) ) {
2253 if ( *next == '\0' ) {
2259 for ( inquote = 0; *next; ) {
2267 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2273 next + 1, strlen( next + 1 ) + 1 );
2274 next++; /* dont parse the escaped character */
2279 if ( strchr( sep, *next ) != NULL ) {
2292 static char buf[BUFSIZ];
2294 static int lmax, lcur;
2296 #define CATLINE( buf ) { \
2298 len = strlen( buf ); \
2299 while ( lcur + len + 1 > lmax ) { \
2301 line = (char *) ch_realloc( line, lmax ); \
2303 strcpy( line + lcur, buf ); \
2308 fp_getline( FILE *fp, int *lineno )
2316 /* hack attack - keeps us from having to keep a stack of bufs... */
2317 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2322 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2323 /* trim off \r\n or \n */
2324 if ( (p = strchr( buf, '\n' )) != NULL ) {
2325 if( p > buf && p[-1] == '\r' ) --p;
2328 if ( ! isspace( (unsigned char) buf[0] ) ) {
2332 /* change leading whitespace to a space */
2340 return( line[0] ? line : NULL );
2344 fp_getline_init( int *lineno )
2350 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2352 load_ucdata( char *path )
2354 static int loaded = 0;
2360 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2363 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2364 "load_ucdata: Error %d loading ucdata.\n", err ));
2366 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2379 ucdata_unload( UCDATA_ALL );
2381 if ( slapd_args_file )
2382 free ( slapd_args_file );
2383 if ( slapd_pid_file )
2384 free ( slapd_pid_file );