1 /* config.c - configuration file handling routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
31 #include <ac/string.h>
33 #include <ac/signal.h>
34 #include <ac/socket.h>
40 #include "slapi/slapi.h"
47 * defaults for various global variables
49 struct slap_limits_set deflimit = {
50 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
53 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
55 -1, /* no limit on unchecked size */
57 0, /* hide number of entries left */
58 0 /* number of total entries returned by pagedResults equal to hard limit */
61 AccessControl *global_acl = NULL;
62 slap_access_t global_default_access = ACL_READ;
63 slap_mask_t global_restrictops = 0;
64 slap_mask_t global_allows = 0;
65 slap_mask_t global_disallows = 0;
66 slap_mask_t global_requires = 0;
67 slap_ssf_set_t global_ssf_set;
69 int global_gentlehup = 0;
70 int global_idletimeout = 0;
71 char *global_host = NULL;
72 char *global_realm = NULL;
73 char *ldap_srvtab = "";
74 char **default_passwd_hash = NULL;
75 int cargc = 0, cargv_size = 0;
77 struct berval default_search_base = BER_BVNULL;
78 struct berval default_search_nbase = BER_BVNULL;
79 unsigned num_subordinates = 0;
80 struct berval global_schemadn = BER_BVNULL;
81 struct berval global_schemandn = BER_BVNULL;
83 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
84 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
86 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
87 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
89 char *slapd_pid_file = NULL;
90 char *slapd_args_file = NULL;
92 char *strtok_quote_ptr;
94 int use_reverse_lookup = 0;
97 int slapi_plugins_used = 0;
100 static char *fp_getline(FILE *fp, int *lineno);
101 static void fp_getline_init(int *lineno);
102 static int fp_parse_line(int lineno, char *line);
104 static char *strtok_quote(char *line, char *sep);
105 static int load_ucdata(char *path);
107 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
108 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
111 read_config( const char *fname, int depth )
114 char *line, *savefname, *saveline;
118 struct berval vals[2];
121 static int lastmod = 1;
122 static BackendInfo *bi = NULL;
123 static BackendDB *be = NULL;
125 vals[1].bv_val = NULL;
128 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
129 cargv_size = ARGS_STEP + 1;
132 if ( (fp = fopen( fname, "r" )) == NULL ) {
135 LDAP_LOG( CONFIG, ENTRY,
136 "read_config: " "could not open config file \"%s\": %s (%d)\n",
137 fname, strerror(errno), errno );
139 Debug( LDAP_DEBUG_ANY,
140 "could not open config file \"%s\": %s (%d)\n",
141 fname, strerror(errno), errno );
147 LDAP_LOG( CONFIG, ENTRY,
148 "read_config: reading config file %s\n", fname, 0, 0 );
150 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
154 fp_getline_init( &lineno );
156 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
157 /* skip comments and blank lines */
158 if ( line[0] == '#' || line[0] == '\0' ) {
162 /* fp_parse_line is destructive, we save a copy */
163 saveline = ch_strdup( line );
165 if ( fp_parse_line( lineno, line ) != 0 ) {
171 LDAP_LOG( CONFIG, INFO,
172 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
174 Debug( LDAP_DEBUG_ANY,
175 "%s: line %d: bad config line (ignored)\n",
182 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
185 LDAP_LOG( CONFIG, CRIT,
186 "%s : line %d: missing type in \"backend\" line.\n",
189 Debug( LDAP_DEBUG_ANY,
190 "%s: line %d: missing type in \"backend <type>\" line\n",
199 LDAP_LOG( CONFIG, CRIT,
200 "%s: line %d: backend line must appear before any "
201 "database definition.\n", fname, lineno , 0 );
203 Debug( LDAP_DEBUG_ANY,
204 "%s: line %d: backend line must appear before any database definition\n",
211 bi = backend_info( cargv[1] );
215 LDAP_LOG( CONFIG, CRIT,
216 "read_config: backend %s initialization failed.\n",
219 Debug( LDAP_DEBUG_ANY,
220 "backend %s initialization failed.\n",
226 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
229 LDAP_LOG( CONFIG, CRIT,
230 "%s: line %d: missing type in \"database <type>\" line\n",
233 Debug( LDAP_DEBUG_ANY,
234 "%s: line %d: missing type in \"database <type>\" line\n",
242 be = backend_db_init( cargv[1] );
246 LDAP_LOG( CONFIG, CRIT,
247 "database %s initialization failed.\n", cargv[1], 0, 0 );
249 Debug( LDAP_DEBUG_ANY,
250 "database %s initialization failed.\n",
257 /* set thread concurrency */
258 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
262 LDAP_LOG( CONFIG, CRIT,
263 "%s: line %d: missing level in \"concurrency <level\" "
264 " line\n", fname, lineno, 0 );
266 Debug( LDAP_DEBUG_ANY,
267 "%s: line %d: missing level in \"concurrency <level>\" line\n",
274 c = atoi( cargv[1] );
278 LDAP_LOG( CONFIG, CRIT,
279 "%s: line %d: invalid level (%d) in "
280 "\"concurrency <level>\" line.\n", fname, lineno, c );
282 Debug( LDAP_DEBUG_ANY,
283 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
290 ldap_pvt_thread_set_concurrency( c );
292 /* set sockbuf max */
293 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
297 LDAP_LOG( CONFIG, CRIT,
298 "%s: line %d: missing max in \"sockbuf_max_incoming "
299 "<bytes>\" line\n", fname, lineno, 0 );
301 Debug( LDAP_DEBUG_ANY,
302 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
309 max = atol( cargv[1] );
313 LDAP_LOG( CONFIG, CRIT,
314 "%s: line %d: invalid max value (%ld) in "
315 "\"sockbuf_max_incoming <bytes>\" line.\n",
316 fname, lineno, max );
318 Debug( LDAP_DEBUG_ANY,
319 "%s: line %d: invalid max value (%ld) in "
320 "\"sockbuf_max_incoming <bytes>\" line.\n",
321 fname, lineno, max );
327 sockbuf_max_incoming = max;
329 /* set sockbuf max authenticated */
330 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
334 LDAP_LOG( CONFIG, CRIT,
335 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
336 "<bytes>\" line\n", fname, lineno, 0 );
338 Debug( LDAP_DEBUG_ANY,
339 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
346 max = atol( cargv[1] );
350 LDAP_LOG( CONFIG, CRIT,
351 "%s: line %d: invalid max value (%ld) in "
352 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
353 fname, lineno, max );
355 Debug( LDAP_DEBUG_ANY,
356 "%s: line %d: invalid max value (%ld) in "
357 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
358 fname, lineno, max );
364 sockbuf_max_incoming_auth = max;
366 /* set conn pending max */
367 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
371 LDAP_LOG( CONFIG, CRIT,
372 "%s: line %d: missing max in \"conn_max_pending "
373 "<requests>\" line\n", fname, lineno, 0 );
375 Debug( LDAP_DEBUG_ANY,
376 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
383 max = atol( cargv[1] );
387 LDAP_LOG( CONFIG, CRIT,
388 "%s: line %d: invalid max value (%ld) in "
389 "\"conn_max_pending <requests>\" line.\n",
390 fname, lineno, max );
392 Debug( LDAP_DEBUG_ANY,
393 "%s: line %d: invalid max value (%ld) in "
394 "\"conn_max_pending <requests>\" line.\n",
395 fname, lineno, max );
401 slap_conn_max_pending = max;
403 /* set conn pending max authenticated */
404 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
408 LDAP_LOG( CONFIG, CRIT,
409 "%s: line %d: missing max in \"conn_max_pending_auth "
410 "<requests>\" line\n", fname, lineno, 0 );
412 Debug( LDAP_DEBUG_ANY,
413 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
420 max = atol( cargv[1] );
424 LDAP_LOG( CONFIG, CRIT,
425 "%s: line %d: invalid max value (%ld) in "
426 "\"conn_max_pending_auth <requests>\" line.\n",
427 fname, lineno, max );
429 Debug( LDAP_DEBUG_ANY,
430 "%s: line %d: invalid max value (%ld) in "
431 "\"conn_max_pending_auth <requests>\" line.\n",
432 fname, lineno, max );
438 slap_conn_max_pending_auth = max;
440 /* default search base */
441 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
444 LDAP_LOG( CONFIG, CRIT,
445 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
446 "line\n", fname, lineno, 0 );
448 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
449 "missing dn in \"defaultSearchBase <dn>\" line\n",
455 } else if ( cargc > 2 ) {
457 LDAP_LOG( CONFIG, INFO,
458 "%s: line %d: extra cruft after <dn> in "
459 "\"defaultSearchBase %s\" line (ignored)\n",
460 fname, lineno, cargv[1] );
462 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
463 "extra cruft after <dn> in \"defaultSearchBase %s\", "
465 fname, lineno, cargv[1] );
469 if ( bi != NULL || be != NULL ) {
471 LDAP_LOG( CONFIG, CRIT,
472 "%s: line %d: defaultSearchBase line must appear "
473 "prior to any backend or database definitions\n",
476 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
477 "defaultSearchBaase line must appear prior to "
478 "any backend or database definition\n",
485 if ( default_search_nbase.bv_len ) {
487 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
488 "default search base \"%s\" already defined "
489 "(discarding old)\n", fname, lineno,
490 default_search_base.bv_val );
492 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
493 "default search base \"%s\" already defined "
494 "(discarding old)\n",
495 fname, lineno, default_search_base.bv_val );
498 free( default_search_base.bv_val );
499 free( default_search_nbase.bv_val );
502 if ( load_ucdata( NULL ) < 0 ) return 1;
507 dn.bv_val = cargv[1];
508 dn.bv_len = strlen( dn.bv_val );
510 rc = dnPrettyNormal( NULL, &dn,
511 &default_search_base,
512 &default_search_nbase, NULL );
514 if( rc != LDAP_SUCCESS ) {
516 LDAP_LOG( CONFIG, CRIT,
517 "%s: line %d: defaultSearchBase DN is invalid.\n",
520 Debug( LDAP_DEBUG_ANY,
521 "%s: line %d: defaultSearchBase DN is invalid\n",
528 /* set maximum threads in thread pool */
529 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
533 LDAP_LOG( CONFIG, CRIT,
534 "%s: line %d: missing count in \"threads <count>\" line\n",
537 Debug( LDAP_DEBUG_ANY,
538 "%s: line %d: missing count in \"threads <count>\" line\n",
545 c = atoi( cargv[1] );
549 LDAP_LOG( CONFIG, CRIT,
550 "%s: line %d: invalid level (%d) in \"threads <count>\""
551 "line\n", fname, lineno, c );
553 Debug( LDAP_DEBUG_ANY,
554 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
561 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
563 /* save for later use */
564 connection_pool_max = c;
566 /* get pid file name */
567 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
570 LDAP_LOG( CONFIG, CRIT,
571 "%s: line %d missing file name in \"pidfile <file>\" "
572 "line.\n", fname, lineno, 0 );
574 Debug( LDAP_DEBUG_ANY,
575 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
582 slapd_pid_file = ch_strdup( cargv[1] );
584 /* get args file name */
585 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
588 LDAP_LOG( CONFIG, CRIT,
589 "%s: %d: missing file name in "
590 "\"argsfile <file>\" line.\n",
593 Debug( LDAP_DEBUG_ANY,
594 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
601 slapd_args_file = ch_strdup( cargv[1] );
603 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
606 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
609 /* default password hash */
610 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
613 LDAP_LOG( CONFIG, CRIT,
614 "%s: line %d: missing hash in "
615 "\"password-hash <hash>\" line.\n",
618 Debug( LDAP_DEBUG_ANY,
619 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
625 if ( default_passwd_hash != NULL ) {
627 LDAP_LOG( CONFIG, CRIT,
628 "%s: line %d: already set default password_hash!\n",
631 Debug( LDAP_DEBUG_ANY,
632 "%s: line %d: already set default password_hash!\n",
639 for(i = 1; i < cargc; i++) {
640 if ( lutil_passwd_scheme( cargv[i] ) == 0 ) {
642 LDAP_LOG( CONFIG, CRIT,
643 "%s: line %d: password scheme \"%s\" not available\n",
644 fname, lineno, cargv[i] );
646 Debug( LDAP_DEBUG_ANY,
647 "%s: line %d: password scheme \"%s\" not available\n",
648 fname, lineno, cargv[i] );
651 ldap_charray_add( &default_passwd_hash, cargv[i] );
654 if( !default_passwd_hash ) {
656 LDAP_LOG( CONFIG, CRIT,
657 "%s: line %d: no valid hashes found\n",
660 Debug( LDAP_DEBUG_ANY,
661 "%s: line %d: no valid hashes found\n",
667 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
671 LDAP_LOG( CONFIG, CRIT,
672 "%s: line %d: missing format in "
673 "\"password-crypt-salt-format <format>\" line\n",
676 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
677 "\"password-crypt-salt-format <format>\" line\n",
684 lutil_salt_format( cargv[1] );
686 /* SASL config options */
687 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
688 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
690 #ifdef SLAP_SASL_REWRITE
691 /* use authid rewrite instead of sasl regexp */
692 } else if ( strncasecmp( cargv[0], "authid-rewrite", sizeof("authid-rewrite") - 1 ) == 0 ) {
693 int rc = slap_sasl_rewrite_config( fname, lineno,
698 #endif /* SLAP_SASL_REWRITE */
700 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
704 LDAP_LOG( CONFIG, CRIT,
705 "%s: line %d: missing dn in "
706 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
708 Debug( LDAP_DEBUG_ANY,
709 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
714 ber_str2bv( cargv[1], 0, 0, &dn );
716 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
717 &be->be_schemandn, NULL );
719 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
720 &global_schemandn, NULL );
722 if ( rc != LDAP_SUCCESS ) {
724 LDAP_LOG( CONFIG, CRIT,
725 "%s: line %d: schemadn DN is invalid.\n",
728 Debug( LDAP_DEBUG_ANY,
729 "%s: line %d: schemadn DN is invalid\n",
735 /* set UCDATA path */
736 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
740 LDAP_LOG( CONFIG, CRIT,
741 "%s: line %d: missing path in "
742 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
744 Debug( LDAP_DEBUG_ANY,
745 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
752 err = load_ucdata( cargv[1] );
756 LDAP_LOG( CONFIG, CRIT,
757 "%s: line %d: ucdata already loaded, ucdata-path "
758 "must be set earlier in the file and/or be "
759 "specified only once!\n", fname, lineno, 0 );
761 Debug( LDAP_DEBUG_ANY,
762 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
771 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
773 struct slap_limits_set *lim;
777 LDAP_LOG( CONFIG, CRIT,
778 "%s: line %d: missing limit in \"sizelimit <limit>\" "
779 "line.\n", fname, lineno, 0 );
781 Debug( LDAP_DEBUG_ANY,
782 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
792 lim = &be->be_def_limit;
795 for ( i = 1; i < cargc; i++ ) {
796 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
797 rc = limits_parse_one( cargv[i], lim );
800 LDAP_LOG( CONFIG, CRIT,
801 "%s: line %d: unable "
802 "to parse value \"%s\" in \"sizelimit "
803 "<limit>\" line.\n", fname, lineno, cargv[i] );
805 Debug( LDAP_DEBUG_ANY,
806 "%s: line %d: unable "
807 "to parse value \"%s\" "
810 fname, lineno, cargv[i] );
816 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
817 lim->lms_s_soft = -1;
821 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
822 if ( next == cargv[i] ) {
824 LDAP_LOG( CONFIG, CRIT,
825 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
826 "line.\n", fname, lineno, cargv[i] );
828 Debug( LDAP_DEBUG_ANY,
829 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
830 fname, lineno, cargv[i] );
834 } else if ( next[0] != '\0' ) {
836 LDAP_LOG( CONFIG, CRIT,
837 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
838 "line ignored.\n", fname, lineno, next );
840 Debug( LDAP_DEBUG_ANY,
841 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
842 fname, lineno, next );
851 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
853 struct slap_limits_set *lim;
857 LDAP_LOG( CONFIG, CRIT,
858 "%s: line %d missing limit in \"timelimit <limit>\" "
859 "line.\n", fname, lineno, 0 );
861 Debug( LDAP_DEBUG_ANY,
862 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
872 lim = &be->be_def_limit;
875 for ( i = 1; i < cargc; i++ ) {
876 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
877 rc = limits_parse_one( cargv[i], lim );
880 LDAP_LOG( CONFIG, CRIT,
881 "%s: line %d: unable to parse value \"%s\" "
882 "in \"timelimit <limit>\" line.\n",
883 fname, lineno, cargv[i] );
885 Debug( LDAP_DEBUG_ANY,
886 "%s: line %d: unable "
887 "to parse value \"%s\" "
890 fname, lineno, cargv[i] );
896 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
897 lim->lms_t_soft = -1;
901 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
902 if ( next == cargv[i] ) {
904 LDAP_LOG( CONFIG, CRIT,
905 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
906 "line.\n", fname, lineno, cargv[i] );
908 Debug( LDAP_DEBUG_ANY,
909 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
910 fname, lineno, cargv[i] );
914 } else if ( next[0] != '\0' ) {
916 LDAP_LOG( CONFIG, CRIT,
917 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
918 "line ignored.\n", fname, lineno, next );
920 Debug( LDAP_DEBUG_ANY,
921 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
922 fname, lineno, next );
930 /* set regex-based limits */
931 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
934 LDAP_LOG( CONFIG, WARNING,
935 "%s: line %d \"limits\" allowed only in database "
936 "environment.\n", fname, lineno, 0 );
938 Debug( LDAP_DEBUG_ANY,
939 "%s: line %d \"limits\" allowed only in database environment.\n%s",
945 if ( limits_parse( be, fname, lineno, cargc, cargv ) ) {
949 /* mark this as a subordinate database */
950 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
953 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
954 "subordinate keyword must appear inside a database "
955 "definition.\n", fname, lineno, 0 );
957 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
958 "must appear inside a database definition.\n",
964 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
968 /* add an overlay to this backend */
969 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
972 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
973 "overlay keyword must appear inside a database "
974 "definition.\n", fname, lineno, 0 );
976 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
977 "must appear inside a database definition.\n",
983 if ( cargv[1][0] == '-' && overlay_config( be, &cargv[1][1] ) ) {
986 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
987 "(optional) overlay \"%s\" configuration "
988 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
990 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
991 "(optional) overlay \"%s\" configuration "
992 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
994 } else if ( overlay_config( be, cargv[1] ) ) {
999 /* set database suffix */
1000 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
1002 struct berval dn, pdn, ndn;
1006 LDAP_LOG( CONFIG, CRIT,
1007 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
1010 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1011 "missing dn in \"suffix <dn>\" line\n",
1017 } else if ( cargc > 2 ) {
1019 LDAP_LOG( CONFIG, INFO,
1020 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
1021 " line (ignored).\n", fname, lineno, cargv[1] );
1023 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
1024 "after <dn> in \"suffix %s\" line (ignored)\n",
1025 fname, lineno, cargv[1] );
1031 LDAP_LOG( CONFIG, INFO,
1032 "%s: line %d: suffix line must appear inside a database "
1033 "definition.\n", fname, lineno, 0 );
1035 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
1036 "must appear inside a database definition\n",
1041 #if defined(SLAPD_MONITOR_DN)
1042 /* "cn=Monitor" is reserved for monitoring slap */
1043 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
1045 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
1046 "%s\" is reserved for monitoring slapd\n",
1047 fname, lineno, SLAPD_MONITOR_DN );
1049 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
1050 "%s\" is reserved for monitoring slapd\n",
1051 fname, lineno, SLAPD_MONITOR_DN );
1054 #endif /* SLAPD_MONITOR_DN */
1057 if ( load_ucdata( NULL ) < 0 ) return 1;
1059 dn.bv_val = cargv[1];
1060 dn.bv_len = strlen( cargv[1] );
1062 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1063 if( rc != LDAP_SUCCESS ) {
1065 LDAP_LOG( CONFIG, CRIT,
1066 "%s: line %d: suffix DN is invalid.\n",
1069 Debug( LDAP_DEBUG_ANY,
1070 "%s: line %d: suffix DN is invalid\n",
1076 tmp_be = select_backend( &ndn, 0, 0 );
1077 if ( tmp_be == be ) {
1079 LDAP_LOG( CONFIG, INFO,
1080 "%s: line %d: suffix already served by this backend "
1081 "(ignored)\n", fname, lineno, 0 );
1083 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1084 "already served by this backend (ignored)\n",
1090 } else if ( tmp_be != NULL ) {
1092 LDAP_LOG( CONFIG, INFO,
1093 "%s: line %d: suffix already served by a preceding "
1094 "backend \"%s\"\n", fname, lineno,
1095 tmp_be->be_suffix[0].bv_val );
1097 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1098 "already served by a preceeding backend \"%s\"\n",
1099 fname, lineno, tmp_be->be_suffix[0].bv_val );
1105 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1107 LDAP_LOG( CONFIG, INFO,
1108 "%s: line %d: suffix DN empty and default search "
1109 "base provided \"%s\" (assuming okay).\n",
1110 fname, lineno, default_search_base.bv_val );
1112 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1113 "suffix DN empty and default "
1114 "search base provided \"%s\" (assuming okay)\n",
1115 fname, lineno, default_search_base.bv_val );
1119 ber_bvarray_add( &be->be_suffix, &pdn );
1120 ber_bvarray_add( &be->be_nsuffix, &ndn );
1122 /* set max deref depth */
1123 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1127 LDAP_LOG( CONFIG, CRIT,
1128 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1129 " line\n", fname, lineno, 0 );
1131 Debug( LDAP_DEBUG_ANY,
1132 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1140 LDAP_LOG( CONFIG, INFO,
1141 "%s: line %d: depth line must appear inside a database "
1142 "definition.\n", fname, lineno ,0 );
1144 Debug( LDAP_DEBUG_ANY,
1145 "%s: line %d: depth line must appear inside a database definition.\n",
1150 } else if ((i = atoi(cargv[1])) < 0) {
1152 LDAP_LOG( CONFIG, INFO,
1153 "%s: line %d: depth must be positive.\n",
1156 Debug( LDAP_DEBUG_ANY,
1157 "%s: line %d: depth must be positive.\n",
1164 be->be_max_deref_depth = i;
1168 /* set magic "root" dn for this database */
1169 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1172 LDAP_LOG( CONFIG, INFO,
1173 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1176 Debug( LDAP_DEBUG_ANY,
1177 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1186 LDAP_LOG( CONFIG, INFO,
1187 "%s: line %d: rootdn line must appear inside a database "
1188 "definition.\n", fname, lineno ,0 );
1190 Debug( LDAP_DEBUG_ANY,
1191 "%s: line %d: rootdn line must appear inside a database definition.\n",
1199 if ( load_ucdata( NULL ) < 0 ) return 1;
1201 dn.bv_val = cargv[1];
1202 dn.bv_len = strlen( cargv[1] );
1204 rc = dnPrettyNormal( NULL, &dn,
1206 &be->be_rootndn, NULL );
1208 if( rc != LDAP_SUCCESS ) {
1210 LDAP_LOG( CONFIG, CRIT,
1211 "%s: line %d: rootdn DN is invalid.\n",
1214 Debug( LDAP_DEBUG_ANY,
1215 "%s: line %d: rootdn DN is invalid\n",
1222 /* set super-secret magic database password */
1223 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1226 LDAP_LOG( CONFIG, CRIT,
1227 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1228 " line\n", fname, lineno ,0 );
1230 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1231 "missing passwd in \"rootpw <passwd>\" line\n",
1240 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1241 "rootpw line must appear inside a database "
1242 "definition.\n", fname, lineno ,0 );
1244 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1245 "rootpw line must appear inside a database "
1252 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1254 if( tmp_be != be ) {
1256 LDAP_LOG( CONFIG, INFO,
1258 "rootpw can only be set when rootdn is under suffix\n",
1259 fname, lineno, "" );
1261 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1262 "rootpw can only be set when rootdn is under suffix\n",
1268 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1269 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1272 /* make this database read-only */
1273 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1276 LDAP_LOG( CONFIG, CRIT,
1277 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1278 "line.\n", fname, lineno ,0 );
1280 Debug( LDAP_DEBUG_ANY,
1281 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1288 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1289 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1291 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1294 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1295 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1297 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1302 /* allow these features */
1303 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1304 strcasecmp( cargv[0], "allow" ) == 0 )
1310 LDAP_LOG( CONFIG, INFO,
1311 "%s: line %d: allow line must appear prior to "
1312 "database definitions.\n", fname, lineno ,0 );
1314 Debug( LDAP_DEBUG_ANY,
1315 "%s: line %d: allow line must appear prior to database definitions\n",
1323 LDAP_LOG( CONFIG, CRIT,
1324 "%s: line %d: missing feature(s) in \"allow <features>\""
1325 " line\n", fname, lineno ,0 );
1327 Debug( LDAP_DEBUG_ANY,
1328 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1337 for( i=1; i < cargc; i++ ) {
1338 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1339 allows |= SLAP_ALLOW_BIND_V2;
1341 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1342 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1344 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1345 allows |= SLAP_ALLOW_BIND_ANON_DN;
1347 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1348 allows |= SLAP_ALLOW_UPDATE_ANON;
1350 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1352 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1353 "unknown feature %s in \"allow <features>\" line.\n",
1354 fname, lineno, cargv[1] );
1356 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1357 "unknown feature %s in \"allow <features>\" line\n",
1358 fname, lineno, cargv[i] );
1365 global_allows = allows;
1367 /* disallow these features */
1368 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1369 strcasecmp( cargv[0], "disallow" ) == 0 )
1371 slap_mask_t disallows;
1375 LDAP_LOG( CONFIG, INFO,
1376 "%s: line %d: disallow line must appear prior to "
1377 "database definitions.\n", fname, lineno ,0 );
1379 Debug( LDAP_DEBUG_ANY,
1380 "%s: line %d: disallow line must appear prior to database definitions\n",
1388 LDAP_LOG( CONFIG, CRIT,
1389 "%s: line %d: missing feature(s) in \"disallow <features>\""
1390 " line.\n", fname, lineno ,0 );
1392 Debug( LDAP_DEBUG_ANY,
1393 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1402 for( i=1; i < cargc; i++ ) {
1403 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1404 disallows |= SLAP_DISALLOW_BIND_ANON;
1406 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1407 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1409 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1410 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1412 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1413 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1415 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1416 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1418 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1420 LDAP_LOG( CONFIG, CRIT,
1421 "%s: line %d: unknown feature %s in "
1422 "\"disallow <features>\" line.\n",
1423 fname, lineno, cargv[i] );
1425 Debug( LDAP_DEBUG_ANY,
1426 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1427 fname, lineno, cargv[i] );
1434 global_disallows = disallows;
1436 /* require these features */
1437 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1438 strcasecmp( cargv[0], "require" ) == 0 )
1440 slap_mask_t requires;
1444 LDAP_LOG( CONFIG, CRIT,
1445 "%s: line %d: missing feature(s) in "
1446 "\"require <features>\" line.\n", fname, lineno ,0 );
1448 Debug( LDAP_DEBUG_ANY,
1449 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1458 for( i=1; i < cargc; i++ ) {
1459 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1460 requires |= SLAP_REQUIRE_BIND;
1462 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1463 requires |= SLAP_REQUIRE_LDAP_V3;
1465 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1466 requires |= SLAP_REQUIRE_AUTHC;
1468 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1469 requires |= SLAP_REQUIRE_SASL;
1471 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1472 requires |= SLAP_REQUIRE_STRONG;
1474 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1476 LDAP_LOG( CONFIG, CRIT,
1477 "%s: line %d: unknown feature %s in "
1478 "\"require <features>\" line.\n",
1479 fname, lineno , cargv[i] );
1481 Debug( LDAP_DEBUG_ANY,
1482 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1483 fname, lineno, cargv[i] );
1491 global_requires = requires;
1493 be->be_requires = requires;
1496 /* required security factors */
1497 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1498 slap_ssf_set_t *set;
1502 LDAP_LOG( CONFIG, CRIT,
1503 "%s: line %d: missing factor(s) in \"security <factors>\""
1504 " line.\n", fname, lineno ,0 );
1506 Debug( LDAP_DEBUG_ANY,
1507 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1515 set = &global_ssf_set;
1517 set = &be->be_ssf_set;
1520 for( i=1; i < cargc; i++ ) {
1521 if( strncasecmp( cargv[i], "ssf=",
1522 sizeof("ssf") ) == 0 )
1525 atoi( &cargv[i][sizeof("ssf")] );
1527 } else if( strncasecmp( cargv[i], "transport=",
1528 sizeof("transport") ) == 0 )
1530 set->sss_transport =
1531 atoi( &cargv[i][sizeof("transport")] );
1533 } else if( strncasecmp( cargv[i], "tls=",
1534 sizeof("tls") ) == 0 )
1537 atoi( &cargv[i][sizeof("tls")] );
1539 } else if( strncasecmp( cargv[i], "sasl=",
1540 sizeof("sasl") ) == 0 )
1543 atoi( &cargv[i][sizeof("sasl")] );
1545 } else if( strncasecmp( cargv[i], "update_ssf=",
1546 sizeof("update_ssf") ) == 0 )
1548 set->sss_update_ssf =
1549 atoi( &cargv[i][sizeof("update_ssf")] );
1551 } else if( strncasecmp( cargv[i], "update_transport=",
1552 sizeof("update_transport") ) == 0 )
1554 set->sss_update_transport =
1555 atoi( &cargv[i][sizeof("update_transport")] );
1557 } else if( strncasecmp( cargv[i], "update_tls=",
1558 sizeof("update_tls") ) == 0 )
1560 set->sss_update_tls =
1561 atoi( &cargv[i][sizeof("update_tls")] );
1563 } else if( strncasecmp( cargv[i], "update_sasl=",
1564 sizeof("update_sasl") ) == 0 )
1566 set->sss_update_sasl =
1567 atoi( &cargv[i][sizeof("update_sasl")] );
1569 } else if( strncasecmp( cargv[i], "simple_bind=",
1570 sizeof("simple_bind") ) == 0 )
1572 set->sss_simple_bind =
1573 atoi( &cargv[i][sizeof("simple_bind")] );
1577 LDAP_LOG( CONFIG, CRIT,
1578 "%s: line %d: unknown factor %S in "
1579 "\"security <factors>\" line.\n",
1580 fname, lineno, cargv[1] );
1582 Debug( LDAP_DEBUG_ANY,
1583 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1584 fname, lineno, cargv[i] );
1590 /* where to send clients when we don't hold it */
1591 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1594 LDAP_LOG( CONFIG, CRIT,
1595 "%s: line %d: missing URL in \"referral <URL>\""
1596 " line.\n", fname, lineno , 0 );
1598 Debug( LDAP_DEBUG_ANY,
1599 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1606 if( validate_global_referral( cargv[1] ) ) {
1608 LDAP_LOG( CONFIG, CRIT,
1609 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1610 fname, lineno, cargv[1] );
1612 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1613 "invalid URL (%s) in \"referral\" line.\n",
1614 fname, lineno, cargv[1] );
1619 vals[0].bv_val = cargv[1];
1620 vals[0].bv_len = strlen( vals[0].bv_val );
1621 if( value_add( &default_referral, vals ) )
1625 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1629 LDAP_LOG( CONFIG, CRIT,
1630 "%s: line %d: Error in logfile directive, "
1631 "\"logfile <filename>\"\n", fname, lineno , 0 );
1633 Debug( LDAP_DEBUG_ANY,
1634 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1640 logfile = fopen( cargv[1], "w" );
1641 if ( logfile != NULL ) lutil_debug_file( logfile );
1644 /* start of a new database definition */
1645 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1649 LDAP_LOG( CONFIG, CRIT,
1650 "%s: line %d: Error in debug directive, "
1651 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1653 Debug( LDAP_DEBUG_ANY,
1654 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1660 level = atoi( cargv[2] );
1661 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1662 lutil_set_debug_level( cargv[1], level );
1663 /* specify an Object Identifier macro */
1664 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1665 rc = parse_oidm( fname, lineno, cargc, cargv );
1668 /* specify an objectclass */
1669 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1672 LDAP_LOG( CONFIG, INFO,
1673 "%s: line %d: illegal objectclass format.\n",
1674 fname, lineno , 0 );
1676 Debug( LDAP_DEBUG_ANY,
1677 "%s: line %d: illegal objectclass format.\n",
1682 } else if ( *cargv[1] == '(' /*')'*/) {
1684 p = strchr(saveline,'(' /*')'*/);
1685 rc = parse_oc( fname, lineno, p, cargv );
1690 LDAP_LOG( CONFIG, INFO,
1691 "%s: line %d: old objectclass format not supported\n",
1692 fname, lineno , 0 );
1694 Debug( LDAP_DEBUG_ANY,
1695 "%s: line %d: old objectclass format not supported.\n",
1700 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1702 p = strchr(saveline,'(' /*')'*/);
1703 rc = parse_cr( fname, lineno, p, cargv );
1706 /* specify an attribute type */
1707 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1708 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1712 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1713 "illegal attribute type format.\n",
1714 fname, lineno , 0 );
1716 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1717 "illegal attribute type format.\n",
1722 } else if ( *cargv[1] == '(' /*')'*/) {
1724 p = strchr(saveline,'(' /*')'*/);
1725 rc = parse_at( fname, lineno, p, cargv );
1730 LDAP_LOG( CONFIG, INFO,
1731 "%s: line %d: old attribute type format not supported.\n",
1732 fname, lineno , 0 );
1734 Debug( LDAP_DEBUG_ANY,
1735 "%s: line %d: old attribute type format not supported.\n",
1741 /* define attribute option(s) */
1742 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1743 ad_define_option( NULL, NULL, 0 );
1744 for ( i = 1; i < cargc; i++ )
1745 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1748 /* turn on/off schema checking */
1749 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1752 LDAP_LOG( CONFIG, CRIT,
1753 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1754 " line.\n", fname, lineno , 0 );
1756 Debug( LDAP_DEBUG_ANY,
1757 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1763 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1765 LDAP_LOG( CONFIG, CRIT,
1766 "%s: line %d: schema checking disabled! your mileage may "
1767 "vary!\n", fname, lineno , 0 );
1769 Debug( LDAP_DEBUG_ANY,
1770 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1773 global_schemacheck = 0;
1775 global_schemacheck = 1;
1778 /* specify access control info */
1779 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1780 parse_acl( be, fname, lineno, cargc, cargv );
1782 /* debug level to log things to syslog */
1783 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1786 LDAP_LOG( CONFIG, CRIT,
1787 "%s: line %d: missing level in \"loglevel <level>\""
1788 " line.\n", fname, lineno , 0 );
1790 Debug( LDAP_DEBUG_ANY,
1791 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1800 for( i=1; i < cargc; i++ ) {
1801 ldap_syslog += atoi( cargv[1] );
1804 /* list of sync replication information in this backend (slave only) */
1805 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1809 LDAP_LOG( CONFIG, INFO,
1810 "%s: line %d: syncrepl line must appear inside "
1811 "a database definition.\n", fname, lineno, 0);
1813 Debug( LDAP_DEBUG_ANY,
1814 "%s: line %d: syncrepl line must appear inside "
1815 "a database definition.\n", fname, lineno, 0);
1819 } else if ( SLAP_SHADOW( be )) {
1821 LDAP_LOG( CONFIG, INFO,
1822 "%s: line %d: syncrepl: database already shadowed.\n",
1825 Debug( LDAP_DEBUG_ANY,
1826 "%s: line %d: syncrepl: database already shadowed.\n",
1831 } else if ( add_syncrepl( be, cargv, cargc )) {
1835 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW );
1837 /* list of replicas of the data in this backend (master only) */
1838 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1841 LDAP_LOG( CONFIG, CRIT,
1842 "%s: line %d: missing host or uri in \"replica "
1843 " <host[:port]\" line\n", fname, lineno , 0 );
1845 Debug( LDAP_DEBUG_ANY,
1846 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1854 LDAP_LOG( CONFIG, INFO,
1855 "%s: line %d: replica line must appear inside "
1856 "a database definition.\n", fname, lineno, 0);
1858 Debug( LDAP_DEBUG_ANY,
1859 "%s: line %d: replica line must appear inside a database definition\n",
1867 for ( i = 1; i < cargc; i++ ) {
1868 if ( strncasecmp( cargv[i], "host=", 5 )
1870 nr = add_replica_info( be,
1873 } else if (strncasecmp( cargv[i], "uri=", 4 )
1875 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1878 LDAP_LOG( CONFIG, INFO,
1879 "%s: line %d: replica line contains invalid "
1880 "uri definition.\n", fname, lineno, 0);
1882 Debug( LDAP_DEBUG_ANY,
1883 "%s: line %d: replica line contains invalid "
1884 "uri definition.\n", fname, lineno, 0);
1888 if (ludp->lud_host == NULL ) {
1890 LDAP_LOG( CONFIG, INFO,
1891 "%s: line %d: replica line contains invalid "
1892 "uri definition - missing hostname.\n",
1895 Debug( LDAP_DEBUG_ANY,
1896 "%s: line %d: replica line contains invalid "
1897 "uri definition - missing hostname.\n", fname, lineno, 0);
1901 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1902 if ( replicahost == NULL ) {
1904 LDAP_LOG( CONFIG, ERR,
1905 "out of memory in read_config\n", 0, 0,0 );
1907 Debug( LDAP_DEBUG_ANY,
1908 "out of memory in read_config\n", 0, 0, 0 );
1910 ldap_free_urldesc( ludp );
1911 exit( EXIT_FAILURE );
1913 sprintf(replicahost, "%s:%d",
1914 ludp->lud_host, ludp->lud_port);
1915 nr = add_replica_info( be, replicahost );
1916 ldap_free_urldesc( ludp );
1917 ch_free(replicahost);
1923 LDAP_LOG( CONFIG, INFO,
1924 "%s: line %d: missing host or uri in \"replica\" line\n",
1925 fname, lineno , 0 );
1927 Debug( LDAP_DEBUG_ANY,
1928 "%s: line %d: missing host or uri in \"replica\" line\n",
1933 } else if ( nr == -1 ) {
1935 LDAP_LOG( CONFIG, INFO,
1936 "%s: line %d: unable to add"
1937 " replica \"%s\"\n",
1941 Debug( LDAP_DEBUG_ANY,
1942 "%s: line %d: unable to add replica \"%s\"\n",
1943 fname, lineno, cargv[i] + 5 );
1947 for ( i = 1; i < cargc; i++ ) {
1948 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1950 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1953 LDAP_LOG( CONFIG, INFO,
1954 "%s: line %d: suffix \"%s\" in \"replica\""
1955 " line is not valid for backend(ignored)\n",
1956 fname, lineno, cargv[i] + 7 );
1958 Debug( LDAP_DEBUG_ANY,
1959 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1960 fname, lineno, cargv[i] + 7 );
1966 LDAP_LOG( CONFIG, INFO,
1967 "%s: line %d: unable to normalize suffix"
1968 " in \"replica\" line (ignored)\n",
1969 fname, lineno , 0 );
1971 Debug( LDAP_DEBUG_ANY,
1972 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1978 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1980 char *arg = cargv[i] + 4;
1982 if ( arg[0] == '!' ) {
1987 if ( arg[0] != '=' ) {
1991 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1993 LDAP_LOG( CONFIG, INFO,
1994 "%s: line %d: attribute \"%s\" in "
1995 "\"replica\" line is unknown\n",
1996 fname, lineno, arg + 1 );
1998 Debug( LDAP_DEBUG_ANY,
1999 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
2000 fname, lineno, arg + 1 );
2009 } else if ( strcasecmp( cargv[0], "replicationInterval" ) == 0 ) {
2012 /* dn of slave entity allowed to write to replica */
2013 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
2016 LDAP_LOG( CONFIG, CRIT,
2017 "%s: line %d: missing dn in \"updatedn <dn>\""
2018 " line.\n", fname, lineno , 0 );
2020 Debug( LDAP_DEBUG_ANY,
2021 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
2029 LDAP_LOG( CONFIG, INFO,
2030 "%s: line %d: updatedn line must appear inside "
2031 "a database definition\n",
2032 fname, lineno , 0 );
2034 Debug( LDAP_DEBUG_ANY,
2035 "%s: line %d: updatedn line must appear inside a database definition\n",
2040 } else if ( SLAP_SHADOW(be) ) {
2042 LDAP_LOG( CONFIG, INFO,
2043 "%s: line %d: updatedn: database already shadowed.\n",
2046 Debug( LDAP_DEBUG_ANY,
2047 "%s: line %d: updatedn: database already shadowed.\n",
2055 if ( load_ucdata( NULL ) < 0 ) return 1;
2057 dn.bv_val = cargv[1];
2058 dn.bv_len = strlen( cargv[1] );
2060 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
2061 if( rc != LDAP_SUCCESS ) {
2063 LDAP_LOG( CONFIG, CRIT,
2064 "%s: line %d: updatedn DN is invalid.\n",
2065 fname, lineno , 0 );
2067 Debug( LDAP_DEBUG_ANY,
2068 "%s: line %d: updatedn DN is invalid\n",
2075 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW );
2077 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
2080 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2081 "missing url in \"updateref <ldapurl>\" line.\n",
2082 fname, lineno , 0 );
2084 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2085 "missing url in \"updateref <ldapurl>\" line\n",
2093 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2094 " line must appear inside a database definition\n",
2095 fname, lineno , 0 );
2097 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2098 " line must appear inside a database definition\n",
2103 } else if ( !SLAP_SHADOW(be) ) {
2105 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2106 "updateref line must come after syncrepl or updatedn.\n",
2107 fname, lineno , 0 );
2109 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2110 "updateref line must after syncrepl or updatedn.\n",
2116 if( validate_global_referral( cargv[1] ) ) {
2118 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2119 "invalid URL (%s) in \"updateref\" line.\n",
2120 fname, lineno, cargv[1] );
2122 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2123 "invalid URL (%s) in \"updateref\" line.\n",
2124 fname, lineno, cargv[1] );
2129 vals[0].bv_val = cargv[1];
2130 vals[0].bv_len = strlen( vals[0].bv_val );
2131 if( value_add( &be->be_update_refs, vals ) ) {
2135 /* replication log file to which changes are appended */
2136 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2139 LDAP_LOG( CONFIG, CRIT,
2140 "%s: line %d: missing filename in \"replogfile <filename>\""
2141 " line.\n", fname, lineno , 0 );
2143 Debug( LDAP_DEBUG_ANY,
2144 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2151 be->be_replogfile = ch_strdup( cargv[1] );
2153 replogfile = ch_strdup( cargv[1] );
2156 /* file from which to read additional rootdse attrs */
2157 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2160 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2161 "missing filename in \"rootDSE <filename>\" line.\n",
2162 fname, lineno , 0 );
2164 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2165 "missing filename in \"rootDSE <filename>\" line.\n",
2171 if( read_root_dse_file( cargv[1] ) ) {
2173 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2174 "could not read \"rootDSE <filename>\" line.\n",
2175 fname, lineno , 0 );
2177 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2178 "could not read \"rootDSE <filename>\" line\n",
2184 /* maintain lastmodified{by,time} attributes */
2185 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2188 LDAP_LOG( CONFIG, CRIT,
2189 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2190 " line.\n", fname, lineno , 0 );
2192 Debug( LDAP_DEBUG_ANY,
2193 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2199 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2201 SLAP_DBFLAGS(be) &= ~SLAP_DBFLAG_NOLASTMOD;
2207 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD;
2214 /* turn on/off gentle SIGHUP handling */
2215 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2217 Debug( LDAP_DEBUG_ANY,
2218 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2222 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2223 global_gentlehup = 0;
2225 global_gentlehup = 1;
2229 /* set idle timeout value */
2230 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2234 LDAP_LOG( CONFIG, CRIT,
2235 "%s: line %d: missing timeout value in "
2236 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2238 Debug( LDAP_DEBUG_ANY,
2239 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2246 i = atoi( cargv[1] );
2250 LDAP_LOG( CONFIG, CRIT,
2251 "%s: line %d: timeout value (%d) invalid "
2252 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2254 Debug( LDAP_DEBUG_ANY,
2255 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2262 global_idletimeout = i;
2264 /* include another config file */
2265 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2268 LDAP_LOG( CONFIG, CRIT,
2269 "%s: line %d: missing filename in \"include "
2270 "<filename>\" line.\n", fname, lineno , 0 );
2272 Debug( LDAP_DEBUG_ANY,
2273 "%s: line %d: missing filename in \"include <filename>\" line\n",
2279 savefname = ch_strdup( cargv[1] );
2280 savelineno = lineno;
2282 if ( read_config( savefname, depth+1 ) != 0 ) {
2287 lineno = savelineno - 1;
2289 /* location of kerberos srvtab file */
2290 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2293 LDAP_LOG( CONFIG, CRIT,
2294 "%s: line %d: missing filename in \"srvtab "
2295 "<filename>\" line.\n", fname, lineno , 0 );
2297 Debug( LDAP_DEBUG_ANY,
2298 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2304 ldap_srvtab = ch_strdup( cargv[1] );
2306 #ifdef SLAPD_MODULES
2307 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2310 LDAP_LOG( CONFIG, INFO,
2311 "%s: line %d: missing filename in \"moduleload "
2312 "<filename>\" line.\n", fname, lineno , 0 );
2314 Debug( LDAP_DEBUG_ANY,
2315 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2319 exit( EXIT_FAILURE );
2321 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2323 LDAP_LOG( CONFIG, CRIT,
2324 "%s: line %d: failed to load or initialize module %s\n",
2325 fname, lineno, cargv[1] );
2327 Debug( LDAP_DEBUG_ANY,
2328 "%s: line %d: failed to load or initialize module %s\n",
2329 fname, lineno, cargv[1]);
2332 exit( EXIT_FAILURE );
2334 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2337 LDAP_LOG( CONFIG, INFO,
2338 "%s: line %d: missing path in \"modulepath <path>\""
2339 " line\n", fname, lineno , 0 );
2341 Debug( LDAP_DEBUG_ANY,
2342 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2346 exit( EXIT_FAILURE );
2348 if (module_path( cargv[1] )) {
2350 LDAP_LOG( CONFIG, CRIT,
2351 "%s: line %d: failed to set module search path to %s.\n",
2352 fname, lineno, cargv[1] );
2354 Debug( LDAP_DEBUG_ANY,
2355 "%s: line %d: failed to set module search path to %s\n",
2356 fname, lineno, cargv[1]);
2359 exit( EXIT_FAILURE );
2362 #endif /*SLAPD_MODULES*/
2365 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2366 rc = ldap_pvt_tls_set_option( NULL,
2367 LDAP_OPT_X_TLS_RANDOM_FILE,
2372 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2373 rc = ldap_pvt_tls_set_option( NULL,
2374 LDAP_OPT_X_TLS_CIPHER_SUITE,
2379 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2380 rc = ldap_pvt_tls_set_option( NULL,
2381 LDAP_OPT_X_TLS_CERTFILE,
2386 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2387 rc = ldap_pvt_tls_set_option( NULL,
2388 LDAP_OPT_X_TLS_KEYFILE,
2393 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2394 rc = ldap_pvt_tls_set_option( NULL,
2395 LDAP_OPT_X_TLS_CACERTDIR,
2400 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2401 rc = ldap_pvt_tls_set_option( NULL,
2402 LDAP_OPT_X_TLS_CACERTFILE,
2406 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2407 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2409 rc = ldap_pvt_tls_set_option( NULL,
2410 LDAP_OPT_X_TLS_REQUIRE_CERT,
2413 rc = ldap_int_tls_config( NULL,
2414 LDAP_OPT_X_TLS_REQUIRE_CERT,
2423 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2424 #ifdef SLAPD_RLOOKUPS
2427 LDAP_LOG( CONFIG, INFO,
2428 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2429 fname, lineno , 0 );
2431 Debug( LDAP_DEBUG_ANY,
2432 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2438 if ( !strcasecmp( cargv[1], "on" ) ) {
2439 use_reverse_lookup = 1;
2440 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2441 use_reverse_lookup = 0;
2444 LDAP_LOG( CONFIG, INFO,
2445 "%s: line %d: reverse-lookup: "
2446 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2448 Debug( LDAP_DEBUG_ANY,
2449 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2455 #else /* !SLAPD_RLOOKUPS */
2457 LDAP_LOG( CONFIG, INFO,
2458 "%s: line %d: reverse lookups "
2459 "are not configured (ignored).\n", fname, lineno , 0 );
2461 Debug( LDAP_DEBUG_ANY,
2462 "%s: line %d: reverse lookups are not configured (ignored).\n",
2465 #endif /* !SLAPD_RLOOKUPS */
2467 /* Netscape plugins */
2468 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2469 #if defined( LDAP_SLAPI )
2471 #ifdef notdef /* allow global plugins, too */
2473 * a "plugin" line must be inside a database
2474 * definition, since we implement pre-,post-
2475 * and extended operation plugins
2479 LDAP_LOG( CONFIG, INFO,
2480 "%s: line %d: plugin line must appear "
2481 "insid a database definition.\n",
2484 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2485 "line must appear inside a database "
2486 "definition\n", fname, lineno, 0 );
2492 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
2496 slapi_plugins_used++;
2498 #else /* !defined( LDAP_SLAPI ) */
2500 LDAP_LOG( CONFIG, INFO,
2501 "%s: line %d: SLAPI not supported.\n",
2504 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2505 "not supported.\n", fname, lineno, 0 );
2509 #endif /* !defined( LDAP_SLAPI ) */
2511 /* Netscape plugins */
2512 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2513 #if defined( LDAP_SLAPI )
2516 LDAP_LOG( CONFIG, INFO,
2517 "%s: line %d: missing file name "
2518 "in pluginlog <filename> line.\n",
2521 Debug( LDAP_DEBUG_ANY,
2522 "%s: line %d: missing file name "
2523 "in pluginlog <filename> line.\n",
2529 if ( slapi_log_file != NULL ) {
2530 ch_free( slapi_log_file );
2533 slapi_log_file = ch_strdup( cargv[1] );
2534 #endif /* !defined( LDAP_SLAPI ) */
2536 /* pass anything else to the current backend info/db config routine */
2539 if ( bi->bi_config ) {
2540 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
2546 case SLAP_CONF_UNKNOWN:
2548 LDAP_LOG( CONFIG, INFO,
2549 "%s: line %d: unknown directive \"%s\" inside "
2550 "backend info definition (ignored).\n",
2551 fname, lineno, cargv[0] );
2553 Debug( LDAP_DEBUG_ANY,
2554 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2555 fname, lineno, cargv[0] );
2564 } else if ( be != NULL ) {
2565 if ( be->be_config ) {
2566 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
2572 case SLAP_CONF_UNKNOWN:
2574 LDAP_LOG( CONFIG, INFO,
2575 "%s: line %d: unknown directive \"%s\" inside "
2576 "backend database definition (ignored).\n",
2577 fname, lineno, cargv[0] );
2579 Debug( LDAP_DEBUG_ANY,
2580 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2581 fname, lineno, cargv[0] );
2592 LDAP_LOG( CONFIG, INFO,
2593 "%s: line %d: unknown directive \"%s\" outside backend "
2594 "info and database definitions (ignored).\n",
2595 fname, lineno, cargv[0] );
2597 Debug( LDAP_DEBUG_ANY,
2598 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2599 fname, lineno, cargv[0] );
2608 if ( depth == 0 ) ch_free( cargv );
2610 if ( !global_schemadn.bv_val ) {
2611 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2613 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2616 if ( load_ucdata( NULL ) < 0 ) return 1;
2628 char logbuf[sizeof("pseudorootpw ***")];
2631 token = strtok_quote( line, " \t" );
2635 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2636 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2637 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2638 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2639 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2641 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2644 if ( strtok_quote_ptr ) {
2645 *strtok_quote_ptr = ' ';
2649 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2651 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2654 if ( strtok_quote_ptr ) {
2655 *strtok_quote_ptr = '\0';
2658 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2659 if ( cargc == cargv_size - 1 ) {
2661 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2663 if ( tmp == NULL ) {
2665 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2667 Debug( LDAP_DEBUG_ANY,
2668 "line %d: out of memory\n",
2674 cargv_size += ARGS_STEP;
2676 cargv[cargc++] = token;
2678 cargv[cargc] = NULL;
2683 strtok_quote( char *line, char *sep )
2689 strtok_quote_ptr = NULL;
2690 if ( line != NULL ) {
2693 while ( *next && strchr( sep, *next ) ) {
2697 if ( *next == '\0' ) {
2703 for ( inquote = 0; *next; ) {
2711 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2717 next + 1, strlen( next + 1 ) + 1 );
2718 next++; /* dont parse the escaped character */
2723 if ( strchr( sep, *next ) != NULL ) {
2724 strtok_quote_ptr = next;
2737 static char buf[BUFSIZ];
2739 static size_t lmax, lcur;
2741 #define CATLINE( buf ) \
2743 size_t len = strlen( buf ); \
2744 while ( lcur + len + 1 > lmax ) { \
2746 line = (char *) ch_realloc( line, lmax ); \
2748 strcpy( line + lcur, buf ); \
2753 fp_getline( FILE *fp, int *lineno )
2761 /* hack attack - keeps us from having to keep a stack of bufs... */
2762 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2767 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2768 /* trim off \r\n or \n */
2769 if ( (p = strchr( buf, '\n' )) != NULL ) {
2770 if( p > buf && p[-1] == '\r' ) --p;
2774 /* trim off trailing \ and append the next line */
2775 if ( line[ 0 ] != '\0'
2776 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2777 && p[ -1 ] != '\\' ) {
2782 if ( ! isspace( (unsigned char) buf[0] ) ) {
2786 /* change leading whitespace to a space */
2795 return( line[0] ? line : NULL );
2799 fp_getline_init( int *lineno )
2805 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2807 load_ucdata( char *path )
2809 static int loaded = 0;
2815 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2818 LDAP_LOG( CONFIG, CRIT,
2819 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2821 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2834 ucdata_unload( UCDATA_ALL );
2835 free( global_schemandn.bv_val );
2836 free( global_schemadn.bv_val );
2838 if ( slapd_args_file )
2839 free ( slapd_args_file );
2840 if ( slapd_pid_file )
2841 free ( slapd_pid_file );
2842 if ( default_passwd_hash )
2843 ldap_charray_free( default_passwd_hash );
2844 acl_destroy( global_acl, NULL );
2855 syncinfo_t *si_entry;
2857 int duplicated_replica_id = 0;
2859 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2863 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2865 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2870 si->si_tls = SYNCINFO_TLS_OFF;
2871 if ( be->be_rootndn.bv_val ) {
2872 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2874 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2875 si->si_schemachecking = 0;
2876 ber_str2bv( "(objectclass=*)", sizeof("(objectclass=*)")-1, 0,
2877 &si->si_filterstr );
2878 si->si_base.bv_val = NULL;
2879 si->si_scope = LDAP_SCOPE_SUBTREE;
2880 si->si_attrsonly = 0;
2881 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
2882 si->si_attrs[0] = NULL;
2883 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2884 si->si_interval = 86400;
2885 si->si_syncCookie.ctxcsn = NULL;
2886 si->si_syncCookie.octet_str = NULL;
2887 si->si_syncCookie.sid = -1;
2888 si->si_manageDSAit = 0;
2891 si->si_syncUUID_ndn.bv_val = NULL;
2892 si->si_syncUUID_ndn.bv_len = 0;
2894 si->si_presentlist = NULL;
2895 LDAP_LIST_INIT( &si->si_nonpresentlist );
2897 rc = parse_syncrepl_line( cargv, cargc, si );
2899 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2900 if ( si->si_rid == si_entry->si_rid ) {
2902 LDAP_LOG( CONFIG, ERR,
2903 "add_syncrepl: duplicated replica id\n", 0, 0,0 );
2905 Debug( LDAP_DEBUG_ANY,
2906 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
2908 duplicated_replica_id = 1;
2913 if ( rc < 0 || duplicated_replica_id ) {
2914 syncinfo_t *si_entry;
2915 /* Something bad happened - back out */
2917 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2919 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2922 /* If error, remove all syncinfo */
2923 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2924 if ( si_entry->si_updatedn.bv_val ) {
2925 ch_free( si->si_updatedn.bv_val );
2927 if ( si_entry->si_filterstr.bv_val ) {
2928 ch_free( si->si_filterstr.bv_val );
2930 if ( si_entry->si_attrs ) {
2932 while ( si_entry->si_attrs[i] != NULL ) {
2933 ch_free( si_entry->si_attrs[i] );
2936 ch_free( si_entry->si_attrs );
2940 while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
2941 si_entry = LDAP_STAILQ_FIRST( &be->be_syncinfo );
2942 LDAP_STAILQ_REMOVE_HEAD( &be->be_syncinfo, si_next );
2943 ch_free( si_entry );
2945 LDAP_STAILQ_INIT( &be->be_syncinfo );
2949 LDAP_LOG ( CONFIG, RESULTS,
2950 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
2951 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2953 Debug( LDAP_DEBUG_CONFIG,
2954 "Config: ** successfully added syncrepl \"%s\"\n",
2955 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2957 if ( !si->si_schemachecking ) {
2958 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2961 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
2967 #define PROVIDERSTR "provider"
2968 #define SUFFIXSTR "suffix"
2969 #define UPDATEDNSTR "updatedn"
2970 #define BINDMETHSTR "bindmethod"
2971 #define SIMPLESTR "simple"
2972 #define SASLSTR "sasl"
2973 #define BINDDNSTR "binddn"
2974 #define CREDSTR "credentials"
2975 #define OLDAUTHCSTR "bindprincipal"
2976 #define AUTHCSTR "authcID"
2977 #define AUTHZSTR "authzID"
2978 #define SRVTABSTR "srvtab"
2979 #define SASLMECHSTR "saslmech"
2980 #define REALMSTR "realm"
2981 #define SECPROPSSTR "secprops"
2982 #define STARTTLSSTR "starttls"
2983 #define CRITICALSTR "critical"
2985 #define SCHEMASTR "schemachecking"
2986 #define FILTERSTR "filter"
2987 #define SEARCHBASESTR "searchbase"
2988 #define SCOPESTR "scope"
2989 #define ATTRSSTR "attrs"
2990 #define ATTRSONLYSTR "attrsonly"
2991 #define TYPESTR "type"
2992 #define INTERVALSTR "interval"
2993 #define LASTMODSTR "lastmod"
2994 #define LMREQSTR "req"
2995 #define LMGENSTR "gen"
2996 #define LMNOSTR "no"
2997 #define MANAGEDSAITSTR "manageDSAit"
2998 #define SLIMITSTR "sizelimit"
2999 #define TLIMITSTR "timelimit"
3001 #define GOT_ID 0x0001
3002 #define GOT_PROVIDER 0x0002
3003 #define GOT_METHOD 0x0004
3004 #define GOT_ALL 0x0007
3007 parse_syncrepl_line(
3018 for ( i = 1; i < cargc; i++ ) {
3019 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
3021 /* '\0' string terminator accounts for '=' */
3022 val = cargv[ i ] + sizeof( IDSTR );
3024 if ( tmp >= 1000 || tmp < 0 ) {
3025 fprintf( stderr, "Error: parse_syncrepl_line: "
3026 "syncrepl id %d is out of range [0..999]\n", tmp );
3031 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
3032 sizeof( PROVIDERSTR ) - 1 )) {
3033 val = cargv[ i ] + sizeof( PROVIDERSTR );
3034 si->si_provideruri = ch_strdup( val );
3035 si->si_provideruri_bv = (BerVarray)
3036 ch_calloc( 2, sizeof( struct berval ));
3037 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
3038 0, &si->si_provideruri_bv[0] );
3039 si->si_provideruri_bv[1].bv_len = 0;
3040 si->si_provideruri_bv[1].bv_val = NULL;
3041 gots |= GOT_PROVIDER;
3042 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
3043 sizeof(STARTTLSSTR) - 1 ) )
3045 val = cargv[ i ] + sizeof( STARTTLSSTR );
3046 if( !strcasecmp( val, CRITICALSTR ) ) {
3047 si->si_tls = SYNCINFO_TLS_CRITICAL;
3049 si->si_tls = SYNCINFO_TLS_ON;
3051 } else if ( !strncasecmp( cargv[ i ],
3052 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
3054 struct berval updatedn = {0, NULL};
3055 val = cargv[ i ] + sizeof( UPDATEDNSTR );
3056 ber_str2bv( val, 0, 0, &updatedn );
3057 ch_free( si->si_updatedn.bv_val );
3058 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
3059 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
3060 sizeof( BINDMETHSTR ) - 1 ) )
3062 val = cargv[ i ] + sizeof( BINDMETHSTR );
3063 if ( !strcasecmp( val, SIMPLESTR )) {
3064 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3066 } else if ( !strcasecmp( val, SASLSTR )) {
3067 #ifdef HAVE_CYRUS_SASL
3068 si->si_bindmethod = LDAP_AUTH_SASL;
3070 #else /* HAVE_CYRUS_SASL */
3071 fprintf( stderr, "Error: parse_syncrepl_line: "
3072 "not compiled with SASL support\n" );
3074 #endif /* HAVE_CYRUS_SASL */
3076 si->si_bindmethod = -1;
3078 } else if ( !strncasecmp( cargv[ i ],
3079 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
3080 val = cargv[ i ] + sizeof( BINDDNSTR );
3081 si->si_binddn = ch_strdup( val );
3082 } else if ( !strncasecmp( cargv[ i ],
3083 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
3084 val = cargv[ i ] + sizeof( CREDSTR );
3085 si->si_passwd = ch_strdup( val );
3086 } else if ( !strncasecmp( cargv[ i ],
3087 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
3088 val = cargv[ i ] + sizeof( SASLMECHSTR );
3089 si->si_saslmech = ch_strdup( val );
3090 } else if ( !strncasecmp( cargv[ i ],
3091 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
3092 val = cargv[ i ] + sizeof( SECPROPSSTR );
3093 si->si_secprops = ch_strdup( val );
3094 } else if ( !strncasecmp( cargv[ i ],
3095 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
3096 val = cargv[ i ] + sizeof( REALMSTR );
3097 si->si_realm = ch_strdup( val );
3098 } else if ( !strncasecmp( cargv[ i ],
3099 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
3100 val = cargv[ i ] + sizeof( AUTHCSTR );
3101 si->si_authcId = ch_strdup( val );
3102 } else if ( !strncasecmp( cargv[ i ],
3103 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
3104 /* Old authcID is provided for some backwards compatibility */
3105 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
3106 si->si_authcId = ch_strdup( val );
3107 } else if ( !strncasecmp( cargv[ i ],
3108 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
3109 val = cargv[ i ] + sizeof( AUTHZSTR );
3110 si->si_authzId = ch_strdup( val );
3111 } else if ( !strncasecmp( cargv[ i ],
3112 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
3114 val = cargv[ i ] + sizeof( SCHEMASTR );
3115 if ( !strncasecmp( val, "on", sizeof( "on" ) - 1 )) {
3116 si->si_schemachecking = 1;
3117 } else if ( !strncasecmp( val, "off", sizeof( "off" ) - 1 ) ) {
3118 si->si_schemachecking = 0;
3120 si->si_schemachecking = 1;
3122 } else if ( !strncasecmp( cargv[ i ],
3123 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
3125 val = cargv[ i ] + sizeof( FILTERSTR );
3126 ber_str2bv( val, 0, 1, &si->si_filterstr );
3127 } else if ( !strncasecmp( cargv[ i ],
3128 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3131 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3132 if ( si->si_base.bv_val ) {
3133 ch_free( si->si_base.bv_val );
3135 ber_str2bv( val, 0, 0, &bv );
3136 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3137 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3140 } else if ( !strncasecmp( cargv[ i ],
3141 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3143 val = cargv[ i ] + sizeof( SCOPESTR );
3144 if ( !strncasecmp( val, "base", sizeof( "base" ) - 1 )) {
3145 si->si_scope = LDAP_SCOPE_BASE;
3146 } else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
3147 si->si_scope = LDAP_SCOPE_ONELEVEL;
3148 #ifdef LDAP_SCOPE_SUBORDINATE
3149 } else if ( !strcasecmp( val, "subordinate" ) ||
3150 !strcasecmp( val, "children" ))
3152 si->si_scope = LDAP_SCOPE_SUBORDINATE;
3154 } else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
3155 si->si_scope = LDAP_SCOPE_SUBTREE;
3157 fprintf( stderr, "Error: parse_syncrepl_line: "
3158 "unknown scope \"%s\"\n", val);
3161 } else if ( !strncasecmp( cargv[ i ],
3162 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3164 si->si_attrsonly = 1;
3165 } else if ( !strncasecmp( cargv[ i ],
3166 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3168 val = cargv[ i ] + sizeof( ATTRSSTR );
3169 str2clist( &si->si_attrs, val, "," );
3170 } else if ( !strncasecmp( cargv[ i ],
3171 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3173 val = cargv[ i ] + sizeof( TYPESTR );
3174 if ( !strncasecmp( val, "refreshOnly", sizeof("refreshOnly")-1 )) {
3175 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3176 } else if ( !strncasecmp( val, "refreshAndPersist",
3177 sizeof("refreshAndPersist")-1 ))
3179 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3180 si->si_interval = 60;
3182 fprintf( stderr, "Error: parse_syncrepl_line: "
3183 "unknown sync type \"%s\"\n", val);
3186 } else if ( !strncasecmp( cargv[ i ],
3187 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3189 val = cargv[ i ] + sizeof( INTERVALSTR );
3190 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
3191 si->si_interval = 0;
3199 hstr = strchr( dstr, ':' );
3200 if ( hstr == NULL ) {
3201 fprintf( stderr, "Error: parse_syncrepl_line: "
3202 "invalid interval \"%s\"\n", val );
3206 mstr = strchr( hstr, ':' );
3207 if ( mstr == NULL ) {
3208 fprintf( stderr, "Error: parse_syncrepl_line: "
3209 "invalid interval \"%s\"\n", val );
3213 sstr = strchr( mstr, ':' );
3214 if ( sstr == NULL ) {
3215 fprintf( stderr, "Error: parse_syncrepl_line: "
3216 "invalid interval \"%s\"\n", val );
3225 if (( hh > 24 ) || ( hh < 0 ) ||
3226 ( mm > 60 ) || ( mm < 0 ) ||
3227 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3228 fprintf( stderr, "Error: parse_syncrepl_line: "
3229 "invalid interval \"%s\"\n", val );
3232 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3234 if ( si->si_interval < 0 ) {
3235 fprintf( stderr, "Error: parse_syncrepl_line: "
3236 "invalid interval \"%ld\"\n",
3237 (long) si->si_interval);
3240 } else if ( !strncasecmp( cargv[ i ],
3241 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3243 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3244 si->si_manageDSAit = atoi( val );
3245 } else if ( !strncasecmp( cargv[ i ],
3246 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3248 val = cargv[ i ] + sizeof( SLIMITSTR );
3249 si->si_slimit = atoi( val );
3250 } else if ( !strncasecmp( cargv[ i ],
3251 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3253 val = cargv[ i ] + sizeof( TLIMITSTR );
3254 si->si_tlimit = atoi( val );
3256 fprintf( stderr, "Error: parse_syncrepl_line: "
3257 "unknown keyword \"%s\"\n", cargv[ i ] );
3261 if ( gots != GOT_ALL ) {
3263 "Error: Malformed \"syncrepl\" line in slapd config file" );
3271 str2clist( char ***out, char *in, const char *brkstr )
3280 /* find last element in list */
3281 for (i = 0; *out && *out[i]; i++);
3283 /* protect the input string from strtok */
3284 str = ch_strdup( in );
3286 if ( *str == '\0' ) {
3291 /* Count words in string */
3293 for ( s = str; *s; s++ ) {
3294 if ( strchr( brkstr, *s ) != NULL ) {
3299 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3301 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3303 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3305 *new = ch_strdup( s );