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);
83 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
84 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
87 read_config( const char *fname, int depth )
90 char *line, *savefname, *saveline;
94 struct berval vals[2];
97 static int lastmod = 1;
98 static BackendInfo *bi = NULL;
99 static BackendDB *be = NULL;
101 vals[1].bv_val = NULL;
104 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
105 cargv_size = ARGS_STEP + 1;
108 if ( (fp = fopen( fname, "r" )) == NULL ) {
111 LDAP_LOG( CONFIG, ENTRY,
112 "read_config: " "could not open config file \"%s\": %s (%d)\n",
113 fname, strerror(errno), errno );
115 Debug( LDAP_DEBUG_ANY,
116 "could not open config file \"%s\": %s (%d)\n",
117 fname, strerror(errno), errno );
123 LDAP_LOG( CONFIG, ENTRY,
124 "read_config: reading config file %s\n", fname, 0, 0 );
126 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
130 fp_getline_init( &lineno );
132 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
133 /* skip comments and blank lines */
134 if ( line[0] == '#' || line[0] == '\0' ) {
138 /* fp_parse_line is destructive, we save a copy */
139 saveline = ch_strdup( line );
141 if ( fp_parse_line( lineno, line ) != 0 ) {
147 LDAP_LOG( CONFIG, INFO,
148 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
150 Debug( LDAP_DEBUG_ANY,
151 "%s: line %d: bad config line (ignored)\n",
158 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
161 LDAP_LOG( CONFIG, CRIT,
162 "%s : line %d: missing type in \"backend\" line.\n",
165 Debug( LDAP_DEBUG_ANY,
166 "%s: line %d: missing type in \"backend <type>\" line\n",
175 LDAP_LOG( CONFIG, CRIT,
176 "%s: line %d: backend line must appear before any "
177 "database definition.\n", fname, lineno , 0 );
179 Debug( LDAP_DEBUG_ANY,
180 "%s: line %d: backend line must appear before any database definition\n",
187 bi = backend_info( cargv[1] );
191 LDAP_LOG( CONFIG, CRIT,
192 "read_config: backend %s initialization failed.\n",
195 Debug( LDAP_DEBUG_ANY,
196 "backend %s initialization failed.\n",
202 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
205 LDAP_LOG( CONFIG, CRIT,
206 "%s: line %d: missing type in \"database <type>\" line\n",
209 Debug( LDAP_DEBUG_ANY,
210 "%s: line %d: missing type in \"database <type>\" line\n",
218 be = backend_db_init( cargv[1] );
222 LDAP_LOG( CONFIG, CRIT,
223 "database %s initialization failed.\n", cargv[1], 0, 0 );
225 Debug( LDAP_DEBUG_ANY,
226 "database %s initialization failed.\n",
233 /* set thread concurrency */
234 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
238 LDAP_LOG( CONFIG, CRIT,
239 "%s: line %d: missing level in \"concurrency <level\" "
240 " line\n", fname, lineno, 0 );
242 Debug( LDAP_DEBUG_ANY,
243 "%s: line %d: missing level in \"concurrency <level>\" line\n",
250 c = atoi( cargv[1] );
254 LDAP_LOG( CONFIG, CRIT,
255 "%s: line %d: invalid level (%d) in "
256 "\"concurrency <level>\" line.\n", fname, lineno, c );
258 Debug( LDAP_DEBUG_ANY,
259 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
266 ldap_pvt_thread_set_concurrency( c );
268 /* set sockbuf max */
269 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
273 LDAP_LOG( CONFIG, CRIT,
274 "%s: line %d: missing max in \"sockbuf_max_incoming "
275 "<bytes>\" line\n", fname, lineno, 0 );
277 Debug( LDAP_DEBUG_ANY,
278 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
285 max = atol( cargv[1] );
289 LDAP_LOG( CONFIG, CRIT,
290 "%s: line %d: invalid max value (%ld) in "
291 "\"sockbuf_max_incoming <bytes>\" line.\n",
292 fname, lineno, max );
294 Debug( LDAP_DEBUG_ANY,
295 "%s: line %d: invalid max value (%ld) in "
296 "\"sockbuf_max_incoming <bytes>\" line.\n",
297 fname, lineno, max );
303 sockbuf_max_incoming = max;
305 /* set sockbuf max authenticated */
306 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
310 LDAP_LOG( CONFIG, CRIT,
311 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
312 "<bytes>\" line\n", fname, lineno, 0 );
314 Debug( LDAP_DEBUG_ANY,
315 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
322 max = atol( cargv[1] );
326 LDAP_LOG( CONFIG, CRIT,
327 "%s: line %d: invalid max value (%ld) in "
328 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
329 fname, lineno, max );
331 Debug( LDAP_DEBUG_ANY,
332 "%s: line %d: invalid max value (%ld) in "
333 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
334 fname, lineno, max );
340 sockbuf_max_incoming_auth = max;
342 /* set conn pending max */
343 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
347 LDAP_LOG( CONFIG, CRIT,
348 "%s: line %d: missing max in \"conn_max_pending "
349 "<requests>\" line\n", fname, lineno, 0 );
351 Debug( LDAP_DEBUG_ANY,
352 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
359 max = atol( cargv[1] );
363 LDAP_LOG( CONFIG, CRIT,
364 "%s: line %d: invalid max value (%ld) in "
365 "\"conn_max_pending <requests>\" line.\n",
366 fname, lineno, max );
368 Debug( LDAP_DEBUG_ANY,
369 "%s: line %d: invalid max value (%ld) in "
370 "\"conn_max_pending <requests>\" line.\n",
371 fname, lineno, max );
377 slap_conn_max_pending = max;
379 /* set conn pending max authenticated */
380 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
384 LDAP_LOG( CONFIG, CRIT,
385 "%s: line %d: missing max in \"conn_max_pending_auth "
386 "<requests>\" line\n", fname, lineno, 0 );
388 Debug( LDAP_DEBUG_ANY,
389 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
396 max = atol( cargv[1] );
400 LDAP_LOG( CONFIG, CRIT,
401 "%s: line %d: invalid max value (%ld) in "
402 "\"conn_max_pending_auth <requests>\" line.\n",
403 fname, lineno, max );
405 Debug( LDAP_DEBUG_ANY,
406 "%s: line %d: invalid max value (%ld) in "
407 "\"conn_max_pending_auth <requests>\" line.\n",
408 fname, lineno, max );
414 slap_conn_max_pending_auth = max;
416 /* default search base */
417 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
420 LDAP_LOG( CONFIG, CRIT,
421 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
422 "line\n", fname, lineno, 0 );
424 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
425 "missing dn in \"defaultSearchBase <dn>\" line\n",
431 } else if ( cargc > 2 ) {
433 LDAP_LOG( CONFIG, INFO,
434 "%s: line %d: extra cruft after <dn> in "
435 "\"defaultSearchBase %s\" line (ignored)\n",
436 fname, lineno, cargv[1] );
438 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
439 "extra cruft after <dn> in \"defaultSearchBase %s\", "
441 fname, lineno, cargv[1] );
445 if ( bi != NULL || be != NULL ) {
447 LDAP_LOG( CONFIG, CRIT,
448 "%s: line %d: defaultSearchBase line must appear "
449 "prior to any backend or database definitions\n",
452 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
453 "defaultSearchBaase line must appear prior to "
454 "any backend or database definition\n",
461 if ( default_search_nbase.bv_len ) {
463 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
464 "default search base \"%s\" already defined "
465 "(discarding old)\n", fname, lineno,
466 default_search_base.bv_val );
468 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
469 "default search base \"%s\" already defined "
470 "(discarding old)\n",
471 fname, lineno, default_search_base.bv_val );
474 free( default_search_base.bv_val );
475 free( default_search_nbase.bv_val );
478 if ( load_ucdata( NULL ) < 0 ) return 1;
483 dn.bv_val = cargv[1];
484 dn.bv_len = strlen( dn.bv_val );
486 rc = dnPrettyNormal( NULL, &dn,
487 &default_search_base,
488 &default_search_nbase, NULL );
490 if( rc != LDAP_SUCCESS ) {
492 LDAP_LOG( CONFIG, CRIT,
493 "%s: line %d: defaultSearchBase DN is invalid.\n",
496 Debug( LDAP_DEBUG_ANY,
497 "%s: line %d: defaultSearchBase DN is invalid\n",
504 /* set maximum threads in thread pool */
505 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
509 LDAP_LOG( CONFIG, CRIT,
510 "%s: line %d: missing count in \"threads <count>\" line\n",
513 Debug( LDAP_DEBUG_ANY,
514 "%s: line %d: missing count in \"threads <count>\" line\n",
521 c = atoi( cargv[1] );
525 LDAP_LOG( CONFIG, CRIT,
526 "%s: line %d: invalid level (%d) in \"threads <count>\""
527 "line\n", fname, lineno, c );
529 Debug( LDAP_DEBUG_ANY,
530 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
537 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
539 /* save for later use */
540 connection_pool_max = c;
542 /* get pid file name */
543 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
546 LDAP_LOG( CONFIG, CRIT,
547 "%s: line %d missing file name in \"pidfile <file>\" "
548 "line.\n", fname, lineno, 0 );
550 Debug( LDAP_DEBUG_ANY,
551 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
558 slapd_pid_file = ch_strdup( cargv[1] );
560 /* get args file name */
561 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
564 LDAP_LOG( CONFIG, CRIT,
565 "%s: %d: missing file name in "
566 "\"argsfile <file>\" line.\n",
569 Debug( LDAP_DEBUG_ANY,
570 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
577 slapd_args_file = ch_strdup( cargv[1] );
579 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
582 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
585 /* default password hash */
586 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
589 LDAP_LOG( CONFIG, CRIT,
590 "%s: line %d: missing hash in "
591 "\"password-hash <hash>\" line.\n",
594 Debug( LDAP_DEBUG_ANY,
595 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
601 if ( default_passwd_hash != NULL ) {
603 LDAP_LOG( CONFIG, CRIT,
604 "%s: line %d: already set default password_hash!\n",
607 Debug( LDAP_DEBUG_ANY,
608 "%s: line %d: already set default password_hash!\n",
616 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
618 LDAP_LOG( CONFIG, CRIT,
619 "%s: line %d: password scheme \"%s\" not available\n",
620 fname, lineno, cargv[1] );
622 Debug( LDAP_DEBUG_ANY,
623 "%s: line %d: password scheme \"%s\" not available\n",
624 fname, lineno, cargv[1] );
629 default_passwd_hash = ch_strdup( cargv[1] );
631 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
635 LDAP_LOG( CONFIG, CRIT,
636 "%s: line %d: missing format in "
637 "\"password-crypt-salt-format <format>\" line\n",
640 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
641 "\"password-crypt-salt-format <format>\" line\n",
648 lutil_salt_format( cargv[1] );
650 /* SASL config options */
651 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
652 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
655 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
659 LDAP_LOG( CONFIG, CRIT,
660 "%s: line %d: missing dn in "
661 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
663 Debug( LDAP_DEBUG_ANY,
664 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
669 ber_str2bv( cargv[1], 0, 0, &dn );
671 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
672 &be->be_schemandn, NULL );
674 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
675 &global_schemandn, NULL );
677 if ( rc != LDAP_SUCCESS ) {
679 LDAP_LOG( CONFIG, CRIT,
680 "%s: line %d: schemadn DN is invalid.\n",
683 Debug( LDAP_DEBUG_ANY,
684 "%s: line %d: schemadn DN is invalid\n",
690 /* set UCDATA path */
691 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
695 LDAP_LOG( CONFIG, CRIT,
696 "%s: line %d: missing path in "
697 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
699 Debug( LDAP_DEBUG_ANY,
700 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
707 err = load_ucdata( cargv[1] );
711 LDAP_LOG( CONFIG, CRIT,
712 "%s: line %d: ucdata already loaded, ucdata-path "
713 "must be set earlier in the file and/or be "
714 "specified only once!\n", fname, lineno, 0 );
716 Debug( LDAP_DEBUG_ANY,
717 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
726 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
728 struct slap_limits_set *lim;
732 LDAP_LOG( CONFIG, CRIT,
733 "%s: line %d: missing limit in \"sizelimit <limit>\" "
734 "line.\n", fname, lineno, 0 );
736 Debug( LDAP_DEBUG_ANY,
737 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
747 lim = &be->be_def_limit;
750 for ( i = 1; i < cargc; i++ ) {
751 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
752 rc = parse_limit( cargv[i], lim );
755 LDAP_LOG( CONFIG, CRIT,
756 "%s: line %d: unable "
757 "to parse value \"%s\" in \"sizelimit "
758 "<limit>\" line.\n", fname, lineno, cargv[i] );
760 Debug( LDAP_DEBUG_ANY,
761 "%s: line %d: unable "
762 "to parse value \"%s\" "
765 fname, lineno, cargv[i] );
771 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
772 lim->lms_s_soft = -1;
776 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
777 if ( next == cargv[i] ) {
779 LDAP_LOG( CONFIG, CRIT,
780 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
781 "line.\n", fname, lineno, cargv[i] );
783 Debug( LDAP_DEBUG_ANY,
784 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
785 fname, lineno, cargv[i] );
789 } else if ( next[0] != '\0' ) {
791 LDAP_LOG( CONFIG, CRIT,
792 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
793 "line ignored.\n", fname, lineno, next );
795 Debug( LDAP_DEBUG_ANY,
796 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
797 fname, lineno, next );
806 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
808 struct slap_limits_set *lim;
812 LDAP_LOG( CONFIG, CRIT,
813 "%s: line %d missing limit in \"timelimit <limit>\" "
814 "line.\n", fname, lineno, 0 );
816 Debug( LDAP_DEBUG_ANY,
817 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
827 lim = &be->be_def_limit;
830 for ( i = 1; i < cargc; i++ ) {
831 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
832 rc = parse_limit( cargv[i], lim );
835 LDAP_LOG( CONFIG, CRIT,
836 "%s: line %d: unable to parse value \"%s\" "
837 "in \"timelimit <limit>\" line.\n",
838 fname, lineno, cargv[i] );
840 Debug( LDAP_DEBUG_ANY,
841 "%s: line %d: unable "
842 "to parse value \"%s\" "
845 fname, lineno, cargv[i] );
851 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
852 lim->lms_t_soft = -1;
856 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
857 if ( next == cargv[i] ) {
859 LDAP_LOG( CONFIG, CRIT,
860 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
861 "line.\n", fname, lineno, cargv[i] );
863 Debug( LDAP_DEBUG_ANY,
864 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
865 fname, lineno, cargv[i] );
869 } else if ( next[0] != '\0' ) {
871 LDAP_LOG( CONFIG, CRIT,
872 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
873 "line ignored.\n", fname, lineno, next );
875 Debug( LDAP_DEBUG_ANY,
876 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
877 fname, lineno, next );
885 /* set regex-based limits */
886 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
889 LDAP_LOG( CONFIG, WARNING,
890 "%s: line %d \"limits\" allowed only in database "
891 "environment.\n", fname, lineno, 0 );
893 Debug( LDAP_DEBUG_ANY,
894 "%s: line %d \"limits\" allowed only in database environment.\n%s",
900 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
904 /* mark this as a subordinate database */
905 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
908 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
909 "subordinate keyword must appear inside a database "
910 "definition.\n", fname, lineno, 0 );
912 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
913 "must appear inside a database definition.\n",
919 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
923 /* add an overlay to this backend */
924 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
927 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
928 "overlay keyword must appear inside a database "
929 "definition.\n", fname, lineno, 0 );
931 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
932 "must appear inside a database definition.\n",
937 } else if ( overlay_config( be, cargv[1] )) {
941 /* set database suffix */
942 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
944 struct berval dn, pdn, ndn;
948 LDAP_LOG( CONFIG, CRIT,
949 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
952 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
953 "missing dn in \"suffix <dn>\" line\n",
959 } else if ( cargc > 2 ) {
961 LDAP_LOG( CONFIG, INFO,
962 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
963 " line (ignored).\n", fname, lineno, cargv[1] );
965 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
966 "after <dn> in \"suffix %s\" line (ignored)\n",
967 fname, lineno, cargv[1] );
973 LDAP_LOG( CONFIG, INFO,
974 "%s: line %d: suffix line must appear inside a database "
975 "definition.\n", fname, lineno, 0 );
977 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
978 "must appear inside a database definition\n",
983 #if defined(SLAPD_MONITOR_DN)
984 /* "cn=Monitor" is reserved for monitoring slap */
985 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
987 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
988 "%s\" is reserved for monitoring slapd\n",
989 fname, lineno, SLAPD_MONITOR_DN );
991 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
992 "%s\" is reserved for monitoring slapd\n",
993 fname, lineno, SLAPD_MONITOR_DN );
996 #endif /* SLAPD_MONITOR_DN */
999 if ( load_ucdata( NULL ) < 0 ) return 1;
1001 dn.bv_val = cargv[1];
1002 dn.bv_len = strlen( cargv[1] );
1004 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1005 if( rc != LDAP_SUCCESS ) {
1007 LDAP_LOG( CONFIG, CRIT,
1008 "%s: line %d: suffix DN is invalid.\n",
1011 Debug( LDAP_DEBUG_ANY,
1012 "%s: line %d: suffix DN is invalid\n",
1018 tmp_be = select_backend( &ndn, 0, 0 );
1019 if ( tmp_be == be ) {
1021 LDAP_LOG( CONFIG, INFO,
1022 "%s: line %d: suffix already served by this backend "
1023 "(ignored)\n", fname, lineno, 0 );
1025 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1026 "already served by this backend (ignored)\n",
1032 } else if ( tmp_be != NULL ) {
1034 LDAP_LOG( CONFIG, INFO,
1035 "%s: line %d: suffix already served by a preceding "
1036 "backend \"%s\"\n", fname, lineno,
1037 tmp_be->be_suffix[0].bv_val );
1039 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1040 "already served by a preceeding backend \"%s\"\n",
1041 fname, lineno, tmp_be->be_suffix[0].bv_val );
1047 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1049 LDAP_LOG( CONFIG, INFO,
1050 "%s: line %d: suffix DN empty and default search "
1051 "base provided \"%s\" (assuming okay).\n",
1052 fname, lineno, default_search_base.bv_val );
1054 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1055 "suffix DN empty and default "
1056 "search base provided \"%s\" (assuming okay)\n",
1057 fname, lineno, default_search_base.bv_val );
1061 ber_bvarray_add( &be->be_suffix, &pdn );
1062 ber_bvarray_add( &be->be_nsuffix, &ndn );
1064 /* set max deref depth */
1065 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1069 LDAP_LOG( CONFIG, CRIT,
1070 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1071 " line\n", fname, lineno, 0 );
1073 Debug( LDAP_DEBUG_ANY,
1074 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1082 LDAP_LOG( CONFIG, INFO,
1083 "%s: line %d: depth line must appear inside a database "
1084 "definition.\n", fname, lineno ,0 );
1086 Debug( LDAP_DEBUG_ANY,
1087 "%s: line %d: depth line must appear inside a database definition.\n",
1092 } else if ((i = atoi(cargv[1])) < 0) {
1094 LDAP_LOG( CONFIG, INFO,
1095 "%s: line %d: depth must be positive.\n",
1098 Debug( LDAP_DEBUG_ANY,
1099 "%s: line %d: depth must be positive.\n",
1106 be->be_max_deref_depth = i;
1110 /* set magic "root" dn for this database */
1111 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1114 LDAP_LOG( CONFIG, INFO,
1115 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1118 Debug( LDAP_DEBUG_ANY,
1119 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1128 LDAP_LOG( CONFIG, INFO,
1129 "%s: line %d: rootdn line must appear inside a database "
1130 "definition.\n", fname, lineno ,0 );
1132 Debug( LDAP_DEBUG_ANY,
1133 "%s: line %d: rootdn line must appear inside a database definition.\n",
1141 if ( load_ucdata( NULL ) < 0 ) return 1;
1143 dn.bv_val = cargv[1];
1144 dn.bv_len = strlen( cargv[1] );
1146 rc = dnPrettyNormal( NULL, &dn,
1148 &be->be_rootndn, NULL );
1150 if( rc != LDAP_SUCCESS ) {
1152 LDAP_LOG( CONFIG, CRIT,
1153 "%s: line %d: rootdn DN is invalid.\n",
1156 Debug( LDAP_DEBUG_ANY,
1157 "%s: line %d: rootdn DN is invalid\n",
1164 /* set super-secret magic database password */
1165 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1168 LDAP_LOG( CONFIG, CRIT,
1169 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1170 " line\n", fname, lineno ,0 );
1172 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1173 "missing passwd in \"rootpw <passwd>\" line\n",
1182 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1183 "rootpw line must appear inside a database "
1184 "definition.\n", fname, lineno ,0 );
1186 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1187 "rootpw line must appear inside a database "
1194 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1196 if( tmp_be != be ) {
1198 LDAP_LOG( CONFIG, INFO,
1200 "rootpw can only be set when rootdn is under suffix\n",
1201 fname, lineno, "" );
1203 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1204 "rootpw can only be set when rootdn is under suffix\n",
1210 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1211 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1214 /* make this database read-only */
1215 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1218 LDAP_LOG( CONFIG, CRIT,
1219 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1220 "line.\n", fname, lineno ,0 );
1222 Debug( LDAP_DEBUG_ANY,
1223 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1230 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1231 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1233 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1236 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1237 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1239 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1244 /* allow these features */
1245 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1246 strcasecmp( cargv[0], "allow" ) == 0 )
1252 LDAP_LOG( CONFIG, INFO,
1253 "%s: line %d: allow line must appear prior to "
1254 "database definitions.\n", fname, lineno ,0 );
1256 Debug( LDAP_DEBUG_ANY,
1257 "%s: line %d: allow line must appear prior to database definitions\n",
1265 LDAP_LOG( CONFIG, CRIT,
1266 "%s: line %d: missing feature(s) in \"allow <features>\""
1267 " line\n", fname, lineno ,0 );
1269 Debug( LDAP_DEBUG_ANY,
1270 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1279 for( i=1; i < cargc; i++ ) {
1280 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1281 allows |= SLAP_ALLOW_BIND_V2;
1283 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1284 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1286 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1287 allows |= SLAP_ALLOW_BIND_ANON_DN;
1289 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1290 allows |= SLAP_ALLOW_UPDATE_ANON;
1292 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1294 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1295 "unknown feature %s in \"allow <features>\" line.\n",
1296 fname, lineno, cargv[1] );
1298 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1299 "unknown feature %s in \"allow <features>\" line\n",
1300 fname, lineno, cargv[i] );
1307 global_allows = allows;
1309 /* disallow these features */
1310 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1311 strcasecmp( cargv[0], "disallow" ) == 0 )
1313 slap_mask_t disallows;
1317 LDAP_LOG( CONFIG, INFO,
1318 "%s: line %d: disallow line must appear prior to "
1319 "database definitions.\n", fname, lineno ,0 );
1321 Debug( LDAP_DEBUG_ANY,
1322 "%s: line %d: disallow line must appear prior to database definitions\n",
1330 LDAP_LOG( CONFIG, CRIT,
1331 "%s: line %d: missing feature(s) in \"disallow <features>\""
1332 " line.\n", fname, lineno ,0 );
1334 Debug( LDAP_DEBUG_ANY,
1335 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1344 for( i=1; i < cargc; i++ ) {
1345 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1346 disallows |= SLAP_DISALLOW_BIND_ANON;
1348 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1349 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1351 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1352 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1354 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1355 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1357 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1358 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1360 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1362 LDAP_LOG( CONFIG, CRIT,
1363 "%s: line %d: unknown feature %s in "
1364 "\"disallow <features>\" line.\n",
1365 fname, lineno, cargv[i] );
1367 Debug( LDAP_DEBUG_ANY,
1368 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1369 fname, lineno, cargv[i] );
1376 global_disallows = disallows;
1378 /* require these features */
1379 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1380 strcasecmp( cargv[0], "require" ) == 0 )
1382 slap_mask_t requires;
1386 LDAP_LOG( CONFIG, CRIT,
1387 "%s: line %d: missing feature(s) in "
1388 "\"require <features>\" line.\n", fname, lineno ,0 );
1390 Debug( LDAP_DEBUG_ANY,
1391 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1400 for( i=1; i < cargc; i++ ) {
1401 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1402 requires |= SLAP_REQUIRE_BIND;
1404 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1405 requires |= SLAP_REQUIRE_LDAP_V3;
1407 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1408 requires |= SLAP_REQUIRE_AUTHC;
1410 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1411 requires |= SLAP_REQUIRE_SASL;
1413 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1414 requires |= SLAP_REQUIRE_STRONG;
1416 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1418 LDAP_LOG( CONFIG, CRIT,
1419 "%s: line %d: unknown feature %s in "
1420 "\"require <features>\" line.\n",
1421 fname, lineno , cargv[i] );
1423 Debug( LDAP_DEBUG_ANY,
1424 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1425 fname, lineno, cargv[i] );
1433 global_requires = requires;
1435 be->be_requires = requires;
1438 /* required security factors */
1439 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1440 slap_ssf_set_t *set;
1444 LDAP_LOG( CONFIG, CRIT,
1445 "%s: line %d: missing factor(s) in \"security <factors>\""
1446 " line.\n", fname, lineno ,0 );
1448 Debug( LDAP_DEBUG_ANY,
1449 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1457 set = &global_ssf_set;
1459 set = &be->be_ssf_set;
1462 for( i=1; i < cargc; i++ ) {
1463 if( strncasecmp( cargv[i], "ssf=",
1464 sizeof("ssf") ) == 0 )
1467 atoi( &cargv[i][sizeof("ssf")] );
1469 } else if( strncasecmp( cargv[i], "transport=",
1470 sizeof("transport") ) == 0 )
1472 set->sss_transport =
1473 atoi( &cargv[i][sizeof("transport")] );
1475 } else if( strncasecmp( cargv[i], "tls=",
1476 sizeof("tls") ) == 0 )
1479 atoi( &cargv[i][sizeof("tls")] );
1481 } else if( strncasecmp( cargv[i], "sasl=",
1482 sizeof("sasl") ) == 0 )
1485 atoi( &cargv[i][sizeof("sasl")] );
1487 } else if( strncasecmp( cargv[i], "update_ssf=",
1488 sizeof("update_ssf") ) == 0 )
1490 set->sss_update_ssf =
1491 atoi( &cargv[i][sizeof("update_ssf")] );
1493 } else if( strncasecmp( cargv[i], "update_transport=",
1494 sizeof("update_transport") ) == 0 )
1496 set->sss_update_transport =
1497 atoi( &cargv[i][sizeof("update_transport")] );
1499 } else if( strncasecmp( cargv[i], "update_tls=",
1500 sizeof("update_tls") ) == 0 )
1502 set->sss_update_tls =
1503 atoi( &cargv[i][sizeof("update_tls")] );
1505 } else if( strncasecmp( cargv[i], "update_sasl=",
1506 sizeof("update_sasl") ) == 0 )
1508 set->sss_update_sasl =
1509 atoi( &cargv[i][sizeof("update_sasl")] );
1511 } else if( strncasecmp( cargv[i], "simple_bind=",
1512 sizeof("simple_bind") ) == 0 )
1514 set->sss_simple_bind =
1515 atoi( &cargv[i][sizeof("simple_bind")] );
1519 LDAP_LOG( CONFIG, CRIT,
1520 "%s: line %d: unknown factor %S in "
1521 "\"security <factors>\" line.\n",
1522 fname, lineno, cargv[1] );
1524 Debug( LDAP_DEBUG_ANY,
1525 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1526 fname, lineno, cargv[i] );
1532 /* where to send clients when we don't hold it */
1533 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1536 LDAP_LOG( CONFIG, CRIT,
1537 "%s: line %d: missing URL in \"referral <URL>\""
1538 " line.\n", fname, lineno , 0 );
1540 Debug( LDAP_DEBUG_ANY,
1541 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1548 if( validate_global_referral( cargv[1] ) ) {
1550 LDAP_LOG( CONFIG, CRIT,
1551 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1552 fname, lineno, cargv[1] );
1554 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1555 "invalid URL (%s) in \"referral\" line.\n",
1556 fname, lineno, cargv[1] );
1561 vals[0].bv_val = cargv[1];
1562 vals[0].bv_len = strlen( vals[0].bv_val );
1563 if( value_add( &default_referral, vals ) )
1567 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1571 LDAP_LOG( CONFIG, CRIT,
1572 "%s: line %d: Error in logfile directive, "
1573 "\"logfile <filename>\"\n", fname, lineno , 0 );
1575 Debug( LDAP_DEBUG_ANY,
1576 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1582 logfile = fopen( cargv[1], "w" );
1583 if ( logfile != NULL ) lutil_debug_file( logfile );
1586 /* start of a new database definition */
1587 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1591 LDAP_LOG( CONFIG, CRIT,
1592 "%s: line %d: Error in debug directive, "
1593 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1595 Debug( LDAP_DEBUG_ANY,
1596 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1602 level = atoi( cargv[2] );
1603 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1604 lutil_set_debug_level( cargv[1], level );
1605 /* specify an Object Identifier macro */
1606 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1607 rc = parse_oidm( fname, lineno, cargc, cargv );
1610 /* specify an objectclass */
1611 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1614 LDAP_LOG( CONFIG, INFO,
1615 "%s: line %d: illegal objectclass format.\n",
1616 fname, lineno , 0 );
1618 Debug( LDAP_DEBUG_ANY,
1619 "%s: line %d: illegal objectclass format.\n",
1624 } else if ( *cargv[1] == '(' /*')'*/) {
1626 p = strchr(saveline,'(' /*')'*/);
1627 rc = parse_oc( fname, lineno, p, cargv );
1632 LDAP_LOG( CONFIG, INFO,
1633 "%s: line %d: old objectclass format not supported\n",
1634 fname, lineno , 0 );
1636 Debug( LDAP_DEBUG_ANY,
1637 "%s: line %d: old objectclass format not supported.\n",
1642 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1644 p = strchr(saveline,'(' /*')'*/);
1645 rc = parse_cr( fname, lineno, p, cargv );
1648 /* specify an attribute type */
1649 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1650 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1654 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1655 "illegal attribute type format.\n",
1656 fname, lineno , 0 );
1658 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1659 "illegal attribute type format.\n",
1664 } else if ( *cargv[1] == '(' /*')'*/) {
1666 p = strchr(saveline,'(' /*')'*/);
1667 rc = parse_at( fname, lineno, p, cargv );
1672 LDAP_LOG( CONFIG, INFO,
1673 "%s: line %d: old attribute type format not supported.\n",
1674 fname, lineno , 0 );
1676 Debug( LDAP_DEBUG_ANY,
1677 "%s: line %d: old attribute type format not supported.\n",
1683 /* define attribute option(s) */
1684 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1685 ad_define_option( NULL, NULL, 0 );
1686 for ( i = 1; i < cargc; i++ )
1687 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1690 /* turn on/off schema checking */
1691 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1694 LDAP_LOG( CONFIG, CRIT,
1695 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1696 " line.\n", fname, lineno , 0 );
1698 Debug( LDAP_DEBUG_ANY,
1699 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1705 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1707 LDAP_LOG( CONFIG, CRIT,
1708 "%s: line %d: schema checking disabled! your mileage may "
1709 "vary!\n", fname, lineno , 0 );
1711 Debug( LDAP_DEBUG_ANY,
1712 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1715 global_schemacheck = 0;
1717 global_schemacheck = 1;
1720 /* specify access control info */
1721 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1722 parse_acl( be, fname, lineno, cargc, cargv );
1724 /* debug level to log things to syslog */
1725 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1728 LDAP_LOG( CONFIG, CRIT,
1729 "%s: line %d: missing level in \"loglevel <level>\""
1730 " line.\n", fname, lineno , 0 );
1732 Debug( LDAP_DEBUG_ANY,
1733 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1742 for( i=1; i < cargc; i++ ) {
1743 ldap_syslog += atoi( cargv[1] );
1746 /* list of sync replication information in this backend (slave only) */
1747 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1751 LDAP_LOG( CONFIG, INFO,
1752 "%s: line %d: syncrepl line must appear inside "
1753 "a database definition.\n", fname, lineno, 0);
1755 Debug( LDAP_DEBUG_ANY,
1756 "%s: line %d: syncrepl line must appear inside "
1757 "a database definition.\n", fname, lineno, 0);
1761 if ( add_syncrepl( be, cargv, cargc )) {
1766 /* list of replicas of the data in this backend (master only) */
1767 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1770 LDAP_LOG( CONFIG, CRIT,
1771 "%s: line %d: missing host or uri in \"replica "
1772 " <host[:port]\" line\n", fname, lineno , 0 );
1774 Debug( LDAP_DEBUG_ANY,
1775 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1783 LDAP_LOG( CONFIG, INFO,
1784 "%s: line %d: replica line must appear inside "
1785 "a database definition.\n", fname, lineno, 0);
1787 Debug( LDAP_DEBUG_ANY,
1788 "%s: line %d: replica line must appear inside a database definition\n",
1796 for ( i = 1; i < cargc; i++ ) {
1797 if ( strncasecmp( cargv[i], "host=", 5 )
1799 nr = add_replica_info( be,
1802 } else if (strncasecmp( cargv[i], "uri=", 4 )
1804 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1807 LDAP_LOG( CONFIG, INFO,
1808 "%s: line %d: replica line contains invalid "
1809 "uri definition.\n", fname, lineno, 0);
1811 Debug( LDAP_DEBUG_ANY,
1812 "%s: line %d: replica line contains invalid "
1813 "uri definition.\n", fname, lineno, 0);
1817 if (ludp->lud_host == NULL ) {
1819 LDAP_LOG( CONFIG, INFO,
1820 "%s: line %d: replica line contains invalid "
1821 "uri definition - missing hostname.\n",
1824 Debug( LDAP_DEBUG_ANY,
1825 "%s: line %d: replica line contains invalid "
1826 "uri definition - missing hostname.\n", fname, lineno, 0);
1830 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1831 if ( replicahost == NULL ) {
1833 LDAP_LOG( CONFIG, ERR,
1834 "out of memory in read_config\n", 0, 0,0 );
1836 Debug( LDAP_DEBUG_ANY,
1837 "out of memory in read_config\n", 0, 0, 0 );
1839 ldap_free_urldesc( ludp );
1840 exit( EXIT_FAILURE );
1842 sprintf(replicahost, "%s:%d",
1843 ludp->lud_host, ludp->lud_port);
1844 nr = add_replica_info( be, replicahost );
1845 ldap_free_urldesc( ludp );
1846 ch_free(replicahost);
1852 LDAP_LOG( CONFIG, INFO,
1853 "%s: line %d: missing host or uri in \"replica\" line\n",
1854 fname, lineno , 0 );
1856 Debug( LDAP_DEBUG_ANY,
1857 "%s: line %d: missing host or uri in \"replica\" line\n",
1862 } else if ( nr == -1 ) {
1864 LDAP_LOG( CONFIG, INFO,
1865 "%s: line %d: unable to add"
1866 " replica \"%s\"\n",
1870 Debug( LDAP_DEBUG_ANY,
1871 "%s: line %d: unable to add replica \"%s\"\n",
1872 fname, lineno, cargv[i] + 5 );
1876 for ( i = 1; i < cargc; i++ ) {
1877 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1879 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1882 LDAP_LOG( CONFIG, INFO,
1883 "%s: line %d: suffix \"%s\" in \"replica\""
1884 " line is not valid for backend(ignored)\n",
1885 fname, lineno, cargv[i] + 7 );
1887 Debug( LDAP_DEBUG_ANY,
1888 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1889 fname, lineno, cargv[i] + 7 );
1895 LDAP_LOG( CONFIG, INFO,
1896 "%s: line %d: unable to normalize suffix"
1897 " in \"replica\" line (ignored)\n",
1898 fname, lineno , 0 );
1900 Debug( LDAP_DEBUG_ANY,
1901 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1907 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1909 char *arg = cargv[i] + 4;
1911 if ( arg[0] == '!' ) {
1916 if ( arg[0] != '=' ) {
1920 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1922 LDAP_LOG( CONFIG, INFO,
1923 "%s: line %d: attribute \"%s\" in "
1924 "\"replica\" line is unknown\n",
1925 fname, lineno, arg + 1 );
1927 Debug( LDAP_DEBUG_ANY,
1928 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1929 fname, lineno, arg + 1 );
1938 /* dn of master entity allowed to write to replica */
1939 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1942 LDAP_LOG( CONFIG, CRIT,
1943 "%s: line %d: missing dn in \"updatedn <dn>\""
1944 " line.\n", fname, lineno , 0 );
1946 Debug( LDAP_DEBUG_ANY,
1947 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1955 LDAP_LOG( CONFIG, INFO,
1956 "%s: line %d: updatedn line must appear inside "
1957 "a database definition\n",
1958 fname, lineno , 0 );
1960 Debug( LDAP_DEBUG_ANY,
1961 "%s: line %d: updatedn line must appear inside a database definition\n",
1969 if ( load_ucdata( NULL ) < 0 ) return 1;
1971 dn.bv_val = cargv[1];
1972 dn.bv_len = strlen( cargv[1] );
1974 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
1975 if( rc != LDAP_SUCCESS ) {
1977 LDAP_LOG( CONFIG, CRIT,
1978 "%s: line %d: updatedn DN is invalid.\n",
1979 fname, lineno , 0 );
1981 Debug( LDAP_DEBUG_ANY,
1982 "%s: line %d: updatedn DN is invalid\n",
1989 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1992 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1993 "missing url in \"updateref <ldapurl>\" line.\n",
1994 fname, lineno , 0 );
1996 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1997 "missing url in \"updateref <ldapurl>\" line\n",
2005 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2006 " line must appear inside a database definition\n",
2007 fname, lineno , 0 );
2009 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2010 " line must appear inside a database definition\n",
2015 } else if ( !be->be_update_ndn.bv_len ) {
2017 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2018 "updateref line must come after updatedn.\n",
2019 fname, lineno , 0 );
2021 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2022 "updateref line must after updatedn.\n",
2028 if( validate_global_referral( cargv[1] ) ) {
2030 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2031 "invalid URL (%s) in \"updateref\" line.\n",
2032 fname, lineno, cargv[1] );
2034 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2035 "invalid URL (%s) in \"updateref\" line.\n",
2036 fname, lineno, cargv[1] );
2041 vals[0].bv_val = cargv[1];
2042 vals[0].bv_len = strlen( vals[0].bv_val );
2043 if( value_add( &be->be_update_refs, vals ) )
2046 /* replication log file to which changes are appended */
2047 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2050 LDAP_LOG( CONFIG, CRIT,
2051 "%s: line %d: missing filename in \"replogfile <filename>\""
2052 " line.\n", fname, lineno , 0 );
2054 Debug( LDAP_DEBUG_ANY,
2055 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2062 be->be_replogfile = ch_strdup( cargv[1] );
2064 replogfile = ch_strdup( cargv[1] );
2067 /* file from which to read additional rootdse attrs */
2068 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2071 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2072 "missing filename in \"rootDSE <filename>\" line.\n",
2073 fname, lineno , 0 );
2075 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2076 "missing filename in \"rootDSE <filename>\" line.\n",
2082 if( read_root_dse_file( cargv[1] ) ) {
2084 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2085 "could not read \"rootDSE <filename>\" line.\n",
2086 fname, lineno , 0 );
2088 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2089 "could not read \"rootDSE <filename>\" line\n",
2095 /* maintain lastmodified{by,time} attributes */
2096 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2099 LDAP_LOG( CONFIG, CRIT,
2100 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2101 " line.\n", fname, lineno , 0 );
2103 Debug( LDAP_DEBUG_ANY,
2104 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2110 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2112 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2118 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2125 /* turn on/off gentle SIGHUP handling */
2126 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2128 Debug( LDAP_DEBUG_ANY,
2129 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2133 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2134 global_gentlehup = 0;
2136 global_gentlehup = 1;
2140 /* set idle timeout value */
2141 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2145 LDAP_LOG( CONFIG, CRIT,
2146 "%s: line %d: missing timeout value in "
2147 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2149 Debug( LDAP_DEBUG_ANY,
2150 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2157 i = atoi( cargv[1] );
2161 LDAP_LOG( CONFIG, CRIT,
2162 "%s: line %d: timeout value (%d) invalid "
2163 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2165 Debug( LDAP_DEBUG_ANY,
2166 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2173 global_idletimeout = i;
2175 /* include another config file */
2176 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2179 LDAP_LOG( CONFIG, CRIT,
2180 "%s: line %d: missing filename in \"include "
2181 "<filename>\" line.\n", fname, lineno , 0 );
2183 Debug( LDAP_DEBUG_ANY,
2184 "%s: line %d: missing filename in \"include <filename>\" line\n",
2190 savefname = ch_strdup( cargv[1] );
2191 savelineno = lineno;
2193 if ( read_config( savefname, depth+1 ) != 0 ) {
2198 lineno = savelineno - 1;
2200 /* location of kerberos srvtab file */
2201 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2204 LDAP_LOG( CONFIG, CRIT,
2205 "%s: line %d: missing filename in \"srvtab "
2206 "<filename>\" line.\n", fname, lineno , 0 );
2208 Debug( LDAP_DEBUG_ANY,
2209 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2215 ldap_srvtab = ch_strdup( cargv[1] );
2217 #ifdef SLAPD_MODULES
2218 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2221 LDAP_LOG( CONFIG, INFO,
2222 "%s: line %d: missing filename in \"moduleload "
2223 "<filename>\" line.\n", fname, lineno , 0 );
2225 Debug( LDAP_DEBUG_ANY,
2226 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2230 exit( EXIT_FAILURE );
2232 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2234 LDAP_LOG( CONFIG, CRIT,
2235 "%s: line %d: failed to load or initialize module %s\n",
2236 fname, lineno, cargv[1] );
2238 Debug( LDAP_DEBUG_ANY,
2239 "%s: line %d: failed to load or initialize module %s\n",
2240 fname, lineno, cargv[1]);
2243 exit( EXIT_FAILURE );
2245 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2248 LDAP_LOG( CONFIG, INFO,
2249 "%s: line %d: missing path in \"modulepath <path>\""
2250 " line\n", fname, lineno , 0 );
2252 Debug( LDAP_DEBUG_ANY,
2253 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2257 exit( EXIT_FAILURE );
2259 if (module_path( cargv[1] )) {
2261 LDAP_LOG( CONFIG, CRIT,
2262 "%s: line %d: failed to set module search path to %s.\n",
2263 fname, lineno, cargv[1] );
2265 Debug( LDAP_DEBUG_ANY,
2266 "%s: line %d: failed to set module search path to %s\n",
2267 fname, lineno, cargv[1]);
2270 exit( EXIT_FAILURE );
2273 #endif /*SLAPD_MODULES*/
2276 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2277 rc = ldap_pvt_tls_set_option( NULL,
2278 LDAP_OPT_X_TLS_RANDOM_FILE,
2283 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2284 rc = ldap_pvt_tls_set_option( NULL,
2285 LDAP_OPT_X_TLS_CIPHER_SUITE,
2290 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2291 rc = ldap_pvt_tls_set_option( NULL,
2292 LDAP_OPT_X_TLS_CERTFILE,
2297 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2298 rc = ldap_pvt_tls_set_option( NULL,
2299 LDAP_OPT_X_TLS_KEYFILE,
2304 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2305 rc = ldap_pvt_tls_set_option( NULL,
2306 LDAP_OPT_X_TLS_CACERTDIR,
2311 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2312 rc = ldap_pvt_tls_set_option( NULL,
2313 LDAP_OPT_X_TLS_CACERTFILE,
2317 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2318 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2320 rc = ldap_pvt_tls_set_option( NULL,
2321 LDAP_OPT_X_TLS_REQUIRE_CERT,
2324 rc = ldap_int_tls_config( NULL,
2325 LDAP_OPT_X_TLS_REQUIRE_CERT,
2334 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2335 #ifdef SLAPD_RLOOKUPS
2338 LDAP_LOG( CONFIG, INFO,
2339 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2340 fname, lineno , 0 );
2342 Debug( LDAP_DEBUG_ANY,
2343 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2349 if ( !strcasecmp( cargv[1], "on" ) ) {
2350 use_reverse_lookup = 1;
2351 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2352 use_reverse_lookup = 0;
2355 LDAP_LOG( CONFIG, INFO,
2356 "%s: line %d: reverse-lookup: "
2357 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2359 Debug( LDAP_DEBUG_ANY,
2360 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2366 #else /* !SLAPD_RLOOKUPS */
2368 LDAP_LOG( CONFIG, INFO,
2369 "%s: line %d: reverse lookups "
2370 "are not configured (ignored).\n", fname, lineno , 0 );
2372 Debug( LDAP_DEBUG_ANY,
2373 "%s: line %d: reverse lookups are not configured (ignored).\n",
2376 #endif /* !SLAPD_RLOOKUPS */
2378 /* Netscape plugins */
2379 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2380 #if defined( LDAP_SLAPI )
2382 #ifdef notdef /* allow global plugins, too */
2384 * a "plugin" line must be inside a database
2385 * definition, since we implement pre-,post-
2386 * and extended operation plugins
2390 LDAP_LOG( CONFIG, INFO,
2391 "%s: line %d: plugin line must appear "
2392 "insid a database definition.\n",
2395 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2396 "line must appear inside a database "
2397 "definition\n", fname, lineno, 0 );
2403 if ( netscape_plugin( be, fname, lineno, cargc, cargv )
2408 #else /* !defined( LDAP_SLAPI ) */
2410 LDAP_LOG( CONFIG, INFO,
2411 "%s: line %d: SLAPI not supported.\n",
2414 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2415 "not supported.\n", fname, lineno, 0 );
2419 #endif /* !defined( LDAP_SLAPI ) */
2421 /* Netscape plugins */
2422 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2423 #if defined( LDAP_SLAPI )
2426 LDAP_LOG( CONFIG, INFO,
2427 "%s: line %d: missing file name "
2428 "in pluginlog <filename> line.\n",
2431 Debug( LDAP_DEBUG_ANY,
2432 "%s: line %d: missing file name "
2433 "in pluginlog <filename> line.\n",
2439 if ( slapi_log_file != NULL ) {
2440 ch_free( slapi_log_file );
2443 slapi_log_file = ch_strdup( cargv[1] );
2444 #endif /* !defined( LDAP_SLAPI ) */
2446 /* pass anything else to the current backend info/db config routine */
2449 if ( bi->bi_config == 0 ) {
2451 LDAP_LOG( CONFIG, INFO,
2452 "%s: line %d: unknown directive \"%s\" inside "
2453 "backend info definition (ignored).\n",
2454 fname, lineno, cargv[0] );
2456 Debug( LDAP_DEBUG_ANY,
2457 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2458 fname, lineno, cargv[0] );
2462 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2468 } else if ( be != NULL ) {
2469 if ( be->be_config == 0 ) {
2471 LDAP_LOG( CONFIG, INFO,
2472 "%s: line %d: uknown directive \"%s\" inside "
2473 "backend database definition (ignored).\n",
2474 fname, lineno, cargv[0] );
2476 Debug( LDAP_DEBUG_ANY,
2477 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2478 fname, lineno, cargv[0] );
2482 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2490 LDAP_LOG( CONFIG, INFO,
2491 "%s: line %d: unknown directive \"%s\" outside backend "
2492 "info and database definitions (ignored).\n",
2493 fname, lineno, cargv[0] );
2495 Debug( LDAP_DEBUG_ANY,
2496 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2497 fname, lineno, cargv[0] );
2506 if ( depth == 0 ) ch_free( cargv );
2508 if ( !global_schemadn.bv_val ) {
2509 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2511 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2514 if ( load_ucdata( NULL ) < 0 ) return 1;
2526 char logbuf[sizeof("pseudorootpw ***")];
2529 token = strtok_quote( line, " \t" );
2533 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2534 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2535 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2536 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2537 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2539 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2542 if ( strtok_quote_ptr ) {
2543 *strtok_quote_ptr = ' ';
2547 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2549 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2552 if ( strtok_quote_ptr ) {
2553 *strtok_quote_ptr = '\0';
2556 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2557 if ( cargc == cargv_size - 1 ) {
2559 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2561 if ( tmp == NULL ) {
2563 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2565 Debug( LDAP_DEBUG_ANY,
2566 "line %d: out of memory\n",
2572 cargv_size += ARGS_STEP;
2574 cargv[cargc++] = token;
2576 cargv[cargc] = NULL;
2581 strtok_quote( char *line, char *sep )
2587 strtok_quote_ptr = NULL;
2588 if ( line != NULL ) {
2591 while ( *next && strchr( sep, *next ) ) {
2595 if ( *next == '\0' ) {
2601 for ( inquote = 0; *next; ) {
2609 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2615 next + 1, strlen( next + 1 ) + 1 );
2616 next++; /* dont parse the escaped character */
2621 if ( strchr( sep, *next ) != NULL ) {
2622 strtok_quote_ptr = next;
2635 static char buf[BUFSIZ];
2637 static size_t lmax, lcur;
2639 #define CATLINE( buf ) \
2641 size_t len = strlen( buf ); \
2642 while ( lcur + len + 1 > lmax ) { \
2644 line = (char *) ch_realloc( line, lmax ); \
2646 strcpy( line + lcur, buf ); \
2651 fp_getline( FILE *fp, int *lineno )
2659 /* hack attack - keeps us from having to keep a stack of bufs... */
2660 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2665 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2666 /* trim off \r\n or \n */
2667 if ( (p = strchr( buf, '\n' )) != NULL ) {
2668 if( p > buf && p[-1] == '\r' ) --p;
2672 /* trim off trailing \ and append the next line */
2673 if ( line[ 0 ] != '\0'
2674 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2675 && p[ -1 ] != '\\' ) {
2680 if ( ! isspace( (unsigned char) buf[0] ) ) {
2684 /* change leading whitespace to a space */
2693 return( line[0] ? line : NULL );
2697 fp_getline_init( int *lineno )
2703 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2705 load_ucdata( char *path )
2707 static int loaded = 0;
2713 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2716 LDAP_LOG( CONFIG, CRIT,
2717 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2719 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2732 ucdata_unload( UCDATA_ALL );
2733 free( global_schemandn.bv_val );
2734 free( global_schemadn.bv_val );
2736 if ( slapd_args_file )
2737 free ( slapd_args_file );
2738 if ( slapd_pid_file )
2739 free ( slapd_pid_file );
2740 if ( default_passwd_hash )
2741 free( default_passwd_hash );
2742 acl_destroy( global_acl, NULL );
2754 if ( be->be_syncinfo ) {
2756 LDAP_LOG( CONFIG, INFO,
2757 "add_syncrepl: multiple syncrepl lines in a database "
2758 "definition are yet to be supported.\n", 0, 0, 0 );
2760 Debug( LDAP_DEBUG_ANY,
2761 "add_syncrepl: multiple syncrepl lines in a database "
2762 "definition are yet to be supported.\n", 0, 0, 0 );
2767 si = be->be_syncinfo = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2771 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2773 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2778 si->si_tls = SYNCINFO_TLS_OFF;
2779 if ( be->be_rootndn.bv_val ) {
2780 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2782 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2783 si->si_schemachecking = 0;
2784 ber_str2bv( "(objectclass=*)", sizeof("(objectclass=*)")-1, 0,
2785 &si->si_filterstr );
2786 if ( be->be_suffix && be->be_suffix[0].bv_val ) {
2787 ber_dupbv( &si->si_base, &be->be_nsuffix[0] );
2789 si->si_scope = LDAP_SCOPE_SUBTREE;
2790 si->si_attrsonly = 0;
2791 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
2792 si->si_attrs[0] = NULL;
2793 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2794 si->si_interval = 86400;
2795 si->si_syncCookie = NULL;
2796 si->si_manageDSAit = 0;
2799 si->si_syncUUID = NULL;
2800 si->si_syncUUID_ndn = NULL;
2801 si->si_sync_mode = LDAP_SYNC_STATE_MODE;
2803 si->si_presentlist = NULL;
2804 LDAP_LIST_INIT( &si->si_nonpresentlist );
2806 if ( parse_syncrepl_line( cargv, cargc, si ) < 0 ) {
2807 /* Something bad happened - back out */
2809 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2811 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2814 be->be_syncinfo = NULL;
2818 LDAP_LOG ( CONFIG, RESULTS,
2819 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
2820 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2822 Debug( LDAP_DEBUG_CONFIG,
2823 "Config: ** successfully added syncrepl \"%s\"\n",
2824 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2826 if ( !si->si_schemachecking ) {
2827 be->be_flags |= SLAP_BFLAG_NO_SCHEMA_CHECK;
2835 #define PROVIDERSTR "provider"
2836 #define SUFFIXSTR "suffix"
2837 #define UPDATEDNSTR "updatedn"
2838 #define BINDMETHSTR "bindmethod"
2839 #define SIMPLESTR "simple"
2840 #define SASLSTR "sasl"
2841 #define BINDDNSTR "binddn"
2842 #define CREDSTR "credentials"
2843 #define OLDAUTHCSTR "bindprincipal"
2844 #define AUTHCSTR "authcID"
2845 #define AUTHZSTR "authzID"
2846 #define SRVTABSTR "srvtab"
2847 #define SASLMECHSTR "saslmech"
2848 #define REALMSTR "realm"
2849 #define SECPROPSSTR "secprops"
2850 #define STARTTLSSTR "starttls"
2851 #define CRITICALSTR "critical"
2853 #define SCHEMASTR "schemachecking"
2854 #define FILTERSTR "filter"
2855 #define SEARCHBASESTR "searchbase"
2856 #define SCOPESTR "scope"
2857 #define ATTRSSTR "attrs"
2858 #define ATTRSONLYSTR "attrsonly"
2859 #define TYPESTR "type"
2860 #define INTERVALSTR "interval"
2861 #define COOKIESTR "cookie"
2862 #define LASTMODSTR "lastmod"
2863 #define LMREQSTR "req"
2864 #define LMGENSTR "gen"
2865 #define LMNOSTR "no"
2866 #define MANAGEDSAITSTR "manageDSAit"
2867 #define SLIMITSTR "sizelimit"
2868 #define TLIMITSTR "timelimit"
2870 #define GOT_ID 0x0001
2871 #define GOT_PROVIDER 0x0002
2872 #define GOT_METHOD 0x0004
2873 #define GOT_ALL 0x0007
2876 parse_syncrepl_line(
2887 for ( i = 1; i < cargc; i++ ) {
2888 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
2890 /* '\0' string terminator accounts for '=' */
2891 val = cargv[ i ] + sizeof( IDSTR );
2893 if ( tmp >= 1000 || tmp < 0 ) {
2894 fprintf( stderr, "Error: parse_syncrepl_line: "
2895 "syncrepl id %d is out of range [0..999]\n", tmp );
2900 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
2901 sizeof( PROVIDERSTR ) - 1 )) {
2902 val = cargv[ i ] + sizeof( PROVIDERSTR );
2903 si->si_provideruri = ch_strdup( val );
2904 si->si_provideruri_bv = (BerVarray)
2905 ch_calloc( 2, sizeof( struct berval ));
2906 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
2907 0, &si->si_provideruri_bv[0] );
2908 si->si_provideruri_bv[1].bv_len = 0;
2909 si->si_provideruri_bv[1].bv_val = NULL;
2910 gots |= GOT_PROVIDER;
2911 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
2912 sizeof(STARTTLSSTR) - 1 ) )
2914 val = cargv[ i ] + sizeof( STARTTLSSTR );
2915 if( !strcasecmp( val, CRITICALSTR ) ) {
2916 si->si_tls = SYNCINFO_TLS_CRITICAL;
2918 si->si_tls = SYNCINFO_TLS_ON;
2920 } else if ( !strncasecmp( cargv[ i ],
2921 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
2923 struct berval updatedn = {0, NULL};
2924 val = cargv[ i ] + sizeof( UPDATEDNSTR );
2925 ber_str2bv( val, 0, 0, &updatedn );
2926 ch_free( si->si_updatedn.bv_val );
2927 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
2928 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
2929 sizeof( BINDMETHSTR ) - 1 ) )
2931 val = cargv[ i ] + sizeof( BINDMETHSTR );
2932 if ( !strcasecmp( val, SIMPLESTR )) {
2933 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2935 } else if ( !strcasecmp( val, SASLSTR )) {
2936 #ifdef HAVE_CYRUS_SASL
2937 si->si_bindmethod = LDAP_AUTH_SASL;
2939 #else /* HAVE_CYRUS_SASL */
2940 fprintf( stderr, "Error: parse_syncrepl_line: "
2941 "not compiled with SASL support\n" );
2943 #endif /* HAVE_CYRUS_SASL */
2945 si->si_bindmethod = -1;
2947 } else if ( !strncasecmp( cargv[ i ],
2948 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
2949 val = cargv[ i ] + sizeof( BINDDNSTR );
2950 si->si_binddn = ch_strdup( val );
2951 } else if ( !strncasecmp( cargv[ i ],
2952 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
2953 val = cargv[ i ] + sizeof( CREDSTR );
2954 si->si_passwd = ch_strdup( val );
2955 } else if ( !strncasecmp( cargv[ i ],
2956 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
2957 val = cargv[ i ] + sizeof( SASLMECHSTR );
2958 si->si_saslmech = ch_strdup( val );
2959 } else if ( !strncasecmp( cargv[ i ],
2960 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
2961 val = cargv[ i ] + sizeof( SECPROPSSTR );
2962 si->si_secprops = ch_strdup( val );
2963 } else if ( !strncasecmp( cargv[ i ],
2964 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
2965 val = cargv[ i ] + sizeof( REALMSTR );
2966 si->si_realm = ch_strdup( val );
2967 } else if ( !strncasecmp( cargv[ i ],
2968 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
2969 val = cargv[ i ] + sizeof( AUTHCSTR );
2970 si->si_authcId = ch_strdup( val );
2971 } else if ( !strncasecmp( cargv[ i ],
2972 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
2973 /* Old authcID is provided for some backwards compatibility */
2974 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
2975 si->si_authcId = ch_strdup( val );
2976 } else if ( !strncasecmp( cargv[ i ],
2977 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
2978 val = cargv[ i ] + sizeof( AUTHZSTR );
2979 si->si_authzId = ch_strdup( val );
2980 } else if ( !strncasecmp( cargv[ i ],
2981 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
2983 val = cargv[ i ] + sizeof( SCHEMASTR );
2984 if ( !strncasecmp( val, "on", sizeof( "on" ) - 1 )) {
2985 si->si_schemachecking = 1;
2986 } else if ( !strncasecmp( val, "off", sizeof( "off" ) - 1 ) ) {
2987 si->si_schemachecking = 0;
2989 si->si_schemachecking = 1;
2991 } else if ( !strncasecmp( cargv[ i ],
2992 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
2994 val = cargv[ i ] + sizeof( FILTERSTR );
2995 ber_str2bv( val, 0, 1, &si->si_filterstr );
2996 } else if ( !strncasecmp( cargv[ i ],
2997 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3000 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3001 ch_free( si->si_base.bv_val );
3002 ber_str2bv( val, 0, 0, &bv );
3003 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3004 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3007 } else if ( !strncasecmp( cargv[ i ],
3008 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3010 val = cargv[ i ] + sizeof( SCOPESTR );
3011 if ( !strncasecmp( val, "base", sizeof( "base" ) - 1 )) {
3012 si->si_scope = LDAP_SCOPE_BASE;
3013 } else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
3014 si->si_scope = LDAP_SCOPE_ONELEVEL;
3015 } else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
3016 si->si_scope = LDAP_SCOPE_SUBTREE;
3018 fprintf( stderr, "Error: parse_syncrepl_line: "
3019 "unknown scope \"%s\"\n", val);
3022 } else if ( !strncasecmp( cargv[ i ],
3023 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3025 si->si_attrsonly = 1;
3026 } else if ( !strncasecmp( cargv[ i ],
3027 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3029 val = cargv[ i ] + sizeof( ATTRSSTR );
3030 str2clist( &si->si_attrs, val, "," );
3031 } else if ( !strncasecmp( cargv[ i ],
3032 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3034 val = cargv[ i ] + sizeof( TYPESTR );
3035 if ( !strncasecmp( val, "refreshOnly", sizeof("refreshOnly")-1 )) {
3036 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3037 } else if ( !strncasecmp( val, "refreshAndPersist",
3038 sizeof("refreshAndPersist")-1 ))
3040 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3041 si->si_interval = 60;
3043 fprintf( stderr, "Error: parse_syncrepl_line: "
3044 "unknown sync type \"%s\"\n", val);
3047 } else if ( !strncasecmp( cargv[ i ],
3048 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3053 val = cargv[ i ] + sizeof( INTERVALSTR );
3055 hstr = strchr( dstr, ':' );
3056 if ( hstr == NULL ) {
3057 fprintf( stderr, "Error: parse_syncrepl_line: "
3058 "invalid interval \"%s\"\n", val );
3062 mstr = strchr( hstr, ':' );
3063 if ( mstr == NULL ) {
3064 fprintf( stderr, "Error: parse_syncrepl_line: "
3065 "invalid interval \"%s\"\n", val );
3069 si->si_interval = (( atoi( dstr ) * 24 + atoi( hstr )) * 60
3070 + atoi( mstr )) * 60;
3072 if ( si->si_interval < 0 ) {
3073 fprintf( stderr, "Error: parse_syncrepl_line: "
3074 "invalid interval \"%ld\"\n",
3075 (long) si->si_interval);
3078 } else if ( !strncasecmp( cargv[ i ],
3079 COOKIESTR, sizeof( COOKIESTR ) - 1 ) )
3081 val = cargv[ i ] + sizeof( COOKIESTR );
3082 si->si_syncCookie = ber_str2bv( val, strlen( val ), 1, NULL );
3083 } else if ( !strncasecmp( cargv[ i ],
3084 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3086 val = cargv[ i ] + sizeof( COOKIESTR );
3087 si->si_manageDSAit = atoi( val );
3088 } else if ( !strncasecmp( cargv[ i ],
3089 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3091 val = cargv[ i ] + sizeof( SLIMITSTR );
3092 si->si_slimit = atoi( val );
3093 } else if ( !strncasecmp( cargv[ i ],
3094 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3096 val = cargv[ i ] + sizeof( TLIMITSTR );
3097 si->si_tlimit = atoi( val );
3099 fprintf( stderr, "Error: parse_syncrepl_line: "
3100 "unknown keyword \"%s\"\n", cargv[ i ] );
3104 if ( gots != GOT_ALL ) {
3106 "Error: Malformed \"syncrepl\" line in slapd config file" );
3114 str2clist( char ***out, char *in, const char *brkstr )
3123 /* find last element in list */
3124 for (i = 0; *out && *out[i]; i++);
3126 /* protect the input string from strtok */
3127 str = ch_strdup( in );
3129 if ( *str == '\0' ) {
3134 /* Count words in string */
3136 for ( s = str; *s; s++ ) {
3137 if ( strchr( brkstr, *s ) != NULL ) {
3142 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3144 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3146 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3148 *new = ch_strdup( s );