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) {
325 iarg = 0; larg = 0; barg = 0;
326 switch(arg_type & ARGS_NUMERIC) {
327 case ARG_INT: iarg = atoi(c->argv[1]); break;
328 case ARG_LONG: larg = atol(c->argv[1]); break;
329 case ARG_BER_LEN_T: barg = (ber_len_t)atol(c->argv[1]); break;
331 if(!strcasecmp(c->argv[1], "on")) {
333 } else if(!strcasecmp(c->argv[1], "off")) {
336 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ignoring ", c->fname, c->lineno, 0);
337 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
338 Conf[i].what, c->argv[1], Conf[i].name);
343 i = (arg_type & ARG_NONZERO) ? 1 : 0;
344 rc = (Conf == SystemConfiguration) ? ((arg_type & ARG_SPECIAL) && (larg < index_substr_if_maxlen)) : 0;
345 if(iarg < i || larg < i || barg < i || rc) {
346 larg = larg ? larg : (barg ? barg : iarg);
347 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: " , c->fname, c->lineno, 0);
348 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf[i].what, larg, Conf[i].name);
349 return(ARG_BAD_CONF);
352 c->value_long = larg;
353 c->value_ber_t = barg;
355 if(arg_type & ARG_STRING) c->value_string = ch_strdup(c->argv[1]);
356 if(arg_type & ARG_MAGIC) {
357 if(!c->be) c->be = frontendDB;
358 rc = (*((ConfigDriver*)Conf[i].arg_item))(c);
359 if(c->be == frontendDB) c->be = NULL;
361 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
362 Debug(LDAP_DEBUG_CONFIG, "handler for <%s> exited with %d!", Conf[i].name, rc, 0);
363 return(ARG_BAD_CONF);
367 if(arg_type & ARGS_POINTER) switch(arg_type & ARGS_POINTER) {
369 case ARG_INT: *((int*)Conf[i].arg_item) = iarg; break;
370 case ARG_LONG: *((long*)Conf[i].arg_item) = larg; break;
371 case ARG_BER_LEN_T: *((ber_len_t*)Conf[i].arg_item) = barg; break;
373 char *cc = *((char**)Conf[i].arg_item);
374 if(cc) ch_free(cc); /* potential memory leak */
375 cc = c->value_string;
376 /* memcpy(Conf[i].arg_item, &c->value_string, sizeof(void *)); */
384 read_config(const char *fname, int depth) {
385 return(read_config_file(fname, depth, NULL));
389 read_config_file(char *fname, int depth, ConfigArgs *cf)
392 char *line, *savefname;
396 c = ch_calloc(1, sizeof(ConfigArgs));
399 memcpy(c, cf, sizeof(ConfigArgs));
401 c->depth = depth; /* XXX */
407 c->argv = ch_calloc(ARGS_STEP + 1, sizeof(*c->argv));
408 c->argv_size = ARGS_STEP + 1;
410 if((fp = fopen(fname, "r")) == NULL) {
412 Debug(LDAP_DEBUG_ANY,
413 "could not open config file \"%s\": %s (%d)\n",
414 fname, strerror(errno), errno);
418 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
422 while(fp_getline(fp, c)) {
423 /* skip comments and blank lines */
424 if(c->line[0] == '#' || c->line[0] == '\0') continue;
425 if(fp_parse_line(c)) goto badline;
428 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: bad config line (ignored)\n", fname, c->lineno, 0);
432 rc = parse_config_table(SystemConfiguration, c);
434 if(rc & ARGS_USERLAND) switch(rc) { /* XXX a usertype would be opaque here */
435 default: Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: unknown user type <%d>\n",
436 c->fname, c->lineno, *c->argv);
438 } else if(rc == ARG_BAD_CONF || rc != ARG_UNKNOWN) {
440 } else if(c->bi && c->bi->bi_config) { /* XXX to check: could both be/bi_config? oops */
441 if(rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv)) switch(rc) {
442 case SLAP_CONF_UNKNOWN:
443 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
444 "unknown directive <%s> inside backend info definition (ignored)\n",
445 c->fname, c->lineno, *c->argv);
450 } else if(c->be && c->be->be_config) {
451 if(rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv)) switch(rc) {
452 case SLAP_CONF_UNKNOWN:
453 Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
454 "unknown directive <%s> inside backend database definition (ignored)\n",
455 c->fname, c->lineno, *c->argv);
460 } else if(frontendDB->be_config) {
461 if(rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv)) switch(rc) {
462 case SLAP_CONF_UNKNOWN:
463 Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
464 "%s: line %lu: unknown directive <%s> inside global database definition (ignored)\n",
465 c->fname, c->lineno, *c->argv);
471 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
472 "unknown directive <%s> outside backend info and database definitions (ignored)\n",
473 c->fname, c->lineno, *c->argv);
481 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
482 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1,
483 &frontendDB->be_schemadn );
484 dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
499 config_generic(ConfigArgs *c) {
500 char *p = strchr(c->line,'(' /*')'*/);
505 if(!(c->bi = backend_info(c->argv[1]))) {
506 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
507 "backend %s failed init!\n", c->fname, c->lineno, c->argv[1]);
514 if(!(c->be = backend_db_init(c->argv[1]))) {
515 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
516 "database %s failed init!\n", c->fname, c->lineno, c->argv[1]);
522 ldap_pvt_thread_set_concurrency(c->value_long);
526 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
527 connection_pool_max = c->value_int; /* save for reference */
531 lutil_salt_format(c->argv[1]);
535 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
541 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
543 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
547 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
552 /* XXX slap_sasl_config doesn't actually use the line argument */
553 if(slap_sasl_config(c->argc, c->argv, c->line, c->fname, c->lineno))
558 c->be->be_max_deref_depth = c->value_int;
562 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv)) return(1);
566 if(parse_oc(c->fname, c->lineno, p, c->argv)) return(1);
570 if(parse_cr(c->fname, c->lineno, p, c->argv)) return(1);
574 if(parse_at(c->fname, c->lineno, p, c->argv)) return(1);
578 ad_define_option(NULL, NULL, 0);
579 for(i = 1; i < c->argc; i++)
580 if(ad_define_option(c->argv[i], c->fname, c->lineno))
585 global_schemacheck = c->value_int;
586 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
587 "schema checking disabled! your mileage may vary!\n",
588 c->fname, c->lineno, 0);
592 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
597 c->be->be_auditlogfile = c->value_string;
602 if(SLAP_MONITOR(c->be)) {
603 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
604 "\"replogfile\" should not be used "
605 "inside monitor database\n",
606 c->fname, c->lineno, 0);
607 return(0); /* FIXME: should this be an error? */
610 c->be->be_replogfile = c->value_string;
614 if(read_root_dse_file(c->argv[1])) {
615 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
616 "could not read \"rootDSE <filename>\" line\n",
617 c->fname, c->lineno, 0);
623 FILE *logfile = fopen(c->argv[1], "w");
624 if(logfile) lutil_debug_file(logfile);
629 if(SLAP_NOLASTMODCMD(c->be)) {
630 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
631 "lastmod not available for %s databases\n",
632 c->fname, c->lineno, c->be->bd_info->bi_type);
636 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
638 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
643 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
648 if(module_path(c->argv[1])) return(1);
654 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
656 slapi_plugins_used++;
660 #ifdef SLAP_AUTH_REWRITE
662 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
669 Debug(LDAP_DEBUG_ANY, "%s: line %lu: unknown CFG_TYPE %d"
670 "(ignored)\n", c->fname, c->lineno, c->type);
678 config_search_base(ConfigArgs *c) {
682 Debug(LDAP_DEBUG_ANY, "%s: line %lu: defaultSearchBase line must appear "
683 "prior to any backend or database definition\n",
684 c->fname, c->lineno, 0);
688 if(default_search_nbase.bv_len) {
689 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
690 "default search base \"%s\" already defined "
691 "(discarding old)\n",
692 c->fname, c->lineno, default_search_base.bv_val);
693 free(default_search_base.bv_val);
694 free(default_search_nbase.bv_val);
697 ber_str2bv(c->argv[1], 0, 1, &dn);
698 rc = dnPrettyNormal(NULL, &dn, &default_search_base, &default_search_nbase, NULL);
700 if(rc != LDAP_SUCCESS) {
701 Debug(LDAP_DEBUG_ANY,
702 "%s: line %lu: defaultSearchBase DN is invalid\n",
703 c->fname, c->lineno, 0 );
710 config_passwd_hash(ConfigArgs *c) {
712 if(default_passwd_hash) {
713 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
714 "already set default password_hash\n",
715 c->fname, c->lineno, 0);
718 for(i = 1; i < c->argc; i++) {
719 if(!lutil_passwd_scheme(c->argv[i])) {
720 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
721 "password scheme \"%s\" not available\n",
722 c->fname, c->lineno, c->argv[i] );
724 ldap_charray_add(&default_passwd_hash, c->argv[i]);
726 if(!default_passwd_hash) {
727 Debug(LDAP_DEBUG_ANY, "%s: line %lu: no valid hashes found\n",
728 c->fname, c->lineno, 0 );
736 config_schema_dn(ConfigArgs *c) {
739 ber_str2bv(c->argv[1], 0, 1, &dn);
740 rc = dnPrettyNormal(NULL, &dn, &c->be->be_schemadn, &c->be->be_schemandn, NULL);
741 if(rc != LDAP_SUCCESS) {
742 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
743 "schema DN is invalid\n", c->fname, c->lineno, 0);
750 config_sizelimit(ConfigArgs *c) {
753 struct slap_limits_set *lim = &c->be->be_def_limit;
754 for(i = 1; i < c->argc; i++) {
755 if(!strncasecmp(c->argv[i], "size", 4)) {
756 if(rc = limits_parse_one(c->argv[i], lim)) {
757 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
758 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
759 c->fname, c->lineno, c->argv[i]);
763 if(!strcasecmp(c->argv[i], "unlimited")) {
764 lim->lms_s_soft = -1;
766 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
767 if(next == c->argv[i]) {
768 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
769 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
770 c->fname, c->lineno, c->argv[i]);
772 } else if(next[0] != '\0') {
773 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
774 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
775 c->fname, c->lineno, next);
785 config_timelimit(ConfigArgs *c) {
788 struct slap_limits_set *lim = &c->be->be_def_limit;
789 for(i = 1; i < c->argc; i++) {
790 if(!strncasecmp(c->argv[i], "time", 4)) {
791 if(rc = limits_parse_one(c->argv[i], lim)) {
792 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
793 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
794 c->fname, c->lineno, c->argv[i]);
798 if(!strcasecmp(c->argv[i], "unlimited")) {
799 lim->lms_t_soft = -1;
801 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
802 if(next == c->argv[i]) {
803 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
804 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
805 c->fname, c->lineno, c->argv[i]);
807 } else if(next[0] != '\0') {
808 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
809 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
810 c->fname, c->lineno, next);
820 config_overlay(ConfigArgs *c) {
821 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
823 Debug(LDAP_DEBUG_ANY, "%s: line %lu: (optional) %s",
824 c->fname, c->lineno, c->be == frontendDB ? "global " : "");
825 Debug(LDAP_DEBUG_ANY, "overlay \"%s\" configuration "
826 "failed (ignored)\n", c->argv[1][1], 0, 0);
827 } else if(overlay_config(c->be, c->argv[1])) {
834 config_suffix(ConfigArgs *c) {
836 struct berval dn, pdn, ndn;
838 #ifdef SLAPD_MONITOR_DN
839 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
840 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
841 "%s\" is reserved for monitoring slapd\n",
842 c->fname, c->lineno, SLAPD_MONITOR_DN);
846 ber_str2bv(c->argv[1], 0, 1, &dn);
848 rc = dnPrettyNormal(NULL, &dn, &pdn, &ndn, NULL);
849 if(rc != LDAP_SUCCESS) {
850 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix DN is invalid\n",
851 c->fname, c->lineno, 0);
854 tbe = select_backend(&ndn, 0, 0);
856 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix already served by this backend! (ignored)\n",
857 c->fname, c->lineno, 0);
861 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix already served by a preceding backend \"%s\"\n",
862 c->fname, c->lineno, tbe->be_suffix[0].bv_val);
866 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
867 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix DN empty and default search "
868 "base provided \"%s\" (assuming okay)\n",
869 c->fname, c->lineno, default_search_base.bv_val);
871 ber_bvarray_add(&c->be->be_suffix, &pdn);
872 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
877 config_rootdn(ConfigArgs *c) {
881 ber_str2bv(c->argv[1], 0, 1, &dn);
883 rc = dnPrettyNormal(NULL, &dn, &c->be->be_rootdn, &c->be->be_rootndn, NULL);
885 if(rc != LDAP_SUCCESS) {
886 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
887 "rootdn DN is invalid\n", c->fname, c->lineno, 0);
894 config_rootpw(ConfigArgs *c) {
895 Backend *tbe = select_backend(&c->be->be_rootndn, 0, 0);
897 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
898 "rootpw can only be set when rootdn is under suffix\n",
899 c->fname, c->lineno, 0);
902 ber_str2bv(c->argv[1], 0, 1, &c->be->be_rootpw);
906 /* restrictops, allows, disallows, requires, loglevel */
908 struct verb_mask_list { char *word; int mask; };
911 verb_to_mask(ConfigArgs *c, struct verb_mask_list *v, int word) {
913 for(j = 0; v[j].word; j++)
914 if(!strcasecmp(c->argv[word], v[j].word))
920 verbs_to_mask(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t *m) {
922 for(i = 1; i < c->argc; i++) {
923 j = verb_to_mask(c, v, i);
924 if(!v[j].word) return(1);
931 config_restrict(ConfigArgs *c) {
932 slap_mask_t restrictops = 0;
934 struct verb_mask_list restrictable_exops[] = {
935 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
936 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
937 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
938 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
941 struct verb_mask_list restrictable_ops[] = {
942 { "bind", SLAP_RESTRICT_OP_BIND },
943 { "add", SLAP_RESTRICT_OP_ADD },
944 { "modify", SLAP_RESTRICT_OP_MODIFY },
945 { "modrdn", SLAP_RESTRICT_OP_RENAME },
946 { "rename", SLAP_RESTRICT_OP_RENAME },
947 { "delete", SLAP_RESTRICT_OP_DELETE },
948 { "search", SLAP_RESTRICT_OP_SEARCH },
949 { "compare", SLAP_RESTRICT_OP_COMPARE },
950 { "read", SLAP_RESTRICT_OP_READS },
951 { "write", SLAP_RESTRICT_OP_WRITES },
955 for(i = 1; i < c->argc; i++) {
956 j = verb_to_mask(c, restrictable_ops, i);
957 if(restrictable_ops[j].word) {
958 restrictops |= restrictable_ops[j].mask;
960 } else if(!strncasecmp(c->argv[i], "extended", STRLENOF("extended"))) {
961 char *e = c->argv[i] + STRLENOF("extended");
963 int k = verb_to_mask(c, restrictable_exops, e[1]);
964 if(restrictable_exops[k].word) {
965 restrictops |= restrictable_exops[k].mask;
969 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
970 restrictops |= SLAP_RESTRICT_OP_EXTENDED;
975 c->be->be_restrictops |= restrictops;
978 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
979 "unknown operation %s in \"restrict <features>\" line\n",
980 c->fname, c->lineno, c->argv[i]);
985 config_allows(ConfigArgs *c) {
986 slap_mask_t allows = 0;
988 struct verb_mask_list allowable_ops[] = {
989 { "bind_v2", SLAP_ALLOW_BIND_V2 },
990 { "bind_anon_cred", SLAP_ALLOW_BIND_ANON_CRED },
991 { "bind_anon_dn", SLAP_ALLOW_BIND_ANON_DN },
992 { "update_anon", SLAP_ALLOW_UPDATE_ANON },
995 if(i = verbs_to_mask(c, allowable_ops, &allows)) {
996 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
997 "unknown feature %s in \"allow <features>\" line\n",
998 c->fname, c->lineno, c->argv[i]);
1001 global_allows |= allows;
1006 config_disallows(ConfigArgs *c) {
1007 slap_mask_t disallows = 0;
1009 struct verb_mask_list disallowable_ops[] = {
1010 { "bind_anon", SLAP_DISALLOW_BIND_ANON },
1011 { "bind_simple", SLAP_DISALLOW_BIND_SIMPLE },
1012 { "bind_krb4", SLAP_DISALLOW_BIND_KRBV4 },
1013 { "tls_2_anon", SLAP_DISALLOW_TLS_2_ANON },
1014 { "tls_authc", SLAP_DISALLOW_TLS_AUTHC },
1017 if(i = verbs_to_mask(c, disallowable_ops, &disallows)) {
1018 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1019 "unknown feature %s in \"disallow <features>\" line\n",
1020 c->fname, c->lineno, c->argv[i]);
1023 global_disallows |= disallows;
1028 config_requires(ConfigArgs *c) {
1029 slap_mask_t requires = 0;
1031 struct verb_mask_list requires_ops[] = {
1032 { "bind", SLAP_REQUIRE_BIND },
1033 { "LDAPv3", SLAP_REQUIRE_LDAP_V3 },
1034 { "authc", SLAP_REQUIRE_AUTHC },
1035 { "sasl", SLAP_REQUIRE_SASL },
1036 { "strong", SLAP_REQUIRE_STRONG },
1039 if(i = verbs_to_mask(c, requires_ops, &requires)) {
1040 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1041 "unknown feature %s in \"require <features>\" line\n",
1042 c->fname, c->lineno, c->argv[i]);
1045 c->be->be_requires = requires;
1050 config_loglevel(ConfigArgs *c) {
1053 struct verb_mask_list loglevel_ops[] = {
1054 { "Trace", LDAP_DEBUG_TRACE },
1055 { "Packets", LDAP_DEBUG_PACKETS },
1056 { "Args", LDAP_DEBUG_ARGS },
1057 { "Conns", LDAP_DEBUG_CONNS },
1058 { "BER", LDAP_DEBUG_BER },
1059 { "Filter", LDAP_DEBUG_FILTER },
1060 { "Config", LDAP_DEBUG_CONFIG },
1061 { "ACL", LDAP_DEBUG_ACL },
1062 { "Stats", LDAP_DEBUG_STATS },
1063 { "Stats2", LDAP_DEBUG_STATS2 },
1064 { "Shell", LDAP_DEBUG_SHELL },
1065 { "Parse", LDAP_DEBUG_PARSE },
1066 { "Cache", LDAP_DEBUG_CACHE },
1067 { "Index", LDAP_DEBUG_INDEX },
1073 for( i=1; i < c->argc; i++ ) {
1076 if ( isdigit( c->argv[i][0] ) ) {
1077 level = strtol( c->argv[i], &next, 10 );
1078 if ( next == NULL || next[0] != '\0' ) {
1079 Debug( LDAP_DEBUG_ANY,
1080 "%s: line %lu: unable to parse level \"%s\" "
1081 "in \"loglevel <level> [...]\" line.\n",
1082 c->fname, c->lineno , c->argv[i] );
1086 int j = verb_to_mask(c, loglevel_ops, c->argv[i][0]);
1087 if(!loglevel_ops[j].word) {
1088 Debug( LDAP_DEBUG_ANY,
1089 "%s: line %lu: unknown level \"%s\" "
1090 "in \"loglevel <level> [...]\" line.\n",
1091 c->fname, c->lineno , c->argv[i] );
1094 level = loglevel_ops[j].mask;
1096 ldap_syslog |= level;
1102 config_syncrepl(ConfigArgs *c) {
1103 if(SLAP_SHADOW(c->be)) {
1104 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1105 "syncrepl: database already shadowed.\n",
1106 c->fname, c->lineno, 0);
1108 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1111 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1116 config_referral(ConfigArgs *c) {
1117 struct berval vals[2];
1118 if(validate_global_referral(c->argv[1])) {
1119 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1120 "invalid URL (%s) in \"referral\" line.\n",
1121 c->fname, c->lineno, c->argv[1] );
1125 ber_str2bv(c->argv[1], 0, 1, &vals[0]);
1126 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1127 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1132 config_security(ConfigArgs *c) {
1133 slap_ssf_set_t *set = &c->be->be_ssf_set;
1136 for(i = 1; i < c->argc; i++) {
1139 if(!strncasecmp(c->argv[i], "ssf=", 4)) {
1140 tgt = &set->sss_ssf;
1141 src = &c->argv[i][4];
1142 } else if(!strncasecmp(c->argv[i], "transport=", 10)) {
1143 tgt = &set->sss_transport;
1144 src = &c->argv[i][10];
1145 } else if(!strncasecmp(c->argv[i], "tls=", 4)) {
1146 tgt = &set->sss_tls;
1147 src = &c->argv[i][4];
1148 } else if(!strncasecmp(c->argv[i], "sasl=", 5)) {
1149 tgt = &set->sss_sasl;
1150 src = &c->argv[i][5];
1151 } else if(!strncasecmp(c->argv[i], "update_ssf=", 11)) {
1152 tgt = &set->sss_update_ssf;
1153 src = &c->argv[i][11];
1154 } else if(!strncasecmp(c->argv[i], "update_transport=", 17)) {
1155 tgt = &set->sss_update_transport;
1156 src = &c->argv[i][17];
1157 } else if(!strncasecmp(c->argv[i], "update_tls=", 11)) {
1158 tgt = &set->sss_update_tls;
1159 src = &c->argv[i][11];
1160 } else if(!strncasecmp(c->argv[i], "update_sasl=", 12)) {
1161 tgt = &set->sss_update_sasl;
1162 src = &c->argv[i][12];
1163 } else if(!strncasecmp(c->argv[i], "simple_bind=", 12)) {
1164 tgt = &set->sss_simple_bind;
1165 src = &c->argv[i][12];
1167 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1168 "unknown factor %s in \"security <factors>\" line\n",
1169 c->fname, c->lineno, c->argv[i]);
1173 *tgt = strtol(src, &next, 10);
1174 if(next == NULL || next[0] != '\0' ) {
1175 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1176 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1177 c->fname, c->lineno, c->argv[i]);
1185 config_replica(ConfigArgs *c) {
1190 if(SLAP_MONITOR(c->be)) {
1191 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1192 "\"replica\" should not be used inside monitor database\n",
1193 c->fname, c->lineno, 0);
1194 return(0); /* FIXME: should this be an error? */
1197 for(i = 1; i < c->argc; i++) {
1198 if(!strncasecmp(c->argv[i], "host=", 5)) {
1199 nr = add_replica_info(c->be, c->argv[i] + 5);
1201 } else if(!strncasecmp(c->argv[i], "uri=", 4)) {
1202 if(ldap_url_parse(c->argv[i] + 4, &ludp) != LDAP_SUCCESS) {
1203 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1204 "replica line contains invalid "
1205 "uri definition.\n", c->fname, c->lineno, 0);
1208 if(!ludp->lud_host) {
1209 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1210 "replica line contains invalid "
1211 "uri definition - missing hostname.\n", c->fname, c->lineno, 0);
1214 replicahost = ch_malloc(strlen(c->argv[i]));
1216 Debug(LDAP_DEBUG_ANY,
1217 "out of memory in read_config\n", 0, 0, 0);
1218 ldap_free_urldesc(ludp);
1221 sprintf(replicahost, "%s:%d", ludp->lud_host, ludp->lud_port);
1222 nr = add_replica_info(c->be, replicahost);
1223 ldap_free_urldesc(ludp);
1224 ch_free(replicahost);
1229 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1230 "missing host or uri in \"replica\" line\n",
1231 c->fname, c->lineno, 0);
1233 } else if(nr == -1) {
1234 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1235 "unable to add replica \"%s\"\n",
1236 c->fname, c->lineno, c->argv[i] + 5);
1239 for(i = 1; i < c->argc; i++) {
1240 if(!strncasecmp(c->argv[i], "suffix=", 7)) {
1241 switch(add_replica_suffix(c->be, nr, c->argv[i] + 7)) {
1243 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1244 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1245 c->fname, c->lineno, c->argv[i] + 7);
1248 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1249 "unable to normalize suffix in \"replica\" line (ignored)\n",
1250 c->fname, c->lineno, 0);
1254 } else if(!strncasecmp(c->argv[i], "attr", 4)) {
1256 char *arg = c->argv[i] + 4;
1264 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1265 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1266 "attribute \"%s\" in \"replica\" line is unknown\n",
1267 c->fname, c->lineno, arg + 1);
1277 config_updatedn(ConfigArgs *c) {
1280 if(SLAP_SHADOW(c->be)) {
1281 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1282 "updatedn: database already shadowed.\n",
1283 c->fname, c->lineno, 0);
1287 ber_str2bv(c->argv[1], 0, 0, &dn);
1289 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1291 if(rc != LDAP_SUCCESS) {
1292 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1293 "updatedn DN is invalid\n", c->fname, c->lineno, 0);
1297 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1302 config_updateref(ConfigArgs *c) {
1303 struct berval vals[2];
1304 if(!SLAP_SHADOW(c->be)) {
1305 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1306 "updateref line must after syncrepl or updatedn.\n",
1307 c->fname, c->lineno, 0);
1311 if(validate_global_referral(c->argv[1])) {
1312 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1313 "invalid URL (%s) in \"updateref\" line.\n",
1314 c->fname, c->lineno, c->argv[1]);
1317 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1318 vals[1].bv_val = NULL;
1319 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1323 /* XXX meaningless in ldif */
1326 config_include(ConfigArgs *c) {
1327 char *savefname = ch_strdup(c->argv[1]);
1328 unsigned long savelineno = c->lineno;
1330 rc = read_config_file(savefname, c->depth + 1, c);
1332 c->lineno = savelineno - 1;
1338 config_tls_option(ConfigArgs *c) {
1341 CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
1342 CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
1343 CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
1344 CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
1345 CFG_TLS_CERT_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
1346 CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
1347 #ifdef HAVE_OPENSSL_CRL
1348 CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
1350 default: Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1351 "unknown tls_option <%x>\n",
1352 c->fname, c->lineno, c->type);
1354 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
1358 config_tls_verify(ConfigArgs *c) {
1360 if(isdigit((unsigned char)c->argv[1][0])) {
1361 i = atoi(c->argv[1]);
1362 return(ldap_pvt_tls_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i));
1364 return(ldap_int_tls_config(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, c->argv[1]));
1369 /* -------------------------------------- */
1373 strtok_quote( char *line, char *sep )
1379 strtok_quote_ptr = NULL;
1380 if ( line != NULL ) {
1383 while ( *next && strchr( sep, *next ) ) {
1387 if ( *next == '\0' ) {
1393 for ( inquote = 0; *next; ) {
1401 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1407 next + 1, strlen( next + 1 ) + 1 );
1408 next++; /* dont parse the escaped character */
1413 if ( strchr( sep, *next ) != NULL ) {
1414 strtok_quote_ptr = next;
1427 static char buf[BUFSIZ];
1429 static size_t lmax, lcur;
1431 #define CATLINE( buf ) \
1433 size_t len = strlen( buf ); \
1434 while ( lcur + len + 1 > lmax ) { \
1436 line = (char *) ch_realloc( line, lmax ); \
1438 strcpy( line + lcur, buf ); \
1443 fp_getline_init(ConfigArgs *c) {
1449 fp_getline(FILE *fp, ConfigArgs *c)
1457 /* avoid stack of bufs */
1458 if(strncasecmp(line, "include", 7) == 0) {
1464 while(fgets(buf, sizeof(buf), fp)) {
1465 if(p = strchr(buf, '\n')) {
1466 if(p > buf && p[-1] == '\r') --p;
1471 if(line[0] && (p = line + strlen(line) - 1)[0] == '\\' && p[-1] != '\\' ) {
1475 if(!isspace((unsigned char)buf[0])) return(1);
1484 return(line[0] ? 1 : 0);
1488 fp_parse_line(ConfigArgs *c)
1491 char *tline = ch_strdup(c->line);
1492 char logbuf[STRLENOF("pseudorootpw ***")]; /* longest secret */
1493 char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
1497 token = strtok_quote(tline, " \t");
1499 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
1500 if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
1501 Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
1502 if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
1504 for(; token; token = strtok_quote(NULL, " \t")) {
1505 if(c->argc == c->argv_size - 1) {
1507 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
1509 Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0);
1513 c->argv_size += ARGS_STEP;
1515 c->argv[c->argc++] = token;
1517 c->argv[c->argc] = NULL;
1523 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1525 load_ucdata( char *path )
1528 static int loaded = 0;
1534 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
1536 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
1544 /* ucdata is now hardcoded */
1553 ucdata_unload( UCDATA_ALL );
1555 /* NOTE: in case of early exit, frontendDB can be NULL */
1556 if ( frontendDB->be_schemandn.bv_val )
1557 free( frontendDB->be_schemandn.bv_val );
1558 if ( frontendDB->be_schemadn.bv_val )
1559 free( frontendDB->be_schemadn.bv_val );
1560 if ( frontendDB->be_acl )
1561 acl_destroy( frontendDB->be_acl, NULL );
1564 if ( slapd_args_file )
1565 free ( slapd_args_file );
1566 if ( slapd_pid_file )
1567 free ( slapd_pid_file );
1568 if ( default_passwd_hash )
1569 ldap_charray_free( default_passwd_hash );
1580 syncinfo_t *si_entry;
1582 int duplicated_replica_id = 0;
1584 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
1587 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
1591 si->si_tls = SYNCINFO_TLS_OFF;
1592 if ( be->be_rootndn.bv_val ) {
1593 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
1595 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1596 si->si_schemachecking = 0;
1597 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
1598 &si->si_filterstr );
1599 si->si_base.bv_val = NULL;
1600 si->si_scope = LDAP_SCOPE_SUBTREE;
1601 si->si_attrsonly = 0;
1602 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1603 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1604 si->si_attrs = NULL;
1605 si->si_allattrs = 0;
1606 si->si_allopattrs = 0;
1607 si->si_exattrs = NULL;
1608 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1609 si->si_interval = 86400;
1610 si->si_retryinterval = NULL;
1611 si->si_retrynum_init = NULL;
1612 si->si_retrynum = NULL;
1613 si->si_syncCookie.ctxcsn = NULL;
1614 si->si_syncCookie.octet_str = NULL;
1615 si->si_syncCookie.sid = -1;
1616 si->si_manageDSAit = 0;
1619 si->si_syncUUID_ndn.bv_val = NULL;
1620 si->si_syncUUID_ndn.bv_len = 0;
1622 si->si_presentlist = NULL;
1623 LDAP_LIST_INIT( &si->si_nonpresentlist );
1625 rc = parse_syncrepl_line( cargv, cargc, si );
1627 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
1628 if ( si->si_rid == si_entry->si_rid ) {
1629 Debug( LDAP_DEBUG_ANY,
1630 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
1631 duplicated_replica_id = 1;
1636 if ( rc < 0 || duplicated_replica_id ) {
1637 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
1638 syncinfo_free( si );
1641 Debug( LDAP_DEBUG_CONFIG,
1642 "Config: ** successfully added syncrepl \"%s\"\n",
1643 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
1644 if ( !si->si_schemachecking ) {
1645 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
1648 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
1653 /* NOTE: used & documented in slapd.conf(5) */
1655 #define PROVIDERSTR "provider"
1656 #define TYPESTR "type"
1657 #define INTERVALSTR "interval"
1658 #define SEARCHBASESTR "searchbase"
1659 #define FILTERSTR "filter"
1660 #define SCOPESTR "scope"
1661 #define ATTRSSTR "attrs"
1662 #define ATTRSONLYSTR "attrsonly"
1663 #define SLIMITSTR "sizelimit"
1664 #define TLIMITSTR "timelimit"
1665 #define SCHEMASTR "schemachecking"
1666 #define UPDATEDNSTR "updatedn"
1667 #define BINDMETHSTR "bindmethod"
1668 #define SIMPLESTR "simple"
1669 #define SASLSTR "sasl"
1670 #define BINDDNSTR "binddn"
1671 #define SASLMECHSTR "saslmech"
1672 #define AUTHCSTR "authcID"
1673 #define AUTHZSTR "authzID"
1674 #define CREDSTR "credentials"
1675 #define REALMSTR "realm"
1676 #define SECPROPSSTR "secprops"
1678 /* FIXME: undocumented */
1679 #define OLDAUTHCSTR "bindprincipal"
1680 #define STARTTLSSTR "starttls"
1681 #define CRITICALSTR "critical"
1682 #define EXATTRSSTR "exattrs"
1683 #define MANAGEDSAITSTR "manageDSAit"
1684 #define RETRYSTR "retry"
1687 #define LASTMODSTR "lastmod"
1688 #define LMGENSTR "gen"
1689 #define LMNOSTR "no"
1690 #define LMREQSTR "req"
1691 #define SRVTABSTR "srvtab"
1692 #define SUFFIXSTR "suffix"
1695 #define GOT_ID 0x0001
1696 #define GOT_PROVIDER 0x0002
1697 #define GOT_METHOD 0x0004
1700 #define GOT_ALL (GOT_ID|GOT_PROVIDER|GOT_METHOD)
1703 parse_syncrepl_line(
1714 for ( i = 1; i < cargc; i++ ) {
1715 if ( !strncasecmp( cargv[ i ], IDSTR "=",
1716 STRLENOF( IDSTR "=" ) ) )
1719 /* '\0' string terminator accounts for '=' */
1720 val = cargv[ i ] + STRLENOF( IDSTR "=" );
1722 if ( tmp >= 1000 || tmp < 0 ) {
1723 fprintf( stderr, "Error: parse_syncrepl_line: "
1724 "syncrepl id %d is out of range [0..999]\n", tmp );
1729 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
1730 STRLENOF( PROVIDERSTR "=" ) ) )
1732 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
1733 si->si_provideruri = ch_strdup( val );
1734 si->si_provideruri_bv = (BerVarray)
1735 ch_calloc( 2, sizeof( struct berval ));
1736 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
1737 1, &si->si_provideruri_bv[0] );
1738 si->si_provideruri_bv[1].bv_len = 0;
1739 si->si_provideruri_bv[1].bv_val = NULL;
1740 gots |= GOT_PROVIDER;
1741 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=",
1742 STRLENOF(STARTTLSSTR "=") ) )
1744 val = cargv[ i ] + STRLENOF( STARTTLSSTR "=" );
1745 if( !strcasecmp( val, CRITICALSTR ) ) {
1746 si->si_tls = SYNCINFO_TLS_CRITICAL;
1748 si->si_tls = SYNCINFO_TLS_ON;
1750 } else if ( !strncasecmp( cargv[ i ], UPDATEDNSTR "=",
1751 STRLENOF( UPDATEDNSTR "=" ) ) )
1753 struct berval updatedn = BER_BVNULL;
1755 val = cargv[ i ] + STRLENOF( UPDATEDNSTR "=" );
1756 ber_str2bv( val, 0, 0, &updatedn );
1757 ch_free( si->si_updatedn.bv_val );
1758 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
1759 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR "=",
1760 STRLENOF( BINDMETHSTR "=" ) ) )
1762 val = cargv[ i ] + STRLENOF( BINDMETHSTR "=" );
1763 if ( !strcasecmp( val, SIMPLESTR )) {
1764 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1766 } else if ( !strcasecmp( val, SASLSTR )) {
1767 #ifdef HAVE_CYRUS_SASL
1768 si->si_bindmethod = LDAP_AUTH_SASL;
1770 #else /* HAVE_CYRUS_SASL */
1771 fprintf( stderr, "Error: parse_syncrepl_line: "
1772 "not compiled with SASL support\n" );
1774 #endif /* HAVE_CYRUS_SASL */
1776 si->si_bindmethod = -1;
1778 } else if ( !strncasecmp( cargv[ i ], BINDDNSTR "=",
1779 STRLENOF( BINDDNSTR "=" ) ) )
1781 val = cargv[ i ] + STRLENOF( BINDDNSTR "=" );
1782 si->si_binddn = ch_strdup( val );
1783 } else if ( !strncasecmp( cargv[ i ], CREDSTR "=",
1784 STRLENOF( CREDSTR "=" ) ) )
1786 val = cargv[ i ] + STRLENOF( CREDSTR "=" );
1787 si->si_passwd = ch_strdup( val );
1788 } else if ( !strncasecmp( cargv[ i ], SASLMECHSTR "=",
1789 STRLENOF( SASLMECHSTR "=" ) ) )
1791 val = cargv[ i ] + STRLENOF( SASLMECHSTR "=" );
1792 si->si_saslmech = ch_strdup( val );
1793 } else if ( !strncasecmp( cargv[ i ], SECPROPSSTR "=",
1794 STRLENOF( SECPROPSSTR "=" ) ) )
1796 val = cargv[ i ] + STRLENOF( SECPROPSSTR "=" );
1797 si->si_secprops = ch_strdup( val );
1798 } else if ( !strncasecmp( cargv[ i ], REALMSTR "=",
1799 STRLENOF( REALMSTR "=" ) ) )
1801 val = cargv[ i ] + STRLENOF( REALMSTR "=" );
1802 si->si_realm = ch_strdup( val );
1803 } else if ( !strncasecmp( cargv[ i ], AUTHCSTR "=",
1804 STRLENOF( AUTHCSTR "=" ) ) )
1806 val = cargv[ i ] + STRLENOF( AUTHCSTR "=" );
1807 if ( si->si_authcId )
1808 ch_free( si->si_authcId );
1809 si->si_authcId = ch_strdup( val );
1810 } else if ( !strncasecmp( cargv[ i ], OLDAUTHCSTR "=",
1811 STRLENOF( OLDAUTHCSTR "=" ) ) )
1813 /* Old authcID is provided for some backwards compatibility */
1814 val = cargv[ i ] + STRLENOF( OLDAUTHCSTR "=" );
1815 if ( si->si_authcId )
1816 ch_free( si->si_authcId );
1817 si->si_authcId = ch_strdup( val );
1818 } else if ( !strncasecmp( cargv[ i ], AUTHZSTR "=",
1819 STRLENOF( AUTHZSTR "=" ) ) )
1821 val = cargv[ i ] + STRLENOF( AUTHZSTR "=" );
1822 si->si_authzId = ch_strdup( val );
1823 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
1824 STRLENOF( SCHEMASTR "=" ) ) )
1826 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
1827 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
1828 si->si_schemachecking = 1;
1829 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
1830 si->si_schemachecking = 0;
1832 si->si_schemachecking = 1;
1834 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
1835 STRLENOF( FILTERSTR "=" ) ) )
1837 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
1838 ber_str2bv( val, 0, 1, &si->si_filterstr );
1839 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
1840 STRLENOF( SEARCHBASESTR "=" ) ) )
1843 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
1844 if ( si->si_base.bv_val ) {
1845 ch_free( si->si_base.bv_val );
1847 ber_str2bv( val, 0, 0, &bv );
1848 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
1849 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
1852 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
1853 STRLENOF( SCOPESTR "=" ) ) )
1855 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
1856 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
1857 si->si_scope = LDAP_SCOPE_BASE;
1858 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
1859 si->si_scope = LDAP_SCOPE_ONELEVEL;
1860 #ifdef LDAP_SCOPE_SUBORDINATE
1861 } else if ( !strcasecmp( val, "subordinate" ) ||
1862 !strcasecmp( val, "children" ))
1864 si->si_scope = LDAP_SCOPE_SUBORDINATE;
1866 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
1867 si->si_scope = LDAP_SCOPE_SUBTREE;
1869 fprintf( stderr, "Error: parse_syncrepl_line: "
1870 "unknown scope \"%s\"\n", val);
1873 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
1874 STRLENOF( ATTRSONLYSTR "=" ) ) )
1876 si->si_attrsonly = 1;
1877 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
1878 STRLENOF( ATTRSSTR "=" ) ) )
1880 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
1881 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
1883 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1884 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
1885 if ( si->si_anlist == NULL ) {
1886 ch_free( attr_fname );
1889 ch_free( attr_fname );
1891 char *str, *s, *next;
1892 char delimstr[] = " ,\t";
1893 str = ch_strdup( val );
1894 for ( s = ldap_pvt_strtok( str, delimstr, &next );
1896 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
1898 if ( strlen(s) == 1 && *s == '*' ) {
1899 si->si_allattrs = 1;
1900 *(val + ( s - str )) = delimstr[0];
1902 if ( strlen(s) == 1 && *s == '+' ) {
1903 si->si_allopattrs = 1;
1904 *(val + ( s - str )) = delimstr[0];
1908 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
1909 if ( si->si_anlist == NULL ) {
1913 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
1914 STRLENOF( EXATTRSSTR "=" ) ) )
1916 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
1917 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
1919 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1920 si->si_exanlist = file2anlist(
1921 si->si_exanlist, attr_fname, " ,\t" );
1922 if ( si->si_exanlist == NULL ) {
1923 ch_free( attr_fname );
1926 ch_free( attr_fname );
1929 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
1930 if ( si->si_exanlist == NULL ) {
1934 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
1935 STRLENOF( TYPESTR "=" ) ) )
1937 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
1938 if ( !strncasecmp( val, "refreshOnly",
1939 STRLENOF("refreshOnly") ))
1941 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1942 } else if ( !strncasecmp( val, "refreshAndPersist",
1943 STRLENOF("refreshAndPersist") ))
1945 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
1946 si->si_interval = 60;
1948 fprintf( stderr, "Error: parse_syncrepl_line: "
1949 "unknown sync type \"%s\"\n", val);
1952 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
1953 STRLENOF( INTERVALSTR "=" ) ) )
1955 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
1956 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
1957 si->si_interval = 0;
1965 hstr = strchr( dstr, ':' );
1966 if ( hstr == NULL ) {
1967 fprintf( stderr, "Error: parse_syncrepl_line: "
1968 "invalid interval \"%s\"\n", val );
1972 mstr = strchr( hstr, ':' );
1973 if ( mstr == NULL ) {
1974 fprintf( stderr, "Error: parse_syncrepl_line: "
1975 "invalid interval \"%s\"\n", val );
1979 sstr = strchr( mstr, ':' );
1980 if ( sstr == NULL ) {
1981 fprintf( stderr, "Error: parse_syncrepl_line: "
1982 "invalid interval \"%s\"\n", val );
1991 if (( hh > 24 ) || ( hh < 0 ) ||
1992 ( mm > 60 ) || ( mm < 0 ) ||
1993 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
1994 fprintf( stderr, "Error: parse_syncrepl_line: "
1995 "invalid interval \"%s\"\n", val );
1998 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2000 if ( si->si_interval < 0 ) {
2001 fprintf( stderr, "Error: parse_syncrepl_line: "
2002 "invalid interval \"%ld\"\n",
2003 (long) si->si_interval);
2006 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2007 STRLENOF( RETRYSTR "=" ) ) )
2013 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2014 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2015 retry_list[0] = NULL;
2017 slap_str2clist( &retry_list, val, " ,\t" );
2019 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2023 "Error: incomplete syncrepl retry list\n" );
2024 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2025 ch_free( retry_list[k] );
2027 ch_free( retry_list );
2028 exit( EXIT_FAILURE );
2030 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2031 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2032 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2033 for ( j = 0; j < n; j++ ) {
2034 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2035 if ( *retry_list[j*2+1] == '+' ) {
2036 si->si_retrynum_init[j] = -1;
2037 si->si_retrynum[j] = -1;
2041 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2042 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2045 si->si_retrynum_init[j] = -2;
2046 si->si_retrynum[j] = -2;
2047 si->si_retryinterval[j] = 0;
2049 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2050 ch_free( retry_list[k] );
2052 ch_free( retry_list );
2053 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2054 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2056 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2057 si->si_manageDSAit = atoi( val );
2058 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2059 STRLENOF( SLIMITSTR "=") ) )
2061 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2062 si->si_slimit = atoi( val );
2063 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2064 STRLENOF( TLIMITSTR "=" ) ) )
2066 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2067 si->si_tlimit = atoi( val );
2069 fprintf( stderr, "Error: parse_syncrepl_line: "
2070 "unknown keyword \"%s\"\n", cargv[ i ] );
2075 if ( gots != GOT_ALL ) {
2077 "Error: Malformed \"syncrepl\" line in slapd config file" );
2085 slap_str2clist( char ***out, char *in, const char *brkstr )
2094 /* find last element in list */
2095 for (i = 0; *out && (*out)[i]; i++);
2097 /* protect the input string from strtok */
2098 str = ch_strdup( in );
2100 if ( *str == '\0' ) {
2105 /* Count words in string */
2107 for ( s = str; *s; s++ ) {
2108 if ( strchr( brkstr, *s ) != NULL ) {
2113 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
2115 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
2117 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
2119 *new = ch_strdup( s );