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 #ifdef SLAP_SASL_REWRITE
687 /* use authid rewrite instead of sasl regexp */
688 } else if ( strncasecmp( cargv[0], "auth-rewrite",
689 STRLENOF("auth-rewrite") ) == 0 )
691 int rc = slap_sasl_rewrite_config( fname, lineno,
696 #endif /* SLAP_SASL_REWRITE */
698 /* Auth + SASL config options */
699 } else if ( !strncasecmp( cargv[0], "auth", STRLENOF("auth") ) ||
700 !strncasecmp( cargv[0], "sasl", STRLENOF("sasl") ))
702 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
706 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
710 LDAP_LOG( CONFIG, CRIT,
711 "%s: line %d: missing dn in "
712 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
714 Debug( LDAP_DEBUG_ANY,
715 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
720 ber_str2bv( cargv[1], 0, 0, &dn );
722 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
723 &be->be_schemandn, NULL );
725 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
726 &global_schemandn, NULL );
728 if ( rc != LDAP_SUCCESS ) {
730 LDAP_LOG( CONFIG, CRIT,
731 "%s: line %d: schemadn DN is invalid.\n",
734 Debug( LDAP_DEBUG_ANY,
735 "%s: line %d: schemadn DN is invalid\n",
741 /* set UCDATA path */
742 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
746 LDAP_LOG( CONFIG, CRIT,
747 "%s: line %d: missing path in "
748 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
750 Debug( LDAP_DEBUG_ANY,
751 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
758 err = load_ucdata( cargv[1] );
762 LDAP_LOG( CONFIG, CRIT,
763 "%s: line %d: ucdata already loaded, ucdata-path "
764 "must be set earlier in the file and/or be "
765 "specified only once!\n", fname, lineno, 0 );
767 Debug( LDAP_DEBUG_ANY,
768 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
777 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
779 struct slap_limits_set *lim;
783 LDAP_LOG( CONFIG, CRIT,
784 "%s: line %d: missing limit in \"sizelimit <limit>\" "
785 "line.\n", fname, lineno, 0 );
787 Debug( LDAP_DEBUG_ANY,
788 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
798 lim = &be->be_def_limit;
801 for ( i = 1; i < cargc; i++ ) {
802 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
803 rc = limits_parse_one( cargv[i], lim );
806 LDAP_LOG( CONFIG, CRIT,
807 "%s: line %d: unable "
808 "to parse value \"%s\" in \"sizelimit "
809 "<limit>\" line.\n", fname, lineno, cargv[i] );
811 Debug( LDAP_DEBUG_ANY,
812 "%s: line %d: unable "
813 "to parse value \"%s\" "
816 fname, lineno, cargv[i] );
822 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
823 lim->lms_s_soft = -1;
827 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
828 if ( next == cargv[i] ) {
830 LDAP_LOG( CONFIG, CRIT,
831 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
832 "line.\n", fname, lineno, cargv[i] );
834 Debug( LDAP_DEBUG_ANY,
835 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
836 fname, lineno, cargv[i] );
840 } else if ( next[0] != '\0' ) {
842 LDAP_LOG( CONFIG, CRIT,
843 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
844 "line ignored.\n", fname, lineno, next );
846 Debug( LDAP_DEBUG_ANY,
847 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
848 fname, lineno, next );
857 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
859 struct slap_limits_set *lim;
863 LDAP_LOG( CONFIG, CRIT,
864 "%s: line %d missing limit in \"timelimit <limit>\" "
865 "line.\n", fname, lineno, 0 );
867 Debug( LDAP_DEBUG_ANY,
868 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
878 lim = &be->be_def_limit;
881 for ( i = 1; i < cargc; i++ ) {
882 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
883 rc = limits_parse_one( cargv[i], lim );
886 LDAP_LOG( CONFIG, CRIT,
887 "%s: line %d: unable to parse value \"%s\" "
888 "in \"timelimit <limit>\" line.\n",
889 fname, lineno, cargv[i] );
891 Debug( LDAP_DEBUG_ANY,
892 "%s: line %d: unable "
893 "to parse value \"%s\" "
896 fname, lineno, cargv[i] );
902 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
903 lim->lms_t_soft = -1;
907 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
908 if ( next == cargv[i] ) {
910 LDAP_LOG( CONFIG, CRIT,
911 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
912 "line.\n", fname, lineno, cargv[i] );
914 Debug( LDAP_DEBUG_ANY,
915 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
916 fname, lineno, cargv[i] );
920 } else if ( next[0] != '\0' ) {
922 LDAP_LOG( CONFIG, CRIT,
923 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
924 "line ignored.\n", fname, lineno, next );
926 Debug( LDAP_DEBUG_ANY,
927 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
928 fname, lineno, next );
936 /* set regex-based limits */
937 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
940 LDAP_LOG( CONFIG, WARNING,
941 "%s: line %d \"limits\" allowed only in database "
942 "environment.\n", fname, lineno, 0 );
944 Debug( LDAP_DEBUG_ANY,
945 "%s: line %d \"limits\" allowed only in database environment.\n%s",
951 if ( limits_parse( be, fname, lineno, cargc, cargv ) ) {
955 /* mark this as a subordinate database */
956 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
959 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
960 "subordinate keyword must appear inside a database "
961 "definition.\n", fname, lineno, 0 );
963 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
964 "must appear inside a database definition.\n",
970 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
974 /* add an overlay to this backend */
975 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
978 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
979 "overlay keyword must appear inside a database "
980 "definition.\n", fname, lineno, 0 );
982 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
983 "must appear inside a database definition.\n",
989 if ( cargv[1][0] == '-' && overlay_config( be, &cargv[1][1] ) ) {
992 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
993 "(optional) overlay \"%s\" configuration "
994 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
996 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
997 "(optional) overlay \"%s\" configuration "
998 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
1000 } else if ( overlay_config( be, cargv[1] ) ) {
1005 /* set database suffix */
1006 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
1008 struct berval dn, pdn, ndn;
1012 LDAP_LOG( CONFIG, CRIT,
1013 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
1016 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1017 "missing dn in \"suffix <dn>\" line\n",
1023 } else if ( cargc > 2 ) {
1025 LDAP_LOG( CONFIG, INFO,
1026 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
1027 " line (ignored).\n", fname, lineno, cargv[1] );
1029 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
1030 "after <dn> in \"suffix %s\" line (ignored)\n",
1031 fname, lineno, cargv[1] );
1037 LDAP_LOG( CONFIG, INFO,
1038 "%s: line %d: suffix line must appear inside a database "
1039 "definition.\n", fname, lineno, 0 );
1041 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
1042 "must appear inside a database definition\n",
1047 #if defined(SLAPD_MONITOR_DN)
1048 /* "cn=Monitor" is reserved for monitoring slap */
1049 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
1051 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
1052 "%s\" is reserved for monitoring slapd\n",
1053 fname, lineno, SLAPD_MONITOR_DN );
1055 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
1056 "%s\" is reserved for monitoring slapd\n",
1057 fname, lineno, SLAPD_MONITOR_DN );
1060 #endif /* SLAPD_MONITOR_DN */
1063 if ( load_ucdata( NULL ) < 0 ) return 1;
1065 dn.bv_val = cargv[1];
1066 dn.bv_len = strlen( cargv[1] );
1068 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1069 if( rc != LDAP_SUCCESS ) {
1071 LDAP_LOG( CONFIG, CRIT,
1072 "%s: line %d: suffix DN is invalid.\n",
1075 Debug( LDAP_DEBUG_ANY,
1076 "%s: line %d: suffix DN is invalid\n",
1082 tmp_be = select_backend( &ndn, 0, 0 );
1083 if ( tmp_be == be ) {
1085 LDAP_LOG( CONFIG, INFO,
1086 "%s: line %d: suffix already served by this backend "
1087 "(ignored)\n", fname, lineno, 0 );
1089 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1090 "already served by this backend (ignored)\n",
1096 } else if ( tmp_be != NULL ) {
1098 LDAP_LOG( CONFIG, INFO,
1099 "%s: line %d: suffix already served by a preceding "
1100 "backend \"%s\"\n", fname, lineno,
1101 tmp_be->be_suffix[0].bv_val );
1103 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1104 "already served by a preceeding backend \"%s\"\n",
1105 fname, lineno, tmp_be->be_suffix[0].bv_val );
1111 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1113 LDAP_LOG( CONFIG, INFO,
1114 "%s: line %d: suffix DN empty and default search "
1115 "base provided \"%s\" (assuming okay).\n",
1116 fname, lineno, default_search_base.bv_val );
1118 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1119 "suffix DN empty and default "
1120 "search base provided \"%s\" (assuming okay)\n",
1121 fname, lineno, default_search_base.bv_val );
1125 ber_bvarray_add( &be->be_suffix, &pdn );
1126 ber_bvarray_add( &be->be_nsuffix, &ndn );
1128 /* set max deref depth */
1129 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1133 LDAP_LOG( CONFIG, CRIT,
1134 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1135 " line\n", fname, lineno, 0 );
1137 Debug( LDAP_DEBUG_ANY,
1138 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1146 LDAP_LOG( CONFIG, INFO,
1147 "%s: line %d: depth line must appear inside a database "
1148 "definition.\n", fname, lineno ,0 );
1150 Debug( LDAP_DEBUG_ANY,
1151 "%s: line %d: depth line must appear inside a database definition.\n",
1156 } else if ((i = atoi(cargv[1])) < 0) {
1158 LDAP_LOG( CONFIG, INFO,
1159 "%s: line %d: depth must be positive.\n",
1162 Debug( LDAP_DEBUG_ANY,
1163 "%s: line %d: depth must be positive.\n",
1170 be->be_max_deref_depth = i;
1174 /* set magic "root" dn for this database */
1175 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1178 LDAP_LOG( CONFIG, INFO,
1179 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1182 Debug( LDAP_DEBUG_ANY,
1183 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1192 LDAP_LOG( CONFIG, INFO,
1193 "%s: line %d: rootdn line must appear inside a database "
1194 "definition.\n", fname, lineno ,0 );
1196 Debug( LDAP_DEBUG_ANY,
1197 "%s: line %d: rootdn line must appear inside a database definition.\n",
1205 if ( load_ucdata( NULL ) < 0 ) return 1;
1207 dn.bv_val = cargv[1];
1208 dn.bv_len = strlen( cargv[1] );
1210 rc = dnPrettyNormal( NULL, &dn,
1212 &be->be_rootndn, NULL );
1214 if( rc != LDAP_SUCCESS ) {
1216 LDAP_LOG( CONFIG, CRIT,
1217 "%s: line %d: rootdn DN is invalid.\n",
1220 Debug( LDAP_DEBUG_ANY,
1221 "%s: line %d: rootdn DN is invalid\n",
1228 /* set super-secret magic database password */
1229 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1232 LDAP_LOG( CONFIG, CRIT,
1233 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1234 " line\n", fname, lineno ,0 );
1236 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1237 "missing passwd in \"rootpw <passwd>\" line\n",
1246 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1247 "rootpw line must appear inside a database "
1248 "definition.\n", fname, lineno ,0 );
1250 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1251 "rootpw line must appear inside a database "
1258 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1260 if( tmp_be != be ) {
1262 LDAP_LOG( CONFIG, INFO,
1264 "rootpw can only be set when rootdn is under suffix\n",
1265 fname, lineno, "" );
1267 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1268 "rootpw can only be set when rootdn is under suffix\n",
1274 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1275 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1278 /* make this database read-only */
1279 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1282 LDAP_LOG( CONFIG, CRIT,
1283 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1284 "line.\n", fname, lineno ,0 );
1286 Debug( LDAP_DEBUG_ANY,
1287 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1294 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1295 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1297 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1300 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1301 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1303 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1308 /* allow these features */
1309 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1310 strcasecmp( cargv[0], "allow" ) == 0 )
1316 LDAP_LOG( CONFIG, INFO,
1317 "%s: line %d: allow line must appear prior to "
1318 "database definitions.\n", fname, lineno ,0 );
1320 Debug( LDAP_DEBUG_ANY,
1321 "%s: line %d: allow line must appear prior to database definitions\n",
1329 LDAP_LOG( CONFIG, CRIT,
1330 "%s: line %d: missing feature(s) in \"allow <features>\""
1331 " line\n", fname, lineno ,0 );
1333 Debug( LDAP_DEBUG_ANY,
1334 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1343 for( i=1; i < cargc; i++ ) {
1344 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1345 allows |= SLAP_ALLOW_BIND_V2;
1347 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1348 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1350 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1351 allows |= SLAP_ALLOW_BIND_ANON_DN;
1353 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1354 allows |= SLAP_ALLOW_UPDATE_ANON;
1356 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1358 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1359 "unknown feature %s in \"allow <features>\" line.\n",
1360 fname, lineno, cargv[1] );
1362 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1363 "unknown feature %s in \"allow <features>\" line\n",
1364 fname, lineno, cargv[i] );
1371 global_allows = allows;
1373 /* disallow these features */
1374 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1375 strcasecmp( cargv[0], "disallow" ) == 0 )
1377 slap_mask_t disallows;
1381 LDAP_LOG( CONFIG, INFO,
1382 "%s: line %d: disallow line must appear prior to "
1383 "database definitions.\n", fname, lineno ,0 );
1385 Debug( LDAP_DEBUG_ANY,
1386 "%s: line %d: disallow line must appear prior to database definitions\n",
1394 LDAP_LOG( CONFIG, CRIT,
1395 "%s: line %d: missing feature(s) in \"disallow <features>\""
1396 " line.\n", fname, lineno ,0 );
1398 Debug( LDAP_DEBUG_ANY,
1399 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1408 for( i=1; i < cargc; i++ ) {
1409 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1410 disallows |= SLAP_DISALLOW_BIND_ANON;
1412 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1413 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1415 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1416 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1418 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1419 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1421 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1422 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1424 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1426 LDAP_LOG( CONFIG, CRIT,
1427 "%s: line %d: unknown feature %s in "
1428 "\"disallow <features>\" line.\n",
1429 fname, lineno, cargv[i] );
1431 Debug( LDAP_DEBUG_ANY,
1432 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1433 fname, lineno, cargv[i] );
1440 global_disallows = disallows;
1442 /* require these features */
1443 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1444 strcasecmp( cargv[0], "require" ) == 0 )
1446 slap_mask_t requires;
1450 LDAP_LOG( CONFIG, CRIT,
1451 "%s: line %d: missing feature(s) in "
1452 "\"require <features>\" line.\n", fname, lineno ,0 );
1454 Debug( LDAP_DEBUG_ANY,
1455 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1464 for( i=1; i < cargc; i++ ) {
1465 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1466 requires |= SLAP_REQUIRE_BIND;
1468 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1469 requires |= SLAP_REQUIRE_LDAP_V3;
1471 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1472 requires |= SLAP_REQUIRE_AUTHC;
1474 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1475 requires |= SLAP_REQUIRE_SASL;
1477 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1478 requires |= SLAP_REQUIRE_STRONG;
1480 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1482 LDAP_LOG( CONFIG, CRIT,
1483 "%s: line %d: unknown feature %s in "
1484 "\"require <features>\" line.\n",
1485 fname, lineno , cargv[i] );
1487 Debug( LDAP_DEBUG_ANY,
1488 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1489 fname, lineno, cargv[i] );
1497 global_requires = requires;
1499 be->be_requires = requires;
1502 /* required security factors */
1503 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1504 slap_ssf_set_t *set;
1508 LDAP_LOG( CONFIG, CRIT,
1509 "%s: line %d: missing factor(s) in \"security <factors>\""
1510 " line.\n", fname, lineno ,0 );
1512 Debug( LDAP_DEBUG_ANY,
1513 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1521 set = &global_ssf_set;
1523 set = &be->be_ssf_set;
1526 for( i=1; i < cargc; i++ ) {
1527 if( strncasecmp( cargv[i], "ssf=",
1528 sizeof("ssf") ) == 0 )
1531 atoi( &cargv[i][sizeof("ssf")] );
1533 } else if( strncasecmp( cargv[i], "transport=",
1534 sizeof("transport") ) == 0 )
1536 set->sss_transport =
1537 atoi( &cargv[i][sizeof("transport")] );
1539 } else if( strncasecmp( cargv[i], "tls=",
1540 sizeof("tls") ) == 0 )
1543 atoi( &cargv[i][sizeof("tls")] );
1545 } else if( strncasecmp( cargv[i], "sasl=",
1546 sizeof("sasl") ) == 0 )
1549 atoi( &cargv[i][sizeof("sasl")] );
1551 } else if( strncasecmp( cargv[i], "update_ssf=",
1552 sizeof("update_ssf") ) == 0 )
1554 set->sss_update_ssf =
1555 atoi( &cargv[i][sizeof("update_ssf")] );
1557 } else if( strncasecmp( cargv[i], "update_transport=",
1558 sizeof("update_transport") ) == 0 )
1560 set->sss_update_transport =
1561 atoi( &cargv[i][sizeof("update_transport")] );
1563 } else if( strncasecmp( cargv[i], "update_tls=",
1564 sizeof("update_tls") ) == 0 )
1566 set->sss_update_tls =
1567 atoi( &cargv[i][sizeof("update_tls")] );
1569 } else if( strncasecmp( cargv[i], "update_sasl=",
1570 sizeof("update_sasl") ) == 0 )
1572 set->sss_update_sasl =
1573 atoi( &cargv[i][sizeof("update_sasl")] );
1575 } else if( strncasecmp( cargv[i], "simple_bind=",
1576 sizeof("simple_bind") ) == 0 )
1578 set->sss_simple_bind =
1579 atoi( &cargv[i][sizeof("simple_bind")] );
1583 LDAP_LOG( CONFIG, CRIT,
1584 "%s: line %d: unknown factor %S in "
1585 "\"security <factors>\" line.\n",
1586 fname, lineno, cargv[1] );
1588 Debug( LDAP_DEBUG_ANY,
1589 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1590 fname, lineno, cargv[i] );
1596 /* where to send clients when we don't hold it */
1597 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1600 LDAP_LOG( CONFIG, CRIT,
1601 "%s: line %d: missing URL in \"referral <URL>\""
1602 " line.\n", fname, lineno , 0 );
1604 Debug( LDAP_DEBUG_ANY,
1605 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1612 if( validate_global_referral( cargv[1] ) ) {
1614 LDAP_LOG( CONFIG, CRIT,
1615 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1616 fname, lineno, cargv[1] );
1618 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1619 "invalid URL (%s) in \"referral\" line.\n",
1620 fname, lineno, cargv[1] );
1625 vals[0].bv_val = cargv[1];
1626 vals[0].bv_len = strlen( vals[0].bv_val );
1627 if( value_add( &default_referral, vals ) )
1631 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1635 LDAP_LOG( CONFIG, CRIT,
1636 "%s: line %d: Error in logfile directive, "
1637 "\"logfile <filename>\"\n", fname, lineno , 0 );
1639 Debug( LDAP_DEBUG_ANY,
1640 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1646 logfile = fopen( cargv[1], "w" );
1647 if ( logfile != NULL ) lutil_debug_file( logfile );
1650 /* start of a new database definition */
1651 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1655 LDAP_LOG( CONFIG, CRIT,
1656 "%s: line %d: Error in debug directive, "
1657 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1659 Debug( LDAP_DEBUG_ANY,
1660 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1666 level = atoi( cargv[2] );
1667 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1668 lutil_set_debug_level( cargv[1], level );
1669 /* specify an Object Identifier macro */
1670 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1671 rc = parse_oidm( fname, lineno, cargc, cargv );
1674 /* specify an objectclass */
1675 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1678 LDAP_LOG( CONFIG, INFO,
1679 "%s: line %d: illegal objectclass format.\n",
1680 fname, lineno , 0 );
1682 Debug( LDAP_DEBUG_ANY,
1683 "%s: line %d: illegal objectclass format.\n",
1688 } else if ( *cargv[1] == '(' /*')'*/) {
1690 p = strchr(saveline,'(' /*')'*/);
1691 rc = parse_oc( fname, lineno, p, cargv );
1696 LDAP_LOG( CONFIG, INFO,
1697 "%s: line %d: old objectclass format not supported\n",
1698 fname, lineno , 0 );
1700 Debug( LDAP_DEBUG_ANY,
1701 "%s: line %d: old objectclass format not supported.\n",
1706 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1708 p = strchr(saveline,'(' /*')'*/);
1709 rc = parse_cr( fname, lineno, p, cargv );
1712 /* specify an attribute type */
1713 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1714 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1718 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1719 "illegal attribute type format.\n",
1720 fname, lineno , 0 );
1722 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1723 "illegal attribute type format.\n",
1728 } else if ( *cargv[1] == '(' /*')'*/) {
1730 p = strchr(saveline,'(' /*')'*/);
1731 rc = parse_at( fname, lineno, p, cargv );
1736 LDAP_LOG( CONFIG, INFO,
1737 "%s: line %d: old attribute type format not supported.\n",
1738 fname, lineno , 0 );
1740 Debug( LDAP_DEBUG_ANY,
1741 "%s: line %d: old attribute type format not supported.\n",
1747 /* define attribute option(s) */
1748 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1749 ad_define_option( NULL, NULL, 0 );
1750 for ( i = 1; i < cargc; i++ )
1751 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1754 /* turn on/off schema checking */
1755 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1758 LDAP_LOG( CONFIG, CRIT,
1759 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1760 " line.\n", fname, lineno , 0 );
1762 Debug( LDAP_DEBUG_ANY,
1763 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1769 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1771 LDAP_LOG( CONFIG, CRIT,
1772 "%s: line %d: schema checking disabled! your mileage may "
1773 "vary!\n", fname, lineno , 0 );
1775 Debug( LDAP_DEBUG_ANY,
1776 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1779 global_schemacheck = 0;
1781 global_schemacheck = 1;
1784 /* specify access control info */
1785 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1786 parse_acl( be, fname, lineno, cargc, cargv );
1788 /* debug level to log things to syslog */
1789 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1792 LDAP_LOG( CONFIG, CRIT,
1793 "%s: line %d: missing level in \"loglevel <level>\""
1794 " line.\n", fname, lineno , 0 );
1796 Debug( LDAP_DEBUG_ANY,
1797 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1806 for( i=1; i < cargc; i++ ) {
1807 ldap_syslog += atoi( cargv[1] );
1810 /* list of sync replication information in this backend (slave only) */
1811 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1815 LDAP_LOG( CONFIG, INFO,
1816 "%s: line %d: syncrepl line must appear inside "
1817 "a database definition.\n", fname, lineno, 0);
1819 Debug( LDAP_DEBUG_ANY,
1820 "%s: line %d: syncrepl line must appear inside "
1821 "a database definition.\n", fname, lineno, 0);
1825 } else if ( SLAP_SHADOW( be )) {
1827 LDAP_LOG( CONFIG, INFO,
1828 "%s: line %d: syncrepl: database already shadowed.\n",
1831 Debug( LDAP_DEBUG_ANY,
1832 "%s: line %d: syncrepl: database already shadowed.\n",
1837 } else if ( add_syncrepl( be, cargv, cargc )) {
1841 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW );
1843 /* list of replicas of the data in this backend (master only) */
1844 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1847 LDAP_LOG( CONFIG, CRIT,
1848 "%s: line %d: missing host or uri in \"replica "
1849 " <host[:port]\" line\n", fname, lineno , 0 );
1851 Debug( LDAP_DEBUG_ANY,
1852 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1860 LDAP_LOG( CONFIG, INFO,
1861 "%s: line %d: replica line must appear inside "
1862 "a database definition.\n", fname, lineno, 0);
1864 Debug( LDAP_DEBUG_ANY,
1865 "%s: line %d: replica line must appear inside a database definition\n",
1873 for ( i = 1; i < cargc; i++ ) {
1874 if ( strncasecmp( cargv[i], "host=", 5 )
1876 nr = add_replica_info( be,
1879 } else if (strncasecmp( cargv[i], "uri=", 4 )
1881 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1884 LDAP_LOG( CONFIG, INFO,
1885 "%s: line %d: replica line contains invalid "
1886 "uri definition.\n", fname, lineno, 0);
1888 Debug( LDAP_DEBUG_ANY,
1889 "%s: line %d: replica line contains invalid "
1890 "uri definition.\n", fname, lineno, 0);
1894 if (ludp->lud_host == NULL ) {
1896 LDAP_LOG( CONFIG, INFO,
1897 "%s: line %d: replica line contains invalid "
1898 "uri definition - missing hostname.\n",
1901 Debug( LDAP_DEBUG_ANY,
1902 "%s: line %d: replica line contains invalid "
1903 "uri definition - missing hostname.\n", fname, lineno, 0);
1907 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1908 if ( replicahost == NULL ) {
1910 LDAP_LOG( CONFIG, ERR,
1911 "out of memory in read_config\n", 0, 0,0 );
1913 Debug( LDAP_DEBUG_ANY,
1914 "out of memory in read_config\n", 0, 0, 0 );
1916 ldap_free_urldesc( ludp );
1917 exit( EXIT_FAILURE );
1919 sprintf(replicahost, "%s:%d",
1920 ludp->lud_host, ludp->lud_port);
1921 nr = add_replica_info( be, replicahost );
1922 ldap_free_urldesc( ludp );
1923 ch_free(replicahost);
1929 LDAP_LOG( CONFIG, INFO,
1930 "%s: line %d: missing host or uri in \"replica\" line\n",
1931 fname, lineno , 0 );
1933 Debug( LDAP_DEBUG_ANY,
1934 "%s: line %d: missing host or uri in \"replica\" line\n",
1939 } else if ( nr == -1 ) {
1941 LDAP_LOG( CONFIG, INFO,
1942 "%s: line %d: unable to add"
1943 " replica \"%s\"\n",
1947 Debug( LDAP_DEBUG_ANY,
1948 "%s: line %d: unable to add replica \"%s\"\n",
1949 fname, lineno, cargv[i] + 5 );
1953 for ( i = 1; i < cargc; i++ ) {
1954 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1956 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1959 LDAP_LOG( CONFIG, INFO,
1960 "%s: line %d: suffix \"%s\" in \"replica\""
1961 " line is not valid for backend(ignored)\n",
1962 fname, lineno, cargv[i] + 7 );
1964 Debug( LDAP_DEBUG_ANY,
1965 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1966 fname, lineno, cargv[i] + 7 );
1972 LDAP_LOG( CONFIG, INFO,
1973 "%s: line %d: unable to normalize suffix"
1974 " in \"replica\" line (ignored)\n",
1975 fname, lineno , 0 );
1977 Debug( LDAP_DEBUG_ANY,
1978 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1984 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1986 char *arg = cargv[i] + 4;
1988 if ( arg[0] == '!' ) {
1993 if ( arg[0] != '=' ) {
1997 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1999 LDAP_LOG( CONFIG, INFO,
2000 "%s: line %d: attribute \"%s\" in "
2001 "\"replica\" line is unknown\n",
2002 fname, lineno, arg + 1 );
2004 Debug( LDAP_DEBUG_ANY,
2005 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
2006 fname, lineno, arg + 1 );
2015 } else if ( strcasecmp( cargv[0], "replicationInterval" ) == 0 ) {
2018 /* dn of slave entity allowed to write to replica */
2019 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
2022 LDAP_LOG( CONFIG, CRIT,
2023 "%s: line %d: missing dn in \"updatedn <dn>\""
2024 " line.\n", fname, lineno , 0 );
2026 Debug( LDAP_DEBUG_ANY,
2027 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
2035 LDAP_LOG( CONFIG, INFO,
2036 "%s: line %d: updatedn line must appear inside "
2037 "a database definition\n",
2038 fname, lineno , 0 );
2040 Debug( LDAP_DEBUG_ANY,
2041 "%s: line %d: updatedn line must appear inside a database definition\n",
2046 } else if ( SLAP_SHADOW(be) ) {
2048 LDAP_LOG( CONFIG, INFO,
2049 "%s: line %d: updatedn: database already shadowed.\n",
2052 Debug( LDAP_DEBUG_ANY,
2053 "%s: line %d: updatedn: database already shadowed.\n",
2061 if ( load_ucdata( NULL ) < 0 ) return 1;
2063 dn.bv_val = cargv[1];
2064 dn.bv_len = strlen( cargv[1] );
2066 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
2067 if( rc != LDAP_SUCCESS ) {
2069 LDAP_LOG( CONFIG, CRIT,
2070 "%s: line %d: updatedn DN is invalid.\n",
2071 fname, lineno , 0 );
2073 Debug( LDAP_DEBUG_ANY,
2074 "%s: line %d: updatedn DN is invalid\n",
2081 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW );
2083 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
2086 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2087 "missing url in \"updateref <ldapurl>\" line.\n",
2088 fname, lineno , 0 );
2090 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2091 "missing url in \"updateref <ldapurl>\" line\n",
2099 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2100 " line must appear inside a database definition\n",
2101 fname, lineno , 0 );
2103 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2104 " line must appear inside a database definition\n",
2109 } else if ( !SLAP_SHADOW(be) ) {
2111 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2112 "updateref line must come after syncrepl or updatedn.\n",
2113 fname, lineno , 0 );
2115 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2116 "updateref line must after syncrepl or updatedn.\n",
2122 if( validate_global_referral( cargv[1] ) ) {
2124 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2125 "invalid URL (%s) in \"updateref\" line.\n",
2126 fname, lineno, cargv[1] );
2128 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2129 "invalid URL (%s) in \"updateref\" line.\n",
2130 fname, lineno, cargv[1] );
2135 vals[0].bv_val = cargv[1];
2136 vals[0].bv_len = strlen( vals[0].bv_val );
2137 if( value_add( &be->be_update_refs, vals ) ) {
2141 /* replication log file to which changes are appended */
2142 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2145 LDAP_LOG( CONFIG, CRIT,
2146 "%s: line %d: missing filename in \"replogfile <filename>\""
2147 " line.\n", fname, lineno , 0 );
2149 Debug( LDAP_DEBUG_ANY,
2150 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2157 be->be_replogfile = ch_strdup( cargv[1] );
2159 replogfile = ch_strdup( cargv[1] );
2162 /* file from which to read additional rootdse attrs */
2163 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2166 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2167 "missing filename in \"rootDSE <filename>\" line.\n",
2168 fname, lineno , 0 );
2170 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2171 "missing filename in \"rootDSE <filename>\" line.\n",
2177 if( read_root_dse_file( cargv[1] ) ) {
2179 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2180 "could not read \"rootDSE <filename>\" line.\n",
2181 fname, lineno , 0 );
2183 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2184 "could not read \"rootDSE <filename>\" line\n",
2190 /* maintain lastmodified{by,time} attributes */
2191 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2194 LDAP_LOG( CONFIG, CRIT,
2195 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2196 " line.\n", fname, lineno , 0 );
2198 Debug( LDAP_DEBUG_ANY,
2199 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2205 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2207 SLAP_DBFLAGS(be) &= ~SLAP_DBFLAG_NOLASTMOD;
2213 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD;
2220 /* turn on/off gentle SIGHUP handling */
2221 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2223 Debug( LDAP_DEBUG_ANY,
2224 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2228 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2229 global_gentlehup = 0;
2231 global_gentlehup = 1;
2235 /* set idle timeout value */
2236 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2240 LDAP_LOG( CONFIG, CRIT,
2241 "%s: line %d: missing timeout value in "
2242 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2244 Debug( LDAP_DEBUG_ANY,
2245 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2252 i = atoi( cargv[1] );
2256 LDAP_LOG( CONFIG, CRIT,
2257 "%s: line %d: timeout value (%d) invalid "
2258 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2260 Debug( LDAP_DEBUG_ANY,
2261 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2268 global_idletimeout = i;
2270 /* include another config file */
2271 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2274 LDAP_LOG( CONFIG, CRIT,
2275 "%s: line %d: missing filename in \"include "
2276 "<filename>\" line.\n", fname, lineno , 0 );
2278 Debug( LDAP_DEBUG_ANY,
2279 "%s: line %d: missing filename in \"include <filename>\" line\n",
2285 savefname = ch_strdup( cargv[1] );
2286 savelineno = lineno;
2288 if ( read_config( savefname, depth+1 ) != 0 ) {
2293 lineno = savelineno - 1;
2295 /* location of kerberos srvtab file */
2296 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2299 LDAP_LOG( CONFIG, CRIT,
2300 "%s: line %d: missing filename in \"srvtab "
2301 "<filename>\" line.\n", fname, lineno , 0 );
2303 Debug( LDAP_DEBUG_ANY,
2304 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2310 ldap_srvtab = ch_strdup( cargv[1] );
2312 #ifdef SLAPD_MODULES
2313 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2316 LDAP_LOG( CONFIG, INFO,
2317 "%s: line %d: missing filename in \"moduleload "
2318 "<filename>\" line.\n", fname, lineno , 0 );
2320 Debug( LDAP_DEBUG_ANY,
2321 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2325 exit( EXIT_FAILURE );
2327 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2329 LDAP_LOG( CONFIG, CRIT,
2330 "%s: line %d: failed to load or initialize module %s\n",
2331 fname, lineno, cargv[1] );
2333 Debug( LDAP_DEBUG_ANY,
2334 "%s: line %d: failed to load or initialize module %s\n",
2335 fname, lineno, cargv[1]);
2338 exit( EXIT_FAILURE );
2340 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2343 LDAP_LOG( CONFIG, INFO,
2344 "%s: line %d: missing path in \"modulepath <path>\""
2345 " line\n", fname, lineno , 0 );
2347 Debug( LDAP_DEBUG_ANY,
2348 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2352 exit( EXIT_FAILURE );
2354 if (module_path( cargv[1] )) {
2356 LDAP_LOG( CONFIG, CRIT,
2357 "%s: line %d: failed to set module search path to %s.\n",
2358 fname, lineno, cargv[1] );
2360 Debug( LDAP_DEBUG_ANY,
2361 "%s: line %d: failed to set module search path to %s\n",
2362 fname, lineno, cargv[1]);
2365 exit( EXIT_FAILURE );
2368 #endif /*SLAPD_MODULES*/
2371 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2372 rc = ldap_pvt_tls_set_option( NULL,
2373 LDAP_OPT_X_TLS_RANDOM_FILE,
2378 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2379 rc = ldap_pvt_tls_set_option( NULL,
2380 LDAP_OPT_X_TLS_CIPHER_SUITE,
2385 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2386 rc = ldap_pvt_tls_set_option( NULL,
2387 LDAP_OPT_X_TLS_CERTFILE,
2392 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2393 rc = ldap_pvt_tls_set_option( NULL,
2394 LDAP_OPT_X_TLS_KEYFILE,
2399 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2400 rc = ldap_pvt_tls_set_option( NULL,
2401 LDAP_OPT_X_TLS_CACERTDIR,
2406 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2407 rc = ldap_pvt_tls_set_option( NULL,
2408 LDAP_OPT_X_TLS_CACERTFILE,
2412 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2413 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2415 rc = ldap_pvt_tls_set_option( NULL,
2416 LDAP_OPT_X_TLS_REQUIRE_CERT,
2419 rc = ldap_int_tls_config( NULL,
2420 LDAP_OPT_X_TLS_REQUIRE_CERT,
2429 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2430 #ifdef SLAPD_RLOOKUPS
2433 LDAP_LOG( CONFIG, INFO,
2434 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2435 fname, lineno , 0 );
2437 Debug( LDAP_DEBUG_ANY,
2438 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2444 if ( !strcasecmp( cargv[1], "on" ) ) {
2445 use_reverse_lookup = 1;
2446 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2447 use_reverse_lookup = 0;
2450 LDAP_LOG( CONFIG, INFO,
2451 "%s: line %d: reverse-lookup: "
2452 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2454 Debug( LDAP_DEBUG_ANY,
2455 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2461 #else /* !SLAPD_RLOOKUPS */
2463 LDAP_LOG( CONFIG, INFO,
2464 "%s: line %d: reverse lookups "
2465 "are not configured (ignored).\n", fname, lineno , 0 );
2467 Debug( LDAP_DEBUG_ANY,
2468 "%s: line %d: reverse lookups are not configured (ignored).\n",
2471 #endif /* !SLAPD_RLOOKUPS */
2473 /* Netscape plugins */
2474 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2475 #if defined( LDAP_SLAPI )
2477 #ifdef notdef /* allow global plugins, too */
2479 * a "plugin" line must be inside a database
2480 * definition, since we implement pre-,post-
2481 * and extended operation plugins
2485 LDAP_LOG( CONFIG, INFO,
2486 "%s: line %d: plugin line must appear "
2487 "insid a database definition.\n",
2490 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2491 "line must appear inside a database "
2492 "definition\n", fname, lineno, 0 );
2498 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
2502 slapi_plugins_used++;
2504 #else /* !defined( LDAP_SLAPI ) */
2506 LDAP_LOG( CONFIG, INFO,
2507 "%s: line %d: SLAPI not supported.\n",
2510 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2511 "not supported.\n", fname, lineno, 0 );
2515 #endif /* !defined( LDAP_SLAPI ) */
2517 /* Netscape plugins */
2518 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2519 #if defined( LDAP_SLAPI )
2522 LDAP_LOG( CONFIG, INFO,
2523 "%s: line %d: missing file name "
2524 "in pluginlog <filename> line.\n",
2527 Debug( LDAP_DEBUG_ANY,
2528 "%s: line %d: missing file name "
2529 "in pluginlog <filename> line.\n",
2535 if ( slapi_log_file != NULL ) {
2536 ch_free( slapi_log_file );
2539 slapi_log_file = ch_strdup( cargv[1] );
2540 #endif /* !defined( LDAP_SLAPI ) */
2542 /* pass anything else to the current backend info/db config routine */
2545 if ( bi->bi_config ) {
2546 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
2552 case SLAP_CONF_UNKNOWN:
2554 LDAP_LOG( CONFIG, INFO,
2555 "%s: line %d: unknown directive \"%s\" inside "
2556 "backend info definition (ignored).\n",
2557 fname, lineno, cargv[0] );
2559 Debug( LDAP_DEBUG_ANY,
2560 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2561 fname, lineno, cargv[0] );
2570 } else if ( be != NULL ) {
2571 if ( be->be_config ) {
2572 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
2578 case SLAP_CONF_UNKNOWN:
2580 LDAP_LOG( CONFIG, INFO,
2581 "%s: line %d: unknown directive \"%s\" inside "
2582 "backend database definition (ignored).\n",
2583 fname, lineno, cargv[0] );
2585 Debug( LDAP_DEBUG_ANY,
2586 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2587 fname, lineno, cargv[0] );
2598 LDAP_LOG( CONFIG, INFO,
2599 "%s: line %d: unknown directive \"%s\" outside backend "
2600 "info and database definitions (ignored).\n",
2601 fname, lineno, cargv[0] );
2603 Debug( LDAP_DEBUG_ANY,
2604 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2605 fname, lineno, cargv[0] );
2614 if ( depth == 0 ) ch_free( cargv );
2616 if ( !global_schemadn.bv_val ) {
2617 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2619 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2622 if ( load_ucdata( NULL ) < 0 ) return 1;
2634 char logbuf[sizeof("pseudorootpw ***")];
2637 token = strtok_quote( line, " \t" );
2641 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2642 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2643 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2644 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2645 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2647 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2650 if ( strtok_quote_ptr ) {
2651 *strtok_quote_ptr = ' ';
2655 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2657 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2660 if ( strtok_quote_ptr ) {
2661 *strtok_quote_ptr = '\0';
2664 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2665 if ( cargc == cargv_size - 1 ) {
2667 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2669 if ( tmp == NULL ) {
2671 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2673 Debug( LDAP_DEBUG_ANY,
2674 "line %d: out of memory\n",
2680 cargv_size += ARGS_STEP;
2682 cargv[cargc++] = token;
2684 cargv[cargc] = NULL;
2689 strtok_quote( char *line, char *sep )
2695 strtok_quote_ptr = NULL;
2696 if ( line != NULL ) {
2699 while ( *next && strchr( sep, *next ) ) {
2703 if ( *next == '\0' ) {
2709 for ( inquote = 0; *next; ) {
2717 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2723 next + 1, strlen( next + 1 ) + 1 );
2724 next++; /* dont parse the escaped character */
2729 if ( strchr( sep, *next ) != NULL ) {
2730 strtok_quote_ptr = next;
2743 static char buf[BUFSIZ];
2745 static size_t lmax, lcur;
2747 #define CATLINE( buf ) \
2749 size_t len = strlen( buf ); \
2750 while ( lcur + len + 1 > lmax ) { \
2752 line = (char *) ch_realloc( line, lmax ); \
2754 strcpy( line + lcur, buf ); \
2759 fp_getline( FILE *fp, int *lineno )
2767 /* hack attack - keeps us from having to keep a stack of bufs... */
2768 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2773 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2774 /* trim off \r\n or \n */
2775 if ( (p = strchr( buf, '\n' )) != NULL ) {
2776 if( p > buf && p[-1] == '\r' ) --p;
2780 /* trim off trailing \ and append the next line */
2781 if ( line[ 0 ] != '\0'
2782 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2783 && p[ -1 ] != '\\' ) {
2788 if ( ! isspace( (unsigned char) buf[0] ) ) {
2792 /* change leading whitespace to a space */
2801 return( line[0] ? line : NULL );
2805 fp_getline_init( int *lineno )
2811 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2813 load_ucdata( char *path )
2815 static int loaded = 0;
2821 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2824 LDAP_LOG( CONFIG, CRIT,
2825 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2827 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2840 ucdata_unload( UCDATA_ALL );
2841 free( global_schemandn.bv_val );
2842 free( global_schemadn.bv_val );
2844 if ( slapd_args_file )
2845 free ( slapd_args_file );
2846 if ( slapd_pid_file )
2847 free ( slapd_pid_file );
2848 if ( default_passwd_hash )
2849 ldap_charray_free( default_passwd_hash );
2850 acl_destroy( global_acl, NULL );
2861 syncinfo_t *si_entry;
2863 int duplicated_replica_id = 0;
2865 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2869 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2871 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2876 si->si_tls = SYNCINFO_TLS_OFF;
2877 if ( be->be_rootndn.bv_val ) {
2878 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2880 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2881 si->si_schemachecking = 0;
2882 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 0,
2883 &si->si_filterstr );
2884 si->si_base.bv_val = NULL;
2885 si->si_scope = LDAP_SCOPE_SUBTREE;
2886 si->si_attrsonly = 0;
2887 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
2888 si->si_attrs[0] = NULL;
2889 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2890 si->si_interval = 86400;
2891 si->si_syncCookie.ctxcsn = NULL;
2892 si->si_syncCookie.octet_str = NULL;
2893 si->si_syncCookie.sid = -1;
2894 si->si_manageDSAit = 0;
2897 si->si_syncUUID_ndn.bv_val = NULL;
2898 si->si_syncUUID_ndn.bv_len = 0;
2900 si->si_presentlist = NULL;
2901 LDAP_LIST_INIT( &si->si_nonpresentlist );
2903 rc = parse_syncrepl_line( cargv, cargc, si );
2905 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2906 if ( si->si_rid == si_entry->si_rid ) {
2908 LDAP_LOG( CONFIG, ERR,
2909 "add_syncrepl: duplicated replica id\n", 0, 0,0 );
2911 Debug( LDAP_DEBUG_ANY,
2912 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
2914 duplicated_replica_id = 1;
2919 if ( rc < 0 || duplicated_replica_id ) {
2920 syncinfo_t *si_entry;
2921 /* Something bad happened - back out */
2923 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2925 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2928 /* If error, remove all syncinfo */
2929 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2930 if ( si_entry->si_updatedn.bv_val ) {
2931 ch_free( si->si_updatedn.bv_val );
2933 if ( si_entry->si_filterstr.bv_val ) {
2934 ch_free( si->si_filterstr.bv_val );
2936 if ( si_entry->si_attrs ) {
2938 while ( si_entry->si_attrs[i] != NULL ) {
2939 ch_free( si_entry->si_attrs[i] );
2942 ch_free( si_entry->si_attrs );
2946 while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
2947 si_entry = LDAP_STAILQ_FIRST( &be->be_syncinfo );
2948 LDAP_STAILQ_REMOVE_HEAD( &be->be_syncinfo, si_next );
2949 ch_free( si_entry );
2951 LDAP_STAILQ_INIT( &be->be_syncinfo );
2955 LDAP_LOG ( CONFIG, RESULTS,
2956 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
2957 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2959 Debug( LDAP_DEBUG_CONFIG,
2960 "Config: ** successfully added syncrepl \"%s\"\n",
2961 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2963 if ( !si->si_schemachecking ) {
2964 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2967 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
2973 #define PROVIDERSTR "provider"
2974 #define SUFFIXSTR "suffix"
2975 #define UPDATEDNSTR "updatedn"
2976 #define BINDMETHSTR "bindmethod"
2977 #define SIMPLESTR "simple"
2978 #define SASLSTR "sasl"
2979 #define BINDDNSTR "binddn"
2980 #define CREDSTR "credentials"
2981 #define OLDAUTHCSTR "bindprincipal"
2982 #define AUTHCSTR "authcID"
2983 #define AUTHZSTR "authzID"
2984 #define SRVTABSTR "srvtab"
2985 #define SASLMECHSTR "saslmech"
2986 #define REALMSTR "realm"
2987 #define SECPROPSSTR "secprops"
2988 #define STARTTLSSTR "starttls"
2989 #define CRITICALSTR "critical"
2991 #define SCHEMASTR "schemachecking"
2992 #define FILTERSTR "filter"
2993 #define SEARCHBASESTR "searchbase"
2994 #define SCOPESTR "scope"
2995 #define ATTRSSTR "attrs"
2996 #define ATTRSONLYSTR "attrsonly"
2997 #define TYPESTR "type"
2998 #define INTERVALSTR "interval"
2999 #define LASTMODSTR "lastmod"
3000 #define LMREQSTR "req"
3001 #define LMGENSTR "gen"
3002 #define LMNOSTR "no"
3003 #define MANAGEDSAITSTR "manageDSAit"
3004 #define SLIMITSTR "sizelimit"
3005 #define TLIMITSTR "timelimit"
3007 #define GOT_ID 0x0001
3008 #define GOT_PROVIDER 0x0002
3009 #define GOT_METHOD 0x0004
3010 #define GOT_ALL 0x0007
3013 parse_syncrepl_line(
3024 for ( i = 1; i < cargc; i++ ) {
3025 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
3027 /* '\0' string terminator accounts for '=' */
3028 val = cargv[ i ] + sizeof( IDSTR );
3030 if ( tmp >= 1000 || tmp < 0 ) {
3031 fprintf( stderr, "Error: parse_syncrepl_line: "
3032 "syncrepl id %d is out of range [0..999]\n", tmp );
3037 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
3038 sizeof( PROVIDERSTR ) - 1 )) {
3039 val = cargv[ i ] + sizeof( PROVIDERSTR );
3040 si->si_provideruri = ch_strdup( val );
3041 si->si_provideruri_bv = (BerVarray)
3042 ch_calloc( 2, sizeof( struct berval ));
3043 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
3044 0, &si->si_provideruri_bv[0] );
3045 si->si_provideruri_bv[1].bv_len = 0;
3046 si->si_provideruri_bv[1].bv_val = NULL;
3047 gots |= GOT_PROVIDER;
3048 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
3049 sizeof(STARTTLSSTR) - 1 ) )
3051 val = cargv[ i ] + sizeof( STARTTLSSTR );
3052 if( !strcasecmp( val, CRITICALSTR ) ) {
3053 si->si_tls = SYNCINFO_TLS_CRITICAL;
3055 si->si_tls = SYNCINFO_TLS_ON;
3057 } else if ( !strncasecmp( cargv[ i ],
3058 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
3060 struct berval updatedn = {0, NULL};
3061 val = cargv[ i ] + sizeof( UPDATEDNSTR );
3062 ber_str2bv( val, 0, 0, &updatedn );
3063 ch_free( si->si_updatedn.bv_val );
3064 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
3065 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
3066 sizeof( BINDMETHSTR ) - 1 ) )
3068 val = cargv[ i ] + sizeof( BINDMETHSTR );
3069 if ( !strcasecmp( val, SIMPLESTR )) {
3070 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3072 } else if ( !strcasecmp( val, SASLSTR )) {
3073 #ifdef HAVE_CYRUS_SASL
3074 si->si_bindmethod = LDAP_AUTH_SASL;
3076 #else /* HAVE_CYRUS_SASL */
3077 fprintf( stderr, "Error: parse_syncrepl_line: "
3078 "not compiled with SASL support\n" );
3080 #endif /* HAVE_CYRUS_SASL */
3082 si->si_bindmethod = -1;
3084 } else if ( !strncasecmp( cargv[ i ],
3085 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
3086 val = cargv[ i ] + sizeof( BINDDNSTR );
3087 si->si_binddn = ch_strdup( val );
3088 } else if ( !strncasecmp( cargv[ i ],
3089 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
3090 val = cargv[ i ] + sizeof( CREDSTR );
3091 si->si_passwd = ch_strdup( val );
3092 } else if ( !strncasecmp( cargv[ i ],
3093 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
3094 val = cargv[ i ] + sizeof( SASLMECHSTR );
3095 si->si_saslmech = ch_strdup( val );
3096 } else if ( !strncasecmp( cargv[ i ],
3097 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
3098 val = cargv[ i ] + sizeof( SECPROPSSTR );
3099 si->si_secprops = ch_strdup( val );
3100 } else if ( !strncasecmp( cargv[ i ],
3101 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
3102 val = cargv[ i ] + sizeof( REALMSTR );
3103 si->si_realm = ch_strdup( val );
3104 } else if ( !strncasecmp( cargv[ i ],
3105 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
3106 val = cargv[ i ] + sizeof( AUTHCSTR );
3107 si->si_authcId = ch_strdup( val );
3108 } else if ( !strncasecmp( cargv[ i ],
3109 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
3110 /* Old authcID is provided for some backwards compatibility */
3111 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
3112 si->si_authcId = ch_strdup( val );
3113 } else if ( !strncasecmp( cargv[ i ],
3114 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
3115 val = cargv[ i ] + sizeof( AUTHZSTR );
3116 si->si_authzId = ch_strdup( val );
3117 } else if ( !strncasecmp( cargv[ i ],
3118 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
3120 val = cargv[ i ] + sizeof( SCHEMASTR );
3121 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
3122 si->si_schemachecking = 1;
3123 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
3124 si->si_schemachecking = 0;
3126 si->si_schemachecking = 1;
3128 } else if ( !strncasecmp( cargv[ i ],
3129 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
3131 val = cargv[ i ] + sizeof( FILTERSTR );
3132 ber_str2bv( val, 0, 1, &si->si_filterstr );
3133 } else if ( !strncasecmp( cargv[ i ],
3134 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3137 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3138 if ( si->si_base.bv_val ) {
3139 ch_free( si->si_base.bv_val );
3141 ber_str2bv( val, 0, 0, &bv );
3142 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3143 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3146 } else if ( !strncasecmp( cargv[ i ],
3147 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3149 val = cargv[ i ] + sizeof( SCOPESTR );
3150 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
3151 si->si_scope = LDAP_SCOPE_BASE;
3152 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
3153 si->si_scope = LDAP_SCOPE_ONELEVEL;
3154 #ifdef LDAP_SCOPE_SUBORDINATE
3155 } else if ( !strcasecmp( val, "subordinate" ) ||
3156 !strcasecmp( val, "children" ))
3158 si->si_scope = LDAP_SCOPE_SUBORDINATE;
3160 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
3161 si->si_scope = LDAP_SCOPE_SUBTREE;
3163 fprintf( stderr, "Error: parse_syncrepl_line: "
3164 "unknown scope \"%s\"\n", val);
3167 } else if ( !strncasecmp( cargv[ i ],
3168 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3170 si->si_attrsonly = 1;
3171 } else if ( !strncasecmp( cargv[ i ],
3172 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3174 val = cargv[ i ] + sizeof( ATTRSSTR );
3175 str2clist( &si->si_attrs, val, "," );
3176 } else if ( !strncasecmp( cargv[ i ],
3177 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3179 val = cargv[ i ] + sizeof( TYPESTR );
3180 if ( !strncasecmp( val, "refreshOnly", STRLENOF("refreshOnly") )) {
3181 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3182 } else if ( !strncasecmp( val, "refreshAndPersist",
3183 STRLENOF("refreshAndPersist") ))
3185 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3186 si->si_interval = 60;
3188 fprintf( stderr, "Error: parse_syncrepl_line: "
3189 "unknown sync type \"%s\"\n", val);
3192 } else if ( !strncasecmp( cargv[ i ],
3193 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3195 val = cargv[ i ] + sizeof( INTERVALSTR );
3196 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
3197 si->si_interval = 0;
3205 hstr = strchr( dstr, ':' );
3206 if ( hstr == NULL ) {
3207 fprintf( stderr, "Error: parse_syncrepl_line: "
3208 "invalid interval \"%s\"\n", val );
3212 mstr = strchr( hstr, ':' );
3213 if ( mstr == NULL ) {
3214 fprintf( stderr, "Error: parse_syncrepl_line: "
3215 "invalid interval \"%s\"\n", val );
3219 sstr = strchr( mstr, ':' );
3220 if ( sstr == NULL ) {
3221 fprintf( stderr, "Error: parse_syncrepl_line: "
3222 "invalid interval \"%s\"\n", val );
3231 if (( hh > 24 ) || ( hh < 0 ) ||
3232 ( mm > 60 ) || ( mm < 0 ) ||
3233 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3234 fprintf( stderr, "Error: parse_syncrepl_line: "
3235 "invalid interval \"%s\"\n", val );
3238 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3240 if ( si->si_interval < 0 ) {
3241 fprintf( stderr, "Error: parse_syncrepl_line: "
3242 "invalid interval \"%ld\"\n",
3243 (long) si->si_interval);
3246 } else if ( !strncasecmp( cargv[ i ],
3247 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3249 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3250 si->si_manageDSAit = atoi( val );
3251 } else if ( !strncasecmp( cargv[ i ],
3252 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3254 val = cargv[ i ] + sizeof( SLIMITSTR );
3255 si->si_slimit = atoi( val );
3256 } else if ( !strncasecmp( cargv[ i ],
3257 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3259 val = cargv[ i ] + sizeof( TLIMITSTR );
3260 si->si_tlimit = atoi( val );
3262 fprintf( stderr, "Error: parse_syncrepl_line: "
3263 "unknown keyword \"%s\"\n", cargv[ i ] );
3267 if ( gots != GOT_ALL ) {
3269 "Error: Malformed \"syncrepl\" line in slapd config file" );
3277 str2clist( char ***out, char *in, const char *brkstr )
3286 /* find last element in list */
3287 for (i = 0; *out && *out[i]; i++);
3289 /* protect the input string from strtok */
3290 str = ch_strdup( in );
3292 if ( *str == '\0' ) {
3297 /* Count words in string */
3299 for ( s = str; *s; s++ ) {
3300 if ( strchr( brkstr, *s ) != NULL ) {
3305 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3307 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3309 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3311 *new = ch_strdup( s );