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 slap_mask_t global_allows = 0;
50 slap_mask_t global_disallows = 0;
52 int global_gentlehup = 0;
53 int global_idletimeout = 0;
54 char *global_host = NULL;
55 char *global_realm = NULL;
56 char *ldap_srvtab = "";
57 char **default_passwd_hash = NULL;
58 int cargc = 0, cargv_size = 0;
60 struct berval default_search_base = BER_BVNULL;
61 struct berval default_search_nbase = BER_BVNULL;
62 unsigned num_subordinates = 0;
64 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
65 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
67 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
68 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
70 char *slapd_pid_file = NULL;
71 char *slapd_args_file = NULL;
73 char *strtok_quote_ptr;
75 int use_reverse_lookup = 0;
78 int slapi_plugins_used = 0;
81 static char *fp_getline(FILE *fp, int *lineno);
82 static void fp_getline_init(int *lineno);
83 static int fp_parse_line(int lineno, char *line);
85 static char *strtok_quote(char *line, char *sep);
86 static int load_ucdata(char *path);
88 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
89 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
92 read_config( const char *fname, int depth )
95 char *line, *savefname, *saveline;
99 struct berval vals[2];
102 static BackendInfo *bi = NULL;
103 static BackendDB *be = NULL;
107 vals[1].bv_val = NULL;
110 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
111 cargv_size = ARGS_STEP + 1;
114 if ( (fp = fopen( fname, "r" )) == NULL ) {
117 LDAP_LOG( CONFIG, ENTRY,
118 "read_config: " "could not open config file \"%s\": %s (%d)\n",
119 fname, strerror(errno), errno );
121 Debug( LDAP_DEBUG_ANY,
122 "could not open config file \"%s\": %s (%d)\n",
123 fname, strerror(errno), errno );
129 LDAP_LOG( CONFIG, ENTRY,
130 "read_config: reading config file %s\n", fname, 0, 0 );
132 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
136 fp_getline_init( &lineno );
138 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
139 /* skip comments and blank lines */
140 if ( line[0] == '#' || line[0] == '\0' ) {
144 /* fp_parse_line is destructive, we save a copy */
145 saveline = ch_strdup( line );
147 if ( fp_parse_line( lineno, line ) != 0 ) {
153 LDAP_LOG( CONFIG, INFO,
154 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
156 Debug( LDAP_DEBUG_ANY,
157 "%s: line %d: bad config line (ignored)\n",
164 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
167 LDAP_LOG( CONFIG, CRIT,
168 "%s : line %d: missing type in \"backend\" line.\n",
171 Debug( LDAP_DEBUG_ANY,
172 "%s: line %d: missing type in \"backend <type>\" line\n",
181 LDAP_LOG( CONFIG, CRIT,
182 "%s: line %d: backend line must appear before any "
183 "database definition.\n", fname, lineno , 0 );
185 Debug( LDAP_DEBUG_ANY,
186 "%s: line %d: backend line must appear before any database definition\n",
193 bi = backend_info( cargv[1] );
197 LDAP_LOG( CONFIG, CRIT,
198 "read_config: backend %s initialization failed.\n",
201 Debug( LDAP_DEBUG_ANY,
202 "backend %s initialization failed.\n",
208 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
211 LDAP_LOG( CONFIG, CRIT,
212 "%s: line %d: missing type in \"database <type>\" line\n",
215 Debug( LDAP_DEBUG_ANY,
216 "%s: line %d: missing type in \"database <type>\" line\n",
224 be = backend_db_init( cargv[1] );
228 LDAP_LOG( CONFIG, CRIT,
229 "database %s initialization failed.\n", cargv[1], 0, 0 );
231 Debug( LDAP_DEBUG_ANY,
232 "database %s initialization failed.\n",
239 /* set thread concurrency */
240 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
244 LDAP_LOG( CONFIG, CRIT,
245 "%s: line %d: missing level in \"concurrency <level>\" "
246 " line\n", fname, lineno, 0 );
248 Debug( LDAP_DEBUG_ANY,
249 "%s: line %d: missing level in \"concurrency <level>\" line\n",
256 c = strtol( cargv[1], &next, 10 );
257 if ( next == NULL || next[0] != '\0' ) {
259 LDAP_LOG( CONFIG, CRIT,
260 "%s: line %d: unable to parse level \"%s\" in \"concurrency <level>\" "
261 " line\n", fname, lineno, cargv[1] );
263 Debug( LDAP_DEBUG_ANY,
264 "%s: line %d: unable to parse level \"%s\" in \"concurrency <level>\" line\n",
265 fname, lineno, cargv[1] );
272 LDAP_LOG( CONFIG, CRIT,
273 "%s: line %d: invalid level (%d) in "
274 "\"concurrency <level>\" line.\n", fname, lineno, c );
276 Debug( LDAP_DEBUG_ANY,
277 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
284 ldap_pvt_thread_set_concurrency( c );
286 /* set sockbuf max */
287 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
291 LDAP_LOG( CONFIG, CRIT,
292 "%s: line %d: missing max in \"sockbuf_max_incoming "
293 "<bytes>\" line\n", fname, lineno, 0 );
295 Debug( LDAP_DEBUG_ANY,
296 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
303 max = atol( cargv[1] );
307 LDAP_LOG( CONFIG, CRIT,
308 "%s: line %d: invalid max value (%ld) in "
309 "\"sockbuf_max_incoming <bytes>\" line.\n",
310 fname, lineno, max );
312 Debug( LDAP_DEBUG_ANY,
313 "%s: line %d: invalid max value (%ld) in "
314 "\"sockbuf_max_incoming <bytes>\" line.\n",
315 fname, lineno, max );
321 sockbuf_max_incoming = max;
323 /* set sockbuf max authenticated */
324 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
328 LDAP_LOG( CONFIG, CRIT,
329 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
330 "<bytes>\" line\n", fname, lineno, 0 );
332 Debug( LDAP_DEBUG_ANY,
333 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
340 max = atol( cargv[1] );
344 LDAP_LOG( CONFIG, CRIT,
345 "%s: line %d: invalid max value (%ld) in "
346 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
347 fname, lineno, max );
349 Debug( LDAP_DEBUG_ANY,
350 "%s: line %d: invalid max value (%ld) in "
351 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
352 fname, lineno, max );
358 sockbuf_max_incoming_auth = max;
360 /* set conn pending max */
361 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
365 LDAP_LOG( CONFIG, CRIT,
366 "%s: line %d: missing max in \"conn_max_pending "
367 "<requests>\" line\n", fname, lineno, 0 );
369 Debug( LDAP_DEBUG_ANY,
370 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
377 max = atol( cargv[1] );
381 LDAP_LOG( CONFIG, CRIT,
382 "%s: line %d: invalid max value (%ld) in "
383 "\"conn_max_pending <requests>\" line.\n",
384 fname, lineno, max );
386 Debug( LDAP_DEBUG_ANY,
387 "%s: line %d: invalid max value (%ld) in "
388 "\"conn_max_pending <requests>\" line.\n",
389 fname, lineno, max );
395 slap_conn_max_pending = max;
397 /* set conn pending max authenticated */
398 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
402 LDAP_LOG( CONFIG, CRIT,
403 "%s: line %d: missing max in \"conn_max_pending_auth "
404 "<requests>\" line\n", fname, lineno, 0 );
406 Debug( LDAP_DEBUG_ANY,
407 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
414 max = atol( cargv[1] );
418 LDAP_LOG( CONFIG, CRIT,
419 "%s: line %d: invalid max value (%ld) in "
420 "\"conn_max_pending_auth <requests>\" line.\n",
421 fname, lineno, max );
423 Debug( LDAP_DEBUG_ANY,
424 "%s: line %d: invalid max value (%ld) in "
425 "\"conn_max_pending_auth <requests>\" line.\n",
426 fname, lineno, max );
432 slap_conn_max_pending_auth = max;
434 /* default search base */
435 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
438 LDAP_LOG( CONFIG, CRIT,
439 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
440 "line\n", fname, lineno, 0 );
442 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
443 "missing dn in \"defaultSearchBase <dn>\" line\n",
449 } else if ( cargc > 2 ) {
451 LDAP_LOG( CONFIG, INFO,
452 "%s: line %d: extra cruft after <dn> in "
453 "\"defaultSearchBase %s\" line (ignored)\n",
454 fname, lineno, cargv[1] );
456 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
457 "extra cruft after <dn> in \"defaultSearchBase %s\", "
459 fname, lineno, cargv[1] );
463 if ( bi != NULL || be != NULL ) {
465 LDAP_LOG( CONFIG, CRIT,
466 "%s: line %d: defaultSearchBase line must appear "
467 "prior to any backend or database definitions\n",
470 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
471 "defaultSearchBaase line must appear prior to "
472 "any backend or database definition\n",
479 if ( default_search_nbase.bv_len ) {
481 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
482 "default search base \"%s\" already defined "
483 "(discarding old)\n", fname, lineno,
484 default_search_base.bv_val );
486 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
487 "default search base \"%s\" already defined "
488 "(discarding old)\n",
489 fname, lineno, default_search_base.bv_val );
492 free( default_search_base.bv_val );
493 free( default_search_nbase.bv_val );
496 if ( load_ucdata( NULL ) < 0 ) return 1;
501 dn.bv_val = cargv[1];
502 dn.bv_len = strlen( dn.bv_val );
504 rc = dnPrettyNormal( NULL, &dn,
505 &default_search_base,
506 &default_search_nbase, NULL );
508 if( rc != LDAP_SUCCESS ) {
510 LDAP_LOG( CONFIG, CRIT,
511 "%s: line %d: defaultSearchBase DN is invalid.\n",
514 Debug( LDAP_DEBUG_ANY,
515 "%s: line %d: defaultSearchBase DN is invalid\n",
522 /* set maximum threads in thread pool */
523 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
527 LDAP_LOG( CONFIG, CRIT,
528 "%s: line %d: missing count in \"threads <count>\" line\n",
531 Debug( LDAP_DEBUG_ANY,
532 "%s: line %d: missing count in \"threads <count>\" line\n",
539 c = strtol( cargv[1], &next, 10 );
540 if (next == NULL || next[0] != '\0' ) {
542 LDAP_LOG( CONFIG, CRIT,
543 "%s: line %d: unable to parse count \"%s\" in \"threads <count>\" line\n",
544 fname, lineno, cargv[1] );
546 Debug( LDAP_DEBUG_ANY,
547 "%s: line %d: unable to parse count \"%s\" in \"threads <count>\" line\n",
548 fname, lineno, cargv[1] );
555 LDAP_LOG( CONFIG, CRIT,
556 "%s: line %d: invalid level (%d) in \"threads <count>\""
557 "line\n", fname, lineno, c );
559 Debug( LDAP_DEBUG_ANY,
560 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
567 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
569 /* save for later use */
570 connection_pool_max = c;
572 /* get pid file name */
573 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
576 LDAP_LOG( CONFIG, CRIT,
577 "%s: line %d missing file name in \"pidfile <file>\" "
578 "line.\n", fname, lineno, 0 );
580 Debug( LDAP_DEBUG_ANY,
581 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
588 slapd_pid_file = ch_strdup( cargv[1] );
590 /* get args file name */
591 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
594 LDAP_LOG( CONFIG, CRIT,
595 "%s: %d: missing file name in "
596 "\"argsfile <file>\" line.\n",
599 Debug( LDAP_DEBUG_ANY,
600 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
607 slapd_args_file = ch_strdup( cargv[1] );
609 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
612 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
615 /* default password hash */
616 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
619 LDAP_LOG( CONFIG, CRIT,
620 "%s: line %d: missing hash in "
621 "\"password-hash <hash>\" line.\n",
624 Debug( LDAP_DEBUG_ANY,
625 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
631 if ( default_passwd_hash != NULL ) {
633 LDAP_LOG( CONFIG, CRIT,
634 "%s: line %d: already set default password_hash!\n",
637 Debug( LDAP_DEBUG_ANY,
638 "%s: line %d: already set default password_hash!\n",
645 for(i = 1; i < cargc; i++) {
646 if ( lutil_passwd_scheme( cargv[i] ) == 0 ) {
648 LDAP_LOG( CONFIG, CRIT,
649 "%s: line %d: password scheme \"%s\" not available\n",
650 fname, lineno, cargv[i] );
652 Debug( LDAP_DEBUG_ANY,
653 "%s: line %d: password scheme \"%s\" not available\n",
654 fname, lineno, cargv[i] );
657 ldap_charray_add( &default_passwd_hash, cargv[i] );
660 if( !default_passwd_hash ) {
662 LDAP_LOG( CONFIG, CRIT,
663 "%s: line %d: no valid hashes found\n",
666 Debug( LDAP_DEBUG_ANY,
667 "%s: line %d: no valid hashes found\n",
673 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
677 LDAP_LOG( CONFIG, CRIT,
678 "%s: line %d: missing format in "
679 "\"password-crypt-salt-format <format>\" line\n",
682 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
683 "\"password-crypt-salt-format <format>\" line\n",
690 lutil_salt_format( cargv[1] );
692 #ifdef SLAP_AUTH_REWRITE
693 /* use authid rewrite instead of sasl regexp */
694 } else if ( strncasecmp( cargv[0], "auth-rewrite",
695 STRLENOF("auth-rewrite") ) == 0 )
697 int rc = slap_sasl_rewrite_config( fname, lineno,
702 #endif /* SLAP_AUTH_REWRITE */
704 /* Auth + SASL config options */
705 } else if ( !strncasecmp( cargv[0], "auth", STRLENOF("auth") ) ||
706 !strncasecmp( cargv[0], "sasl", STRLENOF("sasl") ))
708 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
712 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
716 LDAP_LOG( CONFIG, CRIT,
717 "%s: line %d: missing dn in "
718 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
720 Debug( LDAP_DEBUG_ANY,
721 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
726 ber_str2bv( cargv[1], 0, 0, &dn );
728 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
729 &be->be_schemandn, NULL );
731 rc = dnPrettyNormal( NULL, &dn, &frontendDB->be_schemadn,
732 &frontendDB->be_schemandn, NULL );
734 if ( rc != LDAP_SUCCESS ) {
736 LDAP_LOG( CONFIG, CRIT,
737 "%s: line %d: schemadn DN is invalid.\n",
740 Debug( LDAP_DEBUG_ANY,
741 "%s: line %d: schemadn DN is invalid\n",
747 /* set UCDATA path */
748 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
752 LDAP_LOG( CONFIG, CRIT,
753 "%s: line %d: missing path in "
754 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
756 Debug( LDAP_DEBUG_ANY,
757 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
764 err = load_ucdata( cargv[1] );
768 LDAP_LOG( CONFIG, CRIT,
769 "%s: line %d: ucdata already loaded, ucdata-path "
770 "must be set earlier in the file and/or be "
771 "specified only once!\n", fname, lineno, 0 );
773 Debug( LDAP_DEBUG_ANY,
774 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
783 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
785 struct slap_limits_set *lim;
789 LDAP_LOG( CONFIG, CRIT,
790 "%s: line %d: missing limit in \"sizelimit <limit>\" "
791 "line.\n", fname, lineno, 0 );
793 Debug( LDAP_DEBUG_ANY,
794 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
802 lim = &frontendDB->be_def_limit;
804 lim = &be->be_def_limit;
807 for ( i = 1; i < cargc; i++ ) {
808 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
809 rc = limits_parse_one( cargv[i], lim );
812 LDAP_LOG( CONFIG, CRIT,
813 "%s: line %d: unable "
814 "to parse value \"%s\" in \"sizelimit "
815 "<limit>\" line.\n", fname, lineno, cargv[i] );
817 Debug( LDAP_DEBUG_ANY,
818 "%s: line %d: unable "
819 "to parse value \"%s\" "
822 fname, lineno, cargv[i] );
828 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
829 lim->lms_s_soft = -1;
831 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
832 if ( next == cargv[i] ) {
834 LDAP_LOG( CONFIG, CRIT,
835 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
836 "line.\n", fname, lineno, cargv[i] );
838 Debug( LDAP_DEBUG_ANY,
839 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
840 fname, lineno, cargv[i] );
844 } else if ( next[0] != '\0' ) {
846 LDAP_LOG( CONFIG, CRIT,
847 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
848 "line ignored.\n", fname, lineno, next );
850 Debug( LDAP_DEBUG_ANY,
851 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
852 fname, lineno, next );
861 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
863 struct slap_limits_set *lim;
867 LDAP_LOG( CONFIG, CRIT,
868 "%s: line %d missing limit in \"timelimit <limit>\" "
869 "line.\n", fname, lineno, 0 );
871 Debug( LDAP_DEBUG_ANY,
872 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
880 lim = &frontendDB->be_def_limit;
882 lim = &be->be_def_limit;
885 for ( i = 1; i < cargc; i++ ) {
886 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
887 rc = limits_parse_one( cargv[i], lim );
890 LDAP_LOG( CONFIG, CRIT,
891 "%s: line %d: unable to parse value \"%s\" "
892 "in \"timelimit <limit>\" line.\n",
893 fname, lineno, cargv[i] );
895 Debug( LDAP_DEBUG_ANY,
896 "%s: line %d: unable "
897 "to parse value \"%s\" "
900 fname, lineno, cargv[i] );
906 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
907 lim->lms_t_soft = -1;
909 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
910 if ( next == cargv[i] ) {
912 LDAP_LOG( CONFIG, CRIT,
913 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
914 "line.\n", fname, lineno, cargv[i] );
916 Debug( LDAP_DEBUG_ANY,
917 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
918 fname, lineno, cargv[i] );
922 } else if ( next[0] != '\0' ) {
924 LDAP_LOG( CONFIG, CRIT,
925 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
926 "line ignored.\n", fname, lineno, next );
928 Debug( LDAP_DEBUG_ANY,
929 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
930 fname, lineno, next );
938 /* set regex-based limits */
939 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
942 LDAP_LOG( CONFIG, WARNING,
943 "%s: line %d \"limits\" allowed only in database "
944 "environment.\n", fname, lineno, 0 );
946 Debug( LDAP_DEBUG_ANY,
947 "%s: line %d \"limits\" allowed only in database environment.\n%s",
953 if ( limits_parse( be, fname, lineno, cargc, cargv ) ) {
957 /* mark this as a subordinate database */
958 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
961 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
962 "subordinate keyword must appear inside a database "
963 "definition.\n", fname, lineno, 0 );
965 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
966 "must appear inside a database definition.\n",
972 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
976 /* add an overlay to this backend */
977 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
979 if ( cargv[1][0] == '-' && overlay_config( frontendDB, &cargv[1][1] ) ) {
982 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
983 "(optional) global overlay \"%s\" configuration "
984 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
986 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
987 "(optional) global overlay \"%s\" configuration "
988 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
990 } else if ( overlay_config( frontendDB, cargv[1] ) ) {
995 if ( cargv[1][0] == '-' && overlay_config( be, &cargv[1][1] ) ) {
998 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
999 "(optional) overlay \"%s\" configuration "
1000 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
1002 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1003 "(optional) overlay \"%s\" configuration "
1004 "failed (ignored)\n", fname, lineno, &cargv[1][1] );
1006 } else if ( overlay_config( be, cargv[1] ) ) {
1011 /* set database suffix */
1012 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
1014 struct berval dn, pdn, ndn;
1018 LDAP_LOG( CONFIG, CRIT,
1019 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
1022 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1023 "missing dn in \"suffix <dn>\" line\n",
1029 } else if ( cargc > 2 ) {
1031 LDAP_LOG( CONFIG, INFO,
1032 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
1033 " line (ignored).\n", fname, lineno, cargv[1] );
1035 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
1036 "after <dn> in \"suffix %s\" line (ignored)\n",
1037 fname, lineno, cargv[1] );
1043 LDAP_LOG( CONFIG, INFO,
1044 "%s: line %d: suffix line must appear inside a database "
1045 "definition.\n", fname, lineno, 0 );
1047 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
1048 "must appear inside a database definition\n",
1053 #if defined(SLAPD_MONITOR_DN)
1054 /* "cn=Monitor" is reserved for monitoring slap */
1055 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
1057 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
1058 "%s\" is reserved for monitoring slapd\n",
1059 fname, lineno, SLAPD_MONITOR_DN );
1061 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
1062 "%s\" is reserved for monitoring slapd\n",
1063 fname, lineno, SLAPD_MONITOR_DN );
1066 #endif /* SLAPD_MONITOR_DN */
1069 if ( load_ucdata( NULL ) < 0 ) return 1;
1071 dn.bv_val = cargv[1];
1072 dn.bv_len = strlen( cargv[1] );
1074 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1075 if( rc != LDAP_SUCCESS ) {
1077 LDAP_LOG( CONFIG, CRIT,
1078 "%s: line %d: suffix DN is invalid.\n",
1081 Debug( LDAP_DEBUG_ANY,
1082 "%s: line %d: suffix DN is invalid\n",
1088 tmp_be = select_backend( &ndn, 0, 0 );
1089 if ( tmp_be == be ) {
1091 LDAP_LOG( CONFIG, INFO,
1092 "%s: line %d: suffix already served by this backend "
1093 "(ignored)\n", fname, lineno, 0 );
1095 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1096 "already served by this backend (ignored)\n",
1102 } else if ( tmp_be != NULL ) {
1104 LDAP_LOG( CONFIG, INFO,
1105 "%s: line %d: suffix already served by a preceding "
1106 "backend \"%s\"\n", fname, lineno,
1107 tmp_be->be_suffix[0].bv_val );
1109 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1110 "already served by a preceeding backend \"%s\"\n",
1111 fname, lineno, tmp_be->be_suffix[0].bv_val );
1117 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1119 LDAP_LOG( CONFIG, INFO,
1120 "%s: line %d: suffix DN empty and default search "
1121 "base provided \"%s\" (assuming okay).\n",
1122 fname, lineno, default_search_base.bv_val );
1124 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1125 "suffix DN empty and default "
1126 "search base provided \"%s\" (assuming okay)\n",
1127 fname, lineno, default_search_base.bv_val );
1131 ber_bvarray_add( &be->be_suffix, &pdn );
1132 ber_bvarray_add( &be->be_nsuffix, &ndn );
1134 /* set max deref depth */
1135 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1139 LDAP_LOG( CONFIG, CRIT,
1140 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1141 " line\n", fname, lineno, 0 );
1143 Debug( LDAP_DEBUG_ANY,
1144 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1152 LDAP_LOG( CONFIG, INFO,
1153 "%s: line %d: depth line must appear inside a database "
1154 "definition.\n", fname, lineno ,0 );
1156 Debug( LDAP_DEBUG_ANY,
1157 "%s: line %d: depth line must appear inside a database definition.\n",
1163 i = strtol( cargv[1], &next, 10 );
1164 if ( next == NULL || next[0] != '\0' ) {
1166 LDAP_LOG( CONFIG, INFO,
1167 "%s: line %d: unable to parse depth \"%s\" in \"maxDerefDepth <depth>\" "
1168 "line.\n", fname, lineno, cargv[1] );
1170 Debug( LDAP_DEBUG_ANY,
1171 "%s: line %d: unable to parse depth \"%s\" in \"maxDerefDepth <depth>\" "
1172 "line.\n", fname, lineno, cargv[1] );
1179 LDAP_LOG( CONFIG, INFO,
1180 "%s: line %d: depth must be positive.\n",
1183 Debug( LDAP_DEBUG_ANY,
1184 "%s: line %d: depth must be positive.\n",
1191 be->be_max_deref_depth = i;
1193 /* set magic "root" dn for this database */
1194 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1197 LDAP_LOG( CONFIG, INFO,
1198 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1201 Debug( LDAP_DEBUG_ANY,
1202 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1211 LDAP_LOG( CONFIG, INFO,
1212 "%s: line %d: rootdn line must appear inside a database "
1213 "definition.\n", fname, lineno ,0 );
1215 Debug( LDAP_DEBUG_ANY,
1216 "%s: line %d: rootdn line must appear inside a database definition.\n",
1224 if ( load_ucdata( NULL ) < 0 ) return 1;
1226 dn.bv_val = cargv[1];
1227 dn.bv_len = strlen( cargv[1] );
1229 rc = dnPrettyNormal( NULL, &dn,
1231 &be->be_rootndn, NULL );
1233 if( rc != LDAP_SUCCESS ) {
1235 LDAP_LOG( CONFIG, CRIT,
1236 "%s: line %d: rootdn DN is invalid.\n",
1239 Debug( LDAP_DEBUG_ANY,
1240 "%s: line %d: rootdn DN is invalid\n",
1247 /* set super-secret magic database password */
1248 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1251 LDAP_LOG( CONFIG, CRIT,
1252 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1253 " line\n", fname, lineno ,0 );
1255 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1256 "missing passwd in \"rootpw <passwd>\" line\n",
1265 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1266 "rootpw line must appear inside a database "
1267 "definition.\n", fname, lineno ,0 );
1269 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1270 "rootpw line must appear inside a database "
1277 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1279 if( tmp_be != be ) {
1281 LDAP_LOG( CONFIG, INFO,
1283 "rootpw can only be set when rootdn is under suffix\n",
1284 fname, lineno, "" );
1286 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1287 "rootpw can only be set when rootdn is under suffix\n",
1293 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1294 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1297 /* make this database read-only */
1298 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1301 LDAP_LOG( CONFIG, CRIT,
1302 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1303 "line.\n", fname, lineno ,0 );
1305 Debug( LDAP_DEBUG_ANY,
1306 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1313 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1314 frontendDB->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1316 frontendDB->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1320 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1321 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1323 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1327 /* restricts specific operations */
1328 } else if ( strcasecmp( cargv[0], "restrict" ) == 0 ) {
1329 slap_mask_t restrict = 0;
1330 struct restrictable_exops_t {
1333 } restrictable_exops[] = {
1334 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
1335 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
1336 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
1337 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
1344 LDAP_LOG( CONFIG, CRIT,
1345 "%s: line %d: missing <op_list> in \"restrict <op_list>\" "
1346 "line.\n", fname, lineno ,0 );
1348 Debug( LDAP_DEBUG_ANY,
1349 "%s: line %d: missing <op_list> in \"restrict <op_list>\" "
1350 "line.\n", fname, lineno, 0 );
1356 for ( i = 1; i < cargc; i++ ) {
1357 if ( strcasecmp( cargv[ i ], "read" ) == 0 ) {
1358 restrict |= SLAP_RESTRICT_OP_READS;
1360 } else if ( strcasecmp( cargv[ i ], "write" ) == 0 ) {
1361 restrict |= SLAP_RESTRICT_OP_WRITES;
1363 } else if ( strcasecmp( cargv[ i ], "add" ) == 0 ) {
1364 restrict |= SLAP_RESTRICT_OP_ADD;
1366 } else if ( strcasecmp( cargv[ i ], "bind" ) == 0 ) {
1367 restrict |= SLAP_RESTRICT_OP_BIND;
1369 } else if ( strcasecmp( cargv[ i ], "compare" ) == 0 ) {
1370 restrict |= SLAP_RESTRICT_OP_COMPARE;
1372 } else if ( strcasecmp( cargv[ i ], "delete" ) == 0 ) {
1373 restrict |= SLAP_RESTRICT_OP_DELETE;
1375 } else if ( strncasecmp( cargv[ i ], "extended",
1376 STRLENOF( "extended" ) ) == 0 ) {
1377 char *e = cargv[ i ] + STRLENOF( "extended" );
1379 if ( e[0] == '=' ) {
1383 for ( j = 0; restrictable_exops[ j ].name; j++ ) {
1384 if ( strcmp( e, restrictable_exops[ j ].name ) == 0 ) {
1385 restrict |= restrictable_exops[ j ].flag;
1390 if ( restrictable_exops[ j ].name == NULL ) {
1391 goto restrict_unknown;
1394 restrict &= ~SLAP_RESTRICT_OP_EXTENDED;
1396 } else if ( e[0] == '\0' ) {
1397 restrict &= ~SLAP_RESTRICT_EXOP_MASK;
1398 restrict |= SLAP_RESTRICT_OP_EXTENDED;
1401 goto restrict_unknown;
1404 } else if ( strcasecmp( cargv[ i ], "modify" ) == 0 ) {
1405 restrict |= SLAP_RESTRICT_OP_MODIFY;
1407 } else if ( strcasecmp( cargv[ i ], "rename" ) == 0
1408 || strcasecmp( cargv[ i ], "modrdn" ) == 0 ) {
1409 restrict |= SLAP_RESTRICT_OP_RENAME;
1411 } else if ( strcasecmp( cargv[ i ], "search" ) == 0 ) {
1412 restrict |= SLAP_RESTRICT_OP_SEARCH;
1418 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1419 "unknown operation %s in \"allow <features>\" line.\n",
1420 fname, lineno, cargv[i] );
1422 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1423 "unknown operation %s in \"allow <features>\" line\n",
1424 fname, lineno, cargv[i] );
1431 frontendDB->be_restrictops |= restrict;
1434 be->be_restrictops |= restrict;
1437 /* allow these features */
1438 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1439 strcasecmp( cargv[0], "allow" ) == 0 )
1441 slap_mask_t allows = 0;
1445 LDAP_LOG( CONFIG, INFO,
1446 "%s: line %d: allow line must appear prior to "
1447 "database definitions.\n", fname, lineno ,0 );
1449 Debug( LDAP_DEBUG_ANY,
1450 "%s: line %d: allow line must appear prior to database definitions\n",
1458 LDAP_LOG( CONFIG, CRIT,
1459 "%s: line %d: missing feature(s) in \"allow <features>\""
1460 " line\n", fname, lineno ,0 );
1462 Debug( LDAP_DEBUG_ANY,
1463 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1470 for( i=1; i < cargc; i++ ) {
1471 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1472 allows |= SLAP_ALLOW_BIND_V2;
1474 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1475 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1477 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1478 allows |= SLAP_ALLOW_BIND_ANON_DN;
1480 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1481 allows |= SLAP_ALLOW_UPDATE_ANON;
1485 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1486 "unknown feature %s in \"allow <features>\" line.\n",
1487 fname, lineno, cargv[i] );
1489 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1490 "unknown feature %s in \"allow <features>\" line\n",
1491 fname, lineno, cargv[i] );
1498 global_allows |= allows;
1500 /* disallow these features */
1501 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1502 strcasecmp( cargv[0], "disallow" ) == 0 )
1504 slap_mask_t disallows = 0;
1508 LDAP_LOG( CONFIG, INFO,
1509 "%s: line %d: disallow line must appear prior to "
1510 "database definitions.\n", fname, lineno ,0 );
1512 Debug( LDAP_DEBUG_ANY,
1513 "%s: line %d: disallow line must appear prior to database definitions\n",
1521 LDAP_LOG( CONFIG, CRIT,
1522 "%s: line %d: missing feature(s) in \"disallow <features>\""
1523 " line.\n", fname, lineno ,0 );
1525 Debug( LDAP_DEBUG_ANY,
1526 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1533 for( i=1; i < cargc; i++ ) {
1534 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1535 disallows |= SLAP_DISALLOW_BIND_ANON;
1537 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1538 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1540 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1541 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1543 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1544 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1546 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1547 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1551 LDAP_LOG( CONFIG, CRIT,
1552 "%s: line %d: unknown feature %s in "
1553 "\"disallow <features>\" line.\n",
1554 fname, lineno, cargv[i] );
1556 Debug( LDAP_DEBUG_ANY,
1557 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1558 fname, lineno, cargv[i] );
1565 global_disallows |= disallows;
1567 /* require these features */
1568 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1569 strcasecmp( cargv[0], "require" ) == 0 )
1571 slap_mask_t requires = 0;
1575 LDAP_LOG( CONFIG, CRIT,
1576 "%s: line %d: missing feature(s) in "
1577 "\"require <features>\" line.\n", fname, lineno ,0 );
1579 Debug( LDAP_DEBUG_ANY,
1580 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1587 for( i=1; i < cargc; i++ ) {
1588 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1589 requires |= SLAP_REQUIRE_BIND;
1591 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1592 requires |= SLAP_REQUIRE_LDAP_V3;
1594 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1595 requires |= SLAP_REQUIRE_AUTHC;
1597 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1598 requires |= SLAP_REQUIRE_SASL;
1600 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1601 requires |= SLAP_REQUIRE_STRONG;
1603 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1605 LDAP_LOG( CONFIG, CRIT,
1606 "%s: line %d: unknown feature %s in "
1607 "\"require <features>\" line.\n",
1608 fname, lineno , cargv[i] );
1610 Debug( LDAP_DEBUG_ANY,
1611 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1612 fname, lineno, cargv[i] );
1620 frontendDB->be_requires = requires;
1622 be->be_requires = requires;
1625 /* required security factors */
1626 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1627 slap_ssf_set_t *set;
1631 LDAP_LOG( CONFIG, CRIT,
1632 "%s: line %d: missing factor(s) in \"security <factors>\""
1633 " line.\n", fname, lineno ,0 );
1635 Debug( LDAP_DEBUG_ANY,
1636 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1644 set = &frontendDB->be_ssf_set;
1646 set = &be->be_ssf_set;
1649 for( i=1; i < cargc; i++ ) {
1653 if ( strncasecmp( cargv[i], "ssf=",
1654 STRLENOF("ssf=") ) == 0 )
1656 tgt = &set->sss_ssf;
1657 src = &cargv[i][STRLENOF("ssf=")];
1659 } else if ( strncasecmp( cargv[i], "transport=",
1660 STRLENOF("transport=") ) == 0 )
1662 tgt = &set->sss_transport;
1663 src = &cargv[i][STRLENOF("transport=")];
1665 } else if ( strncasecmp( cargv[i], "tls=",
1666 STRLENOF("tls=") ) == 0 )
1668 tgt = &set->sss_tls;
1669 src = &cargv[i][STRLENOF("tls=")];
1671 } else if ( strncasecmp( cargv[i], "sasl=",
1672 STRLENOF("sasl=") ) == 0 )
1674 tgt = &set->sss_sasl;
1675 src = &cargv[i][STRLENOF("sasl=")];
1677 } else if ( strncasecmp( cargv[i], "update_ssf=",
1678 STRLENOF("update_ssf=") ) == 0 )
1680 tgt = &set->sss_update_ssf;
1681 src = &cargv[i][STRLENOF("update_ssf=")];
1683 } else if ( strncasecmp( cargv[i], "update_transport=",
1684 STRLENOF("update_transport=") ) == 0 )
1686 tgt = &set->sss_update_transport;
1687 src = &cargv[i][STRLENOF("update_transport=")];
1689 } else if ( strncasecmp( cargv[i], "update_tls=",
1690 STRLENOF("update_tls=") ) == 0 )
1692 tgt = &set->sss_update_tls;
1693 src = &cargv[i][STRLENOF("update_tls=")];
1695 } else if ( strncasecmp( cargv[i], "update_sasl=",
1696 STRLENOF("update_sasl=") ) == 0 )
1698 tgt = &set->sss_update_sasl;
1699 src = &cargv[i][STRLENOF("update_sasl=")];
1701 } else if ( strncasecmp( cargv[i], "simple_bind=",
1702 STRLENOF("simple_bind=") ) == 0 )
1704 tgt = &set->sss_simple_bind;
1705 src = &cargv[i][STRLENOF("simple_bind=")];
1709 LDAP_LOG( CONFIG, CRIT,
1710 "%s: line %d: unknown factor %s in "
1711 "\"security <factors>\" line.\n",
1712 fname, lineno, cargv[1] );
1714 Debug( LDAP_DEBUG_ANY,
1715 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1716 fname, lineno, cargv[i] );
1722 *tgt = strtol( src, &next, 10 );
1723 if ( next == NULL || next[0] != '\0' ) {
1725 LDAP_LOG( CONFIG, CRIT,
1726 "%s: line %d: unable to parse factor \"%s\" in "
1727 "\"security <factors>\" line.\n",
1728 fname, lineno, cargv[1] );
1730 Debug( LDAP_DEBUG_ANY,
1731 "%s: line %d: unable to parse factor \"%s\" in \"security <factors>\" line\n",
1732 fname, lineno, cargv[i] );
1739 /* where to send clients when we don't hold it */
1740 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1743 LDAP_LOG( CONFIG, CRIT,
1744 "%s: line %d: missing URL in \"referral <URL>\""
1745 " line.\n", fname, lineno , 0 );
1747 Debug( LDAP_DEBUG_ANY,
1748 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1755 if( validate_global_referral( cargv[1] ) ) {
1757 LDAP_LOG( CONFIG, CRIT,
1758 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1759 fname, lineno, cargv[1] );
1761 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1762 "invalid URL (%s) in \"referral\" line.\n",
1763 fname, lineno, cargv[1] );
1768 vals[0].bv_val = cargv[1];
1769 vals[0].bv_len = strlen( vals[0].bv_val );
1770 if( value_add( &default_referral, vals ) )
1774 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1778 LDAP_LOG( CONFIG, CRIT,
1779 "%s: line %d: Error in logfile directive, "
1780 "\"logfile <filename>\"\n", fname, lineno , 0 );
1782 Debug( LDAP_DEBUG_ANY,
1783 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1789 logfile = fopen( cargv[1], "w" );
1790 if ( logfile != NULL ) lutil_debug_file( logfile );
1793 /* start of a new database definition */
1794 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1798 LDAP_LOG( CONFIG, CRIT,
1799 "%s: line %d: Error in debug directive, "
1800 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1802 Debug( LDAP_DEBUG_ANY,
1803 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1808 level = strtol( cargv[2], &next, 10 );
1809 if ( next == NULL || next[0] != '\0' ){
1811 LDAP_LOG( CONFIG, CRIT,
1812 "%s: line %d: unable to parse level \"%s\" in debug directive, "
1813 "\"debug <subsys> <level>\"\n", fname, lineno , cargv[2] );
1815 Debug( LDAP_DEBUG_ANY,
1816 "%s: line %d: unable to parse level \"%s\" in debug directive, "
1817 "\"debug <subsys> <level>\"\n", fname, lineno , cargv[2] );
1822 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1823 lutil_set_debug_level( cargv[1], level );
1824 /* specify an Object Identifier macro */
1825 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1826 rc = parse_oidm( fname, lineno, cargc, cargv );
1829 /* specify an objectclass */
1830 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1833 LDAP_LOG( CONFIG, INFO,
1834 "%s: line %d: illegal objectclass format.\n",
1835 fname, lineno , 0 );
1837 Debug( LDAP_DEBUG_ANY,
1838 "%s: line %d: illegal objectclass format.\n",
1843 } else if ( *cargv[1] == '(' /*')'*/) {
1845 p = strchr(saveline,'(' /*')'*/);
1846 rc = parse_oc( fname, lineno, p, cargv );
1851 LDAP_LOG( CONFIG, INFO,
1852 "%s: line %d: old objectclass format not supported\n",
1853 fname, lineno , 0 );
1855 Debug( LDAP_DEBUG_ANY,
1856 "%s: line %d: old objectclass format not supported.\n",
1861 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1863 p = strchr(saveline,'(' /*')'*/);
1864 rc = parse_cr( fname, lineno, p, cargv );
1867 /* specify an attribute type */
1868 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1869 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1873 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1874 "illegal attribute type format.\n",
1875 fname, lineno , 0 );
1877 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1878 "illegal attribute type format.\n",
1883 } else if ( *cargv[1] == '(' /*')'*/) {
1885 p = strchr(saveline,'(' /*')'*/);
1886 rc = parse_at( fname, lineno, p, cargv );
1891 LDAP_LOG( CONFIG, INFO,
1892 "%s: line %d: old attribute type format not supported.\n",
1893 fname, lineno , 0 );
1895 Debug( LDAP_DEBUG_ANY,
1896 "%s: line %d: old attribute type format not supported.\n",
1902 /* define attribute option(s) */
1903 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1904 ad_define_option( NULL, NULL, 0 );
1905 for ( i = 1; i < cargc; i++ )
1906 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1909 /* turn on/off schema checking */
1910 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1913 LDAP_LOG( CONFIG, CRIT,
1914 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1915 " line.\n", fname, lineno , 0 );
1917 Debug( LDAP_DEBUG_ANY,
1918 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1924 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1926 LDAP_LOG( CONFIG, CRIT,
1927 "%s: line %d: schema checking disabled! your mileage may "
1928 "vary!\n", fname, lineno , 0 );
1930 Debug( LDAP_DEBUG_ANY,
1931 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1934 global_schemacheck = 0;
1936 global_schemacheck = 1;
1939 /* specify access control info */
1940 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1941 parse_acl( be, fname, lineno, cargc, cargv );
1943 /* debug level to log things to syslog */
1944 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1947 LDAP_LOG( CONFIG, CRIT,
1948 "%s: line %d: missing level(s) in \"loglevel <level> [...]\""
1949 " line.\n", fname, lineno , 0 );
1951 Debug( LDAP_DEBUG_ANY,
1952 "%s: line %d: missing level(s) in \"loglevel <level> [...]\" line\n",
1961 for( i=1; i < cargc; i++ ) {
1964 if ( isdigit( cargv[i][0] ) ) {
1965 level = strtol( cargv[i], &next, 10 );
1966 if ( next == NULL || next[0] != '\0' ) {
1968 LDAP_LOG( CONFIG, CRIT,
1969 "%s: line %d: unable to parse level \"%s\" "
1970 "in \"loglevel <level> [...]\" line.\n",
1971 fname, lineno , cargv[i] );
1973 Debug( LDAP_DEBUG_ANY,
1974 "%s: line %d: unable to parse level \"%s\" "
1975 "in \"loglevel <level> [...]\" line.\n",
1976 fname, lineno , cargv[i] );
1986 { LDAP_DEBUG_TRACE, "Trace" },
1987 { LDAP_DEBUG_PACKETS, "Packets" },
1988 { LDAP_DEBUG_ARGS, "Args" },
1989 { LDAP_DEBUG_CONNS, "Conns" },
1990 { LDAP_DEBUG_BER, "BER" },
1991 { LDAP_DEBUG_FILTER, "Filter" },
1992 { LDAP_DEBUG_CONFIG, "Config" },
1993 { LDAP_DEBUG_ACL, "ACL" },
1994 { LDAP_DEBUG_STATS, "Stats" },
1995 { LDAP_DEBUG_STATS2, "Stats2" },
1996 { LDAP_DEBUG_SHELL, "Shell" },
1997 { LDAP_DEBUG_PARSE, "Parse" },
1998 { LDAP_DEBUG_CACHE, "Cache" },
1999 { LDAP_DEBUG_INDEX, "Index" },
2005 for ( j = 0; int_2_level[j].s; j++ ) {
2006 if ( strcasecmp( cargv[i], int_2_level[j].s ) == 0 ) {
2007 level = int_2_level[j].i;
2012 if ( int_2_level[j].s == NULL ) {
2014 LDAP_LOG( CONFIG, CRIT,
2015 "%s: line %d: unknown level \"%s\" "
2016 "in \"loglevel <level> [...]\" line.\n",
2017 fname, lineno , cargv[i] );
2019 Debug( LDAP_DEBUG_ANY,
2020 "%s: line %d: unknown level \"%s\" "
2021 "in \"loglevel <level> [...]\" line.\n",
2022 fname, lineno , cargv[i] );
2028 ldap_syslog |= level;
2031 /* list of sync replication information in this backend (slave only) */
2032 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
2036 LDAP_LOG( CONFIG, INFO,
2037 "%s: line %d: syncrepl line must appear inside "
2038 "a database definition.\n", fname, lineno, 0);
2040 Debug( LDAP_DEBUG_ANY,
2041 "%s: line %d: syncrepl line must appear inside "
2042 "a database definition.\n", fname, lineno, 0);
2046 } else if ( SLAP_SHADOW( be )) {
2048 LDAP_LOG( CONFIG, INFO,
2049 "%s: line %d: syncrepl: database already shadowed.\n",
2052 Debug( LDAP_DEBUG_ANY,
2053 "%s: line %d: syncrepl: database already shadowed.\n",
2058 } else if ( add_syncrepl( be, cargv, cargc )) {
2062 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW );
2064 /* list of replicas of the data in this backend (master only) */
2065 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
2068 LDAP_LOG( CONFIG, CRIT,
2069 "%s: line %d: missing host or uri in \"replica "
2070 " <host[:port]\" line\n", fname, lineno , 0 );
2072 Debug( LDAP_DEBUG_ANY,
2073 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
2081 LDAP_LOG( CONFIG, INFO,
2082 "%s: line %d: replica line must appear inside "
2083 "a database definition.\n", fname, lineno, 0);
2085 Debug( LDAP_DEBUG_ANY,
2086 "%s: line %d: replica line must appear inside a database definition\n",
2094 for ( i = 1; i < cargc; i++ ) {
2095 if ( strncasecmp( cargv[i], "host=", 5 )
2097 nr = add_replica_info( be,
2100 } else if (strncasecmp( cargv[i], "uri=", 4 )
2102 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
2105 LDAP_LOG( CONFIG, INFO,
2106 "%s: line %d: replica line contains invalid "
2107 "uri definition.\n", fname, lineno, 0);
2109 Debug( LDAP_DEBUG_ANY,
2110 "%s: line %d: replica line contains invalid "
2111 "uri definition.\n", fname, lineno, 0);
2115 if (ludp->lud_host == NULL ) {
2117 LDAP_LOG( CONFIG, INFO,
2118 "%s: line %d: replica line contains invalid "
2119 "uri definition - missing hostname.\n",
2122 Debug( LDAP_DEBUG_ANY,
2123 "%s: line %d: replica line contains invalid "
2124 "uri definition - missing hostname.\n", fname, lineno, 0);
2128 replicahost = ch_malloc( strlen( cargv[ i ] ) );
2129 if ( replicahost == NULL ) {
2131 LDAP_LOG( CONFIG, ERR,
2132 "out of memory in read_config\n", 0, 0,0 );
2134 Debug( LDAP_DEBUG_ANY,
2135 "out of memory in read_config\n", 0, 0, 0 );
2137 ldap_free_urldesc( ludp );
2138 exit( EXIT_FAILURE );
2140 sprintf(replicahost, "%s:%d",
2141 ludp->lud_host, ludp->lud_port);
2142 nr = add_replica_info( be, replicahost );
2143 ldap_free_urldesc( ludp );
2144 ch_free(replicahost);
2150 LDAP_LOG( CONFIG, INFO,
2151 "%s: line %d: missing host or uri in \"replica\" line\n",
2152 fname, lineno , 0 );
2154 Debug( LDAP_DEBUG_ANY,
2155 "%s: line %d: missing host or uri in \"replica\" line\n",
2160 } else if ( nr == -1 ) {
2162 LDAP_LOG( CONFIG, INFO,
2163 "%s: line %d: unable to add"
2164 " replica \"%s\"\n",
2168 Debug( LDAP_DEBUG_ANY,
2169 "%s: line %d: unable to add replica \"%s\"\n",
2170 fname, lineno, cargv[i] + 5 );
2174 for ( i = 1; i < cargc; i++ ) {
2175 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
2177 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
2180 LDAP_LOG( CONFIG, INFO,
2181 "%s: line %d: suffix \"%s\" in \"replica\""
2182 " line is not valid for backend(ignored)\n",
2183 fname, lineno, cargv[i] + 7 );
2185 Debug( LDAP_DEBUG_ANY,
2186 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
2187 fname, lineno, cargv[i] + 7 );
2193 LDAP_LOG( CONFIG, INFO,
2194 "%s: line %d: unable to normalize suffix"
2195 " in \"replica\" line (ignored)\n",
2196 fname, lineno , 0 );
2198 Debug( LDAP_DEBUG_ANY,
2199 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
2205 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
2207 char *arg = cargv[i] + 4;
2209 if ( arg[0] == '!' ) {
2214 if ( arg[0] != '=' ) {
2218 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
2220 LDAP_LOG( CONFIG, INFO,
2221 "%s: line %d: attribute \"%s\" in "
2222 "\"replica\" line is unknown\n",
2223 fname, lineno, arg + 1 );
2225 Debug( LDAP_DEBUG_ANY,
2226 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
2227 fname, lineno, arg + 1 );
2236 } else if ( strcasecmp( cargv[0], "replicationInterval" ) == 0 ) {
2239 /* dn of slave entity allowed to write to replica */
2240 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
2243 LDAP_LOG( CONFIG, CRIT,
2244 "%s: line %d: missing dn in \"updatedn <dn>\""
2245 " line.\n", fname, lineno , 0 );
2247 Debug( LDAP_DEBUG_ANY,
2248 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
2256 LDAP_LOG( CONFIG, INFO,
2257 "%s: line %d: updatedn line must appear inside "
2258 "a database definition\n",
2259 fname, lineno , 0 );
2261 Debug( LDAP_DEBUG_ANY,
2262 "%s: line %d: updatedn line must appear inside a database definition\n",
2267 } else if ( SLAP_SHADOW(be) ) {
2269 LDAP_LOG( CONFIG, INFO,
2270 "%s: line %d: updatedn: database already shadowed.\n",
2273 Debug( LDAP_DEBUG_ANY,
2274 "%s: line %d: updatedn: database already shadowed.\n",
2282 if ( load_ucdata( NULL ) < 0 ) return 1;
2284 dn.bv_val = cargv[1];
2285 dn.bv_len = strlen( cargv[1] );
2287 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
2288 if( rc != LDAP_SUCCESS ) {
2290 LDAP_LOG( CONFIG, CRIT,
2291 "%s: line %d: updatedn DN is invalid.\n",
2292 fname, lineno , 0 );
2294 Debug( LDAP_DEBUG_ANY,
2295 "%s: line %d: updatedn DN is invalid\n",
2302 SLAP_DBFLAGS(be) |= ( SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW );
2304 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
2307 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2308 "missing url in \"updateref <ldapurl>\" line.\n",
2309 fname, lineno , 0 );
2311 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2312 "missing url in \"updateref <ldapurl>\" line\n",
2320 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2321 " line must appear inside a database definition\n",
2322 fname, lineno , 0 );
2324 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2325 " line must appear inside a database definition\n",
2330 } else if ( !SLAP_SHADOW(be) ) {
2332 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2333 "updateref line must come after syncrepl or updatedn.\n",
2334 fname, lineno , 0 );
2336 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2337 "updateref line must after syncrepl or updatedn.\n",
2343 if( validate_global_referral( cargv[1] ) ) {
2345 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2346 "invalid URL (%s) in \"updateref\" line.\n",
2347 fname, lineno, cargv[1] );
2349 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2350 "invalid URL (%s) in \"updateref\" line.\n",
2351 fname, lineno, cargv[1] );
2356 vals[0].bv_val = cargv[1];
2357 vals[0].bv_len = strlen( vals[0].bv_val );
2358 if( value_add( &be->be_update_refs, vals ) ) {
2362 /* replication log file to which changes are appended */
2363 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2366 LDAP_LOG( CONFIG, CRIT,
2367 "%s: line %d: missing filename in \"replogfile <filename>\""
2368 " line.\n", fname, lineno , 0 );
2370 Debug( LDAP_DEBUG_ANY,
2371 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2378 be->be_replogfile = ch_strdup( cargv[1] );
2380 replogfile = ch_strdup( cargv[1] );
2383 /* file from which to read additional rootdse attrs */
2384 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2387 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2388 "missing filename in \"rootDSE <filename>\" line.\n",
2389 fname, lineno , 0 );
2391 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2392 "missing filename in \"rootDSE <filename>\" line.\n",
2398 if( read_root_dse_file( cargv[1] ) ) {
2400 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2401 "could not read \"rootDSE <filename>\" line.\n",
2402 fname, lineno , 0 );
2404 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2405 "could not read \"rootDSE <filename>\" line\n",
2411 /* maintain lastmodified{by,time} attributes */
2412 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2415 LDAP_LOG( CONFIG, CRIT,
2416 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2417 " line.\n", fname, lineno , 0 );
2419 Debug( LDAP_DEBUG_ANY,
2420 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2429 LDAP_LOG( CONFIG, INFO, "%s: line %d: lastmod"
2430 " line must appear inside a database definition\n",
2431 fname, lineno , 0 );
2433 Debug( LDAP_DEBUG_ANY, "%s: line %d: lastmod"
2434 " line must appear inside a database definition\n",
2439 } else if ( SLAP_NOLASTMODCMD(be) ) {
2441 LDAP_LOG( CONFIG, INFO, "%s: line %d: lastmod"
2442 " not available for %s database\n",
2443 fname, lineno , be->bd_info->bi_type );
2445 Debug( LDAP_DEBUG_ANY, "%s: line %d: lastmod"
2446 " not available for %s databases\n",
2447 fname, lineno, be->bd_info->bi_type );
2452 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2453 SLAP_DBFLAGS(be) &= ~SLAP_DBFLAG_NOLASTMOD;
2455 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NOLASTMOD;
2459 /* turn on/off gentle SIGHUP handling */
2460 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2462 Debug( LDAP_DEBUG_ANY,
2463 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2467 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2468 global_gentlehup = 0;
2470 global_gentlehup = 1;
2474 /* set idle timeout value */
2475 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2479 LDAP_LOG( CONFIG, CRIT,
2480 "%s: line %d: missing timeout value in "
2481 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2483 Debug( LDAP_DEBUG_ANY,
2484 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2491 i = atoi( cargv[1] );
2495 LDAP_LOG( CONFIG, CRIT,
2496 "%s: line %d: timeout value (%d) invalid "
2497 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2499 Debug( LDAP_DEBUG_ANY,
2500 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2507 global_idletimeout = i;
2509 /* include another config file */
2510 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2513 LDAP_LOG( CONFIG, CRIT,
2514 "%s: line %d: missing filename in \"include "
2515 "<filename>\" line.\n", fname, lineno , 0 );
2517 Debug( LDAP_DEBUG_ANY,
2518 "%s: line %d: missing filename in \"include <filename>\" line\n",
2524 savefname = ch_strdup( cargv[1] );
2525 savelineno = lineno;
2527 if ( read_config( savefname, depth+1 ) != 0 ) {
2532 lineno = savelineno - 1;
2534 /* location of kerberos srvtab file */
2535 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2538 LDAP_LOG( CONFIG, CRIT,
2539 "%s: line %d: missing filename in \"srvtab "
2540 "<filename>\" line.\n", fname, lineno , 0 );
2542 Debug( LDAP_DEBUG_ANY,
2543 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2549 ldap_srvtab = ch_strdup( cargv[1] );
2551 #ifdef SLAPD_MODULES
2552 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2555 LDAP_LOG( CONFIG, INFO,
2556 "%s: line %d: missing filename in \"moduleload "
2557 "<filename>\" line.\n", fname, lineno , 0 );
2559 Debug( LDAP_DEBUG_ANY,
2560 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2564 exit( EXIT_FAILURE );
2566 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2568 LDAP_LOG( CONFIG, CRIT,
2569 "%s: line %d: failed to load or initialize module %s\n",
2570 fname, lineno, cargv[1] );
2572 Debug( LDAP_DEBUG_ANY,
2573 "%s: line %d: failed to load or initialize module %s\n",
2574 fname, lineno, cargv[1]);
2577 exit( EXIT_FAILURE );
2579 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2582 LDAP_LOG( CONFIG, INFO,
2583 "%s: line %d: missing path in \"modulepath <path>\""
2584 " line\n", fname, lineno , 0 );
2586 Debug( LDAP_DEBUG_ANY,
2587 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2591 exit( EXIT_FAILURE );
2593 if (module_path( cargv[1] )) {
2595 LDAP_LOG( CONFIG, CRIT,
2596 "%s: line %d: failed to set module search path to %s.\n",
2597 fname, lineno, cargv[1] );
2599 Debug( LDAP_DEBUG_ANY,
2600 "%s: line %d: failed to set module search path to %s\n",
2601 fname, lineno, cargv[1]);
2604 exit( EXIT_FAILURE );
2607 #endif /*SLAPD_MODULES*/
2610 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2611 rc = ldap_pvt_tls_set_option( NULL,
2612 LDAP_OPT_X_TLS_RANDOM_FILE,
2617 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2618 rc = ldap_pvt_tls_set_option( NULL,
2619 LDAP_OPT_X_TLS_CIPHER_SUITE,
2624 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2625 rc = ldap_pvt_tls_set_option( NULL,
2626 LDAP_OPT_X_TLS_CERTFILE,
2631 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2632 rc = ldap_pvt_tls_set_option( NULL,
2633 LDAP_OPT_X_TLS_KEYFILE,
2638 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2639 rc = ldap_pvt_tls_set_option( NULL,
2640 LDAP_OPT_X_TLS_CACERTDIR,
2645 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2646 rc = ldap_pvt_tls_set_option( NULL,
2647 LDAP_OPT_X_TLS_CACERTFILE,
2651 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2652 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2654 rc = ldap_pvt_tls_set_option( NULL,
2655 LDAP_OPT_X_TLS_REQUIRE_CERT,
2658 rc = ldap_int_tls_config( NULL,
2659 LDAP_OPT_X_TLS_REQUIRE_CERT,
2668 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2669 #ifdef SLAPD_RLOOKUPS
2672 LDAP_LOG( CONFIG, INFO,
2673 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2674 fname, lineno , 0 );
2676 Debug( LDAP_DEBUG_ANY,
2677 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2683 if ( !strcasecmp( cargv[1], "on" ) ) {
2684 use_reverse_lookup = 1;
2685 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2686 use_reverse_lookup = 0;
2689 LDAP_LOG( CONFIG, INFO,
2690 "%s: line %d: reverse-lookup: "
2691 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2693 Debug( LDAP_DEBUG_ANY,
2694 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2700 #else /* !SLAPD_RLOOKUPS */
2702 LDAP_LOG( CONFIG, INFO,
2703 "%s: line %d: reverse lookups "
2704 "are not configured (ignored).\n", fname, lineno , 0 );
2706 Debug( LDAP_DEBUG_ANY,
2707 "%s: line %d: reverse lookups are not configured (ignored).\n",
2710 #endif /* !SLAPD_RLOOKUPS */
2712 /* Netscape plugins */
2713 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2714 #if defined( LDAP_SLAPI )
2716 #ifdef notdef /* allow global plugins, too */
2718 * a "plugin" line must be inside a database
2719 * definition, since we implement pre-,post-
2720 * and extended operation plugins
2724 LDAP_LOG( CONFIG, INFO,
2725 "%s: line %d: plugin line must appear "
2726 "insid a database definition.\n",
2729 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2730 "line must appear inside a database "
2731 "definition\n", fname, lineno, 0 );
2737 if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
2741 LDAP_LOG( CONFIG, INFO,
2742 "%s: line %d: SLAPI config read failed.\n",
2745 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2746 "config read failed.\n", fname, lineno, 0 );
2750 slapi_plugins_used++;
2752 #else /* !defined( LDAP_SLAPI ) */
2754 LDAP_LOG( CONFIG, INFO,
2755 "%s: line %d: SLAPI not supported.\n",
2758 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2759 "not supported.\n", fname, lineno, 0 );
2763 #endif /* !defined( LDAP_SLAPI ) */
2765 /* Netscape plugins */
2766 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2767 #if defined( LDAP_SLAPI )
2770 LDAP_LOG( CONFIG, INFO,
2771 "%s: line %d: missing file name "
2772 "in pluginlog <filename> line.\n",
2775 Debug( LDAP_DEBUG_ANY,
2776 "%s: line %d: missing file name "
2777 "in pluginlog <filename> line.\n",
2783 if ( slapi_log_file != NULL ) {
2784 ch_free( slapi_log_file );
2787 slapi_log_file = ch_strdup( cargv[1] );
2788 #endif /* !defined( LDAP_SLAPI ) */
2790 /* pass anything else to the current backend info/db config routine */
2793 if ( bi->bi_config ) {
2794 rc = (*bi->bi_config)( bi, fname, lineno, cargc, cargv );
2800 case SLAP_CONF_UNKNOWN:
2802 LDAP_LOG( CONFIG, INFO,
2803 "%s: line %d: unknown directive \"%s\" inside "
2804 "backend info definition (ignored).\n",
2805 fname, lineno, cargv[0] );
2807 Debug( LDAP_DEBUG_ANY,
2808 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2809 fname, lineno, cargv[0] );
2818 } else if ( be != NULL ) {
2819 if ( be->be_config ) {
2820 rc = (*be->be_config)( be, fname, lineno, cargc, cargv );
2826 case SLAP_CONF_UNKNOWN:
2828 LDAP_LOG( CONFIG, INFO,
2829 "%s: line %d: unknown directive \"%s\" inside "
2830 "backend database definition (ignored).\n",
2831 fname, lineno, cargv[0] );
2833 Debug( LDAP_DEBUG_ANY,
2834 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2835 fname, lineno, cargv[0] );
2845 if ( frontendDB->be_config ) {
2846 rc = (*frontendDB->be_config)( frontendDB, fname, lineno, cargc, cargv );
2852 case SLAP_CONF_UNKNOWN:
2854 LDAP_LOG( CONFIG, INFO,
2855 "%s: line %d: unknown directive \"%s\" inside "
2856 "global database definition (ignored).\n",
2857 fname, lineno, cargv[0] );
2859 Debug( LDAP_DEBUG_ANY,
2860 "%s: line %d: unknown directive \"%s\" inside global database definition (ignored)\n",
2861 fname, lineno, cargv[0] );
2875 if ( depth == 0 ) ch_free( cargv );
2877 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
2878 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2879 &frontendDB->be_schemadn );
2880 dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
2883 if ( load_ucdata( NULL ) < 0 ) return 1;
2895 char logbuf[sizeof("pseudorootpw ***")];
2898 token = strtok_quote( line, " \t" );
2902 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2903 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2904 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2905 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2906 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2908 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2911 if ( strtok_quote_ptr ) {
2912 *strtok_quote_ptr = ' ';
2916 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2918 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2921 if ( strtok_quote_ptr ) {
2922 *strtok_quote_ptr = '\0';
2925 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2926 if ( cargc == cargv_size - 1 ) {
2928 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2930 if ( tmp == NULL ) {
2932 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2934 Debug( LDAP_DEBUG_ANY,
2935 "line %d: out of memory\n",
2941 cargv_size += ARGS_STEP;
2943 cargv[cargc++] = token;
2945 cargv[cargc] = NULL;
2950 strtok_quote( char *line, char *sep )
2956 strtok_quote_ptr = NULL;
2957 if ( line != NULL ) {
2960 while ( *next && strchr( sep, *next ) ) {
2964 if ( *next == '\0' ) {
2970 for ( inquote = 0; *next; ) {
2978 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2984 next + 1, strlen( next + 1 ) + 1 );
2985 next++; /* dont parse the escaped character */
2990 if ( strchr( sep, *next ) != NULL ) {
2991 strtok_quote_ptr = next;
3004 static char buf[BUFSIZ];
3006 static size_t lmax, lcur;
3008 #define CATLINE( buf ) \
3010 size_t len = strlen( buf ); \
3011 while ( lcur + len + 1 > lmax ) { \
3013 line = (char *) ch_realloc( line, lmax ); \
3015 strcpy( line + lcur, buf ); \
3020 fp_getline( FILE *fp, int *lineno )
3028 /* hack attack - keeps us from having to keep a stack of bufs... */
3029 if ( strncasecmp( line, "include", 7 ) == 0 ) {
3034 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
3035 /* trim off \r\n or \n */
3036 if ( (p = strchr( buf, '\n' )) != NULL ) {
3037 if( p > buf && p[-1] == '\r' ) --p;
3041 /* trim off trailing \ and append the next line */
3042 if ( line[ 0 ] != '\0'
3043 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
3044 && p[ -1 ] != '\\' ) {
3049 if ( ! isspace( (unsigned char) buf[0] ) ) {
3053 /* change leading whitespace to a space */
3062 return( line[0] ? line : NULL );
3066 fp_getline_init( int *lineno )
3072 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
3074 load_ucdata( char *path )
3077 static int loaded = 0;
3083 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
3086 LDAP_LOG( CONFIG, CRIT,
3087 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
3089 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
3098 /* ucdata is now hardcoded */
3106 ucdata_unload( UCDATA_ALL );
3108 /* NOTE: in case of early exit, frontendDB can be NULL */
3109 if ( frontendDB->be_schemandn.bv_val )
3110 free( frontendDB->be_schemandn.bv_val );
3111 if ( frontendDB->be_schemadn.bv_val )
3112 free( frontendDB->be_schemadn.bv_val );
3113 if ( frontendDB->be_acl )
3114 acl_destroy( frontendDB->be_acl, NULL );
3117 if ( slapd_args_file )
3118 free ( slapd_args_file );
3119 if ( slapd_pid_file )
3120 free ( slapd_pid_file );
3121 if ( default_passwd_hash )
3122 ldap_charray_free( default_passwd_hash );
3133 syncinfo_t *si_entry;
3135 int duplicated_replica_id = 0;
3137 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
3141 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
3143 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
3148 si->si_tls = SYNCINFO_TLS_OFF;
3149 if ( be->be_rootndn.bv_val ) {
3150 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
3152 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3153 si->si_schemachecking = 0;
3154 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 0,
3155 &si->si_filterstr );
3156 si->si_base.bv_val = NULL;
3157 si->si_scope = LDAP_SCOPE_SUBTREE;
3158 si->si_attrsonly = 0;
3159 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
3160 si->si_attrs[0] = NULL;
3161 si->si_exattrs = (char **) ch_calloc( 1, sizeof( char * ));
3162 si->si_exattrs[0] = NULL;
3163 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3164 si->si_interval = 86400;
3165 si->si_retryinterval = 0;
3166 si->si_retrynum_init = 0;
3167 si->si_retrynum = 0;
3168 si->si_syncCookie.ctxcsn = NULL;
3169 si->si_syncCookie.octet_str = NULL;
3170 si->si_syncCookie.sid = -1;
3171 si->si_manageDSAit = 0;
3174 si->si_syncUUID_ndn.bv_val = NULL;
3175 si->si_syncUUID_ndn.bv_len = 0;
3177 si->si_presentlist = NULL;
3178 LDAP_LIST_INIT( &si->si_nonpresentlist );
3180 rc = parse_syncrepl_line( cargv, cargc, si );
3182 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
3183 if ( si->si_rid == si_entry->si_rid ) {
3185 LDAP_LOG( CONFIG, ERR,
3186 "add_syncrepl: duplicated replica id\n", 0, 0,0 );
3188 Debug( LDAP_DEBUG_ANY,
3189 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
3191 duplicated_replica_id = 1;
3196 if ( rc < 0 || duplicated_replica_id ) {
3197 syncinfo_t *si_entry;
3198 /* Something bad happened - back out */
3200 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
3202 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
3205 /* If error, remove all syncinfo */
3206 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
3207 if ( si_entry->si_updatedn.bv_val ) {
3208 ch_free( si->si_updatedn.bv_val );
3210 if ( si_entry->si_filterstr.bv_val ) {
3211 ch_free( si->si_filterstr.bv_val );
3213 if ( si_entry->si_attrs ) {
3215 while ( si_entry->si_attrs[i] != NULL ) {
3216 ch_free( si_entry->si_attrs[i] );
3219 ch_free( si_entry->si_attrs );
3221 if ( si_entry->si_exattrs ) {
3223 while ( si_entry->si_exattrs[i] != NULL ) {
3224 ch_free( si_entry->si_exattrs[i] );
3227 ch_free( si_entry->si_exattrs );
3231 while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
3232 si_entry = LDAP_STAILQ_FIRST( &be->be_syncinfo );
3233 LDAP_STAILQ_REMOVE_HEAD( &be->be_syncinfo, si_next );
3234 ch_free( si_entry );
3236 LDAP_STAILQ_INIT( &be->be_syncinfo );
3240 LDAP_LOG ( CONFIG, RESULTS,
3241 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
3242 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
3244 Debug( LDAP_DEBUG_CONFIG,
3245 "Config: ** successfully added syncrepl \"%s\"\n",
3246 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
3248 if ( !si->si_schemachecking ) {
3249 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
3252 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
3258 #define PROVIDERSTR "provider"
3259 #define SUFFIXSTR "suffix"
3260 #define UPDATEDNSTR "updatedn"
3261 #define BINDMETHSTR "bindmethod"
3262 #define SIMPLESTR "simple"
3263 #define SASLSTR "sasl"
3264 #define BINDDNSTR "binddn"
3265 #define CREDSTR "credentials"
3266 #define OLDAUTHCSTR "bindprincipal"
3267 #define AUTHCSTR "authcID"
3268 #define AUTHZSTR "authzID"
3269 #define SRVTABSTR "srvtab"
3270 #define SASLMECHSTR "saslmech"
3271 #define REALMSTR "realm"
3272 #define SECPROPSSTR "secprops"
3273 #define STARTTLSSTR "starttls"
3274 #define CRITICALSTR "critical"
3276 #define SCHEMASTR "schemachecking"
3277 #define FILTERSTR "filter"
3278 #define SEARCHBASESTR "searchbase"
3279 #define SCOPESTR "scope"
3280 #define ATTRSSTR "attrs"
3281 #define ATTRSONLYSTR "attrsonly"
3282 #define EXATTRSSTR "exattrs"
3283 #define TYPESTR "type"
3284 #define INTERVALSTR "interval"
3285 #define LASTMODSTR "lastmod"
3286 #define LMREQSTR "req"
3287 #define LMGENSTR "gen"
3288 #define LMNOSTR "no"
3289 #define MANAGEDSAITSTR "manageDSAit"
3290 #define SLIMITSTR "sizelimit"
3291 #define TLIMITSTR "timelimit"
3293 #define RETRYSTR "retry"
3295 #define GOT_ID 0x0001
3296 #define GOT_PROVIDER 0x0002
3297 #define GOT_METHOD 0x0004
3298 #define GOT_ALL 0x0007
3301 parse_syncrepl_line(
3312 for ( i = 1; i < cargc; i++ ) {
3313 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
3315 /* '\0' string terminator accounts for '=' */
3316 val = cargv[ i ] + sizeof( IDSTR );
3318 if ( tmp >= 1000 || tmp < 0 ) {
3319 fprintf( stderr, "Error: parse_syncrepl_line: "
3320 "syncrepl id %d is out of range [0..999]\n", tmp );
3325 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
3326 sizeof( PROVIDERSTR ) - 1 )) {
3327 val = cargv[ i ] + sizeof( PROVIDERSTR );
3328 si->si_provideruri = ch_strdup( val );
3329 si->si_provideruri_bv = (BerVarray)
3330 ch_calloc( 2, sizeof( struct berval ));
3331 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
3332 0, &si->si_provideruri_bv[0] );
3333 si->si_provideruri_bv[1].bv_len = 0;
3334 si->si_provideruri_bv[1].bv_val = NULL;
3335 gots |= GOT_PROVIDER;
3336 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
3337 sizeof(STARTTLSSTR) - 1 ) )
3339 val = cargv[ i ] + sizeof( STARTTLSSTR );
3340 if( !strcasecmp( val, CRITICALSTR ) ) {
3341 si->si_tls = SYNCINFO_TLS_CRITICAL;
3343 si->si_tls = SYNCINFO_TLS_ON;
3345 } else if ( !strncasecmp( cargv[ i ],
3346 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
3348 struct berval updatedn = {0, NULL};
3349 val = cargv[ i ] + sizeof( UPDATEDNSTR );
3350 ber_str2bv( val, 0, 0, &updatedn );
3351 ch_free( si->si_updatedn.bv_val );
3352 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
3353 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
3354 sizeof( BINDMETHSTR ) - 1 ) )
3356 val = cargv[ i ] + sizeof( BINDMETHSTR );
3357 if ( !strcasecmp( val, SIMPLESTR )) {
3358 si->si_bindmethod = LDAP_AUTH_SIMPLE;
3360 } else if ( !strcasecmp( val, SASLSTR )) {
3361 #ifdef HAVE_CYRUS_SASL
3362 si->si_bindmethod = LDAP_AUTH_SASL;
3364 #else /* HAVE_CYRUS_SASL */
3365 fprintf( stderr, "Error: parse_syncrepl_line: "
3366 "not compiled with SASL support\n" );
3368 #endif /* HAVE_CYRUS_SASL */
3370 si->si_bindmethod = -1;
3372 } else if ( !strncasecmp( cargv[ i ],
3373 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
3374 val = cargv[ i ] + sizeof( BINDDNSTR );
3375 si->si_binddn = ch_strdup( val );
3376 } else if ( !strncasecmp( cargv[ i ],
3377 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
3378 val = cargv[ i ] + sizeof( CREDSTR );
3379 si->si_passwd = ch_strdup( val );
3380 } else if ( !strncasecmp( cargv[ i ],
3381 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
3382 val = cargv[ i ] + sizeof( SASLMECHSTR );
3383 si->si_saslmech = ch_strdup( val );
3384 } else if ( !strncasecmp( cargv[ i ],
3385 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
3386 val = cargv[ i ] + sizeof( SECPROPSSTR );
3387 si->si_secprops = ch_strdup( val );
3388 } else if ( !strncasecmp( cargv[ i ],
3389 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
3390 val = cargv[ i ] + sizeof( REALMSTR );
3391 si->si_realm = ch_strdup( val );
3392 } else if ( !strncasecmp( cargv[ i ],
3393 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
3394 val = cargv[ i ] + sizeof( AUTHCSTR );
3395 si->si_authcId = ch_strdup( val );
3396 } else if ( !strncasecmp( cargv[ i ],
3397 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
3398 /* Old authcID is provided for some backwards compatibility */
3399 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
3400 si->si_authcId = ch_strdup( val );
3401 } else if ( !strncasecmp( cargv[ i ],
3402 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
3403 val = cargv[ i ] + sizeof( AUTHZSTR );
3404 si->si_authzId = ch_strdup( val );
3405 } else if ( !strncasecmp( cargv[ i ],
3406 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
3408 val = cargv[ i ] + sizeof( SCHEMASTR );
3409 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
3410 si->si_schemachecking = 1;
3411 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
3412 si->si_schemachecking = 0;
3414 si->si_schemachecking = 1;
3416 } else if ( !strncasecmp( cargv[ i ],
3417 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
3419 val = cargv[ i ] + sizeof( FILTERSTR );
3420 ber_str2bv( val, 0, 1, &si->si_filterstr );
3421 } else if ( !strncasecmp( cargv[ i ],
3422 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3425 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3426 if ( si->si_base.bv_val ) {
3427 ch_free( si->si_base.bv_val );
3429 ber_str2bv( val, 0, 0, &bv );
3430 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3431 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3434 } else if ( !strncasecmp( cargv[ i ],
3435 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3437 val = cargv[ i ] + sizeof( SCOPESTR );
3438 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
3439 si->si_scope = LDAP_SCOPE_BASE;
3440 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
3441 si->si_scope = LDAP_SCOPE_ONELEVEL;
3442 #ifdef LDAP_SCOPE_SUBORDINATE
3443 } else if ( !strcasecmp( val, "subordinate" ) ||
3444 !strcasecmp( val, "children" ))
3446 si->si_scope = LDAP_SCOPE_SUBORDINATE;
3448 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
3449 si->si_scope = LDAP_SCOPE_SUBTREE;
3451 fprintf( stderr, "Error: parse_syncrepl_line: "
3452 "unknown scope \"%s\"\n", val);
3455 } else if ( !strncasecmp( cargv[ i ],
3456 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3458 si->si_attrsonly = 1;
3459 } else if ( !strncasecmp( cargv[ i ],
3460 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3462 val = cargv[ i ] + sizeof( ATTRSSTR );
3463 str2clist( &si->si_attrs, val, "," );
3464 } else if ( !strncasecmp( cargv[ i ],
3465 EXATTRSSTR, sizeof( EXATTRSSTR ) - 1 ) )
3467 val = cargv[ i ] + sizeof( EXATTRSSTR );
3468 str2clist( &si->si_exattrs, val, "," );
3469 } else if ( !strncasecmp( cargv[ i ],
3470 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3472 val = cargv[ i ] + sizeof( TYPESTR );
3473 if ( !strncasecmp( val, "refreshOnly", STRLENOF("refreshOnly") )) {
3474 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3475 } else if ( !strncasecmp( val, "refreshAndPersist",
3476 STRLENOF("refreshAndPersist") ))
3478 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3479 si->si_interval = 60;
3481 fprintf( stderr, "Error: parse_syncrepl_line: "
3482 "unknown sync type \"%s\"\n", val);
3485 } else if ( !strncasecmp( cargv[ i ],
3486 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3488 val = cargv[ i ] + sizeof( INTERVALSTR );
3489 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
3490 si->si_interval = 0;
3498 hstr = strchr( dstr, ':' );
3499 if ( hstr == NULL ) {
3500 fprintf( stderr, "Error: parse_syncrepl_line: "
3501 "invalid interval \"%s\"\n", val );
3505 mstr = strchr( hstr, ':' );
3506 if ( mstr == NULL ) {
3507 fprintf( stderr, "Error: parse_syncrepl_line: "
3508 "invalid interval \"%s\"\n", val );
3512 sstr = strchr( mstr, ':' );
3513 if ( sstr == NULL ) {
3514 fprintf( stderr, "Error: parse_syncrepl_line: "
3515 "invalid interval \"%s\"\n", val );
3524 if (( hh > 24 ) || ( hh < 0 ) ||
3525 ( mm > 60 ) || ( mm < 0 ) ||
3526 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3527 fprintf( stderr, "Error: parse_syncrepl_line: "
3528 "invalid interval \"%s\"\n", val );
3531 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3533 if ( si->si_interval < 0 ) {
3534 fprintf( stderr, "Error: parse_syncrepl_line: "
3535 "invalid interval \"%ld\"\n",
3536 (long) si->si_interval);
3539 } else if ( !strncasecmp( cargv[ i ],
3540 RETRYSTR, sizeof( RETRYSTR ) - 1 ) )
3546 val = cargv[ i ] + sizeof( RETRYSTR );
3547 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
3548 retry_list[0] = NULL;
3550 str2clist( &retry_list, val, " ,\t" );
3552 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
3556 "Error: incomplete syncrepl retry list\n" );
3557 for ( k = 0; retry_list && retry_list[k]; k++ ) {
3558 ch_free( retry_list[k] );
3560 ch_free( retry_list );
3561 exit( EXIT_FAILURE );
3563 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
3564 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
3565 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
3566 for ( j = 0; j < n; j++ ) {
3567 si->si_retryinterval[j] = atoi( retry_list[j*2] );
3568 if ( *retry_list[j*2+1] == '+' ) {
3569 si->si_retrynum_init[j] = -1;
3570 si->si_retrynum[j] = -1;
3574 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
3575 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
3578 si->si_retrynum_init[j] = -2;
3579 si->si_retrynum[j] = -2;
3580 si->si_retryinterval[j] = 0;
3582 for ( k = 0; retry_list && retry_list[k]; k++ ) {
3583 ch_free( retry_list[k] );
3585 ch_free( retry_list );
3586 } else if ( !strncasecmp( cargv[ i ],
3587 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3589 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3590 si->si_manageDSAit = atoi( val );
3591 } else if ( !strncasecmp( cargv[ i ],
3592 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3594 val = cargv[ i ] + sizeof( SLIMITSTR );
3595 si->si_slimit = atoi( val );
3596 } else if ( !strncasecmp( cargv[ i ],
3597 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3599 val = cargv[ i ] + sizeof( TLIMITSTR );
3600 si->si_tlimit = atoi( val );
3602 fprintf( stderr, "Error: parse_syncrepl_line: "
3603 "unknown keyword \"%s\"\n", cargv[ i ] );
3607 if ( gots != GOT_ALL ) {
3609 "Error: Malformed \"syncrepl\" line in slapd config file" );
3617 str2clist( char ***out, char *in, const char *brkstr )
3626 /* find last element in list */
3627 for (i = 0; *out && *out[i]; i++);
3629 /* protect the input string from strtok */
3630 str = ch_strdup( in );
3632 if ( *str == '\0' ) {
3637 /* Count words in string */
3639 for ( s = str; *s; s++ ) {
3640 if ( strchr( brkstr, *s ) != NULL ) {
3645 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3647 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3649 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3651 *new = ch_strdup( s );