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];
98 static int lastmod = 1;
99 static BackendInfo *bi = NULL;
100 static BackendDB *be = NULL;
102 vals[1].bv_val = NULL;
105 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
106 cargv_size = ARGS_STEP + 1;
109 if ( (fp = fopen( fname, "r" )) == NULL ) {
112 LDAP_LOG( CONFIG, ENTRY,
113 "read_config: " "could not open config file \"%s\": %s (%d)\n",
114 fname, strerror(errno), errno );
116 Debug( LDAP_DEBUG_ANY,
117 "could not open config file \"%s\": %s (%d)\n",
118 fname, strerror(errno), errno );
124 LDAP_LOG( CONFIG, ENTRY,
125 "read_config: reading config file %s\n", fname, 0, 0 );
127 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
131 fp_getline_init( &lineno );
133 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
134 /* skip comments and blank lines */
135 if ( line[0] == '#' || line[0] == '\0' ) {
139 /* fp_parse_line is destructive, we save a copy */
140 saveline = ch_strdup( line );
142 if ( fp_parse_line( lineno, line ) != 0 ) {
148 LDAP_LOG( CONFIG, INFO,
149 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
151 Debug( LDAP_DEBUG_ANY,
152 "%s: line %d: bad config line (ignored)\n",
159 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
162 LDAP_LOG( CONFIG, CRIT,
163 "%s : line %d: missing type in \"backend\" line.\n",
166 Debug( LDAP_DEBUG_ANY,
167 "%s: line %d: missing type in \"backend <type>\" line\n",
176 LDAP_LOG( CONFIG, CRIT,
177 "%s: line %d: backend line must appear before any "
178 "database definition.\n", fname, lineno , 0 );
180 Debug( LDAP_DEBUG_ANY,
181 "%s: line %d: backend line must appear before any database definition\n",
188 bi = backend_info( cargv[1] );
192 LDAP_LOG( CONFIG, CRIT,
193 "read_config: backend %s initialization failed.\n",
196 Debug( LDAP_DEBUG_ANY,
197 "backend %s initialization failed.\n",
203 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
206 LDAP_LOG( CONFIG, CRIT,
207 "%s: line %d: missing type in \"database <type>\" line\n",
210 Debug( LDAP_DEBUG_ANY,
211 "%s: line %d: missing type in \"database <type>\" line\n",
219 be = backend_db_init( cargv[1] );
223 LDAP_LOG( CONFIG, CRIT,
224 "database %s initialization failed.\n", cargv[1], 0, 0 );
226 Debug( LDAP_DEBUG_ANY,
227 "database %s initialization failed.\n",
234 /* set thread concurrency */
235 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
239 LDAP_LOG( CONFIG, CRIT,
240 "%s: line %d: missing level in \"concurrency <level\" "
241 " line\n", fname, lineno, 0 );
243 Debug( LDAP_DEBUG_ANY,
244 "%s: line %d: missing level in \"concurrency <level>\" line\n",
251 c = atoi( cargv[1] );
255 LDAP_LOG( CONFIG, CRIT,
256 "%s: line %d: invalid level (%d) in "
257 "\"concurrency <level>\" line.\n", fname, lineno, c );
259 Debug( LDAP_DEBUG_ANY,
260 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
267 ldap_pvt_thread_set_concurrency( c );
269 /* set sockbuf max */
270 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
274 LDAP_LOG( CONFIG, CRIT,
275 "%s: line %d: missing max in \"sockbuf_max_incoming "
276 "<bytes>\" line\n", fname, lineno, 0 );
278 Debug( LDAP_DEBUG_ANY,
279 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
286 max = atol( cargv[1] );
290 LDAP_LOG( CONFIG, CRIT,
291 "%s: line %d: invalid max value (%ld) in "
292 "\"sockbuf_max_incoming <bytes>\" line.\n",
293 fname, lineno, max );
295 Debug( LDAP_DEBUG_ANY,
296 "%s: line %d: invalid max value (%ld) in "
297 "\"sockbuf_max_incoming <bytes>\" line.\n",
298 fname, lineno, max );
304 sockbuf_max_incoming = max;
306 /* set sockbuf max authenticated */
307 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
311 LDAP_LOG( CONFIG, CRIT,
312 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
313 "<bytes>\" line\n", fname, lineno, 0 );
315 Debug( LDAP_DEBUG_ANY,
316 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
323 max = atol( cargv[1] );
327 LDAP_LOG( CONFIG, CRIT,
328 "%s: line %d: invalid max value (%ld) in "
329 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
330 fname, lineno, max );
332 Debug( LDAP_DEBUG_ANY,
333 "%s: line %d: invalid max value (%ld) in "
334 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
335 fname, lineno, max );
341 sockbuf_max_incoming_auth = max;
343 /* set conn pending max */
344 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
348 LDAP_LOG( CONFIG, CRIT,
349 "%s: line %d: missing max in \"conn_max_pending "
350 "<requests>\" line\n", fname, lineno, 0 );
352 Debug( LDAP_DEBUG_ANY,
353 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
360 max = atol( cargv[1] );
364 LDAP_LOG( CONFIG, CRIT,
365 "%s: line %d: invalid max value (%ld) in "
366 "\"conn_max_pending <requests>\" line.\n",
367 fname, lineno, max );
369 Debug( LDAP_DEBUG_ANY,
370 "%s: line %d: invalid max value (%ld) in "
371 "\"conn_max_pending <requests>\" line.\n",
372 fname, lineno, max );
378 slap_conn_max_pending = max;
380 /* set conn pending max authenticated */
381 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
385 LDAP_LOG( CONFIG, CRIT,
386 "%s: line %d: missing max in \"conn_max_pending_auth "
387 "<requests>\" line\n", fname, lineno, 0 );
389 Debug( LDAP_DEBUG_ANY,
390 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
397 max = atol( cargv[1] );
401 LDAP_LOG( CONFIG, CRIT,
402 "%s: line %d: invalid max value (%ld) in "
403 "\"conn_max_pending_auth <requests>\" line.\n",
404 fname, lineno, max );
406 Debug( LDAP_DEBUG_ANY,
407 "%s: line %d: invalid max value (%ld) in "
408 "\"conn_max_pending_auth <requests>\" line.\n",
409 fname, lineno, max );
415 slap_conn_max_pending_auth = max;
417 /* default search base */
418 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
421 LDAP_LOG( CONFIG, CRIT,
422 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
423 "line\n", fname, lineno, 0 );
425 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
426 "missing dn in \"defaultSearchBase <dn>\" line\n",
432 } else if ( cargc > 2 ) {
434 LDAP_LOG( CONFIG, INFO,
435 "%s: line %d: extra cruft after <dn> in "
436 "\"defaultSearchBase %s\" line (ignored)\n",
437 fname, lineno, cargv[1] );
439 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
440 "extra cruft after <dn> in \"defaultSearchBase %s\", "
442 fname, lineno, cargv[1] );
446 if ( bi != NULL || be != NULL ) {
448 LDAP_LOG( CONFIG, CRIT,
449 "%s: line %d: defaultSearchBase line must appear "
450 "prior to any backend or database definitions\n",
453 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
454 "defaultSearchBaase line must appear prior to "
455 "any backend or database definition\n",
462 if ( default_search_nbase.bv_len ) {
464 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
465 "default search base \"%s\" already defined "
466 "(discarding old)\n", fname, lineno,
467 default_search_base.bv_val );
469 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
470 "default search base \"%s\" already defined "
471 "(discarding old)\n",
472 fname, lineno, default_search_base.bv_val );
475 free( default_search_base.bv_val );
476 free( default_search_nbase.bv_val );
479 if ( load_ucdata( NULL ) < 0 ) return 1;
484 dn.bv_val = cargv[1];
485 dn.bv_len = strlen( dn.bv_val );
487 rc = dnPrettyNormal( NULL, &dn,
488 &default_search_base,
489 &default_search_nbase, NULL );
491 if( rc != LDAP_SUCCESS ) {
493 LDAP_LOG( CONFIG, CRIT,
494 "%s: line %d: defaultSearchBase DN is invalid.\n",
497 Debug( LDAP_DEBUG_ANY,
498 "%s: line %d: defaultSearchBase DN is invalid\n",
505 /* set maximum threads in thread pool */
506 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
510 LDAP_LOG( CONFIG, CRIT,
511 "%s: line %d: missing count in \"threads <count>\" line\n",
514 Debug( LDAP_DEBUG_ANY,
515 "%s: line %d: missing count in \"threads <count>\" line\n",
522 c = atoi( cargv[1] );
526 LDAP_LOG( CONFIG, CRIT,
527 "%s: line %d: invalid level (%d) in \"threads <count>\""
528 "line\n", fname, lineno, c );
530 Debug( LDAP_DEBUG_ANY,
531 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
538 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
540 /* save for later use */
541 connection_pool_max = c;
543 /* get pid file name */
544 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
547 LDAP_LOG( CONFIG, CRIT,
548 "%s: line %d missing file name in \"pidfile <file>\" "
549 "line.\n", fname, lineno, 0 );
551 Debug( LDAP_DEBUG_ANY,
552 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
559 slapd_pid_file = ch_strdup( cargv[1] );
561 /* get args file name */
562 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
565 LDAP_LOG( CONFIG, CRIT,
566 "%s: %d: missing file name in "
567 "\"argsfile <file>\" line.\n",
570 Debug( LDAP_DEBUG_ANY,
571 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
578 slapd_args_file = ch_strdup( cargv[1] );
580 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
583 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
586 /* default password hash */
587 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
590 LDAP_LOG( CONFIG, CRIT,
591 "%s: line %d: missing hash in "
592 "\"password-hash <hash>\" line.\n",
595 Debug( LDAP_DEBUG_ANY,
596 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
602 if ( default_passwd_hash != NULL ) {
604 LDAP_LOG( CONFIG, CRIT,
605 "%s: line %d: already set default password_hash!\n",
608 Debug( LDAP_DEBUG_ANY,
609 "%s: line %d: already set default password_hash!\n",
617 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
619 LDAP_LOG( CONFIG, CRIT,
620 "%s: line %d: password scheme \"%s\" not available\n",
621 fname, lineno, cargv[1] );
623 Debug( LDAP_DEBUG_ANY,
624 "%s: line %d: password scheme \"%s\" not available\n",
625 fname, lineno, cargv[1] );
630 default_passwd_hash = ch_strdup( cargv[1] );
632 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
636 LDAP_LOG( CONFIG, CRIT,
637 "%s: line %d: missing format in "
638 "\"password-crypt-salt-format <format>\" line\n",
641 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
642 "\"password-crypt-salt-format <format>\" line\n",
649 lutil_salt_format( cargv[1] );
651 /* SASL config options */
652 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
653 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
656 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
660 LDAP_LOG( CONFIG, CRIT,
661 "%s: line %d: missing dn in "
662 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
664 Debug( LDAP_DEBUG_ANY,
665 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
670 ber_str2bv( cargv[1], 0, 0, &dn );
672 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
673 &be->be_schemandn, NULL );
675 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
676 &global_schemandn, NULL );
678 if ( rc != LDAP_SUCCESS ) {
680 LDAP_LOG( CONFIG, CRIT,
681 "%s: line %d: schemadn DN is invalid.\n",
684 Debug( LDAP_DEBUG_ANY,
685 "%s: line %d: schemadn DN is invalid\n",
691 /* set UCDATA path */
692 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
696 LDAP_LOG( CONFIG, CRIT,
697 "%s: line %d: missing path in "
698 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
700 Debug( LDAP_DEBUG_ANY,
701 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
708 err = load_ucdata( cargv[1] );
712 LDAP_LOG( CONFIG, CRIT,
713 "%s: line %d: ucdata already loaded, ucdata-path "
714 "must be set earlier in the file and/or be "
715 "specified only once!\n", fname, lineno, 0 );
717 Debug( LDAP_DEBUG_ANY,
718 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
727 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
729 struct slap_limits_set *lim;
733 LDAP_LOG( CONFIG, CRIT,
734 "%s: line %d: missing limit in \"sizelimit <limit>\" "
735 "line.\n", fname, lineno, 0 );
737 Debug( LDAP_DEBUG_ANY,
738 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
748 lim = &be->be_def_limit;
751 for ( i = 1; i < cargc; i++ ) {
752 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
753 rc = parse_limit( cargv[i], lim );
756 LDAP_LOG( CONFIG, CRIT,
757 "%s: line %d: unable "
758 "to parse value \"%s\" in \"sizelimit "
759 "<limit>\" line.\n", fname, lineno, cargv[i] );
761 Debug( LDAP_DEBUG_ANY,
762 "%s: line %d: unable "
763 "to parse value \"%s\" "
766 fname, lineno, cargv[i] );
772 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
773 lim->lms_s_soft = -1;
777 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
778 if ( next == cargv[i] ) {
780 LDAP_LOG( CONFIG, CRIT,
781 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
782 "line.\n", fname, lineno, cargv[i] );
784 Debug( LDAP_DEBUG_ANY,
785 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
786 fname, lineno, cargv[i] );
790 } else if ( next[0] != '\0' ) {
792 LDAP_LOG( CONFIG, CRIT,
793 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
794 "line ignored.\n", fname, lineno, next );
796 Debug( LDAP_DEBUG_ANY,
797 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
798 fname, lineno, next );
807 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
809 struct slap_limits_set *lim;
813 LDAP_LOG( CONFIG, CRIT,
814 "%s: line %d missing limit in \"timelimit <limit>\" "
815 "line.\n", fname, lineno, 0 );
817 Debug( LDAP_DEBUG_ANY,
818 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
828 lim = &be->be_def_limit;
831 for ( i = 1; i < cargc; i++ ) {
832 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
833 rc = parse_limit( cargv[i], lim );
836 LDAP_LOG( CONFIG, CRIT,
837 "%s: line %d: unable to parse value \"%s\" "
838 "in \"timelimit <limit>\" line.\n",
839 fname, lineno, cargv[i] );
841 Debug( LDAP_DEBUG_ANY,
842 "%s: line %d: unable "
843 "to parse value \"%s\" "
846 fname, lineno, cargv[i] );
852 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
853 lim->lms_t_soft = -1;
857 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
858 if ( next == cargv[i] ) {
860 LDAP_LOG( CONFIG, CRIT,
861 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
862 "line.\n", fname, lineno, cargv[i] );
864 Debug( LDAP_DEBUG_ANY,
865 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
866 fname, lineno, cargv[i] );
870 } else if ( next[0] != '\0' ) {
872 LDAP_LOG( CONFIG, CRIT,
873 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
874 "line ignored.\n", fname, lineno, next );
876 Debug( LDAP_DEBUG_ANY,
877 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
878 fname, lineno, next );
886 /* set regex-based limits */
887 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
890 LDAP_LOG( CONFIG, WARNING,
891 "%s: line %d \"limits\" allowed only in database "
892 "environment.\n", fname, lineno, 0 );
894 Debug( LDAP_DEBUG_ANY,
895 "%s: line %d \"limits\" allowed only in database environment.\n%s",
901 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
905 /* mark this as a subordinate database */
906 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
909 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
910 "subordinate keyword must appear inside a database "
911 "definition.\n", fname, lineno, 0 );
913 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
914 "must appear inside a database definition.\n",
920 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
924 /* set database suffix */
925 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
927 struct berval dn, pdn, ndn;
931 LDAP_LOG( CONFIG, CRIT,
932 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
935 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
936 "missing dn in \"suffix <dn>\" line\n",
942 } else if ( cargc > 2 ) {
944 LDAP_LOG( CONFIG, INFO,
945 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
946 " line (ignored).\n", fname, lineno, cargv[1] );
948 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
949 "after <dn> in \"suffix %s\" line (ignored)\n",
950 fname, lineno, cargv[1] );
956 LDAP_LOG( CONFIG, INFO,
957 "%s: line %d: suffix line must appear inside a database "
958 "definition.\n", fname, lineno, 0 );
960 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
961 "must appear inside a database definition\n",
966 #if defined(SLAPD_MONITOR_DN)
967 /* "cn=Monitor" is reserved for monitoring slap */
968 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
970 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
971 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
974 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
975 SLAPD_MONITOR_DN "\" is reserved for monitoring slapd\n",
979 #endif /* SLAPD_MONITOR_DN */
982 if ( load_ucdata( NULL ) < 0 ) return 1;
984 dn.bv_val = cargv[1];
985 dn.bv_len = strlen( cargv[1] );
987 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
988 if( rc != LDAP_SUCCESS ) {
990 LDAP_LOG( CONFIG, CRIT,
991 "%s: line %d: suffix DN is invalid.\n",
994 Debug( LDAP_DEBUG_ANY,
995 "%s: line %d: suffix DN is invalid\n",
1001 tmp_be = select_backend( &ndn, 0, 0 );
1002 if ( tmp_be == be ) {
1004 LDAP_LOG( CONFIG, INFO,
1005 "%s: line %d: suffix already served by this backend "
1006 "(ignored)\n", fname, lineno, 0 );
1008 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1009 "already served by this backend (ignored)\n",
1015 } else if ( tmp_be != NULL ) {
1017 LDAP_LOG( CONFIG, INFO,
1018 "%s: line %d: suffix already served by a preceding "
1019 "backend \"%s\"\n", fname, lineno,
1020 tmp_be->be_suffix[0].bv_val );
1022 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1023 "already served by a preceeding backend \"%s\"\n",
1024 fname, lineno, tmp_be->be_suffix[0].bv_val );
1030 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1032 LDAP_LOG( CONFIG, INFO,
1033 "%s: line %d: suffix DN empty and default search "
1034 "base provided \"%s\" (assuming okay).\n",
1035 fname, lineno, default_search_base.bv_val );
1037 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1038 "suffix DN empty and default "
1039 "search base provided \"%s\" (assuming okay)\n",
1040 fname, lineno, default_search_base.bv_val );
1044 ber_bvarray_add( &be->be_suffix, &pdn );
1045 ber_bvarray_add( &be->be_nsuffix, &ndn );
1047 /* set max deref depth */
1048 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1052 LDAP_LOG( CONFIG, CRIT,
1053 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1054 " line\n", fname, lineno, 0 );
1056 Debug( LDAP_DEBUG_ANY,
1057 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1065 LDAP_LOG( CONFIG, INFO,
1066 "%s: line %d: depth line must appear inside a database "
1067 "definition.\n", fname, lineno ,0 );
1069 Debug( LDAP_DEBUG_ANY,
1070 "%s: line %d: depth line must appear inside a database definition.\n",
1075 } else if ((i = atoi(cargv[1])) < 0) {
1077 LDAP_LOG( CONFIG, INFO,
1078 "%s: line %d: depth must be positive.\n",
1081 Debug( LDAP_DEBUG_ANY,
1082 "%s: line %d: depth must be positive.\n",
1089 be->be_max_deref_depth = i;
1093 /* set magic "root" dn for this database */
1094 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1097 LDAP_LOG( CONFIG, INFO,
1098 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1101 Debug( LDAP_DEBUG_ANY,
1102 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1111 LDAP_LOG( CONFIG, INFO,
1112 "%s: line %d: rootdn line must appear inside a database "
1113 "definition.\n", fname, lineno ,0 );
1115 Debug( LDAP_DEBUG_ANY,
1116 "%s: line %d: rootdn line must appear inside a database definition.\n",
1124 if ( load_ucdata( NULL ) < 0 ) return 1;
1126 dn.bv_val = cargv[1];
1127 dn.bv_len = strlen( cargv[1] );
1129 rc = dnPrettyNormal( NULL, &dn,
1131 &be->be_rootndn, NULL );
1133 if( rc != LDAP_SUCCESS ) {
1135 LDAP_LOG( CONFIG, CRIT,
1136 "%s: line %d: rootdn DN is invalid.\n",
1139 Debug( LDAP_DEBUG_ANY,
1140 "%s: line %d: rootdn DN is invalid\n",
1147 /* set super-secret magic database password */
1148 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1151 LDAP_LOG( CONFIG, CRIT,
1152 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1153 " line\n", fname, lineno ,0 );
1155 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1156 "missing passwd in \"rootpw <passwd>\" line\n",
1165 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1166 "rootpw line must appear inside a database "
1167 "definition.\n", fname, lineno ,0 );
1169 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1170 "rootpw line must appear inside a database "
1177 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1179 if( tmp_be != be ) {
1181 LDAP_LOG( CONFIG, INFO,
1183 "rootpw can only be set when rootdn is under suffix\n",
1184 fname, lineno, "" );
1186 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1187 "rootpw can only be set when rootdn is under suffix\n",
1193 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1194 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1197 /* make this database read-only */
1198 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1201 LDAP_LOG( CONFIG, CRIT,
1202 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1203 "line.\n", fname, lineno ,0 );
1205 Debug( LDAP_DEBUG_ANY,
1206 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1213 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1214 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1216 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1219 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1220 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1222 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1227 /* allow these features */
1228 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1229 strcasecmp( cargv[0], "allow" ) == 0 )
1235 LDAP_LOG( CONFIG, INFO,
1236 "%s: line %d: allow line must appear prior to "
1237 "database definitions.\n", fname, lineno ,0 );
1239 Debug( LDAP_DEBUG_ANY,
1240 "%s: line %d: allow line must appear prior to database definitions\n",
1248 LDAP_LOG( CONFIG, CRIT,
1249 "%s: line %d: missing feature(s) in \"allow <features>\""
1250 " line\n", fname, lineno ,0 );
1252 Debug( LDAP_DEBUG_ANY,
1253 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1262 for( i=1; i < cargc; i++ ) {
1263 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1264 allows |= SLAP_ALLOW_BIND_V2;
1266 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1267 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1269 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1270 allows |= SLAP_ALLOW_BIND_ANON_DN;
1272 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1273 allows |= SLAP_ALLOW_UPDATE_ANON;
1275 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1277 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1278 "unknown feature %s in \"allow <features>\" line.\n",
1279 fname, lineno, cargv[1] );
1281 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1282 "unknown feature %s in \"allow <features>\" line\n",
1283 fname, lineno, cargv[i] );
1290 global_allows = allows;
1292 /* disallow these features */
1293 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1294 strcasecmp( cargv[0], "disallow" ) == 0 )
1296 slap_mask_t disallows;
1300 LDAP_LOG( CONFIG, INFO,
1301 "%s: line %d: disallow line must appear prior to "
1302 "database definitions.\n", fname, lineno ,0 );
1304 Debug( LDAP_DEBUG_ANY,
1305 "%s: line %d: disallow line must appear prior to database definitions\n",
1313 LDAP_LOG( CONFIG, CRIT,
1314 "%s: line %d: missing feature(s) in \"disallow <features>\""
1315 " line.\n", fname, lineno ,0 );
1317 Debug( LDAP_DEBUG_ANY,
1318 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1327 for( i=1; i < cargc; i++ ) {
1328 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1329 disallows |= SLAP_DISALLOW_BIND_ANON;
1331 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1332 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1334 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1335 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1337 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1338 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1340 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1341 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1343 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1345 LDAP_LOG( CONFIG, CRIT,
1346 "%s: line %d: unknown feature %s in "
1347 "\"disallow <features>\" line.\n",
1348 fname, lineno, cargv[i] );
1350 Debug( LDAP_DEBUG_ANY,
1351 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1352 fname, lineno, cargv[i] );
1359 global_disallows = disallows;
1361 /* require these features */
1362 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1363 strcasecmp( cargv[0], "require" ) == 0 )
1365 slap_mask_t requires;
1369 LDAP_LOG( CONFIG, CRIT,
1370 "%s: line %d: missing feature(s) in "
1371 "\"require <features>\" line.\n", fname, lineno ,0 );
1373 Debug( LDAP_DEBUG_ANY,
1374 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1383 for( i=1; i < cargc; i++ ) {
1384 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1385 requires |= SLAP_REQUIRE_BIND;
1387 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1388 requires |= SLAP_REQUIRE_LDAP_V3;
1390 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1391 requires |= SLAP_REQUIRE_AUTHC;
1393 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1394 requires |= SLAP_REQUIRE_SASL;
1396 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1397 requires |= SLAP_REQUIRE_STRONG;
1399 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1401 LDAP_LOG( CONFIG, CRIT,
1402 "%s: line %d: unknown feature %s in "
1403 "\"require <features>\" line.\n",
1404 fname, lineno , cargv[i] );
1406 Debug( LDAP_DEBUG_ANY,
1407 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1408 fname, lineno, cargv[i] );
1416 global_requires = requires;
1418 be->be_requires = requires;
1421 /* required security factors */
1422 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1423 slap_ssf_set_t *set;
1427 LDAP_LOG( CONFIG, CRIT,
1428 "%s: line %d: missing factor(s) in \"security <factors>\""
1429 " line.\n", fname, lineno ,0 );
1431 Debug( LDAP_DEBUG_ANY,
1432 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1440 set = &global_ssf_set;
1442 set = &be->be_ssf_set;
1445 for( i=1; i < cargc; i++ ) {
1446 if( strncasecmp( cargv[i], "ssf=",
1447 sizeof("ssf") ) == 0 )
1450 atoi( &cargv[i][sizeof("ssf")] );
1452 } else if( strncasecmp( cargv[i], "transport=",
1453 sizeof("transport") ) == 0 )
1455 set->sss_transport =
1456 atoi( &cargv[i][sizeof("transport")] );
1458 } else if( strncasecmp( cargv[i], "tls=",
1459 sizeof("tls") ) == 0 )
1462 atoi( &cargv[i][sizeof("tls")] );
1464 } else if( strncasecmp( cargv[i], "sasl=",
1465 sizeof("sasl") ) == 0 )
1468 atoi( &cargv[i][sizeof("sasl")] );
1470 } else if( strncasecmp( cargv[i], "update_ssf=",
1471 sizeof("update_ssf") ) == 0 )
1473 set->sss_update_ssf =
1474 atoi( &cargv[i][sizeof("update_ssf")] );
1476 } else if( strncasecmp( cargv[i], "update_transport=",
1477 sizeof("update_transport") ) == 0 )
1479 set->sss_update_transport =
1480 atoi( &cargv[i][sizeof("update_transport")] );
1482 } else if( strncasecmp( cargv[i], "update_tls=",
1483 sizeof("update_tls") ) == 0 )
1485 set->sss_update_tls =
1486 atoi( &cargv[i][sizeof("update_tls")] );
1488 } else if( strncasecmp( cargv[i], "update_sasl=",
1489 sizeof("update_sasl") ) == 0 )
1491 set->sss_update_sasl =
1492 atoi( &cargv[i][sizeof("update_sasl")] );
1494 } else if( strncasecmp( cargv[i], "simple_bind=",
1495 sizeof("simple_bind") ) == 0 )
1497 set->sss_simple_bind =
1498 atoi( &cargv[i][sizeof("simple_bind")] );
1502 LDAP_LOG( CONFIG, CRIT,
1503 "%s: line %d: unknown factor %S in "
1504 "\"security <factors>\" line.\n",
1505 fname, lineno, cargv[1] );
1507 Debug( LDAP_DEBUG_ANY,
1508 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1509 fname, lineno, cargv[i] );
1515 /* where to send clients when we don't hold it */
1516 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1519 LDAP_LOG( CONFIG, CRIT,
1520 "%s: line %d: missing URL in \"referral <URL>\""
1521 " line.\n", fname, lineno , 0 );
1523 Debug( LDAP_DEBUG_ANY,
1524 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1531 if( validate_global_referral( cargv[1] ) ) {
1533 LDAP_LOG( CONFIG, CRIT,
1534 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1535 fname, lineno, cargv[1] );
1537 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1538 "invalid URL (%s) in \"referral\" line.\n",
1539 fname, lineno, cargv[1] );
1544 vals[0].bv_val = cargv[1];
1545 vals[0].bv_len = strlen( vals[0].bv_val );
1546 if( value_add( &default_referral, vals ) )
1550 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1554 LDAP_LOG( CONFIG, CRIT,
1555 "%s: line %d: Error in logfile directive, "
1556 "\"logfile <filename>\"\n", fname, lineno , 0 );
1558 Debug( LDAP_DEBUG_ANY,
1559 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1565 logfile = fopen( cargv[1], "w" );
1566 if ( logfile != NULL ) lutil_debug_file( logfile );
1569 /* start of a new database definition */
1570 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1574 LDAP_LOG( CONFIG, CRIT,
1575 "%s: line %d: Error in debug directive, "
1576 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1578 Debug( LDAP_DEBUG_ANY,
1579 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1585 level = atoi( cargv[2] );
1586 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1587 lutil_set_debug_level( cargv[1], level );
1588 /* specify an Object Identifier macro */
1589 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1590 rc = parse_oidm( fname, lineno, cargc, cargv );
1593 /* specify an objectclass */
1594 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1597 LDAP_LOG( CONFIG, INFO,
1598 "%s: line %d: illegal objectclass format.\n",
1599 fname, lineno , 0 );
1601 Debug( LDAP_DEBUG_ANY,
1602 "%s: line %d: illegal objectclass format.\n",
1607 } else if ( *cargv[1] == '(' /*')'*/) {
1609 p = strchr(saveline,'(' /*')'*/);
1610 rc = parse_oc( fname, lineno, p, cargv );
1615 LDAP_LOG( CONFIG, INFO,
1616 "%s: line %d: old objectclass format not supported\n",
1617 fname, lineno , 0 );
1619 Debug( LDAP_DEBUG_ANY,
1620 "%s: line %d: old objectclass format not supported.\n",
1625 #ifdef SLAP_EXTENDED_SCHEMA
1626 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1628 p = strchr(saveline,'(' /*')'*/);
1629 rc = parse_cr( fname, lineno, p, cargv );
1633 /* specify an attribute type */
1634 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1635 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1639 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1640 "illegal attribute type format.\n",
1641 fname, lineno , 0 );
1643 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1644 "illegal attribute type format.\n",
1649 } else if ( *cargv[1] == '(' /*')'*/) {
1651 p = strchr(saveline,'(' /*')'*/);
1652 rc = parse_at( fname, lineno, p, cargv );
1657 LDAP_LOG( CONFIG, INFO,
1658 "%s: line %d: old attribute type format not supported.\n",
1659 fname, lineno , 0 );
1661 Debug( LDAP_DEBUG_ANY,
1662 "%s: line %d: old attribute type format not supported.\n",
1668 /* define attribute option(s) */
1669 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1670 ad_define_option( NULL, NULL, 0 );
1671 for ( i = 1; i < cargc; i++ )
1672 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1675 /* turn on/off schema checking */
1676 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1679 LDAP_LOG( CONFIG, CRIT,
1680 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1681 " line.\n", fname, lineno , 0 );
1683 Debug( LDAP_DEBUG_ANY,
1684 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1690 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1692 LDAP_LOG( CONFIG, CRIT,
1693 "%s: line %d: schema checking disabled! your mileage may "
1694 "vary!\n", fname, lineno , 0 );
1696 Debug( LDAP_DEBUG_ANY,
1697 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1700 global_schemacheck = 0;
1702 global_schemacheck = 1;
1705 /* specify access control info */
1706 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1707 parse_acl( be, fname, lineno, cargc, cargv );
1709 /* debug level to log things to syslog */
1710 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1713 LDAP_LOG( CONFIG, CRIT,
1714 "%s: line %d: missing level in \"loglevel <level>\""
1715 " line.\n", fname, lineno , 0 );
1717 Debug( LDAP_DEBUG_ANY,
1718 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1727 for( i=1; i < cargc; i++ ) {
1728 ldap_syslog += atoi( cargv[1] );
1731 #ifdef LDAP_SYNCREPL
1732 /* list of sync replication information in this backend (slave o
1734 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1736 add_syncrepl( be, cargv, cargc );
1739 /* list of replicas of the data in this backend (master only) */
1740 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1743 LDAP_LOG( CONFIG, CRIT,
1744 "%s: line %d: missing host in \"replica "
1745 " <host[:port]\" line\n", fname, lineno , 0 );
1747 Debug( LDAP_DEBUG_ANY,
1748 "%s: line %d: missing host in \"replica <host[:port]>\" line\n",
1756 LDAP_LOG( CONFIG, INFO,
1757 "%s: line %d: replica line must appear inside "
1758 "a database definition.\n", fname, lineno, 0);
1760 Debug( LDAP_DEBUG_ANY,
1761 "%s: line %d: replica line must appear inside a database definition\n",
1769 for ( i = 1; i < cargc; i++ ) {
1770 if ( strncasecmp( cargv[i], "host=", 5 )
1772 nr = add_replica_info( be,
1779 LDAP_LOG( CONFIG, INFO,
1780 "%s: line %d: missing host in \"replica\" line\n",
1781 fname, lineno , 0 );
1783 Debug( LDAP_DEBUG_ANY,
1784 "%s: line %d: missing host in \"replica\" line\n",
1789 } else if ( nr == -1 ) {
1791 LDAP_LOG( CONFIG, INFO,
1792 "%s: line %d: unable to add"
1793 " replica \"%s\"\n",
1797 Debug( LDAP_DEBUG_ANY,
1798 "%s: line %d: unable to add replica \"%s\"\n",
1799 fname, lineno, cargv[i] + 5 );
1803 for ( i = 1; i < cargc; i++ ) {
1804 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1806 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1809 LDAP_LOG( CONFIG, INFO,
1810 "%s: line %d: suffix \"%s\" in \"replica\""
1811 " line is not valid for backend(ignored)\n",
1812 fname, lineno, cargv[i] + 7 );
1814 Debug( LDAP_DEBUG_ANY,
1815 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1816 fname, lineno, cargv[i] + 7 );
1822 LDAP_LOG( CONFIG, INFO,
1823 "%s: line %d: unable to normalize suffix"
1824 " in \"replica\" line (ignored)\n",
1825 fname, lineno , 0 );
1827 Debug( LDAP_DEBUG_ANY,
1828 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1834 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1836 char *arg = cargv[i] + 4;
1838 if ( arg[0] == '!' ) {
1843 if ( arg[0] != '=' ) {
1847 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1849 LDAP_LOG( CONFIG, INFO,
1850 "%s: line %d: attribute \"%s\" in "
1851 "\"replica\" line is unknown\n",
1852 fname, lineno, arg + 1 );
1854 Debug( LDAP_DEBUG_ANY,
1855 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1856 fname, lineno, arg + 1 );
1865 /* dn of master entity allowed to write to replica */
1866 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1869 LDAP_LOG( CONFIG, CRIT,
1870 "%s: line %d: missing dn in \"updatedn <dn>\""
1871 " line.\n", fname, lineno , 0 );
1873 Debug( LDAP_DEBUG_ANY,
1874 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1882 LDAP_LOG( CONFIG, INFO,
1883 "%s: line %d: updatedn line must appear inside "
1884 "a database definition\n",
1885 fname, lineno , 0 );
1887 Debug( LDAP_DEBUG_ANY,
1888 "%s: line %d: updatedn line must appear inside a database definition\n",
1896 if ( load_ucdata( NULL ) < 0 ) return 1;
1898 dn.bv_val = cargv[1];
1899 dn.bv_len = strlen( cargv[1] );
1901 rc = dnNormalize2( NULL, &dn, &be->be_update_ndn, NULL );
1902 if( rc != LDAP_SUCCESS ) {
1904 LDAP_LOG( CONFIG, CRIT,
1905 "%s: line %d: updatedn DN is invalid.\n",
1906 fname, lineno , 0 );
1908 Debug( LDAP_DEBUG_ANY,
1909 "%s: line %d: updatedn DN is invalid\n",
1916 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1919 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1920 "missing url in \"updateref <ldapurl>\" line.\n",
1921 fname, lineno , 0 );
1923 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1924 "missing url in \"updateref <ldapurl>\" line\n",
1932 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
1933 " line must appear inside a database definition\n",
1934 fname, lineno , 0 );
1936 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
1937 " line must appear inside a database definition\n",
1942 } else if ( !be->be_update_ndn.bv_len ) {
1944 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1945 "updateref line must come after updatedn.\n",
1946 fname, lineno , 0 );
1948 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1949 "updateref line must after updatedn.\n",
1955 if( validate_global_referral( cargv[1] ) ) {
1957 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1958 "invalid URL (%s) in \"updateref\" line.\n",
1959 fname, lineno, cargv[1] );
1961 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1962 "invalid URL (%s) in \"updateref\" line.\n",
1963 fname, lineno, cargv[1] );
1968 vals[0].bv_val = cargv[1];
1969 vals[0].bv_len = strlen( vals[0].bv_val );
1970 if( value_add( &be->be_update_refs, vals ) )
1973 /* replication log file to which changes are appended */
1974 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
1977 LDAP_LOG( CONFIG, CRIT,
1978 "%s: line %d: missing filename in \"replogfile <filename>\""
1979 " line.\n", fname, lineno , 0 );
1981 Debug( LDAP_DEBUG_ANY,
1982 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
1989 be->be_replogfile = ch_strdup( cargv[1] );
1991 replogfile = ch_strdup( cargv[1] );
1994 /* file from which to read additional rootdse attrs */
1995 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
1998 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1999 "missing filename in \"rootDSE <filename>\" line.\n",
2000 fname, lineno , 0 );
2002 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2003 "missing filename in \"rootDSE <filename>\" line.\n",
2009 if( read_root_dse_file( cargv[1] ) ) {
2011 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2012 "could not read \"rootDSE <filename>\" line.\n",
2013 fname, lineno , 0 );
2015 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2016 "could not read \"rootDSE <filename>\" line\n",
2022 /* maintain lastmodified{by,time} attributes */
2023 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2026 LDAP_LOG( CONFIG, CRIT,
2027 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2028 " line.\n", fname, lineno , 0 );
2030 Debug( LDAP_DEBUG_ANY,
2031 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2037 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2039 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2045 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2052 /* turn on/off gentle SIGHUP handling */
2053 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2055 Debug( LDAP_DEBUG_ANY,
2056 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2060 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2061 global_gentlehup = 0;
2063 global_gentlehup = 1;
2067 /* set idle timeout value */
2068 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2072 LDAP_LOG( CONFIG, CRIT,
2073 "%s: line %d: missing timeout value in "
2074 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2076 Debug( LDAP_DEBUG_ANY,
2077 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2084 i = atoi( cargv[1] );
2088 LDAP_LOG( CONFIG, CRIT,
2089 "%s: line %d: timeout value (%d) invalid "
2090 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2092 Debug( LDAP_DEBUG_ANY,
2093 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2100 global_idletimeout = i;
2102 /* include another config file */
2103 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2106 LDAP_LOG( CONFIG, CRIT,
2107 "%s: line %d: missing filename in \"include "
2108 "<filename>\" line.\n", fname, lineno , 0 );
2110 Debug( LDAP_DEBUG_ANY,
2111 "%s: line %d: missing filename in \"include <filename>\" line\n",
2117 savefname = ch_strdup( cargv[1] );
2118 savelineno = lineno;
2120 if ( read_config( savefname, depth+1 ) != 0 ) {
2125 lineno = savelineno - 1;
2127 /* location of kerberos srvtab file */
2128 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2131 LDAP_LOG( CONFIG, CRIT,
2132 "%s: line %d: missing filename in \"srvtab "
2133 "<filename>\" line.\n", fname, lineno , 0 );
2135 Debug( LDAP_DEBUG_ANY,
2136 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2142 ldap_srvtab = ch_strdup( cargv[1] );
2144 #ifdef SLAPD_MODULES
2145 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2148 LDAP_LOG( CONFIG, INFO,
2149 "%s: line %d: missing filename in \"moduleload "
2150 "<filename>\" line.\n", fname, lineno , 0 );
2152 Debug( LDAP_DEBUG_ANY,
2153 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2157 exit( EXIT_FAILURE );
2159 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2161 LDAP_LOG( CONFIG, CRIT,
2162 "%s: line %d: failed to load or initialize module %s\n",
2163 fname, lineno, cargv[1] );
2165 Debug( LDAP_DEBUG_ANY,
2166 "%s: line %d: failed to load or initialize module %s\n",
2167 fname, lineno, cargv[1]);
2170 exit( EXIT_FAILURE );
2172 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2175 LDAP_LOG( CONFIG, INFO,
2176 "%s: line %d: missing path in \"modulepath <path>\""
2177 " line\n", fname, lineno , 0 );
2179 Debug( LDAP_DEBUG_ANY,
2180 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2184 exit( EXIT_FAILURE );
2186 if (module_path( cargv[1] )) {
2188 LDAP_LOG( CONFIG, CRIT,
2189 "%s: line %d: failed to set module search path to %s.\n",
2190 fname, lineno, cargv[1] );
2192 Debug( LDAP_DEBUG_ANY,
2193 "%s: line %d: failed to set module search path to %s\n",
2194 fname, lineno, cargv[1]);
2197 exit( EXIT_FAILURE );
2200 #endif /*SLAPD_MODULES*/
2203 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2204 rc = ldap_pvt_tls_set_option( NULL,
2205 LDAP_OPT_X_TLS_RANDOM_FILE,
2210 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2211 rc = ldap_pvt_tls_set_option( NULL,
2212 LDAP_OPT_X_TLS_CIPHER_SUITE,
2217 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2218 rc = ldap_pvt_tls_set_option( NULL,
2219 LDAP_OPT_X_TLS_CERTFILE,
2224 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2225 rc = ldap_pvt_tls_set_option( NULL,
2226 LDAP_OPT_X_TLS_KEYFILE,
2231 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2232 rc = ldap_pvt_tls_set_option( NULL,
2233 LDAP_OPT_X_TLS_CACERTDIR,
2238 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2239 rc = ldap_pvt_tls_set_option( NULL,
2240 LDAP_OPT_X_TLS_CACERTFILE,
2244 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2245 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2247 rc = ldap_pvt_tls_set_option( NULL,
2248 LDAP_OPT_X_TLS_REQUIRE_CERT,
2251 rc = ldap_int_tls_config( NULL,
2252 LDAP_OPT_X_TLS_REQUIRE_CERT,
2261 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2262 #ifdef SLAPD_RLOOKUPS
2265 LDAP_LOG( CONFIG, INFO,
2266 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2267 fname, lineno , 0 );
2269 Debug( LDAP_DEBUG_ANY,
2270 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2276 if ( !strcasecmp( cargv[1], "on" ) ) {
2277 use_reverse_lookup = 1;
2278 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2279 use_reverse_lookup = 0;
2282 LDAP_LOG( CONFIG, INFO,
2283 "%s: line %d: reverse-lookup: "
2284 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2286 Debug( LDAP_DEBUG_ANY,
2287 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2293 #else /* !SLAPD_RLOOKUPS */
2295 LDAP_LOG( CONFIG, INFO,
2296 "%s: line %d: reverse lookups "
2297 "are not configured (ignored).\n", fname, lineno , 0 );
2299 Debug( LDAP_DEBUG_ANY,
2300 "%s: line %d: reverse lookups are not configured (ignored).\n",
2303 #endif /* !SLAPD_RLOOKUPS */
2305 /* Netscape plugins */
2306 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2307 #if defined( LDAP_SLAPI )
2309 #ifdef notdef /* allow global plugins, too */
2311 * a "plugin" line must be inside a database
2312 * definition, since we implement pre-,post-
2313 * and extended operation plugins
2317 LDAP_LOG( CONFIG, INFO,
2318 "%s: line %d: plugin line must appear "
2319 "inside a database definition.\n",
2322 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2323 "line must appear inside a database "
2324 "definition\n", fname, lineno, 0 );
2330 if ( netscape_plugin( be, fname, lineno, cargc, cargv )
2335 #else /* !defined( LDAP_SLAPI ) */
2337 LDAP_LOG( CONFIG, INFO,
2338 "%s: line %d: SLAPI not supported.\n",
2341 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2342 "not supported.\n", fname, lineno, 0 );
2346 #endif /* !defined( LDAP_SLAPI ) */
2348 /* Netscape plugins */
2349 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2350 #if defined( LDAP_SLAPI )
2353 LDAP_LOG( CONFIG, INFO,
2354 "%s: line %d: missing file name "
2355 "in pluginlog <filename> line.\n",
2358 Debug( LDAP_DEBUG_ANY,
2359 "%s: line %d: missing file name "
2360 "in pluginlog <filename> line.\n",
2366 if ( slapi_log_file != NULL ) {
2367 ch_free( slapi_log_file );
2370 slapi_log_file = ch_strdup( cargv[1] );
2371 #endif /* !defined( LDAP_SLAPI ) */
2373 /* pass anything else to the current backend info/db config routine */
2376 if ( bi->bi_config == 0 ) {
2378 LDAP_LOG( CONFIG, INFO,
2379 "%s: line %d: unknown directive \"%s\" inside "
2380 "backend info definition (ignored).\n",
2381 fname, lineno, cargv[0] );
2383 Debug( LDAP_DEBUG_ANY,
2384 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2385 fname, lineno, cargv[0] );
2389 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2395 } else if ( be != NULL ) {
2396 if ( be->be_config == 0 ) {
2398 LDAP_LOG( CONFIG, INFO,
2399 "%s: line %d: uknown directive \"%s\" inside "
2400 "backend database definition (ignored).\n",
2401 fname, lineno, cargv[0] );
2403 Debug( LDAP_DEBUG_ANY,
2404 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2405 fname, lineno, cargv[0] );
2409 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2417 LDAP_LOG( CONFIG, INFO,
2418 "%s: line %d: unknown directive \"%s\" outside backend "
2419 "info and database definitions (ignored).\n",
2420 fname, lineno, cargv[0] );
2422 Debug( LDAP_DEBUG_ANY,
2423 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2424 fname, lineno, cargv[0] );
2433 if ( depth == 0 ) ch_free( cargv );
2435 if ( !global_schemadn.bv_val ) {
2436 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2438 dnNormalize2( NULL, &global_schemadn, &global_schemandn, NULL );
2441 if ( load_ucdata( NULL ) < 0 ) return 1;
2453 char logbuf[sizeof("pseudorootpw ***")];
2456 token = strtok_quote( line, " \t" );
2460 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2461 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2462 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2463 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2464 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2466 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2469 if ( strtok_quote_ptr ) {
2470 *strtok_quote_ptr = ' ';
2474 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2476 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2479 if ( strtok_quote_ptr ) {
2480 *strtok_quote_ptr = '\0';
2483 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2484 if ( cargc == cargv_size - 1 ) {
2486 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2488 if ( tmp == NULL ) {
2490 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2492 Debug( LDAP_DEBUG_ANY,
2493 "line %d: out of memory\n",
2499 cargv_size += ARGS_STEP;
2501 cargv[cargc++] = token;
2503 cargv[cargc] = NULL;
2508 strtok_quote( char *line, char *sep )
2514 strtok_quote_ptr = NULL;
2515 if ( line != NULL ) {
2518 while ( *next && strchr( sep, *next ) ) {
2522 if ( *next == '\0' ) {
2528 for ( inquote = 0; *next; ) {
2536 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2542 next + 1, strlen( next + 1 ) + 1 );
2543 next++; /* dont parse the escaped character */
2548 if ( strchr( sep, *next ) != NULL ) {
2549 strtok_quote_ptr = next;
2562 static char buf[BUFSIZ];
2564 static size_t lmax, lcur;
2566 #define CATLINE( buf ) \
2568 size_t len = strlen( buf ); \
2569 while ( lcur + len + 1 > lmax ) { \
2571 line = (char *) ch_realloc( line, lmax ); \
2573 strcpy( line + lcur, buf ); \
2578 fp_getline( FILE *fp, int *lineno )
2586 /* hack attack - keeps us from having to keep a stack of bufs... */
2587 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2592 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2593 /* trim off \r\n or \n */
2594 if ( (p = strchr( buf, '\n' )) != NULL ) {
2595 if( p > buf && p[-1] == '\r' ) --p;
2599 /* trim off trailing \ and append the next line */
2600 if ( line[ 0 ] != '\0'
2601 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2602 && p[ -1 ] != '\\' ) {
2607 if ( ! isspace( (unsigned char) buf[0] ) ) {
2611 /* change leading whitespace to a space */
2620 return( line[0] ? line : NULL );
2624 fp_getline_init( int *lineno )
2630 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2632 load_ucdata( char *path )
2634 static int loaded = 0;
2640 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2643 LDAP_LOG( CONFIG, CRIT,
2644 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2646 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2659 ucdata_unload( UCDATA_ALL );
2660 free( global_schemandn.bv_val );
2661 free( global_schemadn.bv_val );
2663 if ( slapd_args_file )
2664 free ( slapd_args_file );
2665 if ( slapd_pid_file )
2666 free ( slapd_pid_file );
2667 if ( default_passwd_hash )
2668 free( default_passwd_hash );
2669 acl_destroy( global_acl, NULL );
2672 #ifdef LDAP_SYNCREPL
2682 si = be->syncinfo = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2686 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2688 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2690 exit( EXIT_FAILURE );
2693 if ( parse_syncrepl_line( cargv, cargc, si ) < 0 ) {
2694 /* Something bad happened - back out */
2696 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2698 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2701 be->syncinfo = NULL;
2704 LDAP_LOG ( CONFIG, RESULTS,
2705 "add_syncrepl: Config: ** successfully added syncrepl \"%s%d\"\n",
2706 si->mastername == NULL ? "(null)" : si->mastername,
2707 si->masterport, 0 );
2709 Debug( LDAP_DEBUG_CONFIG,
2710 "Config: ** successfully added syncrepl \"%s:%d\"\n",
2711 si->mastername == NULL ? "(null)" : si->mastername,
2712 si->masterport, 0 );
2719 #define GOT_ID 0x0001
2720 #define GOT_HOST 0x0002
2721 #define GOT_DN 0x0004
2722 #define GOT_METHOD 0x0008
2723 #define GOT_MECH 0x0010
2724 #define GOT_FILTER 0x0020
2725 #define GOT_SEARCHBASE 0x0040
2726 #define GOT_SCOPE 0x0080
2727 #define GOT_ATTRS 0x0100
2728 #define GOT_TYPE 0x0200
2729 #define GOT_INTERVAL 0x0400
2730 #define GOT_LASTMOD 0x0800
2732 #define GOT_ALL 0x0FFF
2735 parse_syncrepl_line(
2746 for ( i = 1; i < cargc; i++ ) {
2747 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
2748 /* '\0' string terminator accounts for '=' */
2749 val = cargv[ i ] + sizeof( IDSTR );
2750 si->id = atoi( val );
2752 } else if ( !strncasecmp( cargv[ i ], MASTERSTR,
2753 sizeof( MASTERSTR ) - 1 )) {
2754 val = cargv[ i ] + sizeof( MASTERSTR );
2755 si->masteruri = strdup( val );
2756 if (( hp = strchr( val, ':' )) != NULL ) {
2757 if ( *( hp + 1 ) == '/' ) {
2758 if ( *( hp + 2 ) == '/' ) {
2761 if (( hp = strchr( hp+1, ':' )) != NULL ) {
2764 si->masterport = atoi( hp );
2769 si->masterport = atoi( hp );
2772 if ( si->masterport <= 0 ) {
2775 si->mastername = strdup( val );
2777 } else if ( !strncasecmp( cargv[ i ], TLSSTR, sizeof( TLSSTR ) - 1 ) ) {
2778 val = cargv[ i ] + sizeof( TLSSTR );
2779 if( !strcasecmp( val, TLSCRITICALSTR ) ) {
2780 si->tls = TLS_CRITICAL;
2784 } else if ( !strncasecmp( cargv[ i ],
2785 "binddn", sizeof( BINDDNSTR ) - 1 ) ) {
2786 val = cargv[ i ] + sizeof( BINDDNSTR );
2787 si->binddn = strdup( val );
2789 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
2790 sizeof( BINDMETHSTR ) - 1 ) ) {
2791 val = cargv[ i ] + sizeof( BINDMETHSTR );
2792 if ( !strcasecmp( val, SIMPLESTR )) {
2793 si->bindmethod = LDAP_AUTH_SIMPLE;
2795 } else if ( !strcasecmp( val, SASLSTR )) {
2796 si->bindmethod = LDAP_AUTH_SASL;
2799 si->bindmethod = -1;
2801 } else if ( !strncasecmp( cargv[ i ], LASTMODSTR,
2802 sizeof( LASTMODSTR ) - 1 ) ) {
2803 val = cargv[ i ] + sizeof( LASTMODSTR );
2804 if ( !strcasecmp( val, LMREQSTR )) {
2805 si->lastmod = LASTMOD_REQ;
2806 gots |= GOT_LASTMOD;
2807 } else if ( !strcasecmp( val, LMGENSTR )) {
2808 si->lastmod = LASTMOD_GEN;
2809 gots |= GOT_LASTMOD;
2810 } else if ( !strcasecmp( val, LMNOSTR )) {
2811 si->lastmod = LASTMOD_NO;
2812 gots |= GOT_LASTMOD;
2816 } else if ( !strncasecmp( cargv[ i ],
2817 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
2818 val = cargv[ i ] + sizeof( SASLMECHSTR );
2820 si->saslmech = strdup( val );
2821 } else if ( !strncasecmp( cargv[ i ],
2822 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
2823 val = cargv[ i ] + sizeof( CREDSTR );
2824 si->passwd = strdup( val );
2825 } else if ( !strncasecmp( cargv[ i ],
2826 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
2827 val = cargv[ i ] + sizeof( SECPROPSSTR );
2828 si->secprops = strdup( val );
2829 } else if ( !strncasecmp( cargv[ i ],
2830 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
2831 val = cargv[ i ] + sizeof( REALMSTR );
2832 si->realm = strdup( val );
2833 } else if ( !strncasecmp( cargv[ i ],
2834 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
2835 val = cargv[ i ] + sizeof( AUTHCSTR );
2836 si->authcId = strdup( val );
2837 } else if ( !strncasecmp( cargv[ i ],
2838 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
2839 /* Old authcID is provided for some backwards compatibility */
2840 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
2841 si->authcId = strdup( val );
2842 } else if ( !strncasecmp( cargv[ i ],
2843 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
2844 val = cargv[ i ] + sizeof( AUTHZSTR );
2845 si->authzId = strdup( val );
2846 } else if ( !strncasecmp( cargv[ i ],
2847 SRVTABSTR, sizeof( SRVTABSTR ) - 1 ) ) {
2848 val = cargv[ i ] + sizeof( SRVTABSTR );
2849 if ( si->srvtab != NULL ) {
2852 si->srvtab = strdup( val );
2853 } else if ( !strncasecmp( cargv[ i ],
2854 FILTERSTR, sizeof( FILTERSTR ) - 1 ) ) {
2855 val = cargv[ i ] + sizeof( FILTERSTR );
2857 si->filterstr = strdup( val );
2858 } else if ( !strncasecmp( cargv[ i ],
2859 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) ) {
2860 val = cargv[ i ] + sizeof( SEARCHBASESTR );
2861 gots |= GOT_SEARCHBASE;
2862 si->base = strdup( val );
2863 } else if ( !strncasecmp( cargv[ i ],
2864 SCOPESTR, sizeof( SCOPESTR ) - 1 ) ) {
2865 val = cargv[ i ] + sizeof( SCOPESTR );
2867 if ( !strncasecmp( val, "base", sizeof( "base" ) - 1 )) {
2868 si->scope = LDAP_SCOPE_BASE;
2869 } else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
2870 si->scope = LDAP_SCOPE_ONELEVEL;
2871 } else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
2872 si->scope = LDAP_SCOPE_SUBTREE;
2875 "Error: parse_syncrepl_line: unknown scope \"%s\"\n",
2879 } else if ( !strncasecmp( cargv[ i ],
2880 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) ) {
2882 } else if ( !strncasecmp( cargv[ i ],
2883 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) ) {
2885 val = cargv[ i ] + sizeof( ATTRSSTR );
2886 for ( ; hp = strchr( val, ' ' ); val = ++hp ) {
2888 if ( *val != '\0' ) {
2890 tmp = (char **) ch_realloc( si->attrs, nr_attr * sizeof( char * ));
2891 if ( tmp == NULL ) {
2893 LDAP_LOG( CONFIG, ERR, "out of memory\n", 0,0,0 );
2895 Debug( LDAP_DEBUG_ANY,
2896 "out of memory\n", 0,0,0 );
2901 si->attrs[ nr_attr - 1 ] = strdup( val );
2904 if ( *val != '\0' ) {
2906 tmp = (char **) ch_realloc( si->attrs, nr_attr * sizeof( char * ));
2907 if ( tmp == NULL ) {
2909 LDAP_LOG( CONFIG, ERR, "out of memory\n", 0,0,0 );
2911 Debug( LDAP_DEBUG_ANY,
2912 "out of memory\n", 0,0,0 );
2917 si->attrs[ nr_attr - 1 ] = strdup( val );
2920 tmp = (char **) ch_realloc( si->attrs, nr_attr * sizeof( char * ));
2921 if ( tmp == NULL ) {
2923 LDAP_LOG( CONFIG, ERR, "out of memory\n", 0,0,0 );
2925 Debug( LDAP_DEBUG_ANY, "out of memory\n", 0,0,0 );
2930 si->attrs[ nr_attr - 1 ] = NULL;
2932 } else if ( !strncasecmp( cargv[ i ],
2933 TYPESTR, sizeof( TYPESTR ) - 1 ) ) {
2934 val = cargv[ i ] + sizeof( TYPESTR );
2936 if ( !strncasecmp( val, "refreshOnly", sizeof( "refreshOnly" ) - 1 )) {
2937 si->type = LDAP_SYNC_REFRESH_ONLY;
2938 } else if ( !strncasecmp( val, "refreshAndPersist", sizeof( "refreshAndPersist" ) - 1 )) {
2939 gots |= GOT_INTERVAL;
2940 si->type = LDAP_SYNC_REFRESH_AND_PERSIST;
2943 "Error: parse_syncrepl_line: unknown sync type \"%s\"\n",
2947 } else if ( !strncasecmp( cargv[ i ],
2948 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) ) {
2949 val = cargv[ i ] + sizeof( INTERVALSTR );
2950 gots |= GOT_INTERVAL;
2951 si->interval = atoi( val );
2952 if ( si->interval <= 0 ) {
2954 "Error: parse_syncrepl_line: invalid interval \"%d\"\n",
2958 } else if ( !strncasecmp( cargv[ i ],
2959 COOKIESTR, sizeof( COOKIESTR ) - 1 ) ) {
2960 val = cargv[ i ] + sizeof( COOKIESTR );
2961 si->syncCookie = ber_str2bv( val, strlen( val ), 1, NULL );
2964 "Error: parse_syncrepl_line: unknown keyword \"%s\"\n",
2969 if ( si->bindmethod == LDAP_AUTH_SASL) {
2970 if ((gots & GOT_MECH) == 0) {
2971 fprintf( stderr, "Error: \"syncrepl\" line needs SASLmech flag in " );
2972 fprintf( stderr, "slapd config file\n" );
2977 if ( gots != GOT_ALL ) {
2978 fprintf( stderr, "Error: Malformed \"syncrepl\" line in slapd config file"
2984 #endif /* LDAP_SYNCREPL */