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 BackendInfo *bi = NULL;
122 static BackendDB *be = NULL;
126 vals[1].bv_val = NULL;
129 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
130 cargv_size = ARGS_STEP + 1;
133 if ( (fp = fopen( fname, "r" )) == NULL ) {
136 LDAP_LOG( CONFIG, ENTRY,
137 "read_config: " "could not open config file \"%s\": %s (%d)\n",
138 fname, strerror(errno), errno );
140 Debug( LDAP_DEBUG_ANY,
141 "could not open config file \"%s\": %s (%d)\n",
142 fname, strerror(errno), errno );
148 LDAP_LOG( CONFIG, ENTRY,
149 "read_config: reading config file %s\n", fname, 0, 0 );
151 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
155 fp_getline_init( &lineno );
157 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
158 /* skip comments and blank lines */
159 if ( line[0] == '#' || line[0] == '\0' ) {
163 /* fp_parse_line is destructive, we save a copy */
164 saveline = ch_strdup( line );
166 if ( fp_parse_line( lineno, line ) != 0 ) {
172 LDAP_LOG( CONFIG, INFO,
173 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
175 Debug( LDAP_DEBUG_ANY,
176 "%s: line %d: bad config line (ignored)\n",
183 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
186 LDAP_LOG( CONFIG, CRIT,
187 "%s : line %d: missing type in \"backend\" line.\n",
190 Debug( LDAP_DEBUG_ANY,
191 "%s: line %d: missing type in \"backend <type>\" line\n",
200 LDAP_LOG( CONFIG, CRIT,
201 "%s: line %d: backend line must appear before any "
202 "database definition.\n", fname, lineno , 0 );
204 Debug( LDAP_DEBUG_ANY,
205 "%s: line %d: backend line must appear before any database definition\n",
212 bi = backend_info( cargv[1] );
216 LDAP_LOG( CONFIG, CRIT,
217 "read_config: backend %s initialization failed.\n",
220 Debug( LDAP_DEBUG_ANY,
221 "backend %s initialization failed.\n",
227 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
230 LDAP_LOG( CONFIG, CRIT,
231 "%s: line %d: missing type in \"database <type>\" line\n",
234 Debug( LDAP_DEBUG_ANY,
235 "%s: line %d: missing type in \"database <type>\" line\n",
243 be = backend_db_init( cargv[1] );
247 LDAP_LOG( CONFIG, CRIT,
248 "database %s initialization failed.\n", cargv[1], 0, 0 );
250 Debug( LDAP_DEBUG_ANY,
251 "database %s initialization failed.\n",
258 /* set thread concurrency */
259 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
263 LDAP_LOG( CONFIG, CRIT,
264 "%s: line %d: missing level in \"concurrency <level>\" "
265 " line\n", fname, lineno, 0 );
267 Debug( LDAP_DEBUG_ANY,
268 "%s: line %d: missing level in \"concurrency <level>\" line\n",
275 c = strtol( cargv[1], &next, 10 );
276 if ( next == NULL || next[0] != '\0' ) {
278 LDAP_LOG( CONFIG, CRIT,
279 "%s: line %d: unable to parse level \"%s\" in \"concurrency <level>\" "
280 " line\n", fname, lineno, cargv[1] );
282 Debug( LDAP_DEBUG_ANY,
283 "%s: line %d: unable to parse level \"%s\" in \"concurrency <level>\" line\n",
284 fname, lineno, cargv[1] );
291 LDAP_LOG( CONFIG, CRIT,
292 "%s: line %d: invalid level (%d) in "
293 "\"concurrency <level>\" line.\n", fname, lineno, c );
295 Debug( LDAP_DEBUG_ANY,
296 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
303 ldap_pvt_thread_set_concurrency( c );
305 /* set sockbuf max */
306 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
310 LDAP_LOG( CONFIG, CRIT,
311 "%s: line %d: missing max in \"sockbuf_max_incoming "
312 "<bytes>\" line\n", fname, lineno, 0 );
314 Debug( LDAP_DEBUG_ANY,
315 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
322 max = atol( cargv[1] );
326 LDAP_LOG( CONFIG, CRIT,
327 "%s: line %d: invalid max value (%ld) in "
328 "\"sockbuf_max_incoming <bytes>\" line.\n",
329 fname, lineno, max );
331 Debug( LDAP_DEBUG_ANY,
332 "%s: line %d: invalid max value (%ld) in "
333 "\"sockbuf_max_incoming <bytes>\" line.\n",
334 fname, lineno, max );
340 sockbuf_max_incoming = max;
342 /* set sockbuf max authenticated */
343 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
347 LDAP_LOG( CONFIG, CRIT,
348 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
349 "<bytes>\" line\n", fname, lineno, 0 );
351 Debug( LDAP_DEBUG_ANY,
352 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
359 max = atol( cargv[1] );
363 LDAP_LOG( CONFIG, CRIT,
364 "%s: line %d: invalid max value (%ld) in "
365 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
366 fname, lineno, max );
368 Debug( LDAP_DEBUG_ANY,
369 "%s: line %d: invalid max value (%ld) in "
370 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
371 fname, lineno, max );
377 sockbuf_max_incoming_auth = max;
379 /* set conn pending max */
380 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
384 LDAP_LOG( CONFIG, CRIT,
385 "%s: line %d: missing max in \"conn_max_pending "
386 "<requests>\" line\n", fname, lineno, 0 );
388 Debug( LDAP_DEBUG_ANY,
389 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
396 max = atol( cargv[1] );
400 LDAP_LOG( CONFIG, CRIT,
401 "%s: line %d: invalid max value (%ld) in "
402 "\"conn_max_pending <requests>\" line.\n",
403 fname, lineno, max );
405 Debug( LDAP_DEBUG_ANY,
406 "%s: line %d: invalid max value (%ld) in "
407 "\"conn_max_pending <requests>\" line.\n",
408 fname, lineno, max );
414 slap_conn_max_pending = max;
416 /* set conn pending max authenticated */
417 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
421 LDAP_LOG( CONFIG, CRIT,
422 "%s: line %d: missing max in \"conn_max_pending_auth "
423 "<requests>\" line\n", fname, lineno, 0 );
425 Debug( LDAP_DEBUG_ANY,
426 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
433 max = atol( cargv[1] );
437 LDAP_LOG( CONFIG, CRIT,
438 "%s: line %d: invalid max value (%ld) in "
439 "\"conn_max_pending_auth <requests>\" line.\n",
440 fname, lineno, max );
442 Debug( LDAP_DEBUG_ANY,
443 "%s: line %d: invalid max value (%ld) in "
444 "\"conn_max_pending_auth <requests>\" line.\n",
445 fname, lineno, max );
451 slap_conn_max_pending_auth = max;
453 /* default search base */
454 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
457 LDAP_LOG( CONFIG, CRIT,
458 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
459 "line\n", fname, lineno, 0 );
461 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
462 "missing dn in \"defaultSearchBase <dn>\" line\n",
468 } else if ( cargc > 2 ) {
470 LDAP_LOG( CONFIG, INFO,
471 "%s: line %d: extra cruft after <dn> in "
472 "\"defaultSearchBase %s\" line (ignored)\n",
473 fname, lineno, cargv[1] );
475 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
476 "extra cruft after <dn> in \"defaultSearchBase %s\", "
478 fname, lineno, cargv[1] );
482 if ( bi != NULL || be != NULL ) {
484 LDAP_LOG( CONFIG, CRIT,
485 "%s: line %d: defaultSearchBase line must appear "
486 "prior to any backend or database definitions\n",
489 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
490 "defaultSearchBaase line must appear prior to "
491 "any backend or database definition\n",
498 if ( default_search_nbase.bv_len ) {
500 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
501 "default search base \"%s\" already defined "
502 "(discarding old)\n", fname, lineno,
503 default_search_base.bv_val );
505 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
506 "default search base \"%s\" already defined "
507 "(discarding old)\n",
508 fname, lineno, default_search_base.bv_val );
511 free( default_search_base.bv_val );
512 free( default_search_nbase.bv_val );
515 if ( load_ucdata( NULL ) < 0 ) return 1;
520 dn.bv_val = cargv[1];
521 dn.bv_len = strlen( dn.bv_val );
523 rc = dnPrettyNormal( NULL, &dn,
524 &default_search_base,
525 &default_search_nbase, NULL );
527 if( rc != LDAP_SUCCESS ) {
529 LDAP_LOG( CONFIG, CRIT,
530 "%s: line %d: defaultSearchBase DN is invalid.\n",
533 Debug( LDAP_DEBUG_ANY,
534 "%s: line %d: defaultSearchBase DN is invalid\n",
541 /* set maximum threads in thread pool */
542 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
546 LDAP_LOG( CONFIG, CRIT,
547 "%s: line %d: missing count in \"threads <count>\" line\n",
550 Debug( LDAP_DEBUG_ANY,
551 "%s: line %d: missing count in \"threads <count>\" line\n",
558 c = strtol( cargv[1], &next, 10 );
559 if (next == NULL || next[0] != '\0' ) {
561 LDAP_LOG( CONFIG, CRIT,
562 "%s: line %d: unable to parse count \"%s\" in \"threads <count>\" line\n",
563 fname, lineno, cargv[1] );
565 Debug( LDAP_DEBUG_ANY,
566 "%s: line %d: unable to parse count \"%s\" in \"threads <count>\" line\n",
567 fname, lineno, cargv[1] );
574 LDAP_LOG( CONFIG, CRIT,
575 "%s: line %d: invalid level (%d) in \"threads <count>\""
576 "line\n", fname, lineno, c );
578 Debug( LDAP_DEBUG_ANY,
579 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
586 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
588 /* save for later use */
589 connection_pool_max = c;
591 /* get pid file name */
592 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
595 LDAP_LOG( CONFIG, CRIT,
596 "%s: line %d missing file name in \"pidfile <file>\" "
597 "line.\n", fname, lineno, 0 );
599 Debug( LDAP_DEBUG_ANY,
600 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
607 slapd_pid_file = ch_strdup( cargv[1] );
609 /* get args file name */
610 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
613 LDAP_LOG( CONFIG, CRIT,
614 "%s: %d: missing file name in "
615 "\"argsfile <file>\" line.\n",
618 Debug( LDAP_DEBUG_ANY,
619 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
626 slapd_args_file = ch_strdup( cargv[1] );
628 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
631 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
634 /* default password hash */
635 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
638 LDAP_LOG( CONFIG, CRIT,
639 "%s: line %d: missing hash in "
640 "\"password-hash <hash>\" line.\n",
643 Debug( LDAP_DEBUG_ANY,
644 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
650 if ( default_passwd_hash != NULL ) {
652 LDAP_LOG( CONFIG, CRIT,
653 "%s: line %d: already set default password_hash!\n",
656 Debug( LDAP_DEBUG_ANY,
657 "%s: line %d: already set default password_hash!\n",
664 for(i = 1; i < cargc; i++) {
665 if ( lutil_passwd_scheme( cargv[i] ) == 0 ) {
667 LDAP_LOG( CONFIG, CRIT,
668 "%s: line %d: password scheme \"%s\" not available\n",
669 fname, lineno, cargv[i] );
671 Debug( LDAP_DEBUG_ANY,
672 "%s: line %d: password scheme \"%s\" not available\n",
673 fname, lineno, cargv[i] );
676 ldap_charray_add( &default_passwd_hash, cargv[i] );
679 if( !default_passwd_hash ) {
681 LDAP_LOG( CONFIG, CRIT,
682 "%s: line %d: no valid hashes found\n",
685 Debug( LDAP_DEBUG_ANY,
686 "%s: line %d: no valid hashes found\n",
692 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
696 LDAP_LOG( CONFIG, CRIT,
697 "%s: line %d: missing format in "
698 "\"password-crypt-salt-format <format>\" line\n",
701 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
702 "\"password-crypt-salt-format <format>\" line\n",
709 lutil_salt_format( cargv[1] );
711 #ifdef SLAP_AUTH_REWRITE
712 /* use authid rewrite instead of sasl regexp */
713 } else if ( strncasecmp( cargv[0], "auth-rewrite",
714 STRLENOF("auth-rewrite") ) == 0 )
716 int rc = slap_sasl_rewrite_config( fname, lineno,
721 #endif /* SLAP_AUTH_REWRITE */
723 /* Auth + SASL config options */
724 } else if ( !strncasecmp( cargv[0], "auth", STRLENOF("auth") ) ||
725 !strncasecmp( cargv[0], "sasl", STRLENOF("sasl") ))
727 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
731 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
735 LDAP_LOG( CONFIG, CRIT,
736 "%s: line %d: missing dn in "
737 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
739 Debug( LDAP_DEBUG_ANY,
740 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
745 ber_str2bv( cargv[1], 0, 0, &dn );
747 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
748 &be->be_schemandn, NULL );
750 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
751 &global_schemandn, NULL );
753 if ( rc != LDAP_SUCCESS ) {
755 LDAP_LOG( CONFIG, CRIT,
756 "%s: line %d: schemadn DN is invalid.\n",
759 Debug( LDAP_DEBUG_ANY,
760 "%s: line %d: schemadn DN is invalid\n",
766 /* set UCDATA path */
767 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
771 LDAP_LOG( CONFIG, CRIT,
772 "%s: line %d: missing path in "
773 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
775 Debug( LDAP_DEBUG_ANY,
776 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
783 err = load_ucdata( cargv[1] );
787 LDAP_LOG( CONFIG, CRIT,
788 "%s: line %d: ucdata already loaded, ucdata-path "
789 "must be set earlier in the file and/or be "
790 "specified only once!\n", fname, lineno, 0 );
792 Debug( LDAP_DEBUG_ANY,
793 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
802 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
804 struct slap_limits_set *lim;
808 LDAP_LOG( CONFIG, CRIT,
809 "%s: line %d: missing limit in \"sizelimit <limit>\" "
810 "line.\n", fname, lineno, 0 );
812 Debug( LDAP_DEBUG_ANY,
813 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
823 lim = &be->be_def_limit;
826 for ( i = 1; i < cargc; i++ ) {
827 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
828 rc = limits_parse_one( cargv[i], lim );
831 LDAP_LOG( CONFIG, CRIT,
832 "%s: line %d: unable "
833 "to parse value \"%s\" in \"sizelimit "
834 "<limit>\" line.\n", fname, lineno, cargv[i] );
836 Debug( LDAP_DEBUG_ANY,
837 "%s: line %d: unable "
838 "to parse value \"%s\" "
841 fname, lineno, cargv[i] );
847 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
848 lim->lms_s_soft = -1;
850 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
851 if ( next == cargv[i] ) {
853 LDAP_LOG( CONFIG, CRIT,
854 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
855 "line.\n", fname, lineno, cargv[i] );
857 Debug( LDAP_DEBUG_ANY,
858 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
859 fname, lineno, cargv[i] );
863 } else if ( next[0] != '\0' ) {
865 LDAP_LOG( CONFIG, CRIT,
866 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
867 "line ignored.\n", fname, lineno, next );
869 Debug( LDAP_DEBUG_ANY,
870 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
871 fname, lineno, next );
880 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
882 struct slap_limits_set *lim;
886 LDAP_LOG( CONFIG, CRIT,
887 "%s: line %d missing limit in \"timelimit <limit>\" "
888 "line.\n", fname, lineno, 0 );
890 Debug( LDAP_DEBUG_ANY,
891 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
901 lim = &be->be_def_limit;
904 for ( i = 1; i < cargc; i++ ) {
905 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
906 rc = limits_parse_one( cargv[i], lim );
909 LDAP_LOG( CONFIG, CRIT,
910 "%s: line %d: unable to parse value \"%s\" "
911 "in \"timelimit <limit>\" line.\n",
912 fname, lineno, cargv[i] );
914 Debug( LDAP_DEBUG_ANY,
915 "%s: line %d: unable "
916 "to parse value \"%s\" "
919 fname, lineno, cargv[i] );
925 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
926 lim->lms_t_soft = -1;
928 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
929 if ( next == cargv[i] ) {
931 LDAP_LOG( CONFIG, CRIT,
932 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
933 "line.\n", fname, lineno, cargv[i] );
935 Debug( LDAP_DEBUG_ANY,
936 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
937 fname, lineno, cargv[i] );
941 } else if ( next[0] != '\0' ) {
943 LDAP_LOG( CONFIG, CRIT,
944 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
945 "line ignored.\n", fname, lineno, next );
947 Debug( LDAP_DEBUG_ANY,
948 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
949 fname, lineno, next );
957 /* set regex-based limits */
958 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
961 LDAP_LOG( CONFIG, WARNING,
962 "%s: line %d \"limits\" allowed only in database "
963 "environment.\n", fname, lineno, 0 );
965 Debug( LDAP_DEBUG_ANY,
966 "%s: line %d \"limits\" allowed only in database environment.\n%s",
972 if ( limits_parse( be, fname, lineno, cargc, cargv ) ) {
976 /* mark this as a subordinate database */
977 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
980 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
981 "subordinate keyword must appear inside a database "
982 "definition.\n", fname, lineno, 0 );
984 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
985 "must appear inside a database definition.\n",
991 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
995 /* add an overlay to this backend */
996 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
999 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1000 "overlay keyword must appear inside a database "
1001 "definition.\n", fname, lineno, 0 );
1003 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
1004 "must appear inside a database definition.\n",
1010 if ( cargv[1][0] == '-' && overlay_config( be, &cargv[1][1] ) ) {
1013 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1014 "(optional) overlay \"%s\" configuration "
1015 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
1017 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1018 "(optional) overlay \"%s\" configuration "
1019 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
1021 } else if ( overlay_config( be, cargv[1] ) ) {
1026 /* set database suffix */
1027 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
1029 struct berval dn, pdn, ndn;
1033 LDAP_LOG( CONFIG, CRIT,
1034 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
1037 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1038 "missing dn in \"suffix <dn>\" line\n",
1044 } else if ( cargc > 2 ) {
1046 LDAP_LOG( CONFIG, INFO,
1047 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
1048 " line (ignored).\n", fname, lineno, cargv[1] );
1050 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
1051 "after <dn> in \"suffix %s\" line (ignored)\n",
1052 fname, lineno, cargv[1] );
1058 LDAP_LOG( CONFIG, INFO,
1059 "%s: line %d: suffix line must appear inside a database "
1060 "definition.\n", fname, lineno, 0 );
1062 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
1063 "must appear inside a database definition\n",
1068 #if defined(SLAPD_MONITOR_DN)
1069 /* "cn=Monitor" is reserved for monitoring slap */
1070 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
1072 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
1073 "%s\" is reserved for monitoring slapd\n",
1074 fname, lineno, SLAPD_MONITOR_DN );
1076 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
1077 "%s\" is reserved for monitoring slapd\n",
1078 fname, lineno, SLAPD_MONITOR_DN );
1081 #endif /* SLAPD_MONITOR_DN */
1084 if ( load_ucdata( NULL ) < 0 ) return 1;
1086 dn.bv_val = cargv[1];
1087 dn.bv_len = strlen( cargv[1] );
1089 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1090 if( rc != LDAP_SUCCESS ) {
1092 LDAP_LOG( CONFIG, CRIT,
1093 "%s: line %d: suffix DN is invalid.\n",
1096 Debug( LDAP_DEBUG_ANY,
1097 "%s: line %d: suffix DN is invalid\n",
1103 tmp_be = select_backend( &ndn, 0, 0 );
1104 if ( tmp_be == be ) {
1106 LDAP_LOG( CONFIG, INFO,
1107 "%s: line %d: suffix already served by this backend "
1108 "(ignored)\n", fname, lineno, 0 );
1110 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1111 "already served by this backend (ignored)\n",
1117 } else if ( tmp_be != NULL ) {
1119 LDAP_LOG( CONFIG, INFO,
1120 "%s: line %d: suffix already served by a preceding "
1121 "backend \"%s\"\n", fname, lineno,
1122 tmp_be->be_suffix[0].bv_val );
1124 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1125 "already served by a preceeding backend \"%s\"\n",
1126 fname, lineno, tmp_be->be_suffix[0].bv_val );
1132 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1134 LDAP_LOG( CONFIG, INFO,
1135 "%s: line %d: suffix DN empty and default search "
1136 "base provided \"%s\" (assuming okay).\n",
1137 fname, lineno, default_search_base.bv_val );
1139 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1140 "suffix DN empty and default "
1141 "search base provided \"%s\" (assuming okay)\n",
1142 fname, lineno, default_search_base.bv_val );
1146 ber_bvarray_add( &be->be_suffix, &pdn );
1147 ber_bvarray_add( &be->be_nsuffix, &ndn );
1149 /* set max deref depth */
1150 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1154 LDAP_LOG( CONFIG, CRIT,
1155 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1156 " line\n", fname, lineno, 0 );
1158 Debug( LDAP_DEBUG_ANY,
1159 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1167 LDAP_LOG( CONFIG, INFO,
1168 "%s: line %d: depth line must appear inside a database "
1169 "definition.\n", fname, lineno ,0 );
1171 Debug( LDAP_DEBUG_ANY,
1172 "%s: line %d: depth line must appear inside a database definition.\n",
1178 i = strtol( cargv[1], &next, 10 );
1179 if ( next == NULL || next[0] != '\0' ) {
1181 LDAP_LOG( CONFIG, INFO,
1182 "%s: line %d: unable to parse depth \"%s\" in \"maxDerefDepth <depth>\" "
1183 "line.\n", fname, lineno, cargv[1] );
1185 Debug( LDAP_DEBUG_ANY,
1186 "%s: line %d: unable to parse depth \"%s\" in \"maxDerefDepth <depth>\" "
1187 "line.\n", fname, lineno, cargv[1] );
1194 LDAP_LOG( CONFIG, INFO,
1195 "%s: line %d: depth must be positive.\n",
1198 Debug( LDAP_DEBUG_ANY,
1199 "%s: line %d: depth must be positive.\n",
1206 be->be_max_deref_depth = i;
1208 /* set magic "root" dn for this database */
1209 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1212 LDAP_LOG( CONFIG, INFO,
1213 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1216 Debug( LDAP_DEBUG_ANY,
1217 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1226 LDAP_LOG( CONFIG, INFO,
1227 "%s: line %d: rootdn line must appear inside a database "
1228 "definition.\n", fname, lineno ,0 );
1230 Debug( LDAP_DEBUG_ANY,
1231 "%s: line %d: rootdn line must appear inside a database definition.\n",
1239 if ( load_ucdata( NULL ) < 0 ) return 1;
1241 dn.bv_val = cargv[1];
1242 dn.bv_len = strlen( cargv[1] );
1244 rc = dnPrettyNormal( NULL, &dn,
1246 &be->be_rootndn, NULL );
1248 if( rc != LDAP_SUCCESS ) {
1250 LDAP_LOG( CONFIG, CRIT,
1251 "%s: line %d: rootdn DN is invalid.\n",
1254 Debug( LDAP_DEBUG_ANY,
1255 "%s: line %d: rootdn DN is invalid\n",
1262 /* set super-secret magic database password */
1263 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1266 LDAP_LOG( CONFIG, CRIT,
1267 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1268 " line\n", fname, lineno ,0 );
1270 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1271 "missing passwd in \"rootpw <passwd>\" line\n",
1280 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1281 "rootpw line must appear inside a database "
1282 "definition.\n", fname, lineno ,0 );
1284 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1285 "rootpw line must appear inside a database "
1292 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1294 if( tmp_be != be ) {
1296 LDAP_LOG( CONFIG, INFO,
1298 "rootpw can only be set when rootdn is under suffix\n",
1299 fname, lineno, "" );
1301 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1302 "rootpw can only be set when rootdn is under suffix\n",
1308 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1309 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1312 /* make this database read-only */
1313 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1316 LDAP_LOG( CONFIG, CRIT,
1317 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1318 "line.\n", fname, lineno ,0 );
1320 Debug( LDAP_DEBUG_ANY,
1321 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1328 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1329 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1331 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1334 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1335 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1337 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1341 /* restricts specific operations */
1342 } else if ( strcasecmp( cargv[0], "restrict" ) == 0 ) {
1343 slap_mask_t restrict = 0;
1344 struct restrictable_exops_t {
1347 } restrictable_exops[] = {
1348 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
1349 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
1350 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
1351 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
1358 LDAP_LOG( CONFIG, CRIT,
1359 "%s: line %d: missing <op_list> in \"restrict <op_list>\" "
1360 "line.\n", fname, lineno ,0 );
1362 Debug( LDAP_DEBUG_ANY,
1363 "%s: line %d: missing <op_list> in \"restrict <op_list>\" "
1364 "line.\n", fname, lineno, 0 );
1370 for ( i = 1; i < cargc; i++ ) {
1371 if ( strcasecmp( cargv[ i ], "read" ) == 0 ) {
1372 restrict |= SLAP_RESTRICT_OP_READS;
1374 } else if ( strcasecmp( cargv[ i ], "write" ) == 0 ) {
1375 restrict |= SLAP_RESTRICT_OP_WRITES;
1377 } else if ( strcasecmp( cargv[ i ], "add" ) == 0 ) {
1378 restrict |= SLAP_RESTRICT_OP_ADD;
1380 } else if ( strcasecmp( cargv[ i ], "bind" ) == 0 ) {
1381 restrict |= SLAP_RESTRICT_OP_BIND;
1383 } else if ( strcasecmp( cargv[ i ], "compare" ) == 0 ) {
1384 restrict |= SLAP_RESTRICT_OP_COMPARE;
1386 } else if ( strcasecmp( cargv[ i ], "delete" ) == 0 ) {
1387 restrict |= SLAP_RESTRICT_OP_DELETE;
1389 } else if ( strncasecmp( cargv[ i ], "extended",
1390 STRLENOF( "extended" ) ) == 0 ) {
1391 char *e = cargv[ i ] + STRLENOF( "extended" );
1393 if ( e[0] == '=' ) {
1397 for ( j = 0; restrictable_exops[ j ].name; j++ ) {
1398 if ( strcmp( e, restrictable_exops[ j ].name ) == 0 ) {
1399 restrict |= restrictable_exops[ j ].flag;
1404 if ( restrictable_exops[ j ].name == NULL ) {
1405 goto restrict_unknown;
1408 restrict &= ~SLAP_RESTRICT_OP_EXTENDED;
1410 } else if ( e[0] == '\0' ) {
1411 restrict &= ~SLAP_RESTRICT_EXOP_MASK;
1412 restrict |= SLAP_RESTRICT_OP_EXTENDED;
1415 goto restrict_unknown;
1418 } else if ( strcasecmp( cargv[ i ], "modify" ) == 0 ) {
1419 restrict |= SLAP_RESTRICT_OP_MODIFY;
1421 } else if ( strcasecmp( cargv[ i ], "rename" ) == 0
1422 || strcasecmp( cargv[ i ], "modrdn" ) == 0 ) {
1423 restrict |= SLAP_RESTRICT_OP_RENAME;
1425 } else if ( strcasecmp( cargv[ i ], "search" ) == 0 ) {
1426 restrict |= SLAP_RESTRICT_OP_SEARCH;
1432 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1433 "unknown operation %s in \"allow <features>\" line.\n",
1434 fname, lineno, cargv[i] );
1436 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1437 "unknown operation %s in \"allow <features>\" line\n",
1438 fname, lineno, cargv[i] );
1445 global_restrictops |= restrict;
1448 be->be_restrictops |= restrict;
1451 /* allow these features */
1452 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1453 strcasecmp( cargv[0], "allow" ) == 0 )
1459 LDAP_LOG( CONFIG, INFO,
1460 "%s: line %d: allow line must appear prior to "
1461 "database definitions.\n", fname, lineno ,0 );
1463 Debug( LDAP_DEBUG_ANY,
1464 "%s: line %d: allow line must appear prior to database definitions\n",
1472 LDAP_LOG( CONFIG, CRIT,
1473 "%s: line %d: missing feature(s) in \"allow <features>\""
1474 " line\n", fname, lineno ,0 );
1476 Debug( LDAP_DEBUG_ANY,
1477 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1486 for( i=1; i < cargc; i++ ) {
1487 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1488 allows |= SLAP_ALLOW_BIND_V2;
1490 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1491 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1493 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1494 allows |= SLAP_ALLOW_BIND_ANON_DN;
1496 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1497 allows |= SLAP_ALLOW_UPDATE_ANON;
1499 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1501 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1502 "unknown feature %s in \"allow <features>\" line.\n",
1503 fname, lineno, cargv[i] );
1505 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1506 "unknown feature %s in \"allow <features>\" line\n",
1507 fname, lineno, cargv[i] );
1514 global_allows = allows;
1516 /* disallow these features */
1517 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1518 strcasecmp( cargv[0], "disallow" ) == 0 )
1520 slap_mask_t disallows;
1524 LDAP_LOG( CONFIG, INFO,
1525 "%s: line %d: disallow line must appear prior to "
1526 "database definitions.\n", fname, lineno ,0 );
1528 Debug( LDAP_DEBUG_ANY,
1529 "%s: line %d: disallow line must appear prior to database definitions\n",
1537 LDAP_LOG( CONFIG, CRIT,
1538 "%s: line %d: missing feature(s) in \"disallow <features>\""
1539 " line.\n", fname, lineno ,0 );
1541 Debug( LDAP_DEBUG_ANY,
1542 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1551 for( i=1; i < cargc; i++ ) {
1552 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1553 disallows |= SLAP_DISALLOW_BIND_ANON;
1555 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1556 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1558 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1559 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1561 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1562 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1564 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1565 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1567 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1569 LDAP_LOG( CONFIG, CRIT,
1570 "%s: line %d: unknown feature %s in "
1571 "\"disallow <features>\" line.\n",
1572 fname, lineno, cargv[i] );
1574 Debug( LDAP_DEBUG_ANY,
1575 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1576 fname, lineno, cargv[i] );
1583 global_disallows = disallows;
1585 /* require these features */
1586 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1587 strcasecmp( cargv[0], "require" ) == 0 )
1589 slap_mask_t requires;
1593 LDAP_LOG( CONFIG, CRIT,
1594 "%s: line %d: missing feature(s) in "
1595 "\"require <features>\" line.\n", fname, lineno ,0 );
1597 Debug( LDAP_DEBUG_ANY,
1598 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1607 for( i=1; i < cargc; i++ ) {
1608 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1609 requires |= SLAP_REQUIRE_BIND;
1611 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1612 requires |= SLAP_REQUIRE_LDAP_V3;
1614 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1615 requires |= SLAP_REQUIRE_AUTHC;
1617 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1618 requires |= SLAP_REQUIRE_SASL;
1620 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1621 requires |= SLAP_REQUIRE_STRONG;
1623 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1625 LDAP_LOG( CONFIG, CRIT,
1626 "%s: line %d: unknown feature %s in "
1627 "\"require <features>\" line.\n",
1628 fname, lineno , cargv[i] );
1630 Debug( LDAP_DEBUG_ANY,
1631 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1632 fname, lineno, cargv[i] );
1640 global_requires = requires;
1642 be->be_requires = requires;
1645 /* required security factors */
1646 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1647 slap_ssf_set_t *set;
1651 LDAP_LOG( CONFIG, CRIT,
1652 "%s: line %d: missing factor(s) in \"security <factors>\""
1653 " line.\n", fname, lineno ,0 );
1655 Debug( LDAP_DEBUG_ANY,
1656 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1664 set = &global_ssf_set;
1666 set = &be->be_ssf_set;
1669 for( i=1; i < cargc; i++ ) {
1673 if ( strncasecmp( cargv[i], "ssf=",
1674 STRLENOF("ssf=") ) == 0 )
1676 tgt = &set->sss_ssf;
1677 src = &cargv[i][STRLENOF("ssf=")];
1679 } else if ( strncasecmp( cargv[i], "transport=",
1680 STRLENOF("transport=") ) == 0 )
1682 tgt = &set->sss_transport;
1683 src = &cargv[i][STRLENOF("transport=")];
1685 } else if ( strncasecmp( cargv[i], "tls=",
1686 STRLENOF("tls=") ) == 0 )
1688 tgt = &set->sss_tls;
1689 src = &cargv[i][STRLENOF("tls=")];
1691 } else if ( strncasecmp( cargv[i], "sasl=",
1692 STRLENOF("sasl=") ) == 0 )
1694 tgt = &set->sss_sasl;
1695 src = &cargv[i][STRLENOF("sasl=")];
1697 } else if ( strncasecmp( cargv[i], "update_ssf=",
1698 STRLENOF("update_ssf=") ) == 0 )
1700 tgt = &set->sss_update_ssf;
1701 src = &cargv[i][STRLENOF("update_ssf=")];
1703 } else if ( strncasecmp( cargv[i], "update_transport=",
1704 STRLENOF("update_transport=") ) == 0 )
1706 tgt = &set->sss_update_transport;
1707 src = &cargv[i][STRLENOF("update_transport=")];
1709 } else if ( strncasecmp( cargv[i], "update_tls=",
1710 STRLENOF("update_tls=") ) == 0 )
1712 tgt = &set->sss_update_tls;
1713 src = &cargv[i][STRLENOF("update_tls=")];
1715 } else if ( strncasecmp( cargv[i], "update_sasl=",
1716 STRLENOF("update_sasl=") ) == 0 )
1718 tgt = &set->sss_update_sasl;
1719 src = &cargv[i][STRLENOF("update_sasl=")];
1721 } else if ( strncasecmp( cargv[i], "simple_bind=",
1722 STRLENOF("simple_bind=") ) == 0 )
1724 tgt = &set->sss_simple_bind;
1725 src = &cargv[i][STRLENOF("simple_bind=")];
1729 LDAP_LOG( CONFIG, CRIT,
1730 "%s: line %d: unknown factor %s in "
1731 "\"security <factors>\" line.\n",
1732 fname, lineno, cargv[1] );
1734 Debug( LDAP_DEBUG_ANY,
1735 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1736 fname, lineno, cargv[i] );
1742 *tgt = strtol( src, &next, 10 );
1743 if ( next == NULL || next[0] != '\0' ) {
1745 LDAP_LOG( CONFIG, CRIT,
1746 "%s: line %d: unable to parse factor \"%s\" in "
1747 "\"security <factors>\" line.\n",
1748 fname, lineno, cargv[1] );
1750 Debug( LDAP_DEBUG_ANY,
1751 "%s: line %d: unable to parse factor \"%s\" in \"security <factors>\" line\n",
1752 fname, lineno, cargv[i] );
1759 /* where to send clients when we don't hold it */
1760 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1763 LDAP_LOG( CONFIG, CRIT,
1764 "%s: line %d: missing URL in \"referral <URL>\""
1765 " line.\n", fname, lineno , 0 );
1767 Debug( LDAP_DEBUG_ANY,
1768 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1775 if( validate_global_referral( cargv[1] ) ) {
1777 LDAP_LOG( CONFIG, CRIT,
1778 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1779 fname, lineno, cargv[1] );
1781 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1782 "invalid URL (%s) in \"referral\" line.\n",
1783 fname, lineno, cargv[1] );
1788 vals[0].bv_val = cargv[1];
1789 vals[0].bv_len = strlen( vals[0].bv_val );
1790 if( value_add( &default_referral, vals ) )
1794 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1798 LDAP_LOG( CONFIG, CRIT,
1799 "%s: line %d: Error in logfile directive, "
1800 "\"logfile <filename>\"\n", fname, lineno , 0 );
1802 Debug( LDAP_DEBUG_ANY,
1803 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1809 logfile = fopen( cargv[1], "w" );
1810 if ( logfile != NULL ) lutil_debug_file( logfile );
1813 /* start of a new database definition */
1814 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1818 LDAP_LOG( CONFIG, CRIT,
1819 "%s: line %d: Error in debug directive, "
1820 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1822 Debug( LDAP_DEBUG_ANY,
1823 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1828 level = strtol( cargv[2], &next, 10 );
1829 if ( next == NULL || next[0] != '\0' ){
1831 LDAP_LOG( CONFIG, CRIT,
1832 "%s: line %d: unable to parse level \"%s\" in debug directive, "
1833 "\"debug <subsys> <level>\"\n", fname, lineno , cargv[2] );
1835 Debug( LDAP_DEBUG_ANY,
1836 "%s: line %d: unable to parse level \"%s\" in debug directive, "
1837 "\"debug <subsys> <level>\"\n", fname, lineno , cargv[2] );
1842 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1843 lutil_set_debug_level( cargv[1], level );
1844 /* specify an Object Identifier macro */
1845 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1846 rc = parse_oidm( fname, lineno, cargc, cargv );
1849 /* specify an objectclass */
1850 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1853 LDAP_LOG( CONFIG, INFO,
1854 "%s: line %d: illegal objectclass format.\n",
1855 fname, lineno , 0 );
1857 Debug( LDAP_DEBUG_ANY,
1858 "%s: line %d: illegal objectclass format.\n",
1863 } else if ( *cargv[1] == '(' /*')'*/) {
1865 p = strchr(saveline,'(' /*')'*/);
1866 rc = parse_oc( fname, lineno, p, cargv );
1871 LDAP_LOG( CONFIG, INFO,
1872 "%s: line %d: old objectclass format not supported\n",
1873 fname, lineno , 0 );
1875 Debug( LDAP_DEBUG_ANY,
1876 "%s: line %d: old objectclass format not supported.\n",
1881 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1883 p = strchr(saveline,'(' /*')'*/);
1884 rc = parse_cr( fname, lineno, p, cargv );
1887 /* specify an attribute type */
1888 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1889 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1893 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1894 "illegal attribute type format.\n",
1895 fname, lineno , 0 );
1897 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1898 "illegal attribute type format.\n",
1903 } else if ( *cargv[1] == '(' /*')'*/) {
1905 p = strchr(saveline,'(' /*')'*/);
1906 rc = parse_at( fname, lineno, p, cargv );
1911 LDAP_LOG( CONFIG, INFO,
1912 "%s: line %d: old attribute type format not supported.\n",
1913 fname, lineno , 0 );
1915 Debug( LDAP_DEBUG_ANY,
1916 "%s: line %d: old attribute type format not supported.\n",
1922 /* define attribute option(s) */
1923 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1924 ad_define_option( NULL, NULL, 0 );
1925 for ( i = 1; i < cargc; i++ )
1926 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1929 /* turn on/off schema checking */
1930 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1933 LDAP_LOG( CONFIG, CRIT,
1934 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1935 " line.\n", fname, lineno , 0 );
1937 Debug( LDAP_DEBUG_ANY,
1938 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1944 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1946 LDAP_LOG( CONFIG, CRIT,
1947 "%s: line %d: schema checking disabled! your mileage may "
1948 "vary!\n", fname, lineno , 0 );
1950 Debug( LDAP_DEBUG_ANY,
1951 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1954 global_schemacheck = 0;
1956 global_schemacheck = 1;
1959 /* specify access control info */
1960 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1961 parse_acl( be, fname, lineno, cargc, cargv );
1963 /* debug level to log things to syslog */
1964 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1967 LDAP_LOG( CONFIG, CRIT,
1968 "%s: line %d: missing level(s) in \"loglevel <level> [...]\""
1969 " line.\n", fname, lineno , 0 );
1971 Debug( LDAP_DEBUG_ANY,
1972 "%s: line %d: missing level(s) in \"loglevel <level> [...]\" line\n",
1981 for( i=1; i < cargc; i++ ) {
1982 int level = strtol( cargv[i], &next, 10 );
1983 if ( next == NULL || next[0] != '\0' ) {
1985 LDAP_LOG( CONFIG, CRIT,
1986 "%s: line %d: unable to parse level \"%s\" in \"loglevel <level> [...]\""
1987 " line.\n", fname, lineno , cargv[i] );
1989 Debug( LDAP_DEBUG_ANY,
1990 "%s: line %d: unable to parse level \"%s\" in \"loglevel <level> [...]\""
1991 " line.\n", fname, lineno , cargv[i] );
1996 ldap_syslog |= level;
1999 /* list of sync replication information in this backend (slave only) */
2000 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
2004 LDAP_LOG( CONFIG, INFO,
2005 "%s: line %d: syncrepl line must appear inside "
2006 "a database definition.\n", fname, lineno, 0);
2008 Debug( LDAP_DEBUG_ANY,
2009 "%s: line %d: syncrepl line must appear inside "
2010 "a database definition.\n", fname, lineno, 0);
2014 } else if ( SLAP_SHADOW( be )) {
2016 LDAP_LOG( CONFIG, INFO,
2017 "%s: line %d: syncrepl: database already shadowed.\n",
2020 Debug( LDAP_DEBUG_ANY,
2021 "%s: line %d: syncrepl: database already shadowed.\n",
2026 } else if ( add_syncrepl( be, cargv, cargc )) {
2030 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW );
2032 /* list of replicas of the data in this backend (master only) */
2033 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
2036 LDAP_LOG( CONFIG, CRIT,
2037 "%s: line %d: missing host or uri in \"replica "
2038 " <host[:port]\" line\n", fname, lineno , 0 );
2040 Debug( LDAP_DEBUG_ANY,
2041 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
2049 LDAP_LOG( CONFIG, INFO,
2050 "%s: line %d: replica line must appear inside "
2051 "a database definition.\n", fname, lineno, 0);
2053 Debug( LDAP_DEBUG_ANY,
2054 "%s: line %d: replica line must appear inside a database definition\n",
2062 for ( i = 1; i < cargc; i++ ) {
2063 if ( strncasecmp( cargv[i], "host=", 5 )
2065 nr = add_replica_info( be,
2068 } else if (strncasecmp( cargv[i], "uri=", 4 )
2070 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
2073 LDAP_LOG( CONFIG, INFO,
2074 "%s: line %d: replica line contains invalid "
2075 "uri definition.\n", fname, lineno, 0);
2077 Debug( LDAP_DEBUG_ANY,
2078 "%s: line %d: replica line contains invalid "
2079 "uri definition.\n", fname, lineno, 0);
2083 if (ludp->lud_host == NULL ) {
2085 LDAP_LOG( CONFIG, INFO,
2086 "%s: line %d: replica line contains invalid "
2087 "uri definition - missing hostname.\n",
2090 Debug( LDAP_DEBUG_ANY,
2091 "%s: line %d: replica line contains invalid "
2092 "uri definition - missing hostname.\n", fname, lineno, 0);
2096 replicahost = ch_malloc( strlen( cargv[ i ] ) );
2097 if ( replicahost == NULL ) {
2099 LDAP_LOG( CONFIG, ERR,
2100 "out of memory in read_config\n", 0, 0,0 );
2102 Debug( LDAP_DEBUG_ANY,
2103 "out of memory in read_config\n", 0, 0, 0 );
2105 ldap_free_urldesc( ludp );
2106 exit( EXIT_FAILURE );
2108 sprintf(replicahost, "%s:%d",
2109 ludp->lud_host, ludp->lud_port);
2110 nr = add_replica_info( be, replicahost );
2111 ldap_free_urldesc( ludp );
2112 ch_free(replicahost);
2118 LDAP_LOG( CONFIG, INFO,
2119 "%s: line %d: missing host or uri in \"replica\" line\n",
2120 fname, lineno , 0 );
2122 Debug( LDAP_DEBUG_ANY,
2123 "%s: line %d: missing host or uri in \"replica\" line\n",
2128 } else if ( nr == -1 ) {
2130 LDAP_LOG( CONFIG, INFO,
2131 "%s: line %d: unable to add"
2132 " replica \"%s\"\n",
2136 Debug( LDAP_DEBUG_ANY,
2137 "%s: line %d: unable to add replica \"%s\"\n",
2138 fname, lineno, cargv[i] + 5 );
2142 for ( i = 1; i < cargc; i++ ) {
2143 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
2145 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
2148 LDAP_LOG( CONFIG, INFO,
2149 "%s: line %d: suffix \"%s\" in \"replica\""
2150 " line is not valid for backend(ignored)\n",
2151 fname, lineno, cargv[i] + 7 );
2153 Debug( LDAP_DEBUG_ANY,
2154 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
2155 fname, lineno, cargv[i] + 7 );
2161 LDAP_LOG( CONFIG, INFO,
2162 "%s: line %d: unable to normalize suffix"
2163 " in \"replica\" line (ignored)\n",
2164 fname, lineno , 0 );
2166 Debug( LDAP_DEBUG_ANY,
2167 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
2173 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
2175 char *arg = cargv[i] + 4;
2177 if ( arg[0] == '!' ) {
2182 if ( arg[0] != '=' ) {
2186 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
2188 LDAP_LOG( CONFIG, INFO,
2189 "%s: line %d: attribute \"%s\" in "
2190 "\"replica\" line is unknown\n",
2191 fname, lineno, arg + 1 );
2193 Debug( LDAP_DEBUG_ANY,
2194 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
2195 fname, lineno, arg + 1 );
2204 } else if ( strcasecmp( cargv[0], "replicationInterval" ) == 0 ) {
2207 /* dn of slave entity allowed to write to replica */
2208 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
2211 LDAP_LOG( CONFIG, CRIT,
2212 "%s: line %d: missing dn in \"updatedn <dn>\""
2213 " line.\n", fname, lineno , 0 );
2215 Debug( LDAP_DEBUG_ANY,
2216 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
2224 LDAP_LOG( CONFIG, INFO,
2225 "%s: line %d: updatedn line must appear inside "
2226 "a database definition\n",
2227 fname, lineno , 0 );
2229 Debug( LDAP_DEBUG_ANY,
2230 "%s: line %d: updatedn line must appear inside a database definition\n",
2235 } else if ( SLAP_SHADOW(be) ) {
2237 LDAP_LOG( CONFIG, INFO,
2238 "%s: line %d: updatedn: database already shadowed.\n",
2241 Debug( LDAP_DEBUG_ANY,
2242 "%s: line %d: updatedn: database already shadowed.\n",
2250 if ( load_ucdata( NULL ) < 0 ) return 1;
2252 dn.bv_val = cargv[1];
2253 dn.bv_len = strlen( cargv[1] );
2255 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
2256 if( rc != LDAP_SUCCESS ) {
2258 LDAP_LOG( CONFIG, CRIT,
2259 "%s: line %d: updatedn DN is invalid.\n",
2260 fname, lineno , 0 );
2262 Debug( LDAP_DEBUG_ANY,
2263 "%s: line %d: updatedn DN is invalid\n",
2270 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW );
2272 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
2275 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2276 "missing url in \"updateref <ldapurl>\" line.\n",
2277 fname, lineno , 0 );
2279 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2280 "missing url in \"updateref <ldapurl>\" line\n",
2288 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2289 " line must appear inside a database definition\n",
2290 fname, lineno , 0 );
2292 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2293 " line must appear inside a database definition\n",
2298 } else if ( !SLAP_SHADOW(be) ) {
2300 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2301 "updateref line must come after syncrepl or updatedn.\n",
2302 fname, lineno , 0 );
2304 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2305 "updateref line must after syncrepl or updatedn.\n",
2311 if( validate_global_referral( cargv[1] ) ) {
2313 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2314 "invalid URL (%s) in \"updateref\" line.\n",
2315 fname, lineno, cargv[1] );
2317 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2318 "invalid URL (%s) in \"updateref\" line.\n",
2319 fname, lineno, cargv[1] );
2324 vals[0].bv_val = cargv[1];
2325 vals[0].bv_len = strlen( vals[0].bv_val );
2326 if( value_add( &be->be_update_refs, vals ) ) {
2330 /* replication log file to which changes are appended */
2331 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2334 LDAP_LOG( CONFIG, CRIT,
2335 "%s: line %d: missing filename in \"replogfile <filename>\""
2336 " line.\n", fname, lineno , 0 );
2338 Debug( LDAP_DEBUG_ANY,
2339 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2346 be->be_replogfile = ch_strdup( cargv[1] );
2348 replogfile = ch_strdup( cargv[1] );
2351 /* file from which to read additional rootdse attrs */
2352 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2355 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2356 "missing filename in \"rootDSE <filename>\" line.\n",
2357 fname, lineno , 0 );
2359 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2360 "missing filename in \"rootDSE <filename>\" line.\n",
2366 if( read_root_dse_file( cargv[1] ) ) {
2368 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2369 "could not read \"rootDSE <filename>\" line.\n",
2370 fname, lineno , 0 );
2372 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2373 "could not read \"rootDSE <filename>\" line\n",
2379 /* maintain lastmodified{by,time} attributes */
2380 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2383 LDAP_LOG( CONFIG, CRIT,
2384 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2385 " line.\n", fname, lineno , 0 );
2387 Debug( LDAP_DEBUG_ANY,
2388 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2397 LDAP_LOG( CONFIG, INFO, "%s: line %d: lastmod"
2398 " line must appear inside a database definition\n",
2399 fname, lineno , 0 );
2401 Debug( LDAP_DEBUG_ANY, "%s: line %d: lastmod"
2402 " line must appear inside a database definition\n",
2407 } else if ( SLAP_NOLASTMODCMD(be) ) {
2409 LDAP_LOG( CONFIG, INFO, "%s: line %d: lastmod"
2410 " not available for %s database\n",
2411 fname, lineno , be->bd_info->bi_type );
2413 Debug( LDAP_DEBUG_ANY, "%s: line %d: lastmod"
2414 " not available for %s databases\n",
2415 fname, lineno, be->bd_info->bi_type );
2420 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2421 SLAP_DBFLAGS(be) &= ~SLAP_DBFLAG_NOLASTMOD;
2423 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD;
2427 /* turn on/off gentle SIGHUP handling */
2428 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2430 Debug( LDAP_DEBUG_ANY,
2431 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2435 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2436 global_gentlehup = 0;
2438 global_gentlehup = 1;
2442 /* set idle timeout value */
2443 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2447 LDAP_LOG( CONFIG, CRIT,
2448 "%s: line %d: missing timeout value in "
2449 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2451 Debug( LDAP_DEBUG_ANY,
2452 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2459 i = atoi( cargv[1] );
2463 LDAP_LOG( CONFIG, CRIT,
2464 "%s: line %d: timeout value (%d) invalid "
2465 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2467 Debug( LDAP_DEBUG_ANY,
2468 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2475 global_idletimeout = i;
2477 /* include another config file */
2478 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2481 LDAP_LOG( CONFIG, CRIT,
2482 "%s: line %d: missing filename in \"include "
2483 "<filename>\" line.\n", fname, lineno , 0 );
2485 Debug( LDAP_DEBUG_ANY,
2486 "%s: line %d: missing filename in \"include <filename>\" line\n",
2492 savefname = ch_strdup( cargv[1] );
2493 savelineno = lineno;
2495 if ( read_config( savefname, depth+1 ) != 0 ) {
2500 lineno = savelineno - 1;
2502 /* location of kerberos srvtab file */
2503 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2506 LDAP_LOG( CONFIG, CRIT,
2507 "%s: line %d: missing filename in \"srvtab "
2508 "<filename>\" line.\n", fname, lineno , 0 );
2510 Debug( LDAP_DEBUG_ANY,
2511 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2517 ldap_srvtab = ch_strdup( cargv[1] );
2519 #ifdef SLAPD_MODULES
2520 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2523 LDAP_LOG( CONFIG, INFO,
2524 "%s: line %d: missing filename in \"moduleload "
2525 "<filename>\" line.\n", fname, lineno , 0 );
2527 Debug( LDAP_DEBUG_ANY,
2528 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2532 exit( EXIT_FAILURE );
2534 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2536 LDAP_LOG( CONFIG, CRIT,
2537 "%s: line %d: failed to load or initialize module %s\n",
2538 fname, lineno, cargv[1] );
2540 Debug( LDAP_DEBUG_ANY,
2541 "%s: line %d: failed to load or initialize module %s\n",
2542 fname, lineno, cargv[1]);
2545 exit( EXIT_FAILURE );
2547 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2550 LDAP_LOG( CONFIG, INFO,
2551 "%s: line %d: missing path in \"modulepath <path>\""
2552 " line\n", fname, lineno , 0 );
2554 Debug( LDAP_DEBUG_ANY,
2555 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2559 exit( EXIT_FAILURE );
2561 if (module_path( cargv[1] )) {
2563 LDAP_LOG( CONFIG, CRIT,
2564 "%s: line %d: failed to set module search path to %s.\n",
2565 fname, lineno, cargv[1] );
2567 Debug( LDAP_DEBUG_ANY,
2568 "%s: line %d: failed to set module search path to %s\n",
2569 fname, lineno, cargv[1]);
2572 exit( EXIT_FAILURE );
2575 #endif /*SLAPD_MODULES*/
2578 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2579 rc = ldap_pvt_tls_set_option( NULL,
2580 LDAP_OPT_X_TLS_RANDOM_FILE,
2585 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2586 rc = ldap_pvt_tls_set_option( NULL,
2587 LDAP_OPT_X_TLS_CIPHER_SUITE,
2592 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2593 rc = ldap_pvt_tls_set_option( NULL,
2594 LDAP_OPT_X_TLS_CERTFILE,
2599 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2600 rc = ldap_pvt_tls_set_option( NULL,
2601 LDAP_OPT_X_TLS_KEYFILE,
2606 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2607 rc = ldap_pvt_tls_set_option( NULL,
2608 LDAP_OPT_X_TLS_CACERTDIR,
2613 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2614 rc = ldap_pvt_tls_set_option( NULL,
2615 LDAP_OPT_X_TLS_CACERTFILE,
2619 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2620 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2622 rc = ldap_pvt_tls_set_option( NULL,
2623 LDAP_OPT_X_TLS_REQUIRE_CERT,
2626 rc = ldap_int_tls_config( NULL,
2627 LDAP_OPT_X_TLS_REQUIRE_CERT,
2636 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2637 #ifdef SLAPD_RLOOKUPS
2640 LDAP_LOG( CONFIG, INFO,
2641 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2642 fname, lineno , 0 );
2644 Debug( LDAP_DEBUG_ANY,
2645 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2651 if ( !strcasecmp( cargv[1], "on" ) ) {
2652 use_reverse_lookup = 1;
2653 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2654 use_reverse_lookup = 0;
2657 LDAP_LOG( CONFIG, INFO,
2658 "%s: line %d: reverse-lookup: "
2659 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2661 Debug( LDAP_DEBUG_ANY,
2662 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2668 #else /* !SLAPD_RLOOKUPS */
2670 LDAP_LOG( CONFIG, INFO,
2671 "%s: line %d: reverse lookups "
2672 "are not configured (ignored).\n", fname, lineno , 0 );
2674 Debug( LDAP_DEBUG_ANY,
2675 "%s: line %d: reverse lookups are not configured (ignored).\n",
2678 #endif /* !SLAPD_RLOOKUPS */
2680 /* Netscape plugins */
2681 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2682 #if defined( LDAP_SLAPI )
2684 #ifdef notdef /* allow global plugins, too */
2686 * a "plugin" line must be inside a database
2687 * definition, since we implement pre-,post-
2688 * and extended operation plugins
2692 LDAP_LOG( CONFIG, INFO,
2693 "%s: line %d: plugin line must appear "
2694 "insid a database definition.\n",
2697 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2698 "line must appear inside a database "
2699 "definition\n", fname, lineno, 0 );
2705 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
2709 LDAP_LOG( CONFIG, INFO,
2710 "%s: line %d: SLAPI config read failed.\n",
2713 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2714 "config read failed.\n", fname, lineno, 0 );
2718 slapi_plugins_used++;
2720 #else /* !defined( LDAP_SLAPI ) */
2722 LDAP_LOG( CONFIG, INFO,
2723 "%s: line %d: SLAPI not supported.\n",
2726 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2727 "not supported.\n", fname, lineno, 0 );
2731 #endif /* !defined( LDAP_SLAPI ) */
2733 /* Netscape plugins */
2734 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2735 #if defined( LDAP_SLAPI )
2738 LDAP_LOG( CONFIG, INFO,
2739 "%s: line %d: missing file name "
2740 "in pluginlog <filename> line.\n",
2743 Debug( LDAP_DEBUG_ANY,
2744 "%s: line %d: missing file name "
2745 "in pluginlog <filename> line.\n",
2751 if ( slapi_log_file != NULL ) {
2752 ch_free( slapi_log_file );
2755 slapi_log_file = ch_strdup( cargv[1] );
2756 #endif /* !defined( LDAP_SLAPI ) */
2758 /* pass anything else to the current backend info/db config routine */
2761 if ( bi->bi_config ) {
2762 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
2768 case SLAP_CONF_UNKNOWN:
2770 LDAP_LOG( CONFIG, INFO,
2771 "%s: line %d: unknown directive \"%s\" inside "
2772 "backend info definition (ignored).\n",
2773 fname, lineno, cargv[0] );
2775 Debug( LDAP_DEBUG_ANY,
2776 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2777 fname, lineno, cargv[0] );
2786 } else if ( be != NULL ) {
2787 if ( be->be_config ) {
2788 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
2794 case SLAP_CONF_UNKNOWN:
2796 LDAP_LOG( CONFIG, INFO,
2797 "%s: line %d: unknown directive \"%s\" inside "
2798 "backend database definition (ignored).\n",
2799 fname, lineno, cargv[0] );
2801 Debug( LDAP_DEBUG_ANY,
2802 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2803 fname, lineno, cargv[0] );
2814 LDAP_LOG( CONFIG, INFO,
2815 "%s: line %d: unknown directive \"%s\" outside backend "
2816 "info and database definitions (ignored).\n",
2817 fname, lineno, cargv[0] );
2819 Debug( LDAP_DEBUG_ANY,
2820 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2821 fname, lineno, cargv[0] );
2830 if ( depth == 0 ) ch_free( cargv );
2832 if ( !global_schemadn.bv_val ) {
2833 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2835 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2838 if ( load_ucdata( NULL ) < 0 ) return 1;
2850 char logbuf[sizeof("pseudorootpw ***")];
2853 token = strtok_quote( line, " \t" );
2857 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2858 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2859 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2860 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2861 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2863 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2866 if ( strtok_quote_ptr ) {
2867 *strtok_quote_ptr = ' ';
2871 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2873 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2876 if ( strtok_quote_ptr ) {
2877 *strtok_quote_ptr = '\0';
2880 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2881 if ( cargc == cargv_size - 1 ) {
2883 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2885 if ( tmp == NULL ) {
2887 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2889 Debug( LDAP_DEBUG_ANY,
2890 "line %d: out of memory\n",
2896 cargv_size += ARGS_STEP;
2898 cargv[cargc++] = token;
2900 cargv[cargc] = NULL;
2905 strtok_quote( char *line, char *sep )
2911 strtok_quote_ptr = NULL;
2912 if ( line != NULL ) {
2915 while ( *next && strchr( sep, *next ) ) {
2919 if ( *next == '\0' ) {
2925 for ( inquote = 0; *next; ) {
2933 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2939 next + 1, strlen( next + 1 ) + 1 );
2940 next++; /* dont parse the escaped character */
2945 if ( strchr( sep, *next ) != NULL ) {
2946 strtok_quote_ptr = next;
2959 static char buf[BUFSIZ];
2961 static size_t lmax, lcur;
2963 #define CATLINE( buf ) \
2965 size_t len = strlen( buf ); \
2966 while ( lcur + len + 1 > lmax ) { \
2968 line = (char *) ch_realloc( line, lmax ); \
2970 strcpy( line + lcur, buf ); \
2975 fp_getline( FILE *fp, int *lineno )
2983 /* hack attack - keeps us from having to keep a stack of bufs... */
2984 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2989 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2990 /* trim off \r\n or \n */
2991 if ( (p = strchr( buf, '\n' )) != NULL ) {
2992 if( p > buf && p[-1] == '\r' ) --p;
2996 /* trim off trailing \ and append the next line */
2997 if ( line[ 0 ] != '\0'
2998 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2999 && p[ -1 ] != '\\' ) {
3004 if ( ! isspace( (unsigned char) buf[0] ) ) {
3008 /* change leading whitespace to a space */
3017 return( line[0] ? line : NULL );
3021 fp_getline_init( int *lineno )
3027 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
3029 load_ucdata( char *path )
3032 static int loaded = 0;
3038 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
3041 LDAP_LOG( CONFIG, CRIT,
3042 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
3044 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
3053 /* ucdata is now hardcoded */
3061 ucdata_unload( UCDATA_ALL );
3062 free( global_schemandn.bv_val );
3063 free( global_schemadn.bv_val );
3065 if ( slapd_args_file )
3066 free ( slapd_args_file );
3067 if ( slapd_pid_file )
3068 free ( slapd_pid_file );
3069 if ( default_passwd_hash )
3070 ldap_charray_free( default_passwd_hash );
3071 acl_destroy( global_acl, NULL );
3082 syncinfo_t *si_entry;
3084 int duplicated_replica_id = 0;
3086 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
3090 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
3092 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
3097 si->si_tls = SYNCINFO_TLS_OFF;
3098 if ( be->be_rootndn.bv_val ) {
3099 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
3101 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3102 si->si_schemachecking = 0;
3103 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 0,
3104 &si->si_filterstr );
3105 si->si_base.bv_val = NULL;
3106 si->si_scope = LDAP_SCOPE_SUBTREE;
3107 si->si_attrsonly = 0;
3108 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
3109 si->si_attrs[0] = NULL;
3110 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3111 si->si_interval = 86400;
3112 si->si_retryinterval = 0;
3113 si->si_retrynum_init = 0;
3114 si->si_retrynum = 0;
3115 si->si_syncCookie.ctxcsn = NULL;
3116 si->si_syncCookie.octet_str = NULL;
3117 si->si_syncCookie.sid = -1;
3118 si->si_manageDSAit = 0;
3121 si->si_syncUUID_ndn.bv_val = NULL;
3122 si->si_syncUUID_ndn.bv_len = 0;
3124 si->si_presentlist = NULL;
3125 LDAP_LIST_INIT( &si->si_nonpresentlist );
3127 rc = parse_syncrepl_line( cargv, cargc, si );
3129 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
3130 if ( si->si_rid == si_entry->si_rid ) {
3132 LDAP_LOG( CONFIG, ERR,
3133 "add_syncrepl: duplicated replica id\n", 0, 0,0 );
3135 Debug( LDAP_DEBUG_ANY,
3136 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
3138 duplicated_replica_id = 1;
3143 if ( rc < 0 || duplicated_replica_id ) {
3144 syncinfo_t *si_entry;
3145 /* Something bad happened - back out */
3147 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
3149 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
3152 /* If error, remove all syncinfo */
3153 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
3154 if ( si_entry->si_updatedn.bv_val ) {
3155 ch_free( si->si_updatedn.bv_val );
3157 if ( si_entry->si_filterstr.bv_val ) {
3158 ch_free( si->si_filterstr.bv_val );
3160 if ( si_entry->si_attrs ) {
3162 while ( si_entry->si_attrs[i] != NULL ) {
3163 ch_free( si_entry->si_attrs[i] );
3166 ch_free( si_entry->si_attrs );
3170 while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
3171 si_entry = LDAP_STAILQ_FIRST( &be->be_syncinfo );
3172 LDAP_STAILQ_REMOVE_HEAD( &be->be_syncinfo, si_next );
3173 ch_free( si_entry );
3175 LDAP_STAILQ_INIT( &be->be_syncinfo );
3179 LDAP_LOG ( CONFIG, RESULTS,
3180 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
3181 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
3183 Debug( LDAP_DEBUG_CONFIG,
3184 "Config: ** successfully added syncrepl \"%s\"\n",
3185 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
3187 if ( !si->si_schemachecking ) {
3188 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
3191 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
3197 #define PROVIDERSTR "provider"
3198 #define SUFFIXSTR "suffix"
3199 #define UPDATEDNSTR "updatedn"
3200 #define BINDMETHSTR "bindmethod"
3201 #define SIMPLESTR "simple"
3202 #define SASLSTR "sasl"
3203 #define BINDDNSTR "binddn"
3204 #define CREDSTR "credentials"
3205 #define OLDAUTHCSTR "bindprincipal"
3206 #define AUTHCSTR "authcID"
3207 #define AUTHZSTR "authzID"
3208 #define SRVTABSTR "srvtab"
3209 #define SASLMECHSTR "saslmech"
3210 #define REALMSTR "realm"
3211 #define SECPROPSSTR "secprops"
3212 #define STARTTLSSTR "starttls"
3213 #define CRITICALSTR "critical"
3215 #define SCHEMASTR "schemachecking"
3216 #define FILTERSTR "filter"
3217 #define SEARCHBASESTR "searchbase"
3218 #define SCOPESTR "scope"
3219 #define ATTRSSTR "attrs"
3220 #define ATTRSONLYSTR "attrsonly"
3221 #define TYPESTR "type"
3222 #define INTERVALSTR "interval"
3223 #define LASTMODSTR "lastmod"
3224 #define LMREQSTR "req"
3225 #define LMGENSTR "gen"
3226 #define LMNOSTR "no"
3227 #define MANAGEDSAITSTR "manageDSAit"
3228 #define SLIMITSTR "sizelimit"
3229 #define TLIMITSTR "timelimit"
3231 #define RETRYSTR "retry"
3233 #define GOT_ID 0x0001
3234 #define GOT_PROVIDER 0x0002
3235 #define GOT_METHOD 0x0004
3236 #define GOT_ALL 0x0007
3239 parse_syncrepl_line(
3250 for ( i = 1; i < cargc; i++ ) {
3251 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
3253 /* '\0' string terminator accounts for '=' */
3254 val = cargv[ i ] + sizeof( IDSTR );
3256 if ( tmp >= 1000 || tmp < 0 ) {
3257 fprintf( stderr, "Error: parse_syncrepl_line: "
3258 "syncrepl id %d is out of range [0..999]\n", tmp );
3263 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
3264 sizeof( PROVIDERSTR ) - 1 )) {
3265 val = cargv[ i ] + sizeof( PROVIDERSTR );
3266 si->si_provideruri = ch_strdup( val );
3267 si->si_provideruri_bv = (BerVarray)
3268 ch_calloc( 2, sizeof( struct berval ));
3269 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
3270 0, &si->si_provideruri_bv[0] );
3271 si->si_provideruri_bv[1].bv_len = 0;
3272 si->si_provideruri_bv[1].bv_val = NULL;
3273 gots |= GOT_PROVIDER;
3274 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
3275 sizeof(STARTTLSSTR) - 1 ) )
3277 val = cargv[ i ] + sizeof( STARTTLSSTR );
3278 if( !strcasecmp( val, CRITICALSTR ) ) {
3279 si->si_tls = SYNCINFO_TLS_CRITICAL;
3281 si->si_tls = SYNCINFO_TLS_ON;
3283 } else if ( !strncasecmp( cargv[ i ],
3284 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
3286 struct berval updatedn = {0, NULL};
3287 val = cargv[ i ] + sizeof( UPDATEDNSTR );
3288 ber_str2bv( val, 0, 0, &updatedn );
3289 ch_free( si->si_updatedn.bv_val );
3290 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
3291 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
3292 sizeof( BINDMETHSTR ) - 1 ) )
3294 val = cargv[ i ] + sizeof( BINDMETHSTR );
3295 if ( !strcasecmp( val, SIMPLESTR )) {
3296 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3298 } else if ( !strcasecmp( val, SASLSTR )) {
3299 #ifdef HAVE_CYRUS_SASL
3300 si->si_bindmethod = LDAP_AUTH_SASL;
3302 #else /* HAVE_CYRUS_SASL */
3303 fprintf( stderr, "Error: parse_syncrepl_line: "
3304 "not compiled with SASL support\n" );
3306 #endif /* HAVE_CYRUS_SASL */
3308 si->si_bindmethod = -1;
3310 } else if ( !strncasecmp( cargv[ i ],
3311 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
3312 val = cargv[ i ] + sizeof( BINDDNSTR );
3313 si->si_binddn = ch_strdup( val );
3314 } else if ( !strncasecmp( cargv[ i ],
3315 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
3316 val = cargv[ i ] + sizeof( CREDSTR );
3317 si->si_passwd = ch_strdup( val );
3318 } else if ( !strncasecmp( cargv[ i ],
3319 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
3320 val = cargv[ i ] + sizeof( SASLMECHSTR );
3321 si->si_saslmech = ch_strdup( val );
3322 } else if ( !strncasecmp( cargv[ i ],
3323 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
3324 val = cargv[ i ] + sizeof( SECPROPSSTR );
3325 si->si_secprops = ch_strdup( val );
3326 } else if ( !strncasecmp( cargv[ i ],
3327 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
3328 val = cargv[ i ] + sizeof( REALMSTR );
3329 si->si_realm = ch_strdup( val );
3330 } else if ( !strncasecmp( cargv[ i ],
3331 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
3332 val = cargv[ i ] + sizeof( AUTHCSTR );
3333 si->si_authcId = ch_strdup( val );
3334 } else if ( !strncasecmp( cargv[ i ],
3335 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
3336 /* Old authcID is provided for some backwards compatibility */
3337 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
3338 si->si_authcId = ch_strdup( val );
3339 } else if ( !strncasecmp( cargv[ i ],
3340 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
3341 val = cargv[ i ] + sizeof( AUTHZSTR );
3342 si->si_authzId = ch_strdup( val );
3343 } else if ( !strncasecmp( cargv[ i ],
3344 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
3346 val = cargv[ i ] + sizeof( SCHEMASTR );
3347 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
3348 si->si_schemachecking = 1;
3349 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
3350 si->si_schemachecking = 0;
3352 si->si_schemachecking = 1;
3354 } else if ( !strncasecmp( cargv[ i ],
3355 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
3357 val = cargv[ i ] + sizeof( FILTERSTR );
3358 ber_str2bv( val, 0, 1, &si->si_filterstr );
3359 } else if ( !strncasecmp( cargv[ i ],
3360 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3363 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3364 if ( si->si_base.bv_val ) {
3365 ch_free( si->si_base.bv_val );
3367 ber_str2bv( val, 0, 0, &bv );
3368 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3369 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3372 } else if ( !strncasecmp( cargv[ i ],
3373 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3375 val = cargv[ i ] + sizeof( SCOPESTR );
3376 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
3377 si->si_scope = LDAP_SCOPE_BASE;
3378 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
3379 si->si_scope = LDAP_SCOPE_ONELEVEL;
3380 #ifdef LDAP_SCOPE_SUBORDINATE
3381 } else if ( !strcasecmp( val, "subordinate" ) ||
3382 !strcasecmp( val, "children" ))
3384 si->si_scope = LDAP_SCOPE_SUBORDINATE;
3386 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
3387 si->si_scope = LDAP_SCOPE_SUBTREE;
3389 fprintf( stderr, "Error: parse_syncrepl_line: "
3390 "unknown scope \"%s\"\n", val);
3393 } else if ( !strncasecmp( cargv[ i ],
3394 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3396 si->si_attrsonly = 1;
3397 } else if ( !strncasecmp( cargv[ i ],
3398 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3400 val = cargv[ i ] + sizeof( ATTRSSTR );
3401 str2clist( &si->si_attrs, val, "," );
3402 } else if ( !strncasecmp( cargv[ i ],
3403 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3405 val = cargv[ i ] + sizeof( TYPESTR );
3406 if ( !strncasecmp( val, "refreshOnly", STRLENOF("refreshOnly") )) {
3407 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3408 } else if ( !strncasecmp( val, "refreshAndPersist",
3409 STRLENOF("refreshAndPersist") ))
3411 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3412 si->si_interval = 60;
3414 fprintf( stderr, "Error: parse_syncrepl_line: "
3415 "unknown sync type \"%s\"\n", val);
3418 } else if ( !strncasecmp( cargv[ i ],
3419 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3421 val = cargv[ i ] + sizeof( INTERVALSTR );
3422 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
3423 si->si_interval = 0;
3431 hstr = strchr( dstr, ':' );
3432 if ( hstr == NULL ) {
3433 fprintf( stderr, "Error: parse_syncrepl_line: "
3434 "invalid interval \"%s\"\n", val );
3438 mstr = strchr( hstr, ':' );
3439 if ( mstr == NULL ) {
3440 fprintf( stderr, "Error: parse_syncrepl_line: "
3441 "invalid interval \"%s\"\n", val );
3445 sstr = strchr( mstr, ':' );
3446 if ( sstr == NULL ) {
3447 fprintf( stderr, "Error: parse_syncrepl_line: "
3448 "invalid interval \"%s\"\n", val );
3457 if (( hh > 24 ) || ( hh < 0 ) ||
3458 ( mm > 60 ) || ( mm < 0 ) ||
3459 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3460 fprintf( stderr, "Error: parse_syncrepl_line: "
3461 "invalid interval \"%s\"\n", val );
3464 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3466 if ( si->si_interval < 0 ) {
3467 fprintf( stderr, "Error: parse_syncrepl_line: "
3468 "invalid interval \"%ld\"\n",
3469 (long) si->si_interval);
3472 } else if ( !strncasecmp( cargv[ i ],
3473 RETRYSTR, sizeof( RETRYSTR ) - 1 ) )
3479 val = cargv[ i ] + sizeof( RETRYSTR );
3480 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
3481 retry_list[0] = NULL;
3483 str2clist( &retry_list, val, " ,\t" );
3485 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
3489 "Error: incomplete syncrepl retry list\n" );
3490 for ( k = 0; retry_list && retry_list[k]; k++ ) {
3491 ch_free( retry_list[k] );
3493 ch_free( retry_list );
3494 exit( EXIT_FAILURE );
3496 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
3497 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
3498 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
3499 for ( j = 0; j < n; j++ ) {
3500 si->si_retryinterval[j] = atoi( retry_list[j*2] );
3501 if ( *retry_list[j*2+1] == '+' ) {
3502 si->si_retrynum_init[j] = -1;
3503 si->si_retrynum[j] = -1;
3507 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
3508 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
3511 si->si_retrynum_init[j] = -2;
3512 si->si_retrynum[j] = -2;
3513 si->si_retryinterval[j] = 0;
3515 for ( k = 0; retry_list && retry_list[k]; k++ ) {
3516 ch_free( retry_list[k] );
3518 ch_free( retry_list );
3519 } else if ( !strncasecmp( cargv[ i ],
3520 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3522 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3523 si->si_manageDSAit = atoi( val );
3524 } else if ( !strncasecmp( cargv[ i ],
3525 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3527 val = cargv[ i ] + sizeof( SLIMITSTR );
3528 si->si_slimit = atoi( val );
3529 } else if ( !strncasecmp( cargv[ i ],
3530 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3532 val = cargv[ i ] + sizeof( TLIMITSTR );
3533 si->si_tlimit = atoi( val );
3535 fprintf( stderr, "Error: parse_syncrepl_line: "
3536 "unknown keyword \"%s\"\n", cargv[ i ] );
3540 if ( gots != GOT_ALL ) {
3542 "Error: Malformed \"syncrepl\" line in slapd config file" );
3550 str2clist( char ***out, char *in, const char *brkstr )
3559 /* find last element in list */
3560 for (i = 0; *out && *out[i]; i++);
3562 /* protect the input string from strtok */
3563 str = ch_strdup( in );
3565 if ( *str == '\0' ) {
3570 /* Count words in string */
3572 for ( s = str; *s; s++ ) {
3573 if ( strchr( brkstr, *s ) != NULL ) {
3578 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3580 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3582 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3584 *new = ch_strdup( s );