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;
77 int slapi_plugins_used = 0;
80 static char *fp_getline(FILE *fp, int *lineno);
81 static void fp_getline_init(int *lineno);
82 static int fp_parse_line(int lineno, char *line);
84 static char *strtok_quote(char *line, char *sep);
85 static int load_ucdata(char *path);
87 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
88 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
91 read_config( const char *fname, int depth )
94 char *line, *savefname, *saveline;
98 struct berval vals[2];
101 static int lastmod = 1;
102 static BackendInfo *bi = NULL;
103 static BackendDB *be = NULL;
105 vals[1].bv_val = NULL;
108 cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
109 cargv_size = ARGS_STEP + 1;
112 if ( (fp = fopen( fname, "r" )) == NULL ) {
115 LDAP_LOG( CONFIG, ENTRY,
116 "read_config: " "could not open config file \"%s\": %s (%d)\n",
117 fname, strerror(errno), errno );
119 Debug( LDAP_DEBUG_ANY,
120 "could not open config file \"%s\": %s (%d)\n",
121 fname, strerror(errno), errno );
127 LDAP_LOG( CONFIG, ENTRY,
128 "read_config: reading config file %s\n", fname, 0, 0 );
130 Debug( LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0 );
134 fp_getline_init( &lineno );
136 while ( (line = fp_getline( fp, &lineno )) != NULL ) {
137 /* skip comments and blank lines */
138 if ( line[0] == '#' || line[0] == '\0' ) {
142 /* fp_parse_line is destructive, we save a copy */
143 saveline = ch_strdup( line );
145 if ( fp_parse_line( lineno, line ) != 0 ) {
151 LDAP_LOG( CONFIG, INFO,
152 "%s: line %d: bad config line (ignored)\n", fname, lineno, 0 );
154 Debug( LDAP_DEBUG_ANY,
155 "%s: line %d: bad config line (ignored)\n",
162 if ( strcasecmp( cargv[0], "backend" ) == 0 ) {
165 LDAP_LOG( CONFIG, CRIT,
166 "%s : line %d: missing type in \"backend\" line.\n",
169 Debug( LDAP_DEBUG_ANY,
170 "%s: line %d: missing type in \"backend <type>\" line\n",
179 LDAP_LOG( CONFIG, CRIT,
180 "%s: line %d: backend line must appear before any "
181 "database definition.\n", fname, lineno , 0 );
183 Debug( LDAP_DEBUG_ANY,
184 "%s: line %d: backend line must appear before any database definition\n",
191 bi = backend_info( cargv[1] );
195 LDAP_LOG( CONFIG, CRIT,
196 "read_config: backend %s initialization failed.\n",
199 Debug( LDAP_DEBUG_ANY,
200 "backend %s initialization failed.\n",
206 } else if ( strcasecmp( cargv[0], "database" ) == 0 ) {
209 LDAP_LOG( CONFIG, CRIT,
210 "%s: line %d: missing type in \"database <type>\" line\n",
213 Debug( LDAP_DEBUG_ANY,
214 "%s: line %d: missing type in \"database <type>\" line\n",
222 be = backend_db_init( cargv[1] );
226 LDAP_LOG( CONFIG, CRIT,
227 "database %s initialization failed.\n", cargv[1], 0, 0 );
229 Debug( LDAP_DEBUG_ANY,
230 "database %s initialization failed.\n",
237 /* set thread concurrency */
238 } else if ( strcasecmp( cargv[0], "concurrency" ) == 0 ) {
242 LDAP_LOG( CONFIG, CRIT,
243 "%s: line %d: missing level in \"concurrency <level\" "
244 " line\n", fname, lineno, 0 );
246 Debug( LDAP_DEBUG_ANY,
247 "%s: line %d: missing level in \"concurrency <level>\" line\n",
254 c = atoi( cargv[1] );
258 LDAP_LOG( CONFIG, CRIT,
259 "%s: line %d: invalid level (%d) in "
260 "\"concurrency <level>\" line.\n", fname, lineno, c );
262 Debug( LDAP_DEBUG_ANY,
263 "%s: line %d: invalid level (%d) in \"concurrency <level>\" line\n",
270 ldap_pvt_thread_set_concurrency( c );
272 /* set sockbuf max */
273 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming" ) == 0 ) {
277 LDAP_LOG( CONFIG, CRIT,
278 "%s: line %d: missing max in \"sockbuf_max_incoming "
279 "<bytes>\" line\n", fname, lineno, 0 );
281 Debug( LDAP_DEBUG_ANY,
282 "%s: line %d: missing max in \"sockbuf_max_incoming <bytes>\" line\n",
289 max = atol( cargv[1] );
293 LDAP_LOG( CONFIG, CRIT,
294 "%s: line %d: invalid max value (%ld) in "
295 "\"sockbuf_max_incoming <bytes>\" line.\n",
296 fname, lineno, max );
298 Debug( LDAP_DEBUG_ANY,
299 "%s: line %d: invalid max value (%ld) in "
300 "\"sockbuf_max_incoming <bytes>\" line.\n",
301 fname, lineno, max );
307 sockbuf_max_incoming = max;
309 /* set sockbuf max authenticated */
310 } else if ( strcasecmp( cargv[0], "sockbuf_max_incoming_auth" ) == 0 ) {
314 LDAP_LOG( CONFIG, CRIT,
315 "%s: line %d: missing max in \"sockbuf_max_incoming_auth "
316 "<bytes>\" line\n", fname, lineno, 0 );
318 Debug( LDAP_DEBUG_ANY,
319 "%s: line %d: missing max in \"sockbuf_max_incoming_auth <bytes>\" line\n",
326 max = atol( cargv[1] );
330 LDAP_LOG( CONFIG, CRIT,
331 "%s: line %d: invalid max value (%ld) in "
332 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
333 fname, lineno, max );
335 Debug( LDAP_DEBUG_ANY,
336 "%s: line %d: invalid max value (%ld) in "
337 "\"sockbuf_max_incoming_auth <bytes>\" line.\n",
338 fname, lineno, max );
344 sockbuf_max_incoming_auth = max;
346 /* set conn pending max */
347 } else if ( strcasecmp( cargv[0], "conn_max_pending" ) == 0 ) {
351 LDAP_LOG( CONFIG, CRIT,
352 "%s: line %d: missing max in \"conn_max_pending "
353 "<requests>\" line\n", fname, lineno, 0 );
355 Debug( LDAP_DEBUG_ANY,
356 "%s: line %d: missing max in \"conn_max_pending <requests>\" line\n",
363 max = atol( cargv[1] );
367 LDAP_LOG( CONFIG, CRIT,
368 "%s: line %d: invalid max value (%ld) in "
369 "\"conn_max_pending <requests>\" line.\n",
370 fname, lineno, max );
372 Debug( LDAP_DEBUG_ANY,
373 "%s: line %d: invalid max value (%ld) in "
374 "\"conn_max_pending <requests>\" line.\n",
375 fname, lineno, max );
381 slap_conn_max_pending = max;
383 /* set conn pending max authenticated */
384 } else if ( strcasecmp( cargv[0], "conn_max_pending_auth" ) == 0 ) {
388 LDAP_LOG( CONFIG, CRIT,
389 "%s: line %d: missing max in \"conn_max_pending_auth "
390 "<requests>\" line\n", fname, lineno, 0 );
392 Debug( LDAP_DEBUG_ANY,
393 "%s: line %d: missing max in \"conn_max_pending_auth <requests>\" line\n",
400 max = atol( cargv[1] );
404 LDAP_LOG( CONFIG, CRIT,
405 "%s: line %d: invalid max value (%ld) in "
406 "\"conn_max_pending_auth <requests>\" line.\n",
407 fname, lineno, max );
409 Debug( LDAP_DEBUG_ANY,
410 "%s: line %d: invalid max value (%ld) in "
411 "\"conn_max_pending_auth <requests>\" line.\n",
412 fname, lineno, max );
418 slap_conn_max_pending_auth = max;
420 /* default search base */
421 } else if ( strcasecmp( cargv[0], "defaultSearchBase" ) == 0 ) {
424 LDAP_LOG( CONFIG, CRIT,
425 "%s: line %d: missing dn in \"defaultSearchBase <dn\" "
426 "line\n", fname, lineno, 0 );
428 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
429 "missing dn in \"defaultSearchBase <dn>\" line\n",
435 } else if ( cargc > 2 ) {
437 LDAP_LOG( CONFIG, INFO,
438 "%s: line %d: extra cruft after <dn> in "
439 "\"defaultSearchBase %s\" line (ignored)\n",
440 fname, lineno, cargv[1] );
442 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
443 "extra cruft after <dn> in \"defaultSearchBase %s\", "
445 fname, lineno, cargv[1] );
449 if ( bi != NULL || be != NULL ) {
451 LDAP_LOG( CONFIG, CRIT,
452 "%s: line %d: defaultSearchBase line must appear "
453 "prior to any backend or database definitions\n",
456 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
457 "defaultSearchBaase line must appear prior to "
458 "any backend or database definition\n",
465 if ( default_search_nbase.bv_len ) {
467 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
468 "default search base \"%s\" already defined "
469 "(discarding old)\n", fname, lineno,
470 default_search_base.bv_val );
472 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
473 "default search base \"%s\" already defined "
474 "(discarding old)\n",
475 fname, lineno, default_search_base.bv_val );
478 free( default_search_base.bv_val );
479 free( default_search_nbase.bv_val );
482 if ( load_ucdata( NULL ) < 0 ) return 1;
487 dn.bv_val = cargv[1];
488 dn.bv_len = strlen( dn.bv_val );
490 rc = dnPrettyNormal( NULL, &dn,
491 &default_search_base,
492 &default_search_nbase, NULL );
494 if( rc != LDAP_SUCCESS ) {
496 LDAP_LOG( CONFIG, CRIT,
497 "%s: line %d: defaultSearchBase DN is invalid.\n",
500 Debug( LDAP_DEBUG_ANY,
501 "%s: line %d: defaultSearchBase DN is invalid\n",
508 /* set maximum threads in thread pool */
509 } else if ( strcasecmp( cargv[0], "threads" ) == 0 ) {
513 LDAP_LOG( CONFIG, CRIT,
514 "%s: line %d: missing count in \"threads <count>\" line\n",
517 Debug( LDAP_DEBUG_ANY,
518 "%s: line %d: missing count in \"threads <count>\" line\n",
525 c = atoi( cargv[1] );
529 LDAP_LOG( CONFIG, CRIT,
530 "%s: line %d: invalid level (%d) in \"threads <count>\""
531 "line\n", fname, lineno, c );
533 Debug( LDAP_DEBUG_ANY,
534 "%s: line %d: invalid level (%d) in \"threads <count>\" line\n",
541 ldap_pvt_thread_pool_maxthreads( &connection_pool, c );
543 /* save for later use */
544 connection_pool_max = c;
546 /* get pid file name */
547 } else if ( strcasecmp( cargv[0], "pidfile" ) == 0 ) {
550 LDAP_LOG( CONFIG, CRIT,
551 "%s: line %d missing file name in \"pidfile <file>\" "
552 "line.\n", fname, lineno, 0 );
554 Debug( LDAP_DEBUG_ANY,
555 "%s: line %d: missing file name in \"pidfile <file>\" line\n",
562 slapd_pid_file = ch_strdup( cargv[1] );
564 /* get args file name */
565 } else if ( strcasecmp( cargv[0], "argsfile" ) == 0 ) {
568 LDAP_LOG( CONFIG, CRIT,
569 "%s: %d: missing file name in "
570 "\"argsfile <file>\" line.\n",
573 Debug( LDAP_DEBUG_ANY,
574 "%s: line %d: missing file name in \"argsfile <file>\" line\n",
581 slapd_args_file = ch_strdup( cargv[1] );
583 } else if ( strcasecmp( cargv[0], "replica-pidfile" ) == 0 ) {
586 } else if ( strcasecmp( cargv[0], "replica-argsfile" ) == 0 ) {
589 /* default password hash */
590 } else if ( strcasecmp( cargv[0], "password-hash" ) == 0 ) {
593 LDAP_LOG( CONFIG, CRIT,
594 "%s: line %d: missing hash in "
595 "\"password-hash <hash>\" line.\n",
598 Debug( LDAP_DEBUG_ANY,
599 "%s: line %d: missing hash in \"password-hash <hash>\" line\n",
605 if ( default_passwd_hash != NULL ) {
607 LDAP_LOG( CONFIG, CRIT,
608 "%s: line %d: already set default password_hash!\n",
611 Debug( LDAP_DEBUG_ANY,
612 "%s: line %d: already set default password_hash!\n",
620 if ( lutil_passwd_scheme( cargv[1] ) == 0 ) {
622 LDAP_LOG( CONFIG, CRIT,
623 "%s: line %d: password scheme \"%s\" not available\n",
624 fname, lineno, cargv[1] );
626 Debug( LDAP_DEBUG_ANY,
627 "%s: line %d: password scheme \"%s\" not available\n",
628 fname, lineno, cargv[1] );
633 default_passwd_hash = ch_strdup( cargv[1] );
635 } else if ( strcasecmp( cargv[0], "password-crypt-salt-format" ) == 0 )
639 LDAP_LOG( CONFIG, CRIT,
640 "%s: line %d: missing format in "
641 "\"password-crypt-salt-format <format>\" line\n",
644 Debug( LDAP_DEBUG_ANY, "%s: line %d: missing format in "
645 "\"password-crypt-salt-format <format>\" line\n",
652 lutil_salt_format( cargv[1] );
654 /* SASL config options */
655 } else if ( strncasecmp( cargv[0], "sasl", 4 ) == 0 ) {
656 if ( slap_sasl_config( cargc, cargv, line, fname, lineno ) )
659 } else if ( strcasecmp( cargv[0], "schemadn" ) == 0 ) {
663 LDAP_LOG( CONFIG, CRIT,
664 "%s: line %d: missing dn in "
665 "\"schemadn <dn>\" line.\n", fname, lineno, 0 );
667 Debug( LDAP_DEBUG_ANY,
668 "%s: line %d: missing dn in \"schemadn <dn>\" line\n",
673 ber_str2bv( cargv[1], 0, 0, &dn );
675 rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn,
676 &be->be_schemandn, NULL );
678 rc = dnPrettyNormal( NULL, &dn, &global_schemadn,
679 &global_schemandn, NULL );
681 if ( rc != LDAP_SUCCESS ) {
683 LDAP_LOG( CONFIG, CRIT,
684 "%s: line %d: schemadn DN is invalid.\n",
687 Debug( LDAP_DEBUG_ANY,
688 "%s: line %d: schemadn DN is invalid\n",
694 /* set UCDATA path */
695 } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
699 LDAP_LOG( CONFIG, CRIT,
700 "%s: line %d: missing path in "
701 "\"ucdata-path <path>\" line.\n", fname, lineno, 0 );
703 Debug( LDAP_DEBUG_ANY,
704 "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
711 err = load_ucdata( cargv[1] );
715 LDAP_LOG( CONFIG, CRIT,
716 "%s: line %d: ucdata already loaded, ucdata-path "
717 "must be set earlier in the file and/or be "
718 "specified only once!\n", fname, lineno, 0 );
720 Debug( LDAP_DEBUG_ANY,
721 "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
730 } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
732 struct slap_limits_set *lim;
736 LDAP_LOG( CONFIG, CRIT,
737 "%s: line %d: missing limit in \"sizelimit <limit>\" "
738 "line.\n", fname, lineno, 0 );
740 Debug( LDAP_DEBUG_ANY,
741 "%s: line %d: missing limit in \"sizelimit <limit>\" line\n",
751 lim = &be->be_def_limit;
754 for ( i = 1; i < cargc; i++ ) {
755 if ( strncasecmp( cargv[i], "size", 4 ) == 0 ) {
756 rc = parse_limit( cargv[i], lim );
759 LDAP_LOG( CONFIG, CRIT,
760 "%s: line %d: unable "
761 "to parse value \"%s\" in \"sizelimit "
762 "<limit>\" line.\n", fname, lineno, cargv[i] );
764 Debug( LDAP_DEBUG_ANY,
765 "%s: line %d: unable "
766 "to parse value \"%s\" "
769 fname, lineno, cargv[i] );
775 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
776 lim->lms_s_soft = -1;
780 lim->lms_s_soft = strtol( cargv[i] , &next, 0 );
781 if ( next == cargv[i] ) {
783 LDAP_LOG( CONFIG, CRIT,
784 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" "
785 "line.\n", fname, lineno, cargv[i] );
787 Debug( LDAP_DEBUG_ANY,
788 "%s: line %d: unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
789 fname, lineno, cargv[i] );
793 } else if ( next[0] != '\0' ) {
795 LDAP_LOG( CONFIG, CRIT,
796 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" "
797 "line ignored.\n", fname, lineno, next );
799 Debug( LDAP_DEBUG_ANY,
800 "%s: line %d: trailing chars \"%s\" in \"sizelimit <limit>\" line ignored\n",
801 fname, lineno, next );
810 } else if ( strcasecmp( cargv[0], "timelimit" ) == 0 ) {
812 struct slap_limits_set *lim;
816 LDAP_LOG( CONFIG, CRIT,
817 "%s: line %d missing limit in \"timelimit <limit>\" "
818 "line.\n", fname, lineno, 0 );
820 Debug( LDAP_DEBUG_ANY,
821 "%s: line %d: missing limit in \"timelimit <limit>\" line\n",
831 lim = &be->be_def_limit;
834 for ( i = 1; i < cargc; i++ ) {
835 if ( strncasecmp( cargv[i], "time", 4 ) == 0 ) {
836 rc = parse_limit( cargv[i], lim );
839 LDAP_LOG( CONFIG, CRIT,
840 "%s: line %d: unable to parse value \"%s\" "
841 "in \"timelimit <limit>\" line.\n",
842 fname, lineno, cargv[i] );
844 Debug( LDAP_DEBUG_ANY,
845 "%s: line %d: unable "
846 "to parse value \"%s\" "
849 fname, lineno, cargv[i] );
855 if ( strcasecmp( cargv[i], "unlimited" ) == 0 ) {
856 lim->lms_t_soft = -1;
860 lim->lms_t_soft = strtol( cargv[i] , &next, 0 );
861 if ( next == cargv[i] ) {
863 LDAP_LOG( CONFIG, CRIT,
864 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" "
865 "line.\n", fname, lineno, cargv[i] );
867 Debug( LDAP_DEBUG_ANY,
868 "%s: line %d: unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
869 fname, lineno, cargv[i] );
873 } else if ( next[0] != '\0' ) {
875 LDAP_LOG( CONFIG, CRIT,
876 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" "
877 "line ignored.\n", fname, lineno, next );
879 Debug( LDAP_DEBUG_ANY,
880 "%s: line %d: trailing chars \"%s\" in \"timelimit <limit>\" line ignored\n",
881 fname, lineno, next );
889 /* set regex-based limits */
890 } else if ( strcasecmp( cargv[0], "limits" ) == 0 ) {
893 LDAP_LOG( CONFIG, WARNING,
894 "%s: line %d \"limits\" allowed only in database "
895 "environment.\n", fname, lineno, 0 );
897 Debug( LDAP_DEBUG_ANY,
898 "%s: line %d \"limits\" allowed only in database environment.\n%s",
904 if ( parse_limits( be, fname, lineno, cargc, cargv ) ) {
908 /* mark this as a subordinate database */
909 } else if ( strcasecmp( cargv[0], "subordinate" ) == 0 ) {
912 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
913 "subordinate keyword must appear inside a database "
914 "definition.\n", fname, lineno, 0 );
916 Debug( LDAP_DEBUG_ANY, "%s: line %d: subordinate keyword "
917 "must appear inside a database definition.\n",
923 be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE;
927 /* add an overlay to this backend */
928 } else if ( strcasecmp( cargv[0], "overlay" ) == 0 ) {
931 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
932 "overlay keyword must appear inside a database "
933 "definition.\n", fname, lineno, 0 );
935 Debug( LDAP_DEBUG_ANY, "%s: line %d: overlay keyword "
936 "must appear inside a database definition.\n",
941 } else if ( overlay_config( be, cargv[1] )) {
945 /* set database suffix */
946 } else if ( strcasecmp( cargv[0], "suffix" ) == 0 ) {
948 struct berval dn, pdn, ndn;
952 LDAP_LOG( CONFIG, CRIT,
953 "%s: line %d: missing dn in \"suffix <dn>\" line.\n",
956 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
957 "missing dn in \"suffix <dn>\" line\n",
963 } else if ( cargc > 2 ) {
965 LDAP_LOG( CONFIG, INFO,
966 "%s: line %d: extra cruft after <dn> in \"suffix %s\""
967 " line (ignored).\n", fname, lineno, cargv[1] );
969 Debug( LDAP_DEBUG_ANY, "%s: line %d: extra cruft "
970 "after <dn> in \"suffix %s\" line (ignored)\n",
971 fname, lineno, cargv[1] );
977 LDAP_LOG( CONFIG, INFO,
978 "%s: line %d: suffix line must appear inside a database "
979 "definition.\n", fname, lineno, 0 );
981 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix line "
982 "must appear inside a database definition\n",
987 #if defined(SLAPD_MONITOR_DN)
988 /* "cn=Monitor" is reserved for monitoring slap */
989 } else if ( strcasecmp( cargv[1], SLAPD_MONITOR_DN ) == 0 ) {
991 LDAP_LOG( CONFIG, CRIT, "%s: line %d: \""
992 "%s\" is reserved for monitoring slapd\n",
993 fname, lineno, SLAPD_MONITOR_DN );
995 Debug( LDAP_DEBUG_ANY, "%s: line %d: \""
996 "%s\" is reserved for monitoring slapd\n",
997 fname, lineno, SLAPD_MONITOR_DN );
1000 #endif /* SLAPD_MONITOR_DN */
1003 if ( load_ucdata( NULL ) < 0 ) return 1;
1005 dn.bv_val = cargv[1];
1006 dn.bv_len = strlen( cargv[1] );
1008 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
1009 if( rc != LDAP_SUCCESS ) {
1011 LDAP_LOG( CONFIG, CRIT,
1012 "%s: line %d: suffix DN is invalid.\n",
1015 Debug( LDAP_DEBUG_ANY,
1016 "%s: line %d: suffix DN is invalid\n",
1022 tmp_be = select_backend( &ndn, 0, 0 );
1023 if ( tmp_be == be ) {
1025 LDAP_LOG( CONFIG, INFO,
1026 "%s: line %d: suffix already served by this backend "
1027 "(ignored)\n", fname, lineno, 0 );
1029 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1030 "already served by this backend (ignored)\n",
1036 } else if ( tmp_be != NULL ) {
1038 LDAP_LOG( CONFIG, INFO,
1039 "%s: line %d: suffix already served by a preceding "
1040 "backend \"%s\"\n", fname, lineno,
1041 tmp_be->be_suffix[0].bv_val );
1043 Debug( LDAP_DEBUG_ANY, "%s: line %d: suffix "
1044 "already served by a preceeding backend \"%s\"\n",
1045 fname, lineno, tmp_be->be_suffix[0].bv_val );
1051 } else if( pdn.bv_len == 0 && default_search_nbase.bv_len ) {
1053 LDAP_LOG( CONFIG, INFO,
1054 "%s: line %d: suffix DN empty and default search "
1055 "base provided \"%s\" (assuming okay).\n",
1056 fname, lineno, default_search_base.bv_val );
1058 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1059 "suffix DN empty and default "
1060 "search base provided \"%s\" (assuming okay)\n",
1061 fname, lineno, default_search_base.bv_val );
1065 ber_bvarray_add( &be->be_suffix, &pdn );
1066 ber_bvarray_add( &be->be_nsuffix, &ndn );
1068 /* set max deref depth */
1069 } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
1073 LDAP_LOG( CONFIG, CRIT,
1074 "%s: line %d: missing depth in \"maxDerefDepth <depth>\""
1075 " line\n", fname, lineno, 0 );
1077 Debug( LDAP_DEBUG_ANY,
1078 "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
1086 LDAP_LOG( CONFIG, INFO,
1087 "%s: line %d: depth line must appear inside a database "
1088 "definition.\n", fname, lineno ,0 );
1090 Debug( LDAP_DEBUG_ANY,
1091 "%s: line %d: depth line must appear inside a database definition.\n",
1096 } else if ((i = atoi(cargv[1])) < 0) {
1098 LDAP_LOG( CONFIG, INFO,
1099 "%s: line %d: depth must be positive.\n",
1102 Debug( LDAP_DEBUG_ANY,
1103 "%s: line %d: depth must be positive.\n",
1110 be->be_max_deref_depth = i;
1114 /* set magic "root" dn for this database */
1115 } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
1118 LDAP_LOG( CONFIG, INFO,
1119 "%s: line %d: missing dn in \"rootdn <dn>\" line.\n",
1122 Debug( LDAP_DEBUG_ANY,
1123 "%s: line %d: missing dn in \"rootdn <dn>\" line\n",
1132 LDAP_LOG( CONFIG, INFO,
1133 "%s: line %d: rootdn line must appear inside a database "
1134 "definition.\n", fname, lineno ,0 );
1136 Debug( LDAP_DEBUG_ANY,
1137 "%s: line %d: rootdn line must appear inside a database definition.\n",
1145 if ( load_ucdata( NULL ) < 0 ) return 1;
1147 dn.bv_val = cargv[1];
1148 dn.bv_len = strlen( cargv[1] );
1150 rc = dnPrettyNormal( NULL, &dn,
1152 &be->be_rootndn, NULL );
1154 if( rc != LDAP_SUCCESS ) {
1156 LDAP_LOG( CONFIG, CRIT,
1157 "%s: line %d: rootdn DN is invalid.\n",
1160 Debug( LDAP_DEBUG_ANY,
1161 "%s: line %d: rootdn DN is invalid\n",
1168 /* set super-secret magic database password */
1169 } else if ( strcasecmp( cargv[0], "rootpw" ) == 0 ) {
1172 LDAP_LOG( CONFIG, CRIT,
1173 "%s: line %d: missing passwd in \"rootpw <passwd>\""
1174 " line\n", fname, lineno ,0 );
1176 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1177 "missing passwd in \"rootpw <passwd>\" line\n",
1186 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1187 "rootpw line must appear inside a database "
1188 "definition.\n", fname, lineno ,0 );
1190 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1191 "rootpw line must appear inside a database "
1198 Backend *tmp_be = select_backend( &be->be_rootndn, 0, 0 );
1200 if( tmp_be != be ) {
1202 LDAP_LOG( CONFIG, INFO,
1204 "rootpw can only be set when rootdn is under suffix\n",
1205 fname, lineno, "" );
1207 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1208 "rootpw can only be set when rootdn is under suffix\n",
1214 be->be_rootpw.bv_val = ch_strdup( cargv[1] );
1215 be->be_rootpw.bv_len = strlen( be->be_rootpw.bv_val );
1218 /* make this database read-only */
1219 } else if ( strcasecmp( cargv[0], "readonly" ) == 0 ) {
1222 LDAP_LOG( CONFIG, CRIT,
1223 "%s: line %d: missing on|off in \"readonly <on|off>\" "
1224 "line.\n", fname, lineno ,0 );
1226 Debug( LDAP_DEBUG_ANY,
1227 "%s: line %d: missing on|off in \"readonly <on|off>\" line\n",
1234 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1235 global_restrictops |= SLAP_RESTRICT_OP_WRITES;
1237 global_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1240 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
1241 be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1243 be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1248 /* allow these features */
1249 } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
1250 strcasecmp( cargv[0], "allow" ) == 0 )
1256 LDAP_LOG( CONFIG, INFO,
1257 "%s: line %d: allow line must appear prior to "
1258 "database definitions.\n", fname, lineno ,0 );
1260 Debug( LDAP_DEBUG_ANY,
1261 "%s: line %d: allow line must appear prior to database definitions\n",
1269 LDAP_LOG( CONFIG, CRIT,
1270 "%s: line %d: missing feature(s) in \"allow <features>\""
1271 " line\n", fname, lineno ,0 );
1273 Debug( LDAP_DEBUG_ANY,
1274 "%s: line %d: missing feature(s) in \"allow <features>\" line\n",
1283 for( i=1; i < cargc; i++ ) {
1284 if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
1285 allows |= SLAP_ALLOW_BIND_V2;
1287 } else if( strcasecmp( cargv[i], "bind_anon_cred" ) == 0 ) {
1288 allows |= SLAP_ALLOW_BIND_ANON_CRED;
1290 } else if( strcasecmp( cargv[i], "bind_anon_dn" ) == 0 ) {
1291 allows |= SLAP_ALLOW_BIND_ANON_DN;
1293 } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
1294 allows |= SLAP_ALLOW_UPDATE_ANON;
1296 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1298 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1299 "unknown feature %s in \"allow <features>\" line.\n",
1300 fname, lineno, cargv[1] );
1302 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1303 "unknown feature %s in \"allow <features>\" line\n",
1304 fname, lineno, cargv[i] );
1311 global_allows = allows;
1313 /* disallow these features */
1314 } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
1315 strcasecmp( cargv[0], "disallow" ) == 0 )
1317 slap_mask_t disallows;
1321 LDAP_LOG( CONFIG, INFO,
1322 "%s: line %d: disallow line must appear prior to "
1323 "database definitions.\n", fname, lineno ,0 );
1325 Debug( LDAP_DEBUG_ANY,
1326 "%s: line %d: disallow line must appear prior to database definitions\n",
1334 LDAP_LOG( CONFIG, CRIT,
1335 "%s: line %d: missing feature(s) in \"disallow <features>\""
1336 " line.\n", fname, lineno ,0 );
1338 Debug( LDAP_DEBUG_ANY,
1339 "%s: line %d: missing feature(s) in \"disallow <features>\" line\n",
1348 for( i=1; i < cargc; i++ ) {
1349 if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
1350 disallows |= SLAP_DISALLOW_BIND_ANON;
1352 } else if( strcasecmp( cargv[i], "bind_simple" ) == 0 ) {
1353 disallows |= SLAP_DISALLOW_BIND_SIMPLE;
1355 } else if( strcasecmp( cargv[i], "bind_krbv4" ) == 0 ) {
1356 disallows |= SLAP_DISALLOW_BIND_KRBV4;
1358 } else if( strcasecmp( cargv[i], "tls_2_anon" ) == 0 ) {
1359 disallows |= SLAP_DISALLOW_TLS_2_ANON;
1361 } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
1362 disallows |= SLAP_DISALLOW_TLS_AUTHC;
1364 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1366 LDAP_LOG( CONFIG, CRIT,
1367 "%s: line %d: unknown feature %s in "
1368 "\"disallow <features>\" line.\n",
1369 fname, lineno, cargv[i] );
1371 Debug( LDAP_DEBUG_ANY,
1372 "%s: line %d: unknown feature %s in \"disallow <features>\" line\n",
1373 fname, lineno, cargv[i] );
1380 global_disallows = disallows;
1382 /* require these features */
1383 } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
1384 strcasecmp( cargv[0], "require" ) == 0 )
1386 slap_mask_t requires;
1390 LDAP_LOG( CONFIG, CRIT,
1391 "%s: line %d: missing feature(s) in "
1392 "\"require <features>\" line.\n", fname, lineno ,0 );
1394 Debug( LDAP_DEBUG_ANY,
1395 "%s: line %d: missing feature(s) in \"require <features>\" line\n",
1404 for( i=1; i < cargc; i++ ) {
1405 if( strcasecmp( cargv[i], "bind" ) == 0 ) {
1406 requires |= SLAP_REQUIRE_BIND;
1408 } else if( strcasecmp( cargv[i], "LDAPv3" ) == 0 ) {
1409 requires |= SLAP_REQUIRE_LDAP_V3;
1411 } else if( strcasecmp( cargv[i], "authc" ) == 0 ) {
1412 requires |= SLAP_REQUIRE_AUTHC;
1414 } else if( strcasecmp( cargv[i], "SASL" ) == 0 ) {
1415 requires |= SLAP_REQUIRE_SASL;
1417 } else if( strcasecmp( cargv[i], "strong" ) == 0 ) {
1418 requires |= SLAP_REQUIRE_STRONG;
1420 } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
1422 LDAP_LOG( CONFIG, CRIT,
1423 "%s: line %d: unknown feature %s in "
1424 "\"require <features>\" line.\n",
1425 fname, lineno , cargv[i] );
1427 Debug( LDAP_DEBUG_ANY,
1428 "%s: line %d: unknown feature %s in \"require <features>\" line\n",
1429 fname, lineno, cargv[i] );
1437 global_requires = requires;
1439 be->be_requires = requires;
1442 /* required security factors */
1443 } else if ( strcasecmp( cargv[0], "security" ) == 0 ) {
1444 slap_ssf_set_t *set;
1448 LDAP_LOG( CONFIG, CRIT,
1449 "%s: line %d: missing factor(s) in \"security <factors>\""
1450 " line.\n", fname, lineno ,0 );
1452 Debug( LDAP_DEBUG_ANY,
1453 "%s: line %d: missing factor(s) in \"security <factors>\" line\n",
1461 set = &global_ssf_set;
1463 set = &be->be_ssf_set;
1466 for( i=1; i < cargc; i++ ) {
1467 if( strncasecmp( cargv[i], "ssf=",
1468 sizeof("ssf") ) == 0 )
1471 atoi( &cargv[i][sizeof("ssf")] );
1473 } else if( strncasecmp( cargv[i], "transport=",
1474 sizeof("transport") ) == 0 )
1476 set->sss_transport =
1477 atoi( &cargv[i][sizeof("transport")] );
1479 } else if( strncasecmp( cargv[i], "tls=",
1480 sizeof("tls") ) == 0 )
1483 atoi( &cargv[i][sizeof("tls")] );
1485 } else if( strncasecmp( cargv[i], "sasl=",
1486 sizeof("sasl") ) == 0 )
1489 atoi( &cargv[i][sizeof("sasl")] );
1491 } else if( strncasecmp( cargv[i], "update_ssf=",
1492 sizeof("update_ssf") ) == 0 )
1494 set->sss_update_ssf =
1495 atoi( &cargv[i][sizeof("update_ssf")] );
1497 } else if( strncasecmp( cargv[i], "update_transport=",
1498 sizeof("update_transport") ) == 0 )
1500 set->sss_update_transport =
1501 atoi( &cargv[i][sizeof("update_transport")] );
1503 } else if( strncasecmp( cargv[i], "update_tls=",
1504 sizeof("update_tls") ) == 0 )
1506 set->sss_update_tls =
1507 atoi( &cargv[i][sizeof("update_tls")] );
1509 } else if( strncasecmp( cargv[i], "update_sasl=",
1510 sizeof("update_sasl") ) == 0 )
1512 set->sss_update_sasl =
1513 atoi( &cargv[i][sizeof("update_sasl")] );
1515 } else if( strncasecmp( cargv[i], "simple_bind=",
1516 sizeof("simple_bind") ) == 0 )
1518 set->sss_simple_bind =
1519 atoi( &cargv[i][sizeof("simple_bind")] );
1523 LDAP_LOG( CONFIG, CRIT,
1524 "%s: line %d: unknown factor %S in "
1525 "\"security <factors>\" line.\n",
1526 fname, lineno, cargv[1] );
1528 Debug( LDAP_DEBUG_ANY,
1529 "%s: line %d: unknown factor %s in \"security <factors>\" line\n",
1530 fname, lineno, cargv[i] );
1536 /* where to send clients when we don't hold it */
1537 } else if ( strcasecmp( cargv[0], "referral" ) == 0 ) {
1540 LDAP_LOG( CONFIG, CRIT,
1541 "%s: line %d: missing URL in \"referral <URL>\""
1542 " line.\n", fname, lineno , 0 );
1544 Debug( LDAP_DEBUG_ANY,
1545 "%s: line %d: missing URL in \"referral <URL>\" line\n",
1552 if( validate_global_referral( cargv[1] ) ) {
1554 LDAP_LOG( CONFIG, CRIT,
1555 "%s: line %d: invalid URL (%s) in \"referral\" line.\n",
1556 fname, lineno, cargv[1] );
1558 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1559 "invalid URL (%s) in \"referral\" line.\n",
1560 fname, lineno, cargv[1] );
1565 vals[0].bv_val = cargv[1];
1566 vals[0].bv_len = strlen( vals[0].bv_val );
1567 if( value_add( &default_referral, vals ) )
1571 } else if ( strcasecmp( cargv[0], "logfile" ) == 0 ) {
1575 LDAP_LOG( CONFIG, CRIT,
1576 "%s: line %d: Error in logfile directive, "
1577 "\"logfile <filename>\"\n", fname, lineno , 0 );
1579 Debug( LDAP_DEBUG_ANY,
1580 "%s: line %d: Error in logfile directive, \"logfile filename\"\n",
1586 logfile = fopen( cargv[1], "w" );
1587 if ( logfile != NULL ) lutil_debug_file( logfile );
1590 /* start of a new database definition */
1591 } else if ( strcasecmp( cargv[0], "debug" ) == 0 ) {
1595 LDAP_LOG( CONFIG, CRIT,
1596 "%s: line %d: Error in debug directive, "
1597 "\"debug <subsys> <level>\"\n", fname, lineno , 0 );
1599 Debug( LDAP_DEBUG_ANY,
1600 "%s: line %d: Error in debug directive, \"debug subsys level\"\n",
1606 level = atoi( cargv[2] );
1607 if ( level <= 0 ) level = lutil_mnem2level( cargv[2] );
1608 lutil_set_debug_level( cargv[1], level );
1609 /* specify an Object Identifier macro */
1610 } else if ( strcasecmp( cargv[0], "objectidentifier" ) == 0 ) {
1611 rc = parse_oidm( fname, lineno, cargc, cargv );
1614 /* specify an objectclass */
1615 } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
1618 LDAP_LOG( CONFIG, INFO,
1619 "%s: line %d: illegal objectclass format.\n",
1620 fname, lineno , 0 );
1622 Debug( LDAP_DEBUG_ANY,
1623 "%s: line %d: illegal objectclass format.\n",
1628 } else if ( *cargv[1] == '(' /*')'*/) {
1630 p = strchr(saveline,'(' /*')'*/);
1631 rc = parse_oc( fname, lineno, p, cargv );
1636 LDAP_LOG( CONFIG, INFO,
1637 "%s: line %d: old objectclass format not supported\n",
1638 fname, lineno , 0 );
1640 Debug( LDAP_DEBUG_ANY,
1641 "%s: line %d: old objectclass format not supported.\n",
1646 } else if ( strcasecmp( cargv[0], "ditcontentrule" ) == 0 ) {
1648 p = strchr(saveline,'(' /*')'*/);
1649 rc = parse_cr( fname, lineno, p, cargv );
1652 /* specify an attribute type */
1653 } else if (( strcasecmp( cargv[0], "attributetype" ) == 0 )
1654 || ( strcasecmp( cargv[0], "attribute" ) == 0 ))
1658 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
1659 "illegal attribute type format.\n",
1660 fname, lineno , 0 );
1662 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1663 "illegal attribute type format.\n",
1668 } else if ( *cargv[1] == '(' /*')'*/) {
1670 p = strchr(saveline,'(' /*')'*/);
1671 rc = parse_at( fname, lineno, p, cargv );
1676 LDAP_LOG( CONFIG, INFO,
1677 "%s: line %d: old attribute type format not supported.\n",
1678 fname, lineno , 0 );
1680 Debug( LDAP_DEBUG_ANY,
1681 "%s: line %d: old attribute type format not supported.\n",
1687 /* define attribute option(s) */
1688 } else if ( strcasecmp( cargv[0], "attributeoptions" ) == 0 ) {
1689 ad_define_option( NULL, NULL, 0 );
1690 for ( i = 1; i < cargc; i++ )
1691 if ( ad_define_option( cargv[i], fname, lineno ) != 0 )
1694 /* turn on/off schema checking */
1695 } else if ( strcasecmp( cargv[0], "schemacheck" ) == 0 ) {
1698 LDAP_LOG( CONFIG, CRIT,
1699 "%s: line %d: missing on|off in \"schemacheck <on|off>\""
1700 " line.\n", fname, lineno , 0 );
1702 Debug( LDAP_DEBUG_ANY,
1703 "%s: line %d: missing on|off in \"schemacheck <on|off>\" line\n",
1709 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
1711 LDAP_LOG( CONFIG, CRIT,
1712 "%s: line %d: schema checking disabled! your mileage may "
1713 "vary!\n", fname, lineno , 0 );
1715 Debug( LDAP_DEBUG_ANY,
1716 "%s: line %d: schema checking disabled! your mileage may vary!\n",
1719 global_schemacheck = 0;
1721 global_schemacheck = 1;
1724 /* specify access control info */
1725 } else if ( strcasecmp( cargv[0], "access" ) == 0 ) {
1726 parse_acl( be, fname, lineno, cargc, cargv );
1728 /* debug level to log things to syslog */
1729 } else if ( strcasecmp( cargv[0], "loglevel" ) == 0 ) {
1732 LDAP_LOG( CONFIG, CRIT,
1733 "%s: line %d: missing level in \"loglevel <level>\""
1734 " line.\n", fname, lineno , 0 );
1736 Debug( LDAP_DEBUG_ANY,
1737 "%s: line %d: missing level in \"loglevel <level>\" line\n",
1746 for( i=1; i < cargc; i++ ) {
1747 ldap_syslog += atoi( cargv[1] );
1750 /* list of sync replication information in this backend (slave only) */
1751 } else if ( strcasecmp( cargv[0], "syncrepl" ) == 0 ) {
1755 LDAP_LOG( CONFIG, INFO,
1756 "%s: line %d: syncrepl line must appear inside "
1757 "a database definition.\n", fname, lineno, 0);
1759 Debug( LDAP_DEBUG_ANY,
1760 "%s: line %d: syncrepl line must appear inside "
1761 "a database definition.\n", fname, lineno, 0);
1765 if ( add_syncrepl( be, cargv, cargc )) {
1770 /* list of replicas of the data in this backend (master only) */
1771 } else if ( strcasecmp( cargv[0], "replica" ) == 0 ) {
1774 LDAP_LOG( CONFIG, CRIT,
1775 "%s: line %d: missing host or uri in \"replica "
1776 " <host[:port]\" line\n", fname, lineno , 0 );
1778 Debug( LDAP_DEBUG_ANY,
1779 "%s: line %d: missing host or uri in \"replica <host[:port]>\" line\n",
1787 LDAP_LOG( CONFIG, INFO,
1788 "%s: line %d: replica line must appear inside "
1789 "a database definition.\n", fname, lineno, 0);
1791 Debug( LDAP_DEBUG_ANY,
1792 "%s: line %d: replica line must appear inside a database definition\n",
1800 for ( i = 1; i < cargc; i++ ) {
1801 if ( strncasecmp( cargv[i], "host=", 5 )
1803 nr = add_replica_info( be,
1806 } else if (strncasecmp( cargv[i], "uri=", 4 )
1808 if ( ldap_url_parse( cargv[ i ] + 4, &ludp )
1811 LDAP_LOG( CONFIG, INFO,
1812 "%s: line %d: replica line contains invalid "
1813 "uri definition.\n", fname, lineno, 0);
1815 Debug( LDAP_DEBUG_ANY,
1816 "%s: line %d: replica line contains invalid "
1817 "uri definition.\n", fname, lineno, 0);
1821 if (ludp->lud_host == NULL ) {
1823 LDAP_LOG( CONFIG, INFO,
1824 "%s: line %d: replica line contains invalid "
1825 "uri definition - missing hostname.\n",
1828 Debug( LDAP_DEBUG_ANY,
1829 "%s: line %d: replica line contains invalid "
1830 "uri definition - missing hostname.\n", fname, lineno, 0);
1834 replicahost = ch_malloc( strlen( cargv[ i ] ) );
1835 if ( replicahost == NULL ) {
1837 LDAP_LOG( CONFIG, ERR,
1838 "out of memory in read_config\n", 0, 0,0 );
1840 Debug( LDAP_DEBUG_ANY,
1841 "out of memory in read_config\n", 0, 0, 0 );
1843 ldap_free_urldesc( ludp );
1844 exit( EXIT_FAILURE );
1846 sprintf(replicahost, "%s:%d",
1847 ludp->lud_host, ludp->lud_port);
1848 nr = add_replica_info( be, replicahost );
1849 ldap_free_urldesc( ludp );
1850 ch_free(replicahost);
1856 LDAP_LOG( CONFIG, INFO,
1857 "%s: line %d: missing host or uri in \"replica\" line\n",
1858 fname, lineno , 0 );
1860 Debug( LDAP_DEBUG_ANY,
1861 "%s: line %d: missing host or uri in \"replica\" line\n",
1866 } else if ( nr == -1 ) {
1868 LDAP_LOG( CONFIG, INFO,
1869 "%s: line %d: unable to add"
1870 " replica \"%s\"\n",
1874 Debug( LDAP_DEBUG_ANY,
1875 "%s: line %d: unable to add replica \"%s\"\n",
1876 fname, lineno, cargv[i] + 5 );
1880 for ( i = 1; i < cargc; i++ ) {
1881 if ( strncasecmp( cargv[i], "suffix=", 7 ) == 0 ) {
1883 switch ( add_replica_suffix( be, nr, cargv[i] + 7 ) ) {
1886 LDAP_LOG( CONFIG, INFO,
1887 "%s: line %d: suffix \"%s\" in \"replica\""
1888 " line is not valid for backend(ignored)\n",
1889 fname, lineno, cargv[i] + 7 );
1891 Debug( LDAP_DEBUG_ANY,
1892 "%s: line %d: suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1893 fname, lineno, cargv[i] + 7 );
1899 LDAP_LOG( CONFIG, INFO,
1900 "%s: line %d: unable to normalize suffix"
1901 " in \"replica\" line (ignored)\n",
1902 fname, lineno , 0 );
1904 Debug( LDAP_DEBUG_ANY,
1905 "%s: line %d: unable to normalize suffix in \"replica\" line (ignored)\n",
1911 } else if ( strncasecmp( cargv[i], "attr", 4 ) == 0 ) {
1913 char *arg = cargv[i] + 4;
1915 if ( arg[0] == '!' ) {
1920 if ( arg[0] != '=' ) {
1924 if ( add_replica_attrs( be, nr, arg + 1, exclude ) ) {
1926 LDAP_LOG( CONFIG, INFO,
1927 "%s: line %d: attribute \"%s\" in "
1928 "\"replica\" line is unknown\n",
1929 fname, lineno, arg + 1 );
1931 Debug( LDAP_DEBUG_ANY,
1932 "%s: line %d: attribute \"%s\" in \"replica\" line is unknown\n",
1933 fname, lineno, arg + 1 );
1942 /* dn of master entity allowed to write to replica */
1943 } else if ( strcasecmp( cargv[0], "updatedn" ) == 0 ) {
1946 LDAP_LOG( CONFIG, CRIT,
1947 "%s: line %d: missing dn in \"updatedn <dn>\""
1948 " line.\n", fname, lineno , 0 );
1950 Debug( LDAP_DEBUG_ANY,
1951 "%s: line %d: missing dn in \"updatedn <dn>\" line\n",
1959 LDAP_LOG( CONFIG, INFO,
1960 "%s: line %d: updatedn line must appear inside "
1961 "a database definition\n",
1962 fname, lineno , 0 );
1964 Debug( LDAP_DEBUG_ANY,
1965 "%s: line %d: updatedn line must appear inside a database definition\n",
1973 if ( load_ucdata( NULL ) < 0 ) return 1;
1975 dn.bv_val = cargv[1];
1976 dn.bv_len = strlen( cargv[1] );
1978 rc = dnNormalize( 0, NULL, NULL, &dn, &be->be_update_ndn, NULL );
1979 if( rc != LDAP_SUCCESS ) {
1981 LDAP_LOG( CONFIG, CRIT,
1982 "%s: line %d: updatedn DN is invalid.\n",
1983 fname, lineno , 0 );
1985 Debug( LDAP_DEBUG_ANY,
1986 "%s: line %d: updatedn DN is invalid\n",
1993 } else if ( strcasecmp( cargv[0], "updateref" ) == 0 ) {
1996 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
1997 "missing url in \"updateref <ldapurl>\" line.\n",
1998 fname, lineno , 0 );
2000 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2001 "missing url in \"updateref <ldapurl>\" line\n",
2009 LDAP_LOG( CONFIG, INFO, "%s: line %d: updateref"
2010 " line must appear inside a database definition\n",
2011 fname, lineno , 0 );
2013 Debug( LDAP_DEBUG_ANY, "%s: line %d: updateref"
2014 " line must appear inside a database definition\n",
2019 } else if ( !be->be_update_ndn.bv_len ) {
2021 LDAP_LOG( CONFIG, INFO, "%s: line %d: "
2022 "updateref line must come after updatedn.\n",
2023 fname, lineno , 0 );
2025 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2026 "updateref line must after updatedn.\n",
2032 if( validate_global_referral( cargv[1] ) ) {
2034 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2035 "invalid URL (%s) in \"updateref\" line.\n",
2036 fname, lineno, cargv[1] );
2038 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2039 "invalid URL (%s) in \"updateref\" line.\n",
2040 fname, lineno, cargv[1] );
2045 vals[0].bv_val = cargv[1];
2046 vals[0].bv_len = strlen( vals[0].bv_val );
2047 if( value_add( &be->be_update_refs, vals ) )
2050 /* replication log file to which changes are appended */
2051 } else if ( strcasecmp( cargv[0], "replogfile" ) == 0 ) {
2054 LDAP_LOG( CONFIG, CRIT,
2055 "%s: line %d: missing filename in \"replogfile <filename>\""
2056 " line.\n", fname, lineno , 0 );
2058 Debug( LDAP_DEBUG_ANY,
2059 "%s: line %d: missing filename in \"replogfile <filename>\" line\n",
2066 be->be_replogfile = ch_strdup( cargv[1] );
2068 replogfile = ch_strdup( cargv[1] );
2071 /* file from which to read additional rootdse attrs */
2072 } else if ( strcasecmp( cargv[0], "rootDSE" ) == 0) {
2075 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2076 "missing filename in \"rootDSE <filename>\" line.\n",
2077 fname, lineno , 0 );
2079 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2080 "missing filename in \"rootDSE <filename>\" line.\n",
2086 if( read_root_dse_file( cargv[1] ) ) {
2088 LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
2089 "could not read \"rootDSE <filename>\" line.\n",
2090 fname, lineno , 0 );
2092 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
2093 "could not read \"rootDSE <filename>\" line\n",
2099 /* maintain lastmodified{by,time} attributes */
2100 } else if ( strcasecmp( cargv[0], "lastmod" ) == 0 ) {
2103 LDAP_LOG( CONFIG, CRIT,
2104 "%s: line %d: missing on|off in \"lastmod <on|off>\""
2105 " line.\n", fname, lineno , 0 );
2107 Debug( LDAP_DEBUG_ANY,
2108 "%s: line %d: missing on|off in \"lastmod <on|off>\" line\n",
2114 if ( strcasecmp( cargv[1], "on" ) == 0 ) {
2116 be->be_flags &= ~SLAP_BFLAG_NOLASTMOD;
2122 be->be_flags |= SLAP_BFLAG_NOLASTMOD;
2129 /* turn on/off gentle SIGHUP handling */
2130 } else if ( strcasecmp( cargv[0], "gentlehup" ) == 0 ) {
2132 Debug( LDAP_DEBUG_ANY,
2133 "%s: line %d: missing on|off in \"gentlehup <on|off>\" line\n",
2137 if ( strcasecmp( cargv[1], "off" ) == 0 ) {
2138 global_gentlehup = 0;
2140 global_gentlehup = 1;
2144 /* set idle timeout value */
2145 } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) {
2149 LDAP_LOG( CONFIG, CRIT,
2150 "%s: line %d: missing timeout value in "
2151 "\"idletimeout <seconds>\" line.\n", fname, lineno , 0 );
2153 Debug( LDAP_DEBUG_ANY,
2154 "%s: line %d: missing timeout value in \"idletimeout <seconds>\" line\n",
2161 i = atoi( cargv[1] );
2165 LDAP_LOG( CONFIG, CRIT,
2166 "%s: line %d: timeout value (%d) invalid "
2167 "\"idletimeout <seconds>\" line.\n", fname, lineno, i );
2169 Debug( LDAP_DEBUG_ANY,
2170 "%s: line %d: timeout value (%d) invalid \"idletimeout <seconds>\" line\n",
2177 global_idletimeout = i;
2179 /* include another config file */
2180 } else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
2183 LDAP_LOG( CONFIG, CRIT,
2184 "%s: line %d: missing filename in \"include "
2185 "<filename>\" line.\n", fname, lineno , 0 );
2187 Debug( LDAP_DEBUG_ANY,
2188 "%s: line %d: missing filename in \"include <filename>\" line\n",
2194 savefname = ch_strdup( cargv[1] );
2195 savelineno = lineno;
2197 if ( read_config( savefname, depth+1 ) != 0 ) {
2202 lineno = savelineno - 1;
2204 /* location of kerberos srvtab file */
2205 } else if ( strcasecmp( cargv[0], "srvtab" ) == 0 ) {
2208 LDAP_LOG( CONFIG, CRIT,
2209 "%s: line %d: missing filename in \"srvtab "
2210 "<filename>\" line.\n", fname, lineno , 0 );
2212 Debug( LDAP_DEBUG_ANY,
2213 "%s: line %d: missing filename in \"srvtab <filename>\" line\n",
2219 ldap_srvtab = ch_strdup( cargv[1] );
2221 #ifdef SLAPD_MODULES
2222 } else if (strcasecmp( cargv[0], "moduleload") == 0 ) {
2225 LDAP_LOG( CONFIG, INFO,
2226 "%s: line %d: missing filename in \"moduleload "
2227 "<filename>\" line.\n", fname, lineno , 0 );
2229 Debug( LDAP_DEBUG_ANY,
2230 "%s: line %d: missing filename in \"moduleload <filename>\" line\n",
2234 exit( EXIT_FAILURE );
2236 if (module_load(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
2238 LDAP_LOG( CONFIG, CRIT,
2239 "%s: line %d: failed to load or initialize module %s\n",
2240 fname, lineno, cargv[1] );
2242 Debug( LDAP_DEBUG_ANY,
2243 "%s: line %d: failed to load or initialize module %s\n",
2244 fname, lineno, cargv[1]);
2247 exit( EXIT_FAILURE );
2249 } else if (strcasecmp( cargv[0], "modulepath") == 0 ) {
2252 LDAP_LOG( CONFIG, INFO,
2253 "%s: line %d: missing path in \"modulepath <path>\""
2254 " line\n", fname, lineno , 0 );
2256 Debug( LDAP_DEBUG_ANY,
2257 "%s: line %d: missing path in \"modulepath <path>\" line\n",
2261 exit( EXIT_FAILURE );
2263 if (module_path( cargv[1] )) {
2265 LDAP_LOG( CONFIG, CRIT,
2266 "%s: line %d: failed to set module search path to %s.\n",
2267 fname, lineno, cargv[1] );
2269 Debug( LDAP_DEBUG_ANY,
2270 "%s: line %d: failed to set module search path to %s\n",
2271 fname, lineno, cargv[1]);
2274 exit( EXIT_FAILURE );
2277 #endif /*SLAPD_MODULES*/
2280 } else if ( !strcasecmp( cargv[0], "TLSRandFile" ) ) {
2281 rc = ldap_pvt_tls_set_option( NULL,
2282 LDAP_OPT_X_TLS_RANDOM_FILE,
2287 } else if ( !strcasecmp( cargv[0], "TLSCipherSuite" ) ) {
2288 rc = ldap_pvt_tls_set_option( NULL,
2289 LDAP_OPT_X_TLS_CIPHER_SUITE,
2294 } else if ( !strcasecmp( cargv[0], "TLSCertificateFile" ) ) {
2295 rc = ldap_pvt_tls_set_option( NULL,
2296 LDAP_OPT_X_TLS_CERTFILE,
2301 } else if ( !strcasecmp( cargv[0], "TLSCertificateKeyFile" ) ) {
2302 rc = ldap_pvt_tls_set_option( NULL,
2303 LDAP_OPT_X_TLS_KEYFILE,
2308 } else if ( !strcasecmp( cargv[0], "TLSCACertificatePath" ) ) {
2309 rc = ldap_pvt_tls_set_option( NULL,
2310 LDAP_OPT_X_TLS_CACERTDIR,
2315 } else if ( !strcasecmp( cargv[0], "TLSCACertificateFile" ) ) {
2316 rc = ldap_pvt_tls_set_option( NULL,
2317 LDAP_OPT_X_TLS_CACERTFILE,
2321 } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
2322 if ( isdigit( (unsigned char) cargv[1][0] ) ) {
2324 rc = ldap_pvt_tls_set_option( NULL,
2325 LDAP_OPT_X_TLS_REQUIRE_CERT,
2328 rc = ldap_int_tls_config( NULL,
2329 LDAP_OPT_X_TLS_REQUIRE_CERT,
2338 } else if ( !strcasecmp( cargv[0], "reverse-lookup" ) ) {
2339 #ifdef SLAPD_RLOOKUPS
2342 LDAP_LOG( CONFIG, INFO,
2343 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2344 fname, lineno , 0 );
2346 Debug( LDAP_DEBUG_ANY,
2347 "%s: line %d: reverse-lookup: missing \"on\" or \"off\"\n",
2353 if ( !strcasecmp( cargv[1], "on" ) ) {
2354 use_reverse_lookup = 1;
2355 } else if ( !strcasecmp( cargv[1], "off" ) ) {
2356 use_reverse_lookup = 0;
2359 LDAP_LOG( CONFIG, INFO,
2360 "%s: line %d: reverse-lookup: "
2361 "must be \"on\" (default) or \"off\"\n", fname, lineno, 0 );
2363 Debug( LDAP_DEBUG_ANY,
2364 "%s: line %d: reverse-lookup: must be \"on\" (default) or \"off\"\n",
2370 #else /* !SLAPD_RLOOKUPS */
2372 LDAP_LOG( CONFIG, INFO,
2373 "%s: line %d: reverse lookups "
2374 "are not configured (ignored).\n", fname, lineno , 0 );
2376 Debug( LDAP_DEBUG_ANY,
2377 "%s: line %d: reverse lookups are not configured (ignored).\n",
2380 #endif /* !SLAPD_RLOOKUPS */
2382 /* Netscape plugins */
2383 } else if ( strcasecmp( cargv[0], "plugin" ) == 0 ) {
2384 #if defined( LDAP_SLAPI )
2386 #ifdef notdef /* allow global plugins, too */
2388 * a "plugin" line must be inside a database
2389 * definition, since we implement pre-,post-
2390 * and extended operation plugins
2394 LDAP_LOG( CONFIG, INFO,
2395 "%s: line %d: plugin line must appear "
2396 "insid a database definition.\n",
2399 Debug( LDAP_DEBUG_ANY, "%s: line %d: plugin "
2400 "line must appear inside a database "
2401 "definition\n", fname, lineno, 0 );
2407 if ( netscape_plugin( be, fname, lineno, cargc, cargv )
2411 slapi_plugins_used++;
2413 #else /* !defined( LDAP_SLAPI ) */
2415 LDAP_LOG( CONFIG, INFO,
2416 "%s: line %d: SLAPI not supported.\n",
2419 Debug( LDAP_DEBUG_ANY, "%s: line %d: SLAPI "
2420 "not supported.\n", fname, lineno, 0 );
2424 #endif /* !defined( LDAP_SLAPI ) */
2426 /* Netscape plugins */
2427 } else if ( strcasecmp( cargv[0], "pluginlog" ) == 0 ) {
2428 #if defined( LDAP_SLAPI )
2431 LDAP_LOG( CONFIG, INFO,
2432 "%s: line %d: missing file name "
2433 "in pluginlog <filename> line.\n",
2436 Debug( LDAP_DEBUG_ANY,
2437 "%s: line %d: missing file name "
2438 "in pluginlog <filename> line.\n",
2444 if ( slapi_log_file != NULL ) {
2445 ch_free( slapi_log_file );
2448 slapi_log_file = ch_strdup( cargv[1] );
2449 #endif /* !defined( LDAP_SLAPI ) */
2451 /* pass anything else to the current backend info/db config routine */
2454 if ( bi->bi_config == 0 ) {
2456 LDAP_LOG( CONFIG, INFO,
2457 "%s: line %d: unknown directive \"%s\" inside "
2458 "backend info definition (ignored).\n",
2459 fname, lineno, cargv[0] );
2461 Debug( LDAP_DEBUG_ANY,
2462 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
2463 fname, lineno, cargv[0] );
2467 if ( (*bi->bi_config)( bi, fname, lineno, cargc, cargv )
2473 } else if ( be != NULL ) {
2474 if ( be->be_config == 0 ) {
2476 LDAP_LOG( CONFIG, INFO,
2477 "%s: line %d: uknown directive \"%s\" inside "
2478 "backend database definition (ignored).\n",
2479 fname, lineno, cargv[0] );
2481 Debug( LDAP_DEBUG_ANY,
2482 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
2483 fname, lineno, cargv[0] );
2487 if ( (*be->be_config)( be, fname, lineno, cargc, cargv )
2495 LDAP_LOG( CONFIG, INFO,
2496 "%s: line %d: unknown directive \"%s\" outside backend "
2497 "info and database definitions (ignored).\n",
2498 fname, lineno, cargv[0] );
2500 Debug( LDAP_DEBUG_ANY,
2501 "%s: line %d: unknown directive \"%s\" outside backend info and database definitions (ignored)\n",
2502 fname, lineno, cargv[0] );
2511 if ( depth == 0 ) ch_free( cargv );
2513 if ( !global_schemadn.bv_val ) {
2514 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
2516 dnNormalize( 0, NULL, NULL, &global_schemadn, &global_schemandn, NULL );
2519 if ( load_ucdata( NULL ) < 0 ) return 1;
2531 char logbuf[sizeof("pseudorootpw ***")];
2534 token = strtok_quote( line, " \t" );
2538 if ( token && ( strcasecmp( token, "rootpw" ) == 0 ||
2539 strcasecmp( token, "replica" ) == 0 || /* contains "credentials" */
2540 strcasecmp( token, "bindpw" ) == 0 || /* used in back-ldap */
2541 strcasecmp( token, "pseudorootpw" ) == 0 || /* used in back-meta */
2542 strcasecmp( token, "dbpasswd" ) == 0 ) ) /* used in back-sql */
2544 snprintf( logline = logbuf, sizeof logbuf, "%s ***", token );
2547 if ( strtok_quote_ptr ) {
2548 *strtok_quote_ptr = ' ';
2552 LDAP_LOG( CONFIG, DETAIL1, "line %d (%s)\n", lineno, logline , 0 );
2554 Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, logline, 0 );
2557 if ( strtok_quote_ptr ) {
2558 *strtok_quote_ptr = '\0';
2561 for ( ; token != NULL; token = strtok_quote( NULL, " \t" ) ) {
2562 if ( cargc == cargv_size - 1 ) {
2564 tmp = ch_realloc( cargv, (cargv_size + ARGS_STEP) *
2566 if ( tmp == NULL ) {
2568 LDAP_LOG( CONFIG, ERR, "line %d: out of memory\n", lineno, 0,0 );
2570 Debug( LDAP_DEBUG_ANY,
2571 "line %d: out of memory\n",
2577 cargv_size += ARGS_STEP;
2579 cargv[cargc++] = token;
2581 cargv[cargc] = NULL;
2586 strtok_quote( char *line, char *sep )
2592 strtok_quote_ptr = NULL;
2593 if ( line != NULL ) {
2596 while ( *next && strchr( sep, *next ) ) {
2600 if ( *next == '\0' ) {
2606 for ( inquote = 0; *next; ) {
2614 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
2620 next + 1, strlen( next + 1 ) + 1 );
2621 next++; /* dont parse the escaped character */
2626 if ( strchr( sep, *next ) != NULL ) {
2627 strtok_quote_ptr = next;
2640 static char buf[BUFSIZ];
2642 static size_t lmax, lcur;
2644 #define CATLINE( buf ) \
2646 size_t len = strlen( buf ); \
2647 while ( lcur + len + 1 > lmax ) { \
2649 line = (char *) ch_realloc( line, lmax ); \
2651 strcpy( line + lcur, buf ); \
2656 fp_getline( FILE *fp, int *lineno )
2664 /* hack attack - keeps us from having to keep a stack of bufs... */
2665 if ( strncasecmp( line, "include", 7 ) == 0 ) {
2670 while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
2671 /* trim off \r\n or \n */
2672 if ( (p = strchr( buf, '\n' )) != NULL ) {
2673 if( p > buf && p[-1] == '\r' ) --p;
2677 /* trim off trailing \ and append the next line */
2678 if ( line[ 0 ] != '\0'
2679 && (p = line + strlen( line ) - 1)[ 0 ] == '\\'
2680 && p[ -1 ] != '\\' ) {
2685 if ( ! isspace( (unsigned char) buf[0] ) ) {
2689 /* change leading whitespace to a space */
2698 return( line[0] ? line : NULL );
2702 fp_getline_init( int *lineno )
2708 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
2710 load_ucdata( char *path )
2712 static int loaded = 0;
2718 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
2721 LDAP_LOG( CONFIG, CRIT,
2722 "load_ucdata: Error %d loading ucdata.\n", err, 0,0 );
2724 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
2737 ucdata_unload( UCDATA_ALL );
2738 free( global_schemandn.bv_val );
2739 free( global_schemadn.bv_val );
2741 if ( slapd_args_file )
2742 free ( slapd_args_file );
2743 if ( slapd_pid_file )
2744 free ( slapd_pid_file );
2745 if ( default_passwd_hash )
2746 free( default_passwd_hash );
2747 acl_destroy( global_acl, NULL );
2759 if ( be->be_syncinfo ) {
2761 LDAP_LOG( CONFIG, INFO,
2762 "add_syncrepl: multiple syncrepl lines in a database "
2763 "definition are yet to be supported.\n", 0, 0, 0 );
2765 Debug( LDAP_DEBUG_ANY,
2766 "add_syncrepl: multiple syncrepl lines in a database "
2767 "definition are yet to be supported.\n", 0, 0, 0 );
2772 si = be->be_syncinfo = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2776 LDAP_LOG( CONFIG, ERR, "out of memory in add_syncrepl\n", 0, 0,0 );
2778 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2783 si->si_tls = SYNCINFO_TLS_OFF;
2784 if ( be->be_rootndn.bv_val ) {
2785 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
2787 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2788 si->si_schemachecking = 0;
2789 ber_str2bv( "(objectclass=*)", sizeof("(objectclass=*)")-1, 0,
2790 &si->si_filterstr );
2791 if ( be->be_suffix && be->be_suffix[0].bv_val ) {
2792 ber_dupbv( &si->si_base, &be->be_nsuffix[0] );
2794 si->si_scope = LDAP_SCOPE_SUBTREE;
2795 si->si_attrsonly = 0;
2796 si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
2797 si->si_attrs[0] = NULL;
2798 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2799 si->si_interval = 86400;
2800 si->si_syncCookie.ctxcsn = NULL;
2801 si->si_syncCookie.octet_str = NULL;
2802 si->si_syncCookie.sid = -1;
2803 si->si_manageDSAit = 0;
2806 si->si_syncUUID_ndn.bv_val = NULL;
2807 si->si_syncUUID_ndn.bv_len = 0;
2809 si->si_presentlist = NULL;
2810 LDAP_LIST_INIT( &si->si_nonpresentlist );
2812 if ( parse_syncrepl_line( cargv, cargc, si ) < 0 ) {
2813 /* Something bad happened - back out */
2815 LDAP_LOG( CONFIG, ERR, "failed to add syncinfo\n", 0, 0,0 );
2817 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2820 be->be_syncinfo = NULL;
2824 LDAP_LOG ( CONFIG, RESULTS,
2825 "add_syncrepl: Config: ** successfully added syncrepl \"%s\"\n",
2826 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2828 Debug( LDAP_DEBUG_CONFIG,
2829 "Config: ** successfully added syncrepl \"%s\"\n",
2830 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
2832 if ( !si->si_schemachecking ) {
2833 be->be_flags |= SLAP_BFLAG_NO_SCHEMA_CHECK;
2841 #define PROVIDERSTR "provider"
2842 #define SUFFIXSTR "suffix"
2843 #define UPDATEDNSTR "updatedn"
2844 #define BINDMETHSTR "bindmethod"
2845 #define SIMPLESTR "simple"
2846 #define SASLSTR "sasl"
2847 #define BINDDNSTR "binddn"
2848 #define CREDSTR "credentials"
2849 #define OLDAUTHCSTR "bindprincipal"
2850 #define AUTHCSTR "authcID"
2851 #define AUTHZSTR "authzID"
2852 #define SRVTABSTR "srvtab"
2853 #define SASLMECHSTR "saslmech"
2854 #define REALMSTR "realm"
2855 #define SECPROPSSTR "secprops"
2856 #define STARTTLSSTR "starttls"
2857 #define CRITICALSTR "critical"
2859 #define SCHEMASTR "schemachecking"
2860 #define FILTERSTR "filter"
2861 #define SEARCHBASESTR "searchbase"
2862 #define SCOPESTR "scope"
2863 #define ATTRSSTR "attrs"
2864 #define ATTRSONLYSTR "attrsonly"
2865 #define TYPESTR "type"
2866 #define INTERVALSTR "interval"
2867 #define LASTMODSTR "lastmod"
2868 #define LMREQSTR "req"
2869 #define LMGENSTR "gen"
2870 #define LMNOSTR "no"
2871 #define MANAGEDSAITSTR "manageDSAit"
2872 #define SLIMITSTR "sizelimit"
2873 #define TLIMITSTR "timelimit"
2875 #define GOT_ID 0x0001
2876 #define GOT_PROVIDER 0x0002
2877 #define GOT_METHOD 0x0004
2878 #define GOT_ALL 0x0007
2881 parse_syncrepl_line(
2892 for ( i = 1; i < cargc; i++ ) {
2893 if ( !strncasecmp( cargv[ i ], IDSTR, sizeof( IDSTR ) - 1 )) {
2895 /* '\0' string terminator accounts for '=' */
2896 val = cargv[ i ] + sizeof( IDSTR );
2898 if ( tmp >= 1000 || tmp < 0 ) {
2899 fprintf( stderr, "Error: parse_syncrepl_line: "
2900 "syncrepl id %d is out of range [0..999]\n", tmp );
2905 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR,
2906 sizeof( PROVIDERSTR ) - 1 )) {
2907 val = cargv[ i ] + sizeof( PROVIDERSTR );
2908 si->si_provideruri = ch_strdup( val );
2909 si->si_provideruri_bv = (BerVarray)
2910 ch_calloc( 2, sizeof( struct berval ));
2911 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
2912 0, &si->si_provideruri_bv[0] );
2913 si->si_provideruri_bv[1].bv_len = 0;
2914 si->si_provideruri_bv[1].bv_val = NULL;
2915 gots |= GOT_PROVIDER;
2916 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR,
2917 sizeof(STARTTLSSTR) - 1 ) )
2919 val = cargv[ i ] + sizeof( STARTTLSSTR );
2920 if( !strcasecmp( val, CRITICALSTR ) ) {
2921 si->si_tls = SYNCINFO_TLS_CRITICAL;
2923 si->si_tls = SYNCINFO_TLS_ON;
2925 } else if ( !strncasecmp( cargv[ i ],
2926 UPDATEDNSTR, sizeof( UPDATEDNSTR ) - 1 ) )
2928 struct berval updatedn = {0, NULL};
2929 val = cargv[ i ] + sizeof( UPDATEDNSTR );
2930 ber_str2bv( val, 0, 0, &updatedn );
2931 ch_free( si->si_updatedn.bv_val );
2932 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
2933 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR,
2934 sizeof( BINDMETHSTR ) - 1 ) )
2936 val = cargv[ i ] + sizeof( BINDMETHSTR );
2937 if ( !strcasecmp( val, SIMPLESTR )) {
2938 si->si_bindmethod = LDAP_AUTH_SIMPLE;
2940 } else if ( !strcasecmp( val, SASLSTR )) {
2941 #ifdef HAVE_CYRUS_SASL
2942 si->si_bindmethod = LDAP_AUTH_SASL;
2944 #else /* HAVE_CYRUS_SASL */
2945 fprintf( stderr, "Error: parse_syncrepl_line: "
2946 "not compiled with SASL support\n" );
2948 #endif /* HAVE_CYRUS_SASL */
2950 si->si_bindmethod = -1;
2952 } else if ( !strncasecmp( cargv[ i ],
2953 BINDDNSTR, sizeof( BINDDNSTR ) - 1 ) ) {
2954 val = cargv[ i ] + sizeof( BINDDNSTR );
2955 si->si_binddn = ch_strdup( val );
2956 } else if ( !strncasecmp( cargv[ i ],
2957 CREDSTR, sizeof( CREDSTR ) - 1 ) ) {
2958 val = cargv[ i ] + sizeof( CREDSTR );
2959 si->si_passwd = ch_strdup( val );
2960 } else if ( !strncasecmp( cargv[ i ],
2961 SASLMECHSTR, sizeof( SASLMECHSTR ) - 1 ) ) {
2962 val = cargv[ i ] + sizeof( SASLMECHSTR );
2963 si->si_saslmech = ch_strdup( val );
2964 } else if ( !strncasecmp( cargv[ i ],
2965 SECPROPSSTR, sizeof( SECPROPSSTR ) - 1 ) ) {
2966 val = cargv[ i ] + sizeof( SECPROPSSTR );
2967 si->si_secprops = ch_strdup( val );
2968 } else if ( !strncasecmp( cargv[ i ],
2969 REALMSTR, sizeof( REALMSTR ) - 1 ) ) {
2970 val = cargv[ i ] + sizeof( REALMSTR );
2971 si->si_realm = ch_strdup( val );
2972 } else if ( !strncasecmp( cargv[ i ],
2973 AUTHCSTR, sizeof( AUTHCSTR ) - 1 ) ) {
2974 val = cargv[ i ] + sizeof( AUTHCSTR );
2975 si->si_authcId = ch_strdup( val );
2976 } else if ( !strncasecmp( cargv[ i ],
2977 OLDAUTHCSTR, sizeof( OLDAUTHCSTR ) - 1 ) ) {
2978 /* Old authcID is provided for some backwards compatibility */
2979 val = cargv[ i ] + sizeof( OLDAUTHCSTR );
2980 si->si_authcId = ch_strdup( val );
2981 } else if ( !strncasecmp( cargv[ i ],
2982 AUTHZSTR, sizeof( AUTHZSTR ) - 1 ) ) {
2983 val = cargv[ i ] + sizeof( AUTHZSTR );
2984 si->si_authzId = ch_strdup( val );
2985 } else if ( !strncasecmp( cargv[ i ],
2986 SCHEMASTR, sizeof( SCHEMASTR ) - 1 ) )
2988 val = cargv[ i ] + sizeof( SCHEMASTR );
2989 if ( !strncasecmp( val, "on", sizeof( "on" ) - 1 )) {
2990 si->si_schemachecking = 1;
2991 } else if ( !strncasecmp( val, "off", sizeof( "off" ) - 1 ) ) {
2992 si->si_schemachecking = 0;
2994 si->si_schemachecking = 1;
2996 } else if ( !strncasecmp( cargv[ i ],
2997 FILTERSTR, sizeof( FILTERSTR ) - 1 ) )
2999 val = cargv[ i ] + sizeof( FILTERSTR );
3000 ber_str2bv( val, 0, 1, &si->si_filterstr );
3001 } else if ( !strncasecmp( cargv[ i ],
3002 SEARCHBASESTR, sizeof( SEARCHBASESTR ) - 1 ) )
3005 val = cargv[ i ] + sizeof( SEARCHBASESTR );
3006 ch_free( si->si_base.bv_val );
3007 ber_str2bv( val, 0, 0, &bv );
3008 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
3009 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
3012 } else if ( !strncasecmp( cargv[ i ],
3013 SCOPESTR, sizeof( SCOPESTR ) - 1 ) )
3015 val = cargv[ i ] + sizeof( SCOPESTR );
3016 if ( !strncasecmp( val, "base", sizeof( "base" ) - 1 )) {
3017 si->si_scope = LDAP_SCOPE_BASE;
3018 } else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
3019 si->si_scope = LDAP_SCOPE_ONELEVEL;
3020 } else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
3021 si->si_scope = LDAP_SCOPE_SUBTREE;
3023 fprintf( stderr, "Error: parse_syncrepl_line: "
3024 "unknown scope \"%s\"\n", val);
3027 } else if ( !strncasecmp( cargv[ i ],
3028 ATTRSONLYSTR, sizeof( ATTRSONLYSTR ) - 1 ) )
3030 si->si_attrsonly = 1;
3031 } else if ( !strncasecmp( cargv[ i ],
3032 ATTRSSTR, sizeof( ATTRSSTR ) - 1 ) )
3034 val = cargv[ i ] + sizeof( ATTRSSTR );
3035 str2clist( &si->si_attrs, val, "," );
3036 } else if ( !strncasecmp( cargv[ i ],
3037 TYPESTR, sizeof( TYPESTR ) - 1 ) )
3039 val = cargv[ i ] + sizeof( TYPESTR );
3040 if ( !strncasecmp( val, "refreshOnly", sizeof("refreshOnly")-1 )) {
3041 si->si_type = LDAP_SYNC_REFRESH_ONLY;
3042 } else if ( !strncasecmp( val, "refreshAndPersist",
3043 sizeof("refreshAndPersist")-1 ))
3045 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
3046 si->si_interval = 60;
3048 fprintf( stderr, "Error: parse_syncrepl_line: "
3049 "unknown sync type \"%s\"\n", val);
3052 } else if ( !strncasecmp( cargv[ i ],
3053 INTERVALSTR, sizeof( INTERVALSTR ) - 1 ) )
3055 val = cargv[ i ] + sizeof( INTERVALSTR );
3056 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
3057 si->si_interval = 0;
3065 hstr = strchr( dstr, ':' );
3066 if ( hstr == NULL ) {
3067 fprintf( stderr, "Error: parse_syncrepl_line: "
3068 "invalid interval \"%s\"\n", val );
3072 mstr = strchr( hstr, ':' );
3073 if ( mstr == NULL ) {
3074 fprintf( stderr, "Error: parse_syncrepl_line: "
3075 "invalid interval \"%s\"\n", val );
3079 sstr = strchr( mstr, ':' );
3080 if ( sstr == NULL ) {
3081 fprintf( stderr, "Error: parse_syncrepl_line: "
3082 "invalid interval \"%s\"\n", val );
3091 if (( hh > 24 ) || ( hh < 0 ) ||
3092 ( mm > 60 ) || ( mm < 0 ) ||
3093 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
3094 fprintf( stderr, "Error: parse_syncrepl_line: "
3095 "invalid interval \"%s\"\n", val );
3098 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
3100 if ( si->si_interval < 0 ) {
3101 fprintf( stderr, "Error: parse_syncrepl_line: "
3102 "invalid interval \"%ld\"\n",
3103 (long) si->si_interval);
3106 } else if ( !strncasecmp( cargv[ i ],
3107 MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
3109 val = cargv[ i ] + sizeof( MANAGEDSAITSTR );
3110 si->si_manageDSAit = atoi( val );
3111 } else if ( !strncasecmp( cargv[ i ],
3112 SLIMITSTR, sizeof( SLIMITSTR ) - 1 ) )
3114 val = cargv[ i ] + sizeof( SLIMITSTR );
3115 si->si_slimit = atoi( val );
3116 } else if ( !strncasecmp( cargv[ i ],
3117 TLIMITSTR, sizeof( TLIMITSTR ) - 1 ) )
3119 val = cargv[ i ] + sizeof( TLIMITSTR );
3120 si->si_tlimit = atoi( val );
3122 fprintf( stderr, "Error: parse_syncrepl_line: "
3123 "unknown keyword \"%s\"\n", cargv[ i ] );
3127 if ( gots != GOT_ALL ) {
3129 "Error: Malformed \"syncrepl\" line in slapd config file" );
3137 str2clist( char ***out, char *in, const char *brkstr )
3146 /* find last element in list */
3147 for (i = 0; *out && *out[i]; i++);
3149 /* protect the input string from strtok */
3150 str = ch_strdup( in );
3152 if ( *str == '\0' ) {
3157 /* Count words in string */
3159 for ( s = str; *s; s++ ) {
3160 if ( strchr( brkstr, *s ) != NULL ) {
3165 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
3167 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
3169 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
3171 *new = ch_strdup( s );