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] );
922 char *dn = ch_strdup( cargv[1] );
924 if ( load_ucdata( NULL ) < 0 ) {
927 if( dn_validate( dn ) == NULL ) {
929 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
930 "%s: line %d: suffix DN invalid\"%s\"\n",
931 fname, lineno, cargv[1] ));
933 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
934 "suffix DN invalid \"%s\"\n",
935 fname, lineno, cargv[1] );
940 } else if( *dn == '\0' && default_search_nbase != NULL ) {
942 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
943 "%s: line %d: suffix DN empty and default search "
944 "base provided \"%s\" (assuming okay).\n",
945 fname, lineno, default_search_base ));
947 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
948 "suffix DN empty and default "
949 "search base provided \"%s\" (assuming okay)\n",
950 fname, lineno, default_search_base );
954 charray_add( &be->be_suffix, dn );
955 #ifndef USE_LDAP_DN_PARSING
956 (void) ldap_pvt_str2upper( dn );
957 #else /* USE_LDAP_DN_PARSING */
958 if ( dn_normalize( dn ) == NULL ) {
960 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
962 "unable to normalize suffix "
965 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
966 "unable to normalize suffix "
967 "\"%s\"\n", dn, NULL, NULL );
971 #endif /* USE_LDAP_DN_PARSING */
972 ber_bvecadd( &be->be_nsuffix, ber_bvstr( dn ) );
975 /* set database suffixAlias */
976 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
980 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
981 "%s: line %d: missing alias and aliased_dn in "
982 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
985 Debug( LDAP_DEBUG_ANY,
986 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
991 } else if ( cargc < 3 ) {
993 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
994 "%s: line %d: missing aliased_dn in "
995 "\"suffixAlias <alias> <aliased_dn>\" line\n",
998 Debug( LDAP_DEBUG_ANY,
999 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
1004 } else if ( cargc > 3 ) {
1006 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1007 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1010 Debug( LDAP_DEBUG_ANY,
1011 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1019 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1020 "%s: line %d: suffixAlias line must appear inside a "
1021 "database definition (ignored).\n", fname, lineno ));
1023 Debug( LDAP_DEBUG_ANY,
1024 "%s: line %d: suffixAlias line"
1025 " must appear inside a database definition (ignored)\n",
1029 } else if ( (tmp_be = select_backend( cargv[1], 0, 0 )) != NULL ) {
1031 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1032 "%s: line %d: suffixAlias served by a preceeding "
1033 "backend \"%s\" (ignored).\n", fname, lineno,
1034 tmp_be->be_suffix[0] ));
1036 Debug( LDAP_DEBUG_ANY,
1037 "%s: line %d: suffixAlias served by"
1038 " a preceeding backend \"%s\" (ignored)\n",
1039 fname, lineno, tmp_be->be_suffix[0] );
1043 } else if ( (tmp_be = select_backend( cargv[2], 0, 0 )) != NULL ) {
1045 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1046 "%s: line %d: suffixAlias derefs to a different backend "
1047 "a preceeding backend \"%s\" (ignored)\n",
1048 fname, lineno, tmp_be->be_suffix[0] ));
1050 Debug( LDAP_DEBUG_ANY,
1051 "%s: line %d: suffixAlias derefs to differnet backend"
1052 " a preceeding backend \"%s\" (ignored)\n",
1053 fname, lineno, tmp_be->be_suffix[0] );
1058 char *alias, *aliased_dn;
1060 if ( load_ucdata( NULL ) < 0 ) {
1064 alias = ch_strdup( cargv[1] );
1065 (void) dn_normalize( alias );
1067 aliased_dn = ch_strdup( cargv[2] );
1068 (void) dn_normalize( aliased_dn );
1070 ber_bvecadd( &be->be_suffixAlias,
1071 ber_bvstr( alias ) );
1072 ber_bvecadd( &be->be_suffixAlias,
1073 ber_bvstr( aliased_dn ) );
1076 /* set max deref depth */
1077 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1081 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1082 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1083 " line\n", fname, lineno ));
1085 Debug( LDAP_DEBUG_ANY,
1086 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1094 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1095 "%s: line %d: depth line must appear inside a database "
1096 "definition (ignored)\n", fname, lineno ));
1098 Debug( LDAP_DEBUG_ANY,
1099 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1103 } else if ((i = atoi(cargv[1])) < 0) {
1105 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1106 "%s: line %d: depth must be positive (ignored).\n",
1109 Debug( LDAP_DEBUG_ANY,
1110 "%s: line %d: depth must be positive (ignored)\n",
1116 be->be_max_deref_depth = i;
1120 /* set magic "root" dn for this database */
1121 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1124 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1125 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1128 Debug( LDAP_DEBUG_ANY,
1129 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1137 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1138 "%s: line %d: rootdn line must appear inside a database "
1139 "definition (ignored).\n", fname, lineno ));
1141 Debug( LDAP_DEBUG_ANY,
1142 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1147 be->be_root_dn = ch_strdup( cargv[1] );
1148 be->be_root_ndn = ch_strdup( cargv[1] );
1150 if ( load_ucdata( NULL ) < 0 ) {
1153 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1154 free( be->be_root_dn );
1155 free( be->be_root_ndn );
1157 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1158 "%s: line %d: rootdn DN is invalid.\n",
1161 Debug( LDAP_DEBUG_ANY,
1162 "%s: line %d: rootdn DN is invalid\n",
1170 /* set super-secret magic database password */
1171 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1174 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1175 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1176 " line\n", fname, lineno ));
1178 Debug( LDAP_DEBUG_ANY,
1179 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1187 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1188 "%s: line %d: rootpw line must appear inside a database "
1189 "definition (ignored)\n", fname, lineno ));
1191 Debug( LDAP_DEBUG_ANY,
1192 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1197 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1198 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1201 /* make this database read-only */
1202 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1205 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1206 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1209 Debug( LDAP_DEBUG_ANY,
1210 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1217 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1218 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1220 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1223 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1224 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1226 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1231 /* allow these features */
1232 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1233 strcasecmp( cargv[0], "allow" ) == 0 )
1239 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1240 "%s: line %d: allow line must appear prior to "
1241 "database definitions.\n", fname, lineno ));
1243 Debug( LDAP_DEBUG_ANY,
1244 "%s: line %d: allow line must appear prior to database definitions\n",
1252 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1253 "%s: line %d: missing feature(s) in \"allow <features>\""
1254 " line\n", fname, lineno ));
1256 Debug( LDAP_DEBUG_ANY,
1257 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1266 for( i=1; i < cargc; i++ ) {
1267 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1268 allows |= SLAP_ALLOW_TLS_2_ANON;
1270 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1272 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1273 "%s: line %d: unknown feature %s in "
1274 "\"allow <features>\" line.\n",
1275 fname, lineno, cargv[1] ));
1277 Debug( LDAP_DEBUG_ANY,
1278 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1279 fname, lineno, cargv[i] );
1286 global_allows = allows;
1288 /* disallow these features */
1289 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1290 strcasecmp( cargv[0], "disallow" ) == 0 )
1292 slap_mask_t disallows;
1296 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1297 "%s: line %d: disallow line must appear prior to "
1298 "database definitions.\n", fname, lineno ));
1300 Debug( LDAP_DEBUG_ANY,
1301 "%s: line %d: disallow line must appear prior to database definitions\n",
1309 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1310 "%s: line %d: missing feature(s) in \"disallow <features>\""
1311 " line.\n", fname, lineno ));
1313 Debug( LDAP_DEBUG_ANY,
1314 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1323 for( i=1; i < cargc; i++ ) {
1324 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1325 disallows |= SLAP_DISALLOW_BIND_V2;
1327 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1328 disallows |= SLAP_DISALLOW_BIND_ANON;
1330 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1331 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1333 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1334 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1336 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1337 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1339 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1340 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1342 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1343 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1345 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1347 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1348 "%s: line %d: unknown feature %s in "
1349 "\"disallow <features>\" line.\n",
1350 fname, lineno, cargv[i] ));
1352 Debug( LDAP_DEBUG_ANY,
1353 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1354 fname, lineno, cargv[i] );
1361 global_disallows = disallows;
1363 /* require these features */
1364 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1365 strcasecmp( cargv[0], "require" ) == 0 )
1367 slap_mask_t requires;
1371 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1372 "%s: line %d: missing feature(s) in "
1373 "\"require <features>\" line.\n", fname, lineno ));
1375 Debug( LDAP_DEBUG_ANY,
1376 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1385 for( i=1; i < cargc; i++ ) {
1386 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1387 requires |= SLAP_REQUIRE_BIND;
1389 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1390 requires |= SLAP_REQUIRE_LDAP_V3;
1392 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1393 requires |= SLAP_REQUIRE_AUTHC;
1395 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1396 requires |= SLAP_REQUIRE_SASL;
1398 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1399 requires |= SLAP_REQUIRE_STRONG;
1401 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1403 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1404 "%s: line %d: unknown feature %s in "
1405 "\"require <features>\" line.\n",
1408 Debug( LDAP_DEBUG_ANY,
1409 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1410 fname, lineno, cargv[i] );
1418 global_requires = requires;
1420 be->be_requires = requires;
1423 /* required security factors */
1424 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1425 slap_ssf_set_t *set;
1429 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1430 "%s: line %d: missing factor(s) in \"security <factors>\""
1431 " line.\n", fname, lineno ));
1433 Debug( LDAP_DEBUG_ANY,
1434 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1442 set = &global_ssf_set;
1444 set = &be->be_ssf_set;
1447 for( i=1; i < cargc; i++ ) {
1448 if( strncasecmp( cargv[i], "ssf=",
1449 sizeof("ssf") ) == 0 )
1452 atoi( &cargv[i][sizeof("ssf")] );
1454 } else if( strncasecmp( cargv[i], "transport=",
1455 sizeof("transport") ) == 0 )
1457 set->sss_transport =
1458 atoi( &cargv[i][sizeof("transport")] );
1460 } else if( strncasecmp( cargv[i], "tls=",
1461 sizeof("tls") ) == 0 )
1464 atoi( &cargv[i][sizeof("tls")] );
1466 } else if( strncasecmp( cargv[i], "sasl=",
1467 sizeof("sasl") ) == 0 )
1470 atoi( &cargv[i][sizeof("sasl")] );
1472 } else if( strncasecmp( cargv[i], "update_ssf=",
1473 sizeof("update_ssf") ) == 0 )
1475 set->sss_update_ssf =
1476 atoi( &cargv[i][sizeof("update_ssf")] );
1478 } else if( strncasecmp( cargv[i], "update_transport=",
1479 sizeof("update_transport") ) == 0 )
1481 set->sss_update_transport =
1482 atoi( &cargv[i][sizeof("update_transport")] );
1484 } else if( strncasecmp( cargv[i], "update_tls=",
1485 sizeof("update_tls") ) == 0 )
1487 set->sss_update_tls =
1488 atoi( &cargv[i][sizeof("update_tls")] );
1490 } else if( strncasecmp( cargv[i], "update_sasl=",
1491 sizeof("update_sasl") ) == 0 )
1493 set->sss_update_sasl =
1494 atoi( &cargv[i][sizeof("update_sasl")] );
1498 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1499 "%s: line %d: unknown factor %S in "
1500 "\"security <factors>\" line.\n",
1501 fname, lineno, cargv[1] ));
1503 Debug( LDAP_DEBUG_ANY,
1504 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1505 fname, lineno, cargv[i] );
1511 /* where to send clients when we don't hold it */
1512 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1515 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1516 "%s: line %d: missing URL in \"referral <URL>\""
1517 " line.\n", fname, lineno ));
1519 Debug( LDAP_DEBUG_ANY,
1520 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1527 if( validate_global_referral( cargv[1] ) ) {
1529 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1530 "invalid URL (%s) in \"referral\" line.\n",
1531 fname, lineno, cargv[1] ));
1533 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1534 "invalid URL (%s) in \"referral\" line.\n",
1535 fname, lineno, cargv[1] );
1540 vals[0]->bv_val = cargv[1];
1541 vals[0]->bv_len = strlen( vals[0]->bv_val );
1542 value_add( &default_referral, vals );
1545 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1549 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1550 "%s: line %d: Error in logfile directive, "
1551 "\"logfile <filename>\"\n", fname, lineno ));
1553 Debug( LDAP_DEBUG_ANY,
1554 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1560 logfile = fopen( cargv[1], "w" );
1561 if ( logfile != NULL ) lutil_debug_file( logfile );
1564 /* start of a new database definition */
1565 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1569 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1570 "%s: line %d: Error in debug directive, "
1571 "\"debug <subsys> <level>\"\n", fname, lineno ));
1573 Debug( LDAP_DEBUG_ANY,
1574 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1580 level = atoi( cargv[2] );
1581 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1582 lutil_set_debug_level( cargv[1], level );
1583 /* specify an Object Identifier macro */
1584 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1585 rc = parse_oidm( fname, lineno, cargc, cargv );
1588 /* specify an objectclass */
1589 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1590 if ( *cargv[1] == '(' ) {
1592 p = strchr(saveline,'(');
1593 rc = parse_oc( fname, lineno, p, cargv );
1598 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1599 "%s: line %d: old objectclass format not supported\n",
1602 Debug( LDAP_DEBUG_ANY,
1603 "%s: line %d: old objectclass format not supported.\n",
1609 /* specify an attribute type */
1610 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1611 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1613 if ( *cargv[1] == '(' ) {
1615 p = strchr(saveline,'(');
1616 rc = parse_at( fname, lineno, p, cargv );
1621 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1622 "%s: line %d: old attribute type format not supported.\n",
1625 Debug( LDAP_DEBUG_ANY,
1626 "%s: line %d: old attribute type format not supported.\n",
1632 /* turn on/off schema checking */
1633 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1636 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1637 "%s: line %d: missing on|off in "
1638 "\"schemacheck <on|off>\" line.\n",
1641 Debug( LDAP_DEBUG_ANY,
1642 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1648 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1649 global_schemacheck = 0;
1651 global_schemacheck = 1;
1654 /* specify access control info */
1655 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1656 parse_acl( be, fname, lineno, cargc, cargv );
1658 /* debug level to log things to syslog */
1659 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1662 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1663 "%s: line %d: missing level in \"loglevel <level>\""
1664 " line.\n", fname, lineno ));
1666 Debug( LDAP_DEBUG_ANY,
1667 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1676 for( i=1; i < cargc; i++ ) {
1677 ldap_syslog += atoi( cargv[1] );
1680 /* list of replicas of the data in this backend (master only) */
1681 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1684 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1685 "%s: line %d: missing host in \"replica "
1686 " <host[:port]\" line\n", fname, lineno ));
1688 Debug( LDAP_DEBUG_ANY,
1689 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1697 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1698 "%s: line %d: replica line must appear inside "
1699 "a database definition (ignored).\n", fname, lineno ));
1701 Debug( LDAP_DEBUG_ANY,
1702 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1709 for ( i = 1; i < cargc; i++ ) {
1710 if ( strncasecmp( cargv[i], "host=", 5 )
1712 nr = add_replica_info( be,
1719 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1720 "%s: line %d: missing host in \"replica\" "
1721 "line (ignored)\n", fname, lineno ));
1723 Debug( LDAP_DEBUG_ANY,
1724 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1728 } else if ( nr == -1 ) {
1730 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1731 "%s: line %d: unable to add"
1737 Debug( LDAP_DEBUG_ANY,
1738 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1739 fname, lineno, cargv[i] + 5 );
1742 for ( i = 1; i < cargc; i++ ) {
1743 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1745 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1748 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1749 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1750 fname, lineno, cargv[i] + 7 ));
1752 Debug( LDAP_DEBUG_ANY,
1753 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1754 fname, lineno, cargv[i] + 7 );
1760 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1761 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1764 Debug( LDAP_DEBUG_ANY,
1765 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1775 /* dn of master entity allowed to write to replica */
1776 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1779 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1780 "%s: line %d: missing dn in \"updatedn <dn>\""
1781 " line.\n", fname, lineno ));
1783 Debug( LDAP_DEBUG_ANY,
1784 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1792 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1793 "%s: line %d: updatedn line must appear inside "
1794 "a database definition (ignored)\n",
1797 Debug( LDAP_DEBUG_ANY,
1798 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1803 be->be_update_ndn = ch_strdup( cargv[1] );
1804 if ( load_ucdata( NULL ) < 0 ) {
1807 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1809 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1810 "%s: line %d: updatedn DN is invalid.\n",
1813 Debug( LDAP_DEBUG_ANY,
1814 "%s: line %d: updatedn DN is invalid\n",
1822 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1825 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1826 "missing url in \"updateref <ldapurl>\" line.\n",
1829 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1830 "missing url in \"updateref <ldapurl>\" line\n",
1838 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1839 "updateref line must appear inside a database definition "
1840 "(ignored)\n", fname, lineno ));
1842 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1843 "updateref line must appear inside a database definition "
1844 "(ignored)\n", fname, lineno, 0 );
1848 } else if ( be->be_update_ndn == NULL ) {
1850 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1851 "updateref line must come after updatedn (ignored).\n",
1854 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1855 "updateref line must after updatedn (ignored)\n",
1861 if( validate_global_referral( cargv[1] ) ) {
1863 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1864 "invalid URL (%s) in \"updateref\" line.\n",
1865 fname, lineno, cargv[1] ));
1867 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1868 "invalid URL (%s) in \"updateref\" line.\n",
1869 fname, lineno, cargv[1] );
1874 vals[0]->bv_val = cargv[1];
1875 vals[0]->bv_len = strlen( vals[0]->bv_val );
1876 value_add( &be->be_update_refs, vals );
1878 /* replication log file to which changes are appended */
1879 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1882 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1883 "%s: line %d: missing filename in \"replogfile <filename>\""
1884 " line.\n", fname, lineno ));
1886 Debug( LDAP_DEBUG_ANY,
1887 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1894 be->be_replogfile = ch_strdup( cargv[1] );
1896 replogfile = ch_strdup( cargv[1] );
1899 /* file from which to read additional rootdse attrs */
1900 } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
1903 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1904 "missing filename in \"rootDSEfile <filename>\" line.\n",
1907 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1908 "missing filename in \"rootDSEfile <filename>\" line.\n",
1914 if( read_root_dse_file( cargv[1] ) ) {
1916 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1917 "could not read \"rootDSEfile <filename>\" line.\n",
1920 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1921 "could not read \"rootDSEfile <filename>\" line\n",
1927 /* maintain lastmodified{by,time} attributes */
1928 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1931 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1932 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1933 " line.\n", fname, lineno ));
1935 Debug( LDAP_DEBUG_ANY,
1936 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1942 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1944 be->be_lastmod = ON;
1946 global_lastmod = ON;
1949 be->be_lastmod = OFF;
1951 global_lastmod = OFF;
1954 /* set idle timeout value */
1955 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1959 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1960 "%s: line %d: missing timeout value in "
1961 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1963 Debug( LDAP_DEBUG_ANY,
1964 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1971 i = atoi( cargv[1] );
1975 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1976 "%s: line %d: timeout value (%d) invalid "
1977 "\"idletimeout <seconds>\" line.\n",
1978 fname, lineno, i ));
1980 Debug( LDAP_DEBUG_ANY,
1981 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1988 global_idletimeout = i;
1990 /* include another config file */
1991 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1994 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1995 "%s: line %d: missing filename in \"include "
1996 "<filename>\" line.\n", fname, lineno ));
1998 Debug( LDAP_DEBUG_ANY,
1999 "%s: line %d: missing filename in \"include <filename>\" line\n",
2005 savefname = ch_strdup( cargv[1] );
2006 savelineno = lineno;
2008 if ( read_config( savefname ) != 0 ) {
2013 lineno = savelineno - 1;
2015 /* location of kerberos srvtab file */
2016 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2019 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2020 "%s: line %d: missing filename in \"srvtab "
2021 "<filename>\" line.\n", fname, lineno ));
2023 Debug( LDAP_DEBUG_ANY,
2024 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2030 ldap_srvtab = ch_strdup( cargv[1] );
2032 #ifdef SLAPD_MODULES
2033 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2036 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2037 "%s: line %d: missing filename in \"moduleload "
2038 "<filename>\" line.\n", fname, lineno ));
2040 Debug( LDAP_DEBUG_ANY,
2041 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2045 exit( EXIT_FAILURE );
2047 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2049 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2050 "%s: line %d: failed to load or initialize module %s\n"<
2051 fname, lineno, cargv[1] ));
2053 Debug( LDAP_DEBUG_ANY,
2054 "%s: line %d: failed to load or initialize module %s\n",
2055 fname, lineno, cargv[1]);
2058 exit( EXIT_FAILURE );
2060 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2063 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2064 "%s: line %d: missing path in \"modulepath <path>\""
2065 " line\n", fname, lineno ));
2067 Debug( LDAP_DEBUG_ANY,
2068 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2072 exit( EXIT_FAILURE );
2074 if (module_path( cargv[1] )) {
2076 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2077 "%s: line %d: failed to set module search path to %s.\n",
2078 fname, lineno, cargv[1] ));
2080 Debug( LDAP_DEBUG_ANY,
2081 "%s: line %d: failed to set module search path to %s\n",
2082 fname, lineno, cargv[1]);
2085 exit( EXIT_FAILURE );
2088 #endif /*SLAPD_MODULES*/
2091 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2092 rc = ldap_pvt_tls_set_option( NULL,
2093 LDAP_OPT_X_TLS_RANDOM_FILE,
2098 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2099 rc = ldap_pvt_tls_set_option( NULL,
2100 LDAP_OPT_X_TLS_CIPHER_SUITE,
2105 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2106 rc = ldap_pvt_tls_set_option( NULL,
2107 LDAP_OPT_X_TLS_CERTFILE,
2112 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2113 rc = ldap_pvt_tls_set_option( NULL,
2114 LDAP_OPT_X_TLS_KEYFILE,
2119 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2120 rc = ldap_pvt_tls_set_option( NULL,
2121 LDAP_OPT_X_TLS_CACERTDIR,
2126 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2127 rc = ldap_pvt_tls_set_option( NULL,
2128 LDAP_OPT_X_TLS_CACERTFILE,
2132 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2134 rc = ldap_pvt_tls_set_option( NULL,
2135 LDAP_OPT_X_TLS_REQUIRE_CERT,
2142 /* pass anything else to the current backend info/db config routine */
2145 if ( bi->bi_config == 0 ) {
2147 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2148 "%s: line %d: unknown directive \"%s\" inside "
2149 "backend info definition (ignored).\n",
2150 fname, lineno, cargv[0] ));
2152 Debug( LDAP_DEBUG_ANY,
2153 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2154 fname, lineno, cargv[0] );
2158 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2164 } else if ( be != NULL ) {
2165 if ( be->be_config == 0 ) {
2167 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2168 "%s: line %d: uknown directive \"%s\" inside "
2169 "backend database definition (ignored).\n",
2170 fname, lineno, cargv[0] ));
2172 Debug( LDAP_DEBUG_ANY,
2173 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2174 fname, lineno, cargv[0] );
2178 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2186 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2187 "%s: line %d: unknown directive \"%s\" outside backend "
2188 "info and database definitions (ignored).\n",
2189 fname, lineno, cargv[0] ));
2191 Debug( LDAP_DEBUG_ANY,
2192 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2193 fname, lineno, cargv[0] );
2201 if ( load_ucdata( NULL ) < 0 ) {
2217 for ( token = strtok_quote( line, " \t" ); token != NULL;
2218 token = strtok_quote( NULL, " \t" ) ) {
2219 if ( *argcp == MAXARGS ) {
2221 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2222 "fp_parse_line: too many tokens (%d max).\n",
2225 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2231 argv[(*argcp)++] = token;
2233 argv[*argcp] = NULL;
2238 strtok_quote( char *line, char *sep )
2244 if ( line != NULL ) {
2247 while ( *next && strchr( sep, *next ) ) {
2251 if ( *next == '\0' ) {
2257 for ( inquote = 0; *next; ) {
2265 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2271 next + 1, strlen( next + 1 ) + 1 );
2272 next++; /* dont parse the escaped character */
2277 if ( strchr( sep, *next ) != NULL ) {
2290 static char buf[BUFSIZ];
2292 static int lmax, lcur;
2294 #define CATLINE( buf ) { \
2296 len = strlen( buf ); \
2297 while ( lcur + len + 1 > lmax ) { \
2299 line = (char *) ch_realloc( line, lmax ); \
2301 strcpy( line + lcur, buf ); \
2306 fp_getline( FILE *fp, int *lineno )
2314 /* hack attack - keeps us from having to keep a stack of bufs... */
2315 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2320 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2321 /* trim off \r\n or \n */
2322 if ( (p = strchr( buf, '\n' )) != NULL ) {
2323 if( p > buf && p[-1] == '\r' ) --p;
2326 if ( ! isspace( (unsigned char) buf[0] ) ) {
2330 /* change leading whitespace to a space */
2338 return( line[0] ? line : NULL );
2342 fp_getline_init( int *lineno )
2348 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2350 load_ucdata( char *path )
2352 static int loaded = 0;
2358 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2361 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2362 "load_ucdata: Error %d loading ucdata.\n", err ));
2364 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",