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;
52 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
53 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
55 char *slapd_pid_file = NULL;
56 char *slapd_args_file = NULL;
59 SaslRegexp_t *SaslRegexp = NULL;
60 int sasl_external_x509dn_convert;
62 static char *fp_getline(FILE *fp, int *lineno);
63 static void fp_getline_init(int *lineno);
64 static int fp_parse_line(char *line, int *argcp, char **argv);
66 static char *strtok_quote(char *line, char *sep);
67 static int load_ucdata(char *path);
70 read_config( const char *fname )
73 char *line, *savefname, *saveline;
74 int cargc, savelineno;
75 char *cargv[MAXARGS+1];
78 struct berval *vals[2];
81 static BackendInfo *bi = NULL;
82 static BackendDB *be = NULL;
87 if ( (fp = fopen( fname, "r" )) == NULL ) {
90 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
91 "could not open config file \"%s\": %s (%d)\n",
92 fname, strerror(errno), errno ));
94 Debug( LDAP_DEBUG_ANY,
95 "could not open config file \"%s\": %s (%d)\n",
96 fname, strerror(errno), errno );
102 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
103 "read_config: reading config file %s\n", fname ));
105 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
109 fp_getline_init( &lineno );
111 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
112 /* skip comments and blank lines */
113 if ( line[0] == '#' || line[0] == '\0' ) {
118 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
119 "line %d (%s)\n", lineno, line ));
121 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
125 /* fp_parse_line is destructive, we save a copy */
126 saveline = ch_strdup( line );
128 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
134 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
135 "%s: line %d: bad config line (ignored)\n",
138 Debug( LDAP_DEBUG_ANY,
139 "%s: line %d: bad config line (ignored)\n",
146 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
149 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
150 "%s : line %d: missing type in \"backend\" line.\n",
153 Debug( LDAP_DEBUG_ANY,
154 "%s: line %d: missing type in \"backend <type>\" line\n",
163 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
164 "%s: line %d: backend line must appear before any "
165 "database definition.\n", fname, lineno ));
167 Debug( LDAP_DEBUG_ANY,
168 "%s: line %d: backend line must appear before any database definition\n",
175 bi = backend_info( cargv[1] );
179 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
180 "read_config: backend %s initialization failed.\n",
183 Debug( LDAP_DEBUG_ANY,
184 "backend %s initialization failed.\n",
190 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
193 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
194 "%s: line %d: missing type in \"database <type>\" line\n",
197 Debug( LDAP_DEBUG_ANY,
198 "%s: line %d: missing type in \"database <type>\" line\n",
206 be = backend_db_init( cargv[1] );
210 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
211 "database %s initialization failed.\n",
214 Debug( LDAP_DEBUG_ANY,
215 "database %s initialization failed.\n",
222 /* set thread concurrency */
223 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
227 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
228 "%s: line %d: missing level in \"concurrency <level\" line\n",
231 Debug( LDAP_DEBUG_ANY,
232 "%s: line %d: missing level in \"concurrency <level>\" line\n",
239 c = atoi( cargv[1] );
243 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
244 "%s: line %d: invalid level (%d) in "
245 "\"concurrency <level>\" line.\n",
248 Debug( LDAP_DEBUG_ANY,
249 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
256 ldap_pvt_thread_set_concurrency( c );
258 /* set sockbuf max */
259 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
263 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
264 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
267 Debug( LDAP_DEBUG_ANY,
268 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
275 max = atol( cargv[1] );
279 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
280 "%s: line %d: invalid max value (%ld) in "
281 "\"sockbuf_max_incoming <bytes>\" line.\n",
282 fname, lineno, max ));
284 Debug( LDAP_DEBUG_ANY,
285 "%s: line %d: invalid max value (%ld) in "
286 "\"sockbuf_max_incoming <bytes>\" line.\n",
287 fname, lineno, max );
293 sockbuf_max_incoming = max;
295 /* set sockbuf max authenticated */
296 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
300 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
301 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
304 Debug( LDAP_DEBUG_ANY,
305 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
312 max = atol( cargv[1] );
316 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
317 "%s: line %d: invalid max value (%ld) in "
318 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
319 fname, lineno, max ));
321 Debug( LDAP_DEBUG_ANY,
322 "%s: line %d: invalid max value (%ld) in "
323 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
324 fname, lineno, max );
330 sockbuf_max_incoming_auth = max;
332 /* default search base */
333 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
336 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
337 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
338 "line\n", fname, lineno ));
340 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
341 "missing dn in \"defaultSearchBase <dn>\" line\n",
347 } else if ( cargc > 2 ) {
349 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
350 "%s: line %d: extra cruft after <dn> in "
351 "\"defaultSearchBase %s\" line (ignored)\n",
352 fname, lineno, cargv[1] ));
354 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
355 "extra cruft after <dn> in \"defaultSearchBase %s\", "
357 fname, lineno, cargv[1] );
362 if ( bi != NULL || be != NULL ) {
364 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
365 "%s: line %d: defaultSearchBase line must appear "
366 "prior to any backend or database definitions\n",
369 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
370 "defaultSearchBaase line must appear prior to "
371 "any backend or database definition\n",
378 if ( default_search_nbase != NULL ) {
380 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
381 "%s: line %d: default search base \"%s\" already defined "
382 "(discarding old)\n", fname, lineno, default_search_base ));
384 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
385 "default search base \"%s\" already defined "
386 "(discarding old)\n",
387 fname, lineno, default_search_base );
390 free( default_search_base );
391 free( default_search_nbase );
394 default_search_base = ch_strdup( cargv[1] );
395 default_search_nbase = ch_strdup( cargv[1] );
397 if ( load_ucdata( NULL ) < 0 ) {
400 if( dn_normalize( default_search_nbase ) == NULL ) {
402 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
403 "%s: %d: invalid default search base \"%s\"\n",
404 fname, lineno, default_search_base ));
406 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
407 "invalid default search base \"%s\"\n",
408 fname, lineno, default_search_base );
414 /* set maximum threads in thread pool */
415 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
419 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
420 "%s: line %d: missing count in \"threads <count>\" line\n",
423 Debug( LDAP_DEBUG_ANY,
424 "%s: line %d: missing count in \"threads <count>\" line\n",
431 c = atoi( cargv[1] );
435 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
436 "%s: line %d: invalid level (%d) in \"threads <count>\""
437 "line\n",fname, lineno, c ));
439 Debug( LDAP_DEBUG_ANY,
440 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
447 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
449 /* save for later use */
450 connection_pool_max = c;
452 /* get pid file name */
453 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
456 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
457 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
460 Debug( LDAP_DEBUG_ANY,
461 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
468 slapd_pid_file = ch_strdup( cargv[1] );
470 /* get args file name */
471 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
474 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
475 "%s: %d: missing file name in "
476 "\"argsfile <file>\" line.\n",
479 Debug( LDAP_DEBUG_ANY,
480 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
487 slapd_args_file = ch_strdup( cargv[1] );
489 /* default password hash */
490 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
493 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
494 "%s: line %d: missing hash in "
495 "\"password-hash <hash>\" line.\n",
498 Debug( LDAP_DEBUG_ANY,
499 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
505 if ( default_passwd_hash != NULL ) {
507 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
508 "%s: line %d: already set default password_hash!\n",
511 Debug( LDAP_DEBUG_ANY,
512 "%s: line %d: already set default password_hash!\n",
519 default_passwd_hash = ch_strdup( cargv[1] );
522 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
526 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
527 "%s: line %d: missing format in "
528 "\"password-crypt-salt-format <format>\" line\n",
531 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
532 "\"password-crypt-salt-format <format>\" line\n",
539 lutil_salt_format( cargv[1] );
542 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
545 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
546 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
549 Debug( LDAP_DEBUG_ANY,
550 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
557 if ( global_host != NULL ) {
559 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
560 "%s: line %d: already set sasl-host!\n",
563 Debug( LDAP_DEBUG_ANY,
564 "%s: line %d: already set sasl-host!\n",
571 global_host = ch_strdup( cargv[1] );
575 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
578 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
579 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
582 Debug( LDAP_DEBUG_ANY,
583 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
590 if ( global_realm != NULL ) {
592 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
593 "%s: line %d: already set sasl-realm!\n",
596 Debug( LDAP_DEBUG_ANY,
597 "%s: line %d: already set sasl-realm!\n",
604 global_realm = ch_strdup( cargv[1] );
607 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
608 || !strcasecmp( cargv[0], "saslregexp" ) )
613 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
614 "%s: line %d: need 2 args in "
615 "\"saslregexp <match> <replace>\"\n",
618 Debug( LDAP_DEBUG_ANY,
619 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
625 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
630 /* SASL security properties */
631 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
636 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
637 "%s: line %d: missing flags in "
638 "\"sasl-secprops <properties>\" line\n",
641 Debug( LDAP_DEBUG_ANY,
642 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
649 txt = slap_sasl_secprops( cargv[1] );
652 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
653 "%s: line %d sas-secprops: %s\n",
654 fname, lineno, txt ));
656 Debug( LDAP_DEBUG_ANY,
657 "%s: line %d: sasl-secprops: %s\n",
658 fname, lineno, txt );
664 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
665 sasl_external_x509dn_convert++;
667 /* set UCDATA path */
668 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
672 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
673 "%s: line %d: missing path in "
674 "\"ucdata-path <path>\" line.\n",
677 Debug( LDAP_DEBUG_ANY,
678 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
685 err = load_ucdata( cargv[1] );
689 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
690 "%s: line %d: ucdata already loaded, ucdata-path "
691 "must be set earlier in the file and/or be "
692 "specified only once!\n",
695 Debug( LDAP_DEBUG_ANY,
696 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
705 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
707 struct slap_limits_set *lim;
711 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
712 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
715 Debug( LDAP_DEBUG_ANY,
716 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
726 lim = &be->be_def_limit;
729 for ( i = 1; i < cargc; i++ ) {
730 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
731 rc = parse_limit( cargv[i], lim );
733 lim->lms_s_soft = atoi( cargv[i] );
739 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
740 "%s: line %d: unable "
741 "to parse value \"%s\" "
744 fname, lineno, cargv[i] ));
746 Debug( LDAP_DEBUG_ANY,
747 "%s: line %d: unable "
748 "to parse value \"%s\" "
751 fname, lineno, cargv[i] );
757 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
759 struct slap_limits_set *lim;
763 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
764 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
767 Debug( LDAP_DEBUG_ANY,
768 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
778 lim = &be->be_def_limit;
781 for ( i = 1; i < cargc; i++ ) {
782 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
783 rc = parse_limit( cargv[i], lim );
785 lim->lms_t_soft = atoi( cargv[i] );
791 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
792 "%s: line %d: unable "
793 "to parse value \"%s\" "
796 fname, lineno, cargv[i] ));
798 Debug( LDAP_DEBUG_ANY,
799 "%s: line %d: unable "
800 "to parse value \"%s\" "
803 fname, lineno, cargv[i] );
808 /* set regex-based limits */
809 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
812 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
813 "%s: line %d \"limits\" allowed only in database environment.\n",
816 Debug( LDAP_DEBUG_ANY,
817 "%s: line %d \"limits\" allowed only in database environment.\n%s",
823 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
827 /* set database suffix */
828 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
832 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
833 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
836 Debug( LDAP_DEBUG_ANY,
837 "%s: line %d: missing dn in \"suffix <dn>\" line\n",
842 } else if ( cargc > 2 ) {
844 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
845 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
846 " line (ignored).\n", fname, lineno, cargv[1] ));
848 Debug( LDAP_DEBUG_ANY,
849 "%s: line %d: extra cruft after <dn> in \"suffix %s\" line (ignored)\n",
850 fname, lineno, cargv[1] );
856 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
857 "%s: line %d: suffix line must appear inside a database "
858 "definition (ignored).\n", fname, lineno ));
860 Debug( LDAP_DEBUG_ANY,
861 "%s: line %d: suffix line must appear inside a database definition (ignored)\n",
865 #if defined(SLAPD_MONITOR_DN)
866 /* "cn=Monitor" is reserved for monitoring slap */
867 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
869 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
870 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
871 fname, lineno, SLAPD_MONITOR_DN ));
873 Debug( LDAP_DEBUG_ANY,
874 "%s: line %d: \"%s\" is reserved for monitoring slapd\n",
875 fname, lineno, SLAPD_MONITOR_DN );
878 #endif /* SLAPD_MONITOR_DN */
880 } else if ( ( tmp_be = select_backend( cargv[1], 0 ) ) == be ) {
882 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
883 "%s: line %d: suffix already served by this backend "
884 "(ignored)\n", fname, lineno ));
886 Debug( LDAP_DEBUG_ANY,
887 "%s: line %d: suffix already served by this backend (ignored)\n",
891 } else if ( tmp_be != NULL ) {
893 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
894 "%s: line %d: suffix already served by a preceding "
895 "backend \"%s\" (ignored)\n", fname, lineno,
896 tmp_be->be_suffix[0] ));
898 Debug( LDAP_DEBUG_ANY,
899 "%s: line %d: suffix already served by a preceeding backend \"%s\" (ignored)\n",
900 fname, lineno, tmp_be->be_suffix[0] );
904 char *dn = ch_strdup( cargv[1] );
906 if ( load_ucdata( NULL ) < 0 ) {
909 if( dn_validate( dn ) == NULL ) {
911 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
912 "%s: line %d: suffix DN invalid\"%s\"\n",
913 fname, lineno, cargv[1] ));
915 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
916 "suffix DN invalid \"%s\"\n",
917 fname, lineno, cargv[1] );
922 } else if( *dn == '\0' && default_search_nbase != NULL ) {
924 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
925 "%s: line %d: suffix DN empty and default search "
926 "base provided \"%s\" (assuming okay).\n",
927 fname, lineno, default_search_base ));
929 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
930 "suffix DN empty and default "
931 "search base provided \"%s\" (assuming okay)\n",
932 fname, lineno, default_search_base );
936 charray_add( &be->be_suffix, dn );
937 #ifndef USE_LDAP_DN_PARSING
938 (void) ldap_pvt_str2upper( dn );
939 #else /* USE_LDAP_DN_PARSING */
940 if ( dn_normalize( dn ) == NULL ) {
942 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
944 "unable to normalize suffix "
947 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
948 "unable to normalize suffix "
949 "\"%s\"\n", dn, NULL, NULL );
953 #endif /* USE_LDAP_DN_PARSING */
954 ber_bvecadd( &be->be_nsuffix, ber_bvstr( dn ));
957 /* set database suffixAlias */
958 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
962 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
963 "%s: line %d: missing alias and aliased_dn in "
964 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
967 Debug( LDAP_DEBUG_ANY,
968 "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
973 } else if ( cargc < 3 ) {
975 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
976 "%s: line %d: missing aliased_dn in "
977 "\"suffixAlias <alias> <aliased_dn>\" line\n",
980 Debug( LDAP_DEBUG_ANY,
981 "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
986 } else if ( cargc > 3 ) {
988 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
989 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
992 Debug( LDAP_DEBUG_ANY,
993 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1001 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1002 "%s: line %d: suffixAlias line must appear inside a "
1003 "database definition (ignored).\n", fname, lineno ));
1005 Debug( LDAP_DEBUG_ANY,
1006 "%s: line %d: suffixAlias line"
1007 " must appear inside a database definition (ignored)\n",
1011 } else if ( (tmp_be = select_backend( cargv[1], 0 )) != NULL ) {
1013 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1014 "%s: line %d: suffixAlias served by a preceeding "
1015 "backend \"%s\" (ignored).\n", fname, lineno,
1016 tmp_be->be_suffix[0] ));
1018 Debug( LDAP_DEBUG_ANY,
1019 "%s: line %d: suffixAlias served by"
1020 " a preceeding backend \"%s\" (ignored)\n",
1021 fname, lineno, tmp_be->be_suffix[0] );
1025 } else if ( (tmp_be = select_backend( cargv[2], 0 )) != NULL ) {
1027 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1028 "%s: line %d: suffixAlias derefs to a different backend "
1029 "a preceeding backend \"%s\" (ignored)\n",
1030 fname, lineno, tmp_be->be_suffix[0] ));
1032 Debug( LDAP_DEBUG_ANY,
1033 "%s: line %d: suffixAlias derefs to differnet backend"
1034 " a preceeding backend \"%s\" (ignored)\n",
1035 fname, lineno, tmp_be->be_suffix[0] );
1040 char *alias, *aliased_dn;
1042 alias = ch_strdup( cargv[1] );
1043 if ( load_ucdata( NULL ) < 0 ) {
1046 (void) dn_normalize( alias );
1048 aliased_dn = ch_strdup( cargv[2] );
1049 (void) dn_normalize( aliased_dn );
1051 ber_bvecadd( &be->be_suffixAlias,
1052 ber_bvstr( alias ) );
1053 ber_bvecadd( &be->be_suffixAlias,
1054 ber_bvstr( aliased_dn ) );
1057 /* set max deref depth */
1058 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1062 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1063 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1064 " line\n", fname, lineno ));
1066 Debug( LDAP_DEBUG_ANY,
1067 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1075 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1076 "%s: line %d: depth line must appear inside a database "
1077 "definition (ignored)\n", fname, lineno ));
1079 Debug( LDAP_DEBUG_ANY,
1080 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1084 } else if ((i = atoi(cargv[1])) < 0) {
1086 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1087 "%s: line %d: depth must be positive (ignored).\n",
1090 Debug( LDAP_DEBUG_ANY,
1091 "%s: line %d: depth must be positive (ignored)\n",
1097 be->be_max_deref_depth = i;
1101 /* set magic "root" dn for this database */
1102 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1105 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1106 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1109 Debug( LDAP_DEBUG_ANY,
1110 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1118 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1119 "%s: line %d: rootdn line must appear inside a database "
1120 "definition (ignored).\n", fname, lineno ));
1122 Debug( LDAP_DEBUG_ANY,
1123 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1128 be->be_root_dn = ch_strdup( cargv[1] );
1129 be->be_root_ndn = ch_strdup( cargv[1] );
1131 if ( load_ucdata( NULL ) < 0 ) {
1134 if( dn_normalize( be->be_root_ndn ) == NULL ) {
1135 free( be->be_root_dn );
1136 free( be->be_root_ndn );
1138 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1139 "%s: line %d: rootdn DN is invalid.\n",
1142 Debug( LDAP_DEBUG_ANY,
1143 "%s: line %d: rootdn DN is invalid\n",
1151 /* set super-secret magic database password */
1152 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1155 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1156 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1157 " line\n", fname, lineno ));
1159 Debug( LDAP_DEBUG_ANY,
1160 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1168 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1169 "%s: line %d: rootpw line must appear inside a database "
1170 "definition (ignored)\n", fname, lineno ));
1172 Debug( LDAP_DEBUG_ANY,
1173 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1178 be->be_root_pw.bv_val = ch_strdup( cargv[1] );
1179 be->be_root_pw.bv_len = strlen( be->be_root_pw.bv_val );
1182 /* make this database read-only */
1183 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1186 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1187 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1190 Debug( LDAP_DEBUG_ANY,
1191 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1198 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1199 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1201 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1204 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1205 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1207 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1212 /* allow these features */
1213 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1214 strcasecmp( cargv[0], "allow" ) == 0 )
1220 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1221 "%s: line %d: allow line must appear prior to "
1222 "database definitions.\n", fname, lineno ));
1224 Debug( LDAP_DEBUG_ANY,
1225 "%s: line %d: allow line must appear prior to database definitions\n",
1233 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1234 "%s: line %d: missing feature(s) in \"allow <features>\""
1235 " line\n", fname, lineno ));
1237 Debug( LDAP_DEBUG_ANY,
1238 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1247 for( i=1; i < cargc; i++ ) {
1248 if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1249 allows |= SLAP_ALLOW_TLS_2_ANON;
1251 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1253 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1254 "%s: line %d: unknown feature %s in "
1255 "\"allow <features>\" line.\n",
1256 fname, lineno, cargv[1] ));
1258 Debug( LDAP_DEBUG_ANY,
1259 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1260 fname, lineno, cargv[i] );
1267 global_allows = allows;
1269 /* disallow these features */
1270 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1271 strcasecmp( cargv[0], "disallow" ) == 0 )
1273 slap_mask_t disallows;
1277 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1278 "%s: line %d: disallow line must appear prior to "
1279 "database definitions.\n", fname, lineno ));
1281 Debug( LDAP_DEBUG_ANY,
1282 "%s: line %d: disallow line must appear prior to database definitions\n",
1290 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1291 "%s: line %d: missing feature(s) in \"disallow <features>\""
1292 " line.\n", fname, lineno ));
1294 Debug( LDAP_DEBUG_ANY,
1295 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1304 for( i=1; i < cargc; i++ ) {
1305 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1306 disallows |= SLAP_DISALLOW_BIND_V2;
1308 } else if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1309 disallows |= SLAP_DISALLOW_BIND_ANON;
1311 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1312 disallows |= SLAP_DISALLOW_BIND_ANON_CRED;
1314 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1315 disallows |= SLAP_DISALLOW_BIND_ANON_DN;
1317 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1318 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1320 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1321 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1323 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1324 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1326 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1328 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1329 "%s: line %d: unknown feature %s in "
1330 "\"disallow <features>\" line.\n",
1331 fname, lineno, cargv[i] ));
1333 Debug( LDAP_DEBUG_ANY,
1334 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1335 fname, lineno, cargv[i] );
1342 global_disallows = disallows;
1344 /* require these features */
1345 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1346 strcasecmp( cargv[0], "require" ) == 0 )
1348 slap_mask_t requires;
1352 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1353 "%s: line %d: missing feature(s) in "
1354 "\"require <features>\" line.\n", fname, lineno ));
1356 Debug( LDAP_DEBUG_ANY,
1357 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1366 for( i=1; i < cargc; i++ ) {
1367 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1368 requires |= SLAP_REQUIRE_BIND;
1370 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1371 requires |= SLAP_REQUIRE_LDAP_V3;
1373 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1374 requires |= SLAP_REQUIRE_AUTHC;
1376 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1377 requires |= SLAP_REQUIRE_SASL;
1379 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1380 requires |= SLAP_REQUIRE_STRONG;
1382 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1384 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1385 "%s: line %d: unknown feature %s in "
1386 "\"require <features>\" line.\n",
1389 Debug( LDAP_DEBUG_ANY,
1390 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1391 fname, lineno, cargv[i] );
1399 global_requires = requires;
1401 be->be_requires = requires;
1404 /* required security factors */
1405 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1406 slap_ssf_set_t *set;
1410 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1411 "%s: line %d: missing factor(s) in \"security <factors>\""
1412 " line.\n", fname, lineno ));
1414 Debug( LDAP_DEBUG_ANY,
1415 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1423 set = &global_ssf_set;
1425 set = &be->be_ssf_set;
1428 for( i=1; i < cargc; i++ ) {
1429 if( strncasecmp( cargv[i], "ssf=",
1430 sizeof("ssf") ) == 0 )
1433 atoi( &cargv[i][sizeof("ssf")] );
1435 } else if( strncasecmp( cargv[i], "transport=",
1436 sizeof("transport") ) == 0 )
1438 set->sss_transport =
1439 atoi( &cargv[i][sizeof("transport")] );
1441 } else if( strncasecmp( cargv[i], "tls=",
1442 sizeof("tls") ) == 0 )
1445 atoi( &cargv[i][sizeof("tls")] );
1447 } else if( strncasecmp( cargv[i], "sasl=",
1448 sizeof("sasl") ) == 0 )
1451 atoi( &cargv[i][sizeof("sasl")] );
1453 } else if( strncasecmp( cargv[i], "update_ssf=",
1454 sizeof("update_ssf") ) == 0 )
1456 set->sss_update_ssf =
1457 atoi( &cargv[i][sizeof("update_ssf")] );
1459 } else if( strncasecmp( cargv[i], "update_transport=",
1460 sizeof("update_transport") ) == 0 )
1462 set->sss_update_transport =
1463 atoi( &cargv[i][sizeof("update_transport")] );
1465 } else if( strncasecmp( cargv[i], "update_tls=",
1466 sizeof("update_tls") ) == 0 )
1468 set->sss_update_tls =
1469 atoi( &cargv[i][sizeof("update_tls")] );
1471 } else if( strncasecmp( cargv[i], "update_sasl=",
1472 sizeof("update_sasl") ) == 0 )
1474 set->sss_update_sasl =
1475 atoi( &cargv[i][sizeof("update_sasl")] );
1479 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1480 "%s: line %d: unknown factor %S in "
1481 "\"security <factors>\" line.\n",
1482 fname, lineno, cargv[1] ));
1484 Debug( LDAP_DEBUG_ANY,
1485 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1486 fname, lineno, cargv[i] );
1492 /* where to send clients when we don't hold it */
1493 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1496 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1497 "%s: line %d: missing URL in \"referral <URL>\""
1498 " line.\n", fname, lineno ));
1500 Debug( LDAP_DEBUG_ANY,
1501 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1508 if( validate_global_referral( cargv[1] ) ) {
1510 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1511 "invalid URL (%s) in \"referral\" line.\n",
1512 fname, lineno, cargv[1] ));
1514 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1515 "invalid URL (%s) in \"referral\" line.\n",
1516 fname, lineno, cargv[1] );
1521 vals[0]->bv_val = cargv[1];
1522 vals[0]->bv_len = strlen( vals[0]->bv_val );
1523 value_add( &default_referral, vals );
1526 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1530 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1531 "%s: line %d: Error in logfile directive, "
1532 "\"logfile <filename>\"\n", fname, lineno ));
1534 Debug( LDAP_DEBUG_ANY,
1535 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1541 logfile = fopen( cargv[1], "w" );
1542 if ( logfile != NULL ) lutil_debug_file( logfile );
1545 /* start of a new database definition */
1546 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1550 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1551 "%s: line %d: Error in debug directive, "
1552 "\"debug <subsys> <level>\"\n", fname, lineno ));
1554 Debug( LDAP_DEBUG_ANY,
1555 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1561 level = atoi( cargv[2] );
1562 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1563 lutil_set_debug_level( cargv[1], level );
1564 /* specify an Object Identifier macro */
1565 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1566 rc = parse_oidm( fname, lineno, cargc, cargv );
1569 /* specify an objectclass */
1570 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1571 if ( *cargv[1] == '(' ) {
1573 p = strchr(saveline,'(');
1574 rc = parse_oc( fname, lineno, p, cargv );
1579 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1580 "%s: line %d: old objectclass format not supported\n",
1583 Debug( LDAP_DEBUG_ANY,
1584 "%s: line %d: old objectclass format not supported.\n",
1590 /* specify an attribute type */
1591 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1592 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1594 if ( *cargv[1] == '(' ) {
1596 p = strchr(saveline,'(');
1597 rc = parse_at( fname, lineno, p, cargv );
1602 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1603 "%s: line %d: old attribute type format not supported.\n",
1606 Debug( LDAP_DEBUG_ANY,
1607 "%s: line %d: old attribute type format not supported.\n",
1613 /* turn on/off schema checking */
1614 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1617 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1618 "%s: line %d: missing on|off in "
1619 "\"schemacheck <on|off>\" line.\n",
1622 Debug( LDAP_DEBUG_ANY,
1623 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1629 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1630 global_schemacheck = 0;
1632 global_schemacheck = 1;
1635 /* specify access control info */
1636 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1637 parse_acl( be, fname, lineno, cargc, cargv );
1639 /* debug level to log things to syslog */
1640 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1643 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1644 "%s: line %d: missing level in \"loglevel <level>\""
1645 " line.\n", fname, lineno ));
1647 Debug( LDAP_DEBUG_ANY,
1648 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1657 for( i=1; i < cargc; i++ ) {
1658 ldap_syslog += atoi( cargv[1] );
1661 /* list of replicas of the data in this backend (master only) */
1662 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1665 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1666 "%s: line %d: missing host in \"replica "
1667 " <host[:port]\" line\n", fname, lineno ));
1669 Debug( LDAP_DEBUG_ANY,
1670 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1678 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1679 "%s: line %d: replica line must appear inside "
1680 "a database definition (ignored).\n", fname, lineno ));
1682 Debug( LDAP_DEBUG_ANY,
1683 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1690 for ( i = 1; i < cargc; i++ ) {
1691 if ( strncasecmp( cargv[i], "host=", 5 )
1693 nr = add_replica_info( be,
1700 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1701 "%s: line %d: missing host in \"replica\" "
1702 "line (ignored)\n", fname, lineno ));
1704 Debug( LDAP_DEBUG_ANY,
1705 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1709 } else if ( nr == -1 ) {
1711 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1712 "%s: line %d: unable to add"
1718 Debug( LDAP_DEBUG_ANY,
1719 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1720 fname, lineno, cargv[i] + 5 );
1723 for ( i = 1; i < cargc; i++ ) {
1724 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1726 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1729 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1730 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1731 fname, lineno, cargv[i] + 7 ));
1733 Debug( LDAP_DEBUG_ANY,
1734 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1735 fname, lineno, cargv[i] + 7 );
1741 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1742 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1745 Debug( LDAP_DEBUG_ANY,
1746 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1756 /* dn of master entity allowed to write to replica */
1757 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1760 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1761 "%s: line %d: missing dn in \"updatedn <dn>\""
1762 " line.\n", fname, lineno ));
1764 Debug( LDAP_DEBUG_ANY,
1765 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1773 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1774 "%s: line %d: updatedn line must appear inside "
1775 "a database definition (ignored)\n",
1778 Debug( LDAP_DEBUG_ANY,
1779 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1784 be->be_update_ndn = ch_strdup( cargv[1] );
1785 if ( load_ucdata( NULL ) < 0 ) {
1788 if( dn_normalize( be->be_update_ndn ) == NULL ) {
1790 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1791 "%s: line %d: updatedn DN is invalid.\n",
1794 Debug( LDAP_DEBUG_ANY,
1795 "%s: line %d: updatedn DN is invalid\n",
1803 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1806 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1807 "missing url in \"updateref <ldapurl>\" line.\n",
1810 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1811 "missing url in \"updateref <ldapurl>\" line\n",
1819 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1820 "updateref line must appear inside a database definition "
1821 "(ignored)\n", fname, lineno ));
1823 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1824 "updateref line must appear inside a database definition "
1825 "(ignored)\n", fname, lineno, 0 );
1829 } else if ( be->be_update_ndn == NULL ) {
1831 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1832 "updateref line must come after updatedn (ignored).\n",
1835 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1836 "updateref line must after updatedn (ignored)\n",
1842 if( validate_global_referral( cargv[1] ) ) {
1844 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1845 "invalid URL (%s) in \"updateref\" line.\n",
1846 fname, lineno, cargv[1] ));
1848 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1849 "invalid URL (%s) in \"updateref\" line.\n",
1850 fname, lineno, cargv[1] );
1855 vals[0]->bv_val = cargv[1];
1856 vals[0]->bv_len = strlen( vals[0]->bv_val );
1857 value_add( &be->be_update_refs, vals );
1859 /* replication log file to which changes are appended */
1860 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1863 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1864 "%s: line %d: missing filename in \"replogfile <filename>\""
1865 " line.\n", fname, lineno ));
1867 Debug( LDAP_DEBUG_ANY,
1868 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1875 be->be_replogfile = ch_strdup( cargv[1] );
1877 replogfile = ch_strdup( cargv[1] );
1880 /* file from which to read additional rootdse attrs */
1881 } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
1884 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1885 "missing filename in \"rootDSEfile <filename>\" line.\n",
1888 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1889 "missing filename in \"rootDSEfile <filename>\" line.\n",
1895 if( read_root_dse_file( cargv[1] ) ) {
1897 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1898 "could not read \"rootDSEfile <filename>\" line.\n",
1901 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1902 "could not read \"rootDSEfile <filename>\" line\n",
1908 /* maintain lastmodified{by,time} attributes */
1909 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1912 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1913 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1914 " line.\n", fname, lineno ));
1916 Debug( LDAP_DEBUG_ANY,
1917 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1923 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1925 be->be_lastmod = ON;
1927 global_lastmod = ON;
1930 be->be_lastmod = OFF;
1932 global_lastmod = OFF;
1935 /* set idle timeout value */
1936 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1940 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1941 "%s: line %d: missing timeout value in "
1942 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
1944 Debug( LDAP_DEBUG_ANY,
1945 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1952 i = atoi( cargv[1] );
1956 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1957 "%s: line %d: timeout value (%d) invalid "
1958 "\"idletimeout <seconds>\" line.\n",
1959 fname, lineno, i ));
1961 Debug( LDAP_DEBUG_ANY,
1962 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1969 global_idletimeout = i;
1971 /* include another config file */
1972 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1975 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1976 "%s: line %d: missing filename in \"include "
1977 "<filename>\" line.\n", fname, lineno ));
1979 Debug( LDAP_DEBUG_ANY,
1980 "%s: line %d: missing filename in \"include <filename>\" line\n",
1986 savefname = ch_strdup( cargv[1] );
1987 savelineno = lineno;
1989 if ( read_config( savefname ) != 0 ) {
1994 lineno = savelineno - 1;
1996 /* location of kerberos srvtab file */
1997 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2000 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2001 "%s: line %d: missing filename in \"srvtab "
2002 "<filename>\" line.\n", fname, lineno ));
2004 Debug( LDAP_DEBUG_ANY,
2005 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2011 ldap_srvtab = ch_strdup( cargv[1] );
2013 #ifdef SLAPD_MODULES
2014 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2017 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2018 "%s: line %d: missing filename in \"moduleload "
2019 "<filename>\" line.\n", fname, lineno ));
2021 Debug( LDAP_DEBUG_ANY,
2022 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2026 exit( EXIT_FAILURE );
2028 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2030 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2031 "%s: line %d: failed to load or initialize module %s\n"<
2032 fname, lineno, cargv[1] ));
2034 Debug( LDAP_DEBUG_ANY,
2035 "%s: line %d: failed to load or initialize module %s\n",
2036 fname, lineno, cargv[1]);
2039 exit( EXIT_FAILURE );
2041 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2044 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2045 "%s: line %d: missing path in \"modulepath <path>\""
2046 " line\n", fname, lineno ));
2048 Debug( LDAP_DEBUG_ANY,
2049 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2053 exit( EXIT_FAILURE );
2055 if (module_path( cargv[1] )) {
2057 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2058 "%s: line %d: failed to set module search path to %s.\n",
2059 fname, lineno, cargv[1] ));
2061 Debug( LDAP_DEBUG_ANY,
2062 "%s: line %d: failed to set module search path to %s\n",
2063 fname, lineno, cargv[1]);
2066 exit( EXIT_FAILURE );
2069 #endif /*SLAPD_MODULES*/
2072 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2073 rc = ldap_pvt_tls_set_option( NULL,
2074 LDAP_OPT_X_TLS_RANDOM_FILE,
2079 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2080 rc = ldap_pvt_tls_set_option( NULL,
2081 LDAP_OPT_X_TLS_CIPHER_SUITE,
2086 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2087 rc = ldap_pvt_tls_set_option( NULL,
2088 LDAP_OPT_X_TLS_CERTFILE,
2093 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2094 rc = ldap_pvt_tls_set_option( NULL,
2095 LDAP_OPT_X_TLS_KEYFILE,
2100 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2101 rc = ldap_pvt_tls_set_option( NULL,
2102 LDAP_OPT_X_TLS_CACERTDIR,
2107 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2108 rc = ldap_pvt_tls_set_option( NULL,
2109 LDAP_OPT_X_TLS_CACERTFILE,
2113 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2115 rc = ldap_pvt_tls_set_option( NULL,
2116 LDAP_OPT_X_TLS_REQUIRE_CERT,
2123 /* pass anything else to the current backend info/db config routine */
2126 if ( bi->bi_config == 0 ) {
2128 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2129 "%s: line %d: unknown directive \"%s\" inside "
2130 "backend info definition (ignored).\n",
2131 fname, lineno, cargv[0] ));
2133 Debug( LDAP_DEBUG_ANY,
2134 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2135 fname, lineno, cargv[0] );
2139 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2145 } else if ( be != NULL ) {
2146 if ( be->be_config == 0 ) {
2148 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2149 "%s: line %d: uknown directive \"%s\" inside "
2150 "backend database definition (ignored).\n",
2151 fname, lineno, cargv[0] ));
2153 Debug( LDAP_DEBUG_ANY,
2154 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2155 fname, lineno, cargv[0] );
2159 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2167 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2168 "%s: line %d: unknown directive \"%s\" outside backend "
2169 "info and database definitions (ignored).\n",
2170 fname, lineno, cargv[0] ));
2172 Debug( LDAP_DEBUG_ANY,
2173 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2174 fname, lineno, cargv[0] );
2182 if ( load_ucdata( NULL ) < 0 ) {
2198 for ( token = strtok_quote( line, " \t" ); token != NULL;
2199 token = strtok_quote( NULL, " \t" ) ) {
2200 if ( *argcp == MAXARGS ) {
2202 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2203 "fp_parse_line: too many tokens (%d max).\n",
2206 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2212 argv[(*argcp)++] = token;
2214 argv[*argcp] = NULL;
2219 strtok_quote( char *line, char *sep )
2225 if ( line != NULL ) {
2228 while ( *next && strchr( sep, *next ) ) {
2232 if ( *next == '\0' ) {
2238 for ( inquote = 0; *next; ) {
2246 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2252 next + 1, strlen( next + 1 ) + 1 );
2253 next++; /* dont parse the escaped character */
2258 if ( strchr( sep, *next ) != NULL ) {
2271 static char buf[BUFSIZ];
2273 static int lmax, lcur;
2275 #define CATLINE( buf ) { \
2277 len = strlen( buf ); \
2278 while ( lcur + len + 1 > lmax ) { \
2280 line = (char *) ch_realloc( line, lmax ); \
2282 strcpy( line + lcur, buf ); \
2287 fp_getline( FILE *fp, int *lineno )
2295 /* hack attack - keeps us from having to keep a stack of bufs... */
2296 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2301 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2302 /* trim off \r\n or \n */
2303 if ( (p = strchr( buf, '\n' )) != NULL ) {
2304 if( p > buf && p[-1] == '\r' ) --p;
2307 if ( ! isspace( (unsigned char) buf[0] ) ) {
2311 /* change leading whitespace to a space */
2319 return( line[0] ? line : NULL );
2323 fp_getline_init( int *lineno )
2329 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2331 load_ucdata( char *path )
2333 static int loaded = 0;
2339 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2342 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2343 "load_ucdata: Error %d loading ucdata.\n", err ));
2345 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",