1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
14 #include <ac/signal.h>
15 #include <ac/socket.h>
25 * defaults for various global variables
27 struct slap_limits_set deflimit = {
28 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
31 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
33 -1 /* no limit on unchecked size */
36 AccessControl *global_acl = NULL;
37 slap_access_t global_default_access = ACL_READ;
38 slap_mask_t global_restrictops = 0;
39 slap_mask_t global_allows = 0;
40 slap_mask_t global_disallows = 0;
41 slap_mask_t global_requires = 0;
42 slap_ssf_set_t global_ssf_set;
44 int global_gentlehup = 0;
45 int global_idletimeout = 0;
46 char *global_host = NULL;
47 char *global_realm = NULL;
48 char *ldap_srvtab = "";
49 char *default_passwd_hash = NULL;
50 int cargc = 0, cargv_size = 0;
52 struct berval default_search_base = { 0, NULL };
53 struct berval default_search_nbase = { 0, NULL };
54 unsigned num_subordinates = 0;
55 #ifdef SLAPD_SCHEMA_DN
56 struct berval global_schemadn = { 0, NULL };
57 struct berval global_schemandn = { 0, NULL };
60 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
61 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
63 char *slapd_pid_file = NULL;
64 char *slapd_args_file = NULL;
66 char *strtok_quote_ptr;
69 int use_reverse_lookup = 1;
70 #else /* !SLAPD_RLOOKUPS */
71 int use_reverse_lookup = 0;
72 #endif /* !SLAPD_RLOOKUPS */
74 static char *fp_getline(FILE *fp, int *lineno);
75 static void fp_getline_init(int *lineno);
76 static int fp_parse_line(int lineno, char *line);
78 static char *strtok_quote(char *line, char *sep);
79 static int load_ucdata(char *path);
82 read_config( const char *fname, int depth )
85 char *line, *savefname, *saveline;
89 struct berval vals[2];
91 static int lastmod = 1;
92 static BackendInfo *bi = NULL;
93 static BackendDB *be = NULL;
95 vals[1].bv_val = NULL;
98 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
99 cargv_size = ARGS_STEP + 1;
102 if ( (fp = fopen( fname, "r" )) == NULL ) {
105 LDAP_LOG( CONFIG, ENTRY,
106 "read_config: " "could not open config file \"%s\": %s (%d)\n",
107 fname, strerror(errno), errno );
109 Debug( LDAP_DEBUG_ANY,
110 "could not open config file \"%s\": %s (%d)\n",
111 fname, strerror(errno), errno );
117 LDAP_LOG( CONFIG, ENTRY,
118 "read_config: reading config file %s\n", fname, 0, 0 );
120 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
124 fp_getline_init( &lineno );
126 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
127 /* skip comments and blank lines */
128 if ( line[0] == '#' || line[0] == '\0' ) {
132 /* fp_parse_line is destructive, we save a copy */
133 saveline = ch_strdup( line );
135 if ( fp_parse_line( lineno, line ) != 0 ) {
141 LDAP_LOG( CONFIG, INFO,
142 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
144 Debug( LDAP_DEBUG_ANY,
145 "%s: line %d: bad config line (ignored)\n",
152 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
155 LDAP_LOG( CONFIG, CRIT,
156 "%s : line %d: missing type in \"backend\" line.\n",
159 Debug( LDAP_DEBUG_ANY,
160 "%s: line %d: missing type in \"backend <type>\" line\n",
169 LDAP_LOG( CONFIG, CRIT,
170 "%s: line %d: backend line must appear before any "
171 "database definition.\n", fname, lineno , 0 );
173 Debug( LDAP_DEBUG_ANY,
174 "%s: line %d: backend line must appear before any database definition\n",
181 bi = backend_info( cargv[1] );
185 LDAP_LOG( CONFIG, CRIT,
186 "read_config: backend %s initialization failed.\n",
189 Debug( LDAP_DEBUG_ANY,
190 "backend %s initialization failed.\n",
196 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
199 LDAP_LOG( CONFIG, CRIT,
200 "%s: line %d: missing type in \"database <type>\" line\n",
203 Debug( LDAP_DEBUG_ANY,
204 "%s: line %d: missing type in \"database <type>\" line\n",
212 be = backend_db_init( cargv[1] );
216 LDAP_LOG( CONFIG, CRIT,
217 "database %s initialization failed.\n", cargv[1], 0, 0 );
219 Debug( LDAP_DEBUG_ANY,
220 "database %s initialization failed.\n",
227 /* set thread concurrency */
228 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
232 LDAP_LOG( CONFIG, CRIT,
233 "%s: line %d: missing level in \"concurrency <level\" "
234 " line\n", fname, lineno, 0 );
236 Debug( LDAP_DEBUG_ANY,
237 "%s: line %d: missing level in \"concurrency <level>\" line\n",
244 c = atoi( cargv[1] );
248 LDAP_LOG( CONFIG, CRIT,
249 "%s: line %d: invalid level (%d) in "
250 "\"concurrency <level>\" line.\n", fname, lineno, c );
252 Debug( LDAP_DEBUG_ANY,
253 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
260 ldap_pvt_thread_set_concurrency( c );
262 /* set sockbuf max */
263 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
267 LDAP_LOG( CONFIG, CRIT,
268 "%s: line %d: missing max in \"sockbuf_max_incoming "
269 "<bytes>\" line\n", fname, lineno, 0 );
271 Debug( LDAP_DEBUG_ANY,
272 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
279 max = atol( cargv[1] );
283 LDAP_LOG( CONFIG, CRIT,
284 "%s: line %d: invalid max value (%ld) in "
285 "\"sockbuf_max_incoming <bytes>\" line.\n",
286 fname, lineno, max );
288 Debug( LDAP_DEBUG_ANY,
289 "%s: line %d: invalid max value (%ld) in "
290 "\"sockbuf_max_incoming <bytes>\" line.\n",
291 fname, lineno, max );
297 sockbuf_max_incoming = max;
299 /* set sockbuf max authenticated */
300 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
304 LDAP_LOG( CONFIG, CRIT,
305 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
306 "<bytes>\" line\n", fname, lineno, 0 );
308 Debug( LDAP_DEBUG_ANY,
309 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
316 max = atol( cargv[1] );
320 LDAP_LOG( CONFIG, CRIT,
321 "%s: line %d: invalid max value (%ld) in "
322 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
323 fname, lineno, max );
325 Debug( LDAP_DEBUG_ANY,
326 "%s: line %d: invalid max value (%ld) in "
327 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
328 fname, lineno, max );
334 sockbuf_max_incoming_auth = max;
336 /* default search base */
337 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
340 LDAP_LOG( CONFIG, CRIT,
341 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
342 "line\n", fname, lineno, 0 );
344 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
345 "missing dn in \"defaultSearchBase <dn>\" line\n",
351 } else if ( cargc > 2 ) {
353 LDAP_LOG( CONFIG, INFO,
354 "%s: line %d: extra cruft after <dn> in "
355 "\"defaultSearchBase %s\" line (ignored)\n",
356 fname, lineno, cargv[1] );
358 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
359 "extra cruft after <dn> in \"defaultSearchBase %s\", "
361 fname, lineno, cargv[1] );
365 if ( bi != NULL || be != NULL ) {
367 LDAP_LOG( CONFIG, CRIT,
368 "%s: line %d: defaultSearchBase line must appear "
369 "prior to any backend or database definitions\n",
372 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
373 "defaultSearchBaase line must appear prior to "
374 "any backend or database definition\n",
381 if ( default_search_nbase.bv_len ) {
383 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
384 "default search base \"%s\" already defined "
385 "(discarding old)\n", fname, lineno,
386 default_search_base.bv_val );
388 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
389 "default search base \"%s\" already defined "
390 "(discarding old)\n",
391 fname, lineno, default_search_base.bv_val );
394 free( default_search_base.bv_val );
395 free( default_search_nbase.bv_val );
398 if ( load_ucdata( NULL ) < 0 ) return 1;
403 dn.bv_val = cargv[1];
404 dn.bv_len = strlen( dn.bv_val );
406 rc = dnPrettyNormal( NULL, &dn,
407 &default_search_base,
408 &default_search_nbase );
410 if( rc != LDAP_SUCCESS ) {
412 LDAP_LOG( CONFIG, CRIT,
413 "%s: line %d: defaultSearchBase DN is invalid.\n",
416 Debug( LDAP_DEBUG_ANY,
417 "%s: line %d: defaultSearchBase DN is invalid\n",
424 /* set maximum threads in thread pool */
425 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
429 LDAP_LOG( CONFIG, CRIT,
430 "%s: line %d: missing count in \"threads <count>\" line\n",
433 Debug( LDAP_DEBUG_ANY,
434 "%s: line %d: missing count in \"threads <count>\" line\n",
441 c = atoi( cargv[1] );
445 LDAP_LOG( CONFIG, CRIT,
446 "%s: line %d: invalid level (%d) in \"threads <count>\""
447 "line\n", fname, lineno, c );
449 Debug( LDAP_DEBUG_ANY,
450 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
457 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
459 /* save for later use */
460 connection_pool_max = c;
462 /* get pid file name */
463 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
466 LDAP_LOG( CONFIG, CRIT,
467 "%s: line %d missing file name in \"pidfile <file>\" "
468 "line.\n", fname, lineno, 0 );
470 Debug( LDAP_DEBUG_ANY,
471 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
478 slapd_pid_file = ch_strdup( cargv[1] );
480 /* get args file name */
481 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
484 LDAP_LOG( CONFIG, CRIT,
485 "%s: %d: missing file name in "
486 "\"argsfile <file>\" line.\n",
489 Debug( LDAP_DEBUG_ANY,
490 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
497 slapd_args_file = ch_strdup( cargv[1] );
499 /* default password hash */
500 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
503 LDAP_LOG( CONFIG, CRIT,
504 "%s: line %d: missing hash in "
505 "\"password-hash <hash>\" line.\n",
508 Debug( LDAP_DEBUG_ANY,
509 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
515 if ( default_passwd_hash != NULL ) {
517 LDAP_LOG( CONFIG, CRIT,
518 "%s: line %d: already set default password_hash!\n",
521 Debug( LDAP_DEBUG_ANY,
522 "%s: line %d: already set default password_hash!\n",
530 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
532 LDAP_LOG( CONFIG, CRIT,
533 "%s: line %d: password scheme \"%s\" not available\n",
534 fname, lineno, cargv[1] );
536 Debug( LDAP_DEBUG_ANY,
537 "%s: line %d: password scheme \"%s\" not available\n",
538 fname, lineno, cargv[1] );
543 default_passwd_hash = ch_strdup( cargv[1] );
545 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
549 LDAP_LOG( CONFIG, CRIT,
550 "%s: line %d: missing format in "
551 "\"password-crypt-salt-format <format>\" line\n",
554 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
555 "\"password-crypt-salt-format <format>\" line\n",
562 lutil_salt_format( cargv[1] );
564 #ifdef HAVE_CYRUS_SASL
565 /* SASL config options */
566 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
567 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
569 #endif /* HAVE_CYRUS_SASL */
571 /* set UCDATA path */
572 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
576 LDAP_LOG( CONFIG, CRIT,
577 "%s: line %d: missing path in "
578 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
580 Debug( LDAP_DEBUG_ANY,
581 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
588 err = load_ucdata( cargv[1] );
592 LDAP_LOG( CONFIG, CRIT,
593 "%s: line %d: ucdata already loaded, ucdata-path "
594 "must be set earlier in the file and/or be "
595 "specified only once!\n", fname, lineno, 0 );
597 Debug( LDAP_DEBUG_ANY,
598 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
607 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
609 struct slap_limits_set *lim;
613 LDAP_LOG( CONFIG, CRIT,
614 "%s: line %d: missing limit in \"sizelimit <limit>\" "
615 "line.\n", fname, lineno, 0 );
617 Debug( LDAP_DEBUG_ANY,
618 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
628 lim = &be->be_def_limit;
631 for ( i = 1; i < cargc; i++ ) {
632 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
633 rc = parse_limit( cargv[i], lim );
635 lim->lms_s_soft = atoi( cargv[i] );
641 LDAP_LOG( CONFIG, CRIT,
642 "%s: line %d: unable "
643 "to parse value \"%s\" in \"sizelimit "
644 "<limit>\" line.\n", fname, lineno, cargv[i] );
646 Debug( LDAP_DEBUG_ANY,
647 "%s: line %d: unable "
648 "to parse value \"%s\" "
651 fname, lineno, cargv[i] );
657 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
659 struct slap_limits_set *lim;
663 LDAP_LOG( CONFIG, CRIT,
664 "%s: line %d missing limit in \"timelimit <limit>\" "
665 "line.\n", fname, lineno, 0 );
667 Debug( LDAP_DEBUG_ANY,
668 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
678 lim = &be->be_def_limit;
681 for ( i = 1; i < cargc; i++ ) {
682 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
683 rc = parse_limit( cargv[i], lim );
685 lim->lms_t_soft = atoi( cargv[i] );
691 LDAP_LOG( CONFIG, CRIT,
692 "%s: line %d: unable to parse value \"%s\" "
693 "in \"timelimit <limit>\" line.\n",
694 fname, lineno, cargv[i] );
696 Debug( LDAP_DEBUG_ANY,
697 "%s: line %d: unable "
698 "to parse value \"%s\" "
701 fname, lineno, cargv[i] );
706 /* set regex-based limits */
707 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
710 LDAP_LOG( CONFIG, WARNING,
711 "%s: line %d \"limits\" allowed only in database "
712 "environment.\n", fname, lineno, 0 );
714 Debug( LDAP_DEBUG_ANY,
715 "%s: line %d \"limits\" allowed only in database environment.\n%s",
721 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
725 /* mark this as a subordinate database */
726 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
729 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
730 "subordinate keyword must appear inside a database "
731 "definition.\n", fname, lineno, 0 );
733 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
734 "must appear inside a database definition.\n",
740 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
744 /* set database suffix */
745 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
747 struct berval dn, pdn, ndn;
751 LDAP_LOG( CONFIG, CRIT,
752 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
755 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
756 "missing dn in \"suffix <dn>\" line\n",
762 } else if ( cargc > 2 ) {
764 LDAP_LOG( CONFIG, INFO,
765 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
766 " line (ignored).\n", fname, lineno, cargv[1] );
768 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
769 "after <dn> in \"suffix %s\" line (ignored)\n",
770 fname, lineno, cargv[1] );
776 LDAP_LOG( CONFIG, INFO,
777 "%s: line %d: suffix line must appear inside a database "
778 "definition.\n", fname, lineno, 0 );
780 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
781 "must appear inside a database definition\n",
786 #if defined(SLAPD_MONITOR_DN)
787 /* "cn=Monitor" is reserved for monitoring slap */
788 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
790 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
791 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
794 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
795 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
799 #endif /* SLAPD_MONITOR_DN */
802 if ( load_ucdata( NULL ) < 0 ) return 1;
804 dn.bv_val = cargv[1];
805 dn.bv_len = strlen( cargv[1] );
807 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
808 if( rc != LDAP_SUCCESS ) {
810 LDAP_LOG( CONFIG, CRIT,
811 "%s: line %d: suffix DN is invalid.\n",
814 Debug( LDAP_DEBUG_ANY,
815 "%s: line %d: suffix DN is invalid\n",
821 tmp_be = select_backend( &ndn, 0, 0 );
822 if ( tmp_be == be ) {
824 LDAP_LOG( CONFIG, INFO,
825 "%s: line %d: suffix already served by this backend "
826 "(ignored)\n", fname, lineno, 0 );
828 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
829 "already served by this backend (ignored)\n",
835 } else if ( tmp_be != NULL ) {
837 LDAP_LOG( CONFIG, INFO,
838 "%s: line %d: suffix already served by a preceding "
839 "backend \"%s\"\n", fname, lineno,
840 tmp_be->be_suffix[0].bv_val );
842 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
843 "already served by a preceeding backend \"%s\"\n",
844 fname, lineno, tmp_be->be_suffix[0].bv_val );
850 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
852 LDAP_LOG( CONFIG, INFO,
853 "%s: line %d: suffix DN empty and default search "
854 "base provided \"%s\" (assuming okay).\n",
855 fname, lineno, default_search_base.bv_val );
857 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
858 "suffix DN empty and default "
859 "search base provided \"%s\" (assuming okay)\n",
860 fname, lineno, default_search_base.bv_val );
864 ber_bvarray_add( &be->be_suffix, &pdn );
865 ber_bvarray_add( &be->be_nsuffix, &ndn );
867 /* set database suffixAlias */
868 } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
870 struct berval alias, palias, nalias;
871 struct berval aliased, paliased, naliased;
875 LDAP_LOG( CONFIG, CRIT,
876 "%s: line %d: missing alias and aliased_dn in "
877 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
880 Debug( LDAP_DEBUG_ANY,
881 "%s: line %d: missing alias and aliased_dn in "
882 "\"suffixAlias <alias> <aliased_dn>\" line.\n",
887 } else if ( cargc < 3 ) {
889 LDAP_LOG( CONFIG, CRIT,
890 "%s: line %d: missing aliased_dn in "
891 "\"suffixAlias <alias> <aliased_dn>\" line\n",
894 Debug( LDAP_DEBUG_ANY,
895 "%s: line %d: missing aliased_dn in "
896 "\"suffixAlias <alias> <aliased_dn>\" line\n",
901 } else if ( cargc > 3 ) {
903 LDAP_LOG( CONFIG, CRIT,
904 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
907 Debug( LDAP_DEBUG_ANY,
908 "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
915 LDAP_LOG( CONFIG, INFO,
916 "%s: line %d: suffix line must appear inside a database "
917 "definition.\n", fname, lineno, 0 );
919 Debug( LDAP_DEBUG_ANY,
920 "%s: line %d: suffixAlias line"
921 " must appear inside a database definition.\n",
927 if ( load_ucdata( NULL ) < 0 ) return 1;
929 alias.bv_val = cargv[1];
930 alias.bv_len = strlen( cargv[1] );
932 rc = dnPrettyNormal( NULL, &alias, &palias, &nalias );
933 if( rc != LDAP_SUCCESS ) {
935 LDAP_LOG( CONFIG, CRIT,
936 "%s: line %d: alias DN is invalid.\n", fname, lineno, 0 );
938 Debug( LDAP_DEBUG_ANY,
939 "%s: line %d: alias DN is invalid\n",
945 tmp_be = select_backend( &nalias, 0, 0 );
946 free( nalias.bv_val );
947 if ( tmp_be && tmp_be != be ) {
949 LDAP_LOG( CONFIG, INFO,
950 "%s: line %d: suffixAlias served by a preceeding "
951 "backend \"%s\"\n", fname, lineno,
952 tmp_be->be_suffix[0].bv_val );
954 Debug( LDAP_DEBUG_ANY,
955 "%s: line %d: suffixAlias served by"
956 " a preceeding backend \"%s\"\n",
957 fname, lineno, tmp_be->be_suffix[0].bv_val );
959 free( palias.bv_val );
963 aliased.bv_val = cargv[2];
964 aliased.bv_len = strlen( cargv[2] );
966 rc = dnPrettyNormal( NULL, &aliased, &paliased, &naliased );
967 if( rc != LDAP_SUCCESS ) {
969 LDAP_LOG( CONFIG, CRIT,
970 "%s: line %d: aliased DN is invalid.\n", fname, lineno,0 );
972 Debug( LDAP_DEBUG_ANY,
973 "%s: line %d: aliased DN is invalid\n",
976 free( palias.bv_val );
980 tmp_be = select_backend( &naliased, 0, 0 );
981 free( naliased.bv_val );
982 if ( tmp_be && tmp_be != be ) {
984 LDAP_LOG( CONFIG, INFO,
985 "%s: line %d: suffixAlias derefs to a different backend "
986 "a preceeding backend \"%s\"\n",
987 fname, lineno, tmp_be->be_suffix[0].bv_val );
989 Debug( LDAP_DEBUG_ANY,
990 "%s: line %d: suffixAlias derefs to differnet backend"
991 " a preceeding backend \"%s\"\n",
992 fname, lineno, tmp_be->be_suffix[0].bv_val );
994 free( palias.bv_val );
995 free( paliased.bv_val );
999 ber_bvarray_add( &be->be_suffixAlias, &palias );
1000 ber_bvarray_add( &be->be_suffixAlias, &paliased );
1002 /* set max deref depth */
1003 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1007 LDAP_LOG( CONFIG, CRIT,
1008 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1009 " line\n", fname, lineno, 0 );
1011 Debug( LDAP_DEBUG_ANY,
1012 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1020 LDAP_LOG( CONFIG, INFO,
1021 "%s: line %d: depth line must appear inside a database "
1022 "definition.\n", fname, lineno ,0 );
1024 Debug( LDAP_DEBUG_ANY,
1025 "%s: line %d: depth line must appear inside a database definition.\n",
1030 } else if ((i = atoi(cargv[1])) < 0) {
1032 LDAP_LOG( CONFIG, INFO,
1033 "%s: line %d: depth must be positive.\n",
1036 Debug( LDAP_DEBUG_ANY,
1037 "%s: line %d: depth must be positive.\n",
1044 be->be_max_deref_depth = i;
1048 /* set magic "root" dn for this database */
1049 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1052 LDAP_LOG( CONFIG, INFO,
1053 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1056 Debug( LDAP_DEBUG_ANY,
1057 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1066 LDAP_LOG( CONFIG, INFO,
1067 "%s: line %d: rootdn line must appear inside a database "
1068 "definition.\n", fname, lineno ,0 );
1070 Debug( LDAP_DEBUG_ANY,
1071 "%s: line %d: rootdn line must appear inside a database definition.\n",
1079 if ( load_ucdata( NULL ) < 0 ) return 1;
1081 dn.bv_val = cargv[1];
1082 dn.bv_len = strlen( cargv[1] );
1084 rc = dnPrettyNormal( NULL, &dn,
1088 if( rc != LDAP_SUCCESS ) {
1090 LDAP_LOG( CONFIG, CRIT,
1091 "%s: line %d: rootdn DN is invalid.\n",
1094 Debug( LDAP_DEBUG_ANY,
1095 "%s: line %d: rootdn DN is invalid\n",
1102 /* set super-secret magic database password */
1103 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1106 LDAP_LOG( CONFIG, CRIT,
1107 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1108 " line\n", fname, lineno ,0 );
1110 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1111 "missing passwd in \"rootpw <passwd>\" line\n",
1120 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1121 "rootpw line must appear inside a database "
1122 "definition.\n", fname, lineno ,0 );
1124 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1125 "rootpw line must appear inside a database "
1132 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1134 if( tmp_be != be ) {
1136 LDAP_LOG( CONFIG, INFO,
1138 "rootpw can only be set when rootdn is under suffix\n",
1139 fname, lineno, "" );
1141 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1142 "rootpw can only be set when rootdn is under suffix\n",
1148 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1149 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1152 /* make this database read-only */
1153 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1156 LDAP_LOG( CONFIG, CRIT,
1157 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1158 "line.\n", fname, lineno ,0 );
1160 Debug( LDAP_DEBUG_ANY,
1161 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1168 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1169 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1171 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1174 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1175 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1177 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1182 /* allow these features */
1183 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1184 strcasecmp( cargv[0], "allow" ) == 0 )
1190 LDAP_LOG( CONFIG, INFO,
1191 "%s: line %d: allow line must appear prior to "
1192 "database definitions.\n", fname, lineno ,0 );
1194 Debug( LDAP_DEBUG_ANY,
1195 "%s: line %d: allow line must appear prior to database definitions\n",
1203 LDAP_LOG( CONFIG, CRIT,
1204 "%s: line %d: missing feature(s) in \"allow <features>\""
1205 " line\n", fname, lineno ,0 );
1207 Debug( LDAP_DEBUG_ANY,
1208 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1217 for( i=1; i < cargc; i++ ) {
1218 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1219 allows |= SLAP_ALLOW_BIND_V2;
1221 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1222 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1224 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1225 allows |= SLAP_ALLOW_BIND_ANON_DN;
1227 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1229 LDAP_LOG( CONFIG, CRIT,
1230 "%s: line %d: unknown feature %s in "
1231 "\"allow <features>\" line.\n",
1232 fname, lineno, cargv[1] );
1234 Debug( LDAP_DEBUG_ANY,
1235 "%s: line %d: unknown feature %s in \"allow <features>\" line\n",
1236 fname, lineno, cargv[i] );
1243 global_allows = allows;
1245 /* disallow these features */
1246 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1247 strcasecmp( cargv[0], "disallow" ) == 0 )
1249 slap_mask_t disallows;
1253 LDAP_LOG( CONFIG, INFO,
1254 "%s: line %d: disallow line must appear prior to "
1255 "database definitions.\n", fname, lineno ,0 );
1257 Debug( LDAP_DEBUG_ANY,
1258 "%s: line %d: disallow line must appear prior to database definitions\n",
1266 LDAP_LOG( CONFIG, CRIT,
1267 "%s: line %d: missing feature(s) in \"disallow <features>\""
1268 " line.\n", fname, lineno ,0 );
1270 Debug( LDAP_DEBUG_ANY,
1271 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1280 for( i=1; i < cargc; i++ ) {
1281 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1282 disallows |= SLAP_DISALLOW_BIND_ANON;
1284 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1285 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1287 } else if( strcasecmp( cargv[i], "bind_simple_unprotected" ) == 0 ) {
1288 disallows |= SLAP_DISALLOW_BIND_SIMPLE_UNPROTECTED;
1290 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1291 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1293 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1294 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1296 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1297 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1299 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1301 LDAP_LOG( CONFIG, CRIT,
1302 "%s: line %d: unknown feature %s in "
1303 "\"disallow <features>\" line.\n",
1304 fname, lineno, cargv[i] );
1306 Debug( LDAP_DEBUG_ANY,
1307 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1308 fname, lineno, cargv[i] );
1315 global_disallows = disallows;
1317 /* require these features */
1318 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1319 strcasecmp( cargv[0], "require" ) == 0 )
1321 slap_mask_t requires;
1325 LDAP_LOG( CONFIG, CRIT,
1326 "%s: line %d: missing feature(s) in "
1327 "\"require <features>\" line.\n", fname, lineno ,0 );
1329 Debug( LDAP_DEBUG_ANY,
1330 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1339 for( i=1; i < cargc; i++ ) {
1340 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1341 requires |= SLAP_REQUIRE_BIND;
1343 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1344 requires |= SLAP_REQUIRE_LDAP_V3;
1346 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1347 requires |= SLAP_REQUIRE_AUTHC;
1349 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1350 requires |= SLAP_REQUIRE_SASL;
1352 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1353 requires |= SLAP_REQUIRE_STRONG;
1355 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1357 LDAP_LOG( CONFIG, CRIT,
1358 "%s: line %d: unknown feature %s in "
1359 "\"require <features>\" line.\n",
1360 fname, lineno , cargv[i] );
1362 Debug( LDAP_DEBUG_ANY,
1363 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1364 fname, lineno, cargv[i] );
1372 global_requires = requires;
1374 be->be_requires = requires;
1377 /* required security factors */
1378 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1379 slap_ssf_set_t *set;
1383 LDAP_LOG( CONFIG, CRIT,
1384 "%s: line %d: missing factor(s) in \"security <factors>\""
1385 " line.\n", fname, lineno ,0 );
1387 Debug( LDAP_DEBUG_ANY,
1388 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1396 set = &global_ssf_set;
1398 set = &be->be_ssf_set;
1401 for( i=1; i < cargc; i++ ) {
1402 if( strncasecmp( cargv[i], "ssf=",
1403 sizeof("ssf") ) == 0 )
1406 atoi( &cargv[i][sizeof("ssf")] );
1408 } else if( strncasecmp( cargv[i], "transport=",
1409 sizeof("transport") ) == 0 )
1411 set->sss_transport =
1412 atoi( &cargv[i][sizeof("transport")] );
1414 } else if( strncasecmp( cargv[i], "tls=",
1415 sizeof("tls") ) == 0 )
1418 atoi( &cargv[i][sizeof("tls")] );
1420 } else if( strncasecmp( cargv[i], "sasl=",
1421 sizeof("sasl") ) == 0 )
1424 atoi( &cargv[i][sizeof("sasl")] );
1426 } else if( strncasecmp( cargv[i], "update_ssf=",
1427 sizeof("update_ssf") ) == 0 )
1429 set->sss_update_ssf =
1430 atoi( &cargv[i][sizeof("update_ssf")] );
1432 } else if( strncasecmp( cargv[i], "update_transport=",
1433 sizeof("update_transport") ) == 0 )
1435 set->sss_update_transport =
1436 atoi( &cargv[i][sizeof("update_transport")] );
1438 } else if( strncasecmp( cargv[i], "update_tls=",
1439 sizeof("update_tls") ) == 0 )
1441 set->sss_update_tls =
1442 atoi( &cargv[i][sizeof("update_tls")] );
1444 } else if( strncasecmp( cargv[i], "update_sasl=",
1445 sizeof("update_sasl") ) == 0 )
1447 set->sss_update_sasl =
1448 atoi( &cargv[i][sizeof("update_sasl")] );
1452 LDAP_LOG( CONFIG, CRIT,
1453 "%s: line %d: unknown factor %S in "
1454 "\"security <factors>\" line.\n",
1455 fname, lineno, cargv[1] );
1457 Debug( LDAP_DEBUG_ANY,
1458 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1459 fname, lineno, cargv[i] );
1465 /* where to send clients when we don't hold it */
1466 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1469 LDAP_LOG( CONFIG, CRIT,
1470 "%s: line %d: missing URL in \"referral <URL>\""
1471 " line.\n", fname, lineno , 0 );
1473 Debug( LDAP_DEBUG_ANY,
1474 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1481 if( validate_global_referral( cargv[1] ) ) {
1483 LDAP_LOG( CONFIG, CRIT,
1484 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1485 fname, lineno, cargv[1] );
1487 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1488 "invalid URL (%s) in \"referral\" line.\n",
1489 fname, lineno, cargv[1] );
1494 vals[0].bv_val = cargv[1];
1495 vals[0].bv_len = strlen( vals[0].bv_val );
1496 value_add( &default_referral, vals );
1499 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1503 LDAP_LOG( CONFIG, CRIT,
1504 "%s: line %d: Error in logfile directive, "
1505 "\"logfile <filename>\"\n", fname, lineno , 0 );
1507 Debug( LDAP_DEBUG_ANY,
1508 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1514 logfile = fopen( cargv[1], "w" );
1515 if ( logfile != NULL ) lutil_debug_file( logfile );
1518 /* start of a new database definition */
1519 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1523 LDAP_LOG( CONFIG, CRIT,
1524 "%s: line %d: Error in debug directive, "
1525 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1527 Debug( LDAP_DEBUG_ANY,
1528 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1534 level = atoi( cargv[2] );
1535 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1536 lutil_set_debug_level( cargv[1], level );
1537 /* specify an Object Identifier macro */
1538 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1539 rc = parse_oidm( fname, lineno, cargc, cargv );
1542 /* specify an objectclass */
1543 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1544 if ( *cargv[1] == '(' ) {
1546 p = strchr(saveline,'(');
1547 rc = parse_oc( fname, lineno, p, cargv );
1552 LDAP_LOG( CONFIG, INFO,
1553 "%s: line %d: old objectclass format not supported\n",
1554 fname, lineno , 0 );
1556 Debug( LDAP_DEBUG_ANY,
1557 "%s: line %d: old objectclass format not supported.\n",
1562 /* specify an attribute type */
1563 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1564 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1566 if ( *cargv[1] == '(' ) {
1568 p = strchr(saveline,'(');
1569 rc = parse_at( fname, lineno, p, cargv );
1574 LDAP_LOG( CONFIG, INFO,
1575 "%s: line %d: old attribute type format not supported.\n",
1576 fname, lineno , 0 );
1578 Debug( LDAP_DEBUG_ANY,
1579 "%s: line %d: old attribute type format not supported.\n",
1585 /* turn on/off schema checking */
1586 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1589 LDAP_LOG( CONFIG, CRIT,
1590 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1591 " line.\n", fname, lineno , 0 );
1593 Debug( LDAP_DEBUG_ANY,
1594 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1600 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1602 LDAP_LOG( CONFIG, CRIT,
1603 "%s: line %d: schema checking disabled! your mileage may "
1604 "vary!\n", fname, lineno , 0 );
1606 Debug( LDAP_DEBUG_ANY,
1607 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1610 global_schemacheck = 0;
1612 global_schemacheck = 1;
1615 /* specify access control info */
1616 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1617 parse_acl( be, fname, lineno, cargc, cargv );
1619 /* debug level to log things to syslog */
1620 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1623 LDAP_LOG( CONFIG, CRIT,
1624 "%s: line %d: missing level in \"loglevel <level>\""
1625 " line.\n", fname, lineno , 0 );
1627 Debug( LDAP_DEBUG_ANY,
1628 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1637 for( i=1; i < cargc; i++ ) {
1638 ldap_syslog += atoi( cargv[1] );
1641 /* list of replicas of the data in this backend (master only) */
1642 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1645 LDAP_LOG( CONFIG, CRIT,
1646 "%s: line %d: missing host in \"replica "
1647 " <host[:port]\" line\n", fname, lineno , 0 );
1649 Debug( LDAP_DEBUG_ANY,
1650 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1658 LDAP_LOG( CONFIG, INFO,
1659 "%s: line %d: replica line must appear inside "
1660 "a database definition.\n", fname, lineno, 0);
1662 Debug( LDAP_DEBUG_ANY,
1663 "%s: line %d: replica line must appear inside a database definition\n",
1671 for ( i = 1; i < cargc; i++ ) {
1672 if ( strncasecmp( cargv[i], "host=", 5 )
1674 nr = add_replica_info( be,
1681 LDAP_LOG( CONFIG, INFO,
1682 "%s: line %d: missing host in \"replica\" line\n",
1683 fname, lineno , 0 );
1685 Debug( LDAP_DEBUG_ANY,
1686 "%s: line %d: missing host in \"replica\" line\n",
1691 } else if ( nr == -1 ) {
1693 LDAP_LOG( CONFIG, INFO,
1694 "%s: line %d: unable to add"
1695 " replica \"%s\"\n",
1699 Debug( LDAP_DEBUG_ANY,
1700 "%s: line %d: unable to add replica \"%s\"\n",
1701 fname, lineno, cargv[i] + 5 );
1705 for ( i = 1; i < cargc; i++ ) {
1706 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1708 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1711 LDAP_LOG( CONFIG, INFO,
1712 "%s: line %d: suffix \"%s\" in \"replica\""
1713 " line is not valid for backend(ignored)\n",
1714 fname, lineno, cargv[i] + 7 );
1716 Debug( LDAP_DEBUG_ANY,
1717 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1718 fname, lineno, cargv[i] + 7 );
1724 LDAP_LOG( CONFIG, INFO,
1725 "%s: line %d: unable to normalize suffix"
1726 " in \"replica\" line (ignored)\n",
1727 fname, lineno , 0 );
1729 Debug( LDAP_DEBUG_ANY,
1730 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1736 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1738 char *arg = cargv[i] + 4;
1740 if ( arg[0] == '!' ) {
1745 if ( arg[0] != '=' ) {
1749 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1751 LDAP_LOG( CONFIG, INFO,
1752 "%s: line %d: attribute \"%s\" in "
1753 "\"replica\" line is unknown\n",
1754 fname, lineno, arg + 1 );
1756 Debug( LDAP_DEBUG_ANY,
1757 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1758 fname, lineno, arg + 1 );
1767 /* dn of master entity allowed to write to replica */
1768 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1771 LDAP_LOG( CONFIG, CRIT,
1772 "%s: line %d: missing dn in \"updatedn <dn>\""
1773 " line.\n", fname, lineno , 0 );
1775 Debug( LDAP_DEBUG_ANY,
1776 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1784 LDAP_LOG( CONFIG, INFO,
1785 "%s: line %d: updatedn line must appear inside "
1786 "a database definition\n",
1787 fname, lineno , 0 );
1789 Debug( LDAP_DEBUG_ANY,
1790 "%s: line %d: updatedn line must appear inside a database definition\n",
1798 if ( load_ucdata( NULL ) < 0 ) return 1;
1800 dn.bv_val = cargv[1];
1801 dn.bv_len = strlen( cargv[1] );
1803 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn );
1804 if( rc != LDAP_SUCCESS ) {
1806 LDAP_LOG( CONFIG, CRIT,
1807 "%s: line %d: updatedn DN is invalid.\n",
1808 fname, lineno , 0 );
1810 Debug( LDAP_DEBUG_ANY,
1811 "%s: line %d: updatedn DN is invalid\n",
1818 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1821 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1822 "missing url in \"updateref <ldapurl>\" line.\n",
1823 fname, lineno , 0 );
1825 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1826 "missing url in \"updateref <ldapurl>\" line\n",
1834 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
1835 " line must appear inside a database definition\n",
1836 fname, lineno , 0 );
1838 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1839 " line must appear inside a database definition\n",
1844 } else if ( !be->be_update_ndn.bv_len ) {
1846 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1847 "updateref line must come after updatedn.\n",
1848 fname, lineno , 0 );
1850 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1851 "updateref line must after updatedn.\n",
1857 if( validate_global_referral( cargv[1] ) ) {
1859 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1860 "invalid URL (%s) in \"updateref\" line.\n",
1861 fname, lineno, cargv[1] );
1863 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1864 "invalid URL (%s) in \"updateref\" line.\n",
1865 fname, lineno, cargv[1] );
1870 vals[0].bv_val = cargv[1];
1871 vals[0].bv_len = strlen( vals[0].bv_val );
1872 value_add( &be->be_update_refs, vals );
1874 /* replication log file to which changes are appended */
1875 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1878 LDAP_LOG( CONFIG, CRIT,
1879 "%s: line %d: missing filename in \"replogfile <filename>\""
1880 " line.\n", fname, lineno , 0 );
1882 Debug( LDAP_DEBUG_ANY,
1883 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1890 be->be_replogfile = ch_strdup( cargv[1] );
1892 replogfile = ch_strdup( cargv[1] );
1895 /* file from which to read additional rootdse attrs */
1896 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1899 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1900 "missing filename in \"rootDSE <filename>\" line.\n",
1901 fname, lineno , 0 );
1903 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1904 "missing filename in \"rootDSE <filename>\" line.\n",
1910 if( read_root_dse_file( cargv[1] ) ) {
1912 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1913 "could not read \"rootDSE <filename>\" line.\n",
1914 fname, lineno , 0 );
1916 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1917 "could not read \"rootDSE <filename>\" line\n",
1923 /* maintain lastmodified{by,time} attributes */
1924 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1927 LDAP_LOG( CONFIG, CRIT,
1928 "%s: line %d: missing on|off in \"lastmod <on|off>\""
1929 " line.\n", fname, lineno , 0 );
1931 Debug( LDAP_DEBUG_ANY,
1932 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1938 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1940 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
1946 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
1953 /* turn on/off gentle SIGHUP handling */
1954 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
1956 Debug( LDAP_DEBUG_ANY,
1957 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
1961 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1962 global_gentlehup = 0;
1964 global_gentlehup = 1;
1968 /* set idle timeout value */
1969 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1973 LDAP_LOG( CONFIG, CRIT,
1974 "%s: line %d: missing timeout value in "
1975 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
1977 Debug( LDAP_DEBUG_ANY,
1978 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1985 i = atoi( cargv[1] );
1989 LDAP_LOG( CONFIG, CRIT,
1990 "%s: line %d: timeout value (%d) invalid "
1991 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
1993 Debug( LDAP_DEBUG_ANY,
1994 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2001 global_idletimeout = i;
2003 /* include another config file */
2004 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2007 LDAP_LOG( CONFIG, CRIT,
2008 "%s: line %d: missing filename in \"include "
2009 "<filename>\" line.\n", fname, lineno , 0 );
2011 Debug( LDAP_DEBUG_ANY,
2012 "%s: line %d: missing filename in \"include <filename>\" line\n",
2018 savefname = ch_strdup( cargv[1] );
2019 savelineno = lineno;
2021 if ( read_config( savefname, depth+1 ) != 0 ) {
2026 lineno = savelineno - 1;
2028 /* location of kerberos srvtab file */
2029 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2032 LDAP_LOG( CONFIG, CRIT,
2033 "%s: line %d: missing filename in \"srvtab "
2034 "<filename>\" line.\n", fname, lineno , 0 );
2036 Debug( LDAP_DEBUG_ANY,
2037 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2043 ldap_srvtab = ch_strdup( cargv[1] );
2045 #ifdef SLAPD_MODULES
2046 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2049 LDAP_LOG( CONFIG, INFO,
2050 "%s: line %d: missing filename in \"moduleload "
2051 "<filename>\" line.\n", fname, lineno , 0 );
2053 Debug( LDAP_DEBUG_ANY,
2054 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2058 exit( EXIT_FAILURE );
2060 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2062 LDAP_LOG( CONFIG, CRIT,
2063 "%s: line %d: failed to load or initialize module %s\n",
2064 fname, lineno, cargv[1] );
2066 Debug( LDAP_DEBUG_ANY,
2067 "%s: line %d: failed to load or initialize module %s\n",
2068 fname, lineno, cargv[1]);
2071 exit( EXIT_FAILURE );
2073 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2076 LDAP_LOG( CONFIG, INFO,
2077 "%s: line %d: missing path in \"modulepath <path>\""
2078 " line\n", fname, lineno , 0 );
2080 Debug( LDAP_DEBUG_ANY,
2081 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2085 exit( EXIT_FAILURE );
2087 if (module_path( cargv[1] )) {
2089 LDAP_LOG( CONFIG, CRIT,
2090 "%s: line %d: failed to set module search path to %s.\n",
2091 fname, lineno, cargv[1] );
2093 Debug( LDAP_DEBUG_ANY,
2094 "%s: line %d: failed to set module search path to %s\n",
2095 fname, lineno, cargv[1]);
2098 exit( EXIT_FAILURE );
2101 #endif /*SLAPD_MODULES*/
2104 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2105 rc = ldap_pvt_tls_set_option( NULL,
2106 LDAP_OPT_X_TLS_RANDOM_FILE,
2111 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2112 rc = ldap_pvt_tls_set_option( NULL,
2113 LDAP_OPT_X_TLS_CIPHER_SUITE,
2118 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2119 rc = ldap_pvt_tls_set_option( NULL,
2120 LDAP_OPT_X_TLS_CERTFILE,
2125 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2126 rc = ldap_pvt_tls_set_option( NULL,
2127 LDAP_OPT_X_TLS_KEYFILE,
2132 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2133 rc = ldap_pvt_tls_set_option( NULL,
2134 LDAP_OPT_X_TLS_CACERTDIR,
2139 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2140 rc = ldap_pvt_tls_set_option( NULL,
2141 LDAP_OPT_X_TLS_CACERTFILE,
2145 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2146 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2148 rc = ldap_pvt_tls_set_option( NULL,
2149 LDAP_OPT_X_TLS_REQUIRE_CERT,
2152 rc = ldap_int_tls_config( NULL,
2153 LDAP_OPT_X_TLS_REQUIRE_CERT,
2162 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2163 #ifdef SLAPD_RLOOKUPS
2166 LDAP_LOG( CONFIG, INFO,
2167 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2168 fname, lineno , 0 );
2170 Debug( LDAP_DEBUG_ANY,
2171 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2177 if ( !strcasecmp( cargv[1], "on" ) ) {
2178 use_reverse_lookup = 1;
2179 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2180 use_reverse_lookup = 0;
2183 LDAP_LOG( CONFIG, INFO,
2184 "%s: line %d: reverse-lookup: "
2185 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2187 Debug( LDAP_DEBUG_ANY,
2188 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2194 #else /* !SLAPD_RLOOKUPS */
2196 LDAP_LOG( CONFIG, INFO,
2197 "%s: line %d: reverse lookups "
2198 "are not configured (ignored).\n", fname, lineno , 0 );
2200 Debug( LDAP_DEBUG_ANY,
2201 "%s: line %d: reverse lookups are not configured (ignored).\n",
2204 #endif /* !SLAPD_RLOOKUPS */
2206 /* pass anything else to the current backend info/db config routine */
2209 if ( bi->bi_config == 0 ) {
2211 LDAP_LOG( CONFIG, INFO,
2212 "%s: line %d: unknown directive \"%s\" inside "
2213 "backend info definition (ignored).\n",
2214 fname, lineno, cargv[0] );
2216 Debug( LDAP_DEBUG_ANY,
2217 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2218 fname, lineno, cargv[0] );
2222 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2228 } else if ( be != NULL ) {
2229 if ( be->be_config == 0 ) {
2231 LDAP_LOG( CONFIG, INFO,
2232 "%s: line %d: uknown directive \"%s\" inside "
2233 "backend database definition (ignored).\n",
2234 fname, lineno, cargv[0] );
2236 Debug( LDAP_DEBUG_ANY,
2237 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2238 fname, lineno, cargv[0] );
2242 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2250 LDAP_LOG( CONFIG, INFO,
2251 "%s: line %d: unknown directive \"%s\" outside backend "
2252 "info and database definitions (ignored).\n",
2253 fname, lineno, cargv[0] );
2255 Debug( LDAP_DEBUG_ANY,
2256 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2257 fname, lineno, cargv[0] );
2266 if ( depth == 0 ) ch_free( cargv );
2268 if ( load_ucdata( NULL ) < 0 ) return 1;
2280 char logbuf[sizeof("pseudorootpw ***")];
2283 token = strtok_quote( line, " \t" );
2287 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2288 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2289 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2290 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2291 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2293 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2296 if ( strtok_quote_ptr ) {
2297 *strtok_quote_ptr = ' ';
2301 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2303 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2306 if ( strtok_quote_ptr ) {
2307 *strtok_quote_ptr = '\0';
2310 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2311 if ( cargc == cargv_size - 1 ) {
2313 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2315 if ( tmp == NULL ) {
2317 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2319 Debug( LDAP_DEBUG_ANY,
2320 "line %d: out of memory\n",
2326 cargv_size += ARGS_STEP;
2328 cargv[cargc++] = token;
2330 cargv[cargc] = NULL;
2335 strtok_quote( char *line, char *sep )
2341 strtok_quote_ptr = NULL;
2342 if ( line != NULL ) {
2345 while ( *next && strchr( sep, *next ) ) {
2349 if ( *next == '\0' ) {
2355 for ( inquote = 0; *next; ) {
2363 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2369 next + 1, strlen( next + 1 ) + 1 );
2370 next++; /* dont parse the escaped character */
2375 if ( strchr( sep, *next ) != NULL ) {
2376 strtok_quote_ptr = next;
2389 static char buf[BUFSIZ];
2391 static size_t lmax, lcur;
2393 #define CATLINE( buf ) \
2395 size_t len = strlen( buf ); \
2396 while ( lcur + len + 1 > lmax ) { \
2398 line = (char *) ch_realloc( line, lmax ); \
2400 strcpy( line + lcur, buf ); \
2405 fp_getline( FILE *fp, int *lineno )
2413 /* hack attack - keeps us from having to keep a stack of bufs... */
2414 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2419 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2420 /* trim off \r\n or \n */
2421 if ( (p = strchr( buf, '\n' )) != NULL ) {
2422 if( p > buf && p[-1] == '\r' ) --p;
2426 /* trim off trailing \ and append the next line */
2427 if ( line[ 0 ] != '\0'
2428 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2429 && p[ -1 ] != '\\' ) {
2434 if ( ! isspace( (unsigned char) buf[0] ) ) {
2438 /* change leading whitespace to a space */
2447 return( line[0] ? line : NULL );
2451 fp_getline_init( int *lineno )
2457 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2459 load_ucdata( char *path )
2461 static int loaded = 0;
2467 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2470 LDAP_LOG( CONFIG, CRIT,
2471 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2473 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2486 ucdata_unload( UCDATA_ALL );
2488 if ( slapd_args_file )
2489 free ( slapd_args_file );
2490 if ( slapd_pid_file )
2491 free ( slapd_pid_file );
2492 acl_destroy( global_acl, NULL );