1 /* bconfig.c - the config backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2007 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>
32 #include "slapi/slapi.h"
40 #define CONFIG_RDN "cn=config"
41 #define SCHEMA_RDN "cn=schema"
43 static struct berval config_rdn = BER_BVC(CONFIG_RDN);
44 static struct berval schema_rdn = BER_BVC(SCHEMA_RDN);
46 extern int slap_DN_strict; /* dn.c */
49 typedef struct modpath_s {
50 struct modpath_s *mp_next;
51 struct berval mp_path;
55 static ModPaths modpaths, *modlast = &modpaths, *modcur = &modpaths;
58 typedef struct ConfigFile {
59 struct ConfigFile *c_sibs;
60 struct ConfigFile *c_kids;
62 AttributeType *c_at_head, *c_at_tail;
63 ContentRule *c_cr_head, *c_cr_tail;
64 ObjectClass *c_oc_head, *c_oc_tail;
65 OidMacro *c_om_head, *c_om_tail;
70 ConfigFile *cb_config;
72 BackendDB cb_db; /* underlying database */
77 static CfBackInfo cfBackInfo;
79 static char *passwd_salt;
80 static char *logfileName;
81 #ifdef SLAP_AUTH_REWRITE
82 static BerVarray authz_rewrites;
85 static struct berval cfdir;
88 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
89 *cfAd_include, *cfAd_attr, *cfAd_oc, *cfAd_om;
91 static ConfigFile *cfn;
93 static Avlnode *CfOcTree;
95 /* System schema state */
96 extern AttributeType *at_sys_tail; /* at.c */
97 extern ObjectClass *oc_sys_tail; /* oc.c */
98 extern OidMacro *om_sys_tail; /* oidm.c */
99 static AttributeType *cf_at_tail;
100 static ObjectClass *cf_oc_tail;
101 static OidMacro *cf_om_tail;
103 static int config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca,
104 SlapReply *rs, int *renumber, Operation *op );
106 static int config_check_schema( Operation *op, CfBackInfo *cfb );
108 static ConfigDriver config_fname;
109 static ConfigDriver config_cfdir;
110 static ConfigDriver config_generic;
111 static ConfigDriver config_search_base;
112 static ConfigDriver config_passwd_hash;
113 static ConfigDriver config_schema_dn;
114 static ConfigDriver config_sizelimit;
115 static ConfigDriver config_timelimit;
116 static ConfigDriver config_overlay;
117 static ConfigDriver config_subordinate;
118 static ConfigDriver config_suffix;
119 static ConfigDriver config_rootdn;
120 static ConfigDriver config_rootpw;
121 static ConfigDriver config_restrict;
122 static ConfigDriver config_allows;
123 static ConfigDriver config_disallows;
124 static ConfigDriver config_requires;
125 static ConfigDriver config_security;
126 static ConfigDriver config_referral;
127 static ConfigDriver config_loglevel;
128 static ConfigDriver config_updatedn;
129 static ConfigDriver config_updateref;
130 static ConfigDriver config_include;
131 static ConfigDriver config_obsolete;
133 static ConfigDriver config_tls_option;
134 static ConfigDriver config_tls_config;
136 extern ConfigDriver syncrepl_config;
187 static OidRec OidMacros[] = {
188 /* OpenLDAProot:666.11.1 */
189 { "OLcfg", "1.3.6.1.4.1.4203.666.11.1" },
190 { "OLcfgAt", "OLcfg:3" },
191 { "OLcfgGlAt", "OLcfgAt:0" },
192 { "OLcfgBkAt", "OLcfgAt:1" },
193 { "OLcfgDbAt", "OLcfgAt:2" },
194 { "OLcfgOvAt", "OLcfgAt:3" },
195 { "OLcfgOc", "OLcfg:4" },
196 { "OLcfgGlOc", "OLcfgOc:0" },
197 { "OLcfgBkOc", "OLcfgOc:1" },
198 { "OLcfgDbOc", "OLcfgOc:2" },
199 { "OLcfgOvOc", "OLcfgOc:3" },
201 /* Syntaxes. We should just start using the standard names and
202 * document that they are predefined and available for users
203 * to reference in their own schema. Defining schema without
204 * OID macros is for masochists...
206 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
207 { "OMsBoolean", "OMsyn:7" },
208 { "OMsDN", "OMsyn:12" },
209 { "OMsDirectoryString", "OMsyn:15" },
210 { "OMsInteger", "OMsyn:27" },
211 { "OMsOID", "OMsyn:38" },
212 { "OMsOctetString", "OMsyn:40" },
217 * Backend/Database registry
219 * OLcfg{Bk|Db}{Oc|At}:0 -> common
220 * OLcfg{Bk|Db}{Oc|At}:1 -> back-bdb(/back-hdb)
221 * OLcfg{Bk|Db}{Oc|At}:2 -> back-ldif
222 * OLcfg{Bk|Db}{Oc|At}:3 -> back-ldap
228 * OLcfgOv{Oc|At}:1 -> syncprov
229 * OLcfgOv{Oc|At}:2 -> pcache
230 * OLcfgOv{Oc|At}:3 -> chain
231 * OLcfgOv{Oc|At}:4 -> accesslog
232 * OLcfgOv{Oc|At}:5 -> valsort
233 * (FIXME: separate arc for contribware?)
234 * OLcfgOv{Oc|At}:6 -> smbk5pwd
235 * OLcfgOv{Oc|At}:7 -> distproc
236 * OLcfgOv{Oc|At}:8 -> dynlist
237 * OLcfgOv{Oc|At}:9 -> dds
238 * OLcfgOv{Oc|At}:10 -> unique
239 * OLcfgOv{Oc|At}:11 -> refint
240 * OLcfgOv{Oc|At}:12 -> ppolicy
241 * OLcfgOv{Oc|At}:13 -> constraint
242 * OLcfgOv{Oc|At}:14 -> translucent
243 * OLcfgOv{Oc|At}:15 -> auditlog
246 /* alphabetical ordering */
248 static ConfigTable config_back_cf_table[] = {
249 /* This attr is read-only */
250 { "", "", 0, 0, 0, ARG_MAGIC,
251 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
252 "DESC 'File for slapd configuration directives' "
253 "EQUALITY caseIgnoreMatch "
254 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
255 { "", "", 0, 0, 0, ARG_MAGIC,
256 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
257 "DESC 'Directory for slapd configuration backend' "
258 "EQUALITY caseIgnoreMatch "
259 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
260 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
261 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
262 "DESC 'Access Control List' "
263 "EQUALITY caseIgnoreMatch "
264 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
265 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
266 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
267 "DESC 'Allowed set of deprecated features' "
268 "EQUALITY caseIgnoreMatch "
269 "SYNTAX OMsDirectoryString )", NULL, NULL },
270 { "argsfile", "file", 2, 2, 0, ARG_STRING,
271 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
272 "DESC 'File for slapd command line options' "
273 "EQUALITY caseIgnoreMatch "
274 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
275 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
276 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
277 "EQUALITY caseIgnoreMatch "
278 "SYNTAX OMsDirectoryString )", NULL, NULL },
279 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
280 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
281 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
282 "DESC 'OpenLDAP attributeTypes' "
283 "EQUALITY caseIgnoreMatch "
284 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
286 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
287 #ifdef SLAP_AUTH_REWRITE
288 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
292 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
293 "EQUALITY caseIgnoreMatch "
294 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
295 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
296 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
297 "EQUALITY caseIgnoreMatch "
298 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
299 { "authz-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
300 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
301 "EQUALITY caseIgnoreMatch "
302 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
303 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
304 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
305 "DESC 'A type of backend' "
306 "EQUALITY caseIgnoreMatch "
307 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
309 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
310 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
311 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
312 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
313 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
314 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
315 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
316 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
317 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
318 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
319 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
320 "DESC 'The backend type for a database instance' "
321 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
322 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
323 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
324 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
325 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
326 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
327 "EQUALITY caseIgnoreMatch "
328 "SYNTAX OMsDirectoryString )", NULL, NULL },
329 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
330 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
331 "DESC 'OpenLDAP DIT content rules' "
332 "EQUALITY caseIgnoreMatch "
333 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
335 { "gentlehup", "on|off", 2, 2, 0,
337 ARG_ON_OFF, &global_gentlehup,
341 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
342 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
343 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
344 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
345 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
346 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
347 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
348 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
349 { "include", "file", 2, 2, 0, ARG_MAGIC,
350 &config_include, NULL, NULL, NULL },
351 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
352 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
353 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
354 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
355 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
356 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
357 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
358 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
359 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
360 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
361 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
362 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
363 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
364 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
365 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
366 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
367 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
368 "EQUALITY caseIgnoreMatch "
369 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
370 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
371 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
372 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
373 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
374 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
375 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
376 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
377 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
378 "EQUALITY caseIgnoreMatch "
379 "SYNTAX OMsDirectoryString )", NULL, NULL },
380 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
381 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
382 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
383 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
384 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
385 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
386 { "moduleload", "file", 2, 0, 0,
388 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
392 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
393 "EQUALITY caseIgnoreMatch "
394 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
395 { "modulepath", "path", 2, 2, 0,
397 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
401 "( OLcfgGlAt:31 NAME 'olcModulePath' "
402 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
403 { "monitoring", "TRUE|FALSE", 2, 2, 0,
404 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
405 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
406 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
407 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
408 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
409 "DESC 'OpenLDAP object classes' "
410 "EQUALITY caseIgnoreMatch "
411 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
413 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
414 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
415 "EQUALITY caseIgnoreMatch "
416 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
417 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
418 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
419 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
420 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
421 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
422 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
423 { "password-hash", "hash", 2, 2, 0, ARG_MAGIC,
424 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
425 "EQUALITY caseIgnoreMatch "
426 "SYNTAX OMsDirectoryString )", NULL, NULL },
427 { "pidfile", "file", 2, 2, 0, ARG_STRING,
428 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
429 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
430 { "plugin", NULL, 0, 0, 0,
432 ARG_MAGIC|CFG_PLUGIN, &config_generic,
436 "( OLcfgGlAt:38 NAME 'olcPlugin' "
437 "EQUALITY caseIgnoreMatch "
438 "SYNTAX OMsDirectoryString )", NULL, NULL },
439 { "pluginlog", "filename", 2, 2, 0,
441 ARG_STRING, &slapi_log_file,
445 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
446 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
447 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
448 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
449 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
450 { "referral", "url", 2, 2, 0, ARG_MAGIC,
451 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
452 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
453 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
454 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
455 "EQUALITY caseIgnoreMatch "
456 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
457 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
458 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
459 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
460 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
461 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
462 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
463 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
464 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
465 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
466 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
467 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
468 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
469 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
470 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
471 "EQUALITY caseIgnoreMatch "
472 "SYNTAX OMsDirectoryString )", NULL, NULL },
473 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
474 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
475 "EQUALITY caseIgnoreMatch "
476 "SYNTAX OMsDirectoryString )", NULL, NULL },
477 { "reverse-lookup", "on|off", 2, 2, 0,
478 #ifdef SLAPD_RLOOKUPS
479 ARG_ON_OFF, &use_reverse_lookup,
483 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
484 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
485 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
486 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
487 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
488 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
489 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
490 "EQUALITY caseIgnoreMatch "
491 "SYNTAX OMsDirectoryString )", NULL, NULL },
492 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
493 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
494 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
495 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
496 &config_generic, NULL, NULL, NULL },
497 { "sasl-host", "host", 2, 2, 0,
498 #ifdef HAVE_CYRUS_SASL
499 ARG_STRING|ARG_UNIQUE, &global_host,
503 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
504 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
505 { "sasl-realm", "realm", 2, 2, 0,
506 #ifdef HAVE_CYRUS_SASL
507 ARG_STRING|ARG_UNIQUE, &global_realm,
511 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
512 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
513 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
514 &config_generic, NULL, NULL, NULL },
515 { "sasl-secprops", "properties", 2, 2, 0,
516 #ifdef HAVE_CYRUS_SASL
517 ARG_MAGIC|CFG_SASLSECP, &config_generic,
521 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
522 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
523 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
524 &config_generic, NULL, NULL, NULL },
525 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
526 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
527 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
528 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
529 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
530 "EQUALITY caseIgnoreMatch "
531 "SYNTAX OMsDirectoryString )", NULL, NULL },
532 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
533 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
534 "EQUALITY caseIgnoreMatch "
535 "SYNTAX OMsDirectoryString )", NULL, NULL },
536 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
537 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
538 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
539 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
540 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
541 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
542 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
543 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
544 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
545 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
546 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
547 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
548 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
549 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
550 "EQUALITY distinguishedNameMatch "
551 "SYNTAX OMsDN )", NULL, NULL },
552 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
553 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
554 "EQUALITY caseIgnoreMatch "
555 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
556 { "threads", "count", 2, 2, 0,
560 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
562 "( OLcfgGlAt:66 NAME 'olcThreads' "
563 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
564 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
565 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
566 "SYNTAX OMsDirectoryString )", NULL, NULL },
567 { "TLSCACertificateFile", NULL, 0, 0, 0,
569 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
573 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
574 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
575 { "TLSCACertificatePath", NULL, 0, 0, 0,
577 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
581 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
582 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
583 { "TLSCertificateFile", NULL, 0, 0, 0,
585 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
589 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
590 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
591 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
593 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
597 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
598 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
599 { "TLSCipherSuite", NULL, 0, 0, 0,
601 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
605 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
606 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
607 { "TLSCRLCheck", NULL, 0, 0, 0,
608 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
609 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
613 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
614 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
615 { "TLSRandFile", NULL, 0, 0, 0,
617 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
621 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
622 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
623 { "TLSVerifyClient", NULL, 0, 0, 0,
625 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
629 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
630 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
631 { "TLSDHParamFile", NULL, 0, 0, 0,
633 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
637 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
638 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
639 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
640 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
641 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
642 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
643 NULL, NULL, NULL, NULL },
644 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
645 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
646 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
647 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
648 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
649 "EQUALITY caseIgnoreMatch "
650 "SUP labeledURI )", NULL, NULL },
651 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
652 NULL, NULL, NULL, NULL }
655 /* Routines to check if a child can be added to this type */
656 static ConfigLDAPadd cfAddSchema, cfAddDatabase,
657 cfAddBackend, cfAddModule, cfAddOverlay;
659 /* NOTE: be careful when defining array members
660 * that can be conditionally compiled */
661 #define CFOC_GLOBAL cf_ocs[1]
662 #define CFOC_SCHEMA cf_ocs[2]
663 #define CFOC_BACKEND cf_ocs[3]
664 #define CFOC_DATABASE cf_ocs[4]
665 #define CFOC_OVERLAY cf_ocs[5]
666 #define CFOC_FRONTEND cf_ocs[6]
668 #define CFOC_MODULE cf_ocs[7]
669 #endif /* SLAPD_MODULES */
671 static ConfigOCs cf_ocs[] = {
674 "DESC 'OpenLDAP configuration object' "
675 "ABSTRACT SUP top )", Cft_Abstract, NULL },
678 "DESC 'OpenLDAP Global configuration options' "
679 "SUP olcConfig STRUCTURAL "
680 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
681 "olcAttributeOptions $ olcAuthIDRewrite $ "
682 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
683 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
684 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
685 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
686 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcLocalSSF $ "
688 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
689 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
690 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
692 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
693 "olcSecurity $ olcServerID $ olcSizeLimit $ "
694 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
695 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
696 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
697 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
698 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
700 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
701 "olcDitContentRules ) )", Cft_Global },
703 "NAME 'olcSchemaConfig' "
704 "DESC 'OpenLDAP schema object' "
705 "SUP olcConfig STRUCTURAL "
706 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
707 "olcObjectClasses $ olcDitContentRules ) )",
708 Cft_Schema, NULL, cfAddSchema },
710 "NAME 'olcBackendConfig' "
711 "DESC 'OpenLDAP Backend-specific options' "
712 "SUP olcConfig STRUCTURAL "
713 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
715 "NAME 'olcDatabaseConfig' "
716 "DESC 'OpenLDAP Database-specific options' "
717 "SUP olcConfig STRUCTURAL "
719 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
720 "olcLastMod $ olcLimits $ "
721 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
722 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
723 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
724 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ "
725 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
727 Cft_Database, NULL, cfAddDatabase },
729 "NAME 'olcOverlayConfig' "
730 "DESC 'OpenLDAP Overlay-specific options' "
731 "SUP olcConfig STRUCTURAL "
732 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
733 /* This should be STRUCTURAL like all the other database classes, but
734 * that would mean inheriting all of the olcDatabaseConfig attributes,
735 * which causes them to be merged twice in config_build_entry.
738 "NAME 'olcFrontendConfig' "
739 "DESC 'OpenLDAP frontend configuration' "
741 "MAY olcDefaultSearchBase )",
742 Cft_Database, NULL, NULL },
745 "NAME 'olcModuleList' "
746 "DESC 'OpenLDAP dynamic module info' "
747 "SUP olcConfig STRUCTURAL "
748 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
749 Cft_Module, NULL, cfAddModule },
754 typedef struct ServerID {
755 struct ServerID *si_next;
756 struct berval si_url;
760 static ServerID *sid_list;
763 config_generic(ConfigArgs *c) {
766 if ( c->op == SLAP_CONFIG_EMIT ) {
770 c->value_int = ldap_pvt_thread_get_concurrency();
773 c->value_int = connection_pool_max;
776 c->value_int = slap_tool_thread_max;
780 c->value_string = ch_strdup( passwd_salt );
785 if ( c->be->be_limits ) {
790 for ( i=0; c->be->be_limits[i]; i++ ) {
791 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
792 if ( bv.bv_len >= sizeof( buf ) ) {
793 ber_bvarray_free_x( c->rvalue_vals, NULL );
794 c->rvalue_vals = NULL;
798 bv.bv_val = buf + bv.bv_len;
799 limits_unparse( c->be->be_limits[i], &bv,
800 sizeof( buf ) - ( bv.bv_val - buf ) );
801 bv.bv_len += bv.bv_val - buf;
803 value_add_one( &c->rvalue_vals, &bv );
806 if ( !c->rvalue_vals ) rc = 1;
809 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_OP_WRITES) ==
810 SLAP_RESTRICT_OP_WRITES;
813 c->value_string = ch_strdup( slap_sasl_getpolicy());
816 slap_sasl_regexp_unparse( &c->rvalue_vals );
817 if ( !c->rvalue_vals ) rc = 1;
819 #ifdef HAVE_CYRUS_SASL
821 struct berval bv = BER_BVNULL;
822 slap_sasl_secprops_unparse( &bv );
823 if ( !BER_BVISNULL( &bv )) {
824 ber_bvarray_add( &c->rvalue_vals, &bv );
832 c->value_int = c->be->be_max_deref_depth;
835 if ( SLAP_DBHIDDEN( c->be )) {
842 ConfigFile *cf = c->private;
844 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
845 else if ( cf->c_om_head )
846 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
848 if ( !c->rvalue_vals )
853 ad_unparse_options( &c->rvalue_vals );
856 ConfigFile *cf = c->private;
858 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
859 else if ( cf->c_oc_head )
860 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
862 if ( !c->rvalue_vals )
867 ConfigFile *cf = c->private;
869 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
870 else if ( cf->c_at_head )
871 at_unparse( &c->rvalue_vals, cf->c_at_head,
873 if ( !c->rvalue_vals )
878 ConfigFile *cf = c->private;
880 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
881 else if ( cf->c_cr_head )
882 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
884 if ( !c->rvalue_vals )
891 char *src, *dst, ibuf[11];
892 struct berval bv, abv;
893 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
894 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
895 if ( abv.bv_len >= sizeof( ibuf ) ) {
896 ber_bvarray_free_x( c->rvalue_vals, NULL );
897 c->rvalue_vals = NULL;
901 acl_unparse( a, &bv );
902 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
903 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
904 /* Turn TAB / EOL into plain space */
905 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
906 if (isspace((unsigned char)*src)) *dst++ = ' ';
910 if (dst[-1] == ' ') {
914 abv.bv_len = dst - abv.bv_val;
915 ber_bvarray_add( &c->rvalue_vals, &abv );
921 ConfigFile *cf = c->private;
922 if ( cf->c_dseFiles ) {
923 value_add( &c->rvalue_vals, cf->c_dseFiles );
935 for ( si = sid_list; si; si=si->si_next ) {
936 if ( !BER_BVISEMPTY( &si->si_url )) {
937 bv.bv_len = si->si_url.bv_len + 6;
938 bv.bv_val = ch_malloc( bv.bv_len );
939 sprintf( bv.bv_val, "%d %s", si->si_num,
941 ber_bvarray_add( &c->rvalue_vals, &bv );
945 bv.bv_len = sprintf( buf, "%d", si->si_num );
946 value_add_one( &c->rvalue_vals, &bv );
955 c->value_string = ch_strdup( logfileName );
960 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
963 if ( SLAP_SHADOW(c->be))
964 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
969 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
971 case CFG_SSTR_IF_MAX:
972 c->value_int = index_substr_if_maxlen;
974 case CFG_SSTR_IF_MIN:
975 c->value_int = index_substr_if_minlen;
979 ModPaths *mp = c->private;
982 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
985 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
986 SLAP_X_ORDERED_FMT "%s", i,
987 mp->mp_loads[i].bv_val );
988 if ( bv.bv_len >= sizeof( c->log ) ) {
989 ber_bvarray_free_x( c->rvalue_vals, NULL );
990 c->rvalue_vals = NULL;
993 value_add_one( &c->rvalue_vals, &bv );
997 rc = c->rvalue_vals ? 0 : 1;
1001 ModPaths *mp = c->private;
1002 if ( !BER_BVISNULL( &mp->mp_path ))
1003 value_add_one( &c->rvalue_vals, &mp->mp_path );
1005 rc = c->rvalue_vals ? 0 : 1;
1011 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1012 if ( !c->rvalue_vals ) rc = 1;
1015 #ifdef SLAP_AUTH_REWRITE
1017 if ( authz_rewrites ) {
1018 struct berval bv, idx;
1023 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1024 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1025 if ( idx.bv_len >= sizeof( ibuf ) ) {
1026 ber_bvarray_free_x( c->rvalue_vals, NULL );
1027 c->rvalue_vals = NULL;
1030 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1031 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1032 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1033 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1034 authz_rewrites[i].bv_val,
1035 authz_rewrites[i].bv_len + 1 );
1036 ber_bvarray_add( &c->rvalue_vals, &bv );
1039 if ( !c->rvalue_vals ) rc = 1;
1046 } else if ( c->op == LDAP_MOD_DELETE ) {
1049 /* single-valued attrs, no-ops */
1057 case CFG_MIRRORMODE:
1058 case CFG_MONITORING:
1060 case CFG_SSTR_IF_MAX:
1061 case CFG_SSTR_IF_MIN:
1064 /* no-ops, requires slapd restart */
1069 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1073 ch_free( passwd_salt );
1078 ch_free( logfileName );
1082 case CFG_SERVERID: {
1084 ServerID *si, **sip;
1086 for ( i=0, si = sid_list, sip = &sid_list;
1087 si; si = *sip, i++ ) {
1088 if ( c->valx == -1 || i == c->valx ) {
1100 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1104 if ( c->valx < 0 ) {
1106 if ( c->be == frontendDB )
1109 end = frontendDB->be_acl;
1110 acl_destroy( c->be->be_acl, end );
1111 c->be->be_acl = end;
1114 AccessControl **prev, *a;
1116 for (i=0, prev = &c->be->be_acl; i < c->valx;
1119 prev = &a->acl_next;
1122 *prev = a->acl_next;
1128 CfEntryInfo *ce = c->ca_entry->e_private;
1129 /* can't modify the hardcoded schema */
1130 if ( ce->ce_parent->ce_type == Cft_Global )
1134 if ( c->valx < 0 ) {
1137 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1139 if ( oc == cfn->c_oc_tail )
1142 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1144 ObjectClass *oc, *prev = NULL;
1147 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1152 if ( cfn->c_oc_tail == oc ) {
1153 cfn->c_oc_tail = prev;
1155 if ( cfn->c_oc_head == oc ) {
1157 cfn->c_oc_head = oc;
1163 CfEntryInfo *ce = c->ca_entry->e_private;
1164 /* can't modify the hardcoded schema */
1165 if ( ce->ce_parent->ce_type == Cft_Global )
1169 if ( c->valx < 0 ) {
1172 for( at = cfn->c_at_head; at; at_next( &at )) {
1174 if ( at == cfn->c_at_tail )
1177 cfn->c_at_head = cfn->c_at_tail = NULL;
1179 AttributeType *at, *prev = NULL;
1182 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1187 if ( cfn->c_at_tail == at ) {
1188 cfn->c_at_tail = prev;
1190 if ( cfn->c_at_head == at ) {
1192 cfn->c_at_head = at;
1198 /* FIXME: there is no limits_free function */
1200 /* FIXME: there is no ad_option_free function */
1202 /* FIXME: there is no way to remove attributes added by
1216 if(!(c->bi = backend_info(c->argv[1]))) {
1217 snprintf( c->msg, sizeof( c->msg ), "<%s> failed init", c->argv[0] );
1218 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1219 c->log, c->msg, c->argv[1] );
1226 /* NOTE: config is always the first backend!
1228 if ( !strcasecmp( c->argv[1], "config" )) {
1229 c->be = LDAP_STAILQ_FIRST(&backendDB);
1230 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1233 c->be = backend_db_init(c->argv[1], NULL, c->valx);
1235 snprintf( c->msg, sizeof( c->msg ), "<%s> failed init", c->argv[0] );
1236 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1237 c->log, c->msg, c->argv[1] );
1244 ldap_pvt_thread_set_concurrency(c->value_int);
1248 if ( c->value_int < 2 ) {
1249 snprintf( c->msg, sizeof( c->msg ),
1250 "threads=%d smaller than minimum value 2",
1252 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1253 c->log, c->msg, 0 );
1256 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1257 snprintf( c->msg, sizeof( c->msg ),
1258 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1259 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1260 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1261 c->log, c->msg, 0 );
1263 if ( slapMode & SLAP_SERVER_MODE )
1264 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1265 connection_pool_max = c->value_int; /* save for reference */
1269 if ( slapMode & SLAP_TOOL_MODE )
1270 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1271 slap_tool_thread_max = c->value_int; /* save for reference */
1275 if ( passwd_salt ) ch_free( passwd_salt );
1276 passwd_salt = c->value_string;
1277 lutil_salt_format(passwd_salt);
1281 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1287 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
1289 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
1293 ch_free(c->value_string);
1294 if (slap_sasl_setpolicy( c->argv[1] )) {
1295 snprintf( c->msg, sizeof( c->msg ), "<%s> unable to parse value", c->argv[0] );
1296 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1297 c->log, c->msg, c->argv[1] );
1303 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1307 #ifdef HAVE_CYRUS_SASL
1310 char *txt = slap_sasl_secprops( c->argv[1] );
1312 snprintf( c->msg, sizeof(c->msg), "<%s> %s",
1314 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
1322 c->be->be_max_deref_depth = c->value_int;
1328 if ( c->op == LDAP_MOD_ADD && c->private && cfn != c->private )
1330 if(parse_oidm(c, 1, &om))
1332 if (!cfn->c_om_head) cfn->c_om_head = om;
1333 cfn->c_om_tail = om;
1338 ObjectClass *oc, *prev;
1340 if ( c->op == LDAP_MOD_ADD && c->private && cfn != c->private )
1342 if ( c->valx < 0 ) {
1343 prev = cfn->c_oc_tail;
1346 /* If adding anything after the first, prev is easy */
1349 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1354 /* If adding the first, and head exists, find its prev */
1355 if (cfn->c_oc_head) {
1356 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1361 /* else prev is NULL, append to end of global list */
1363 if(parse_oc(c, &oc, prev)) return(1);
1364 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1365 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1370 AttributeType *at, *prev;
1372 if ( c->op == LDAP_MOD_ADD && c->private && cfn != c->private )
1374 if ( c->valx < 0 ) {
1375 prev = cfn->c_at_tail;
1378 /* If adding anything after the first, prev is easy */
1381 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1386 /* If adding the first, and head exists, find its prev */
1387 if (cfn->c_at_head) {
1388 for ( at_start( &at ); at != cfn->c_at_head; ) {
1393 /* else prev is NULL, append to end of global list */
1395 if(parse_at(c, &at, prev)) return(1);
1396 if (!cfn->c_at_head) cfn->c_at_head = at;
1397 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1404 if ( c->op == LDAP_MOD_ADD && c->private && cfn != c->private )
1406 if(parse_cr(c, &cr)) return(1);
1407 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1408 cfn->c_cr_tail = cr;
1413 ad_define_option(NULL, NULL, 0);
1414 for(i = 1; i < c->argc; i++)
1415 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1420 /* Don't append to the global ACL if we're on a specific DB */
1422 if ( c->be != frontendDB && frontendDB->be_acl && c->valx == -1 ) {
1425 for ( a=c->be->be_acl; a && a != frontendDB->be_acl;
1429 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1435 if(root_dse_read_file(c->argv[1])) {
1436 snprintf( c->msg, sizeof( c->msg ), "<%s> could not read file", c->argv[0] );
1437 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1438 c->log, c->msg, c->argv[1] );
1443 ber_str2bv( c->argv[1], 0, 1, &bv );
1444 if ( c->op == LDAP_MOD_ADD && c->private && cfn != c->private )
1446 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1452 ServerID *si, **sip;
1454 int num = atoi( c->argv[1] );
1455 if ( num < 0 || num > SLAP_SYNC_SID_MAX ) {
1456 snprintf( c->msg, sizeof( c->msg ),
1457 "<%s> illegal server ID", c->argv[0] );
1458 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1459 c->log, c->msg, c->argv[1] );
1462 /* only one value allowed if no URL is given */
1463 if ( c->argc > 2 ) {
1466 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1467 snprintf( c->msg, sizeof( c->msg ),
1468 "<%s> only one server ID allowed now", c->argv[0] );
1469 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1470 c->log, c->msg, c->argv[1] );
1474 if ( ldap_url_parse( c->argv[2], &lud )) {
1475 snprintf( c->msg, sizeof( c->msg ),
1476 "<%s> invalid URL", c->argv[0] );
1477 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1478 c->log, c->msg, c->argv[2] );
1481 len = strlen( c->argv[2] );
1482 si = ch_malloc( sizeof(ServerID) + len + 1 );
1483 si->si_url.bv_val = (char *)(si+1);
1484 si->si_url.bv_len = len;
1485 strcpy( si->si_url.bv_val, c->argv[2] );
1488 snprintf( c->msg, sizeof( c->msg ),
1489 "<%s> unqualified server ID not allowed now", c->argv[0] );
1490 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1491 c->log, c->msg, c->argv[1] );
1494 si = ch_malloc( sizeof(ServerID) );
1495 BER_BVZERO( &si->si_url );
1496 slap_serverID = num;
1500 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
1503 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
1504 /* If hostname is empty, or is localhost, or matches
1505 * our hostname, this serverID refers to this host.
1506 * Compare it against listeners and ports.
1508 if ( !lud->lud_host || !lud->lud_host[0] ||
1509 !strncasecmp("localhost", lud->lud_host,
1510 STRLENOF("localhost")) ||
1511 !strcasecmp( global_host, lud->lud_host )) {
1512 Listener **l = slapd_get_listeners();
1515 for ( i=0; l[i]; i++ ) {
1518 ldap_url_parse( l[i]->sl_url.bv_val, &lu2 );
1520 if ( strcasecmp( lud->lud_scheme,
1523 if ( lud->lud_port != lu2->lud_port )
1525 /* Listener on ANY address */
1526 if ( !lu2->lud_host || !lu2->lud_host[0] ) {
1530 /* URL on ANY address */
1531 if ( !lud->lud_host || !lud->lud_host[0] ) {
1535 /* Listener has specific host, must
1538 if ( !strcasecmp( lud->lud_host,
1544 ldap_free_urldesc( lu2 );
1546 slap_serverID = si->si_num;
1553 ldap_free_urldesc( lud );
1558 if ( logfileName ) ch_free( logfileName );
1559 logfileName = c->value_string;
1560 logfile = fopen(logfileName, "w");
1561 if(logfile) lutil_debug_file(logfile);
1565 if(SLAP_NOLASTMODCMD(c->be)) {
1566 snprintf( c->msg, sizeof( c->msg ), "<%s> not available for %s database",
1567 c->argv[0], c->be->bd_info->bi_type );
1568 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1569 c->log, c->msg, 0 );
1573 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
1575 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
1578 case CFG_MIRRORMODE:
1579 if(!SLAP_SHADOW(c->be)) {
1580 snprintf( c->msg, sizeof( c->msg ), "<%s> database is not a shadow",
1582 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1583 c->log, c->msg, 0 );
1587 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
1589 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
1592 case CFG_MONITORING:
1594 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
1596 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
1601 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
1603 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
1606 case CFG_SSTR_IF_MAX:
1607 if (c->value_int < index_substr_if_minlen) {
1608 snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value", c->argv[0] );
1609 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
1610 c->log, c->msg, c->value_int );
1613 index_substr_if_maxlen = c->value_int;
1616 case CFG_SSTR_IF_MIN:
1617 if (c->value_int > index_substr_if_maxlen) {
1618 snprintf( c->msg, sizeof( c->msg ), "<%s> invalid value", c->argv[0] );
1619 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
1620 c->log, c->msg, c->value_int );
1623 index_substr_if_minlen = c->value_int;
1626 #ifdef SLAPD_MODULES
1628 /* If we're just adding a module on an existing modpath,
1629 * make sure we've selected the current path.
1631 if ( c->op == LDAP_MOD_ADD && c->private && modcur != c->private ) {
1632 modcur = c->private;
1633 /* This should never fail */
1634 if ( module_path( modcur->mp_path.bv_val )) {
1635 snprintf( c->msg, sizeof( c->msg ), "<%s> module path no longer valid",
1637 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
1638 c->log, c->msg, modcur->mp_path.bv_val );
1642 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
1644 /* Record this load on the current path */
1648 if ( c->op == SLAP_CONFIG_ADD ) {
1649 ptr = c->line + STRLENOF("moduleload");
1650 while (!isspace((unsigned char) *ptr)) ptr++;
1651 while (isspace((unsigned char) *ptr)) ptr++;
1655 ber_str2bv(ptr, 0, 1, &bv);
1656 ber_bvarray_add( &modcur->mp_loads, &bv );
1658 /* Check for any new hardcoded schema */
1659 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
1660 config_check_schema( NULL, &cfBackInfo );
1665 if(module_path(c->argv[1])) return(1);
1666 /* Record which path was used with each module */
1670 if (!modpaths.mp_loads) {
1673 mp = ch_malloc( sizeof( ModPaths ));
1674 modlast->mp_next = mp;
1676 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
1678 mp->mp_loads = NULL;
1689 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
1691 slapi_plugins_used++;
1695 #ifdef SLAP_AUTH_REWRITE
1700 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
1703 if ( c->argc > 1 ) {
1706 /* quote all args but the first */
1707 line = ldap_charray2str( c->argv, "\" \"" );
1708 ber_str2bv( line, 0, 0, &bv );
1709 s = ber_bvchr( &bv, '"' );
1710 assert( s != NULL );
1711 /* move the trailing quote of argv[0] to the end */
1712 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
1713 bv.bv_val[ bv.bv_len - 1 ] = '"';
1716 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
1719 ber_bvarray_add( &authz_rewrites, &bv );
1726 Debug( LDAP_DEBUG_ANY,
1727 "%s: unknown CFG_TYPE %d.\n",
1728 c->log, c->type, 0 );
1737 config_fname(ConfigArgs *c) {
1738 if(c->op == SLAP_CONFIG_EMIT) {
1740 ConfigFile *cf = c->private;
1741 value_add_one( &c->rvalue_vals, &cf->c_file );
1750 config_cfdir(ConfigArgs *c) {
1751 if(c->op == SLAP_CONFIG_EMIT) {
1752 if ( !BER_BVISEMPTY( &cfdir )) {
1753 value_add_one( &c->rvalue_vals, &cfdir );
1762 config_search_base(ConfigArgs *c) {
1763 if(c->op == SLAP_CONFIG_EMIT) {
1765 if (!BER_BVISEMPTY(&default_search_base)) {
1766 value_add_one(&c->rvalue_vals, &default_search_base);
1767 value_add_one(&c->rvalue_nvals, &default_search_nbase);
1771 } else if( c->op == LDAP_MOD_DELETE ) {
1772 ch_free( default_search_base.bv_val );
1773 ch_free( default_search_nbase.bv_val );
1774 BER_BVZERO( &default_search_base );
1775 BER_BVZERO( &default_search_nbase );
1779 if(c->bi || c->be != frontendDB) {
1780 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
1781 "prior to any backend or database definition\n",
1786 if(default_search_nbase.bv_len) {
1787 free(default_search_base.bv_val);
1788 free(default_search_nbase.bv_val);
1791 default_search_base = c->value_dn;
1792 default_search_nbase = c->value_ndn;
1797 config_passwd_hash(ConfigArgs *c) {
1799 if (c->op == SLAP_CONFIG_EMIT) {
1801 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
1802 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
1803 value_add_one(&c->rvalue_vals, &bv);
1806 } else if ( c->op == LDAP_MOD_DELETE ) {
1807 if ( c->valx < 0 ) {
1808 ldap_charray_free( default_passwd_hash );
1809 default_passwd_hash = NULL;
1812 ch_free( default_passwd_hash[i] );
1813 for (; default_passwd_hash[i]; i++ )
1814 default_passwd_hash[i] = default_passwd_hash[i+1];
1818 if(default_passwd_hash) {
1819 Debug(LDAP_DEBUG_ANY, "%s: "
1820 "already set default password_hash\n",
1824 for(i = 1; i < c->argc; i++) {
1825 if(!lutil_passwd_scheme(c->argv[i])) {
1826 snprintf( c->msg, sizeof( c->msg ), "<%s> scheme not available", c->argv[0] );
1827 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
1828 c->log, c->msg, c->argv[i]);
1830 ldap_charray_add(&default_passwd_hash, c->argv[i]);
1832 if(!default_passwd_hash) {
1833 snprintf( c->msg, sizeof( c->msg ), "<%s> no valid hashes found", c->argv[0] );
1834 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1835 c->log, c->msg, 0 );
1843 config_schema_dn(ConfigArgs *c) {
1844 if ( c->op == SLAP_CONFIG_EMIT ) {
1846 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
1847 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
1848 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
1852 } else if ( c->op == LDAP_MOD_DELETE ) {
1853 ch_free( c->be->be_schemadn.bv_val );
1854 ch_free( c->be->be_schemandn.bv_val );
1855 BER_BVZERO( &c->be->be_schemadn );
1856 BER_BVZERO( &c->be->be_schemandn );
1859 ch_free( c->be->be_schemadn.bv_val );
1860 ch_free( c->be->be_schemandn.bv_val );
1861 c->be->be_schemadn = c->value_dn;
1862 c->be->be_schemandn = c->value_ndn;
1867 config_sizelimit(ConfigArgs *c) {
1869 struct slap_limits_set *lim = &c->be->be_def_limit;
1870 if (c->op == SLAP_CONFIG_EMIT) {
1875 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
1876 if ( !BER_BVISEMPTY( &bv ))
1877 value_add_one( &c->rvalue_vals, &bv );
1881 } else if ( c->op == LDAP_MOD_DELETE ) {
1882 /* Reset to defaults */
1883 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
1884 lim->lms_s_hard = 0;
1885 lim->lms_s_unchecked = -1;
1887 lim->lms_s_pr_hide = 0;
1888 lim->lms_s_pr_total = 0;
1891 for(i = 1; i < c->argc; i++) {
1892 if(!strncasecmp(c->argv[i], "size", 4)) {
1893 rc = limits_parse_one(c->argv[i], lim);
1895 snprintf( c->msg, sizeof( c->msg ), "<%s> unable to parse value", c->argv[0] );
1896 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1897 c->log, c->msg, c->argv[i]);
1901 if(!strcasecmp(c->argv[i], "unlimited")) {
1902 lim->lms_s_soft = -1;
1904 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
1905 snprintf( c->msg, sizeof( c->msg ), "<%s> unable to parse limit", c->argv[0]);
1906 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1907 c->log, c->msg, c->argv[i]);
1911 lim->lms_s_hard = 0;
1918 config_timelimit(ConfigArgs *c) {
1920 struct slap_limits_set *lim = &c->be->be_def_limit;
1921 if (c->op == SLAP_CONFIG_EMIT) {
1926 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
1927 if ( !BER_BVISEMPTY( &bv ))
1928 value_add_one( &c->rvalue_vals, &bv );
1932 } else if ( c->op == LDAP_MOD_DELETE ) {
1933 /* Reset to defaults */
1934 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
1935 lim->lms_t_hard = 0;
1938 for(i = 1; i < c->argc; i++) {
1939 if(!strncasecmp(c->argv[i], "time", 4)) {
1940 rc = limits_parse_one(c->argv[i], lim);
1942 snprintf( c->msg, sizeof( c->msg ), "<%s> unable to parse value", c->argv[0] );
1943 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1944 c->log, c->msg, c->argv[i]);
1948 if(!strcasecmp(c->argv[i], "unlimited")) {
1949 lim->lms_t_soft = -1;
1951 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
1952 snprintf( c->msg, sizeof( c->msg ), "<%s> unable to parse limit", c->argv[0]);
1953 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1954 c->log, c->msg, c->argv[i]);
1958 lim->lms_t_hard = 0;
1965 config_overlay(ConfigArgs *c) {
1966 if (c->op == SLAP_CONFIG_EMIT) {
1968 } else if ( c->op == LDAP_MOD_DELETE ) {
1971 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
1974 Debug( LDAP_DEBUG_ANY,
1975 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
1976 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
1978 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi)) {
1985 config_subordinate(ConfigArgs *c)
1991 case SLAP_CONFIG_EMIT:
1992 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
1995 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
1996 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
1999 value_add_one( &c->rvalue_vals, &bv );
2003 case LDAP_MOD_DELETE:
2004 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2005 glue_sub_del( c->be );
2007 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2012 case SLAP_CONFIG_ADD:
2013 advertise = ( c->argc == 2 && !strcasecmp( c->argv[1], "advertise" ));
2014 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2021 config_suffix(ConfigArgs *c)
2024 struct berval pdn, ndn;
2025 char *notallowed = NULL;
2027 if ( c->be == frontendDB ) {
2028 notallowed = "frontend";
2030 } else if ( SLAP_MONITOR(c->be) ) {
2031 notallowed = "monitor";
2033 } else if ( SLAP_CONFIG(c->be) ) {
2034 notallowed = "config";
2037 if ( notallowed != NULL ) {
2038 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2042 case LDAP_MOD_DELETE:
2043 case LDAP_MOD_REPLACE:
2044 case LDAP_MOD_INCREMENT:
2045 case SLAP_CONFIG_ADD:
2046 if ( !BER_BVISNULL( &c->value_dn ) ) {
2047 snprintf( buf, sizeof( buf ), "<%s> ",
2048 c->value_dn.bv_val );
2051 Debug(LDAP_DEBUG_ANY,
2052 "%s: suffix %snot allowed in %s database.\n",
2053 c->log, buf, notallowed );
2056 case SLAP_CONFIG_EMIT:
2057 /* don't complain when emitting... */
2061 /* FIXME: don't know what values may be valid;
2062 * please remove assertion, or add legal values
2063 * to either block */
2071 if (c->op == SLAP_CONFIG_EMIT) {
2072 if ( c->be->be_suffix == NULL
2073 || BER_BVISNULL( &c->be->be_suffix[0] ) )
2077 value_add( &c->rvalue_vals, c->be->be_suffix );
2078 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
2081 } else if ( c->op == LDAP_MOD_DELETE ) {
2082 if ( c->valx < 0 ) {
2083 ber_bvarray_free( c->be->be_suffix );
2084 ber_bvarray_free( c->be->be_nsuffix );
2085 c->be->be_suffix = NULL;
2086 c->be->be_nsuffix = NULL;
2089 ch_free( c->be->be_suffix[i].bv_val );
2090 ch_free( c->be->be_nsuffix[i].bv_val );
2092 c->be->be_suffix[i] = c->be->be_suffix[i+1];
2093 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
2095 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
2100 #ifdef SLAPD_MONITOR_DN
2101 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
2102 snprintf( c->msg, sizeof( c->msg ), "<%s> DN is reserved for monitoring slapd",
2104 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2105 c->log, c->msg, SLAPD_MONITOR_DN);
2112 if (SLAP_DBHIDDEN( c->be ))
2115 tbe = select_backend(&ndn, 0, 0);
2117 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
2123 BackendDB *b2 = tbe;
2125 /* Does tbe precede be? */
2126 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
2129 char *type = tbe->bd_info->bi_type;
2131 if ( overlay_is_over( tbe ) ) {
2132 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
2133 type = oi->oi_orig->bi_type;
2136 snprintf( c->msg, sizeof( c->msg ), "<%s> namingContext \"%s\" "
2137 "already served by a preceding %s database",
2138 c->argv[0], pdn.bv_val, type );
2139 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
2140 c->log, c->msg, tbe->be_suffix[0].bv_val);
2146 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
2147 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
2148 "base provided \"%s\" (assuming okay)\n",
2149 c->log, default_search_base.bv_val, 0);
2151 ber_bvarray_add(&c->be->be_suffix, &pdn);
2152 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
2157 config_rootdn(ConfigArgs *c) {
2158 if (c->op == SLAP_CONFIG_EMIT) {
2159 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
2160 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
2161 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
2166 } else if ( c->op == LDAP_MOD_DELETE ) {
2167 ch_free( c->be->be_rootdn.bv_val );
2168 ch_free( c->be->be_rootndn.bv_val );
2169 BER_BVZERO( &c->be->be_rootdn );
2170 BER_BVZERO( &c->be->be_rootndn );
2173 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
2174 ch_free( c->be->be_rootdn.bv_val );
2175 ch_free( c->be->be_rootndn.bv_val );
2177 c->be->be_rootdn = c->value_dn;
2178 c->be->be_rootndn = c->value_ndn;
2183 config_rootpw(ConfigArgs *c) {
2186 if (c->op == SLAP_CONFIG_EMIT) {
2187 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
2188 /* don't copy, because "rootpw" is marked
2190 c->value_bv = c->be->be_rootpw;
2194 } else if ( c->op == LDAP_MOD_DELETE ) {
2195 ch_free( c->be->be_rootpw.bv_val );
2196 BER_BVZERO( &c->be->be_rootpw );
2200 tbe = select_backend(&c->be->be_rootndn, 0, 0);
2202 snprintf( c->msg, sizeof( c->msg ), "<%s> can only be set when rootdn is under suffix",
2204 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2208 if ( !BER_BVISNULL( &c->be->be_rootpw ))
2209 ch_free( c->be->be_rootpw.bv_val );
2210 c->be->be_rootpw = c->value_bv;
2215 config_restrict(ConfigArgs *c) {
2216 slap_mask_t restrictops = 0;
2218 slap_verbmasks restrictable_ops[] = {
2219 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
2220 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
2221 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
2222 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
2223 { BER_BVC("modrdn"), 0 },
2224 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
2225 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
2226 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
2227 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
2228 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
2229 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
2230 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
2231 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
2232 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
2233 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
2234 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
2238 if (c->op == SLAP_CONFIG_EMIT) {
2239 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
2241 } else if ( c->op == LDAP_MOD_DELETE ) {
2243 c->be->be_restrictops = 0;
2245 restrictops = verb_to_mask( c->line, restrictable_ops );
2246 c->be->be_restrictops ^= restrictops;
2250 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
2252 snprintf( c->msg, sizeof( c->msg ), "<%s> unknown operation", c->argv[0] );
2253 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2254 c->log, c->msg, c->argv[i]);
2257 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
2258 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
2259 c->be->be_restrictops |= restrictops;
2264 config_allows(ConfigArgs *c) {
2265 slap_mask_t allows = 0;
2267 slap_verbmasks allowable_ops[] = {
2268 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
2269 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
2270 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
2271 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
2272 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
2275 if (c->op == SLAP_CONFIG_EMIT) {
2276 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
2277 } else if ( c->op == LDAP_MOD_DELETE ) {
2281 allows = verb_to_mask( c->line, allowable_ops );
2282 global_allows ^= allows;
2286 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
2288 snprintf( c->msg, sizeof( c->msg ), "<%s> unknown feature", c->argv[0] );
2289 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2290 c->log, c->msg, c->argv[i]);
2293 global_allows |= allows;
2298 config_disallows(ConfigArgs *c) {
2299 slap_mask_t disallows = 0;
2301 slap_verbmasks disallowable_ops[] = {
2302 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
2303 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
2304 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
2305 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
2308 if (c->op == SLAP_CONFIG_EMIT) {
2309 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
2310 } else if ( c->op == LDAP_MOD_DELETE ) {
2312 global_disallows = 0;
2314 disallows = verb_to_mask( c->line, disallowable_ops );
2315 global_disallows ^= disallows;
2319 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
2321 snprintf( c->msg, sizeof( c->msg ), "<%s> unknown feature", c->argv[0] );
2322 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2323 c->log, c->msg, c->argv[i]);
2326 global_disallows |= disallows;
2331 config_requires(ConfigArgs *c) {
2332 slap_mask_t requires = frontendDB->be_requires;
2333 int i, argc = c->argc;
2334 char **argv = c->argv;
2336 slap_verbmasks requires_ops[] = {
2337 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
2338 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
2339 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
2340 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
2341 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
2344 if (c->op == SLAP_CONFIG_EMIT) {
2345 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
2346 } else if ( c->op == LDAP_MOD_DELETE ) {
2348 c->be->be_requires = 0;
2350 requires = verb_to_mask( c->line, requires_ops );
2351 c->be->be_requires ^= requires;
2355 /* "none" can only be first, to wipe out default/global values */
2356 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
2361 i = verbs_to_mask(argc, argv, requires_ops, &requires);
2363 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
2364 snprintf( c->msg, sizeof( c->msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
2365 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2368 snprintf( c->msg, sizeof( c->msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
2369 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2370 c->log, c->msg, c->argv[i]);
2374 c->be->be_requires = requires;
2378 static slap_verbmasks *loglevel_ops;
2381 loglevel_init( void )
2383 slap_verbmasks lo[] = {
2384 { BER_BVC("Any"), -1 },
2385 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
2386 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
2387 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
2388 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
2389 { BER_BVC("BER"), LDAP_DEBUG_BER },
2390 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
2391 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
2392 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
2393 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
2394 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
2395 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
2396 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
2397 #if 0 /* no longer used (nor supported) */
2398 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
2399 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
2401 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
2402 { BER_BVC("None"), LDAP_DEBUG_NONE },
2406 return slap_verbmasks_init( &loglevel_ops, lo );
2410 loglevel_destroy( void )
2412 if ( loglevel_ops ) {
2413 (void)slap_verbmasks_destroy( loglevel_ops );
2415 loglevel_ops = NULL;
2418 static slap_mask_t loglevel_ignore[] = { -1, 0 };
2421 slap_loglevel_register( slap_mask_t m, struct berval *s )
2425 if ( loglevel_ops == NULL ) {
2429 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
2432 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
2440 slap_loglevel_get( struct berval *s, int *l )
2446 if ( loglevel_ops == NULL ) {
2450 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
2451 m |= loglevel_ops[ i ].mask;
2456 for ( i = 1; i <= ( 1 << ( sizeof( int ) * 8 - 1 ) ) && !( m & i ); i <<= 1 )
2463 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
2466 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
2477 str2loglevel( const char *s, int *l )
2481 if ( loglevel_ops == NULL ) {
2485 i = verb_to_mask( s, loglevel_ops );
2487 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
2491 *l = loglevel_ops[ i ].mask;
2497 loglevel2str( int l )
2499 struct berval bv = BER_BVNULL;
2501 loglevel2bv( l, &bv );
2507 loglevel2bv( int l, struct berval *bv )
2509 if ( loglevel_ops == NULL ) {
2515 return enum_to_verb( loglevel_ops, l, bv ) == -1;
2519 loglevel2bvarray( int l, BerVarray *bva )
2521 if ( loglevel_ops == NULL ) {
2525 return mask_to_verbs( loglevel_ops, l, bva );
2529 loglevel_print( FILE *out )
2533 if ( loglevel_ops == NULL ) {
2537 fprintf( out, "Installed log subsystems:\n\n" );
2538 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
2539 fprintf( out, "\t%-30s (%lu)\n",
2540 loglevel_ops[ i ].word.bv_val,
2541 loglevel_ops[ i ].mask );
2544 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
2545 "by specific code\n\n" );
2550 static int config_syslog;
2553 config_loglevel(ConfigArgs *c) {
2556 if ( loglevel_ops == NULL ) {
2560 if (c->op == SLAP_CONFIG_EMIT) {
2561 /* Get default or commandline slapd setting */
2562 if ( ldap_syslog && !config_syslog )
2563 config_syslog = ldap_syslog;
2564 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
2566 } else if ( c->op == LDAP_MOD_DELETE ) {
2570 int level = verb_to_mask( c->line, loglevel_ops );
2571 config_syslog ^= level;
2573 if ( slapMode & SLAP_SERVER_MODE ) {
2574 ldap_syslog = config_syslog;
2581 for( i=1; i < c->argc; i++ ) {
2584 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
2585 if( lutil_atoi( &level, c->argv[i] ) != 0 ) {
2586 snprintf( c->msg, sizeof( c->msg ), "<%s> unable to parse level", c->argv[0] );
2587 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2588 c->log, c->msg, c->argv[i]);
2592 if ( str2loglevel( c->argv[i], &level ) ) {
2593 snprintf( c->msg, sizeof( c->msg ), "<%s> unknown level", c->argv[0] );
2594 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2595 c->log, c->msg, c->argv[i]);
2599 config_syslog |= level;
2601 if ( slapMode & SLAP_SERVER_MODE ) {
2602 ldap_syslog = config_syslog;
2608 config_referral(ConfigArgs *c) {
2610 if (c->op == SLAP_CONFIG_EMIT) {
2611 if ( default_referral ) {
2612 value_add( &c->rvalue_vals, default_referral );
2617 } else if ( c->op == LDAP_MOD_DELETE ) {
2618 if ( c->valx < 0 ) {
2619 ber_bvarray_free( default_referral );
2620 default_referral = NULL;
2623 ch_free( default_referral[i].bv_val );
2624 for (; default_referral[i].bv_val; i++ )
2625 default_referral[i] = default_referral[i+1];
2629 if(validate_global_referral(c->argv[1])) {
2630 snprintf( c->msg, sizeof( c->msg ), "<%s> invalid URL", c->argv[0] );
2631 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2632 c->log, c->msg, c->argv[1]);
2636 ber_str2bv(c->argv[1], 0, 0, &val);
2637 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
2645 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
2646 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
2647 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
2648 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
2649 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
2650 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
2651 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
2652 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
2653 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
2658 config_security(ConfigArgs *c) {
2659 slap_ssf_set_t *set = &c->be->be_ssf_set;
2662 if (c->op == SLAP_CONFIG_EMIT) {
2668 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
2669 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
2672 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
2673 if ( bv.bv_len >= sizeof( numbuf ) ) {
2674 ber_bvarray_free_x( c->rvalue_vals, NULL );
2675 c->rvalue_vals = NULL;
2679 bv.bv_len += sec_keys[i].key.bv_len;
2680 bv.bv_val = ch_malloc( bv.bv_len + 1);
2681 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
2682 strcpy( next, numbuf );
2683 ber_bvarray_add( &c->rvalue_vals, &bv );
2688 for(i = 1; i < c->argc; i++) {
2689 slap_ssf_t *tgt = NULL;
2691 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
2692 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
2693 sec_keys[j].key.bv_len)) {
2694 src = c->argv[i] + sec_keys[j].key.bv_len;
2695 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
2700 snprintf( c->msg, sizeof( c->msg ), "<%s> unknown factor", c->argv[0] );
2701 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2702 c->log, c->msg, c->argv[i]);
2706 if ( lutil_atou( tgt, src ) != 0 ) {
2707 snprintf( c->msg, sizeof( c->msg ), "<%s> unable to parse factor", c->argv[0] );
2708 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2709 c->log, c->msg, c->argv[i]);
2717 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
2721 for (; !BER_BVISNULL( &an->an_name ); an++) {
2722 /* if buflen == 0, assume the buffer size has been
2723 * already checked otherwise */
2724 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
2725 if ( comma ) *ptr++ = ',';
2726 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
2733 config_updatedn(ConfigArgs *c) {
2734 if (c->op == SLAP_CONFIG_EMIT) {
2735 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
2736 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
2737 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
2741 } else if ( c->op == LDAP_MOD_DELETE ) {
2742 ch_free( c->be->be_update_ndn.bv_val );
2743 BER_BVZERO( &c->be->be_update_ndn );
2744 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
2747 if(SLAP_SHADOW(c->be)) {
2748 snprintf( c->msg, sizeof( c->msg ), "<%s> database already shadowed", c->argv[0] );
2749 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2754 ber_memfree_x( c->value_dn.bv_val, NULL );
2755 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
2756 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
2758 c->be->be_update_ndn = c->value_ndn;
2759 BER_BVZERO( &c->value_dn );
2760 BER_BVZERO( &c->value_ndn );
2762 return config_slurp_shadow( c );
2766 config_shadow( ConfigArgs *c, int flag )
2768 char *notallowed = NULL;
2770 if ( c->be == frontendDB ) {
2771 notallowed = "frontend";
2773 } else if ( SLAP_MONITOR(c->be) ) {
2774 notallowed = "monitor";
2777 if ( notallowed != NULL ) {
2778 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
2782 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
2788 config_updateref(ConfigArgs *c) {
2790 if (c->op == SLAP_CONFIG_EMIT) {
2791 if ( c->be->be_update_refs ) {
2792 value_add( &c->rvalue_vals, c->be->be_update_refs );
2797 } else if ( c->op == LDAP_MOD_DELETE ) {
2798 if ( c->valx < 0 ) {
2799 ber_bvarray_free( c->be->be_update_refs );
2800 c->be->be_update_refs = NULL;
2803 ch_free( c->be->be_update_refs[i].bv_val );
2804 for (; c->be->be_update_refs[i].bv_val; i++)
2805 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
2809 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
2810 snprintf( c->msg, sizeof( c->msg ), "<%s> must appear after syncrepl or updatedn",
2812 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2817 if(validate_global_referral(c->argv[1])) {
2818 snprintf( c->msg, sizeof( c->msg ), "<%s> invalid URL", c->argv[0] );
2819 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2820 c->log, c->msg, c->argv[1]);
2823 ber_str2bv(c->argv[1], 0, 0, &val);
2824 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
2829 config_obsolete(ConfigArgs *c) {
2830 if (c->op == SLAP_CONFIG_EMIT)
2833 snprintf( c->msg, sizeof( c->msg ), "<%s> keyword is obsolete (ignored)",
2835 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0);
2840 config_include(ConfigArgs *c) {
2841 int savelineno = c->lineno;
2844 ConfigFile *cfsave = cfn;
2845 ConfigFile *cf2 = NULL;
2847 /* No dynamic config for include files */
2848 cf = ch_calloc( 1, sizeof(ConfigFile));
2849 if ( cfn->c_kids ) {
2850 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
2856 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
2857 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
2858 c->lineno = savelineno - 1;
2861 if ( cf2 ) cf2->c_sibs = NULL;
2862 else cfn->c_kids = NULL;
2863 ch_free( cf->c_file.bv_val );
2873 config_tls_option(ConfigArgs *c) {
2875 LDAP *ld = slap_tls_ld;
2877 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
2878 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
2879 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
2880 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
2881 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
2882 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
2883 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
2884 default: Debug(LDAP_DEBUG_ANY, "%s: "
2885 "unknown tls_option <0x%x>\n",
2886 c->log, c->type, 0);
2889 if (c->op == SLAP_CONFIG_EMIT) {
2890 return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
2891 } else if ( c->op == LDAP_MOD_DELETE ) {
2892 return ldap_pvt_tls_set_option( ld, flag, NULL );
2894 ch_free(c->value_string);
2895 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
2898 /* FIXME: this ought to be provided by libldap */
2900 config_tls_config(ConfigArgs *c) {
2903 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
2904 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
2906 Debug(LDAP_DEBUG_ANY, "%s: "
2907 "unknown tls_option <0x%x>\n",
2908 c->log, c->type, 0);
2911 if (c->op == SLAP_CONFIG_EMIT) {
2912 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
2913 } else if ( c->op == LDAP_MOD_DELETE ) {
2915 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
2917 ch_free( c->value_string );
2918 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
2919 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
2920 Debug(LDAP_DEBUG_ANY, "%s: "
2921 "unable to parse %s \"%s\"\n",
2922 c->log, c->argv[0], c->argv[1] );
2925 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
2927 return(ldap_int_tls_config(slap_tls_ld, flag, c->argv[1]));
2932 static CfEntryInfo *
2933 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
2943 if ( dn_match( &root->ce_entry->e_nname, dn ))
2946 c = dn->bv_val+dn->bv_len;
2947 for (;*c != ',';c--);
2951 for (--c;c>dn->bv_val && *c != ',';c--);
2955 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
2957 root = root->ce_kids;
2959 for (;root;root=root->ce_sibs) {
2960 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
2961 if ( cdn.bv_val == dn->bv_val ) {
2971 typedef struct setup_cookie {
2981 config_ldif_resp( Operation *op, SlapReply *rs )
2983 if ( rs->sr_type == REP_SEARCH ) {
2984 setup_cookie *sc = op->o_callback->sc_private;
2986 sc->cfb->cb_got_ldif = 1;
2987 /* Does the frontend exist? */
2988 if ( !sc->got_frontend ) {
2989 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
2990 "olcDatabase", STRLENOF( "olcDatabase" ))) {
2991 if ( strncmp( rs->sr_entry->e_nname.bv_val +
2992 STRLENOF( "olcDatabase" ), "={-1}frontend",
2993 STRLENOF( "={-1}frontend" ))) {
2996 sc->ca->be = frontendDB;
2997 sc->ca->bi = frontendDB->bd_info;
2998 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
2999 rdn.bv_val = sc->ca->log;
3000 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
3001 "%s=" SLAP_X_ORDERED_FMT "%s",
3002 cfAd_database->ad_cname.bv_val, -1,
3003 sc->ca->bi->bi_type);
3005 sc->frontend = config_build_entry( op, rs,
3006 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
3007 sc->ca->be->be_cf_ocs );
3016 /* Does the configDB exist? */
3017 if ( sc->got_frontend && !sc->got_config &&
3018 !strncmp( rs->sr_entry->e_nname.bv_val,
3019 "olcDatabase", STRLENOF( "olcDatabase" ))) {
3020 if ( strncmp( rs->sr_entry->e_nname.bv_val +
3021 STRLENOF( "olcDatabase" ), "={0}config",
3022 STRLENOF( "={0}config" ))) {
3025 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
3026 sc->ca->bi = sc->ca->be->bd_info;
3027 rdn.bv_val = sc->ca->log;
3028 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
3029 "%s=" SLAP_X_ORDERED_FMT "%s",
3030 cfAd_database->ad_cname.bv_val, 0,
3031 sc->ca->bi->bi_type);
3033 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
3034 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
3041 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
3042 if ( rs->sr_err != LDAP_SUCCESS ) {
3043 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
3044 rs->sr_entry->e_name.bv_val, sc->ca->msg, 0 );
3050 /* Configure and read the underlying back-ldif store */
3052 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
3053 CfBackInfo *cfb = be->be_private;
3059 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
3060 Connection conn = {0};
3061 OperationBuffer opbuf;
3063 SlapReply rs = {REP_RESULT};
3064 Filter filter = { LDAP_FILTER_PRESENT };
3065 struct berval filterstr = BER_BVC("(objectclass=*)");
3068 /* Is the config directory available? */
3069 if ( stat( dir, &st ) < 0 ) {
3070 /* No, so don't bother using the backing store.
3071 * All changes will be in-memory only.
3076 cfb->cb_db.bd_info = backend_info( "ldif" );
3077 if ( !cfb->cb_db.bd_info )
3078 return 0; /* FIXME: eventually this will be a fatal error */
3080 if ( backend_db_init( "ldif", &cfb->cb_db, -1 ) == NULL )
3083 cfb->cb_db.be_suffix = be->be_suffix;
3084 cfb->cb_db.be_nsuffix = be->be_nsuffix;
3086 /* The suffix is always "cn=config". The underlying DB's rootdn
3087 * is always the same as the suffix.
3089 cfb->cb_db.be_rootdn = be->be_suffix[0];
3090 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
3092 ber_str2bv( dir, 0, 1, &cfdir );
3097 argv[0] = "directory";
3098 argv[1] = (char *)dir;
3101 c.table = Cft_Database;
3103 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
3107 if ( config_add_vals( ct, &c ))
3110 if ( backend_startup_one( &cfb->cb_db ))
3114 void *thrctx = ldap_pvt_thread_pool_context();
3117 op = (Operation *) &opbuf;
3118 connection_fake_init( &conn, op, thrctx );
3120 filter.f_desc = slap_schema.si_ad_objectClass;
3122 op->o_tag = LDAP_REQ_SEARCH;
3124 op->ors_filter = &filter;
3125 op->ors_filterstr = filterstr;
3126 op->ors_scope = LDAP_SCOPE_SUBTREE;
3128 op->o_dn = c.be->be_rootdn;
3129 op->o_ndn = c.be->be_rootndn;
3131 op->o_req_dn = be->be_suffix[0];
3132 op->o_req_ndn = be->be_nsuffix[0];
3134 op->ors_tlimit = SLAP_NO_LIMIT;
3135 op->ors_slimit = SLAP_NO_LIMIT;
3137 op->ors_attrs = slap_anlist_all_attributes;
3138 op->ors_attrsonly = 0;
3140 op->o_callback = &cb;
3143 cb.sc_private = ≻
3144 sc.got_frontend = 0;
3149 op->o_bd = &cfb->cb_db;
3151 /* Allow unknown attrs in DNs */
3152 prev_DN_strict = slap_DN_strict;
3155 rc = op->o_bd->be_search( op, &rs );
3157 /* Restore normal DN validation */
3158 slap_DN_strict = prev_DN_strict;
3160 op->o_tag = LDAP_REQ_ADD;
3161 if ( rc == LDAP_SUCCESS && sc.frontend ) {
3162 op->ora_e = sc.frontend;
3163 rc = op->o_bd->be_add( op, &rs );
3165 if ( rc == LDAP_SUCCESS && sc.config ) {
3166 op->ora_e = sc.config;
3167 rc = op->o_bd->be_add( op, &rs );
3169 ldap_pvt_thread_pool_context_reset( thrctx );
3172 /* ITS#4194 - only use if it's present, or we're converting. */
3173 if ( !readit || rc == LDAP_SUCCESS )
3174 cfb->cb_use_ldif = 1;
3180 CfOc_cmp( const void *c1, const void *c2 ) {
3181 const ConfigOCs *co1 = c1;
3182 const ConfigOCs *co2 = c2;
3184 return ber_bvcmp( co1->co_name, co2->co_name );
3188 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
3191 i = init_config_attrs( ct );
3194 /* set up the objectclasses */
3195 i = init_config_ocs( ocs );
3198 for (i=0; ocs[i].co_def; i++) {
3199 if ( ocs[i].co_oc ) {
3200 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
3201 if ( !ocs[i].co_table )
3202 ocs[i].co_table = ct;
3203 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
3210 read_config(const char *fname, const char *dir) {
3213 const char *cfdir, *cfname;
3216 /* Setup the config backend */
3217 be = backend_db_init( "config", NULL, 0 );
3221 cfb = be->be_private;
3222 be->be_dfltaccess = ACL_NONE;
3224 /* If no .conf, or a dir was specified, setup the dir */
3225 if ( !fname || dir ) {
3227 /* If explicitly given, check for existence */
3230 if ( stat( dir, &st ) < 0 ) {
3231 Debug( LDAP_DEBUG_ANY,
3232 "invalid config directory %s, error %d\n",
3238 cfdir = SLAPD_DEFAULT_CONFIGDIR;
3240 /* if fname is defaulted, try reading .d */
3241 rc = config_setup_ldif( be, cfdir, !fname );
3244 /* It may be OK if the base object doesn't exist yet. */
3245 if ( rc != LDAP_NO_SUCH_OBJECT )
3247 /* ITS#4194: But if dir was specified and no fname,
3248 * then we were supposed to read the dir. Unless we're
3249 * trying to slapadd the dir...
3251 if ( dir && !fname ) {
3252 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
3254 /* Assume it's slapadd with a config dir, let it continue */
3256 cfb->cb_got_ldif = 1;
3257 cfb->cb_use_ldif = 1;
3262 /* If we read the config from back-ldif, nothing to do here */
3263 if ( cfb->cb_got_ldif ) {
3272 cfname = SLAPD_DEFAULT_CONFIGFILE;
3274 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
3277 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
3280 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
3281 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
3282 &frontendDB->be_schemadn );
3283 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
3284 if ( rc != LDAP_SUCCESS ) {
3285 Debug(LDAP_DEBUG_ANY, "read_config: "
3286 "unable to normalize default schema DN \"%s\"\n",
3287 frontendDB->be_schemadn.bv_val, 0, 0 );
3288 /* must not happen */
3296 config_back_bind( Operation *op, SlapReply *rs )
3298 if ( op->orb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op )) {
3299 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
3300 /* frontend sends result */
3301 return LDAP_SUCCESS;
3304 rs->sr_err = LDAP_INVALID_CREDENTIALS;
3305 send_ldap_result( op, rs );
3311 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
3315 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
3317 rs->sr_attrs = op->ors_attrs;
3318 rs->sr_entry = ce->ce_entry;
3320 rc = send_search_entry( op, rs );
3322 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
3323 if ( ce->ce_kids ) {
3324 rc = config_send( op, rs, ce->ce_kids, 1 );
3325 if ( rc ) return rc;
3328 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
3329 rc = config_send( op, rs, ce, 0 );
3337 static ConfigTable *
3338 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
3343 for (j=0; j<nocs; j++) {
3344 for (i=0; colst[j]->co_table[i].name; i++)
3345 if ( colst[j]->co_table[i].ad == ad ) {
3346 ca->table = colst[j]->co_type;
3347 return &colst[j]->co_table[i];
3353 /* Sort the attributes of the entry according to the order defined
3354 * in the objectclass, with required attributes occurring before
3355 * allowed attributes. For any attributes with sequencing dependencies
3356 * (e.g., rootDN must be defined after suffix) the objectclass must
3357 * list the attributes in the desired sequence.
3360 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
3362 Attribute *a, *head = NULL, *tail = NULL, **prev;
3365 for (i=0; i<nocs; i++) {
3366 if ( colst[i]->co_oc->soc_required ) {
3367 AttributeType **at = colst[i]->co_oc->soc_required;
3368 for (j=0; at[j]; j++) {
3369 for (a=e->e_attrs, prev=&e->e_attrs; a;
3370 prev = &(*prev)->a_next, a=a->a_next) {
3371 if ( a->a_desc == at[j]->sat_ad ) {
3385 if ( colst[i]->co_oc->soc_allowed ) {
3386 AttributeType **at = colst[i]->co_oc->soc_allowed;
3387 for (j=0; at[j]; j++) {
3388 for (a=e->e_attrs, prev=&e->e_attrs; a;
3389 prev = &(*prev)->a_next, a=a->a_next) {
3390 if ( a->a_desc == at[j]->sat_ad ) {
3406 tail->a_next = e->e_attrs;
3412 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
3414 Attribute *a = NULL;
3415 AttributeDescription *ad;
3425 Modifications *ml = ptr;
3427 vals = ml->sml_values;
3430 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
3431 rc = ordered_value_sort( a, 1 );
3433 snprintf(ca->msg, sizeof( ca->msg ), "ordered_value_sort failed on attr %s\n",
3434 ad->ad_cname.bv_val );
3438 for ( i=0; vals[i].bv_val; i++ ) {
3439 ca->line = vals[i].bv_val;
3440 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
3441 ca->line[0] == '{' ) {
3442 char *idx = strchr( ca->line, '}' );
3443 if ( idx ) ca->line = idx+1;
3445 rc = config_parse_vals( ct, ca, i );
3454 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
3457 struct berval rtype, rval;
3459 AttributeDescription *ad = NULL;
3461 dnRdn( &e->e_name, rdn );
3462 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
3463 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
3464 rtype.bv_val = rdn->bv_val;
3465 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
3468 slap_bv2ad( &rtype, &ad, &rs->sr_text );
3469 a = attr_find( e->e_attrs, ad );
3470 if (!a ) return LDAP_NAMING_VIOLATION;
3477 config_rename_kids( CfEntryInfo *ce )
3480 struct berval rdn, nrdn;
3482 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
3483 dnRdn ( &ce2->ce_entry->e_name, &rdn );
3484 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
3485 free( ce2->ce_entry->e_name.bv_val );
3486 free( ce2->ce_entry->e_nname.bv_val );
3487 build_new_dn( &ce2->ce_entry->e_name, &ce->ce_entry->e_name,
3489 build_new_dn( &ce2->ce_entry->e_nname, &ce->ce_entry->e_nname,
3491 config_rename_kids( ce2 );
3496 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
3497 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
3498 struct berval *nnewrdn, int use_ldif )
3502 struct berval odn, ondn;
3506 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
3507 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
3510 free( a->a_vals[0].bv_val );
3511 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
3512 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
3513 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
3514 strcpy( a->a_vals[0].bv_val, ptr1 );
3516 if ( a->a_nvals != a->a_vals ) {
3517 free( a->a_nvals[0].bv_val );
3518 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
3519 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
3520 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
3521 strcpy( a->a_nvals[0].bv_val, ptr1 );
3524 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
3525 BackendDB *be = op->o_bd;
3526 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
3527 struct berval dn, ndn, xdn, xndn;
3529 op->o_bd = &cfb->cb_db;
3531 /* Save current rootdn; use the underlying DB's rootdn */
3535 xndn = op->o_req_ndn;
3536 op->o_dn = op->o_bd->be_rootdn;
3537 op->o_ndn = op->o_bd->be_rootndn;
3539 op->o_req_ndn = ondn;
3541 scp = op->o_callback;
3542 op->o_callback = ≻
3543 op->orr_newrdn = *newrdn;
3544 op->orr_nnewrdn = *nnewrdn;
3545 op->orr_newSup = NULL;
3546 op->orr_nnewSup = NULL;
3547 op->orr_deleteoldrdn = 1;
3548 op->orr_modlist = NULL;
3549 slap_modrdn2mods( op, rs );
3550 slap_mods_opattrs( op, &op->orr_modlist, 1 );
3551 rc = op->o_bd->be_modrdn( op, rs );
3552 slap_mods_free( op->orr_modlist, 1 );
3555 op->o_callback = scp;
3559 op->o_req_ndn = xndn;
3562 free( ondn.bv_val );
3564 config_rename_kids( e->e_private );
3569 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
3570 Entry *e, int idx, int tailindex, int use_ldif )
3572 struct berval ival, newrdn, nnewrdn;
3575 char ibuf[32], *ptr1, *ptr2 = NULL;
3578 rc = config_rename_attr( rs, e, &rdn, &a );
3579 if ( rc ) return rc;
3582 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
3583 if ( ival.bv_len >= sizeof( ibuf ) ) {
3584 return LDAP_NAMING_VIOLATION;
3587 newrdn.bv_len = rdn.bv_len + ival.bv_len;
3588 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
3591 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
3592 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
3595 ptr2 = ber_bvchr( &rdn, '}' );
3599 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
3601 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
3602 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
3603 a->a_desc->ad_cname.bv_len );
3605 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
3606 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
3610 /* Do the equivalent of ModRDN */
3611 /* Replace DN / NDN */
3612 newrdn.bv_len = ptr1 - newrdn.bv_val;
3613 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
3614 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
3616 free( nnewrdn.bv_val );
3617 free( newrdn.bv_val );
3622 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
3623 SlapReply *rs, int *renum, int *ibase )
3626 int index = -1, gotindex = 0, nsibs, rc = 0;
3627 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
3628 char *ptr1, *ptr2 = NULL;
3631 if ( renum ) *renum = 0;
3633 /* These entries don't get indexed/renumbered */
3634 if ( ce_type == Cft_Global ) return 0;
3635 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
3637 if ( ce_type == Cft_Module )
3640 /* See if the rdn has an index already */
3641 dnRdn( &e->e_name, &rdn );
3642 if ( ce_type == Cft_Database ) {
3643 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
3644 "frontend", STRLENOF("frontend") ))
3646 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
3647 "config", STRLENOF("config") ))
3650 ptr1 = ber_bvchr( &e->e_name, '{' );
3651 if ( ptr1 && ptr1 - e->e_name.bv_val < rdn.bv_len ) {
3653 ptr2 = strchr( ptr1, '}' );
3654 if (!ptr2 || ptr2 - e->e_name.bv_val > rdn.bv_len)
3655 return LDAP_NAMING_VIOLATION;
3656 if ( ptr2-ptr1 == 1)
3657 return LDAP_NAMING_VIOLATION;
3659 index = strtol( ptr1 + 1, &next, 10 );
3660 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
3661 return LDAP_NAMING_VIOLATION;
3664 /* Special case, we allow -1 for the frontendDB */
3665 if ( index != -1 || !isfrontend )
3666 return LDAP_NAMING_VIOLATION;
3668 if ( isconfig && index != 0 ){
3669 return LDAP_NAMING_VIOLATION;
3673 /* count related kids */
3674 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
3675 if ( ce->ce_type == ce_type ) nsibs++;
3678 /* account for -1 frontend */
3679 if ( ce_type == Cft_Database )
3682 if ( index != nsibs ) {
3684 if ( index < nsibs ) {
3685 if ( tailindex ) return LDAP_NAMING_VIOLATION;
3686 /* Siblings need to be renumbered */
3687 if ( index != -1 || !isfrontend )
3691 /* config DB is always "0" */
3692 if ( isconfig && index == -1 ) {
3695 if ( !isfrontend && index == -1 ) {
3699 /* just make index = nsibs */
3701 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
3704 if ( ibase ) *ibase = index;
3705 if ( renum ) *renum = renumber;
3710 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
3715 co.co_name = &oc->soc_cname;
3716 cop = avl_find( CfOcTree, &co, CfOc_cmp );
3720 /* check for duplicates */
3721 for ( i = 0; i < *nocs; i++ ) {
3722 if ( *copp && (*copp)[i] == cop ) {
3728 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
3729 if ( tmp == NULL ) {
3733 (*copp)[*nocs] = cop;
3738 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
3739 if ( count_oc( *sups, copp, nocs ) ) {
3748 count_ocs( Attribute *oc_at, int *nocs )
3751 ConfigOCs **colst = NULL;
3755 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
3759 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
3761 assert( oc != NULL );
3762 if ( count_oc( oc, &colst, nocs ) ) {
3772 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
3776 /* This entry is hardcoded, don't re-parse it */
3777 if ( p->ce_type == Cft_Global ) {
3778 cfn = p->ce_private;
3780 return LDAP_COMPARE_TRUE;
3782 if ( p->ce_type != Cft_Schema )
3783 return LDAP_CONSTRAINT_VIOLATION;
3785 cfn = ch_calloc( 1, sizeof(ConfigFile) );
3787 cfo = p->ce_private;
3788 cfn->c_sibs = cfo->c_kids;
3790 return LDAP_SUCCESS;
3794 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
3796 if ( p->ce_type != Cft_Global ) {
3797 return LDAP_CONSTRAINT_VIOLATION;
3799 ca->be = frontendDB; /* just to get past check_vals */
3800 return LDAP_SUCCESS;
3804 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
3806 if ( p->ce_type != Cft_Global ) {
3807 return LDAP_CONSTRAINT_VIOLATION;
3809 return LDAP_SUCCESS;
3813 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
3815 if ( p->ce_type != Cft_Global ) {
3816 return LDAP_CONSTRAINT_VIOLATION;
3818 return LDAP_SUCCESS;
3822 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
3824 if ( p->ce_type != Cft_Database ) {
3825 return LDAP_CONSTRAINT_VIOLATION;
3828 return LDAP_SUCCESS;
3832 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
3837 AttributeDescription *ad;
3842 if ( cfn->c_cr_head ) {
3843 struct berval bv = BER_BVC("olcDitContentRules");
3845 slap_bv2ad( &bv, &ad, &text );
3846 ct = config_find_table( colst, nocs, ad, ca );
3847 config_del_vals( ct, ca );
3849 if ( cfn->c_oc_head ) {
3850 struct berval bv = BER_BVC("olcObjectClasses");
3852 slap_bv2ad( &bv, &ad, &text );
3853 ct = config_find_table( colst, nocs, ad, ca );
3854 config_del_vals( ct, ca );
3856 if ( cfn->c_at_head ) {
3857 struct berval bv = BER_BVC("olcAttributeTypes");
3859 slap_bv2ad( &bv, &ad, &text );
3860 ct = config_find_table( colst, nocs, ad, ca );
3861 config_del_vals( ct, ca );
3863 if ( cfn->c_om_head ) {
3864 struct berval bv = BER_BVC("olcObjectIdentifier");
3866 slap_bv2ad( &bv, &ad, &text );
3867 ct = config_find_table( colst, nocs, ad, ca );
3868 config_del_vals( ct, ca );
3870 cfo = p->ce_private;
3871 cfo->c_kids = cfn->c_sibs;
3876 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
3878 int rc = LDAP_CONSTRAINT_VIOLATION;
3881 if ( (*cop)->co_ldadd ) {
3882 rc = (*cop)->co_ldadd( last, e, ca );
3883 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
3888 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
3889 ConfigOCs co = { 0 };
3891 co.co_name = &(*ocp)->soc_cname;
3892 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
3893 if ( *cop == NULL ) {
3897 rc = config_add_oc( cop, last, e, ca );
3898 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
3906 /* Parse an LDAP entry into config directives */
3908 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
3909 int *renum, Operation *op )
3911 CfEntryInfo *ce, *last = NULL;
3912 ConfigOCs co, *coptr, **colst;
3913 Attribute *a, *oc_at, *soc_at;
3914 int i, ibase = -1, nocs, rc = 0;
3919 memset( ca, 0, sizeof(ConfigArgs));
3921 /* Make sure parent exists and entry does not. But allow
3922 * Databases and Overlays to be inserted. Don't do any
3923 * auto-renumbering if manageDSAit control is present.
3925 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
3927 if ( ( op && op->o_managedsait ) ||
3928 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
3929 ce->ce_type != Cft_Module ) )
3931 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
3932 "DN=\"%s\" already exists\n",
3933 op->o_log_prefix, e->e_name.bv_val, 0 );
3934 return LDAP_ALREADY_EXISTS;
3938 dnParent( &e->e_nname, &pdn );
3940 /* If last is NULL, the new entry is the root/suffix entry,
3941 * otherwise last should be the parent.
3943 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
3945 rs->sr_matched = last->ce_entry->e_name.bv_val;
3947 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
3948 "DN=\"%s\" not child of DN=\"%s\"\n",
3949 op ? op->o_log_prefix : "", e->e_name.bv_val,
3950 last->ce_entry->e_name.bv_val );
3951 return LDAP_NO_SUCH_OBJECT;
3955 /* No parent, must be root. This will never happen... */
3956 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
3957 return LDAP_NO_SUCH_OBJECT;
3960 if ( last && !access_allowed( op, last->ce_entry,
3961 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
3963 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
3964 "DN=\"%s\" no write access to \"children\" of parent\n",
3965 op->o_log_prefix, e->e_name.bv_val, 0 );
3966 return LDAP_INSUFFICIENT_ACCESS;
3970 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
3972 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
3973 "DN=\"%s\" no objectClass\n",
3974 op ? op->o_log_prefix : "", e->e_name.bv_val, 0 );
3975 return LDAP_OBJECT_CLASS_VIOLATION;
3978 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
3980 ObjectClass *soc = NULL;
3981 char textbuf[ SLAP_TEXT_BUFLEN ];
3982 const char *text = textbuf;
3984 /* FIXME: check result */
3985 rc = structural_class( oc_at->a_nvals, &soc, NULL,
3986 &text, textbuf, sizeof(textbuf), NULL );
3987 if ( rc != LDAP_SUCCESS ) {
3988 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
3989 "DN=\"%s\" no structural objectClass (%s)\n",
3990 op ? op->o_log_prefix : "", e->e_name.bv_val, text );
3993 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
3994 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
3995 if ( soc_at == NULL ) {
3996 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
3997 "DN=\"%s\" no structural objectClass; "
3998 "unable to merge computed class %s\n",
3999 op ? op->o_log_prefix : "", e->e_name.bv_val,
4000 soc->soc_cname.bv_val );
4001 return LDAP_OBJECT_CLASS_VIOLATION;
4004 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4005 "DN=\"%s\" no structural objectClass; "
4006 "computed objectClass %s merged\n",
4007 op ? op->o_log_prefix : "", e->e_name.bv_val,
4008 soc->soc_cname.bv_val );
4011 /* Fake the coordinates based on whether we're part of an
4012 * LDAP Add or if reading the config dir
4015 ca->fname = "slapd";
4018 ca->fname = cfdir.bv_val;
4023 co.co_name = &soc_at->a_nvals[0];
4024 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
4025 if ( coptr == NULL ) {
4026 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4027 "DN=\"%s\" no structural objectClass in configuration table\n",
4028 op ? op->o_log_prefix : "", e->e_name.bv_val, 0 );
4029 return LDAP_OBJECT_CLASS_VIOLATION;
4032 /* Only the root can be Cft_Global, everything else must
4033 * have a parent. Only limited nesting arrangements are allowed.
4035 rc = LDAP_CONSTRAINT_VIOLATION;
4036 if ( coptr->co_type == Cft_Global && !last ) {
4037 cfn = cfb->cb_config;
4039 ca->be = frontendDB; /* just to get past check_vals */
4043 /* Check whether the Add is allowed by its parent, and do
4044 * any necessary arg setup
4047 rc = config_add_oc( &coptr, last, e, ca );
4048 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
4049 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4050 "DN=\"%s\" no structural objectClass add function\n",
4051 op ? op->o_log_prefix : "", e->e_name.bv_val, 0 );
4052 return LDAP_OBJECT_CLASS_VIOLATION;
4056 colst = count_ocs( oc_at, &nocs );
4058 /* Add the entry but don't parse it, we already have its contents */
4059 if ( rc == LDAP_COMPARE_TRUE ) {
4064 if ( rc != LDAP_SUCCESS )
4067 /* Parse all the values and check for simple syntax errors before
4068 * performing any set actions.
4070 * If doing an LDAPadd, check for indexed names and any necessary
4071 * renaming/renumbering. Entries that don't need indexed names are
4072 * ignored. Entries that need an indexed name and arrive without one
4073 * are assigned to the end. Entries that arrive with an index may
4074 * cause the following entries to be renumbered/bumped down.
4076 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
4077 * don't allow Adding an entry with an index that's already in use.
4078 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
4080 * These entries can have auto-assigned indexes (appended to the end)
4081 * but only the other types support auto-renumbering of siblings.
4084 rc = check_name_index( last, coptr->co_type, e, rs, renum,
4089 if ( renum && *renum && coptr->co_type != Cft_Database &&
4090 coptr->co_type != Cft_Overlay )
4092 snprintf( ca->msg, sizeof( ca->msg ),
4093 "operation requires sibling renumbering" );
4094 rc = LDAP_UNWILLING_TO_PERFORM;
4099 init_config_argv( ca );
4101 /* Make sure we process attrs in the required order */
4102 sort_attrs( e, colst, nocs );
4104 for ( a = e->e_attrs; a; a = a->a_next ) {
4105 if ( a == oc_at ) continue;
4106 ct = config_find_table( colst, nocs, a->a_desc, ca );
4107 if ( !ct ) continue; /* user data? */
4108 rc = check_vals( ct, ca, a, 1 );
4109 if ( rc ) goto done_noop;
4112 /* Basic syntax checks are OK. Do the actual settings. */
4113 for ( a=e->e_attrs; a; a=a->a_next ) {
4114 if ( a == oc_at ) continue;
4115 ct = config_find_table( colst, nocs, a->a_desc, ca );
4116 if ( !ct ) continue; /* user data? */
4117 for (i=0; a->a_vals[i].bv_val; i++) {
4119 ca->line = a->a_vals[i].bv_val;
4120 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
4121 ptr = strchr( ca->line, '}' );
4123 iptr = strchr( ca->line, '{' );
4127 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
4129 ca->valx = strtol( iptr+1, NULL, 0 );
4136 rc = config_parse_add( ct, ca, i );
4144 /* Newly added databases and overlays need to be started up */
4145 if ( CONFIG_ONLINE_ADD( ca )) {
4146 if ( colst[0]->co_type == Cft_Database ) {
4147 rc = backend_startup_one( ca->be );
4149 } else if ( colst[0]->co_type == Cft_Overlay ) {
4150 if ( ca->bi->bi_db_open ) {
4151 BackendInfo *bi_orig = ca->be->bd_info;
4152 ca->be->bd_info = ca->bi;
4153 rc = ca->bi->bi_db_open( ca->be );
4154 ca->be->bd_info = bi_orig;
4158 snprintf( ca->msg, sizeof( ca->msg ), "<%s> failed startup", ca->argv[0] );
4159 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
4160 ca->log, ca->msg, ca->argv[1] );
4167 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
4168 ce->ce_parent = last;
4169 ce->ce_entry = entry_dup( e );
4170 ce->ce_entry->e_private = ce;
4171 ce->ce_type = colst[0]->co_type;
4174 ce->ce_private = ca->private;
4175 ca->ca_entry = ce->ce_entry;
4178 } else if ( last->ce_kids ) {
4179 CfEntryInfo *c2, **cprev;
4181 /* Advance to first of this type */
4182 cprev = &last->ce_kids;
4183 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
4184 cprev = &c2->ce_sibs;
4187 /* Account for the (-1) frontendDB entry */
4188 if ( ce->ce_type == Cft_Database ) {
4189 if ( ca->be == frontendDB )
4191 else if ( ibase != -1 )
4196 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
4197 cprev = &c2->ce_sibs;
4203 for ( i=0; i<ibase; i++ ) {
4205 cprev = &c2->ce_sibs;
4208 ce->ce_sibs = *cprev;
4216 if ( (colst[0]->co_type == Cft_Database) && ca->be ) {
4217 if ( ca->be != frontendDB )
4218 backend_destroy_one( ca->be, 1 );
4219 } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) {
4220 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
4221 } else if ( colst[0]->co_type == Cft_Schema ) {
4222 schema_destroy_one( ca, colst, nocs, last );
4227 ch_free( ca->argv );
4228 if ( colst ) ch_free( colst );
4232 #define BIGTMP 10000
4234 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
4235 int base, int rebase, int max, int use_ldif )
4237 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
4238 ConfigType etype = ce->ce_type;
4239 int count = 0, rc = 0;
4241 /* Reverse ce list */
4242 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
4243 if (ce2->ce_type != etype) {
4248 ce2->ce_sibs = cetmp;
4251 if ( max && count >= max ) {
4257 /* Move original to a temp name until increments are done */
4259 ce->ce_entry->e_private = NULL;
4260 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4261 base+BIGTMP, 0, use_ldif );
4262 ce->ce_entry->e_private = ce;
4264 /* start incrementing */
4265 for (ce2=cetmp; ce2; ce2=ce3) {
4267 ce2->ce_sibs = cerem;
4270 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
4271 count+base, 0, use_ldif );
4275 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4276 base, 0, use_ldif );
4281 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
4282 CfEntryInfo *ce2, int old, int use_ldif )
4286 /* Renumber original to a temp value */
4287 ce->ce_entry->e_private = NULL;
4288 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4289 old+BIGTMP, 0, use_ldif );
4290 ce->ce_entry->e_private = ce;
4292 /* start decrementing */
4293 for (; ce2 != ce; ce2=ce2->ce_sibs) {
4294 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
4295 count+old, 0, use_ldif );
4298 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4299 count+old, 0, use_ldif );
4302 /* Parse an LDAP entry into config directives, then store in underlying
4306 config_back_add( Operation *op, SlapReply *rs )
4312 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
4313 NULL, ACL_WADD, NULL )) {
4314 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4318 cfb = (CfBackInfo *)op->o_bd->be_private;
4320 /* add opattrs for syncprov */
4322 char textbuf[SLAP_TEXT_BUFLEN];
4323 size_t textlen = sizeof textbuf;
4324 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1,
4325 &rs->sr_text, textbuf, sizeof( textbuf ) );
4326 if ( rs->sr_err != LDAP_SUCCESS )
4328 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
4329 if ( rs->sr_err != LDAP_SUCCESS ) {
4330 Debug( LDAP_DEBUG_TRACE,
4331 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
4332 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
4337 ldap_pvt_thread_pool_pause( &connection_pool );
4340 * 1) check for existence of entry
4341 * 2) check for sibling renumbering
4342 * 3) perform internal add
4343 * 4) perform any necessary renumbering
4344 * 5) store entry in underlying database
4346 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
4347 if ( rs->sr_err != LDAP_SUCCESS ) {
4348 rs->sr_text = ca.msg;
4353 CfEntryInfo *ce = ca.ca_entry->e_private;
4354 req_add_s addr = op->oq_add;
4355 op->o_tag = LDAP_REQ_MODRDN;
4356 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
4357 op->o_tag = LDAP_REQ_ADD;
4359 if ( rs->sr_err != LDAP_SUCCESS ) {
4364 if ( cfb->cb_use_ldif ) {
4365 BackendDB *be = op->o_bd;
4366 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4367 struct berval dn, ndn;
4369 op->o_bd = &cfb->cb_db;
4371 /* Save current rootdn; use the underlying DB's rootdn */
4374 op->o_dn = op->o_bd->be_rootdn;
4375 op->o_ndn = op->o_bd->be_rootndn;
4377 scp = op->o_callback;
4378 op->o_callback = ≻
4379 op->o_bd->be_add( op, rs );
4381 op->o_callback = scp;
4387 ldap_pvt_thread_pool_resume( &connection_pool );
4390 send_ldap_result( op, rs );
4391 slap_graduate_commit_csn( op );
4395 typedef struct delrec {
4396 struct delrec *next;
4402 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
4407 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
4408 ca->line[0] == '{' )
4410 char *ptr = strchr( ca->line + 1, '}' );
4414 ca->valx = strtol( ca->line + 1, &next, 0 );
4415 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
4421 rc = config_parse_add( ct, ca, i );
4429 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
4432 int rc = LDAP_UNWILLING_TO_PERFORM;
4434 Entry *e = ce->ce_entry;
4435 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
4440 delrec *dels = NULL, *deltail = NULL;
4442 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
4443 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
4445 colst = count_ocs( oc_at, &nocs );
4447 /* make sure add/del flags are clear; should always be true */
4448 for ( s = save_attrs; s; s = s->a_next ) {
4449 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
4452 e->e_attrs = attrs_dup( e->e_attrs );
4454 init_config_argv( ca );
4457 ca->private = ce->ce_private;
4459 ca->fname = "slapd";
4461 strcpy( ca->log, "back-config" );
4463 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
4464 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
4465 switch (ml->sml_op) {
4466 case LDAP_MOD_DELETE:
4467 case LDAP_MOD_REPLACE: {
4468 BerVarray vals = NULL, nvals = NULL;
4470 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
4472 snprintf(ca->msg, sizeof(ca->msg), "cannot delete %s",
4473 ml->sml_desc->ad_cname.bv_val );
4476 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4477 vals = ml->sml_values;
4478 nvals = ml->sml_nvalues;
4479 ml->sml_values = NULL;
4480 ml->sml_nvalues = NULL;
4482 /* If we're deleting by values, remember the indexes of the
4483 * values we deleted.
4485 if ( ct && ml->sml_values ) {
4487 for (i=0; ml->sml_values[i].bv_val; i++);
4488 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
4499 rc = modify_delete_vindex(e, &ml->sml_mod,
4500 get_permissiveModify(op),
4501 &rs->sr_text, ca->msg, sizeof(ca->msg), idx );
4502 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4503 ml->sml_values = vals;
4504 ml->sml_nvalues = nvals;
4509 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
4512 case SLAP_MOD_SOFTADD: {
4513 int mop = ml->sml_op;
4515 ml->sml_op = LDAP_MOD_ADD;
4517 if ( ct->arg_type & ARG_NO_INSERT ) {
4518 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
4520 for (i = 0; a->a_vals[i].bv_val; i++ );
4524 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
4525 if ( ml->sml_values[i].bv_val[0] == '{' &&
4528 char *next, *val = ml->sml_values[i].bv_val + 1;
4531 j = strtol( val, &next, 0 );
4532 if ( next == val || next[ 0 ] != '}' || j < navals ) {
4534 snprintf(ca->msg, sizeof(ca->msg), "cannot insert %s",
4535 ml->sml_desc->ad_cname.bv_val );
4539 rc = check_vals( ct, ca, ml, 0 );
4540 if ( rc ) goto out_noop;
4543 rc = modify_add_values(e, &ml->sml_mod,
4544 get_permissiveModify(op),
4545 &rs->sr_text, ca->msg, sizeof(ca->msg) );
4547 /* If value already exists, show success here
4548 * and ignore this operation down below.
4550 if ( mop == SLAP_MOD_SOFTADD ) {
4551 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
4561 case LDAP_MOD_INCREMENT: /* FIXME */
4566 if(rc != LDAP_SUCCESS) break;
4569 if ( rc == LDAP_SUCCESS) {
4570 /* check that the entry still obeys the schema */
4571 rc = entry_schema_check(op, e, NULL, 0, 0,
4572 &rs->sr_text, ca->msg, sizeof(ca->msg) );
4573 if ( rc ) goto out_noop;
4575 /* Basic syntax checks are OK. Do the actual settings. */
4576 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
4577 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
4578 if ( !ct ) continue;
4580 s = attr_find( save_attrs, ml->sml_desc );
4581 a = attr_find( e->e_attrs, ml->sml_desc );
4583 switch (ml->sml_op) {
4584 case LDAP_MOD_DELETE:
4585 case LDAP_MOD_REPLACE: {
4586 BerVarray vals = NULL, nvals = NULL;
4589 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4590 vals = ml->sml_values;
4591 nvals = ml->sml_nvalues;
4592 ml->sml_values = NULL;
4593 ml->sml_nvalues = NULL;
4596 if ( ml->sml_values )
4599 /* If we didn't delete the whole attribute */
4600 if ( ml->sml_values && a ) {
4601 struct berval *mvals;
4604 if ( ml->sml_nvalues )
4605 mvals = ml->sml_nvalues;
4607 mvals = ml->sml_values;
4609 /* use the indexes we saved up above */
4610 for (i=0; i < d->nidx; i++) {
4611 struct berval bv = *mvals++;
4612 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
4613 bv.bv_val[0] == '{' ) {
4614 ptr = strchr( bv.bv_val, '}' ) + 1;
4615 bv.bv_len -= ptr - bv.bv_val;
4618 ca->line = bv.bv_val;
4619 ca->valx = d->idx[i];
4620 rc = config_del_vals( ct, ca );
4621 if ( rc != LDAP_SUCCESS ) break;
4623 s->a_flags |= SLAP_ATTR_IXDEL;
4624 for (j=i+1; j < d->nidx; j++)
4625 if ( d->idx[j] >d->idx[i] )
4631 rc = config_del_vals( ct, ca );
4632 if ( rc ) rc = LDAP_OTHER;
4634 s->a_flags |= SLAP_ATTR_IXDEL;
4636 if ( ml->sml_values ) {
4641 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4642 ml->sml_values = vals;
4643 ml->sml_nvalues = nvals;
4645 if ( !vals || rc != LDAP_SUCCESS )
4648 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
4651 for (i=0; ml->sml_values[i].bv_val; i++) {
4652 ca->line = ml->sml_values[i].bv_val;
4654 rc = config_modify_add( ct, ca, ml->sml_desc, i );
4657 a->a_flags |= SLAP_ATTR_IXADD;
4664 /* Undo for a failed operation */
4665 if ( rc != LDAP_SUCCESS ) {
4666 for ( s = save_attrs; s; s = s->a_next ) {
4667 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
4668 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
4669 ct = config_find_table( colst, nocs, s->a_desc, ca );
4670 a = attr_find( e->e_attrs, s->a_desc );
4672 /* clear the flag so the add check below will skip it */
4673 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
4676 config_del_vals( ct, ca );
4678 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
4679 ca->line = s->a_vals[i].bv_val;
4681 config_modify_add( ct, ca, s->a_desc, i );
4685 for ( a = e->e_attrs; a; a = a->a_next ) {
4686 if ( a->a_flags & SLAP_ATTR_IXADD ) {
4687 ct = config_find_table( colst, nocs, a->a_desc, ca );
4690 config_del_vals( ct, ca );
4691 s = attr_find( save_attrs, a->a_desc );
4693 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
4694 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
4695 ca->line = s->a_vals[i].bv_val;
4697 config_modify_add( ct, ca, s->a_desc, i );
4707 if ( rc == LDAP_SUCCESS ) {
4708 attrs_free( save_attrs );
4710 attrs_free( e->e_attrs );
4711 e->e_attrs = save_attrs;
4713 ch_free( ca->argv );
4714 if ( colst ) ch_free( colst );
4716 deltail = dels->next;
4725 config_back_modify( Operation *op, SlapReply *rs )
4728 CfEntryInfo *ce, *last;
4730 ConfigArgs ca = {0};
4733 AttributeDescription *rad = NULL;
4735 cfb = (CfBackInfo *)op->o_bd->be_private;
4737 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
4740 rs->sr_matched = last->ce_entry->e_name.bv_val;
4741 rs->sr_err = LDAP_NO_SUCH_OBJECT;
4745 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
4746 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4750 /* Get type of RDN */
4751 rdn = ce->ce_entry->e_nname;
4752 ptr = strchr( rdn.bv_val, '=' );
4753 rdn.bv_len = ptr - rdn.bv_val;
4754 slap_bv2ad( &rdn, &rad, &rs->sr_text );
4756 /* Some basic validation... */
4757 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
4758 /* Don't allow Modify of RDN; must use ModRdn for that. */
4759 if ( ml->sml_desc == rad ) {
4760 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
4761 rs->sr_text = "Use modrdn to change the entry name";
4766 slap_mods_opattrs( op, &op->orm_modlist, 1 );
4768 if ( !slapd_shutdown )
4769 ldap_pvt_thread_pool_pause( &connection_pool );
4772 * 1) perform the Modify on the cached Entry.
4773 * 2) verify that the Entry still satisfies the schema.
4774 * 3) perform the individual config operations.
4775 * 4) store Modified entry in underlying LDIF backend.
4777 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
4779 rs->sr_text = ca.msg;
4780 } else if ( cfb->cb_use_ldif ) {
4781 BackendDB *be = op->o_bd;
4782 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4783 struct berval dn, ndn;
4785 op->o_bd = &cfb->cb_db;
4789 op->o_dn = op->o_bd->be_rootdn;
4790 op->o_ndn = op->o_bd->be_rootndn;
4792 scp = op->o_callback;
4793 op->o_callback = ≻
4794 op->o_bd->be_modify( op, rs );
4796 op->o_callback = scp;
4801 if ( !slapd_shutdown )
4802 ldap_pvt_thread_pool_resume( &connection_pool );
4804 send_ldap_result( op, rs );
4805 slap_graduate_commit_csn( op );
4810 config_back_modrdn( Operation *op, SlapReply *rs )
4813 CfEntryInfo *ce, *last;
4817 cfb = (CfBackInfo *)op->o_bd->be_private;
4819 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
4822 rs->sr_matched = last->ce_entry->e_name.bv_val;
4823 rs->sr_err = LDAP_NO_SUCH_OBJECT;
4826 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
4827 NULL, ACL_WRITE, NULL )) {
4828 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4832 if ( ce->ce_parent )
4833 parent = ce->ce_parent->ce_entry;
4835 parent = (Entry *)&slap_entry_root;
4836 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
4837 NULL, ACL_WRITE, NULL )) {
4838 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4843 /* We don't allow moving objects to new parents.
4844 * Generally we only allow reordering a set of ordered entries.
4846 if ( op->orr_newSup ) {
4847 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
4851 /* If newRDN == oldRDN, quietly succeed */
4852 dnRdn( &op->o_req_ndn, &rdn );
4853 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
4854 rs->sr_err = LDAP_SUCCESS;
4858 /* Current behavior, subject to change as needed:
4860 * For backends and overlays, we only allow renumbering.
4861 * For schema, we allow renaming with the same number.
4862 * Otherwise, the op is not allowed.
4865 if ( ce->ce_type == Cft_Schema ) {
4869 /* Can't alter the main cn=schema entry */
4870 if ( ce->ce_parent->ce_type == Cft_Global ) {
4871 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
4872 rs->sr_text = "renaming not allowed for this entry";
4876 /* We could support this later if desired */
4877 ptr1 = ber_bvchr( &rdn, '}' );
4878 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
4879 len = ptr1 - rdn.bv_val;
4880 if ( len != ptr2 - op->orr_newrdn.bv_val ||
4881 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
4882 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
4883 rs->sr_text = "schema reordering not supported";
4886 } else if ( ce->ce_type == Cft_Database ||
4887 ce->ce_type == Cft_Overlay ) {
4888 char *ptr1, *ptr2, *iptr1, *iptr2;
4891 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
4892 if ( *iptr2 != '{' ) {
4893 rs->sr_err = LDAP_NAMING_VIOLATION;
4894 rs->sr_text = "new ordering index is required";
4898 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
4899 ptr1 = ber_bvchr( &rdn, '}' );
4900 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
4902 rs->sr_err = LDAP_NAMING_VIOLATION;
4903 rs->sr_text = "new ordering index is required";
4907 len1 = ptr1 - rdn.bv_val;
4908 len2 = ptr2 - op->orr_newrdn.bv_val;
4910 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
4911 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
4912 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
4913 rs->sr_text = "changing database/overlay type not allowed";
4916 ixold = strtol( iptr1, NULL, 0 );
4917 ixnew = strtol( iptr2, &ptr1, 0 );
4918 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
4919 rs->sr_err = LDAP_NAMING_VIOLATION;
4922 /* config DB is always 0, cannot be changed */
4923 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
4924 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
4928 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
4929 rs->sr_text = "renaming not supported for this entry";
4933 ldap_pvt_thread_pool_pause( &connection_pool );
4935 if ( ce->ce_type == Cft_Schema ) {
4936 req_modrdn_s modr = op->oq_modrdn;
4939 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
4940 if ( rs->sr_err == LDAP_SUCCESS ) {
4941 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
4942 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
4945 op->oq_modrdn = modr;
4947 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
4948 req_modrdn_s modr = op->oq_modrdn;
4951 /* Advance to first of this type */
4952 cprev = &ce->ce_parent->ce_kids;
4953 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
4954 cprev = &ce2->ce_sibs;
4957 /* Skip the -1 entry */
4958 if ( ce->ce_type == Cft_Database ) {
4959 cprev = &ce2->ce_sibs;
4965 /* Remove from old slot */
4966 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
4967 cprev = &ce2->ce_sibs;
4968 *cprev = ce->ce_sibs;
4969 ceold = ce->ce_sibs;
4971 /* Insert into new slot */
4973 for ( i=0; i<ixnew; i++ ) {
4977 cprev = &ce2->ce_sibs;
4979 ce->ce_sibs = *cprev;
4984 /* NOTE: These should be encoded in the OC tables, not inline here */
4985 if ( ce->ce_type == Cft_Database )
4986 backend_db_move( ce->ce_be, ixnew );
4987 else if ( ce->ce_type == Cft_Overlay )
4988 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
4990 if ( ixold < ixnew ) {
4991 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
4994 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
4995 ixold - ixnew, cfb->cb_use_ldif );
4997 op->oq_modrdn = modr;
5000 ldap_pvt_thread_pool_resume( &connection_pool );
5002 send_ldap_result( op, rs );
5007 config_back_delete( Operation *op, SlapReply *rs )
5009 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, NULL );
5014 config_back_search( Operation *op, SlapReply *rs )
5017 CfEntryInfo *ce, *last;
5020 cfb = (CfBackInfo *)op->o_bd->be_private;
5022 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5025 rs->sr_matched = last->ce_entry->e_name.bv_val;
5026 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5029 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
5030 ACL_SEARCH, NULL, &mask ))
5032 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
5033 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5035 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5039 switch ( op->ors_scope ) {
5040 case LDAP_SCOPE_BASE:
5041 case LDAP_SCOPE_SUBTREE:
5042 config_send( op, rs, ce, 0 );
5045 case LDAP_SCOPE_ONELEVEL:
5046 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
5047 config_send( op, rs, ce, 1 );
5052 rs->sr_err = LDAP_SUCCESS;
5054 send_ldap_result( op, rs );
5058 /* no-op, we never free entries */
5059 int config_entry_release(
5064 if ( !e->e_private ) {
5067 return LDAP_SUCCESS;
5070 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
5072 int config_back_entry_get(
5076 AttributeDescription *at,
5081 CfEntryInfo *ce, *last;
5083 cfb = (CfBackInfo *)op->o_bd->be_private;
5085 ce = config_find_base( cfb->cb_root, ndn, &last );
5087 *ent = ce->ce_entry;
5088 if ( *ent && oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
5093 return ( *ent == NULL ? 1 : 0 );
5097 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
5098 ConfigTable *ct, ConfigArgs *c )
5102 for (; at && *at; at++) {
5103 /* Skip the naming attr */
5104 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
5106 for (i=0;ct[i].name;i++) {
5107 if (ct[i].ad == (*at)->sat_ad) {
5108 rc = config_get_vals(&ct[i], c);
5109 /* NOTE: tolerate that config_get_vals()
5110 * returns success with no values */
5111 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
5112 if ( c->rvalue_nvals )
5113 attr_merge(e, ct[i].ad, c->rvalue_vals,
5116 attr_merge_normalize(e, ct[i].ad,
5117 c->rvalue_vals, NULL);
5118 ber_bvarray_free( c->rvalue_nvals );
5119 ber_bvarray_free( c->rvalue_vals );
5128 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
5129 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
5131 Entry *e = entry_alloc();
5132 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5134 struct berval ad_name;
5135 AttributeDescription *ad = NULL;
5142 CfEntryInfo *ceprev = NULL;
5144 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
5147 ce->ce_type = main->co_type;
5148 ce->ce_parent = parent;
5150 pdn = parent->ce_entry->e_nname;
5151 if ( parent->ce_kids )
5152 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
5153 ceprev->ce_type <= ce->ce_type;
5154 ceprev = ceprev->ce_sibs );
5159 ce->ce_private = c->private;
5163 build_new_dn( &e->e_name, &pdn, rdn, NULL );
5164 ber_dupbv( &e->e_nname, &e->e_name );
5166 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
5167 main->co_name, NULL );
5169 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
5170 extra->co_name, NULL );
5171 ptr = strchr(rdn->bv_val, '=');
5172 ad_name.bv_val = rdn->bv_val;
5173 ad_name.bv_len = ptr - rdn->bv_val;
5174 rc = slap_bv2ad( &ad_name, &ad, &text );
5179 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
5180 attr_merge_normalize_one(e, ad, &val, NULL );
5183 c->table = main->co_type;
5184 if ( oc->soc_required )
5185 config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
5187 if ( oc->soc_allowed )
5188 config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
5192 c->table = extra->co_type;
5193 if ( oc->soc_required )
5194 config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
5196 if ( oc->soc_allowed )
5197 config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
5200 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5201 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->msg,
5202 sizeof(c->msg), op ? op->o_tmpmemctx : NULL );
5203 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
5204 if ( op && !op->o_noop ) {
5206 op->ora_modlist = NULL;
5207 op->o_bd->be_add( op, rs );
5208 if ( ( rs->sr_err != LDAP_SUCCESS )
5209 && (rs->sr_err != LDAP_ALREADY_EXISTS) ) {
5214 ce->ce_sibs = ceprev->ce_sibs;
5215 ceprev->ce_sibs = ce;
5216 } else if ( parent ) {
5217 ce->ce_sibs = parent->ce_kids;
5218 parent->ce_kids = ce;
5225 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
5226 Operation *op, SlapReply *rs )
5229 ConfigFile *cf = c->private;
5233 for (; cf; cf=cf->c_sibs, c->depth++) {
5234 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
5235 !cf->c_om_head ) continue;
5236 c->value_dn.bv_val = c->log;
5237 LUTIL_SLASHPATH( cf->c_file.bv_val );
5238 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
5243 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
5245 ptr = strchr( bv.bv_val, '.' );
5247 bv.bv_len = ptr - bv.bv_val;
5248 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
5249 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
5250 /* FIXME: how can indicate error? */
5253 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
5255 c->value_dn.bv_len += bv.bv_len;
5256 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
5259 e = config_build_entry( op, rs, ceparent, c, &c->value_dn,
5260 &CFOC_SCHEMA, NULL );
5263 } else if ( e && cf->c_kids ) {
5264 c->private = cf->c_kids;
5265 config_build_schema_inc( c, e->e_private, op, rs );
5271 #ifdef SLAPD_MODULES
5274 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
5275 Operation *op, SlapReply *rs )
5280 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
5281 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
5283 c->value_dn.bv_val = c->log;
5284 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
5285 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
5286 /* FIXME: how can indicate error? */
5290 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
5299 config_check_schema(Operation *op, CfBackInfo *cfb)
5301 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
5303 CfEntryInfo *ce, *last;
5306 /* If there's no root entry, we must be in the midst of converting */
5307 if ( !cfb->cb_root )
5310 /* Make sure the main schema entry exists */
5311 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
5318 /* Make sure it's up to date */
5319 if ( cf_om_tail != om_sys_tail ) {
5320 a = attr_find( e->e_attrs, cfAd_om );
5322 if ( a->a_nvals != a->a_vals )
5323 ber_bvarray_free( a->a_nvals );
5324 ber_bvarray_free( a->a_vals );
5328 oidm_unparse( &bv, NULL, NULL, 1 );
5329 attr_merge_normalize( e, cfAd_om, bv, NULL );
5330 ber_bvarray_free( bv );
5331 cf_om_tail = om_sys_tail;
5333 if ( cf_at_tail != at_sys_tail ) {
5334 a = attr_find( e->e_attrs, cfAd_attr );
5336 if ( a->a_nvals != a->a_vals )
5337 ber_bvarray_free( a->a_nvals );
5338 ber_bvarray_free( a->a_vals );
5342 at_unparse( &bv, NULL, NULL, 1 );
5343 attr_merge_normalize( e, cfAd_attr, bv, NULL );
5344 ber_bvarray_free( bv );
5345 cf_at_tail = at_sys_tail;
5347 if ( cf_oc_tail != oc_sys_tail ) {
5348 a = attr_find( e->e_attrs, cfAd_oc );
5350 if ( a->a_nvals != a->a_vals )
5351 ber_bvarray_free( a->a_nvals );
5352 ber_bvarray_free( a->a_vals );
5356 oc_unparse( &bv, NULL, NULL, 1 );
5357 attr_merge_normalize( e, cfAd_oc, bv, NULL );
5358 ber_bvarray_free( bv );
5359 cf_oc_tail = oc_sys_tail;
5362 SlapReply rs = {REP_RESULT};
5364 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
5365 &CFOC_SCHEMA, NULL );
5370 ce->ce_private = cfb->cb_config;
5371 cf_at_tail = at_sys_tail;
5372 cf_oc_tail = oc_sys_tail;
5373 cf_om_tail = om_sys_tail;
5378 static const char *defacl[] = {
5379 NULL, "to", "*", "by", "*", "none", NULL
5383 config_back_db_open( BackendDB *be )
5385 CfBackInfo *cfb = be->be_private;
5388 CfEntryInfo *ce, *ceparent;
5392 Connection conn = {0};
5393 OperationBuffer opbuf;
5395 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
5396 SlapReply rs = {REP_RESULT};
5397 void *thrctx = NULL;
5399 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
5401 /* If we have no explicitly configured ACLs, don't just use
5402 * the global ACLs. Explicitly deny access to everything.
5404 if ( frontendDB->be_acl && be->be_acl == frontendDB->be_acl ) {
5405 parse_acl(be, "config_back_db_open", 0, 6, (char **)defacl, 0 );
5408 thrctx = ldap_pvt_thread_pool_context();
5409 op = (Operation *) &opbuf;
5410 connection_fake_init( &conn, op, thrctx );
5412 op->o_tag = LDAP_REQ_ADD;
5413 op->o_callback = &cb;
5414 op->o_bd = &cfb->cb_db;
5415 op->o_dn = op->o_bd->be_rootdn;
5416 op->o_ndn = op->o_bd->be_rootndn;
5418 if ( !cfb->cb_use_ldif ) {
5422 /* If we read the config from back-ldif, do some quick sanity checks */
5423 if ( cfb->cb_got_ldif ) {
5424 return config_check_schema( op, cfb );
5427 /* create root of tree */
5429 c.private = cfb->cb_config;
5431 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
5441 #ifdef SLAPD_MODULES
5442 /* Create Module nodes... */
5443 if ( modpaths.mp_loads ) {
5444 if ( config_build_modules( &c, ceparent, op, &rs ) ){
5450 /* Create schema nodes... cn=schema will contain the hardcoded core
5451 * schema, read-only. Child objects will contain runtime loaded schema
5456 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
5461 ce->ce_private = cfb->cb_config;
5462 cf_at_tail = at_sys_tail;
5463 cf_oc_tail = oc_sys_tail;
5464 cf_om_tail = om_sys_tail;
5466 /* Create schema nodes for included schema... */
5467 if ( cfb->cb_config->c_kids ) {
5469 c.private = cfb->cb_config->c_kids;
5470 if (config_build_schema_inc( &c, ce, op, &rs )) {
5475 /* Create backend nodes. Skip if they don't provide a cf_table.
5476 * There usually aren't any of these.
5480 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
5481 if (!bi->bi_cf_ocs) {
5482 /* If it only supports the old config mech, complain. */
5483 if ( bi->bi_config ) {
5484 Debug( LDAP_DEBUG_ANY,
5485 "WARNING: No dynamic config support for backend %s.\n",
5486 bi->bi_type, 0, 0 );
5491 if (!bi->bi_private) continue;
5494 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
5495 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
5496 if ( rdn.bv_len >= sizeof( c.log ) ) {
5497 /* FIXME: holler ... */ ;
5500 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
5507 /* Create database nodes... */
5508 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
5509 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
5510 for ( i = -1, be = frontendDB ; be;
5511 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
5512 slap_overinfo *oi = NULL;
5514 if ( overlay_is_over( be )) {
5515 oi = be->bd_info->bi_private;
5521 /* If this backend supports the old config mechanism, but not
5522 * the new mech, complain.
5524 if ( !be->be_cf_ocs && bi->bi_db_config ) {
5525 Debug( LDAP_DEBUG_ANY,
5526 "WARNING: No dynamic config support for database %s.\n",
5527 bi->bi_type, 0, 0 );
5531 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
5532 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
5534 if ( rdn.bv_len >= sizeof( c.log ) ) {
5535 /* FIXME: holler ... */ ;
5539 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
5545 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd )
5546 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
5547 /* Iterate through overlays */
5553 for (j=0,on=oi->oi_list; on; j++,on=on->on_next) {
5554 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
5555 Debug( LDAP_DEBUG_ANY,
5556 "WARNING: No dynamic config support for overlay %s.\n",
5557 on->on_bi.bi_type, 0, 0 );
5561 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
5562 "%s=" SLAP_X_ORDERED_FMT "%s",
5563 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
5564 if ( rdn.bv_len >= sizeof( c.log ) ) {
5565 /* FIXME: holler ... */ ;
5569 oe = config_build_entry( op, &rs, ce, &c, &rdn,
5570 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
5574 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd )
5575 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
5580 ldap_pvt_thread_pool_context_reset( thrctx );
5582 if ( unsupp && cfb->cb_use_ldif ) {
5583 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
5584 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
5591 cfb_free_cffile( ConfigFile *cf )
5595 for (; cf; cf=next) {
5598 cfb_free_cffile( cf->c_kids );
5599 ch_free( cf->c_file.bv_val );
5600 ber_bvarray_free( cf->c_dseFiles );
5606 cfb_free_entries( CfEntryInfo *ce )
5610 for (; ce; ce=next) {
5613 cfb_free_entries( ce->ce_kids );
5614 ce->ce_entry->e_private = NULL;
5615 entry_free( ce->ce_entry );
5621 config_back_db_close( BackendDB *be )
5623 CfBackInfo *cfb = be->be_private;
5625 cfb_free_entries( cfb->cb_root );
5626 cfb->cb_root = NULL;
5628 if ( cfb->cb_db.bd_info ) {
5629 backend_shutdown( &cfb->cb_db );
5636 config_back_db_destroy( BackendDB *be )
5638 CfBackInfo *cfb = be->be_private;
5640 cfb_free_cffile( cfb->cb_config );
5642 ch_free( cfdir.bv_val );
5644 avl_free( CfOcTree, NULL );
5646 if ( cfb->cb_db.bd_info ) {
5647 cfb->cb_db.be_suffix = NULL;
5648 cfb->cb_db.be_nsuffix = NULL;
5649 BER_BVZERO( &cfb->cb_db.be_rootdn );
5650 BER_BVZERO( &cfb->cb_db.be_rootndn );
5652 backend_destroy_one( &cfb->cb_db, 0 );
5661 config_back_db_init( BackendDB *be )
5667 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
5668 cfn = cfb->cb_config;
5669 be->be_private = cfb;
5671 ber_dupbv( &be->be_rootdn, &config_rdn );
5672 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
5673 ber_dupbv( &dn, &be->be_rootdn );
5674 ber_bvarray_add( &be->be_suffix, &dn );
5675 ber_dupbv( &dn, &be->be_rootdn );
5676 ber_bvarray_add( &be->be_nsuffix, &dn );
5678 /* Hide from namingContexts */
5679 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
5685 config_back_destroy( BackendInfo *bi )
5687 ldif_must_b64_encode_release();
5692 config_tool_entry_open( BackendDB *be, int mode )
5694 CfBackInfo *cfb = be->be_private;
5695 BackendInfo *bi = cfb->cb_db.bd_info;
5697 if ( bi && bi->bi_tool_entry_open )
5698 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
5705 config_tool_entry_close( BackendDB *be )
5707 CfBackInfo *cfb = be->be_private;
5708 BackendInfo *bi = cfb->cb_db.bd_info;
5710 if ( bi && bi->bi_tool_entry_close )
5711 return bi->bi_tool_entry_close( &cfb->cb_db );
5717 config_tool_entry_first( BackendDB *be )
5719 CfBackInfo *cfb = be->be_private;
5720 BackendInfo *bi = cfb->cb_db.bd_info;
5722 if ( bi && bi->bi_tool_entry_first )
5723 return bi->bi_tool_entry_first( &cfb->cb_db );
5729 config_tool_entry_next( BackendDB *be )
5731 CfBackInfo *cfb = be->be_private;
5732 BackendInfo *bi = cfb->cb_db.bd_info;
5734 if ( bi && bi->bi_tool_entry_next )
5735 return bi->bi_tool_entry_next( &cfb->cb_db );
5741 config_tool_entry_get( BackendDB *be, ID id )
5743 CfBackInfo *cfb = be->be_private;
5744 BackendInfo *bi = cfb->cb_db.bd_info;
5746 if ( bi && bi->bi_tool_entry_get )
5747 return bi->bi_tool_entry_get( &cfb->cb_db, id );
5752 static int entry_put_got_frontend=0;
5753 static int entry_put_got_config=0;
5755 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
5757 CfBackInfo *cfb = be->be_private;
5758 BackendInfo *bi = cfb->cb_db.bd_info;
5760 struct berval rdn, vals[ 2 ];
5762 OperationBuffer opbuf;
5765 Connection conn = {0};
5766 Operation *op = NULL;
5767 SlapReply rs = {REP_RESULT};
5770 /* Create entry for frontend database if it does not exist already */
5771 if ( !entry_put_got_frontend ) {
5772 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
5773 STRLENOF( "olcDatabase" ))) {
5774 if ( strncmp( e->e_nname.bv_val +
5775 STRLENOF( "olcDatabase" ), "={-1}frontend",
5776 STRLENOF( "={-1}frontend" )) &&
5777 strncmp( e->e_nname.bv_val +
5778 STRLENOF( "olcDatabase" ), "=frontend",
5779 STRLENOF( "=frontend" ))) {
5781 vals[1].bv_val = NULL;
5782 memset( &ca, 0, sizeof(ConfigArgs));
5784 ca.bi = frontendDB->bd_info;
5785 ca.be->be_cf_ocs = &CFOC_FRONTEND;
5786 rdn.bv_val = ca.log;
5787 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
5788 "%s=" SLAP_X_ORDERED_FMT "%s",
5789 cfAd_database->ad_cname.bv_val, -1,
5791 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
5792 &CFOC_DATABASE, ca.be->be_cf_ocs );
5793 op = (Operation *) &opbuf;
5794 thrctx = ldap_pvt_thread_pool_context();
5795 connection_fake_init2( &conn, op, thrctx,0 );
5796 op->o_bd = &cfb->cb_db;
5797 op->o_tag = LDAP_REQ_ADD;
5799 op->o_dn = be->be_rootdn;
5800 op->o_ndn = be->be_rootndn;
5801 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
5802 if ( rc != LDAP_SUCCESS ) {
5803 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
5804 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
5808 if ( ce && bi && bi->bi_tool_entry_put &&
5809 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
5810 entry_put_got_frontend++;
5812 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
5813 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
5817 entry_put_got_frontend++;
5821 /* Create entry for config database if it does not exist already */
5822 if ( !entry_put_got_config ) {
5823 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
5824 STRLENOF( "olcDatabase" ))) {
5825 if ( strncmp( e->e_nname.bv_val +
5826 STRLENOF( "olcDatabase" ), "={0}config",
5827 STRLENOF( "={0}config" )) &&
5828 strncmp( e->e_nname.bv_val +
5829 STRLENOF( "olcDatabase" ), "=config",
5830 STRLENOF( "=config" )) ) {
5832 vals[1].bv_val = NULL;
5833 memset( &ca, 0, sizeof(ConfigArgs));
5834 ca.be = LDAP_STAILQ_FIRST( &backendDB );
5835 ca.bi = ca.be->bd_info;
5836 rdn.bv_val = ca.log;
5837 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
5838 "%s=" SLAP_X_ORDERED_FMT "%s",
5839 cfAd_database->ad_cname.bv_val, 0,
5841 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
5844 thrctx = ldap_pvt_thread_pool_context();
5845 op = (Operation *) &opbuf;
5846 connection_fake_init2( &conn, op, thrctx,0 );
5847 op->o_bd = &cfb->cb_db;
5848 op->o_tag = LDAP_REQ_ADD;
5849 op->o_dn = be->be_rootdn;
5850 op->o_ndn = be->be_rootndn;
5853 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
5854 if ( rc != LDAP_SUCCESS ) {
5855 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
5856 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
5859 if (ce && bi && bi->bi_tool_entry_put &&
5860 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
5861 entry_put_got_config++;
5863 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
5864 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
5868 entry_put_got_config++;
5872 if ( bi && bi->bi_tool_entry_put &&
5873 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
5874 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
5881 AttributeDescription **desc;
5883 { "attribute", &cfAd_attr },
5884 { "backend", &cfAd_backend },
5885 { "database", &cfAd_database },
5886 { "include", &cfAd_include },
5887 { "objectclass", &cfAd_oc },
5888 { "objectidentifier", &cfAd_om },
5889 { "overlay", &cfAd_overlay },
5894 * add / delete: all types that may be added or deleted must use an
5895 * X-ORDERED attributeType for their RDN. Adding and deleting entries
5896 * should automatically renumber the index of any siblings as needed,
5897 * so that no gaps in the numbering sequence exist after the add/delete
5899 * What can be added:
5901 * backend objects for backend-specific config directives
5905 * delete: probably no support this time around.
5907 * modrdn: generally not done. Will be invoked automatically by add/
5908 * delete to update numbering sequence. Perform as an explicit operation
5909 * so that the renumbering effect may be replicated. Subtree rename must
5910 * be supported, since renumbering a database will affect all its child
5913 * modify: must be fully supported.
5917 config_back_initialize( BackendInfo *bi )
5919 ConfigTable *ct = config_back_cf_table;
5923 AttributeDescription *ad = NULL;
5925 static char *controls[] = {
5926 LDAP_CONTROL_MANAGEDSAIT,
5930 /* Make sure we don't exceed the bits reserved for userland */
5931 config_check_userland( CFG_LAST );
5933 bi->bi_controls = controls;
5938 bi->bi_destroy = config_back_destroy;
5940 bi->bi_db_init = config_back_db_init;
5941 bi->bi_db_config = 0;
5942 bi->bi_db_open = config_back_db_open;
5943 bi->bi_db_close = config_back_db_close;
5944 bi->bi_db_destroy = config_back_db_destroy;
5946 bi->bi_op_bind = config_back_bind;
5947 bi->bi_op_unbind = 0;
5948 bi->bi_op_search = config_back_search;
5949 bi->bi_op_compare = 0;
5950 bi->bi_op_modify = config_back_modify;
5951 bi->bi_op_modrdn = config_back_modrdn;
5952 bi->bi_op_add = config_back_add;
5953 bi->bi_op_delete = config_back_delete;
5954 bi->bi_op_abandon = 0;
5956 bi->bi_extended = 0;
5958 bi->bi_chk_referrals = 0;
5960 bi->bi_access_allowed = slap_access_allowed;
5962 bi->bi_connection_init = 0;
5963 bi->bi_connection_destroy = 0;
5965 bi->bi_entry_release_rw = config_entry_release;
5966 bi->bi_entry_get_rw = config_back_entry_get;
5968 bi->bi_tool_entry_open = config_tool_entry_open;
5969 bi->bi_tool_entry_close = config_tool_entry_close;
5970 bi->bi_tool_entry_first = config_tool_entry_first;
5971 bi->bi_tool_entry_next = config_tool_entry_next;
5972 bi->bi_tool_entry_get = config_tool_entry_get;
5973 bi->bi_tool_entry_put = config_tool_entry_put;
5976 argv[ 0 ] = "slapd";
5982 for (i=0; OidMacros[i].name; i++ ) {
5983 argv[1] = OidMacros[i].name;
5984 argv[2] = OidMacros[i].oid;
5985 parse_oidm( &ca, 0, NULL );
5988 bi->bi_cf_ocs = cf_ocs;
5990 i = config_register_schema( ct, cf_ocs );
5993 /* setup olcRootPW to be base64-encoded when written in LDIF form;
5994 * basically, we don't care if it fails */
5995 i = slap_str2ad( "olcRootPW", &ad, &text );
5997 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
5998 "warning, unable to get \"olcRootPW\" "
5999 "attribute description: %d: %s\n",
6002 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
6003 ad->ad_type->sat_oid );
6006 /* set up the notable AttributeDescriptions */
6008 for (;ct->name;ct++) {
6009 if (strcmp(ct->name, ads[i].name)) continue;
6010 *ads[i].desc = ct->ad;
6012 if (!ads[i].name) break;