1 /* bconfig.c - the config backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 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>.
17 * This work was originally developed by Howard Chu for inclusion
18 * in OpenLDAP Software.
24 #include <ac/string.h>
31 #include "slapi/slapi.h"
38 static struct berval config_rdn = BER_BVC("cn=config");
39 static struct berval schema_rdn = BER_BVC("cn=schema");
42 typedef struct modpath_s {
43 struct modpath_s *mp_next;
44 struct berval mp_path;
48 static ModPaths modpaths, *modlast = &modpaths, *modcur = &modpaths;
51 typedef struct ConfigFile {
52 struct ConfigFile *c_sibs;
53 struct ConfigFile *c_kids;
55 AttributeType *c_at_head, *c_at_tail;
56 ContentRule *c_cr_head, *c_cr_tail;
57 ObjectClass *c_oc_head, *c_oc_tail;
58 OidMacro *c_om_head, *c_om_tail;
62 typedef struct CfOcInfo {
63 struct berval *co_name;
64 ConfigTable *co_table;
68 typedef struct CfEntryInfo {
69 struct CfEntryInfo *ce_parent;
70 struct CfEntryInfo *ce_sibs;
71 struct CfEntryInfo *ce_kids;
79 ConfigFile *cb_config;
81 BackendDB *cb_be; /* config backend */
82 BackendDB cb_db; /* underlying database */
86 /* These do nothing in slapd, they're kept only to make them
89 static char *replica_pidFile, *replica_argsFile;
90 static int replicationInterval;
92 static char *passwd_salt;
93 static char *logfileName;
94 static BerVarray authz_rewrites;
96 static struct berval cfdir;
99 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
102 static ObjectClass *cfOc_schema, *cfOc_global, *cfOc_backend, *cfOc_database,
103 *cfOc_include, *cfOc_overlay, *cfOc_module;
105 static ConfigFile cf_prv, *cfn = &cf_prv;
107 static Avlnode *CfOcTree;
109 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
110 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
111 static void syncrepl_unparse LDAP_P (( syncinfo_t *, struct berval *));
112 static int config_add_internal( CfBackInfo *cfb, Entry *e, SlapReply *rs );
114 static ConfigDriver config_fname;
115 static ConfigDriver config_cfdir;
116 static ConfigDriver config_generic;
117 static ConfigDriver config_search_base;
118 static ConfigDriver config_passwd_hash;
119 static ConfigDriver config_schema_dn;
120 static ConfigDriver config_sizelimit;
121 static ConfigDriver config_timelimit;
122 static ConfigDriver config_limits;
123 static ConfigDriver config_overlay;
124 static ConfigDriver config_suffix;
125 static ConfigDriver config_deref_depth;
126 static ConfigDriver config_rootdn;
127 static ConfigDriver config_rootpw;
128 static ConfigDriver config_restrict;
129 static ConfigDriver config_allows;
130 static ConfigDriver config_disallows;
131 static ConfigDriver config_requires;
132 static ConfigDriver config_security;
133 static ConfigDriver config_referral;
134 static ConfigDriver config_loglevel;
135 static ConfigDriver config_syncrepl;
136 static ConfigDriver config_replica;
137 static ConfigDriver config_updatedn;
138 static ConfigDriver config_updateref;
139 static ConfigDriver config_include;
141 static ConfigDriver config_tls_option;
142 static ConfigDriver config_tls_config;
191 static OidRec OidMacros[] = {
192 /* OpenLDAProot:666.11.1 */
193 { "OLcfg", "1.3.6.1.4.1.4203.666.11.1" },
194 { "OLcfgAt", "OLcfg:3" },
195 { "OLcfgOc", "OLcfg:4" },
196 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
197 { "OMsInteger", "OMsyn:2" },
198 { "OMsBoolean", "OMsyn:7" },
199 { "OMsDN", "OMsyn:12" },
200 { "OMsDirectoryString", "OMsyn:15" },
201 { "OMsOctetString", "OMsyn:40" },
205 /* alphabetical ordering */
207 ConfigTable config_back_cf_table[] = {
208 /* This attr is read-only */
209 { "", "", 0, 0, 0, ARG_MAGIC,
210 &config_fname, "( OLcfgAt:78 NAME 'olcConfigFile' "
211 "DESC 'File for slapd configuration directives' "
212 "EQUALITY caseIgnoreMatch "
213 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
214 { "", "", 0, 0, 0, ARG_MAGIC,
215 &config_cfdir, "( OLcfgAt:79 NAME 'olcConfigDir' "
216 "DESC 'Directory for slapd configuration backend' "
217 "EQUALITY caseIgnoreMatch "
218 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
219 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
220 &config_generic, "( OLcfgAt:1 NAME 'olcAccess' "
221 "DESC 'Access Control List' "
222 "EQUALITY caseIgnoreMatch "
223 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
224 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
225 &config_allows, "( OLcfgAt:2 NAME 'olcAllows' "
226 "DESC 'Allowed set of deprecated features' "
227 "EQUALITY caseIgnoreMatch "
228 "SYNTAX OMsDirectoryString )", NULL, NULL },
229 { "argsfile", "file", 2, 2, 0, ARG_STRING,
230 &slapd_args_file, "( OLcfgAt:3 NAME 'olcArgsFile' "
231 "DESC 'File for slapd command line options' "
232 "EQUALITY caseIgnoreMatch "
233 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
234 { "attribute", "attribute", 2, 0, 9, ARG_PAREN|ARG_MAGIC|CFG_ATTR,
235 &config_generic, "( OLcfgAt:4 NAME 'olcAttributeTypes' "
236 "DESC 'OpenLDAP attributeTypes' "
237 "EQUALITY objectIdentifierFirstComponentMatch "
238 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 X-ORDERED 'VALUES' )",
240 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
241 &config_generic, "( OLcfgAt:5 NAME 'olcAttributeOptions' "
242 "EQUALITY caseIgnoreMatch "
243 "SYNTAX OMsDirectoryString )", NULL, NULL },
244 { "authid-rewrite", NULL, 2, 0, 0,
245 #ifdef SLAP_AUTH_REWRITE
246 ARG_MAGIC|CFG_REWRITE, &config_generic,
250 "( OLcfgAt:6 NAME 'olcAuthIDRewrite' "
251 "EQUALITY caseIgnoreMatch "
252 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
253 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
254 &config_generic, "( OLcfgAt:7 NAME 'olcAuthzPolicy' "
255 "EQUALITY caseIgnoreMatch "
256 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
257 { "authz-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
258 &config_generic, "( OLcfgAt:8 NAME 'olcAuthzRegexp' "
259 "EQUALITY caseIgnoreMatch "
260 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
261 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
262 &config_generic, "( OLcfgAt:9 NAME 'olcBackend' "
263 "DESC 'A type of backend' "
264 "EQUALITY caseIgnoreMatch "
265 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
266 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
267 &config_generic, "( OLcfgAt:10 NAME 'olcConcurrency' "
268 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
269 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
270 &slap_conn_max_pending, "( OLcfgAt:11 NAME 'olcConnMaxPending' "
271 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
272 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
273 &slap_conn_max_pending_auth, "( OLcfgAt:12 NAME 'olcConnMaxPendingAuth' "
274 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
275 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
276 &config_generic, "( OLcfgAt:13 NAME 'olcDatabase' "
277 "DESC 'The backend type for a database instance' "
278 "SUP olcBackend X-ORDERED 'VALUES' )", NULL, NULL },
279 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_MAGIC,
280 &config_search_base, "( OLcfgAt:14 NAME 'olcDefaultSearchBase' "
281 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
282 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
283 &config_disallows, "( OLcfgAt:15 NAME 'olcDisallows' "
284 "EQUALITY caseIgnoreMatch "
285 "SYNTAX OMsDirectoryString )", NULL, NULL },
286 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT,
287 &config_generic, "( OLcfgAt:16 NAME 'olcDitContentRules' "
288 "DESC 'OpenLDAP DIT content rules' "
289 "EQUALITY objectIdentifierFirstComponentMatch "
290 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 X-ORDERED 'VALUES' )",
292 { "gentlehup", "on|off", 2, 2, 0,
294 ARG_ON_OFF, &global_gentlehup,
298 "( OLcfgAt:17 NAME 'olcGentleHUP' "
299 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
300 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
301 &global_idletimeout, "( OLcfgAt:18 NAME 'olcIdleTimeout' "
302 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
303 /* XXX -- special case? */
304 { "include", "file", 2, 2, 0, ARG_MAGIC,
305 &config_include, "( OLcfgAt:19 NAME 'olcInclude' "
306 "SUP labeledURI )", NULL, NULL },
307 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
308 &config_generic, "( OLcfgAt:20 NAME 'olcIndexSubstrIfMinLen' "
309 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
310 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
311 &config_generic, "( OLcfgAt:21 NAME 'olcIndexSubstrIfMaxLen' "
312 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
313 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
314 &index_substr_any_len, "( OLcfgAt:22 NAME 'olcIndexSubstrAnyLen' "
315 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
316 { "index_substr_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
317 &index_substr_any_step, "( OLcfgAt:23 NAME 'olcIndexSubstrAnyStep' "
318 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
319 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
320 &config_generic, "( OLcfgAt:24 NAME 'olcLastMod' "
321 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
322 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
323 &config_generic, "( OLcfgAt:25 NAME 'olcLimits' "
324 "SYNTAX OMsDirectoryString )", NULL, NULL },
325 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
326 &local_ssf, "( OLcfgAt:26 NAME 'olcLocalSSF' "
327 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
328 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
329 &config_generic, "( OLcfgAt:27 NAME 'olcLogFile' "
330 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
331 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
332 &config_loglevel, "( OLcfgAt:28 NAME 'olcLogLevel' "
333 "SYNTAX OMsDirectoryString )", NULL, NULL },
334 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
335 &config_generic, "( OLcfgAt:29 NAME 'olcMaxDerefDepth' "
336 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
337 { "moduleload", "file", 2, 0, 0,
339 ARG_MAGIC|CFG_MODLOAD, &config_generic,
343 "( OLcfgAt:30 NAME 'olcModuleLoad' "
344 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
345 { "modulepath", "path", 2, 2, 0,
347 ARG_MAGIC|CFG_MODPATH, &config_generic,
351 "( OLcfgAt:31 NAME 'olcModulePath' "
352 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
353 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
354 &config_generic, "( OLcfgAt:32 NAME 'olcObjectClasses' "
355 "DESC 'OpenLDAP object classes' "
356 "EQUALITY objectIdentifierFirstComponentMatch "
357 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 X-ORDERED 'VALUES' )",
359 { "objectidentifier", NULL, 0, 0, 0, ARG_MAGIC|CFG_OID,
360 &config_generic, "( OLcfgAt:33 NAME 'olcObjectIdentifier' "
361 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
362 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
363 &config_overlay, "( OLcfgAt:34 NAME 'olcOverlay' "
364 "SUP olcDatabase X-ORDERED 'VALUES' )", NULL, NULL },
365 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
366 &config_generic, "( OLcfgAt:35 NAME 'olcPasswordCryptSaltFormat' "
367 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
368 { "password-hash", "hash", 2, 2, 0, ARG_MAGIC,
369 &config_passwd_hash, "( OLcfgAt:36 NAME 'olcPasswordHash' "
370 "SYNTAX OMsDirectoryString )", NULL, NULL },
371 { "pidfile", "file", 2, 2, 0, ARG_STRING,
372 &slapd_pid_file, "( OLcfgAt:37 NAME 'olcPidFile' "
373 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
374 { "plugin", NULL, 0, 0, 0,
376 ARG_MAGIC|CFG_PLUGIN, &config_generic,
380 "( OLcfgAt:38 NAME 'olcPlugin' "
381 "SYNTAX OMsDirectoryString )", NULL, NULL },
382 { "pluginlog", "filename", 2, 2, 0,
384 ARG_STRING, &slapi_log_file,
388 "( OLcfgAt:39 NAME 'olcPluginLogFile' "
389 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
390 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
391 &config_generic, "( OLcfgAt:40 NAME 'olcReadOnly' "
392 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
393 { "referral", "url", 2, 2, 0, ARG_MAGIC,
394 &config_referral, "( OLcfgAt:41 NAME 'olcReferral' "
395 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
396 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
397 &config_replica, "( OLcfgAt:42 NAME 'olcReplica' "
398 "SUP labeledURI )", NULL, NULL },
399 { "replica-argsfile", NULL, 0, 0, 0, ARG_STRING,
400 &replica_argsFile, "( OLcfgAt:43 NAME 'olcReplicaArgsFile' "
401 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
402 { "replica-pidfile", NULL, 0, 0, 0, ARG_STRING,
403 &replica_pidFile, "( OLcfgAt:44 NAME 'olcReplicaPidFile' "
404 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
405 { "replicationInterval", NULL, 0, 0, 0, ARG_INT,
406 &replicationInterval, "( OLcfgAt:45 NAME 'olcReplicationInterval' "
407 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
408 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLOG,
409 &config_generic, "( OLcfgAt:46 NAME 'olcReplogFile' "
410 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
411 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
412 &config_requires, "( OLcfgAt:47 NAME 'olcRequires' "
413 "SYNTAX OMsDirectoryString )", NULL, NULL },
414 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
415 &config_restrict, "( OLcfgAt:48 NAME 'olcRestrict' "
416 "SYNTAX OMsDirectoryString )", NULL, NULL },
417 { "reverse-lookup", "on|off", 2, 2, 0,
418 #ifdef SLAPD_RLOOKUPS
419 ARG_ON_OFF, &use_reverse_lookup,
423 "( OLcfgAt:49 NAME 'olcReverseLookup' "
424 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
425 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
426 &config_rootdn, "( OLcfgAt:50 NAME 'olcRootDN' "
427 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
428 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
429 &config_generic, "( OLcfgAt:51 NAME 'olcRootDSE' "
430 "SYNTAX OMsDirectoryString )", NULL, NULL },
431 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
432 &config_rootpw, "( OLcfgAt:52 NAME 'olcRootPW' "
433 "SYNTAX OMsOctetString SINGLE-VALUE )", NULL, NULL },
434 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
435 &config_generic, NULL, NULL, NULL },
436 { "sasl-host", "host", 2, 2, 0,
437 #ifdef HAVE_CYRUS_SASL
438 ARG_STRING|ARG_UNIQUE, &global_host,
442 "( OLcfgAt:53 NAME 'olcSaslHost' "
443 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
444 { "sasl-realm", "realm", 2, 2, 0,
445 #ifdef HAVE_CYRUS_SASL
446 ARG_STRING|ARG_UNIQUE, &global_realm,
450 "( OLcfgAt:54 NAME 'olcSaslRealm' "
451 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
452 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
453 &config_generic, NULL, NULL, NULL },
454 { "sasl-secprops", "properties", 2, 2, 0,
455 #ifdef HAVE_CYRUS_SASL
456 ARG_MAGIC|CFG_SASLSECP, &config_generic,
460 "( OLcfgAt:56 NAME 'olcSaslSecProps' "
461 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
462 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
463 &config_generic, NULL, NULL, NULL },
464 { "schemacheck", "on|off", 2, 2, 0, ARG_ON_OFF|ARG_MAGIC|CFG_CHECK,
465 &config_generic, "( OLcfgAt:57 NAME 'olcSchemaCheck' "
466 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
467 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_MAGIC,
468 &config_schema_dn, "( OLcfgAt:58 NAME 'olcSchemaDN' "
469 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
470 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
471 &config_security, "( OLcfgAt:59 NAME 'olcSecurity' "
472 "SYNTAX OMsDirectoryString )", NULL, NULL },
473 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_SIZE,
474 &config_sizelimit, "( OLcfgAt:60 NAME 'olcSizeLimit' "
475 "SYNTAX OMsInteger )", NULL, NULL },
476 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
477 &sockbuf_max_incoming, "( OLcfgAt:61 NAME 'olcSockbufMaxIncoming' "
478 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
479 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
480 &sockbuf_max_incoming_auth, "( OLcfgAt:62 NAME 'olcSockbufMaxIncomingAuth' "
481 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
482 { "srvtab", "file", 2, 2, 0,
483 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
484 ARG_STRING, &ldap_srvtab,
488 "( OLcfgAt:63 NAME 'olcSrvtab' "
489 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
490 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
491 &config_suffix, "( OLcfgAt:64 NAME 'olcSuffix' "
492 "SYNTAX OMsDN )", NULL, NULL },
493 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
494 &config_syncrepl, "( OLcfgAt:65 NAME 'olcSyncrepl' "
495 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
496 { "threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_THREADS,
497 &config_generic, "( OLcfgAt:66 NAME 'olcThreads' "
498 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
499 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_TIME,
500 &config_timelimit, "( OLcfgAt:67 NAME 'olcTimeLimit' "
501 "SYNTAX OMsInteger )", NULL, NULL },
502 { "TLSCACertificateFile", NULL, 0, 0, 0,
504 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
508 "( OLcfgAt:68 NAME 'olcTLSCACertificateFile' "
509 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
510 { "TLSCACertificatePath", NULL, 0, 0, 0,
512 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
516 "( OLcfgAt:69 NAME 'olcTLSCACertificatePath' "
517 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
518 { "TLSCertificateFile", NULL, 0, 0, 0,
520 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
524 "( OLcfgAt:70 NAME 'olcTLSCertificateFile' "
525 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
526 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
528 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
532 "( OLcfgAt:71 NAME 'olcTLSCertificateKeyFile' "
533 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
534 { "TLSCipherSuite", NULL, 0, 0, 0,
536 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
540 "( OLcfgAt:72 NAME 'olcTLSCipherSuite' "
541 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
542 { "TLSCRLCheck", NULL, 0, 0, 0,
544 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
548 "( OLcfgAt:73 NAME 'olcTLSCRLCheck' "
549 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
550 { "TLSRandFile", NULL, 0, 0, 0,
552 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
556 "( OLcfgAt:74 NAME 'olcTLSRandFile' "
557 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
558 { "TLSVerifyClient", NULL, 0, 0, 0,
560 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
564 "( OLcfgAt:75 NAME 'olcTLSVerifyClient' "
565 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
566 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
567 NULL, NULL, NULL, NULL },
568 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_MAGIC,
569 &config_updatedn, "( OLcfgAt:76 NAME 'olcUpdateDN' "
570 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
571 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
572 &config_updateref, "( OLcfgAt:77 NAME 'olcUpdateRef' "
573 "SUP labeledURI )", NULL, NULL },
574 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
575 NULL, NULL, NULL, NULL }
578 static ConfigOCs cf_ocs[] = {
581 "DESC 'OpenLDAP configuration object' "
583 "MAY ( cn $ olcConfigFile ) )", Cft_Abstract, NULL },
586 "DESC 'OpenLDAP Global configuration options' "
587 "SUP olcConfig STRUCTURAL "
588 "MAY ( olcConfigDir $ olcAllows $ olcArgsFile $ olcAttributeOptions $ "
589 "olcAuthIDRewrite $ olcAuthzPolicy $ olcAuthzRegexp $ "
590 "olcConcurrency $ olcConnMaxPending $ olcConnMaxPendingAuth $ "
591 "olcDefaultSearchBase $ olcDisallows $ olcGentleHUP $ "
592 "olcIdleTimeout $ olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
593 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcLocalSSF $ "
594 "olcLogLevel $ olcModulePath $ olcObjectIdentifier $ "
595 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
596 "olcPlugin $ olcPluginLogFile $ olcReadOnly $ olcReferral $ "
597 "olcReplicaPidFile $ olcReplicaArgsFile $ olcReplicationInterval $ "
598 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
599 "olcRootDSE $ olcRootPW $ olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
600 "olcSchemaCheck $ olcSchemaDN $ olcSecurity $ olcSizeLimit $ "
601 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ olcSrvtab $ "
602 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
603 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
604 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
605 "olcTLSRandFile $ olcTLSVerifyClient ) )", Cft_Global, &cfOc_global },
607 "NAME 'olcSchemaConfig' "
608 "DESC 'OpenLDAP schema object' "
609 "SUP olcConfig STRUCTURAL "
610 "MAY ( olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
611 "olcDitContentRules ) )", Cft_Schema, &cfOc_schema },
613 "NAME 'olcBackendConfig' "
614 "DESC 'OpenLDAP Backend-specific options' "
615 "SUP olcConfig STRUCTURAL "
616 "MAY ( olcBackend ) )", Cft_Backend, &cfOc_backend },
618 "NAME 'olcDatabaseConfig' "
619 "DESC 'OpenLDAP Database-specific options' "
620 "SUP olcConfig STRUCTURAL "
621 "MAY ( olcDatabase $ olcAccess $ olcLastMod $ olcLimits $ "
622 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
623 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
624 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSuffix $ olcSyncrepl $ "
625 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )",
626 Cft_Database, &cfOc_database },
628 "NAME 'olcOverlayConfig' "
629 "DESC 'OpenLDAP Overlay-specific options' "
630 "SUP olcConfig STRUCTURAL "
631 "MAY ( olcOverlay ) )", Cft_Overlay, &cfOc_overlay },
633 "NAME 'olcIncludeFile' "
634 "DESC 'OpenLDAP configuration include file' "
635 "SUP olcConfig STRUCTURAL "
636 "MAY ( olcInclude $ olcRootDSE ) )",
637 Cft_Include, &cfOc_include },
640 "NAME 'olcModuleList' "
641 "DESC 'OpenLDAP dynamic module info' "
642 "SUP olcConfig STRUCTURAL "
643 "MUST olcModuleLoad )",
644 Cft_Module, &cfOc_module },
650 config_generic(ConfigArgs *c) {
654 if ( c->op == SLAP_CONFIG_EMIT ) {
658 c->value_int = ldap_pvt_thread_get_concurrency();
661 c->value_int = connection_pool_max;
665 c->value_string = ch_strdup( passwd_salt );
670 if ( c->be->be_limits ) {
675 for ( i=0; c->be->be_limits[i]; i++ ) {
676 bv.bv_len = sprintf( buf, "{%d}", i );
677 bv.bv_val = buf+bv.bv_len;
678 limits_unparse( c->be->be_limits[i], &bv );
679 bv.bv_len += bv.bv_val - buf;
681 value_add_one( &c->rvalue_vals, &bv );
684 if ( !c->rvalue_vals ) rc = 1;
687 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_OP_WRITES) != 0;
690 c->value_string = ch_strdup( slap_sasl_getpolicy());
693 slap_sasl_regexp_unparse( &c->rvalue_vals );
694 if ( !c->rvalue_vals ) rc = 1;
696 #ifdef HAVE_CYRUS_SASL
698 struct berval bv = BER_BVNULL;
699 slap_sasl_secprops_unparse( &bv );
700 if ( !BER_BVISNULL( &bv )) {
701 ber_bvarray_add( &c->rvalue_vals, &bv );
709 c->value_int = c->be->be_max_deref_depth;
712 ConfigFile *cf = c->private;
714 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
715 else if ( cf->c_om_head )
716 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
718 if ( !c->rvalue_vals )
723 ConfigFile *cf = c->private;
725 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
726 else if ( cf->c_oc_head )
727 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
729 if ( !c->rvalue_vals )
734 ConfigFile *cf = c->private;
736 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
737 else if ( cf->c_at_head )
738 at_unparse( &c->rvalue_vals, cf->c_at_head,
740 if ( !c->rvalue_vals )
745 ConfigFile *cf = c->private;
747 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
748 else if ( cf->c_cr_head )
749 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
751 if ( !c->rvalue_vals )
757 c->value_int = global_schemacheck;
761 char *src, *dst, ibuf[11];
762 struct berval bv, abv;
763 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
764 abv.bv_len = sprintf( ibuf, "{%x}", i );
765 acl_unparse( a, &bv );
766 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
767 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
768 /* Turn TAB / EOL into plain space */
769 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
770 if (isspace(*src)) *dst++ = ' ';
774 if (dst[-1] == ' ') {
778 abv.bv_len = dst - abv.bv_val;
779 ber_bvarray_add( &c->rvalue_vals, &abv );
785 if ( c->be->be_replogfile )
786 c->value_string = ch_strdup( c->be->be_replogfile );
789 ConfigFile *cf = c->private;
790 if ( cf->c_dseFiles ) {
791 value_add( &c->rvalue_vals, cf->c_dseFiles );
799 c->value_string = ch_strdup( logfileName );
804 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
806 case CFG_SSTR_IF_MAX:
807 c->value_int = index_substr_if_maxlen;
809 case CFG_SSTR_IF_MIN:
810 c->value_int = index_substr_if_minlen;
814 ModPaths *mp = c->private;
817 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
820 bv.bv_len = sprintf( bv.bv_val, "{%d}%s", i,
821 mp->mp_loads[i].bv_val );
822 value_add_one( &c->rvalue_vals, &bv );
826 rc = c->rvalue_vals ? 0 : 1;
831 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
833 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
836 bv.bv_len = sprintf( bv.bv_val, "{%d}%s", i,
837 mp->mp_path.bv_val );
838 value_add_one( &c->rvalue_vals, &bv );
840 rc = c->rvalue_vals ? 0 : 1;
846 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
847 if ( !c->rvalue_vals ) rc = 1;
850 #ifdef SLAP_AUTH_REWRITE
852 if ( authz_rewrites ) {
853 struct berval bv, idx;
858 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
859 idx.bv_len = sprintf( idx.bv_val, "{%d}", i );
860 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
861 bv.bv_val = ch_malloc( bv.bv_len + 1 );
862 strcpy( bv.bv_val, idx.bv_val );
863 strcpy( bv.bv_val+idx.bv_len, authz_rewrites[i].bv_val );
864 ber_bvarray_add( &c->rvalue_vals, &bv );
867 if ( !c->rvalue_vals ) rc = 1;
876 p = strchr(c->line,'(' /*')'*/);
879 if(!(c->bi = backend_info(c->argv[1]))) {
880 Debug(LDAP_DEBUG_ANY, "%s: "
881 "backend %s failed init!\n", c->log, c->argv[1], 0);
888 /* NOTE: config is always the first backend!
890 if ( !strcasecmp( c->argv[1], "config" )) {
892 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
894 } else if(!(c->be = backend_db_init(c->argv[1]))) {
895 Debug(LDAP_DEBUG_ANY, "%s: "
896 "database %s failed init!\n", c->log, c->argv[1], 0);
902 ldap_pvt_thread_set_concurrency(c->value_int);
906 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
907 connection_pool_max = c->value_int; /* save for reference */
911 if ( passwd_salt ) ch_free( passwd_salt );
912 passwd_salt = c->value_string;
913 lutil_salt_format(passwd_salt);
917 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
923 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
925 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
929 ch_free(c->value_string);
930 if (slap_sasl_setpolicy( c->argv[1] )) {
931 Debug(LDAP_DEBUG_ANY, "%s: unable to parse value \"%s\" in"
932 " \"authz-policy <policy>\"\n",
933 c->log, c->argv[1], 0 );
939 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
943 #ifdef HAVE_CYRUS_SASL
946 char *txt = slap_sasl_secprops( c->argv[1] );
948 Debug(LDAP_DEBUG_ANY, "%s: sasl-secprops: %s\n",
957 c->be->be_max_deref_depth = c->value_int;
963 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv, 1, &om))
965 if (!cfn->c_om_head) cfn->c_om_head = om;
973 if(parse_oc(c->fname, c->lineno, p, c->argv, &oc)) return(1);
974 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
982 if(parse_cr(c->fname, c->lineno, p, c->argv, &cr)) return(1);
983 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
991 if(parse_at(c->fname, c->lineno, p, c->argv, &at)) return(1);
992 if (!cfn->c_at_head) cfn->c_at_head = at;
998 ad_define_option(NULL, NULL, 0);
999 for(i = 1; i < c->argc; i++)
1000 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1005 global_schemacheck = c->value_int;
1006 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: "
1007 "schema checking disabled! your mileage may vary!\n",
1012 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
1016 if(SLAP_MONITOR(c->be)) {
1017 Debug(LDAP_DEBUG_ANY, "%s: "
1018 "\"replogfile\" should not be used "
1019 "inside monitor database\n",
1021 return(0); /* FIXME: should this be an error? */
1024 c->be->be_replogfile = c->value_string;
1028 if(read_root_dse_file(c->argv[1])) {
1029 Debug(LDAP_DEBUG_ANY, "%s: "
1030 "could not read \"rootDSE <filename>\" line\n",
1036 ber_str2bv( c->argv[1], 0, 1, &bv );
1037 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1043 if ( logfileName ) ch_free( logfileName );
1044 logfileName = c->value_string;
1045 logfile = fopen(logfileName, "w");
1046 if(logfile) lutil_debug_file(logfile);
1050 if(SLAP_NOLASTMODCMD(c->be)) {
1051 Debug(LDAP_DEBUG_ANY, "%s: "
1052 "lastmod not available for %s databases\n",
1053 c->log, c->be->bd_info->bi_type, 0);
1057 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
1059 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
1062 case CFG_SSTR_IF_MAX:
1063 if (c->value_int < index_substr_if_minlen) {
1064 Debug(LDAP_DEBUG_ANY, "%s: "
1065 "invalid max value (%d)\n",
1066 c->log, c->value_int, 0 );
1069 index_substr_if_maxlen = c->value_int;
1072 case CFG_SSTR_IF_MIN:
1073 if (c->value_int > index_substr_if_maxlen) {
1074 Debug(LDAP_DEBUG_ANY, "%s: "
1075 "invalid min value (%d)\n",
1076 c->log, c->value_int, 0 );
1079 index_substr_if_minlen = c->value_int;
1082 #ifdef SLAPD_MODULES
1084 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
1086 /* Record this load on the current path */
1089 ber_str2bv(c->line, 0, 1, &bv);
1090 ber_bvarray_add( &modcur->mp_loads, &bv );
1095 if(module_path(c->argv[1])) return(1);
1096 /* Record which path was used with each module */
1100 if (!modpaths.mp_loads) {
1103 mp = ch_malloc( sizeof( ModPaths ));
1104 modlast->mp_next = mp;
1106 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
1108 mp->mp_loads = NULL;
1110 if ( c->op == SLAP_CONFIG_ADD )
1119 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
1121 slapi_plugins_used++;
1125 #ifdef SLAP_AUTH_REWRITE
1128 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
1130 ber_str2bv( c->line, 0, 1, &bv );
1131 ber_bvarray_add( &authz_rewrites, &bv );
1138 Debug(LDAP_DEBUG_ANY, "%s: unknown CFG_TYPE %d"
1139 "(ignored)\n", c->log, c->type, 0);
1147 config_fname(ConfigArgs *c) {
1148 if(c->op == SLAP_CONFIG_EMIT) {
1150 ConfigFile *cf = c->private;
1151 value_add_one( &c->rvalue_vals, &cf->c_file );
1160 config_cfdir(ConfigArgs *c) {
1161 if(c->op == SLAP_CONFIG_EMIT) {
1162 value_add_one( &c->rvalue_vals, &cfdir );
1169 config_search_base(ConfigArgs *c) {
1172 if(c->op == SLAP_CONFIG_EMIT) {
1174 if (!BER_BVISEMPTY(&default_search_base)) {
1175 value_add_one(&c->rvalue_vals, &default_search_base);
1176 value_add_one(&c->rvalue_nvals, &default_search_nbase);
1182 if(c->bi || c->be != frontendDB) {
1183 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
1184 "prior to any backend or database definition\n",
1189 if(default_search_nbase.bv_len) {
1190 Debug(LDAP_DEBUG_ANY, "%s: "
1191 "default search base \"%s\" already defined "
1192 "(discarding old)\n",
1193 c->log, default_search_base.bv_val, 0);
1194 free(default_search_base.bv_val);
1195 free(default_search_nbase.bv_val);
1198 default_search_base = c->value_dn;
1199 default_search_nbase = c->value_ndn;
1204 config_passwd_hash(ConfigArgs *c) {
1206 if (c->op == SLAP_CONFIG_EMIT) {
1208 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
1209 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
1210 value_add_one(&c->rvalue_vals, &bv);
1214 if(default_passwd_hash) {
1215 Debug(LDAP_DEBUG_ANY, "%s: "
1216 "already set default password_hash\n",
1220 for(i = 1; i < c->argc; i++) {
1221 if(!lutil_passwd_scheme(c->argv[i])) {
1222 Debug(LDAP_DEBUG_ANY, "%s: "
1223 "password scheme \"%s\" not available\n",
1224 c->log, c->argv[i], 0);
1226 ldap_charray_add(&default_passwd_hash, c->argv[i]);
1228 if(!default_passwd_hash) {
1229 Debug(LDAP_DEBUG_ANY, "%s: no valid hashes found\n",
1238 config_schema_dn(ConfigArgs *c) {
1239 if ( c->op == SLAP_CONFIG_EMIT ) {
1241 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
1242 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
1243 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
1248 c->be->be_schemadn = c->value_dn;
1249 c->be->be_schemandn = c->value_ndn;
1254 config_sizelimit(ConfigArgs *c) {
1257 struct slap_limits_set *lim = &c->be->be_def_limit;
1258 if (c->op == SLAP_CONFIG_EMIT) {
1263 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv );
1264 if ( !BER_BVISEMPTY( &bv ))
1265 value_add_one( &c->rvalue_vals, &bv );
1270 for(i = 1; i < c->argc; i++) {
1271 if(!strncasecmp(c->argv[i], "size", 4)) {
1272 rc = limits_parse_one(c->argv[i], lim);
1274 Debug(LDAP_DEBUG_ANY, "%s: "
1275 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
1276 c->log, c->argv[i], 0);
1280 if(!strcasecmp(c->argv[i], "unlimited")) {
1281 lim->lms_s_soft = -1;
1283 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
1284 if(next == c->argv[i]) {
1285 Debug(LDAP_DEBUG_ANY, "%s: "
1286 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
1287 c->log, c->argv[i], 0);
1289 } else if(next[0] != '\0') {
1290 Debug(LDAP_DEBUG_ANY, "%s: "
1291 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
1295 lim->lms_s_hard = 0;
1302 config_timelimit(ConfigArgs *c) {
1305 struct slap_limits_set *lim = &c->be->be_def_limit;
1306 if (c->op == SLAP_CONFIG_EMIT) {
1311 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv );
1312 if ( !BER_BVISEMPTY( &bv ))
1313 value_add_one( &c->rvalue_vals, &bv );
1318 for(i = 1; i < c->argc; i++) {
1319 if(!strncasecmp(c->argv[i], "time", 4)) {
1320 rc = limits_parse_one(c->argv[i], lim);
1322 Debug(LDAP_DEBUG_ANY, "%s: "
1323 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
1324 c->log, c->argv[i], 0);
1328 if(!strcasecmp(c->argv[i], "unlimited")) {
1329 lim->lms_t_soft = -1;
1331 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
1332 if(next == c->argv[i]) {
1333 Debug(LDAP_DEBUG_ANY, "%s: "
1334 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
1335 c->log, c->argv[i], 0);
1337 } else if(next[0] != '\0') {
1338 Debug(LDAP_DEBUG_ANY, "%s: "
1339 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
1343 lim->lms_t_hard = 0;
1350 config_overlay(ConfigArgs *c) {
1351 if (c->op == SLAP_CONFIG_EMIT) {
1354 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
1356 Debug(LDAP_DEBUG_ANY, "%s: (optional) %s overlay \"%s\" configuration failed (ignored)\n",
1357 c->log, c->be == frontendDB ? "global " : "", c->argv[1][1]);
1358 } else if(overlay_config(c->be, c->argv[1])) {
1365 config_suffix(ConfigArgs *c) {
1367 struct berval pdn, ndn;
1370 if (c->be == frontendDB) return 1;
1372 if (c->op == SLAP_CONFIG_EMIT) {
1373 if (!BER_BVISNULL( &c->be->be_suffix[0] )) {
1374 value_add( &c->rvalue_vals, c->be->be_suffix );
1375 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
1381 #ifdef SLAPD_MONITOR_DN
1382 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
1383 Debug(LDAP_DEBUG_ANY, "%s: "
1384 "\"%s\" is reserved for monitoring slapd\n",
1385 c->log, SLAPD_MONITOR_DN, 0);
1392 tbe = select_backend(&ndn, 0, 0);
1394 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by this backend! (ignored)\n",
1399 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by a preceding backend \"%s\"\n",
1400 c->log, tbe->be_suffix[0].bv_val, 0);
1404 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
1405 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
1406 "base provided \"%s\" (assuming okay)\n",
1407 c->log, default_search_base.bv_val, 0);
1409 ber_bvarray_add(&c->be->be_suffix, &pdn);
1410 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
1415 config_rootdn(ConfigArgs *c) {
1416 if (c->op == SLAP_CONFIG_EMIT) {
1417 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
1418 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
1419 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
1425 c->be->be_rootdn = c->value_dn;
1426 c->be->be_rootndn = c->value_ndn;
1431 config_rootpw(ConfigArgs *c) {
1433 if (c->op == SLAP_CONFIG_EMIT) {
1434 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
1435 ber_dupbv( &c->value_bv, &c->be->be_rootpw);
1441 tbe = select_backend(&c->be->be_rootndn, 0, 0);
1443 Debug(LDAP_DEBUG_ANY, "%s: "
1444 "rootpw can only be set when rootdn is under suffix\n",
1448 c->be->be_rootpw = c->value_bv;
1453 config_restrict(ConfigArgs *c) {
1454 slap_mask_t restrictops = 0;
1456 slap_verbmasks restrictable_ops[] = {
1457 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
1458 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
1459 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
1460 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
1461 { BER_BVC("modrdn"), 0 },
1462 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
1463 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
1464 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
1465 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
1466 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
1467 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
1468 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
1469 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
1470 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
1471 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
1475 if (c->op == SLAP_CONFIG_EMIT) {
1476 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
1479 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
1481 Debug(LDAP_DEBUG_ANY, "%s: "
1482 "unknown operation %s in \"restrict <features>\" line\n",
1483 c->log, c->argv[i], 0);
1486 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
1487 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
1488 c->be->be_restrictops |= restrictops;
1493 config_allows(ConfigArgs *c) {
1494 slap_mask_t allows = 0;
1496 slap_verbmasks allowable_ops[] = {
1497 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
1498 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
1499 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
1500 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
1503 if (c->op == SLAP_CONFIG_EMIT) {
1504 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
1506 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
1508 Debug(LDAP_DEBUG_ANY, "%s: "
1509 "unknown feature %s in \"allow <features>\" line\n",
1510 c->log, c->argv[i], 0);
1513 global_allows |= allows;
1518 config_disallows(ConfigArgs *c) {
1519 slap_mask_t disallows = 0;
1521 slap_verbmasks disallowable_ops[] = {
1522 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
1523 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
1524 { BER_BVC("bind_krb4"), SLAP_DISALLOW_BIND_KRBV4 },
1525 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
1526 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
1529 if (c->op == SLAP_CONFIG_EMIT) {
1530 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
1532 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
1534 Debug(LDAP_DEBUG_ANY, "%s: "
1535 "unknown feature %s in \"disallow <features>\" line\n",
1536 c->log, c->argv[i], 0);
1539 global_disallows |= disallows;
1544 config_requires(ConfigArgs *c) {
1545 slap_mask_t requires = 0;
1547 slap_verbmasks requires_ops[] = {
1548 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
1549 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
1550 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
1551 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
1552 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
1555 if (c->op == SLAP_CONFIG_EMIT) {
1556 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
1558 i = verbs_to_mask(c->argc, c->argv, requires_ops, &requires);
1560 Debug(LDAP_DEBUG_ANY, "%s: "
1561 "unknown feature %s in \"require <features>\" line\n",
1562 c->log, c->argv[i], 0);
1565 c->be->be_requires = requires;
1570 config_loglevel(ConfigArgs *c) {
1573 slap_verbmasks loglevel_ops[] = {
1574 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
1575 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
1576 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
1577 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
1578 { BER_BVC("BER"), LDAP_DEBUG_BER },
1579 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
1580 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
1581 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
1582 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
1583 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
1584 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
1585 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
1586 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
1587 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
1588 { BER_BVC("Any"), -1 },
1592 if (c->op == SLAP_CONFIG_EMIT) {
1593 return mask_to_verbs( loglevel_ops, ldap_syslog, &c->rvalue_vals );
1598 for( i=1; i < c->argc; i++ ) {
1601 if ( isdigit( c->argv[i][0] ) ) {
1602 level = strtol( c->argv[i], &next, 10 );
1603 if ( next == NULL || next[0] != '\0' ) {
1604 Debug( LDAP_DEBUG_ANY,
1605 "%s: unable to parse level \"%s\" "
1606 "in \"loglevel <level> [...]\" line.\n",
1607 c->log, c->argv[i], 0);
1611 int j = verb_to_mask(c->argv[i], loglevel_ops);
1612 if(BER_BVISNULL(&loglevel_ops[j].word)) {
1613 Debug( LDAP_DEBUG_ANY,
1614 "%s: unknown level \"%s\" "
1615 "in \"loglevel <level> [...]\" line.\n",
1616 c->log, c->argv[i], 0);
1619 level = loglevel_ops[j].mask;
1621 ldap_syslog |= level;
1627 config_syncrepl(ConfigArgs *c) {
1628 if (c->op == SLAP_CONFIG_EMIT) {
1629 if ( c->be->be_syncinfo ) {
1631 syncrepl_unparse( c->be->be_syncinfo, &bv );
1632 ber_bvarray_add( &c->rvalue_vals, &bv );
1637 if(SLAP_SHADOW(c->be)) {
1638 Debug(LDAP_DEBUG_ANY, "%s: "
1639 "syncrepl: database already shadowed.\n",
1642 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1645 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1650 config_referral(ConfigArgs *c) {
1651 struct berval vals[2];
1652 if (c->op == SLAP_CONFIG_EMIT) {
1653 if ( default_referral ) {
1654 value_add( &c->rvalue_vals, default_referral );
1660 if(validate_global_referral(c->argv[1])) {
1661 Debug(LDAP_DEBUG_ANY, "%s: "
1662 "invalid URL (%s) in \"referral\" line.\n",
1663 c->log, c->argv[1], 0);
1667 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1668 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1669 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1677 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
1678 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
1679 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
1680 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
1681 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
1682 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
1683 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
1684 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
1685 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
1690 config_security(ConfigArgs *c) {
1691 slap_ssf_set_t *set = &c->be->be_ssf_set;
1694 if (c->op == SLAP_CONFIG_EMIT) {
1700 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
1701 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
1704 bv.bv_len = sprintf( numbuf, "%u", *tgt );
1705 bv.bv_len += sec_keys[i].key.bv_len;
1706 bv.bv_val = ch_malloc( bv.bv_len + 1);
1707 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
1708 strcpy( next, numbuf );
1709 ber_bvarray_add( &c->rvalue_vals, &bv );
1714 for(i = 1; i < c->argc; i++) {
1715 slap_ssf_t *tgt = NULL;
1717 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
1718 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
1719 sec_keys[j].key.bv_len)) {
1720 src = c->argv[i] + sec_keys[j].key.bv_len;
1721 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
1726 Debug(LDAP_DEBUG_ANY, "%s: "
1727 "unknown factor %s in \"security <factors>\" line\n",
1728 c->log, c->argv[i], 0);
1732 *tgt = strtol(src, &next, 10);
1733 if(next == NULL || next[0] != '\0' ) {
1734 Debug(LDAP_DEBUG_ANY, "%s: "
1735 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1736 c->log, c->argv[i], 0);
1744 anlist_unparse( AttributeName *an, char *ptr ) {
1747 for (; !BER_BVISNULL( &an->an_name ); an++) {
1748 if ( comma ) *ptr++ = ',';
1749 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
1756 replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
1760 struct berval bc = {0};
1763 len = sprintf(numbuf, "{%d}", i );
1765 len += strlen( ri->ri_uri ) + STRLENOF("uri=");
1766 if ( ri->ri_nsuffix ) {
1767 for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
1768 len += ri->ri_nsuffix[i].bv_len + STRLENOF(" suffix=\"\"");
1771 if ( ri->ri_attrs ) {
1772 len += STRLENOF("attr");
1773 if ( ri->ri_exclude ) len++;
1774 for (i=0; !BER_BVISNULL( &ri->ri_attrs[i].an_name ); i++) {
1775 len += 1 + ri->ri_attrs[i].an_name.bv_len;
1778 bindconf_unparse( &ri->ri_bindconf, &bc );
1781 bv->bv_val = ch_malloc(len + 1);
1784 ptr = lutil_strcopy( bv->bv_val, numbuf );
1785 ptr = lutil_strcopy( ptr, "uri=" );
1786 ptr = lutil_strcopy( ptr, ri->ri_uri );
1788 if ( ri->ri_nsuffix ) {
1789 for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
1790 ptr = lutil_strcopy( ptr, " suffix=\"" );
1791 ptr = lutil_strcopy( ptr, ri->ri_nsuffix[i].bv_val );
1795 if ( ri->ri_attrs ) {
1796 ptr = lutil_strcopy( ptr, "attr" );
1797 if ( ri->ri_exclude ) *ptr++ = '!';
1799 ptr = anlist_unparse( ri->ri_attrs, ptr );
1802 strcpy( ptr, bc.bv_val );
1803 ch_free( bc.bv_val );
1808 config_replica(ConfigArgs *c) {
1809 int i, nr = -1, len;
1810 char *replicahost, *replicauri;
1813 if (c->op == SLAP_CONFIG_EMIT) {
1814 if (c->be->be_replica) {
1816 for (i=0;c->be->be_replica[i]; i++) {
1817 replica_unparse( c->be->be_replica[i], i, &bv );
1818 ber_bvarray_add( &c->rvalue_vals, &bv );
1824 if(SLAP_MONITOR(c->be)) {
1825 Debug(LDAP_DEBUG_ANY, "%s: "
1826 "\"replica\" should not be used inside monitor database\n",
1828 return(0); /* FIXME: should this be an error? */
1831 for(i = 1; i < c->argc; i++) {
1832 if(!strncasecmp(c->argv[i], "host=", STRLENOF("host="))) {
1833 replicahost = c->argv[i] + STRLENOF("host=");
1834 len = strlen( replicahost );
1835 replicauri = ch_malloc( len + STRLENOF("ldap://") + 1 );
1836 sprintf( replicauri, "ldap://%s", replicahost );
1837 replicahost = replicauri + STRLENOF( "ldap://");
1838 nr = add_replica_info(c->be, replicauri, replicahost);
1840 } else if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) {
1841 if(ldap_url_parse(c->argv[i] + STRLENOF("uri="), &ludp) != LDAP_SUCCESS) {
1842 Debug(LDAP_DEBUG_ANY, "%s: "
1843 "replica line contains invalid "
1844 "uri definition.\n", c->log, 0, 0);
1847 if(!ludp->lud_host) {
1848 Debug(LDAP_DEBUG_ANY, "%s: "
1849 "replica line contains invalid "
1850 "uri definition - missing hostname.\n",
1854 ldap_free_urldesc(ludp);
1855 replicauri = c->argv[i] + STRLENOF("uri=");
1856 replicauri = ch_strdup( replicauri );
1857 replicahost = strchr( replicauri, '/' );
1859 nr = add_replica_info(c->be, replicauri, replicahost);
1864 Debug(LDAP_DEBUG_ANY, "%s: "
1865 "missing host or uri in \"replica\" line\n",
1868 } else if(nr == -1) {
1869 Debug(LDAP_DEBUG_ANY, "%s: "
1870 "unable to add replica \"%s\"\n",
1871 c->log, replicauri, 0);
1874 for(i = 1; i < c->argc; i++) {
1875 if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
1876 switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) {
1878 Debug(LDAP_DEBUG_ANY, "%s: "
1879 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1880 c->log, c->argv[i] + STRLENOF("suffix="), 0);
1883 Debug(LDAP_DEBUG_ANY, "%s: "
1884 "unable to normalize suffix in \"replica\" line (ignored)\n",
1889 } else if(!strncasecmp(c->argv[i], "attr", STRLENOF("attr"))) {
1891 char *arg = c->argv[i] + STRLENOF("attr");
1899 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1900 Debug(LDAP_DEBUG_ANY, "%s: "
1901 "attribute \"%s\" in \"replica\" line is unknown\n",
1902 c->log, arg + 1, 0);
1905 } else if ( bindconf_parse( c->argv[i],
1906 &c->be->be_replica[nr]->ri_bindconf ) ) {
1915 config_updatedn(ConfigArgs *c) {
1918 if (c->op == SLAP_CONFIG_EMIT) {
1919 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
1920 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
1921 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
1926 if(SLAP_SHADOW(c->be)) {
1927 Debug(LDAP_DEBUG_ANY, "%s: "
1928 "updatedn: database already shadowed.\n",
1933 ber_str2bv(c->argv[1], 0, 0, &dn);
1935 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1937 if(rc != LDAP_SUCCESS) {
1938 Debug(LDAP_DEBUG_ANY, "%s: "
1939 "updatedn DN is invalid: %d (%s)\n",
1940 c->log, rc, ldap_err2string( rc ));
1944 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1949 config_updateref(ConfigArgs *c) {
1950 struct berval vals[2];
1951 if (c->op == SLAP_CONFIG_EMIT) {
1952 if ( c->be->be_update_refs ) {
1953 value_add( &c->rvalue_vals, c->be->be_update_refs );
1959 if(!SLAP_SHADOW(c->be)) {
1960 Debug(LDAP_DEBUG_ANY, "%s: "
1961 "updateref line must come after syncrepl or updatedn.\n",
1966 if(validate_global_referral(c->argv[1])) {
1967 Debug(LDAP_DEBUG_ANY, "%s: "
1968 "invalid URL (%s) in \"updateref\" line.\n",
1969 c->log, c->argv[1], 0);
1972 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1973 vals[1].bv_val = NULL;
1974 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1979 config_include(ConfigArgs *c) {
1980 unsigned long savelineno = c->lineno;
1983 ConfigFile *cfsave = cfn;
1984 ConfigFile *cf2 = NULL;
1985 if (c->op == SLAP_CONFIG_EMIT) {
1988 cf = ch_calloc( 1, sizeof(ConfigFile));
1989 if ( cfn->c_kids ) {
1990 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
1996 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
1997 rc = read_config_file(c->argv[1], c->depth + 1, c);
1998 c->lineno = savelineno - 1;
2001 if ( cf2 ) cf2->c_sibs = NULL;
2002 else cfn->c_kids = NULL;
2003 ch_free( cf->c_file.bv_val );
2011 config_tls_option(ConfigArgs *c) {
2014 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
2015 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
2016 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
2017 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
2018 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
2019 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
2020 default: Debug(LDAP_DEBUG_ANY, "%s: "
2021 "unknown tls_option <%x>\n",
2022 c->log, c->type, 0);
2024 if (c->op == SLAP_CONFIG_EMIT) {
2025 return ldap_pvt_tls_get_option( NULL, flag, &c->value_string );
2027 ch_free(c->value_string);
2028 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
2031 /* FIXME: this ought to be provided by libldap */
2033 config_tls_config(ConfigArgs *c) {
2035 slap_verbmasks crlkeys[] = {
2036 { BER_BVC("none"), LDAP_OPT_X_TLS_CRL_NONE },
2037 { BER_BVC("peer"), LDAP_OPT_X_TLS_CRL_PEER },
2038 { BER_BVC("all"), LDAP_OPT_X_TLS_CRL_ALL },
2041 slap_verbmasks vfykeys[] = {
2042 { BER_BVC("never"), LDAP_OPT_X_TLS_NEVER },
2043 { BER_BVC("demand"), LDAP_OPT_X_TLS_DEMAND },
2044 { BER_BVC("try"), LDAP_OPT_X_TLS_TRY },
2045 { BER_BVC("hard"), LDAP_OPT_X_TLS_HARD },
2049 #ifdef HAVE_OPENSSL_CRL
2050 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; keys = crlkeys;
2053 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; keys = vfykeys;
2055 default: Debug(LDAP_DEBUG_ANY, "%s: "
2056 "unknown tls_option <%x>\n",
2057 c->log, c->type, 0);
2059 if (c->op == SLAP_CONFIG_EMIT) {
2060 ldap_pvt_tls_get_option( NULL, flag, &c->value_int );
2061 for (i=0; !BER_BVISNULL(&keys[i].word); i++) {
2062 if (keys[i].mask == c->value_int) {
2063 c->value_string = ch_strdup( keys[i].word.bv_val );
2069 ch_free( c->value_string );
2070 if(isdigit((unsigned char)c->argv[1][0])) {
2071 i = atoi(c->argv[1]);
2072 return(ldap_pvt_tls_set_option(NULL, flag, &i));
2074 return(ldap_int_tls_config(NULL, flag, c->argv[1]));
2089 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2092 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2096 si->si_bindconf.sb_tls = SB_TLS_OFF;
2097 si->si_bindconf.sb_method = LDAP_AUTH_SIMPLE;
2098 si->si_schemachecking = 0;
2099 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
2100 &si->si_filterstr );
2101 si->si_base.bv_val = NULL;
2102 si->si_scope = LDAP_SCOPE_SUBTREE;
2103 si->si_attrsonly = 0;
2104 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
2105 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
2106 si->si_attrs = NULL;
2107 si->si_allattrs = 0;
2108 si->si_allopattrs = 0;
2109 si->si_exattrs = NULL;
2110 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2111 si->si_interval = 86400;
2112 si->si_retryinterval = NULL;
2113 si->si_retrynum_init = NULL;
2114 si->si_retrynum = NULL;
2115 si->si_manageDSAit = 0;
2119 si->si_presentlist = NULL;
2120 LDAP_LIST_INIT( &si->si_nonpresentlist );
2121 ldap_pvt_thread_mutex_init( &si->si_mutex );
2123 rc = parse_syncrepl_line( cargv, cargc, si );
2126 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2127 syncinfo_free( si );
2130 Debug( LDAP_DEBUG_CONFIG,
2131 "Config: ** successfully added syncrepl \"%s\"\n",
2132 BER_BVISNULL( &si->si_provideruri ) ?
2133 "(null)" : si->si_provideruri.bv_val, 0, 0 );
2134 if ( !si->si_schemachecking ) {
2135 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2138 be->be_syncinfo = si;
2143 /* NOTE: used & documented in slapd.conf(5) */
2145 #define PROVIDERSTR "provider"
2146 #define TYPESTR "type"
2147 #define INTERVALSTR "interval"
2148 #define SEARCHBASESTR "searchbase"
2149 #define FILTERSTR "filter"
2150 #define SCOPESTR "scope"
2151 #define ATTRSSTR "attrs"
2152 #define ATTRSONLYSTR "attrsonly"
2153 #define SLIMITSTR "sizelimit"
2154 #define TLIMITSTR "timelimit"
2155 #define SCHEMASTR "schemachecking"
2157 /* FIXME: undocumented */
2158 #define OLDAUTHCSTR "bindprincipal"
2159 #define EXATTRSSTR "exattrs"
2160 #define RETRYSTR "retry"
2163 #define LASTMODSTR "lastmod"
2164 #define LMGENSTR "gen"
2165 #define LMNOSTR "no"
2166 #define LMREQSTR "req"
2167 #define SRVTABSTR "srvtab"
2168 #define SUFFIXSTR "suffix"
2169 #define MANAGEDSAITSTR "manageDSAit"
2172 #define GOT_ID 0x0001
2173 #define GOT_PROVIDER 0x0002
2176 #define GOT_ALL (GOT_ID|GOT_PROVIDER)
2182 { BER_BVC("base"), LDAP_SCOPE_BASE },
2183 { BER_BVC("one"), LDAP_SCOPE_ONELEVEL },
2184 #ifdef LDAP_SCOPE_SUBORDINATE
2185 { BER_BVC("children"), LDAP_SCOPE_SUBORDINATE },
2186 { BER_BVC("subordinate"), 0 },
2188 { BER_BVC("sub"), LDAP_SCOPE_SUBTREE },
2193 parse_syncrepl_line(
2203 for ( i = 1; i < cargc; i++ ) {
2204 if ( !strncasecmp( cargv[ i ], IDSTR "=",
2205 STRLENOF( IDSTR "=" ) ) )
2208 /* '\0' string terminator accounts for '=' */
2209 val = cargv[ i ] + STRLENOF( IDSTR "=" );
2211 if ( tmp >= 1000 || tmp < 0 ) {
2212 fprintf( stderr, "Error: parse_syncrepl_line: "
2213 "syncrepl id %d is out of range [0..999]\n", tmp );
2218 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
2219 STRLENOF( PROVIDERSTR "=" ) ) )
2221 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
2222 ber_str2bv( val, 0, 1, &si->si_provideruri );
2223 gots |= GOT_PROVIDER;
2224 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
2225 STRLENOF( SCHEMASTR "=" ) ) )
2227 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
2228 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
2229 si->si_schemachecking = 1;
2230 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
2231 si->si_schemachecking = 0;
2233 si->si_schemachecking = 1;
2235 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
2236 STRLENOF( FILTERSTR "=" ) ) )
2238 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
2239 ber_str2bv( val, 0, 1, &si->si_filterstr );
2240 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
2241 STRLENOF( SEARCHBASESTR "=" ) ) )
2246 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
2247 if ( si->si_base.bv_val ) {
2248 ch_free( si->si_base.bv_val );
2250 ber_str2bv( val, 0, 0, &bv );
2251 rc = dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL );
2252 if ( rc != LDAP_SUCCESS ) {
2253 fprintf( stderr, "Invalid base DN \"%s\": %d (%s)\n",
2254 val, rc, ldap_err2string( rc ) );
2257 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
2258 STRLENOF( SCOPESTR "=" ) ) )
2261 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
2262 for ( j=0; !BER_BVISNULL(&scopes[j].key); j++ ) {
2263 if (!strncasecmp( val, scopes[j].key.bv_val,
2264 scopes[j].key.bv_len )) {
2265 while (!scopes[j].val) j--;
2266 si->si_scope = scopes[j].val;
2270 if ( BER_BVISNULL(&scopes[j].key) ) {
2271 fprintf( stderr, "Error: parse_syncrepl_line: "
2272 "unknown scope \"%s\"\n", val);
2275 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
2276 STRLENOF( ATTRSONLYSTR "=" ) ) )
2278 si->si_attrsonly = 1;
2279 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
2280 STRLENOF( ATTRSSTR "=" ) ) )
2282 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
2283 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
2285 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2286 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
2287 if ( si->si_anlist == NULL ) {
2288 ch_free( attr_fname );
2291 si->si_anfile = attr_fname;
2293 char *str, *s, *next;
2294 char delimstr[] = " ,\t";
2295 str = ch_strdup( val );
2296 for ( s = ldap_pvt_strtok( str, delimstr, &next );
2298 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
2300 if ( strlen(s) == 1 && *s == '*' ) {
2301 si->si_allattrs = 1;
2302 *(val + ( s - str )) = delimstr[0];
2304 if ( strlen(s) == 1 && *s == '+' ) {
2305 si->si_allopattrs = 1;
2306 *(val + ( s - str )) = delimstr[0];
2310 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
2311 if ( si->si_anlist == NULL ) {
2315 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
2316 STRLENOF( EXATTRSSTR "=" ) ) )
2318 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
2319 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
2321 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2322 si->si_exanlist = file2anlist(
2323 si->si_exanlist, attr_fname, " ,\t" );
2324 if ( si->si_exanlist == NULL ) {
2325 ch_free( attr_fname );
2328 ch_free( attr_fname );
2330 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
2331 if ( si->si_exanlist == NULL ) {
2335 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
2336 STRLENOF( TYPESTR "=" ) ) )
2338 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
2339 if ( !strncasecmp( val, "refreshOnly",
2340 STRLENOF("refreshOnly") ))
2342 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2343 } else if ( !strncasecmp( val, "refreshAndPersist",
2344 STRLENOF("refreshAndPersist") ))
2346 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
2347 si->si_interval = 60;
2349 fprintf( stderr, "Error: parse_syncrepl_line: "
2350 "unknown sync type \"%s\"\n", val);
2353 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
2354 STRLENOF( INTERVALSTR "=" ) ) )
2356 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
2357 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
2358 si->si_interval = 0;
2366 hstr = strchr( dstr, ':' );
2367 if ( hstr == NULL ) {
2368 fprintf( stderr, "Error: parse_syncrepl_line: "
2369 "invalid interval \"%s\"\n", val );
2373 mstr = strchr( hstr, ':' );
2374 if ( mstr == NULL ) {
2375 fprintf( stderr, "Error: parse_syncrepl_line: "
2376 "invalid interval \"%s\"\n", val );
2380 sstr = strchr( mstr, ':' );
2381 if ( sstr == NULL ) {
2382 fprintf( stderr, "Error: parse_syncrepl_line: "
2383 "invalid interval \"%s\"\n", val );
2392 if (( hh > 24 ) || ( hh < 0 ) ||
2393 ( mm > 60 ) || ( mm < 0 ) ||
2394 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2395 fprintf( stderr, "Error: parse_syncrepl_line: "
2396 "invalid interval \"%s\"\n", val );
2399 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2401 if ( si->si_interval < 0 ) {
2402 fprintf( stderr, "Error: parse_syncrepl_line: "
2403 "invalid interval \"%ld\"\n",
2404 (long) si->si_interval);
2407 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2408 STRLENOF( RETRYSTR "=" ) ) )
2413 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2414 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2415 retry_list[0] = NULL;
2417 slap_str2clist( &retry_list, val, " ,\t" );
2419 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2423 "Error: incomplete syncrepl retry list\n" );
2424 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2425 ch_free( retry_list[k] );
2427 ch_free( retry_list );
2428 exit( EXIT_FAILURE );
2430 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2431 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2432 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2433 for ( j = 0; j < n; j++ ) {
2434 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2435 if ( *retry_list[j*2+1] == '+' ) {
2436 si->si_retrynum_init[j] = -1;
2437 si->si_retrynum[j] = -1;
2441 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2442 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2445 si->si_retrynum_init[j] = -2;
2446 si->si_retrynum[j] = -2;
2447 si->si_retryinterval[j] = 0;
2449 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2450 ch_free( retry_list[k] );
2452 ch_free( retry_list );
2453 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2454 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2456 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2457 si->si_manageDSAit = atoi( val );
2458 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2459 STRLENOF( SLIMITSTR "=") ) )
2461 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2462 si->si_slimit = atoi( val );
2463 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2464 STRLENOF( TLIMITSTR "=" ) ) )
2466 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2467 si->si_tlimit = atoi( val );
2468 } else if ( bindconf_parse( cargv[i], &si->si_bindconf )) {
2469 fprintf( stderr, "Error: parse_syncrepl_line: "
2470 "unknown keyword \"%s\"\n", cargv[ i ] );
2475 if ( gots != GOT_ALL ) {
2477 "Error: Malformed \"syncrepl\" line in slapd config file" );
2485 syncrepl_unparse( syncinfo_t *si, struct berval *bv )
2488 char buf[BUFSIZ*2], *ptr;
2491 bindconf_unparse( &si->si_bindconf, &bc );
2493 ptr += sprintf( ptr, IDSTR "=%03d " PROVIDERSTR "=%s",
2494 si->si_rid, si->si_provideruri.bv_val );
2495 if ( !BER_BVISNULL( &bc )) {
2496 ptr = lutil_strcopy( ptr, bc.bv_val );
2499 if ( !BER_BVISEMPTY( &si->si_filterstr )) {
2500 ptr = lutil_strcopy( ptr, " " FILTERSTR "=\"" );
2501 ptr = lutil_strcopy( ptr, si->si_filterstr.bv_val );
2504 if ( !BER_BVISNULL( &si->si_base )) {
2505 ptr = lutil_strcopy( ptr, " " SEARCHBASESTR "=\"" );
2506 ptr = lutil_strcopy( ptr, si->si_base.bv_val );
2509 for (i=0; !BER_BVISNULL(&scopes[i].key);i++) {
2510 if ( si->si_scope == scopes[i].val ) {
2511 ptr = lutil_strcopy( ptr, " " SCOPESTR "=" );
2512 ptr = lutil_strcopy( ptr, scopes[i].key.bv_val );
2516 if ( si->si_attrsonly ) {
2517 ptr = lutil_strcopy( ptr, " " ATTRSONLYSTR "=yes" );
2519 if ( si->si_anfile ) {
2520 ptr = lutil_strcopy( ptr, " " ATTRSSTR "=:include:" );
2521 ptr = lutil_strcopy( ptr, si->si_anfile );
2522 } else if ( si->si_allattrs || si->si_allopattrs ||
2523 ( si->si_anlist && !BER_BVISNULL(&si->si_anlist[0].an_name) )) {
2525 ptr = lutil_strcopy( ptr, " " ATTRSSTR "=\"" );
2527 ptr = anlist_unparse( si->si_anlist, ptr );
2528 if ( si->si_allattrs ) {
2529 if ( old != ptr ) *ptr++ = ',';
2532 if ( si->si_allopattrs ) {
2533 if ( old != ptr ) *ptr++ = ',';
2538 if ( si->si_exanlist && !BER_BVISNULL(&si->si_exanlist[0].an_name) ) {
2539 ptr = lutil_strcopy( ptr, " " EXATTRSSTR "=" );
2540 ptr = anlist_unparse( si->si_exanlist, ptr );
2542 ptr = lutil_strcopy( ptr, " " SCHEMASTR "=" );
2543 ptr = lutil_strcopy( ptr, si->si_schemachecking ? "on" : "off" );
2545 ptr = lutil_strcopy( ptr, " " TYPESTR "=" );
2546 ptr = lutil_strcopy( ptr, si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ?
2547 "refreshAndPersist" : "refreshOnly" );
2549 if ( si->si_type == LDAP_SYNC_REFRESH_ONLY ) {
2552 dd = si->si_interval;
2559 ptr = lutil_strcopy( ptr, " " INTERVALSTR "=" );
2560 ptr += sprintf( ptr, "%02d:%02d:%02d:%02d", dd, hh, mm, ss );
2561 } else if ( si->si_retryinterval ) {
2563 ptr = lutil_strcopy( ptr, " " RETRYSTR "=\"" );
2564 for (i=0; si->si_retryinterval[i]; i++) {
2565 if ( space ) *ptr++ = ' ';
2567 ptr += sprintf( ptr, "%d", si->si_retryinterval[i] );
2568 if ( si->si_retrynum_init[i] == -1 )
2571 ptr += sprintf( ptr, "%d", si->si_retrynum_init );
2576 #if 0 /* FIXME: unused in syncrepl.c, should remove it */
2577 ptr = lutil_strcopy( ptr, " " MANAGEDSAITSTR "=" );
2578 ptr += sprintf( ptr, "%d", si->si_manageDSAit );
2581 if ( si->si_slimit ) {
2582 ptr = lutil_strcopy( ptr, " " SLIMITSTR "=" );
2583 ptr += sprintf( ptr, "%d", si->si_slimit );
2586 if ( si->si_tlimit ) {
2587 ptr = lutil_strcopy( ptr, " " TLIMITSTR "=" );
2588 ptr += sprintf( ptr, "%d", si->si_tlimit );
2590 bc.bv_len = ptr - buf;
2592 ber_dupbv( bv, &bc );
2595 static CfEntryInfo *
2596 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
2606 if ( dn_match( &root->ce_entry->e_nname, dn ))
2609 c = dn->bv_val+dn->bv_len;
2610 for (;*c != ',';c--);
2614 for (--c;c>dn->bv_val && *c != ',';c--);
2618 cdn.bv_len = dn->bv_len - (c-dn->bv_val);
2620 root = root->ce_kids;
2622 for (;root;root=root->ce_sibs) {
2623 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
2624 if ( cdn.bv_val == dn->bv_val ) {
2635 config_ldif_resp( Operation *op, SlapReply *rs )
2637 if ( rs->sr_type == REP_SEARCH ) {
2638 CfBackInfo *cfb = op->o_callback->sc_private;
2640 cfb->cb_got_ldif = 1;
2641 rs->sr_err = config_add_internal( cfb, rs->sr_entry, NULL );
2646 /* Configure and read the underlying back-ldif store */
2648 config_setup_ldif( BackendDB *be, const char *dir ) {
2649 CfBackInfo *cfb = be->be_private;
2654 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
2655 Connection conn = {0};
2656 char opbuf[OPERATION_BUFFER_SIZE];
2658 SlapReply rs = {REP_RESULT};
2659 Filter filter = { LDAP_FILTER_PRESENT };
2660 struct berval filterstr = BER_BVC("(objectclass=*)");
2662 cfb->cb_db.bd_info = backend_info( "ldif" );
2663 if ( !cfb->cb_db.bd_info )
2664 return 0; /* FIXME: eventually this will be a fatal error */
2666 if ( cfb->cb_db.bd_info->bi_db_init( &cfb->cb_db )) return 1;
2668 /* Mark that back-ldif type is in use */
2669 cfb->cb_db.bd_info->bi_nDB++;
2671 cfb->cb_db.be_suffix = be->be_suffix;
2672 cfb->cb_db.be_nsuffix = be->be_nsuffix;
2673 cfb->cb_db.be_rootdn = be->be_rootdn;
2674 cfb->cb_db.be_rootndn = be->be_rootndn;
2676 ber_str2bv( dir, 0, 1, &cfdir );
2681 argv[0] = "directory";
2682 argv[1] = (char *)dir;
2686 ct = config_find_keyword( c.be->be_cf_table, &c );
2690 if ( config_add_vals( ct, &c ))
2693 if ( backend_startup_one( &cfb->cb_db ))
2696 op = (Operation *)opbuf;
2697 connection_fake_init( &conn, op, cfb );
2699 filter.f_desc = slap_schema.si_ad_objectClass;
2701 op->o_tag = LDAP_REQ_SEARCH;
2703 op->ors_filter = &filter;
2704 op->ors_filterstr = filterstr;
2705 op->ors_scope = LDAP_SCOPE_SUBTREE;
2707 op->o_dn = be->be_rootdn;
2708 op->o_ndn = be->be_rootndn;
2710 op->o_req_dn = be->be_suffix[0];
2711 op->o_req_ndn = be->be_nsuffix[0];
2713 op->ors_tlimit = SLAP_NO_LIMIT;
2714 op->ors_slimit = SLAP_NO_LIMIT;
2716 op->ors_attrs = slap_anlist_all_attributes;
2717 op->ors_attrsonly = 0;
2719 op->o_callback = &cb;
2720 cb.sc_private = cfb;
2722 op->o_bd = &cfb->cb_db;
2723 op->o_bd->be_search( op, &rs );
2729 CfOcInfo_cmp( const void *c1, const void *c2 ) {
2730 const CfOcInfo *co1 = c1;
2731 const CfOcInfo *co2 = c2;
2733 return ber_bvcmp( co1->co_name, co2->co_name );
2737 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
2741 i = init_config_attrs( ct );
2744 /* set up the objectclasses */
2745 i = init_config_ocs( ocs );
2748 for (i=0; ocs[i].def; i++) {
2750 co = ch_malloc( sizeof(CfOcInfo) );
2751 co->co_name = &(*ocs[i].oc)->soc_cname;
2753 co->co_type = ocs[i].cft;
2754 avl_insert( &CfOcTree, co, CfOcInfo_cmp, avl_dup_error );
2761 read_config(const char *fname, const char *dir) {
2765 /* Setup the config backend */
2766 be = backend_db_init( "config" );
2770 /* Setup the underlying back-ldif backend */
2771 if ( config_setup_ldif( be, dir ))
2775 /* If we read the config from back-ldif, nothing to do here */
2776 cfb = be->be_private;
2777 if ( cfb->cb_got_ldif )
2780 ber_str2bv( fname, 0, 1, &cf_prv.c_file );
2782 return read_config_file(fname, 0, NULL);
2786 config_back_bind( Operation *op, SlapReply *rs )
2788 if ( op->orb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op )) {
2789 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
2790 /* frontend sends result */
2791 return LDAP_SUCCESS;
2794 rs->sr_err = LDAP_INVALID_CREDENTIALS;
2795 send_ldap_result( op, rs );
2801 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
2805 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
2807 rs->sr_attrs = op->ors_attrs;
2808 rs->sr_entry = ce->ce_entry;
2809 rc = send_search_entry( op, rs );
2811 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
2812 if ( ce->ce_kids ) {
2813 rc = config_send( op, rs, ce->ce_kids, 1 );
2814 if ( rc ) return rc;
2817 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
2818 rc = config_send( op, rs, ce, 0 );
2826 static ConfigTable *
2827 config_find_table( CfOcInfo *co, AttributeDescription *ad )
2831 for (i=0; co->co_table[i].name; i++)
2832 if ( co->co_table[i].ad == ad )
2833 return &co->co_table[i];
2837 /* Sort the values in an X-ORDERED attribute.
2838 * If the values have no index, leave them in their given order.
2839 * If the values have indexes, sort them and then strip the index.
2840 * If some are indexed and some are not, return Error.
2842 * FIXME: This function probably belongs in the frontend somewhere,
2843 * like slap_mods_check.
2846 sort_vals( Attribute *a )
2849 int index = 0, noindex = 0;
2851 /* count attrs, look for index */
2852 for (i=0; a->a_vals[i].bv_val; i++) {
2853 if ( a->a_vals[i].bv_val[0] == '{' ) {
2856 ptr = strchr( a->a_vals[i].bv_val, '}' );
2857 if ( !ptr || !ptr[1] )
2858 return LDAP_INVALID_SYNTAX;
2860 return LDAP_INVALID_SYNTAX;
2864 return LDAP_INVALID_SYNTAX;
2869 int vals = i, *indexes, j, idx;
2870 struct berval tmp, ntmp;
2873 /* Strip index from normalized values */
2874 if ( !a->a_nvals || a->a_vals == a->a_nvals ) {
2875 a->a_nvals = ch_malloc( (vals+1)*sizeof(struct berval));
2876 for ( i=0; i<vals; i++ ) {
2877 ptr = strchr(a->a_vals[i].bv_val, '}') + 1;
2878 a->a_nvals[i].bv_len = a->a_vals[i].bv_len -
2879 (ptr - a->a_vals[i].bv_val);
2880 a->a_nvals[i].bv_val = ch_malloc( a->a_nvals[i].bv_len + 1);
2881 strcpy(a->a_nvals[i].bv_val, ptr );
2884 for ( i=0; i<vals; i++ ) {
2885 ptr = strchr(a->a_nvals[i].bv_val, '}') + 1;
2886 a->a_nvals[i].bv_len -= ptr - a->a_nvals[i].bv_val;
2887 strcpy(a->a_nvals[i].bv_val, ptr);
2891 indexes = ch_malloc( vals * sizeof(int) );
2892 for ( i=0; i<vals; i++)
2893 indexes[i] = atoi(a->a_vals[i].bv_val+1);
2895 /* Insertion sort */
2896 for ( i=1; i<vals; i++ ) {
2899 ntmp = a->a_nvals[i];
2901 while ((j > 0) && (indexes[j-1] > idx)) {
2902 indexes[j] = indexes[j-1];
2903 a->a_vals[j] = a->a_vals[j-1];
2904 a->a_nvals[j] = a->a_nvals[j-1];
2909 a->a_nvals[j] = ntmp;
2916 check_attr( ConfigTable *ct, ConfigArgs *ca, Attribute *a )
2920 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
2921 rc = sort_vals( a );
2925 for ( i=0; a->a_nvals[i].bv_val; i++ ) {
2926 ca->line = a->a_nvals[i].bv_val;
2927 rc = config_parse_vals( ct, ca, i );
2934 /* Parse an LDAP entry into config directives */
2936 config_add_internal( CfBackInfo *cfb, Entry *e, SlapReply *rs )
2938 CfEntryInfo *ce, *last;
2939 CfOcInfo co, *coptr, **colst = NULL;
2940 Attribute *a, *oc_at, *type_attr;
2941 AttributeDescription *type_ad = NULL;
2943 ConfigArgs ca = {0};
2946 ConfigTable *ct, *type_ct = NULL;
2948 /* Make sure parent exists and entry does not */
2949 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
2951 return LDAP_ALREADY_EXISTS;
2953 dnParent( &e->e_nname, &pdn );
2955 /* If last is NULL, the new entry is the root/suffix entry,
2956 * otherwise last should be the parent.
2958 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn )) {
2960 rs->sr_matched = last->ce_entry->e_name.bv_val;
2961 return LDAP_NO_SUCH_OBJECT;
2964 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
2965 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
2967 /* count the objectclasses */
2968 for ( i=0; oc_at->a_nvals[i].bv_val; i++ );
2970 colst = (CfOcInfo **)ch_malloc( nocs * sizeof(CfOcInfo *));
2972 for ( i=0, j=0; i<nocs; i++) {
2973 co.co_name = &oc_at->a_nvals[i];
2974 coptr = avl_find( CfOcTree, &co, CfOcInfo_cmp );
2976 /* ignore non-config objectclasses. probably should be
2977 * an error, general data doesn't belong here.
2979 if ( !coptr ) continue;
2981 /* Ignore the root objectclass, it has no implementation.
2983 if ( coptr->co_type == Cft_Abstract ) continue;
2988 /* Only the root can be Cft_Global, everything else must
2989 * have a parent. Only limited nesting arrangements are allowed.
2991 switch( colst[0]->co_type ) {
2994 rc = LDAP_CONSTRAINT_VIOLATION;
3002 if ( !last || ( last->ce_type != Cft_Global &&
3003 last->ce_type != colst[0]->co_type )) {
3004 rc = LDAP_CONSTRAINT_VIOLATION;
3009 if ( !last || ( last->ce_type != Cft_Global &&
3010 last->ce_type != Cft_Database &&
3011 last->ce_type != colst[0]->co_type )) {
3012 rc = LDAP_CONSTRAINT_VIOLATION;
3015 #ifdef SLAPD_MODULES
3017 if ( !last || last->ce_type != Cft_Global ) {
3018 rc = LDAP_CONSTRAINT_VIOLATION;
3025 /* Parse all the values and check for simple syntax errors before
3026 * performing any set actions.
3028 switch (colst[0]->co_type) {
3030 /* The cn=schema entry is all hardcoded, so never reparse it */
3031 if (last->ce_type == Cft_Global )
3039 if ( last->ce_type == Cft_Backend )
3040 ca.bi = last->ce_bi;
3042 type_ad = cfAd_backend;
3045 if ( last->ce_type == Cft_Database ) {
3046 ca.be = last->ce_be;
3048 type_ad = cfAd_database;
3049 /* dummy, just to get past check_attr */
3055 ca.be = last->ce_be;
3056 type_ad = cfAd_overlay;
3059 if ( !rs ) /* ignored */
3061 type_ad = cfAd_include;
3062 #ifdef SLAPD_MODULES
3066 ptr = strchr( e->e_name.bv_val, '{' );
3068 rc = LDAP_NAMING_VIOLATION;
3072 for (i=0, mp=&modpaths; mp && i<j; mp=mp->mp_next);
3073 /* There is no corresponding modpath for this load? */
3075 rc = LDAP_NAMING_VIOLATION;
3078 module_path( mp->mp_path.bv_val );
3084 init_config_argv( &ca );
3086 type_attr = attr_find( e->e_attrs, type_ad );
3088 rc = LDAP_OBJECT_CLASS_VIOLATION;
3091 for ( i=0; i<nocs; i++ ) {
3092 type_ct = config_find_table( colst[i], type_ad );
3093 if ( type_ct ) break;
3096 rc = LDAP_OBJECT_CLASS_VIOLATION;
3099 rc = check_attr( type_ct, &ca, type_attr );
3100 if ( rc ) goto leave;
3102 for ( a=e->e_attrs; a; a=a->a_next ) {
3103 if ( a == type_attr || a == oc_at ) continue;
3105 for ( i=0; i<nocs; i++ ) {
3106 ct = config_find_table( colst[i], a->a_desc );
3109 if ( !ct ) continue; /* user data? */
3110 rc = check_attr( ct, &ca, a );
3111 if ( rc ) goto leave;
3114 /* Basic syntax checks are OK. Do the actual settings. */
3116 ca.line = type_attr->a_nvals[0].bv_val;
3117 rc = config_parse_add( type_ct, &ca, 0 );
3118 if ( rc ) goto leave;
3120 for ( a=e->e_attrs; a; a=a->a_next ) {
3121 if ( a == type_attr || a == oc_at ) continue;
3123 for ( i=0; i<nocs; i++ ) {
3124 ct = config_find_table( colst[i], a->a_desc );
3127 if ( !ct ) continue; /* user data? */
3128 for (i=0; a->a_nvals[i].bv_val; i++) {
3129 ca.line = a->a_nvals[i].bv_val;
3130 rc = config_parse_add( ct, &ca, i );
3131 if ( rc ) goto leave;
3135 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
3136 ce->ce_parent = last;
3137 ce->ce_entry = entry_dup( e );
3138 ce->ce_entry->e_private = ce;
3139 ce->ce_type = colst[0]->co_type;
3142 } else if ( last->ce_kids ) {
3145 for (c2=last->ce_kids; c2 && c2->ce_sibs; c2 = c2->ce_sibs);
3153 if ( colst ) ch_free( colst );
3157 /* Parse an LDAP entry into config directives, then store in underlying
3161 config_back_add( Operation *op, SlapReply *rs )
3164 CfEntryInfo *ce, *last;
3166 if ( !be_isroot( op ) ) {
3167 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3168 send_ldap_result( op, rs );
3171 cfb = (CfBackInfo *)op->o_bd->be_private;
3173 ldap_pvt_thread_pool_pause( &connection_pool );
3176 * 1) check for existence of entry
3177 * 2) perform internal add
3178 * 3) store entry in underlying database
3181 ldap_pvt_thread_pool_resume( &connection_pool );
3184 send_ldap_result( op, rs );
3189 config_back_modify( Operation *op, SlapReply *rs )
3192 CfEntryInfo *ce, *last;
3194 if ( !be_isroot( op ) ) {
3195 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3196 send_ldap_result( op, rs );
3199 cfb = (CfBackInfo *)op->o_bd->be_private;
3201 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
3204 rs->sr_matched = last->ce_entry->e_name.bv_val;
3205 rs->sr_err = LDAP_NO_SUCH_OBJECT;
3208 ldap_pvt_thread_pool_pause( &connection_pool );
3211 * 1) perform the Modify on the cached Entry.
3212 * 2) verify that the Entry still satisfies the schema.
3213 * 3) perform the individual config operations.
3214 * 4) store Modified entry in underlying LDIF backend.
3216 ldap_pvt_thread_pool_resume( &connection_pool );
3218 send_ldap_result( op, rs );
3223 config_back_search( Operation *op, SlapReply *rs )
3226 CfEntryInfo *ce, *last;
3229 if ( !be_isroot( op ) ) {
3230 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3231 send_ldap_result( op, rs );
3234 cfb = (CfBackInfo *)op->o_bd->be_private;
3236 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
3239 rs->sr_matched = last->ce_entry->e_name.bv_val;
3240 rs->sr_err = LDAP_NO_SUCH_OBJECT;
3243 switch ( op->ors_scope ) {
3244 case LDAP_SCOPE_BASE:
3245 case LDAP_SCOPE_SUBTREE:
3246 config_send( op, rs, ce, 0 );
3249 case LDAP_SCOPE_ONELEVEL:
3250 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
3251 config_send( op, rs, ce, 1 );
3256 rs->sr_err = LDAP_SUCCESS;
3258 send_ldap_result( op, rs );
3263 config_alloc_entry( CfEntryInfo *parent, struct berval *rdn )
3265 Entry *e = ch_calloc( 1, sizeof(Entry) );
3266 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
3271 ce->ce_parent = parent;
3273 pdn = parent->ce_entry->e_nname;
3278 build_new_dn( &e->e_name, &pdn, rdn, NULL );
3279 ber_dupbv( &e->e_nname, &e->e_name );
3288 config_build_entry( ConfigArgs *c, Entry *e, ObjectClass *oc,
3289 struct berval *rdn, ConfigTable *ct, int table )
3291 struct berval vals[2];
3292 struct berval ad_name;
3293 AttributeDescription *ad = NULL;
3297 char textbuf[SLAP_TEXT_BUFLEN];
3298 size_t textlen = sizeof(textbuf);
3302 BER_BVZERO( &vals[1] );
3304 vals[0] = oc->soc_cname;
3305 attr_merge(e, slap_schema.si_ad_objectClass, vals, NULL );
3306 ptr = strchr(rdn->bv_val, '=');
3307 ad_name.bv_val = rdn->bv_val;
3308 ad_name.bv_len = ptr - rdn->bv_val;
3309 rc = slap_bv2ad( &ad_name, &ad, &text );
3313 vals[0].bv_val = ptr+1;
3314 vals[0].bv_len = rdn->bv_len - (vals[0].bv_val - rdn->bv_val);
3315 attr_merge(e, ad, vals, NULL );
3317 for (at=oc->soc_required; at && *at; at++) {
3318 /* Skip the naming attr */
3319 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
3321 for (i=0;ct[i].name;i++) {
3322 if (ct[i].ad == (*at)->sat_ad) {
3323 rc = config_get_vals(&ct[i], c);
3324 if (rc == LDAP_SUCCESS) {
3325 attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
3326 ber_bvarray_free( c->rvalue_nvals );
3327 ber_bvarray_free( c->rvalue_vals );
3334 for (at=oc->soc_allowed; at && *at; at++) {
3335 /* Skip the naming attr */
3336 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
3338 for (i=0;ct[i].name;i++) {
3339 if (ct[i].ad == (*at)->sat_ad) {
3340 rc = config_get_vals(&ct[i], c);
3341 if (rc == LDAP_SUCCESS) {
3342 attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
3343 ber_bvarray_free( c->rvalue_nvals );
3344 ber_bvarray_free( c->rvalue_vals );
3352 if ( table == BI_TABLE )
3353 ct = c->bi->bi_cf_table;
3355 ct = c->be->be_cf_table;
3356 for (;ct && ct->name;ct++) {
3357 if (!ct->ad) continue;
3358 rc = config_get_vals(ct, c);
3359 if (rc == LDAP_SUCCESS) {
3360 attr_merge(e, ct->ad, c->rvalue_vals, c->rvalue_nvals);
3364 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
3365 rc = structural_class(oc_at->a_vals, vals, NULL, &text, textbuf, textlen);
3366 BER_BVZERO( &vals[1] );
3367 attr_merge(e, slap_schema.si_ad_structuralObjectClass, vals, NULL );
3372 static CfEntryInfo *
3373 config_build_includes( ConfigArgs *c, CfEntryInfo *ceparent,
3374 Operation *op, SlapReply *rs )
3378 ConfigFile *cf = c->private;
3379 CfEntryInfo *ce, *ceprev;
3381 if ( ceparent->ce_kids ) {
3382 for ( ceprev = ceparent->ce_kids; ceprev->ce_sibs;
3383 ceprev = ceprev->ce_sibs );
3386 for (i=0; cf; cf=cf->c_sibs, i++) {
3387 c->value_dn.bv_val = c->log;
3388 c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=include{%02d}", i);
3389 e = config_alloc_entry( ceparent, &c->value_dn );
3391 config_build_entry( c, e, cfOc_include, &c->value_dn,
3392 c->bi->bi_cf_table, NO_TABLE );
3394 op->o_bd->be_add( op, rs );
3396 ce->ce_type = Cft_Include;
3398 if ( !ceparent->ce_kids ) {
3399 ceparent->ce_kids = ce;
3401 ceprev->ce_sibs = ce;
3405 c->private = cf->c_kids;
3406 config_build_includes( c, ce, op, rs );
3412 #ifdef SLAPD_MODULES
3414 static CfEntryInfo *
3415 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
3416 Operation *op, SlapReply *rs )
3420 CfEntryInfo *ce, *ceprev;
3423 if ( ceparent->ce_kids ) {
3424 for ( ceprev = ceparent->ce_kids; ceprev->ce_sibs;
3425 ceprev = ceprev->ce_sibs );
3428 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
3429 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
3431 c->value_dn.bv_val = c->log;
3432 c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=module{%02d}", i);
3433 e = config_alloc_entry( ceparent, &c->value_dn );
3435 ce->ce_type = Cft_Include;
3437 config_build_entry( c, e, cfOc_module, &c->value_dn,
3438 c->bi->bi_cf_table, NO_TABLE );
3440 op->o_bd->be_add( op, rs );
3442 if ( !ceparent->ce_kids ) {
3443 ceparent->ce_kids = ce;
3445 ceprev->ce_sibs = ce;
3454 config_back_db_open( BackendDB *be )
3456 CfBackInfo *cfb = be->be_private;
3459 CfEntryInfo *ce, *ceparent, *ceprev;
3465 Connection conn = {0};
3466 char opbuf[OPERATION_BUFFER_SIZE];
3468 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
3469 SlapReply rs = {REP_RESULT};
3471 /* If we read the config from back-ldif, nothing to do here */
3472 if ( cfb->cb_got_ldif )
3475 op = (Operation *)opbuf;
3476 connection_fake_init( &conn, op, cfb );
3478 op->o_dn = be->be_rootdn;
3479 op->o_ndn = be->be_rootndn;
3481 op->o_tag = LDAP_REQ_ADD;
3482 op->o_callback = &cb;
3483 op->o_bd = &cfb->cb_db;
3485 /* create root of tree */
3487 e = config_alloc_entry( NULL, &rdn );
3489 ce->ce_type = Cft_Global;
3493 c.private = cfb->cb_config;
3494 ct = c.bi->bi_cf_table;
3495 config_build_entry( &c, e, cfOc_global, &rdn, ct, NO_TABLE );
3497 op->o_bd->be_add( op, &rs );
3503 /* Create schema nodes... cn=schema will contain the hardcoded core
3504 * schema, read-only. Child objects will contain runtime loaded schema
3508 e = config_alloc_entry( ceparent, &rdn );
3510 ce->ce_type = Cft_Schema;
3512 config_build_entry( &c, e, cfOc_schema, &rdn, ct, NO_TABLE );
3514 op->o_bd->be_add( op, &rs );
3515 if ( !ceparent->ce_kids ) {
3516 ceparent->ce_kids = ce;
3518 ceprev->ce_sibs = ce;
3522 /* Create includeFile nodes... */
3523 if ( cfb->cb_config->c_kids ) {
3524 c.private = cfb->cb_config->c_kids;
3525 ceprev = config_build_includes( &c, ceparent, op, &rs );
3528 #ifdef SLAPD_MODULES
3529 /* Create Module nodes... */
3530 if ( modpaths.mp_loads ) {
3531 ceprev = config_build_includes( &c, ceparent, op, &rs );
3535 /* Create backend nodes. Skip if they don't provide a cf_table.
3536 * There usually aren't any of these.
3541 for (i=0; i<nBackendInfo; i++, bi++) {
3542 if (!bi->bi_cf_table) continue;
3543 if (!bi->bi_private) continue;
3546 rdn.bv_len = sprintf(rdn.bv_val, "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
3547 e = config_alloc_entry( ceparent, &rdn );
3549 ce->ce_type = Cft_Backend;
3552 config_build_entry( &c, e, cfOc_backend, &rdn, ct, BI_TABLE );
3554 op->o_bd->be_add( op, &rs );
3555 if ( !ceparent->ce_kids ) {
3556 ceparent->ce_kids = ce;
3558 ceprev->ce_sibs = ce;
3563 /* Create database nodes... */
3564 for (i=0; i<nBackendDB; i++) {
3565 slap_overinfo *oi = NULL;
3569 bptr = &backendDB[i];
3571 if ( overlay_is_over( bptr )) {
3572 oi = bptr->bd_info->bi_private;
3578 rdn.bv_len = sprintf(rdn.bv_val, "%s={%0x}%s", cfAd_database->ad_cname.bv_val,
3580 e = config_alloc_entry( ceparent, &rdn );
3584 ce->ce_type = Cft_Database;
3587 config_build_entry( &c, e, cfOc_database, &rdn, ct, BE_TABLE );
3589 op->o_bd->be_add( op, &rs );
3590 if ( !ceparent->ce_kids ) {
3591 ceparent->ce_kids = ce;
3593 ceprev->ce_sibs = ce;
3596 /* Iterate through overlays */
3600 CfEntryInfo *opar = ce, *oprev = NULL;
3603 for (j=0,on=oi->oi_list; on; j++,on=on->on_next) {
3605 rdn.bv_len = sprintf(rdn.bv_val, "%s={%0x}%s",
3606 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
3607 oe = config_alloc_entry( opar, &rdn );
3611 ce->ce_type = Cft_Overlay;
3614 config_build_entry( &c, oe, cfOc_overlay, &rdn, ct, BI_TABLE );
3616 op->o_bd->be_add( op, &rs );
3617 if ( !opar->ce_kids ) {
3620 oprev->ce_sibs = ce;
3631 config_back_db_destroy( Backend *be )
3633 free( be->be_private );
3638 config_back_db_init( Backend *be )
3643 cfb = ch_calloc( 1, sizeof(CfBackInfo));
3644 cfb->cb_config = &cf_prv;
3646 be->be_private = cfb;
3648 ber_dupbv( &be->be_rootdn, &config_rdn );
3649 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
3650 ber_dupbv( &dn, &be->be_rootdn );
3651 ber_bvarray_add( &be->be_suffix, &dn );
3652 ber_dupbv( &dn, &be->be_rootdn );
3653 ber_bvarray_add( &be->be_nsuffix, &dn );
3655 /* Hide from namingContexts */
3656 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
3663 AttributeDescription **desc;
3665 { "backend", &cfAd_backend },
3666 { "database", &cfAd_database },
3667 { "include", &cfAd_include },
3668 { "overlay", &cfAd_overlay },
3669 { NULL, NULL, NULL }
3673 * add / delete: all types that may be added or deleted must use an
3674 * X-ORDERED attributeType for their RDN. Adding and deleting entries
3675 * should automatically renumber the index of any siblings as needed,
3676 * so that no gaps in the numbering sequence exist after the add/delete
3678 * What can be added:
3680 * backend objects for backend-specific config directives
3684 * delete: probably no support this time around.
3686 * modrdn: generally not done. Will be invoked automatically by add/
3687 * delete to update numbering sequence. Perform as an explicit operation
3688 * so that the renumbering effect may be replicated. Subtree rename must
3689 * be supported, since renumbering a database will affect all its child
3692 * modify: must be fully supported.
3696 config_back_initialize( BackendInfo *bi )
3698 ConfigTable *ct = config_back_cf_table;
3707 bi->bi_db_init = config_back_db_init;
3708 bi->bi_db_config = 0;
3709 bi->bi_db_open = config_back_db_open;
3710 bi->bi_db_close = 0;
3711 bi->bi_db_destroy = config_back_db_destroy;
3713 bi->bi_op_bind = config_back_bind;
3714 bi->bi_op_unbind = 0;
3715 bi->bi_op_search = config_back_search;
3716 bi->bi_op_compare = 0;
3717 bi->bi_op_modify = config_back_modify;
3718 bi->bi_op_modrdn = 0;
3720 bi->bi_op_delete = 0;
3721 bi->bi_op_abandon = 0;
3723 bi->bi_extended = 0;
3725 bi->bi_chk_referrals = 0;
3727 bi->bi_connection_init = 0;
3728 bi->bi_connection_destroy = 0;
3731 for (i=0; OidMacros[i].name; i++ ) {
3732 argv[1] = OidMacros[i].name;
3733 argv[2] = OidMacros[i].oid;
3734 parse_oidm( "slapd", i, 3, argv, 0, NULL );
3737 bi->bi_cf_table = ct;
3739 i = config_register_schema( ct, cf_ocs );
3742 /* set up the notable AttributeDescriptions */
3744 for (;ct->name;ct++) {
3745 if (strcmp(ct->name, ads[i].name)) continue;
3746 *ads[i].desc = ct->ad;
3748 if (!ads[i].name) break;