1 /* config.c - configuration file handling routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2005 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"
44 #endif /* HAVE_LIMITS_H */
47 #endif /* ! PATH_MAX */
53 * defaults for various global variables
55 slap_mask_t global_allows = 0;
56 slap_mask_t global_disallows = 0;
57 int global_gentlehup = 0;
58 int global_idletimeout = 0;
59 char *global_host = NULL;
60 char *global_realm = NULL;
61 char *ldap_srvtab = "";
62 char **default_passwd_hash = NULL;
63 struct berval default_search_base = BER_BVNULL;
64 struct berval default_search_nbase = BER_BVNULL;
66 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
67 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
69 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
70 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
72 char *slapd_pid_file = NULL;
73 char *slapd_args_file = NULL;
75 char *strtok_quote_ptr;
77 int use_reverse_lookup = 0;
80 int slapi_plugins_used = 0;
83 static int fp_getline(FILE *fp, ConfigArgs *c);
84 static void fp_getline_init(ConfigArgs *c);
85 static int fp_parse_line(ConfigArgs *c);
87 static char *strtok_quote(char *line, char *sep);
89 static int load_ucdata(char *path);
92 int read_config_file(const char *fname, int depth, ConfigArgs *cf);
94 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
95 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
97 int config_generic(ConfigArgs *c);
98 int config_search_base(ConfigArgs *c);
99 int config_passwd_hash(ConfigArgs *c);
100 int config_schema_dn(ConfigArgs *c);
101 int config_sizelimit(ConfigArgs *c);
102 int config_timelimit(ConfigArgs *c);
103 int config_limits(ConfigArgs *c);
104 int config_overlay(ConfigArgs *c);
105 int config_suffix(ConfigArgs *c);
106 int config_deref_depth(ConfigArgs *c);
107 int config_rootdn(ConfigArgs *c);
108 int config_rootpw(ConfigArgs *c);
109 int config_restrict(ConfigArgs *c);
110 int config_allows(ConfigArgs *c);
111 int config_disallows(ConfigArgs *c);
112 int config_requires(ConfigArgs *c);
113 int config_security(ConfigArgs *c);
114 int config_referral(ConfigArgs *c);
115 int config_loglevel(ConfigArgs *c);
116 int config_syncrepl(ConfigArgs *c);
117 int config_replica(ConfigArgs *c);
118 int config_updatedn(ConfigArgs *c);
119 int config_updateref(ConfigArgs *c);
120 int config_include(ConfigArgs *c);
122 int config_tls_option(ConfigArgs *c);
123 int config_tls_verify(ConfigArgs *c);
126 int config_plugin(ConfigArgs *c);
128 int config_pluginlog(ConfigArgs *c);
170 /* original config.c ordering */
172 ConfigTable SystemConfiguration[] = {
173 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND, &config_generic, NULL, NULL, NULL },
174 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE, &config_generic, NULL, NULL, NULL },
175 { "localSSF", "ssf", 2, 2, 0, ARG_LONG, &local_ssf, NULL, NULL, NULL },
176 { "concurrency", "level", 2, 2, 0, ARG_LONG|ARG_NONZERO|ARG_MAGIC|CFG_CONCUR, &config_generic, NULL, NULL, NULL },
177 { "index_substr_if_minlen","min", 2, 2, 0, ARG_INT|ARG_NONZERO, &index_substr_if_minlen, NULL, NULL, NULL },
178 { "index_substr_if_maxlen","max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_SPECIAL, &index_substr_if_maxlen, NULL, NULL, NULL },
179 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO, &index_substr_any_len, NULL, NULL, NULL },
180 { "index_substr_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO, &index_substr_any_step, NULL, NULL, NULL },
181 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_LONG, &sockbuf_max_incoming, NULL, NULL, NULL },
182 { "sockbuf_max_incoming_auth","max", 2, 2, 0, ARG_LONG, &sockbuf_max_incoming_auth, NULL, NULL, NULL },
183 { "conn_max_pending", "max", 2, 2, 0, ARG_LONG, &slap_conn_max_pending, NULL, NULL, NULL },
184 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_LONG, &slap_conn_max_pending_auth, NULL, NULL, NULL },
185 { "defaultSearchBase", "dn", 2, 2, 0, ARG_DN|ARG_MAGIC, &config_search_base, NULL, NULL, NULL },
186 { "threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic, NULL, NULL, NULL },
187 { "pidfile", "file", 2, 2, 0, ARG_STRING, &slapd_pid_file, NULL, NULL, NULL },
188 { "argsfile", "file", 2, 2, 0, ARG_STRING, &slapd_args_file, NULL, NULL, NULL },
189 { "password-hash", "hash", 2, 2, 0, ARG_MAGIC, &config_passwd_hash, NULL, NULL, NULL },
190 { "password-crypt-salt-format","salt", 2, 2, 0, ARG_MAGIC|CFG_SALT, &config_generic, NULL, NULL, NULL },
191 #ifdef SLAP_AUTH_REWRITE
192 { "auth-rewrite", NULL, 2, 2, 14, ARG_MAGIC|CFG_REWRITE, &config_generic, NULL, NULL, NULL },
194 { "authz-policy", "policy", 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY, &config_generic, NULL, NULL, NULL },
195 { "authz-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP, &config_generic, NULL, NULL, NULL },
196 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY, &config_generic, NULL, NULL, NULL },
197 { "sasl-regexp", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZREGEXP, &config_generic, NULL, NULL, NULL },
198 { "saslRegexp", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZREGEXP, &config_generic, NULL, NULL, NULL },
199 #ifdef HAVE_CYRUS_SASL
200 { "sasl-host", "host", 2, 2, 0, ARG_STRING|ARG_UNIQUE, &global_host, NULL, NULL, NULL },
201 { "sasl-realm", "realm", 2, 2, 0, ARG_STRING|ARG_UNIQUE, &global_realm, NULL, NULL, NULL },
202 { "sasl-secprops", "properties", 2, 2, 0, ARG_MAGIC|CFG_SASLSECP, &config_generic, NULL, NULL, NULL },
204 { "sasl-host", NULL, 2, 2, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
205 { "sasl-realm", NULL, 2, 2, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
206 { "sasl-secprops", NULL, 2, 2, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
208 { "schemadn", "dn", 2, 2, 0, ARG_DN|ARG_MAGIC, &config_schema_dn, NULL, NULL, NULL },
209 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
210 { "sizelimit", "limit", 2, 2, 0, ARG_MAGIC|CFG_SIZE, &config_sizelimit, NULL, NULL, NULL },
211 { "timelimit", "limit", 2, 2, 0, ARG_MAGIC|CFG_TIME, &config_timelimit, NULL, NULL, NULL },
212 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS, &config_generic, NULL, NULL, NULL },
213 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC, &config_overlay, NULL, NULL, NULL },
214 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC, &config_suffix, NULL, NULL, NULL },
215 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH, &config_generic, NULL, NULL, NULL },
216 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC, &config_rootdn, NULL, NULL, NULL },
217 { "rootpw", "password", 2, 2, 0, ARG_DB|ARG_MAGIC, &config_rootpw, NULL, NULL, NULL },
218 { "readonly", "on|off", 2, 2, 0, ARG_ON_OFF|ARG_MAGIC|CFG_RO, &config_generic, NULL, NULL, NULL },
219 { "restrict", "op_list", 2, 0, 0, ARG_MAGIC, &config_restrict, NULL, NULL, NULL },
220 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC, &config_allows, NULL, NULL, NULL },
221 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC, &config_disallows, NULL, NULL, NULL },
222 { "require", "features", 2, 0, 7, ARG_MAGIC, &config_requires, NULL, NULL, NULL },
223 { "security", "factors", 2, 0, 0, ARG_MAGIC, &config_security, NULL, NULL, NULL },
224 { "referral", "url", 2, 2, 0, ARG_MAGIC, &config_referral, NULL, NULL, NULL },
225 { "logfile", "file", 2, 2, 0, ARG_MAGIC|CFG_LOGFILE, &config_generic, NULL, NULL, NULL },
226 { "objectidentifier", NULL, 0, 0, 0, ARG_MAGIC|CFG_OID, &config_generic, NULL, NULL, NULL },
227 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC, &config_generic, NULL, NULL, NULL },
228 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT, &config_generic, NULL, NULL, NULL },
229 { "attribute", "attribute", 2, 0, 9, ARG_PAREN|ARG_MAGIC|CFG_ATTR, &config_generic, NULL, NULL, NULL },
230 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT, &config_generic, NULL, NULL, NULL },
231 { "schemacheck", "on|off", 2, 2, 0, ARG_ON_OFF|ARG_MAGIC|CFG_CHECK, &config_generic, NULL, NULL, NULL },
232 { "access", NULL, 0, 0, 0, ARG_MAGIC|CFG_ACL, &config_generic, NULL, NULL, NULL },
233 { "loglevel", "level", 2, 0, 0, ARG_MAGIC, &config_loglevel, NULL, NULL, NULL },
234 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC, &config_syncrepl, NULL, NULL, NULL },
235 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC, &config_replica, NULL, NULL, NULL },
236 { "replicationInterval", NULL, 0, 0, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
237 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_MAGIC, &config_updatedn, NULL, NULL, NULL },
238 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC, &config_updateref, NULL, NULL, NULL },
239 { "replogfile", "filename", 2, 2, 0, ARG_MAGIC|ARG_STRING|CFG_REPLOG, &config_generic, NULL, NULL, NULL },
240 { "rootDSE", "filename", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE, &config_generic, NULL, NULL, NULL },
241 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD, &config_generic, NULL, NULL, NULL },
243 { "gentlehup", "on|off", 2, 2, 0, ARG_ON_OFF, &global_gentlehup, NULL, NULL, NULL },
245 { "gentlehup", NULL, 2, 2, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
247 { "idletimeout", "timeout", 2, 2, 0, ARG_INT, &global_idletimeout, NULL, NULL, NULL },
248 /* XXX -- special case? */
249 { "include", "filename", 2, 2, 0, ARG_MAGIC, &config_include, NULL, NULL, NULL },
250 { "srvtab", "filename", 2, 2, 0, ARG_STRING, &ldap_srvtab, NULL, NULL, NULL },
252 { "moduleload", "filename", 2, 2, 0, ARG_MAGIC|CFG_MODLOAD, &config_generic, NULL, NULL, NULL },
253 { "modulepath", "path", 2, 2, 0, ARG_MAGIC|CFG_MODPATH, &config_generic, NULL, NULL, NULL },
256 { "TLSRandFile", NULL, 0, 0, 0, CFG_TLS_RAND|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
257 { "TLSCipherSuite", NULL, 0, 0, 0, CFG_TLS_CIPHER|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
258 { "TLSCertificateFile", NULL, 0, 0, 0, CFG_TLS_CERT_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
259 { "TLSCertificateKeyFile", NULL, 0, 0, 0, CFG_TLS_CERT_KEY|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
260 { "TLSCertificatePath", NULL, 0, 0, 0, CFG_TLS_CERT_PATH|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
261 { "TLSCACertificateFile", NULL, 0, 0, 0, CFG_TLS_CA_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
262 #ifdef HAVE_OPENSSL_CRL
263 { "TLSCRLCheck", NULL, 0, 0, 0, CFG_TLS_CRLCHECK|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
265 { "TLSCRLCheck", NULL, 0, 0, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
267 { "TLSVerifyClient", NULL, 0, 0, 0, CFG_TLS_VERIFY|ARG_MAGIC, &config_tls_verify, NULL, NULL, NULL },
269 #ifdef SLAPD_RLOOKUPS
270 { "reverse-lookup", "on|off", 2, 2, 0, ARG_ON_OFF, &use_reverse_lookup, NULL, NULL, NULL },
272 { "reverse-lookup", NULL, 2, 2, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
275 { "plugin", NULL, 0, 0, 0, ARG_MAGIC|CFG_PLUGIN, &config_generic, NULL, NULL, NULL },
276 { "pluginlog", "filename", 2, 2, 0, ARG_STRING, &slapi_log_file, NULL, NULL, NULL },
278 { "plugin", NULL, 0, 0, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
279 { "pluginlog", NULL, 0, 0, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
281 { "replica-pidfile", NULL, 0, 0, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
282 { "replica-argsfile", NULL, 0, 0, 0, ARG_IGNORED, NULL, NULL, NULL, NULL },
283 { NULL, NULL, 0, 0, 0, ARG_IGNORED, NULL, NULL, NULL, NULL }
288 new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv )
291 c = ch_calloc( 1, sizeof( ConfigArgs ) );
292 if ( c == NULL ) return(NULL);
298 snprintf( c->log, sizeof( c->log ), "%s: line %lu", fname, lineno );
302 int parse_config_table(ConfigTable *Conf, ConfigArgs *c) {
303 int i, rc, arg_user, arg_type, iarg;
306 for(i = 0; Conf[i].name; i++)
307 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
308 (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
309 if(!Conf[i].name) return(ARG_UNKNOWN);
310 arg_type = Conf[i].arg_type;
311 if(arg_type == ARG_IGNORED) {
312 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> ignored\n",
313 c->log, Conf[i].name, 0);
316 if(Conf[i].min_args && (c->argc < Conf[i].min_args)) {
317 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> missing <%s> argument\n",
318 c->log, Conf[i].name, Conf[i].what);
319 return(ARG_BAD_CONF);
321 if(Conf[i].max_args && (c->argc > Conf[i].max_args)) {
322 Debug(LDAP_DEBUG_CONFIG, "%s: extra cruft after <%s> in <%s> line (ignored)\n",
323 c->log, Conf[i].what, Conf[i].name);
325 if((arg_type & ARG_DB) && !c->be) {
326 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> allowed only within database declaration\n",
327 c->log, Conf[i].name, 0);
328 return(ARG_BAD_CONF);
330 if((arg_type & ARG_PRE_DB) && c->be) {
331 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> must appear before any database declaration\n",
332 c->log, Conf[i].name, 0);
333 return(ARG_BAD_CONF);
335 if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
336 Debug(LDAP_DEBUG_CONFIG, "%s: old <%s> format not supported\n",
337 c->log, Conf[i].name, 0);
338 return(ARG_BAD_CONF);
340 if((arg_type & ARGS_POINTER) && !Conf[i].arg_item) {
341 Debug(LDAP_DEBUG_CONFIG, "%s: null arg_item for <%s>\n",
342 c->log, Conf[i].name, 0);
343 return(ARG_BAD_CONF);
345 c->type = arg_user = (arg_type & ARGS_USERLAND);
346 c->value_int = c->value_long = c->value_ber_t = 0;
347 c->value_string = NULL;
348 BER_BVZERO( &c->value_dn );
349 BER_BVZERO( &c->value_ndn );
350 if(arg_type & ARGS_NUMERIC) {
352 iarg = 0; larg = 0; barg = 0;
353 switch(arg_type & ARGS_NUMERIC) {
354 case ARG_INT: iarg = atoi(c->argv[1]); break;
355 case ARG_LONG: larg = atol(c->argv[1]); break;
356 case ARG_BER_LEN_T: barg = (ber_len_t)atol(c->argv[1]); break;
358 if(!strcasecmp(c->argv[1], "on")) {
360 } else if(!strcasecmp(c->argv[1], "off")) {
363 Debug(LDAP_DEBUG_CONFIG, "%s: ignoring ", c->log, 0, 0);
364 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
365 Conf[i].what, c->argv[1], Conf[i].name);
370 j = (arg_type & ARG_NONZERO) ? 1 : 0;
371 rc = (Conf == SystemConfiguration) ? ((arg_type & ARG_SPECIAL) && (larg < index_substr_if_maxlen)) : 0;
372 if(iarg < j || larg < j || barg < j || rc) {
373 larg = larg ? larg : (barg ? barg : iarg);
374 Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
375 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf[i].what, larg, Conf[i].name);
376 return(ARG_BAD_CONF);
379 c->value_long = larg;
380 c->value_ber_t = barg;
382 if(arg_type & ARG_STRING) c->value_string = ch_strdup(c->argv[1]);
383 if(arg_type & ARG_DN) {
385 ber_str2bv( c->argv[1], 0, 0, &bv );
386 rc = dnPrettyNormal( NULL, &bv, &c->value_dn, &c->value_ndn, NULL );
387 if ( rc != LDAP_SUCCESS ) {
388 Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
389 Debug(LDAP_DEBUG_CONFIG, "%s DN is invalid %d (%s)\n",
390 Conf[i].name, rc, ldap_err2string( rc ));
391 return(ARG_BAD_CONF);
394 if(arg_type & ARG_MAGIC) {
395 if(!c->be) c->be = frontendDB;
396 rc = (*((ConfigDriver*)Conf[i].arg_item))(c);
397 if(c->be == frontendDB) c->be = NULL;
399 Debug(LDAP_DEBUG_CONFIG, "%s: handler for <%s> exited with %d!",
400 c->log, Conf[i].name, rc);
401 return(ARG_BAD_CONF);
405 if(arg_type & ARGS_POINTER) switch(arg_type & ARGS_POINTER) {
407 case ARG_INT: *((int*)Conf[i].arg_item) = iarg; break;
408 case ARG_LONG: *((long*)Conf[i].arg_item) = larg; break;
409 case ARG_BER_LEN_T: *((ber_len_t*)Conf[i].arg_item) = barg; break;
411 char *cc = *((char**)Conf[i].arg_item);
413 if (arg_type & ARG_UNIQUE) {
414 Debug(LDAP_DEBUG_CONFIG, "%s: already set %s!\n",
415 c->log, Conf[i].name, 0 );
416 return(ARG_BAD_CONF);
418 ch_free(cc); /* potential memory leak */
420 *(char **)Conf[i].arg_item = c->value_string;
428 read_config(const char *fname, int depth) {
429 return read_config_file(fname, depth, NULL);
433 read_config_file(const char *fname, int depth, ConfigArgs *cf)
439 c = ch_calloc( 1, sizeof( ConfigArgs ) );
445 memcpy( c, cf, sizeof( ConfigArgs ) );
447 c->depth = depth; /* XXX */
453 c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
454 c->argv_size = ARGS_STEP + 1;
456 fp = fopen( fname, "r" );
459 Debug(LDAP_DEBUG_ANY,
460 "could not open config file \"%s\": %s (%d)\n",
461 fname, strerror(errno), errno);
465 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
469 while ( fp_getline( fp, c ) ) {
470 /* skip comments and blank lines */
471 if ( c->line[0] == '#' || c->line[0] == '\0' ) {
475 snprintf( c->log, sizeof( c->log ), "%s: line %lu",
476 c->fname, c->lineno );
478 if ( fp_parse_line( c ) ) {
483 Debug(LDAP_DEBUG_CONFIG, "%s: bad config line (ignored)\n", c->log, 0, 0);
487 rc = parse_config_table( SystemConfiguration, c );
491 if ( rc & ARGS_USERLAND ) {
492 switch(rc) { /* XXX a usertype would be opaque here */
494 Debug(LDAP_DEBUG_CONFIG, "%s: unknown user type <%d>\n",
495 c->log, *c->argv, 0);
499 } else if ( rc == ARG_BAD_CONF || rc != ARG_UNKNOWN ) {
502 } else if ( c->bi && c->bi->bi_config ) { /* XXX to check: could both be/bi_config? oops */
503 rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv);
506 case SLAP_CONF_UNKNOWN:
507 Debug(LDAP_DEBUG_CONFIG, "%s: "
508 "unknown directive <%s> inside backend info definition (ignored)\n",
509 c->log, *c->argv, 0);
516 } else if ( c->be && c->be->be_config ) {
517 rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv);
520 case SLAP_CONF_UNKNOWN:
521 Debug( LDAP_DEBUG_CONFIG, "%s: "
522 "unknown directive <%s> inside backend database definition (ignored)\n",
523 c->log, *c->argv, 0);
530 } else if ( frontendDB->be_config ) {
531 rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
534 case SLAP_CONF_UNKNOWN:
535 Debug( LDAP_DEBUG_CONFIG, "%s: "
536 "unknown directive <%s> inside global database definition (ignored)\n",
537 c->log, *c->argv, 0);
545 Debug(LDAP_DEBUG_CONFIG, "%s: "
546 "unknown directive <%s> outside backend info and database definitions (ignored)\n",
547 c->log, *c->argv, 0);
555 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
556 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
557 &frontendDB->be_schemadn );
558 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
559 if ( rc != LDAP_SUCCESS ) {
560 Debug(LDAP_DEBUG_ANY, "%s: "
561 "unable to normalize default schema DN \"%s\"\n",
562 c->log, frontendDB->be_schemadn.bv_val, 0 );
563 /* must not happen */
580 config_generic(ConfigArgs *c) {
581 char *p = strchr(c->line,'(' /*')'*/);
586 if(!(c->bi = backend_info(c->argv[1]))) {
587 Debug(LDAP_DEBUG_ANY, "%s: "
588 "backend %s failed init!\n", c->log, c->argv[1], 0);
595 if(!(c->be = backend_db_init(c->argv[1]))) {
596 Debug(LDAP_DEBUG_ANY, "%s: "
597 "database %s failed init!\n", c->log, c->argv[1], 0);
603 ldap_pvt_thread_set_concurrency(c->value_long);
607 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
608 connection_pool_max = c->value_int; /* save for reference */
612 lutil_salt_format(c->argv[1]);
616 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
622 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
624 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
628 if (slap_sasl_setpolicy( c->argv[1] )) {
629 Debug(LDAP_DEBUG_ANY, "%s: unable to parse value \"%s\" in"
630 " \"authz-policy <policy>\"\n",
631 c->log, c->argv[1], 0 );
637 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
641 #ifdef HAVE_CYRUS_SASL
644 char *txt = slap_sasl_secprops( c->argv[1] );
646 Debug(LDAP_DEBUG_ANY, "%s: sasl-secprops: %s\n",
654 c->be->be_max_deref_depth = c->value_int;
658 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv)) return(1);
662 if(parse_oc(c->fname, c->lineno, p, c->argv)) return(1);
666 if(parse_cr(c->fname, c->lineno, p, c->argv)) return(1);
670 if(parse_at(c->fname, c->lineno, p, c->argv)) return(1);
674 ad_define_option(NULL, NULL, 0);
675 for(i = 1; i < c->argc; i++)
676 if(ad_define_option(c->argv[i], c->fname, c->lineno))
681 global_schemacheck = c->value_int;
682 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: "
683 "schema checking disabled! your mileage may vary!\n",
688 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
693 c->be->be_auditlogfile = c->value_string;
698 if(SLAP_MONITOR(c->be)) {
699 Debug(LDAP_DEBUG_ANY, "%s: "
700 "\"replogfile\" should not be used "
701 "inside monitor database\n",
703 return(0); /* FIXME: should this be an error? */
706 c->be->be_replogfile = c->value_string;
710 if(read_root_dse_file(c->argv[1])) {
711 Debug(LDAP_DEBUG_ANY, "%s: "
712 "could not read \"rootDSE <filename>\" line\n",
719 FILE *logfile = fopen(c->argv[1], "w");
720 if(logfile) lutil_debug_file(logfile);
725 if(SLAP_NOLASTMODCMD(c->be)) {
726 Debug(LDAP_DEBUG_ANY, "%s: "
727 "lastmod not available for %s databases\n",
728 c->log, c->be->bd_info->bi_type, 0);
732 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
734 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
739 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
744 if(module_path(c->argv[1])) return(1);
750 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
752 slapi_plugins_used++;
756 #ifdef SLAP_AUTH_REWRITE
758 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
765 Debug(LDAP_DEBUG_ANY, "%s: unknown CFG_TYPE %d"
766 "(ignored)\n", c->log, c->type, 0);
774 config_search_base(ConfigArgs *c) {
777 if(c->bi || c->be != frontendDB) {
778 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
779 "prior to any backend or database definition\n",
784 if(default_search_nbase.bv_len) {
785 Debug(LDAP_DEBUG_ANY, "%s: "
786 "default search base \"%s\" already defined "
787 "(discarding old)\n",
788 c->log, default_search_base.bv_val, 0);
789 free(default_search_base.bv_val);
790 free(default_search_nbase.bv_val);
793 default_search_base = c->value_dn;
794 default_search_nbase = c->value_ndn;
799 config_passwd_hash(ConfigArgs *c) {
801 if(default_passwd_hash) {
802 Debug(LDAP_DEBUG_ANY, "%s: "
803 "already set default password_hash\n",
807 for(i = 1; i < c->argc; i++) {
808 if(!lutil_passwd_scheme(c->argv[i])) {
809 Debug(LDAP_DEBUG_ANY, "%s: "
810 "password scheme \"%s\" not available\n",
811 c->log, c->argv[i], 0);
813 ldap_charray_add(&default_passwd_hash, c->argv[i]);
815 if(!default_passwd_hash) {
816 Debug(LDAP_DEBUG_ANY, "%s: no valid hashes found\n",
825 config_schema_dn(ConfigArgs *c) {
828 c->be->be_schemadn = c->value_dn;
829 c->be->be_schemandn = c->value_ndn;
834 config_sizelimit(ConfigArgs *c) {
837 struct slap_limits_set *lim = &c->be->be_def_limit;
838 for(i = 1; i < c->argc; i++) {
839 if(!strncasecmp(c->argv[i], "size", 4)) {
840 rc = limits_parse_one(c->argv[i], lim);
842 Debug(LDAP_DEBUG_ANY, "%s: "
843 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
844 c->log, c->argv[i], 0);
848 if(!strcasecmp(c->argv[i], "unlimited")) {
849 lim->lms_s_soft = -1;
851 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
852 if(next == c->argv[i]) {
853 Debug(LDAP_DEBUG_ANY, "%s: "
854 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
855 c->log, c->argv[i], 0);
857 } else if(next[0] != '\0') {
858 Debug(LDAP_DEBUG_ANY, "%s: "
859 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
870 config_timelimit(ConfigArgs *c) {
873 struct slap_limits_set *lim = &c->be->be_def_limit;
874 for(i = 1; i < c->argc; i++) {
875 if(!strncasecmp(c->argv[i], "time", 4)) {
876 rc = limits_parse_one(c->argv[i], lim);
878 Debug(LDAP_DEBUG_ANY, "%s: "
879 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
880 c->log, c->argv[i], 0);
884 if(!strcasecmp(c->argv[i], "unlimited")) {
885 lim->lms_t_soft = -1;
887 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
888 if(next == c->argv[i]) {
889 Debug(LDAP_DEBUG_ANY, "%s: "
890 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
891 c->log, c->argv[i], 0);
893 } else if(next[0] != '\0') {
894 Debug(LDAP_DEBUG_ANY, "%s: "
895 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
906 config_overlay(ConfigArgs *c) {
907 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
909 Debug(LDAP_DEBUG_ANY, "%s: (optional) %s overlay \"%s\" configuration failed (ignored)\n",
910 c->log, c->be == frontendDB ? "global " : "", c->argv[1][1]);
911 } else if(overlay_config(c->be, c->argv[1])) {
918 config_suffix(ConfigArgs *c) {
920 struct berval pdn, ndn;
922 #ifdef SLAPD_MONITOR_DN
923 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
924 Debug(LDAP_DEBUG_ANY, "%s: "
925 "\"%s\" is reserved for monitoring slapd\n",
926 c->log, SLAPD_MONITOR_DN, 0);
933 tbe = select_backend(&ndn, 0, 0);
935 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by this backend! (ignored)\n",
940 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by a preceding backend \"%s\"\n",
941 c->log, tbe->be_suffix[0].bv_val, 0);
945 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
946 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
947 "base provided \"%s\" (assuming okay)\n",
948 c->log, default_search_base.bv_val, 0);
950 ber_bvarray_add(&c->be->be_suffix, &pdn);
951 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
956 config_rootdn(ConfigArgs *c) {
957 c->be->be_rootdn = c->value_dn;
958 c->be->be_rootndn = c->value_ndn;
963 config_rootpw(ConfigArgs *c) {
964 Backend *tbe = select_backend(&c->be->be_rootndn, 0, 0);
966 Debug(LDAP_DEBUG_ANY, "%s: "
967 "rootpw can only be set when rootdn is under suffix\n",
971 ber_str2bv(c->argv[1], 0, 1, &c->be->be_rootpw);
975 /* restrictops, allows, disallows, requires, loglevel */
977 struct verb_mask_list { char *word; int mask; };
980 verb_to_mask(ConfigArgs *c, struct verb_mask_list *v, int word) {
982 for(j = 0; v[j].word; j++)
983 if(!strcasecmp(c->argv[word], v[j].word))
989 verbs_to_mask(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t *m) {
991 for(i = 1; i < c->argc; i++) {
992 j = verb_to_mask(c, v, i);
993 if(!v[j].word) return(1);
1000 config_restrict(ConfigArgs *c) {
1001 slap_mask_t restrictops = 0;
1003 struct verb_mask_list restrictable_exops[] = {
1004 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
1005 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
1006 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
1007 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
1010 struct verb_mask_list restrictable_ops[] = {
1011 { "bind", SLAP_RESTRICT_OP_BIND },
1012 { "add", SLAP_RESTRICT_OP_ADD },
1013 { "modify", SLAP_RESTRICT_OP_MODIFY },
1014 { "modrdn", SLAP_RESTRICT_OP_RENAME },
1015 { "rename", SLAP_RESTRICT_OP_RENAME },
1016 { "delete", SLAP_RESTRICT_OP_DELETE },
1017 { "search", SLAP_RESTRICT_OP_SEARCH },
1018 { "compare", SLAP_RESTRICT_OP_COMPARE },
1019 { "read", SLAP_RESTRICT_OP_READS },
1020 { "write", SLAP_RESTRICT_OP_WRITES },
1024 for(i = 1; i < c->argc; i++) {
1025 j = verb_to_mask(c, restrictable_ops, i);
1026 if(restrictable_ops[j].word) {
1027 restrictops |= restrictable_ops[j].mask;
1029 } else if(!strncasecmp(c->argv[i], "extended", STRLENOF("extended"))) {
1030 char *e = c->argv[i] + STRLENOF("extended");
1032 int k = verb_to_mask(c, restrictable_exops, e[1]);
1033 if(restrictable_exops[k].word) {
1034 restrictops |= restrictable_exops[k].mask;
1038 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
1039 restrictops |= SLAP_RESTRICT_OP_EXTENDED;
1044 c->be->be_restrictops |= restrictops;
1047 Debug(LDAP_DEBUG_ANY, "%s: "
1048 "unknown operation %s in \"restrict <features>\" line\n",
1049 c->log, c->argv[i], 0);
1054 config_allows(ConfigArgs *c) {
1055 slap_mask_t allows = 0;
1057 struct verb_mask_list allowable_ops[] = {
1058 { "bind_v2", SLAP_ALLOW_BIND_V2 },
1059 { "bind_anon_cred", SLAP_ALLOW_BIND_ANON_CRED },
1060 { "bind_anon_dn", SLAP_ALLOW_BIND_ANON_DN },
1061 { "update_anon", SLAP_ALLOW_UPDATE_ANON },
1064 i = verbs_to_mask(c, allowable_ops, &allows);
1066 Debug(LDAP_DEBUG_ANY, "%s: "
1067 "unknown feature %s in \"allow <features>\" line\n",
1068 c->log, c->argv[i], 0);
1071 global_allows |= allows;
1076 config_disallows(ConfigArgs *c) {
1077 slap_mask_t disallows = 0;
1079 struct verb_mask_list disallowable_ops[] = {
1080 { "bind_anon", SLAP_DISALLOW_BIND_ANON },
1081 { "bind_simple", SLAP_DISALLOW_BIND_SIMPLE },
1082 { "bind_krb4", SLAP_DISALLOW_BIND_KRBV4 },
1083 { "tls_2_anon", SLAP_DISALLOW_TLS_2_ANON },
1084 { "tls_authc", SLAP_DISALLOW_TLS_AUTHC },
1087 i = verbs_to_mask(c, disallowable_ops, &disallows);
1089 Debug(LDAP_DEBUG_ANY, "%s: "
1090 "unknown feature %s in \"disallow <features>\" line\n",
1091 c->log, c->argv[i], 0);
1094 global_disallows |= disallows;
1099 config_requires(ConfigArgs *c) {
1100 slap_mask_t requires = 0;
1102 struct verb_mask_list requires_ops[] = {
1103 { "bind", SLAP_REQUIRE_BIND },
1104 { "LDAPv3", SLAP_REQUIRE_LDAP_V3 },
1105 { "authc", SLAP_REQUIRE_AUTHC },
1106 { "sasl", SLAP_REQUIRE_SASL },
1107 { "strong", SLAP_REQUIRE_STRONG },
1110 i = verbs_to_mask(c, requires_ops, &requires);
1112 Debug(LDAP_DEBUG_ANY, "%s: "
1113 "unknown feature %s in \"require <features>\" line\n",
1114 c->log, c->argv[i], 0);
1117 c->be->be_requires = requires;
1122 config_loglevel(ConfigArgs *c) {
1125 struct verb_mask_list loglevel_ops[] = {
1126 { "Trace", LDAP_DEBUG_TRACE },
1127 { "Packets", LDAP_DEBUG_PACKETS },
1128 { "Args", LDAP_DEBUG_ARGS },
1129 { "Conns", LDAP_DEBUG_CONNS },
1130 { "BER", LDAP_DEBUG_BER },
1131 { "Filter", LDAP_DEBUG_FILTER },
1132 { "Config", LDAP_DEBUG_CONFIG },
1133 { "ACL", LDAP_DEBUG_ACL },
1134 { "Stats", LDAP_DEBUG_STATS },
1135 { "Stats2", LDAP_DEBUG_STATS2 },
1136 { "Shell", LDAP_DEBUG_SHELL },
1137 { "Parse", LDAP_DEBUG_PARSE },
1138 { "Cache", LDAP_DEBUG_CACHE },
1139 { "Index", LDAP_DEBUG_INDEX },
1145 for( i=1; i < c->argc; i++ ) {
1148 if ( isdigit( c->argv[i][0] ) ) {
1149 level = strtol( c->argv[i], &next, 10 );
1150 if ( next == NULL || next[0] != '\0' ) {
1151 Debug( LDAP_DEBUG_ANY,
1152 "%s: unable to parse level \"%s\" "
1153 "in \"loglevel <level> [...]\" line.\n",
1154 c->log, c->argv[i], 0);
1158 int j = verb_to_mask(c, loglevel_ops, c->argv[i][0]);
1159 if(!loglevel_ops[j].word) {
1160 Debug( LDAP_DEBUG_ANY,
1161 "%s: unknown level \"%s\" "
1162 "in \"loglevel <level> [...]\" line.\n",
1163 c->log, c->argv[i], 0);
1166 level = loglevel_ops[j].mask;
1168 ldap_syslog |= level;
1174 config_syncrepl(ConfigArgs *c) {
1175 if(SLAP_SHADOW(c->be)) {
1176 Debug(LDAP_DEBUG_ANY, "%s: "
1177 "syncrepl: database already shadowed.\n",
1180 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1183 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1188 config_referral(ConfigArgs *c) {
1189 struct berval vals[2];
1190 if(validate_global_referral(c->argv[1])) {
1191 Debug(LDAP_DEBUG_ANY, "%s: "
1192 "invalid URL (%s) in \"referral\" line.\n",
1193 c->log, c->argv[1], 0);
1197 ber_str2bv(c->argv[1], 0, 1, &vals[0]);
1198 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1199 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1204 config_security(ConfigArgs *c) {
1205 slap_ssf_set_t *set = &c->be->be_ssf_set;
1208 for(i = 1; i < c->argc; i++) {
1211 if(!strncasecmp(c->argv[i], "ssf=", 4)) {
1212 tgt = &set->sss_ssf;
1213 src = &c->argv[i][4];
1214 } else if(!strncasecmp(c->argv[i], "transport=", 10)) {
1215 tgt = &set->sss_transport;
1216 src = &c->argv[i][10];
1217 } else if(!strncasecmp(c->argv[i], "tls=", 4)) {
1218 tgt = &set->sss_tls;
1219 src = &c->argv[i][4];
1220 } else if(!strncasecmp(c->argv[i], "sasl=", 5)) {
1221 tgt = &set->sss_sasl;
1222 src = &c->argv[i][5];
1223 } else if(!strncasecmp(c->argv[i], "update_ssf=", 11)) {
1224 tgt = &set->sss_update_ssf;
1225 src = &c->argv[i][11];
1226 } else if(!strncasecmp(c->argv[i], "update_transport=", 17)) {
1227 tgt = &set->sss_update_transport;
1228 src = &c->argv[i][17];
1229 } else if(!strncasecmp(c->argv[i], "update_tls=", 11)) {
1230 tgt = &set->sss_update_tls;
1231 src = &c->argv[i][11];
1232 } else if(!strncasecmp(c->argv[i], "update_sasl=", 12)) {
1233 tgt = &set->sss_update_sasl;
1234 src = &c->argv[i][12];
1235 } else if(!strncasecmp(c->argv[i], "simple_bind=", 12)) {
1236 tgt = &set->sss_simple_bind;
1237 src = &c->argv[i][12];
1239 Debug(LDAP_DEBUG_ANY, "%s: "
1240 "unknown factor %s in \"security <factors>\" line\n",
1241 c->log, c->argv[i], 0);
1245 *tgt = strtol(src, &next, 10);
1246 if(next == NULL || next[0] != '\0' ) {
1247 Debug(LDAP_DEBUG_ANY, "%s: "
1248 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1249 c->log, c->argv[i], 0);
1257 config_replica(ConfigArgs *c) {
1259 char *replicahost, *replicalog = NULL;
1262 if(SLAP_MONITOR(c->be)) {
1263 Debug(LDAP_DEBUG_ANY, "%s: "
1264 "\"replica\" should not be used inside monitor database\n",
1266 return(0); /* FIXME: should this be an error? */
1269 for(i = 1; i < c->argc; i++) {
1270 if(!strncasecmp(c->argv[i], "host=", STRLENOF("host="))) {
1271 replicalog = c->argv[i] + STRLENOF("host=");
1272 nr = add_replica_info(c->be, c->argv[i] + STRLENOF("host="));
1274 } else if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) {
1275 if(ldap_url_parse(c->argv[i] + STRLENOF("uri="), &ludp) != LDAP_SUCCESS) {
1276 Debug(LDAP_DEBUG_ANY, "%s: "
1277 "replica line contains invalid "
1278 "uri definition.\n", c->log, 0, 0);
1281 if(!ludp->lud_host) {
1282 Debug(LDAP_DEBUG_ANY, "%s: "
1283 "replica line contains invalid "
1284 "uri definition - missing hostname.\n",
1288 replicahost = ch_malloc(strlen(c->argv[i]));
1290 Debug(LDAP_DEBUG_ANY,
1291 "out of memory in read_config\n", 0, 0, 0);
1292 ldap_free_urldesc(ludp);
1295 sprintf(replicahost, "%s:%d", ludp->lud_host, ludp->lud_port);
1296 replicalog = c->argv[i] + STRLENOF("uri=");
1297 nr = add_replica_info(c->be, replicahost);
1298 ldap_free_urldesc(ludp);
1299 ch_free(replicahost);
1304 Debug(LDAP_DEBUG_ANY, "%s: "
1305 "missing host or uri in \"replica\" line\n",
1308 } else if(nr == -1) {
1309 Debug(LDAP_DEBUG_ANY, "%s: "
1310 "unable to add replica \"%s\"\n",
1311 c->log, replicalog, 0);
1314 for(i = 1; i < c->argc; i++) {
1315 if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
1316 switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) {
1318 Debug(LDAP_DEBUG_ANY, "%s: "
1319 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1320 c->log, c->argv[i] + STRLENOF("suffix="), 0);
1323 Debug(LDAP_DEBUG_ANY, "%s: "
1324 "unable to normalize suffix in \"replica\" line (ignored)\n",
1329 } else if(!strncasecmp(c->argv[i], "attr", STRLENOF("attr"))) {
1331 char *arg = c->argv[i] + STRLENOF("attr");
1339 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1340 Debug(LDAP_DEBUG_ANY, "%s: "
1341 "attribute \"%s\" in \"replica\" line is unknown\n",
1342 c->log, arg + 1, 0);
1352 config_updatedn(ConfigArgs *c) {
1355 if(SLAP_SHADOW(c->be)) {
1356 Debug(LDAP_DEBUG_ANY, "%s: "
1357 "updatedn: database already shadowed.\n",
1362 ber_str2bv(c->argv[1], 0, 0, &dn);
1364 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1366 if(rc != LDAP_SUCCESS) {
1367 Debug(LDAP_DEBUG_ANY, "%s: "
1368 "updatedn DN is invalid: %d (%s)\n",
1369 c->log, rc, ldap_err2string( rc ));
1373 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1378 config_updateref(ConfigArgs *c) {
1379 struct berval vals[2];
1380 if(!SLAP_SHADOW(c->be)) {
1381 Debug(LDAP_DEBUG_ANY, "%s: "
1382 "updateref line must after syncrepl or updatedn.\n",
1387 if(validate_global_referral(c->argv[1])) {
1388 Debug(LDAP_DEBUG_ANY, "%s: "
1389 "invalid URL (%s) in \"updateref\" line.\n",
1390 c->log, c->argv[1], 0);
1393 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1394 vals[1].bv_val = NULL;
1395 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1399 /* XXX meaningless in ldif */
1402 config_include(ConfigArgs *c) {
1403 char *savefname = ch_strdup(c->argv[1]);
1404 unsigned long savelineno = c->lineno;
1406 rc = read_config_file(savefname, c->depth + 1, c);
1408 c->lineno = savelineno - 1;
1414 config_tls_option(ConfigArgs *c) {
1417 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
1418 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
1419 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
1420 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
1421 case CFG_TLS_CERT_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
1422 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
1423 #ifdef HAVE_OPENSSL_CRL
1424 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
1426 default: Debug(LDAP_DEBUG_ANY, "%s: "
1427 "unknown tls_option <%x>\n",
1428 c->log, c->type, 0);
1430 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
1434 config_tls_verify(ConfigArgs *c) {
1436 if(isdigit((unsigned char)c->argv[1][0])) {
1437 i = atoi(c->argv[1]);
1438 return(ldap_pvt_tls_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i));
1440 return(ldap_int_tls_config(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, c->argv[1]));
1445 /* -------------------------------------- */
1449 strtok_quote( char *line, char *sep )
1455 strtok_quote_ptr = NULL;
1456 if ( line != NULL ) {
1459 while ( *next && strchr( sep, *next ) ) {
1463 if ( *next == '\0' ) {
1469 for ( inquote = 0; *next; ) {
1477 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1483 next + 1, strlen( next + 1 ) + 1 );
1484 next++; /* dont parse the escaped character */
1489 if ( strchr( sep, *next ) != NULL ) {
1490 strtok_quote_ptr = next;
1503 static char buf[BUFSIZ];
1505 static size_t lmax, lcur;
1507 #define CATLINE( buf ) \
1509 size_t len = strlen( buf ); \
1510 while ( lcur + len + 1 > lmax ) { \
1512 line = (char *) ch_realloc( line, lmax ); \
1514 strcpy( line + lcur, buf ); \
1519 fp_getline_init(ConfigArgs *c) {
1525 fp_getline( FILE *fp, ConfigArgs *c )
1533 /* avoid stack of bufs */
1534 if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
1540 while ( fgets( buf, sizeof( buf ), fp ) ) {
1541 p = strchr( buf, '\n' );
1543 if ( p > buf && p[-1] == '\r' ) {
1551 && ( p = line + strlen( line ) - 1 )[0] == '\\'
1558 if ( !isspace( (unsigned char)buf[0] ) ) {
1569 return(line[0] ? 1 : 0);
1573 fp_parse_line(ConfigArgs *c)
1576 char *tline = ch_strdup(c->line);
1577 char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
1581 token = strtok_quote(tline, " \t");
1583 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
1584 if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
1585 Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
1586 if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
1588 for(; token; token = strtok_quote(NULL, " \t")) {
1589 if(c->argc == c->argv_size - 1) {
1591 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
1593 Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0);
1597 c->argv_size += ARGS_STEP;
1599 c->argv[c->argc++] = token;
1601 c->argv[c->argc] = NULL;
1607 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1609 load_ucdata( char *path )
1612 static int loaded = 0;
1618 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
1620 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
1628 /* ucdata is now hardcoded */
1637 ucdata_unload( UCDATA_ALL );
1639 /* NOTE: in case of early exit, frontendDB can be NULL */
1640 if ( frontendDB->be_schemandn.bv_val )
1641 free( frontendDB->be_schemandn.bv_val );
1642 if ( frontendDB->be_schemadn.bv_val )
1643 free( frontendDB->be_schemadn.bv_val );
1644 if ( frontendDB->be_acl )
1645 acl_destroy( frontendDB->be_acl, NULL );
1648 if ( slapd_args_file )
1649 free ( slapd_args_file );
1650 if ( slapd_pid_file )
1651 free ( slapd_pid_file );
1652 if ( default_passwd_hash )
1653 ldap_charray_free( default_passwd_hash );
1666 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
1669 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
1673 si->si_tls = SYNCINFO_TLS_OFF;
1674 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1675 si->si_schemachecking = 0;
1676 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
1677 &si->si_filterstr );
1678 si->si_base.bv_val = NULL;
1679 si->si_scope = LDAP_SCOPE_SUBTREE;
1680 si->si_attrsonly = 0;
1681 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1682 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1683 si->si_attrs = NULL;
1684 si->si_allattrs = 0;
1685 si->si_allopattrs = 0;
1686 si->si_exattrs = NULL;
1687 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1688 si->si_interval = 86400;
1689 si->si_retryinterval = NULL;
1690 si->si_retrynum_init = NULL;
1691 si->si_retrynum = NULL;
1692 si->si_manageDSAit = 0;
1696 si->si_presentlist = NULL;
1697 LDAP_LIST_INIT( &si->si_nonpresentlist );
1698 ldap_pvt_thread_mutex_init( &si->si_mutex );
1700 rc = parse_syncrepl_line( cargv, cargc, si );
1703 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
1704 syncinfo_free( si );
1707 Debug( LDAP_DEBUG_CONFIG,
1708 "Config: ** successfully added syncrepl \"%s\"\n",
1709 BER_BVISNULL( &si->si_provideruri ) ?
1710 "(null)" : si->si_provideruri.bv_val, 0, 0 );
1711 if ( !si->si_schemachecking ) {
1712 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
1715 be->be_syncinfo = si;
1720 /* NOTE: used & documented in slapd.conf(5) */
1722 #define PROVIDERSTR "provider"
1723 #define TYPESTR "type"
1724 #define INTERVALSTR "interval"
1725 #define SEARCHBASESTR "searchbase"
1726 #define FILTERSTR "filter"
1727 #define SCOPESTR "scope"
1728 #define ATTRSSTR "attrs"
1729 #define ATTRSONLYSTR "attrsonly"
1730 #define SLIMITSTR "sizelimit"
1731 #define TLIMITSTR "timelimit"
1732 #define SCHEMASTR "schemachecking"
1733 #define BINDMETHSTR "bindmethod"
1734 #define SIMPLESTR "simple"
1735 #define SASLSTR "sasl"
1736 #define BINDDNSTR "binddn"
1737 #define SASLMECHSTR "saslmech"
1738 #define AUTHCSTR "authcID"
1739 #define AUTHZSTR "authzID"
1740 #define CREDSTR "credentials"
1741 #define REALMSTR "realm"
1742 #define SECPROPSSTR "secprops"
1744 /* FIXME: undocumented */
1745 #define OLDAUTHCSTR "bindprincipal"
1746 #define STARTTLSSTR "starttls"
1747 #define CRITICALSTR "critical"
1748 #define EXATTRSSTR "exattrs"
1749 #define MANAGEDSAITSTR "manageDSAit"
1750 #define RETRYSTR "retry"
1753 #define LASTMODSTR "lastmod"
1754 #define LMGENSTR "gen"
1755 #define LMNOSTR "no"
1756 #define LMREQSTR "req"
1757 #define SRVTABSTR "srvtab"
1758 #define SUFFIXSTR "suffix"
1759 #define UPDATEDNSTR "updatedn"
1762 #define GOT_ID 0x0001
1763 #define GOT_PROVIDER 0x0002
1764 #define GOT_METHOD 0x0004
1767 #define GOT_ALL (GOT_ID|GOT_PROVIDER|GOT_METHOD)
1770 parse_syncrepl_line(
1780 for ( i = 1; i < cargc; i++ ) {
1781 if ( !strncasecmp( cargv[ i ], IDSTR "=",
1782 STRLENOF( IDSTR "=" ) ) )
1785 /* '\0' string terminator accounts for '=' */
1786 val = cargv[ i ] + STRLENOF( IDSTR "=" );
1788 if ( tmp >= 1000 || tmp < 0 ) {
1789 fprintf( stderr, "Error: parse_syncrepl_line: "
1790 "syncrepl id %d is out of range [0..999]\n", tmp );
1795 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
1796 STRLENOF( PROVIDERSTR "=" ) ) )
1798 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
1799 ber_str2bv( val, 0, 1, &si->si_provideruri );
1800 gots |= GOT_PROVIDER;
1801 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=",
1802 STRLENOF(STARTTLSSTR "=") ) )
1804 val = cargv[ i ] + STRLENOF( STARTTLSSTR "=" );
1805 if( !strcasecmp( val, CRITICALSTR ) ) {
1806 si->si_tls = SYNCINFO_TLS_CRITICAL;
1808 si->si_tls = SYNCINFO_TLS_ON;
1810 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR "=",
1811 STRLENOF( BINDMETHSTR "=" ) ) )
1813 val = cargv[ i ] + STRLENOF( BINDMETHSTR "=" );
1814 if ( !strcasecmp( val, SIMPLESTR )) {
1815 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1817 } else if ( !strcasecmp( val, SASLSTR )) {
1818 #ifdef HAVE_CYRUS_SASL
1819 si->si_bindmethod = LDAP_AUTH_SASL;
1821 #else /* HAVE_CYRUS_SASL */
1822 fprintf( stderr, "Error: parse_syncrepl_line: "
1823 "not compiled with SASL support\n" );
1825 #endif /* HAVE_CYRUS_SASL */
1827 si->si_bindmethod = -1;
1829 } else if ( !strncasecmp( cargv[ i ], BINDDNSTR "=",
1830 STRLENOF( BINDDNSTR "=" ) ) )
1832 val = cargv[ i ] + STRLENOF( BINDDNSTR "=" );
1833 si->si_binddn = ch_strdup( val );
1834 } else if ( !strncasecmp( cargv[ i ], CREDSTR "=",
1835 STRLENOF( CREDSTR "=" ) ) )
1837 val = cargv[ i ] + STRLENOF( CREDSTR "=" );
1838 si->si_passwd = ch_strdup( val );
1839 } else if ( !strncasecmp( cargv[ i ], SASLMECHSTR "=",
1840 STRLENOF( SASLMECHSTR "=" ) ) )
1842 val = cargv[ i ] + STRLENOF( SASLMECHSTR "=" );
1843 si->si_saslmech = ch_strdup( val );
1844 } else if ( !strncasecmp( cargv[ i ], SECPROPSSTR "=",
1845 STRLENOF( SECPROPSSTR "=" ) ) )
1847 val = cargv[ i ] + STRLENOF( SECPROPSSTR "=" );
1848 si->si_secprops = ch_strdup( val );
1849 } else if ( !strncasecmp( cargv[ i ], REALMSTR "=",
1850 STRLENOF( REALMSTR "=" ) ) )
1852 val = cargv[ i ] + STRLENOF( REALMSTR "=" );
1853 si->si_realm = ch_strdup( val );
1854 } else if ( !strncasecmp( cargv[ i ], AUTHCSTR "=",
1855 STRLENOF( AUTHCSTR "=" ) ) )
1857 val = cargv[ i ] + STRLENOF( AUTHCSTR "=" );
1858 if ( si->si_authcId )
1859 ch_free( si->si_authcId );
1860 si->si_authcId = ch_strdup( val );
1861 } else if ( !strncasecmp( cargv[ i ], OLDAUTHCSTR "=",
1862 STRLENOF( OLDAUTHCSTR "=" ) ) )
1864 /* Old authcID is provided for some backwards compatibility */
1865 val = cargv[ i ] + STRLENOF( OLDAUTHCSTR "=" );
1866 if ( si->si_authcId )
1867 ch_free( si->si_authcId );
1868 si->si_authcId = ch_strdup( val );
1869 } else if ( !strncasecmp( cargv[ i ], AUTHZSTR "=",
1870 STRLENOF( AUTHZSTR "=" ) ) )
1872 val = cargv[ i ] + STRLENOF( AUTHZSTR "=" );
1873 si->si_authzId = ch_strdup( val );
1874 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
1875 STRLENOF( SCHEMASTR "=" ) ) )
1877 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
1878 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
1879 si->si_schemachecking = 1;
1880 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
1881 si->si_schemachecking = 0;
1883 si->si_schemachecking = 1;
1885 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
1886 STRLENOF( FILTERSTR "=" ) ) )
1888 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
1889 ber_str2bv( val, 0, 1, &si->si_filterstr );
1890 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
1891 STRLENOF( SEARCHBASESTR "=" ) ) )
1896 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
1897 if ( si->si_base.bv_val ) {
1898 ch_free( si->si_base.bv_val );
1900 ber_str2bv( val, 0, 0, &bv );
1901 rc = dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL );
1902 if ( rc != LDAP_SUCCESS ) {
1903 fprintf( stderr, "Invalid base DN \"%s\": %d (%s)\n",
1904 val, rc, ldap_err2string( rc ) );
1907 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
1908 STRLENOF( SCOPESTR "=" ) ) )
1910 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
1911 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
1912 si->si_scope = LDAP_SCOPE_BASE;
1913 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
1914 si->si_scope = LDAP_SCOPE_ONELEVEL;
1915 #ifdef LDAP_SCOPE_SUBORDINATE
1916 } else if ( !strcasecmp( val, "subordinate" ) ||
1917 !strcasecmp( val, "children" ))
1919 si->si_scope = LDAP_SCOPE_SUBORDINATE;
1921 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
1922 si->si_scope = LDAP_SCOPE_SUBTREE;
1924 fprintf( stderr, "Error: parse_syncrepl_line: "
1925 "unknown scope \"%s\"\n", val);
1928 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
1929 STRLENOF( ATTRSONLYSTR "=" ) ) )
1931 si->si_attrsonly = 1;
1932 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
1933 STRLENOF( ATTRSSTR "=" ) ) )
1935 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
1936 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
1938 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1939 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
1940 if ( si->si_anlist == NULL ) {
1941 ch_free( attr_fname );
1944 ch_free( attr_fname );
1946 char *str, *s, *next;
1947 char delimstr[] = " ,\t";
1948 str = ch_strdup( val );
1949 for ( s = ldap_pvt_strtok( str, delimstr, &next );
1951 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
1953 if ( strlen(s) == 1 && *s == '*' ) {
1954 si->si_allattrs = 1;
1955 *(val + ( s - str )) = delimstr[0];
1957 if ( strlen(s) == 1 && *s == '+' ) {
1958 si->si_allopattrs = 1;
1959 *(val + ( s - str )) = delimstr[0];
1963 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
1964 if ( si->si_anlist == NULL ) {
1968 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
1969 STRLENOF( EXATTRSSTR "=" ) ) )
1971 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
1972 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
1974 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1975 si->si_exanlist = file2anlist(
1976 si->si_exanlist, attr_fname, " ,\t" );
1977 if ( si->si_exanlist == NULL ) {
1978 ch_free( attr_fname );
1981 ch_free( attr_fname );
1983 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
1984 if ( si->si_exanlist == NULL ) {
1988 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
1989 STRLENOF( TYPESTR "=" ) ) )
1991 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
1992 if ( !strncasecmp( val, "refreshOnly",
1993 STRLENOF("refreshOnly") ))
1995 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1996 } else if ( !strncasecmp( val, "refreshAndPersist",
1997 STRLENOF("refreshAndPersist") ))
1999 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
2000 si->si_interval = 60;
2002 fprintf( stderr, "Error: parse_syncrepl_line: "
2003 "unknown sync type \"%s\"\n", val);
2006 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
2007 STRLENOF( INTERVALSTR "=" ) ) )
2009 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
2010 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
2011 si->si_interval = 0;
2019 hstr = strchr( dstr, ':' );
2020 if ( hstr == NULL ) {
2021 fprintf( stderr, "Error: parse_syncrepl_line: "
2022 "invalid interval \"%s\"\n", val );
2026 mstr = strchr( hstr, ':' );
2027 if ( mstr == NULL ) {
2028 fprintf( stderr, "Error: parse_syncrepl_line: "
2029 "invalid interval \"%s\"\n", val );
2033 sstr = strchr( mstr, ':' );
2034 if ( sstr == NULL ) {
2035 fprintf( stderr, "Error: parse_syncrepl_line: "
2036 "invalid interval \"%s\"\n", val );
2045 if (( hh > 24 ) || ( hh < 0 ) ||
2046 ( mm > 60 ) || ( mm < 0 ) ||
2047 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2048 fprintf( stderr, "Error: parse_syncrepl_line: "
2049 "invalid interval \"%s\"\n", val );
2052 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2054 if ( si->si_interval < 0 ) {
2055 fprintf( stderr, "Error: parse_syncrepl_line: "
2056 "invalid interval \"%ld\"\n",
2057 (long) si->si_interval);
2060 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2061 STRLENOF( RETRYSTR "=" ) ) )
2066 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2067 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2068 retry_list[0] = NULL;
2070 slap_str2clist( &retry_list, val, " ,\t" );
2072 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2076 "Error: incomplete syncrepl retry list\n" );
2077 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2078 ch_free( retry_list[k] );
2080 ch_free( retry_list );
2081 exit( EXIT_FAILURE );
2083 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2084 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2085 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2086 for ( j = 0; j < n; j++ ) {
2087 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2088 if ( *retry_list[j*2+1] == '+' ) {
2089 si->si_retrynum_init[j] = -1;
2090 si->si_retrynum[j] = -1;
2094 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2095 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2098 si->si_retrynum_init[j] = -2;
2099 si->si_retrynum[j] = -2;
2100 si->si_retryinterval[j] = 0;
2102 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2103 ch_free( retry_list[k] );
2105 ch_free( retry_list );
2106 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2107 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2109 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2110 si->si_manageDSAit = atoi( val );
2111 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2112 STRLENOF( SLIMITSTR "=") ) )
2114 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2115 si->si_slimit = atoi( val );
2116 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2117 STRLENOF( TLIMITSTR "=" ) ) )
2119 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2120 si->si_tlimit = atoi( val );
2122 fprintf( stderr, "Error: parse_syncrepl_line: "
2123 "unknown keyword \"%s\"\n", cargv[ i ] );
2128 if ( gots != GOT_ALL ) {
2130 "Error: Malformed \"syncrepl\" line in slapd config file" );
2138 slap_str2clist( char ***out, char *in, const char *brkstr )
2146 /* find last element in list */
2147 for (i = 0; *out && (*out)[i]; i++);
2149 /* protect the input string from strtok */
2150 str = ch_strdup( in );
2152 if ( *str == '\0' ) {
2157 /* Count words in string */
2159 for ( s = str; *s; s++ ) {
2160 if ( strchr( brkstr, *s ) != NULL ) {
2165 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
2167 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
2169 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
2171 *new = ch_strdup( s );