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);
168 /* original config.c ordering */
170 ConfigTable SystemConfiguration[] = {
171 { "backend", 2, 2, 0, "type", ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND, &config_generic, NULL, NULL, NULL },
172 { "database", 2, 2, 0, "type", ARG_MAGIC|CFG_DATABASE, &config_generic, NULL, NULL, NULL },
173 { "localSSF", 2, 2, 0, "ssf", ARG_LONG, &local_ssf, NULL, NULL, NULL },
174 { "concurrency", 2, 2, 0, "level", ARG_LONG|ARG_NONZERO|ARG_MAGIC|CFG_CONCUR, &config_generic, NULL, NULL, NULL },
175 { "index_substr_if_minlen", 2, 2, 0, "min", ARG_INT|ARG_NONZERO, &index_substr_if_minlen, NULL, NULL, NULL },
176 { "index_substr_if_maxlen", 2, 2, 0, "max", ARG_INT|ARG_NONZERO|ARG_SPECIAL, &index_substr_if_maxlen, NULL, NULL, NULL },
177 { "index_substr_any_len", 2, 2, 0, "len", ARG_INT|ARG_NONZERO, &index_substr_any_len, NULL, NULL, NULL },
178 { "index_substr_step", 2, 2, 0, "step", ARG_INT|ARG_NONZERO, &index_substr_any_step, NULL, NULL, NULL },
179 { "sockbuf_max_incoming", 2, 2, 0, "max", ARG_LONG, &sockbuf_max_incoming, NULL, NULL, NULL },
180 { "sockbuf_max_incoming_auth",2, 2, 0, "max", ARG_LONG, &sockbuf_max_incoming_auth, NULL, NULL, NULL },
181 { "conn_max_pending", 2, 2, 0, "max", ARG_LONG, &slap_conn_max_pending, NULL, NULL, NULL },
182 { "conn_max_pending_auth", 2, 2, 0, "max", ARG_LONG, &slap_conn_max_pending_auth, NULL, NULL, NULL },
183 { "defaultSearchBase", 2, 2, 0, "dn", ARG_MAGIC, &config_search_base, NULL, NULL, NULL },
184 { "threads", 2, 2, 0, "count", ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic, NULL, NULL, NULL },
185 { "pidfile", 2, 2, 0, "file", ARG_STRING, &slapd_pid_file, NULL, NULL, NULL },
186 { "argsfile", 2, 2, 0, "file", ARG_STRING, &slapd_args_file, NULL, NULL, NULL },
187 { "password-hash", 2, 2, 0, "hash", ARG_MAGIC, &config_passwd_hash, NULL, NULL, NULL },
188 { "password-crypt-salt-format",2, 2, 0, "salt", ARG_MAGIC|CFG_SALT, &config_generic, NULL, NULL, NULL },
189 #ifdef SLAP_AUTH_REWRITE
190 { "auth-rewrite", 2, 2, 14, NULL, ARG_MAGIC|CFG_REWRITE, &config_generic, NULL, NULL, NULL },
192 { "sasl", 2, 0, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL }, /* XXX */
193 { "auth", 2, 2, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL },
194 { "schemadn", 2, 2, 0, "dn", ARG_MAGIC, &config_schema_dn, NULL, NULL, NULL },
195 { "ucdata-path", 2, 2, 0, "path", ARG_IGNORED, NULL, NULL, NULL, NULL },
196 { "sizelimit", 2, 2, 0, "limit", ARG_MAGIC|CFG_SIZE, &config_sizelimit, NULL, NULL, NULL },
197 { "timelimit", 2, 2, 0, "limit", ARG_MAGIC|CFG_TIME, &config_timelimit, NULL, NULL, NULL },
198 { "limits", 2, 0, 0, "limits", ARG_DB|ARG_MAGIC|CFG_LIMITS, &config_generic, NULL, NULL, NULL },
199 { "overlay", 2, 2, 0, "overlay", ARG_MAGIC, &config_overlay, NULL, NULL, NULL },
200 { "suffix", 2, 2, 0, "suffix", ARG_DB|ARG_MAGIC, &config_suffix, NULL, NULL, NULL },
201 { "maxDerefDepth", 2, 2, 0, "depth", ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH, &config_generic, NULL, NULL, NULL },
202 { "rootdn", 2, 2, 0, "dn", ARG_DB|ARG_MAGIC, &config_rootdn, NULL, NULL, NULL },
203 { "rootpw", 2, 2, 0, "password", ARG_DB|ARG_MAGIC, &config_rootpw, NULL, NULL, NULL },
204 { "readonly", 2, 2, 0, "on|off", ARG_ON_OFF|ARG_MAGIC|CFG_RO, &config_generic, NULL, NULL, NULL },
205 { "restrict", 2, 0, 0, "op_list", ARG_MAGIC, &config_restrict, NULL, NULL, NULL },
206 { "allows", 2, 0, 5, "features", ARG_PRE_DB|ARG_MAGIC, &config_allows, NULL, NULL, NULL },
207 { "disallows", 2, 0, 8, "features", ARG_PRE_DB|ARG_MAGIC, &config_disallows, NULL, NULL, NULL },
208 { "require", 2, 0, 7, "features", ARG_MAGIC, &config_requires, NULL, NULL, NULL },
209 { "security", 2, 0, 0, "factors", ARG_MAGIC, &config_security, NULL, NULL, NULL },
210 { "referral", 2, 2, 0, "url", ARG_MAGIC, &config_referral, NULL, NULL, NULL },
211 { "logfile", 2, 2, 0, "file", ARG_MAGIC|CFG_LOGFILE, &config_generic, NULL, NULL, NULL },
212 { "objectidentifier", 0, 0, 0, NULL, ARG_MAGIC|CFG_OID, &config_generic, NULL, NULL, NULL },
213 { "objectclass", 2, 0, 0, "objectclass", ARG_PAREN|ARG_MAGIC|CFG_OC, &config_generic, NULL, NULL, NULL },
214 { "ditcontentrule", 0, 0, 0, NULL, ARG_MAGIC|CFG_DIT, &config_generic, NULL, NULL, NULL },
215 { "attribute", 2, 0, 9, "attribute", ARG_PAREN|ARG_MAGIC|CFG_ATTR, &config_generic, NULL, NULL, NULL },
216 { "attributeoptions", 0, 0, 0, NULL, ARG_MAGIC|CFG_ATOPT, &config_generic, NULL, NULL, NULL },
217 { "schemacheck", 2, 2, 0, "on|off", ARG_ON_OFF|ARG_MAGIC|CFG_CHECK, &config_generic, NULL, NULL, NULL },
218 { "access", 0, 0, 0, NULL, ARG_MAGIC|CFG_ACL, &config_generic, NULL, NULL, NULL },
219 { "loglevel", 2, 0, 0, "level", ARG_MAGIC, &config_loglevel, NULL, NULL, NULL },
220 { "syncrepl", 0, 0, 0, NULL, ARG_DB|ARG_MAGIC, &config_syncrepl, NULL, NULL, NULL },
221 { "replica", 2, 0, 0, "host or uri", ARG_DB|ARG_MAGIC, &config_replica, NULL, NULL, NULL },
222 { "replicationInterval", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
223 { "updatedn", 2, 2, 0, "dn", ARG_DB|ARG_MAGIC, &config_updatedn, NULL, NULL, NULL },
224 { "updateref", 2, 2, 0, "url", ARG_DB|ARG_MAGIC, &config_updateref, NULL, NULL, NULL },
225 { "replogfile", 2, 2, 0, "filename", ARG_MAGIC|ARG_STRING|CFG_REPLOG, &config_generic, NULL, NULL, NULL },
226 { "rootDSE", 2, 2, 0, "filename", ARG_MAGIC|CFG_ROOTDSE, &config_generic, NULL, NULL, NULL },
227 { "lastmod", 2, 2, 0, "on|off", ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD, &config_generic, NULL, NULL, NULL },
229 { "gentlehup", 2, 2, 0, "on|off", ARG_ON_OFF, &global_gentlehup, NULL, NULL, NULL },
231 { "gentlehup", 2, 2, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
233 { "idletimeout", 2, 2, 0, "timeout", ARG_INT, &global_idletimeout, NULL, NULL, NULL },
234 /* XXX -- special case? */
235 { "include", 2, 2, 0, "filename", ARG_MAGIC, &config_include, NULL, NULL, NULL },
236 { "srvtab", 2, 2, 0, "filename", ARG_STRING, &ldap_srvtab, NULL, NULL, NULL },
238 { "moduleload", 2, 2, 0, "filename", ARG_MAGIC|CFG_MODLOAD, &config_generic, NULL, NULL, NULL },
239 { "modulepath", 2, 2, 0, "path", ARG_MAGIC|CFG_MODPATH, &config_generic, NULL, NULL, NULL },
242 { "TLSRandFile", 0, 0, 0, NULL, CFG_TLS_RAND|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
243 { "TLSCipherSuite", 0, 0, 0, NULL, CFG_TLS_CIPHER|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
244 { "TLSCertificateFile", 0, 0, 0, NULL, CFG_TLS_CERT_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
245 { "TLSCertificateKeyFile", 0, 0, 0, NULL, CFG_TLS_CERT_KEY|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
246 { "TLSCertificatePath", 0, 0, 0, NULL, CFG_TLS_CERT_PATH|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
247 { "TLSCACertificateFile", 0, 0, 0, NULL, CFG_TLS_CA_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
248 #ifdef HAVE_OPENSSL_CRL
249 { "TLSCRLCheck", 0, 0, 0, NULL, CFG_TLS_CRLCHECK|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
251 { "TLSCRLCheck", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
253 { "TLSVerifyClient", 0, 0, 0, NULL, CFG_TLS_VERIFY|ARG_MAGIC, &config_tls_verify, NULL, NULL, NULL },
255 #ifdef SLAPD_RLOOKUPS
256 { "reverse-lookup", 2, 2, 0, "on|off", ARG_ON_OFF, &use_reverse_lookup, NULL, NULL, NULL },
258 { "reverse-lookup", 2, 2, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
261 { "plugin", 0, 0, 0, NULL, ARG_MAGIC|CFG_PLUGIN, &config_generic, NULL, NULL, NULL },
262 { "pluginlog", 2, 2, 0, "filename", ARG_STRING, &slapi_log_file, NULL, NULL, NULL },
264 { "plugin", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
265 { "pluginlog", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
267 { "replica-pidfile", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
268 { "replica-argsfile", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
269 { NULL, 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL }
274 new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv )
277 c = ch_calloc( 1, sizeof( ConfigArgs ) );
278 if ( c == NULL ) return(NULL);
284 snprintf( c->log, sizeof( c->log ), "%s: line %lu", fname, lineno );
288 int parse_config_table(ConfigTable *Conf, ConfigArgs *c) {
289 int i, rc, arg_user, arg_type, iarg;
292 for(i = 0; Conf[i].name; i++)
293 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
294 (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
295 if(!Conf[i].name) return(ARG_UNKNOWN);
296 arg_type = Conf[i].arg_type;
297 if(arg_type == ARG_IGNORED) {
298 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> ignored\n",
299 c->log, Conf[i].name, 0);
302 if(Conf[i].min_args && (c->argc < Conf[i].min_args)) {
303 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> missing <%s> argument\n",
304 c->log, Conf[i].name, Conf[i].what);
305 return(ARG_BAD_CONF);
307 if(Conf[i].max_args && (c->argc > Conf[i].max_args)) {
308 Debug(LDAP_DEBUG_CONFIG, "%s: extra cruft after <%s> in <%s> line (ignored)\n",
309 c->log, Conf[i].what, Conf[i].name);
311 if((arg_type & ARG_DB) && !c->be) {
312 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> allowed only within database declaration\n",
313 c->log, Conf[i].name, 0);
314 return(ARG_BAD_CONF);
316 if((arg_type & ARG_PRE_DB) && c->be) {
317 Debug(LDAP_DEBUG_CONFIG, "%s: keyword <%s> must appear before any database declaration\n",
318 c->log, Conf[i].name, 0);
319 return(ARG_BAD_CONF);
321 if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
322 Debug(LDAP_DEBUG_CONFIG, "%s: old <%s> format not supported\n",
323 c->log, Conf[i].name, 0);
324 return(ARG_BAD_CONF);
326 if((arg_type & ARGS_POINTER) && !Conf[i].arg_item) {
327 Debug(LDAP_DEBUG_CONFIG, "%s: null arg_item for <%s>\n",
328 c->log, Conf[i].name, 0);
329 return(ARG_BAD_CONF);
331 c->type = arg_user = (arg_type & ARGS_USERLAND);
332 c->value_int = c->value_long = c->value_ber_t = 0;
333 c->value_string = NULL;
334 if(arg_type & ARGS_NUMERIC) {
336 iarg = 0; larg = 0; barg = 0;
337 switch(arg_type & ARGS_NUMERIC) {
338 case ARG_INT: iarg = atoi(c->argv[1]); break;
339 case ARG_LONG: larg = atol(c->argv[1]); break;
340 case ARG_BER_LEN_T: barg = (ber_len_t)atol(c->argv[1]); break;
342 if(!strcasecmp(c->argv[1], "on")) {
344 } else if(!strcasecmp(c->argv[1], "off")) {
347 Debug(LDAP_DEBUG_CONFIG, "%s: ignoring ", c->log, 0, 0);
348 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
349 Conf[i].what, c->argv[1], Conf[i].name);
354 j = (arg_type & ARG_NONZERO) ? 1 : 0;
355 rc = (Conf == SystemConfiguration) ? ((arg_type & ARG_SPECIAL) && (larg < index_substr_if_maxlen)) : 0;
356 if(iarg < j || larg < j || barg < j || rc) {
357 larg = larg ? larg : (barg ? barg : iarg);
358 Debug(LDAP_DEBUG_CONFIG, "%s: " , c->log, 0, 0);
359 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf[i].what, larg, Conf[i].name);
360 return(ARG_BAD_CONF);
363 c->value_long = larg;
364 c->value_ber_t = barg;
366 if(arg_type & ARG_STRING) c->value_string = ch_strdup(c->argv[1]);
367 if(arg_type & ARG_MAGIC) {
368 if(!c->be) c->be = frontendDB;
369 rc = (*((ConfigDriver*)Conf[i].arg_item))(c);
370 if(c->be == frontendDB) c->be = NULL;
372 Debug(LDAP_DEBUG_CONFIG, "%s: handler for <%s> exited with %d!",
373 c->log, Conf[i].name, rc);
374 return(ARG_BAD_CONF);
378 if(arg_type & ARGS_POINTER) switch(arg_type & ARGS_POINTER) {
380 case ARG_INT: *((int*)Conf[i].arg_item) = iarg; break;
381 case ARG_LONG: *((long*)Conf[i].arg_item) = larg; break;
382 case ARG_BER_LEN_T: *((ber_len_t*)Conf[i].arg_item) = barg; break;
384 char *cc = *((char**)Conf[i].arg_item);
385 if(cc) ch_free(cc); /* potential memory leak */
386 *(char **)Conf[i].arg_item = c->value_string;
394 read_config(const char *fname, int depth) {
395 return read_config_file(fname, depth, NULL);
399 read_config_file(const char *fname, int depth, ConfigArgs *cf)
405 c = ch_calloc( 1, sizeof( ConfigArgs ) );
411 memcpy( c, cf, sizeof( ConfigArgs ) );
413 c->depth = depth; /* XXX */
419 c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
420 c->argv_size = ARGS_STEP + 1;
422 fp = fopen( fname, "r" );
425 Debug(LDAP_DEBUG_ANY,
426 "could not open config file \"%s\": %s (%d)\n",
427 fname, strerror(errno), errno);
431 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
435 while ( fp_getline( fp, c ) ) {
436 /* skip comments and blank lines */
437 if ( c->line[0] == '#' || c->line[0] == '\0' ) {
441 snprintf( c->log, sizeof( c->log ), "%s: line %lu",
442 c->fname, c->lineno );
444 if ( fp_parse_line( c ) ) {
449 Debug(LDAP_DEBUG_CONFIG, "%s: bad config line (ignored)\n", c->log, 0, 0);
453 rc = parse_config_table( SystemConfiguration, c );
457 if ( rc & ARGS_USERLAND ) {
458 switch(rc) { /* XXX a usertype would be opaque here */
460 Debug(LDAP_DEBUG_CONFIG, "%s: unknown user type <%d>\n",
461 c->log, *c->argv, 0);
465 } else if ( rc == ARG_BAD_CONF || rc != ARG_UNKNOWN ) {
468 } else if ( c->bi && c->bi->bi_config ) { /* XXX to check: could both be/bi_config? oops */
469 rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv);
472 case SLAP_CONF_UNKNOWN:
473 Debug(LDAP_DEBUG_CONFIG, "%s: "
474 "unknown directive <%s> inside backend info definition (ignored)\n",
475 c->log, *c->argv, 0);
482 } else if ( c->be && c->be->be_config ) {
483 rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv);
486 case SLAP_CONF_UNKNOWN:
487 Debug( LDAP_DEBUG_CONFIG, "%s: "
488 "unknown directive <%s> inside backend database definition (ignored)\n",
489 c->log, *c->argv, 0);
496 } else if ( frontendDB->be_config ) {
497 rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
500 case SLAP_CONF_UNKNOWN:
501 Debug( LDAP_DEBUG_CONFIG, "%s: "
502 "unknown directive <%s> inside global database definition (ignored)\n",
503 c->log, *c->argv, 0);
511 Debug(LDAP_DEBUG_CONFIG, "%s: "
512 "unknown directive <%s> outside backend info and database definitions (ignored)\n",
513 c->log, *c->argv, 0);
521 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
522 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
523 &frontendDB->be_schemadn );
524 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
525 if ( rc != LDAP_SUCCESS ) {
526 Debug(LDAP_DEBUG_ANY, "%s: "
527 "unable to normalize default schema DN \"%s\"\n",
528 c->log, frontendDB->be_schemadn.bv_val, 0 );
529 /* must not happen */
546 config_generic(ConfigArgs *c) {
547 char *p = strchr(c->line,'(' /*')'*/);
552 if(!(c->bi = backend_info(c->argv[1]))) {
553 Debug(LDAP_DEBUG_ANY, "%s: "
554 "backend %s failed init!\n", c->log, c->argv[1], 0);
561 if(!(c->be = backend_db_init(c->argv[1]))) {
562 Debug(LDAP_DEBUG_ANY, "%s: "
563 "database %s failed init!\n", c->log, c->argv[1], 0);
569 ldap_pvt_thread_set_concurrency(c->value_long);
573 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
574 connection_pool_max = c->value_int; /* save for reference */
578 lutil_salt_format(c->argv[1]);
582 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
588 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
590 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
594 /* XXX slap_sasl_config doesn't actually use the line argument */
595 if(slap_sasl_config(c->argc, c->argv, c->line, c->fname, c->lineno))
600 c->be->be_max_deref_depth = c->value_int;
604 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv)) return(1);
608 if(parse_oc(c->fname, c->lineno, p, c->argv)) return(1);
612 if(parse_cr(c->fname, c->lineno, p, c->argv)) return(1);
616 if(parse_at(c->fname, c->lineno, p, c->argv)) return(1);
620 ad_define_option(NULL, NULL, 0);
621 for(i = 1; i < c->argc; i++)
622 if(ad_define_option(c->argv[i], c->fname, c->lineno))
627 global_schemacheck = c->value_int;
628 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: "
629 "schema checking disabled! your mileage may vary!\n",
634 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
639 c->be->be_auditlogfile = c->value_string;
644 if(SLAP_MONITOR(c->be)) {
645 Debug(LDAP_DEBUG_ANY, "%s: "
646 "\"replogfile\" should not be used "
647 "inside monitor database\n",
649 return(0); /* FIXME: should this be an error? */
652 c->be->be_replogfile = c->value_string;
656 if(read_root_dse_file(c->argv[1])) {
657 Debug(LDAP_DEBUG_ANY, "%s: "
658 "could not read \"rootDSE <filename>\" line\n",
665 FILE *logfile = fopen(c->argv[1], "w");
666 if(logfile) lutil_debug_file(logfile);
671 if(SLAP_NOLASTMODCMD(c->be)) {
672 Debug(LDAP_DEBUG_ANY, "%s: "
673 "lastmod not available for %s databases\n",
674 c->log, c->be->bd_info->bi_type, 0);
678 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
680 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
685 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
690 if(module_path(c->argv[1])) return(1);
696 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
698 slapi_plugins_used++;
702 #ifdef SLAP_AUTH_REWRITE
704 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
711 Debug(LDAP_DEBUG_ANY, "%s: unknown CFG_TYPE %d"
712 "(ignored)\n", c->log, c->type, 0);
720 config_search_base(ConfigArgs *c) {
723 if(c->bi || c->be != frontendDB) {
724 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
725 "prior to any backend or database definition\n",
730 if(default_search_nbase.bv_len) {
731 Debug(LDAP_DEBUG_ANY, "%s: "
732 "default search base \"%s\" already defined "
733 "(discarding old)\n",
734 c->log, default_search_base.bv_val, 0);
735 free(default_search_base.bv_val);
736 free(default_search_nbase.bv_val);
739 ber_str2bv(c->argv[1], 0, 1, &dn);
740 rc = dnPrettyNormal(NULL, &dn, &default_search_base, &default_search_nbase, NULL);
742 if(rc != LDAP_SUCCESS) {
743 Debug(LDAP_DEBUG_ANY,
744 "%s: defaultSearchBase DN is invalid: %d (%s)\n",
745 c->log, rc, ldap_err2string( rc ));
752 config_passwd_hash(ConfigArgs *c) {
754 if(default_passwd_hash) {
755 Debug(LDAP_DEBUG_ANY, "%s: "
756 "already set default password_hash\n",
760 for(i = 1; i < c->argc; i++) {
761 if(!lutil_passwd_scheme(c->argv[i])) {
762 Debug(LDAP_DEBUG_ANY, "%s: "
763 "password scheme \"%s\" not available\n",
764 c->log, c->argv[i], 0);
766 ldap_charray_add(&default_passwd_hash, c->argv[i]);
768 if(!default_passwd_hash) {
769 Debug(LDAP_DEBUG_ANY, "%s: no valid hashes found\n",
778 config_schema_dn(ConfigArgs *c) {
781 ber_str2bv(c->argv[1], 0, 1, &dn);
782 rc = dnPrettyNormal(NULL, &dn, &c->be->be_schemadn, &c->be->be_schemandn, NULL);
783 if(rc != LDAP_SUCCESS) {
784 Debug(LDAP_DEBUG_ANY, "%s: "
785 "schema DN is invalid: %d (%s)\n",
786 c->log, rc, ldap_err2string( rc ));
793 config_sizelimit(ConfigArgs *c) {
796 struct slap_limits_set *lim = &c->be->be_def_limit;
797 for(i = 1; i < c->argc; i++) {
798 if(!strncasecmp(c->argv[i], "size", 4)) {
799 rc = limits_parse_one(c->argv[i], lim);
801 Debug(LDAP_DEBUG_ANY, "%s: "
802 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
803 c->log, c->argv[i], 0);
807 if(!strcasecmp(c->argv[i], "unlimited")) {
808 lim->lms_s_soft = -1;
810 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
811 if(next == c->argv[i]) {
812 Debug(LDAP_DEBUG_ANY, "%s: "
813 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
814 c->log, c->argv[i], 0);
816 } else if(next[0] != '\0') {
817 Debug(LDAP_DEBUG_ANY, "%s: "
818 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
829 config_timelimit(ConfigArgs *c) {
832 struct slap_limits_set *lim = &c->be->be_def_limit;
833 for(i = 1; i < c->argc; i++) {
834 if(!strncasecmp(c->argv[i], "time", 4)) {
835 rc = limits_parse_one(c->argv[i], lim);
837 Debug(LDAP_DEBUG_ANY, "%s: "
838 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
839 c->log, c->argv[i], 0);
843 if(!strcasecmp(c->argv[i], "unlimited")) {
844 lim->lms_t_soft = -1;
846 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
847 if(next == c->argv[i]) {
848 Debug(LDAP_DEBUG_ANY, "%s: "
849 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
850 c->log, c->argv[i], 0);
852 } else if(next[0] != '\0') {
853 Debug(LDAP_DEBUG_ANY, "%s: "
854 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
865 config_overlay(ConfigArgs *c) {
866 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
868 Debug(LDAP_DEBUG_ANY, "%s: (optional) %s overlay \"%s\" configuration failed (ignored)\n",
869 c->log, c->be == frontendDB ? "global " : "", c->argv[1][1]);
870 } else if(overlay_config(c->be, c->argv[1])) {
877 config_suffix(ConfigArgs *c) {
879 struct berval dn, pdn, ndn;
881 #ifdef SLAPD_MONITOR_DN
882 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
883 Debug(LDAP_DEBUG_ANY, "%s: "
884 "\"%s\" is reserved for monitoring slapd\n",
885 c->log, SLAPD_MONITOR_DN, 0);
889 ber_str2bv(c->argv[1], 0, 1, &dn);
891 rc = dnPrettyNormal(NULL, &dn, &pdn, &ndn, NULL);
892 if(rc != LDAP_SUCCESS) {
893 Debug( LDAP_DEBUG_ANY,
894 "%s: suffix DN is invalid: %d (%s)\n",
895 c->log, rc, ldap_err2string( rc ));
898 tbe = select_backend(&ndn, 0, 0);
900 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by this backend! (ignored)\n",
905 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by a preceding backend \"%s\"\n",
906 c->log, tbe->be_suffix[0].bv_val, 0);
910 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
911 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
912 "base provided \"%s\" (assuming okay)\n",
913 c->log, default_search_base.bv_val, 0);
915 ber_bvarray_add(&c->be->be_suffix, &pdn);
916 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
921 config_rootdn(ConfigArgs *c) {
925 ber_str2bv(c->argv[1], 0, 1, &dn);
927 rc = dnPrettyNormal(NULL, &dn, &c->be->be_rootdn, &c->be->be_rootndn, NULL);
929 if(rc != LDAP_SUCCESS) {
930 Debug(LDAP_DEBUG_ANY, "%s: "
931 "rootdn DN is invalid: %d (%s)\n",
932 c->log, rc, ldap_err2string( rc ));
939 config_rootpw(ConfigArgs *c) {
940 Backend *tbe = select_backend(&c->be->be_rootndn, 0, 0);
942 Debug(LDAP_DEBUG_ANY, "%s: "
943 "rootpw can only be set when rootdn is under suffix\n",
947 ber_str2bv(c->argv[1], 0, 1, &c->be->be_rootpw);
951 /* restrictops, allows, disallows, requires, loglevel */
953 struct verb_mask_list { char *word; int mask; };
956 verb_to_mask(ConfigArgs *c, struct verb_mask_list *v, int word) {
958 for(j = 0; v[j].word; j++)
959 if(!strcasecmp(c->argv[word], v[j].word))
965 verbs_to_mask(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t *m) {
967 for(i = 1; i < c->argc; i++) {
968 j = verb_to_mask(c, v, i);
969 if(!v[j].word) return(1);
976 config_restrict(ConfigArgs *c) {
977 slap_mask_t restrictops = 0;
979 struct verb_mask_list restrictable_exops[] = {
980 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
981 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
982 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
983 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
986 struct verb_mask_list restrictable_ops[] = {
987 { "bind", SLAP_RESTRICT_OP_BIND },
988 { "add", SLAP_RESTRICT_OP_ADD },
989 { "modify", SLAP_RESTRICT_OP_MODIFY },
990 { "modrdn", SLAP_RESTRICT_OP_RENAME },
991 { "rename", SLAP_RESTRICT_OP_RENAME },
992 { "delete", SLAP_RESTRICT_OP_DELETE },
993 { "search", SLAP_RESTRICT_OP_SEARCH },
994 { "compare", SLAP_RESTRICT_OP_COMPARE },
995 { "read", SLAP_RESTRICT_OP_READS },
996 { "write", SLAP_RESTRICT_OP_WRITES },
1000 for(i = 1; i < c->argc; i++) {
1001 j = verb_to_mask(c, restrictable_ops, i);
1002 if(restrictable_ops[j].word) {
1003 restrictops |= restrictable_ops[j].mask;
1005 } else if(!strncasecmp(c->argv[i], "extended", STRLENOF("extended"))) {
1006 char *e = c->argv[i] + STRLENOF("extended");
1008 int k = verb_to_mask(c, restrictable_exops, e[1]);
1009 if(restrictable_exops[k].word) {
1010 restrictops |= restrictable_exops[k].mask;
1014 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
1015 restrictops |= SLAP_RESTRICT_OP_EXTENDED;
1020 c->be->be_restrictops |= restrictops;
1023 Debug(LDAP_DEBUG_ANY, "%s: "
1024 "unknown operation %s in \"restrict <features>\" line\n",
1025 c->log, c->argv[i], 0);
1030 config_allows(ConfigArgs *c) {
1031 slap_mask_t allows = 0;
1033 struct verb_mask_list allowable_ops[] = {
1034 { "bind_v2", SLAP_ALLOW_BIND_V2 },
1035 { "bind_anon_cred", SLAP_ALLOW_BIND_ANON_CRED },
1036 { "bind_anon_dn", SLAP_ALLOW_BIND_ANON_DN },
1037 { "update_anon", SLAP_ALLOW_UPDATE_ANON },
1040 i = verbs_to_mask(c, allowable_ops, &allows);
1042 Debug(LDAP_DEBUG_ANY, "%s: "
1043 "unknown feature %s in \"allow <features>\" line\n",
1044 c->log, c->argv[i], 0);
1047 global_allows |= allows;
1052 config_disallows(ConfigArgs *c) {
1053 slap_mask_t disallows = 0;
1055 struct verb_mask_list disallowable_ops[] = {
1056 { "bind_anon", SLAP_DISALLOW_BIND_ANON },
1057 { "bind_simple", SLAP_DISALLOW_BIND_SIMPLE },
1058 { "bind_krb4", SLAP_DISALLOW_BIND_KRBV4 },
1059 { "tls_2_anon", SLAP_DISALLOW_TLS_2_ANON },
1060 { "tls_authc", SLAP_DISALLOW_TLS_AUTHC },
1063 i = verbs_to_mask(c, disallowable_ops, &disallows);
1065 Debug(LDAP_DEBUG_ANY, "%s: "
1066 "unknown feature %s in \"disallow <features>\" line\n",
1067 c->log, c->argv[i], 0);
1070 global_disallows |= disallows;
1075 config_requires(ConfigArgs *c) {
1076 slap_mask_t requires = 0;
1078 struct verb_mask_list requires_ops[] = {
1079 { "bind", SLAP_REQUIRE_BIND },
1080 { "LDAPv3", SLAP_REQUIRE_LDAP_V3 },
1081 { "authc", SLAP_REQUIRE_AUTHC },
1082 { "sasl", SLAP_REQUIRE_SASL },
1083 { "strong", SLAP_REQUIRE_STRONG },
1086 i = verbs_to_mask(c, requires_ops, &requires);
1088 Debug(LDAP_DEBUG_ANY, "%s: "
1089 "unknown feature %s in \"require <features>\" line\n",
1090 c->log, c->argv[i], 0);
1093 c->be->be_requires = requires;
1098 config_loglevel(ConfigArgs *c) {
1101 struct verb_mask_list loglevel_ops[] = {
1102 { "Trace", LDAP_DEBUG_TRACE },
1103 { "Packets", LDAP_DEBUG_PACKETS },
1104 { "Args", LDAP_DEBUG_ARGS },
1105 { "Conns", LDAP_DEBUG_CONNS },
1106 { "BER", LDAP_DEBUG_BER },
1107 { "Filter", LDAP_DEBUG_FILTER },
1108 { "Config", LDAP_DEBUG_CONFIG },
1109 { "ACL", LDAP_DEBUG_ACL },
1110 { "Stats", LDAP_DEBUG_STATS },
1111 { "Stats2", LDAP_DEBUG_STATS2 },
1112 { "Shell", LDAP_DEBUG_SHELL },
1113 { "Parse", LDAP_DEBUG_PARSE },
1114 { "Cache", LDAP_DEBUG_CACHE },
1115 { "Index", LDAP_DEBUG_INDEX },
1121 for( i=1; i < c->argc; i++ ) {
1124 if ( isdigit( c->argv[i][0] ) ) {
1125 level = strtol( c->argv[i], &next, 10 );
1126 if ( next == NULL || next[0] != '\0' ) {
1127 Debug( LDAP_DEBUG_ANY,
1128 "%s: unable to parse level \"%s\" "
1129 "in \"loglevel <level> [...]\" line.\n",
1130 c->log, c->argv[i], 0);
1134 int j = verb_to_mask(c, loglevel_ops, c->argv[i][0]);
1135 if(!loglevel_ops[j].word) {
1136 Debug( LDAP_DEBUG_ANY,
1137 "%s: unknown level \"%s\" "
1138 "in \"loglevel <level> [...]\" line.\n",
1139 c->log, c->argv[i], 0);
1142 level = loglevel_ops[j].mask;
1144 ldap_syslog |= level;
1150 config_syncrepl(ConfigArgs *c) {
1151 if(SLAP_SHADOW(c->be)) {
1152 Debug(LDAP_DEBUG_ANY, "%s: "
1153 "syncrepl: database already shadowed.\n",
1156 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1159 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1164 config_referral(ConfigArgs *c) {
1165 struct berval vals[2];
1166 if(validate_global_referral(c->argv[1])) {
1167 Debug(LDAP_DEBUG_ANY, "%s: "
1168 "invalid URL (%s) in \"referral\" line.\n",
1169 c->log, c->argv[1], 0);
1173 ber_str2bv(c->argv[1], 0, 1, &vals[0]);
1174 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1175 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1180 config_security(ConfigArgs *c) {
1181 slap_ssf_set_t *set = &c->be->be_ssf_set;
1184 for(i = 1; i < c->argc; i++) {
1187 if(!strncasecmp(c->argv[i], "ssf=", 4)) {
1188 tgt = &set->sss_ssf;
1189 src = &c->argv[i][4];
1190 } else if(!strncasecmp(c->argv[i], "transport=", 10)) {
1191 tgt = &set->sss_transport;
1192 src = &c->argv[i][10];
1193 } else if(!strncasecmp(c->argv[i], "tls=", 4)) {
1194 tgt = &set->sss_tls;
1195 src = &c->argv[i][4];
1196 } else if(!strncasecmp(c->argv[i], "sasl=", 5)) {
1197 tgt = &set->sss_sasl;
1198 src = &c->argv[i][5];
1199 } else if(!strncasecmp(c->argv[i], "update_ssf=", 11)) {
1200 tgt = &set->sss_update_ssf;
1201 src = &c->argv[i][11];
1202 } else if(!strncasecmp(c->argv[i], "update_transport=", 17)) {
1203 tgt = &set->sss_update_transport;
1204 src = &c->argv[i][17];
1205 } else if(!strncasecmp(c->argv[i], "update_tls=", 11)) {
1206 tgt = &set->sss_update_tls;
1207 src = &c->argv[i][11];
1208 } else if(!strncasecmp(c->argv[i], "update_sasl=", 12)) {
1209 tgt = &set->sss_update_sasl;
1210 src = &c->argv[i][12];
1211 } else if(!strncasecmp(c->argv[i], "simple_bind=", 12)) {
1212 tgt = &set->sss_simple_bind;
1213 src = &c->argv[i][12];
1215 Debug(LDAP_DEBUG_ANY, "%s: "
1216 "unknown factor %s in \"security <factors>\" line\n",
1217 c->log, c->argv[i], 0);
1221 *tgt = strtol(src, &next, 10);
1222 if(next == NULL || next[0] != '\0' ) {
1223 Debug(LDAP_DEBUG_ANY, "%s: "
1224 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1225 c->log, c->argv[i], 0);
1233 config_replica(ConfigArgs *c) {
1235 char *replicahost, *replicalog = NULL;
1238 if(SLAP_MONITOR(c->be)) {
1239 Debug(LDAP_DEBUG_ANY, "%s: "
1240 "\"replica\" should not be used inside monitor database\n",
1242 return(0); /* FIXME: should this be an error? */
1245 for(i = 1; i < c->argc; i++) {
1246 if(!strncasecmp(c->argv[i], "host=", STRLENOF("host="))) {
1247 replicalog = c->argv[i] + STRLENOF("host=");
1248 nr = add_replica_info(c->be, c->argv[i] + STRLENOF("host="));
1250 } else if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) {
1251 if(ldap_url_parse(c->argv[i] + STRLENOF("uri="), &ludp) != LDAP_SUCCESS) {
1252 Debug(LDAP_DEBUG_ANY, "%s: "
1253 "replica line contains invalid "
1254 "uri definition.\n", c->log, 0, 0);
1257 if(!ludp->lud_host) {
1258 Debug(LDAP_DEBUG_ANY, "%s: "
1259 "replica line contains invalid "
1260 "uri definition - missing hostname.\n",
1264 replicahost = ch_malloc(strlen(c->argv[i]));
1266 Debug(LDAP_DEBUG_ANY,
1267 "out of memory in read_config\n", 0, 0, 0);
1268 ldap_free_urldesc(ludp);
1271 sprintf(replicahost, "%s:%d", ludp->lud_host, ludp->lud_port);
1272 replicalog = c->argv[i] + STRLENOF("uri=");
1273 nr = add_replica_info(c->be, replicahost);
1274 ldap_free_urldesc(ludp);
1275 ch_free(replicahost);
1280 Debug(LDAP_DEBUG_ANY, "%s: "
1281 "missing host or uri in \"replica\" line\n",
1284 } else if(nr == -1) {
1285 Debug(LDAP_DEBUG_ANY, "%s: "
1286 "unable to add replica \"%s\"\n",
1287 c->log, replicalog, 0);
1290 for(i = 1; i < c->argc; i++) {
1291 if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
1292 switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) {
1294 Debug(LDAP_DEBUG_ANY, "%s: "
1295 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1296 c->log, c->argv[i] + STRLENOF("suffix="), 0);
1299 Debug(LDAP_DEBUG_ANY, "%s: "
1300 "unable to normalize suffix in \"replica\" line (ignored)\n",
1305 } else if(!strncasecmp(c->argv[i], "attr", STRLENOF("attr"))) {
1307 char *arg = c->argv[i] + STRLENOF("attr");
1315 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1316 Debug(LDAP_DEBUG_ANY, "%s: "
1317 "attribute \"%s\" in \"replica\" line is unknown\n",
1318 c->log, arg + 1, 0);
1328 config_updatedn(ConfigArgs *c) {
1331 if(SLAP_SHADOW(c->be)) {
1332 Debug(LDAP_DEBUG_ANY, "%s: "
1333 "updatedn: database already shadowed.\n",
1338 ber_str2bv(c->argv[1], 0, 0, &dn);
1340 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1342 if(rc != LDAP_SUCCESS) {
1343 Debug(LDAP_DEBUG_ANY, "%s: "
1344 "updatedn DN is invalid: %d (%s)\n",
1345 c->log, rc, ldap_err2string( rc ));
1349 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1354 config_updateref(ConfigArgs *c) {
1355 struct berval vals[2];
1356 if(!SLAP_SHADOW(c->be)) {
1357 Debug(LDAP_DEBUG_ANY, "%s: "
1358 "updateref line must after syncrepl or updatedn.\n",
1363 if(validate_global_referral(c->argv[1])) {
1364 Debug(LDAP_DEBUG_ANY, "%s: "
1365 "invalid URL (%s) in \"updateref\" line.\n",
1366 c->log, c->argv[1], 0);
1369 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1370 vals[1].bv_val = NULL;
1371 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1375 /* XXX meaningless in ldif */
1378 config_include(ConfigArgs *c) {
1379 char *savefname = ch_strdup(c->argv[1]);
1380 unsigned long savelineno = c->lineno;
1382 rc = read_config_file(savefname, c->depth + 1, c);
1384 c->lineno = savelineno - 1;
1390 config_tls_option(ConfigArgs *c) {
1393 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
1394 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
1395 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
1396 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
1397 case CFG_TLS_CERT_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
1398 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
1399 #ifdef HAVE_OPENSSL_CRL
1400 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
1402 default: Debug(LDAP_DEBUG_ANY, "%s: "
1403 "unknown tls_option <%x>\n",
1404 c->log, c->type, 0);
1406 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
1410 config_tls_verify(ConfigArgs *c) {
1412 if(isdigit((unsigned char)c->argv[1][0])) {
1413 i = atoi(c->argv[1]);
1414 return(ldap_pvt_tls_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i));
1416 return(ldap_int_tls_config(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, c->argv[1]));
1421 /* -------------------------------------- */
1425 strtok_quote( char *line, char *sep )
1431 strtok_quote_ptr = NULL;
1432 if ( line != NULL ) {
1435 while ( *next && strchr( sep, *next ) ) {
1439 if ( *next == '\0' ) {
1445 for ( inquote = 0; *next; ) {
1453 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1459 next + 1, strlen( next + 1 ) + 1 );
1460 next++; /* dont parse the escaped character */
1465 if ( strchr( sep, *next ) != NULL ) {
1466 strtok_quote_ptr = next;
1479 static char buf[BUFSIZ];
1481 static size_t lmax, lcur;
1483 #define CATLINE( buf ) \
1485 size_t len = strlen( buf ); \
1486 while ( lcur + len + 1 > lmax ) { \
1488 line = (char *) ch_realloc( line, lmax ); \
1490 strcpy( line + lcur, buf ); \
1495 fp_getline_init(ConfigArgs *c) {
1501 fp_getline( FILE *fp, ConfigArgs *c )
1509 /* avoid stack of bufs */
1510 if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
1516 while ( fgets( buf, sizeof( buf ), fp ) ) {
1517 p = strchr( buf, '\n' );
1519 if ( p > buf && p[-1] == '\r' ) {
1527 && ( p = line + strlen( line ) - 1 )[0] == '\\'
1534 if ( !isspace( (unsigned char)buf[0] ) ) {
1545 return(line[0] ? 1 : 0);
1549 fp_parse_line(ConfigArgs *c)
1552 char *tline = ch_strdup(c->line);
1553 char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
1557 token = strtok_quote(tline, " \t");
1559 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
1560 if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
1561 Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
1562 if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
1564 for(; token; token = strtok_quote(NULL, " \t")) {
1565 if(c->argc == c->argv_size - 1) {
1567 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
1569 Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0);
1573 c->argv_size += ARGS_STEP;
1575 c->argv[c->argc++] = token;
1577 c->argv[c->argc] = NULL;
1583 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1585 load_ucdata( char *path )
1588 static int loaded = 0;
1594 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
1596 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
1604 /* ucdata is now hardcoded */
1613 ucdata_unload( UCDATA_ALL );
1615 /* NOTE: in case of early exit, frontendDB can be NULL */
1616 if ( frontendDB->be_schemandn.bv_val )
1617 free( frontendDB->be_schemandn.bv_val );
1618 if ( frontendDB->be_schemadn.bv_val )
1619 free( frontendDB->be_schemadn.bv_val );
1620 if ( frontendDB->be_acl )
1621 acl_destroy( frontendDB->be_acl, NULL );
1624 if ( slapd_args_file )
1625 free ( slapd_args_file );
1626 if ( slapd_pid_file )
1627 free ( slapd_pid_file );
1628 if ( default_passwd_hash )
1629 ldap_charray_free( default_passwd_hash );
1642 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
1645 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
1649 si->si_tls = SYNCINFO_TLS_OFF;
1650 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1651 si->si_schemachecking = 0;
1652 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
1653 &si->si_filterstr );
1654 si->si_base.bv_val = NULL;
1655 si->si_scope = LDAP_SCOPE_SUBTREE;
1656 si->si_attrsonly = 0;
1657 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1658 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1659 si->si_attrs = NULL;
1660 si->si_allattrs = 0;
1661 si->si_allopattrs = 0;
1662 si->si_exattrs = NULL;
1663 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1664 si->si_interval = 86400;
1665 si->si_retryinterval = NULL;
1666 si->si_retrynum_init = NULL;
1667 si->si_retrynum = NULL;
1668 si->si_syncCookie.ctxcsn = NULL;
1669 si->si_syncCookie.octet_str = NULL;
1670 si->si_manageDSAit = 0;
1674 si->si_presentlist = NULL;
1675 LDAP_LIST_INIT( &si->si_nonpresentlist );
1677 rc = parse_syncrepl_line( cargv, cargc, si );
1680 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
1681 syncinfo_free( si );
1684 Debug( LDAP_DEBUG_CONFIG,
1685 "Config: ** successfully added syncrepl \"%s\"\n",
1686 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
1687 if ( !si->si_schemachecking ) {
1688 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
1691 be->be_syncinfo = si;
1696 /* NOTE: used & documented in slapd.conf(5) */
1698 #define PROVIDERSTR "provider"
1699 #define TYPESTR "type"
1700 #define INTERVALSTR "interval"
1701 #define SEARCHBASESTR "searchbase"
1702 #define FILTERSTR "filter"
1703 #define SCOPESTR "scope"
1704 #define ATTRSSTR "attrs"
1705 #define ATTRSONLYSTR "attrsonly"
1706 #define SLIMITSTR "sizelimit"
1707 #define TLIMITSTR "timelimit"
1708 #define SCHEMASTR "schemachecking"
1709 #define BINDMETHSTR "bindmethod"
1710 #define SIMPLESTR "simple"
1711 #define SASLSTR "sasl"
1712 #define BINDDNSTR "binddn"
1713 #define SASLMECHSTR "saslmech"
1714 #define AUTHCSTR "authcID"
1715 #define AUTHZSTR "authzID"
1716 #define CREDSTR "credentials"
1717 #define REALMSTR "realm"
1718 #define SECPROPSSTR "secprops"
1720 /* FIXME: undocumented */
1721 #define OLDAUTHCSTR "bindprincipal"
1722 #define STARTTLSSTR "starttls"
1723 #define CRITICALSTR "critical"
1724 #define EXATTRSSTR "exattrs"
1725 #define MANAGEDSAITSTR "manageDSAit"
1726 #define RETRYSTR "retry"
1729 #define LASTMODSTR "lastmod"
1730 #define LMGENSTR "gen"
1731 #define LMNOSTR "no"
1732 #define LMREQSTR "req"
1733 #define SRVTABSTR "srvtab"
1734 #define SUFFIXSTR "suffix"
1735 #define UPDATEDNSTR "updatedn"
1738 #define GOT_ID 0x0001
1739 #define GOT_PROVIDER 0x0002
1740 #define GOT_METHOD 0x0004
1743 #define GOT_ALL (GOT_ID|GOT_PROVIDER|GOT_METHOD)
1746 parse_syncrepl_line(
1756 for ( i = 1; i < cargc; i++ ) {
1757 if ( !strncasecmp( cargv[ i ], IDSTR "=",
1758 STRLENOF( IDSTR "=" ) ) )
1761 /* '\0' string terminator accounts for '=' */
1762 val = cargv[ i ] + STRLENOF( IDSTR "=" );
1764 if ( tmp >= 1000 || tmp < 0 ) {
1765 fprintf( stderr, "Error: parse_syncrepl_line: "
1766 "syncrepl id %d is out of range [0..999]\n", tmp );
1771 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
1772 STRLENOF( PROVIDERSTR "=" ) ) )
1774 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
1775 si->si_provideruri = ch_strdup( val );
1776 si->si_provideruri_bv = (BerVarray)
1777 ch_calloc( 2, sizeof( struct berval ));
1778 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
1779 1, &si->si_provideruri_bv[0] );
1780 si->si_provideruri_bv[1].bv_len = 0;
1781 si->si_provideruri_bv[1].bv_val = NULL;
1782 gots |= GOT_PROVIDER;
1783 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=",
1784 STRLENOF(STARTTLSSTR "=") ) )
1786 val = cargv[ i ] + STRLENOF( STARTTLSSTR "=" );
1787 if( !strcasecmp( val, CRITICALSTR ) ) {
1788 si->si_tls = SYNCINFO_TLS_CRITICAL;
1790 si->si_tls = SYNCINFO_TLS_ON;
1792 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR "=",
1793 STRLENOF( BINDMETHSTR "=" ) ) )
1795 val = cargv[ i ] + STRLENOF( BINDMETHSTR "=" );
1796 if ( !strcasecmp( val, SIMPLESTR )) {
1797 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1799 } else if ( !strcasecmp( val, SASLSTR )) {
1800 #ifdef HAVE_CYRUS_SASL
1801 si->si_bindmethod = LDAP_AUTH_SASL;
1803 #else /* HAVE_CYRUS_SASL */
1804 fprintf( stderr, "Error: parse_syncrepl_line: "
1805 "not compiled with SASL support\n" );
1807 #endif /* HAVE_CYRUS_SASL */
1809 si->si_bindmethod = -1;
1811 } else if ( !strncasecmp( cargv[ i ], BINDDNSTR "=",
1812 STRLENOF( BINDDNSTR "=" ) ) )
1814 val = cargv[ i ] + STRLENOF( BINDDNSTR "=" );
1815 si->si_binddn = ch_strdup( val );
1816 } else if ( !strncasecmp( cargv[ i ], CREDSTR "=",
1817 STRLENOF( CREDSTR "=" ) ) )
1819 val = cargv[ i ] + STRLENOF( CREDSTR "=" );
1820 si->si_passwd = ch_strdup( val );
1821 } else if ( !strncasecmp( cargv[ i ], SASLMECHSTR "=",
1822 STRLENOF( SASLMECHSTR "=" ) ) )
1824 val = cargv[ i ] + STRLENOF( SASLMECHSTR "=" );
1825 si->si_saslmech = ch_strdup( val );
1826 } else if ( !strncasecmp( cargv[ i ], SECPROPSSTR "=",
1827 STRLENOF( SECPROPSSTR "=" ) ) )
1829 val = cargv[ i ] + STRLENOF( SECPROPSSTR "=" );
1830 si->si_secprops = ch_strdup( val );
1831 } else if ( !strncasecmp( cargv[ i ], REALMSTR "=",
1832 STRLENOF( REALMSTR "=" ) ) )
1834 val = cargv[ i ] + STRLENOF( REALMSTR "=" );
1835 si->si_realm = ch_strdup( val );
1836 } else if ( !strncasecmp( cargv[ i ], AUTHCSTR "=",
1837 STRLENOF( AUTHCSTR "=" ) ) )
1839 val = cargv[ i ] + STRLENOF( AUTHCSTR "=" );
1840 if ( si->si_authcId )
1841 ch_free( si->si_authcId );
1842 si->si_authcId = ch_strdup( val );
1843 } else if ( !strncasecmp( cargv[ i ], OLDAUTHCSTR "=",
1844 STRLENOF( OLDAUTHCSTR "=" ) ) )
1846 /* Old authcID is provided for some backwards compatibility */
1847 val = cargv[ i ] + STRLENOF( OLDAUTHCSTR "=" );
1848 if ( si->si_authcId )
1849 ch_free( si->si_authcId );
1850 si->si_authcId = ch_strdup( val );
1851 } else if ( !strncasecmp( cargv[ i ], AUTHZSTR "=",
1852 STRLENOF( AUTHZSTR "=" ) ) )
1854 val = cargv[ i ] + STRLENOF( AUTHZSTR "=" );
1855 si->si_authzId = ch_strdup( val );
1856 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
1857 STRLENOF( SCHEMASTR "=" ) ) )
1859 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
1860 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
1861 si->si_schemachecking = 1;
1862 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
1863 si->si_schemachecking = 0;
1865 si->si_schemachecking = 1;
1867 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
1868 STRLENOF( FILTERSTR "=" ) ) )
1870 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
1871 ber_str2bv( val, 0, 1, &si->si_filterstr );
1872 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
1873 STRLENOF( SEARCHBASESTR "=" ) ) )
1878 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
1879 if ( si->si_base.bv_val ) {
1880 ch_free( si->si_base.bv_val );
1882 ber_str2bv( val, 0, 0, &bv );
1883 rc = dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL );
1884 if ( rc != LDAP_SUCCESS ) {
1885 fprintf( stderr, "Invalid base DN \"%s\": %d (%s)\n",
1886 val, rc, ldap_err2string( rc ) );
1889 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
1890 STRLENOF( SCOPESTR "=" ) ) )
1892 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
1893 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
1894 si->si_scope = LDAP_SCOPE_BASE;
1895 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
1896 si->si_scope = LDAP_SCOPE_ONELEVEL;
1897 #ifdef LDAP_SCOPE_SUBORDINATE
1898 } else if ( !strcasecmp( val, "subordinate" ) ||
1899 !strcasecmp( val, "children" ))
1901 si->si_scope = LDAP_SCOPE_SUBORDINATE;
1903 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
1904 si->si_scope = LDAP_SCOPE_SUBTREE;
1906 fprintf( stderr, "Error: parse_syncrepl_line: "
1907 "unknown scope \"%s\"\n", val);
1910 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
1911 STRLENOF( ATTRSONLYSTR "=" ) ) )
1913 si->si_attrsonly = 1;
1914 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
1915 STRLENOF( ATTRSSTR "=" ) ) )
1917 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
1918 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
1920 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1921 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
1922 if ( si->si_anlist == NULL ) {
1923 ch_free( attr_fname );
1926 ch_free( attr_fname );
1928 char *str, *s, *next;
1929 char delimstr[] = " ,\t";
1930 str = ch_strdup( val );
1931 for ( s = ldap_pvt_strtok( str, delimstr, &next );
1933 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
1935 if ( strlen(s) == 1 && *s == '*' ) {
1936 si->si_allattrs = 1;
1937 *(val + ( s - str )) = delimstr[0];
1939 if ( strlen(s) == 1 && *s == '+' ) {
1940 si->si_allopattrs = 1;
1941 *(val + ( s - str )) = delimstr[0];
1945 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
1946 if ( si->si_anlist == NULL ) {
1950 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
1951 STRLENOF( EXATTRSSTR "=" ) ) )
1953 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
1954 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
1956 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1957 si->si_exanlist = file2anlist(
1958 si->si_exanlist, attr_fname, " ,\t" );
1959 if ( si->si_exanlist == NULL ) {
1960 ch_free( attr_fname );
1963 ch_free( attr_fname );
1965 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
1966 if ( si->si_exanlist == NULL ) {
1970 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
1971 STRLENOF( TYPESTR "=" ) ) )
1973 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
1974 if ( !strncasecmp( val, "refreshOnly",
1975 STRLENOF("refreshOnly") ))
1977 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1978 } else if ( !strncasecmp( val, "refreshAndPersist",
1979 STRLENOF("refreshAndPersist") ))
1981 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
1982 si->si_interval = 60;
1984 fprintf( stderr, "Error: parse_syncrepl_line: "
1985 "unknown sync type \"%s\"\n", val);
1988 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
1989 STRLENOF( INTERVALSTR "=" ) ) )
1991 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
1992 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
1993 si->si_interval = 0;
2001 hstr = strchr( dstr, ':' );
2002 if ( hstr == NULL ) {
2003 fprintf( stderr, "Error: parse_syncrepl_line: "
2004 "invalid interval \"%s\"\n", val );
2008 mstr = strchr( hstr, ':' );
2009 if ( mstr == NULL ) {
2010 fprintf( stderr, "Error: parse_syncrepl_line: "
2011 "invalid interval \"%s\"\n", val );
2015 sstr = strchr( mstr, ':' );
2016 if ( sstr == NULL ) {
2017 fprintf( stderr, "Error: parse_syncrepl_line: "
2018 "invalid interval \"%s\"\n", val );
2027 if (( hh > 24 ) || ( hh < 0 ) ||
2028 ( mm > 60 ) || ( mm < 0 ) ||
2029 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2030 fprintf( stderr, "Error: parse_syncrepl_line: "
2031 "invalid interval \"%s\"\n", val );
2034 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2036 if ( si->si_interval < 0 ) {
2037 fprintf( stderr, "Error: parse_syncrepl_line: "
2038 "invalid interval \"%ld\"\n",
2039 (long) si->si_interval);
2042 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2043 STRLENOF( RETRYSTR "=" ) ) )
2048 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2049 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2050 retry_list[0] = NULL;
2052 slap_str2clist( &retry_list, val, " ,\t" );
2054 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2058 "Error: incomplete syncrepl retry list\n" );
2059 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2060 ch_free( retry_list[k] );
2062 ch_free( retry_list );
2063 exit( EXIT_FAILURE );
2065 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2066 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2067 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2068 for ( j = 0; j < n; j++ ) {
2069 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2070 if ( *retry_list[j*2+1] == '+' ) {
2071 si->si_retrynum_init[j] = -1;
2072 si->si_retrynum[j] = -1;
2076 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2077 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2080 si->si_retrynum_init[j] = -2;
2081 si->si_retrynum[j] = -2;
2082 si->si_retryinterval[j] = 0;
2084 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2085 ch_free( retry_list[k] );
2087 ch_free( retry_list );
2088 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2089 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2091 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2092 si->si_manageDSAit = atoi( val );
2093 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2094 STRLENOF( SLIMITSTR "=") ) )
2096 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2097 si->si_slimit = atoi( val );
2098 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2099 STRLENOF( TLIMITSTR "=" ) ) )
2101 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2102 si->si_tlimit = atoi( val );
2104 fprintf( stderr, "Error: parse_syncrepl_line: "
2105 "unknown keyword \"%s\"\n", cargv[ i ] );
2110 if ( gots != GOT_ALL ) {
2112 "Error: Malformed \"syncrepl\" line in slapd config file" );
2120 slap_str2clist( char ***out, char *in, const char *brkstr )
2128 /* find last element in list */
2129 for (i = 0; *out && (*out)[i]; i++);
2131 /* protect the input string from strtok */
2132 str = ch_strdup( in );
2134 if ( *str == '\0' ) {
2139 /* Count words in string */
2141 for ( s = str; *s; s++ ) {
2142 if ( strchr( brkstr, *s ) != NULL ) {
2147 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
2149 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
2151 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
2153 *new = ch_strdup( s );