1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
14 #include <ac/socket.h>
24 * defaults for various global variables
26 struct slap_limits_set deflimit = {
27 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
30 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
32 -1 /* no limit on unchecked size */
35 AccessControl *global_acl = NULL;
36 slap_access_t global_default_access = ACL_READ;
37 slap_mask_t global_restrictops = 0;
38 slap_mask_t global_allows = 0;
39 slap_mask_t global_disallows = 0;
40 slap_mask_t global_requires = 0;
41 slap_ssf_set_t global_ssf_set;
43 int global_lastmod = ON;
44 int global_idletimeout = 0;
45 char *global_host = NULL;
46 char *global_realm = NULL;
47 char *ldap_srvtab = "";
48 char *default_passwd_hash;
49 struct berval default_search_base = { 0, NULL };
50 struct berval default_search_nbase = { 0, NULL };
51 unsigned num_subordinates = 0;
53 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
54 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
56 char *slapd_pid_file = NULL;
57 char *slapd_args_file = NULL;
60 SaslRegexp_t *SaslRegexp = NULL;
61 int sasl_external_x509dn_convert;
63 static char *fp_getline(FILE *fp, int *lineno);
64 static void fp_getline_init(int *lineno);
65 static int fp_parse_line(char *line, int *argcp, char **argv);
67 static char *strtok_quote(char *line, char *sep);
68 static int load_ucdata(char *path);
71 read_config( const char *fname )
74 char *line, *savefname, *saveline;
75 int cargc, savelineno;
76 char *cargv[MAXARGS+1];
79 struct berval *vals[2];
82 static BackendInfo *bi = NULL;
83 static BackendDB *be = NULL;
88 if ( (fp = fopen( fname, "r" )) == NULL ) {
91 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY, "read_config: "
92 "could not open config file \"%s\": %s (%d)\n",
93 fname, strerror(errno), errno ));
95 Debug( LDAP_DEBUG_ANY,
96 "could not open config file \"%s\": %s (%d)\n",
97 fname, strerror(errno), errno );
103 LDAP_LOG(( "config", LDAP_LEVEL_ENTRY,
104 "read_config: reading config file %s\n", fname ));
106 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
110 fp_getline_init( &lineno );
112 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
113 /* skip comments and blank lines */
114 if ( line[0] == '#' || line[0] == '\0' ) {
119 LDAP_LOG(( "config", LDAP_LEVEL_DETAIL1,
120 "line %d (%s)\n", lineno, line ));
122 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
126 /* fp_parse_line is destructive, we save a copy */
127 saveline = ch_strdup( line );
129 if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
135 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
136 "%s: line %d: bad config line (ignored)\n",
139 Debug( LDAP_DEBUG_ANY,
140 "%s: line %d: bad config line (ignored)\n",
147 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
150 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
151 "%s : line %d: missing type in \"backend\" line.\n",
154 Debug( LDAP_DEBUG_ANY,
155 "%s: line %d: missing type in \"backend <type>\" line\n",
164 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
165 "%s: line %d: backend line must appear before any "
166 "database definition.\n", fname, lineno ));
168 Debug( LDAP_DEBUG_ANY,
169 "%s: line %d: backend line must appear before any database definition\n",
176 bi = backend_info( cargv[1] );
180 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
181 "read_config: backend %s initialization failed.\n",
184 Debug( LDAP_DEBUG_ANY,
185 "backend %s initialization failed.\n",
191 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
194 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
195 "%s: line %d: missing type in \"database <type>\" line\n",
198 Debug( LDAP_DEBUG_ANY,
199 "%s: line %d: missing type in \"database <type>\" line\n",
207 be = backend_db_init( cargv[1] );
211 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
212 "database %s initialization failed.\n",
215 Debug( LDAP_DEBUG_ANY,
216 "database %s initialization failed.\n",
223 /* set thread concurrency */
224 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
228 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
229 "%s: line %d: missing level in \"concurrency <level\" line\n",
232 Debug( LDAP_DEBUG_ANY,
233 "%s: line %d: missing level in \"concurrency <level>\" line\n",
240 c = atoi( cargv[1] );
244 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
245 "%s: line %d: invalid level (%d) in "
246 "\"concurrency <level>\" line.\n",
249 Debug( LDAP_DEBUG_ANY,
250 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
257 ldap_pvt_thread_set_concurrency( c );
259 /* set sockbuf max */
260 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
264 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
265 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
268 Debug( LDAP_DEBUG_ANY,
269 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes\" line\n",
276 max = atol( cargv[1] );
280 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
281 "%s: line %d: invalid max value (%ld) in "
282 "\"sockbuf_max_incoming <bytes>\" line.\n",
283 fname, lineno, max ));
285 Debug( LDAP_DEBUG_ANY,
286 "%s: line %d: invalid max value (%ld) in "
287 "\"sockbuf_max_incoming <bytes>\" line.\n",
288 fname, lineno, max );
294 sockbuf_max_incoming = max;
296 /* set sockbuf max authenticated */
297 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
301 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
302 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
305 Debug( LDAP_DEBUG_ANY,
306 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
313 max = atol( cargv[1] );
317 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
318 "%s: line %d: invalid max value (%ld) in "
319 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
320 fname, lineno, max ));
322 Debug( LDAP_DEBUG_ANY,
323 "%s: line %d: invalid max value (%ld) in "
324 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
325 fname, lineno, max );
331 sockbuf_max_incoming_auth = max;
333 /* default search base */
334 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
337 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
338 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
339 "line\n", fname, lineno ));
341 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
342 "missing dn in \"defaultSearchBase <dn>\" line\n",
348 } else if ( cargc > 2 ) {
350 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
351 "%s: line %d: extra cruft after <dn> in "
352 "\"defaultSearchBase %s\" line (ignored)\n",
353 fname, lineno, cargv[1] ));
355 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
356 "extra cruft after <dn> in \"defaultSearchBase %s\", "
358 fname, lineno, cargv[1] );
362 if ( bi != NULL || be != NULL ) {
364 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
365 "%s: line %d: defaultSearchBase line must appear "
366 "prior to any backend or database definitions\n",
369 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
370 "defaultSearchBaase line must appear prior to "
371 "any backend or database definition\n",
378 if ( default_search_nbase.bv_len ) {
380 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
381 "default search base \"%s\" already defined "
382 "(discarding old)\n", fname, lineno,
383 default_search_base->bv_val ));
385 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
386 "default search base \"%s\" already defined "
387 "(discarding old)\n",
388 fname, lineno, default_search_base.bv_val );
391 free( default_search_base.bv_val );
392 free( default_search_nbase.bv_val );
395 if ( load_ucdata( NULL ) < 0 ) return 1;
400 dn.bv_val = cargv[1];
401 dn.bv_len = strlen( dn.bv_val );
403 rc = dnPrettyNormal( NULL, &dn,
404 &default_search_base,
405 &default_search_nbase );
407 if( rc != LDAP_SUCCESS ) {
409 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
410 "%s: line %d: defaultSearchBase DN is invalid.\n",
413 Debug( LDAP_DEBUG_ANY,
414 "%s: line %d: defaultSearchBase DN is invalid\n",
421 /* set maximum threads in thread pool */
422 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
426 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
427 "%s: line %d: missing count in \"threads <count>\" line\n",
430 Debug( LDAP_DEBUG_ANY,
431 "%s: line %d: missing count in \"threads <count>\" line\n",
438 c = atoi( cargv[1] );
442 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
443 "%s: line %d: invalid level (%d) in \"threads <count>\""
444 "line\n",fname, lineno, c ));
446 Debug( LDAP_DEBUG_ANY,
447 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
454 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
456 /* save for later use */
457 connection_pool_max = c;
459 /* get pid file name */
460 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
463 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
464 "%s: line %d missing file name in \"pidfile <file>\" line.\n",
467 Debug( LDAP_DEBUG_ANY,
468 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
475 slapd_pid_file = ch_strdup( cargv[1] );
477 /* get args file name */
478 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
481 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
482 "%s: %d: missing file name in "
483 "\"argsfile <file>\" line.\n",
486 Debug( LDAP_DEBUG_ANY,
487 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
494 slapd_args_file = ch_strdup( cargv[1] );
496 /* default password hash */
497 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
500 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
501 "%s: line %d: missing hash in "
502 "\"password-hash <hash>\" line.\n",
505 Debug( LDAP_DEBUG_ANY,
506 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
512 if ( default_passwd_hash != NULL ) {
514 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
515 "%s: line %d: already set default password_hash!\n",
518 Debug( LDAP_DEBUG_ANY,
519 "%s: line %d: already set default password_hash!\n",
526 default_passwd_hash = ch_strdup( cargv[1] );
529 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
533 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
534 "%s: line %d: missing format in "
535 "\"password-crypt-salt-format <format>\" line\n",
538 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
539 "\"password-crypt-salt-format <format>\" line\n",
546 lutil_salt_format( cargv[1] );
549 } else if ( strcasecmp( cargv[0], "sasl-host" ) == 0 ) {
552 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
553 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
556 Debug( LDAP_DEBUG_ANY,
557 "%s: line %d: missing host in \"sasl-host <host>\" line\n",
564 if ( global_host != NULL ) {
566 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
567 "%s: line %d: already set sasl-host!\n",
570 Debug( LDAP_DEBUG_ANY,
571 "%s: line %d: already set sasl-host!\n",
578 global_host = ch_strdup( cargv[1] );
582 } else if ( strcasecmp( cargv[0], "sasl-realm" ) == 0 ) {
585 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
586 "%s: line %d: missing realm in \"sasl-realm <realm>\" line.\n",
589 Debug( LDAP_DEBUG_ANY,
590 "%s: line %d: missing realm in \"sasl-realm <realm>\" line\n",
597 if ( global_realm != NULL ) {
599 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
600 "%s: line %d: already set sasl-realm!\n",
603 Debug( LDAP_DEBUG_ANY,
604 "%s: line %d: already set sasl-realm!\n",
611 global_realm = ch_strdup( cargv[1] );
614 } else if ( !strcasecmp( cargv[0], "sasl-regexp" )
615 || !strcasecmp( cargv[0], "saslregexp" ) )
620 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
621 "%s: line %d: need 2 args in "
622 "\"saslregexp <match> <replace>\"\n",
625 Debug( LDAP_DEBUG_ANY,
626 "%s: line %d: need 2 args in \"saslregexp <match> <replace>\"\n",
632 rc = slap_sasl_regexp_config( cargv[1], cargv[2] );
637 /* SASL security properties */
638 } else if ( strcasecmp( cargv[0], "sasl-secprops" ) == 0 ) {
643 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
644 "%s: line %d: missing flags in "
645 "\"sasl-secprops <properties>\" line\n",
648 Debug( LDAP_DEBUG_ANY,
649 "%s: line %d: missing flags in \"sasl-secprops <properties>\" line\n",
656 txt = slap_sasl_secprops( cargv[1] );
659 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
660 "%s: line %d sas-secprops: %s\n",
661 fname, lineno, txt ));
663 Debug( LDAP_DEBUG_ANY,
664 "%s: line %d: sasl-secprops: %s\n",
665 fname, lineno, txt );
671 } else if ( strcasecmp( cargv[0], "sasl-external-x509dn-convert" ) == 0 ) {
672 sasl_external_x509dn_convert++;
674 /* set UCDATA path */
675 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
679 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
680 "%s: line %d: missing path in "
681 "\"ucdata-path <path>\" line.\n",
684 Debug( LDAP_DEBUG_ANY,
685 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
692 err = load_ucdata( cargv[1] );
696 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
697 "%s: line %d: ucdata already loaded, ucdata-path "
698 "must be set earlier in the file and/or be "
699 "specified only once!\n",
702 Debug( LDAP_DEBUG_ANY,
703 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
712 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
714 struct slap_limits_set *lim;
718 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
719 "%s: line %d: missing limit in \"sizelimit <limit>\" line.\n",
722 Debug( LDAP_DEBUG_ANY,
723 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
733 lim = &be->be_def_limit;
736 for ( i = 1; i < cargc; i++ ) {
737 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
738 rc = parse_limit( cargv[i], lim );
740 lim->lms_s_soft = atoi( cargv[i] );
746 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
747 "%s: line %d: unable "
748 "to parse value \"%s\" "
751 fname, lineno, cargv[i] ));
753 Debug( LDAP_DEBUG_ANY,
754 "%s: line %d: unable "
755 "to parse value \"%s\" "
758 fname, lineno, cargv[i] );
764 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
766 struct slap_limits_set *lim;
770 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
771 "%s: line %d missing limit in \"timelimit <limit>\" line.\n",
774 Debug( LDAP_DEBUG_ANY,
775 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
785 lim = &be->be_def_limit;
788 for ( i = 1; i < cargc; i++ ) {
789 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
790 rc = parse_limit( cargv[i], lim );
792 lim->lms_t_soft = atoi( cargv[i] );
798 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
799 "%s: line %d: unable "
800 "to parse value \"%s\" "
803 fname, lineno, cargv[i] ));
805 Debug( LDAP_DEBUG_ANY,
806 "%s: line %d: unable "
807 "to parse value \"%s\" "
810 fname, lineno, cargv[i] );
815 /* set regex-based limits */
816 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
819 LDAP_LOG(( "config", LDAP_LEVEL_WARNING,
820 "%s: line %d \"limits\" allowed only in database environment.\n",
823 Debug( LDAP_DEBUG_ANY,
824 "%s: line %d \"limits\" allowed only in database environment.\n%s",
830 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
834 /* mark this as a subordinate database */
835 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
838 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
839 "subordinate keyword must appear inside a database "
840 "definition (ignored).\n", fname, lineno ));
842 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
843 "must appear inside a database definition (ignored)\n",
847 be->be_glueflags |= SLAP_GLUE_SUBORDINATE;
851 /* set database suffix */
852 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
855 struct berval *pdn = NULL;
856 struct berval *ndn = NULL;
860 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
861 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
864 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
865 "missing dn in \"suffix <dn>\" line\n",
871 } else if ( cargc > 2 ) {
873 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
874 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
875 " line (ignored).\n", fname, lineno, cargv[1] ));
877 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
878 "after <dn> in \"suffix %s\" line (ignored)\n",
879 fname, lineno, cargv[1] );
885 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
886 "%s: line %d: suffix line must appear inside a database "
887 "definition.\n", fname, lineno ));
889 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
890 "must appear inside a database definition\n",
895 #if defined(SLAPD_MONITOR_DN)
896 /* "cn=Monitor" is reserved for monitoring slap */
897 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
899 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: \""
900 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
903 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
904 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
908 #endif /* SLAPD_MONITOR_DN */
911 if ( load_ucdata( NULL ) < 0 ) return 1;
913 dn.bv_val = cargv[1];
914 dn.bv_len = strlen( cargv[1] );
915 pdn = ch_malloc( sizeof( struct berval ));
916 ndn = ch_malloc( sizeof( struct berval ));
918 rc = dnPrettyNormal( NULL, &dn, pdn, ndn );
919 if( rc != LDAP_SUCCESS ) {
921 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
922 "%s: line %d: suffix DN is invalid.\n",
925 Debug( LDAP_DEBUG_ANY,
926 "%s: line %d: suffix DN is invalid\n",
932 tmp_be = select_backend( ndn, 0, 0 );
933 if ( tmp_be == be ) {
935 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
936 "%s: line %d: suffix already served by this backend "
937 "(ignored)\n", fname, lineno ));
939 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
940 "already served by this backend (ignored)\n",
946 } else if ( tmp_be != NULL ) {
948 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
949 "%s: line %d: suffix already served by a preceding "
950 "backend \"%s\"\n", fname, lineno,
951 tmp_be->be_suffix[0]->bv_val ));
953 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
954 "already served by a preceeding backend \"%s\"\n",
955 fname, lineno, tmp_be->be_suffix[0]->bv_val );
961 } else if( pdn->bv_len == 0 && default_search_nbase.bv_len ) {
963 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
964 "%s: line %d: suffix DN empty and default search "
965 "base provided \"%s\" (assuming okay).\n",
966 fname, lineno, default_search_base.bv_val ));
968 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
969 "suffix DN empty and default "
970 "search base provided \"%s\" (assuming okay)\n",
971 fname, lineno, default_search_base.bv_val );
975 ber_bvecadd( &be->be_suffix, pdn );
976 ber_bvecadd( &be->be_nsuffix, ndn );
978 /* set database suffixAlias */
979 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
981 struct berval alias, *palias, nalias;
982 struct berval aliased, *paliased, naliased;
986 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
987 "%s: line %d: missing alias and aliased_dn in "
988 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
991 Debug( LDAP_DEBUG_ANY,
992 "%s: line %d: missing alias and aliased_dn in "
993 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
998 } else if ( cargc < 3 ) {
1000 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1001 "%s: line %d: missing aliased_dn in "
1002 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1005 Debug( LDAP_DEBUG_ANY,
1006 "%s: line %d: missing aliased_dn in "
1007 "\"suffixAlias <alias> <aliased_dn>\" line\n",
1012 } else if ( cargc > 3 ) {
1014 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1015 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1018 Debug( LDAP_DEBUG_ANY,
1019 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
1027 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1028 "%s: line %d: suffixAlias line must appear inside a "
1029 "database definition (ignored).\n", fname, lineno ));
1031 Debug( LDAP_DEBUG_ANY,
1032 "%s: line %d: suffixAlias line"
1033 " must appear inside a database definition (ignored)\n",
1038 if ( load_ucdata( NULL ) < 0 ) return 1;
1040 alias.bv_val = cargv[1];
1041 alias.bv_len = strlen( cargv[1] );
1042 palias = ch_malloc(sizeof(struct berval));
1044 rc = dnPrettyNormal( NULL, &alias, palias, &nalias );
1045 if( rc != LDAP_SUCCESS ) {
1047 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1048 "%s: line %d: alias DN is invalid.\n",
1051 Debug( LDAP_DEBUG_ANY,
1052 "%s: line %d: alias DN is invalid\n",
1058 tmp_be = select_backend( &nalias, 0, 0 );
1059 free( nalias.bv_val );
1060 if ( tmp_be != be ) {
1062 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1063 "%s: line %d: suffixAlias served by a preceeding "
1065 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1067 Debug( LDAP_DEBUG_ANY,
1068 "%s: line %d: suffixAlias served by"
1069 " a preceeding backend \"%s\"\n",
1070 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1072 ber_bvfree( palias );
1076 aliased.bv_val = cargv[2];
1077 aliased.bv_len = strlen( cargv[2] );
1078 paliased = ch_malloc(sizeof(struct berval));
1080 rc = dnPrettyNormal( NULL, &aliased, paliased, &naliased );
1081 if( rc != LDAP_SUCCESS ) {
1083 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1084 "%s: line %d: aliased DN is invalid.\n",
1087 Debug( LDAP_DEBUG_ANY,
1088 "%s: line %d: aliased DN is invalid\n",
1091 ber_bvfree( palias );
1095 tmp_be = select_backend( &naliased, 0, 0 );
1096 free( naliased.bv_val );
1097 if ( tmp_be != be ) {
1099 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1100 "%s: line %d: suffixAlias derefs to a different backend "
1101 "a preceeding backend \"%s\"\n",
1102 fname, lineno, tmp_be->be_suffix[0]->bv_val ));
1104 Debug( LDAP_DEBUG_ANY,
1105 "%s: line %d: suffixAlias derefs to differnet backend"
1106 " a preceeding backend \"%s\"\n",
1107 fname, lineno, tmp_be->be_suffix[0]->bv_val );
1109 ber_bvfree( palias );
1110 ber_bvfree( paliased );
1114 ber_bvecadd( &be->be_suffixAlias, palias );
1115 ber_bvecadd( &be->be_suffixAlias, paliased );
1117 /* set max deref depth */
1118 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1122 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1123 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1124 " line\n", fname, lineno ));
1126 Debug( LDAP_DEBUG_ANY,
1127 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1135 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1136 "%s: line %d: depth line must appear inside a database "
1137 "definition (ignored)\n", fname, lineno ));
1139 Debug( LDAP_DEBUG_ANY,
1140 "%s: line %d: depth line must appear inside a database definition (ignored)\n",
1144 } else if ((i = atoi(cargv[1])) < 0) {
1146 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1147 "%s: line %d: depth must be positive (ignored).\n",
1150 Debug( LDAP_DEBUG_ANY,
1151 "%s: line %d: depth must be positive (ignored)\n",
1157 be->be_max_deref_depth = i;
1161 /* set magic "root" dn for this database */
1162 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1165 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1166 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1169 Debug( LDAP_DEBUG_ANY,
1170 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1178 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1179 "%s: line %d: rootdn line must appear inside a database "
1180 "definition (ignored).\n", fname, lineno ));
1182 Debug( LDAP_DEBUG_ANY,
1183 "%s: line %d: rootdn line must appear inside a database definition (ignored)\n",
1190 if ( load_ucdata( NULL ) < 0 ) return 1;
1192 dn.bv_val = cargv[1];
1193 dn.bv_len = strlen( cargv[1] );
1195 rc = dnPrettyNormal( NULL, &dn,
1199 if( rc != LDAP_SUCCESS ) {
1201 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1202 "%s: line %d: rootdn DN is invalid.\n",
1205 Debug( LDAP_DEBUG_ANY,
1206 "%s: line %d: rootdn DN is invalid\n",
1213 /* set super-secret magic database password */
1214 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1217 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1218 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1219 " line\n", fname, lineno ));
1221 Debug( LDAP_DEBUG_ANY,
1222 "%s: line %d: missing passwd in \"rootpw <passwd>\" line\n",
1230 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1231 "%s: line %d: rootpw line must appear inside a database "
1232 "definition (ignored)\n", fname, lineno ));
1234 Debug( LDAP_DEBUG_ANY,
1235 "%s: line %d: rootpw line must appear inside a database definition (ignored)\n",
1240 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1241 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1244 /* make this database read-only */
1245 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1248 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1249 "%s: line %d: missing on|off in \"readonly <on|off>\" line.\n",
1252 Debug( LDAP_DEBUG_ANY,
1253 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1260 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1261 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1263 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1266 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1267 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1269 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1274 /* allow these features */
1275 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1276 strcasecmp( cargv[0], "allow" ) == 0 )
1282 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1283 "%s: line %d: allow line must appear prior to "
1284 "database definitions.\n", fname, lineno ));
1286 Debug( LDAP_DEBUG_ANY,
1287 "%s: line %d: allow line must appear prior to database definitions\n",
1295 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1296 "%s: line %d: missing feature(s) in \"allow <features>\""
1297 " line\n", fname, lineno ));
1299 Debug( LDAP_DEBUG_ANY,
1300 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1309 for( i=1; i < cargc; i++ ) {
1310 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1311 allows |= SLAP_ALLOW_BIND_V2;
1313 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1314 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1316 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1317 allows |= SLAP_ALLOW_BIND_ANON_DN;
1319 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1321 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1322 "%s: line %d: unknown feature %s in "
1323 "\"allow <features>\" line.\n",
1324 fname, lineno, cargv[1] ));
1326 Debug( LDAP_DEBUG_ANY,
1327 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1328 fname, lineno, cargv[i] );
1335 global_allows = allows;
1337 /* disallow these features */
1338 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1339 strcasecmp( cargv[0], "disallow" ) == 0 )
1341 slap_mask_t disallows;
1345 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1346 "%s: line %d: disallow line must appear prior to "
1347 "database definitions.\n", fname, lineno ));
1349 Debug( LDAP_DEBUG_ANY,
1350 "%s: line %d: disallow line must appear prior to database definitions\n",
1358 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1359 "%s: line %d: missing feature(s) in \"disallow <features>\""
1360 " line.\n", fname, lineno ));
1362 Debug( LDAP_DEBUG_ANY,
1363 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1372 for( i=1; i < cargc; i++ ) {
1373 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1374 disallows |= SLAP_DISALLOW_BIND_ANON;
1376 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1377 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1379 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1380 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1382 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1383 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1385 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1386 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1388 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1390 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1391 "%s: line %d: unknown feature %s in "
1392 "\"disallow <features>\" line.\n",
1393 fname, lineno, cargv[i] ));
1395 Debug( LDAP_DEBUG_ANY,
1396 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1397 fname, lineno, cargv[i] );
1404 global_disallows = disallows;
1406 /* require these features */
1407 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1408 strcasecmp( cargv[0], "require" ) == 0 )
1410 slap_mask_t requires;
1414 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1415 "%s: line %d: missing feature(s) in "
1416 "\"require <features>\" line.\n", fname, lineno ));
1418 Debug( LDAP_DEBUG_ANY,
1419 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1428 for( i=1; i < cargc; i++ ) {
1429 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1430 requires |= SLAP_REQUIRE_BIND;
1432 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1433 requires |= SLAP_REQUIRE_LDAP_V3;
1435 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1436 requires |= SLAP_REQUIRE_AUTHC;
1438 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1439 requires |= SLAP_REQUIRE_SASL;
1441 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1442 requires |= SLAP_REQUIRE_STRONG;
1444 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1446 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1447 "%s: line %d: unknown feature %s in "
1448 "\"require <features>\" line.\n",
1451 Debug( LDAP_DEBUG_ANY,
1452 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1453 fname, lineno, cargv[i] );
1461 global_requires = requires;
1463 be->be_requires = requires;
1466 /* required security factors */
1467 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1468 slap_ssf_set_t *set;
1472 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1473 "%s: line %d: missing factor(s) in \"security <factors>\""
1474 " line.\n", fname, lineno ));
1476 Debug( LDAP_DEBUG_ANY,
1477 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1485 set = &global_ssf_set;
1487 set = &be->be_ssf_set;
1490 for( i=1; i < cargc; i++ ) {
1491 if( strncasecmp( cargv[i], "ssf=",
1492 sizeof("ssf") ) == 0 )
1495 atoi( &cargv[i][sizeof("ssf")] );
1497 } else if( strncasecmp( cargv[i], "transport=",
1498 sizeof("transport") ) == 0 )
1500 set->sss_transport =
1501 atoi( &cargv[i][sizeof("transport")] );
1503 } else if( strncasecmp( cargv[i], "tls=",
1504 sizeof("tls") ) == 0 )
1507 atoi( &cargv[i][sizeof("tls")] );
1509 } else if( strncasecmp( cargv[i], "sasl=",
1510 sizeof("sasl") ) == 0 )
1513 atoi( &cargv[i][sizeof("sasl")] );
1515 } else if( strncasecmp( cargv[i], "update_ssf=",
1516 sizeof("update_ssf") ) == 0 )
1518 set->sss_update_ssf =
1519 atoi( &cargv[i][sizeof("update_ssf")] );
1521 } else if( strncasecmp( cargv[i], "update_transport=",
1522 sizeof("update_transport") ) == 0 )
1524 set->sss_update_transport =
1525 atoi( &cargv[i][sizeof("update_transport")] );
1527 } else if( strncasecmp( cargv[i], "update_tls=",
1528 sizeof("update_tls") ) == 0 )
1530 set->sss_update_tls =
1531 atoi( &cargv[i][sizeof("update_tls")] );
1533 } else if( strncasecmp( cargv[i], "update_sasl=",
1534 sizeof("update_sasl") ) == 0 )
1536 set->sss_update_sasl =
1537 atoi( &cargv[i][sizeof("update_sasl")] );
1541 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1542 "%s: line %d: unknown factor %S in "
1543 "\"security <factors>\" line.\n",
1544 fname, lineno, cargv[1] ));
1546 Debug( LDAP_DEBUG_ANY,
1547 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1548 fname, lineno, cargv[i] );
1554 /* where to send clients when we don't hold it */
1555 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1558 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1559 "%s: line %d: missing URL in \"referral <URL>\""
1560 " line.\n", fname, lineno ));
1562 Debug( LDAP_DEBUG_ANY,
1563 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1570 if( validate_global_referral( cargv[1] ) ) {
1572 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1573 "invalid URL (%s) in \"referral\" line.\n",
1574 fname, lineno, cargv[1] ));
1576 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1577 "invalid URL (%s) in \"referral\" line.\n",
1578 fname, lineno, cargv[1] );
1583 vals[0]->bv_val = cargv[1];
1584 vals[0]->bv_len = strlen( vals[0]->bv_val );
1585 value_add( &default_referral, vals );
1588 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1592 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1593 "%s: line %d: Error in logfile directive, "
1594 "\"logfile <filename>\"\n", fname, lineno ));
1596 Debug( LDAP_DEBUG_ANY,
1597 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1603 logfile = fopen( cargv[1], "w" );
1604 if ( logfile != NULL ) lutil_debug_file( logfile );
1607 /* start of a new database definition */
1608 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1612 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1613 "%s: line %d: Error in debug directive, "
1614 "\"debug <subsys> <level>\"\n", fname, lineno ));
1616 Debug( LDAP_DEBUG_ANY,
1617 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1623 level = atoi( cargv[2] );
1624 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1625 lutil_set_debug_level( cargv[1], level );
1626 /* specify an Object Identifier macro */
1627 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1628 rc = parse_oidm( fname, lineno, cargc, cargv );
1631 /* specify an objectclass */
1632 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1633 if ( *cargv[1] == '(' ) {
1635 p = strchr(saveline,'(');
1636 rc = parse_oc( fname, lineno, p, cargv );
1641 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1642 "%s: line %d: old objectclass format not supported\n",
1645 Debug( LDAP_DEBUG_ANY,
1646 "%s: line %d: old objectclass format not supported.\n",
1652 /* specify an attribute type */
1653 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1654 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1656 if ( *cargv[1] == '(' ) {
1658 p = strchr(saveline,'(');
1659 rc = parse_at( fname, lineno, p, cargv );
1664 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1665 "%s: line %d: old attribute type format not supported.\n",
1668 Debug( LDAP_DEBUG_ANY,
1669 "%s: line %d: old attribute type format not supported.\n",
1675 /* turn on/off schema checking */
1676 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1679 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1680 "%s: line %d: missing on|off in "
1681 "\"schemacheck <on|off>\" line.\n",
1684 Debug( LDAP_DEBUG_ANY,
1685 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1691 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1692 global_schemacheck = 0;
1694 global_schemacheck = 1;
1697 /* specify access control info */
1698 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1699 parse_acl( be, fname, lineno, cargc, cargv );
1701 /* debug level to log things to syslog */
1702 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1705 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1706 "%s: line %d: missing level in \"loglevel <level>\""
1707 " line.\n", fname, lineno ));
1709 Debug( LDAP_DEBUG_ANY,
1710 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1719 for( i=1; i < cargc; i++ ) {
1720 ldap_syslog += atoi( cargv[1] );
1723 /* list of replicas of the data in this backend (master only) */
1724 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1727 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1728 "%s: line %d: missing host in \"replica "
1729 " <host[:port]\" line\n", fname, lineno ));
1731 Debug( LDAP_DEBUG_ANY,
1732 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1740 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1741 "%s: line %d: replica line must appear inside "
1742 "a database definition (ignored).\n", fname, lineno ));
1744 Debug( LDAP_DEBUG_ANY,
1745 "%s: line %d: replica line must appear inside a database definition (ignored)\n",
1752 for ( i = 1; i < cargc; i++ ) {
1753 if ( strncasecmp( cargv[i], "host=", 5 )
1755 nr = add_replica_info( be,
1762 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1763 "%s: line %d: missing host in \"replica\" "
1764 "line (ignored)\n", fname, lineno ));
1766 Debug( LDAP_DEBUG_ANY,
1767 "%s: line %d: missing host in \"replica\" line (ignored)\n",
1771 } else if ( nr == -1 ) {
1773 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1774 "%s: line %d: unable to add"
1780 Debug( LDAP_DEBUG_ANY,
1781 "%s: line %d: unable to add replica \"%s\" (ignored)\n",
1782 fname, lineno, cargv[i] + 5 );
1785 for ( i = 1; i < cargc; i++ ) {
1786 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1788 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1791 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1792 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1793 fname, lineno, cargv[i] + 7 ));
1795 Debug( LDAP_DEBUG_ANY,
1796 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1797 fname, lineno, cargv[i] + 7 );
1803 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1804 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1807 Debug( LDAP_DEBUG_ANY,
1808 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1818 /* dn of master entity allowed to write to replica */
1819 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1822 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1823 "%s: line %d: missing dn in \"updatedn <dn>\""
1824 " line.\n", fname, lineno ));
1826 Debug( LDAP_DEBUG_ANY,
1827 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1835 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
1836 "%s: line %d: updatedn line must appear inside "
1837 "a database definition (ignored)\n",
1840 Debug( LDAP_DEBUG_ANY,
1841 "%s: line %d: updatedn line must appear inside a database definition (ignored)\n",
1846 struct berval dn, *ndn = NULL;
1848 if ( load_ucdata( NULL ) < 0 ) return 1;
1850 dn.bv_val = cargv[1];
1851 dn.bv_len = strlen( cargv[1] );
1853 rc = dnNormalize( NULL, &dn, &ndn );
1854 if( rc != LDAP_SUCCESS ) {
1856 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1857 "%s: line %d: updatedn DN is invalid.\n",
1860 Debug( LDAP_DEBUG_ANY,
1861 "%s: line %d: updatedn DN is invalid\n",
1867 be->be_update_ndn = *ndn;
1871 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1874 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1875 "missing url in \"updateref <ldapurl>\" line.\n",
1878 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1879 "missing url in \"updateref <ldapurl>\" line\n",
1887 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: updateref"
1888 " line must appear inside a database definition\n",
1891 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1892 " line must appear inside a database definition\n",
1897 } else if ( !be->be_update_ndn.bv_len ) {
1899 LDAP_LOG(( "config", LDAP_LEVEL_INFO, "%s: line %d: "
1900 "updateref line must come after updatedn.\n",
1903 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1904 "updateref line must after updatedn.\n",
1910 if( validate_global_referral( cargv[1] ) ) {
1912 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1913 "invalid URL (%s) in \"updateref\" line.\n",
1914 fname, lineno, cargv[1] ));
1916 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1917 "invalid URL (%s) in \"updateref\" line.\n",
1918 fname, lineno, cargv[1] );
1923 vals[0]->bv_val = cargv[1];
1924 vals[0]->bv_len = strlen( vals[0]->bv_val );
1925 value_add( &be->be_update_refs, vals );
1927 /* replication log file to which changes are appended */
1928 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1931 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1932 "%s: line %d: missing filename in \"replogfile <filename>\""
1933 " line.\n", fname, lineno ));
1935 Debug( LDAP_DEBUG_ANY,
1936 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1943 be->be_replogfile = ch_strdup( cargv[1] );
1945 replogfile = ch_strdup( cargv[1] );
1948 /* file from which to read additional rootdse attrs */
1949 } else if ( strcasecmp( cargv[0], "rootdse" ) == 0) {
1952 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1953 "missing filename in \"rootDSE <filename>\" line.\n",
1956 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1957 "missing filename in \"rootDSE <filename>\" line.\n",
1963 if( read_root_dse_file( cargv[1] ) ) {
1965 LDAP_LOG(( "config", LDAP_LEVEL_CRIT, "%s: line %d: "
1966 "could not read \"rootDSE <filename>\" line.\n",
1969 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1970 "could not read \"rootDSE <filename>\" line\n",
1976 /* maintain lastmodified{by,time} attributes */
1977 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1980 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
1981 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1982 " line.\n", fname, lineno ));
1984 Debug( LDAP_DEBUG_ANY,
1985 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1991 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1993 be->be_lastmod = ON;
1995 global_lastmod = ON;
1998 be->be_lastmod = OFF;
2000 global_lastmod = OFF;
2003 /* set idle timeout value */
2004 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2008 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2009 "%s: line %d: missing timeout value in "
2010 "\"idletimeout <seconds>\" line.\n", fname, lineno ));
2012 Debug( LDAP_DEBUG_ANY,
2013 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2020 i = atoi( cargv[1] );
2024 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2025 "%s: line %d: timeout value (%d) invalid "
2026 "\"idletimeout <seconds>\" line.\n",
2027 fname, lineno, i ));
2029 Debug( LDAP_DEBUG_ANY,
2030 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2037 global_idletimeout = i;
2039 /* include another config file */
2040 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2043 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2044 "%s: line %d: missing filename in \"include "
2045 "<filename>\" line.\n", fname, lineno ));
2047 Debug( LDAP_DEBUG_ANY,
2048 "%s: line %d: missing filename in \"include <filename>\" line\n",
2054 savefname = ch_strdup( cargv[1] );
2055 savelineno = lineno;
2057 if ( read_config( savefname ) != 0 ) {
2062 lineno = savelineno - 1;
2064 /* location of kerberos srvtab file */
2065 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2068 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2069 "%s: line %d: missing filename in \"srvtab "
2070 "<filename>\" line.\n", fname, lineno ));
2072 Debug( LDAP_DEBUG_ANY,
2073 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2079 ldap_srvtab = ch_strdup( cargv[1] );
2081 #ifdef SLAPD_MODULES
2082 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2085 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2086 "%s: line %d: missing filename in \"moduleload "
2087 "<filename>\" line.\n", fname, lineno ));
2089 Debug( LDAP_DEBUG_ANY,
2090 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2094 exit( EXIT_FAILURE );
2096 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2098 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2099 "%s: line %d: failed to load or initialize module %s\n"<
2100 fname, lineno, cargv[1] ));
2102 Debug( LDAP_DEBUG_ANY,
2103 "%s: line %d: failed to load or initialize module %s\n",
2104 fname, lineno, cargv[1]);
2107 exit( EXIT_FAILURE );
2109 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2112 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2113 "%s: line %d: missing path in \"modulepath <path>\""
2114 " line\n", fname, lineno ));
2116 Debug( LDAP_DEBUG_ANY,
2117 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2121 exit( EXIT_FAILURE );
2123 if (module_path( cargv[1] )) {
2125 LDAP_LOG(( "cofig", LDAP_LEVEL_CRIT,
2126 "%s: line %d: failed to set module search path to %s.\n",
2127 fname, lineno, cargv[1] ));
2129 Debug( LDAP_DEBUG_ANY,
2130 "%s: line %d: failed to set module search path to %s\n",
2131 fname, lineno, cargv[1]);
2134 exit( EXIT_FAILURE );
2137 #endif /*SLAPD_MODULES*/
2140 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2141 rc = ldap_pvt_tls_set_option( NULL,
2142 LDAP_OPT_X_TLS_RANDOM_FILE,
2147 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2148 rc = ldap_pvt_tls_set_option( NULL,
2149 LDAP_OPT_X_TLS_CIPHER_SUITE,
2154 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2155 rc = ldap_pvt_tls_set_option( NULL,
2156 LDAP_OPT_X_TLS_CERTFILE,
2161 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2162 rc = ldap_pvt_tls_set_option( NULL,
2163 LDAP_OPT_X_TLS_KEYFILE,
2168 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2169 rc = ldap_pvt_tls_set_option( NULL,
2170 LDAP_OPT_X_TLS_CACERTDIR,
2175 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2176 rc = ldap_pvt_tls_set_option( NULL,
2177 LDAP_OPT_X_TLS_CACERTFILE,
2181 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2183 rc = ldap_pvt_tls_set_option( NULL,
2184 LDAP_OPT_X_TLS_REQUIRE_CERT,
2191 /* pass anything else to the current backend info/db config routine */
2194 if ( bi->bi_config == 0 ) {
2196 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2197 "%s: line %d: unknown directive \"%s\" inside "
2198 "backend info definition (ignored).\n",
2199 fname, lineno, cargv[0] ));
2201 Debug( LDAP_DEBUG_ANY,
2202 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2203 fname, lineno, cargv[0] );
2207 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2213 } else if ( be != NULL ) {
2214 if ( be->be_config == 0 ) {
2216 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2217 "%s: line %d: uknown directive \"%s\" inside "
2218 "backend database definition (ignored).\n",
2219 fname, lineno, cargv[0] ));
2221 Debug( LDAP_DEBUG_ANY,
2222 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2223 fname, lineno, cargv[0] );
2227 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2235 LDAP_LOG(( "config", LDAP_LEVEL_INFO,
2236 "%s: line %d: unknown directive \"%s\" outside backend "
2237 "info and database definitions (ignored).\n",
2238 fname, lineno, cargv[0] ));
2240 Debug( LDAP_DEBUG_ANY,
2241 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2242 fname, lineno, cargv[0] );
2251 if ( load_ucdata( NULL ) < 0 ) return 1;
2265 for ( token = strtok_quote( line, " \t" ); token != NULL;
2266 token = strtok_quote( NULL, " \t" ) ) {
2267 if ( *argcp == MAXARGS ) {
2269 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2270 "fp_parse_line: too many tokens (%d max).\n",
2273 Debug( LDAP_DEBUG_ANY, "Too many tokens (max %d)\n",
2279 argv[(*argcp)++] = token;
2281 argv[*argcp] = NULL;
2286 strtok_quote( char *line, char *sep )
2292 if ( line != NULL ) {
2295 while ( *next && strchr( sep, *next ) ) {
2299 if ( *next == '\0' ) {
2305 for ( inquote = 0; *next; ) {
2313 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2319 next + 1, strlen( next + 1 ) + 1 );
2320 next++; /* dont parse the escaped character */
2325 if ( strchr( sep, *next ) != NULL ) {
2338 static char buf[BUFSIZ];
2340 static int lmax, lcur;
2342 #define CATLINE( buf ) { \
2344 len = strlen( buf ); \
2345 while ( lcur + len + 1 > lmax ) { \
2347 line = (char *) ch_realloc( line, lmax ); \
2349 strcpy( line + lcur, buf ); \
2354 fp_getline( FILE *fp, int *lineno )
2362 /* hack attack - keeps us from having to keep a stack of bufs... */
2363 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2368 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2369 /* trim off \r\n or \n */
2370 if ( (p = strchr( buf, '\n' )) != NULL ) {
2371 if( p > buf && p[-1] == '\r' ) --p;
2374 if ( ! isspace( (unsigned char) buf[0] ) ) {
2378 /* change leading whitespace to a space */
2386 return( line[0] ? line : NULL );
2390 fp_getline_init( int *lineno )
2396 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2398 load_ucdata( char *path )
2400 static int loaded = 0;
2406 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2409 LDAP_LOG(( "config", LDAP_LEVEL_CRIT,
2410 "load_ucdata: Error %d loading ucdata.\n", err ));
2412 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2425 ucdata_unload( UCDATA_ALL );
2427 if ( slapd_args_file )
2428 free ( slapd_args_file );
2429 if ( slapd_pid_file )
2430 free ( slapd_pid_file );
2431 acl_destroy( global_acl, NULL );