1 /* bconfig.c - the config backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2009 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;
66 Syntax *c_syn_head, *c_syn_tail;
71 ConfigFile *cb_config;
73 BackendDB cb_db; /* underlying database */
78 static CfBackInfo cfBackInfo;
80 static char *passwd_salt;
82 static char *logfileName;
83 #ifdef SLAP_AUTH_REWRITE
84 static BerVarray authz_rewrites;
87 static struct berval cfdir;
90 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
91 *cfAd_include, *cfAd_attr, *cfAd_oc, *cfAd_om, *cfAd_syntax;
93 static ConfigFile *cfn;
95 static Avlnode *CfOcTree;
97 /* System schema state */
98 extern AttributeType *at_sys_tail; /* at.c */
99 extern ObjectClass *oc_sys_tail; /* oc.c */
100 extern OidMacro *om_sys_tail; /* oidm.c */
101 extern Syntax *syn_sys_tail; /* syntax.c */
102 static AttributeType *cf_at_tail;
103 static ObjectClass *cf_oc_tail;
104 static OidMacro *cf_om_tail;
105 static Syntax *cf_syn_tail;
107 static int config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca,
108 SlapReply *rs, int *renumber, Operation *op );
110 static int config_check_schema( Operation *op, CfBackInfo *cfb );
112 static ConfigDriver config_fname;
113 static ConfigDriver config_cfdir;
114 static ConfigDriver config_generic;
115 static ConfigDriver config_search_base;
116 static ConfigDriver config_passwd_hash;
117 static ConfigDriver config_schema_dn;
118 static ConfigDriver config_sizelimit;
119 static ConfigDriver config_timelimit;
120 static ConfigDriver config_overlay;
121 static ConfigDriver config_subordinate;
122 static ConfigDriver config_suffix;
123 static ConfigDriver config_rootdn;
124 static ConfigDriver config_rootpw;
125 static ConfigDriver config_restrict;
126 static ConfigDriver config_allows;
127 static ConfigDriver config_disallows;
128 static ConfigDriver config_requires;
129 static ConfigDriver config_security;
130 static ConfigDriver config_referral;
131 static ConfigDriver config_loglevel;
132 static ConfigDriver config_updatedn;
133 static ConfigDriver config_updateref;
134 static ConfigDriver config_include;
135 static ConfigDriver config_obsolete;
137 static ConfigDriver config_tls_option;
138 static ConfigDriver config_tls_config;
140 extern ConfigDriver syncrepl_config;
148 CFG_TLS_PROTOCOL_MIN,
197 static OidRec OidMacros[] = {
198 /* OpenLDAProot:1.12.2 */
199 { "OLcfg", "1.3.6.1.4.1.4203.1.12.2" },
200 { "OLcfgAt", "OLcfg:3" },
201 { "OLcfgGlAt", "OLcfgAt:0" },
202 { "OLcfgBkAt", "OLcfgAt:1" },
203 { "OLcfgDbAt", "OLcfgAt:2" },
204 { "OLcfgOvAt", "OLcfgAt:3" },
205 { "OLcfgCtAt", "OLcfgAt:4" }, /* contrib modules */
206 { "OLcfgOc", "OLcfg:4" },
207 { "OLcfgGlOc", "OLcfgOc:0" },
208 { "OLcfgBkOc", "OLcfgOc:1" },
209 { "OLcfgDbOc", "OLcfgOc:2" },
210 { "OLcfgOvOc", "OLcfgOc:3" },
211 { "OLcfgCtOc", "OLcfgOc:4" }, /* contrib modules */
213 /* Syntaxes. We should just start using the standard names and
214 * document that they are predefined and available for users
215 * to reference in their own schema. Defining schema without
216 * OID macros is for masochists...
218 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
219 { "OMsBoolean", "OMsyn:7" },
220 { "OMsDN", "OMsyn:12" },
221 { "OMsDirectoryString", "OMsyn:15" },
222 { "OMsIA5String", "OMsyn:26" },
223 { "OMsInteger", "OMsyn:27" },
224 { "OMsOID", "OMsyn:38" },
225 { "OMsOctetString", "OMsyn:40" },
230 * Backend/Database registry
232 * OLcfg{Bk|Db}{Oc|At}:0 -> common
233 * OLcfg{Bk|Db}{Oc|At}:1 -> back-bdb(/back-hdb)
234 * OLcfg{Bk|Db}{Oc|At}:2 -> back-ldif
235 * OLcfg{Bk|Db}{Oc|At}:3 -> back-ldap
236 * OLcfg{Bk|Db}{Oc|At}:4 -> back-monitor
237 * OLcfg{Bk|Db}{Oc|At}:5 -> back-relay
238 * OLcfg{Bk|Db}{Oc|At}:6 -> back-sql
239 * OLcfg{Bk|Db}{Oc|At}:7 -> back-sock
245 * OLcfgOv{Oc|At}:1 -> syncprov
246 * OLcfgOv{Oc|At}:2 -> pcache
247 * OLcfgOv{Oc|At}:3 -> chain
248 * OLcfgOv{Oc|At}:4 -> accesslog
249 * OLcfgOv{Oc|At}:5 -> valsort
250 * OLcfgOv{Oc|At}:7 -> distproc
251 * OLcfgOv{Oc|At}:8 -> dynlist
252 * OLcfgOv{Oc|At}:9 -> dds
253 * OLcfgOv{Oc|At}:10 -> unique
254 * OLcfgOv{Oc|At}:11 -> refint
255 * OLcfgOv{Oc|At}:12 -> ppolicy
256 * OLcfgOv{Oc|At}:13 -> constraint
257 * OLcfgOv{Oc|At}:14 -> translucent
258 * OLcfgOv{Oc|At}:15 -> auditlog
259 * OLcfgOv{Oc|At}:16 -> rwm
260 * OLcfgOv{Oc|At}:17 -> dyngroup
261 * OLcfgOv{Oc|At}:18 -> memberof
262 * OLcfgOv{Oc|At}:19 -> collect
263 * OLcfgOv{Oc|At}:20 -> retcode
264 * OLcfgOv{Oc|At}:21 -> sssvlv
267 /* alphabetical ordering */
269 static ConfigTable config_back_cf_table[] = {
270 /* This attr is read-only */
271 { "", "", 0, 0, 0, ARG_MAGIC,
272 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
273 "DESC 'File for slapd configuration directives' "
274 "EQUALITY caseIgnoreMatch "
275 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
276 { "", "", 0, 0, 0, ARG_MAGIC,
277 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
278 "DESC 'Directory for slapd configuration backend' "
279 "EQUALITY caseIgnoreMatch "
280 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
281 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
282 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
283 "DESC 'Access Control List' "
284 "EQUALITY caseIgnoreMatch "
285 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
286 { "add_content_acl", NULL, 0, 0, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_ACL_ADD,
287 &config_generic, "( OLcfgGlAt:86 NAME 'olcAddContentAcl' "
288 "DESC 'Check ACLs against content of Add ops' "
289 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
290 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
291 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
292 "DESC 'Allowed set of deprecated features' "
293 "EQUALITY caseIgnoreMatch "
294 "SYNTAX OMsDirectoryString )", NULL, NULL },
295 { "argsfile", "file", 2, 2, 0, ARG_STRING,
296 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
297 "DESC 'File for slapd command line options' "
298 "EQUALITY caseIgnoreMatch "
299 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
300 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
301 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
302 "EQUALITY caseIgnoreMatch "
303 "SYNTAX OMsDirectoryString )", NULL, NULL },
304 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
305 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
306 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
307 "DESC 'OpenLDAP attributeTypes' "
308 "EQUALITY caseIgnoreMatch "
309 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
311 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
312 #ifdef SLAP_AUTH_REWRITE
313 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
317 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
318 "EQUALITY caseIgnoreMatch "
319 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
320 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
321 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
322 "EQUALITY caseIgnoreMatch "
323 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
324 { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
325 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
326 "EQUALITY caseIgnoreMatch "
327 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
328 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
329 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
330 "DESC 'A type of backend' "
331 "EQUALITY caseIgnoreMatch "
332 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
334 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
335 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
336 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
337 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
338 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
339 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
340 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
341 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
342 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
343 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
344 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
345 "DESC 'The backend type for a database instance' "
346 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
347 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
348 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
349 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
350 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
351 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
352 "EQUALITY caseIgnoreMatch "
353 "SYNTAX OMsDirectoryString )", NULL, NULL },
354 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
355 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
356 "DESC 'OpenLDAP DIT content rules' "
357 "EQUALITY caseIgnoreMatch "
358 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
360 { "gentlehup", "on|off", 2, 2, 0,
362 ARG_ON_OFF, &global_gentlehup,
366 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
367 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
368 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
369 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
370 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
371 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
372 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
373 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
374 { "include", "file", 2, 2, 0, ARG_MAGIC,
375 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
376 "SUP labeledURI )", NULL, NULL },
377 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
378 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
379 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
380 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
381 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
382 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
383 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
384 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
385 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
386 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
387 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
388 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
389 { "index_intlen", "len", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_IX_INTLEN,
390 &config_generic, "( OLcfgGlAt:84 NAME 'olcIndexIntLen' "
391 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
392 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
393 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
394 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
395 { "ldapsyntax", "syntax", 2, 0, 0,
396 ARG_PAREN|ARG_MAGIC|CFG_SYNTAX,
397 &config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
398 "DESC 'OpenLDAP ldapSyntax' "
399 "EQUALITY caseIgnoreMatch "
400 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
402 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
403 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
404 "EQUALITY caseIgnoreMatch "
405 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
406 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
407 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
408 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
409 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
410 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
411 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
412 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
413 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
414 "EQUALITY caseIgnoreMatch "
415 "SYNTAX OMsDirectoryString )", NULL, NULL },
416 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
417 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
418 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
419 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
420 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
421 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
422 { "moduleload", "file", 2, 0, 0,
424 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
428 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
429 "EQUALITY caseIgnoreMatch "
430 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
431 { "modulepath", "path", 2, 2, 0,
433 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
437 "( OLcfgGlAt:31 NAME 'olcModulePath' "
438 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
439 { "monitoring", "TRUE|FALSE", 2, 2, 0,
440 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
441 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
442 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
443 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
444 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
445 "DESC 'OpenLDAP object classes' "
446 "EQUALITY caseIgnoreMatch "
447 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
449 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
450 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
451 "EQUALITY caseIgnoreMatch "
452 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
453 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
454 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
455 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
456 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
457 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
458 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
459 { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
460 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
461 "EQUALITY caseIgnoreMatch "
462 "SYNTAX OMsDirectoryString )", NULL, NULL },
463 { "pidfile", "file", 2, 2, 0, ARG_STRING,
464 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
465 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
466 { "plugin", NULL, 0, 0, 0,
468 ARG_MAGIC|CFG_PLUGIN, &config_generic,
472 "( OLcfgGlAt:38 NAME 'olcPlugin' "
473 "EQUALITY caseIgnoreMatch "
474 "SYNTAX OMsDirectoryString )", NULL, NULL },
475 { "pluginlog", "filename", 2, 2, 0,
477 ARG_STRING, &slapi_log_file,
481 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
482 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
483 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
484 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
485 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
486 { "referral", "url", 2, 2, 0, ARG_MAGIC,
487 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
488 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
489 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
490 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
491 "EQUALITY caseIgnoreMatch "
492 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
493 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
494 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
495 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
496 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
497 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
498 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
499 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
500 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
501 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
502 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
503 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
504 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
505 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
506 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
507 "EQUALITY caseIgnoreMatch "
508 "SYNTAX OMsDirectoryString )", NULL, NULL },
509 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
510 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
511 "EQUALITY caseIgnoreMatch "
512 "SYNTAX OMsDirectoryString )", NULL, NULL },
513 { "reverse-lookup", "on|off", 2, 2, 0,
514 #ifdef SLAPD_RLOOKUPS
515 ARG_ON_OFF, &use_reverse_lookup,
519 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
520 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
521 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
522 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
523 "EQUALITY distinguishedNameMatch "
524 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
525 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
526 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
527 "EQUALITY caseIgnoreMatch "
528 "SYNTAX OMsDirectoryString )", NULL, NULL },
529 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
530 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
531 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
532 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
533 &config_generic, NULL, NULL, NULL },
534 { "sasl-auxprops", NULL, 2, 0, 0,
535 #ifdef HAVE_CYRUS_SASL
536 ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
540 "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
541 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
542 { "sasl-host", "host", 2, 2, 0,
543 #ifdef HAVE_CYRUS_SASL
544 ARG_STRING|ARG_UNIQUE, &sasl_host,
548 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
549 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
550 { "sasl-realm", "realm", 2, 2, 0,
551 #ifdef HAVE_CYRUS_SASL
552 ARG_STRING|ARG_UNIQUE, &global_realm,
556 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
557 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
558 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
559 &config_generic, NULL, NULL, NULL },
560 { "sasl-secprops", "properties", 2, 2, 0,
561 #ifdef HAVE_CYRUS_SASL
562 ARG_MAGIC|CFG_SASLSECP, &config_generic,
566 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
567 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
568 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
569 &config_generic, NULL, NULL, NULL },
570 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
571 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
572 "EQUALITY distinguishedNameMatch "
573 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
574 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
575 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
576 "EQUALITY caseIgnoreMatch "
577 "SYNTAX OMsDirectoryString )", NULL, NULL },
578 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
579 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
580 "EQUALITY caseIgnoreMatch "
581 "SYNTAX OMsDirectoryString )", NULL, NULL },
582 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
583 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
584 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
585 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
586 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
587 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
588 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
589 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
590 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
591 { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
592 &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
593 "DESC 'Attributes whose values will always be sorted' "
594 "EQUALITY caseIgnoreMatch "
595 "SYNTAX OMsDirectoryString )", NULL, NULL },
596 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
597 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
598 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
599 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
600 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
601 "EQUALITY distinguishedNameMatch "
602 "SYNTAX OMsDN )", NULL, NULL },
603 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
604 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
605 "EQUALITY caseIgnoreMatch "
606 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
607 { "threads", "count", 2, 2, 0,
611 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
613 "( OLcfgGlAt:66 NAME 'olcThreads' "
614 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
615 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
616 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
617 "SYNTAX OMsDirectoryString )", NULL, NULL },
618 { "TLSCACertificateFile", NULL, 0, 0, 0,
620 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
624 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
625 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
626 { "TLSCACertificatePath", NULL, 0, 0, 0,
628 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
632 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
633 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
634 { "TLSCertificateFile", NULL, 0, 0, 0,
636 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
640 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
641 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
642 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
644 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
648 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
649 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
650 { "TLSCipherSuite", NULL, 0, 0, 0,
652 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
656 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
657 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
658 { "TLSCRLCheck", NULL, 0, 0, 0,
659 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
660 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
664 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
665 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
666 { "TLSCRLFile", NULL, 0, 0, 0,
667 #if defined(HAVE_GNUTLS)
668 CFG_TLS_CRL_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
672 "( OLcfgGlAt:82 NAME 'olcTLSCRLFile' "
673 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
674 { "TLSRandFile", NULL, 0, 0, 0,
676 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
680 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
681 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
682 { "TLSVerifyClient", NULL, 0, 0, 0,
684 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
688 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
689 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
690 { "TLSDHParamFile", NULL, 0, 0, 0,
692 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
696 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
697 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
698 { "TLSProtocolMin", NULL, 0, 0, 0,
700 CFG_TLS_PROTOCOL_MIN|ARG_STRING|ARG_MAGIC, &config_tls_config,
704 "( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' "
705 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
706 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
707 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
708 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
709 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
710 NULL, NULL, NULL, NULL },
711 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
712 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
713 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
714 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
715 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
716 "EQUALITY caseIgnoreMatch "
717 "SUP labeledURI )", NULL, NULL },
718 { "writetimeout", "timeout", 2, 2, 0, ARG_INT,
719 &global_writetimeout, "( OLcfgGlAt:88 NAME 'olcWriteTimeout' "
720 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
721 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
722 NULL, NULL, NULL, NULL }
725 /* Need to no-op this keyword for dynamic config */
726 ConfigTable olcDatabaseDummy[] = {
727 { "", "", 0, 0, 0, ARG_IGNORED,
728 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
729 "DESC 'The backend type for a database instance' "
730 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
731 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
734 /* Routines to check if a child can be added to this type */
735 static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
736 cfAddBackend, cfAddModule, cfAddOverlay;
738 /* NOTE: be careful when defining array members
739 * that can be conditionally compiled */
740 #define CFOC_GLOBAL cf_ocs[1]
741 #define CFOC_SCHEMA cf_ocs[2]
742 #define CFOC_BACKEND cf_ocs[3]
743 #define CFOC_DATABASE cf_ocs[4]
744 #define CFOC_OVERLAY cf_ocs[5]
745 #define CFOC_INCLUDE cf_ocs[6]
746 #define CFOC_FRONTEND cf_ocs[7]
748 #define CFOC_MODULE cf_ocs[8]
749 #endif /* SLAPD_MODULES */
751 static ConfigOCs cf_ocs[] = {
754 "DESC 'OpenLDAP configuration object' "
755 "ABSTRACT SUP top )", Cft_Abstract, NULL },
758 "DESC 'OpenLDAP Global configuration options' "
759 "SUP olcConfig STRUCTURAL "
760 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
761 "olcAttributeOptions $ olcAuthIDRewrite $ "
762 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
763 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
764 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
765 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
766 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcIndexIntLen $ "
767 "olcLocalSSF $ olcLogFile $ olcLogLevel $ "
768 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
769 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
770 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
772 "olcSaslAuxprops $ olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
773 "olcSecurity $ olcServerID $ olcSizeLimit $ "
774 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
775 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
776 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
777 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
778 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
779 "olcTLSCRLFile $ olcToolThreads $ olcWriteTimeout $ "
780 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
781 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
783 "NAME 'olcSchemaConfig' "
784 "DESC 'OpenLDAP schema object' "
785 "SUP olcConfig STRUCTURAL "
786 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
787 "olcObjectClasses $ olcDitContentRules $ olcLdapSyntaxes ) )",
788 Cft_Schema, NULL, cfAddSchema },
790 "NAME 'olcBackendConfig' "
791 "DESC 'OpenLDAP Backend-specific options' "
792 "SUP olcConfig STRUCTURAL "
793 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
795 "NAME 'olcDatabaseConfig' "
796 "DESC 'OpenLDAP Database-specific options' "
797 "SUP olcConfig STRUCTURAL "
799 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
800 "olcAddContentAcl $ olcLastMod $ olcLimits $ "
801 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
802 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
803 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
804 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ "
805 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
807 Cft_Database, NULL, cfAddDatabase },
809 "NAME 'olcOverlayConfig' "
810 "DESC 'OpenLDAP Overlay-specific options' "
811 "SUP olcConfig STRUCTURAL "
812 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
814 "NAME 'olcIncludeFile' "
815 "DESC 'OpenLDAP configuration include file' "
816 "SUP olcConfig STRUCTURAL "
818 "MAY ( cn $ olcRootDSE ) )",
819 /* Used to be Cft_Include, that def has been removed */
820 Cft_Abstract, NULL, cfAddInclude },
821 /* This should be STRUCTURAL like all the other database classes, but
822 * that would mean inheriting all of the olcDatabaseConfig attributes,
823 * which causes them to be merged twice in config_build_entry.
826 "NAME 'olcFrontendConfig' "
827 "DESC 'OpenLDAP frontend configuration' "
829 "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
830 Cft_Database, NULL, NULL },
833 "NAME 'olcModuleList' "
834 "DESC 'OpenLDAP dynamic module info' "
835 "SUP olcConfig STRUCTURAL "
836 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
837 Cft_Module, NULL, cfAddModule },
842 typedef struct ServerID {
843 struct ServerID *si_next;
844 struct berval si_url;
848 static ServerID *sid_list;
850 typedef struct voidList {
851 struct voidList *vl_next;
855 typedef struct ADlist {
856 struct ADlist *al_next;
857 AttributeDescription *al_desc;
860 static ADlist *sortVals;
863 config_generic(ConfigArgs *c) {
866 if ( c->op == SLAP_CONFIG_EMIT ) {
870 c->value_int = ldap_pvt_thread_get_concurrency();
873 c->value_int = connection_pool_max;
876 c->value_int = slap_tool_thread_max;
880 c->value_string = ch_strdup( passwd_salt );
885 if ( c->be->be_limits ) {
889 for ( i=0; c->be->be_limits[i]; i++ ) {
890 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
891 if ( bv.bv_len >= sizeof( buf ) ) {
892 ber_bvarray_free_x( c->rvalue_vals, NULL );
893 c->rvalue_vals = NULL;
897 bv.bv_val = buf + bv.bv_len;
898 limits_unparse( c->be->be_limits[i], &bv,
899 sizeof( buf ) - ( bv.bv_val - buf ) );
900 bv.bv_len += bv.bv_val - buf;
902 value_add_one( &c->rvalue_vals, &bv );
905 if ( !c->rvalue_vals ) rc = 1;
908 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
911 c->value_string = ch_strdup( slap_sasl_getpolicy());
914 slap_sasl_regexp_unparse( &c->rvalue_vals );
915 if ( !c->rvalue_vals ) rc = 1;
917 #ifdef HAVE_CYRUS_SASL
919 struct berval bv = BER_BVNULL;
920 slap_sasl_secprops_unparse( &bv );
921 if ( !BER_BVISNULL( &bv )) {
922 ber_bvarray_add( &c->rvalue_vals, &bv );
930 c->value_int = c->be->be_max_deref_depth;
933 if ( SLAP_DBHIDDEN( c->be )) {
940 ConfigFile *cf = c->ca_private;
942 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
943 else if ( cf->c_om_head )
944 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
946 if ( !c->rvalue_vals )
951 ad_unparse_options( &c->rvalue_vals );
954 ConfigFile *cf = c->ca_private;
956 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
957 else if ( cf->c_oc_head )
958 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
960 if ( !c->rvalue_vals )
965 ConfigFile *cf = c->ca_private;
967 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
968 else if ( cf->c_at_head )
969 at_unparse( &c->rvalue_vals, cf->c_at_head,
971 if ( !c->rvalue_vals )
976 ConfigFile *cf = c->ca_private;
978 syn_unparse( &c->rvalue_vals, NULL, NULL, 1 );
979 else if ( cf->c_syn_head )
980 syn_unparse( &c->rvalue_vals, cf->c_syn_head,
982 if ( !c->rvalue_vals )
987 ConfigFile *cf = c->ca_private;
989 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
990 else if ( cf->c_cr_head )
991 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
993 if ( !c->rvalue_vals )
1000 char *src, *dst, ibuf[11];
1001 struct berval bv, abv;
1002 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
1003 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1004 if ( abv.bv_len >= sizeof( ibuf ) ) {
1005 ber_bvarray_free_x( c->rvalue_vals, NULL );
1006 c->rvalue_vals = NULL;
1010 acl_unparse( a, &bv );
1011 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
1012 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
1013 /* Turn TAB / EOL into plain space */
1014 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
1015 if (isspace((unsigned char)*src)) *dst++ = ' ';
1019 if (dst[-1] == ' ') {
1023 abv.bv_len = dst - abv.bv_val;
1024 ber_bvarray_add( &c->rvalue_vals, &abv );
1030 c->value_int = (SLAP_DBACL_ADD(c->be) != 0);
1033 ConfigFile *cf = c->ca_private;
1034 if ( cf->c_dseFiles ) {
1035 value_add( &c->rvalue_vals, cf->c_dseFiles );
1046 for ( si = sid_list; si; si=si->si_next ) {
1047 assert( si->si_num >= 0 && si->si_num <= SLAP_SYNC_SID_MAX );
1048 if ( !BER_BVISEMPTY( &si->si_url )) {
1049 bv.bv_len = si->si_url.bv_len + 6;
1050 bv.bv_val = ch_malloc( bv.bv_len );
1051 bv.bv_len = sprintf( bv.bv_val, "%d %s", si->si_num,
1052 si->si_url.bv_val );
1053 ber_bvarray_add( &c->rvalue_vals, &bv );
1057 bv.bv_len = sprintf( buf, "%d", si->si_num );
1058 value_add_one( &c->rvalue_vals, &bv );
1067 c->value_string = ch_strdup( logfileName );
1072 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
1074 case CFG_MIRRORMODE:
1075 if ( SLAP_SHADOW(c->be))
1076 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
1080 case CFG_MONITORING:
1081 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
1083 case CFG_SSTR_IF_MAX:
1084 c->value_int = index_substr_if_maxlen;
1086 case CFG_SSTR_IF_MIN:
1087 c->value_int = index_substr_if_minlen;
1090 c->value_int = index_intlen;
1092 case CFG_SORTVALS: {
1095 for ( sv = sortVals; sv; sv = sv->al_next ) {
1096 value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
1100 #ifdef SLAPD_MODULES
1102 ModPaths *mp = c->ca_private;
1105 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
1108 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
1109 SLAP_X_ORDERED_FMT "%s", i,
1110 mp->mp_loads[i].bv_val );
1111 if ( bv.bv_len >= sizeof( c->log ) ) {
1112 ber_bvarray_free_x( c->rvalue_vals, NULL );
1113 c->rvalue_vals = NULL;
1116 value_add_one( &c->rvalue_vals, &bv );
1120 rc = c->rvalue_vals ? 0 : 1;
1124 ModPaths *mp = c->ca_private;
1125 if ( !BER_BVISNULL( &mp->mp_path ))
1126 value_add_one( &c->rvalue_vals, &mp->mp_path );
1128 rc = c->rvalue_vals ? 0 : 1;
1134 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1135 if ( !c->rvalue_vals ) rc = 1;
1138 #ifdef SLAP_AUTH_REWRITE
1140 if ( authz_rewrites ) {
1141 struct berval bv, idx;
1146 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1147 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1148 if ( idx.bv_len >= sizeof( ibuf ) ) {
1149 ber_bvarray_free_x( c->rvalue_vals, NULL );
1150 c->rvalue_vals = NULL;
1153 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1154 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1155 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1156 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1157 authz_rewrites[i].bv_val,
1158 authz_rewrites[i].bv_len + 1 );
1159 ber_bvarray_add( &c->rvalue_vals, &bv );
1162 if ( !c->rvalue_vals ) rc = 1;
1169 } else if ( c->op == LDAP_MOD_DELETE ) {
1172 /* single-valued attrs, no-ops */
1180 case CFG_MIRRORMODE:
1181 case CFG_MONITORING:
1183 case CFG_SSTR_IF_MAX:
1184 case CFG_SSTR_IF_MIN:
1188 /* no-ops, requires slapd restart */
1193 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1197 ch_free( passwd_salt );
1202 ch_free( logfileName );
1210 case CFG_SERVERID: {
1211 ServerID *si, **sip;
1213 for ( i=0, si = sid_list, sip = &sid_list;
1214 si; si = *sip, i++ ) {
1215 if ( c->valx == -1 || i == c->valx ) {
1227 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1231 index_intlen = SLAP_INDEX_INTLEN_DEFAULT;
1232 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1233 SLAP_INDEX_INTLEN_DEFAULT );
1237 if ( c->valx < 0 ) {
1238 acl_destroy( c->be->be_acl );
1239 c->be->be_acl = NULL;
1242 AccessControl **prev, *a;
1244 for (i=0, prev = &c->be->be_acl; i < c->valx;
1247 prev = &a->acl_next;
1250 *prev = a->acl_next;
1257 /* Can be NULL when undoing a failed add */
1258 if ( c->ca_entry ) {
1259 ce = c->ca_entry->e_private;
1260 /* can't modify the hardcoded schema */
1261 if ( ce->ce_parent->ce_type == Cft_Global )
1265 cfn = c->ca_private;
1266 if ( c->valx < 0 ) {
1269 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1271 if ( oc == cfn->c_oc_tail )
1274 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1276 ObjectClass *oc, *prev = NULL;
1278 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1283 if ( cfn->c_oc_tail == oc ) {
1284 cfn->c_oc_tail = prev;
1286 if ( cfn->c_oc_head == oc ) {
1288 cfn->c_oc_head = oc;
1295 /* Can be NULL when undoing a failed add */
1296 if ( c->ca_entry ) {
1297 ce = c->ca_entry->e_private;
1298 /* can't modify the hardcoded schema */
1299 if ( ce->ce_parent->ce_type == Cft_Global )
1303 cfn = c->ca_private;
1304 if ( c->valx < 0 ) {
1307 for( at = cfn->c_at_head; at; at_next( &at )) {
1309 if ( at == cfn->c_at_tail )
1312 cfn->c_at_head = cfn->c_at_tail = NULL;
1314 AttributeType *at, *prev = NULL;
1316 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1321 if ( cfn->c_at_tail == at ) {
1322 cfn->c_at_tail = prev;
1324 if ( cfn->c_at_head == at ) {
1326 cfn->c_at_head = at;
1333 /* Can be NULL when undoing a failed add */
1334 if ( c->ca_entry ) {
1335 ce = c->ca_entry->e_private;
1336 /* can't modify the hardcoded schema */
1337 if ( ce->ce_parent->ce_type == Cft_Global )
1341 cfn = c->ca_private;
1342 if ( c->valx < 0 ) {
1345 for( syn = cfn->c_syn_head; syn; syn_next( &syn )) {
1347 if ( syn == cfn->c_syn_tail )
1350 cfn->c_syn_head = cfn->c_syn_tail = NULL;
1352 Syntax *syn, *prev = NULL;
1354 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++) {
1359 if ( cfn->c_syn_tail == syn ) {
1360 cfn->c_syn_tail = prev;
1362 if ( cfn->c_syn_head == syn ) {
1364 cfn->c_syn_head = syn;
1369 if ( c->valx < 0 ) {
1371 for ( sv = sortVals; sv; sv = sortVals ) {
1372 sortVals = sv->al_next;
1373 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1380 for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
1381 prev = &sv->al_next;
1384 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1385 *prev = sv->al_next;
1391 /* FIXME: there is no limits_free function */
1392 if ( c->valx < 0 ) {
1393 limits_destroy( c->be->be_limits );
1394 c->be->be_limits = NULL;
1399 if ( c->be->be_limits ) {
1400 for ( num = 0; c->be->be_limits[ num ]; num++ )
1404 if ( c->valx >= num ) {
1409 limits_destroy( c->be->be_limits );
1410 c->be->be_limits = NULL;
1413 limits_free_one( c->be->be_limits[ c->valx ] );
1415 for ( cnt = c->valx; cnt < num; cnt++ ) {
1416 c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
1423 /* FIXME: there is no ad_option_free function */
1425 /* FIXME: there is no way to remove attributes added by
1439 if(!(c->bi = backend_info(c->argv[1]))) {
1440 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1441 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1442 c->log, c->cr_msg, c->argv[1] );
1449 /* NOTE: config is always the first backend!
1451 if ( !strcasecmp( c->argv[1], "config" )) {
1452 c->be = LDAP_STAILQ_FIRST(&backendDB);
1453 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1456 c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply);
1458 if ( c->cr_msg[0] == 0 )
1459 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1460 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n", c->log, c->cr_msg, c->argv[1] );
1467 ldap_pvt_thread_set_concurrency(c->value_int);
1471 if ( c->value_int < 2 ) {
1472 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1473 "threads=%d smaller than minimum value 2",
1475 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1476 c->log, c->cr_msg, 0 );
1479 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1480 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1481 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1482 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1483 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1484 c->log, c->cr_msg, 0 );
1486 if ( slapMode & SLAP_SERVER_MODE )
1487 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1488 connection_pool_max = c->value_int; /* save for reference */
1492 if ( slapMode & SLAP_TOOL_MODE )
1493 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1494 slap_tool_thread_max = c->value_int; /* save for reference */
1498 if ( passwd_salt ) ch_free( passwd_salt );
1499 passwd_salt = c->value_string;
1500 lutil_salt_format(passwd_salt);
1504 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1510 c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1512 c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1516 ch_free(c->value_string);
1517 if (slap_sasl_setpolicy( c->argv[1] )) {
1518 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
1519 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1520 c->log, c->cr_msg, c->argv[1] );
1526 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1530 #ifdef HAVE_CYRUS_SASL
1533 char *txt = slap_sasl_secprops( c->argv[1] );
1535 snprintf( c->cr_msg, sizeof(c->cr_msg), "<%s> %s",
1537 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0 );
1545 c->be->be_max_deref_depth = c->value_int;
1551 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1552 cfn = c->ca_private;
1553 if(parse_oidm(c, 1, &om))
1555 if (!cfn->c_om_head) cfn->c_om_head = om;
1556 cfn->c_om_tail = om;
1561 ObjectClass *oc, *prev;
1563 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1564 cfn = c->ca_private;
1565 if ( c->valx < 0 ) {
1566 prev = cfn->c_oc_tail;
1569 /* If adding anything after the first, prev is easy */
1572 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1577 /* If adding the first, and head exists, find its prev */
1578 if (cfn->c_oc_head) {
1579 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1584 /* else prev is NULL, append to end of global list */
1586 if(parse_oc(c, &oc, prev)) return(1);
1587 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1588 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1593 AttributeType *at, *prev;
1595 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1596 cfn = c->ca_private;
1597 if ( c->valx < 0 ) {
1598 prev = cfn->c_at_tail;
1601 /* If adding anything after the first, prev is easy */
1604 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1609 /* If adding the first, and head exists, find its prev */
1610 if (cfn->c_at_head) {
1611 for ( at_start( &at ); at != cfn->c_at_head; ) {
1616 /* else prev is NULL, append to end of global list */
1618 if(parse_at(c, &at, prev)) return(1);
1619 if (!cfn->c_at_head) cfn->c_at_head = at;
1620 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1627 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1628 cfn = c->ca_private;
1629 if ( c->valx < 0 ) {
1630 prev = cfn->c_syn_tail;
1633 /* If adding anything after the first, prev is easy */
1636 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
1641 /* If adding the first, and head exists, find its prev */
1642 if (cfn->c_syn_head) {
1643 for ( syn_start( &syn ); syn != cfn->c_syn_head; ) {
1648 /* else prev is NULL, append to end of global list */
1650 if ( parse_syn( c, &syn, prev ) ) return(1);
1651 if ( !cfn->c_syn_head ) cfn->c_syn_head = syn;
1652 if ( cfn->c_syn_tail == prev ) cfn->c_syn_tail = syn;
1659 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1660 cfn = c->ca_private;
1661 if(parse_cr(c, &cr)) return(1);
1662 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1663 cfn->c_cr_tail = cr;
1668 ad_define_option(NULL, NULL, 0);
1669 for(i = 1; i < c->argc; i++)
1670 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1675 if ( c->value_int < SLAP_INDEX_INTLEN_DEFAULT )
1676 c->value_int = SLAP_INDEX_INTLEN_DEFAULT;
1677 else if ( c->value_int > 255 )
1679 index_intlen = c->value_int;
1680 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1684 case CFG_SORTVALS: {
1685 ADlist *svnew = NULL, *svtail, *sv;
1687 for ( i = 1; i < c->argc; i++ ) {
1688 AttributeDescription *ad = NULL;
1692 rc = slap_str2ad( c->argv[i], &ad, &text );
1694 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
1697 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1698 c->log, c->cr_msg, c->argv[i] );
1699 for ( sv = svnew; sv; sv = svnew ) {
1700 svnew = sv->al_next;
1705 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
1706 ad->ad_type->sat_single_value ) {
1707 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
1709 goto sortval_reject;
1711 sv = ch_malloc( sizeof( ADlist ));
1716 svtail->al_next = sv;
1721 for ( sv = svnew; sv; sv = sv->al_next )
1722 sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
1723 for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
1725 sv->al_next = svnew;
1732 /* Don't append to the global ACL if we're on a specific DB */
1734 if ( c->valx == -1 ) {
1737 for ( a=c->be->be_acl; a; a = a->acl_next )
1740 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1747 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_ACL_ADD;
1749 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_ACL_ADD;
1753 if(root_dse_read_file(c->argv[1])) {
1754 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> could not read file", c->argv[0] );
1755 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1756 c->log, c->cr_msg, c->argv[1] );
1761 ber_str2bv( c->argv[1], 0, 1, &bv );
1762 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1763 cfn = c->ca_private;
1764 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1770 ServerID *si, **sip;
1773 if ( lutil_atoi( &num, c->argv[1] ) ||
1774 num < 0 || num > SLAP_SYNC_SID_MAX )
1776 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1777 "<%s> illegal server ID", c->argv[0] );
1778 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1779 c->log, c->cr_msg, c->argv[1] );
1782 /* only one value allowed if no URL is given */
1783 if ( c->argc > 2 ) {
1786 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1787 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1788 "<%s> only one server ID allowed now", c->argv[0] );
1789 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1790 c->log, c->cr_msg, c->argv[1] );
1794 if ( ldap_url_parse( c->argv[2], &lud )) {
1795 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1796 "<%s> invalid URL", c->argv[0] );
1797 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1798 c->log, c->cr_msg, c->argv[2] );
1801 len = strlen( c->argv[2] );
1802 si = ch_malloc( sizeof(ServerID) + len + 1 );
1803 si->si_url.bv_val = (char *)(si+1);
1804 si->si_url.bv_len = len;
1805 strcpy( si->si_url.bv_val, c->argv[2] );
1808 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1809 "<%s> unqualified server ID not allowed now", c->argv[0] );
1810 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1811 c->log, c->cr_msg, c->argv[1] );
1814 si = ch_malloc( sizeof(ServerID) );
1815 BER_BVZERO( &si->si_url );
1816 slap_serverID = num;
1817 Debug( LDAP_DEBUG_CONFIG,
1819 c->log, slap_serverID, 0 );
1823 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
1826 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
1827 Listener *l = config_check_my_url( c->argv[2], lud );
1829 slap_serverID = si->si_num;
1830 Debug( LDAP_DEBUG_CONFIG,
1831 "%s: SID=%d (listener=%s)\n",
1832 c->log, slap_serverID,
1837 ldap_free_urldesc( lud );
1841 if ( logfileName ) ch_free( logfileName );
1842 logfileName = c->value_string;
1843 logfile = fopen(logfileName, "w");
1844 if(logfile) lutil_debug_file(logfile);
1848 if(SLAP_NOLASTMODCMD(c->be)) {
1849 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> not available for %s database",
1850 c->argv[0], c->be->bd_info->bi_type );
1851 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1852 c->log, c->cr_msg, 0 );
1856 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
1858 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
1861 case CFG_MIRRORMODE:
1862 if(c->value_int && !SLAP_SHADOW(c->be)) {
1863 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database is not a shadow",
1865 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1866 c->log, c->cr_msg, 0 );
1870 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
1872 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
1875 case CFG_MONITORING:
1877 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
1879 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
1884 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
1886 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
1889 case CFG_SSTR_IF_MAX:
1890 if (c->value_int < index_substr_if_minlen) {
1891 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
1892 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
1893 c->log, c->cr_msg, c->value_int );
1896 index_substr_if_maxlen = c->value_int;
1899 case CFG_SSTR_IF_MIN:
1900 if (c->value_int > index_substr_if_maxlen) {
1901 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
1902 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
1903 c->log, c->cr_msg, c->value_int );
1906 index_substr_if_minlen = c->value_int;
1909 #ifdef SLAPD_MODULES
1911 /* If we're just adding a module on an existing modpath,
1912 * make sure we've selected the current path.
1914 if ( c->op == LDAP_MOD_ADD && c->ca_private && modcur != c->ca_private ) {
1915 modcur = c->ca_private;
1916 /* This should never fail */
1917 if ( module_path( modcur->mp_path.bv_val )) {
1918 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> module path no longer valid",
1920 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
1921 c->log, c->cr_msg, modcur->mp_path.bv_val );
1925 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
1927 /* Record this load on the current path */
1931 if ( c->op == SLAP_CONFIG_ADD ) {
1932 ptr = c->line + STRLENOF("moduleload");
1933 while (!isspace((unsigned char) *ptr)) ptr++;
1934 while (isspace((unsigned char) *ptr)) ptr++;
1938 ber_str2bv(ptr, 0, 1, &bv);
1939 ber_bvarray_add( &modcur->mp_loads, &bv );
1941 /* Check for any new hardcoded schema */
1942 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
1943 config_check_schema( NULL, &cfBackInfo );
1948 if(module_path(c->argv[1])) return(1);
1949 /* Record which path was used with each module */
1953 if (!modpaths.mp_loads) {
1956 mp = ch_malloc( sizeof( ModPaths ));
1957 modlast->mp_next = mp;
1959 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
1961 mp->mp_loads = NULL;
1972 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
1974 slapi_plugins_used++;
1978 #ifdef SLAP_AUTH_REWRITE
1983 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
1986 if ( c->argc > 1 ) {
1989 /* quote all args but the first */
1990 line = ldap_charray2str( c->argv, "\" \"" );
1991 ber_str2bv( line, 0, 0, &bv );
1992 s = ber_bvchr( &bv, '"' );
1993 assert( s != NULL );
1994 /* move the trailing quote of argv[0] to the end */
1995 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
1996 bv.bv_val[ bv.bv_len - 1 ] = '"';
1999 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
2002 ber_bvarray_add( &authz_rewrites, &bv );
2009 Debug( LDAP_DEBUG_ANY,
2010 "%s: unknown CFG_TYPE %d.\n",
2011 c->log, c->type, 0 );
2020 config_fname(ConfigArgs *c) {
2021 if(c->op == SLAP_CONFIG_EMIT) {
2022 if (c->ca_private) {
2023 ConfigFile *cf = c->ca_private;
2024 value_add_one( &c->rvalue_vals, &cf->c_file );
2033 config_cfdir(ConfigArgs *c) {
2034 if(c->op == SLAP_CONFIG_EMIT) {
2035 if ( !BER_BVISEMPTY( &cfdir )) {
2036 value_add_one( &c->rvalue_vals, &cfdir );
2045 config_search_base(ConfigArgs *c) {
2046 if(c->op == SLAP_CONFIG_EMIT) {
2048 if (!BER_BVISEMPTY(&default_search_base)) {
2049 value_add_one(&c->rvalue_vals, &default_search_base);
2050 value_add_one(&c->rvalue_nvals, &default_search_nbase);
2054 } else if( c->op == LDAP_MOD_DELETE ) {
2055 ch_free( default_search_base.bv_val );
2056 ch_free( default_search_nbase.bv_val );
2057 BER_BVZERO( &default_search_base );
2058 BER_BVZERO( &default_search_nbase );
2062 if(c->bi || c->be != frontendDB) {
2063 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
2064 "prior to any backend or database definition\n",
2069 if(default_search_nbase.bv_len) {
2070 free(default_search_base.bv_val);
2071 free(default_search_nbase.bv_val);
2074 default_search_base = c->value_dn;
2075 default_search_nbase = c->value_ndn;
2079 /* For RE23 compatibility we allow this in the global entry
2080 * but we now defer it to the frontend entry to allow modules
2081 * to load new hash types.
2084 config_passwd_hash(ConfigArgs *c) {
2086 if (c->op == SLAP_CONFIG_EMIT) {
2088 /* Don't generate it in the global entry */
2089 if ( c->table == Cft_Global )
2091 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
2092 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
2093 value_add_one(&c->rvalue_vals, &bv);
2096 } else if ( c->op == LDAP_MOD_DELETE ) {
2097 /* Deleting from global is a no-op, only the frontendDB entry matters */
2098 if ( c->table == Cft_Global )
2100 if ( c->valx < 0 ) {
2101 ldap_charray_free( default_passwd_hash );
2102 default_passwd_hash = NULL;
2105 ch_free( default_passwd_hash[i] );
2106 for (; default_passwd_hash[i]; i++ )
2107 default_passwd_hash[i] = default_passwd_hash[i+1];
2111 for(i = 1; i < c->argc; i++) {
2112 if(!lutil_passwd_scheme(c->argv[i])) {
2113 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
2114 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2115 c->log, c->cr_msg, c->argv[i]);
2117 ldap_charray_add(&default_passwd_hash, c->argv[i]);
2120 if(!default_passwd_hash) {
2121 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
2122 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2123 c->log, c->cr_msg, 0 );
2130 config_schema_dn(ConfigArgs *c) {
2131 if ( c->op == SLAP_CONFIG_EMIT ) {
2133 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
2134 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
2135 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
2139 } else if ( c->op == LDAP_MOD_DELETE ) {
2140 ch_free( c->be->be_schemadn.bv_val );
2141 ch_free( c->be->be_schemandn.bv_val );
2142 BER_BVZERO( &c->be->be_schemadn );
2143 BER_BVZERO( &c->be->be_schemandn );
2146 ch_free( c->be->be_schemadn.bv_val );
2147 ch_free( c->be->be_schemandn.bv_val );
2148 c->be->be_schemadn = c->value_dn;
2149 c->be->be_schemandn = c->value_ndn;
2154 config_sizelimit(ConfigArgs *c) {
2156 struct slap_limits_set *lim = &c->be->be_def_limit;
2157 if (c->op == SLAP_CONFIG_EMIT) {
2162 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
2163 if ( !BER_BVISEMPTY( &bv ))
2164 value_add_one( &c->rvalue_vals, &bv );
2168 } else if ( c->op == LDAP_MOD_DELETE ) {
2169 /* Reset to defaults */
2170 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
2171 lim->lms_s_hard = 0;
2172 lim->lms_s_unchecked = -1;
2174 lim->lms_s_pr_hide = 0;
2175 lim->lms_s_pr_total = 0;
2178 for(i = 1; i < c->argc; i++) {
2179 if(!strncasecmp(c->argv[i], "size", 4)) {
2180 rc = limits_parse_one(c->argv[i], lim);
2182 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2183 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2184 c->log, c->cr_msg, c->argv[i]);
2188 if(!strcasecmp(c->argv[i], "unlimited")) {
2189 lim->lms_s_soft = -1;
2191 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
2192 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2193 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2194 c->log, c->cr_msg, c->argv[i]);
2198 lim->lms_s_hard = 0;
2205 config_timelimit(ConfigArgs *c) {
2207 struct slap_limits_set *lim = &c->be->be_def_limit;
2208 if (c->op == SLAP_CONFIG_EMIT) {
2213 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
2214 if ( !BER_BVISEMPTY( &bv ))
2215 value_add_one( &c->rvalue_vals, &bv );
2219 } else if ( c->op == LDAP_MOD_DELETE ) {
2220 /* Reset to defaults */
2221 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
2222 lim->lms_t_hard = 0;
2225 for(i = 1; i < c->argc; i++) {
2226 if(!strncasecmp(c->argv[i], "time", 4)) {
2227 rc = limits_parse_one(c->argv[i], lim);
2229 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2230 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2231 c->log, c->cr_msg, c->argv[i]);
2235 if(!strcasecmp(c->argv[i], "unlimited")) {
2236 lim->lms_t_soft = -1;
2238 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
2239 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2240 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2241 c->log, c->cr_msg, c->argv[i]);
2245 lim->lms_t_hard = 0;
2252 config_overlay(ConfigArgs *c) {
2253 if (c->op == SLAP_CONFIG_EMIT) {
2255 } else if ( c->op == LDAP_MOD_DELETE ) {
2258 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
2259 c->valx, &c->bi, &c->reply)) {
2261 Debug( LDAP_DEBUG_ANY,
2262 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
2263 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
2265 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi, &c->reply)) {
2272 config_subordinate(ConfigArgs *c)
2278 case SLAP_CONFIG_EMIT:
2279 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
2282 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
2283 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
2286 value_add_one( &c->rvalue_vals, &bv );
2290 case LDAP_MOD_DELETE:
2291 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2292 glue_sub_del( c->be );
2294 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2299 case SLAP_CONFIG_ADD:
2300 if ( c->be->be_nsuffix == NULL ) {
2302 snprintf( c->cr_msg, sizeof( c->cr_msg),
2303 "subordinate configuration needs a suffix" );
2304 Debug( LDAP_DEBUG_ANY,
2306 c->log, c->cr_msg, 0 );
2311 if ( c->argc == 2 ) {
2312 if ( strcasecmp( c->argv[1], "advertise" ) == 0 ) {
2315 } else if ( strcasecmp( c->argv[1], "TRUE" ) != 0 ) {
2317 snprintf( c->cr_msg, sizeof( c->cr_msg),
2318 "subordinate must be \"TRUE\" or \"advertise\"" );
2319 Debug( LDAP_DEBUG_ANY,
2320 "%s: suffix \"%s\": %s.\n",
2321 c->log, c->be->be_suffix[0].bv_val, c->cr_msg );
2327 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2335 config_suffix(ConfigArgs *c)
2338 struct berval pdn, ndn;
2339 char *notallowed = NULL;
2341 if ( c->be == frontendDB ) {
2342 notallowed = "frontend";
2344 } else if ( SLAP_MONITOR(c->be) ) {
2345 notallowed = "monitor";
2347 } else if ( SLAP_CONFIG(c->be) ) {
2348 notallowed = "config";
2351 if ( notallowed != NULL ) {
2352 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2356 case LDAP_MOD_DELETE:
2357 case LDAP_MOD_REPLACE:
2358 case LDAP_MOD_INCREMENT:
2359 case SLAP_CONFIG_ADD:
2360 if ( !BER_BVISNULL( &c->value_dn ) ) {
2361 snprintf( buf, sizeof( buf ), "<%s> ",
2362 c->value_dn.bv_val );
2365 Debug(LDAP_DEBUG_ANY,
2366 "%s: suffix %snot allowed in %s database.\n",
2367 c->log, buf, notallowed );
2370 case SLAP_CONFIG_EMIT:
2371 /* don't complain when emitting... */
2375 /* FIXME: don't know what values may be valid;
2376 * please remove assertion, or add legal values
2377 * to either block */
2385 if (c->op == SLAP_CONFIG_EMIT) {
2386 if ( c->be->be_suffix == NULL
2387 || BER_BVISNULL( &c->be->be_suffix[0] ) )
2391 value_add( &c->rvalue_vals, c->be->be_suffix );
2392 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
2395 } else if ( c->op == LDAP_MOD_DELETE ) {
2396 if ( c->valx < 0 ) {
2397 ber_bvarray_free( c->be->be_suffix );
2398 ber_bvarray_free( c->be->be_nsuffix );
2399 c->be->be_suffix = NULL;
2400 c->be->be_nsuffix = NULL;
2403 ch_free( c->be->be_suffix[i].bv_val );
2404 ch_free( c->be->be_nsuffix[i].bv_val );
2406 c->be->be_suffix[i] = c->be->be_suffix[i+1];
2407 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
2409 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
2414 #ifdef SLAPD_MONITOR_DN
2415 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
2416 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> DN is reserved for monitoring slapd",
2418 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2419 c->log, c->cr_msg, SLAPD_MONITOR_DN);
2424 if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
2425 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
2426 c->argv[0], c->be->bd_info->bi_type );
2427 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2428 c->log, c->cr_msg, 0);
2435 if (SLAP_DBHIDDEN( c->be ))
2438 tbe = select_backend(&ndn, 0);
2440 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
2446 BackendDB *b2 = tbe;
2448 /* Does tbe precede be? */
2449 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
2452 char *type = tbe->bd_info->bi_type;
2454 if ( overlay_is_over( tbe ) ) {
2455 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
2456 type = oi->oi_orig->bi_type;
2459 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> namingContext \"%s\" "
2460 "already served by a preceding %s database",
2461 c->argv[0], pdn.bv_val, type );
2462 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
2463 c->log, c->cr_msg, tbe->be_suffix[0].bv_val);
2469 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
2470 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
2471 "base provided \"%s\" (assuming okay)\n",
2472 c->log, default_search_base.bv_val, 0);
2474 ber_bvarray_add(&c->be->be_suffix, &pdn);
2475 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
2480 config_rootdn(ConfigArgs *c) {
2481 if (c->op == SLAP_CONFIG_EMIT) {
2482 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
2483 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
2484 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
2489 } else if ( c->op == LDAP_MOD_DELETE ) {
2490 ch_free( c->be->be_rootdn.bv_val );
2491 ch_free( c->be->be_rootndn.bv_val );
2492 BER_BVZERO( &c->be->be_rootdn );
2493 BER_BVZERO( &c->be->be_rootndn );
2496 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
2497 ch_free( c->be->be_rootdn.bv_val );
2498 ch_free( c->be->be_rootndn.bv_val );
2500 c->be->be_rootdn = c->value_dn;
2501 c->be->be_rootndn = c->value_ndn;
2506 config_rootpw(ConfigArgs *c) {
2509 if (c->op == SLAP_CONFIG_EMIT) {
2510 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
2511 /* don't copy, because "rootpw" is marked
2513 c->value_bv = c->be->be_rootpw;
2517 } else if ( c->op == LDAP_MOD_DELETE ) {
2518 ch_free( c->be->be_rootpw.bv_val );
2519 BER_BVZERO( &c->be->be_rootpw );
2523 tbe = select_backend(&c->be->be_rootndn, 0);
2525 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> can only be set when rootdn is under suffix",
2527 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2528 c->log, c->cr_msg, 0);
2531 if ( !BER_BVISNULL( &c->be->be_rootpw ))
2532 ch_free( c->be->be_rootpw.bv_val );
2533 c->be->be_rootpw = c->value_bv;
2538 config_restrict(ConfigArgs *c) {
2539 slap_mask_t restrictops = 0;
2541 slap_verbmasks restrictable_ops[] = {
2542 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
2543 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
2544 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
2545 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
2546 { BER_BVC("modrdn"), 0 },
2547 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
2548 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
2549 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
2550 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
2551 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
2552 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
2553 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
2554 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
2555 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
2556 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
2557 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
2561 if (c->op == SLAP_CONFIG_EMIT) {
2562 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
2564 } else if ( c->op == LDAP_MOD_DELETE ) {
2566 c->be->be_restrictops = 0;
2568 restrictops = verb_to_mask( c->line, restrictable_ops );
2569 c->be->be_restrictops ^= restrictops;
2573 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
2575 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown operation", c->argv[0] );
2576 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2577 c->log, c->cr_msg, c->argv[i]);
2580 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
2581 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
2582 c->be->be_restrictops |= restrictops;
2587 config_allows(ConfigArgs *c) {
2588 slap_mask_t allows = 0;
2590 slap_verbmasks allowable_ops[] = {
2591 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
2592 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
2593 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
2594 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
2595 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
2598 if (c->op == SLAP_CONFIG_EMIT) {
2599 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
2600 } else if ( c->op == LDAP_MOD_DELETE ) {
2604 allows = verb_to_mask( c->line, allowable_ops );
2605 global_allows ^= allows;
2609 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
2611 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
2612 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2613 c->log, c->cr_msg, c->argv[i]);
2616 global_allows |= allows;
2621 config_disallows(ConfigArgs *c) {
2622 slap_mask_t disallows = 0;
2624 slap_verbmasks disallowable_ops[] = {
2625 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
2626 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
2627 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
2628 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
2629 { BER_BVC("proxy_authz_non_critical"), SLAP_DISALLOW_PROXY_AUTHZ_N_CRIT },
2630 { BER_BVC("dontusecopy_non_critical"), SLAP_DISALLOW_DONTUSECOPY_N_CRIT },
2633 if (c->op == SLAP_CONFIG_EMIT) {
2634 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
2635 } else if ( c->op == LDAP_MOD_DELETE ) {
2637 global_disallows = 0;
2639 disallows = verb_to_mask( c->line, disallowable_ops );
2640 global_disallows ^= disallows;
2644 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
2646 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
2647 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2648 c->log, c->cr_msg, c->argv[i]);
2651 global_disallows |= disallows;
2656 config_requires(ConfigArgs *c) {
2657 slap_mask_t requires = frontendDB->be_requires;
2658 int i, argc = c->argc;
2659 char **argv = c->argv;
2661 slap_verbmasks requires_ops[] = {
2662 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
2663 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
2664 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
2665 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
2666 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
2669 if (c->op == SLAP_CONFIG_EMIT) {
2670 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
2671 } else if ( c->op == LDAP_MOD_DELETE ) {
2673 c->be->be_requires = 0;
2675 requires = verb_to_mask( c->line, requires_ops );
2676 c->be->be_requires ^= requires;
2680 /* "none" can only be first, to wipe out default/global values */
2681 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
2686 i = verbs_to_mask(argc, argv, requires_ops, &requires);
2688 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
2689 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
2690 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2691 c->log, c->cr_msg, 0);
2693 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
2694 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2695 c->log, c->cr_msg, c->argv[i]);
2699 c->be->be_requires = requires;
2703 static slap_verbmasks *loglevel_ops;
2706 loglevel_init( void )
2708 slap_verbmasks lo[] = {
2709 { BER_BVC("Any"), -1 },
2710 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
2711 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
2712 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
2713 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
2714 { BER_BVC("BER"), LDAP_DEBUG_BER },
2715 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
2716 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
2717 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
2718 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
2719 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
2720 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
2721 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
2722 #if 0 /* no longer used (nor supported) */
2723 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
2724 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
2726 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
2727 { BER_BVC("None"), LDAP_DEBUG_NONE },
2731 return slap_verbmasks_init( &loglevel_ops, lo );
2735 loglevel_destroy( void )
2737 if ( loglevel_ops ) {
2738 (void)slap_verbmasks_destroy( loglevel_ops );
2740 loglevel_ops = NULL;
2743 static slap_mask_t loglevel_ignore[] = { -1, 0 };
2746 slap_loglevel_register( slap_mask_t m, struct berval *s )
2750 if ( loglevel_ops == NULL ) {
2754 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
2757 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
2765 slap_loglevel_get( struct berval *s, int *l )
2770 if ( loglevel_ops == NULL ) {
2774 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
2775 m |= loglevel_ops[ i ].mask;
2778 for ( i = 1; m & i; i <<= 1 )
2785 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
2788 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
2799 str2loglevel( const char *s, int *l )
2803 if ( loglevel_ops == NULL ) {
2807 i = verb_to_mask( s, loglevel_ops );
2809 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
2813 *l = loglevel_ops[ i ].mask;
2819 loglevel2str( int l )
2821 struct berval bv = BER_BVNULL;
2823 loglevel2bv( l, &bv );
2829 loglevel2bv( int l, struct berval *bv )
2831 if ( loglevel_ops == NULL ) {
2837 return enum_to_verb( loglevel_ops, l, bv ) == -1;
2841 loglevel2bvarray( int l, BerVarray *bva )
2843 if ( loglevel_ops == NULL ) {
2847 return mask_to_verbs( loglevel_ops, l, bva );
2851 loglevel_print( FILE *out )
2855 if ( loglevel_ops == NULL ) {
2859 fprintf( out, "Installed log subsystems:\n\n" );
2860 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
2861 fprintf( out, "\t%-30s (%lu)\n",
2862 loglevel_ops[ i ].word.bv_val,
2863 loglevel_ops[ i ].mask );
2866 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
2867 "by specific code\n\n" );
2872 static int config_syslog;
2875 config_loglevel(ConfigArgs *c) {
2878 if ( loglevel_ops == NULL ) {
2882 if (c->op == SLAP_CONFIG_EMIT) {
2883 /* Get default or commandline slapd setting */
2884 if ( ldap_syslog && !config_syslog )
2885 config_syslog = ldap_syslog;
2886 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
2888 } else if ( c->op == LDAP_MOD_DELETE ) {
2892 int level = verb_to_mask( c->line, loglevel_ops );
2893 config_syslog ^= level;
2895 if ( slapMode & SLAP_SERVER_MODE ) {
2896 ldap_syslog = config_syslog;
2901 for( i=1; i < c->argc; i++ ) {
2904 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
2905 if( lutil_atoix( &level, c->argv[i], 0 ) != 0 ) {
2906 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
2907 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2908 c->log, c->cr_msg, c->argv[i]);
2912 if ( str2loglevel( c->argv[i], &level ) ) {
2913 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown level", c->argv[0] );
2914 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2915 c->log, c->cr_msg, c->argv[i]);
2919 /* Explicitly setting a zero clears all the levels */
2921 config_syslog |= level;
2925 if ( slapMode & SLAP_SERVER_MODE ) {
2926 ldap_syslog = config_syslog;
2932 config_referral(ConfigArgs *c) {
2934 if (c->op == SLAP_CONFIG_EMIT) {
2935 if ( default_referral ) {
2936 value_add( &c->rvalue_vals, default_referral );
2941 } else if ( c->op == LDAP_MOD_DELETE ) {
2942 if ( c->valx < 0 ) {
2943 ber_bvarray_free( default_referral );
2944 default_referral = NULL;
2947 ch_free( default_referral[i].bv_val );
2948 for (; default_referral[i].bv_val; i++ )
2949 default_referral[i] = default_referral[i+1];
2953 if(validate_global_referral(c->argv[1])) {
2954 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
2955 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2956 c->log, c->cr_msg, c->argv[1]);
2960 ber_str2bv(c->argv[1], 0, 0, &val);
2961 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
2969 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
2970 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
2971 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
2972 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
2973 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
2974 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
2975 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
2976 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
2977 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
2982 config_security(ConfigArgs *c) {
2983 slap_ssf_set_t *set = &c->be->be_ssf_set;
2986 if (c->op == SLAP_CONFIG_EMIT) {
2992 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
2993 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
2996 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
2997 if ( bv.bv_len >= sizeof( numbuf ) ) {
2998 ber_bvarray_free_x( c->rvalue_vals, NULL );
2999 c->rvalue_vals = NULL;
3003 bv.bv_len += sec_keys[i].key.bv_len;
3004 bv.bv_val = ch_malloc( bv.bv_len + 1);
3005 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
3006 strcpy( next, numbuf );
3007 ber_bvarray_add( &c->rvalue_vals, &bv );
3012 for(i = 1; i < c->argc; i++) {
3013 slap_ssf_t *tgt = NULL;
3015 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
3016 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
3017 sec_keys[j].key.bv_len)) {
3018 src = c->argv[i] + sec_keys[j].key.bv_len;
3019 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
3024 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown factor", c->argv[0] );
3025 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3026 c->log, c->cr_msg, c->argv[i]);
3030 if ( lutil_atou( tgt, src ) != 0 ) {
3031 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse factor", c->argv[0] );
3032 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3033 c->log, c->cr_msg, c->argv[i]);
3041 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
3045 for (; !BER_BVISNULL( &an->an_name ); an++) {
3046 /* if buflen == 0, assume the buffer size has been
3047 * already checked otherwise */
3048 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
3049 if ( comma ) *ptr++ = ',';
3050 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
3057 config_updatedn(ConfigArgs *c) {
3058 if (c->op == SLAP_CONFIG_EMIT) {
3059 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
3060 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
3061 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
3065 } else if ( c->op == LDAP_MOD_DELETE ) {
3066 ch_free( c->be->be_update_ndn.bv_val );
3067 BER_BVZERO( &c->be->be_update_ndn );
3068 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
3071 if(SLAP_SHADOW(c->be)) {
3072 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database already shadowed", c->argv[0] );
3073 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3074 c->log, c->cr_msg, 0);
3078 ber_memfree_x( c->value_dn.bv_val, NULL );
3079 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
3080 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
3082 c->be->be_update_ndn = c->value_ndn;
3083 BER_BVZERO( &c->value_dn );
3084 BER_BVZERO( &c->value_ndn );
3086 return config_slurp_shadow( c );
3090 config_shadow( ConfigArgs *c, int flag )
3092 char *notallowed = NULL;
3094 if ( c->be == frontendDB ) {
3095 notallowed = "frontend";
3097 } else if ( SLAP_MONITOR(c->be) ) {
3098 notallowed = "monitor";
3101 if ( notallowed != NULL ) {
3102 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
3106 if ( SLAP_SHADOW(c->be) ) {
3107 /* if already shadow, only check consistency */
3108 if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
3109 Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%x.\n", c->log, flag, 0 );
3114 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
3121 config_updateref(ConfigArgs *c) {
3123 if (c->op == SLAP_CONFIG_EMIT) {
3124 if ( c->be->be_update_refs ) {
3125 value_add( &c->rvalue_vals, c->be->be_update_refs );
3130 } else if ( c->op == LDAP_MOD_DELETE ) {
3131 if ( c->valx < 0 ) {
3132 ber_bvarray_free( c->be->be_update_refs );
3133 c->be->be_update_refs = NULL;
3136 ch_free( c->be->be_update_refs[i].bv_val );
3137 for (; c->be->be_update_refs[i].bv_val; i++)
3138 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
3142 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
3143 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> must appear after syncrepl or updatedn",
3145 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3146 c->log, c->cr_msg, 0);
3150 if(validate_global_referral(c->argv[1])) {
3151 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3152 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3153 c->log, c->cr_msg, c->argv[1]);
3156 ber_str2bv(c->argv[1], 0, 0, &val);
3157 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
3162 config_obsolete(ConfigArgs *c) {
3163 if (c->op == SLAP_CONFIG_EMIT)
3166 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> keyword is obsolete (ignored)",
3168 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0);
3173 config_include(ConfigArgs *c) {
3174 int savelineno = c->lineno;
3177 ConfigFile *cfsave = cfn;
3178 ConfigFile *cf2 = NULL;
3180 /* Leftover from RE23. No dynamic config for include files */
3181 if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
3184 cf = ch_calloc( 1, sizeof(ConfigFile));
3185 if ( cfn->c_kids ) {
3186 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
3192 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
3193 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
3194 c->lineno = savelineno - 1;
3197 if ( cf2 ) cf2->c_sibs = NULL;
3198 else cfn->c_kids = NULL;
3199 ch_free( cf->c_file.bv_val );
3209 config_tls_cleanup(ConfigArgs *c) {
3212 if ( slap_tls_ld ) {
3215 ldap_pvt_tls_ctx_free( slap_tls_ctx );
3217 /* Force new ctx to be created */
3218 rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
3220 /* The ctx's refcount is bumped up here */
3221 ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
3222 /* This is a no-op if it's already loaded */
3223 load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
3230 config_tls_option(ConfigArgs *c) {
3232 LDAP *ld = slap_tls_ld;
3234 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
3235 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
3236 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
3237 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
3238 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
3239 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
3240 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
3242 case CFG_TLS_CRL_FILE: flag = LDAP_OPT_X_TLS_CRLFILE; break;
3244 default: Debug(LDAP_DEBUG_ANY, "%s: "
3245 "unknown tls_option <0x%x>\n",
3246 c->log, c->type, 0);
3249 if (c->op == SLAP_CONFIG_EMIT) {
3250 return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3251 } else if ( c->op == LDAP_MOD_DELETE ) {
3252 c->cleanup = config_tls_cleanup;
3253 return ldap_pvt_tls_set_option( ld, flag, NULL );
3255 ch_free(c->value_string);
3256 c->cleanup = config_tls_cleanup;
3257 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3260 /* FIXME: this ought to be provided by libldap */
3262 config_tls_config(ConfigArgs *c) {
3265 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
3266 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
3267 case CFG_TLS_PROTOCOL_MIN: flag = LDAP_OPT_X_TLS_PROTOCOL_MIN; break;
3269 Debug(LDAP_DEBUG_ANY, "%s: "
3270 "unknown tls_option <0x%x>\n",
3271 c->log, c->type, 0);
3274 if (c->op == SLAP_CONFIG_EMIT) {
3275 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3276 } else if ( c->op == LDAP_MOD_DELETE ) {
3278 c->cleanup = config_tls_cleanup;
3279 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3281 ch_free( c->value_string );
3282 c->cleanup = config_tls_cleanup;
3283 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3284 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3285 Debug(LDAP_DEBUG_ANY, "%s: "
3286 "unable to parse %s \"%s\"\n",
3287 c->log, c->argv[0], c->argv[1] );
3290 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
3292 return(ldap_pvt_tls_config(slap_tls_ld, flag, c->argv[1]));
3297 static CfEntryInfo *
3298 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
3308 if ( dn_match( &root->ce_entry->e_nname, dn ))
3311 c = dn->bv_val+dn->bv_len;
3312 for (;*c != ',';c--);
3316 for (--c;c>dn->bv_val && *c != ',';c--);
3320 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
3322 root = root->ce_kids;
3324 for (;root;root=root->ce_sibs) {
3325 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
3326 if ( cdn.bv_val == dn->bv_val ) {
3336 typedef struct setup_cookie {
3346 config_ldif_resp( Operation *op, SlapReply *rs )
3348 if ( rs->sr_type == REP_SEARCH ) {
3349 setup_cookie *sc = op->o_callback->sc_private;
3352 sc->cfb->cb_got_ldif = 1;
3353 /* Does the frontend exist? */
3354 if ( !sc->got_frontend ) {
3355 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
3356 "olcDatabase", STRLENOF( "olcDatabase" )))
3358 if ( strncmp( rs->sr_entry->e_nname.bv_val +
3359 STRLENOF( "olcDatabase" ), "={-1}frontend",
3360 STRLENOF( "={-1}frontend" )))
3364 sc->ca->be = frontendDB;
3365 sc->ca->bi = frontendDB->bd_info;
3366 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
3367 rdn.bv_val = sc->ca->log;
3368 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
3369 "%s=" SLAP_X_ORDERED_FMT "%s",
3370 cfAd_database->ad_cname.bv_val, -1,
3371 sc->ca->bi->bi_type);
3373 sc->frontend = config_build_entry( op, rs,
3374 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
3375 sc->ca->be->be_cf_ocs );
3385 dnParent( &rs->sr_entry->e_nname, &pdn );
3387 /* Does the configDB exist? */
3388 if ( sc->got_frontend && !sc->got_config &&
3389 !strncmp( rs->sr_entry->e_nname.bv_val,
3390 "olcDatabase", STRLENOF( "olcDatabase" )) &&
3391 dn_match( &config_rdn, &pdn ) )
3393 if ( strncmp( rs->sr_entry->e_nname.bv_val +
3394 STRLENOF( "olcDatabase" ), "={0}config",
3395 STRLENOF( "={0}config" )))
3399 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
3400 sc->ca->bi = sc->ca->be->bd_info;
3401 rdn.bv_val = sc->ca->log;
3402 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
3403 "%s=" SLAP_X_ORDERED_FMT "%s",
3404 cfAd_database->ad_cname.bv_val, 0,
3405 sc->ca->bi->bi_type);
3407 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
3408 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
3415 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
3416 if ( rs->sr_err != LDAP_SUCCESS ) {
3417 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
3418 rs->sr_entry->e_name.bv_val, sc->ca->cr_msg, 0 );
3424 /* Configure and read the underlying back-ldif store */
3426 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
3427 CfBackInfo *cfb = be->be_private;
3433 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
3434 Connection conn = {0};
3435 OperationBuffer opbuf;
3437 SlapReply rs = {REP_RESULT};
3438 Filter filter = { LDAP_FILTER_PRESENT };
3439 struct berval filterstr = BER_BVC("(objectclass=*)");
3442 /* Is the config directory available? */
3443 if ( stat( dir, &st ) < 0 ) {
3444 /* No, so don't bother using the backing store.
3445 * All changes will be in-memory only.
3450 cfb->cb_db.bd_info = backend_info( "ldif" );
3451 if ( !cfb->cb_db.bd_info )
3452 return 0; /* FIXME: eventually this will be a fatal error */
3454 if ( backend_db_init( "ldif", &cfb->cb_db, -1, NULL ) == NULL )
3457 cfb->cb_db.be_suffix = be->be_suffix;
3458 cfb->cb_db.be_nsuffix = be->be_nsuffix;
3460 /* The suffix is always "cn=config". The underlying DB's rootdn
3461 * is always the same as the suffix.
3463 cfb->cb_db.be_rootdn = be->be_suffix[0];
3464 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
3466 ber_str2bv( dir, 0, 1, &cfdir );
3471 argv[0] = "directory";
3472 argv[1] = (char *)dir;
3477 c.table = Cft_Database;
3479 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
3483 if ( config_add_vals( ct, &c ))
3486 if ( backend_startup_one( &cfb->cb_db, &c.reply ))
3490 void *thrctx = ldap_pvt_thread_pool_context();
3493 connection_fake_init( &conn, &opbuf, thrctx );
3496 filter.f_desc = slap_schema.si_ad_objectClass;
3498 op->o_tag = LDAP_REQ_SEARCH;
3500 op->ors_filter = &filter;
3501 op->ors_filterstr = filterstr;
3502 op->ors_scope = LDAP_SCOPE_SUBTREE;
3504 op->o_dn = c.be->be_rootdn;
3505 op->o_ndn = c.be->be_rootndn;
3507 op->o_req_dn = be->be_suffix[0];
3508 op->o_req_ndn = be->be_nsuffix[0];
3510 op->ors_tlimit = SLAP_NO_LIMIT;
3511 op->ors_slimit = SLAP_NO_LIMIT;
3513 op->ors_attrs = slap_anlist_all_attributes;
3514 op->ors_attrsonly = 0;
3516 op->o_callback = &cb;
3519 cb.sc_private = ≻
3520 sc.got_frontend = 0;
3525 op->o_bd = &cfb->cb_db;
3527 /* Allow unknown attrs in DNs */
3528 prev_DN_strict = slap_DN_strict;
3531 rc = op->o_bd->be_search( op, &rs );
3533 /* Restore normal DN validation */
3534 slap_DN_strict = prev_DN_strict;
3536 op->o_tag = LDAP_REQ_ADD;
3537 if ( rc == LDAP_SUCCESS && sc.frontend ) {
3538 op->ora_e = sc.frontend;
3539 rc = op->o_bd->be_add( op, &rs );
3541 if ( rc == LDAP_SUCCESS && sc.config ) {
3542 op->ora_e = sc.config;
3543 rc = op->o_bd->be_add( op, &rs );
3545 ldap_pvt_thread_pool_context_reset( thrctx );
3548 /* ITS#4194 - only use if it's present, or we're converting. */
3549 if ( !readit || rc == LDAP_SUCCESS )
3550 cfb->cb_use_ldif = 1;
3556 CfOc_cmp( const void *c1, const void *c2 ) {
3557 const ConfigOCs *co1 = c1;
3558 const ConfigOCs *co2 = c2;
3560 return ber_bvcmp( co1->co_name, co2->co_name );
3564 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
3567 i = init_config_attrs( ct );
3570 /* set up the objectclasses */
3571 i = init_config_ocs( ocs );
3574 for (i=0; ocs[i].co_def; i++) {
3575 if ( ocs[i].co_oc ) {
3576 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
3577 if ( !ocs[i].co_table )
3578 ocs[i].co_table = ct;
3579 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
3586 read_config(const char *fname, const char *dir) {
3589 const char *cfdir, *cfname;
3592 /* Setup the config backend */
3593 be = backend_db_init( "config", NULL, 0, NULL );
3597 cfb = be->be_private;
3598 be->be_dfltaccess = ACL_NONE;
3600 /* If no .conf, or a dir was specified, setup the dir */
3601 if ( !fname || dir ) {
3603 /* If explicitly given, check for existence */
3606 if ( stat( dir, &st ) < 0 ) {
3607 Debug( LDAP_DEBUG_ANY,
3608 "invalid config directory %s, error %d\n",
3614 cfdir = SLAPD_DEFAULT_CONFIGDIR;
3616 /* if fname is defaulted, try reading .d */
3617 rc = config_setup_ldif( be, cfdir, !fname );
3620 /* It may be OK if the base object doesn't exist yet. */
3621 if ( rc != LDAP_NO_SUCH_OBJECT )
3623 /* ITS#4194: But if dir was specified and no fname,
3624 * then we were supposed to read the dir. Unless we're
3625 * trying to slapadd the dir...
3627 if ( dir && !fname ) {
3628 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
3630 /* Assume it's slapadd with a config dir, let it continue */
3632 cfb->cb_got_ldif = 1;
3633 cfb->cb_use_ldif = 1;
3638 /* If we read the config from back-ldif, nothing to do here */
3639 if ( cfb->cb_got_ldif ) {
3648 cfname = SLAPD_DEFAULT_CONFIGFILE;
3650 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
3653 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
3656 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
3657 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
3658 &frontendDB->be_schemadn );
3659 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
3660 if ( rc != LDAP_SUCCESS ) {
3661 Debug(LDAP_DEBUG_ANY, "read_config: "
3662 "unable to normalize default schema DN \"%s\"\n",
3663 frontendDB->be_schemadn.bv_val, 0, 0 );
3664 /* must not happen */
3672 config_back_bind( Operation *op, SlapReply *rs )
3674 if ( be_isroot_pw( op ) ) {
3675 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
3676 /* frontend sends result */
3677 return LDAP_SUCCESS;
3680 rs->sr_err = LDAP_INVALID_CREDENTIALS;
3681 send_ldap_result( op, rs );
3687 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
3691 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
3693 rs->sr_attrs = op->ors_attrs;
3694 rs->sr_entry = ce->ce_entry;
3696 rc = send_search_entry( op, rs );
3697 if ( rc != LDAP_SUCCESS ) {
3701 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
3702 if ( ce->ce_kids ) {
3703 rc = config_send( op, rs, ce->ce_kids, 1 );
3704 if ( rc ) return rc;
3707 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
3708 rc = config_send( op, rs, ce, 0 );
3716 static ConfigTable *
3717 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
3722 for (j=0; j<nocs; j++) {
3723 for (i=0; colst[j]->co_table[i].name; i++)
3724 if ( colst[j]->co_table[i].ad == ad ) {
3725 ca->table = colst[j]->co_type;
3726 return &colst[j]->co_table[i];
3732 /* Sort the attributes of the entry according to the order defined
3733 * in the objectclass, with required attributes occurring before
3734 * allowed attributes. For any attributes with sequencing dependencies
3735 * (e.g., rootDN must be defined after suffix) the objectclass must
3736 * list the attributes in the desired sequence.
3739 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
3741 Attribute *a, *head = NULL, *tail = NULL, **prev;
3744 for (i=0; i<nocs; i++) {
3745 if ( colst[i]->co_oc->soc_required ) {
3746 AttributeType **at = colst[i]->co_oc->soc_required;
3747 for (j=0; at[j]; j++) {
3748 for (a=e->e_attrs, prev=&e->e_attrs; a;
3749 prev = &(*prev)->a_next, a=a->a_next) {
3750 if ( a->a_desc == at[j]->sat_ad ) {
3764 if ( colst[i]->co_oc->soc_allowed ) {
3765 AttributeType **at = colst[i]->co_oc->soc_allowed;
3766 for (j=0; at[j]; j++) {
3767 for (a=e->e_attrs, prev=&e->e_attrs; a;
3768 prev = &(*prev)->a_next, a=a->a_next) {
3769 if ( a->a_desc == at[j]->sat_ad ) {
3785 tail->a_next = e->e_attrs;
3791 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
3793 Attribute *a = NULL;
3794 AttributeDescription *ad;
3804 Modifications *ml = ptr;
3806 vals = ml->sml_values;
3809 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
3810 rc = ordered_value_sort( a, 1 );
3812 snprintf(ca->cr_msg, sizeof( ca->cr_msg ), "ordered_value_sort failed on attr %s\n",
3813 ad->ad_cname.bv_val );
3817 for ( i=0; vals[i].bv_val; i++ ) {
3818 ca->line = vals[i].bv_val;
3819 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
3820 ca->line[0] == '{' ) {
3821 char *idx = strchr( ca->line, '}' );
3822 if ( idx ) ca->line = idx+1;
3824 rc = config_parse_vals( ct, ca, i );
3833 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
3836 struct berval rtype, rval;
3838 AttributeDescription *ad = NULL;
3840 dnRdn( &e->e_name, rdn );
3841 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
3842 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
3843 rtype.bv_val = rdn->bv_val;
3844 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
3847 slap_bv2ad( &rtype, &ad, &rs->sr_text );
3848 a = attr_find( e->e_attrs, ad );
3849 if (!a ) return LDAP_NAMING_VIOLATION;
3856 config_rename_kids( CfEntryInfo *ce )
3859 struct berval rdn, nrdn;
3861 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
3862 struct berval newdn, newndn;
3863 dnRdn ( &ce2->ce_entry->e_name, &rdn );
3864 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
3865 build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
3866 build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
3867 free( ce2->ce_entry->e_name.bv_val );
3868 free( ce2->ce_entry->e_nname.bv_val );
3869 ce2->ce_entry->e_name = newdn;
3870 ce2->ce_entry->e_nname = newndn;
3871 config_rename_kids( ce2 );
3876 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
3877 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
3878 struct berval *nnewrdn, int use_ldif )
3882 struct berval odn, ondn;
3886 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
3887 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
3890 free( a->a_vals[0].bv_val );
3891 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
3892 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
3893 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
3894 strcpy( a->a_vals[0].bv_val, ptr1 );
3896 if ( a->a_nvals != a->a_vals ) {
3897 free( a->a_nvals[0].bv_val );
3898 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
3899 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
3900 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
3901 strcpy( a->a_nvals[0].bv_val, ptr1 );
3904 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
3905 BackendDB *be = op->o_bd;
3906 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
3907 struct berval dn, ndn, xdn, xndn;
3909 op->o_bd = &cfb->cb_db;
3911 /* Save current rootdn; use the underlying DB's rootdn */
3915 xndn = op->o_req_ndn;
3916 op->o_dn = op->o_bd->be_rootdn;
3917 op->o_ndn = op->o_bd->be_rootndn;
3919 op->o_req_ndn = ondn;
3921 scp = op->o_callback;
3922 op->o_callback = ≻
3923 op->orr_newrdn = *newrdn;
3924 op->orr_nnewrdn = *nnewrdn;
3925 op->orr_newSup = NULL;
3926 op->orr_nnewSup = NULL;
3927 op->orr_deleteoldrdn = 1;
3928 op->orr_modlist = NULL;
3929 slap_modrdn2mods( op, rs );
3930 slap_mods_opattrs( op, &op->orr_modlist, 1 );
3931 rc = op->o_bd->be_modrdn( op, rs );
3932 slap_mods_free( op->orr_modlist, 1 );
3935 op->o_callback = scp;
3939 op->o_req_ndn = xndn;
3942 free( ondn.bv_val );
3944 config_rename_kids( e->e_private );
3949 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
3950 Entry *e, int idx, int tailindex, int use_ldif )
3952 struct berval ival, newrdn, nnewrdn;
3955 char ibuf[32], *ptr1, *ptr2 = NULL;
3958 rc = config_rename_attr( rs, e, &rdn, &a );
3959 if ( rc ) return rc;
3962 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
3963 if ( ival.bv_len >= sizeof( ibuf ) ) {
3964 return LDAP_NAMING_VIOLATION;
3967 newrdn.bv_len = rdn.bv_len + ival.bv_len;
3968 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
3971 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
3972 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
3975 ptr2 = ber_bvchr( &rdn, '}' );
3979 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
3981 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
3982 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
3983 a->a_desc->ad_cname.bv_len );
3985 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
3986 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
3990 /* Do the equivalent of ModRDN */
3991 /* Replace DN / NDN */
3992 newrdn.bv_len = ptr1 - newrdn.bv_val;
3993 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
3994 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
3996 free( nnewrdn.bv_val );
3997 free( newrdn.bv_val );
4002 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
4003 SlapReply *rs, int *renum, int *ibase )
4006 int index = -1, gotindex = 0, nsibs, rc = 0;
4007 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
4008 char *ptr1, *ptr2 = NULL;
4011 if ( renum ) *renum = 0;
4013 /* These entries don't get indexed/renumbered */
4014 if ( ce_type == Cft_Global ) return 0;
4015 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
4017 if ( ce_type == Cft_Module )
4020 /* See if the rdn has an index already */
4021 dnRdn( &e->e_name, &rdn );
4022 if ( ce_type == Cft_Database ) {
4023 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
4024 "frontend", STRLENOF("frontend") ))
4026 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
4027 "config", STRLENOF("config") ))
4030 ptr1 = ber_bvchr( &e->e_name, '{' );
4031 if ( ptr1 && ptr1 < &e->e_name.bv_val[ rdn.bv_len ] ) {
4033 ptr2 = strchr( ptr1, '}' );
4034 if ( !ptr2 || ptr2 > &e->e_name.bv_val[ rdn.bv_len ] )
4035 return LDAP_NAMING_VIOLATION;
4036 if ( ptr2-ptr1 == 1)
4037 return LDAP_NAMING_VIOLATION;
4039 index = strtol( ptr1 + 1, &next, 10 );
4040 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
4041 return LDAP_NAMING_VIOLATION;
4044 /* Special case, we allow -1 for the frontendDB */
4045 if ( index != -1 || !isfrontend )
4046 return LDAP_NAMING_VIOLATION;
4048 if ( isconfig && index != 0 ){
4049 return LDAP_NAMING_VIOLATION;
4053 /* count related kids */
4054 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
4055 if ( ce->ce_type == ce_type ) nsibs++;
4058 /* account for -1 frontend */
4059 if ( ce_type == Cft_Database )
4062 if ( index != nsibs ) {
4064 if ( index < nsibs ) {
4065 if ( tailindex ) return LDAP_NAMING_VIOLATION;
4066 /* Siblings need to be renumbered */
4067 if ( index != -1 || !isfrontend )
4071 /* config DB is always "0" */
4072 if ( isconfig && index == -1 ) {
4075 if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
4079 /* just make index = nsibs */
4081 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
4084 if ( ibase ) *ibase = index;
4085 if ( renum ) *renum = renumber;
4090 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
4095 co.co_name = &oc->soc_cname;
4096 cop = avl_find( CfOcTree, &co, CfOc_cmp );
4100 /* check for duplicates */
4101 for ( i = 0; i < *nocs; i++ ) {
4102 if ( *copp && (*copp)[i] == cop ) {
4108 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
4109 if ( tmp == NULL ) {
4113 (*copp)[*nocs] = cop;
4118 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
4119 if ( count_oc( *sups, copp, nocs ) ) {
4128 count_ocs( Attribute *oc_at, int *nocs )
4131 ConfigOCs **colst = NULL;
4135 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
4139 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
4141 assert( oc != NULL );
4142 if ( count_oc( oc, &colst, nocs ) ) {
4152 cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4154 /* Leftover from RE23. Never parse this entry */
4155 return LDAP_COMPARE_TRUE;
4159 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4163 /* This entry is hardcoded, don't re-parse it */
4164 if ( p->ce_type == Cft_Global ) {
4165 cfn = p->ce_private;
4166 ca->ca_private = cfn;
4167 return LDAP_COMPARE_TRUE;
4169 if ( p->ce_type != Cft_Schema )
4170 return LDAP_CONSTRAINT_VIOLATION;
4172 cfn = ch_calloc( 1, sizeof(ConfigFile) );
4173 ca->ca_private = cfn;
4174 cfo = p->ce_private;
4175 cfn->c_sibs = cfo->c_kids;
4177 return LDAP_SUCCESS;
4181 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4183 if ( p->ce_type != Cft_Global ) {
4184 return LDAP_CONSTRAINT_VIOLATION;
4186 /* config must be {0}, nothing else allowed */
4187 if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
4188 strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
4189 return LDAP_CONSTRAINT_VIOLATION;
4191 ca->be = frontendDB; /* just to get past check_vals */
4192 return LDAP_SUCCESS;
4196 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4198 if ( p->ce_type != Cft_Global ) {
4199 return LDAP_CONSTRAINT_VIOLATION;
4201 return LDAP_SUCCESS;
4205 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4207 if ( p->ce_type != Cft_Global ) {
4208 return LDAP_CONSTRAINT_VIOLATION;
4210 return LDAP_SUCCESS;
4214 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4216 if ( p->ce_type != Cft_Database ) {
4217 return LDAP_CONSTRAINT_VIOLATION;
4220 return LDAP_SUCCESS;
4224 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
4229 AttributeDescription *ad;
4234 if ( cfn->c_cr_head ) {
4235 struct berval bv = BER_BVC("olcDitContentRules");
4237 slap_bv2ad( &bv, &ad, &text );
4238 ct = config_find_table( colst, nocs, ad, ca );
4239 config_del_vals( ct, ca );
4241 if ( cfn->c_oc_head ) {
4242 struct berval bv = BER_BVC("olcObjectClasses");
4244 slap_bv2ad( &bv, &ad, &text );
4245 ct = config_find_table( colst, nocs, ad, ca );
4246 config_del_vals( ct, ca );
4248 if ( cfn->c_at_head ) {
4249 struct berval bv = BER_BVC("olcAttributeTypes");
4251 slap_bv2ad( &bv, &ad, &text );
4252 ct = config_find_table( colst, nocs, ad, ca );
4253 config_del_vals( ct, ca );
4255 if ( cfn->c_syn_head ) {
4256 struct berval bv = BER_BVC("olcLdapSyntaxes");
4258 slap_bv2ad( &bv, &ad, &text );
4259 ct = config_find_table( colst, nocs, ad, ca );
4260 config_del_vals( ct, ca );
4262 if ( cfn->c_om_head ) {
4263 struct berval bv = BER_BVC("olcObjectIdentifier");
4265 slap_bv2ad( &bv, &ad, &text );
4266 ct = config_find_table( colst, nocs, ad, ca );
4267 config_del_vals( ct, ca );
4269 cfo = p->ce_private;
4270 cfo->c_kids = cfn->c_sibs;
4275 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
4277 int rc = LDAP_CONSTRAINT_VIOLATION;
4280 if ( (*cop)->co_ldadd ) {
4281 rc = (*cop)->co_ldadd( last, e, ca );
4282 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4287 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
4288 ConfigOCs co = { 0 };
4290 co.co_name = &(*ocp)->soc_cname;
4291 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
4292 if ( *cop == NULL ) {
4296 rc = config_add_oc( cop, last, e, ca );
4297 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4305 /* Parse an LDAP entry into config directives */
4307 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
4308 int *renum, Operation *op )
4310 CfEntryInfo *ce, *last = NULL;
4311 ConfigOCs co, *coptr, **colst;
4312 Attribute *a, *oc_at, *soc_at;
4313 int i, ibase = -1, nocs, rc = 0;
4316 char *ptr, *log_prefix = op ? op->o_log_prefix : "";
4318 memset( ca, 0, sizeof(ConfigArgs));
4320 /* Make sure parent exists and entry does not. But allow
4321 * Databases and Overlays to be inserted. Don't do any
4322 * auto-renumbering if manageDSAit control is present.
4324 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
4326 if ( ( op && op->o_managedsait ) ||
4327 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
4328 ce->ce_type != Cft_Module ) )
4330 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4331 "DN=\"%s\" already exists\n",
4332 log_prefix, e->e_name.bv_val, 0 );
4333 return LDAP_ALREADY_EXISTS;
4337 dnParent( &e->e_nname, &pdn );
4339 /* If last is NULL, the new entry is the root/suffix entry,
4340 * otherwise last should be the parent.
4342 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
4344 rs->sr_matched = last->ce_entry->e_name.bv_val;
4346 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4347 "DN=\"%s\" not child of DN=\"%s\"\n",
4348 log_prefix, e->e_name.bv_val,
4349 last->ce_entry->e_name.bv_val );
4350 return LDAP_NO_SUCH_OBJECT;
4354 /* No parent, must be root. This will never happen... */
4355 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
4356 return LDAP_NO_SUCH_OBJECT;
4359 if ( last && !access_allowed( op, last->ce_entry,
4360 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
4362 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4363 "DN=\"%s\" no write access to \"children\" of parent\n",
4364 log_prefix, e->e_name.bv_val, 0 );
4365 return LDAP_INSUFFICIENT_ACCESS;
4369 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
4371 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4372 "DN=\"%s\" no objectClass\n",
4373 log_prefix, e->e_name.bv_val, 0 );
4374 return LDAP_OBJECT_CLASS_VIOLATION;
4377 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
4379 ObjectClass *soc = NULL;
4380 char textbuf[ SLAP_TEXT_BUFLEN ];
4381 const char *text = textbuf;
4383 /* FIXME: check result */
4384 rc = structural_class( oc_at->a_nvals, &soc, NULL,
4385 &text, textbuf, sizeof(textbuf), NULL );
4386 if ( rc != LDAP_SUCCESS ) {
4387 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4388 "DN=\"%s\" no structural objectClass (%s)\n",
4389 log_prefix, e->e_name.bv_val, text );
4392 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
4393 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
4394 if ( soc_at == NULL ) {
4395 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4396 "DN=\"%s\" no structural objectClass; "
4397 "unable to merge computed class %s\n",
4398 log_prefix, e->e_name.bv_val,
4399 soc->soc_cname.bv_val );
4400 return LDAP_OBJECT_CLASS_VIOLATION;
4403 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4404 "DN=\"%s\" no structural objectClass; "
4405 "computed objectClass %s merged\n",
4406 log_prefix, e->e_name.bv_val,
4407 soc->soc_cname.bv_val );
4410 /* Fake the coordinates based on whether we're part of an
4411 * LDAP Add or if reading the config dir
4414 ca->fname = "slapd";
4417 ca->fname = cfdir.bv_val;
4422 co.co_name = &soc_at->a_nvals[0];
4423 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
4424 if ( coptr == NULL ) {
4425 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4426 "DN=\"%s\" no structural objectClass in configuration table\n",
4427 log_prefix, e->e_name.bv_val, 0 );
4428 return LDAP_OBJECT_CLASS_VIOLATION;
4431 /* Only the root can be Cft_Global, everything else must
4432 * have a parent. Only limited nesting arrangements are allowed.
4434 rc = LDAP_CONSTRAINT_VIOLATION;
4435 if ( coptr->co_type == Cft_Global && !last ) {
4436 cfn = cfb->cb_config;
4437 ca->ca_private = cfn;
4438 ca->be = frontendDB; /* just to get past check_vals */
4442 colst = count_ocs( oc_at, &nocs );
4444 /* Check whether the Add is allowed by its parent, and do
4445 * any necessary arg setup
4448 rc = config_add_oc( &coptr, last, e, ca );
4449 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
4450 for ( i = 0; i<nocs; i++ ) {
4451 /* Already checked these */
4452 if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
4454 if ( colst[i]->co_ldadd &&
4455 ( rc = colst[i]->co_ldadd( last, e, ca ))
4456 != LDAP_CONSTRAINT_VIOLATION ) {
4462 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
4463 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4464 "DN=\"%s\" no structural objectClass add function\n",
4465 log_prefix, e->e_name.bv_val, 0 );
4466 return LDAP_OBJECT_CLASS_VIOLATION;
4470 /* Add the entry but don't parse it, we already have its contents */
4471 if ( rc == LDAP_COMPARE_TRUE ) {
4476 if ( rc != LDAP_SUCCESS )
4479 /* Parse all the values and check for simple syntax errors before
4480 * performing any set actions.
4482 * If doing an LDAPadd, check for indexed names and any necessary
4483 * renaming/renumbering. Entries that don't need indexed names are
4484 * ignored. Entries that need an indexed name and arrive without one
4485 * are assigned to the end. Entries that arrive with an index may
4486 * cause the following entries to be renumbered/bumped down.
4488 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
4489 * don't allow Adding an entry with an index that's already in use.
4490 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
4492 * These entries can have auto-assigned indexes (appended to the end)
4493 * but only the other types support auto-renumbering of siblings.
4496 rc = check_name_index( last, coptr->co_type, e, rs, renum,
4501 if ( renum && *renum && coptr->co_type != Cft_Database &&
4502 coptr->co_type != Cft_Overlay )
4504 snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
4505 "operation requires sibling renumbering" );
4506 rc = LDAP_UNWILLING_TO_PERFORM;
4511 init_config_argv( ca );
4513 /* Make sure we process attrs in the required order */
4514 sort_attrs( e, colst, nocs );
4516 for ( a = e->e_attrs; a; a = a->a_next ) {
4517 if ( a == oc_at ) continue;
4518 ct = config_find_table( colst, nocs, a->a_desc, ca );
4519 if ( !ct ) continue; /* user data? */
4520 rc = check_vals( ct, ca, a, 1 );
4521 if ( rc ) goto done_noop;
4524 /* Basic syntax checks are OK. Do the actual settings. */
4525 for ( a=e->e_attrs; a; a=a->a_next ) {
4526 if ( a == oc_at ) continue;
4527 ct = config_find_table( colst, nocs, a->a_desc, ca );
4528 if ( !ct ) continue; /* user data? */
4529 for (i=0; a->a_vals[i].bv_val; i++) {
4532 ca->line = a->a_vals[i].bv_val;
4533 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
4534 ptr = strchr( ca->line, '}' );
4536 iptr = strchr( ca->line, '{' );
4540 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
4542 ca->valx = strtol( iptr+1, NULL, 0 );
4547 rc = config_parse_add( ct, ca, i );
4555 /* Newly added databases and overlays need to be started up */
4556 if ( CONFIG_ONLINE_ADD( ca )) {
4557 if ( colst[0]->co_type == Cft_Database ) {
4558 rc = backend_startup_one( ca->be, &ca->reply );
4560 } else if ( colst[0]->co_type == Cft_Overlay ) {
4561 if ( ca->bi->bi_db_open ) {
4562 BackendInfo *bi_orig = ca->be->bd_info;
4563 ca->be->bd_info = ca->bi;
4564 rc = ca->bi->bi_db_open( ca->be, &ca->reply );
4565 ca->be->bd_info = bi_orig;
4567 } else if ( ca->cleanup ) {
4568 rc = ca->cleanup( ca );
4571 if (ca->cr_msg[0] == '\0')
4572 snprintf( ca->cr_msg, sizeof( ca->cr_msg ), "<%s> failed startup", ca->argv[0] );
4574 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
4575 ca->log, ca->cr_msg, ca->argv[1] );
4582 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
4583 ce->ce_parent = last;
4584 ce->ce_entry = entry_dup( e );
4585 ce->ce_entry->e_private = ce;
4586 ce->ce_type = colst[0]->co_type;
4589 ce->ce_private = ca->ca_private;
4590 ca->ca_entry = ce->ce_entry;
4593 } else if ( last->ce_kids ) {
4594 CfEntryInfo *c2, **cprev;
4596 /* Advance to first of this type */
4597 cprev = &last->ce_kids;
4598 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
4599 cprev = &c2->ce_sibs;
4602 /* Account for the (-1) frontendDB entry */
4603 if ( ce->ce_type == Cft_Database ) {
4604 if ( ca->be == frontendDB )
4606 else if ( ibase != -1 )
4611 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
4612 cprev = &c2->ce_sibs;
4618 for ( i=0; i<ibase; i++ ) {
4620 cprev = &c2->ce_sibs;
4623 ce->ce_sibs = *cprev;
4631 if ( (colst[0]->co_type == Cft_Database) && ca->be ) {
4632 if ( ca->be != frontendDB )
4633 backend_destroy_one( ca->be, 1 );
4634 } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) {
4635 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
4636 } else if ( colst[0]->co_type == Cft_Schema ) {
4637 schema_destroy_one( ca, colst, nocs, last );
4642 ch_free( ca->argv );
4643 if ( colst ) ch_free( colst );
4647 #define BIGTMP 10000
4649 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
4650 int base, int rebase, int max, int use_ldif )
4652 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
4653 ConfigType etype = ce->ce_type;
4654 int count = 0, rc = 0;
4656 /* Reverse ce list */
4657 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
4658 if (ce2->ce_type != etype) {
4663 ce2->ce_sibs = cetmp;
4666 if ( max && count >= max ) {
4672 /* Move original to a temp name until increments are done */
4674 ce->ce_entry->e_private = NULL;
4675 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4676 base+BIGTMP, 0, use_ldif );
4677 ce->ce_entry->e_private = ce;
4679 /* start incrementing */
4680 for (ce2=cetmp; ce2; ce2=ce3) {
4682 ce2->ce_sibs = cerem;
4685 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
4686 count+base, 0, use_ldif );
4690 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4691 base, 0, use_ldif );
4696 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
4697 CfEntryInfo *ce2, int old, int use_ldif )
4701 /* Renumber original to a temp value */
4702 ce->ce_entry->e_private = NULL;
4703 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4704 old+BIGTMP, 0, use_ldif );
4705 ce->ce_entry->e_private = ce;
4707 /* start decrementing */
4708 for (; ce2 != ce; ce2=ce2->ce_sibs) {
4709 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
4710 count+old, 0, use_ldif );
4713 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4714 count+old, 0, use_ldif );
4717 /* Parse an LDAP entry into config directives, then store in underlying
4721 config_back_add( Operation *op, SlapReply *rs )
4727 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
4728 NULL, ACL_WADD, NULL )) {
4729 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4734 * Check for attribute ACL
4736 if ( !acl_check_modlist( op, op->ora_e, op->orm_modlist )) {
4737 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4738 rs->sr_text = "no write access to attribute";
4742 cfb = (CfBackInfo *)op->o_bd->be_private;
4744 /* add opattrs for syncprov */
4746 char textbuf[SLAP_TEXT_BUFLEN];
4747 size_t textlen = sizeof textbuf;
4748 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1, NULL,
4749 &rs->sr_text, textbuf, sizeof( textbuf ) );
4750 if ( rs->sr_err != LDAP_SUCCESS )
4752 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
4753 if ( rs->sr_err != LDAP_SUCCESS ) {
4754 Debug( LDAP_DEBUG_TRACE,
4755 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
4756 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
4761 if ( op->o_abandon ) {
4762 rs->sr_err = SLAPD_ABANDON;
4765 ldap_pvt_thread_pool_pause( &connection_pool );
4768 * 1) check for existence of entry
4769 * 2) check for sibling renumbering
4770 * 3) perform internal add
4771 * 4) perform any necessary renumbering
4772 * 5) store entry in underlying database
4774 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
4775 if ( rs->sr_err != LDAP_SUCCESS ) {
4776 rs->sr_text = ca.cr_msg;
4781 CfEntryInfo *ce = ca.ca_entry->e_private;
4782 req_add_s addr = op->oq_add;
4783 op->o_tag = LDAP_REQ_MODRDN;
4784 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
4785 op->o_tag = LDAP_REQ_ADD;
4787 if ( rs->sr_err != LDAP_SUCCESS ) {
4792 if ( cfb->cb_use_ldif ) {
4793 BackendDB *be = op->o_bd;
4794 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4795 struct berval dn, ndn;
4797 op->o_bd = &cfb->cb_db;
4799 /* Save current rootdn; use the underlying DB's rootdn */
4802 op->o_dn = op->o_bd->be_rootdn;
4803 op->o_ndn = op->o_bd->be_rootndn;
4805 scp = op->o_callback;
4806 op->o_callback = ≻
4807 op->o_bd->be_add( op, rs );
4809 op->o_callback = scp;
4815 ldap_pvt_thread_pool_resume( &connection_pool );
4818 send_ldap_result( op, rs );
4819 slap_graduate_commit_csn( op );
4823 typedef struct delrec {
4824 struct delrec *next;
4830 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
4836 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
4837 ca->line[0] == '{' )
4839 char *ptr = strchr( ca->line + 1, '}' );
4843 ca->valx = strtol( ca->line + 1, &next, 0 );
4844 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
4850 rc = config_parse_add( ct, ca, i );
4858 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
4861 int rc = LDAP_UNWILLING_TO_PERFORM;
4863 Entry *e = ce->ce_entry;
4864 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
4869 delrec *dels = NULL, *deltail = NULL;
4871 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
4872 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
4874 colst = count_ocs( oc_at, &nocs );
4876 /* make sure add/del flags are clear; should always be true */
4877 for ( s = save_attrs; s; s = s->a_next ) {
4878 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
4881 e->e_attrs = attrs_dup( e->e_attrs );
4883 init_config_argv( ca );
4886 ca->ca_private = ce->ce_private;
4888 ca->fname = "slapd";
4890 strcpy( ca->log, "back-config" );
4892 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
4893 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
4894 switch (ml->sml_op) {
4895 case LDAP_MOD_DELETE:
4896 case LDAP_MOD_REPLACE: {
4897 BerVarray vals = NULL, nvals = NULL;
4899 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
4901 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot delete %s",
4902 ml->sml_desc->ad_cname.bv_val );
4905 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4906 vals = ml->sml_values;
4907 nvals = ml->sml_nvalues;
4908 ml->sml_values = NULL;
4909 ml->sml_nvalues = NULL;
4911 /* If we're deleting by values, remember the indexes of the
4912 * values we deleted.
4914 if ( ct && ml->sml_values ) {
4916 i = ml->sml_numvals;
4917 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
4928 rc = modify_delete_vindex(e, &ml->sml_mod,
4929 get_permissiveModify(op),
4930 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg), idx );
4931 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4932 ml->sml_values = vals;
4933 ml->sml_nvalues = nvals;
4938 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
4941 case SLAP_MOD_SOFTADD: {
4942 int mop = ml->sml_op;
4944 ml->sml_op = LDAP_MOD_ADD;
4946 if ( ct->arg_type & ARG_NO_INSERT ) {
4947 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
4949 navals = a->a_numvals;
4952 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
4953 if ( ml->sml_values[i].bv_val[0] == '{' &&
4956 char *next, *val = ml->sml_values[i].bv_val + 1;
4959 j = strtol( val, &next, 0 );
4960 if ( next == val || next[ 0 ] != '}' || j < navals ) {
4962 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot insert %s",
4963 ml->sml_desc->ad_cname.bv_val );
4967 rc = check_vals( ct, ca, ml, 0 );
4968 if ( rc ) goto out_noop;
4971 rc = modify_add_values(e, &ml->sml_mod,
4972 get_permissiveModify(op),
4973 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
4975 /* If value already exists, show success here
4976 * and ignore this operation down below.
4978 if ( mop == SLAP_MOD_SOFTADD ) {
4979 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
4989 case LDAP_MOD_INCREMENT: /* FIXME */
4994 if(rc != LDAP_SUCCESS) break;
4997 if ( rc == LDAP_SUCCESS) {
4998 /* check that the entry still obeys the schema */
4999 rc = entry_schema_check(op, e, NULL, 0, 0, NULL,
5000 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5002 if ( rc ) goto out_noop;
5004 /* Basic syntax checks are OK. Do the actual settings. */
5005 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5006 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5007 if ( !ct ) continue;
5009 s = attr_find( save_attrs, ml->sml_desc );
5010 a = attr_find( e->e_attrs, ml->sml_desc );
5012 switch (ml->sml_op) {
5013 case LDAP_MOD_DELETE:
5014 case LDAP_MOD_REPLACE: {
5015 BerVarray vals = NULL, nvals = NULL;
5018 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5019 vals = ml->sml_values;
5020 nvals = ml->sml_nvalues;
5021 ml->sml_values = NULL;
5022 ml->sml_nvalues = NULL;
5025 if ( ml->sml_values )
5028 /* If we didn't delete the whole attribute */
5029 if ( ml->sml_values && a ) {
5030 struct berval *mvals;
5033 if ( ml->sml_nvalues )
5034 mvals = ml->sml_nvalues;
5036 mvals = ml->sml_values;
5038 /* use the indexes we saved up above */
5039 for (i=0; i < d->nidx; i++) {
5040 struct berval bv = *mvals++;
5041 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
5042 bv.bv_val[0] == '{' ) {
5043 ptr = strchr( bv.bv_val, '}' ) + 1;
5044 bv.bv_len -= ptr - bv.bv_val;
5047 ca->line = bv.bv_val;
5048 ca->valx = d->idx[i];
5049 rc = config_del_vals( ct, ca );
5050 if ( rc != LDAP_SUCCESS ) break;
5052 s->a_flags |= SLAP_ATTR_IXDEL;
5053 for (j=i+1; j < d->nidx; j++)
5054 if ( d->idx[j] >d->idx[i] )
5060 rc = config_del_vals( ct, ca );
5061 if ( rc ) rc = LDAP_OTHER;
5063 s->a_flags |= SLAP_ATTR_IXDEL;
5065 if ( ml->sml_values ) {
5070 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5071 ml->sml_values = vals;
5072 ml->sml_nvalues = nvals;
5074 if ( !vals || rc != LDAP_SUCCESS )
5077 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5080 for (i=0; ml->sml_values[i].bv_val; i++) {
5081 ca->line = ml->sml_values[i].bv_val;
5083 rc = config_modify_add( ct, ca, ml->sml_desc, i );
5086 a->a_flags |= SLAP_ATTR_IXADD;
5093 /* Undo for a failed operation */
5094 if ( rc != LDAP_SUCCESS ) {
5095 ConfigReply msg = ca->reply;
5096 for ( s = save_attrs; s; s = s->a_next ) {
5097 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
5098 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5099 ct = config_find_table( colst, nocs, s->a_desc, ca );
5100 a = attr_find( e->e_attrs, s->a_desc );
5102 /* clear the flag so the add check below will skip it */
5103 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5106 config_del_vals( ct, ca );
5108 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5109 ca->line = s->a_vals[i].bv_val;
5111 config_modify_add( ct, ca, s->a_desc, i );
5115 for ( a = e->e_attrs; a; a = a->a_next ) {
5116 if ( a->a_flags & SLAP_ATTR_IXADD ) {
5117 ct = config_find_table( colst, nocs, a->a_desc, ca );
5120 config_del_vals( ct, ca );
5121 s = attr_find( save_attrs, a->a_desc );
5123 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5124 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5125 ca->line = s->a_vals[i].bv_val;
5127 config_modify_add( ct, ca, s->a_desc, i );
5138 if ( rc == LDAP_SUCCESS ) {
5139 attrs_free( save_attrs );
5141 attrs_free( e->e_attrs );
5142 e->e_attrs = save_attrs;
5144 ch_free( ca->argv );
5145 if ( colst ) ch_free( colst );
5147 deltail = dels->next;
5156 config_back_modify( Operation *op, SlapReply *rs )
5159 CfEntryInfo *ce, *last;
5161 ConfigArgs ca = {0};
5164 AttributeDescription *rad = NULL;
5167 cfb = (CfBackInfo *)op->o_bd->be_private;
5169 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5172 rs->sr_matched = last->ce_entry->e_name.bv_val;
5173 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5177 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
5178 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5182 /* Get type of RDN */
5183 rdn = ce->ce_entry->e_nname;
5184 ptr = strchr( rdn.bv_val, '=' );
5185 rdn.bv_len = ptr - rdn.bv_val;
5186 slap_bv2ad( &rdn, &rad, &rs->sr_text );
5188 /* Some basic validation... */
5189 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5190 /* Don't allow Modify of RDN; must use ModRdn for that. */
5191 if ( ml->sml_desc == rad ) {
5192 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
5193 rs->sr_text = "Use modrdn to change the entry name";
5196 /* Internal update of contextCSN? */
5197 if ( ml->sml_desc == slap_schema.si_ad_contextCSN && op->o_conn->c_conn_idx == -1 ) {
5203 slap_mods_opattrs( op, &op->orm_modlist, 1 );
5206 if ( op->o_abandon ) {
5207 rs->sr_err = SLAPD_ABANDON;
5210 ldap_pvt_thread_pool_pause( &connection_pool );
5214 * 1) perform the Modify on the cached Entry.
5215 * 2) verify that the Entry still satisfies the schema.
5216 * 3) perform the individual config operations.
5217 * 4) store Modified entry in underlying LDIF backend.
5219 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
5221 rs->sr_text = ca.cr_msg;
5222 } else if ( cfb->cb_use_ldif ) {
5223 BackendDB *be = op->o_bd;
5224 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5225 struct berval dn, ndn;
5227 op->o_bd = &cfb->cb_db;
5231 op->o_dn = op->o_bd->be_rootdn;
5232 op->o_ndn = op->o_bd->be_rootndn;
5234 scp = op->o_callback;
5235 op->o_callback = ≻
5236 op->o_bd->be_modify( op, rs );
5238 op->o_callback = scp;
5244 ldap_pvt_thread_pool_resume( &connection_pool );
5246 send_ldap_result( op, rs );
5247 slap_graduate_commit_csn( op );
5252 config_back_modrdn( Operation *op, SlapReply *rs )
5255 CfEntryInfo *ce, *last;
5259 cfb = (CfBackInfo *)op->o_bd->be_private;
5261 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5264 rs->sr_matched = last->ce_entry->e_name.bv_val;
5265 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5268 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
5269 NULL, ACL_WRITE, NULL )) {
5270 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5274 if ( ce->ce_parent )
5275 parent = ce->ce_parent->ce_entry;
5277 parent = (Entry *)&slap_entry_root;
5278 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
5279 NULL, ACL_WRITE, NULL )) {
5280 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5285 /* We don't allow moving objects to new parents.
5286 * Generally we only allow reordering a set of ordered entries.
5288 if ( op->orr_newSup ) {
5289 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5293 /* If newRDN == oldRDN, quietly succeed */
5294 dnRdn( &op->o_req_ndn, &rdn );
5295 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
5296 rs->sr_err = LDAP_SUCCESS;
5300 /* Current behavior, subject to change as needed:
5302 * For backends and overlays, we only allow renumbering.
5303 * For schema, we allow renaming with the same number.
5304 * Otherwise, the op is not allowed.
5307 if ( ce->ce_type == Cft_Schema ) {
5311 /* Can't alter the main cn=schema entry */
5312 if ( ce->ce_parent->ce_type == Cft_Global ) {
5313 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5314 rs->sr_text = "renaming not allowed for this entry";
5318 /* We could support this later if desired */
5319 ptr1 = ber_bvchr( &rdn, '}' );
5320 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5321 len = ptr1 - rdn.bv_val;
5322 if ( len != ptr2 - op->orr_newrdn.bv_val ||
5323 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
5324 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5325 rs->sr_text = "schema reordering not supported";
5328 } else if ( ce->ce_type == Cft_Database ||
5329 ce->ce_type == Cft_Overlay ) {
5330 char *ptr1, *ptr2, *iptr1, *iptr2;
5333 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
5334 if ( *iptr2 != '{' ) {
5335 rs->sr_err = LDAP_NAMING_VIOLATION;
5336 rs->sr_text = "new ordering index is required";
5340 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
5341 ptr1 = ber_bvchr( &rdn, '}' );
5342 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5344 rs->sr_err = LDAP_NAMING_VIOLATION;
5345 rs->sr_text = "new ordering index is required";
5349 len1 = ptr1 - rdn.bv_val;
5350 len2 = ptr2 - op->orr_newrdn.bv_val;
5352 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
5353 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
5354 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5355 rs->sr_text = "changing database/overlay type not allowed";
5358 ixold = strtol( iptr1, NULL, 0 );
5359 ixnew = strtol( iptr2, &ptr1, 0 );
5360 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
5361 rs->sr_err = LDAP_NAMING_VIOLATION;
5364 /* config DB is always 0, cannot be changed */
5365 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
5366 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
5370 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5371 rs->sr_text = "renaming not supported for this entry";
5375 if ( op->o_abandon ) {
5376 rs->sr_err = SLAPD_ABANDON;
5379 ldap_pvt_thread_pool_pause( &connection_pool );
5381 if ( ce->ce_type == Cft_Schema ) {
5382 req_modrdn_s modr = op->oq_modrdn;
5385 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
5386 if ( rs->sr_err == LDAP_SUCCESS ) {
5387 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
5388 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
5391 op->oq_modrdn = modr;
5393 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
5394 req_modrdn_s modr = op->oq_modrdn;
5397 /* Advance to first of this type */
5398 cprev = &ce->ce_parent->ce_kids;
5399 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
5400 cprev = &ce2->ce_sibs;
5403 /* Skip the -1 entry */
5404 if ( ce->ce_type == Cft_Database ) {
5405 cprev = &ce2->ce_sibs;
5411 /* Remove from old slot */
5412 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
5413 cprev = &ce2->ce_sibs;
5414 *cprev = ce->ce_sibs;
5415 ceold = ce->ce_sibs;
5417 /* Insert into new slot */
5419 for ( i=0; i<ixnew; i++ ) {
5423 cprev = &ce2->ce_sibs;
5425 ce->ce_sibs = *cprev;
5430 /* NOTE: These should be encoded in the OC tables, not inline here */
5431 if ( ce->ce_type == Cft_Database )
5432 backend_db_move( ce->ce_be, ixnew );
5433 else if ( ce->ce_type == Cft_Overlay )
5434 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
5436 if ( ixold < ixnew ) {
5437 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
5440 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
5441 ixold - ixnew, cfb->cb_use_ldif );
5443 op->oq_modrdn = modr;
5446 ldap_pvt_thread_pool_resume( &connection_pool );
5448 send_ldap_result( op, rs );
5453 config_back_delete( Operation *op, SlapReply *rs )
5455 #ifdef SLAP_CONFIG_DELETE
5457 CfEntryInfo *ce, *last, *ce2;
5459 cfb = (CfBackInfo *)op->o_bd->be_private;
5461 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5464 rs->sr_matched = last->ce_entry->e_name.bv_val;
5465 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5466 } else if ( ce->ce_kids ) {
5467 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5468 } else if ( op->o_abandon ) {
5469 rs->sr_err = SLAPD_ABANDON;
5470 } else if ( ce->ce_type == Cft_Overlay || ce->ce_type == Cft_Database ){
5474 ldap_pvt_thread_pool_pause( &connection_pool );
5476 if ( ce->ce_type == Cft_Overlay ){
5477 overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
5478 } else { /* Cft_Database*/
5479 if ( ce->ce_be == frontendDB || ce->ce_be == op->o_bd ){
5480 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5481 rs->sr_text = "Cannot delete config or frontend database";
5482 ldap_pvt_thread_pool_resume( &connection_pool );
5485 if ( ce->ce_be->bd_info->bi_db_close ) {
5486 ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
5488 backend_destroy_one( ce->ce_be, 1);
5491 /* remove CfEntryInfo from the siblings list */
5492 if ( ce->ce_parent->ce_kids == ce ) {
5493 ce->ce_parent->ce_kids = ce->ce_sibs;
5495 for ( ce2 = ce->ce_parent->ce_kids ; ce2; ce2 = ce2->ce_sibs ) {
5496 if ( ce2->ce_sibs == ce ) {
5497 ce2->ce_sibs = ce->ce_sibs;
5503 /* remove from underlying database */
5504 if ( cfb->cb_use_ldif ) {
5505 BackendDB *be = op->o_bd;
5506 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5507 struct berval dn, ndn, req_dn, req_ndn;
5509 op->o_bd = &cfb->cb_db;
5513 req_dn = op->o_req_dn;
5514 req_ndn = op->o_req_ndn;
5516 op->o_dn = op->o_bd->be_rootdn;
5517 op->o_ndn = op->o_bd->be_rootndn;
5518 op->o_req_dn = ce->ce_entry->e_name;
5519 op->o_req_ndn = ce->ce_entry->e_nname;
5521 scp = op->o_callback;
5522 op->o_callback = ≻
5523 op->o_bd->be_delete( op, rs );
5525 op->o_callback = scp;
5528 op->o_req_dn = req_dn;
5529 op->o_req_ndn = req_ndn;
5532 /* renumber siblings */
5533 iptr = ber_bvchr( &op->o_req_ndn, '{' ) + 1;
5534 ixold = strtol( iptr, NULL, 0 );
5535 for (ce2 = ce->ce_sibs, count=0; ce2; ce2=ce2->ce_sibs) {
5536 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5537 count+ixold, 0, cfb->cb_use_ldif );
5541 ce->ce_entry->e_private=NULL;
5542 entry_free(ce->ce_entry);
5544 ldap_pvt_thread_pool_resume( &connection_pool );
5546 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5549 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5550 #endif /* SLAP_CONFIG_DELETE */
5552 send_ldap_result( op, rs );
5557 config_back_search( Operation *op, SlapReply *rs )
5560 CfEntryInfo *ce, *last;
5563 cfb = (CfBackInfo *)op->o_bd->be_private;
5565 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5568 rs->sr_matched = last->ce_entry->e_name.bv_val;
5569 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5572 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
5573 ACL_SEARCH, NULL, &mask ))
5575 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
5576 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5578 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5582 switch ( op->ors_scope ) {
5583 case LDAP_SCOPE_BASE:
5584 case LDAP_SCOPE_SUBTREE:
5585 rs->sr_err = config_send( op, rs, ce, 0 );
5588 case LDAP_SCOPE_ONELEVEL:
5589 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
5590 rs->sr_err = config_send( op, rs, ce, 1 );
5599 send_ldap_result( op, rs );
5603 /* no-op, we never free entries */
5604 int config_entry_release(
5609 if ( !e->e_private ) {
5612 return LDAP_SUCCESS;
5615 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
5617 int config_back_entry_get(
5621 AttributeDescription *at,
5626 CfEntryInfo *ce, *last;
5627 int rc = LDAP_NO_SUCH_OBJECT;
5629 cfb = (CfBackInfo *)op->o_bd->be_private;
5631 ce = config_find_base( cfb->cb_root, ndn, &last );
5633 *ent = ce->ce_entry;
5636 if ( oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
5637 rc = LDAP_NO_SUCH_ATTRIBUTE;
5647 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
5648 ConfigTable *ct, ConfigArgs *c )
5652 for (; at && *at; at++) {
5653 /* Skip the naming attr */
5654 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
5656 for (i=0;ct[i].name;i++) {
5657 if (ct[i].ad == (*at)->sat_ad) {
5658 rc = config_get_vals(&ct[i], c);
5659 /* NOTE: tolerate that config_get_vals()
5660 * returns success with no values */
5661 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
5662 if ( c->rvalue_nvals )
5663 rc = attr_merge(e, ct[i].ad, c->rvalue_vals,
5666 slap_syntax_validate_func *validate =
5667 ct[i].ad->ad_type->sat_syntax->ssyn_validate;
5670 for ( j=0; c->rvalue_vals[j].bv_val; j++ ) {
5671 rc = ordered_value_validate( ct[i].ad,
5672 &c->rvalue_vals[j], LDAP_MOD_ADD );
5674 Debug( LDAP_DEBUG_ANY,
5675 "config_build_attrs: error %d on %s value #%d\n",
5676 rc, ct[i].ad->ad_cname.bv_val, j );
5682 rc = attr_merge_normalize(e, ct[i].ad,
5683 c->rvalue_vals, NULL);
5685 ber_bvarray_free( c->rvalue_nvals );
5686 ber_bvarray_free( c->rvalue_vals );
5688 Debug( LDAP_DEBUG_ANY,
5689 "config_build_attrs: error %d on %s\n",
5690 rc, ct[i].ad->ad_cname.bv_val, 0 );
5702 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
5703 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
5705 Entry *e = entry_alloc();
5706 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5708 struct berval ad_name;
5709 AttributeDescription *ad = NULL;
5712 const char *text = "";
5716 CfEntryInfo *ceprev = NULL;
5718 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
5721 ce->ce_type = main->co_type;
5722 ce->ce_parent = parent;
5724 pdn = parent->ce_entry->e_nname;
5725 if ( parent->ce_kids && parent->ce_kids->ce_type <= ce->ce_type )
5726 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
5727 ceprev->ce_type <= ce->ce_type;
5728 ceprev = ceprev->ce_sibs );
5733 ce->ce_private = c->ca_private;
5737 build_new_dn( &e->e_name, &pdn, rdn, NULL );
5738 ber_dupbv( &e->e_nname, &e->e_name );
5740 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
5741 main->co_name, NULL );
5743 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
5744 extra->co_name, NULL );
5745 ptr = strchr(rdn->bv_val, '=');
5746 ad_name.bv_val = rdn->bv_val;
5747 ad_name.bv_len = ptr - rdn->bv_val;
5748 rc = slap_bv2ad( &ad_name, &ad, &text );
5753 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
5754 attr_merge_normalize_one(e, ad, &val, NULL );
5757 c->table = main->co_type;
5758 if ( oc->soc_required ) {
5759 rc = config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
5760 if ( rc ) goto fail;
5763 if ( oc->soc_allowed ) {
5764 rc = config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
5765 if ( rc ) goto fail;
5770 c->table = extra->co_type;
5771 if ( oc->soc_required ) {
5772 rc = config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
5773 if ( rc ) goto fail;
5776 if ( oc->soc_allowed ) {
5777 rc = config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
5778 if ( rc ) goto fail;
5782 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5783 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->cr_msg,
5784 sizeof(c->cr_msg), op ? op->o_tmpmemctx : NULL );
5785 if ( rc != LDAP_SUCCESS ) {
5787 Debug( LDAP_DEBUG_ANY,
5788 "config_build_entry: build \"%s\" failed: \"%s\"\n",
5789 rdn->bv_val, text, 0);
5792 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
5795 op->ora_modlist = NULL;
5796 slap_add_opattrs( op, NULL, NULL, 0, 0 );
5797 if ( !op->o_noop ) {
5798 op->o_bd->be_add( op, rs );
5799 if ( ( rs->sr_err != LDAP_SUCCESS )
5800 && (rs->sr_err != LDAP_ALREADY_EXISTS) ) {
5806 ce->ce_sibs = ceprev->ce_sibs;
5807 ceprev->ce_sibs = ce;
5808 } else if ( parent ) {
5809 ce->ce_sibs = parent->ce_kids;
5810 parent->ce_kids = ce;
5817 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
5818 Operation *op, SlapReply *rs )
5821 ConfigFile *cf = c->ca_private;
5823 struct berval bv, rdn;
5825 for (; cf; cf=cf->c_sibs, c->depth++) {
5826 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
5827 !cf->c_om_head && !cf->c_syn_head ) continue;
5828 c->value_dn.bv_val = c->log;
5829 LUTIL_SLASHPATH( cf->c_file.bv_val );
5830 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
5835 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
5837 ptr = strchr( bv.bv_val, '.' );
5839 bv.bv_len = ptr - bv.bv_val;
5840 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
5841 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
5842 /* FIXME: how can indicate error? */
5845 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
5847 c->value_dn.bv_len += bv.bv_len;
5848 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
5852 e = config_build_entry( op, rs, ceparent, c, &rdn,
5853 &CFOC_SCHEMA, NULL );
5856 } else if ( e && cf->c_kids ) {
5857 c->ca_private = cf->c_kids;
5858 config_build_schema_inc( c, e->e_private, op, rs );
5864 #ifdef SLAPD_MODULES
5867 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
5868 Operation *op, SlapReply *rs )
5873 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
5874 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
5876 c->value_dn.bv_val = c->log;
5877 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
5878 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
5879 /* FIXME: how can indicate error? */
5883 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
5892 config_check_schema(Operation *op, CfBackInfo *cfb)
5894 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
5896 CfEntryInfo *ce, *last;
5899 /* If there's no root entry, we must be in the midst of converting */
5900 if ( !cfb->cb_root )
5903 /* Make sure the main schema entry exists */
5904 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
5911 /* Make sure it's up to date */
5912 if ( cf_om_tail != om_sys_tail ) {
5913 a = attr_find( e->e_attrs, cfAd_om );
5915 if ( a->a_nvals != a->a_vals )
5916 ber_bvarray_free( a->a_nvals );
5917 ber_bvarray_free( a->a_vals );
5922 oidm_unparse( &bv, NULL, NULL, 1 );
5923 attr_merge_normalize( e, cfAd_om, bv, NULL );
5924 ber_bvarray_free( bv );
5925 cf_om_tail = om_sys_tail;
5927 if ( cf_at_tail != at_sys_tail ) {
5928 a = attr_find( e->e_attrs, cfAd_attr );
5930 if ( a->a_nvals != a->a_vals )
5931 ber_bvarray_free( a->a_nvals );
5932 ber_bvarray_free( a->a_vals );
5937 at_unparse( &bv, NULL, NULL, 1 );
5938 attr_merge_normalize( e, cfAd_attr, bv, NULL );
5939 ber_bvarray_free( bv );
5940 cf_at_tail = at_sys_tail;
5942 if ( cf_oc_tail != oc_sys_tail ) {
5943 a = attr_find( e->e_attrs, cfAd_oc );
5945 if ( a->a_nvals != a->a_vals )
5946 ber_bvarray_free( a->a_nvals );
5947 ber_bvarray_free( a->a_vals );
5952 oc_unparse( &bv, NULL, NULL, 1 );
5953 attr_merge_normalize( e, cfAd_oc, bv, NULL );
5954 ber_bvarray_free( bv );
5955 cf_oc_tail = oc_sys_tail;
5957 if ( cf_syn_tail != syn_sys_tail ) {
5958 a = attr_find( e->e_attrs, cfAd_syntax );
5960 if ( a->a_nvals != a->a_vals )
5961 ber_bvarray_free( a->a_nvals );
5962 ber_bvarray_free( a->a_vals );
5967 syn_unparse( &bv, NULL, NULL, 1 );
5968 attr_merge_normalize( e, cfAd_syntax, bv, NULL );
5969 ber_bvarray_free( bv );
5970 cf_syn_tail = syn_sys_tail;
5973 SlapReply rs = {REP_RESULT};
5974 c.ca_private = NULL;
5975 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
5976 &CFOC_SCHEMA, NULL );
5981 ce->ce_private = cfb->cb_config;
5982 cf_at_tail = at_sys_tail;
5983 cf_oc_tail = oc_sys_tail;
5984 cf_om_tail = om_sys_tail;
5985 cf_syn_tail = syn_sys_tail;
5990 static const char *defacl[] = {
5991 NULL, "to", "*", "by", "*", "none", NULL
5995 config_back_db_open( BackendDB *be, ConfigReply *cr )
5997 CfBackInfo *cfb = be->be_private;
6000 CfEntryInfo *ce, *ceparent;
6004 Connection conn = {0};
6005 OperationBuffer opbuf;
6007 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
6008 SlapReply rs = {REP_RESULT};
6009 void *thrctx = NULL;
6011 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
6013 /* If we have no explicitly configured ACLs, don't just use
6014 * the global ACLs. Explicitly deny access to everything.
6016 if ( !be->be_acl ) {
6017 parse_acl(be, "config_back_db_open", 0, 6, (char **)defacl, 0 );
6020 thrctx = ldap_pvt_thread_pool_context();
6021 connection_fake_init( &conn, &opbuf, thrctx );
6024 op->o_tag = LDAP_REQ_ADD;
6025 op->o_callback = &cb;
6026 op->o_bd = &cfb->cb_db;
6027 op->o_dn = op->o_bd->be_rootdn;
6028 op->o_ndn = op->o_bd->be_rootndn;
6030 if ( !cfb->cb_use_ldif ) {
6034 /* If we read the config from back-ldif, do some quick sanity checks */
6035 if ( cfb->cb_got_ldif ) {
6036 return config_check_schema( op, cfb );
6039 /* create root of tree */
6041 c.ca_private = cfb->cb_config;
6043 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
6053 #ifdef SLAPD_MODULES
6054 /* Create Module nodes... */
6055 if ( modpaths.mp_loads ) {
6056 if ( config_build_modules( &c, ceparent, op, &rs ) ){
6062 /* Create schema nodes... cn=schema will contain the hardcoded core
6063 * schema, read-only. Child objects will contain runtime loaded schema
6067 c.ca_private = NULL;
6068 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
6073 ce->ce_private = cfb->cb_config;
6074 cf_at_tail = at_sys_tail;
6075 cf_oc_tail = oc_sys_tail;
6076 cf_om_tail = om_sys_tail;
6077 cf_syn_tail = syn_sys_tail;
6079 /* Create schema nodes for included schema... */
6080 if ( cfb->cb_config->c_kids ) {
6082 c.ca_private = cfb->cb_config->c_kids;
6083 if (config_build_schema_inc( &c, ce, op, &rs )) {
6088 /* Create backend nodes. Skip if they don't provide a cf_table.
6089 * There usually aren't any of these.
6093 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
6094 if (!bi->bi_cf_ocs) {
6095 /* If it only supports the old config mech, complain. */
6096 if ( bi->bi_config ) {
6097 Debug( LDAP_DEBUG_ANY,
6098 "WARNING: No dynamic config support for backend %s.\n",
6099 bi->bi_type, 0, 0 );
6104 if (!bi->bi_private) continue;
6107 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6108 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
6109 if ( rdn.bv_len >= sizeof( c.log ) ) {
6110 /* FIXME: holler ... */ ;
6113 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
6120 /* Create database nodes... */
6121 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
6122 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
6123 for ( i = -1, be = frontendDB ; be;
6124 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
6125 slap_overinfo *oi = NULL;
6127 if ( overlay_is_over( be )) {
6128 oi = be->bd_info->bi_private;
6134 /* If this backend supports the old config mechanism, but not
6135 * the new mech, complain.
6137 if ( !be->be_cf_ocs && bi->bi_db_config ) {
6138 Debug( LDAP_DEBUG_ANY,
6139 "WARNING: No dynamic config support for database %s.\n",
6140 bi->bi_type, 0, 0 );
6144 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6145 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
6147 if ( rdn.bv_len >= sizeof( c.log ) ) {
6148 /* FIXME: holler ... */ ;
6152 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
6158 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd )
6159 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
6160 /* Iterate through overlays */
6165 voidList *vl, *v0 = NULL;
6167 /* overlays are in LIFO order, must reverse stack */
6168 for (on=oi->oi_list; on; on=on->on_next) {
6169 vl = ch_malloc( sizeof( voidList ));
6174 for (j=0; vl; j++,vl=v0) {
6178 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
6179 Debug( LDAP_DEBUG_ANY,
6180 "WARNING: No dynamic config support for overlay %s.\n",
6181 on->on_bi.bi_type, 0, 0 );
6185 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6186 "%s=" SLAP_X_ORDERED_FMT "%s",
6187 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
6188 if ( rdn.bv_len >= sizeof( c.log ) ) {
6189 /* FIXME: holler ... */ ;
6193 oe = config_build_entry( op, &rs, ce, &c, &rdn,
6194 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
6198 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd )
6199 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
6204 ldap_pvt_thread_pool_context_reset( thrctx );
6206 if ( unsupp && cfb->cb_use_ldif ) {
6207 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
6208 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
6215 cfb_free_cffile( ConfigFile *cf )
6219 for (; cf; cf=next) {
6222 cfb_free_cffile( cf->c_kids );
6223 ch_free( cf->c_file.bv_val );
6224 ber_bvarray_free( cf->c_dseFiles );
6230 cfb_free_entries( CfEntryInfo *ce )
6234 for (; ce; ce=next) {
6237 cfb_free_entries( ce->ce_kids );
6238 ce->ce_entry->e_private = NULL;
6239 entry_free( ce->ce_entry );
6245 config_back_db_close( BackendDB *be, ConfigReply *cr )
6247 CfBackInfo *cfb = be->be_private;
6249 cfb_free_entries( cfb->cb_root );
6250 cfb->cb_root = NULL;
6252 if ( cfb->cb_db.bd_info ) {
6253 backend_shutdown( &cfb->cb_db );
6260 config_back_db_destroy( BackendDB *be, ConfigReply *cr )
6262 CfBackInfo *cfb = be->be_private;
6264 cfb_free_cffile( cfb->cb_config );
6266 ch_free( cfdir.bv_val );
6268 avl_free( CfOcTree, NULL );
6270 if ( cfb->cb_db.bd_info ) {
6271 cfb->cb_db.be_suffix = NULL;
6272 cfb->cb_db.be_nsuffix = NULL;
6273 BER_BVZERO( &cfb->cb_db.be_rootdn );
6274 BER_BVZERO( &cfb->cb_db.be_rootndn );
6276 backend_destroy_one( &cfb->cb_db, 0 );
6285 config_back_db_init( BackendDB *be, ConfigReply* cr )
6291 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
6292 cfn = cfb->cb_config;
6293 be->be_private = cfb;
6295 ber_dupbv( &be->be_rootdn, &config_rdn );
6296 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
6297 ber_dupbv( &dn, &be->be_rootdn );
6298 ber_bvarray_add( &be->be_suffix, &dn );
6299 ber_dupbv( &dn, &be->be_rootdn );
6300 ber_bvarray_add( &be->be_nsuffix, &dn );
6302 /* Hide from namingContexts */
6303 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
6305 /* Check ACLs on content of Adds by default */
6306 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_ACL_ADD;
6312 config_back_destroy( BackendInfo *bi )
6314 ldif_must_b64_encode_release();
6319 config_tool_entry_open( BackendDB *be, int mode )
6321 CfBackInfo *cfb = be->be_private;
6322 BackendInfo *bi = cfb->cb_db.bd_info;
6324 if ( bi && bi->bi_tool_entry_open )
6325 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
6332 config_tool_entry_close( BackendDB *be )
6334 CfBackInfo *cfb = be->be_private;
6335 BackendInfo *bi = cfb->cb_db.bd_info;
6337 if ( bi && bi->bi_tool_entry_close )
6338 return bi->bi_tool_entry_close( &cfb->cb_db );
6344 config_tool_entry_first( BackendDB *be )
6346 CfBackInfo *cfb = be->be_private;
6347 BackendInfo *bi = cfb->cb_db.bd_info;
6349 if ( bi && bi->bi_tool_entry_first )
6350 return bi->bi_tool_entry_first( &cfb->cb_db );
6356 config_tool_entry_next( BackendDB *be )
6358 CfBackInfo *cfb = be->be_private;
6359 BackendInfo *bi = cfb->cb_db.bd_info;
6361 if ( bi && bi->bi_tool_entry_next )
6362 return bi->bi_tool_entry_next( &cfb->cb_db );
6368 config_tool_entry_get( BackendDB *be, ID id )
6370 CfBackInfo *cfb = be->be_private;
6371 BackendInfo *bi = cfb->cb_db.bd_info;
6373 if ( bi && bi->bi_tool_entry_get )
6374 return bi->bi_tool_entry_get( &cfb->cb_db, id );
6379 static int entry_put_got_frontend=0;
6380 static int entry_put_got_config=0;
6382 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
6384 CfBackInfo *cfb = be->be_private;
6385 BackendInfo *bi = cfb->cb_db.bd_info;
6387 struct berval rdn, vals[ 2 ];
6389 OperationBuffer opbuf;
6391 Connection conn = {0};
6392 Operation *op = NULL;
6396 /* Create entry for frontend database if it does not exist already */
6397 if ( !entry_put_got_frontend ) {
6398 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
6399 STRLENOF( "olcDatabase" ))) {
6400 if ( strncmp( e->e_nname.bv_val +
6401 STRLENOF( "olcDatabase" ), "={-1}frontend",
6402 STRLENOF( "={-1}frontend" )) &&
6403 strncmp( e->e_nname.bv_val +
6404 STRLENOF( "olcDatabase" ), "=frontend",
6405 STRLENOF( "=frontend" ))) {
6407 vals[1].bv_val = NULL;
6408 memset( &ca, 0, sizeof(ConfigArgs));
6410 ca.bi = frontendDB->bd_info;
6411 ca.be->be_cf_ocs = &CFOC_FRONTEND;
6412 rdn.bv_val = ca.log;
6413 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
6414 "%s=" SLAP_X_ORDERED_FMT "%s",
6415 cfAd_database->ad_cname.bv_val, -1,
6417 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
6418 &CFOC_DATABASE, ca.be->be_cf_ocs );
6419 thrctx = ldap_pvt_thread_pool_context();
6420 connection_fake_init2( &conn, &opbuf, thrctx,0 );
6422 op->o_bd = &cfb->cb_db;
6423 op->o_tag = LDAP_REQ_ADD;
6425 op->o_dn = be->be_rootdn;
6426 op->o_ndn = be->be_rootndn;
6427 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
6428 if ( rc != LDAP_SUCCESS ) {
6429 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
6430 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
6434 if ( ce && bi && bi->bi_tool_entry_put &&
6435 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
6436 entry_put_got_frontend++;
6438 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
6439 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
6443 entry_put_got_frontend++;
6448 /* Create entry for config database if it does not exist already */
6449 if ( !entry_put_got_config && !isFrontend ) {
6450 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
6451 STRLENOF( "olcDatabase" ))) {
6452 if ( strncmp( e->e_nname.bv_val +
6453 STRLENOF( "olcDatabase" ), "={0}config",
6454 STRLENOF( "={0}config" )) &&
6455 strncmp( e->e_nname.bv_val +
6456 STRLENOF( "olcDatabase" ), "=config",
6457 STRLENOF( "=config" )) ) {
6459 vals[1].bv_val = NULL;
6460 memset( &ca, 0, sizeof(ConfigArgs));
6461 ca.be = LDAP_STAILQ_FIRST( &backendDB );
6462 ca.bi = ca.be->bd_info;
6463 rdn.bv_val = ca.log;
6464 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
6465 "%s=" SLAP_X_ORDERED_FMT "%s",
6466 cfAd_database->ad_cname.bv_val, 0,
6468 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
6471 thrctx = ldap_pvt_thread_pool_context();
6472 connection_fake_init2( &conn, &opbuf, thrctx,0 );
6474 op->o_bd = &cfb->cb_db;
6475 op->o_tag = LDAP_REQ_ADD;
6476 op->o_dn = be->be_rootdn;
6477 op->o_ndn = be->be_rootndn;
6480 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
6481 if ( rc != LDAP_SUCCESS ) {
6482 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
6483 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
6486 if (ce && bi && bi->bi_tool_entry_put &&
6487 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
6488 entry_put_got_config++;
6490 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
6491 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
6495 entry_put_got_config++;
6499 if ( bi && bi->bi_tool_entry_put &&
6500 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
6501 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
6508 AttributeDescription **desc;
6510 { "attribute", &cfAd_attr },
6511 { "backend", &cfAd_backend },
6512 { "database", &cfAd_database },
6513 { "include", &cfAd_include },
6514 { "ldapsyntax", &cfAd_syntax },
6515 { "objectclass", &cfAd_oc },
6516 { "objectidentifier", &cfAd_om },
6517 { "overlay", &cfAd_overlay },
6522 * add / delete: all types that may be added or deleted must use an
6523 * X-ORDERED attributeType for their RDN. Adding and deleting entries
6524 * should automatically renumber the index of any siblings as needed,
6525 * so that no gaps in the numbering sequence exist after the add/delete
6527 * What can be added:
6529 * backend objects for backend-specific config directives
6533 * delete: probably no support this time around.
6535 * modrdn: generally not done. Will be invoked automatically by add/
6536 * delete to update numbering sequence. Perform as an explicit operation
6537 * so that the renumbering effect may be replicated. Subtree rename must
6538 * be supported, since renumbering a database will affect all its child
6541 * modify: must be fully supported.
6545 config_back_initialize( BackendInfo *bi )
6547 ConfigTable *ct = config_back_cf_table;
6551 AttributeDescription *ad = NULL;
6553 static char *controls[] = {
6554 LDAP_CONTROL_MANAGEDSAIT,
6558 /* Make sure we don't exceed the bits reserved for userland */
6559 config_check_userland( CFG_LAST );
6561 bi->bi_controls = controls;
6566 bi->bi_destroy = config_back_destroy;
6568 bi->bi_db_init = config_back_db_init;
6569 bi->bi_db_config = 0;
6570 bi->bi_db_open = config_back_db_open;
6571 bi->bi_db_close = config_back_db_close;
6572 bi->bi_db_destroy = config_back_db_destroy;
6574 bi->bi_op_bind = config_back_bind;
6575 bi->bi_op_unbind = 0;
6576 bi->bi_op_search = config_back_search;
6577 bi->bi_op_compare = 0;
6578 bi->bi_op_modify = config_back_modify;
6579 bi->bi_op_modrdn = config_back_modrdn;
6580 bi->bi_op_add = config_back_add;
6581 bi->bi_op_delete = config_back_delete;
6582 bi->bi_op_abandon = 0;
6584 bi->bi_extended = 0;
6586 bi->bi_chk_referrals = 0;
6588 bi->bi_access_allowed = slap_access_allowed;
6590 bi->bi_connection_init = 0;
6591 bi->bi_connection_destroy = 0;
6593 bi->bi_entry_release_rw = config_entry_release;
6594 bi->bi_entry_get_rw = config_back_entry_get;
6596 bi->bi_tool_entry_open = config_tool_entry_open;
6597 bi->bi_tool_entry_close = config_tool_entry_close;
6598 bi->bi_tool_entry_first = config_tool_entry_first;
6599 bi->bi_tool_entry_next = config_tool_entry_next;
6600 bi->bi_tool_entry_get = config_tool_entry_get;
6601 bi->bi_tool_entry_put = config_tool_entry_put;
6604 argv[ 0 ] = "slapd";
6610 for (i=0; OidMacros[i].name; i++ ) {
6611 argv[1] = OidMacros[i].name;
6612 argv[2] = OidMacros[i].oid;
6613 parse_oidm( &ca, 0, NULL );
6616 bi->bi_cf_ocs = cf_ocs;
6618 i = config_register_schema( ct, cf_ocs );
6621 i = slap_str2ad( "olcDatabase", &olcDatabaseDummy[0].ad, &text );
6624 /* setup olcRootPW to be base64-encoded when written in LDIF form;
6625 * basically, we don't care if it fails */
6626 i = slap_str2ad( "olcRootPW", &ad, &text );
6628 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
6629 "warning, unable to get \"olcRootPW\" "
6630 "attribute description: %d: %s\n",
6633 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
6634 ad->ad_type->sat_oid );
6637 /* set up the notable AttributeDescriptions */
6639 for (;ct->name;ct++) {
6640 if (strcmp(ct->name, ads[i].name)) continue;
6641 *ads[i].desc = ct->ad;
6643 if (!ads[i].name) break;