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 alias = ch_strdup( cargv[1] );
1061 if ( load_ucdata( NULL ) < 0 ) {
1064 (void) dn_normalize( alias );
1066 aliased_dn = ch_strdup( cargv[2] );
1067 (void) dn_normalize( aliased_dn );
1069 ber_bvecadd( &be->be_suffixAlias,
1070 ber_bvstr( alias ) );
1071 ber_bvecadd( &be->be_suffixAlias,
1072 ber_bvstr( aliased_dn ) );
1075 /* set max deref depth */
1076 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1080 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1081 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1082 " line\n", fname, lineno ));
1084 Debug( LDAP_DEBUG_ANY,
1085 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1093 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1094 "%s: line %d: depth line must appear inside a database "
1095 "definition (ignored)\n", fname, lineno ));
1097 Debug( LDAP_DEBUG_ANY,
1098 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1102 } else if ((i = atoi(cargv[1])) < 0) {
1104 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1105 "%s: line %d: depth must be positive (ignored).\n",
1108 Debug( LDAP_DEBUG_ANY,
1109 "%s: line %d: depth must be positive (ignored)\n",
1115 be->be_max_deref_depth = i;
1119 /* set magic "root" dn for this database */
1120 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1123 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1124 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1127 Debug( LDAP_DEBUG_ANY,
1128 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1136 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1137 "%s: line %d: rootdn line must appear inside a database "
1138 "definition (ignored).\n", fname, lineno ));
1140 Debug( LDAP_DEBUG_ANY,
1141 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1146 be->be_root_dn = ch_strdup( cargv[1] );
1147 be->be_root_ndn = ch_strdup( cargv[1] );
1149 if ( load_ucdata( NULL ) < 0 ) {
1152 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1153 free( be->be_root_dn );
1154 free( be->be_root_ndn );
1156 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1157 "%s: line %d: rootdn DN is invalid.\n",
1160 Debug( LDAP_DEBUG_ANY,
1161 "%s: line %d: rootdn DN is invalid\n",
1169 /* set super-secret magic database password */
1170 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1173 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1174 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1175 " line\n", fname, lineno ));
1177 Debug( LDAP_DEBUG_ANY,
1178 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1186 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1187 "%s: line %d: rootpw line must appear inside a database "
1188 "definition (ignored)\n", fname, lineno ));
1190 Debug( LDAP_DEBUG_ANY,
1191 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1196 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1197 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1200 /* make this database read-only */
1201 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1204 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1205 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1208 Debug( LDAP_DEBUG_ANY,
1209 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1216 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1217 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1219 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1222 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1223 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1225 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1230 /* allow these features */
1231 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1232 strcasecmp( cargv[0], "allow" ) == 0 )
1238 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1239 "%s: line %d: allow line must appear prior to "
1240 "database definitions.\n", fname, lineno ));
1242 Debug( LDAP_DEBUG_ANY,
1243 "%s: line %d: allow line must appear prior to database definitions\n",
1251 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1252 "%s: line %d: missing feature(s) in \"allow <features>\""
1253 " line\n", fname, lineno ));
1255 Debug( LDAP_DEBUG_ANY,
1256 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1265 for( i=1; i < cargc; i++ ) {
1266 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1267 allows |= SLAP_ALLOW_TLS_2_ANON;
1269 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1271 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1272 "%s: line %d: unknown feature %s in "
1273 "\"allow <features>\" line.\n",
1274 fname, lineno, cargv[1] ));
1276 Debug( LDAP_DEBUG_ANY,
1277 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1278 fname, lineno, cargv[i] );
1285 global_allows = allows;
1287 /* disallow these features */
1288 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1289 strcasecmp( cargv[0], "disallow" ) == 0 )
1291 slap_mask_t disallows;
1295 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1296 "%s: line %d: disallow line must appear prior to "
1297 "database definitions.\n", fname, lineno ));
1299 Debug( LDAP_DEBUG_ANY,
1300 "%s: line %d: disallow line must appear prior to database definitions\n",
1308 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1309 "%s: line %d: missing feature(s) in \"disallow <features>\""
1310 " line.\n", fname, lineno ));
1312 Debug( LDAP_DEBUG_ANY,
1313 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1322 for( i=1; i < cargc; i++ ) {
1323 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1324 disallows |= SLAP_DISALLOW_BIND_V2;
1326 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1327 disallows |= SLAP_DISALLOW_BIND_ANON;
1329 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1330 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1332 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1333 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1335 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1336 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1338 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1339 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1341 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1342 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1344 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1346 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1347 "%s: line %d: unknown feature %s in "
1348 "\"disallow <features>\" line.\n",
1349 fname, lineno, cargv[i] ));
1351 Debug( LDAP_DEBUG_ANY,
1352 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1353 fname, lineno, cargv[i] );
1360 global_disallows = disallows;
1362 /* require these features */
1363 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1364 strcasecmp( cargv[0], "require" ) == 0 )
1366 slap_mask_t requires;
1370 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1371 "%s: line %d: missing feature(s) in "
1372 "\"require <features>\" line.\n", fname, lineno ));
1374 Debug( LDAP_DEBUG_ANY,
1375 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1384 for( i=1; i < cargc; i++ ) {
1385 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1386 requires |= SLAP_REQUIRE_BIND;
1388 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1389 requires |= SLAP_REQUIRE_LDAP_V3;
1391 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1392 requires |= SLAP_REQUIRE_AUTHC;
1394 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1395 requires |= SLAP_REQUIRE_SASL;
1397 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1398 requires |= SLAP_REQUIRE_STRONG;
1400 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1402 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1403 "%s: line %d: unknown feature %s in "
1404 "\"require <features>\" line.\n",
1407 Debug( LDAP_DEBUG_ANY,
1408 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1409 fname, lineno, cargv[i] );
1417 global_requires = requires;
1419 be->be_requires = requires;
1422 /* required security factors */
1423 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1424 slap_ssf_set_t *set;
1428 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1429 "%s: line %d: missing factor(s) in \"security <factors>\""
1430 " line.\n", fname, lineno ));
1432 Debug( LDAP_DEBUG_ANY,
1433 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1441 set = &global_ssf_set;
1443 set = &be->be_ssf_set;
1446 for( i=1; i < cargc; i++ ) {
1447 if( strncasecmp( cargv[i], "ssf=",
1448 sizeof("ssf") ) == 0 )
1451 atoi( &cargv[i][sizeof("ssf")] );
1453 } else if( strncasecmp( cargv[i], "transport=",
1454 sizeof("transport") ) == 0 )
1456 set->sss_transport =
1457 atoi( &cargv[i][sizeof("transport")] );
1459 } else if( strncasecmp( cargv[i], "tls=",
1460 sizeof("tls") ) == 0 )
1463 atoi( &cargv[i][sizeof("tls")] );
1465 } else if( strncasecmp( cargv[i], "sasl=",
1466 sizeof("sasl") ) == 0 )
1469 atoi( &cargv[i][sizeof("sasl")] );
1471 } else if( strncasecmp( cargv[i], "update_ssf=",
1472 sizeof("update_ssf") ) == 0 )
1474 set->sss_update_ssf =
1475 atoi( &cargv[i][sizeof("update_ssf")] );
1477 } else if( strncasecmp( cargv[i], "update_transport=",
1478 sizeof("update_transport") ) == 0 )
1480 set->sss_update_transport =
1481 atoi( &cargv[i][sizeof("update_transport")] );
1483 } else if( strncasecmp( cargv[i], "update_tls=",
1484 sizeof("update_tls") ) == 0 )
1486 set->sss_update_tls =
1487 atoi( &cargv[i][sizeof("update_tls")] );
1489 } else if( strncasecmp( cargv[i], "update_sasl=",
1490 sizeof("update_sasl") ) == 0 )
1492 set->sss_update_sasl =
1493 atoi( &cargv[i][sizeof("update_sasl")] );
1497 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1498 "%s: line %d: unknown factor %S in "
1499 "\"security <factors>\" line.\n",
1500 fname, lineno, cargv[1] ));
1502 Debug( LDAP_DEBUG_ANY,
1503 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1504 fname, lineno, cargv[i] );
1510 /* where to send clients when we don't hold it */
1511 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1514 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1515 "%s: line %d: missing URL in \"referral <URL>\""
1516 " line.\n", fname, lineno ));
1518 Debug( LDAP_DEBUG_ANY,
1519 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1526 if( validate_global_referral( cargv[1] ) ) {
1528 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1529 "invalid URL (%s) in \"referral\" line.\n",
1530 fname, lineno, cargv[1] ));
1532 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1533 "invalid URL (%s) in \"referral\" line.\n",
1534 fname, lineno, cargv[1] );
1539 vals[0]->bv_val = cargv[1];
1540 vals[0]->bv_len = strlen( vals[0]->bv_val );
1541 value_add( &default_referral, vals );
1544 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1548 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1549 "%s: line %d: Error in logfile directive, "
1550 "\"logfile <filename>\"\n", fname, lineno ));
1552 Debug( LDAP_DEBUG_ANY,
1553 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1559 logfile = fopen( cargv[1], "w" );
1560 if ( logfile != NULL ) lutil_debug_file( logfile );
1563 /* start of a new database definition */
1564 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1568 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1569 "%s: line %d: Error in debug directive, "
1570 "\"debug <subsys> <level>\"\n", fname, lineno ));
1572 Debug( LDAP_DEBUG_ANY,
1573 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1579 level = atoi( cargv[2] );
1580 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1581 lutil_set_debug_level( cargv[1], level );
1582 /* specify an Object Identifier macro */
1583 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1584 rc = parse_oidm( fname, lineno, cargc, cargv );
1587 /* specify an objectclass */
1588 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1589 if ( *cargv[1] == '(' ) {
1591 p = strchr(saveline,'(');
1592 rc = parse_oc( fname, lineno, p, cargv );
1597 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1598 "%s: line %d: old objectclass format not supported\n",
1601 Debug( LDAP_DEBUG_ANY,
1602 "%s: line %d: old objectclass format not supported.\n",
1608 /* specify an attribute type */
1609 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1610 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1612 if ( *cargv[1] == '(' ) {
1614 p = strchr(saveline,'(');
1615 rc = parse_at( fname, lineno, p, cargv );
1620 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1621 "%s: line %d: old attribute type format not supported.\n",
1624 Debug( LDAP_DEBUG_ANY,
1625 "%s: line %d: old attribute type format not supported.\n",
1631 /* turn on/off schema checking */
1632 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1635 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1636 "%s: line %d: missing on|off in "
1637 "\"schemacheck <on|off>\" line.\n",
1640 Debug( LDAP_DEBUG_ANY,
1641 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1647 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1648 global_schemacheck = 0;
1650 global_schemacheck = 1;
1653 /* specify access control info */
1654 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1655 parse_acl( be, fname, lineno, cargc, cargv );
1657 /* debug level to log things to syslog */
1658 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1661 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1662 "%s: line %d: missing level in \"loglevel <level>\""
1663 " line.\n", fname, lineno ));
1665 Debug( LDAP_DEBUG_ANY,
1666 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1675 for( i=1; i < cargc; i++ ) {
1676 ldap_syslog += atoi( cargv[1] );
1679 /* list of replicas of the data in this backend (master only) */
1680 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1683 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1684 "%s: line %d: missing host in \"replica "
1685 " <host[:port]\" line\n", fname, lineno ));
1687 Debug( LDAP_DEBUG_ANY,
1688 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1696 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1697 "%s: line %d: replica line must appear inside "
1698 "a database definition (ignored).\n", fname, lineno ));
1700 Debug( LDAP_DEBUG_ANY,
1701 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1708 for ( i = 1; i < cargc; i++ ) {
1709 if ( strncasecmp( cargv[i], "host=", 5 )
1711 nr = add_replica_info( be,
1718 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1719 "%s: line %d: missing host in \"replica\" "
1720 "line (ignored)\n", fname, lineno ));
1722 Debug( LDAP_DEBUG_ANY,
1723 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1727 } else if ( nr == -1 ) {
1729 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1730 "%s: line %d: unable to add"
1736 Debug( LDAP_DEBUG_ANY,
1737 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1738 fname, lineno, cargv[i] + 5 );
1741 for ( i = 1; i < cargc; i++ ) {
1742 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1744 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1747 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1748 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1749 fname, lineno, cargv[i] + 7 ));
1751 Debug( LDAP_DEBUG_ANY,
1752 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1753 fname, lineno, cargv[i] + 7 );
1759 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1760 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1763 Debug( LDAP_DEBUG_ANY,
1764 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1774 /* dn of master entity allowed to write to replica */
1775 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1778 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1779 "%s: line %d: missing dn in \"updatedn <dn>\""
1780 " line.\n", fname, lineno ));
1782 Debug( LDAP_DEBUG_ANY,
1783 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1791 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1792 "%s: line %d: updatedn line must appear inside "
1793 "a database definition (ignored)\n",
1796 Debug( LDAP_DEBUG_ANY,
1797 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1802 be->be_update_ndn = ch_strdup( cargv[1] );
1803 if ( load_ucdata( NULL ) < 0 ) {
1806 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1808 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1809 "%s: line %d: updatedn DN is invalid.\n",
1812 Debug( LDAP_DEBUG_ANY,
1813 "%s: line %d: updatedn DN is invalid\n",
1821 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1824 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1825 "missing url in \"updateref <ldapurl>\" line.\n",
1828 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1829 "missing url in \"updateref <ldapurl>\" line\n",
1837 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1838 "updateref line must appear inside a database definition "
1839 "(ignored)\n", fname, lineno ));
1841 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1842 "updateref line must appear inside a database definition "
1843 "(ignored)\n", fname, lineno, 0 );
1847 } else if ( be->be_update_ndn == NULL ) {
1849 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1850 "updateref line must come after updatedn (ignored).\n",
1853 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1854 "updateref line must after updatedn (ignored)\n",
1860 if( validate_global_referral( cargv[1] ) ) {
1862 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1863 "invalid URL (%s) in \"updateref\" line.\n",
1864 fname, lineno, cargv[1] ));
1866 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1867 "invalid URL (%s) in \"updateref\" line.\n",
1868 fname, lineno, cargv[1] );
1873 vals[0]->bv_val = cargv[1];
1874 vals[0]->bv_len = strlen( vals[0]->bv_val );
1875 value_add( &be->be_update_refs, vals );
1877 /* replication log file to which changes are appended */
1878 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1881 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1882 "%s: line %d: missing filename in \"replogfile <filename>\""
1883 " line.\n", fname, lineno ));
1885 Debug( LDAP_DEBUG_ANY,
1886 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1893 be->be_replogfile = ch_strdup( cargv[1] );
1895 replogfile = ch_strdup( cargv[1] );
1898 /* file from which to read additional rootdse attrs */
1899 } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
1902 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1903 "missing filename in \"rootDSEfile <filename>\" line.\n",
1906 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1907 "missing filename in \"rootDSEfile <filename>\" line.\n",
1913 if( read_root_dse_file( cargv[1] ) ) {
1915 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1916 "could not read \"rootDSEfile <filename>\" line.\n",
1919 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1920 "could not read \"rootDSEfile <filename>\" line\n",
1926 /* maintain lastmodified{by,time} attributes */
1927 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1930 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1931 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1932 " line.\n", fname, lineno ));
1934 Debug( LDAP_DEBUG_ANY,
1935 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1941 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1943 be->be_lastmod = ON;
1945 global_lastmod = ON;
1948 be->be_lastmod = OFF;
1950 global_lastmod = OFF;
1953 /* set idle timeout value */
1954 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1958 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1959 "%s: line %d: missing timeout value in "
1960 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1962 Debug( LDAP_DEBUG_ANY,
1963 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1970 i = atoi( cargv[1] );
1974 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1975 "%s: line %d: timeout value (%d) invalid "
1976 "\"idletimeout <seconds>\" line.\n",
1977 fname, lineno, i ));
1979 Debug( LDAP_DEBUG_ANY,
1980 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1987 global_idletimeout = i;
1989 /* include another config file */
1990 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1993 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1994 "%s: line %d: missing filename in \"include "
1995 "<filename>\" line.\n", fname, lineno ));
1997 Debug( LDAP_DEBUG_ANY,
1998 "%s: line %d: missing filename in \"include <filename>\" line\n",
2004 savefname = ch_strdup( cargv[1] );
2005 savelineno = lineno;
2007 if ( read_config( savefname ) != 0 ) {
2012 lineno = savelineno - 1;
2014 /* location of kerberos srvtab file */
2015 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2018 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2019 "%s: line %d: missing filename in \"srvtab "
2020 "<filename>\" line.\n", fname, lineno ));
2022 Debug( LDAP_DEBUG_ANY,
2023 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2029 ldap_srvtab = ch_strdup( cargv[1] );
2031 #ifdef SLAPD_MODULES
2032 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2035 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2036 "%s: line %d: missing filename in \"moduleload "
2037 "<filename>\" line.\n", fname, lineno ));
2039 Debug( LDAP_DEBUG_ANY,
2040 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2044 exit( EXIT_FAILURE );
2046 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2048 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2049 "%s: line %d: failed to load or initialize module %s\n"<
2050 fname, lineno, cargv[1] ));
2052 Debug( LDAP_DEBUG_ANY,
2053 "%s: line %d: failed to load or initialize module %s\n",
2054 fname, lineno, cargv[1]);
2057 exit( EXIT_FAILURE );
2059 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2062 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2063 "%s: line %d: missing path in \"modulepath <path>\""
2064 " line\n", fname, lineno ));
2066 Debug( LDAP_DEBUG_ANY,
2067 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2071 exit( EXIT_FAILURE );
2073 if (module_path( cargv[1] )) {
2075 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2076 "%s: line %d: failed to set module search path to %s.\n",
2077 fname, lineno, cargv[1] ));
2079 Debug( LDAP_DEBUG_ANY,
2080 "%s: line %d: failed to set module search path to %s\n",
2081 fname, lineno, cargv[1]);
2084 exit( EXIT_FAILURE );
2087 #endif /*SLAPD_MODULES*/
2090 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2091 rc = ldap_pvt_tls_set_option( NULL,
2092 LDAP_OPT_X_TLS_RANDOM_FILE,
2097 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2098 rc = ldap_pvt_tls_set_option( NULL,
2099 LDAP_OPT_X_TLS_CIPHER_SUITE,
2104 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2105 rc = ldap_pvt_tls_set_option( NULL,
2106 LDAP_OPT_X_TLS_CERTFILE,
2111 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2112 rc = ldap_pvt_tls_set_option( NULL,
2113 LDAP_OPT_X_TLS_KEYFILE,
2118 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2119 rc = ldap_pvt_tls_set_option( NULL,
2120 LDAP_OPT_X_TLS_CACERTDIR,
2125 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2126 rc = ldap_pvt_tls_set_option( NULL,
2127 LDAP_OPT_X_TLS_CACERTFILE,
2131 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2133 rc = ldap_pvt_tls_set_option( NULL,
2134 LDAP_OPT_X_TLS_REQUIRE_CERT,
2141 /* pass anything else to the current backend info/db config routine */
2144 if ( bi->bi_config == 0 ) {
2146 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2147 "%s: line %d: unknown directive \"%s\" inside "
2148 "backend info definition (ignored).\n",
2149 fname, lineno, cargv[0] ));
2151 Debug( LDAP_DEBUG_ANY,
2152 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2153 fname, lineno, cargv[0] );
2157 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2163 } else if ( be != NULL ) {
2164 if ( be->be_config == 0 ) {
2166 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2167 "%s: line %d: uknown directive \"%s\" inside "
2168 "backend database definition (ignored).\n",
2169 fname, lineno, cargv[0] ));
2171 Debug( LDAP_DEBUG_ANY,
2172 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2173 fname, lineno, cargv[0] );
2177 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2185 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2186 "%s: line %d: unknown directive \"%s\" outside backend "
2187 "info and database definitions (ignored).\n",
2188 fname, lineno, cargv[0] ));
2190 Debug( LDAP_DEBUG_ANY,
2191 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2192 fname, lineno, cargv[0] );
2200 if ( load_ucdata( NULL ) < 0 ) {
2216 for ( token = strtok_quote( line, " \t" ); token != NULL;
2217 token = strtok_quote( NULL, " \t" ) ) {
2218 if ( *argcp == MAXARGS ) {
2220 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2221 "fp_parse_line: too many tokens (%d max).\n",
2224 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2230 argv[(*argcp)++] = token;
2232 argv[*argcp] = NULL;
2237 strtok_quote( char *line, char *sep )
2243 if ( line != NULL ) {
2246 while ( *next && strchr( sep, *next ) ) {
2250 if ( *next == '\0' ) {
2256 for ( inquote = 0; *next; ) {
2264 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2270 next + 1, strlen( next + 1 ) + 1 );
2271 next++; /* dont parse the escaped character */
2276 if ( strchr( sep, *next ) != NULL ) {
2289 static char buf[BUFSIZ];
2291 static int lmax, lcur;
2293 #define CATLINE( buf ) { \
2295 len = strlen( buf ); \
2296 while ( lcur + len + 1 > lmax ) { \
2298 line = (char *) ch_realloc( line, lmax ); \
2300 strcpy( line + lcur, buf ); \
2305 fp_getline( FILE *fp, int *lineno )
2313 /* hack attack - keeps us from having to keep a stack of bufs... */
2314 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2319 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2320 /* trim off \r\n or \n */
2321 if ( (p = strchr( buf, '\n' )) != NULL ) {
2322 if( p > buf && p[-1] == '\r' ) --p;
2325 if ( ! isspace( (unsigned char) buf[0] ) ) {
2329 /* change leading whitespace to a space */
2337 return( line[0] ? line : NULL );
2341 fp_getline_init( int *lineno )
2347 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2349 load_ucdata( char *path )
2351 static int loaded = 0;
2357 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2360 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2361 "load_ucdata: Error %d loading ucdata.\n", err ));
2363 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",