1 /* config.c - configuration file handling routines */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
14 #include <ac/signal.h>
15 #include <ac/socket.h>
28 * defaults for various global variables
30 struct slap_limits_set deflimit = {
31 SLAPD_DEFAULT_TIMELIMIT, /* backward compatible limits */
34 SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */
36 -1, /* no limit on unchecked size */
38 0 /* hide number of entries left */
41 AccessControl *global_acl = NULL;
42 slap_access_t global_default_access = ACL_READ;
43 slap_mask_t global_restrictops = 0;
44 slap_mask_t global_allows = 0;
45 slap_mask_t global_disallows = 0;
46 slap_mask_t global_requires = 0;
47 slap_ssf_set_t global_ssf_set;
49 int global_gentlehup = 0;
50 int global_idletimeout = 0;
51 char *global_host = NULL;
52 char *global_realm = NULL;
53 char *ldap_srvtab = "";
54 char *default_passwd_hash = NULL;
55 int cargc = 0, cargv_size = 0;
57 struct berval default_search_base = { 0, NULL };
58 struct berval default_search_nbase = { 0, NULL };
59 unsigned num_subordinates = 0;
60 struct berval global_schemadn = { 0, NULL };
61 struct berval global_schemandn = { 0, NULL };
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;
76 static char *fp_getline(FILE *fp, int *lineno);
77 static void fp_getline_init(int *lineno);
78 static int fp_parse_line(int lineno, char *line);
80 static char *strtok_quote(char *line, char *sep);
81 static int load_ucdata(char *path);
84 static void add_syncrepl LDAP_P(( Backend *, char **, int ));
85 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
89 read_config( const char *fname, int depth )
92 char *line, *savefname, *saveline;
96 struct berval vals[2];
99 static int lastmod = 1;
100 static BackendInfo *bi = NULL;
101 static BackendDB *be = NULL;
103 vals[1].bv_val = NULL;
106 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
107 cargv_size = ARGS_STEP + 1;
110 if ( (fp = fopen( fname, "r" )) == NULL ) {
113 LDAP_LOG( CONFIG, ENTRY,
114 "read_config: " "could not open config file \"%s\": %s (%d)\n",
115 fname, strerror(errno), errno );
117 Debug( LDAP_DEBUG_ANY,
118 "could not open config file \"%s\": %s (%d)\n",
119 fname, strerror(errno), errno );
125 LDAP_LOG( CONFIG, ENTRY,
126 "read_config: reading config file %s\n", fname, 0, 0 );
128 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
132 fp_getline_init( &lineno );
134 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
135 /* skip comments and blank lines */
136 if ( line[0] == '#' || line[0] == '\0' ) {
140 /* fp_parse_line is destructive, we save a copy */
141 saveline = ch_strdup( line );
143 if ( fp_parse_line( lineno, line ) != 0 ) {
149 LDAP_LOG( CONFIG, INFO,
150 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
152 Debug( LDAP_DEBUG_ANY,
153 "%s: line %d: bad config line (ignored)\n",
160 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
163 LDAP_LOG( CONFIG, CRIT,
164 "%s : line %d: missing type in \"backend\" line.\n",
167 Debug( LDAP_DEBUG_ANY,
168 "%s: line %d: missing type in \"backend <type>\" line\n",
177 LDAP_LOG( CONFIG, CRIT,
178 "%s: line %d: backend line must appear before any "
179 "database definition.\n", fname, lineno , 0 );
181 Debug( LDAP_DEBUG_ANY,
182 "%s: line %d: backend line must appear before any database definition\n",
189 bi = backend_info( cargv[1] );
193 LDAP_LOG( CONFIG, CRIT,
194 "read_config: backend %s initialization failed.\n",
197 Debug( LDAP_DEBUG_ANY,
198 "backend %s initialization failed.\n",
204 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
207 LDAP_LOG( CONFIG, CRIT,
208 "%s: line %d: missing type in \"database <type>\" line\n",
211 Debug( LDAP_DEBUG_ANY,
212 "%s: line %d: missing type in \"database <type>\" line\n",
220 be = backend_db_init( cargv[1] );
224 LDAP_LOG( CONFIG, CRIT,
225 "database %s initialization failed.\n", cargv[1], 0, 0 );
227 Debug( LDAP_DEBUG_ANY,
228 "database %s initialization failed.\n",
235 /* set thread concurrency */
236 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
240 LDAP_LOG( CONFIG, CRIT,
241 "%s: line %d: missing level in \"concurrency <level\" "
242 " line\n", fname, lineno, 0 );
244 Debug( LDAP_DEBUG_ANY,
245 "%s: line %d: missing level in \"concurrency <level>\" line\n",
252 c = atoi( cargv[1] );
256 LDAP_LOG( CONFIG, CRIT,
257 "%s: line %d: invalid level (%d) in "
258 "\"concurrency <level>\" line.\n", fname, lineno, c );
260 Debug( LDAP_DEBUG_ANY,
261 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
268 ldap_pvt_thread_set_concurrency( c );
270 /* set sockbuf max */
271 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
275 LDAP_LOG( CONFIG, CRIT,
276 "%s: line %d: missing max in \"sockbuf_max_incoming "
277 "<bytes>\" line\n", fname, lineno, 0 );
279 Debug( LDAP_DEBUG_ANY,
280 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
287 max = atol( cargv[1] );
291 LDAP_LOG( CONFIG, CRIT,
292 "%s: line %d: invalid max value (%ld) in "
293 "\"sockbuf_max_incoming <bytes>\" line.\n",
294 fname, lineno, max );
296 Debug( LDAP_DEBUG_ANY,
297 "%s: line %d: invalid max value (%ld) in "
298 "\"sockbuf_max_incoming <bytes>\" line.\n",
299 fname, lineno, max );
305 sockbuf_max_incoming = max;
307 /* set sockbuf max authenticated */
308 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
312 LDAP_LOG( CONFIG, CRIT,
313 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
314 "<bytes>\" line\n", fname, lineno, 0 );
316 Debug( LDAP_DEBUG_ANY,
317 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
324 max = atol( cargv[1] );
328 LDAP_LOG( CONFIG, CRIT,
329 "%s: line %d: invalid max value (%ld) in "
330 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
331 fname, lineno, max );
333 Debug( LDAP_DEBUG_ANY,
334 "%s: line %d: invalid max value (%ld) in "
335 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
336 fname, lineno, max );
342 sockbuf_max_incoming_auth = max;
344 /* set conn pending max */
345 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
349 LDAP_LOG( CONFIG, CRIT,
350 "%s: line %d: missing max in \"conn_max_pending "
351 "<requests>\" line\n", fname, lineno, 0 );
353 Debug( LDAP_DEBUG_ANY,
354 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
361 max = atol( cargv[1] );
365 LDAP_LOG( CONFIG, CRIT,
366 "%s: line %d: invalid max value (%ld) in "
367 "\"conn_max_pending <requests>\" line.\n",
368 fname, lineno, max );
370 Debug( LDAP_DEBUG_ANY,
371 "%s: line %d: invalid max value (%ld) in "
372 "\"conn_max_pending <requests>\" line.\n",
373 fname, lineno, max );
379 slap_conn_max_pending = max;
381 /* set conn pending max authenticated */
382 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
386 LDAP_LOG( CONFIG, CRIT,
387 "%s: line %d: missing max in \"conn_max_pending_auth "
388 "<requests>\" line\n", fname, lineno, 0 );
390 Debug( LDAP_DEBUG_ANY,
391 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
398 max = atol( cargv[1] );
402 LDAP_LOG( CONFIG, CRIT,
403 "%s: line %d: invalid max value (%ld) in "
404 "\"conn_max_pending_auth <requests>\" line.\n",
405 fname, lineno, max );
407 Debug( LDAP_DEBUG_ANY,
408 "%s: line %d: invalid max value (%ld) in "
409 "\"conn_max_pending_auth <requests>\" line.\n",
410 fname, lineno, max );
416 slap_conn_max_pending_auth = max;
418 /* default search base */
419 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
422 LDAP_LOG( CONFIG, CRIT,
423 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
424 "line\n", fname, lineno, 0 );
426 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
427 "missing dn in \"defaultSearchBase <dn>\" line\n",
433 } else if ( cargc > 2 ) {
435 LDAP_LOG( CONFIG, INFO,
436 "%s: line %d: extra cruft after <dn> in "
437 "\"defaultSearchBase %s\" line (ignored)\n",
438 fname, lineno, cargv[1] );
440 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
441 "extra cruft after <dn> in \"defaultSearchBase %s\", "
443 fname, lineno, cargv[1] );
447 if ( bi != NULL || be != NULL ) {
449 LDAP_LOG( CONFIG, CRIT,
450 "%s: line %d: defaultSearchBase line must appear "
451 "prior to any backend or database definitions\n",
454 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
455 "defaultSearchBaase line must appear prior to "
456 "any backend or database definition\n",
463 if ( default_search_nbase.bv_len ) {
465 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
466 "default search base \"%s\" already defined "
467 "(discarding old)\n", fname, lineno,
468 default_search_base.bv_val );
470 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
471 "default search base \"%s\" already defined "
472 "(discarding old)\n",
473 fname, lineno, default_search_base.bv_val );
476 free( default_search_base.bv_val );
477 free( default_search_nbase.bv_val );
480 if ( load_ucdata( NULL ) < 0 ) return 1;
485 dn.bv_val = cargv[1];
486 dn.bv_len = strlen( dn.bv_val );
488 rc = dnPrettyNormal( NULL, &dn,
489 &default_search_base,
490 &default_search_nbase, NULL );
492 if( rc != LDAP_SUCCESS ) {
494 LDAP_LOG( CONFIG, CRIT,
495 "%s: line %d: defaultSearchBase DN is invalid.\n",
498 Debug( LDAP_DEBUG_ANY,
499 "%s: line %d: defaultSearchBase DN is invalid\n",
506 /* set maximum threads in thread pool */
507 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
511 LDAP_LOG( CONFIG, CRIT,
512 "%s: line %d: missing count in \"threads <count>\" line\n",
515 Debug( LDAP_DEBUG_ANY,
516 "%s: line %d: missing count in \"threads <count>\" line\n",
523 c = atoi( cargv[1] );
527 LDAP_LOG( CONFIG, CRIT,
528 "%s: line %d: invalid level (%d) in \"threads <count>\""
529 "line\n", fname, lineno, c );
531 Debug( LDAP_DEBUG_ANY,
532 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
539 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
541 /* save for later use */
542 connection_pool_max = c;
544 /* get pid file name */
545 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
548 LDAP_LOG( CONFIG, CRIT,
549 "%s: line %d missing file name in \"pidfile <file>\" "
550 "line.\n", fname, lineno, 0 );
552 Debug( LDAP_DEBUG_ANY,
553 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
560 slapd_pid_file = ch_strdup( cargv[1] );
562 /* get args file name */
563 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
566 LDAP_LOG( CONFIG, CRIT,
567 "%s: %d: missing file name in "
568 "\"argsfile <file>\" line.\n",
571 Debug( LDAP_DEBUG_ANY,
572 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
579 slapd_args_file = ch_strdup( cargv[1] );
581 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
584 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
587 /* default password hash */
588 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
591 LDAP_LOG( CONFIG, CRIT,
592 "%s: line %d: missing hash in "
593 "\"password-hash <hash>\" line.\n",
596 Debug( LDAP_DEBUG_ANY,
597 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
603 if ( default_passwd_hash != NULL ) {
605 LDAP_LOG( CONFIG, CRIT,
606 "%s: line %d: already set default password_hash!\n",
609 Debug( LDAP_DEBUG_ANY,
610 "%s: line %d: already set default password_hash!\n",
618 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
620 LDAP_LOG( CONFIG, CRIT,
621 "%s: line %d: password scheme \"%s\" not available\n",
622 fname, lineno, cargv[1] );
624 Debug( LDAP_DEBUG_ANY,
625 "%s: line %d: password scheme \"%s\" not available\n",
626 fname, lineno, cargv[1] );
631 default_passwd_hash = ch_strdup( cargv[1] );
633 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
637 LDAP_LOG( CONFIG, CRIT,
638 "%s: line %d: missing format in "
639 "\"password-crypt-salt-format <format>\" line\n",
642 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
643 "\"password-crypt-salt-format <format>\" line\n",
650 lutil_salt_format( cargv[1] );
652 /* SASL config options */
653 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
654 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
657 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
661 LDAP_LOG( CONFIG, CRIT,
662 "%s: line %d: missing dn in "
663 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
665 Debug( LDAP_DEBUG_ANY,
666 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
671 ber_str2bv( cargv[1], 0, 0, &dn );
673 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
674 &be->be_schemandn, NULL );
676 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
677 &global_schemandn, NULL );
679 if ( rc != LDAP_SUCCESS ) {
681 LDAP_LOG( CONFIG, CRIT,
682 "%s: line %d: schemadn DN is invalid.\n",
685 Debug( LDAP_DEBUG_ANY,
686 "%s: line %d: schemadn DN is invalid\n",
692 /* set UCDATA path */
693 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
697 LDAP_LOG( CONFIG, CRIT,
698 "%s: line %d: missing path in "
699 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
701 Debug( LDAP_DEBUG_ANY,
702 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
709 err = load_ucdata( cargv[1] );
713 LDAP_LOG( CONFIG, CRIT,
714 "%s: line %d: ucdata already loaded, ucdata-path "
715 "must be set earlier in the file and/or be "
716 "specified only once!\n", fname, lineno, 0 );
718 Debug( LDAP_DEBUG_ANY,
719 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
728 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
730 struct slap_limits_set *lim;
734 LDAP_LOG( CONFIG, CRIT,
735 "%s: line %d: missing limit in \"sizelimit <limit>\" "
736 "line.\n", fname, lineno, 0 );
738 Debug( LDAP_DEBUG_ANY,
739 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
749 lim = &be->be_def_limit;
752 for ( i = 1; i < cargc; i++ ) {
753 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
754 rc = parse_limit( cargv[i], lim );
757 LDAP_LOG( CONFIG, CRIT,
758 "%s: line %d: unable "
759 "to parse value \"%s\" in \"sizelimit "
760 "<limit>\" line.\n", fname, lineno, cargv[i] );
762 Debug( LDAP_DEBUG_ANY,
763 "%s: line %d: unable "
764 "to parse value \"%s\" "
767 fname, lineno, cargv[i] );
773 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
774 lim->lms_s_soft = -1;
778 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
779 if ( next == cargv[i] ) {
781 LDAP_LOG( CONFIG, CRIT,
782 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
783 "line.\n", fname, lineno, cargv[i] );
785 Debug( LDAP_DEBUG_ANY,
786 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
787 fname, lineno, cargv[i] );
791 } else if ( next[0] != '\0' ) {
793 LDAP_LOG( CONFIG, CRIT,
794 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
795 "line ignored.\n", fname, lineno, next );
797 Debug( LDAP_DEBUG_ANY,
798 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
799 fname, lineno, next );
808 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
810 struct slap_limits_set *lim;
814 LDAP_LOG( CONFIG, CRIT,
815 "%s: line %d missing limit in \"timelimit <limit>\" "
816 "line.\n", fname, lineno, 0 );
818 Debug( LDAP_DEBUG_ANY,
819 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
829 lim = &be->be_def_limit;
832 for ( i = 1; i < cargc; i++ ) {
833 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
834 rc = parse_limit( cargv[i], lim );
837 LDAP_LOG( CONFIG, CRIT,
838 "%s: line %d: unable to parse value \"%s\" "
839 "in \"timelimit <limit>\" line.\n",
840 fname, lineno, cargv[i] );
842 Debug( LDAP_DEBUG_ANY,
843 "%s: line %d: unable "
844 "to parse value \"%s\" "
847 fname, lineno, cargv[i] );
853 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
854 lim->lms_t_soft = -1;
858 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
859 if ( next == cargv[i] ) {
861 LDAP_LOG( CONFIG, CRIT,
862 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
863 "line.\n", fname, lineno, cargv[i] );
865 Debug( LDAP_DEBUG_ANY,
866 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
867 fname, lineno, cargv[i] );
871 } else if ( next[0] != '\0' ) {
873 LDAP_LOG( CONFIG, CRIT,
874 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
875 "line ignored.\n", fname, lineno, next );
877 Debug( LDAP_DEBUG_ANY,
878 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
879 fname, lineno, next );
887 /* set regex-based limits */
888 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
891 LDAP_LOG( CONFIG, WARNING,
892 "%s: line %d \"limits\" allowed only in database "
893 "environment.\n", fname, lineno, 0 );
895 Debug( LDAP_DEBUG_ANY,
896 "%s: line %d \"limits\" allowed only in database environment.\n%s",
902 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
906 /* mark this as a subordinate database */
907 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
910 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
911 "subordinate keyword must appear inside a database "
912 "definition.\n", fname, lineno, 0 );
914 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
915 "must appear inside a database definition.\n",
921 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
925 /* add an overlay to this backend */
926 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
929 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
930 "overlay keyword must appear inside a database "
931 "definition.\n", fname, lineno, 0 );
933 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
934 "must appear inside a database definition.\n",
939 } else if ( overlay_config( be, cargv[1] )) {
943 /* set database suffix */
944 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
946 struct berval dn, pdn, ndn;
950 LDAP_LOG( CONFIG, CRIT,
951 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
954 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
955 "missing dn in \"suffix <dn>\" line\n",
961 } else if ( cargc > 2 ) {
963 LDAP_LOG( CONFIG, INFO,
964 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
965 " line (ignored).\n", fname, lineno, cargv[1] );
967 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
968 "after <dn> in \"suffix %s\" line (ignored)\n",
969 fname, lineno, cargv[1] );
975 LDAP_LOG( CONFIG, INFO,
976 "%s: line %d: suffix line must appear inside a database "
977 "definition.\n", fname, lineno, 0 );
979 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
980 "must appear inside a database definition\n",
985 #if defined(SLAPD_MONITOR_DN)
986 /* "cn=Monitor" is reserved for monitoring slap */
987 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
989 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
990 "%s\" is reserved for monitoring slapd\n",
991 fname, lineno, SLAPD_MONITOR_DN );
993 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
994 "%s\" is reserved for monitoring slapd\n",
995 fname, lineno, SLAPD_MONITOR_DN );
998 #endif /* SLAPD_MONITOR_DN */
1001 if ( load_ucdata( NULL ) < 0 ) return 1;
1003 dn.bv_val = cargv[1];
1004 dn.bv_len = strlen( cargv[1] );
1006 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1007 if( rc != LDAP_SUCCESS ) {
1009 LDAP_LOG( CONFIG, CRIT,
1010 "%s: line %d: suffix DN is invalid.\n",
1013 Debug( LDAP_DEBUG_ANY,
1014 "%s: line %d: suffix DN is invalid\n",
1020 tmp_be = select_backend( &ndn, 0, 0 );
1021 if ( tmp_be == be ) {
1023 LDAP_LOG( CONFIG, INFO,
1024 "%s: line %d: suffix already served by this backend "
1025 "(ignored)\n", fname, lineno, 0 );
1027 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1028 "already served by this backend (ignored)\n",
1034 } else if ( tmp_be != NULL ) {
1036 LDAP_LOG( CONFIG, INFO,
1037 "%s: line %d: suffix already served by a preceding "
1038 "backend \"%s\"\n", fname, lineno,
1039 tmp_be->be_suffix[0].bv_val );
1041 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1042 "already served by a preceeding backend \"%s\"\n",
1043 fname, lineno, tmp_be->be_suffix[0].bv_val );
1049 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1051 LDAP_LOG( CONFIG, INFO,
1052 "%s: line %d: suffix DN empty and default search "
1053 "base provided \"%s\" (assuming okay).\n",
1054 fname, lineno, default_search_base.bv_val );
1056 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1057 "suffix DN empty and default "
1058 "search base provided \"%s\" (assuming okay)\n",
1059 fname, lineno, default_search_base.bv_val );
1063 ber_bvarray_add( &be->be_suffix, &pdn );
1064 ber_bvarray_add( &be->be_nsuffix, &ndn );
1066 /* set max deref depth */
1067 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1071 LDAP_LOG( CONFIG, CRIT,
1072 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1073 " line\n", fname, lineno, 0 );
1075 Debug( LDAP_DEBUG_ANY,
1076 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1084 LDAP_LOG( CONFIG, INFO,
1085 "%s: line %d: depth line must appear inside a database "
1086 "definition.\n", fname, lineno ,0 );
1088 Debug( LDAP_DEBUG_ANY,
1089 "%s: line %d: depth line must appear inside a database definition.\n",
1094 } else if ((i = atoi(cargv[1])) < 0) {
1096 LDAP_LOG( CONFIG, INFO,
1097 "%s: line %d: depth must be positive.\n",
1100 Debug( LDAP_DEBUG_ANY,
1101 "%s: line %d: depth must be positive.\n",
1108 be->be_max_deref_depth = i;
1112 /* set magic "root" dn for this database */
1113 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1116 LDAP_LOG( CONFIG, INFO,
1117 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1120 Debug( LDAP_DEBUG_ANY,
1121 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1130 LDAP_LOG( CONFIG, INFO,
1131 "%s: line %d: rootdn line must appear inside a database "
1132 "definition.\n", fname, lineno ,0 );
1134 Debug( LDAP_DEBUG_ANY,
1135 "%s: line %d: rootdn line must appear inside a database definition.\n",
1143 if ( load_ucdata( NULL ) < 0 ) return 1;
1145 dn.bv_val = cargv[1];
1146 dn.bv_len = strlen( cargv[1] );
1148 rc = dnPrettyNormal( NULL, &dn,
1150 &be->be_rootndn, NULL );
1152 if( rc != LDAP_SUCCESS ) {
1154 LDAP_LOG( CONFIG, CRIT,
1155 "%s: line %d: rootdn DN is invalid.\n",
1158 Debug( LDAP_DEBUG_ANY,
1159 "%s: line %d: rootdn DN is invalid\n",
1166 /* set super-secret magic database password */
1167 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1170 LDAP_LOG( CONFIG, CRIT,
1171 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1172 " line\n", fname, lineno ,0 );
1174 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1175 "missing passwd in \"rootpw <passwd>\" line\n",
1184 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1185 "rootpw line must appear inside a database "
1186 "definition.\n", fname, lineno ,0 );
1188 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1189 "rootpw line must appear inside a database "
1196 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1198 if( tmp_be != be ) {
1200 LDAP_LOG( CONFIG, INFO,
1202 "rootpw can only be set when rootdn is under suffix\n",
1203 fname, lineno, "" );
1205 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1206 "rootpw can only be set when rootdn is under suffix\n",
1212 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1213 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1216 /* make this database read-only */
1217 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1220 LDAP_LOG( CONFIG, CRIT,
1221 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1222 "line.\n", fname, lineno ,0 );
1224 Debug( LDAP_DEBUG_ANY,
1225 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1232 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1233 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1235 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1238 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1239 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1241 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1246 /* allow these features */
1247 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1248 strcasecmp( cargv[0], "allow" ) == 0 )
1254 LDAP_LOG( CONFIG, INFO,
1255 "%s: line %d: allow line must appear prior to "
1256 "database definitions.\n", fname, lineno ,0 );
1258 Debug( LDAP_DEBUG_ANY,
1259 "%s: line %d: allow line must appear prior to database definitions\n",
1267 LDAP_LOG( CONFIG, CRIT,
1268 "%s: line %d: missing feature(s) in \"allow <features>\""
1269 " line\n", fname, lineno ,0 );
1271 Debug( LDAP_DEBUG_ANY,
1272 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1281 for( i=1; i < cargc; i++ ) {
1282 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1283 allows |= SLAP_ALLOW_BIND_V2;
1285 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1286 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1288 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1289 allows |= SLAP_ALLOW_BIND_ANON_DN;
1291 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1292 allows |= SLAP_ALLOW_UPDATE_ANON;
1294 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1296 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1297 "unknown feature %s in \"allow <features>\" line.\n",
1298 fname, lineno, cargv[1] );
1300 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1301 "unknown feature %s in \"allow <features>\" line\n",
1302 fname, lineno, cargv[i] );
1309 global_allows = allows;
1311 /* disallow these features */
1312 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1313 strcasecmp( cargv[0], "disallow" ) == 0 )
1315 slap_mask_t disallows;
1319 LDAP_LOG( CONFIG, INFO,
1320 "%s: line %d: disallow line must appear prior to "
1321 "database definitions.\n", fname, lineno ,0 );
1323 Debug( LDAP_DEBUG_ANY,
1324 "%s: line %d: disallow line must appear prior to database definitions\n",
1332 LDAP_LOG( CONFIG, CRIT,
1333 "%s: line %d: missing feature(s) in \"disallow <features>\""
1334 " line.\n", fname, lineno ,0 );
1336 Debug( LDAP_DEBUG_ANY,
1337 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1346 for( i=1; i < cargc; i++ ) {
1347 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1348 disallows |= SLAP_DISALLOW_BIND_ANON;
1350 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1351 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1353 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1354 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1356 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1357 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1359 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1360 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1362 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1364 LDAP_LOG( CONFIG, CRIT,
1365 "%s: line %d: unknown feature %s in "
1366 "\"disallow <features>\" line.\n",
1367 fname, lineno, cargv[i] );
1369 Debug( LDAP_DEBUG_ANY,
1370 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1371 fname, lineno, cargv[i] );
1378 global_disallows = disallows;
1380 /* require these features */
1381 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1382 strcasecmp( cargv[0], "require" ) == 0 )
1384 slap_mask_t requires;
1388 LDAP_LOG( CONFIG, CRIT,
1389 "%s: line %d: missing feature(s) in "
1390 "\"require <features>\" line.\n", fname, lineno ,0 );
1392 Debug( LDAP_DEBUG_ANY,
1393 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1402 for( i=1; i < cargc; i++ ) {
1403 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1404 requires |= SLAP_REQUIRE_BIND;
1406 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1407 requires |= SLAP_REQUIRE_LDAP_V3;
1409 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1410 requires |= SLAP_REQUIRE_AUTHC;
1412 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1413 requires |= SLAP_REQUIRE_SASL;
1415 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1416 requires |= SLAP_REQUIRE_STRONG;
1418 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1420 LDAP_LOG( CONFIG, CRIT,
1421 "%s: line %d: unknown feature %s in "
1422 "\"require <features>\" line.\n",
1423 fname, lineno , cargv[i] );
1425 Debug( LDAP_DEBUG_ANY,
1426 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1427 fname, lineno, cargv[i] );
1435 global_requires = requires;
1437 be->be_requires = requires;
1440 /* required security factors */
1441 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1442 slap_ssf_set_t *set;
1446 LDAP_LOG( CONFIG, CRIT,
1447 "%s: line %d: missing factor(s) in \"security <factors>\""
1448 " line.\n", fname, lineno ,0 );
1450 Debug( LDAP_DEBUG_ANY,
1451 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1459 set = &global_ssf_set;
1461 set = &be->be_ssf_set;
1464 for( i=1; i < cargc; i++ ) {
1465 if( strncasecmp( cargv[i], "ssf=",
1466 sizeof("ssf") ) == 0 )
1469 atoi( &cargv[i][sizeof("ssf")] );
1471 } else if( strncasecmp( cargv[i], "transport=",
1472 sizeof("transport") ) == 0 )
1474 set->sss_transport =
1475 atoi( &cargv[i][sizeof("transport")] );
1477 } else if( strncasecmp( cargv[i], "tls=",
1478 sizeof("tls") ) == 0 )
1481 atoi( &cargv[i][sizeof("tls")] );
1483 } else if( strncasecmp( cargv[i], "sasl=",
1484 sizeof("sasl") ) == 0 )
1487 atoi( &cargv[i][sizeof("sasl")] );
1489 } else if( strncasecmp( cargv[i], "update_ssf=",
1490 sizeof("update_ssf") ) == 0 )
1492 set->sss_update_ssf =
1493 atoi( &cargv[i][sizeof("update_ssf")] );
1495 } else if( strncasecmp( cargv[i], "update_transport=",
1496 sizeof("update_transport") ) == 0 )
1498 set->sss_update_transport =
1499 atoi( &cargv[i][sizeof("update_transport")] );
1501 } else if( strncasecmp( cargv[i], "update_tls=",
1502 sizeof("update_tls") ) == 0 )
1504 set->sss_update_tls =
1505 atoi( &cargv[i][sizeof("update_tls")] );
1507 } else if( strncasecmp( cargv[i], "update_sasl=",
1508 sizeof("update_sasl") ) == 0 )
1510 set->sss_update_sasl =
1511 atoi( &cargv[i][sizeof("update_sasl")] );
1513 } else if( strncasecmp( cargv[i], "simple_bind=",
1514 sizeof("simple_bind") ) == 0 )
1516 set->sss_simple_bind =
1517 atoi( &cargv[i][sizeof("simple_bind")] );
1521 LDAP_LOG( CONFIG, CRIT,
1522 "%s: line %d: unknown factor %S in "
1523 "\"security <factors>\" line.\n",
1524 fname, lineno, cargv[1] );
1526 Debug( LDAP_DEBUG_ANY,
1527 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1528 fname, lineno, cargv[i] );
1534 /* where to send clients when we don't hold it */
1535 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1538 LDAP_LOG( CONFIG, CRIT,
1539 "%s: line %d: missing URL in \"referral <URL>\""
1540 " line.\n", fname, lineno , 0 );
1542 Debug( LDAP_DEBUG_ANY,
1543 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1550 if( validate_global_referral( cargv[1] ) ) {
1552 LDAP_LOG( CONFIG, CRIT,
1553 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1554 fname, lineno, cargv[1] );
1556 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1557 "invalid URL (%s) in \"referral\" line.\n",
1558 fname, lineno, cargv[1] );
1563 vals[0].bv_val = cargv[1];
1564 vals[0].bv_len = strlen( vals[0].bv_val );
1565 if( value_add( &default_referral, vals ) )
1569 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1573 LDAP_LOG( CONFIG, CRIT,
1574 "%s: line %d: Error in logfile directive, "
1575 "\"logfile <filename>\"\n", fname, lineno , 0 );
1577 Debug( LDAP_DEBUG_ANY,
1578 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1584 logfile = fopen( cargv[1], "w" );
1585 if ( logfile != NULL ) lutil_debug_file( logfile );
1588 /* start of a new database definition */
1589 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1593 LDAP_LOG( CONFIG, CRIT,
1594 "%s: line %d: Error in debug directive, "
1595 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1597 Debug( LDAP_DEBUG_ANY,
1598 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1604 level = atoi( cargv[2] );
1605 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1606 lutil_set_debug_level( cargv[1], level );
1607 /* specify an Object Identifier macro */
1608 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1609 rc = parse_oidm( fname, lineno, cargc, cargv );
1612 /* specify an objectclass */
1613 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1616 LDAP_LOG( CONFIG, INFO,
1617 "%s: line %d: illegal objectclass format.\n",
1618 fname, lineno , 0 );
1620 Debug( LDAP_DEBUG_ANY,
1621 "%s: line %d: illegal objectclass format.\n",
1626 } else if ( *cargv[1] == '(' /*')'*/) {
1628 p = strchr(saveline,'(' /*')'*/);
1629 rc = parse_oc( fname, lineno, p, cargv );
1634 LDAP_LOG( CONFIG, INFO,
1635 "%s: line %d: old objectclass format not supported\n",
1636 fname, lineno , 0 );
1638 Debug( LDAP_DEBUG_ANY,
1639 "%s: line %d: old objectclass format not supported.\n",
1644 #ifdef SLAP_EXTENDED_SCHEMA
1645 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1647 p = strchr(saveline,'(' /*')'*/);
1648 rc = parse_cr( fname, lineno, p, cargv );
1652 /* specify an attribute type */
1653 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1654 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1658 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1659 "illegal attribute type format.\n",
1660 fname, lineno , 0 );
1662 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1663 "illegal attribute type format.\n",
1668 } else if ( *cargv[1] == '(' /*')'*/) {
1670 p = strchr(saveline,'(' /*')'*/);
1671 rc = parse_at( fname, lineno, p, cargv );
1676 LDAP_LOG( CONFIG, INFO,
1677 "%s: line %d: old attribute type format not supported.\n",
1678 fname, lineno , 0 );
1680 Debug( LDAP_DEBUG_ANY,
1681 "%s: line %d: old attribute type format not supported.\n",
1687 /* define attribute option(s) */
1688 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1689 ad_define_option( NULL, NULL, 0 );
1690 for ( i = 1; i < cargc; i++ )
1691 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1694 /* turn on/off schema checking */
1695 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1698 LDAP_LOG( CONFIG, CRIT,
1699 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1700 " line.\n", fname, lineno , 0 );
1702 Debug( LDAP_DEBUG_ANY,
1703 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1709 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1711 LDAP_LOG( CONFIG, CRIT,
1712 "%s: line %d: schema checking disabled! your mileage may "
1713 "vary!\n", fname, lineno , 0 );
1715 Debug( LDAP_DEBUG_ANY,
1716 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1719 global_schemacheck = 0;
1721 global_schemacheck = 1;
1724 /* specify access control info */
1725 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1726 parse_acl( be, fname, lineno, cargc, cargv );
1728 /* debug level to log things to syslog */
1729 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1732 LDAP_LOG( CONFIG, CRIT,
1733 "%s: line %d: missing level in \"loglevel <level>\""
1734 " line.\n", fname, lineno , 0 );
1736 Debug( LDAP_DEBUG_ANY,
1737 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1746 for( i=1; i < cargc; i++ ) {
1747 ldap_syslog += atoi( cargv[1] );
1750 #ifdef LDAP_SYNCREPL
1751 /* list of sync replication information in this backend (slave only) */
1752 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1754 add_syncrepl( be, cargv, cargc );
1757 /* list of replicas of the data in this backend (master only) */
1758 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1761 LDAP_LOG( CONFIG, CRIT,
1762 "%s: line %d: missing host or uri in \"replica "
1763 " <host[:port]\" line\n", fname, lineno , 0 );
1765 Debug( LDAP_DEBUG_ANY,
1766 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1774 LDAP_LOG( CONFIG, INFO,
1775 "%s: line %d: replica line must appear inside "
1776 "a database definition.\n", fname, lineno, 0);
1778 Debug( LDAP_DEBUG_ANY,
1779 "%s: line %d: replica line must appear inside a database definition\n",
1787 for ( i = 1; i < cargc; i++ ) {
1788 if ( strncasecmp( cargv[i], "host=", 5 )
1790 nr = add_replica_info( be,
1793 } else if (strncasecmp( cargv[i], "uri=", 4 )
1795 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1798 LDAP_LOG( CONFIG, INFO,
1799 "%s: line %d: replica line contains invalid "
1800 "uri definition.\n", fname, lineno, 0);
1802 Debug( LDAP_DEBUG_ANY,
1803 "%s: line %d: replica line contains invalid "
1804 "uri definition.\n", fname, lineno, 0);
1808 if (ludp->lud_host == NULL ) {
1810 LDAP_LOG( CONFIG, INFO,
1811 "%s: line %d: replica line contains invalid "
1812 "uri definition - missing hostname.\n",
1815 Debug( LDAP_DEBUG_ANY,
1816 "%s: line %d: replica line contains invalid "
1817 "uri definition - missing hostname.\n", fname, lineno, 0);
1821 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1822 if ( replicahost == NULL ) {
1824 LDAP_LOG( CONFIG, ERR,
1825 "out of memory in read_config\n", 0, 0,0 );
1827 Debug( LDAP_DEBUG_ANY,
1828 "out of memory in read_config\n", 0, 0, 0 );
1830 ldap_free_urldesc( ludp );
1831 exit( EXIT_FAILURE );
1833 sprintf(replicahost, "%s:%d",
1834 ludp->lud_host, ludp->lud_port);
1835 nr = add_replica_info( be, replicahost );
1836 ldap_free_urldesc( ludp );
1837 ch_free(replicahost);
1843 LDAP_LOG( CONFIG, INFO,
1844 "%s: line %d: missing host or uri in \"replica\" line\n",
1845 fname, lineno , 0 );
1847 Debug( LDAP_DEBUG_ANY,
1848 "%s: line %d: missing host or uri in \"replica\" line\n",
1853 } else if ( nr == -1 ) {
1855 LDAP_LOG( CONFIG, INFO,
1856 "%s: line %d: unable to add"
1857 " replica \"%s\"\n",
1861 Debug( LDAP_DEBUG_ANY,
1862 "%s: line %d: unable to add replica \"%s\"\n",
1863 fname, lineno, cargv[i] + 5 );
1867 for ( i = 1; i < cargc; i++ ) {
1868 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1870 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1873 LDAP_LOG( CONFIG, INFO,
1874 "%s: line %d: suffix \"%s\" in \"replica\""
1875 " line is not valid for backend(ignored)\n",
1876 fname, lineno, cargv[i] + 7 );
1878 Debug( LDAP_DEBUG_ANY,
1879 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1880 fname, lineno, cargv[i] + 7 );
1886 LDAP_LOG( CONFIG, INFO,
1887 "%s: line %d: unable to normalize suffix"
1888 " in \"replica\" line (ignored)\n",
1889 fname, lineno , 0 );
1891 Debug( LDAP_DEBUG_ANY,
1892 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1898 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1900 char *arg = cargv[i] + 4;
1902 if ( arg[0] == '!' ) {
1907 if ( arg[0] != '=' ) {
1911 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1913 LDAP_LOG( CONFIG, INFO,
1914 "%s: line %d: attribute \"%s\" in "
1915 "\"replica\" line is unknown\n",
1916 fname, lineno, arg + 1 );
1918 Debug( LDAP_DEBUG_ANY,
1919 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1920 fname, lineno, arg + 1 );
1929 /* dn of master entity allowed to write to replica */
1930 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1933 LDAP_LOG( CONFIG, CRIT,
1934 "%s: line %d: missing dn in \"updatedn <dn>\""
1935 " line.\n", fname, lineno , 0 );
1937 Debug( LDAP_DEBUG_ANY,
1938 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1946 LDAP_LOG( CONFIG, INFO,
1947 "%s: line %d: updatedn line must appear inside "
1948 "a database definition\n",
1949 fname, lineno , 0 );
1951 Debug( LDAP_DEBUG_ANY,
1952 "%s: line %d: updatedn line must appear inside a database definition\n",
1960 if ( load_ucdata( NULL ) < 0 ) return 1;
1962 dn.bv_val = cargv[1];
1963 dn.bv_len = strlen( cargv[1] );
1965 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
1966 if( rc != LDAP_SUCCESS ) {
1968 LDAP_LOG( CONFIG, CRIT,
1969 "%s: line %d: updatedn DN is invalid.\n",
1970 fname, lineno , 0 );
1972 Debug( LDAP_DEBUG_ANY,
1973 "%s: line %d: updatedn DN is invalid\n",
1980 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1983 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1984 "missing url in \"updateref <ldapurl>\" line.\n",
1985 fname, lineno , 0 );
1987 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1988 "missing url in \"updateref <ldapurl>\" line\n",
1996 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
1997 " line must appear inside a database definition\n",
1998 fname, lineno , 0 );
2000 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2001 " line must appear inside a database definition\n",
2006 } else if ( !be->be_update_ndn.bv_len ) {
2008 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2009 "updateref line must come after updatedn.\n",
2010 fname, lineno , 0 );
2012 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2013 "updateref line must after updatedn.\n",
2019 if( validate_global_referral( cargv[1] ) ) {
2021 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2022 "invalid URL (%s) in \"updateref\" line.\n",
2023 fname, lineno, cargv[1] );
2025 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2026 "invalid URL (%s) in \"updateref\" line.\n",
2027 fname, lineno, cargv[1] );
2032 vals[0].bv_val = cargv[1];
2033 vals[0].bv_len = strlen( vals[0].bv_val );
2034 if( value_add( &be->be_update_refs, vals ) )
2037 /* replication log file to which changes are appended */
2038 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2041 LDAP_LOG( CONFIG, CRIT,
2042 "%s: line %d: missing filename in \"replogfile <filename>\""
2043 " line.\n", fname, lineno , 0 );
2045 Debug( LDAP_DEBUG_ANY,
2046 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2053 be->be_replogfile = ch_strdup( cargv[1] );
2055 replogfile = ch_strdup( cargv[1] );
2058 /* file from which to read additional rootdse attrs */
2059 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2062 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2063 "missing filename in \"rootDSE <filename>\" line.\n",
2064 fname, lineno , 0 );
2066 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2067 "missing filename in \"rootDSE <filename>\" line.\n",
2073 if( read_root_dse_file( cargv[1] ) ) {
2075 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2076 "could not read \"rootDSE <filename>\" line.\n",
2077 fname, lineno , 0 );
2079 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2080 "could not read \"rootDSE <filename>\" line\n",
2086 /* maintain lastmodified{by,time} attributes */
2087 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2090 LDAP_LOG( CONFIG, CRIT,
2091 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2092 " line.\n", fname, lineno , 0 );
2094 Debug( LDAP_DEBUG_ANY,
2095 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2101 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2103 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2109 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2116 /* turn on/off gentle SIGHUP handling */
2117 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2119 Debug( LDAP_DEBUG_ANY,
2120 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2124 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2125 global_gentlehup = 0;
2127 global_gentlehup = 1;
2131 /* set idle timeout value */
2132 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2136 LDAP_LOG( CONFIG, CRIT,
2137 "%s: line %d: missing timeout value in "
2138 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2140 Debug( LDAP_DEBUG_ANY,
2141 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2148 i = atoi( cargv[1] );
2152 LDAP_LOG( CONFIG, CRIT,
2153 "%s: line %d: timeout value (%d) invalid "
2154 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2156 Debug( LDAP_DEBUG_ANY,
2157 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2164 global_idletimeout = i;
2166 /* include another config file */
2167 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2170 LDAP_LOG( CONFIG, CRIT,
2171 "%s: line %d: missing filename in \"include "
2172 "<filename>\" line.\n", fname, lineno , 0 );
2174 Debug( LDAP_DEBUG_ANY,
2175 "%s: line %d: missing filename in \"include <filename>\" line\n",
2181 savefname = ch_strdup( cargv[1] );
2182 savelineno = lineno;
2184 if ( read_config( savefname, depth+1 ) != 0 ) {
2189 lineno = savelineno - 1;
2191 /* location of kerberos srvtab file */
2192 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2195 LDAP_LOG( CONFIG, CRIT,
2196 "%s: line %d: missing filename in \"srvtab "
2197 "<filename>\" line.\n", fname, lineno , 0 );
2199 Debug( LDAP_DEBUG_ANY,
2200 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2206 ldap_srvtab = ch_strdup( cargv[1] );
2208 #ifdef SLAPD_MODULES
2209 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2212 LDAP_LOG( CONFIG, INFO,
2213 "%s: line %d: missing filename in \"moduleload "
2214 "<filename>\" line.\n", fname, lineno , 0 );
2216 Debug( LDAP_DEBUG_ANY,
2217 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2221 exit( EXIT_FAILURE );
2223 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2225 LDAP_LOG( CONFIG, CRIT,
2226 "%s: line %d: failed to load or initialize module %s\n",
2227 fname, lineno, cargv[1] );
2229 Debug( LDAP_DEBUG_ANY,
2230 "%s: line %d: failed to load or initialize module %s\n",
2231 fname, lineno, cargv[1]);
2234 exit( EXIT_FAILURE );
2236 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2239 LDAP_LOG( CONFIG, INFO,
2240 "%s: line %d: missing path in \"modulepath <path>\""
2241 " line\n", fname, lineno , 0 );
2243 Debug( LDAP_DEBUG_ANY,
2244 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2248 exit( EXIT_FAILURE );
2250 if (module_path( cargv[1] )) {
2252 LDAP_LOG( CONFIG, CRIT,
2253 "%s: line %d: failed to set module search path to %s.\n",
2254 fname, lineno, cargv[1] );
2256 Debug( LDAP_DEBUG_ANY,
2257 "%s: line %d: failed to set module search path to %s\n",
2258 fname, lineno, cargv[1]);
2261 exit( EXIT_FAILURE );
2264 #endif /*SLAPD_MODULES*/
2267 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2268 rc = ldap_pvt_tls_set_option( NULL,
2269 LDAP_OPT_X_TLS_RANDOM_FILE,
2274 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2275 rc = ldap_pvt_tls_set_option( NULL,
2276 LDAP_OPT_X_TLS_CIPHER_SUITE,
2281 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2282 rc = ldap_pvt_tls_set_option( NULL,
2283 LDAP_OPT_X_TLS_CERTFILE,
2288 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2289 rc = ldap_pvt_tls_set_option( NULL,
2290 LDAP_OPT_X_TLS_KEYFILE,
2295 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2296 rc = ldap_pvt_tls_set_option( NULL,
2297 LDAP_OPT_X_TLS_CACERTDIR,
2302 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2303 rc = ldap_pvt_tls_set_option( NULL,
2304 LDAP_OPT_X_TLS_CACERTFILE,
2308 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2309 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2311 rc = ldap_pvt_tls_set_option( NULL,
2312 LDAP_OPT_X_TLS_REQUIRE_CERT,
2315 rc = ldap_int_tls_config( NULL,
2316 LDAP_OPT_X_TLS_REQUIRE_CERT,
2325 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2326 #ifdef SLAPD_RLOOKUPS
2329 LDAP_LOG( CONFIG, INFO,
2330 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2331 fname, lineno , 0 );
2333 Debug( LDAP_DEBUG_ANY,
2334 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2340 if ( !strcasecmp( cargv[1], "on" ) ) {
2341 use_reverse_lookup = 1;
2342 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2343 use_reverse_lookup = 0;
2346 LDAP_LOG( CONFIG, INFO,
2347 "%s: line %d: reverse-lookup: "
2348 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2350 Debug( LDAP_DEBUG_ANY,
2351 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2357 #else /* !SLAPD_RLOOKUPS */
2359 LDAP_LOG( CONFIG, INFO,
2360 "%s: line %d: reverse lookups "
2361 "are not configured (ignored).\n", fname, lineno , 0 );
2363 Debug( LDAP_DEBUG_ANY,
2364 "%s: line %d: reverse lookups are not configured (ignored).\n",
2367 #endif /* !SLAPD_RLOOKUPS */
2369 /* Netscape plugins */
2370 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2371 #if defined( LDAP_SLAPI )
2373 #ifdef notdef /* allow global plugins, too */
2375 * a "plugin" line must be inside a database
2376 * definition, since we implement pre-,post-
2377 * and extended operation plugins
2381 LDAP_LOG( CONFIG, INFO,
2382 "%s: line %d: plugin line must appear "
2383 "inside a database definition.\n",
2386 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2387 "line must appear inside a database "
2388 "definition\n", fname, lineno, 0 );
2394 if ( netscape_plugin( be, fname, lineno, cargc, cargv )
2399 #else /* !defined( LDAP_SLAPI ) */
2401 LDAP_LOG( CONFIG, INFO,
2402 "%s: line %d: SLAPI not supported.\n",
2405 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2406 "not supported.\n", fname, lineno, 0 );
2410 #endif /* !defined( LDAP_SLAPI ) */
2412 /* Netscape plugins */
2413 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2414 #if defined( LDAP_SLAPI )
2417 LDAP_LOG( CONFIG, INFO,
2418 "%s: line %d: missing file name "
2419 "in pluginlog <filename> line.\n",
2422 Debug( LDAP_DEBUG_ANY,
2423 "%s: line %d: missing file name "
2424 "in pluginlog <filename> line.\n",
2430 if ( slapi_log_file != NULL ) {
2431 ch_free( slapi_log_file );
2434 slapi_log_file = ch_strdup( cargv[1] );
2435 #endif /* !defined( LDAP_SLAPI ) */
2437 /* pass anything else to the current backend info/db config routine */
2440 if ( bi->bi_config == 0 ) {
2442 LDAP_LOG( CONFIG, INFO,
2443 "%s: line %d: unknown directive \"%s\" inside "
2444 "backend info definition (ignored).\n",
2445 fname, lineno, cargv[0] );
2447 Debug( LDAP_DEBUG_ANY,
2448 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2449 fname, lineno, cargv[0] );
2453 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2459 } else if ( be != NULL ) {
2460 if ( be->be_config == 0 ) {
2462 LDAP_LOG( CONFIG, INFO,
2463 "%s: line %d: uknown directive \"%s\" inside "
2464 "backend database definition (ignored).\n",
2465 fname, lineno, cargv[0] );
2467 Debug( LDAP_DEBUG_ANY,
2468 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2469 fname, lineno, cargv[0] );
2473 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2481 LDAP_LOG( CONFIG, INFO,
2482 "%s: line %d: unknown directive \"%s\" outside backend "
2483 "info and database definitions (ignored).\n",
2484 fname, lineno, cargv[0] );
2486 Debug( LDAP_DEBUG_ANY,
2487 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2488 fname, lineno, cargv[0] );
2497 if ( depth == 0 ) ch_free( cargv );
2499 if ( !global_schemadn.bv_val ) {
2500 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2502 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2505 if ( load_ucdata( NULL ) < 0 ) return 1;
2517 char logbuf[sizeof("pseudorootpw ***")];
2520 token = strtok_quote( line, " \t" );
2524 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2525 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2526 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2527 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2528 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2530 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2533 if ( strtok_quote_ptr ) {
2534 *strtok_quote_ptr = ' ';
2538 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2540 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2543 if ( strtok_quote_ptr ) {
2544 *strtok_quote_ptr = '\0';
2547 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2548 if ( cargc == cargv_size - 1 ) {
2550 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2552 if ( tmp == NULL ) {
2554 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2556 Debug( LDAP_DEBUG_ANY,
2557 "line %d: out of memory\n",
2563 cargv_size += ARGS_STEP;
2565 cargv[cargc++] = token;
2567 cargv[cargc] = NULL;
2572 strtok_quote( char *line, char *sep )
2578 strtok_quote_ptr = NULL;
2579 if ( line != NULL ) {
2582 while ( *next && strchr( sep, *next ) ) {
2586 if ( *next == '\0' ) {
2592 for ( inquote = 0; *next; ) {
2600 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2606 next + 1, strlen( next + 1 ) + 1 );
2607 next++; /* dont parse the escaped character */
2612 if ( strchr( sep, *next ) != NULL ) {
2613 strtok_quote_ptr = next;
2626 static char buf[BUFSIZ];
2628 static size_t lmax, lcur;
2630 #define CATLINE( buf ) \
2632 size_t len = strlen( buf ); \
2633 while ( lcur + len + 1 > lmax ) { \
2635 line = (char *) ch_realloc( line, lmax ); \
2637 strcpy( line + lcur, buf ); \
2642 fp_getline( FILE *fp, int *lineno )
2650 /* hack attack - keeps us from having to keep a stack of bufs... */
2651 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2656 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2657 /* trim off \r\n or \n */
2658 if ( (p = strchr( buf, '\n' )) != NULL ) {
2659 if( p > buf && p[-1] == '\r' ) --p;
2663 /* trim off trailing \ and append the next line */
2664 if ( line[ 0 ] != '\0'
2665 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2666 && p[ -1 ] != '\\' ) {
2671 if ( ! isspace( (unsigned char) buf[0] ) ) {
2675 /* change leading whitespace to a space */
2684 return( line[0] ? line : NULL );
2688 fp_getline_init( int *lineno )
2694 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2696 load_ucdata( char *path )
2698 static int loaded = 0;
2704 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2707 LDAP_LOG( CONFIG, CRIT,
2708 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2710 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2723 ucdata_unload( UCDATA_ALL );
2724 free( global_schemandn.bv_val );
2725 free( global_schemadn.bv_val );
2727 if ( slapd_args_file )
2728 free ( slapd_args_file );
2729 if ( slapd_pid_file )
2730 free ( slapd_pid_file );
2731 if ( default_passwd_hash )
2732 free( default_passwd_hash );
2733 acl_destroy( global_acl, NULL );
2736 #ifdef LDAP_SYNCREPL
2746 si = be->syncinfo = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2748 /* set default values; FIXME : add others */
2750 if ( be->be_rootndn.bv_val )
2751 ber_dupbv( &si->updatedn, &be->be_rootndn );
2752 si->bindmethod = LDAP_AUTH_SIMPLE;
2753 si->lastmod = LASTMOD_NO;
2754 si->filterstr = "(objectclass=*)";
2755 if ( be->be_suffix && be->be_suffix[0].bv_val )
2756 si->base = ch_strdup( be->be_suffix[0].bv_val );
2757 si->scope = LDAP_SCOPE_SUBTREE;
2759 si->attrsexclude = 0;
2760 si->attrs = (char **) ch_calloc( 1, sizeof( char * ));
2761 si->attrs[0] = NULL;
2762 si->type = LDAP_SYNC_REFRESH_ONLY;
2763 si->interval = 86400;
2764 si->syncCookie = NULL;
2765 si->manageDSAit = 0;
2768 si->syncUUID = NULL;
2769 si->syncUUID_ndn = NULL;
2771 si->presentlist = NULL;
2772 LDAP_LIST_INIT( &si->nonpresentlist );
2776 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2778 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2780 exit( EXIT_FAILURE );
2783 if ( parse_syncrepl_line( cargv, cargc, si ) < 0 ) {
2784 /* Something bad happened - back out */
2786 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2788 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2791 be->syncinfo = NULL;
2794 LDAP_LOG ( CONFIG, RESULTS,
2795 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
2796 si->provideruri == NULL ? "(null)" : si->provideruri, 0, 0 );
2798 Debug( LDAP_DEBUG_CONFIG,
2799 "Config: ** successfully added syncrepl \"%s\"\n",
2800 si->provideruri == NULL ? "(null)" : si->provideruri, 0, 0 );
2807 #define PROVIDERSTR "provider"
2808 #define SUFFIXSTR "suffix"
2809 #define UPDATEDNSTR "updatedn"
2810 #define BINDMETHSTR "bindmethod"
2811 #define SIMPLESTR "simple"
2812 #define SASLSTR "sasl"
2813 #define BINDDNSTR "binddn"
2814 #define CREDSTR "credentials"
2815 #define OLDAUTHCSTR "bindprincipal"
2816 #define AUTHCSTR "authcID"
2817 #define AUTHZSTR "authzID"
2818 #define SRVTABSTR "srvtab"
2819 #define SASLMECHSTR "saslmech"
2820 #define REALMSTR "realm"
2821 #define SECPROPSSTR "secprops"
2822 #define STARTTLSSTR "starttls"
2823 #define CRITICALSTR "critical"
2825 #define FILTERSTR "filter"
2826 #define SEARCHBASESTR "searchbase"
2827 #define SCOPESTR "scope"
2828 #define ATTRSSTR "attrs"
2829 #define ATTRSONLYSTR "attrsonly"
2830 #define TYPESTR "type"
2831 #define INTERVALSTR "interval"
2832 #define COOKIESTR "cookie"
2833 #define LASTMODSTR "lastmod"
2834 #define LMREQSTR "req"
2835 #define LMGENSTR "gen"
2836 #define LMNOSTR "no"
2837 #define MANAGEDSAITSTR "manageDSAit"
2838 #define SLIMITSTR "sizelimit"
2839 #define TLIMITSTR "timelimit"
2841 #define GOT_ID 0x0001
2842 #define GOT_PROVIDER 0x0002
2843 #define GOT_METHOD 0x0004
2844 #define GOT_ALL 0x0007
2847 parse_syncrepl_line(
2858 for ( i = 1; i < cargc; i++ ) {
2859 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
2860 /* '\0' string terminator accounts for '=' */
2861 val = cargv[ i ] + sizeof( IDSTR );
2862 si->id = atoi( val );
2864 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
2865 sizeof( PROVIDERSTR ) - 1 )) {
2866 val = cargv[ i ] + sizeof( PROVIDERSTR );
2867 si->provideruri = ch_strdup( val );
2868 si->provideruri_bv = (BerVarray) ch_calloc( 2, sizeof( struct berval ));
2869 ber_str2bv( si->provideruri, strlen( si->provideruri ), 0, &si->provideruri_bv[0] );
2870 si->provideruri_bv[1].bv_len = 0;
2871 si->provideruri_bv[1].bv_val = NULL;
2872 gots |= GOT_PROVIDER;
2873 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
2874 sizeof(STARTTLSSTR) - 1 ) )
2876 val = cargv[ i ] + sizeof( STARTTLSSTR );
2877 if( !strcasecmp( val, CRITICALSTR ) ) {
2878 si->tls = TLS_CRITICAL;
2882 } else if ( !strncasecmp( cargv[ i ],
2883 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) ) {
2885 struct berval updatedn = {0, NULL};
2886 val = cargv[ i ] + sizeof( UPDATEDNSTR );
2887 str = ch_strdup( val );
2888 ber_str2bv( str, strlen(str), 1, &updatedn );
2889 dnNormalize( 0, NULL, NULL, &updatedn, &si->updatedn, NULL );
2891 ch_free( updatedn.bv_val );
2892 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
2893 sizeof( BINDMETHSTR ) - 1 ) ) {
2894 val = cargv[ i ] + sizeof( BINDMETHSTR );
2895 if ( !strcasecmp( val, SIMPLESTR )) {
2896 si->bindmethod = LDAP_AUTH_SIMPLE;
2898 } else if ( !strcasecmp( val, SASLSTR )) {
2899 si->bindmethod = LDAP_AUTH_SASL;
2902 si->bindmethod = -1;
2904 } else if ( !strncasecmp( cargv[ i ],
2905 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
2906 val = cargv[ i ] + sizeof( BINDDNSTR );
2907 si->binddn = ch_strdup( val );
2908 } else if ( !strncasecmp( cargv[ i ],
2909 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
2910 val = cargv[ i ] + sizeof( CREDSTR );
2911 si->passwd = ch_strdup( val );
2912 } else if ( !strncasecmp( cargv[ i ],
2913 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
2914 val = cargv[ i ] + sizeof( SASLMECHSTR );
2915 si->saslmech = ch_strdup( val );
2916 } else if ( !strncasecmp( cargv[ i ],
2917 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
2918 val = cargv[ i ] + sizeof( SECPROPSSTR );
2919 si->secprops = ch_strdup( val );
2920 } else if ( !strncasecmp( cargv[ i ],
2921 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
2922 val = cargv[ i ] + sizeof( REALMSTR );
2923 si->realm = ch_strdup( val );
2924 } else if ( !strncasecmp( cargv[ i ],
2925 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
2926 val = cargv[ i ] + sizeof( AUTHCSTR );
2927 si->authcId = ch_strdup( val );
2928 } else if ( !strncasecmp( cargv[ i ],
2929 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
2930 /* Old authcID is provided for some backwards compatibility */
2931 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
2932 si->authcId = ch_strdup( val );
2933 } else if ( !strncasecmp( cargv[ i ],
2934 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
2935 val = cargv[ i ] + sizeof( AUTHZSTR );
2936 si->authzId = ch_strdup( val );
2937 } else if ( !strncasecmp( cargv[ i ],
2938 SRVTABSTR, sizeof( SRVTABSTR ) - 1 ) ) {
2939 val = cargv[ i ] + sizeof( SRVTABSTR );
2940 if ( si->srvtab != NULL ) {
2943 si->srvtab = ch_strdup( val );
2944 } else if ( !strncasecmp( cargv[ i ], LASTMODSTR,
2945 sizeof( LASTMODSTR ) - 1 ) ) {
2946 val = cargv[ i ] + sizeof( LASTMODSTR );
2947 if ( !strcasecmp( val, LMREQSTR )) {
2948 si->lastmod = LASTMOD_REQ;
2949 } else if ( !strcasecmp( val, LMGENSTR )) {
2950 si->lastmod = LASTMOD_GEN;
2951 } else if ( !strcasecmp( val, LMNOSTR )) {
2952 si->lastmod = LASTMOD_NO;
2956 } else if ( !strncasecmp( cargv[ i ],
2957 FILTERSTR, sizeof( FILTERSTR ) - 1 ) ) {
2958 val = cargv[ i ] + sizeof( FILTERSTR );
2959 si->filterstr = ch_strdup( val );
2960 } else if ( !strncasecmp( cargv[ i ],
2961 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) ) {
2962 val = cargv[ i ] + sizeof( SEARCHBASESTR );
2963 si->base = ch_strdup( val );
2964 } else if ( !strncasecmp( cargv[ i ],
2965 SCOPESTR, sizeof( SCOPESTR ) - 1 ) ) {
2966 val = cargv[ i ] + sizeof( SCOPESTR );
2967 if ( !strncasecmp( val, "base", sizeof( "base" ) - 1 )) {
2968 si->scope = LDAP_SCOPE_BASE;
2969 } else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
2970 si->scope = LDAP_SCOPE_ONELEVEL;
2971 } else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
2972 si->scope = LDAP_SCOPE_SUBTREE;
2974 fprintf( stderr, "Error: parse_syncrepl_line: "
2975 "unknown scope \"%s\"\n", val);
2978 } else if ( !strncasecmp( cargv[ i ],
2979 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) ) {
2981 } else if ( !strncasecmp( cargv[ i ],
2982 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) ) {
2983 val = cargv[ i ] + sizeof( ATTRSSTR ) - 1;
2984 if ( *val == '!' ) {
2985 si->attrsexclude = 1;
2988 if ( *val++ != '=' )
2990 str2clist( &si->attrs, val, "," );
2991 } else if ( !strncasecmp( cargv[ i ],
2992 TYPESTR, sizeof( TYPESTR ) - 1 ) ) {
2993 val = cargv[ i ] + sizeof( TYPESTR );
2994 if ( !strncasecmp( val, "refreshOnly", sizeof( "refreshOnly" ) - 1 )) {
2995 si->type = LDAP_SYNC_REFRESH_ONLY;
2996 } else if ( !strncasecmp( val, "refreshAndPersist", sizeof( "refreshAndPersist" ) - 1 )) {
2997 si->type = LDAP_SYNC_REFRESH_AND_PERSIST;
3000 fprintf( stderr, "Error: parse_syncrepl_line: "
3001 "unknown sync type \"%s\"\n", val);
3004 } else if ( !strncasecmp( cargv[ i ],
3005 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) ) {
3006 val = cargv[ i ] + sizeof( INTERVALSTR );
3007 if ( si->type == LDAP_SYNC_REFRESH_AND_PERSIST )
3010 si->interval = atoi( val );
3011 if ( si->interval < 0 ) {
3012 fprintf( stderr, "Error: parse_syncrepl_line: "
3013 "invalid interval \"%ld\"\n",
3014 (long) si->interval);
3017 } else if ( !strncasecmp( cargv[ i ],
3018 COOKIESTR, sizeof( COOKIESTR ) - 1 ) ) {
3019 val = cargv[ i ] + sizeof( COOKIESTR );
3020 si->syncCookie = ber_str2bv( val, strlen( val ), 1, NULL );
3021 } else if ( !strncasecmp( cargv[ i ],
3022 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) ) {
3023 val = cargv[ i ] + sizeof( COOKIESTR );
3024 si->manageDSAit = atoi( val );
3025 } else if ( !strncasecmp( cargv[ i ],
3026 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) ) {
3027 val = cargv[ i ] + sizeof( SLIMITSTR );
3028 si->slimit = atoi( val );
3029 } else if ( !strncasecmp( cargv[ i ],
3030 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) ) {
3031 val = cargv[ i ] + sizeof( TLIMITSTR );
3032 si->tlimit = atoi( val );
3034 fprintf( stderr, "Error: parse_syncrepl_line: "
3035 "unknown keyword \"%s\"\n", cargv[ i ] );
3039 if ( gots != GOT_ALL ) {
3040 fprintf( stderr, "Error: Malformed \"syncrepl\" line in slapd config file"
3047 #endif /* LDAP_SYNCREPL */