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 */
51 SLAPD_DEFAULT_TIMELIMIT,
53 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
54 SLAPD_DEFAULT_SIZELIMIT,
55 -1, /* no limit on unchecked size */
57 0, /* hide number of entries left */
58 SLAPD_DEFAULT_SIZELIMIT /* 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 );
846 lim->lms_s_hard = lim->lms_s_soft;
847 lim->lms_s_pr_total = lim->lms_s_soft;
852 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
854 struct slap_limits_set *lim;
858 LDAP_LOG( CONFIG, CRIT,
859 "%s: line %d missing limit in \"timelimit <limit>\" "
860 "line.\n", fname, lineno, 0 );
862 Debug( LDAP_DEBUG_ANY,
863 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
873 lim = &be->be_def_limit;
876 for ( i = 1; i < cargc; i++ ) {
877 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
878 rc = limits_parse_one( cargv[i], lim );
881 LDAP_LOG( CONFIG, CRIT,
882 "%s: line %d: unable to parse value \"%s\" "
883 "in \"timelimit <limit>\" line.\n",
884 fname, lineno, cargv[i] );
886 Debug( LDAP_DEBUG_ANY,
887 "%s: line %d: unable "
888 "to parse value \"%s\" "
891 fname, lineno, cargv[i] );
897 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
898 lim->lms_t_soft = -1;
902 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
903 if ( next == cargv[i] ) {
905 LDAP_LOG( CONFIG, CRIT,
906 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
907 "line.\n", fname, lineno, cargv[i] );
909 Debug( LDAP_DEBUG_ANY,
910 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
911 fname, lineno, cargv[i] );
915 } else if ( next[0] != '\0' ) {
917 LDAP_LOG( CONFIG, CRIT,
918 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
919 "line ignored.\n", fname, lineno, next );
921 Debug( LDAP_DEBUG_ANY,
922 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
923 fname, lineno, next );
927 lim->lms_t_hard = lim->lms_t_soft;
931 /* set regex-based limits */
932 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
935 LDAP_LOG( CONFIG, WARNING,
936 "%s: line %d \"limits\" allowed only in database "
937 "environment.\n", fname, lineno, 0 );
939 Debug( LDAP_DEBUG_ANY,
940 "%s: line %d \"limits\" allowed only in database environment.\n%s",
946 if ( limits_parse( be, fname, lineno, cargc, cargv ) ) {
950 /* mark this as a subordinate database */
951 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
954 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
955 "subordinate keyword must appear inside a database "
956 "definition.\n", fname, lineno, 0 );
958 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
959 "must appear inside a database definition.\n",
965 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
969 /* add an overlay to this backend */
970 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
973 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
974 "overlay keyword must appear inside a database "
975 "definition.\n", fname, lineno, 0 );
977 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
978 "must appear inside a database definition.\n",
984 if ( cargv[1][0] == '-' && overlay_config( be, &cargv[1][1] ) ) {
987 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
988 "(optional) overlay \"%s\" configuration "
989 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
991 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
992 "(optional) overlay \"%s\" configuration "
993 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
995 } else if ( overlay_config( be, cargv[1] ) ) {
1000 /* set database suffix */
1001 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
1003 struct berval dn, pdn, ndn;
1007 LDAP_LOG( CONFIG, CRIT,
1008 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
1011 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1012 "missing dn in \"suffix <dn>\" line\n",
1018 } else if ( cargc > 2 ) {
1020 LDAP_LOG( CONFIG, INFO,
1021 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
1022 " line (ignored).\n", fname, lineno, cargv[1] );
1024 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
1025 "after <dn> in \"suffix %s\" line (ignored)\n",
1026 fname, lineno, cargv[1] );
1032 LDAP_LOG( CONFIG, INFO,
1033 "%s: line %d: suffix line must appear inside a database "
1034 "definition.\n", fname, lineno, 0 );
1036 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
1037 "must appear inside a database definition\n",
1042 #if defined(SLAPD_MONITOR_DN)
1043 /* "cn=Monitor" is reserved for monitoring slap */
1044 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
1046 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
1047 "%s\" is reserved for monitoring slapd\n",
1048 fname, lineno, SLAPD_MONITOR_DN );
1050 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
1051 "%s\" is reserved for monitoring slapd\n",
1052 fname, lineno, SLAPD_MONITOR_DN );
1055 #endif /* SLAPD_MONITOR_DN */
1058 if ( load_ucdata( NULL ) < 0 ) return 1;
1060 dn.bv_val = cargv[1];
1061 dn.bv_len = strlen( cargv[1] );
1063 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1064 if( rc != LDAP_SUCCESS ) {
1066 LDAP_LOG( CONFIG, CRIT,
1067 "%s: line %d: suffix DN is invalid.\n",
1070 Debug( LDAP_DEBUG_ANY,
1071 "%s: line %d: suffix DN is invalid\n",
1077 tmp_be = select_backend( &ndn, 0, 0 );
1078 if ( tmp_be == be ) {
1080 LDAP_LOG( CONFIG, INFO,
1081 "%s: line %d: suffix already served by this backend "
1082 "(ignored)\n", fname, lineno, 0 );
1084 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1085 "already served by this backend (ignored)\n",
1091 } else if ( tmp_be != NULL ) {
1093 LDAP_LOG( CONFIG, INFO,
1094 "%s: line %d: suffix already served by a preceding "
1095 "backend \"%s\"\n", fname, lineno,
1096 tmp_be->be_suffix[0].bv_val );
1098 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1099 "already served by a preceeding backend \"%s\"\n",
1100 fname, lineno, tmp_be->be_suffix[0].bv_val );
1106 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1108 LDAP_LOG( CONFIG, INFO,
1109 "%s: line %d: suffix DN empty and default search "
1110 "base provided \"%s\" (assuming okay).\n",
1111 fname, lineno, default_search_base.bv_val );
1113 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1114 "suffix DN empty and default "
1115 "search base provided \"%s\" (assuming okay)\n",
1116 fname, lineno, default_search_base.bv_val );
1120 ber_bvarray_add( &be->be_suffix, &pdn );
1121 ber_bvarray_add( &be->be_nsuffix, &ndn );
1123 /* set max deref depth */
1124 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1128 LDAP_LOG( CONFIG, CRIT,
1129 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1130 " line\n", fname, lineno, 0 );
1132 Debug( LDAP_DEBUG_ANY,
1133 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1141 LDAP_LOG( CONFIG, INFO,
1142 "%s: line %d: depth line must appear inside a database "
1143 "definition.\n", fname, lineno ,0 );
1145 Debug( LDAP_DEBUG_ANY,
1146 "%s: line %d: depth line must appear inside a database definition.\n",
1151 } else if ((i = atoi(cargv[1])) < 0) {
1153 LDAP_LOG( CONFIG, INFO,
1154 "%s: line %d: depth must be positive.\n",
1157 Debug( LDAP_DEBUG_ANY,
1158 "%s: line %d: depth must be positive.\n",
1165 be->be_max_deref_depth = i;
1169 /* set magic "root" dn for this database */
1170 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1173 LDAP_LOG( CONFIG, INFO,
1174 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1177 Debug( LDAP_DEBUG_ANY,
1178 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1187 LDAP_LOG( CONFIG, INFO,
1188 "%s: line %d: rootdn line must appear inside a database "
1189 "definition.\n", fname, lineno ,0 );
1191 Debug( LDAP_DEBUG_ANY,
1192 "%s: line %d: rootdn line must appear inside a database definition.\n",
1200 if ( load_ucdata( NULL ) < 0 ) return 1;
1202 dn.bv_val = cargv[1];
1203 dn.bv_len = strlen( cargv[1] );
1205 rc = dnPrettyNormal( NULL, &dn,
1207 &be->be_rootndn, NULL );
1209 if( rc != LDAP_SUCCESS ) {
1211 LDAP_LOG( CONFIG, CRIT,
1212 "%s: line %d: rootdn DN is invalid.\n",
1215 Debug( LDAP_DEBUG_ANY,
1216 "%s: line %d: rootdn DN is invalid\n",
1223 /* set super-secret magic database password */
1224 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1227 LDAP_LOG( CONFIG, CRIT,
1228 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1229 " line\n", fname, lineno ,0 );
1231 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1232 "missing passwd in \"rootpw <passwd>\" line\n",
1241 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1242 "rootpw line must appear inside a database "
1243 "definition.\n", fname, lineno ,0 );
1245 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1246 "rootpw line must appear inside a database "
1253 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1255 if( tmp_be != be ) {
1257 LDAP_LOG( CONFIG, INFO,
1259 "rootpw can only be set when rootdn is under suffix\n",
1260 fname, lineno, "" );
1262 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1263 "rootpw can only be set when rootdn is under suffix\n",
1269 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1270 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1273 /* make this database read-only */
1274 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1277 LDAP_LOG( CONFIG, CRIT,
1278 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1279 "line.\n", fname, lineno ,0 );
1281 Debug( LDAP_DEBUG_ANY,
1282 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1289 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1290 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1292 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1295 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1296 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1298 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1303 /* allow these features */
1304 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1305 strcasecmp( cargv[0], "allow" ) == 0 )
1311 LDAP_LOG( CONFIG, INFO,
1312 "%s: line %d: allow line must appear prior to "
1313 "database definitions.\n", fname, lineno ,0 );
1315 Debug( LDAP_DEBUG_ANY,
1316 "%s: line %d: allow line must appear prior to database definitions\n",
1324 LDAP_LOG( CONFIG, CRIT,
1325 "%s: line %d: missing feature(s) in \"allow <features>\""
1326 " line\n", fname, lineno ,0 );
1328 Debug( LDAP_DEBUG_ANY,
1329 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1338 for( i=1; i < cargc; i++ ) {
1339 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1340 allows |= SLAP_ALLOW_BIND_V2;
1342 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1343 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1345 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1346 allows |= SLAP_ALLOW_BIND_ANON_DN;
1348 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1349 allows |= SLAP_ALLOW_UPDATE_ANON;
1351 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1353 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1354 "unknown feature %s in \"allow <features>\" line.\n",
1355 fname, lineno, cargv[1] );
1357 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1358 "unknown feature %s in \"allow <features>\" line\n",
1359 fname, lineno, cargv[i] );
1366 global_allows = allows;
1368 /* disallow these features */
1369 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1370 strcasecmp( cargv[0], "disallow" ) == 0 )
1372 slap_mask_t disallows;
1376 LDAP_LOG( CONFIG, INFO,
1377 "%s: line %d: disallow line must appear prior to "
1378 "database definitions.\n", fname, lineno ,0 );
1380 Debug( LDAP_DEBUG_ANY,
1381 "%s: line %d: disallow line must appear prior to database definitions\n",
1389 LDAP_LOG( CONFIG, CRIT,
1390 "%s: line %d: missing feature(s) in \"disallow <features>\""
1391 " line.\n", fname, lineno ,0 );
1393 Debug( LDAP_DEBUG_ANY,
1394 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1403 for( i=1; i < cargc; i++ ) {
1404 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1405 disallows |= SLAP_DISALLOW_BIND_ANON;
1407 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1408 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1410 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1411 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1413 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1414 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1416 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1417 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1419 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1421 LDAP_LOG( CONFIG, CRIT,
1422 "%s: line %d: unknown feature %s in "
1423 "\"disallow <features>\" line.\n",
1424 fname, lineno, cargv[i] );
1426 Debug( LDAP_DEBUG_ANY,
1427 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1428 fname, lineno, cargv[i] );
1435 global_disallows = disallows;
1437 /* require these features */
1438 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1439 strcasecmp( cargv[0], "require" ) == 0 )
1441 slap_mask_t requires;
1445 LDAP_LOG( CONFIG, CRIT,
1446 "%s: line %d: missing feature(s) in "
1447 "\"require <features>\" line.\n", fname, lineno ,0 );
1449 Debug( LDAP_DEBUG_ANY,
1450 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1459 for( i=1; i < cargc; i++ ) {
1460 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1461 requires |= SLAP_REQUIRE_BIND;
1463 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1464 requires |= SLAP_REQUIRE_LDAP_V3;
1466 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1467 requires |= SLAP_REQUIRE_AUTHC;
1469 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1470 requires |= SLAP_REQUIRE_SASL;
1472 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1473 requires |= SLAP_REQUIRE_STRONG;
1475 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1477 LDAP_LOG( CONFIG, CRIT,
1478 "%s: line %d: unknown feature %s in "
1479 "\"require <features>\" line.\n",
1480 fname, lineno , cargv[i] );
1482 Debug( LDAP_DEBUG_ANY,
1483 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1484 fname, lineno, cargv[i] );
1492 global_requires = requires;
1494 be->be_requires = requires;
1497 /* required security factors */
1498 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1499 slap_ssf_set_t *set;
1503 LDAP_LOG( CONFIG, CRIT,
1504 "%s: line %d: missing factor(s) in \"security <factors>\""
1505 " line.\n", fname, lineno ,0 );
1507 Debug( LDAP_DEBUG_ANY,
1508 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1516 set = &global_ssf_set;
1518 set = &be->be_ssf_set;
1521 for( i=1; i < cargc; i++ ) {
1522 if( strncasecmp( cargv[i], "ssf=",
1523 sizeof("ssf") ) == 0 )
1526 atoi( &cargv[i][sizeof("ssf")] );
1528 } else if( strncasecmp( cargv[i], "transport=",
1529 sizeof("transport") ) == 0 )
1531 set->sss_transport =
1532 atoi( &cargv[i][sizeof("transport")] );
1534 } else if( strncasecmp( cargv[i], "tls=",
1535 sizeof("tls") ) == 0 )
1538 atoi( &cargv[i][sizeof("tls")] );
1540 } else if( strncasecmp( cargv[i], "sasl=",
1541 sizeof("sasl") ) == 0 )
1544 atoi( &cargv[i][sizeof("sasl")] );
1546 } else if( strncasecmp( cargv[i], "update_ssf=",
1547 sizeof("update_ssf") ) == 0 )
1549 set->sss_update_ssf =
1550 atoi( &cargv[i][sizeof("update_ssf")] );
1552 } else if( strncasecmp( cargv[i], "update_transport=",
1553 sizeof("update_transport") ) == 0 )
1555 set->sss_update_transport =
1556 atoi( &cargv[i][sizeof("update_transport")] );
1558 } else if( strncasecmp( cargv[i], "update_tls=",
1559 sizeof("update_tls") ) == 0 )
1561 set->sss_update_tls =
1562 atoi( &cargv[i][sizeof("update_tls")] );
1564 } else if( strncasecmp( cargv[i], "update_sasl=",
1565 sizeof("update_sasl") ) == 0 )
1567 set->sss_update_sasl =
1568 atoi( &cargv[i][sizeof("update_sasl")] );
1570 } else if( strncasecmp( cargv[i], "simple_bind=",
1571 sizeof("simple_bind") ) == 0 )
1573 set->sss_simple_bind =
1574 atoi( &cargv[i][sizeof("simple_bind")] );
1578 LDAP_LOG( CONFIG, CRIT,
1579 "%s: line %d: unknown factor %S in "
1580 "\"security <factors>\" line.\n",
1581 fname, lineno, cargv[1] );
1583 Debug( LDAP_DEBUG_ANY,
1584 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1585 fname, lineno, cargv[i] );
1591 /* where to send clients when we don't hold it */
1592 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1595 LDAP_LOG( CONFIG, CRIT,
1596 "%s: line %d: missing URL in \"referral <URL>\""
1597 " line.\n", fname, lineno , 0 );
1599 Debug( LDAP_DEBUG_ANY,
1600 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1607 if( validate_global_referral( cargv[1] ) ) {
1609 LDAP_LOG( CONFIG, CRIT,
1610 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1611 fname, lineno, cargv[1] );
1613 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1614 "invalid URL (%s) in \"referral\" line.\n",
1615 fname, lineno, cargv[1] );
1620 vals[0].bv_val = cargv[1];
1621 vals[0].bv_len = strlen( vals[0].bv_val );
1622 if( value_add( &default_referral, vals ) )
1626 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1630 LDAP_LOG( CONFIG, CRIT,
1631 "%s: line %d: Error in logfile directive, "
1632 "\"logfile <filename>\"\n", fname, lineno , 0 );
1634 Debug( LDAP_DEBUG_ANY,
1635 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1641 logfile = fopen( cargv[1], "w" );
1642 if ( logfile != NULL ) lutil_debug_file( logfile );
1645 /* start of a new database definition */
1646 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1650 LDAP_LOG( CONFIG, CRIT,
1651 "%s: line %d: Error in debug directive, "
1652 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1654 Debug( LDAP_DEBUG_ANY,
1655 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1661 level = atoi( cargv[2] );
1662 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1663 lutil_set_debug_level( cargv[1], level );
1664 /* specify an Object Identifier macro */
1665 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1666 rc = parse_oidm( fname, lineno, cargc, cargv );
1669 /* specify an objectclass */
1670 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1673 LDAP_LOG( CONFIG, INFO,
1674 "%s: line %d: illegal objectclass format.\n",
1675 fname, lineno , 0 );
1677 Debug( LDAP_DEBUG_ANY,
1678 "%s: line %d: illegal objectclass format.\n",
1683 } else if ( *cargv[1] == '(' /*')'*/) {
1685 p = strchr(saveline,'(' /*')'*/);
1686 rc = parse_oc( fname, lineno, p, cargv );
1691 LDAP_LOG( CONFIG, INFO,
1692 "%s: line %d: old objectclass format not supported\n",
1693 fname, lineno , 0 );
1695 Debug( LDAP_DEBUG_ANY,
1696 "%s: line %d: old objectclass format not supported.\n",
1701 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1703 p = strchr(saveline,'(' /*')'*/);
1704 rc = parse_cr( fname, lineno, p, cargv );
1707 /* specify an attribute type */
1708 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1709 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1713 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1714 "illegal attribute type format.\n",
1715 fname, lineno , 0 );
1717 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1718 "illegal attribute type format.\n",
1723 } else if ( *cargv[1] == '(' /*')'*/) {
1725 p = strchr(saveline,'(' /*')'*/);
1726 rc = parse_at( fname, lineno, p, cargv );
1731 LDAP_LOG( CONFIG, INFO,
1732 "%s: line %d: old attribute type format not supported.\n",
1733 fname, lineno , 0 );
1735 Debug( LDAP_DEBUG_ANY,
1736 "%s: line %d: old attribute type format not supported.\n",
1742 /* define attribute option(s) */
1743 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1744 ad_define_option( NULL, NULL, 0 );
1745 for ( i = 1; i < cargc; i++ )
1746 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1749 /* turn on/off schema checking */
1750 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1753 LDAP_LOG( CONFIG, CRIT,
1754 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1755 " line.\n", fname, lineno , 0 );
1757 Debug( LDAP_DEBUG_ANY,
1758 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1764 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1766 LDAP_LOG( CONFIG, CRIT,
1767 "%s: line %d: schema checking disabled! your mileage may "
1768 "vary!\n", fname, lineno , 0 );
1770 Debug( LDAP_DEBUG_ANY,
1771 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1774 global_schemacheck = 0;
1776 global_schemacheck = 1;
1779 /* specify access control info */
1780 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1781 parse_acl( be, fname, lineno, cargc, cargv );
1783 /* debug level to log things to syslog */
1784 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1787 LDAP_LOG( CONFIG, CRIT,
1788 "%s: line %d: missing level in \"loglevel <level>\""
1789 " line.\n", fname, lineno , 0 );
1791 Debug( LDAP_DEBUG_ANY,
1792 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1801 for( i=1; i < cargc; i++ ) {
1802 ldap_syslog += atoi( cargv[1] );
1805 /* list of sync replication information in this backend (slave only) */
1806 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1810 LDAP_LOG( CONFIG, INFO,
1811 "%s: line %d: syncrepl line must appear inside "
1812 "a database definition.\n", fname, lineno, 0);
1814 Debug( LDAP_DEBUG_ANY,
1815 "%s: line %d: syncrepl line must appear inside "
1816 "a database definition.\n", fname, lineno, 0);
1820 } else if ( SLAP_SHADOW( be )) {
1822 LDAP_LOG( CONFIG, INFO,
1823 "%s: line %d: syncrepl: database already shadowed.\n",
1826 Debug( LDAP_DEBUG_ANY,
1827 "%s: line %d: syncrepl: database already shadowed.\n",
1832 } else if ( add_syncrepl( be, cargv, cargc )) {
1836 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW );
1838 /* list of replicas of the data in this backend (master only) */
1839 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1842 LDAP_LOG( CONFIG, CRIT,
1843 "%s: line %d: missing host or uri in \"replica "
1844 " <host[:port]\" line\n", fname, lineno , 0 );
1846 Debug( LDAP_DEBUG_ANY,
1847 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1855 LDAP_LOG( CONFIG, INFO,
1856 "%s: line %d: replica line must appear inside "
1857 "a database definition.\n", fname, lineno, 0);
1859 Debug( LDAP_DEBUG_ANY,
1860 "%s: line %d: replica line must appear inside a database definition\n",
1868 for ( i = 1; i < cargc; i++ ) {
1869 if ( strncasecmp( cargv[i], "host=", 5 )
1871 nr = add_replica_info( be,
1874 } else if (strncasecmp( cargv[i], "uri=", 4 )
1876 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1879 LDAP_LOG( CONFIG, INFO,
1880 "%s: line %d: replica line contains invalid "
1881 "uri definition.\n", fname, lineno, 0);
1883 Debug( LDAP_DEBUG_ANY,
1884 "%s: line %d: replica line contains invalid "
1885 "uri definition.\n", fname, lineno, 0);
1889 if (ludp->lud_host == NULL ) {
1891 LDAP_LOG( CONFIG, INFO,
1892 "%s: line %d: replica line contains invalid "
1893 "uri definition - missing hostname.\n",
1896 Debug( LDAP_DEBUG_ANY,
1897 "%s: line %d: replica line contains invalid "
1898 "uri definition - missing hostname.\n", fname, lineno, 0);
1902 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1903 if ( replicahost == NULL ) {
1905 LDAP_LOG( CONFIG, ERR,
1906 "out of memory in read_config\n", 0, 0,0 );
1908 Debug( LDAP_DEBUG_ANY,
1909 "out of memory in read_config\n", 0, 0, 0 );
1911 ldap_free_urldesc( ludp );
1912 exit( EXIT_FAILURE );
1914 sprintf(replicahost, "%s:%d",
1915 ludp->lud_host, ludp->lud_port);
1916 nr = add_replica_info( be, replicahost );
1917 ldap_free_urldesc( ludp );
1918 ch_free(replicahost);
1924 LDAP_LOG( CONFIG, INFO,
1925 "%s: line %d: missing host or uri in \"replica\" line\n",
1926 fname, lineno , 0 );
1928 Debug( LDAP_DEBUG_ANY,
1929 "%s: line %d: missing host or uri in \"replica\" line\n",
1934 } else if ( nr == -1 ) {
1936 LDAP_LOG( CONFIG, INFO,
1937 "%s: line %d: unable to add"
1938 " replica \"%s\"\n",
1942 Debug( LDAP_DEBUG_ANY,
1943 "%s: line %d: unable to add replica \"%s\"\n",
1944 fname, lineno, cargv[i] + 5 );
1948 for ( i = 1; i < cargc; i++ ) {
1949 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1951 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1954 LDAP_LOG( CONFIG, INFO,
1955 "%s: line %d: suffix \"%s\" in \"replica\""
1956 " line is not valid for backend(ignored)\n",
1957 fname, lineno, cargv[i] + 7 );
1959 Debug( LDAP_DEBUG_ANY,
1960 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1961 fname, lineno, cargv[i] + 7 );
1967 LDAP_LOG( CONFIG, INFO,
1968 "%s: line %d: unable to normalize suffix"
1969 " in \"replica\" line (ignored)\n",
1970 fname, lineno , 0 );
1972 Debug( LDAP_DEBUG_ANY,
1973 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1979 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1981 char *arg = cargv[i] + 4;
1983 if ( arg[0] == '!' ) {
1988 if ( arg[0] != '=' ) {
1992 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1994 LDAP_LOG( CONFIG, INFO,
1995 "%s: line %d: attribute \"%s\" in "
1996 "\"replica\" line is unknown\n",
1997 fname, lineno, arg + 1 );
1999 Debug( LDAP_DEBUG_ANY,
2000 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
2001 fname, lineno, arg + 1 );
2010 } else if ( strcasecmp( cargv[0], "replicationInterval" ) == 0 ) {
2013 /* dn of slave entity allowed to write to replica */
2014 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
2017 LDAP_LOG( CONFIG, CRIT,
2018 "%s: line %d: missing dn in \"updatedn <dn>\""
2019 " line.\n", fname, lineno , 0 );
2021 Debug( LDAP_DEBUG_ANY,
2022 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
2030 LDAP_LOG( CONFIG, INFO,
2031 "%s: line %d: updatedn line must appear inside "
2032 "a database definition\n",
2033 fname, lineno , 0 );
2035 Debug( LDAP_DEBUG_ANY,
2036 "%s: line %d: updatedn line must appear inside a database definition\n",
2041 } else if ( SLAP_SHADOW(be) ) {
2043 LDAP_LOG( CONFIG, INFO,
2044 "%s: line %d: updatedn: database already shadowed.\n",
2047 Debug( LDAP_DEBUG_ANY,
2048 "%s: line %d: updatedn: database already shadowed.\n",
2056 if ( load_ucdata( NULL ) < 0 ) return 1;
2058 dn.bv_val = cargv[1];
2059 dn.bv_len = strlen( cargv[1] );
2061 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
2062 if( rc != LDAP_SUCCESS ) {
2064 LDAP_LOG( CONFIG, CRIT,
2065 "%s: line %d: updatedn DN is invalid.\n",
2066 fname, lineno , 0 );
2068 Debug( LDAP_DEBUG_ANY,
2069 "%s: line %d: updatedn DN is invalid\n",
2076 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW );
2078 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
2081 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2082 "missing url in \"updateref <ldapurl>\" line.\n",
2083 fname, lineno , 0 );
2085 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2086 "missing url in \"updateref <ldapurl>\" line\n",
2094 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2095 " line must appear inside a database definition\n",
2096 fname, lineno , 0 );
2098 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2099 " line must appear inside a database definition\n",
2104 } else if ( !SLAP_SHADOW(be) ) {
2106 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2107 "updateref line must come after syncrepl or updatedn.\n",
2108 fname, lineno , 0 );
2110 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2111 "updateref line must after syncrepl or updatedn.\n",
2117 if( validate_global_referral( cargv[1] ) ) {
2119 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2120 "invalid URL (%s) in \"updateref\" line.\n",
2121 fname, lineno, cargv[1] );
2123 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2124 "invalid URL (%s) in \"updateref\" line.\n",
2125 fname, lineno, cargv[1] );
2130 vals[0].bv_val = cargv[1];
2131 vals[0].bv_len = strlen( vals[0].bv_val );
2132 if( value_add( &be->be_update_refs, vals ) ) {
2136 /* replication log file to which changes are appended */
2137 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2140 LDAP_LOG( CONFIG, CRIT,
2141 "%s: line %d: missing filename in \"replogfile <filename>\""
2142 " line.\n", fname, lineno , 0 );
2144 Debug( LDAP_DEBUG_ANY,
2145 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2152 be->be_replogfile = ch_strdup( cargv[1] );
2154 replogfile = ch_strdup( cargv[1] );
2157 /* file from which to read additional rootdse attrs */
2158 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2161 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2162 "missing filename in \"rootDSE <filename>\" line.\n",
2163 fname, lineno , 0 );
2165 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2166 "missing filename in \"rootDSE <filename>\" line.\n",
2172 if( read_root_dse_file( cargv[1] ) ) {
2174 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2175 "could not read \"rootDSE <filename>\" line.\n",
2176 fname, lineno , 0 );
2178 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2179 "could not read \"rootDSE <filename>\" line\n",
2185 /* maintain lastmodified{by,time} attributes */
2186 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2189 LDAP_LOG( CONFIG, CRIT,
2190 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2191 " line.\n", fname, lineno , 0 );
2193 Debug( LDAP_DEBUG_ANY,
2194 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2200 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2202 SLAP_DBFLAGS(be) &= ~SLAP_DBFLAG_NOLASTMOD;
2208 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD;
2215 /* turn on/off gentle SIGHUP handling */
2216 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2218 Debug( LDAP_DEBUG_ANY,
2219 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2223 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2224 global_gentlehup = 0;
2226 global_gentlehup = 1;
2230 /* set idle timeout value */
2231 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2235 LDAP_LOG( CONFIG, CRIT,
2236 "%s: line %d: missing timeout value in "
2237 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2239 Debug( LDAP_DEBUG_ANY,
2240 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2247 i = atoi( cargv[1] );
2251 LDAP_LOG( CONFIG, CRIT,
2252 "%s: line %d: timeout value (%d) invalid "
2253 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2255 Debug( LDAP_DEBUG_ANY,
2256 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2263 global_idletimeout = i;
2265 /* include another config file */
2266 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2269 LDAP_LOG( CONFIG, CRIT,
2270 "%s: line %d: missing filename in \"include "
2271 "<filename>\" line.\n", fname, lineno , 0 );
2273 Debug( LDAP_DEBUG_ANY,
2274 "%s: line %d: missing filename in \"include <filename>\" line\n",
2280 savefname = ch_strdup( cargv[1] );
2281 savelineno = lineno;
2283 if ( read_config( savefname, depth+1 ) != 0 ) {
2288 lineno = savelineno - 1;
2290 /* location of kerberos srvtab file */
2291 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2294 LDAP_LOG( CONFIG, CRIT,
2295 "%s: line %d: missing filename in \"srvtab "
2296 "<filename>\" line.\n", fname, lineno , 0 );
2298 Debug( LDAP_DEBUG_ANY,
2299 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2305 ldap_srvtab = ch_strdup( cargv[1] );
2307 #ifdef SLAPD_MODULES
2308 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2311 LDAP_LOG( CONFIG, INFO,
2312 "%s: line %d: missing filename in \"moduleload "
2313 "<filename>\" line.\n", fname, lineno , 0 );
2315 Debug( LDAP_DEBUG_ANY,
2316 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2320 exit( EXIT_FAILURE );
2322 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2324 LDAP_LOG( CONFIG, CRIT,
2325 "%s: line %d: failed to load or initialize module %s\n",
2326 fname, lineno, cargv[1] );
2328 Debug( LDAP_DEBUG_ANY,
2329 "%s: line %d: failed to load or initialize module %s\n",
2330 fname, lineno, cargv[1]);
2333 exit( EXIT_FAILURE );
2335 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2338 LDAP_LOG( CONFIG, INFO,
2339 "%s: line %d: missing path in \"modulepath <path>\""
2340 " line\n", fname, lineno , 0 );
2342 Debug( LDAP_DEBUG_ANY,
2343 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2347 exit( EXIT_FAILURE );
2349 if (module_path( cargv[1] )) {
2351 LDAP_LOG( CONFIG, CRIT,
2352 "%s: line %d: failed to set module search path to %s.\n",
2353 fname, lineno, cargv[1] );
2355 Debug( LDAP_DEBUG_ANY,
2356 "%s: line %d: failed to set module search path to %s\n",
2357 fname, lineno, cargv[1]);
2360 exit( EXIT_FAILURE );
2363 #endif /*SLAPD_MODULES*/
2366 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2367 rc = ldap_pvt_tls_set_option( NULL,
2368 LDAP_OPT_X_TLS_RANDOM_FILE,
2373 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2374 rc = ldap_pvt_tls_set_option( NULL,
2375 LDAP_OPT_X_TLS_CIPHER_SUITE,
2380 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2381 rc = ldap_pvt_tls_set_option( NULL,
2382 LDAP_OPT_X_TLS_CERTFILE,
2387 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2388 rc = ldap_pvt_tls_set_option( NULL,
2389 LDAP_OPT_X_TLS_KEYFILE,
2394 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2395 rc = ldap_pvt_tls_set_option( NULL,
2396 LDAP_OPT_X_TLS_CACERTDIR,
2401 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2402 rc = ldap_pvt_tls_set_option( NULL,
2403 LDAP_OPT_X_TLS_CACERTFILE,
2407 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2408 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2410 rc = ldap_pvt_tls_set_option( NULL,
2411 LDAP_OPT_X_TLS_REQUIRE_CERT,
2414 rc = ldap_int_tls_config( NULL,
2415 LDAP_OPT_X_TLS_REQUIRE_CERT,
2424 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2425 #ifdef SLAPD_RLOOKUPS
2428 LDAP_LOG( CONFIG, INFO,
2429 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2430 fname, lineno , 0 );
2432 Debug( LDAP_DEBUG_ANY,
2433 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2439 if ( !strcasecmp( cargv[1], "on" ) ) {
2440 use_reverse_lookup = 1;
2441 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2442 use_reverse_lookup = 0;
2445 LDAP_LOG( CONFIG, INFO,
2446 "%s: line %d: reverse-lookup: "
2447 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2449 Debug( LDAP_DEBUG_ANY,
2450 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2456 #else /* !SLAPD_RLOOKUPS */
2458 LDAP_LOG( CONFIG, INFO,
2459 "%s: line %d: reverse lookups "
2460 "are not configured (ignored).\n", fname, lineno , 0 );
2462 Debug( LDAP_DEBUG_ANY,
2463 "%s: line %d: reverse lookups are not configured (ignored).\n",
2466 #endif /* !SLAPD_RLOOKUPS */
2468 /* Netscape plugins */
2469 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2470 #if defined( LDAP_SLAPI )
2472 #ifdef notdef /* allow global plugins, too */
2474 * a "plugin" line must be inside a database
2475 * definition, since we implement pre-,post-
2476 * and extended operation plugins
2480 LDAP_LOG( CONFIG, INFO,
2481 "%s: line %d: plugin line must appear "
2482 "insid a database definition.\n",
2485 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2486 "line must appear inside a database "
2487 "definition\n", fname, lineno, 0 );
2493 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
2497 slapi_plugins_used++;
2499 #else /* !defined( LDAP_SLAPI ) */
2501 LDAP_LOG( CONFIG, INFO,
2502 "%s: line %d: SLAPI not supported.\n",
2505 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2506 "not supported.\n", fname, lineno, 0 );
2510 #endif /* !defined( LDAP_SLAPI ) */
2512 /* Netscape plugins */
2513 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2514 #if defined( LDAP_SLAPI )
2517 LDAP_LOG( CONFIG, INFO,
2518 "%s: line %d: missing file name "
2519 "in pluginlog <filename> line.\n",
2522 Debug( LDAP_DEBUG_ANY,
2523 "%s: line %d: missing file name "
2524 "in pluginlog <filename> line.\n",
2530 if ( slapi_log_file != NULL ) {
2531 ch_free( slapi_log_file );
2534 slapi_log_file = ch_strdup( cargv[1] );
2535 #endif /* !defined( LDAP_SLAPI ) */
2537 /* pass anything else to the current backend info/db config routine */
2540 if ( bi->bi_config ) {
2541 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
2547 case SLAP_CONF_UNKNOWN:
2549 LDAP_LOG( CONFIG, INFO,
2550 "%s: line %d: unknown directive \"%s\" inside "
2551 "backend info definition (ignored).\n",
2552 fname, lineno, cargv[0] );
2554 Debug( LDAP_DEBUG_ANY,
2555 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2556 fname, lineno, cargv[0] );
2565 } else if ( be != NULL ) {
2566 if ( be->be_config ) {
2567 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
2573 case SLAP_CONF_UNKNOWN:
2575 LDAP_LOG( CONFIG, INFO,
2576 "%s: line %d: unknown directive \"%s\" inside "
2577 "backend database definition (ignored).\n",
2578 fname, lineno, cargv[0] );
2580 Debug( LDAP_DEBUG_ANY,
2581 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2582 fname, lineno, cargv[0] );
2593 LDAP_LOG( CONFIG, INFO,
2594 "%s: line %d: unknown directive \"%s\" outside backend "
2595 "info and database definitions (ignored).\n",
2596 fname, lineno, cargv[0] );
2598 Debug( LDAP_DEBUG_ANY,
2599 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2600 fname, lineno, cargv[0] );
2609 if ( depth == 0 ) ch_free( cargv );
2611 if ( !global_schemadn.bv_val ) {
2612 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2614 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2617 if ( load_ucdata( NULL ) < 0 ) return 1;
2629 char logbuf[sizeof("pseudorootpw ***")];
2632 token = strtok_quote( line, " \t" );
2636 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2637 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2638 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2639 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2640 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2642 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2645 if ( strtok_quote_ptr ) {
2646 *strtok_quote_ptr = ' ';
2650 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2652 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2655 if ( strtok_quote_ptr ) {
2656 *strtok_quote_ptr = '\0';
2659 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2660 if ( cargc == cargv_size - 1 ) {
2662 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2664 if ( tmp == NULL ) {
2666 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2668 Debug( LDAP_DEBUG_ANY,
2669 "line %d: out of memory\n",
2675 cargv_size += ARGS_STEP;
2677 cargv[cargc++] = token;
2679 cargv[cargc] = NULL;
2684 strtok_quote( char *line, char *sep )
2690 strtok_quote_ptr = NULL;
2691 if ( line != NULL ) {
2694 while ( *next && strchr( sep, *next ) ) {
2698 if ( *next == '\0' ) {
2704 for ( inquote = 0; *next; ) {
2712 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2718 next + 1, strlen( next + 1 ) + 1 );
2719 next++; /* dont parse the escaped character */
2724 if ( strchr( sep, *next ) != NULL ) {
2725 strtok_quote_ptr = next;
2738 static char buf[BUFSIZ];
2740 static size_t lmax, lcur;
2742 #define CATLINE( buf ) \
2744 size_t len = strlen( buf ); \
2745 while ( lcur + len + 1 > lmax ) { \
2747 line = (char *) ch_realloc( line, lmax ); \
2749 strcpy( line + lcur, buf ); \
2754 fp_getline( FILE *fp, int *lineno )
2762 /* hack attack - keeps us from having to keep a stack of bufs... */
2763 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2768 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2769 /* trim off \r\n or \n */
2770 if ( (p = strchr( buf, '\n' )) != NULL ) {
2771 if( p > buf && p[-1] == '\r' ) --p;
2775 /* trim off trailing \ and append the next line */
2776 if ( line[ 0 ] != '\0'
2777 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2778 && p[ -1 ] != '\\' ) {
2783 if ( ! isspace( (unsigned char) buf[0] ) ) {
2787 /* change leading whitespace to a space */
2796 return( line[0] ? line : NULL );
2800 fp_getline_init( int *lineno )
2806 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2808 load_ucdata( char *path )
2810 static int loaded = 0;
2816 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2819 LDAP_LOG( CONFIG, CRIT,
2820 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2822 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2835 ucdata_unload( UCDATA_ALL );
2836 free( global_schemandn.bv_val );
2837 free( global_schemadn.bv_val );
2839 if ( slapd_args_file )
2840 free ( slapd_args_file );
2841 if ( slapd_pid_file )
2842 free ( slapd_pid_file );
2843 if ( default_passwd_hash )
2844 ldap_charray_free( default_passwd_hash );
2845 acl_destroy( global_acl, NULL );
2856 syncinfo_t *si_entry;
2858 int duplicated_replica_id = 0;
2860 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2864 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2866 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2871 si->si_tls = SYNCINFO_TLS_OFF;
2872 if ( be->be_rootndn.bv_val ) {
2873 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2875 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2876 si->si_schemachecking = 0;
2877 ber_str2bv( "(objectclass=*)", sizeof("(objectclass=*)")-1, 0,
2878 &si->si_filterstr );
2879 si->si_base.bv_val = NULL;
2880 si->si_scope = LDAP_SCOPE_SUBTREE;
2881 si->si_attrsonly = 0;
2882 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
2883 si->si_attrs[0] = NULL;
2884 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2885 si->si_interval = 86400;
2886 si->si_syncCookie.ctxcsn = NULL;
2887 si->si_syncCookie.octet_str = NULL;
2888 si->si_syncCookie.sid = -1;
2889 si->si_manageDSAit = 0;
2892 si->si_syncUUID_ndn.bv_val = NULL;
2893 si->si_syncUUID_ndn.bv_len = 0;
2895 si->si_presentlist = NULL;
2896 LDAP_LIST_INIT( &si->si_nonpresentlist );
2898 rc = parse_syncrepl_line( cargv, cargc, si );
2900 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2901 if ( si->si_rid == si_entry->si_rid ) {
2903 LDAP_LOG( CONFIG, ERR,
2904 "add_syncrepl: duplicated replica id\n", 0, 0,0 );
2906 Debug( LDAP_DEBUG_ANY,
2907 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
2909 duplicated_replica_id = 1;
2914 if ( rc < 0 || duplicated_replica_id ) {
2915 syncinfo_t *si_entry;
2916 /* Something bad happened - back out */
2918 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2920 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2923 /* If error, remove all syncinfo */
2924 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2925 if ( si_entry->si_updatedn.bv_val ) {
2926 ch_free( si->si_updatedn.bv_val );
2928 if ( si_entry->si_filterstr.bv_val ) {
2929 ch_free( si->si_filterstr.bv_val );
2931 if ( si_entry->si_attrs ) {
2933 while ( si_entry->si_attrs[i] != NULL ) {
2934 ch_free( si_entry->si_attrs[i] );
2937 ch_free( si_entry->si_attrs );
2941 while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
2942 si_entry = LDAP_STAILQ_FIRST( &be->be_syncinfo );
2943 LDAP_STAILQ_REMOVE_HEAD( &be->be_syncinfo, si_next );
2944 ch_free( si_entry );
2946 LDAP_STAILQ_INIT( &be->be_syncinfo );
2950 LDAP_LOG ( CONFIG, RESULTS,
2951 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
2952 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2954 Debug( LDAP_DEBUG_CONFIG,
2955 "Config: ** successfully added syncrepl \"%s\"\n",
2956 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2958 if ( !si->si_schemachecking ) {
2959 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2962 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
2968 #define PROVIDERSTR "provider"
2969 #define SUFFIXSTR "suffix"
2970 #define UPDATEDNSTR "updatedn"
2971 #define BINDMETHSTR "bindmethod"
2972 #define SIMPLESTR "simple"
2973 #define SASLSTR "sasl"
2974 #define BINDDNSTR "binddn"
2975 #define CREDSTR "credentials"
2976 #define OLDAUTHCSTR "bindprincipal"
2977 #define AUTHCSTR "authcID"
2978 #define AUTHZSTR "authzID"
2979 #define SRVTABSTR "srvtab"
2980 #define SASLMECHSTR "saslmech"
2981 #define REALMSTR "realm"
2982 #define SECPROPSSTR "secprops"
2983 #define STARTTLSSTR "starttls"
2984 #define CRITICALSTR "critical"
2986 #define SCHEMASTR "schemachecking"
2987 #define FILTERSTR "filter"
2988 #define SEARCHBASESTR "searchbase"
2989 #define SCOPESTR "scope"
2990 #define ATTRSSTR "attrs"
2991 #define ATTRSONLYSTR "attrsonly"
2992 #define TYPESTR "type"
2993 #define INTERVALSTR "interval"
2994 #define LASTMODSTR "lastmod"
2995 #define LMREQSTR "req"
2996 #define LMGENSTR "gen"
2997 #define LMNOSTR "no"
2998 #define MANAGEDSAITSTR "manageDSAit"
2999 #define SLIMITSTR "sizelimit"
3000 #define TLIMITSTR "timelimit"
3002 #define GOT_ID 0x0001
3003 #define GOT_PROVIDER 0x0002
3004 #define GOT_METHOD 0x0004
3005 #define GOT_ALL 0x0007
3008 parse_syncrepl_line(
3019 for ( i = 1; i < cargc; i++ ) {
3020 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
3022 /* '\0' string terminator accounts for '=' */
3023 val = cargv[ i ] + sizeof( IDSTR );
3025 if ( tmp >= 1000 || tmp < 0 ) {
3026 fprintf( stderr, "Error: parse_syncrepl_line: "
3027 "syncrepl id %d is out of range [0..999]\n", tmp );
3032 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
3033 sizeof( PROVIDERSTR ) - 1 )) {
3034 val = cargv[ i ] + sizeof( PROVIDERSTR );
3035 si->si_provideruri = ch_strdup( val );
3036 si->si_provideruri_bv = (BerVarray)
3037 ch_calloc( 2, sizeof( struct berval ));
3038 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
3039 0, &si->si_provideruri_bv[0] );
3040 si->si_provideruri_bv[1].bv_len = 0;
3041 si->si_provideruri_bv[1].bv_val = NULL;
3042 gots |= GOT_PROVIDER;
3043 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
3044 sizeof(STARTTLSSTR) - 1 ) )
3046 val = cargv[ i ] + sizeof( STARTTLSSTR );
3047 if( !strcasecmp( val, CRITICALSTR ) ) {
3048 si->si_tls = SYNCINFO_TLS_CRITICAL;
3050 si->si_tls = SYNCINFO_TLS_ON;
3052 } else if ( !strncasecmp( cargv[ i ],
3053 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
3055 struct berval updatedn = {0, NULL};
3056 val = cargv[ i ] + sizeof( UPDATEDNSTR );
3057 ber_str2bv( val, 0, 0, &updatedn );
3058 ch_free( si->si_updatedn.bv_val );
3059 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
3060 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
3061 sizeof( BINDMETHSTR ) - 1 ) )
3063 val = cargv[ i ] + sizeof( BINDMETHSTR );
3064 if ( !strcasecmp( val, SIMPLESTR )) {
3065 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3067 } else if ( !strcasecmp( val, SASLSTR )) {
3068 #ifdef HAVE_CYRUS_SASL
3069 si->si_bindmethod = LDAP_AUTH_SASL;
3071 #else /* HAVE_CYRUS_SASL */
3072 fprintf( stderr, "Error: parse_syncrepl_line: "
3073 "not compiled with SASL support\n" );
3075 #endif /* HAVE_CYRUS_SASL */
3077 si->si_bindmethod = -1;
3079 } else if ( !strncasecmp( cargv[ i ],
3080 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
3081 val = cargv[ i ] + sizeof( BINDDNSTR );
3082 si->si_binddn = ch_strdup( val );
3083 } else if ( !strncasecmp( cargv[ i ],
3084 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
3085 val = cargv[ i ] + sizeof( CREDSTR );
3086 si->si_passwd = ch_strdup( val );
3087 } else if ( !strncasecmp( cargv[ i ],
3088 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
3089 val = cargv[ i ] + sizeof( SASLMECHSTR );
3090 si->si_saslmech = ch_strdup( val );
3091 } else if ( !strncasecmp( cargv[ i ],
3092 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
3093 val = cargv[ i ] + sizeof( SECPROPSSTR );
3094 si->si_secprops = ch_strdup( val );
3095 } else if ( !strncasecmp( cargv[ i ],
3096 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
3097 val = cargv[ i ] + sizeof( REALMSTR );
3098 si->si_realm = ch_strdup( val );
3099 } else if ( !strncasecmp( cargv[ i ],
3100 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
3101 val = cargv[ i ] + sizeof( AUTHCSTR );
3102 si->si_authcId = ch_strdup( val );
3103 } else if ( !strncasecmp( cargv[ i ],
3104 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
3105 /* Old authcID is provided for some backwards compatibility */
3106 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
3107 si->si_authcId = ch_strdup( val );
3108 } else if ( !strncasecmp( cargv[ i ],
3109 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
3110 val = cargv[ i ] + sizeof( AUTHZSTR );
3111 si->si_authzId = ch_strdup( val );
3112 } else if ( !strncasecmp( cargv[ i ],
3113 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
3115 val = cargv[ i ] + sizeof( SCHEMASTR );
3116 if ( !strncasecmp( val, "on", sizeof( "on" ) - 1 )) {
3117 si->si_schemachecking = 1;
3118 } else if ( !strncasecmp( val, "off", sizeof( "off" ) - 1 ) ) {
3119 si->si_schemachecking = 0;
3121 si->si_schemachecking = 1;
3123 } else if ( !strncasecmp( cargv[ i ],
3124 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
3126 val = cargv[ i ] + sizeof( FILTERSTR );
3127 ber_str2bv( val, 0, 1, &si->si_filterstr );
3128 } else if ( !strncasecmp( cargv[ i ],
3129 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3132 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3133 if ( si->si_base.bv_val ) {
3134 ch_free( si->si_base.bv_val );
3136 ber_str2bv( val, 0, 0, &bv );
3137 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3138 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3141 } else if ( !strncasecmp( cargv[ i ],
3142 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3144 val = cargv[ i ] + sizeof( SCOPESTR );
3145 if ( !strncasecmp( val, "base", sizeof( "base" ) - 1 )) {
3146 si->si_scope = LDAP_SCOPE_BASE;
3147 } else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
3148 si->si_scope = LDAP_SCOPE_ONELEVEL;
3149 #ifdef LDAP_SCOPE_SUBORDINATE
3150 } else if ( !strcasecmp( val, "subordinate" ) ||
3151 !strcasecmp( val, "children" ))
3153 si->si_scope = LDAP_SCOPE_SUBORDINATE;
3155 } else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
3156 si->si_scope = LDAP_SCOPE_SUBTREE;
3158 fprintf( stderr, "Error: parse_syncrepl_line: "
3159 "unknown scope \"%s\"\n", val);
3162 } else if ( !strncasecmp( cargv[ i ],
3163 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3165 si->si_attrsonly = 1;
3166 } else if ( !strncasecmp( cargv[ i ],
3167 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3169 val = cargv[ i ] + sizeof( ATTRSSTR );
3170 str2clist( &si->si_attrs, val, "," );
3171 } else if ( !strncasecmp( cargv[ i ],
3172 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3174 val = cargv[ i ] + sizeof( TYPESTR );
3175 if ( !strncasecmp( val, "refreshOnly", sizeof("refreshOnly")-1 )) {
3176 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3177 } else if ( !strncasecmp( val, "refreshAndPersist",
3178 sizeof("refreshAndPersist")-1 ))
3180 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3181 si->si_interval = 60;
3183 fprintf( stderr, "Error: parse_syncrepl_line: "
3184 "unknown sync type \"%s\"\n", val);
3187 } else if ( !strncasecmp( cargv[ i ],
3188 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3190 val = cargv[ i ] + sizeof( INTERVALSTR );
3191 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
3192 si->si_interval = 0;
3200 hstr = strchr( dstr, ':' );
3201 if ( hstr == NULL ) {
3202 fprintf( stderr, "Error: parse_syncrepl_line: "
3203 "invalid interval \"%s\"\n", val );
3207 mstr = strchr( hstr, ':' );
3208 if ( mstr == NULL ) {
3209 fprintf( stderr, "Error: parse_syncrepl_line: "
3210 "invalid interval \"%s\"\n", val );
3214 sstr = strchr( mstr, ':' );
3215 if ( sstr == NULL ) {
3216 fprintf( stderr, "Error: parse_syncrepl_line: "
3217 "invalid interval \"%s\"\n", val );
3226 if (( hh > 24 ) || ( hh < 0 ) ||
3227 ( mm > 60 ) || ( mm < 0 ) ||
3228 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3229 fprintf( stderr, "Error: parse_syncrepl_line: "
3230 "invalid interval \"%s\"\n", val );
3233 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3235 if ( si->si_interval < 0 ) {
3236 fprintf( stderr, "Error: parse_syncrepl_line: "
3237 "invalid interval \"%ld\"\n",
3238 (long) si->si_interval);
3241 } else if ( !strncasecmp( cargv[ i ],
3242 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3244 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3245 si->si_manageDSAit = atoi( val );
3246 } else if ( !strncasecmp( cargv[ i ],
3247 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3249 val = cargv[ i ] + sizeof( SLIMITSTR );
3250 si->si_slimit = atoi( val );
3251 } else if ( !strncasecmp( cargv[ i ],
3252 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3254 val = cargv[ i ] + sizeof( TLIMITSTR );
3255 si->si_tlimit = atoi( val );
3257 fprintf( stderr, "Error: parse_syncrepl_line: "
3258 "unknown keyword \"%s\"\n", cargv[ i ] );
3262 if ( gots != GOT_ALL ) {
3264 "Error: Malformed \"syncrepl\" line in slapd config file" );
3272 str2clist( char ***out, char *in, const char *brkstr )
3281 /* find last element in list */
3282 for (i = 0; *out && *out[i]; i++);
3284 /* protect the input string from strtok */
3285 str = ch_strdup( in );
3287 if ( *str == '\0' ) {
3292 /* Count words in string */
3294 for ( s = str; *s; s++ ) {
3295 if ( strchr( brkstr, *s ) != NULL ) {
3300 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3302 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3304 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3306 *new = ch_strdup( s );