1 /* config.c - configuration file handling routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
31 #include <ac/string.h>
33 #include <ac/signal.h>
34 #include <ac/socket.h>
39 #include "slapi/slapi.h"
47 * defaults for various global variables
49 slap_mask_t global_allows = 0;
50 slap_mask_t global_disallows = 0;
51 int global_gentlehup = 0;
52 int global_idletimeout = 0;
53 char *global_host = NULL;
54 char *global_realm = NULL;
55 char *ldap_srvtab = "";
56 char **default_passwd_hash = NULL;
57 struct berval default_search_base = BER_BVNULL;
58 struct berval default_search_nbase = BER_BVNULL;
60 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
61 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
63 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
64 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
66 char *slapd_pid_file = NULL;
67 char *slapd_args_file = NULL;
69 char *strtok_quote_ptr;
71 int use_reverse_lookup = 0;
74 int slapi_plugins_used = 0;
77 static int fp_getline(FILE *fp, ConfigArgs *c);
78 static void fp_getline_init(ConfigArgs *c);
79 static int fp_parse_line(ConfigArgs *c);
81 static char *strtok_quote(char *line, char *sep);
83 static int load_ucdata(char *path);
86 int read_config_file(const char *fname, int depth, ConfigArgs *cf);
88 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
89 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
91 int config_generic(ConfigArgs *c);
92 int config_search_base(ConfigArgs *c);
93 int config_passwd_hash(ConfigArgs *c);
94 int config_schema_dn(ConfigArgs *c);
95 int config_sizelimit(ConfigArgs *c);
96 int config_timelimit(ConfigArgs *c);
97 int config_limits(ConfigArgs *c);
98 int config_overlay(ConfigArgs *c);
99 int config_suffix(ConfigArgs *c);
100 int config_deref_depth(ConfigArgs *c);
101 int config_rootdn(ConfigArgs *c);
102 int config_rootpw(ConfigArgs *c);
103 int config_restrict(ConfigArgs *c);
104 int config_allows(ConfigArgs *c);
105 int config_disallows(ConfigArgs *c);
106 int config_requires(ConfigArgs *c);
107 int config_security(ConfigArgs *c);
108 int config_referral(ConfigArgs *c);
109 int config_loglevel(ConfigArgs *c);
110 int config_syncrepl(ConfigArgs *c);
111 int config_replica(ConfigArgs *c);
112 int config_updatedn(ConfigArgs *c);
113 int config_updateref(ConfigArgs *c);
114 int config_include(ConfigArgs *c);
116 int config_tls_option(ConfigArgs *c);
117 int config_tls_verify(ConfigArgs *c);
120 int config_plugin(ConfigArgs *c);
122 int config_pluginlog(ConfigArgs *c);
162 /* original config.c ordering */
164 ConfigTable SystemConfiguration[] = {
165 { "backend", 2, 2, 0, "type", ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND, &config_generic, NULL, NULL, NULL },
166 { "database", 2, 2, 0, "type", ARG_MAGIC|CFG_DATABASE, &config_generic, NULL, NULL, NULL },
167 { "localSSF", 2, 2, 0, "ssf", ARG_LONG, &local_ssf, NULL, NULL, NULL },
168 { "concurrency", 2, 2, 0, "level", ARG_LONG|ARG_NONZERO|ARG_MAGIC|CFG_CONCUR, &config_generic, NULL, NULL, NULL },
169 { "index_substr_if_minlen", 2, 2, 0, "min", ARG_INT|ARG_NONZERO, &index_substr_if_minlen, NULL, NULL, NULL },
170 { "index_substr_if_maxlen", 2, 2, 0, "max", ARG_INT|ARG_NONZERO|ARG_SPECIAL, &index_substr_if_maxlen, NULL, NULL, NULL },
171 { "index_substr_any_len", 2, 2, 0, "len", ARG_INT|ARG_NONZERO, &index_substr_any_len, NULL, NULL, NULL },
172 { "index_substr_step", 2, 2, 0, "step", ARG_INT|ARG_NONZERO, &index_substr_any_step, NULL, NULL, NULL },
173 { "sockbuf_max_incoming", 2, 2, 0, "max", ARG_LONG, &sockbuf_max_incoming, NULL, NULL, NULL },
174 { "sockbuf_max_incoming_auth",2, 2, 0, "max", ARG_LONG, &sockbuf_max_incoming_auth, NULL, NULL, NULL },
175 { "conn_max_pending", 2, 2, 0, "max", ARG_LONG, &slap_conn_max_pending, NULL, NULL, NULL },
176 { "conn_max_pending_auth", 2, 2, 0, "max", ARG_LONG, &slap_conn_max_pending_auth, NULL, NULL, NULL },
177 { "defaultSearchBase", 2, 2, 0, "dn", ARG_MAGIC, &config_search_base, NULL, NULL, NULL },
178 { "threads", 2, 2, 0, "count", ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic, NULL, NULL, NULL },
179 { "pidfile", 2, 2, 0, "file", ARG_STRING, &slapd_pid_file, NULL, NULL, NULL },
180 { "argsfile", 2, 2, 0, "file", ARG_STRING, &slapd_args_file, NULL, NULL, NULL },
181 { "password-hash", 2, 2, 0, "hash", ARG_MAGIC, &config_passwd_hash, NULL, NULL, NULL },
182 { "password-crypt-salt-format",2, 2, 0, "salt", ARG_MAGIC|CFG_SALT, &config_generic, NULL, NULL, NULL },
183 #ifdef SLAP_AUTH_REWRITE
184 { "auth-rewrite", 2, 2, 14, NULL, ARG_MAGIC|CFG_REWRITE, &config_generic, NULL, NULL, NULL },
186 { "sasl", 2, 0, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL }, /* XXX */
187 { "auth", 2, 2, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL },
188 { "schemadn", 2, 2, 0, "dn", ARG_MAGIC, &config_schema_dn, NULL, NULL, NULL },
189 { "ucdata-path", 2, 2, 0, "path", ARG_IGNORED, NULL, NULL, NULL, NULL },
190 { "sizelimit", 2, 2, 0, "limit", ARG_MAGIC|CFG_SIZE, &config_sizelimit, NULL, NULL, NULL },
191 { "timelimit", 2, 2, 0, "limit", ARG_MAGIC|CFG_TIME, &config_timelimit, NULL, NULL, NULL },
192 { "limits", 2, 2, 0, "limits", ARG_DB|ARG_MAGIC|CFG_LIMITS, &config_generic, NULL, NULL, NULL },
193 { "overlay", 2, 2, 0, "overlay", ARG_DB|ARG_MAGIC, &config_overlay, NULL, NULL, NULL },
194 { "suffix", 2, 2, 0, "suffix", ARG_DB|ARG_MAGIC, &config_suffix, NULL, NULL, NULL },
195 { "maxDerefDepth", 2, 2, 0, "depth", ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH, &config_generic, NULL, NULL, NULL },
196 { "rootdn", 2, 2, 0, "dn", ARG_DB|ARG_MAGIC, &config_rootdn, NULL, NULL, NULL },
197 { "rootpw", 2, 2, 0, "password", ARG_DB|ARG_MAGIC, &config_rootpw, NULL, NULL, NULL },
198 { "readonly", 2, 2, 0, "on|off", ARG_ON_OFF|ARG_MAGIC|CFG_RO, &config_generic, NULL, NULL, NULL },
199 { "restrict", 2, 0, 0, "op_list", ARG_MAGIC, &config_restrict, NULL, NULL, NULL },
200 { "allows", 2, 0, 5, "features", ARG_PRE_DB|ARG_MAGIC, &config_allows, NULL, NULL, NULL },
201 { "disallows", 2, 0, 8, "features", ARG_PRE_DB|ARG_MAGIC, &config_disallows, NULL, NULL, NULL },
202 { "require", 2, 0, 7, "features", ARG_MAGIC, &config_requires, NULL, NULL, NULL },
203 { "security", 2, 0, 0, "factors", ARG_MAGIC, &config_security, NULL, NULL, NULL },
204 { "referral", 2, 2, 0, "url", ARG_MAGIC, &config_referral, NULL, NULL, NULL },
205 { "logfile", 2, 2, 0, "file", ARG_MAGIC|CFG_LOGFILE, &config_generic, NULL, NULL, NULL },
206 { "objectidentifier", 0, 0, 0, NULL, ARG_MAGIC|CFG_OID, &config_generic, NULL, NULL, NULL },
207 { "objectclass", 2, 0, 0, "objectclass", ARG_PAREN|ARG_MAGIC|CFG_OC, &config_generic, NULL, NULL, NULL },
208 { "ditcontentrule", 0, 0, 0, NULL, ARG_MAGIC|CFG_DIT, &config_generic, NULL, NULL, NULL },
209 { "attribute", 2, 0, 9, "attribute", ARG_PAREN|ARG_MAGIC|CFG_ATTR, &config_generic, NULL, NULL, NULL },
210 { "attributeoptions", 0, 0, 0, NULL, ARG_MAGIC|CFG_ATOPT, &config_generic, NULL, NULL, NULL },
211 { "schemacheck", 2, 2, 0, "on|off", ARG_ON_OFF|ARG_MAGIC|CFG_CHECK, &config_generic, NULL, NULL, NULL },
212 { "access", 0, 0, 0, NULL, ARG_MAGIC|CFG_ACL, &config_generic, NULL, NULL, NULL },
213 { "loglevel", 2, 0, 0, "level", ARG_MAGIC, &config_loglevel, NULL, NULL, NULL },
214 { "syncrepl", 0, 0, 0, NULL, ARG_DB|ARG_MAGIC, &config_syncrepl, NULL, NULL, NULL },
215 { "replica", 2, 0, 0, "host or uri", ARG_DB|ARG_MAGIC, &config_replica, NULL, NULL, NULL },
216 { "replicationInterval", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
217 { "updatedn", 2, 2, 0, "dn", ARG_DB|ARG_MAGIC, &config_updatedn, NULL, NULL, NULL },
218 { "updateref", 2, 2, 0, "url", ARG_DB|ARG_MAGIC, &config_updateref, NULL, NULL, NULL },
219 { "replogfile", 2, 2, 0, "filename", ARG_MAGIC|ARG_STRING|CFG_REPLOG, &config_generic, NULL, NULL, NULL },
220 { "rootDSE", 2, 2, 0, "filename", ARG_MAGIC|CFG_ROOTDSE, &config_generic, NULL, NULL, NULL },
221 { "lastmod", 2, 2, 0, "on|off", ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD, &config_generic, NULL, NULL, NULL },
223 { "gentlehup", 2, 2, 0, "on|off", ARG_ON_OFF, &global_gentlehup, NULL, NULL, NULL },
225 { "gentlehup", 2, 2, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
227 { "idletimeout", 2, 2, 0, "timeout", ARG_INT, &global_idletimeout, NULL, NULL, NULL },
228 /* XXX -- special case? */
229 { "include", 2, 2, 0, "filename", ARG_MAGIC, &config_include, NULL, NULL, NULL },
230 { "srvtab", 2, 2, 0, "filename", ARG_STRING, &ldap_srvtab, NULL, NULL, NULL },
232 { "moduleload", 2, 2, 0, "filename", ARG_MAGIC|CFG_MODLOAD, &config_generic, NULL, NULL, NULL },
233 { "modulepath", 2, 2, 0, "path", ARG_MAGIC|CFG_MODPATH, &config_generic, NULL, NULL, NULL },
236 { "TLSRandFile", 0, 0, 0, NULL, CFG_TLS_RAND|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
237 { "TLSCipherSuite", 0, 0, 0, NULL, CFG_TLS_CIPHER|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
238 { "TLSCertificateFile", 0, 0, 0, NULL, CFG_TLS_CERT_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
239 { "TLSCertificateKeyFile", 0, 0, 0, NULL, CFG_TLS_CERT_KEY|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
240 { "TLSCertificatePath", 0, 0, 0, NULL, CFG_TLS_CERT_PATH|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
241 { "TLSCACertificateFile", 0, 0, 0, NULL, CFG_TLS_CA_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
242 #ifdef HAVE_OPENSSL_CRL
243 { "TLSCRLCheck", 0, 0, 0, NULL, CFG_TLS_CRLCHECK|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
245 { "TLSCRLCheck", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
247 { "TLSVerifyClient", 0, 0, 0, NULL, CFG_TLS_VERIFY|ARG_MAGIC, &config_tls_verify, NULL, NULL, NULL },
249 #ifdef SLAPD_RLOOKUPS
250 { "reverse-lookup", 2, 2, 0, "on|off", ARG_ON_OFF, &use_reverse_lookup, NULL, NULL, NULL },
252 { "reverse-lookup", 2, 2, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
255 { "plugin", 0, 0, 0, NULL, ARG_MAGIC|CFG_PLUGIN, &config_generic, NULL, NULL, NULL },
256 { "pluginlog", 2, 2, 0, "filename", ARG_STRING, &slapi_log_file, NULL, NULL, NULL },
258 { "plugin", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
259 { "pluginlog", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
261 { "replica-pidfile", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
262 { "replica-argsfile", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
263 { NULL, 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL }
268 new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv )
271 c = ch_calloc( 1, sizeof( ConfigArgs ) );
272 if ( c == NULL ) return(NULL);
281 int parse_config_table(ConfigTable *Conf, ConfigArgs *c) {
282 int i, rc, arg_user, arg_type, iarg;
285 for(i = 0; Conf[i].name; i++)
286 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
287 (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
288 if(!Conf[i].name) return(ARG_UNKNOWN);
289 arg_type = Conf[i].arg_type;
290 if(arg_type == ARG_IGNORED) {
291 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> ignored\n",
292 c->fname, c->lineno, Conf[i].name);
295 if(Conf[i].min_args && (c->argc < Conf[i].min_args)) {
296 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
297 Debug(LDAP_DEBUG_CONFIG, "keyword <%s> missing <%s> argument\n", Conf[i].name, Conf[i].what, 0);
298 return(ARG_BAD_CONF);
300 if(Conf[i].max_args && (c->argc > Conf[i].max_args)) {
301 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
302 Debug(LDAP_DEBUG_CONFIG, "extra cruft after <%s> in <%s> line (ignored)\n", Conf[i].what, Conf[i].name, 0);
304 if((arg_type & ARG_DB) && !c->be) {
305 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> allowed only within database declaration\n",
306 c->fname, c->lineno, Conf[i].name);
307 return(ARG_BAD_CONF);
309 if((arg_type & ARG_PRE_DB) && c->be) {
310 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> must appear before any database declaration\n",
311 c->fname, c->lineno, Conf[i].name);
312 return(ARG_BAD_CONF);
314 if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
315 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: old <%s> format not supported\n", c->fname, c->lineno, Conf[i].name);
316 return(ARG_BAD_CONF);
318 if((arg_type & ARGS_POINTER) && !Conf[i].arg_item) {
319 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: null arg_item for <%s>\n", c->fname, c->lineno, Conf[i].name);
320 return(ARG_BAD_CONF);
322 c->type = arg_user = (arg_type & ARGS_USERLAND);
323 c->value_int = c->value_long = c->value_ber_t = 0;
324 c->value_string = NULL;
325 if(arg_type & ARGS_NUMERIC) {
327 iarg = 0; larg = 0; barg = 0;
328 switch(arg_type & ARGS_NUMERIC) {
329 case ARG_INT: iarg = atoi(c->argv[1]); break;
330 case ARG_LONG: larg = atol(c->argv[1]); break;
331 case ARG_BER_LEN_T: barg = (ber_len_t)atol(c->argv[1]); break;
333 if(!strcasecmp(c->argv[1], "on")) {
335 } else if(!strcasecmp(c->argv[1], "off")) {
338 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ignoring ", c->fname, c->lineno, 0);
339 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
340 Conf[i].what, c->argv[1], Conf[i].name);
345 j = (arg_type & ARG_NONZERO) ? 1 : 0;
346 rc = (Conf == SystemConfiguration) ? ((arg_type & ARG_SPECIAL) && (larg < index_substr_if_maxlen)) : 0;
347 if(iarg < j || larg < j || barg < j || rc) {
348 larg = larg ? larg : (barg ? barg : iarg);
349 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: " , c->fname, c->lineno, 0);
350 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf[i].what, larg, Conf[i].name);
351 return(ARG_BAD_CONF);
354 c->value_long = larg;
355 c->value_ber_t = barg;
357 if(arg_type & ARG_STRING) c->value_string = ch_strdup(c->argv[1]);
358 if(arg_type & ARG_MAGIC) {
359 if(!c->be) c->be = frontendDB;
360 rc = (*((ConfigDriver*)Conf[i].arg_item))(c);
361 if(c->be == frontendDB) c->be = NULL;
363 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
364 Debug(LDAP_DEBUG_CONFIG, "handler for <%s> exited with %d!", Conf[i].name, rc, 0);
365 return(ARG_BAD_CONF);
369 if(arg_type & ARGS_POINTER) switch(arg_type & ARGS_POINTER) {
371 case ARG_INT: *((int*)Conf[i].arg_item) = iarg; break;
372 case ARG_LONG: *((long*)Conf[i].arg_item) = larg; break;
373 case ARG_BER_LEN_T: *((ber_len_t*)Conf[i].arg_item) = barg; break;
375 char *cc = *((char**)Conf[i].arg_item);
376 if(cc) ch_free(cc); /* potential memory leak */
377 *(char **)Conf[i].arg_item = c->value_string;
385 read_config(const char *fname, int depth) {
386 return read_config_file(fname, depth, NULL);
390 read_config_file(const char *fname, int depth, ConfigArgs *cf)
396 c = ch_calloc( 1, sizeof( ConfigArgs ) );
402 memcpy( c, cf, sizeof( ConfigArgs ) );
404 c->depth = depth; /* XXX */
410 c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
411 c->argv_size = ARGS_STEP + 1;
413 fp = fopen( fname, "r" );
416 Debug(LDAP_DEBUG_ANY,
417 "could not open config file \"%s\": %s (%d)\n",
418 fname, strerror(errno), errno);
422 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
426 while ( fp_getline( fp, c ) ) {
427 /* skip comments and blank lines */
428 if ( c->line[0] == '#' || c->line[0] == '\0' ) {
431 if ( fp_parse_line( c ) ) {
436 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: bad config line (ignored)\n", fname, c->lineno, 0);
440 rc = parse_config_table( SystemConfiguration, c );
444 if ( rc & ARGS_USERLAND ) {
445 switch(rc) { /* XXX a usertype would be opaque here */
447 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: unknown user type <%d>\n",
448 c->fname, c->lineno, *c->argv);
452 } else if ( rc == ARG_BAD_CONF || rc != ARG_UNKNOWN ) {
455 } else if ( c->bi && c->bi->bi_config ) { /* XXX to check: could both be/bi_config? oops */
456 rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv);
459 case SLAP_CONF_UNKNOWN:
460 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
461 "unknown directive <%s> inside backend info definition (ignored)\n",
462 c->fname, c->lineno, *c->argv);
469 } else if ( c->be && c->be->be_config ) {
470 rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv);
473 case SLAP_CONF_UNKNOWN:
474 Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
475 "unknown directive <%s> inside backend database definition (ignored)\n",
476 c->fname, c->lineno, *c->argv);
483 } else if ( frontendDB->be_config ) {
484 rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
487 case SLAP_CONF_UNKNOWN:
488 Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
489 "%s: line %lu: unknown directive <%s> inside global database definition (ignored)\n",
490 c->fname, c->lineno, *c->argv);
498 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
499 "unknown directive <%s> outside backend info and database definitions (ignored)\n",
500 c->fname, c->lineno, *c->argv);
508 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
509 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
510 &frontendDB->be_schemadn );
511 dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
526 config_generic(ConfigArgs *c) {
527 char *p = strchr(c->line,'(' /*')'*/);
532 if(!(c->bi = backend_info(c->argv[1]))) {
533 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
534 "backend %s failed init!\n", c->fname, c->lineno, c->argv[1]);
541 if(!(c->be = backend_db_init(c->argv[1]))) {
542 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
543 "database %s failed init!\n", c->fname, c->lineno, c->argv[1]);
549 ldap_pvt_thread_set_concurrency(c->value_long);
553 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
554 connection_pool_max = c->value_int; /* save for reference */
558 lutil_salt_format(c->argv[1]);
562 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
568 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
570 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
574 /* XXX slap_sasl_config doesn't actually use the line argument */
575 if(slap_sasl_config(c->argc, c->argv, c->line, c->fname, c->lineno))
580 c->be->be_max_deref_depth = c->value_int;
584 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv)) return(1);
588 if(parse_oc(c->fname, c->lineno, p, c->argv)) return(1);
592 if(parse_cr(c->fname, c->lineno, p, c->argv)) return(1);
596 if(parse_at(c->fname, c->lineno, p, c->argv)) return(1);
600 ad_define_option(NULL, NULL, 0);
601 for(i = 1; i < c->argc; i++)
602 if(ad_define_option(c->argv[i], c->fname, c->lineno))
607 global_schemacheck = c->value_int;
608 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
609 "schema checking disabled! your mileage may vary!\n",
610 c->fname, c->lineno, 0);
614 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
619 c->be->be_auditlogfile = c->value_string;
624 if(SLAP_MONITOR(c->be)) {
625 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
626 "\"replogfile\" should not be used "
627 "inside monitor database\n",
628 c->fname, c->lineno, 0);
629 return(0); /* FIXME: should this be an error? */
632 c->be->be_replogfile = c->value_string;
636 if(read_root_dse_file(c->argv[1])) {
637 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
638 "could not read \"rootDSE <filename>\" line\n",
639 c->fname, c->lineno, 0);
645 FILE *logfile = fopen(c->argv[1], "w");
646 if(logfile) lutil_debug_file(logfile);
651 if(SLAP_NOLASTMODCMD(c->be)) {
652 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
653 "lastmod not available for %s databases\n",
654 c->fname, c->lineno, c->be->bd_info->bi_type);
658 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
660 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
665 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
670 if(module_path(c->argv[1])) return(1);
676 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
678 slapi_plugins_used++;
682 #ifdef SLAP_AUTH_REWRITE
684 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
691 Debug(LDAP_DEBUG_ANY, "%s: line %lu: unknown CFG_TYPE %d"
692 "(ignored)\n", c->fname, c->lineno, c->type);
700 config_search_base(ConfigArgs *c) {
703 if(c->bi || c->be != frontendDB) {
704 Debug(LDAP_DEBUG_ANY, "%s: line %lu: defaultSearchBase line must appear "
705 "prior to any backend or database definition\n",
706 c->fname, c->lineno, 0);
710 if(default_search_nbase.bv_len) {
711 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
712 "default search base \"%s\" already defined "
713 "(discarding old)\n",
714 c->fname, c->lineno, default_search_base.bv_val);
715 free(default_search_base.bv_val);
716 free(default_search_nbase.bv_val);
719 ber_str2bv(c->argv[1], 0, 1, &dn);
720 rc = dnPrettyNormal(NULL, &dn, &default_search_base, &default_search_nbase, NULL);
722 if(rc != LDAP_SUCCESS) {
723 Debug(LDAP_DEBUG_ANY,
724 "%s: line %lu: defaultSearchBase DN is invalid\n",
725 c->fname, c->lineno, 0 );
732 config_passwd_hash(ConfigArgs *c) {
734 if(default_passwd_hash) {
735 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
736 "already set default password_hash\n",
737 c->fname, c->lineno, 0);
740 for(i = 1; i < c->argc; i++) {
741 if(!lutil_passwd_scheme(c->argv[i])) {
742 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
743 "password scheme \"%s\" not available\n",
744 c->fname, c->lineno, c->argv[i] );
746 ldap_charray_add(&default_passwd_hash, c->argv[i]);
748 if(!default_passwd_hash) {
749 Debug(LDAP_DEBUG_ANY, "%s: line %lu: no valid hashes found\n",
750 c->fname, c->lineno, 0 );
758 config_schema_dn(ConfigArgs *c) {
761 ber_str2bv(c->argv[1], 0, 1, &dn);
762 rc = dnPrettyNormal(NULL, &dn, &c->be->be_schemadn, &c->be->be_schemandn, NULL);
763 if(rc != LDAP_SUCCESS) {
764 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
765 "schema DN is invalid\n", c->fname, c->lineno, 0);
772 config_sizelimit(ConfigArgs *c) {
775 struct slap_limits_set *lim = &c->be->be_def_limit;
776 for(i = 1; i < c->argc; i++) {
777 if(!strncasecmp(c->argv[i], "size", 4)) {
778 rc = limits_parse_one(c->argv[i], lim);
780 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
781 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
782 c->fname, c->lineno, c->argv[i]);
786 if(!strcasecmp(c->argv[i], "unlimited")) {
787 lim->lms_s_soft = -1;
789 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
790 if(next == c->argv[i]) {
791 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
792 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
793 c->fname, c->lineno, c->argv[i]);
795 } else if(next[0] != '\0') {
796 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
797 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
798 c->fname, c->lineno, next);
808 config_timelimit(ConfigArgs *c) {
811 struct slap_limits_set *lim = &c->be->be_def_limit;
812 for(i = 1; i < c->argc; i++) {
813 if(!strncasecmp(c->argv[i], "time", 4)) {
814 rc = limits_parse_one(c->argv[i], lim);
816 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
817 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
818 c->fname, c->lineno, c->argv[i]);
822 if(!strcasecmp(c->argv[i], "unlimited")) {
823 lim->lms_t_soft = -1;
825 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
826 if(next == c->argv[i]) {
827 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
828 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
829 c->fname, c->lineno, c->argv[i]);
831 } else if(next[0] != '\0') {
832 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
833 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
834 c->fname, c->lineno, next);
844 config_overlay(ConfigArgs *c) {
845 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
847 Debug(LDAP_DEBUG_ANY, "%s: line %lu: (optional) %s",
848 c->fname, c->lineno, c->be == frontendDB ? "global " : "");
849 Debug(LDAP_DEBUG_ANY, "overlay \"%s\" configuration "
850 "failed (ignored)\n", c->argv[1][1], 0, 0);
851 } else if(overlay_config(c->be, c->argv[1])) {
858 config_suffix(ConfigArgs *c) {
860 struct berval dn, pdn, ndn;
862 #ifdef SLAPD_MONITOR_DN
863 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
864 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
865 "%s\" is reserved for monitoring slapd\n",
866 c->fname, c->lineno, SLAPD_MONITOR_DN);
870 ber_str2bv(c->argv[1], 0, 1, &dn);
872 rc = dnPrettyNormal(NULL, &dn, &pdn, &ndn, NULL);
873 if(rc != LDAP_SUCCESS) {
874 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix DN is invalid\n",
875 c->fname, c->lineno, 0);
878 tbe = select_backend(&ndn, 0, 0);
880 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix already served by this backend! (ignored)\n",
881 c->fname, c->lineno, 0);
885 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix already served by a preceding backend \"%s\"\n",
886 c->fname, c->lineno, tbe->be_suffix[0].bv_val);
890 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
891 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix DN empty and default search "
892 "base provided \"%s\" (assuming okay)\n",
893 c->fname, c->lineno, default_search_base.bv_val);
895 ber_bvarray_add(&c->be->be_suffix, &pdn);
896 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
901 config_rootdn(ConfigArgs *c) {
905 ber_str2bv(c->argv[1], 0, 1, &dn);
907 rc = dnPrettyNormal(NULL, &dn, &c->be->be_rootdn, &c->be->be_rootndn, NULL);
909 if(rc != LDAP_SUCCESS) {
910 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
911 "rootdn DN is invalid\n", c->fname, c->lineno, 0);
918 config_rootpw(ConfigArgs *c) {
919 Backend *tbe = select_backend(&c->be->be_rootndn, 0, 0);
921 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
922 "rootpw can only be set when rootdn is under suffix\n",
923 c->fname, c->lineno, 0);
926 ber_str2bv(c->argv[1], 0, 1, &c->be->be_rootpw);
930 /* restrictops, allows, disallows, requires, loglevel */
932 struct verb_mask_list { char *word; int mask; };
935 verb_to_mask(ConfigArgs *c, struct verb_mask_list *v, int word) {
937 for(j = 0; v[j].word; j++)
938 if(!strcasecmp(c->argv[word], v[j].word))
944 verbs_to_mask(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t *m) {
946 for(i = 1; i < c->argc; i++) {
947 j = verb_to_mask(c, v, i);
948 if(!v[j].word) return(1);
955 config_restrict(ConfigArgs *c) {
956 slap_mask_t restrictops = 0;
958 struct verb_mask_list restrictable_exops[] = {
959 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
960 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
961 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
962 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
965 struct verb_mask_list restrictable_ops[] = {
966 { "bind", SLAP_RESTRICT_OP_BIND },
967 { "add", SLAP_RESTRICT_OP_ADD },
968 { "modify", SLAP_RESTRICT_OP_MODIFY },
969 { "modrdn", SLAP_RESTRICT_OP_RENAME },
970 { "rename", SLAP_RESTRICT_OP_RENAME },
971 { "delete", SLAP_RESTRICT_OP_DELETE },
972 { "search", SLAP_RESTRICT_OP_SEARCH },
973 { "compare", SLAP_RESTRICT_OP_COMPARE },
974 { "read", SLAP_RESTRICT_OP_READS },
975 { "write", SLAP_RESTRICT_OP_WRITES },
979 for(i = 1; i < c->argc; i++) {
980 j = verb_to_mask(c, restrictable_ops, i);
981 if(restrictable_ops[j].word) {
982 restrictops |= restrictable_ops[j].mask;
984 } else if(!strncasecmp(c->argv[i], "extended", STRLENOF("extended"))) {
985 char *e = c->argv[i] + STRLENOF("extended");
987 int k = verb_to_mask(c, restrictable_exops, e[1]);
988 if(restrictable_exops[k].word) {
989 restrictops |= restrictable_exops[k].mask;
993 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
994 restrictops |= SLAP_RESTRICT_OP_EXTENDED;
999 c->be->be_restrictops |= restrictops;
1002 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1003 "unknown operation %s in \"restrict <features>\" line\n",
1004 c->fname, c->lineno, c->argv[i]);
1009 config_allows(ConfigArgs *c) {
1010 slap_mask_t allows = 0;
1012 struct verb_mask_list allowable_ops[] = {
1013 { "bind_v2", SLAP_ALLOW_BIND_V2 },
1014 { "bind_anon_cred", SLAP_ALLOW_BIND_ANON_CRED },
1015 { "bind_anon_dn", SLAP_ALLOW_BIND_ANON_DN },
1016 { "update_anon", SLAP_ALLOW_UPDATE_ANON },
1019 i = verbs_to_mask(c, allowable_ops, &allows);
1021 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1022 "unknown feature %s in \"allow <features>\" line\n",
1023 c->fname, c->lineno, c->argv[i]);
1026 global_allows |= allows;
1031 config_disallows(ConfigArgs *c) {
1032 slap_mask_t disallows = 0;
1034 struct verb_mask_list disallowable_ops[] = {
1035 { "bind_anon", SLAP_DISALLOW_BIND_ANON },
1036 { "bind_simple", SLAP_DISALLOW_BIND_SIMPLE },
1037 { "bind_krb4", SLAP_DISALLOW_BIND_KRBV4 },
1038 { "tls_2_anon", SLAP_DISALLOW_TLS_2_ANON },
1039 { "tls_authc", SLAP_DISALLOW_TLS_AUTHC },
1042 i = verbs_to_mask(c, disallowable_ops, &disallows);
1044 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1045 "unknown feature %s in \"disallow <features>\" line\n",
1046 c->fname, c->lineno, c->argv[i]);
1049 global_disallows |= disallows;
1054 config_requires(ConfigArgs *c) {
1055 slap_mask_t requires = 0;
1057 struct verb_mask_list requires_ops[] = {
1058 { "bind", SLAP_REQUIRE_BIND },
1059 { "LDAPv3", SLAP_REQUIRE_LDAP_V3 },
1060 { "authc", SLAP_REQUIRE_AUTHC },
1061 { "sasl", SLAP_REQUIRE_SASL },
1062 { "strong", SLAP_REQUIRE_STRONG },
1065 i = verbs_to_mask(c, requires_ops, &requires);
1067 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1068 "unknown feature %s in \"require <features>\" line\n",
1069 c->fname, c->lineno, c->argv[i]);
1072 c->be->be_requires = requires;
1077 config_loglevel(ConfigArgs *c) {
1080 struct verb_mask_list loglevel_ops[] = {
1081 { "Trace", LDAP_DEBUG_TRACE },
1082 { "Packets", LDAP_DEBUG_PACKETS },
1083 { "Args", LDAP_DEBUG_ARGS },
1084 { "Conns", LDAP_DEBUG_CONNS },
1085 { "BER", LDAP_DEBUG_BER },
1086 { "Filter", LDAP_DEBUG_FILTER },
1087 { "Config", LDAP_DEBUG_CONFIG },
1088 { "ACL", LDAP_DEBUG_ACL },
1089 { "Stats", LDAP_DEBUG_STATS },
1090 { "Stats2", LDAP_DEBUG_STATS2 },
1091 { "Shell", LDAP_DEBUG_SHELL },
1092 { "Parse", LDAP_DEBUG_PARSE },
1093 { "Cache", LDAP_DEBUG_CACHE },
1094 { "Index", LDAP_DEBUG_INDEX },
1100 for( i=1; i < c->argc; i++ ) {
1103 if ( isdigit( c->argv[i][0] ) ) {
1104 level = strtol( c->argv[i], &next, 10 );
1105 if ( next == NULL || next[0] != '\0' ) {
1106 Debug( LDAP_DEBUG_ANY,
1107 "%s: line %lu: unable to parse level \"%s\" "
1108 "in \"loglevel <level> [...]\" line.\n",
1109 c->fname, c->lineno , c->argv[i] );
1113 int j = verb_to_mask(c, loglevel_ops, c->argv[i][0]);
1114 if(!loglevel_ops[j].word) {
1115 Debug( LDAP_DEBUG_ANY,
1116 "%s: line %lu: unknown level \"%s\" "
1117 "in \"loglevel <level> [...]\" line.\n",
1118 c->fname, c->lineno , c->argv[i] );
1121 level = loglevel_ops[j].mask;
1123 ldap_syslog |= level;
1129 config_syncrepl(ConfigArgs *c) {
1130 if(SLAP_SHADOW(c->be)) {
1131 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1132 "syncrepl: database already shadowed.\n",
1133 c->fname, c->lineno, 0);
1135 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1138 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1143 config_referral(ConfigArgs *c) {
1144 struct berval vals[2];
1145 if(validate_global_referral(c->argv[1])) {
1146 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1147 "invalid URL (%s) in \"referral\" line.\n",
1148 c->fname, c->lineno, c->argv[1] );
1152 ber_str2bv(c->argv[1], 0, 1, &vals[0]);
1153 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1154 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1159 config_security(ConfigArgs *c) {
1160 slap_ssf_set_t *set = &c->be->be_ssf_set;
1163 for(i = 1; i < c->argc; i++) {
1166 if(!strncasecmp(c->argv[i], "ssf=", 4)) {
1167 tgt = &set->sss_ssf;
1168 src = &c->argv[i][4];
1169 } else if(!strncasecmp(c->argv[i], "transport=", 10)) {
1170 tgt = &set->sss_transport;
1171 src = &c->argv[i][10];
1172 } else if(!strncasecmp(c->argv[i], "tls=", 4)) {
1173 tgt = &set->sss_tls;
1174 src = &c->argv[i][4];
1175 } else if(!strncasecmp(c->argv[i], "sasl=", 5)) {
1176 tgt = &set->sss_sasl;
1177 src = &c->argv[i][5];
1178 } else if(!strncasecmp(c->argv[i], "update_ssf=", 11)) {
1179 tgt = &set->sss_update_ssf;
1180 src = &c->argv[i][11];
1181 } else if(!strncasecmp(c->argv[i], "update_transport=", 17)) {
1182 tgt = &set->sss_update_transport;
1183 src = &c->argv[i][17];
1184 } else if(!strncasecmp(c->argv[i], "update_tls=", 11)) {
1185 tgt = &set->sss_update_tls;
1186 src = &c->argv[i][11];
1187 } else if(!strncasecmp(c->argv[i], "update_sasl=", 12)) {
1188 tgt = &set->sss_update_sasl;
1189 src = &c->argv[i][12];
1190 } else if(!strncasecmp(c->argv[i], "simple_bind=", 12)) {
1191 tgt = &set->sss_simple_bind;
1192 src = &c->argv[i][12];
1194 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1195 "unknown factor %s in \"security <factors>\" line\n",
1196 c->fname, c->lineno, c->argv[i]);
1200 *tgt = strtol(src, &next, 10);
1201 if(next == NULL || next[0] != '\0' ) {
1202 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1203 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1204 c->fname, c->lineno, c->argv[i]);
1212 config_replica(ConfigArgs *c) {
1217 if(SLAP_MONITOR(c->be)) {
1218 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1219 "\"replica\" should not be used inside monitor database\n",
1220 c->fname, c->lineno, 0);
1221 return(0); /* FIXME: should this be an error? */
1224 for(i = 1; i < c->argc; i++) {
1225 if(!strncasecmp(c->argv[i], "host=", 5)) {
1226 nr = add_replica_info(c->be, c->argv[i] + 5);
1228 } else if(!strncasecmp(c->argv[i], "uri=", 4)) {
1229 if(ldap_url_parse(c->argv[i] + 4, &ludp) != LDAP_SUCCESS) {
1230 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1231 "replica line contains invalid "
1232 "uri definition.\n", c->fname, c->lineno, 0);
1235 if(!ludp->lud_host) {
1236 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1237 "replica line contains invalid "
1238 "uri definition - missing hostname.\n", c->fname, c->lineno, 0);
1241 replicahost = ch_malloc(strlen(c->argv[i]));
1243 Debug(LDAP_DEBUG_ANY,
1244 "out of memory in read_config\n", 0, 0, 0);
1245 ldap_free_urldesc(ludp);
1248 sprintf(replicahost, "%s:%d", ludp->lud_host, ludp->lud_port);
1249 nr = add_replica_info(c->be, replicahost);
1250 ldap_free_urldesc(ludp);
1251 ch_free(replicahost);
1256 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1257 "missing host or uri in \"replica\" line\n",
1258 c->fname, c->lineno, 0);
1260 } else if(nr == -1) {
1261 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1262 "unable to add replica \"%s\"\n",
1263 c->fname, c->lineno, c->argv[i] + 5);
1266 for(i = 1; i < c->argc; i++) {
1267 if(!strncasecmp(c->argv[i], "suffix=", 7)) {
1268 switch(add_replica_suffix(c->be, nr, c->argv[i] + 7)) {
1270 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1271 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1272 c->fname, c->lineno, c->argv[i] + 7);
1275 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1276 "unable to normalize suffix in \"replica\" line (ignored)\n",
1277 c->fname, c->lineno, 0);
1281 } else if(!strncasecmp(c->argv[i], "attr", 4)) {
1283 char *arg = c->argv[i] + 4;
1291 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1292 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1293 "attribute \"%s\" in \"replica\" line is unknown\n",
1294 c->fname, c->lineno, arg + 1);
1304 config_updatedn(ConfigArgs *c) {
1307 if(SLAP_SHADOW(c->be)) {
1308 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1309 "updatedn: database already shadowed.\n",
1310 c->fname, c->lineno, 0);
1314 ber_str2bv(c->argv[1], 0, 0, &dn);
1316 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1318 if(rc != LDAP_SUCCESS) {
1319 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1320 "updatedn DN is invalid\n", c->fname, c->lineno, 0);
1324 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1329 config_updateref(ConfigArgs *c) {
1330 struct berval vals[2];
1331 if(!SLAP_SHADOW(c->be)) {
1332 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1333 "updateref line must after syncrepl or updatedn.\n",
1334 c->fname, c->lineno, 0);
1338 if(validate_global_referral(c->argv[1])) {
1339 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1340 "invalid URL (%s) in \"updateref\" line.\n",
1341 c->fname, c->lineno, c->argv[1]);
1344 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1345 vals[1].bv_val = NULL;
1346 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1350 /* XXX meaningless in ldif */
1353 config_include(ConfigArgs *c) {
1354 char *savefname = ch_strdup(c->argv[1]);
1355 unsigned long savelineno = c->lineno;
1357 rc = read_config_file(savefname, c->depth + 1, c);
1359 c->lineno = savelineno - 1;
1365 config_tls_option(ConfigArgs *c) {
1368 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
1369 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
1370 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
1371 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
1372 case CFG_TLS_CERT_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
1373 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
1374 #ifdef HAVE_OPENSSL_CRL
1375 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
1377 default: Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1378 "unknown tls_option <%x>\n",
1379 c->fname, c->lineno, c->type);
1381 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
1385 config_tls_verify(ConfigArgs *c) {
1387 if(isdigit((unsigned char)c->argv[1][0])) {
1388 i = atoi(c->argv[1]);
1389 return(ldap_pvt_tls_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i));
1391 return(ldap_int_tls_config(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, c->argv[1]));
1396 /* -------------------------------------- */
1400 strtok_quote( char *line, char *sep )
1406 strtok_quote_ptr = NULL;
1407 if ( line != NULL ) {
1410 while ( *next && strchr( sep, *next ) ) {
1414 if ( *next == '\0' ) {
1420 for ( inquote = 0; *next; ) {
1428 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1434 next + 1, strlen( next + 1 ) + 1 );
1435 next++; /* dont parse the escaped character */
1440 if ( strchr( sep, *next ) != NULL ) {
1441 strtok_quote_ptr = next;
1454 static char buf[BUFSIZ];
1456 static size_t lmax, lcur;
1458 #define CATLINE( buf ) \
1460 size_t len = strlen( buf ); \
1461 while ( lcur + len + 1 > lmax ) { \
1463 line = (char *) ch_realloc( line, lmax ); \
1465 strcpy( line + lcur, buf ); \
1470 fp_getline_init(ConfigArgs *c) {
1476 fp_getline( FILE *fp, ConfigArgs *c )
1484 /* avoid stack of bufs */
1485 if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
1491 while ( fgets( buf, sizeof( buf ), fp ) ) {
1492 p = strchr( buf, '\n' );
1494 if ( p > buf && p[-1] == '\r' ) {
1502 && ( p = line + strlen( line ) - 1 )[0] == '\\'
1509 if ( !isspace( (unsigned char)buf[0] ) ) {
1520 return(line[0] ? 1 : 0);
1524 fp_parse_line(ConfigArgs *c)
1527 char *tline = ch_strdup(c->line);
1528 char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
1532 token = strtok_quote(tline, " \t");
1534 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
1535 if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
1536 Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
1537 if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
1539 for(; token; token = strtok_quote(NULL, " \t")) {
1540 if(c->argc == c->argv_size - 1) {
1542 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
1544 Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0);
1548 c->argv_size += ARGS_STEP;
1550 c->argv[c->argc++] = token;
1552 c->argv[c->argc] = NULL;
1558 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1560 load_ucdata( char *path )
1563 static int loaded = 0;
1569 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
1571 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
1579 /* ucdata is now hardcoded */
1588 ucdata_unload( UCDATA_ALL );
1590 /* NOTE: in case of early exit, frontendDB can be NULL */
1591 if ( frontendDB->be_schemandn.bv_val )
1592 free( frontendDB->be_schemandn.bv_val );
1593 if ( frontendDB->be_schemadn.bv_val )
1594 free( frontendDB->be_schemadn.bv_val );
1595 if ( frontendDB->be_acl )
1596 acl_destroy( frontendDB->be_acl, NULL );
1599 if ( slapd_args_file )
1600 free ( slapd_args_file );
1601 if ( slapd_pid_file )
1602 free ( slapd_pid_file );
1603 if ( default_passwd_hash )
1604 ldap_charray_free( default_passwd_hash );
1615 syncinfo_t *si_entry;
1617 int duplicated_replica_id = 0;
1619 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
1622 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
1626 si->si_tls = SYNCINFO_TLS_OFF;
1627 if ( be->be_rootndn.bv_val ) {
1628 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
1630 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1631 si->si_schemachecking = 0;
1632 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
1633 &si->si_filterstr );
1634 si->si_base.bv_val = NULL;
1635 si->si_scope = LDAP_SCOPE_SUBTREE;
1636 si->si_attrsonly = 0;
1637 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1638 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1639 si->si_attrs = NULL;
1640 si->si_allattrs = 0;
1641 si->si_allopattrs = 0;
1642 si->si_exattrs = NULL;
1643 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1644 si->si_interval = 86400;
1645 si->si_retryinterval = NULL;
1646 si->si_retrynum_init = NULL;
1647 si->si_retrynum = NULL;
1648 si->si_syncCookie.ctxcsn = NULL;
1649 si->si_syncCookie.octet_str = NULL;
1650 si->si_syncCookie.sid = -1;
1651 si->si_manageDSAit = 0;
1655 si->si_presentlist = NULL;
1656 LDAP_LIST_INIT( &si->si_nonpresentlist );
1658 rc = parse_syncrepl_line( cargv, cargc, si );
1660 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
1661 if ( si->si_rid == si_entry->si_rid ) {
1662 Debug( LDAP_DEBUG_ANY,
1663 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
1664 duplicated_replica_id = 1;
1669 if ( rc < 0 || duplicated_replica_id ) {
1670 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
1671 syncinfo_free( si );
1674 Debug( LDAP_DEBUG_CONFIG,
1675 "Config: ** successfully added syncrepl \"%s\"\n",
1676 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
1677 if ( !si->si_schemachecking ) {
1678 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
1681 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
1686 /* NOTE: used & documented in slapd.conf(5) */
1688 #define PROVIDERSTR "provider"
1689 #define TYPESTR "type"
1690 #define INTERVALSTR "interval"
1691 #define SEARCHBASESTR "searchbase"
1692 #define FILTERSTR "filter"
1693 #define SCOPESTR "scope"
1694 #define ATTRSSTR "attrs"
1695 #define ATTRSONLYSTR "attrsonly"
1696 #define SLIMITSTR "sizelimit"
1697 #define TLIMITSTR "timelimit"
1698 #define SCHEMASTR "schemachecking"
1699 #define UPDATEDNSTR "updatedn"
1700 #define BINDMETHSTR "bindmethod"
1701 #define SIMPLESTR "simple"
1702 #define SASLSTR "sasl"
1703 #define BINDDNSTR "binddn"
1704 #define SASLMECHSTR "saslmech"
1705 #define AUTHCSTR "authcID"
1706 #define AUTHZSTR "authzID"
1707 #define CREDSTR "credentials"
1708 #define REALMSTR "realm"
1709 #define SECPROPSSTR "secprops"
1711 /* FIXME: undocumented */
1712 #define OLDAUTHCSTR "bindprincipal"
1713 #define STARTTLSSTR "starttls"
1714 #define CRITICALSTR "critical"
1715 #define EXATTRSSTR "exattrs"
1716 #define MANAGEDSAITSTR "manageDSAit"
1717 #define RETRYSTR "retry"
1720 #define LASTMODSTR "lastmod"
1721 #define LMGENSTR "gen"
1722 #define LMNOSTR "no"
1723 #define LMREQSTR "req"
1724 #define SRVTABSTR "srvtab"
1725 #define SUFFIXSTR "suffix"
1728 #define GOT_ID 0x0001
1729 #define GOT_PROVIDER 0x0002
1730 #define GOT_METHOD 0x0004
1733 #define GOT_ALL (GOT_ID|GOT_PROVIDER|GOT_METHOD)
1736 parse_syncrepl_line(
1746 for ( i = 1; i < cargc; i++ ) {
1747 if ( !strncasecmp( cargv[ i ], IDSTR "=",
1748 STRLENOF( IDSTR "=" ) ) )
1751 /* '\0' string terminator accounts for '=' */
1752 val = cargv[ i ] + STRLENOF( IDSTR "=" );
1754 if ( tmp >= 1000 || tmp < 0 ) {
1755 fprintf( stderr, "Error: parse_syncrepl_line: "
1756 "syncrepl id %d is out of range [0..999]\n", tmp );
1761 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
1762 STRLENOF( PROVIDERSTR "=" ) ) )
1764 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
1765 si->si_provideruri = ch_strdup( val );
1766 si->si_provideruri_bv = (BerVarray)
1767 ch_calloc( 2, sizeof( struct berval ));
1768 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
1769 1, &si->si_provideruri_bv[0] );
1770 si->si_provideruri_bv[1].bv_len = 0;
1771 si->si_provideruri_bv[1].bv_val = NULL;
1772 gots |= GOT_PROVIDER;
1773 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=",
1774 STRLENOF(STARTTLSSTR "=") ) )
1776 val = cargv[ i ] + STRLENOF( STARTTLSSTR "=" );
1777 if( !strcasecmp( val, CRITICALSTR ) ) {
1778 si->si_tls = SYNCINFO_TLS_CRITICAL;
1780 si->si_tls = SYNCINFO_TLS_ON;
1782 } else if ( !strncasecmp( cargv[ i ], UPDATEDNSTR "=",
1783 STRLENOF( UPDATEDNSTR "=" ) ) )
1785 struct berval updatedn = BER_BVNULL;
1787 val = cargv[ i ] + STRLENOF( UPDATEDNSTR "=" );
1788 ber_str2bv( val, 0, 0, &updatedn );
1789 ch_free( si->si_updatedn.bv_val );
1790 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
1791 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR "=",
1792 STRLENOF( BINDMETHSTR "=" ) ) )
1794 val = cargv[ i ] + STRLENOF( BINDMETHSTR "=" );
1795 if ( !strcasecmp( val, SIMPLESTR )) {
1796 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1798 } else if ( !strcasecmp( val, SASLSTR )) {
1799 #ifdef HAVE_CYRUS_SASL
1800 si->si_bindmethod = LDAP_AUTH_SASL;
1802 #else /* HAVE_CYRUS_SASL */
1803 fprintf( stderr, "Error: parse_syncrepl_line: "
1804 "not compiled with SASL support\n" );
1806 #endif /* HAVE_CYRUS_SASL */
1808 si->si_bindmethod = -1;
1810 } else if ( !strncasecmp( cargv[ i ], BINDDNSTR "=",
1811 STRLENOF( BINDDNSTR "=" ) ) )
1813 val = cargv[ i ] + STRLENOF( BINDDNSTR "=" );
1814 si->si_binddn = ch_strdup( val );
1815 } else if ( !strncasecmp( cargv[ i ], CREDSTR "=",
1816 STRLENOF( CREDSTR "=" ) ) )
1818 val = cargv[ i ] + STRLENOF( CREDSTR "=" );
1819 si->si_passwd = ch_strdup( val );
1820 } else if ( !strncasecmp( cargv[ i ], SASLMECHSTR "=",
1821 STRLENOF( SASLMECHSTR "=" ) ) )
1823 val = cargv[ i ] + STRLENOF( SASLMECHSTR "=" );
1824 si->si_saslmech = ch_strdup( val );
1825 } else if ( !strncasecmp( cargv[ i ], SECPROPSSTR "=",
1826 STRLENOF( SECPROPSSTR "=" ) ) )
1828 val = cargv[ i ] + STRLENOF( SECPROPSSTR "=" );
1829 si->si_secprops = ch_strdup( val );
1830 } else if ( !strncasecmp( cargv[ i ], REALMSTR "=",
1831 STRLENOF( REALMSTR "=" ) ) )
1833 val = cargv[ i ] + STRLENOF( REALMSTR "=" );
1834 si->si_realm = ch_strdup( val );
1835 } else if ( !strncasecmp( cargv[ i ], AUTHCSTR "=",
1836 STRLENOF( AUTHCSTR "=" ) ) )
1838 val = cargv[ i ] + STRLENOF( AUTHCSTR "=" );
1839 if ( si->si_authcId )
1840 ch_free( si->si_authcId );
1841 si->si_authcId = ch_strdup( val );
1842 } else if ( !strncasecmp( cargv[ i ], OLDAUTHCSTR "=",
1843 STRLENOF( OLDAUTHCSTR "=" ) ) )
1845 /* Old authcID is provided for some backwards compatibility */
1846 val = cargv[ i ] + STRLENOF( OLDAUTHCSTR "=" );
1847 if ( si->si_authcId )
1848 ch_free( si->si_authcId );
1849 si->si_authcId = ch_strdup( val );
1850 } else if ( !strncasecmp( cargv[ i ], AUTHZSTR "=",
1851 STRLENOF( AUTHZSTR "=" ) ) )
1853 val = cargv[ i ] + STRLENOF( AUTHZSTR "=" );
1854 si->si_authzId = ch_strdup( val );
1855 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
1856 STRLENOF( SCHEMASTR "=" ) ) )
1858 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
1859 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
1860 si->si_schemachecking = 1;
1861 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
1862 si->si_schemachecking = 0;
1864 si->si_schemachecking = 1;
1866 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
1867 STRLENOF( FILTERSTR "=" ) ) )
1869 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
1870 ber_str2bv( val, 0, 1, &si->si_filterstr );
1871 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
1872 STRLENOF( SEARCHBASESTR "=" ) ) )
1875 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
1876 if ( si->si_base.bv_val ) {
1877 ch_free( si->si_base.bv_val );
1879 ber_str2bv( val, 0, 0, &bv );
1880 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
1881 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
1884 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
1885 STRLENOF( SCOPESTR "=" ) ) )
1887 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
1888 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
1889 si->si_scope = LDAP_SCOPE_BASE;
1890 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
1891 si->si_scope = LDAP_SCOPE_ONELEVEL;
1892 #ifdef LDAP_SCOPE_SUBORDINATE
1893 } else if ( !strcasecmp( val, "subordinate" ) ||
1894 !strcasecmp( val, "children" ))
1896 si->si_scope = LDAP_SCOPE_SUBORDINATE;
1898 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
1899 si->si_scope = LDAP_SCOPE_SUBTREE;
1901 fprintf( stderr, "Error: parse_syncrepl_line: "
1902 "unknown scope \"%s\"\n", val);
1905 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
1906 STRLENOF( ATTRSONLYSTR "=" ) ) )
1908 si->si_attrsonly = 1;
1909 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
1910 STRLENOF( ATTRSSTR "=" ) ) )
1912 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
1913 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
1915 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1916 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
1917 if ( si->si_anlist == NULL ) {
1918 ch_free( attr_fname );
1921 ch_free( attr_fname );
1923 char *str, *s, *next;
1924 char delimstr[] = " ,\t";
1925 str = ch_strdup( val );
1926 for ( s = ldap_pvt_strtok( str, delimstr, &next );
1928 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
1930 if ( strlen(s) == 1 && *s == '*' ) {
1931 si->si_allattrs = 1;
1932 *(val + ( s - str )) = delimstr[0];
1934 if ( strlen(s) == 1 && *s == '+' ) {
1935 si->si_allopattrs = 1;
1936 *(val + ( s - str )) = delimstr[0];
1940 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
1941 if ( si->si_anlist == NULL ) {
1945 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
1946 STRLENOF( EXATTRSSTR "=" ) ) )
1948 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
1949 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
1951 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1952 si->si_exanlist = file2anlist(
1953 si->si_exanlist, attr_fname, " ,\t" );
1954 if ( si->si_exanlist == NULL ) {
1955 ch_free( attr_fname );
1958 ch_free( attr_fname );
1960 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
1961 if ( si->si_exanlist == NULL ) {
1965 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
1966 STRLENOF( TYPESTR "=" ) ) )
1968 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
1969 if ( !strncasecmp( val, "refreshOnly",
1970 STRLENOF("refreshOnly") ))
1972 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1973 } else if ( !strncasecmp( val, "refreshAndPersist",
1974 STRLENOF("refreshAndPersist") ))
1976 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
1977 si->si_interval = 60;
1979 fprintf( stderr, "Error: parse_syncrepl_line: "
1980 "unknown sync type \"%s\"\n", val);
1983 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
1984 STRLENOF( INTERVALSTR "=" ) ) )
1986 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
1987 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
1988 si->si_interval = 0;
1996 hstr = strchr( dstr, ':' );
1997 if ( hstr == NULL ) {
1998 fprintf( stderr, "Error: parse_syncrepl_line: "
1999 "invalid interval \"%s\"\n", val );
2003 mstr = strchr( hstr, ':' );
2004 if ( mstr == NULL ) {
2005 fprintf( stderr, "Error: parse_syncrepl_line: "
2006 "invalid interval \"%s\"\n", val );
2010 sstr = strchr( mstr, ':' );
2011 if ( sstr == NULL ) {
2012 fprintf( stderr, "Error: parse_syncrepl_line: "
2013 "invalid interval \"%s\"\n", val );
2022 if (( hh > 24 ) || ( hh < 0 ) ||
2023 ( mm > 60 ) || ( mm < 0 ) ||
2024 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2025 fprintf( stderr, "Error: parse_syncrepl_line: "
2026 "invalid interval \"%s\"\n", val );
2029 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2031 if ( si->si_interval < 0 ) {
2032 fprintf( stderr, "Error: parse_syncrepl_line: "
2033 "invalid interval \"%ld\"\n",
2034 (long) si->si_interval);
2037 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2038 STRLENOF( RETRYSTR "=" ) ) )
2043 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2044 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2045 retry_list[0] = NULL;
2047 slap_str2clist( &retry_list, val, " ,\t" );
2049 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2053 "Error: incomplete syncrepl retry list\n" );
2054 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2055 ch_free( retry_list[k] );
2057 ch_free( retry_list );
2058 exit( EXIT_FAILURE );
2060 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2061 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2062 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2063 for ( j = 0; j < n; j++ ) {
2064 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2065 if ( *retry_list[j*2+1] == '+' ) {
2066 si->si_retrynum_init[j] = -1;
2067 si->si_retrynum[j] = -1;
2071 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2072 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2075 si->si_retrynum_init[j] = -2;
2076 si->si_retrynum[j] = -2;
2077 si->si_retryinterval[j] = 0;
2079 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2080 ch_free( retry_list[k] );
2082 ch_free( retry_list );
2083 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2084 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2086 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2087 si->si_manageDSAit = atoi( val );
2088 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2089 STRLENOF( SLIMITSTR "=") ) )
2091 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2092 si->si_slimit = atoi( val );
2093 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2094 STRLENOF( TLIMITSTR "=" ) ) )
2096 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2097 si->si_tlimit = atoi( val );
2099 fprintf( stderr, "Error: parse_syncrepl_line: "
2100 "unknown keyword \"%s\"\n", cargv[ i ] );
2105 if ( gots != GOT_ALL ) {
2107 "Error: Malformed \"syncrepl\" line in slapd config file" );
2115 slap_str2clist( char ***out, char *in, const char *brkstr )
2123 /* find last element in list */
2124 for (i = 0; *out && (*out)[i]; i++);
2126 /* protect the input string from strtok */
2127 str = ch_strdup( in );
2129 if ( *str == '\0' ) {
2134 /* Count words in string */
2136 for ( s = str; *s; s++ ) {
2137 if ( strchr( brkstr, *s ) != NULL ) {
2142 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
2144 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
2146 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
2148 *new = ch_strdup( s );