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;
59 unsigned num_subordinates = 0;
61 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
62 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
64 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
65 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
67 char *slapd_pid_file = NULL;
68 char *slapd_args_file = NULL;
70 char *strtok_quote_ptr;
72 int use_reverse_lookup = 0;
75 int slapi_plugins_used = 0;
78 static int fp_getline(FILE *fp, ConfigArgs *c);
79 static void fp_getline_init(ConfigArgs *c);
80 static int fp_parse_line(ConfigArgs *c);
82 static char *strtok_quote(char *line, char *sep);
84 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 *));
90 int config_generic(ConfigArgs *c);
91 int config_search_base(ConfigArgs *c);
92 int config_passwd_hash(ConfigArgs *c);
93 int config_schema_dn(ConfigArgs *c);
94 int config_sizelimit(ConfigArgs *c);
95 int config_timelimit(ConfigArgs *c);
96 int config_limits(ConfigArgs *c);
97 int config_overlay(ConfigArgs *c);
98 int config_suffix(ConfigArgs *c);
99 int config_deref_depth(ConfigArgs *c);
100 int config_rootdn(ConfigArgs *c);
101 int config_rootpw(ConfigArgs *c);
102 int config_restrict(ConfigArgs *c);
103 int config_allows(ConfigArgs *c);
104 int config_disallows(ConfigArgs *c);
105 int config_requires(ConfigArgs *c);
106 int config_security(ConfigArgs *c);
107 int config_referral(ConfigArgs *c);
108 int config_loglevel(ConfigArgs *c);
109 int config_syncrepl(ConfigArgs *c);
110 int config_replica(ConfigArgs *c);
111 int config_updatedn(ConfigArgs *c);
112 int config_updateref(ConfigArgs *c);
113 int config_include(ConfigArgs *c);
115 int config_tls_option(ConfigArgs *c);
116 int config_tls_verify(ConfigArgs *c);
119 int config_plugin(ConfigArgs *c);
121 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, 2, 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 { "subordinate", 1, 1, 0, "sub", ARG_DB|ARG_MAGIC|CFG_SUB, &config_generic, NULL, NULL, NULL },
194 { "overlay", 2, 2, 0, "overlay", ARG_DB|ARG_MAGIC, &config_overlay, NULL, NULL, NULL },
195 { "suffix", 2, 2, 0, "suffix", ARG_DB|ARG_MAGIC, &config_suffix, NULL, NULL, NULL },
196 { "maxDerefDepth", 2, 2, 0, "depth", ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH, &config_generic, NULL, NULL, NULL },
197 { "rootdn", 2, 2, 0, "dn", ARG_DB|ARG_MAGIC, &config_rootdn, NULL, NULL, NULL },
198 { "rootpw", 2, 2, 0, "password", ARG_DB|ARG_MAGIC, &config_rootpw, NULL, NULL, NULL },
199 { "readonly", 2, 2, 0, "on|off", ARG_ON_OFF|ARG_MAGIC|CFG_RO, &config_generic, NULL, NULL, NULL },
200 { "restrict", 2, 0, 0, "op_list", ARG_MAGIC, &config_restrict, NULL, NULL, NULL },
201 { "allows", 2, 0, 5, "features", ARG_PRE_DB|ARG_MAGIC, &config_allows, NULL, NULL, NULL },
202 { "disallows", 2, 0, 8, "features", ARG_PRE_DB|ARG_MAGIC, &config_disallows, NULL, NULL, NULL },
203 { "require", 2, 0, 7, "features", ARG_MAGIC, &config_requires, NULL, NULL, NULL },
204 { "security", 2, 0, 0, "factors", ARG_MAGIC, &config_security, NULL, NULL, NULL },
205 { "referral", 2, 2, 0, "url", ARG_MAGIC, &config_referral, NULL, NULL, NULL },
206 { "logfile", 2, 2, 0, "file", ARG_MAGIC|CFG_LOGFILE, &config_generic, NULL, NULL, NULL },
207 { "objectidentifier", 0, 0, 0, NULL, ARG_MAGIC|CFG_OID, &config_generic, NULL, NULL, NULL },
208 { "objectclass", 2, 0, 0, "objectclass", ARG_PAREN|ARG_MAGIC|CFG_OC, &config_generic, NULL, NULL, NULL },
209 { "ditcontentrule", 0, 0, 0, NULL, ARG_MAGIC|CFG_DIT, &config_generic, NULL, NULL, NULL },
210 { "attribute", 2, 0, 9, "attribute", ARG_PAREN|ARG_MAGIC|CFG_ATTR, &config_generic, NULL, NULL, NULL },
211 { "attributeoptions", 0, 0, 0, NULL, ARG_MAGIC|CFG_ATOPT, &config_generic, NULL, NULL, NULL },
212 { "schemacheck", 2, 2, 0, "on|off", ARG_ON_OFF|ARG_MAGIC|CFG_CHECK, &config_generic, NULL, NULL, NULL },
213 { "access", 0, 0, 0, NULL, ARG_MAGIC|CFG_ACL, &config_generic, NULL, NULL, NULL },
214 { "loglevel", 2, 0, 0, "level", ARG_MAGIC, &config_loglevel, NULL, NULL, NULL },
215 { "syncrepl", 0, 0, 0, NULL, ARG_DB|ARG_MAGIC, &config_syncrepl, NULL, NULL, NULL },
216 { "replica", 2, 0, 0, "host or uri", ARG_DB|ARG_MAGIC, &config_replica, NULL, NULL, NULL },
217 { "replicationInterval", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
218 { "updatedn", 2, 2, 0, "dn", ARG_DB|ARG_MAGIC, &config_updatedn, NULL, NULL, NULL },
219 { "updateref", 2, 2, 0, "url", ARG_DB|ARG_MAGIC, &config_updateref, NULL, NULL, NULL },
220 { "replogfile", 2, 2, 0, "filename", ARG_MAGIC|ARG_STRING|CFG_REPLOG, &config_generic, NULL, NULL, NULL },
221 { "rootDSE", 2, 2, 0, "filename", ARG_MAGIC|CFG_ROOTDSE, &config_generic, NULL, NULL, NULL },
222 { "lastmod", 2, 2, 0, "on|off", ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD, &config_generic, NULL, NULL, NULL },
224 { "gentlehup", 2, 2, 0, "on|off", ARG_ON_OFF, &global_gentlehup, NULL, NULL, NULL },
226 { "gentlehup", 2, 2, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
228 { "idletimeout", 2, 2, 0, "timeout", ARG_INT, &global_idletimeout, NULL, NULL, NULL },
229 /* XXX -- special case? */
230 { "include", 2, 2, 0, "filename", ARG_MAGIC, &config_include, NULL, NULL, NULL },
231 { "srvtab", 2, 2, 0, "filename", ARG_STRING, &ldap_srvtab, NULL, NULL, NULL },
233 { "moduleload", 2, 2, 0, "filename", ARG_MAGIC|CFG_MODLOAD, &config_generic, NULL, NULL, NULL },
234 { "modulepath", 2, 2, 0, "path", ARG_MAGIC|CFG_MODPATH, &config_generic, NULL, NULL, NULL },
237 { "TLSRandFile", 0, 0, 0, NULL, CFG_TLS_RAND|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
238 { "TLSCipherSuite", 0, 0, 0, NULL, CFG_TLS_CIPHER|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
239 { "TLSCertificateFile", 0, 0, 0, NULL, CFG_TLS_CERT_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
240 { "TLSCertificateKeyFile", 0, 0, 0, NULL, CFG_TLS_CERT_KEY|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
241 { "TLSCertificatePath", 0, 0, 0, NULL, CFG_TLS_CERT_PATH|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
242 { "TLSCACertificateFile", 0, 0, 0, NULL, CFG_TLS_CA_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
243 #ifdef HAVE_OPENSSL_CRL
244 { "TLSCRLCheck", 0, 0, 0, NULL, CFG_TLS_CRLCHECK|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
246 { "TLSCRLCheck", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
248 { "TLSVerifyClient", 0, 0, 0, NULL, CFG_TLS_VERIFY|ARG_MAGIC, &config_tls_verify, NULL, NULL, NULL },
250 #ifdef SLAPD_RLOOKUPS
251 { "reverse-lookup", 2, 2, 0, "on|off", ARG_ON_OFF, &use_reverse_lookup, NULL, NULL, NULL },
253 { "reverse-lookup", 2, 2, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
256 { "plugin", 0, 0, 0, NULL, ARG_MAGIC|CFG_PLUGIN, &config_generic, NULL, NULL, NULL },
257 { "pluginlog", 2, 2, 0, "filename", ARG_STRING, &slapi_log_file, NULL, NULL, NULL },
259 { "plugin", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
260 { "pluginlog", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
262 { "replica-pidfile", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
263 { "replica-argsfile", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
264 { NULL, 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL }
269 new_config_args(BackendDB *be, const char *fname, int lineno, int argc, char **argv) {
271 if(!(c = ch_calloc(1, sizeof(ConfigArgs)))) return(NULL);
280 int parse_config_table(ConfigTable *Conf, ConfigArgs *c) {
281 int i, rc, arg_user, arg_type, iarg;
284 for(i = 0; Conf[i].name; i++)
285 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
286 (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
287 if(!Conf[i].name) return(ARG_UNKNOWN);
288 arg_type = Conf[i].arg_type;
289 if(arg_type == ARG_IGNORED) {
290 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> ignored\n",
291 c->fname, c->lineno, Conf[i].name);
294 if(Conf[i].min_args && (c->argc < Conf[i].min_args)) {
295 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
296 Debug(LDAP_DEBUG_CONFIG, "keyword <%s> missing <%s> argument\n", Conf[i].name, Conf[i].what, 0);
297 return(ARG_BAD_CONF);
299 if(Conf[i].max_args && (c->argc > Conf[i].max_args)) {
300 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
301 Debug(LDAP_DEBUG_CONFIG, "extra cruft after <%s> in <%s> line (ignored)\n", Conf[i].what, Conf[i].name, 0);
303 if((arg_type & ARG_DB) && !c->be) {
304 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> allowed only within database declaration\n",
305 c->fname, c->lineno, Conf[i].name);
306 return(ARG_BAD_CONF);
308 if((arg_type & ARG_PRE_DB) && c->be) {
309 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> must appear before any database declaration\n",
310 c->fname, c->lineno, Conf[i].name);
311 return(ARG_BAD_CONF);
313 if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
314 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: old <%s> format not supported\n", c->fname, c->lineno, Conf[i].name);
315 return(ARG_BAD_CONF);
317 if((arg_type & ARGS_POINTER) && !Conf[i].arg_item) {
318 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: null arg_item for <%s>\n", c->fname, c->lineno, Conf[i].name);
319 return(ARG_BAD_CONF);
321 c->type = arg_user = (arg_type & ARGS_USERLAND);
322 c->value_int = c->value_long = c->value_ber_t = 0;
323 c->value_string = NULL;
324 if(arg_type & ARGS_NUMERIC) {
326 iarg = 0; larg = 0; barg = 0;
327 switch(arg_type & ARGS_NUMERIC) {
328 case ARG_INT: iarg = atoi(c->argv[1]); break;
329 case ARG_LONG: larg = atol(c->argv[1]); break;
330 case ARG_BER_LEN_T: barg = (ber_len_t)atol(c->argv[1]); break;
332 if(!strcasecmp(c->argv[1], "on")) {
334 } else if(!strcasecmp(c->argv[1], "off")) {
337 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ignoring ", c->fname, c->lineno, 0);
338 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
339 Conf[i].what, c->argv[1], Conf[i].name);
344 j = (arg_type & ARG_NONZERO) ? 1 : 0;
345 rc = (Conf == SystemConfiguration) ? ((arg_type & ARG_SPECIAL) && (larg < index_substr_if_maxlen)) : 0;
346 if(iarg < j || larg < j || barg < j || rc) {
347 larg = larg ? larg : (barg ? barg : iarg);
348 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: " , c->fname, c->lineno, 0);
349 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf[i].what, larg, Conf[i].name);
350 return(ARG_BAD_CONF);
353 c->value_long = larg;
354 c->value_ber_t = barg;
356 if(arg_type & ARG_STRING) c->value_string = ch_strdup(c->argv[1]);
357 if(arg_type & ARG_MAGIC) {
358 if(!c->be) c->be = frontendDB;
359 rc = (*((ConfigDriver*)Conf[i].arg_item))(c);
360 if(c->be == frontendDB) c->be = NULL;
362 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
363 Debug(LDAP_DEBUG_CONFIG, "handler for <%s> exited with %d!", Conf[i].name, rc, 0);
364 return(ARG_BAD_CONF);
368 if(arg_type & ARGS_POINTER) switch(arg_type & ARGS_POINTER) {
370 case ARG_INT: *((int*)Conf[i].arg_item) = iarg; break;
371 case ARG_LONG: *((long*)Conf[i].arg_item) = larg; break;
372 case ARG_BER_LEN_T: *((ber_len_t*)Conf[i].arg_item) = barg; break;
374 char *cc = *((char**)Conf[i].arg_item);
375 if(cc) ch_free(cc); /* potential memory leak */
376 cc = c->value_string;
377 /* memcpy(Conf[i].arg_item, &c->value_string, sizeof(void *)); */
385 read_config(const char *fname, int depth) {
386 return(read_config_file(fname, depth, NULL));
390 read_config_file(char *fname, int depth, ConfigArgs *cf)
393 char *line, *savefname;
397 c = ch_calloc(1, sizeof(ConfigArgs));
400 memcpy(c, cf, sizeof(ConfigArgs));
402 c->depth = depth; /* XXX */
408 c->argv = ch_calloc(ARGS_STEP + 1, sizeof(*c->argv));
409 c->argv_size = ARGS_STEP + 1;
411 if((fp = fopen(fname, "r")) == NULL) {
413 Debug(LDAP_DEBUG_ANY,
414 "could not open config file \"%s\": %s (%d)\n",
415 fname, strerror(errno), errno);
419 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
423 while(fp_getline(fp, c)) {
424 /* skip comments and blank lines */
425 if(c->line[0] == '#' || c->line[0] == '\0') continue;
426 if(fp_parse_line(c)) goto badline;
429 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: bad config line (ignored)\n", fname, c->lineno, 0);
433 rc = parse_config_table(SystemConfiguration, c);
435 if(rc & ARGS_USERLAND) switch(rc) { /* XXX a usertype would be opaque here */
436 default: Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: unknown user type <%d>\n",
437 c->fname, c->lineno, *c->argv);
439 } else if(rc == ARG_BAD_CONF || rc != ARG_UNKNOWN) {
441 } else if(c->bi && c->bi->bi_config) { /* XXX to check: could both be/bi_config? oops */
442 if(rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv)) switch(rc) {
443 case SLAP_CONF_UNKNOWN:
444 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
445 "unknown directive <%s> inside backend info definition (ignored)\n",
446 c->fname, c->lineno, *c->argv);
451 } else if(c->be && c->be->be_config) {
452 if(rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv)) switch(rc) {
453 case SLAP_CONF_UNKNOWN:
454 Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
455 "unknown directive <%s> inside backend database definition (ignored)\n",
456 c->fname, c->lineno, *c->argv);
461 } else if(frontendDB->be_config) {
462 if(rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv)) switch(rc) {
463 case SLAP_CONF_UNKNOWN:
464 Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
465 "%s: line %lu: unknown directive <%s> inside global database definition (ignored)\n",
466 c->fname, c->lineno, *c->argv);
472 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
473 "unknown directive <%s> outside backend info and database definitions (ignored)\n",
474 c->fname, c->lineno, *c->argv);
482 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
483 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
484 &frontendDB->be_schemadn );
485 dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
500 config_generic(ConfigArgs *c) {
501 char *p = strchr(c->line,'(' /*')'*/);
506 if(!(c->bi = backend_info(c->argv[1]))) {
507 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
508 "backend %s failed init!\n", c->fname, c->lineno, c->argv[1]);
515 if(!(c->be = backend_db_init(c->argv[1]))) {
516 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
517 "database %s failed init!\n", c->fname, c->lineno, c->argv[1]);
523 ldap_pvt_thread_set_concurrency(c->value_long);
527 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
528 connection_pool_max = c->value_int; /* save for reference */
532 lutil_salt_format(c->argv[1]);
536 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
542 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
544 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
548 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
553 /* XXX slap_sasl_config doesn't actually use the line argument */
554 if(slap_sasl_config(c->argc, c->argv, c->line, c->fname, c->lineno))
559 c->be->be_max_deref_depth = c->value_int;
563 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv)) return(1);
567 if(parse_oc(c->fname, c->lineno, p, c->argv)) return(1);
571 if(parse_cr(c->fname, c->lineno, p, c->argv)) return(1);
575 if(parse_at(c->fname, c->lineno, p, c->argv)) return(1);
579 ad_define_option(NULL, NULL, 0);
580 for(i = 1; i < c->argc; i++)
581 if(ad_define_option(c->argv[i], c->fname, c->lineno))
586 global_schemacheck = c->value_int;
587 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
588 "schema checking disabled! your mileage may vary!\n",
589 c->fname, c->lineno, 0);
593 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
598 c->be->be_auditlogfile = c->value_string;
603 if(SLAP_MONITOR(c->be)) {
604 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
605 "\"replogfile\" should not be used "
606 "inside monitor database\n",
607 c->fname, c->lineno, 0);
608 return(0); /* FIXME: should this be an error? */
611 c->be->be_replogfile = c->value_string;
615 if(read_root_dse_file(c->argv[1])) {
616 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
617 "could not read \"rootDSE <filename>\" line\n",
618 c->fname, c->lineno, 0);
624 FILE *logfile = fopen(c->argv[1], "w");
625 if(logfile) lutil_debug_file(logfile);
630 if(SLAP_NOLASTMODCMD(c->be)) {
631 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
632 "lastmod not available for %s databases\n",
633 c->fname, c->lineno, c->be->bd_info->bi_type);
637 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
639 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
644 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
649 if(module_path(c->argv[1])) return(1);
655 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
657 slapi_plugins_used++;
661 #ifdef SLAP_AUTH_REWRITE
663 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
670 Debug(LDAP_DEBUG_ANY, "%s: line %lu: unknown CFG_TYPE %d"
671 "(ignored)\n", c->fname, c->lineno, c->type);
679 config_search_base(ConfigArgs *c) {
683 Debug(LDAP_DEBUG_ANY, "%s: line %lu: defaultSearchBase line must appear "
684 "prior to any backend or database definition\n",
685 c->fname, c->lineno, 0);
689 if(default_search_nbase.bv_len) {
690 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
691 "default search base \"%s\" already defined "
692 "(discarding old)\n",
693 c->fname, c->lineno, default_search_base.bv_val);
694 free(default_search_base.bv_val);
695 free(default_search_nbase.bv_val);
698 ber_str2bv(c->argv[1], 0, 1, &dn);
699 rc = dnPrettyNormal(NULL, &dn, &default_search_base, &default_search_nbase, NULL);
701 if(rc != LDAP_SUCCESS) {
702 Debug(LDAP_DEBUG_ANY,
703 "%s: line %lu: defaultSearchBase DN is invalid\n",
704 c->fname, c->lineno, 0 );
711 config_passwd_hash(ConfigArgs *c) {
713 if(default_passwd_hash) {
714 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
715 "already set default password_hash\n",
716 c->fname, c->lineno, 0);
719 for(i = 1; i < c->argc; i++) {
720 if(!lutil_passwd_scheme(c->argv[i])) {
721 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
722 "password scheme \"%s\" not available\n",
723 c->fname, c->lineno, c->argv[i] );
725 ldap_charray_add(&default_passwd_hash, c->argv[i]);
727 if(!default_passwd_hash) {
728 Debug(LDAP_DEBUG_ANY, "%s: line %lu: no valid hashes found\n",
729 c->fname, c->lineno, 0 );
737 config_schema_dn(ConfigArgs *c) {
740 ber_str2bv(c->argv[1], 0, 1, &dn);
741 rc = dnPrettyNormal(NULL, &dn, &c->be->be_schemadn, &c->be->be_schemandn, NULL);
742 if(rc != LDAP_SUCCESS) {
743 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
744 "schema DN is invalid\n", c->fname, c->lineno, 0);
751 config_sizelimit(ConfigArgs *c) {
754 struct slap_limits_set *lim = &c->be->be_def_limit;
755 for(i = 1; i < c->argc; i++) {
756 if(!strncasecmp(c->argv[i], "size", 4)) {
757 if(rc = limits_parse_one(c->argv[i], lim)) {
758 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
759 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
760 c->fname, c->lineno, c->argv[i]);
764 if(!strcasecmp(c->argv[i], "unlimited")) {
765 lim->lms_s_soft = -1;
767 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
768 if(next == c->argv[i]) {
769 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
770 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
771 c->fname, c->lineno, c->argv[i]);
773 } else if(next[0] != '\0') {
774 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
775 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
776 c->fname, c->lineno, next);
786 config_timelimit(ConfigArgs *c) {
789 struct slap_limits_set *lim = &c->be->be_def_limit;
790 for(i = 1; i < c->argc; i++) {
791 if(!strncasecmp(c->argv[i], "time", 4)) {
792 if(rc = limits_parse_one(c->argv[i], lim)) {
793 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
794 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
795 c->fname, c->lineno, c->argv[i]);
799 if(!strcasecmp(c->argv[i], "unlimited")) {
800 lim->lms_t_soft = -1;
802 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
803 if(next == c->argv[i]) {
804 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
805 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
806 c->fname, c->lineno, c->argv[i]);
808 } else if(next[0] != '\0') {
809 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
810 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
811 c->fname, c->lineno, next);
821 config_overlay(ConfigArgs *c) {
822 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
824 Debug(LDAP_DEBUG_ANY, "%s: line %lu: (optional) %s",
825 c->fname, c->lineno, c->be == frontendDB ? "global " : "");
826 Debug(LDAP_DEBUG_ANY, "overlay \"%s\" configuration "
827 "failed (ignored)\n", c->argv[1][1], 0, 0);
828 } else if(overlay_config(c->be, c->argv[1])) {
835 config_suffix(ConfigArgs *c) {
837 struct berval dn, pdn, ndn;
839 #ifdef SLAPD_MONITOR_DN
840 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
841 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
842 "%s\" is reserved for monitoring slapd\n",
843 c->fname, c->lineno, SLAPD_MONITOR_DN);
847 ber_str2bv(c->argv[1], 0, 1, &dn);
849 rc = dnPrettyNormal(NULL, &dn, &pdn, &ndn, NULL);
850 if(rc != LDAP_SUCCESS) {
851 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix DN is invalid\n",
852 c->fname, c->lineno, 0);
855 tbe = select_backend(&ndn, 0, 0);
857 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix already served by this backend! (ignored)\n",
858 c->fname, c->lineno, 0);
862 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix already served by a preceding backend \"%s\"\n",
863 c->fname, c->lineno, tbe->be_suffix[0].bv_val);
867 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
868 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix DN empty and default search "
869 "base provided \"%s\" (assuming okay)\n",
870 c->fname, c->lineno, default_search_base.bv_val);
872 ber_bvarray_add(&c->be->be_suffix, &pdn);
873 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
878 config_rootdn(ConfigArgs *c) {
882 ber_str2bv(c->argv[1], 0, 1, &dn);
884 rc = dnPrettyNormal(NULL, &dn, &c->be->be_rootdn, &c->be->be_rootndn, NULL);
886 if(rc != LDAP_SUCCESS) {
887 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
888 "rootdn DN is invalid\n", c->fname, c->lineno, 0);
895 config_rootpw(ConfigArgs *c) {
896 Backend *tbe = select_backend(&c->be->be_rootndn, 0, 0);
898 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
899 "rootpw can only be set when rootdn is under suffix\n",
900 c->fname, c->lineno, 0);
903 ber_str2bv(c->argv[1], 0, 1, &c->be->be_rootpw);
907 /* restrictops, allows, disallows, requires, loglevel */
909 struct verb_mask_list { char *word; int mask; };
912 verb_to_mask(ConfigArgs *c, struct verb_mask_list *v, int word) {
914 for(j = 0; v[j].word; j++)
915 if(!strcasecmp(c->argv[word], v[j].word))
921 verbs_to_mask(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t *m) {
923 for(i = 1; i < c->argc; i++) {
924 j = verb_to_mask(c, v, i);
925 if(!v[j].word) return(1);
932 config_restrict(ConfigArgs *c) {
933 slap_mask_t restrictops = 0;
935 struct verb_mask_list restrictable_exops[] = {
936 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
937 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
938 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
939 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
942 struct verb_mask_list restrictable_ops[] = {
943 { "bind", SLAP_RESTRICT_OP_BIND },
944 { "add", SLAP_RESTRICT_OP_ADD },
945 { "modify", SLAP_RESTRICT_OP_MODIFY },
946 { "modrdn", SLAP_RESTRICT_OP_RENAME },
947 { "rename", SLAP_RESTRICT_OP_RENAME },
948 { "delete", SLAP_RESTRICT_OP_DELETE },
949 { "search", SLAP_RESTRICT_OP_SEARCH },
950 { "compare", SLAP_RESTRICT_OP_COMPARE },
951 { "read", SLAP_RESTRICT_OP_READS },
952 { "write", SLAP_RESTRICT_OP_WRITES },
956 for(i = 1; i < c->argc; i++) {
957 j = verb_to_mask(c, restrictable_ops, i);
958 if(restrictable_ops[j].word) {
959 restrictops |= restrictable_ops[j].mask;
961 } else if(!strncasecmp(c->argv[i], "extended", STRLENOF("extended"))) {
962 char *e = c->argv[i] + STRLENOF("extended");
964 int k = verb_to_mask(c, restrictable_exops, e[1]);
965 if(restrictable_exops[k].word) {
966 restrictops |= restrictable_exops[k].mask;
970 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
971 restrictops |= SLAP_RESTRICT_OP_EXTENDED;
976 c->be->be_restrictops |= restrictops;
979 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
980 "unknown operation %s in \"restrict <features>\" line\n",
981 c->fname, c->lineno, c->argv[i]);
986 config_allows(ConfigArgs *c) {
987 slap_mask_t allows = 0;
989 struct verb_mask_list allowable_ops[] = {
990 { "bind_v2", SLAP_ALLOW_BIND_V2 },
991 { "bind_anon_cred", SLAP_ALLOW_BIND_ANON_CRED },
992 { "bind_anon_dn", SLAP_ALLOW_BIND_ANON_DN },
993 { "update_anon", SLAP_ALLOW_UPDATE_ANON },
996 if(i = verbs_to_mask(c, allowable_ops, &allows)) {
997 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
998 "unknown feature %s in \"allow <features>\" line\n",
999 c->fname, c->lineno, c->argv[i]);
1002 global_allows |= allows;
1007 config_disallows(ConfigArgs *c) {
1008 slap_mask_t disallows = 0;
1010 struct verb_mask_list disallowable_ops[] = {
1011 { "bind_anon", SLAP_DISALLOW_BIND_ANON },
1012 { "bind_simple", SLAP_DISALLOW_BIND_SIMPLE },
1013 { "bind_krb4", SLAP_DISALLOW_BIND_KRBV4 },
1014 { "tls_2_anon", SLAP_DISALLOW_TLS_2_ANON },
1015 { "tls_authc", SLAP_DISALLOW_TLS_AUTHC },
1018 if(i = verbs_to_mask(c, disallowable_ops, &disallows)) {
1019 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1020 "unknown feature %s in \"disallow <features>\" line\n",
1021 c->fname, c->lineno, c->argv[i]);
1024 global_disallows |= disallows;
1029 config_requires(ConfigArgs *c) {
1030 slap_mask_t requires = 0;
1032 struct verb_mask_list requires_ops[] = {
1033 { "bind", SLAP_REQUIRE_BIND },
1034 { "LDAPv3", SLAP_REQUIRE_LDAP_V3 },
1035 { "authc", SLAP_REQUIRE_AUTHC },
1036 { "sasl", SLAP_REQUIRE_SASL },
1037 { "strong", SLAP_REQUIRE_STRONG },
1040 if(i = verbs_to_mask(c, requires_ops, &requires)) {
1041 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1042 "unknown feature %s in \"require <features>\" line\n",
1043 c->fname, c->lineno, c->argv[i]);
1046 c->be->be_requires = requires;
1051 config_loglevel(ConfigArgs *c) {
1054 struct verb_mask_list loglevel_ops[] = {
1055 { "Trace", LDAP_DEBUG_TRACE },
1056 { "Packets", LDAP_DEBUG_PACKETS },
1057 { "Args", LDAP_DEBUG_ARGS },
1058 { "Conns", LDAP_DEBUG_CONNS },
1059 { "BER", LDAP_DEBUG_BER },
1060 { "Filter", LDAP_DEBUG_FILTER },
1061 { "Config", LDAP_DEBUG_CONFIG },
1062 { "ACL", LDAP_DEBUG_ACL },
1063 { "Stats", LDAP_DEBUG_STATS },
1064 { "Stats2", LDAP_DEBUG_STATS2 },
1065 { "Shell", LDAP_DEBUG_SHELL },
1066 { "Parse", LDAP_DEBUG_PARSE },
1067 { "Cache", LDAP_DEBUG_CACHE },
1068 { "Index", LDAP_DEBUG_INDEX },
1074 for( i=1; i < c->argc; i++ ) {
1077 if ( isdigit( c->argv[i][0] ) ) {
1078 level = strtol( c->argv[i], &next, 10 );
1079 if ( next == NULL || next[0] != '\0' ) {
1080 Debug( LDAP_DEBUG_ANY,
1081 "%s: line %lu: unable to parse level \"%s\" "
1082 "in \"loglevel <level> [...]\" line.\n",
1083 c->fname, c->lineno , c->argv[i] );
1087 int j = verb_to_mask(c, loglevel_ops, c->argv[i][0]);
1088 if(!loglevel_ops[j].word) {
1089 Debug( LDAP_DEBUG_ANY,
1090 "%s: line %lu: unknown level \"%s\" "
1091 "in \"loglevel <level> [...]\" line.\n",
1092 c->fname, c->lineno , c->argv[i] );
1095 level = loglevel_ops[j].mask;
1097 ldap_syslog |= level;
1103 config_syncrepl(ConfigArgs *c) {
1104 if(SLAP_SHADOW(c->be)) {
1105 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1106 "syncrepl: database already shadowed.\n",
1107 c->fname, c->lineno, 0);
1109 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1112 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1117 config_referral(ConfigArgs *c) {
1118 struct berval vals[2];
1119 if(validate_global_referral(c->argv[1])) {
1120 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1121 "invalid URL (%s) in \"referral\" line.\n",
1122 c->fname, c->lineno, c->argv[1] );
1126 ber_str2bv(c->argv[1], 0, 1, &vals[0]);
1127 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1128 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1133 config_security(ConfigArgs *c) {
1134 slap_ssf_set_t *set = &c->be->be_ssf_set;
1137 for(i = 1; i < c->argc; i++) {
1140 if(!strncasecmp(c->argv[i], "ssf=", 4)) {
1141 tgt = &set->sss_ssf;
1142 src = &c->argv[i][4];
1143 } else if(!strncasecmp(c->argv[i], "transport=", 10)) {
1144 tgt = &set->sss_transport;
1145 src = &c->argv[i][10];
1146 } else if(!strncasecmp(c->argv[i], "tls=", 4)) {
1147 tgt = &set->sss_tls;
1148 src = &c->argv[i][4];
1149 } else if(!strncasecmp(c->argv[i], "sasl=", 5)) {
1150 tgt = &set->sss_sasl;
1151 src = &c->argv[i][5];
1152 } else if(!strncasecmp(c->argv[i], "update_ssf=", 11)) {
1153 tgt = &set->sss_update_ssf;
1154 src = &c->argv[i][11];
1155 } else if(!strncasecmp(c->argv[i], "update_transport=", 17)) {
1156 tgt = &set->sss_update_transport;
1157 src = &c->argv[i][17];
1158 } else if(!strncasecmp(c->argv[i], "update_tls=", 11)) {
1159 tgt = &set->sss_update_tls;
1160 src = &c->argv[i][11];
1161 } else if(!strncasecmp(c->argv[i], "update_sasl=", 12)) {
1162 tgt = &set->sss_update_sasl;
1163 src = &c->argv[i][12];
1164 } else if(!strncasecmp(c->argv[i], "simple_bind=", 12)) {
1165 tgt = &set->sss_simple_bind;
1166 src = &c->argv[i][12];
1168 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1169 "unknown factor %s in \"security <factors>\" line\n",
1170 c->fname, c->lineno, c->argv[i]);
1174 *tgt = strtol(src, &next, 10);
1175 if(next == NULL || next[0] != '\0' ) {
1176 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1177 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1178 c->fname, c->lineno, c->argv[i]);
1186 config_replica(ConfigArgs *c) {
1191 if(SLAP_MONITOR(c->be)) {
1192 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1193 "\"replica\" should not be used inside monitor database\n",
1194 c->fname, c->lineno, 0);
1195 return(0); /* FIXME: should this be an error? */
1198 for(i = 1; i < c->argc; i++) {
1199 if(!strncasecmp(c->argv[i], "host=", 5)) {
1200 nr = add_replica_info(c->be, c->argv[i] + 5);
1202 } else if(!strncasecmp(c->argv[i], "uri=", 4)) {
1203 if(ldap_url_parse(c->argv[i] + 4, &ludp) != LDAP_SUCCESS) {
1204 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1205 "replica line contains invalid "
1206 "uri definition.\n", c->fname, c->lineno, 0);
1209 if(!ludp->lud_host) {
1210 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1211 "replica line contains invalid "
1212 "uri definition - missing hostname.\n", c->fname, c->lineno, 0);
1215 replicahost = ch_malloc(strlen(c->argv[i]));
1217 Debug(LDAP_DEBUG_ANY,
1218 "out of memory in read_config\n", 0, 0, 0);
1219 ldap_free_urldesc(ludp);
1222 sprintf(replicahost, "%s:%d", ludp->lud_host, ludp->lud_port);
1223 nr = add_replica_info(c->be, replicahost);
1224 ldap_free_urldesc(ludp);
1225 ch_free(replicahost);
1230 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1231 "missing host or uri in \"replica\" line\n",
1232 c->fname, c->lineno, 0);
1234 } else if(nr == -1) {
1235 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1236 "unable to add replica \"%s\"\n",
1237 c->fname, c->lineno, c->argv[i] + 5);
1240 for(i = 1; i < c->argc; i++) {
1241 if(!strncasecmp(c->argv[i], "suffix=", 7)) {
1242 switch(add_replica_suffix(c->be, nr, c->argv[i] + 7)) {
1244 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1245 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1246 c->fname, c->lineno, c->argv[i] + 7);
1249 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1250 "unable to normalize suffix in \"replica\" line (ignored)\n",
1251 c->fname, c->lineno, 0);
1255 } else if(!strncasecmp(c->argv[i], "attr", 4)) {
1257 char *arg = c->argv[i] + 4;
1265 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1266 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1267 "attribute \"%s\" in \"replica\" line is unknown\n",
1268 c->fname, c->lineno, arg + 1);
1278 config_updatedn(ConfigArgs *c) {
1281 if(SLAP_SHADOW(c->be)) {
1282 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1283 "updatedn: database already shadowed.\n",
1284 c->fname, c->lineno, 0);
1288 ber_str2bv(c->argv[1], 0, 0, &dn);
1290 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1292 if(rc != LDAP_SUCCESS) {
1293 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1294 "updatedn DN is invalid\n", c->fname, c->lineno, 0);
1298 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1303 config_updateref(ConfigArgs *c) {
1304 struct berval vals[2];
1305 if(!SLAP_SHADOW(c->be)) {
1306 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1307 "updateref line must after syncrepl or updatedn.\n",
1308 c->fname, c->lineno, 0);
1312 if(validate_global_referral(c->argv[1])) {
1313 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1314 "invalid URL (%s) in \"updateref\" line.\n",
1315 c->fname, c->lineno, c->argv[1]);
1318 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1319 vals[1].bv_val = NULL;
1320 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1324 /* XXX meaningless in ldif */
1327 config_include(ConfigArgs *c) {
1328 char *savefname = ch_strdup(c->argv[1]);
1329 unsigned long savelineno = c->lineno;
1331 rc = read_config_file(savefname, c->depth + 1, c);
1333 c->lineno = savelineno - 1;
1339 config_tls_option(ConfigArgs *c) {
1342 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
1343 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
1344 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
1345 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
1346 case CFG_TLS_CERT_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
1347 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
1348 #ifdef HAVE_OPENSSL_CRL
1349 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
1351 default: Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1352 "unknown tls_option <%x>\n",
1353 c->fname, c->lineno, c->type);
1355 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
1359 config_tls_verify(ConfigArgs *c) {
1361 if(isdigit((unsigned char)c->argv[1][0])) {
1362 i = atoi(c->argv[1]);
1363 return(ldap_pvt_tls_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i));
1365 return(ldap_int_tls_config(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, c->argv[1]));
1370 /* -------------------------------------- */
1374 strtok_quote( char *line, char *sep )
1380 strtok_quote_ptr = NULL;
1381 if ( line != NULL ) {
1384 while ( *next && strchr( sep, *next ) ) {
1388 if ( *next == '\0' ) {
1394 for ( inquote = 0; *next; ) {
1402 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1408 next + 1, strlen( next + 1 ) + 1 );
1409 next++; /* dont parse the escaped character */
1414 if ( strchr( sep, *next ) != NULL ) {
1415 strtok_quote_ptr = next;
1428 static char buf[BUFSIZ];
1430 static size_t lmax, lcur;
1432 #define CATLINE( buf ) \
1434 size_t len = strlen( buf ); \
1435 while ( lcur + len + 1 > lmax ) { \
1437 line = (char *) ch_realloc( line, lmax ); \
1439 strcpy( line + lcur, buf ); \
1444 fp_getline_init(ConfigArgs *c) {
1450 fp_getline(FILE *fp, ConfigArgs *c)
1458 /* avoid stack of bufs */
1459 if(strncasecmp(line, "include", 7) == 0) {
1465 while(fgets(buf, sizeof(buf), fp)) {
1466 if(p = strchr(buf, '\n')) {
1467 if(p > buf && p[-1] == '\r') --p;
1472 if(line[0] && (p = line + strlen(line) - 1)[0] == '\\' && p[-1] != '\\' ) {
1476 if(!isspace((unsigned char)buf[0])) return(1);
1485 return(line[0] ? 1 : 0);
1489 fp_parse_line(ConfigArgs *c)
1492 char *tline = ch_strdup(c->line);
1493 char logbuf[STRLENOF("pseudorootpw ***")]; /* longest secret */
1494 char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
1498 token = strtok_quote(tline, " \t");
1500 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
1501 if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
1502 Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
1503 if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
1505 for(; token; token = strtok_quote(NULL, " \t")) {
1506 if(c->argc == c->argv_size - 1) {
1508 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
1510 Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0);
1514 c->argv_size += ARGS_STEP;
1516 c->argv[c->argc++] = token;
1518 c->argv[c->argc] = NULL;
1524 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1526 load_ucdata( char *path )
1529 static int loaded = 0;
1535 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
1537 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
1545 /* ucdata is now hardcoded */
1554 ucdata_unload( UCDATA_ALL );
1556 /* NOTE: in case of early exit, frontendDB can be NULL */
1557 if ( frontendDB->be_schemandn.bv_val )
1558 free( frontendDB->be_schemandn.bv_val );
1559 if ( frontendDB->be_schemadn.bv_val )
1560 free( frontendDB->be_schemadn.bv_val );
1561 if ( frontendDB->be_acl )
1562 acl_destroy( frontendDB->be_acl, NULL );
1565 if ( slapd_args_file )
1566 free ( slapd_args_file );
1567 if ( slapd_pid_file )
1568 free ( slapd_pid_file );
1569 if ( default_passwd_hash )
1570 ldap_charray_free( default_passwd_hash );
1581 syncinfo_t *si_entry;
1583 int duplicated_replica_id = 0;
1585 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
1588 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
1592 si->si_tls = SYNCINFO_TLS_OFF;
1593 if ( be->be_rootndn.bv_val ) {
1594 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
1596 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1597 si->si_schemachecking = 0;
1598 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
1599 &si->si_filterstr );
1600 si->si_base.bv_val = NULL;
1601 si->si_scope = LDAP_SCOPE_SUBTREE;
1602 si->si_attrsonly = 0;
1603 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1604 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1605 si->si_attrs = NULL;
1606 si->si_allattrs = 0;
1607 si->si_allopattrs = 0;
1608 si->si_exattrs = NULL;
1609 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1610 si->si_interval = 86400;
1611 si->si_retryinterval = NULL;
1612 si->si_retrynum_init = NULL;
1613 si->si_retrynum = NULL;
1614 si->si_syncCookie.ctxcsn = NULL;
1615 si->si_syncCookie.octet_str = NULL;
1616 si->si_syncCookie.sid = -1;
1617 si->si_manageDSAit = 0;
1621 si->si_presentlist = NULL;
1622 LDAP_LIST_INIT( &si->si_nonpresentlist );
1624 rc = parse_syncrepl_line( cargv, cargc, si );
1626 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
1627 if ( si->si_rid == si_entry->si_rid ) {
1628 Debug( LDAP_DEBUG_ANY,
1629 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
1630 duplicated_replica_id = 1;
1635 if ( rc < 0 || duplicated_replica_id ) {
1636 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
1637 syncinfo_free( si );
1640 Debug( LDAP_DEBUG_CONFIG,
1641 "Config: ** successfully added syncrepl \"%s\"\n",
1642 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
1643 if ( !si->si_schemachecking ) {
1644 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
1647 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
1652 /* NOTE: used & documented in slapd.conf(5) */
1654 #define PROVIDERSTR "provider"
1655 #define TYPESTR "type"
1656 #define INTERVALSTR "interval"
1657 #define SEARCHBASESTR "searchbase"
1658 #define FILTERSTR "filter"
1659 #define SCOPESTR "scope"
1660 #define ATTRSSTR "attrs"
1661 #define ATTRSONLYSTR "attrsonly"
1662 #define SLIMITSTR "sizelimit"
1663 #define TLIMITSTR "timelimit"
1664 #define SCHEMASTR "schemachecking"
1665 #define UPDATEDNSTR "updatedn"
1666 #define BINDMETHSTR "bindmethod"
1667 #define SIMPLESTR "simple"
1668 #define SASLSTR "sasl"
1669 #define BINDDNSTR "binddn"
1670 #define SASLMECHSTR "saslmech"
1671 #define AUTHCSTR "authcID"
1672 #define AUTHZSTR "authzID"
1673 #define CREDSTR "credentials"
1674 #define REALMSTR "realm"
1675 #define SECPROPSSTR "secprops"
1677 /* FIXME: undocumented */
1678 #define OLDAUTHCSTR "bindprincipal"
1679 #define STARTTLSSTR "starttls"
1680 #define CRITICALSTR "critical"
1681 #define EXATTRSSTR "exattrs"
1682 #define MANAGEDSAITSTR "manageDSAit"
1683 #define RETRYSTR "retry"
1686 #define LASTMODSTR "lastmod"
1687 #define LMGENSTR "gen"
1688 #define LMNOSTR "no"
1689 #define LMREQSTR "req"
1690 #define SRVTABSTR "srvtab"
1691 #define SUFFIXSTR "suffix"
1694 #define GOT_ID 0x0001
1695 #define GOT_PROVIDER 0x0002
1696 #define GOT_METHOD 0x0004
1699 #define GOT_ALL (GOT_ID|GOT_PROVIDER|GOT_METHOD)
1702 parse_syncrepl_line(
1713 for ( i = 1; i < cargc; i++ ) {
1714 if ( !strncasecmp( cargv[ i ], IDSTR "=",
1715 STRLENOF( IDSTR "=" ) ) )
1718 /* '\0' string terminator accounts for '=' */
1719 val = cargv[ i ] + STRLENOF( IDSTR "=" );
1721 if ( tmp >= 1000 || tmp < 0 ) {
1722 fprintf( stderr, "Error: parse_syncrepl_line: "
1723 "syncrepl id %d is out of range [0..999]\n", tmp );
1728 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
1729 STRLENOF( PROVIDERSTR "=" ) ) )
1731 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
1732 si->si_provideruri = ch_strdup( val );
1733 si->si_provideruri_bv = (BerVarray)
1734 ch_calloc( 2, sizeof( struct berval ));
1735 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
1736 1, &si->si_provideruri_bv[0] );
1737 si->si_provideruri_bv[1].bv_len = 0;
1738 si->si_provideruri_bv[1].bv_val = NULL;
1739 gots |= GOT_PROVIDER;
1740 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=",
1741 STRLENOF(STARTTLSSTR "=") ) )
1743 val = cargv[ i ] + STRLENOF( STARTTLSSTR "=" );
1744 if( !strcasecmp( val, CRITICALSTR ) ) {
1745 si->si_tls = SYNCINFO_TLS_CRITICAL;
1747 si->si_tls = SYNCINFO_TLS_ON;
1749 } else if ( !strncasecmp( cargv[ i ], UPDATEDNSTR "=",
1750 STRLENOF( UPDATEDNSTR "=" ) ) )
1752 struct berval updatedn = BER_BVNULL;
1754 val = cargv[ i ] + STRLENOF( UPDATEDNSTR "=" );
1755 ber_str2bv( val, 0, 0, &updatedn );
1756 ch_free( si->si_updatedn.bv_val );
1757 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
1758 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR "=",
1759 STRLENOF( BINDMETHSTR "=" ) ) )
1761 val = cargv[ i ] + STRLENOF( BINDMETHSTR "=" );
1762 if ( !strcasecmp( val, SIMPLESTR )) {
1763 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1765 } else if ( !strcasecmp( val, SASLSTR )) {
1766 #ifdef HAVE_CYRUS_SASL
1767 si->si_bindmethod = LDAP_AUTH_SASL;
1769 #else /* HAVE_CYRUS_SASL */
1770 fprintf( stderr, "Error: parse_syncrepl_line: "
1771 "not compiled with SASL support\n" );
1773 #endif /* HAVE_CYRUS_SASL */
1775 si->si_bindmethod = -1;
1777 } else if ( !strncasecmp( cargv[ i ], BINDDNSTR "=",
1778 STRLENOF( BINDDNSTR "=" ) ) )
1780 val = cargv[ i ] + STRLENOF( BINDDNSTR "=" );
1781 si->si_binddn = ch_strdup( val );
1782 } else if ( !strncasecmp( cargv[ i ], CREDSTR "=",
1783 STRLENOF( CREDSTR "=" ) ) )
1785 val = cargv[ i ] + STRLENOF( CREDSTR "=" );
1786 si->si_passwd = ch_strdup( val );
1787 } else if ( !strncasecmp( cargv[ i ], SASLMECHSTR "=",
1788 STRLENOF( SASLMECHSTR "=" ) ) )
1790 val = cargv[ i ] + STRLENOF( SASLMECHSTR "=" );
1791 si->si_saslmech = ch_strdup( val );
1792 } else if ( !strncasecmp( cargv[ i ], SECPROPSSTR "=",
1793 STRLENOF( SECPROPSSTR "=" ) ) )
1795 val = cargv[ i ] + STRLENOF( SECPROPSSTR "=" );
1796 si->si_secprops = ch_strdup( val );
1797 } else if ( !strncasecmp( cargv[ i ], REALMSTR "=",
1798 STRLENOF( REALMSTR "=" ) ) )
1800 val = cargv[ i ] + STRLENOF( REALMSTR "=" );
1801 si->si_realm = ch_strdup( val );
1802 } else if ( !strncasecmp( cargv[ i ], AUTHCSTR "=",
1803 STRLENOF( AUTHCSTR "=" ) ) )
1805 val = cargv[ i ] + STRLENOF( AUTHCSTR "=" );
1806 if ( si->si_authcId )
1807 ch_free( si->si_authcId );
1808 si->si_authcId = ch_strdup( val );
1809 } else if ( !strncasecmp( cargv[ i ], OLDAUTHCSTR "=",
1810 STRLENOF( OLDAUTHCSTR "=" ) ) )
1812 /* Old authcID is provided for some backwards compatibility */
1813 val = cargv[ i ] + STRLENOF( OLDAUTHCSTR "=" );
1814 if ( si->si_authcId )
1815 ch_free( si->si_authcId );
1816 si->si_authcId = ch_strdup( val );
1817 } else if ( !strncasecmp( cargv[ i ], AUTHZSTR "=",
1818 STRLENOF( AUTHZSTR "=" ) ) )
1820 val = cargv[ i ] + STRLENOF( AUTHZSTR "=" );
1821 si->si_authzId = ch_strdup( val );
1822 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
1823 STRLENOF( SCHEMASTR "=" ) ) )
1825 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
1826 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
1827 si->si_schemachecking = 1;
1828 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
1829 si->si_schemachecking = 0;
1831 si->si_schemachecking = 1;
1833 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
1834 STRLENOF( FILTERSTR "=" ) ) )
1836 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
1837 ber_str2bv( val, 0, 1, &si->si_filterstr );
1838 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
1839 STRLENOF( SEARCHBASESTR "=" ) ) )
1842 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
1843 if ( si->si_base.bv_val ) {
1844 ch_free( si->si_base.bv_val );
1846 ber_str2bv( val, 0, 0, &bv );
1847 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
1848 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
1851 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
1852 STRLENOF( SCOPESTR "=" ) ) )
1854 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
1855 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
1856 si->si_scope = LDAP_SCOPE_BASE;
1857 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
1858 si->si_scope = LDAP_SCOPE_ONELEVEL;
1859 #ifdef LDAP_SCOPE_SUBORDINATE
1860 } else if ( !strcasecmp( val, "subordinate" ) ||
1861 !strcasecmp( val, "children" ))
1863 si->si_scope = LDAP_SCOPE_SUBORDINATE;
1865 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
1866 si->si_scope = LDAP_SCOPE_SUBTREE;
1868 fprintf( stderr, "Error: parse_syncrepl_line: "
1869 "unknown scope \"%s\"\n", val);
1872 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
1873 STRLENOF( ATTRSONLYSTR "=" ) ) )
1875 si->si_attrsonly = 1;
1876 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
1877 STRLENOF( ATTRSSTR "=" ) ) )
1879 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
1880 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
1882 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1883 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
1884 if ( si->si_anlist == NULL ) {
1885 ch_free( attr_fname );
1888 ch_free( attr_fname );
1890 char *str, *s, *next;
1891 char delimstr[] = " ,\t";
1892 str = ch_strdup( val );
1893 for ( s = ldap_pvt_strtok( str, delimstr, &next );
1895 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
1897 if ( strlen(s) == 1 && *s == '*' ) {
1898 si->si_allattrs = 1;
1899 *(val + ( s - str )) = delimstr[0];
1901 if ( strlen(s) == 1 && *s == '+' ) {
1902 si->si_allopattrs = 1;
1903 *(val + ( s - str )) = delimstr[0];
1907 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
1908 if ( si->si_anlist == NULL ) {
1912 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
1913 STRLENOF( EXATTRSSTR "=" ) ) )
1915 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
1916 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
1918 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1919 si->si_exanlist = file2anlist(
1920 si->si_exanlist, attr_fname, " ,\t" );
1921 if ( si->si_exanlist == NULL ) {
1922 ch_free( attr_fname );
1925 ch_free( attr_fname );
1928 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
1929 if ( si->si_exanlist == NULL ) {
1933 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
1934 STRLENOF( TYPESTR "=" ) ) )
1936 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
1937 if ( !strncasecmp( val, "refreshOnly",
1938 STRLENOF("refreshOnly") ))
1940 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1941 } else if ( !strncasecmp( val, "refreshAndPersist",
1942 STRLENOF("refreshAndPersist") ))
1944 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
1945 si->si_interval = 60;
1947 fprintf( stderr, "Error: parse_syncrepl_line: "
1948 "unknown sync type \"%s\"\n", val);
1951 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
1952 STRLENOF( INTERVALSTR "=" ) ) )
1954 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
1955 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
1956 si->si_interval = 0;
1964 hstr = strchr( dstr, ':' );
1965 if ( hstr == NULL ) {
1966 fprintf( stderr, "Error: parse_syncrepl_line: "
1967 "invalid interval \"%s\"\n", val );
1971 mstr = strchr( hstr, ':' );
1972 if ( mstr == NULL ) {
1973 fprintf( stderr, "Error: parse_syncrepl_line: "
1974 "invalid interval \"%s\"\n", val );
1978 sstr = strchr( mstr, ':' );
1979 if ( sstr == NULL ) {
1980 fprintf( stderr, "Error: parse_syncrepl_line: "
1981 "invalid interval \"%s\"\n", val );
1990 if (( hh > 24 ) || ( hh < 0 ) ||
1991 ( mm > 60 ) || ( mm < 0 ) ||
1992 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
1993 fprintf( stderr, "Error: parse_syncrepl_line: "
1994 "invalid interval \"%s\"\n", val );
1997 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
1999 if ( si->si_interval < 0 ) {
2000 fprintf( stderr, "Error: parse_syncrepl_line: "
2001 "invalid interval \"%ld\"\n",
2002 (long) si->si_interval);
2005 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2006 STRLENOF( RETRYSTR "=" ) ) )
2012 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2013 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2014 retry_list[0] = NULL;
2016 slap_str2clist( &retry_list, val, " ,\t" );
2018 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2022 "Error: incomplete syncrepl retry list\n" );
2023 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2024 ch_free( retry_list[k] );
2026 ch_free( retry_list );
2027 exit( EXIT_FAILURE );
2029 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2030 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2031 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2032 for ( j = 0; j < n; j++ ) {
2033 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2034 if ( *retry_list[j*2+1] == '+' ) {
2035 si->si_retrynum_init[j] = -1;
2036 si->si_retrynum[j] = -1;
2040 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2041 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2044 si->si_retrynum_init[j] = -2;
2045 si->si_retrynum[j] = -2;
2046 si->si_retryinterval[j] = 0;
2048 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2049 ch_free( retry_list[k] );
2051 ch_free( retry_list );
2052 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2053 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2055 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2056 si->si_manageDSAit = atoi( val );
2057 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2058 STRLENOF( SLIMITSTR "=") ) )
2060 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2061 si->si_slimit = atoi( val );
2062 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2063 STRLENOF( TLIMITSTR "=" ) ) )
2065 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2066 si->si_tlimit = atoi( val );
2068 fprintf( stderr, "Error: parse_syncrepl_line: "
2069 "unknown keyword \"%s\"\n", cargv[ i ] );
2074 if ( gots != GOT_ALL ) {
2076 "Error: Malformed \"syncrepl\" line in slapd config file" );
2084 slap_str2clist( char ***out, char *in, const char *brkstr )
2093 /* find last element in list */
2094 for (i = 0; *out && (*out)[i]; i++);
2096 /* protect the input string from strtok */
2097 str = ch_strdup( in );
2099 if ( *str == '\0' ) {
2104 /* Count words in string */
2106 for ( s = str; *s; s++ ) {
2107 if ( strchr( brkstr, *s ) != NULL ) {
2112 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
2114 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
2116 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
2118 *new = ch_strdup( s );