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>
39 #include "slapi/slapi.h"
46 * defaults for various global variables
48 slap_mask_t global_allows = 0;
49 slap_mask_t global_disallows = 0;
51 int global_gentlehup = 0;
52 int global_idletimeout = 0;
53 char *global_host = NULL;
54 char *global_realm = NULL;
55 char *ldap_srvtab = "";
56 char **default_passwd_hash = NULL;
57 int cargc = 0, cargv_size = 0;
59 struct berval default_search_base = BER_BVNULL;
60 struct berval default_search_nbase = BER_BVNULL;
61 unsigned num_subordinates = 0;
63 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
64 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
66 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
67 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
69 char *slapd_pid_file = NULL;
70 char *slapd_args_file = NULL;
72 char *strtok_quote_ptr;
74 int use_reverse_lookup = 0;
77 int slapi_plugins_used = 0;
80 static char *fp_getline(FILE *fp, int *lineno);
81 static void fp_getline_init(int *lineno);
82 static int fp_parse_line(int lineno, char *line);
84 static char *strtok_quote(char *line, char *sep);
85 static int load_ucdata(char *path);
87 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
88 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
91 read_config( const char *fname, int depth )
94 char *line, *savefname, *saveline;
98 struct berval vals[2];
101 static BackendInfo *bi = NULL;
102 static BackendDB *be = NULL;
105 vals[1].bv_val = NULL;
108 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
109 cargv_size = ARGS_STEP + 1;
112 if ( (fp = fopen( fname, "r" )) == NULL ) {
114 Debug( LDAP_DEBUG_ANY,
115 "could not open config file \"%s\": %s (%d)\n",
116 fname, strerror(errno), errno );
120 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
123 fp_getline_init( &lineno );
125 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
126 /* skip comments and blank lines */
127 if ( line[0] == '#' || line[0] == '\0' ) {
131 /* fp_parse_line is destructive, we save a copy */
132 saveline = ch_strdup( line );
134 if ( fp_parse_line( lineno, line ) != 0 ) {
139 Debug( LDAP_DEBUG_ANY,
140 "%s: line %d: bad config line (ignored)\n",
146 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
148 Debug( LDAP_DEBUG_ANY,
149 "%s: line %d: missing type in \"backend <type>\" line\n",
156 Debug( LDAP_DEBUG_ANY,
157 "%s: line %d: backend line must appear before any database definition\n",
163 bi = backend_info( cargv[1] );
166 Debug( LDAP_DEBUG_ANY,
167 "backend %s initialization failed.\n",
172 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
174 Debug( LDAP_DEBUG_ANY,
175 "%s: line %d: missing type in \"database <type>\" line\n",
182 be = backend_db_init( cargv[1] );
185 Debug( LDAP_DEBUG_ANY,
186 "database %s initialization failed.\n",
192 /* set local security factor */
193 } else if ( strcasecmp( cargv[0], "localSSF" ) == 0 ) {
196 Debug( LDAP_DEBUG_ANY,
197 "%s: line %d: missing ssf in \"localSSF <ssf>\" line\n",
202 ssf = atol( cargv[1] );
205 Debug( LDAP_DEBUG_ANY,
206 "%s: line %d: invalid ssf value (%ld) in "
207 "\"localSSF <ssf>\" line.\n",
208 fname, lineno, ssf );
214 /* set thread concurrency */
215 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
218 Debug( LDAP_DEBUG_ANY,
219 "%s: line %d: missing level in \"concurrency <level>\" line\n",
225 c = strtol( cargv[1], &next, 10 );
226 if ( next == NULL || next[0] != '\0' ) {
227 Debug( LDAP_DEBUG_ANY,
228 "%s: line %d: unable to parse level \"%s\" in \"concurrency <level>\" line\n",
229 fname, lineno, cargv[1] );
234 Debug( LDAP_DEBUG_ANY,
235 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
241 ldap_pvt_thread_set_concurrency( c );
243 /* set sockbuf max */
244 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
247 Debug( LDAP_DEBUG_ANY,
248 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
254 max = atol( cargv[1] );
257 Debug( LDAP_DEBUG_ANY,
258 "%s: line %d: invalid max value (%ld) in "
259 "\"sockbuf_max_incoming <bytes>\" line.\n",
260 fname, lineno, max );
265 sockbuf_max_incoming = max;
267 /* set sockbuf max authenticated */
268 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
271 Debug( LDAP_DEBUG_ANY,
272 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
278 max = atol( cargv[1] );
281 Debug( LDAP_DEBUG_ANY,
282 "%s: line %d: invalid max value (%ld) in "
283 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
284 fname, lineno, max );
289 sockbuf_max_incoming_auth = max;
291 /* set conn pending max */
292 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
295 Debug( LDAP_DEBUG_ANY,
296 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
302 max = atol( cargv[1] );
305 Debug( LDAP_DEBUG_ANY,
306 "%s: line %d: invalid max value (%ld) in "
307 "\"conn_max_pending <requests>\" line.\n",
308 fname, lineno, max );
313 slap_conn_max_pending = max;
315 /* set conn pending max authenticated */
316 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
319 Debug( LDAP_DEBUG_ANY,
320 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
326 max = atol( cargv[1] );
329 Debug( LDAP_DEBUG_ANY,
330 "%s: line %d: invalid max value (%ld) in "
331 "\"conn_max_pending_auth <requests>\" line.\n",
332 fname, lineno, max );
337 slap_conn_max_pending_auth = max;
339 /* default search base */
340 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
342 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
343 "missing dn in \"defaultSearchBase <dn>\" line\n",
348 } else if ( cargc > 2 ) {
349 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
350 "extra cruft after <dn> in \"defaultSearchBase %s\", "
352 fname, lineno, cargv[1] );
355 if ( bi != NULL || be != NULL ) {
356 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
357 "defaultSearchBaase line must appear prior to "
358 "any backend or database definition\n",
364 if ( default_search_nbase.bv_len ) {
365 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
366 "default search base \"%s\" already defined "
367 "(discarding old)\n",
368 fname, lineno, default_search_base.bv_val );
370 free( default_search_base.bv_val );
371 free( default_search_nbase.bv_val );
374 if ( load_ucdata( NULL ) < 0 ) return 1;
379 dn.bv_val = cargv[1];
380 dn.bv_len = strlen( dn.bv_val );
382 rc = dnPrettyNormal( NULL, &dn,
383 &default_search_base,
384 &default_search_nbase, NULL );
386 if( rc != LDAP_SUCCESS ) {
387 Debug( LDAP_DEBUG_ANY,
388 "%s: line %d: defaultSearchBase DN is invalid\n",
394 /* set maximum threads in thread pool */
395 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
398 Debug( LDAP_DEBUG_ANY,
399 "%s: line %d: missing count in \"threads <count>\" line\n",
405 c = strtol( cargv[1], &next, 10 );
406 if (next == NULL || next[0] != '\0' ) {
407 Debug( LDAP_DEBUG_ANY,
408 "%s: line %d: unable to parse count \"%s\" in \"threads <count>\" line\n",
409 fname, lineno, cargv[1] );
414 Debug( LDAP_DEBUG_ANY,
415 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
421 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
423 /* save for later use */
424 connection_pool_max = c;
426 /* get pid file name */
427 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
429 Debug( LDAP_DEBUG_ANY,
430 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
436 slapd_pid_file = ch_strdup( cargv[1] );
438 /* get args file name */
439 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
441 Debug( LDAP_DEBUG_ANY,
442 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
448 slapd_args_file = ch_strdup( cargv[1] );
450 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
453 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
456 /* default password hash */
457 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
459 Debug( LDAP_DEBUG_ANY,
460 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
465 if ( default_passwd_hash != NULL ) {
466 Debug( LDAP_DEBUG_ANY,
467 "%s: line %d: already set default password_hash!\n",
473 for(i = 1; i < cargc; i++) {
474 if ( lutil_passwd_scheme( cargv[i] ) == 0 ) {
475 Debug( LDAP_DEBUG_ANY,
476 "%s: line %d: password scheme \"%s\" not available\n",
477 fname, lineno, cargv[i] );
479 ldap_charray_add( &default_passwd_hash, cargv[i] );
482 if( !default_passwd_hash ) {
483 Debug( LDAP_DEBUG_ANY,
484 "%s: line %d: no valid hashes found\n",
489 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
492 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
493 "\"password-crypt-salt-format <format>\" line\n",
499 lutil_salt_format( cargv[1] );
501 #ifdef SLAP_AUTH_REWRITE
502 /* use authid rewrite instead of sasl regexp */
503 } else if ( strncasecmp( cargv[0], "auth-rewrite",
504 STRLENOF("auth-rewrite") ) == 0 )
506 int rc = slap_sasl_rewrite_config( fname, lineno,
511 #endif /* SLAP_AUTH_REWRITE */
513 /* Auth + SASL config options */
514 } else if ( !strncasecmp( cargv[0], "auth", STRLENOF("auth") ) ||
515 !strncasecmp( cargv[0], "sasl", STRLENOF("sasl") ))
517 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
521 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
524 Debug( LDAP_DEBUG_ANY,
525 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
529 ber_str2bv( cargv[1], 0, 0, &dn );
531 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
532 &be->be_schemandn, NULL );
534 rc = dnPrettyNormal( NULL, &dn, &frontendDB->be_schemadn,
535 &frontendDB->be_schemandn, NULL );
537 if ( rc != LDAP_SUCCESS ) {
538 Debug( LDAP_DEBUG_ANY,
539 "%s: line %d: schemadn DN is invalid\n",
544 /* set UCDATA path */
545 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
548 Debug( LDAP_DEBUG_ANY,
549 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
555 err = load_ucdata( cargv[1] );
558 Debug( LDAP_DEBUG_ANY,
559 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
567 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
569 struct slap_limits_set *lim;
572 Debug( LDAP_DEBUG_ANY,
573 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
580 lim = &frontendDB->be_def_limit;
582 lim = &be->be_def_limit;
585 for ( i = 1; i < cargc; i++ ) {
586 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
587 rc = limits_parse_one( cargv[i], lim );
589 Debug( LDAP_DEBUG_ANY,
590 "%s: line %d: unable "
591 "to parse value \"%s\" "
594 fname, lineno, cargv[i] );
599 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
600 lim->lms_s_soft = -1;
602 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
603 if ( next == cargv[i] ) {
604 Debug( LDAP_DEBUG_ANY,
605 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
606 fname, lineno, cargv[i] );
609 } else if ( next[0] != '\0' ) {
610 Debug( LDAP_DEBUG_ANY,
611 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
612 fname, lineno, next );
620 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
622 struct slap_limits_set *lim;
625 Debug( LDAP_DEBUG_ANY,
626 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
633 lim = &frontendDB->be_def_limit;
635 lim = &be->be_def_limit;
638 for ( i = 1; i < cargc; i++ ) {
639 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
640 rc = limits_parse_one( cargv[i], lim );
642 Debug( LDAP_DEBUG_ANY,
643 "%s: line %d: unable "
644 "to parse value \"%s\" "
647 fname, lineno, cargv[i] );
652 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
653 lim->lms_t_soft = -1;
655 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
656 if ( next == cargv[i] ) {
657 Debug( LDAP_DEBUG_ANY,
658 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
659 fname, lineno, cargv[i] );
662 } else if ( next[0] != '\0' ) {
663 Debug( LDAP_DEBUG_ANY,
664 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
665 fname, lineno, next );
672 /* set regex-based limits */
673 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
675 Debug( LDAP_DEBUG_ANY,
676 "%s: line %d \"limits\" allowed only in database environment.\n%s",
681 if ( limits_parse( be, fname, lineno, cargc, cargv ) ) {
685 /* mark this as a subordinate database */
686 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
688 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
689 "must appear inside a database definition.\n",
694 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
698 /* add an overlay to this backend */
699 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
701 if ( cargv[1][0] == '-' && overlay_config( frontendDB, &cargv[1][1] ) ) {
703 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
704 "(optional) global overlay \"%s\" configuration "
705 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
706 } else if ( overlay_config( frontendDB, cargv[1] ) ) {
711 if ( cargv[1][0] == '-' && overlay_config( be, &cargv[1][1] ) ) {
713 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
714 "(optional) overlay \"%s\" configuration "
715 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
716 } else if ( overlay_config( be, cargv[1] ) ) {
721 /* set database suffix */
722 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
724 struct berval dn, pdn, ndn;
727 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
728 "missing dn in \"suffix <dn>\" line\n",
733 } else if ( cargc > 2 ) {
734 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
735 "after <dn> in \"suffix %s\" line (ignored)\n",
736 fname, lineno, cargv[1] );
740 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
741 "must appear inside a database definition\n",
745 #if defined(SLAPD_MONITOR_DN)
746 /* "cn=Monitor" is reserved for monitoring slap */
747 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
748 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
749 "%s\" is reserved for monitoring slapd\n",
750 fname, lineno, SLAPD_MONITOR_DN );
752 #endif /* SLAPD_MONITOR_DN */
755 if ( load_ucdata( NULL ) < 0 ) return 1;
757 dn.bv_val = cargv[1];
758 dn.bv_len = strlen( cargv[1] );
760 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
761 if( rc != LDAP_SUCCESS ) {
762 Debug( LDAP_DEBUG_ANY,
763 "%s: line %d: suffix DN is invalid\n",
768 tmp_be = select_backend( &ndn, 0, 0 );
769 if ( tmp_be == be ) {
770 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
771 "already served by this backend (ignored)\n",
776 } else if ( tmp_be != NULL ) {
777 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
778 "already served by a preceeding backend \"%s\"\n",
779 fname, lineno, tmp_be->be_suffix[0].bv_val );
784 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
785 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
786 "suffix DN empty and default "
787 "search base provided \"%s\" (assuming okay)\n",
788 fname, lineno, default_search_base.bv_val );
791 ber_bvarray_add( &be->be_suffix, &pdn );
792 ber_bvarray_add( &be->be_nsuffix, &ndn );
794 /* set max deref depth */
795 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
798 Debug( LDAP_DEBUG_ANY,
799 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
805 Debug( LDAP_DEBUG_ANY,
806 "%s: line %d: depth line must appear inside a database definition.\n",
811 i = strtol( cargv[1], &next, 10 );
812 if ( next == NULL || next[0] != '\0' ) {
813 Debug( LDAP_DEBUG_ANY,
814 "%s: line %d: unable to parse depth \"%s\" in \"maxDerefDepth <depth>\" "
815 "line.\n", fname, lineno, cargv[1] );
820 Debug( LDAP_DEBUG_ANY,
821 "%s: line %d: depth must be positive.\n",
827 be->be_max_deref_depth = i;
829 /* set magic "root" dn for this database */
830 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
832 Debug( LDAP_DEBUG_ANY,
833 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
840 Debug( LDAP_DEBUG_ANY,
841 "%s: line %d: rootdn line must appear inside a database definition.\n",
848 if ( load_ucdata( NULL ) < 0 ) return 1;
850 dn.bv_val = cargv[1];
851 dn.bv_len = strlen( cargv[1] );
853 rc = dnPrettyNormal( NULL, &dn,
855 &be->be_rootndn, NULL );
857 if( rc != LDAP_SUCCESS ) {
858 Debug( LDAP_DEBUG_ANY,
859 "%s: line %d: rootdn DN is invalid\n",
865 /* set super-secret magic database password */
866 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
868 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
869 "missing passwd in \"rootpw <passwd>\" line\n",
876 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
877 "rootpw line must appear inside a database "
883 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
886 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
887 "rootpw can only be set when rootdn is under suffix\n",
892 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
893 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
896 /* make this database read-only */
897 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
899 Debug( LDAP_DEBUG_ANY,
900 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
906 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
907 frontendDB->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
909 frontendDB->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
913 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
914 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
916 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
920 /* restricts specific operations */
921 } else if ( strcasecmp( cargv[0], "restrict" ) == 0 ) {
922 slap_mask_t restrictops = 0;
923 struct restrictable_exops_t {
926 } restrictable_exops[] = {
927 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
928 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
929 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
930 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
936 Debug( LDAP_DEBUG_ANY,
937 "%s: line %d: missing <op_list> in \"restrict <op_list>\" "
938 "line.\n", fname, lineno, 0 );
942 for ( i = 1; i < cargc; i++ ) {
943 if ( strcasecmp( cargv[ i ], "read" ) == 0 ) {
944 restrictops |= SLAP_RESTRICT_OP_READS;
946 } else if ( strcasecmp( cargv[ i ], "write" ) == 0 ) {
947 restrictops |= SLAP_RESTRICT_OP_WRITES;
949 } else if ( strcasecmp( cargv[ i ], "add" ) == 0 ) {
950 restrictops |= SLAP_RESTRICT_OP_ADD;
952 } else if ( strcasecmp( cargv[ i ], "bind" ) == 0 ) {
953 restrictops |= SLAP_RESTRICT_OP_BIND;
955 } else if ( strcasecmp( cargv[ i ], "compare" ) == 0 ) {
956 restrictops |= SLAP_RESTRICT_OP_COMPARE;
958 } else if ( strcasecmp( cargv[ i ], "delete" ) == 0 ) {
959 restrictops |= SLAP_RESTRICT_OP_DELETE;
961 } else if ( strncasecmp( cargv[ i ], "extended",
962 STRLENOF( "extended" ) ) == 0 )
964 char *e = cargv[ i ] + STRLENOF( "extended" );
970 for ( j = 0; restrictable_exops[ j ].name; j++ ) {
971 if ( strcmp( e, restrictable_exops[j].name ) == 0 )
973 restrictops |= restrictable_exops[ j ].flag;
978 if ( restrictable_exops[ j ].name == NULL ) {
979 goto restrict_unknown;
982 restrictops &= ~SLAP_RESTRICT_OP_EXTENDED;
984 } else if ( e[0] == '\0' ) {
985 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
986 restrictops |= SLAP_RESTRICT_OP_EXTENDED;
989 goto restrict_unknown;
992 } else if ( strcasecmp( cargv[ i ], "modify" ) == 0 ) {
993 restrictops |= SLAP_RESTRICT_OP_MODIFY;
995 } else if ( strcasecmp( cargv[ i ], "rename" ) == 0
996 || strcasecmp( cargv[ i ], "modrdn" ) == 0 )
998 restrictops |= SLAP_RESTRICT_OP_RENAME;
1000 } else if ( strcasecmp( cargv[ i ], "search" ) == 0 ) {
1001 restrictops |= SLAP_RESTRICT_OP_SEARCH;
1006 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1007 "unknown operation %s in \"allow <features>\" line\n",
1008 fname, lineno, cargv[i] );
1014 frontendDB->be_restrictops |= restrictops;
1016 be->be_restrictops |= restrictops;
1019 /* allow these features */
1020 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1021 strcasecmp( cargv[0], "allow" ) == 0 )
1023 slap_mask_t allows = 0;
1026 Debug( LDAP_DEBUG_ANY,
1027 "%s: line %d: allow line must appear prior to database definitions\n",
1033 Debug( LDAP_DEBUG_ANY,
1034 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1040 for( i=1; i < cargc; i++ ) {
1041 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1042 allows |= SLAP_ALLOW_BIND_V2;
1044 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1045 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1047 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1048 allows |= SLAP_ALLOW_BIND_ANON_DN;
1050 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1051 allows |= SLAP_ALLOW_UPDATE_ANON;
1054 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1055 "unknown feature %s in \"allow <features>\" line\n",
1056 fname, lineno, cargv[i] );
1062 global_allows |= allows;
1064 /* disallow these features */
1065 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1066 strcasecmp( cargv[0], "disallow" ) == 0 )
1068 slap_mask_t disallows = 0;
1071 Debug( LDAP_DEBUG_ANY,
1072 "%s: line %d: disallow line must appear prior to database definitions\n",
1078 Debug( LDAP_DEBUG_ANY,
1079 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1085 for( i=1; i < cargc; i++ ) {
1086 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1087 disallows |= SLAP_DISALLOW_BIND_ANON;
1089 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1090 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1092 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1093 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1095 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1096 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1098 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1099 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1102 Debug( LDAP_DEBUG_ANY,
1103 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1104 fname, lineno, cargv[i] );
1110 global_disallows |= disallows;
1112 /* require these features */
1113 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1114 strcasecmp( cargv[0], "require" ) == 0 )
1116 slap_mask_t requires = 0;
1119 Debug( LDAP_DEBUG_ANY,
1120 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1126 for( i=1; i < cargc; i++ ) {
1127 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1128 requires |= SLAP_REQUIRE_BIND;
1130 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1131 requires |= SLAP_REQUIRE_LDAP_V3;
1133 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1134 requires |= SLAP_REQUIRE_AUTHC;
1136 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1137 requires |= SLAP_REQUIRE_SASL;
1139 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1140 requires |= SLAP_REQUIRE_STRONG;
1142 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1143 Debug( LDAP_DEBUG_ANY,
1144 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1145 fname, lineno, cargv[i] );
1152 frontendDB->be_requires = requires;
1154 be->be_requires = requires;
1157 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1158 slap_ssf_set_t *set;
1161 Debug( LDAP_DEBUG_ANY,
1162 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1169 set = &frontendDB->be_ssf_set;
1171 set = &be->be_ssf_set;
1174 for( i=1; i < cargc; i++ ) {
1178 if ( strncasecmp( cargv[i], "ssf=",
1179 STRLENOF("ssf=") ) == 0 )
1181 tgt = &set->sss_ssf;
1182 src = &cargv[i][STRLENOF("ssf=")];
1184 } else if ( strncasecmp( cargv[i], "transport=",
1185 STRLENOF("transport=") ) == 0 )
1187 tgt = &set->sss_transport;
1188 src = &cargv[i][STRLENOF("transport=")];
1190 } else if ( strncasecmp( cargv[i], "tls=",
1191 STRLENOF("tls=") ) == 0 )
1193 tgt = &set->sss_tls;
1194 src = &cargv[i][STRLENOF("tls=")];
1196 } else if ( strncasecmp( cargv[i], "sasl=",
1197 STRLENOF("sasl=") ) == 0 )
1199 tgt = &set->sss_sasl;
1200 src = &cargv[i][STRLENOF("sasl=")];
1202 } else if ( strncasecmp( cargv[i], "update_ssf=",
1203 STRLENOF("update_ssf=") ) == 0 )
1205 tgt = &set->sss_update_ssf;
1206 src = &cargv[i][STRLENOF("update_ssf=")];
1208 } else if ( strncasecmp( cargv[i], "update_transport=",
1209 STRLENOF("update_transport=") ) == 0 )
1211 tgt = &set->sss_update_transport;
1212 src = &cargv[i][STRLENOF("update_transport=")];
1214 } else if ( strncasecmp( cargv[i], "update_tls=",
1215 STRLENOF("update_tls=") ) == 0 )
1217 tgt = &set->sss_update_tls;
1218 src = &cargv[i][STRLENOF("update_tls=")];
1220 } else if ( strncasecmp( cargv[i], "update_sasl=",
1221 STRLENOF("update_sasl=") ) == 0 )
1223 tgt = &set->sss_update_sasl;
1224 src = &cargv[i][STRLENOF("update_sasl=")];
1226 } else if ( strncasecmp( cargv[i], "simple_bind=",
1227 STRLENOF("simple_bind=") ) == 0 )
1229 tgt = &set->sss_simple_bind;
1230 src = &cargv[i][STRLENOF("simple_bind=")];
1233 Debug( LDAP_DEBUG_ANY,
1234 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1235 fname, lineno, cargv[i] );
1240 *tgt = strtol( src, &next, 10 );
1241 if ( next == NULL || next[0] != '\0' ) {
1242 Debug( LDAP_DEBUG_ANY,
1243 "%s: line %d: unable to parse factor \"%s\" in \"security <factors>\" line\n",
1244 fname, lineno, cargv[i] );
1250 /* where to send clients when we don't hold it */
1251 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1253 Debug( LDAP_DEBUG_ANY,
1254 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1260 if( validate_global_referral( cargv[1] ) ) {
1261 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1262 "invalid URL (%s) in \"referral\" line.\n",
1263 fname, lineno, cargv[1] );
1267 vals[0].bv_val = cargv[1];
1268 vals[0].bv_len = strlen( vals[0].bv_val );
1269 if( value_add( &default_referral, vals ) )
1272 /* start of a new database definition */
1273 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1276 Debug( LDAP_DEBUG_ANY,
1277 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1281 level = strtol( cargv[2], &next, 10 );
1282 if ( next == NULL || next[0] != '\0' ){
1283 Debug( LDAP_DEBUG_ANY,
1284 "%s: line %d: unable to parse level \"%s\" in debug directive, "
1285 "\"debug <subsys> <level>\"\n", fname, lineno , cargv[2] );
1289 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1290 lutil_set_debug_level( cargv[1], level );
1291 /* specify an Object Identifier macro */
1292 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1293 rc = parse_oidm( fname, lineno, cargc, cargv );
1296 /* specify an objectclass */
1297 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1299 Debug( LDAP_DEBUG_ANY,
1300 "%s: line %d: illegal objectclass format.\n",
1304 } else if ( *cargv[1] == '(' /*')'*/) {
1306 p = strchr(saveline,'(' /*')'*/);
1307 rc = parse_oc( fname, lineno, p, cargv );
1311 Debug( LDAP_DEBUG_ANY,
1312 "%s: line %d: old objectclass format not supported.\n",
1316 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1318 p = strchr(saveline,'(' /*')'*/);
1319 rc = parse_cr( fname, lineno, p, cargv );
1322 /* specify an attribute type */
1323 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1324 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1327 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1328 "illegal attribute type format.\n",
1332 } else if ( *cargv[1] == '(' /*')'*/) {
1334 p = strchr(saveline,'(' /*')'*/);
1335 rc = parse_at( fname, lineno, p, cargv );
1339 Debug( LDAP_DEBUG_ANY,
1340 "%s: line %d: old attribute type format not supported.\n",
1345 /* define attribute option(s) */
1346 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1347 ad_define_option( NULL, NULL, 0 );
1348 for ( i = 1; i < cargc; i++ )
1349 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1352 /* turn on/off schema checking */
1353 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1355 Debug( LDAP_DEBUG_ANY,
1356 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1361 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1362 Debug( LDAP_DEBUG_ANY,
1363 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1365 global_schemacheck = 0;
1367 global_schemacheck = 1;
1370 /* specify access control info */
1371 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1372 parse_acl( be, fname, lineno, cargc, cargv );
1374 /* debug level to log things to syslog */
1375 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1377 Debug( LDAP_DEBUG_ANY,
1378 "%s: line %d: missing level(s) in \"loglevel <level> [...]\" line\n",
1386 for( i=1; i < cargc; i++ ) {
1389 if ( isdigit( cargv[i][0] ) ) {
1390 level = strtol( cargv[i], &next, 10 );
1391 if ( next == NULL || next[0] != '\0' ) {
1392 Debug( LDAP_DEBUG_ANY,
1393 "%s: line %d: unable to parse level \"%s\" "
1394 "in \"loglevel <level> [...]\" line.\n",
1395 fname, lineno , cargv[i] );
1404 { LDAP_DEBUG_TRACE, "Trace" },
1405 { LDAP_DEBUG_PACKETS, "Packets" },
1406 { LDAP_DEBUG_ARGS, "Args" },
1407 { LDAP_DEBUG_CONNS, "Conns" },
1408 { LDAP_DEBUG_BER, "BER" },
1409 { LDAP_DEBUG_FILTER, "Filter" },
1410 { LDAP_DEBUG_CONFIG, "Config" },
1411 { LDAP_DEBUG_ACL, "ACL" },
1412 { LDAP_DEBUG_STATS, "Stats" },
1413 { LDAP_DEBUG_STATS2, "Stats2" },
1414 { LDAP_DEBUG_SHELL, "Shell" },
1415 { LDAP_DEBUG_PARSE, "Parse" },
1416 { LDAP_DEBUG_CACHE, "Cache" },
1417 { LDAP_DEBUG_INDEX, "Index" },
1423 for ( j = 0; int_2_level[j].s; j++ ) {
1424 if ( strcasecmp( cargv[i], int_2_level[j].s ) == 0 ) {
1425 level = int_2_level[j].i;
1430 if ( int_2_level[j].s == NULL ) {
1431 Debug( LDAP_DEBUG_ANY,
1432 "%s: line %d: unknown level \"%s\" "
1433 "in \"loglevel <level> [...]\" line.\n",
1434 fname, lineno , cargv[i] );
1439 ldap_syslog |= level;
1442 /* list of sync replication information in this backend (slave only) */
1443 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1446 Debug( LDAP_DEBUG_ANY,
1447 "%s: line %d: syncrepl line must appear inside "
1448 "a database definition.\n", fname, lineno, 0);
1451 } else if ( SLAP_SHADOW( be )) {
1452 Debug( LDAP_DEBUG_ANY,
1453 "%s: line %d: syncrepl: database already shadowed.\n",
1457 } else if ( add_syncrepl( be, cargv, cargc )) {
1461 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW );
1463 /* list of replicas of the data in this backend (master only) */
1464 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1466 Debug( LDAP_DEBUG_ANY,
1467 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1473 Debug( LDAP_DEBUG_ANY,
1474 "%s: line %d: replica line must appear inside a database definition\n",
1481 for ( i = 1; i < cargc; i++ ) {
1482 if ( strncasecmp( cargv[i], "host=", 5 )
1484 nr = add_replica_info( be,
1487 } else if (strncasecmp( cargv[i], "uri=", 4 )
1489 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1491 Debug( LDAP_DEBUG_ANY,
1492 "%s: line %d: replica line contains invalid "
1493 "uri definition.\n", fname, lineno, 0);
1496 if (ludp->lud_host == NULL ) {
1497 Debug( LDAP_DEBUG_ANY,
1498 "%s: line %d: replica line contains invalid "
1499 "uri definition - missing hostname.\n", fname, lineno, 0);
1502 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1503 if ( replicahost == NULL ) {
1504 Debug( LDAP_DEBUG_ANY,
1505 "out of memory in read_config\n", 0, 0, 0 );
1506 ldap_free_urldesc( ludp );
1507 exit( EXIT_FAILURE );
1509 sprintf(replicahost, "%s:%d",
1510 ludp->lud_host, ludp->lud_port);
1511 nr = add_replica_info( be, replicahost );
1512 ldap_free_urldesc( ludp );
1513 ch_free(replicahost);
1518 Debug( LDAP_DEBUG_ANY,
1519 "%s: line %d: missing host or uri in \"replica\" line\n",
1523 } else if ( nr == -1 ) {
1524 Debug( LDAP_DEBUG_ANY,
1525 "%s: line %d: unable to add replica \"%s\"\n",
1526 fname, lineno, cargv[i] + 5 );
1529 for ( i = 1; i < cargc; i++ ) {
1530 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1532 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1534 Debug( LDAP_DEBUG_ANY,
1535 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1536 fname, lineno, cargv[i] + 7 );
1540 Debug( LDAP_DEBUG_ANY,
1541 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1546 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1548 char *arg = cargv[i] + 4;
1550 if ( arg[0] == '!' ) {
1555 if ( arg[0] != '=' ) {
1559 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1560 Debug( LDAP_DEBUG_ANY,
1561 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1562 fname, lineno, arg + 1 );
1570 } else if ( strcasecmp( cargv[0], "replicationInterval" ) == 0 ) {
1573 /* dn of slave entity allowed to write to replica */
1574 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1576 Debug( LDAP_DEBUG_ANY,
1577 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1583 Debug( LDAP_DEBUG_ANY,
1584 "%s: line %d: updatedn line must appear inside a database definition\n",
1588 } else if ( SLAP_SHADOW(be) ) {
1589 Debug( LDAP_DEBUG_ANY,
1590 "%s: line %d: updatedn: database already shadowed.\n",
1597 if ( load_ucdata( NULL ) < 0 ) return 1;
1599 dn.bv_val = cargv[1];
1600 dn.bv_len = strlen( cargv[1] );
1602 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
1603 if( rc != LDAP_SUCCESS ) {
1604 Debug( LDAP_DEBUG_ANY,
1605 "%s: line %d: updatedn DN is invalid\n",
1611 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW );
1613 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1615 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1616 "missing url in \"updateref <ldapurl>\" line\n",
1622 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1623 " line must appear inside a database definition\n",
1627 } else if ( !SLAP_SHADOW(be) ) {
1628 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1629 "updateref line must after syncrepl or updatedn.\n",
1634 if( validate_global_referral( cargv[1] ) ) {
1635 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1636 "invalid URL (%s) in \"updateref\" line.\n",
1637 fname, lineno, cargv[1] );
1641 vals[0].bv_val = cargv[1];
1642 vals[0].bv_len = strlen( vals[0].bv_val );
1643 if( value_add( &be->be_update_refs, vals ) ) {
1647 /* replication log file to which changes are appended */
1648 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1650 Debug( LDAP_DEBUG_ANY,
1651 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1657 be->be_replogfile = ch_strdup( cargv[1] );
1659 replogfile = ch_strdup( cargv[1] );
1662 /* file from which to read additional rootdse attrs */
1663 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1665 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1666 "missing filename in \"rootDSE <filename>\" line.\n",
1671 if( read_root_dse_file( cargv[1] ) ) {
1672 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1673 "could not read \"rootDSE <filename>\" line\n",
1678 /* maintain lastmodified{by,time} attributes */
1679 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
1681 Debug( LDAP_DEBUG_ANY,
1682 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
1689 Debug( LDAP_DEBUG_ANY, "%s: line %d: lastmod"
1690 " line must appear inside a database definition\n",
1694 } else if ( SLAP_NOLASTMODCMD(be) ) {
1695 Debug( LDAP_DEBUG_ANY, "%s: line %d: lastmod"
1696 " not available for %s databases\n",
1697 fname, lineno, be->bd_info->bi_type );
1701 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1702 SLAP_DBFLAGS(be) &= ~SLAP_DBFLAG_NOLASTMOD;
1704 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD;
1708 /* turn on/off gentle SIGHUP handling */
1709 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
1711 Debug( LDAP_DEBUG_ANY,
1712 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
1716 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1717 global_gentlehup = 0;
1719 global_gentlehup = 1;
1723 /* set idle timeout value */
1724 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
1727 Debug( LDAP_DEBUG_ANY,
1728 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
1734 i = atoi( cargv[1] );
1737 Debug( LDAP_DEBUG_ANY,
1738 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
1744 global_idletimeout = i;
1746 /* include another config file */
1747 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
1749 Debug( LDAP_DEBUG_ANY,
1750 "%s: line %d: missing filename in \"include <filename>\" line\n",
1755 savefname = ch_strdup( cargv[1] );
1756 savelineno = lineno;
1758 if ( read_config( savefname, depth+1 ) != 0 ) {
1763 lineno = savelineno - 1;
1765 /* location of kerberos srvtab file */
1766 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
1768 Debug( LDAP_DEBUG_ANY,
1769 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
1774 ldap_srvtab = ch_strdup( cargv[1] );
1776 #ifdef SLAPD_MODULES
1777 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
1779 Debug( LDAP_DEBUG_ANY,
1780 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
1783 exit( EXIT_FAILURE );
1785 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
1786 Debug( LDAP_DEBUG_ANY,
1787 "%s: line %d: failed to load or initialize module %s\n",
1788 fname, lineno, cargv[1]);
1790 exit( EXIT_FAILURE );
1792 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
1794 Debug( LDAP_DEBUG_ANY,
1795 "%s: line %d: missing path in \"modulepath <path>\" line\n",
1798 exit( EXIT_FAILURE );
1800 if (module_path( cargv[1] )) {
1801 Debug( LDAP_DEBUG_ANY,
1802 "%s: line %d: failed to set module search path to %s\n",
1803 fname, lineno, cargv[1]);
1805 exit( EXIT_FAILURE );
1808 #endif /*SLAPD_MODULES*/
1811 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
1812 rc = ldap_pvt_tls_set_option( NULL,
1813 LDAP_OPT_X_TLS_RANDOM_FILE,
1818 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
1819 rc = ldap_pvt_tls_set_option( NULL,
1820 LDAP_OPT_X_TLS_CIPHER_SUITE,
1825 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
1826 rc = ldap_pvt_tls_set_option( NULL,
1827 LDAP_OPT_X_TLS_CERTFILE,
1832 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
1833 rc = ldap_pvt_tls_set_option( NULL,
1834 LDAP_OPT_X_TLS_KEYFILE,
1839 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
1840 rc = ldap_pvt_tls_set_option( NULL,
1841 LDAP_OPT_X_TLS_CACERTDIR,
1846 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
1847 rc = ldap_pvt_tls_set_option( NULL,
1848 LDAP_OPT_X_TLS_CACERTFILE,
1852 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
1853 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
1855 rc = ldap_pvt_tls_set_option( NULL,
1856 LDAP_OPT_X_TLS_REQUIRE_CERT,
1859 rc = ldap_int_tls_config( NULL,
1860 LDAP_OPT_X_TLS_REQUIRE_CERT,
1869 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
1870 #ifdef SLAPD_RLOOKUPS
1872 Debug( LDAP_DEBUG_ANY,
1873 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
1878 if ( !strcasecmp( cargv[1], "on" ) ) {
1879 use_reverse_lookup = 1;
1880 } else if ( !strcasecmp( cargv[1], "off" ) ) {
1881 use_reverse_lookup = 0;
1883 Debug( LDAP_DEBUG_ANY,
1884 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
1889 #else /* !SLAPD_RLOOKUPS */
1890 Debug( LDAP_DEBUG_ANY,
1891 "%s: line %d: reverse lookups are not configured (ignored).\n",
1893 #endif /* !SLAPD_RLOOKUPS */
1895 /* Netscape plugins */
1896 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
1897 #if defined( LDAP_SLAPI )
1899 #ifdef notdef /* allow global plugins, too */
1901 * a "plugin" line must be inside a database
1902 * definition, since we implement pre-,post-
1903 * and extended operation plugins
1906 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
1907 "line must appear inside a database "
1908 "definition\n", fname, lineno, 0 );
1913 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
1916 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
1917 "config read failed.\n", fname, lineno, 0 );
1920 slapi_plugins_used++;
1922 #else /* !defined( LDAP_SLAPI ) */
1923 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
1924 "not supported.\n", fname, lineno, 0 );
1927 #endif /* !defined( LDAP_SLAPI ) */
1929 /* Netscape plugins */
1930 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
1931 #if defined( LDAP_SLAPI )
1933 Debug( LDAP_DEBUG_ANY,
1934 "%s: line %d: missing file name "
1935 "in pluginlog <filename> line.\n",
1940 if ( slapi_log_file != NULL ) {
1941 ch_free( slapi_log_file );
1944 slapi_log_file = ch_strdup( cargv[1] );
1945 #endif /* !defined( LDAP_SLAPI ) */
1947 /* pass anything else to the current backend info/db config routine */
1950 if ( bi->bi_config ) {
1951 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
1957 case SLAP_CONF_UNKNOWN:
1958 Debug( LDAP_DEBUG_ANY,
1959 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
1960 fname, lineno, cargv[0] );
1968 } else if ( be != NULL ) {
1969 if ( be->be_config ) {
1970 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
1976 case SLAP_CONF_UNKNOWN:
1977 Debug( LDAP_DEBUG_ANY,
1978 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
1979 fname, lineno, cargv[0] );
1988 if ( frontendDB->be_config ) {
1989 rc = (*frontendDB->be_config)( frontendDB, fname, lineno, cargc, cargv );
1995 case SLAP_CONF_UNKNOWN:
1996 Debug( LDAP_DEBUG_ANY,
1997 "%s: line %d: unknown directive \"%s\" inside global database definition (ignored)\n",
1998 fname, lineno, cargv[0] );
2011 if ( depth == 0 ) ch_free( cargv );
2013 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
2014 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2015 &frontendDB->be_schemadn );
2016 dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
2019 if ( load_ucdata( NULL ) < 0 ) return 1;
2031 char logbuf[sizeof("pseudorootpw ***")];
2034 token = strtok_quote( line, " \t" );
2038 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2039 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2040 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2041 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2042 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2044 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2047 if ( strtok_quote_ptr ) {
2048 *strtok_quote_ptr = ' ';
2051 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2053 if ( strtok_quote_ptr ) {
2054 *strtok_quote_ptr = '\0';
2057 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2058 if ( cargc == cargv_size - 1 ) {
2060 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2062 if ( tmp == NULL ) {
2063 Debug( LDAP_DEBUG_ANY,
2064 "line %d: out of memory\n",
2069 cargv_size += ARGS_STEP;
2071 cargv[cargc++] = token;
2073 cargv[cargc] = NULL;
2078 strtok_quote( char *line, char *sep )
2084 strtok_quote_ptr = NULL;
2085 if ( line != NULL ) {
2088 while ( *next && strchr( sep, *next ) ) {
2092 if ( *next == '\0' ) {
2098 for ( inquote = 0; *next; ) {
2106 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2112 next + 1, strlen( next + 1 ) + 1 );
2113 next++; /* dont parse the escaped character */
2118 if ( strchr( sep, *next ) != NULL ) {
2119 strtok_quote_ptr = next;
2132 static char buf[BUFSIZ];
2134 static size_t lmax, lcur;
2136 #define CATLINE( buf ) \
2138 size_t len = strlen( buf ); \
2139 while ( lcur + len + 1 > lmax ) { \
2141 line = (char *) ch_realloc( line, lmax ); \
2143 strcpy( line + lcur, buf ); \
2148 fp_getline( FILE *fp, int *lineno )
2156 /* hack attack - keeps us from having to keep a stack of bufs... */
2157 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2162 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2163 /* trim off \r\n or \n */
2164 if ( (p = strchr( buf, '\n' )) != NULL ) {
2165 if( p > buf && p[-1] == '\r' ) --p;
2169 /* trim off trailing \ and append the next line */
2170 if ( line[ 0 ] != '\0'
2171 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2172 && p[ -1 ] != '\\' ) {
2177 if ( ! isspace( (unsigned char) buf[0] ) ) {
2181 /* change leading whitespace to a space */
2190 return( line[0] ? line : NULL );
2194 fp_getline_init( int *lineno )
2200 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2202 load_ucdata( char *path )
2205 static int loaded = 0;
2211 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2213 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2221 /* ucdata is now hardcoded */
2229 ucdata_unload( UCDATA_ALL );
2231 /* NOTE: in case of early exit, frontendDB can be NULL */
2232 if ( frontendDB->be_schemandn.bv_val )
2233 free( frontendDB->be_schemandn.bv_val );
2234 if ( frontendDB->be_schemadn.bv_val )
2235 free( frontendDB->be_schemadn.bv_val );
2236 if ( frontendDB->be_acl )
2237 acl_destroy( frontendDB->be_acl, NULL );
2240 if ( slapd_args_file )
2241 free ( slapd_args_file );
2242 if ( slapd_pid_file )
2243 free ( slapd_pid_file );
2244 if ( default_passwd_hash )
2245 ldap_charray_free( default_passwd_hash );
2256 syncinfo_t *si_entry;
2258 int duplicated_replica_id = 0;
2260 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2263 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2267 si->si_tls = SYNCINFO_TLS_OFF;
2268 if ( be->be_rootndn.bv_val ) {
2269 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2271 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2272 si->si_schemachecking = 0;
2273 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
2274 &si->si_filterstr );
2275 si->si_base.bv_val = NULL;
2276 si->si_scope = LDAP_SCOPE_SUBTREE;
2277 si->si_attrsonly = 0;
2278 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
2279 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
2280 si->si_attrs = NULL;
2281 si->si_allattrs = 0;
2282 si->si_allopattrs = 0;
2283 si->si_exattrs = NULL;
2284 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2285 si->si_interval = 86400;
2286 si->si_retryinterval = NULL;
2287 si->si_retrynum_init = NULL;
2288 si->si_retrynum = NULL;
2289 si->si_syncCookie.ctxcsn = NULL;
2290 si->si_syncCookie.octet_str = NULL;
2291 si->si_syncCookie.sid = -1;
2292 si->si_manageDSAit = 0;
2295 si->si_syncUUID_ndn.bv_val = NULL;
2296 si->si_syncUUID_ndn.bv_len = 0;
2298 si->si_presentlist = NULL;
2299 LDAP_LIST_INIT( &si->si_nonpresentlist );
2301 rc = parse_syncrepl_line( cargv, cargc, si );
2303 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
2304 if ( si->si_rid == si_entry->si_rid ) {
2305 Debug( LDAP_DEBUG_ANY,
2306 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
2307 duplicated_replica_id = 1;
2312 if ( rc < 0 || duplicated_replica_id ) {
2313 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2314 syncinfo_free( si );
2317 Debug( LDAP_DEBUG_CONFIG,
2318 "Config: ** successfully added syncrepl \"%s\"\n",
2319 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2320 if ( !si->si_schemachecking ) {
2321 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2324 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
2329 /* NOTE: used & documented in slapd.conf(5) */
2331 #define PROVIDERSTR "provider"
2332 #define TYPESTR "type"
2333 #define INTERVALSTR "interval"
2334 #define SEARCHBASESTR "searchbase"
2335 #define FILTERSTR "filter"
2336 #define SCOPESTR "scope"
2337 #define ATTRSSTR "attrs"
2338 #define ATTRSONLYSTR "attrsonly"
2339 #define SLIMITSTR "sizelimit"
2340 #define TLIMITSTR "timelimit"
2341 #define SCHEMASTR "schemachecking"
2342 #define UPDATEDNSTR "updatedn"
2343 #define BINDMETHSTR "bindmethod"
2344 #define SIMPLESTR "simple"
2345 #define SASLSTR "sasl"
2346 #define BINDDNSTR "binddn"
2347 #define SASLMECHSTR "saslmech"
2348 #define AUTHCSTR "authcID"
2349 #define AUTHZSTR "authzID"
2350 #define CREDSTR "credentials"
2351 #define REALMSTR "realm"
2352 #define SECPROPSSTR "secprops"
2354 /* FIXME: undocumented */
2355 #define OLDAUTHCSTR "bindprincipal"
2356 #define STARTTLSSTR "starttls"
2357 #define CRITICALSTR "critical"
2358 #define EXATTRSSTR "exattrs"
2359 #define MANAGEDSAITSTR "manageDSAit"
2360 #define RETRYSTR "retry"
2363 #define LASTMODSTR "lastmod"
2364 #define LMGENSTR "gen"
2365 #define LMNOSTR "no"
2366 #define LMREQSTR "req"
2367 #define SRVTABSTR "srvtab"
2368 #define SUFFIXSTR "suffix"
2371 #define GOT_ID 0x0001
2372 #define GOT_PROVIDER 0x0002
2373 #define GOT_METHOD 0x0004
2376 #define GOT_ALL (GOT_ID|GOT_PROVIDER|GOT_METHOD)
2379 parse_syncrepl_line(
2390 for ( i = 1; i < cargc; i++ ) {
2391 if ( !strncasecmp( cargv[ i ], IDSTR "=",
2392 STRLENOF( IDSTR "=" ) ) )
2395 /* '\0' string terminator accounts for '=' */
2396 val = cargv[ i ] + STRLENOF( IDSTR "=" );
2398 if ( tmp >= 1000 || tmp < 0 ) {
2399 fprintf( stderr, "Error: parse_syncrepl_line: "
2400 "syncrepl id %d is out of range [0..999]\n", tmp );
2405 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
2406 STRLENOF( PROVIDERSTR "=" ) ) )
2408 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
2409 si->si_provideruri = ch_strdup( val );
2410 si->si_provideruri_bv = (BerVarray)
2411 ch_calloc( 2, sizeof( struct berval ));
2412 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
2413 1, &si->si_provideruri_bv[0] );
2414 si->si_provideruri_bv[1].bv_len = 0;
2415 si->si_provideruri_bv[1].bv_val = NULL;
2416 gots |= GOT_PROVIDER;
2417 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=",
2418 STRLENOF(STARTTLSSTR "=") ) )
2420 val = cargv[ i ] + STRLENOF( STARTTLSSTR "=" );
2421 if( !strcasecmp( val, CRITICALSTR ) ) {
2422 si->si_tls = SYNCINFO_TLS_CRITICAL;
2424 si->si_tls = SYNCINFO_TLS_ON;
2426 } else if ( !strncasecmp( cargv[ i ], UPDATEDNSTR "=",
2427 STRLENOF( UPDATEDNSTR "=" ) ) )
2429 struct berval updatedn = BER_BVNULL;
2431 val = cargv[ i ] + STRLENOF( UPDATEDNSTR "=" );
2432 ber_str2bv( val, 0, 0, &updatedn );
2433 ch_free( si->si_updatedn.bv_val );
2434 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
2435 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR "=",
2436 STRLENOF( BINDMETHSTR "=" ) ) )
2438 val = cargv[ i ] + STRLENOF( BINDMETHSTR "=" );
2439 if ( !strcasecmp( val, SIMPLESTR )) {
2440 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2442 } else if ( !strcasecmp( val, SASLSTR )) {
2443 #ifdef HAVE_CYRUS_SASL
2444 si->si_bindmethod = LDAP_AUTH_SASL;
2446 #else /* HAVE_CYRUS_SASL */
2447 fprintf( stderr, "Error: parse_syncrepl_line: "
2448 "not compiled with SASL support\n" );
2450 #endif /* HAVE_CYRUS_SASL */
2452 si->si_bindmethod = -1;
2454 } else if ( !strncasecmp( cargv[ i ], BINDDNSTR "=",
2455 STRLENOF( BINDDNSTR "=" ) ) )
2457 val = cargv[ i ] + STRLENOF( BINDDNSTR "=" );
2458 si->si_binddn = ch_strdup( val );
2459 } else if ( !strncasecmp( cargv[ i ], CREDSTR "=",
2460 STRLENOF( CREDSTR "=" ) ) )
2462 val = cargv[ i ] + STRLENOF( CREDSTR "=" );
2463 si->si_passwd = ch_strdup( val );
2464 } else if ( !strncasecmp( cargv[ i ], SASLMECHSTR "=",
2465 STRLENOF( SASLMECHSTR "=" ) ) )
2467 val = cargv[ i ] + STRLENOF( SASLMECHSTR "=" );
2468 si->si_saslmech = ch_strdup( val );
2469 } else if ( !strncasecmp( cargv[ i ], SECPROPSSTR "=",
2470 STRLENOF( SECPROPSSTR "=" ) ) )
2472 val = cargv[ i ] + STRLENOF( SECPROPSSTR "=" );
2473 si->si_secprops = ch_strdup( val );
2474 } else if ( !strncasecmp( cargv[ i ], REALMSTR "=",
2475 STRLENOF( REALMSTR "=" ) ) )
2477 val = cargv[ i ] + STRLENOF( REALMSTR "=" );
2478 si->si_realm = ch_strdup( val );
2479 } else if ( !strncasecmp( cargv[ i ], AUTHCSTR "=",
2480 STRLENOF( AUTHCSTR "=" ) ) )
2482 val = cargv[ i ] + STRLENOF( AUTHCSTR "=" );
2483 if ( si->si_authcId )
2484 ch_free( si->si_authcId );
2485 si->si_authcId = ch_strdup( val );
2486 } else if ( !strncasecmp( cargv[ i ], OLDAUTHCSTR "=",
2487 STRLENOF( OLDAUTHCSTR "=" ) ) )
2489 /* Old authcID is provided for some backwards compatibility */
2490 val = cargv[ i ] + STRLENOF( OLDAUTHCSTR "=" );
2491 if ( si->si_authcId )
2492 ch_free( si->si_authcId );
2493 si->si_authcId = ch_strdup( val );
2494 } else if ( !strncasecmp( cargv[ i ], AUTHZSTR "=",
2495 STRLENOF( AUTHZSTR "=" ) ) )
2497 val = cargv[ i ] + STRLENOF( AUTHZSTR "=" );
2498 si->si_authzId = ch_strdup( val );
2499 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
2500 STRLENOF( SCHEMASTR "=" ) ) )
2502 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
2503 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
2504 si->si_schemachecking = 1;
2505 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
2506 si->si_schemachecking = 0;
2508 si->si_schemachecking = 1;
2510 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
2511 STRLENOF( FILTERSTR "=" ) ) )
2513 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
2514 ber_str2bv( val, 0, 1, &si->si_filterstr );
2515 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
2516 STRLENOF( SEARCHBASESTR "=" ) ) )
2519 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
2520 if ( si->si_base.bv_val ) {
2521 ch_free( si->si_base.bv_val );
2523 ber_str2bv( val, 0, 0, &bv );
2524 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
2525 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
2528 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
2529 STRLENOF( SCOPESTR "=" ) ) )
2531 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
2532 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
2533 si->si_scope = LDAP_SCOPE_BASE;
2534 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
2535 si->si_scope = LDAP_SCOPE_ONELEVEL;
2536 #ifdef LDAP_SCOPE_SUBORDINATE
2537 } else if ( !strcasecmp( val, "subordinate" ) ||
2538 !strcasecmp( val, "children" ))
2540 si->si_scope = LDAP_SCOPE_SUBORDINATE;
2542 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
2543 si->si_scope = LDAP_SCOPE_SUBTREE;
2545 fprintf( stderr, "Error: parse_syncrepl_line: "
2546 "unknown scope \"%s\"\n", val);
2549 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
2550 STRLENOF( ATTRSONLYSTR "=" ) ) )
2552 si->si_attrsonly = 1;
2553 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
2554 STRLENOF( ATTRSSTR "=" ) ) )
2556 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
2557 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
2559 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2560 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
2561 if ( si->si_anlist == NULL ) {
2562 ch_free( attr_fname );
2565 ch_free( attr_fname );
2567 char *str, *s, *next;
2568 char delimstr[] = " ,\t";
2569 str = ch_strdup( val );
2570 for ( s = ldap_pvt_strtok( str, delimstr, &next );
2572 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
2574 if ( strlen(s) == 1 && *s == '*' ) {
2575 si->si_allattrs = 1;
2576 *(val + ( s - str )) = delimstr[0];
2578 if ( strlen(s) == 1 && *s == '+' ) {
2579 si->si_allopattrs = 1;
2580 *(val + ( s - str )) = delimstr[0];
2584 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
2585 if ( si->si_anlist == NULL ) {
2589 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
2590 STRLENOF( EXATTRSSTR "=" ) ) )
2592 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
2593 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
2595 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2596 si->si_exanlist = file2anlist(
2597 si->si_exanlist, attr_fname, " ,\t" );
2598 if ( si->si_exanlist == NULL ) {
2599 ch_free( attr_fname );
2602 ch_free( attr_fname );
2605 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
2606 if ( si->si_exanlist == NULL ) {
2610 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
2611 STRLENOF( TYPESTR "=" ) ) )
2613 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
2614 if ( !strncasecmp( val, "refreshOnly",
2615 STRLENOF("refreshOnly") ))
2617 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2618 } else if ( !strncasecmp( val, "refreshAndPersist",
2619 STRLENOF("refreshAndPersist") ))
2621 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
2622 si->si_interval = 60;
2624 fprintf( stderr, "Error: parse_syncrepl_line: "
2625 "unknown sync type \"%s\"\n", val);
2628 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
2629 STRLENOF( INTERVALSTR "=" ) ) )
2631 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
2632 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
2633 si->si_interval = 0;
2641 hstr = strchr( dstr, ':' );
2642 if ( hstr == NULL ) {
2643 fprintf( stderr, "Error: parse_syncrepl_line: "
2644 "invalid interval \"%s\"\n", val );
2648 mstr = strchr( hstr, ':' );
2649 if ( mstr == NULL ) {
2650 fprintf( stderr, "Error: parse_syncrepl_line: "
2651 "invalid interval \"%s\"\n", val );
2655 sstr = strchr( mstr, ':' );
2656 if ( sstr == NULL ) {
2657 fprintf( stderr, "Error: parse_syncrepl_line: "
2658 "invalid interval \"%s\"\n", val );
2667 if (( hh > 24 ) || ( hh < 0 ) ||
2668 ( mm > 60 ) || ( mm < 0 ) ||
2669 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2670 fprintf( stderr, "Error: parse_syncrepl_line: "
2671 "invalid interval \"%s\"\n", val );
2674 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2676 if ( si->si_interval < 0 ) {
2677 fprintf( stderr, "Error: parse_syncrepl_line: "
2678 "invalid interval \"%ld\"\n",
2679 (long) si->si_interval);
2682 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2683 STRLENOF( RETRYSTR "=" ) ) )
2689 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2690 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2691 retry_list[0] = NULL;
2693 slap_str2clist( &retry_list, val, " ,\t" );
2695 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2699 "Error: incomplete syncrepl retry list\n" );
2700 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2701 ch_free( retry_list[k] );
2703 ch_free( retry_list );
2704 exit( EXIT_FAILURE );
2706 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2707 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2708 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2709 for ( j = 0; j < n; j++ ) {
2710 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2711 if ( *retry_list[j*2+1] == '+' ) {
2712 si->si_retrynum_init[j] = -1;
2713 si->si_retrynum[j] = -1;
2717 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2718 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2721 si->si_retrynum_init[j] = -2;
2722 si->si_retrynum[j] = -2;
2723 si->si_retryinterval[j] = 0;
2725 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2726 ch_free( retry_list[k] );
2728 ch_free( retry_list );
2729 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2730 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2732 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2733 si->si_manageDSAit = atoi( val );
2734 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2735 STRLENOF( SLIMITSTR "=") ) )
2737 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2738 si->si_slimit = atoi( val );
2739 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2740 STRLENOF( TLIMITSTR "=" ) ) )
2742 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2743 si->si_tlimit = atoi( val );
2745 fprintf( stderr, "Error: parse_syncrepl_line: "
2746 "unknown keyword \"%s\"\n", cargv[ i ] );
2750 if ( gots != GOT_ALL ) {
2752 "Error: Malformed \"syncrepl\" line in slapd config file" );
2760 slap_str2clist( char ***out, char *in, const char *brkstr )
2769 /* find last element in list */
2770 for (i = 0; *out && (*out)[i]; i++);
2772 /* protect the input string from strtok */
2773 str = ch_strdup( in );
2775 if ( *str == '\0' ) {
2780 /* Count words in string */
2782 for ( s = str; *s; s++ ) {
2783 if ( strchr( brkstr, *s ) != NULL ) {
2788 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
2790 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
2792 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
2794 *new = ch_strdup( s );