1 /* config.c - configuration file handling routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
31 #include <ac/string.h>
33 #include <ac/signal.h>
34 #include <ac/socket.h>
39 #include "slapi/slapi.h"
47 * defaults for various global variables
49 slap_mask_t global_allows = 0;
50 slap_mask_t global_disallows = 0;
51 int global_gentlehup = 0;
52 int global_idletimeout = 0;
53 char *global_host = NULL;
54 char *global_realm = NULL;
55 char *ldap_srvtab = "";
56 char **default_passwd_hash = NULL;
57 struct berval default_search_base = BER_BVNULL;
58 struct berval default_search_nbase = BER_BVNULL;
59 unsigned num_subordinates = 0;
61 ber_len_t sockbuf_max_incoming = SLAP_SB_MAX_INCOMING_DEFAULT;
62 ber_len_t sockbuf_max_incoming_auth= SLAP_SB_MAX_INCOMING_AUTH;
64 int slap_conn_max_pending = SLAP_CONN_MAX_PENDING_DEFAULT;
65 int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
67 char *slapd_pid_file = NULL;
68 char *slapd_args_file = NULL;
70 char *strtok_quote_ptr;
72 int use_reverse_lookup = 0;
75 int slapi_plugins_used = 0;
78 static int fp_getline(FILE *fp, ConfigArgs *c);
79 static void fp_getline_init(ConfigArgs *c);
80 static int fp_parse_line(ConfigArgs *c);
82 static char *strtok_quote(char *line, char *sep);
84 static int load_ucdata(char *path);
87 int read_config_file(const char *fname, int depth, ConfigArgs *cf);
89 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
90 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
92 int config_generic(ConfigArgs *c);
93 int config_search_base(ConfigArgs *c);
94 int config_passwd_hash(ConfigArgs *c);
95 int config_schema_dn(ConfigArgs *c);
96 int config_sizelimit(ConfigArgs *c);
97 int config_timelimit(ConfigArgs *c);
98 int config_limits(ConfigArgs *c);
99 int config_overlay(ConfigArgs *c);
100 int config_suffix(ConfigArgs *c);
101 int config_deref_depth(ConfigArgs *c);
102 int config_rootdn(ConfigArgs *c);
103 int config_rootpw(ConfigArgs *c);
104 int config_restrict(ConfigArgs *c);
105 int config_allows(ConfigArgs *c);
106 int config_disallows(ConfigArgs *c);
107 int config_requires(ConfigArgs *c);
108 int config_security(ConfigArgs *c);
109 int config_referral(ConfigArgs *c);
110 int config_loglevel(ConfigArgs *c);
111 int config_syncrepl(ConfigArgs *c);
112 int config_replica(ConfigArgs *c);
113 int config_updatedn(ConfigArgs *c);
114 int config_updateref(ConfigArgs *c);
115 int config_include(ConfigArgs *c);
117 int config_tls_option(ConfigArgs *c);
118 int config_tls_verify(ConfigArgs *c);
121 int config_plugin(ConfigArgs *c);
123 int config_pluginlog(ConfigArgs *c);
164 /* original config.c ordering */
166 ConfigTable SystemConfiguration[] = {
167 { "backend", 2, 2, 0, "type", ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND, &config_generic, NULL, NULL, NULL },
168 { "database", 2, 2, 0, "type", ARG_MAGIC|CFG_DATABASE, &config_generic, NULL, NULL, NULL },
169 { "localSSF", 2, 2, 0, "ssf", ARG_LONG, &local_ssf, NULL, NULL, NULL },
170 { "concurrency", 2, 2, 0, "level", ARG_LONG|ARG_NONZERO|ARG_MAGIC|CFG_CONCUR, &config_generic, NULL, NULL, NULL },
171 { "index_substr_if_minlen", 2, 2, 0, "min", ARG_INT|ARG_NONZERO, &index_substr_if_minlen, NULL, NULL, NULL },
172 { "index_substr_if_maxlen", 2, 2, 0, "max", ARG_INT|ARG_NONZERO|ARG_SPECIAL, &index_substr_if_maxlen, NULL, NULL, NULL },
173 { "index_substr_any_len", 2, 2, 0, "len", ARG_INT|ARG_NONZERO, &index_substr_any_len, NULL, NULL, NULL },
174 { "index_substr_step", 2, 2, 0, "step", ARG_INT|ARG_NONZERO, &index_substr_any_step, NULL, NULL, NULL },
175 { "sockbuf_max_incoming", 2, 2, 0, "max", ARG_LONG, &sockbuf_max_incoming, NULL, NULL, NULL },
176 { "sockbuf_max_incoming_auth",2, 2, 0, "max", ARG_LONG, &sockbuf_max_incoming_auth, NULL, NULL, NULL },
177 { "conn_max_pending", 2, 2, 0, "max", ARG_LONG, &slap_conn_max_pending, NULL, NULL, NULL },
178 { "conn_max_pending_auth", 2, 2, 0, "max", ARG_LONG, &slap_conn_max_pending_auth, NULL, NULL, NULL },
179 { "defaultSearchBase", 2, 2, 0, "dn", ARG_MAGIC, &config_search_base, NULL, NULL, NULL },
180 { "threads", 2, 2, 0, "count", ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic, NULL, NULL, NULL },
181 { "pidfile", 2, 2, 0, "file", ARG_STRING, &slapd_pid_file, NULL, NULL, NULL },
182 { "argsfile", 2, 2, 0, "file", ARG_STRING, &slapd_args_file, NULL, NULL, NULL },
183 { "password-hash", 2, 2, 0, "hash", ARG_MAGIC, &config_passwd_hash, NULL, NULL, NULL },
184 { "password-crypt-salt-format",2, 2, 0, "salt", ARG_MAGIC|CFG_SALT, &config_generic, NULL, NULL, NULL },
185 #ifdef SLAP_AUTH_REWRITE
186 { "auth-rewrite", 2, 2, 14, NULL, ARG_MAGIC|CFG_REWRITE, &config_generic, NULL, NULL, NULL },
188 { "sasl", 2, 0, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL }, /* XXX */
189 { "auth", 2, 2, 4, NULL, ARG_MAGIC|CFG_SASLOPT, &config_generic, NULL, NULL, NULL },
190 { "schemadn", 2, 2, 0, "dn", ARG_MAGIC, &config_schema_dn, NULL, NULL, NULL },
191 { "ucdata-path", 2, 2, 0, "path", ARG_IGNORED, NULL, NULL, NULL, NULL },
192 { "sizelimit", 2, 2, 0, "limit", ARG_MAGIC|CFG_SIZE, &config_sizelimit, NULL, NULL, NULL },
193 { "timelimit", 2, 2, 0, "limit", ARG_MAGIC|CFG_TIME, &config_timelimit, NULL, NULL, NULL },
194 { "limits", 2, 2, 0, "limits", ARG_DB|ARG_MAGIC|CFG_LIMITS, &config_generic, NULL, NULL, NULL },
195 { "subordinate", 1, 1, 0, "sub", ARG_DB|ARG_MAGIC|CFG_SUB, &config_generic, NULL, NULL, NULL },
196 { "overlay", 2, 2, 0, "overlay", ARG_DB|ARG_MAGIC, &config_overlay, NULL, NULL, NULL },
197 { "suffix", 2, 2, 0, "suffix", ARG_DB|ARG_MAGIC, &config_suffix, NULL, NULL, NULL },
198 { "maxDerefDepth", 2, 2, 0, "depth", ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH, &config_generic, NULL, NULL, NULL },
199 { "rootdn", 2, 2, 0, "dn", ARG_DB|ARG_MAGIC, &config_rootdn, NULL, NULL, NULL },
200 { "rootpw", 2, 2, 0, "password", ARG_DB|ARG_MAGIC, &config_rootpw, NULL, NULL, NULL },
201 { "readonly", 2, 2, 0, "on|off", ARG_ON_OFF|ARG_MAGIC|CFG_RO, &config_generic, NULL, NULL, NULL },
202 { "restrict", 2, 0, 0, "op_list", ARG_MAGIC, &config_restrict, NULL, NULL, NULL },
203 { "allows", 2, 0, 5, "features", ARG_PRE_DB|ARG_MAGIC, &config_allows, NULL, NULL, NULL },
204 { "disallows", 2, 0, 8, "features", ARG_PRE_DB|ARG_MAGIC, &config_disallows, NULL, NULL, NULL },
205 { "require", 2, 0, 7, "features", ARG_MAGIC, &config_requires, NULL, NULL, NULL },
206 { "security", 2, 0, 0, "factors", ARG_MAGIC, &config_security, NULL, NULL, NULL },
207 { "referral", 2, 2, 0, "url", ARG_MAGIC, &config_referral, NULL, NULL, NULL },
208 { "logfile", 2, 2, 0, "file", ARG_MAGIC|CFG_LOGFILE, &config_generic, NULL, NULL, NULL },
209 { "objectidentifier", 0, 0, 0, NULL, ARG_MAGIC|CFG_OID, &config_generic, NULL, NULL, NULL },
210 { "objectclass", 2, 0, 0, "objectclass", ARG_PAREN|ARG_MAGIC|CFG_OC, &config_generic, NULL, NULL, NULL },
211 { "ditcontentrule", 0, 0, 0, NULL, ARG_MAGIC|CFG_DIT, &config_generic, NULL, NULL, NULL },
212 { "attribute", 2, 0, 9, "attribute", ARG_PAREN|ARG_MAGIC|CFG_ATTR, &config_generic, NULL, NULL, NULL },
213 { "attributeoptions", 0, 0, 0, NULL, ARG_MAGIC|CFG_ATOPT, &config_generic, NULL, NULL, NULL },
214 { "schemacheck", 2, 2, 0, "on|off", ARG_ON_OFF|ARG_MAGIC|CFG_CHECK, &config_generic, NULL, NULL, NULL },
215 { "access", 0, 0, 0, NULL, ARG_MAGIC|CFG_ACL, &config_generic, NULL, NULL, NULL },
216 { "loglevel", 2, 0, 0, "level", ARG_MAGIC, &config_loglevel, NULL, NULL, NULL },
217 { "syncrepl", 0, 0, 0, NULL, ARG_DB|ARG_MAGIC, &config_syncrepl, NULL, NULL, NULL },
218 { "replica", 2, 0, 0, "host or uri", ARG_DB|ARG_MAGIC, &config_replica, NULL, NULL, NULL },
219 { "replicationInterval", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
220 { "updatedn", 2, 2, 0, "dn", ARG_DB|ARG_MAGIC, &config_updatedn, NULL, NULL, NULL },
221 { "updateref", 2, 2, 0, "url", ARG_DB|ARG_MAGIC, &config_updateref, NULL, NULL, NULL },
222 { "replogfile", 2, 2, 0, "filename", ARG_MAGIC|ARG_STRING|CFG_REPLOG, &config_generic, NULL, NULL, NULL },
223 { "rootDSE", 2, 2, 0, "filename", ARG_MAGIC|CFG_ROOTDSE, &config_generic, NULL, NULL, NULL },
224 { "lastmod", 2, 2, 0, "on|off", ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD, &config_generic, NULL, NULL, NULL },
226 { "gentlehup", 2, 2, 0, "on|off", ARG_ON_OFF, &global_gentlehup, NULL, NULL, NULL },
228 { "gentlehup", 2, 2, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
230 { "idletimeout", 2, 2, 0, "timeout", ARG_INT, &global_idletimeout, NULL, NULL, NULL },
231 /* XXX -- special case? */
232 { "include", 2, 2, 0, "filename", ARG_MAGIC, &config_include, NULL, NULL, NULL },
233 { "srvtab", 2, 2, 0, "filename", ARG_STRING, &ldap_srvtab, NULL, NULL, NULL },
235 { "moduleload", 2, 2, 0, "filename", ARG_MAGIC|CFG_MODLOAD, &config_generic, NULL, NULL, NULL },
236 { "modulepath", 2, 2, 0, "path", ARG_MAGIC|CFG_MODPATH, &config_generic, NULL, NULL, NULL },
239 { "TLSRandFile", 0, 0, 0, NULL, CFG_TLS_RAND|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
240 { "TLSCipherSuite", 0, 0, 0, NULL, CFG_TLS_CIPHER|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
241 { "TLSCertificateFile", 0, 0, 0, NULL, CFG_TLS_CERT_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
242 { "TLSCertificateKeyFile", 0, 0, 0, NULL, CFG_TLS_CERT_KEY|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
243 { "TLSCertificatePath", 0, 0, 0, NULL, CFG_TLS_CERT_PATH|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
244 { "TLSCACertificateFile", 0, 0, 0, NULL, CFG_TLS_CA_FILE|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
245 #ifdef HAVE_OPENSSL_CRL
246 { "TLSCRLCheck", 0, 0, 0, NULL, CFG_TLS_CRLCHECK|ARG_MAGIC, &config_tls_option, NULL, NULL, NULL },
248 { "TLSCRLCheck", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
250 { "TLSVerifyClient", 0, 0, 0, NULL, CFG_TLS_VERIFY|ARG_MAGIC, &config_tls_verify, NULL, NULL, NULL },
252 #ifdef SLAPD_RLOOKUPS
253 { "reverse-lookup", 2, 2, 0, "on|off", ARG_ON_OFF, &use_reverse_lookup, NULL, NULL, NULL },
255 { "reverse-lookup", 2, 2, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
258 { "plugin", 0, 0, 0, NULL, ARG_MAGIC|CFG_PLUGIN, &config_generic, NULL, NULL, NULL },
259 { "pluginlog", 2, 2, 0, "filename", ARG_STRING, &slapi_log_file, NULL, NULL, NULL },
261 { "plugin", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
262 { "pluginlog", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
264 { "replica-pidfile", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
265 { "replica-argsfile", 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL },
266 { NULL, 0, 0, 0, NULL, ARG_IGNORED, NULL, NULL, NULL, NULL }
271 new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv )
274 c = ch_calloc( 1, sizeof( ConfigArgs ) );
275 if ( c == NULL ) return(NULL);
284 int parse_config_table(ConfigTable *Conf, ConfigArgs *c) {
285 int i, rc, arg_user, arg_type, iarg;
288 for(i = 0; Conf[i].name; i++)
289 if( (Conf[i].length && (!strncasecmp(c->argv[0], Conf[i].name, Conf[i].length))) ||
290 (!strcasecmp(c->argv[0], Conf[i].name)) ) break;
291 if(!Conf[i].name) return(ARG_UNKNOWN);
292 arg_type = Conf[i].arg_type;
293 if(arg_type == ARG_IGNORED) {
294 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> ignored\n",
295 c->fname, c->lineno, Conf[i].name);
298 if(Conf[i].min_args && (c->argc < Conf[i].min_args)) {
299 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
300 Debug(LDAP_DEBUG_CONFIG, "keyword <%s> missing <%s> argument\n", Conf[i].name, Conf[i].what, 0);
301 return(ARG_BAD_CONF);
303 if(Conf[i].max_args && (c->argc > Conf[i].max_args)) {
304 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
305 Debug(LDAP_DEBUG_CONFIG, "extra cruft after <%s> in <%s> line (ignored)\n", Conf[i].what, Conf[i].name, 0);
307 if((arg_type & ARG_DB) && !c->be) {
308 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> allowed only within database declaration\n",
309 c->fname, c->lineno, Conf[i].name);
310 return(ARG_BAD_CONF);
312 if((arg_type & ARG_PRE_DB) && c->be) {
313 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: keyword <%s> must appear before any database declaration\n",
314 c->fname, c->lineno, Conf[i].name);
315 return(ARG_BAD_CONF);
317 if((arg_type & ARG_PAREN) && *c->argv[1] != '(' /*')'*/) {
318 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: old <%s> format not supported\n", c->fname, c->lineno, Conf[i].name);
319 return(ARG_BAD_CONF);
321 if((arg_type & ARGS_POINTER) && !Conf[i].arg_item) {
322 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: null arg_item for <%s>\n", c->fname, c->lineno, Conf[i].name);
323 return(ARG_BAD_CONF);
325 c->type = arg_user = (arg_type & ARGS_USERLAND);
326 c->value_int = c->value_long = c->value_ber_t = 0;
327 c->value_string = NULL;
328 if(arg_type & ARGS_NUMERIC) {
330 iarg = 0; larg = 0; barg = 0;
331 switch(arg_type & ARGS_NUMERIC) {
332 case ARG_INT: iarg = atoi(c->argv[1]); break;
333 case ARG_LONG: larg = atol(c->argv[1]); break;
334 case ARG_BER_LEN_T: barg = (ber_len_t)atol(c->argv[1]); break;
336 if(!strcasecmp(c->argv[1], "on")) {
338 } else if(!strcasecmp(c->argv[1], "off")) {
341 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ignoring ", c->fname, c->lineno, 0);
342 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%s) in <%s> line\n",
343 Conf[i].what, c->argv[1], Conf[i].name);
348 j = (arg_type & ARG_NONZERO) ? 1 : 0;
349 rc = (Conf == SystemConfiguration) ? ((arg_type & ARG_SPECIAL) && (larg < index_substr_if_maxlen)) : 0;
350 if(iarg < j || larg < j || barg < j || rc) {
351 larg = larg ? larg : (barg ? barg : iarg);
352 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: " , c->fname, c->lineno, 0);
353 Debug(LDAP_DEBUG_CONFIG, "invalid %s value (%ld) in <%s> line\n", Conf[i].what, larg, Conf[i].name);
354 return(ARG_BAD_CONF);
357 c->value_long = larg;
358 c->value_ber_t = barg;
360 if(arg_type & ARG_STRING) c->value_string = ch_strdup(c->argv[1]);
361 if(arg_type & ARG_MAGIC) {
362 if(!c->be) c->be = frontendDB;
363 rc = (*((ConfigDriver*)Conf[i].arg_item))(c);
364 if(c->be == frontendDB) c->be = NULL;
366 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: ", c->fname, c->lineno, 0);
367 Debug(LDAP_DEBUG_CONFIG, "handler for <%s> exited with %d!", Conf[i].name, rc, 0);
368 return(ARG_BAD_CONF);
372 if(arg_type & ARGS_POINTER) switch(arg_type & ARGS_POINTER) {
374 case ARG_INT: *((int*)Conf[i].arg_item) = iarg; break;
375 case ARG_LONG: *((long*)Conf[i].arg_item) = larg; break;
376 case ARG_BER_LEN_T: *((ber_len_t*)Conf[i].arg_item) = barg; break;
378 char *cc = *((char**)Conf[i].arg_item);
379 if(cc) ch_free(cc); /* potential memory leak */
380 cc = c->value_string;
381 /* memcpy(Conf[i].arg_item, &c->value_string, sizeof(void *)); */
389 read_config(const char *fname, int depth) {
390 return read_config_file(fname, depth, NULL);
394 read_config_file(const char *fname, int depth, ConfigArgs *cf)
400 c = ch_calloc( 1, sizeof( ConfigArgs ) );
406 memcpy( c, cf, sizeof( ConfigArgs ) );
408 c->depth = depth; /* XXX */
414 c->argv = ch_calloc( ARGS_STEP + 1, sizeof( *c->argv ) );
415 c->argv_size = ARGS_STEP + 1;
417 fp = fopen( fname, "r" );
420 Debug(LDAP_DEBUG_ANY,
421 "could not open config file \"%s\": %s (%d)\n",
422 fname, strerror(errno), errno);
426 Debug(LDAP_DEBUG_CONFIG, "reading config file %s\n", fname, 0, 0);
430 while ( fp_getline( fp, c ) ) {
431 /* skip comments and blank lines */
432 if ( c->line[0] == '#' || c->line[0] == '\0' ) {
435 if ( fp_parse_line( c ) ) {
440 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: bad config line (ignored)\n", fname, c->lineno, 0);
444 rc = parse_config_table( SystemConfiguration, c );
448 if ( rc & ARGS_USERLAND ) {
449 switch(rc) { /* XXX a usertype would be opaque here */
451 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: unknown user type <%d>\n",
452 c->fname, c->lineno, *c->argv);
456 } else if ( rc == ARG_BAD_CONF || rc != ARG_UNKNOWN ) {
459 } else if ( c->bi && c->bi->bi_config ) { /* XXX to check: could both be/bi_config? oops */
460 rc = (*c->bi->bi_config)(c->bi, c->fname, c->lineno, c->argc, c->argv);
463 case SLAP_CONF_UNKNOWN:
464 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
465 "unknown directive <%s> inside backend info definition (ignored)\n",
466 c->fname, c->lineno, *c->argv);
473 } else if ( c->be && c->be->be_config ) {
474 rc = (*c->be->be_config)(c->be, c->fname, c->lineno, c->argc, c->argv);
477 case SLAP_CONF_UNKNOWN:
478 Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
479 "unknown directive <%s> inside backend database definition (ignored)\n",
480 c->fname, c->lineno, *c->argv);
487 } else if ( frontendDB->be_config ) {
488 rc = (*frontendDB->be_config)(frontendDB, c->fname, (int)c->lineno, c->argc, c->argv);
491 case SLAP_CONF_UNKNOWN:
492 Debug( LDAP_DEBUG_CONFIG, "%s: line %lu: "
493 "%s: line %lu: unknown directive <%s> inside global database definition (ignored)\n",
494 c->fname, c->lineno, *c->argv);
502 Debug(LDAP_DEBUG_CONFIG, "%s: line %lu: "
503 "unknown directive <%s> outside backend info and database definitions (ignored)\n",
504 c->fname, c->lineno, *c->argv);
512 if ( BER_BVISNULL( &frontendDB->be_schemadn ) ) {
513 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
514 &frontendDB->be_schemadn );
515 dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
530 config_generic(ConfigArgs *c) {
531 char *p = strchr(c->line,'(' /*')'*/);
536 if(!(c->bi = backend_info(c->argv[1]))) {
537 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
538 "backend %s failed init!\n", c->fname, c->lineno, c->argv[1]);
545 if(!(c->be = backend_db_init(c->argv[1]))) {
546 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
547 "database %s failed init!\n", c->fname, c->lineno, c->argv[1]);
553 ldap_pvt_thread_set_concurrency(c->value_long);
557 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
558 connection_pool_max = c->value_int; /* save for reference */
562 lutil_salt_format(c->argv[1]);
566 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
572 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
574 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
578 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_GLUE_SUBORDINATE;
583 /* XXX slap_sasl_config doesn't actually use the line argument */
584 if(slap_sasl_config(c->argc, c->argv, c->line, c->fname, c->lineno))
589 c->be->be_max_deref_depth = c->value_int;
593 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv)) return(1);
597 if(parse_oc(c->fname, c->lineno, p, c->argv)) return(1);
601 if(parse_cr(c->fname, c->lineno, p, c->argv)) return(1);
605 if(parse_at(c->fname, c->lineno, p, c->argv)) return(1);
609 ad_define_option(NULL, NULL, 0);
610 for(i = 1; i < c->argc; i++)
611 if(ad_define_option(c->argv[i], c->fname, c->lineno))
616 global_schemacheck = c->value_int;
617 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
618 "schema checking disabled! your mileage may vary!\n",
619 c->fname, c->lineno, 0);
623 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
628 c->be->be_auditlogfile = c->value_string;
633 if(SLAP_MONITOR(c->be)) {
634 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
635 "\"replogfile\" should not be used "
636 "inside monitor database\n",
637 c->fname, c->lineno, 0);
638 return(0); /* FIXME: should this be an error? */
641 c->be->be_replogfile = c->value_string;
645 if(read_root_dse_file(c->argv[1])) {
646 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
647 "could not read \"rootDSE <filename>\" line\n",
648 c->fname, c->lineno, 0);
654 FILE *logfile = fopen(c->argv[1], "w");
655 if(logfile) lutil_debug_file(logfile);
660 if(SLAP_NOLASTMODCMD(c->be)) {
661 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
662 "lastmod not available for %s databases\n",
663 c->fname, c->lineno, c->be->bd_info->bi_type);
667 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
669 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
674 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
679 if(module_path(c->argv[1])) return(1);
685 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
687 slapi_plugins_used++;
691 #ifdef SLAP_AUTH_REWRITE
693 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
700 Debug(LDAP_DEBUG_ANY, "%s: line %lu: unknown CFG_TYPE %d"
701 "(ignored)\n", c->fname, c->lineno, c->type);
709 config_search_base(ConfigArgs *c) {
713 Debug(LDAP_DEBUG_ANY, "%s: line %lu: defaultSearchBase line must appear "
714 "prior to any backend or database definition\n",
715 c->fname, c->lineno, 0);
719 if(default_search_nbase.bv_len) {
720 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
721 "default search base \"%s\" already defined "
722 "(discarding old)\n",
723 c->fname, c->lineno, default_search_base.bv_val);
724 free(default_search_base.bv_val);
725 free(default_search_nbase.bv_val);
728 ber_str2bv(c->argv[1], 0, 1, &dn);
729 rc = dnPrettyNormal(NULL, &dn, &default_search_base, &default_search_nbase, NULL);
731 if(rc != LDAP_SUCCESS) {
732 Debug(LDAP_DEBUG_ANY,
733 "%s: line %lu: defaultSearchBase DN is invalid\n",
734 c->fname, c->lineno, 0 );
741 config_passwd_hash(ConfigArgs *c) {
743 if(default_passwd_hash) {
744 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
745 "already set default password_hash\n",
746 c->fname, c->lineno, 0);
749 for(i = 1; i < c->argc; i++) {
750 if(!lutil_passwd_scheme(c->argv[i])) {
751 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
752 "password scheme \"%s\" not available\n",
753 c->fname, c->lineno, c->argv[i] );
755 ldap_charray_add(&default_passwd_hash, c->argv[i]);
757 if(!default_passwd_hash) {
758 Debug(LDAP_DEBUG_ANY, "%s: line %lu: no valid hashes found\n",
759 c->fname, c->lineno, 0 );
767 config_schema_dn(ConfigArgs *c) {
770 ber_str2bv(c->argv[1], 0, 1, &dn);
771 rc = dnPrettyNormal(NULL, &dn, &c->be->be_schemadn, &c->be->be_schemandn, NULL);
772 if(rc != LDAP_SUCCESS) {
773 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
774 "schema DN is invalid\n", c->fname, c->lineno, 0);
781 config_sizelimit(ConfigArgs *c) {
784 struct slap_limits_set *lim = &c->be->be_def_limit;
785 for(i = 1; i < c->argc; i++) {
786 if(!strncasecmp(c->argv[i], "size", 4)) {
787 rc = limits_parse_one(c->argv[i], lim);
789 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
790 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
791 c->fname, c->lineno, c->argv[i]);
795 if(!strcasecmp(c->argv[i], "unlimited")) {
796 lim->lms_s_soft = -1;
798 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
799 if(next == c->argv[i]) {
800 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
801 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
802 c->fname, c->lineno, c->argv[i]);
804 } else if(next[0] != '\0') {
805 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
806 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
807 c->fname, c->lineno, next);
817 config_timelimit(ConfigArgs *c) {
820 struct slap_limits_set *lim = &c->be->be_def_limit;
821 for(i = 1; i < c->argc; i++) {
822 if(!strncasecmp(c->argv[i], "time", 4)) {
823 rc = limits_parse_one(c->argv[i], lim);
825 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
826 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
827 c->fname, c->lineno, c->argv[i]);
831 if(!strcasecmp(c->argv[i], "unlimited")) {
832 lim->lms_t_soft = -1;
834 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
835 if(next == c->argv[i]) {
836 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
837 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
838 c->fname, c->lineno, c->argv[i]);
840 } else if(next[0] != '\0') {
841 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
842 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
843 c->fname, c->lineno, next);
853 config_overlay(ConfigArgs *c) {
854 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
856 Debug(LDAP_DEBUG_ANY, "%s: line %lu: (optional) %s",
857 c->fname, c->lineno, c->be == frontendDB ? "global " : "");
858 Debug(LDAP_DEBUG_ANY, "overlay \"%s\" configuration "
859 "failed (ignored)\n", c->argv[1][1], 0, 0);
860 } else if(overlay_config(c->be, c->argv[1])) {
867 config_suffix(ConfigArgs *c) {
869 struct berval dn, pdn, ndn;
871 #ifdef SLAPD_MONITOR_DN
872 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
873 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
874 "%s\" is reserved for monitoring slapd\n",
875 c->fname, c->lineno, SLAPD_MONITOR_DN);
879 ber_str2bv(c->argv[1], 0, 1, &dn);
881 rc = dnPrettyNormal(NULL, &dn, &pdn, &ndn, NULL);
882 if(rc != LDAP_SUCCESS) {
883 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix DN is invalid\n",
884 c->fname, c->lineno, 0);
887 tbe = select_backend(&ndn, 0, 0);
889 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix already served by this backend! (ignored)\n",
890 c->fname, c->lineno, 0);
894 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix already served by a preceding backend \"%s\"\n",
895 c->fname, c->lineno, tbe->be_suffix[0].bv_val);
899 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
900 Debug(LDAP_DEBUG_ANY, "%s: line %lu: suffix DN empty and default search "
901 "base provided \"%s\" (assuming okay)\n",
902 c->fname, c->lineno, default_search_base.bv_val);
904 ber_bvarray_add(&c->be->be_suffix, &pdn);
905 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
910 config_rootdn(ConfigArgs *c) {
914 ber_str2bv(c->argv[1], 0, 1, &dn);
916 rc = dnPrettyNormal(NULL, &dn, &c->be->be_rootdn, &c->be->be_rootndn, NULL);
918 if(rc != LDAP_SUCCESS) {
919 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
920 "rootdn DN is invalid\n", c->fname, c->lineno, 0);
927 config_rootpw(ConfigArgs *c) {
928 Backend *tbe = select_backend(&c->be->be_rootndn, 0, 0);
930 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
931 "rootpw can only be set when rootdn is under suffix\n",
932 c->fname, c->lineno, 0);
935 ber_str2bv(c->argv[1], 0, 1, &c->be->be_rootpw);
939 /* restrictops, allows, disallows, requires, loglevel */
941 struct verb_mask_list { char *word; int mask; };
944 verb_to_mask(ConfigArgs *c, struct verb_mask_list *v, int word) {
946 for(j = 0; v[j].word; j++)
947 if(!strcasecmp(c->argv[word], v[j].word))
953 verbs_to_mask(ConfigArgs *c, struct verb_mask_list *v, slap_mask_t *m) {
955 for(i = 1; i < c->argc; i++) {
956 j = verb_to_mask(c, v, i);
957 if(!v[j].word) return(1);
964 config_restrict(ConfigArgs *c) {
965 slap_mask_t restrictops = 0;
967 struct verb_mask_list restrictable_exops[] = {
968 { LDAP_EXOP_START_TLS, SLAP_RESTRICT_EXOP_START_TLS },
969 { LDAP_EXOP_MODIFY_PASSWD, SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
970 { LDAP_EXOP_X_WHO_AM_I, SLAP_RESTRICT_EXOP_WHOAMI },
971 { LDAP_EXOP_X_CANCEL, SLAP_RESTRICT_EXOP_CANCEL },
974 struct verb_mask_list restrictable_ops[] = {
975 { "bind", SLAP_RESTRICT_OP_BIND },
976 { "add", SLAP_RESTRICT_OP_ADD },
977 { "modify", SLAP_RESTRICT_OP_MODIFY },
978 { "modrdn", SLAP_RESTRICT_OP_RENAME },
979 { "rename", SLAP_RESTRICT_OP_RENAME },
980 { "delete", SLAP_RESTRICT_OP_DELETE },
981 { "search", SLAP_RESTRICT_OP_SEARCH },
982 { "compare", SLAP_RESTRICT_OP_COMPARE },
983 { "read", SLAP_RESTRICT_OP_READS },
984 { "write", SLAP_RESTRICT_OP_WRITES },
988 for(i = 1; i < c->argc; i++) {
989 j = verb_to_mask(c, restrictable_ops, i);
990 if(restrictable_ops[j].word) {
991 restrictops |= restrictable_ops[j].mask;
993 } else if(!strncasecmp(c->argv[i], "extended", STRLENOF("extended"))) {
994 char *e = c->argv[i] + STRLENOF("extended");
996 int k = verb_to_mask(c, restrictable_exops, e[1]);
997 if(restrictable_exops[k].word) {
998 restrictops |= restrictable_exops[k].mask;
1002 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
1003 restrictops |= SLAP_RESTRICT_OP_EXTENDED;
1008 c->be->be_restrictops |= restrictops;
1011 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1012 "unknown operation %s in \"restrict <features>\" line\n",
1013 c->fname, c->lineno, c->argv[i]);
1018 config_allows(ConfigArgs *c) {
1019 slap_mask_t allows = 0;
1021 struct verb_mask_list allowable_ops[] = {
1022 { "bind_v2", SLAP_ALLOW_BIND_V2 },
1023 { "bind_anon_cred", SLAP_ALLOW_BIND_ANON_CRED },
1024 { "bind_anon_dn", SLAP_ALLOW_BIND_ANON_DN },
1025 { "update_anon", SLAP_ALLOW_UPDATE_ANON },
1028 i = verbs_to_mask(c, allowable_ops, &allows);
1030 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1031 "unknown feature %s in \"allow <features>\" line\n",
1032 c->fname, c->lineno, c->argv[i]);
1035 global_allows |= allows;
1040 config_disallows(ConfigArgs *c) {
1041 slap_mask_t disallows = 0;
1043 struct verb_mask_list disallowable_ops[] = {
1044 { "bind_anon", SLAP_DISALLOW_BIND_ANON },
1045 { "bind_simple", SLAP_DISALLOW_BIND_SIMPLE },
1046 { "bind_krb4", SLAP_DISALLOW_BIND_KRBV4 },
1047 { "tls_2_anon", SLAP_DISALLOW_TLS_2_ANON },
1048 { "tls_authc", SLAP_DISALLOW_TLS_AUTHC },
1051 i = verbs_to_mask(c, disallowable_ops, &disallows);
1053 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1054 "unknown feature %s in \"disallow <features>\" line\n",
1055 c->fname, c->lineno, c->argv[i]);
1058 global_disallows |= disallows;
1063 config_requires(ConfigArgs *c) {
1064 slap_mask_t requires = 0;
1066 struct verb_mask_list requires_ops[] = {
1067 { "bind", SLAP_REQUIRE_BIND },
1068 { "LDAPv3", SLAP_REQUIRE_LDAP_V3 },
1069 { "authc", SLAP_REQUIRE_AUTHC },
1070 { "sasl", SLAP_REQUIRE_SASL },
1071 { "strong", SLAP_REQUIRE_STRONG },
1074 i = verbs_to_mask(c, requires_ops, &requires);
1076 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1077 "unknown feature %s in \"require <features>\" line\n",
1078 c->fname, c->lineno, c->argv[i]);
1081 c->be->be_requires = requires;
1086 config_loglevel(ConfigArgs *c) {
1089 struct verb_mask_list loglevel_ops[] = {
1090 { "Trace", LDAP_DEBUG_TRACE },
1091 { "Packets", LDAP_DEBUG_PACKETS },
1092 { "Args", LDAP_DEBUG_ARGS },
1093 { "Conns", LDAP_DEBUG_CONNS },
1094 { "BER", LDAP_DEBUG_BER },
1095 { "Filter", LDAP_DEBUG_FILTER },
1096 { "Config", LDAP_DEBUG_CONFIG },
1097 { "ACL", LDAP_DEBUG_ACL },
1098 { "Stats", LDAP_DEBUG_STATS },
1099 { "Stats2", LDAP_DEBUG_STATS2 },
1100 { "Shell", LDAP_DEBUG_SHELL },
1101 { "Parse", LDAP_DEBUG_PARSE },
1102 { "Cache", LDAP_DEBUG_CACHE },
1103 { "Index", LDAP_DEBUG_INDEX },
1109 for( i=1; i < c->argc; i++ ) {
1112 if ( isdigit( c->argv[i][0] ) ) {
1113 level = strtol( c->argv[i], &next, 10 );
1114 if ( next == NULL || next[0] != '\0' ) {
1115 Debug( LDAP_DEBUG_ANY,
1116 "%s: line %lu: unable to parse level \"%s\" "
1117 "in \"loglevel <level> [...]\" line.\n",
1118 c->fname, c->lineno , c->argv[i] );
1122 int j = verb_to_mask(c, loglevel_ops, c->argv[i][0]);
1123 if(!loglevel_ops[j].word) {
1124 Debug( LDAP_DEBUG_ANY,
1125 "%s: line %lu: unknown level \"%s\" "
1126 "in \"loglevel <level> [...]\" line.\n",
1127 c->fname, c->lineno , c->argv[i] );
1130 level = loglevel_ops[j].mask;
1132 ldap_syslog |= level;
1138 config_syncrepl(ConfigArgs *c) {
1139 if(SLAP_SHADOW(c->be)) {
1140 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1141 "syncrepl: database already shadowed.\n",
1142 c->fname, c->lineno, 0);
1144 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1147 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1152 config_referral(ConfigArgs *c) {
1153 struct berval vals[2];
1154 if(validate_global_referral(c->argv[1])) {
1155 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1156 "invalid URL (%s) in \"referral\" line.\n",
1157 c->fname, c->lineno, c->argv[1] );
1161 ber_str2bv(c->argv[1], 0, 1, &vals[0]);
1162 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1163 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1168 config_security(ConfigArgs *c) {
1169 slap_ssf_set_t *set = &c->be->be_ssf_set;
1172 for(i = 1; i < c->argc; i++) {
1175 if(!strncasecmp(c->argv[i], "ssf=", 4)) {
1176 tgt = &set->sss_ssf;
1177 src = &c->argv[i][4];
1178 } else if(!strncasecmp(c->argv[i], "transport=", 10)) {
1179 tgt = &set->sss_transport;
1180 src = &c->argv[i][10];
1181 } else if(!strncasecmp(c->argv[i], "tls=", 4)) {
1182 tgt = &set->sss_tls;
1183 src = &c->argv[i][4];
1184 } else if(!strncasecmp(c->argv[i], "sasl=", 5)) {
1185 tgt = &set->sss_sasl;
1186 src = &c->argv[i][5];
1187 } else if(!strncasecmp(c->argv[i], "update_ssf=", 11)) {
1188 tgt = &set->sss_update_ssf;
1189 src = &c->argv[i][11];
1190 } else if(!strncasecmp(c->argv[i], "update_transport=", 17)) {
1191 tgt = &set->sss_update_transport;
1192 src = &c->argv[i][17];
1193 } else if(!strncasecmp(c->argv[i], "update_tls=", 11)) {
1194 tgt = &set->sss_update_tls;
1195 src = &c->argv[i][11];
1196 } else if(!strncasecmp(c->argv[i], "update_sasl=", 12)) {
1197 tgt = &set->sss_update_sasl;
1198 src = &c->argv[i][12];
1199 } else if(!strncasecmp(c->argv[i], "simple_bind=", 12)) {
1200 tgt = &set->sss_simple_bind;
1201 src = &c->argv[i][12];
1203 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1204 "unknown factor %s in \"security <factors>\" line\n",
1205 c->fname, c->lineno, c->argv[i]);
1209 *tgt = strtol(src, &next, 10);
1210 if(next == NULL || next[0] != '\0' ) {
1211 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1212 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1213 c->fname, c->lineno, c->argv[i]);
1221 config_replica(ConfigArgs *c) {
1226 if(SLAP_MONITOR(c->be)) {
1227 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1228 "\"replica\" should not be used inside monitor database\n",
1229 c->fname, c->lineno, 0);
1230 return(0); /* FIXME: should this be an error? */
1233 for(i = 1; i < c->argc; i++) {
1234 if(!strncasecmp(c->argv[i], "host=", 5)) {
1235 nr = add_replica_info(c->be, c->argv[i] + 5);
1237 } else if(!strncasecmp(c->argv[i], "uri=", 4)) {
1238 if(ldap_url_parse(c->argv[i] + 4, &ludp) != LDAP_SUCCESS) {
1239 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1240 "replica line contains invalid "
1241 "uri definition.\n", c->fname, c->lineno, 0);
1244 if(!ludp->lud_host) {
1245 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1246 "replica line contains invalid "
1247 "uri definition - missing hostname.\n", c->fname, c->lineno, 0);
1250 replicahost = ch_malloc(strlen(c->argv[i]));
1252 Debug(LDAP_DEBUG_ANY,
1253 "out of memory in read_config\n", 0, 0, 0);
1254 ldap_free_urldesc(ludp);
1257 sprintf(replicahost, "%s:%d", ludp->lud_host, ludp->lud_port);
1258 nr = add_replica_info(c->be, replicahost);
1259 ldap_free_urldesc(ludp);
1260 ch_free(replicahost);
1265 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1266 "missing host or uri in \"replica\" line\n",
1267 c->fname, c->lineno, 0);
1269 } else if(nr == -1) {
1270 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1271 "unable to add replica \"%s\"\n",
1272 c->fname, c->lineno, c->argv[i] + 5);
1275 for(i = 1; i < c->argc; i++) {
1276 if(!strncasecmp(c->argv[i], "suffix=", 7)) {
1277 switch(add_replica_suffix(c->be, nr, c->argv[i] + 7)) {
1279 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1280 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1281 c->fname, c->lineno, c->argv[i] + 7);
1284 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1285 "unable to normalize suffix in \"replica\" line (ignored)\n",
1286 c->fname, c->lineno, 0);
1290 } else if(!strncasecmp(c->argv[i], "attr", 4)) {
1292 char *arg = c->argv[i] + 4;
1300 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1301 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1302 "attribute \"%s\" in \"replica\" line is unknown\n",
1303 c->fname, c->lineno, arg + 1);
1313 config_updatedn(ConfigArgs *c) {
1316 if(SLAP_SHADOW(c->be)) {
1317 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1318 "updatedn: database already shadowed.\n",
1319 c->fname, c->lineno, 0);
1323 ber_str2bv(c->argv[1], 0, 0, &dn);
1325 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1327 if(rc != LDAP_SUCCESS) {
1328 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1329 "updatedn DN is invalid\n", c->fname, c->lineno, 0);
1333 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1338 config_updateref(ConfigArgs *c) {
1339 struct berval vals[2];
1340 if(!SLAP_SHADOW(c->be)) {
1341 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1342 "updateref line must after syncrepl or updatedn.\n",
1343 c->fname, c->lineno, 0);
1347 if(validate_global_referral(c->argv[1])) {
1348 Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1349 "invalid URL (%s) in \"updateref\" line.\n",
1350 c->fname, c->lineno, c->argv[1]);
1353 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1354 vals[1].bv_val = NULL;
1355 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1359 /* XXX meaningless in ldif */
1362 config_include(ConfigArgs *c) {
1363 char *savefname = ch_strdup(c->argv[1]);
1364 unsigned long savelineno = c->lineno;
1366 rc = read_config_file(savefname, c->depth + 1, c);
1368 c->lineno = savelineno - 1;
1374 config_tls_option(ConfigArgs *c) {
1377 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
1378 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
1379 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
1380 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
1381 case CFG_TLS_CERT_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
1382 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
1383 #ifdef HAVE_OPENSSL_CRL
1384 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
1386 default: Debug(LDAP_DEBUG_ANY, "%s: line %lu: "
1387 "unknown tls_option <%x>\n",
1388 c->fname, c->lineno, c->type);
1390 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
1394 config_tls_verify(ConfigArgs *c) {
1396 if(isdigit((unsigned char)c->argv[1][0])) {
1397 i = atoi(c->argv[1]);
1398 return(ldap_pvt_tls_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i));
1400 return(ldap_int_tls_config(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, c->argv[1]));
1405 /* -------------------------------------- */
1409 strtok_quote( char *line, char *sep )
1415 strtok_quote_ptr = NULL;
1416 if ( line != NULL ) {
1419 while ( *next && strchr( sep, *next ) ) {
1423 if ( *next == '\0' ) {
1429 for ( inquote = 0; *next; ) {
1437 AC_MEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
1443 next + 1, strlen( next + 1 ) + 1 );
1444 next++; /* dont parse the escaped character */
1449 if ( strchr( sep, *next ) != NULL ) {
1450 strtok_quote_ptr = next;
1463 static char buf[BUFSIZ];
1465 static size_t lmax, lcur;
1467 #define CATLINE( buf ) \
1469 size_t len = strlen( buf ); \
1470 while ( lcur + len + 1 > lmax ) { \
1472 line = (char *) ch_realloc( line, lmax ); \
1474 strcpy( line + lcur, buf ); \
1479 fp_getline_init(ConfigArgs *c) {
1485 fp_getline( FILE *fp, ConfigArgs *c )
1493 /* avoid stack of bufs */
1494 if ( strncasecmp( line, "include", STRLENOF( "include" ) ) == 0 ) {
1500 while ( fgets( buf, sizeof( buf ), fp ) ) {
1501 p = strchr( buf, '\n' );
1503 if ( p > buf && p[-1] == '\r' ) {
1511 && ( p = line + strlen( line ) - 1 )[0] == '\\'
1518 if ( !isspace( (unsigned char)buf[0] ) ) {
1529 return(line[0] ? 1 : 0);
1533 fp_parse_line(ConfigArgs *c)
1536 char *tline = ch_strdup(c->line);
1537 char *hide[] = { "rootpw", "replica", "bindpw", "pseudorootpw", "dbpasswd", '\0' };
1541 token = strtok_quote(tline, " \t");
1543 if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
1544 if(strtok_quote_ptr) *strtok_quote_ptr = ' ';
1545 Debug(LDAP_DEBUG_CONFIG, "line %lu (%s%s)\n", c->lineno, hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
1546 if(strtok_quote_ptr) *strtok_quote_ptr = '\0';
1548 for(; token; token = strtok_quote(NULL, " \t")) {
1549 if(c->argc == c->argv_size - 1) {
1551 tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
1553 Debug(LDAP_DEBUG_ANY, "line %lu: out of memory\n", c->lineno, 0, 0);
1557 c->argv_size += ARGS_STEP;
1559 c->argv[c->argc++] = token;
1561 c->argv[c->argc] = NULL;
1567 /* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
1569 load_ucdata( char *path )
1572 static int loaded = 0;
1578 err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA, UCDATA_ALL );
1580 Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
1588 /* ucdata is now hardcoded */
1597 ucdata_unload( UCDATA_ALL );
1599 /* NOTE: in case of early exit, frontendDB can be NULL */
1600 if ( frontendDB->be_schemandn.bv_val )
1601 free( frontendDB->be_schemandn.bv_val );
1602 if ( frontendDB->be_schemadn.bv_val )
1603 free( frontendDB->be_schemadn.bv_val );
1604 if ( frontendDB->be_acl )
1605 acl_destroy( frontendDB->be_acl, NULL );
1608 if ( slapd_args_file )
1609 free ( slapd_args_file );
1610 if ( slapd_pid_file )
1611 free ( slapd_pid_file );
1612 if ( default_passwd_hash )
1613 ldap_charray_free( default_passwd_hash );
1624 syncinfo_t *si_entry;
1626 int duplicated_replica_id = 0;
1628 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
1631 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
1635 si->si_tls = SYNCINFO_TLS_OFF;
1636 if ( be->be_rootndn.bv_val ) {
1637 ber_dupbv( &si->si_updatedn, &be->be_rootndn );
1639 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1640 si->si_schemachecking = 0;
1641 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
1642 &si->si_filterstr );
1643 si->si_base.bv_val = NULL;
1644 si->si_scope = LDAP_SCOPE_SUBTREE;
1645 si->si_attrsonly = 0;
1646 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1647 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1648 si->si_attrs = NULL;
1649 si->si_allattrs = 0;
1650 si->si_allopattrs = 0;
1651 si->si_exattrs = NULL;
1652 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1653 si->si_interval = 86400;
1654 si->si_retryinterval = NULL;
1655 si->si_retrynum_init = NULL;
1656 si->si_retrynum = NULL;
1657 si->si_syncCookie.ctxcsn = NULL;
1658 si->si_syncCookie.octet_str = NULL;
1659 si->si_syncCookie.sid = -1;
1660 si->si_manageDSAit = 0;
1664 si->si_presentlist = NULL;
1665 LDAP_LIST_INIT( &si->si_nonpresentlist );
1667 rc = parse_syncrepl_line( cargv, cargc, si );
1669 LDAP_STAILQ_FOREACH( si_entry, &be->be_syncinfo, si_next ) {
1670 if ( si->si_rid == si_entry->si_rid ) {
1671 Debug( LDAP_DEBUG_ANY,
1672 "add_syncrepl: duplicated replica id\n",0, 0, 0 );
1673 duplicated_replica_id = 1;
1678 if ( rc < 0 || duplicated_replica_id ) {
1679 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
1680 syncinfo_free( si );
1683 Debug( LDAP_DEBUG_CONFIG,
1684 "Config: ** successfully added syncrepl \"%s\"\n",
1685 si->si_provideruri == NULL ? "(null)" : si->si_provideruri, 0, 0 );
1686 if ( !si->si_schemachecking ) {
1687 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
1690 LDAP_STAILQ_INSERT_TAIL( &be->be_syncinfo, si, si_next );
1695 /* NOTE: used & documented in slapd.conf(5) */
1697 #define PROVIDERSTR "provider"
1698 #define TYPESTR "type"
1699 #define INTERVALSTR "interval"
1700 #define SEARCHBASESTR "searchbase"
1701 #define FILTERSTR "filter"
1702 #define SCOPESTR "scope"
1703 #define ATTRSSTR "attrs"
1704 #define ATTRSONLYSTR "attrsonly"
1705 #define SLIMITSTR "sizelimit"
1706 #define TLIMITSTR "timelimit"
1707 #define SCHEMASTR "schemachecking"
1708 #define UPDATEDNSTR "updatedn"
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"
1737 #define GOT_ID 0x0001
1738 #define GOT_PROVIDER 0x0002
1739 #define GOT_METHOD 0x0004
1742 #define GOT_ALL (GOT_ID|GOT_PROVIDER|GOT_METHOD)
1745 parse_syncrepl_line(
1755 for ( i = 1; i < cargc; i++ ) {
1756 if ( !strncasecmp( cargv[ i ], IDSTR "=",
1757 STRLENOF( IDSTR "=" ) ) )
1760 /* '\0' string terminator accounts for '=' */
1761 val = cargv[ i ] + STRLENOF( IDSTR "=" );
1763 if ( tmp >= 1000 || tmp < 0 ) {
1764 fprintf( stderr, "Error: parse_syncrepl_line: "
1765 "syncrepl id %d is out of range [0..999]\n", tmp );
1770 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
1771 STRLENOF( PROVIDERSTR "=" ) ) )
1773 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
1774 si->si_provideruri = ch_strdup( val );
1775 si->si_provideruri_bv = (BerVarray)
1776 ch_calloc( 2, sizeof( struct berval ));
1777 ber_str2bv( si->si_provideruri, strlen( si->si_provideruri ),
1778 1, &si->si_provideruri_bv[0] );
1779 si->si_provideruri_bv[1].bv_len = 0;
1780 si->si_provideruri_bv[1].bv_val = NULL;
1781 gots |= GOT_PROVIDER;
1782 } else if ( !strncasecmp( cargv[ i ], STARTTLSSTR "=",
1783 STRLENOF(STARTTLSSTR "=") ) )
1785 val = cargv[ i ] + STRLENOF( STARTTLSSTR "=" );
1786 if( !strcasecmp( val, CRITICALSTR ) ) {
1787 si->si_tls = SYNCINFO_TLS_CRITICAL;
1789 si->si_tls = SYNCINFO_TLS_ON;
1791 } else if ( !strncasecmp( cargv[ i ], UPDATEDNSTR "=",
1792 STRLENOF( UPDATEDNSTR "=" ) ) )
1794 struct berval updatedn = BER_BVNULL;
1796 val = cargv[ i ] + STRLENOF( UPDATEDNSTR "=" );
1797 ber_str2bv( val, 0, 0, &updatedn );
1798 ch_free( si->si_updatedn.bv_val );
1799 dnNormalize( 0, NULL, NULL, &updatedn, &si->si_updatedn, NULL );
1800 } else if ( !strncasecmp( cargv[ i ], BINDMETHSTR "=",
1801 STRLENOF( BINDMETHSTR "=" ) ) )
1803 val = cargv[ i ] + STRLENOF( BINDMETHSTR "=" );
1804 if ( !strcasecmp( val, SIMPLESTR )) {
1805 si->si_bindmethod = LDAP_AUTH_SIMPLE;
1807 } else if ( !strcasecmp( val, SASLSTR )) {
1808 #ifdef HAVE_CYRUS_SASL
1809 si->si_bindmethod = LDAP_AUTH_SASL;
1811 #else /* HAVE_CYRUS_SASL */
1812 fprintf( stderr, "Error: parse_syncrepl_line: "
1813 "not compiled with SASL support\n" );
1815 #endif /* HAVE_CYRUS_SASL */
1817 si->si_bindmethod = -1;
1819 } else if ( !strncasecmp( cargv[ i ], BINDDNSTR "=",
1820 STRLENOF( BINDDNSTR "=" ) ) )
1822 val = cargv[ i ] + STRLENOF( BINDDNSTR "=" );
1823 si->si_binddn = ch_strdup( val );
1824 } else if ( !strncasecmp( cargv[ i ], CREDSTR "=",
1825 STRLENOF( CREDSTR "=" ) ) )
1827 val = cargv[ i ] + STRLENOF( CREDSTR "=" );
1828 si->si_passwd = ch_strdup( val );
1829 } else if ( !strncasecmp( cargv[ i ], SASLMECHSTR "=",
1830 STRLENOF( SASLMECHSTR "=" ) ) )
1832 val = cargv[ i ] + STRLENOF( SASLMECHSTR "=" );
1833 si->si_saslmech = ch_strdup( val );
1834 } else if ( !strncasecmp( cargv[ i ], SECPROPSSTR "=",
1835 STRLENOF( SECPROPSSTR "=" ) ) )
1837 val = cargv[ i ] + STRLENOF( SECPROPSSTR "=" );
1838 si->si_secprops = ch_strdup( val );
1839 } else if ( !strncasecmp( cargv[ i ], REALMSTR "=",
1840 STRLENOF( REALMSTR "=" ) ) )
1842 val = cargv[ i ] + STRLENOF( REALMSTR "=" );
1843 si->si_realm = ch_strdup( val );
1844 } else if ( !strncasecmp( cargv[ i ], AUTHCSTR "=",
1845 STRLENOF( AUTHCSTR "=" ) ) )
1847 val = cargv[ i ] + STRLENOF( AUTHCSTR "=" );
1848 if ( si->si_authcId )
1849 ch_free( si->si_authcId );
1850 si->si_authcId = ch_strdup( val );
1851 } else if ( !strncasecmp( cargv[ i ], OLDAUTHCSTR "=",
1852 STRLENOF( OLDAUTHCSTR "=" ) ) )
1854 /* Old authcID is provided for some backwards compatibility */
1855 val = cargv[ i ] + STRLENOF( OLDAUTHCSTR "=" );
1856 if ( si->si_authcId )
1857 ch_free( si->si_authcId );
1858 si->si_authcId = ch_strdup( val );
1859 } else if ( !strncasecmp( cargv[ i ], AUTHZSTR "=",
1860 STRLENOF( AUTHZSTR "=" ) ) )
1862 val = cargv[ i ] + STRLENOF( AUTHZSTR "=" );
1863 si->si_authzId = ch_strdup( val );
1864 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
1865 STRLENOF( SCHEMASTR "=" ) ) )
1867 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
1868 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
1869 si->si_schemachecking = 1;
1870 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
1871 si->si_schemachecking = 0;
1873 si->si_schemachecking = 1;
1875 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
1876 STRLENOF( FILTERSTR "=" ) ) )
1878 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
1879 ber_str2bv( val, 0, 1, &si->si_filterstr );
1880 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
1881 STRLENOF( SEARCHBASESTR "=" ) ) )
1884 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
1885 if ( si->si_base.bv_val ) {
1886 ch_free( si->si_base.bv_val );
1888 ber_str2bv( val, 0, 0, &bv );
1889 if ( dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL )) {
1890 fprintf( stderr, "Invalid base DN \"%s\"\n", val );
1893 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
1894 STRLENOF( SCOPESTR "=" ) ) )
1896 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
1897 if ( !strncasecmp( val, "base", STRLENOF( "base" ) )) {
1898 si->si_scope = LDAP_SCOPE_BASE;
1899 } else if ( !strncasecmp( val, "one", STRLENOF( "one" ) )) {
1900 si->si_scope = LDAP_SCOPE_ONELEVEL;
1901 #ifdef LDAP_SCOPE_SUBORDINATE
1902 } else if ( !strcasecmp( val, "subordinate" ) ||
1903 !strcasecmp( val, "children" ))
1905 si->si_scope = LDAP_SCOPE_SUBORDINATE;
1907 } else if ( !strncasecmp( val, "sub", STRLENOF( "sub" ) )) {
1908 si->si_scope = LDAP_SCOPE_SUBTREE;
1910 fprintf( stderr, "Error: parse_syncrepl_line: "
1911 "unknown scope \"%s\"\n", val);
1914 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
1915 STRLENOF( ATTRSONLYSTR "=" ) ) )
1917 si->si_attrsonly = 1;
1918 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
1919 STRLENOF( ATTRSSTR "=" ) ) )
1921 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
1922 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
1924 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1925 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
1926 if ( si->si_anlist == NULL ) {
1927 ch_free( attr_fname );
1930 ch_free( attr_fname );
1932 char *str, *s, *next;
1933 char delimstr[] = " ,\t";
1934 str = ch_strdup( val );
1935 for ( s = ldap_pvt_strtok( str, delimstr, &next );
1937 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
1939 if ( strlen(s) == 1 && *s == '*' ) {
1940 si->si_allattrs = 1;
1941 *(val + ( s - str )) = delimstr[0];
1943 if ( strlen(s) == 1 && *s == '+' ) {
1944 si->si_allopattrs = 1;
1945 *(val + ( s - str )) = delimstr[0];
1949 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
1950 if ( si->si_anlist == NULL ) {
1954 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
1955 STRLENOF( EXATTRSSTR "=" ) ) )
1957 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
1958 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
1960 attr_fname = ch_strdup( val + STRLENOF(":include:") );
1961 si->si_exanlist = file2anlist(
1962 si->si_exanlist, attr_fname, " ,\t" );
1963 if ( si->si_exanlist == NULL ) {
1964 ch_free( attr_fname );
1967 ch_free( attr_fname );
1969 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
1970 if ( si->si_exanlist == NULL ) {
1974 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
1975 STRLENOF( TYPESTR "=" ) ) )
1977 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
1978 if ( !strncasecmp( val, "refreshOnly",
1979 STRLENOF("refreshOnly") ))
1981 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1982 } else if ( !strncasecmp( val, "refreshAndPersist",
1983 STRLENOF("refreshAndPersist") ))
1985 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
1986 si->si_interval = 60;
1988 fprintf( stderr, "Error: parse_syncrepl_line: "
1989 "unknown sync type \"%s\"\n", val);
1992 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
1993 STRLENOF( INTERVALSTR "=" ) ) )
1995 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
1996 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
1997 si->si_interval = 0;
2005 hstr = strchr( dstr, ':' );
2006 if ( hstr == NULL ) {
2007 fprintf( stderr, "Error: parse_syncrepl_line: "
2008 "invalid interval \"%s\"\n", val );
2012 mstr = strchr( hstr, ':' );
2013 if ( mstr == NULL ) {
2014 fprintf( stderr, "Error: parse_syncrepl_line: "
2015 "invalid interval \"%s\"\n", val );
2019 sstr = strchr( mstr, ':' );
2020 if ( sstr == NULL ) {
2021 fprintf( stderr, "Error: parse_syncrepl_line: "
2022 "invalid interval \"%s\"\n", val );
2031 if (( hh > 24 ) || ( hh < 0 ) ||
2032 ( mm > 60 ) || ( mm < 0 ) ||
2033 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2034 fprintf( stderr, "Error: parse_syncrepl_line: "
2035 "invalid interval \"%s\"\n", val );
2038 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2040 if ( si->si_interval < 0 ) {
2041 fprintf( stderr, "Error: parse_syncrepl_line: "
2042 "invalid interval \"%ld\"\n",
2043 (long) si->si_interval);
2046 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2047 STRLENOF( RETRYSTR "=" ) ) )
2052 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2053 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2054 retry_list[0] = NULL;
2056 slap_str2clist( &retry_list, val, " ,\t" );
2058 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2062 "Error: incomplete syncrepl retry list\n" );
2063 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2064 ch_free( retry_list[k] );
2066 ch_free( retry_list );
2067 exit( EXIT_FAILURE );
2069 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2070 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2071 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2072 for ( j = 0; j < n; j++ ) {
2073 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2074 if ( *retry_list[j*2+1] == '+' ) {
2075 si->si_retrynum_init[j] = -1;
2076 si->si_retrynum[j] = -1;
2080 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2081 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2084 si->si_retrynum_init[j] = -2;
2085 si->si_retrynum[j] = -2;
2086 si->si_retryinterval[j] = 0;
2088 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2089 ch_free( retry_list[k] );
2091 ch_free( retry_list );
2092 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2093 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2095 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2096 si->si_manageDSAit = atoi( val );
2097 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2098 STRLENOF( SLIMITSTR "=") ) )
2100 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2101 si->si_slimit = atoi( val );
2102 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2103 STRLENOF( TLIMITSTR "=" ) ) )
2105 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2106 si->si_tlimit = atoi( val );
2108 fprintf( stderr, "Error: parse_syncrepl_line: "
2109 "unknown keyword \"%s\"\n", cargv[ i ] );
2114 if ( gots != GOT_ALL ) {
2116 "Error: Malformed \"syncrepl\" line in slapd config file" );
2124 slap_str2clist( char ***out, char *in, const char *brkstr )
2132 /* find last element in list */
2133 for (i = 0; *out && (*out)[i]; i++);
2135 /* protect the input string from strtok */
2136 str = ch_strdup( in );
2138 if ( *str == '\0' ) {
2143 /* Count words in string */
2145 for ( s = str; *s; s++ ) {
2146 if ( strchr( brkstr, *s ) != NULL ) {
2151 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
2153 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
2155 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
2157 *new = ch_strdup( s );