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
266 /* alphabetical ordering */
268 static ConfigTable config_back_cf_table[] = {
269 /* This attr is read-only */
270 { "", "", 0, 0, 0, ARG_MAGIC,
271 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
272 "DESC 'File for slapd configuration directives' "
273 "EQUALITY caseIgnoreMatch "
274 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
275 { "", "", 0, 0, 0, ARG_MAGIC,
276 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
277 "DESC 'Directory for slapd configuration backend' "
278 "EQUALITY caseIgnoreMatch "
279 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
280 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
281 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
282 "DESC 'Access Control List' "
283 "EQUALITY caseIgnoreMatch "
284 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
285 { "add_content_acl", NULL, 0, 0, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_ACL_ADD,
286 &config_generic, "( OLcfgGlAt:86 NAME 'olcAddContentAcl' "
287 "DESC 'Check ACLs against content of Add ops' "
288 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
289 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
290 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
291 "DESC 'Allowed set of deprecated features' "
292 "EQUALITY caseIgnoreMatch "
293 "SYNTAX OMsDirectoryString )", NULL, NULL },
294 { "argsfile", "file", 2, 2, 0, ARG_STRING,
295 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
296 "DESC 'File for slapd command line options' "
297 "EQUALITY caseIgnoreMatch "
298 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
299 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
300 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
301 "EQUALITY caseIgnoreMatch "
302 "SYNTAX OMsDirectoryString )", NULL, NULL },
303 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
304 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
305 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
306 "DESC 'OpenLDAP attributeTypes' "
307 "EQUALITY caseIgnoreMatch "
308 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
310 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
311 #ifdef SLAP_AUTH_REWRITE
312 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
316 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
317 "EQUALITY caseIgnoreMatch "
318 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
319 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
320 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
321 "EQUALITY caseIgnoreMatch "
322 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
323 { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
324 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
325 "EQUALITY caseIgnoreMatch "
326 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
327 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
328 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
329 "DESC 'A type of backend' "
330 "EQUALITY caseIgnoreMatch "
331 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
333 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
334 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
335 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
336 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
337 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
338 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
339 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
340 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
341 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
342 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
343 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
344 "DESC 'The backend type for a database instance' "
345 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
346 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
347 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
348 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
349 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
350 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
351 "EQUALITY caseIgnoreMatch "
352 "SYNTAX OMsDirectoryString )", NULL, NULL },
353 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
354 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
355 "DESC 'OpenLDAP DIT content rules' "
356 "EQUALITY caseIgnoreMatch "
357 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
359 { "gentlehup", "on|off", 2, 2, 0,
361 ARG_ON_OFF, &global_gentlehup,
365 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
366 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
367 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
368 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
369 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
370 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
371 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
372 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
373 { "include", "file", 2, 2, 0, ARG_MAGIC,
374 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
375 "SUP labeledURI )", NULL, NULL },
376 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
377 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
378 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
379 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
380 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
381 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
382 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
383 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
384 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
385 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
386 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
387 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
388 { "index_intlen", "len", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_IX_INTLEN,
389 &config_generic, "( OLcfgGlAt:84 NAME 'olcIndexIntLen' "
390 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
391 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
392 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
393 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
394 { "ldapsyntax", "syntax", 2, 0, 0,
395 ARG_PAREN|ARG_MAGIC|CFG_SYNTAX,
396 &config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
397 "DESC 'OpenLDAP ldapSyntax' "
398 "EQUALITY caseIgnoreMatch "
399 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
401 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
402 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
403 "EQUALITY caseIgnoreMatch "
404 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
405 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
406 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
407 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
408 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
409 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
410 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
411 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
412 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
413 "EQUALITY caseIgnoreMatch "
414 "SYNTAX OMsDirectoryString )", NULL, NULL },
415 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
416 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
417 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
418 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
419 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
420 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
421 { "moduleload", "file", 2, 0, 0,
423 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
427 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
428 "EQUALITY caseIgnoreMatch "
429 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
430 { "modulepath", "path", 2, 2, 0,
432 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
436 "( OLcfgGlAt:31 NAME 'olcModulePath' "
437 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
438 { "monitoring", "TRUE|FALSE", 2, 2, 0,
439 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
440 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
441 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
442 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
443 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
444 "DESC 'OpenLDAP object classes' "
445 "EQUALITY caseIgnoreMatch "
446 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
448 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
449 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
450 "EQUALITY caseIgnoreMatch "
451 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
452 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
453 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
454 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
455 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
456 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
457 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
458 { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
459 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
460 "EQUALITY caseIgnoreMatch "
461 "SYNTAX OMsDirectoryString )", NULL, NULL },
462 { "pidfile", "file", 2, 2, 0, ARG_STRING,
463 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
464 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
465 { "plugin", NULL, 0, 0, 0,
467 ARG_MAGIC|CFG_PLUGIN, &config_generic,
471 "( OLcfgGlAt:38 NAME 'olcPlugin' "
472 "EQUALITY caseIgnoreMatch "
473 "SYNTAX OMsDirectoryString )", NULL, NULL },
474 { "pluginlog", "filename", 2, 2, 0,
476 ARG_STRING, &slapi_log_file,
480 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
481 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
482 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
483 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
484 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
485 { "referral", "url", 2, 2, 0, ARG_MAGIC,
486 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
487 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
488 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
489 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
490 "EQUALITY caseIgnoreMatch "
491 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
492 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
493 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
494 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
495 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
496 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
497 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
498 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
499 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
500 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
501 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
502 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
503 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
504 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
505 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
506 "EQUALITY caseIgnoreMatch "
507 "SYNTAX OMsDirectoryString )", NULL, NULL },
508 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
509 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
510 "EQUALITY caseIgnoreMatch "
511 "SYNTAX OMsDirectoryString )", NULL, NULL },
512 { "reverse-lookup", "on|off", 2, 2, 0,
513 #ifdef SLAPD_RLOOKUPS
514 ARG_ON_OFF, &use_reverse_lookup,
518 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
519 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
520 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
521 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
522 "EQUALITY distinguishedNameMatch "
523 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
524 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
525 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
526 "EQUALITY caseIgnoreMatch "
527 "SYNTAX OMsDirectoryString )", NULL, NULL },
528 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
529 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
530 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
531 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
532 &config_generic, NULL, NULL, NULL },
533 { "sasl-auxprops", NULL, 2, 0, 0,
534 #ifdef HAVE_CYRUS_SASL
535 ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
539 "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
540 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
541 { "sasl-host", "host", 2, 2, 0,
542 #ifdef HAVE_CYRUS_SASL
543 ARG_STRING|ARG_UNIQUE, &sasl_host,
547 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
548 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
549 { "sasl-realm", "realm", 2, 2, 0,
550 #ifdef HAVE_CYRUS_SASL
551 ARG_STRING|ARG_UNIQUE, &global_realm,
555 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
556 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
557 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
558 &config_generic, NULL, NULL, NULL },
559 { "sasl-secprops", "properties", 2, 2, 0,
560 #ifdef HAVE_CYRUS_SASL
561 ARG_MAGIC|CFG_SASLSECP, &config_generic,
565 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
566 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
567 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
568 &config_generic, NULL, NULL, NULL },
569 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
570 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
571 "EQUALITY distinguishedNameMatch "
572 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
573 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
574 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
575 "EQUALITY caseIgnoreMatch "
576 "SYNTAX OMsDirectoryString )", NULL, NULL },
577 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
578 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
579 "EQUALITY caseIgnoreMatch "
580 "SYNTAX OMsDirectoryString )", NULL, NULL },
581 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
582 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
583 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
584 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
585 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
586 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
587 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
588 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
589 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
590 { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
591 &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
592 "DESC 'Attributes whose values will always be sorted' "
593 "EQUALITY caseIgnoreMatch "
594 "SYNTAX OMsDirectoryString )", NULL, NULL },
595 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
596 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
597 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
598 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
599 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
600 "EQUALITY distinguishedNameMatch "
601 "SYNTAX OMsDN )", NULL, NULL },
602 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
603 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
604 "EQUALITY caseIgnoreMatch "
605 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
606 { "threads", "count", 2, 2, 0,
610 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
612 "( OLcfgGlAt:66 NAME 'olcThreads' "
613 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
614 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
615 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
616 "SYNTAX OMsDirectoryString )", NULL, NULL },
617 { "TLSCACertificateFile", NULL, 0, 0, 0,
619 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
623 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
624 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
625 { "TLSCACertificatePath", NULL, 0, 0, 0,
627 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
631 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
632 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
633 { "TLSCertificateFile", NULL, 0, 0, 0,
635 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
639 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
640 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
641 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
643 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
647 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
648 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
649 { "TLSCipherSuite", NULL, 0, 0, 0,
651 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
655 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
656 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
657 { "TLSCRLCheck", NULL, 0, 0, 0,
658 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
659 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
663 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
664 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
665 { "TLSCRLFile", NULL, 0, 0, 0,
666 #if defined(HAVE_GNUTLS)
667 CFG_TLS_CRL_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
671 "( OLcfgGlAt:82 NAME 'olcTLSCRLFile' "
672 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
673 { "TLSRandFile", NULL, 0, 0, 0,
675 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
679 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
680 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
681 { "TLSVerifyClient", NULL, 0, 0, 0,
683 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
687 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
688 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
689 { "TLSDHParamFile", NULL, 0, 0, 0,
691 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
695 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
696 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
697 { "TLSProtocolMin", NULL, 0, 0, 0,
699 CFG_TLS_PROTOCOL_MIN|ARG_STRING|ARG_MAGIC, &config_tls_config,
703 "( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' "
704 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
705 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
706 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
707 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
708 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
709 NULL, NULL, NULL, NULL },
710 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
711 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
712 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
713 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
714 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
715 "EQUALITY caseIgnoreMatch "
716 "SUP labeledURI )", NULL, NULL },
717 { "writetimeout", "timeout", 2, 2, 0, ARG_INT,
718 &global_writetimeout, "( OLcfgGlAt:88 NAME 'olcWriteTimeout' "
719 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
720 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
721 NULL, NULL, NULL, NULL }
724 /* Need to no-op this keyword for dynamic config */
725 ConfigTable olcDatabaseDummy[] = {
726 { "", "", 0, 0, 0, ARG_IGNORED,
727 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
728 "DESC 'The backend type for a database instance' "
729 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
730 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
733 /* Routines to check if a child can be added to this type */
734 static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
735 cfAddBackend, cfAddModule, cfAddOverlay;
737 /* NOTE: be careful when defining array members
738 * that can be conditionally compiled */
739 #define CFOC_GLOBAL cf_ocs[1]
740 #define CFOC_SCHEMA cf_ocs[2]
741 #define CFOC_BACKEND cf_ocs[3]
742 #define CFOC_DATABASE cf_ocs[4]
743 #define CFOC_OVERLAY cf_ocs[5]
744 #define CFOC_INCLUDE cf_ocs[6]
745 #define CFOC_FRONTEND cf_ocs[7]
747 #define CFOC_MODULE cf_ocs[8]
748 #endif /* SLAPD_MODULES */
750 static ConfigOCs cf_ocs[] = {
753 "DESC 'OpenLDAP configuration object' "
754 "ABSTRACT SUP top )", Cft_Abstract, NULL },
757 "DESC 'OpenLDAP Global configuration options' "
758 "SUP olcConfig STRUCTURAL "
759 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
760 "olcAttributeOptions $ olcAuthIDRewrite $ "
761 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
762 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
763 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
764 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
765 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcIndexIntLen $ "
766 "olcLocalSSF $ olcLogFile $ olcLogLevel $ "
767 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
768 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
769 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
771 "olcSaslAuxprops $ olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
772 "olcSecurity $ olcServerID $ olcSizeLimit $ "
773 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
774 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
775 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
776 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
777 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
778 "olcTLSCRLFile $ olcToolThreads $ olcWriteTimeout $ "
779 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
780 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
782 "NAME 'olcSchemaConfig' "
783 "DESC 'OpenLDAP schema object' "
784 "SUP olcConfig STRUCTURAL "
785 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
786 "olcObjectClasses $ olcDitContentRules $ olcLdapSyntaxes ) )",
787 Cft_Schema, NULL, cfAddSchema },
789 "NAME 'olcBackendConfig' "
790 "DESC 'OpenLDAP Backend-specific options' "
791 "SUP olcConfig STRUCTURAL "
792 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
794 "NAME 'olcDatabaseConfig' "
795 "DESC 'OpenLDAP Database-specific options' "
796 "SUP olcConfig STRUCTURAL "
798 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
799 "olcAddContentAcl $ olcLastMod $ olcLimits $ "
800 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
801 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
802 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
803 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ "
804 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
806 Cft_Database, NULL, cfAddDatabase },
808 "NAME 'olcOverlayConfig' "
809 "DESC 'OpenLDAP Overlay-specific options' "
810 "SUP olcConfig STRUCTURAL "
811 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
813 "NAME 'olcIncludeFile' "
814 "DESC 'OpenLDAP configuration include file' "
815 "SUP olcConfig STRUCTURAL "
817 "MAY ( cn $ olcRootDSE ) )",
818 /* Used to be Cft_Include, that def has been removed */
819 Cft_Abstract, NULL, cfAddInclude },
820 /* This should be STRUCTURAL like all the other database classes, but
821 * that would mean inheriting all of the olcDatabaseConfig attributes,
822 * which causes them to be merged twice in config_build_entry.
825 "NAME 'olcFrontendConfig' "
826 "DESC 'OpenLDAP frontend configuration' "
828 "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
829 Cft_Database, NULL, NULL },
832 "NAME 'olcModuleList' "
833 "DESC 'OpenLDAP dynamic module info' "
834 "SUP olcConfig STRUCTURAL "
835 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
836 Cft_Module, NULL, cfAddModule },
841 typedef struct ServerID {
842 struct ServerID *si_next;
843 struct berval si_url;
847 static ServerID *sid_list;
849 typedef struct voidList {
850 struct voidList *vl_next;
854 typedef struct ADlist {
855 struct ADlist *al_next;
856 AttributeDescription *al_desc;
859 static ADlist *sortVals;
862 config_generic(ConfigArgs *c) {
865 if ( c->op == SLAP_CONFIG_EMIT ) {
869 c->value_int = ldap_pvt_thread_get_concurrency();
872 c->value_int = connection_pool_max;
875 c->value_int = slap_tool_thread_max;
879 c->value_string = ch_strdup( passwd_salt );
884 if ( c->be->be_limits ) {
888 for ( i=0; c->be->be_limits[i]; i++ ) {
889 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
890 if ( bv.bv_len >= sizeof( buf ) ) {
891 ber_bvarray_free_x( c->rvalue_vals, NULL );
892 c->rvalue_vals = NULL;
896 bv.bv_val = buf + bv.bv_len;
897 limits_unparse( c->be->be_limits[i], &bv,
898 sizeof( buf ) - ( bv.bv_val - buf ) );
899 bv.bv_len += bv.bv_val - buf;
901 value_add_one( &c->rvalue_vals, &bv );
904 if ( !c->rvalue_vals ) rc = 1;
907 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
910 c->value_string = ch_strdup( slap_sasl_getpolicy());
913 slap_sasl_regexp_unparse( &c->rvalue_vals );
914 if ( !c->rvalue_vals ) rc = 1;
916 #ifdef HAVE_CYRUS_SASL
918 struct berval bv = BER_BVNULL;
919 slap_sasl_secprops_unparse( &bv );
920 if ( !BER_BVISNULL( &bv )) {
921 ber_bvarray_add( &c->rvalue_vals, &bv );
929 c->value_int = c->be->be_max_deref_depth;
932 if ( SLAP_DBHIDDEN( c->be )) {
939 ConfigFile *cf = c->ca_private;
941 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
942 else if ( cf->c_om_head )
943 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
945 if ( !c->rvalue_vals )
950 ad_unparse_options( &c->rvalue_vals );
953 ConfigFile *cf = c->ca_private;
955 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
956 else if ( cf->c_oc_head )
957 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
959 if ( !c->rvalue_vals )
964 ConfigFile *cf = c->ca_private;
966 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
967 else if ( cf->c_at_head )
968 at_unparse( &c->rvalue_vals, cf->c_at_head,
970 if ( !c->rvalue_vals )
975 ConfigFile *cf = c->ca_private;
977 syn_unparse( &c->rvalue_vals, NULL, NULL, 1 );
978 else if ( cf->c_syn_head )
979 syn_unparse( &c->rvalue_vals, cf->c_syn_head,
981 if ( !c->rvalue_vals )
986 ConfigFile *cf = c->ca_private;
988 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
989 else if ( cf->c_cr_head )
990 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
992 if ( !c->rvalue_vals )
999 char *src, *dst, ibuf[11];
1000 struct berval bv, abv;
1001 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
1002 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1003 if ( abv.bv_len >= sizeof( ibuf ) ) {
1004 ber_bvarray_free_x( c->rvalue_vals, NULL );
1005 c->rvalue_vals = NULL;
1009 acl_unparse( a, &bv );
1010 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
1011 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
1012 /* Turn TAB / EOL into plain space */
1013 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
1014 if (isspace((unsigned char)*src)) *dst++ = ' ';
1018 if (dst[-1] == ' ') {
1022 abv.bv_len = dst - abv.bv_val;
1023 ber_bvarray_add( &c->rvalue_vals, &abv );
1029 c->value_int = (SLAP_DBACL_ADD(c->be) != 0);
1032 ConfigFile *cf = c->ca_private;
1033 if ( cf->c_dseFiles ) {
1034 value_add( &c->rvalue_vals, cf->c_dseFiles );
1045 for ( si = sid_list; si; si=si->si_next ) {
1046 assert( si->si_num >= 0 && si->si_num <= SLAP_SYNC_SID_MAX );
1047 if ( !BER_BVISEMPTY( &si->si_url )) {
1048 bv.bv_len = si->si_url.bv_len + 6;
1049 bv.bv_val = ch_malloc( bv.bv_len );
1050 bv.bv_len = sprintf( bv.bv_val, "%d %s", si->si_num,
1051 si->si_url.bv_val );
1052 ber_bvarray_add( &c->rvalue_vals, &bv );
1056 bv.bv_len = sprintf( buf, "%d", si->si_num );
1057 value_add_one( &c->rvalue_vals, &bv );
1066 c->value_string = ch_strdup( logfileName );
1071 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
1073 case CFG_MIRRORMODE:
1074 if ( SLAP_SHADOW(c->be))
1075 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
1079 case CFG_MONITORING:
1080 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
1082 case CFG_SSTR_IF_MAX:
1083 c->value_int = index_substr_if_maxlen;
1085 case CFG_SSTR_IF_MIN:
1086 c->value_int = index_substr_if_minlen;
1089 c->value_int = index_intlen;
1091 case CFG_SORTVALS: {
1094 for ( sv = sortVals; sv; sv = sv->al_next ) {
1095 value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
1099 #ifdef SLAPD_MODULES
1101 ModPaths *mp = c->ca_private;
1104 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
1107 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
1108 SLAP_X_ORDERED_FMT "%s", i,
1109 mp->mp_loads[i].bv_val );
1110 if ( bv.bv_len >= sizeof( c->log ) ) {
1111 ber_bvarray_free_x( c->rvalue_vals, NULL );
1112 c->rvalue_vals = NULL;
1115 value_add_one( &c->rvalue_vals, &bv );
1119 rc = c->rvalue_vals ? 0 : 1;
1123 ModPaths *mp = c->ca_private;
1124 if ( !BER_BVISNULL( &mp->mp_path ))
1125 value_add_one( &c->rvalue_vals, &mp->mp_path );
1127 rc = c->rvalue_vals ? 0 : 1;
1133 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1134 if ( !c->rvalue_vals ) rc = 1;
1137 #ifdef SLAP_AUTH_REWRITE
1139 if ( authz_rewrites ) {
1140 struct berval bv, idx;
1145 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1146 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1147 if ( idx.bv_len >= sizeof( ibuf ) ) {
1148 ber_bvarray_free_x( c->rvalue_vals, NULL );
1149 c->rvalue_vals = NULL;
1152 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1153 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1154 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1155 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1156 authz_rewrites[i].bv_val,
1157 authz_rewrites[i].bv_len + 1 );
1158 ber_bvarray_add( &c->rvalue_vals, &bv );
1161 if ( !c->rvalue_vals ) rc = 1;
1168 } else if ( c->op == LDAP_MOD_DELETE ) {
1171 /* single-valued attrs, no-ops */
1179 case CFG_MIRRORMODE:
1180 case CFG_MONITORING:
1182 case CFG_SSTR_IF_MAX:
1183 case CFG_SSTR_IF_MIN:
1187 /* no-ops, requires slapd restart */
1192 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1196 ch_free( passwd_salt );
1201 ch_free( logfileName );
1209 case CFG_SERVERID: {
1210 ServerID *si, **sip;
1212 for ( i=0, si = sid_list, sip = &sid_list;
1213 si; si = *sip, i++ ) {
1214 if ( c->valx == -1 || i == c->valx ) {
1226 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1230 index_intlen = SLAP_INDEX_INTLEN_DEFAULT;
1231 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1232 SLAP_INDEX_INTLEN_DEFAULT );
1236 if ( c->valx < 0 ) {
1237 acl_destroy( c->be->be_acl );
1238 c->be->be_acl = NULL;
1241 AccessControl **prev, *a;
1243 for (i=0, prev = &c->be->be_acl; i < c->valx;
1246 prev = &a->acl_next;
1249 *prev = a->acl_next;
1256 /* Can be NULL when undoing a failed add */
1257 if ( c->ca_entry ) {
1258 ce = c->ca_entry->e_private;
1259 /* can't modify the hardcoded schema */
1260 if ( ce->ce_parent->ce_type == Cft_Global )
1264 cfn = c->ca_private;
1265 if ( c->valx < 0 ) {
1268 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1270 if ( oc == cfn->c_oc_tail )
1273 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1275 ObjectClass *oc, *prev = NULL;
1277 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1282 if ( cfn->c_oc_tail == oc ) {
1283 cfn->c_oc_tail = prev;
1285 if ( cfn->c_oc_head == oc ) {
1287 cfn->c_oc_head = oc;
1294 /* Can be NULL when undoing a failed add */
1295 if ( c->ca_entry ) {
1296 ce = c->ca_entry->e_private;
1297 /* can't modify the hardcoded schema */
1298 if ( ce->ce_parent->ce_type == Cft_Global )
1302 cfn = c->ca_private;
1303 if ( c->valx < 0 ) {
1306 for( at = cfn->c_at_head; at; at_next( &at )) {
1308 if ( at == cfn->c_at_tail )
1311 cfn->c_at_head = cfn->c_at_tail = NULL;
1313 AttributeType *at, *prev = NULL;
1315 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1320 if ( cfn->c_at_tail == at ) {
1321 cfn->c_at_tail = prev;
1323 if ( cfn->c_at_head == at ) {
1325 cfn->c_at_head = at;
1332 /* Can be NULL when undoing a failed add */
1333 if ( c->ca_entry ) {
1334 ce = c->ca_entry->e_private;
1335 /* can't modify the hardcoded schema */
1336 if ( ce->ce_parent->ce_type == Cft_Global )
1340 cfn = c->ca_private;
1341 if ( c->valx < 0 ) {
1344 for( syn = cfn->c_syn_head; syn; syn_next( &syn )) {
1346 if ( syn == cfn->c_syn_tail )
1349 cfn->c_syn_head = cfn->c_syn_tail = NULL;
1351 Syntax *syn, *prev = NULL;
1353 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++) {
1358 if ( cfn->c_syn_tail == syn ) {
1359 cfn->c_syn_tail = prev;
1361 if ( cfn->c_syn_head == syn ) {
1363 cfn->c_syn_head = syn;
1368 if ( c->valx < 0 ) {
1370 for ( sv = sortVals; sv; sv = sortVals ) {
1371 sortVals = sv->al_next;
1372 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1379 for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
1380 prev = &sv->al_next;
1383 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1384 *prev = sv->al_next;
1390 /* FIXME: there is no limits_free function */
1391 if ( c->valx < 0 ) {
1392 limits_destroy( c->be->be_limits );
1393 c->be->be_limits = NULL;
1398 if ( c->be->be_limits ) {
1399 for ( num = 0; c->be->be_limits[ num ]; num++ )
1403 if ( c->valx >= num ) {
1408 limits_destroy( c->be->be_limits );
1409 c->be->be_limits = NULL;
1412 limits_free_one( c->be->be_limits[ c->valx ] );
1414 for ( cnt = c->valx; cnt < num; cnt++ ) {
1415 c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
1422 /* FIXME: there is no ad_option_free function */
1424 /* FIXME: there is no way to remove attributes added by
1438 if(!(c->bi = backend_info(c->argv[1]))) {
1439 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1440 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1441 c->log, c->cr_msg, c->argv[1] );
1448 /* NOTE: config is always the first backend!
1450 if ( !strcasecmp( c->argv[1], "config" )) {
1451 c->be = LDAP_STAILQ_FIRST(&backendDB);
1452 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1455 c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply);
1457 if ( c->cr_msg[0] == 0 )
1458 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1459 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n", c->log, c->cr_msg, c->argv[1] );
1466 ldap_pvt_thread_set_concurrency(c->value_int);
1470 if ( c->value_int < 2 ) {
1471 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1472 "threads=%d smaller than minimum value 2",
1474 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1475 c->log, c->cr_msg, 0 );
1478 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1479 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1480 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1481 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1482 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1483 c->log, c->cr_msg, 0 );
1485 if ( slapMode & SLAP_SERVER_MODE )
1486 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1487 connection_pool_max = c->value_int; /* save for reference */
1491 if ( slapMode & SLAP_TOOL_MODE )
1492 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1493 slap_tool_thread_max = c->value_int; /* save for reference */
1497 if ( passwd_salt ) ch_free( passwd_salt );
1498 passwd_salt = c->value_string;
1499 lutil_salt_format(passwd_salt);
1503 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1509 c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1511 c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1515 ch_free(c->value_string);
1516 if (slap_sasl_setpolicy( c->argv[1] )) {
1517 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
1518 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1519 c->log, c->cr_msg, c->argv[1] );
1525 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1529 #ifdef HAVE_CYRUS_SASL
1532 char *txt = slap_sasl_secprops( c->argv[1] );
1534 snprintf( c->cr_msg, sizeof(c->cr_msg), "<%s> %s",
1536 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0 );
1544 c->be->be_max_deref_depth = c->value_int;
1550 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1551 cfn = c->ca_private;
1552 if(parse_oidm(c, 1, &om))
1554 if (!cfn->c_om_head) cfn->c_om_head = om;
1555 cfn->c_om_tail = om;
1560 ObjectClass *oc, *prev;
1562 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1563 cfn = c->ca_private;
1564 if ( c->valx < 0 ) {
1565 prev = cfn->c_oc_tail;
1568 /* If adding anything after the first, prev is easy */
1571 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1576 /* If adding the first, and head exists, find its prev */
1577 if (cfn->c_oc_head) {
1578 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1583 /* else prev is NULL, append to end of global list */
1585 if(parse_oc(c, &oc, prev)) return(1);
1586 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1587 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1592 AttributeType *at, *prev;
1594 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1595 cfn = c->ca_private;
1596 if ( c->valx < 0 ) {
1597 prev = cfn->c_at_tail;
1600 /* If adding anything after the first, prev is easy */
1603 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1608 /* If adding the first, and head exists, find its prev */
1609 if (cfn->c_at_head) {
1610 for ( at_start( &at ); at != cfn->c_at_head; ) {
1615 /* else prev is NULL, append to end of global list */
1617 if(parse_at(c, &at, prev)) return(1);
1618 if (!cfn->c_at_head) cfn->c_at_head = at;
1619 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1626 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1627 cfn = c->ca_private;
1628 if ( c->valx < 0 ) {
1629 prev = cfn->c_syn_tail;
1632 /* If adding anything after the first, prev is easy */
1635 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
1640 /* If adding the first, and head exists, find its prev */
1641 if (cfn->c_syn_head) {
1642 for ( syn_start( &syn ); syn != cfn->c_syn_head; ) {
1647 /* else prev is NULL, append to end of global list */
1649 if ( parse_syn( c, &syn, prev ) ) return(1);
1650 if ( !cfn->c_syn_head ) cfn->c_syn_head = syn;
1651 if ( cfn->c_syn_tail == prev ) cfn->c_syn_tail = syn;
1658 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1659 cfn = c->ca_private;
1660 if(parse_cr(c, &cr)) return(1);
1661 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1662 cfn->c_cr_tail = cr;
1667 ad_define_option(NULL, NULL, 0);
1668 for(i = 1; i < c->argc; i++)
1669 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1674 if ( c->value_int < SLAP_INDEX_INTLEN_DEFAULT )
1675 c->value_int = SLAP_INDEX_INTLEN_DEFAULT;
1676 else if ( c->value_int > 255 )
1678 index_intlen = c->value_int;
1679 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1683 case CFG_SORTVALS: {
1684 ADlist *svnew = NULL, *svtail, *sv;
1686 for ( i = 1; i < c->argc; i++ ) {
1687 AttributeDescription *ad = NULL;
1691 rc = slap_str2ad( c->argv[i], &ad, &text );
1693 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
1696 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1697 c->log, c->cr_msg, c->argv[i] );
1698 for ( sv = svnew; sv; sv = svnew ) {
1699 svnew = sv->al_next;
1704 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
1705 ad->ad_type->sat_single_value ) {
1706 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
1708 goto sortval_reject;
1710 sv = ch_malloc( sizeof( ADlist ));
1715 svtail->al_next = sv;
1720 for ( sv = svnew; sv; sv = sv->al_next )
1721 sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
1722 for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
1724 sv->al_next = svnew;
1731 /* Don't append to the global ACL if we're on a specific DB */
1733 if ( c->valx == -1 ) {
1736 for ( a=c->be->be_acl; a; a = a->acl_next )
1739 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1746 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_ACL_ADD;
1748 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_ACL_ADD;
1752 if(root_dse_read_file(c->argv[1])) {
1753 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> could not read file", c->argv[0] );
1754 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1755 c->log, c->cr_msg, c->argv[1] );
1760 ber_str2bv( c->argv[1], 0, 1, &bv );
1761 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1762 cfn = c->ca_private;
1763 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1769 ServerID *si, **sip;
1772 if ( lutil_atoi( &num, c->argv[1] ) ||
1773 num < 0 || num > SLAP_SYNC_SID_MAX )
1775 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1776 "<%s> illegal server ID", c->argv[0] );
1777 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1778 c->log, c->cr_msg, c->argv[1] );
1781 /* only one value allowed if no URL is given */
1782 if ( c->argc > 2 ) {
1785 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1786 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1787 "<%s> only one server ID allowed now", c->argv[0] );
1788 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1789 c->log, c->cr_msg, c->argv[1] );
1793 if ( ldap_url_parse( c->argv[2], &lud )) {
1794 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1795 "<%s> invalid URL", c->argv[0] );
1796 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1797 c->log, c->cr_msg, c->argv[2] );
1800 len = strlen( c->argv[2] );
1801 si = ch_malloc( sizeof(ServerID) + len + 1 );
1802 si->si_url.bv_val = (char *)(si+1);
1803 si->si_url.bv_len = len;
1804 strcpy( si->si_url.bv_val, c->argv[2] );
1807 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1808 "<%s> unqualified server ID not allowed now", c->argv[0] );
1809 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1810 c->log, c->cr_msg, c->argv[1] );
1813 si = ch_malloc( sizeof(ServerID) );
1814 BER_BVZERO( &si->si_url );
1815 slap_serverID = num;
1816 Debug( LDAP_DEBUG_CONFIG,
1818 c->log, slap_serverID, 0 );
1822 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
1825 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
1826 Listener **l = slapd_get_listeners();
1829 /* Try a straight compare with Listener strings */
1830 for ( i=0; l && l[i]; i++ ) {
1831 if ( !strcasecmp( c->argv[2], l[i]->sl_url.bv_val )) {
1837 /* If hostname is empty, or is localhost, or matches
1838 * our hostname, this serverID refers to this host.
1839 * Compare it against listeners and ports.
1841 if ( !isMe && ( !lud->lud_host || !lud->lud_host[0] ||
1842 !strncasecmp("localhost", lud->lud_host,
1843 STRLENOF("localhost")) ||
1844 !strcasecmp( global_host, lud->lud_host ))) {
1846 for ( i=0; l && l[i]; i++ ) {
1848 ldap_url_parse( l[i]->sl_url.bv_val, &lu2 );
1850 if ( strcasecmp( lud->lud_scheme,
1853 if ( lud->lud_port != lu2->lud_port )
1855 /* Listener on ANY address */
1856 if ( !lu2->lud_host || !lu2->lud_host[0] ) {
1860 /* URL on ANY address */
1861 if ( !lud->lud_host || !lud->lud_host[0] ) {
1865 /* Listener has specific host, must
1868 if ( !strcasecmp( lud->lud_host,
1874 ldap_free_urldesc( lu2 );
1881 slap_serverID = si->si_num;
1882 Debug( LDAP_DEBUG_CONFIG,
1883 "%s: SID=%d (listener=%s)\n",
1884 c->log, slap_serverID,
1885 l[i]->sl_url.bv_val );
1889 ldap_free_urldesc( lud );
1893 if ( logfileName ) ch_free( logfileName );
1894 logfileName = c->value_string;
1895 logfile = fopen(logfileName, "w");
1896 if(logfile) lutil_debug_file(logfile);
1900 if(SLAP_NOLASTMODCMD(c->be)) {
1901 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> not available for %s database",
1902 c->argv[0], c->be->bd_info->bi_type );
1903 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1904 c->log, c->cr_msg, 0 );
1908 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
1910 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
1913 case CFG_MIRRORMODE:
1914 if(!SLAP_SHADOW(c->be)) {
1915 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database is not a shadow",
1917 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1918 c->log, c->cr_msg, 0 );
1922 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
1924 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
1927 case CFG_MONITORING:
1929 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
1931 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
1936 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
1938 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
1941 case CFG_SSTR_IF_MAX:
1942 if (c->value_int < index_substr_if_minlen) {
1943 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
1944 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
1945 c->log, c->cr_msg, c->value_int );
1948 index_substr_if_maxlen = c->value_int;
1951 case CFG_SSTR_IF_MIN:
1952 if (c->value_int > index_substr_if_maxlen) {
1953 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
1954 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
1955 c->log, c->cr_msg, c->value_int );
1958 index_substr_if_minlen = c->value_int;
1961 #ifdef SLAPD_MODULES
1963 /* If we're just adding a module on an existing modpath,
1964 * make sure we've selected the current path.
1966 if ( c->op == LDAP_MOD_ADD && c->ca_private && modcur != c->ca_private ) {
1967 modcur = c->ca_private;
1968 /* This should never fail */
1969 if ( module_path( modcur->mp_path.bv_val )) {
1970 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> module path no longer valid",
1972 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
1973 c->log, c->cr_msg, modcur->mp_path.bv_val );
1977 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
1979 /* Record this load on the current path */
1983 if ( c->op == SLAP_CONFIG_ADD ) {
1984 ptr = c->line + STRLENOF("moduleload");
1985 while (!isspace((unsigned char) *ptr)) ptr++;
1986 while (isspace((unsigned char) *ptr)) ptr++;
1990 ber_str2bv(ptr, 0, 1, &bv);
1991 ber_bvarray_add( &modcur->mp_loads, &bv );
1993 /* Check for any new hardcoded schema */
1994 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
1995 config_check_schema( NULL, &cfBackInfo );
2000 if(module_path(c->argv[1])) return(1);
2001 /* Record which path was used with each module */
2005 if (!modpaths.mp_loads) {
2008 mp = ch_malloc( sizeof( ModPaths ));
2009 modlast->mp_next = mp;
2011 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
2013 mp->mp_loads = NULL;
2024 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
2026 slapi_plugins_used++;
2030 #ifdef SLAP_AUTH_REWRITE
2035 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
2038 if ( c->argc > 1 ) {
2041 /* quote all args but the first */
2042 line = ldap_charray2str( c->argv, "\" \"" );
2043 ber_str2bv( line, 0, 0, &bv );
2044 s = ber_bvchr( &bv, '"' );
2045 assert( s != NULL );
2046 /* move the trailing quote of argv[0] to the end */
2047 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
2048 bv.bv_val[ bv.bv_len - 1 ] = '"';
2051 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
2054 ber_bvarray_add( &authz_rewrites, &bv );
2061 Debug( LDAP_DEBUG_ANY,
2062 "%s: unknown CFG_TYPE %d.\n",
2063 c->log, c->type, 0 );
2072 config_fname(ConfigArgs *c) {
2073 if(c->op == SLAP_CONFIG_EMIT) {
2074 if (c->ca_private) {
2075 ConfigFile *cf = c->ca_private;
2076 value_add_one( &c->rvalue_vals, &cf->c_file );
2085 config_cfdir(ConfigArgs *c) {
2086 if(c->op == SLAP_CONFIG_EMIT) {
2087 if ( !BER_BVISEMPTY( &cfdir )) {
2088 value_add_one( &c->rvalue_vals, &cfdir );
2097 config_search_base(ConfigArgs *c) {
2098 if(c->op == SLAP_CONFIG_EMIT) {
2100 if (!BER_BVISEMPTY(&default_search_base)) {
2101 value_add_one(&c->rvalue_vals, &default_search_base);
2102 value_add_one(&c->rvalue_nvals, &default_search_nbase);
2106 } else if( c->op == LDAP_MOD_DELETE ) {
2107 ch_free( default_search_base.bv_val );
2108 ch_free( default_search_nbase.bv_val );
2109 BER_BVZERO( &default_search_base );
2110 BER_BVZERO( &default_search_nbase );
2114 if(c->bi || c->be != frontendDB) {
2115 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
2116 "prior to any backend or database definition\n",
2121 if(default_search_nbase.bv_len) {
2122 free(default_search_base.bv_val);
2123 free(default_search_nbase.bv_val);
2126 default_search_base = c->value_dn;
2127 default_search_nbase = c->value_ndn;
2131 /* For RE23 compatibility we allow this in the global entry
2132 * but we now defer it to the frontend entry to allow modules
2133 * to load new hash types.
2136 config_passwd_hash(ConfigArgs *c) {
2138 if (c->op == SLAP_CONFIG_EMIT) {
2140 /* Don't generate it in the global entry */
2141 if ( c->table == Cft_Global )
2143 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
2144 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
2145 value_add_one(&c->rvalue_vals, &bv);
2148 } else if ( c->op == LDAP_MOD_DELETE ) {
2149 /* Deleting from global is a no-op, only the frontendDB entry matters */
2150 if ( c->table == Cft_Global )
2152 if ( c->valx < 0 ) {
2153 ldap_charray_free( default_passwd_hash );
2154 default_passwd_hash = NULL;
2157 ch_free( default_passwd_hash[i] );
2158 for (; default_passwd_hash[i]; i++ )
2159 default_passwd_hash[i] = default_passwd_hash[i+1];
2163 for(i = 1; i < c->argc; i++) {
2164 if(!lutil_passwd_scheme(c->argv[i])) {
2165 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
2166 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2167 c->log, c->cr_msg, c->argv[i]);
2169 ldap_charray_add(&default_passwd_hash, c->argv[i]);
2172 if(!default_passwd_hash) {
2173 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
2174 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2175 c->log, c->cr_msg, 0 );
2182 config_schema_dn(ConfigArgs *c) {
2183 if ( c->op == SLAP_CONFIG_EMIT ) {
2185 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
2186 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
2187 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
2191 } else if ( c->op == LDAP_MOD_DELETE ) {
2192 ch_free( c->be->be_schemadn.bv_val );
2193 ch_free( c->be->be_schemandn.bv_val );
2194 BER_BVZERO( &c->be->be_schemadn );
2195 BER_BVZERO( &c->be->be_schemandn );
2198 ch_free( c->be->be_schemadn.bv_val );
2199 ch_free( c->be->be_schemandn.bv_val );
2200 c->be->be_schemadn = c->value_dn;
2201 c->be->be_schemandn = c->value_ndn;
2206 config_sizelimit(ConfigArgs *c) {
2208 struct slap_limits_set *lim = &c->be->be_def_limit;
2209 if (c->op == SLAP_CONFIG_EMIT) {
2214 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
2215 if ( !BER_BVISEMPTY( &bv ))
2216 value_add_one( &c->rvalue_vals, &bv );
2220 } else if ( c->op == LDAP_MOD_DELETE ) {
2221 /* Reset to defaults */
2222 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
2223 lim->lms_s_hard = 0;
2224 lim->lms_s_unchecked = -1;
2226 lim->lms_s_pr_hide = 0;
2227 lim->lms_s_pr_total = 0;
2230 for(i = 1; i < c->argc; i++) {
2231 if(!strncasecmp(c->argv[i], "size", 4)) {
2232 rc = limits_parse_one(c->argv[i], lim);
2234 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2235 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2236 c->log, c->cr_msg, c->argv[i]);
2240 if(!strcasecmp(c->argv[i], "unlimited")) {
2241 lim->lms_s_soft = -1;
2243 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
2244 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2245 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2246 c->log, c->cr_msg, c->argv[i]);
2250 lim->lms_s_hard = 0;
2257 config_timelimit(ConfigArgs *c) {
2259 struct slap_limits_set *lim = &c->be->be_def_limit;
2260 if (c->op == SLAP_CONFIG_EMIT) {
2265 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
2266 if ( !BER_BVISEMPTY( &bv ))
2267 value_add_one( &c->rvalue_vals, &bv );
2271 } else if ( c->op == LDAP_MOD_DELETE ) {
2272 /* Reset to defaults */
2273 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
2274 lim->lms_t_hard = 0;
2277 for(i = 1; i < c->argc; i++) {
2278 if(!strncasecmp(c->argv[i], "time", 4)) {
2279 rc = limits_parse_one(c->argv[i], lim);
2281 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2282 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2283 c->log, c->cr_msg, c->argv[i]);
2287 if(!strcasecmp(c->argv[i], "unlimited")) {
2288 lim->lms_t_soft = -1;
2290 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
2291 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2292 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2293 c->log, c->cr_msg, c->argv[i]);
2297 lim->lms_t_hard = 0;
2304 config_overlay(ConfigArgs *c) {
2305 if (c->op == SLAP_CONFIG_EMIT) {
2307 } else if ( c->op == LDAP_MOD_DELETE ) {
2310 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
2311 c->valx, &c->bi, &c->reply)) {
2313 Debug( LDAP_DEBUG_ANY,
2314 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
2315 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
2317 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi, &c->reply)) {
2324 config_subordinate(ConfigArgs *c)
2330 case SLAP_CONFIG_EMIT:
2331 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
2334 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
2335 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
2338 value_add_one( &c->rvalue_vals, &bv );
2342 case LDAP_MOD_DELETE:
2343 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2344 glue_sub_del( c->be );
2346 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2351 case SLAP_CONFIG_ADD:
2352 advertise = ( c->argc == 2 && !strcasecmp( c->argv[1], "advertise" ));
2353 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2360 config_suffix(ConfigArgs *c)
2363 struct berval pdn, ndn;
2364 char *notallowed = NULL;
2366 if ( c->be == frontendDB ) {
2367 notallowed = "frontend";
2369 } else if ( SLAP_MONITOR(c->be) ) {
2370 notallowed = "monitor";
2372 } else if ( SLAP_CONFIG(c->be) ) {
2373 notallowed = "config";
2376 if ( notallowed != NULL ) {
2377 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2381 case LDAP_MOD_DELETE:
2382 case LDAP_MOD_REPLACE:
2383 case LDAP_MOD_INCREMENT:
2384 case SLAP_CONFIG_ADD:
2385 if ( !BER_BVISNULL( &c->value_dn ) ) {
2386 snprintf( buf, sizeof( buf ), "<%s> ",
2387 c->value_dn.bv_val );
2390 Debug(LDAP_DEBUG_ANY,
2391 "%s: suffix %snot allowed in %s database.\n",
2392 c->log, buf, notallowed );
2395 case SLAP_CONFIG_EMIT:
2396 /* don't complain when emitting... */
2400 /* FIXME: don't know what values may be valid;
2401 * please remove assertion, or add legal values
2402 * to either block */
2410 if (c->op == SLAP_CONFIG_EMIT) {
2411 if ( c->be->be_suffix == NULL
2412 || BER_BVISNULL( &c->be->be_suffix[0] ) )
2416 value_add( &c->rvalue_vals, c->be->be_suffix );
2417 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
2420 } else if ( c->op == LDAP_MOD_DELETE ) {
2421 if ( c->valx < 0 ) {
2422 ber_bvarray_free( c->be->be_suffix );
2423 ber_bvarray_free( c->be->be_nsuffix );
2424 c->be->be_suffix = NULL;
2425 c->be->be_nsuffix = NULL;
2428 ch_free( c->be->be_suffix[i].bv_val );
2429 ch_free( c->be->be_nsuffix[i].bv_val );
2431 c->be->be_suffix[i] = c->be->be_suffix[i+1];
2432 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
2434 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
2439 #ifdef SLAPD_MONITOR_DN
2440 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
2441 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> DN is reserved for monitoring slapd",
2443 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2444 c->log, c->cr_msg, SLAPD_MONITOR_DN);
2449 if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
2450 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
2451 c->argv[0], c->be->bd_info->bi_type );
2452 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2453 c->log, c->cr_msg, 0);
2460 if (SLAP_DBHIDDEN( c->be ))
2463 tbe = select_backend(&ndn, 0);
2465 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
2471 BackendDB *b2 = tbe;
2473 /* Does tbe precede be? */
2474 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
2477 char *type = tbe->bd_info->bi_type;
2479 if ( overlay_is_over( tbe ) ) {
2480 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
2481 type = oi->oi_orig->bi_type;
2484 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> namingContext \"%s\" "
2485 "already served by a preceding %s database",
2486 c->argv[0], pdn.bv_val, type );
2487 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
2488 c->log, c->cr_msg, tbe->be_suffix[0].bv_val);
2494 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
2495 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
2496 "base provided \"%s\" (assuming okay)\n",
2497 c->log, default_search_base.bv_val, 0);
2499 ber_bvarray_add(&c->be->be_suffix, &pdn);
2500 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
2505 config_rootdn(ConfigArgs *c) {
2506 if (c->op == SLAP_CONFIG_EMIT) {
2507 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
2508 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
2509 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
2514 } else if ( c->op == LDAP_MOD_DELETE ) {
2515 ch_free( c->be->be_rootdn.bv_val );
2516 ch_free( c->be->be_rootndn.bv_val );
2517 BER_BVZERO( &c->be->be_rootdn );
2518 BER_BVZERO( &c->be->be_rootndn );
2521 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
2522 ch_free( c->be->be_rootdn.bv_val );
2523 ch_free( c->be->be_rootndn.bv_val );
2525 c->be->be_rootdn = c->value_dn;
2526 c->be->be_rootndn = c->value_ndn;
2531 config_rootpw(ConfigArgs *c) {
2534 if (c->op == SLAP_CONFIG_EMIT) {
2535 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
2536 /* don't copy, because "rootpw" is marked
2538 c->value_bv = c->be->be_rootpw;
2542 } else if ( c->op == LDAP_MOD_DELETE ) {
2543 ch_free( c->be->be_rootpw.bv_val );
2544 BER_BVZERO( &c->be->be_rootpw );
2548 tbe = select_backend(&c->be->be_rootndn, 0);
2550 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> can only be set when rootdn is under suffix",
2552 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2553 c->log, c->cr_msg, 0);
2556 if ( !BER_BVISNULL( &c->be->be_rootpw ))
2557 ch_free( c->be->be_rootpw.bv_val );
2558 c->be->be_rootpw = c->value_bv;
2563 config_restrict(ConfigArgs *c) {
2564 slap_mask_t restrictops = 0;
2566 slap_verbmasks restrictable_ops[] = {
2567 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
2568 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
2569 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
2570 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
2571 { BER_BVC("modrdn"), 0 },
2572 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
2573 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
2574 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
2575 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
2576 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
2577 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
2578 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
2579 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
2580 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
2581 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
2582 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
2586 if (c->op == SLAP_CONFIG_EMIT) {
2587 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
2589 } else if ( c->op == LDAP_MOD_DELETE ) {
2591 c->be->be_restrictops = 0;
2593 restrictops = verb_to_mask( c->line, restrictable_ops );
2594 c->be->be_restrictops ^= restrictops;
2598 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
2600 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown operation", c->argv[0] );
2601 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2602 c->log, c->cr_msg, c->argv[i]);
2605 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
2606 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
2607 c->be->be_restrictops |= restrictops;
2612 config_allows(ConfigArgs *c) {
2613 slap_mask_t allows = 0;
2615 slap_verbmasks allowable_ops[] = {
2616 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
2617 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
2618 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
2619 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
2620 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
2623 if (c->op == SLAP_CONFIG_EMIT) {
2624 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
2625 } else if ( c->op == LDAP_MOD_DELETE ) {
2629 allows = verb_to_mask( c->line, allowable_ops );
2630 global_allows ^= allows;
2634 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
2636 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
2637 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2638 c->log, c->cr_msg, c->argv[i]);
2641 global_allows |= allows;
2646 config_disallows(ConfigArgs *c) {
2647 slap_mask_t disallows = 0;
2649 slap_verbmasks disallowable_ops[] = {
2650 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
2651 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
2652 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
2653 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
2654 { BER_BVC("proxy_authz_non_critical"), SLAP_DISALLOW_PROXY_AUTHZ_N_CRIT },
2655 { BER_BVC("dontusecopy_non_critical"), SLAP_DISALLOW_DONTUSECOPY_N_CRIT },
2658 if (c->op == SLAP_CONFIG_EMIT) {
2659 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
2660 } else if ( c->op == LDAP_MOD_DELETE ) {
2662 global_disallows = 0;
2664 disallows = verb_to_mask( c->line, disallowable_ops );
2665 global_disallows ^= disallows;
2669 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
2671 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
2672 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2673 c->log, c->cr_msg, c->argv[i]);
2676 global_disallows |= disallows;
2681 config_requires(ConfigArgs *c) {
2682 slap_mask_t requires = frontendDB->be_requires;
2683 int i, argc = c->argc;
2684 char **argv = c->argv;
2686 slap_verbmasks requires_ops[] = {
2687 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
2688 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
2689 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
2690 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
2691 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
2694 if (c->op == SLAP_CONFIG_EMIT) {
2695 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
2696 } else if ( c->op == LDAP_MOD_DELETE ) {
2698 c->be->be_requires = 0;
2700 requires = verb_to_mask( c->line, requires_ops );
2701 c->be->be_requires ^= requires;
2705 /* "none" can only be first, to wipe out default/global values */
2706 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
2711 i = verbs_to_mask(argc, argv, requires_ops, &requires);
2713 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
2714 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
2715 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2716 c->log, c->cr_msg, 0);
2718 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
2719 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2720 c->log, c->cr_msg, c->argv[i]);
2724 c->be->be_requires = requires;
2728 static slap_verbmasks *loglevel_ops;
2731 loglevel_init( void )
2733 slap_verbmasks lo[] = {
2734 { BER_BVC("Any"), -1 },
2735 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
2736 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
2737 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
2738 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
2739 { BER_BVC("BER"), LDAP_DEBUG_BER },
2740 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
2741 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
2742 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
2743 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
2744 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
2745 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
2746 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
2747 #if 0 /* no longer used (nor supported) */
2748 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
2749 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
2751 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
2752 { BER_BVC("None"), LDAP_DEBUG_NONE },
2756 return slap_verbmasks_init( &loglevel_ops, lo );
2760 loglevel_destroy( void )
2762 if ( loglevel_ops ) {
2763 (void)slap_verbmasks_destroy( loglevel_ops );
2765 loglevel_ops = NULL;
2768 static slap_mask_t loglevel_ignore[] = { -1, 0 };
2771 slap_loglevel_register( slap_mask_t m, struct berval *s )
2775 if ( loglevel_ops == NULL ) {
2779 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
2782 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
2790 slap_loglevel_get( struct berval *s, int *l )
2795 if ( loglevel_ops == NULL ) {
2799 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
2800 m |= loglevel_ops[ i ].mask;
2803 for ( i = 1; m & i; i <<= 1 )
2810 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
2813 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
2824 str2loglevel( const char *s, int *l )
2828 if ( loglevel_ops == NULL ) {
2832 i = verb_to_mask( s, loglevel_ops );
2834 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
2838 *l = loglevel_ops[ i ].mask;
2844 loglevel2str( int l )
2846 struct berval bv = BER_BVNULL;
2848 loglevel2bv( l, &bv );
2854 loglevel2bv( int l, struct berval *bv )
2856 if ( loglevel_ops == NULL ) {
2862 return enum_to_verb( loglevel_ops, l, bv ) == -1;
2866 loglevel2bvarray( int l, BerVarray *bva )
2868 if ( loglevel_ops == NULL ) {
2872 return mask_to_verbs( loglevel_ops, l, bva );
2876 loglevel_print( FILE *out )
2880 if ( loglevel_ops == NULL ) {
2884 fprintf( out, "Installed log subsystems:\n\n" );
2885 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
2886 fprintf( out, "\t%-30s (%lu)\n",
2887 loglevel_ops[ i ].word.bv_val,
2888 loglevel_ops[ i ].mask );
2891 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
2892 "by specific code\n\n" );
2897 static int config_syslog;
2900 config_loglevel(ConfigArgs *c) {
2903 if ( loglevel_ops == NULL ) {
2907 if (c->op == SLAP_CONFIG_EMIT) {
2908 /* Get default or commandline slapd setting */
2909 if ( ldap_syslog && !config_syslog )
2910 config_syslog = ldap_syslog;
2911 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
2913 } else if ( c->op == LDAP_MOD_DELETE ) {
2917 int level = verb_to_mask( c->line, loglevel_ops );
2918 config_syslog ^= level;
2920 if ( slapMode & SLAP_SERVER_MODE ) {
2921 ldap_syslog = config_syslog;
2926 for( i=1; i < c->argc; i++ ) {
2929 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
2930 if( lutil_atoi( &level, c->argv[i] ) != 0 ) {
2931 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
2932 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2933 c->log, c->cr_msg, c->argv[i]);
2937 if ( str2loglevel( c->argv[i], &level ) ) {
2938 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown level", c->argv[0] );
2939 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2940 c->log, c->cr_msg, c->argv[i]);
2944 /* Explicitly setting a zero clears all the levels */
2946 config_syslog |= level;
2950 if ( slapMode & SLAP_SERVER_MODE ) {
2951 ldap_syslog = config_syslog;
2957 config_referral(ConfigArgs *c) {
2959 if (c->op == SLAP_CONFIG_EMIT) {
2960 if ( default_referral ) {
2961 value_add( &c->rvalue_vals, default_referral );
2966 } else if ( c->op == LDAP_MOD_DELETE ) {
2967 if ( c->valx < 0 ) {
2968 ber_bvarray_free( default_referral );
2969 default_referral = NULL;
2972 ch_free( default_referral[i].bv_val );
2973 for (; default_referral[i].bv_val; i++ )
2974 default_referral[i] = default_referral[i+1];
2978 if(validate_global_referral(c->argv[1])) {
2979 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
2980 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2981 c->log, c->cr_msg, c->argv[1]);
2985 ber_str2bv(c->argv[1], 0, 0, &val);
2986 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
2994 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
2995 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
2996 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
2997 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
2998 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
2999 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
3000 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
3001 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
3002 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
3007 config_security(ConfigArgs *c) {
3008 slap_ssf_set_t *set = &c->be->be_ssf_set;
3011 if (c->op == SLAP_CONFIG_EMIT) {
3017 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
3018 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
3021 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
3022 if ( bv.bv_len >= sizeof( numbuf ) ) {
3023 ber_bvarray_free_x( c->rvalue_vals, NULL );
3024 c->rvalue_vals = NULL;
3028 bv.bv_len += sec_keys[i].key.bv_len;
3029 bv.bv_val = ch_malloc( bv.bv_len + 1);
3030 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
3031 strcpy( next, numbuf );
3032 ber_bvarray_add( &c->rvalue_vals, &bv );
3037 for(i = 1; i < c->argc; i++) {
3038 slap_ssf_t *tgt = NULL;
3040 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
3041 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
3042 sec_keys[j].key.bv_len)) {
3043 src = c->argv[i] + sec_keys[j].key.bv_len;
3044 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
3049 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown factor", c->argv[0] );
3050 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3051 c->log, c->cr_msg, c->argv[i]);
3055 if ( lutil_atou( tgt, src ) != 0 ) {
3056 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse factor", c->argv[0] );
3057 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3058 c->log, c->cr_msg, c->argv[i]);
3066 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
3070 for (; !BER_BVISNULL( &an->an_name ); an++) {
3071 /* if buflen == 0, assume the buffer size has been
3072 * already checked otherwise */
3073 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
3074 if ( comma ) *ptr++ = ',';
3075 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
3082 config_updatedn(ConfigArgs *c) {
3083 if (c->op == SLAP_CONFIG_EMIT) {
3084 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
3085 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
3086 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
3090 } else if ( c->op == LDAP_MOD_DELETE ) {
3091 ch_free( c->be->be_update_ndn.bv_val );
3092 BER_BVZERO( &c->be->be_update_ndn );
3093 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
3096 if(SLAP_SHADOW(c->be)) {
3097 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database already shadowed", c->argv[0] );
3098 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3099 c->log, c->cr_msg, 0);
3103 ber_memfree_x( c->value_dn.bv_val, NULL );
3104 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
3105 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
3107 c->be->be_update_ndn = c->value_ndn;
3108 BER_BVZERO( &c->value_dn );
3109 BER_BVZERO( &c->value_ndn );
3111 return config_slurp_shadow( c );
3115 config_shadow( ConfigArgs *c, int flag )
3117 char *notallowed = NULL;
3119 if ( c->be == frontendDB ) {
3120 notallowed = "frontend";
3122 } else if ( SLAP_MONITOR(c->be) ) {
3123 notallowed = "monitor";
3126 if ( notallowed != NULL ) {
3127 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
3131 if ( SLAP_SHADOW(c->be) ) {
3132 /* if already shadow, only check consistency */
3133 if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
3134 Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%x.\n", c->log, flag, 0 );
3139 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
3146 config_updateref(ConfigArgs *c) {
3148 if (c->op == SLAP_CONFIG_EMIT) {
3149 if ( c->be->be_update_refs ) {
3150 value_add( &c->rvalue_vals, c->be->be_update_refs );
3155 } else if ( c->op == LDAP_MOD_DELETE ) {
3156 if ( c->valx < 0 ) {
3157 ber_bvarray_free( c->be->be_update_refs );
3158 c->be->be_update_refs = NULL;
3161 ch_free( c->be->be_update_refs[i].bv_val );
3162 for (; c->be->be_update_refs[i].bv_val; i++)
3163 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
3167 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
3168 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> must appear after syncrepl or updatedn",
3170 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3171 c->log, c->cr_msg, 0);
3175 if(validate_global_referral(c->argv[1])) {
3176 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3177 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3178 c->log, c->cr_msg, c->argv[1]);
3181 ber_str2bv(c->argv[1], 0, 0, &val);
3182 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
3187 config_obsolete(ConfigArgs *c) {
3188 if (c->op == SLAP_CONFIG_EMIT)
3191 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> keyword is obsolete (ignored)",
3193 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0);
3198 config_include(ConfigArgs *c) {
3199 int savelineno = c->lineno;
3202 ConfigFile *cfsave = cfn;
3203 ConfigFile *cf2 = NULL;
3205 /* Leftover from RE23. No dynamic config for include files */
3206 if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
3209 cf = ch_calloc( 1, sizeof(ConfigFile));
3210 if ( cfn->c_kids ) {
3211 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
3217 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
3218 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
3219 c->lineno = savelineno - 1;
3222 if ( cf2 ) cf2->c_sibs = NULL;
3223 else cfn->c_kids = NULL;
3224 ch_free( cf->c_file.bv_val );
3234 config_tls_cleanup(ConfigArgs *c) {
3237 if ( slap_tls_ld ) {
3240 ldap_pvt_tls_ctx_free( slap_tls_ctx );
3242 /* Force new ctx to be created */
3243 rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
3245 /* The ctx's refcount is bumped up here */
3246 ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
3247 /* This is a no-op if it's already loaded */
3248 load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
3255 config_tls_option(ConfigArgs *c) {
3257 LDAP *ld = slap_tls_ld;
3259 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
3260 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
3261 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
3262 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
3263 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
3264 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
3265 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
3267 case CFG_TLS_CRL_FILE: flag = LDAP_OPT_X_TLS_CRLFILE; break;
3269 default: 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 ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3276 } else if ( c->op == LDAP_MOD_DELETE ) {
3277 c->cleanup = config_tls_cleanup;
3278 return ldap_pvt_tls_set_option( ld, flag, NULL );
3280 ch_free(c->value_string);
3281 c->cleanup = config_tls_cleanup;
3282 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3285 /* FIXME: this ought to be provided by libldap */
3287 config_tls_config(ConfigArgs *c) {
3290 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
3291 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
3292 case CFG_TLS_PROTOCOL_MIN: flag = LDAP_OPT_X_TLS_PROTOCOL_MIN; break;
3294 Debug(LDAP_DEBUG_ANY, "%s: "
3295 "unknown tls_option <0x%x>\n",
3296 c->log, c->type, 0);
3299 if (c->op == SLAP_CONFIG_EMIT) {
3300 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3301 } else if ( c->op == LDAP_MOD_DELETE ) {
3303 c->cleanup = config_tls_cleanup;
3304 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3306 ch_free( c->value_string );
3307 c->cleanup = config_tls_cleanup;
3308 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3309 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3310 Debug(LDAP_DEBUG_ANY, "%s: "
3311 "unable to parse %s \"%s\"\n",
3312 c->log, c->argv[0], c->argv[1] );
3315 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
3317 return(ldap_int_tls_config(slap_tls_ld, flag, c->argv[1]));
3322 static CfEntryInfo *
3323 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
3333 if ( dn_match( &root->ce_entry->e_nname, dn ))
3336 c = dn->bv_val+dn->bv_len;
3337 for (;*c != ',';c--);
3341 for (--c;c>dn->bv_val && *c != ',';c--);
3345 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
3347 root = root->ce_kids;
3349 for (;root;root=root->ce_sibs) {
3350 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
3351 if ( cdn.bv_val == dn->bv_val ) {
3361 typedef struct setup_cookie {
3371 config_ldif_resp( Operation *op, SlapReply *rs )
3373 if ( rs->sr_type == REP_SEARCH ) {
3374 setup_cookie *sc = op->o_callback->sc_private;
3377 sc->cfb->cb_got_ldif = 1;
3378 /* Does the frontend exist? */
3379 if ( !sc->got_frontend ) {
3380 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
3381 "olcDatabase", STRLENOF( "olcDatabase" )))
3383 if ( strncmp( rs->sr_entry->e_nname.bv_val +
3384 STRLENOF( "olcDatabase" ), "={-1}frontend",
3385 STRLENOF( "={-1}frontend" )))
3389 sc->ca->be = frontendDB;
3390 sc->ca->bi = frontendDB->bd_info;
3391 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
3392 rdn.bv_val = sc->ca->log;
3393 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
3394 "%s=" SLAP_X_ORDERED_FMT "%s",
3395 cfAd_database->ad_cname.bv_val, -1,
3396 sc->ca->bi->bi_type);
3398 sc->frontend = config_build_entry( op, rs,
3399 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
3400 sc->ca->be->be_cf_ocs );
3410 dnParent( &rs->sr_entry->e_nname, &pdn );
3412 /* Does the configDB exist? */
3413 if ( sc->got_frontend && !sc->got_config &&
3414 !strncmp( rs->sr_entry->e_nname.bv_val,
3415 "olcDatabase", STRLENOF( "olcDatabase" )) &&
3416 dn_match( &config_rdn, &pdn ) )
3418 if ( strncmp( rs->sr_entry->e_nname.bv_val +
3419 STRLENOF( "olcDatabase" ), "={0}config",
3420 STRLENOF( "={0}config" )))
3424 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
3425 sc->ca->bi = sc->ca->be->bd_info;
3426 rdn.bv_val = sc->ca->log;
3427 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
3428 "%s=" SLAP_X_ORDERED_FMT "%s",
3429 cfAd_database->ad_cname.bv_val, 0,
3430 sc->ca->bi->bi_type);
3432 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
3433 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
3440 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
3441 if ( rs->sr_err != LDAP_SUCCESS ) {
3442 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
3443 rs->sr_entry->e_name.bv_val, sc->ca->cr_msg, 0 );
3449 /* Configure and read the underlying back-ldif store */
3451 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
3452 CfBackInfo *cfb = be->be_private;
3458 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
3459 Connection conn = {0};
3460 OperationBuffer opbuf;
3462 SlapReply rs = {REP_RESULT};
3463 Filter filter = { LDAP_FILTER_PRESENT };
3464 struct berval filterstr = BER_BVC("(objectclass=*)");
3467 /* Is the config directory available? */
3468 if ( stat( dir, &st ) < 0 ) {
3469 /* No, so don't bother using the backing store.
3470 * All changes will be in-memory only.
3475 cfb->cb_db.bd_info = backend_info( "ldif" );
3476 if ( !cfb->cb_db.bd_info )
3477 return 0; /* FIXME: eventually this will be a fatal error */
3479 if ( backend_db_init( "ldif", &cfb->cb_db, -1, NULL ) == NULL )
3482 cfb->cb_db.be_suffix = be->be_suffix;
3483 cfb->cb_db.be_nsuffix = be->be_nsuffix;
3485 /* The suffix is always "cn=config". The underlying DB's rootdn
3486 * is always the same as the suffix.
3488 cfb->cb_db.be_rootdn = be->be_suffix[0];
3489 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
3491 ber_str2bv( dir, 0, 1, &cfdir );
3496 argv[0] = "directory";
3497 argv[1] = (char *)dir;
3502 c.table = Cft_Database;
3504 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
3508 if ( config_add_vals( ct, &c ))
3511 if ( backend_startup_one( &cfb->cb_db, &c.reply ))
3515 void *thrctx = ldap_pvt_thread_pool_context();
3518 connection_fake_init( &conn, &opbuf, thrctx );
3521 filter.f_desc = slap_schema.si_ad_objectClass;
3523 op->o_tag = LDAP_REQ_SEARCH;
3525 op->ors_filter = &filter;
3526 op->ors_filterstr = filterstr;
3527 op->ors_scope = LDAP_SCOPE_SUBTREE;
3529 op->o_dn = c.be->be_rootdn;
3530 op->o_ndn = c.be->be_rootndn;
3532 op->o_req_dn = be->be_suffix[0];
3533 op->o_req_ndn = be->be_nsuffix[0];
3535 op->ors_tlimit = SLAP_NO_LIMIT;
3536 op->ors_slimit = SLAP_NO_LIMIT;
3538 op->ors_attrs = slap_anlist_all_attributes;
3539 op->ors_attrsonly = 0;
3541 op->o_callback = &cb;
3544 cb.sc_private = ≻
3545 sc.got_frontend = 0;
3550 op->o_bd = &cfb->cb_db;
3552 /* Allow unknown attrs in DNs */
3553 prev_DN_strict = slap_DN_strict;
3556 rc = op->o_bd->be_search( op, &rs );
3558 /* Restore normal DN validation */
3559 slap_DN_strict = prev_DN_strict;
3561 op->o_tag = LDAP_REQ_ADD;
3562 if ( rc == LDAP_SUCCESS && sc.frontend ) {
3563 op->ora_e = sc.frontend;
3564 rc = op->o_bd->be_add( op, &rs );
3566 if ( rc == LDAP_SUCCESS && sc.config ) {
3567 op->ora_e = sc.config;
3568 rc = op->o_bd->be_add( op, &rs );
3570 ldap_pvt_thread_pool_context_reset( thrctx );
3573 /* ITS#4194 - only use if it's present, or we're converting. */
3574 if ( !readit || rc == LDAP_SUCCESS )
3575 cfb->cb_use_ldif = 1;
3581 CfOc_cmp( const void *c1, const void *c2 ) {
3582 const ConfigOCs *co1 = c1;
3583 const ConfigOCs *co2 = c2;
3585 return ber_bvcmp( co1->co_name, co2->co_name );
3589 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
3592 i = init_config_attrs( ct );
3595 /* set up the objectclasses */
3596 i = init_config_ocs( ocs );
3599 for (i=0; ocs[i].co_def; i++) {
3600 if ( ocs[i].co_oc ) {
3601 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
3602 if ( !ocs[i].co_table )
3603 ocs[i].co_table = ct;
3604 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
3611 read_config(const char *fname, const char *dir) {
3614 const char *cfdir, *cfname;
3617 /* Setup the config backend */
3618 be = backend_db_init( "config", NULL, 0, NULL );
3622 cfb = be->be_private;
3623 be->be_dfltaccess = ACL_NONE;
3625 /* If no .conf, or a dir was specified, setup the dir */
3626 if ( !fname || dir ) {
3628 /* If explicitly given, check for existence */
3631 if ( stat( dir, &st ) < 0 ) {
3632 Debug( LDAP_DEBUG_ANY,
3633 "invalid config directory %s, error %d\n",
3639 cfdir = SLAPD_DEFAULT_CONFIGDIR;
3641 /* if fname is defaulted, try reading .d */
3642 rc = config_setup_ldif( be, cfdir, !fname );
3645 /* It may be OK if the base object doesn't exist yet. */
3646 if ( rc != LDAP_NO_SUCH_OBJECT )
3648 /* ITS#4194: But if dir was specified and no fname,
3649 * then we were supposed to read the dir. Unless we're
3650 * trying to slapadd the dir...
3652 if ( dir && !fname ) {
3653 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
3655 /* Assume it's slapadd with a config dir, let it continue */
3657 cfb->cb_got_ldif = 1;
3658 cfb->cb_use_ldif = 1;
3663 /* If we read the config from back-ldif, nothing to do here */
3664 if ( cfb->cb_got_ldif ) {
3673 cfname = SLAPD_DEFAULT_CONFIGFILE;
3675 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
3678 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
3681 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
3682 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
3683 &frontendDB->be_schemadn );
3684 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
3685 if ( rc != LDAP_SUCCESS ) {
3686 Debug(LDAP_DEBUG_ANY, "read_config: "
3687 "unable to normalize default schema DN \"%s\"\n",
3688 frontendDB->be_schemadn.bv_val, 0, 0 );
3689 /* must not happen */
3697 config_back_bind( Operation *op, SlapReply *rs )
3699 if ( be_isroot_pw( op ) ) {
3700 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
3701 /* frontend sends result */
3702 return LDAP_SUCCESS;
3705 rs->sr_err = LDAP_INVALID_CREDENTIALS;
3706 send_ldap_result( op, rs );
3712 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
3716 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
3718 rs->sr_attrs = op->ors_attrs;
3719 rs->sr_entry = ce->ce_entry;
3721 rc = send_search_entry( op, rs );
3722 if ( rc != LDAP_SUCCESS ) {
3726 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
3727 if ( ce->ce_kids ) {
3728 rc = config_send( op, rs, ce->ce_kids, 1 );
3729 if ( rc ) return rc;
3732 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
3733 rc = config_send( op, rs, ce, 0 );
3741 static ConfigTable *
3742 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
3747 for (j=0; j<nocs; j++) {
3748 for (i=0; colst[j]->co_table[i].name; i++)
3749 if ( colst[j]->co_table[i].ad == ad ) {
3750 ca->table = colst[j]->co_type;
3751 return &colst[j]->co_table[i];
3757 /* Sort the attributes of the entry according to the order defined
3758 * in the objectclass, with required attributes occurring before
3759 * allowed attributes. For any attributes with sequencing dependencies
3760 * (e.g., rootDN must be defined after suffix) the objectclass must
3761 * list the attributes in the desired sequence.
3764 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
3766 Attribute *a, *head = NULL, *tail = NULL, **prev;
3769 for (i=0; i<nocs; i++) {
3770 if ( colst[i]->co_oc->soc_required ) {
3771 AttributeType **at = colst[i]->co_oc->soc_required;
3772 for (j=0; at[j]; j++) {
3773 for (a=e->e_attrs, prev=&e->e_attrs; a;
3774 prev = &(*prev)->a_next, a=a->a_next) {
3775 if ( a->a_desc == at[j]->sat_ad ) {
3789 if ( colst[i]->co_oc->soc_allowed ) {
3790 AttributeType **at = colst[i]->co_oc->soc_allowed;
3791 for (j=0; at[j]; j++) {
3792 for (a=e->e_attrs, prev=&e->e_attrs; a;
3793 prev = &(*prev)->a_next, a=a->a_next) {
3794 if ( a->a_desc == at[j]->sat_ad ) {
3810 tail->a_next = e->e_attrs;
3816 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
3818 Attribute *a = NULL;
3819 AttributeDescription *ad;
3829 Modifications *ml = ptr;
3831 vals = ml->sml_values;
3834 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
3835 rc = ordered_value_sort( a, 1 );
3837 snprintf(ca->cr_msg, sizeof( ca->cr_msg ), "ordered_value_sort failed on attr %s\n",
3838 ad->ad_cname.bv_val );
3842 for ( i=0; vals[i].bv_val; i++ ) {
3843 ca->line = vals[i].bv_val;
3844 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
3845 ca->line[0] == '{' ) {
3846 char *idx = strchr( ca->line, '}' );
3847 if ( idx ) ca->line = idx+1;
3849 rc = config_parse_vals( ct, ca, i );
3858 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
3861 struct berval rtype, rval;
3863 AttributeDescription *ad = NULL;
3865 dnRdn( &e->e_name, rdn );
3866 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
3867 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
3868 rtype.bv_val = rdn->bv_val;
3869 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
3872 slap_bv2ad( &rtype, &ad, &rs->sr_text );
3873 a = attr_find( e->e_attrs, ad );
3874 if (!a ) return LDAP_NAMING_VIOLATION;
3881 config_rename_kids( CfEntryInfo *ce )
3884 struct berval rdn, nrdn;
3886 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
3887 struct berval newdn, newndn;
3888 dnRdn ( &ce2->ce_entry->e_name, &rdn );
3889 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
3890 build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
3891 build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
3892 free( ce2->ce_entry->e_name.bv_val );
3893 free( ce2->ce_entry->e_nname.bv_val );
3894 ce2->ce_entry->e_name = newdn;
3895 ce2->ce_entry->e_nname = newndn;
3896 config_rename_kids( ce2 );
3901 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
3902 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
3903 struct berval *nnewrdn, int use_ldif )
3907 struct berval odn, ondn;
3911 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
3912 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
3915 free( a->a_vals[0].bv_val );
3916 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
3917 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
3918 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
3919 strcpy( a->a_vals[0].bv_val, ptr1 );
3921 if ( a->a_nvals != a->a_vals ) {
3922 free( a->a_nvals[0].bv_val );
3923 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
3924 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
3925 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
3926 strcpy( a->a_nvals[0].bv_val, ptr1 );
3929 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
3930 BackendDB *be = op->o_bd;
3931 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
3932 struct berval dn, ndn, xdn, xndn;
3934 op->o_bd = &cfb->cb_db;
3936 /* Save current rootdn; use the underlying DB's rootdn */
3940 xndn = op->o_req_ndn;
3941 op->o_dn = op->o_bd->be_rootdn;
3942 op->o_ndn = op->o_bd->be_rootndn;
3944 op->o_req_ndn = ondn;
3946 scp = op->o_callback;
3947 op->o_callback = ≻
3948 op->orr_newrdn = *newrdn;
3949 op->orr_nnewrdn = *nnewrdn;
3950 op->orr_newSup = NULL;
3951 op->orr_nnewSup = NULL;
3952 op->orr_deleteoldrdn = 1;
3953 op->orr_modlist = NULL;
3954 slap_modrdn2mods( op, rs );
3955 slap_mods_opattrs( op, &op->orr_modlist, 1 );
3956 rc = op->o_bd->be_modrdn( op, rs );
3957 slap_mods_free( op->orr_modlist, 1 );
3960 op->o_callback = scp;
3964 op->o_req_ndn = xndn;
3967 free( ondn.bv_val );
3969 config_rename_kids( e->e_private );
3974 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
3975 Entry *e, int idx, int tailindex, int use_ldif )
3977 struct berval ival, newrdn, nnewrdn;
3980 char ibuf[32], *ptr1, *ptr2 = NULL;
3983 rc = config_rename_attr( rs, e, &rdn, &a );
3984 if ( rc ) return rc;
3987 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
3988 if ( ival.bv_len >= sizeof( ibuf ) ) {
3989 return LDAP_NAMING_VIOLATION;
3992 newrdn.bv_len = rdn.bv_len + ival.bv_len;
3993 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
3996 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
3997 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4000 ptr2 = ber_bvchr( &rdn, '}' );
4004 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
4006 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
4007 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
4008 a->a_desc->ad_cname.bv_len );
4010 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4011 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
4015 /* Do the equivalent of ModRDN */
4016 /* Replace DN / NDN */
4017 newrdn.bv_len = ptr1 - newrdn.bv_val;
4018 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
4019 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
4021 free( nnewrdn.bv_val );
4022 free( newrdn.bv_val );
4027 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
4028 SlapReply *rs, int *renum, int *ibase )
4031 int index = -1, gotindex = 0, nsibs, rc = 0;
4032 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
4033 char *ptr1, *ptr2 = NULL;
4036 if ( renum ) *renum = 0;
4038 /* These entries don't get indexed/renumbered */
4039 if ( ce_type == Cft_Global ) return 0;
4040 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
4042 if ( ce_type == Cft_Module )
4045 /* See if the rdn has an index already */
4046 dnRdn( &e->e_name, &rdn );
4047 if ( ce_type == Cft_Database ) {
4048 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
4049 "frontend", STRLENOF("frontend") ))
4051 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
4052 "config", STRLENOF("config") ))
4055 ptr1 = ber_bvchr( &e->e_name, '{' );
4056 if ( ptr1 && ptr1 < &e->e_name.bv_val[ rdn.bv_len ] ) {
4058 ptr2 = strchr( ptr1, '}' );
4059 if ( !ptr2 || ptr2 > &e->e_name.bv_val[ rdn.bv_len ] )
4060 return LDAP_NAMING_VIOLATION;
4061 if ( ptr2-ptr1 == 1)
4062 return LDAP_NAMING_VIOLATION;
4064 index = strtol( ptr1 + 1, &next, 10 );
4065 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
4066 return LDAP_NAMING_VIOLATION;
4069 /* Special case, we allow -1 for the frontendDB */
4070 if ( index != -1 || !isfrontend )
4071 return LDAP_NAMING_VIOLATION;
4073 if ( isconfig && index != 0 ){
4074 return LDAP_NAMING_VIOLATION;
4078 /* count related kids */
4079 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
4080 if ( ce->ce_type == ce_type ) nsibs++;
4083 /* account for -1 frontend */
4084 if ( ce_type == Cft_Database )
4087 if ( index != nsibs ) {
4089 if ( index < nsibs ) {
4090 if ( tailindex ) return LDAP_NAMING_VIOLATION;
4091 /* Siblings need to be renumbered */
4092 if ( index != -1 || !isfrontend )
4096 /* config DB is always "0" */
4097 if ( isconfig && index == -1 ) {
4100 if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
4104 /* just make index = nsibs */
4106 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
4109 if ( ibase ) *ibase = index;
4110 if ( renum ) *renum = renumber;
4115 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
4120 co.co_name = &oc->soc_cname;
4121 cop = avl_find( CfOcTree, &co, CfOc_cmp );
4125 /* check for duplicates */
4126 for ( i = 0; i < *nocs; i++ ) {
4127 if ( *copp && (*copp)[i] == cop ) {
4133 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
4134 if ( tmp == NULL ) {
4138 (*copp)[*nocs] = cop;
4143 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
4144 if ( count_oc( *sups, copp, nocs ) ) {
4153 count_ocs( Attribute *oc_at, int *nocs )
4156 ConfigOCs **colst = NULL;
4160 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
4164 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
4166 assert( oc != NULL );
4167 if ( count_oc( oc, &colst, nocs ) ) {
4177 cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4179 /* Leftover from RE23. Never parse this entry */
4180 return LDAP_COMPARE_TRUE;
4184 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4188 /* This entry is hardcoded, don't re-parse it */
4189 if ( p->ce_type == Cft_Global ) {
4190 cfn = p->ce_private;
4191 ca->ca_private = cfn;
4192 return LDAP_COMPARE_TRUE;
4194 if ( p->ce_type != Cft_Schema )
4195 return LDAP_CONSTRAINT_VIOLATION;
4197 cfn = ch_calloc( 1, sizeof(ConfigFile) );
4198 ca->ca_private = cfn;
4199 cfo = p->ce_private;
4200 cfn->c_sibs = cfo->c_kids;
4202 return LDAP_SUCCESS;
4206 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4208 if ( p->ce_type != Cft_Global ) {
4209 return LDAP_CONSTRAINT_VIOLATION;
4211 /* config must be {0}, nothing else allowed */
4212 if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
4213 strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
4214 return LDAP_CONSTRAINT_VIOLATION;
4216 ca->be = frontendDB; /* just to get past check_vals */
4217 return LDAP_SUCCESS;
4221 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4223 if ( p->ce_type != Cft_Global ) {
4224 return LDAP_CONSTRAINT_VIOLATION;
4226 return LDAP_SUCCESS;
4230 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4232 if ( p->ce_type != Cft_Global ) {
4233 return LDAP_CONSTRAINT_VIOLATION;
4235 return LDAP_SUCCESS;
4239 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4241 if ( p->ce_type != Cft_Database ) {
4242 return LDAP_CONSTRAINT_VIOLATION;
4245 return LDAP_SUCCESS;
4249 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
4254 AttributeDescription *ad;
4259 if ( cfn->c_cr_head ) {
4260 struct berval bv = BER_BVC("olcDitContentRules");
4262 slap_bv2ad( &bv, &ad, &text );
4263 ct = config_find_table( colst, nocs, ad, ca );
4264 config_del_vals( ct, ca );
4266 if ( cfn->c_oc_head ) {
4267 struct berval bv = BER_BVC("olcObjectClasses");
4269 slap_bv2ad( &bv, &ad, &text );
4270 ct = config_find_table( colst, nocs, ad, ca );
4271 config_del_vals( ct, ca );
4273 if ( cfn->c_at_head ) {
4274 struct berval bv = BER_BVC("olcAttributeTypes");
4276 slap_bv2ad( &bv, &ad, &text );
4277 ct = config_find_table( colst, nocs, ad, ca );
4278 config_del_vals( ct, ca );
4280 if ( cfn->c_syn_head ) {
4281 struct berval bv = BER_BVC("olcLdapSyntaxes");
4283 slap_bv2ad( &bv, &ad, &text );
4284 ct = config_find_table( colst, nocs, ad, ca );
4285 config_del_vals( ct, ca );
4287 if ( cfn->c_om_head ) {
4288 struct berval bv = BER_BVC("olcObjectIdentifier");
4290 slap_bv2ad( &bv, &ad, &text );
4291 ct = config_find_table( colst, nocs, ad, ca );
4292 config_del_vals( ct, ca );
4294 cfo = p->ce_private;
4295 cfo->c_kids = cfn->c_sibs;
4300 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
4302 int rc = LDAP_CONSTRAINT_VIOLATION;
4305 if ( (*cop)->co_ldadd ) {
4306 rc = (*cop)->co_ldadd( last, e, ca );
4307 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4312 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
4313 ConfigOCs co = { 0 };
4315 co.co_name = &(*ocp)->soc_cname;
4316 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
4317 if ( *cop == NULL ) {
4321 rc = config_add_oc( cop, last, e, ca );
4322 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4330 /* Parse an LDAP entry into config directives */
4332 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
4333 int *renum, Operation *op )
4335 CfEntryInfo *ce, *last = NULL;
4336 ConfigOCs co, *coptr, **colst;
4337 Attribute *a, *oc_at, *soc_at;
4338 int i, ibase = -1, nocs, rc = 0;
4341 char *ptr, *log_prefix = op ? op->o_log_prefix : "";
4343 memset( ca, 0, sizeof(ConfigArgs));
4345 /* Make sure parent exists and entry does not. But allow
4346 * Databases and Overlays to be inserted. Don't do any
4347 * auto-renumbering if manageDSAit control is present.
4349 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
4351 if ( ( op && op->o_managedsait ) ||
4352 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
4353 ce->ce_type != Cft_Module ) )
4355 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4356 "DN=\"%s\" already exists\n",
4357 log_prefix, e->e_name.bv_val, 0 );
4358 return LDAP_ALREADY_EXISTS;
4362 dnParent( &e->e_nname, &pdn );
4364 /* If last is NULL, the new entry is the root/suffix entry,
4365 * otherwise last should be the parent.
4367 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
4369 rs->sr_matched = last->ce_entry->e_name.bv_val;
4371 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4372 "DN=\"%s\" not child of DN=\"%s\"\n",
4373 log_prefix, e->e_name.bv_val,
4374 last->ce_entry->e_name.bv_val );
4375 return LDAP_NO_SUCH_OBJECT;
4379 /* No parent, must be root. This will never happen... */
4380 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
4381 return LDAP_NO_SUCH_OBJECT;
4384 if ( last && !access_allowed( op, last->ce_entry,
4385 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
4387 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4388 "DN=\"%s\" no write access to \"children\" of parent\n",
4389 log_prefix, e->e_name.bv_val, 0 );
4390 return LDAP_INSUFFICIENT_ACCESS;
4394 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
4396 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4397 "DN=\"%s\" no objectClass\n",
4398 log_prefix, e->e_name.bv_val, 0 );
4399 return LDAP_OBJECT_CLASS_VIOLATION;
4402 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
4404 ObjectClass *soc = NULL;
4405 char textbuf[ SLAP_TEXT_BUFLEN ];
4406 const char *text = textbuf;
4408 /* FIXME: check result */
4409 rc = structural_class( oc_at->a_nvals, &soc, NULL,
4410 &text, textbuf, sizeof(textbuf), NULL );
4411 if ( rc != LDAP_SUCCESS ) {
4412 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4413 "DN=\"%s\" no structural objectClass (%s)\n",
4414 log_prefix, e->e_name.bv_val, text );
4417 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
4418 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
4419 if ( soc_at == NULL ) {
4420 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4421 "DN=\"%s\" no structural objectClass; "
4422 "unable to merge computed class %s\n",
4423 log_prefix, e->e_name.bv_val,
4424 soc->soc_cname.bv_val );
4425 return LDAP_OBJECT_CLASS_VIOLATION;
4428 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4429 "DN=\"%s\" no structural objectClass; "
4430 "computed objectClass %s merged\n",
4431 log_prefix, e->e_name.bv_val,
4432 soc->soc_cname.bv_val );
4435 /* Fake the coordinates based on whether we're part of an
4436 * LDAP Add or if reading the config dir
4439 ca->fname = "slapd";
4442 ca->fname = cfdir.bv_val;
4447 co.co_name = &soc_at->a_nvals[0];
4448 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
4449 if ( coptr == NULL ) {
4450 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4451 "DN=\"%s\" no structural objectClass in configuration table\n",
4452 log_prefix, e->e_name.bv_val, 0 );
4453 return LDAP_OBJECT_CLASS_VIOLATION;
4456 /* Only the root can be Cft_Global, everything else must
4457 * have a parent. Only limited nesting arrangements are allowed.
4459 rc = LDAP_CONSTRAINT_VIOLATION;
4460 if ( coptr->co_type == Cft_Global && !last ) {
4461 cfn = cfb->cb_config;
4462 ca->ca_private = cfn;
4463 ca->be = frontendDB; /* just to get past check_vals */
4467 colst = count_ocs( oc_at, &nocs );
4469 /* Check whether the Add is allowed by its parent, and do
4470 * any necessary arg setup
4473 rc = config_add_oc( &coptr, last, e, ca );
4474 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
4475 for ( i = 0; i<nocs; i++ ) {
4476 /* Already checked these */
4477 if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
4479 if ( colst[i]->co_ldadd &&
4480 ( rc = colst[i]->co_ldadd( last, e, ca ))
4481 != LDAP_CONSTRAINT_VIOLATION ) {
4487 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
4488 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4489 "DN=\"%s\" no structural objectClass add function\n",
4490 log_prefix, e->e_name.bv_val, 0 );
4491 return LDAP_OBJECT_CLASS_VIOLATION;
4495 /* Add the entry but don't parse it, we already have its contents */
4496 if ( rc == LDAP_COMPARE_TRUE ) {
4501 if ( rc != LDAP_SUCCESS )
4504 /* Parse all the values and check for simple syntax errors before
4505 * performing any set actions.
4507 * If doing an LDAPadd, check for indexed names and any necessary
4508 * renaming/renumbering. Entries that don't need indexed names are
4509 * ignored. Entries that need an indexed name and arrive without one
4510 * are assigned to the end. Entries that arrive with an index may
4511 * cause the following entries to be renumbered/bumped down.
4513 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
4514 * don't allow Adding an entry with an index that's already in use.
4515 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
4517 * These entries can have auto-assigned indexes (appended to the end)
4518 * but only the other types support auto-renumbering of siblings.
4521 rc = check_name_index( last, coptr->co_type, e, rs, renum,
4526 if ( renum && *renum && coptr->co_type != Cft_Database &&
4527 coptr->co_type != Cft_Overlay )
4529 snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
4530 "operation requires sibling renumbering" );
4531 rc = LDAP_UNWILLING_TO_PERFORM;
4536 init_config_argv( ca );
4538 /* Make sure we process attrs in the required order */
4539 sort_attrs( e, colst, nocs );
4541 for ( a = e->e_attrs; a; a = a->a_next ) {
4542 if ( a == oc_at ) continue;
4543 ct = config_find_table( colst, nocs, a->a_desc, ca );
4544 if ( !ct ) continue; /* user data? */
4545 rc = check_vals( ct, ca, a, 1 );
4546 if ( rc ) goto done_noop;
4549 /* Basic syntax checks are OK. Do the actual settings. */
4550 for ( a=e->e_attrs; a; a=a->a_next ) {
4551 if ( a == oc_at ) continue;
4552 ct = config_find_table( colst, nocs, a->a_desc, ca );
4553 if ( !ct ) continue; /* user data? */
4554 for (i=0; a->a_vals[i].bv_val; i++) {
4557 ca->line = a->a_vals[i].bv_val;
4558 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
4559 ptr = strchr( ca->line, '}' );
4561 iptr = strchr( ca->line, '{' );
4565 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
4567 ca->valx = strtol( iptr+1, NULL, 0 );
4572 rc = config_parse_add( ct, ca, i );
4580 /* Newly added databases and overlays need to be started up */
4581 if ( CONFIG_ONLINE_ADD( ca )) {
4582 if ( colst[0]->co_type == Cft_Database ) {
4583 rc = backend_startup_one( ca->be, &ca->reply );
4585 } else if ( colst[0]->co_type == Cft_Overlay ) {
4586 if ( ca->bi->bi_db_open ) {
4587 BackendInfo *bi_orig = ca->be->bd_info;
4588 ca->be->bd_info = ca->bi;
4589 rc = ca->bi->bi_db_open( ca->be, &ca->reply );
4590 ca->be->bd_info = bi_orig;
4592 } else if ( ca->cleanup ) {
4593 rc = ca->cleanup( ca );
4596 if (ca->cr_msg[0] == '\0')
4597 snprintf( ca->cr_msg, sizeof( ca->cr_msg ), "<%s> failed startup", ca->argv[0] );
4599 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
4600 ca->log, ca->cr_msg, ca->argv[1] );
4607 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
4608 ce->ce_parent = last;
4609 ce->ce_entry = entry_dup( e );
4610 ce->ce_entry->e_private = ce;
4611 ce->ce_type = colst[0]->co_type;
4614 ce->ce_private = ca->ca_private;
4615 ca->ca_entry = ce->ce_entry;
4618 } else if ( last->ce_kids ) {
4619 CfEntryInfo *c2, **cprev;
4621 /* Advance to first of this type */
4622 cprev = &last->ce_kids;
4623 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
4624 cprev = &c2->ce_sibs;
4627 /* Account for the (-1) frontendDB entry */
4628 if ( ce->ce_type == Cft_Database ) {
4629 if ( ca->be == frontendDB )
4631 else if ( ibase != -1 )
4636 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
4637 cprev = &c2->ce_sibs;
4643 for ( i=0; i<ibase; i++ ) {
4645 cprev = &c2->ce_sibs;
4648 ce->ce_sibs = *cprev;
4656 if ( (colst[0]->co_type == Cft_Database) && ca->be ) {
4657 if ( ca->be != frontendDB )
4658 backend_destroy_one( ca->be, 1 );
4659 } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) {
4660 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
4661 } else if ( colst[0]->co_type == Cft_Schema ) {
4662 schema_destroy_one( ca, colst, nocs, last );
4667 ch_free( ca->argv );
4668 if ( colst ) ch_free( colst );
4672 #define BIGTMP 10000
4674 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
4675 int base, int rebase, int max, int use_ldif )
4677 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
4678 ConfigType etype = ce->ce_type;
4679 int count = 0, rc = 0;
4681 /* Reverse ce list */
4682 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
4683 if (ce2->ce_type != etype) {
4688 ce2->ce_sibs = cetmp;
4691 if ( max && count >= max ) {
4697 /* Move original to a temp name until increments are done */
4699 ce->ce_entry->e_private = NULL;
4700 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4701 base+BIGTMP, 0, use_ldif );
4702 ce->ce_entry->e_private = ce;
4704 /* start incrementing */
4705 for (ce2=cetmp; ce2; ce2=ce3) {
4707 ce2->ce_sibs = cerem;
4710 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
4711 count+base, 0, use_ldif );
4715 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4716 base, 0, use_ldif );
4721 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
4722 CfEntryInfo *ce2, int old, int use_ldif )
4726 /* Renumber original to a temp value */
4727 ce->ce_entry->e_private = NULL;
4728 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4729 old+BIGTMP, 0, use_ldif );
4730 ce->ce_entry->e_private = ce;
4732 /* start decrementing */
4733 for (; ce2 != ce; ce2=ce2->ce_sibs) {
4734 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
4735 count+old, 0, use_ldif );
4738 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4739 count+old, 0, use_ldif );
4742 /* Parse an LDAP entry into config directives, then store in underlying
4746 config_back_add( Operation *op, SlapReply *rs )
4752 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
4753 NULL, ACL_WADD, NULL )) {
4754 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4759 * Check for attribute ACL
4761 if ( !acl_check_modlist( op, op->ora_e, op->orm_modlist )) {
4762 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4763 rs->sr_text = "no write access to attribute";
4767 cfb = (CfBackInfo *)op->o_bd->be_private;
4769 /* add opattrs for syncprov */
4771 char textbuf[SLAP_TEXT_BUFLEN];
4772 size_t textlen = sizeof textbuf;
4773 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1, NULL,
4774 &rs->sr_text, textbuf, sizeof( textbuf ) );
4775 if ( rs->sr_err != LDAP_SUCCESS )
4777 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
4778 if ( rs->sr_err != LDAP_SUCCESS ) {
4779 Debug( LDAP_DEBUG_TRACE,
4780 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
4781 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
4786 if ( op->o_abandon ) {
4787 rs->sr_err = SLAPD_ABANDON;
4790 ldap_pvt_thread_pool_pause( &connection_pool );
4793 * 1) check for existence of entry
4794 * 2) check for sibling renumbering
4795 * 3) perform internal add
4796 * 4) perform any necessary renumbering
4797 * 5) store entry in underlying database
4799 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
4800 if ( rs->sr_err != LDAP_SUCCESS ) {
4801 rs->sr_text = ca.cr_msg;
4806 CfEntryInfo *ce = ca.ca_entry->e_private;
4807 req_add_s addr = op->oq_add;
4808 op->o_tag = LDAP_REQ_MODRDN;
4809 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
4810 op->o_tag = LDAP_REQ_ADD;
4812 if ( rs->sr_err != LDAP_SUCCESS ) {
4817 if ( cfb->cb_use_ldif ) {
4818 BackendDB *be = op->o_bd;
4819 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4820 struct berval dn, ndn;
4822 op->o_bd = &cfb->cb_db;
4824 /* Save current rootdn; use the underlying DB's rootdn */
4827 op->o_dn = op->o_bd->be_rootdn;
4828 op->o_ndn = op->o_bd->be_rootndn;
4830 scp = op->o_callback;
4831 op->o_callback = ≻
4832 op->o_bd->be_add( op, rs );
4834 op->o_callback = scp;
4840 ldap_pvt_thread_pool_resume( &connection_pool );
4843 send_ldap_result( op, rs );
4844 slap_graduate_commit_csn( op );
4848 typedef struct delrec {
4849 struct delrec *next;
4855 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
4861 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
4862 ca->line[0] == '{' )
4864 char *ptr = strchr( ca->line + 1, '}' );
4868 ca->valx = strtol( ca->line + 1, &next, 0 );
4869 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
4875 rc = config_parse_add( ct, ca, i );
4883 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
4886 int rc = LDAP_UNWILLING_TO_PERFORM;
4888 Entry *e = ce->ce_entry;
4889 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
4894 delrec *dels = NULL, *deltail = NULL;
4896 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
4897 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
4899 colst = count_ocs( oc_at, &nocs );
4901 /* make sure add/del flags are clear; should always be true */
4902 for ( s = save_attrs; s; s = s->a_next ) {
4903 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
4906 e->e_attrs = attrs_dup( e->e_attrs );
4908 init_config_argv( ca );
4911 ca->ca_private = ce->ce_private;
4913 ca->fname = "slapd";
4915 strcpy( ca->log, "back-config" );
4917 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
4918 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
4919 switch (ml->sml_op) {
4920 case LDAP_MOD_DELETE:
4921 case LDAP_MOD_REPLACE: {
4922 BerVarray vals = NULL, nvals = NULL;
4924 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
4926 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot delete %s",
4927 ml->sml_desc->ad_cname.bv_val );
4930 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4931 vals = ml->sml_values;
4932 nvals = ml->sml_nvalues;
4933 ml->sml_values = NULL;
4934 ml->sml_nvalues = NULL;
4936 /* If we're deleting by values, remember the indexes of the
4937 * values we deleted.
4939 if ( ct && ml->sml_values ) {
4941 i = ml->sml_numvals;
4942 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
4953 rc = modify_delete_vindex(e, &ml->sml_mod,
4954 get_permissiveModify(op),
4955 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg), idx );
4956 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4957 ml->sml_values = vals;
4958 ml->sml_nvalues = nvals;
4963 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
4966 case SLAP_MOD_SOFTADD: {
4967 int mop = ml->sml_op;
4969 ml->sml_op = LDAP_MOD_ADD;
4971 if ( ct->arg_type & ARG_NO_INSERT ) {
4972 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
4974 navals = a->a_numvals;
4977 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
4978 if ( ml->sml_values[i].bv_val[0] == '{' &&
4981 char *next, *val = ml->sml_values[i].bv_val + 1;
4984 j = strtol( val, &next, 0 );
4985 if ( next == val || next[ 0 ] != '}' || j < navals ) {
4987 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot insert %s",
4988 ml->sml_desc->ad_cname.bv_val );
4992 rc = check_vals( ct, ca, ml, 0 );
4993 if ( rc ) goto out_noop;
4996 rc = modify_add_values(e, &ml->sml_mod,
4997 get_permissiveModify(op),
4998 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5000 /* If value already exists, show success here
5001 * and ignore this operation down below.
5003 if ( mop == SLAP_MOD_SOFTADD ) {
5004 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
5014 case LDAP_MOD_INCREMENT: /* FIXME */
5019 if(rc != LDAP_SUCCESS) break;
5022 if ( rc == LDAP_SUCCESS) {
5023 /* check that the entry still obeys the schema */
5024 rc = entry_schema_check(op, e, NULL, 0, 0, NULL,
5025 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5027 if ( rc ) goto out_noop;
5029 /* Basic syntax checks are OK. Do the actual settings. */
5030 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5031 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5032 if ( !ct ) continue;
5034 s = attr_find( save_attrs, ml->sml_desc );
5035 a = attr_find( e->e_attrs, ml->sml_desc );
5037 switch (ml->sml_op) {
5038 case LDAP_MOD_DELETE:
5039 case LDAP_MOD_REPLACE: {
5040 BerVarray vals = NULL, nvals = NULL;
5043 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5044 vals = ml->sml_values;
5045 nvals = ml->sml_nvalues;
5046 ml->sml_values = NULL;
5047 ml->sml_nvalues = NULL;
5050 if ( ml->sml_values )
5053 /* If we didn't delete the whole attribute */
5054 if ( ml->sml_values && a ) {
5055 struct berval *mvals;
5058 if ( ml->sml_nvalues )
5059 mvals = ml->sml_nvalues;
5061 mvals = ml->sml_values;
5063 /* use the indexes we saved up above */
5064 for (i=0; i < d->nidx; i++) {
5065 struct berval bv = *mvals++;
5066 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
5067 bv.bv_val[0] == '{' ) {
5068 ptr = strchr( bv.bv_val, '}' ) + 1;
5069 bv.bv_len -= ptr - bv.bv_val;
5072 ca->line = bv.bv_val;
5073 ca->valx = d->idx[i];
5074 rc = config_del_vals( ct, ca );
5075 if ( rc != LDAP_SUCCESS ) break;
5077 s->a_flags |= SLAP_ATTR_IXDEL;
5078 for (j=i+1; j < d->nidx; j++)
5079 if ( d->idx[j] >d->idx[i] )
5085 rc = config_del_vals( ct, ca );
5086 if ( rc ) rc = LDAP_OTHER;
5088 s->a_flags |= SLAP_ATTR_IXDEL;
5090 if ( ml->sml_values ) {
5095 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5096 ml->sml_values = vals;
5097 ml->sml_nvalues = nvals;
5099 if ( !vals || rc != LDAP_SUCCESS )
5102 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5105 for (i=0; ml->sml_values[i].bv_val; i++) {
5106 ca->line = ml->sml_values[i].bv_val;
5108 rc = config_modify_add( ct, ca, ml->sml_desc, i );
5111 a->a_flags |= SLAP_ATTR_IXADD;
5118 /* Undo for a failed operation */
5119 if ( rc != LDAP_SUCCESS ) {
5120 ConfigReply msg = ca->reply;
5121 for ( s = save_attrs; s; s = s->a_next ) {
5122 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
5123 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5124 ct = config_find_table( colst, nocs, s->a_desc, ca );
5125 a = attr_find( e->e_attrs, s->a_desc );
5127 /* clear the flag so the add check below will skip it */
5128 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5131 config_del_vals( ct, ca );
5133 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5134 ca->line = s->a_vals[i].bv_val;
5136 config_modify_add( ct, ca, s->a_desc, i );
5140 for ( a = e->e_attrs; a; a = a->a_next ) {
5141 if ( a->a_flags & SLAP_ATTR_IXADD ) {
5142 ct = config_find_table( colst, nocs, a->a_desc, ca );
5145 config_del_vals( ct, ca );
5146 s = attr_find( save_attrs, a->a_desc );
5148 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5149 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5150 ca->line = s->a_vals[i].bv_val;
5152 config_modify_add( ct, ca, s->a_desc, i );
5163 if ( rc == LDAP_SUCCESS ) {
5164 attrs_free( save_attrs );
5166 attrs_free( e->e_attrs );
5167 e->e_attrs = save_attrs;
5169 ch_free( ca->argv );
5170 if ( colst ) ch_free( colst );
5172 deltail = dels->next;
5181 config_back_modify( Operation *op, SlapReply *rs )
5184 CfEntryInfo *ce, *last;
5186 ConfigArgs ca = {0};
5189 AttributeDescription *rad = NULL;
5192 cfb = (CfBackInfo *)op->o_bd->be_private;
5194 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5197 rs->sr_matched = last->ce_entry->e_name.bv_val;
5198 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5202 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
5203 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5207 /* Get type of RDN */
5208 rdn = ce->ce_entry->e_nname;
5209 ptr = strchr( rdn.bv_val, '=' );
5210 rdn.bv_len = ptr - rdn.bv_val;
5211 slap_bv2ad( &rdn, &rad, &rs->sr_text );
5213 /* Some basic validation... */
5214 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5215 /* Don't allow Modify of RDN; must use ModRdn for that. */
5216 if ( ml->sml_desc == rad ) {
5217 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
5218 rs->sr_text = "Use modrdn to change the entry name";
5221 /* Internal update of contextCSN? */
5222 if ( ml->sml_desc == slap_schema.si_ad_contextCSN && op->o_conn->c_conn_idx == -1 ) {
5228 slap_mods_opattrs( op, &op->orm_modlist, 1 );
5231 if ( op->o_abandon ) {
5232 rs->sr_err = SLAPD_ABANDON;
5235 ldap_pvt_thread_pool_pause( &connection_pool );
5239 * 1) perform the Modify on the cached Entry.
5240 * 2) verify that the Entry still satisfies the schema.
5241 * 3) perform the individual config operations.
5242 * 4) store Modified entry in underlying LDIF backend.
5244 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
5246 rs->sr_text = ca.cr_msg;
5247 } else if ( cfb->cb_use_ldif ) {
5248 BackendDB *be = op->o_bd;
5249 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5250 struct berval dn, ndn;
5252 op->o_bd = &cfb->cb_db;
5256 op->o_dn = op->o_bd->be_rootdn;
5257 op->o_ndn = op->o_bd->be_rootndn;
5259 scp = op->o_callback;
5260 op->o_callback = ≻
5261 op->o_bd->be_modify( op, rs );
5263 op->o_callback = scp;
5269 ldap_pvt_thread_pool_resume( &connection_pool );
5271 send_ldap_result( op, rs );
5272 slap_graduate_commit_csn( op );
5277 config_back_modrdn( Operation *op, SlapReply *rs )
5280 CfEntryInfo *ce, *last;
5284 cfb = (CfBackInfo *)op->o_bd->be_private;
5286 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5289 rs->sr_matched = last->ce_entry->e_name.bv_val;
5290 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5293 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
5294 NULL, ACL_WRITE, NULL )) {
5295 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5299 if ( ce->ce_parent )
5300 parent = ce->ce_parent->ce_entry;
5302 parent = (Entry *)&slap_entry_root;
5303 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
5304 NULL, ACL_WRITE, NULL )) {
5305 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5310 /* We don't allow moving objects to new parents.
5311 * Generally we only allow reordering a set of ordered entries.
5313 if ( op->orr_newSup ) {
5314 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5318 /* If newRDN == oldRDN, quietly succeed */
5319 dnRdn( &op->o_req_ndn, &rdn );
5320 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
5321 rs->sr_err = LDAP_SUCCESS;
5325 /* Current behavior, subject to change as needed:
5327 * For backends and overlays, we only allow renumbering.
5328 * For schema, we allow renaming with the same number.
5329 * Otherwise, the op is not allowed.
5332 if ( ce->ce_type == Cft_Schema ) {
5336 /* Can't alter the main cn=schema entry */
5337 if ( ce->ce_parent->ce_type == Cft_Global ) {
5338 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5339 rs->sr_text = "renaming not allowed for this entry";
5343 /* We could support this later if desired */
5344 ptr1 = ber_bvchr( &rdn, '}' );
5345 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5346 len = ptr1 - rdn.bv_val;
5347 if ( len != ptr2 - op->orr_newrdn.bv_val ||
5348 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
5349 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5350 rs->sr_text = "schema reordering not supported";
5353 } else if ( ce->ce_type == Cft_Database ||
5354 ce->ce_type == Cft_Overlay ) {
5355 char *ptr1, *ptr2, *iptr1, *iptr2;
5358 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
5359 if ( *iptr2 != '{' ) {
5360 rs->sr_err = LDAP_NAMING_VIOLATION;
5361 rs->sr_text = "new ordering index is required";
5365 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
5366 ptr1 = ber_bvchr( &rdn, '}' );
5367 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5369 rs->sr_err = LDAP_NAMING_VIOLATION;
5370 rs->sr_text = "new ordering index is required";
5374 len1 = ptr1 - rdn.bv_val;
5375 len2 = ptr2 - op->orr_newrdn.bv_val;
5377 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
5378 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
5379 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5380 rs->sr_text = "changing database/overlay type not allowed";
5383 ixold = strtol( iptr1, NULL, 0 );
5384 ixnew = strtol( iptr2, &ptr1, 0 );
5385 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
5386 rs->sr_err = LDAP_NAMING_VIOLATION;
5389 /* config DB is always 0, cannot be changed */
5390 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
5391 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
5395 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5396 rs->sr_text = "renaming not supported for this entry";
5400 if ( op->o_abandon ) {
5401 rs->sr_err = SLAPD_ABANDON;
5404 ldap_pvt_thread_pool_pause( &connection_pool );
5406 if ( ce->ce_type == Cft_Schema ) {
5407 req_modrdn_s modr = op->oq_modrdn;
5410 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
5411 if ( rs->sr_err == LDAP_SUCCESS ) {
5412 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
5413 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
5416 op->oq_modrdn = modr;
5418 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
5419 req_modrdn_s modr = op->oq_modrdn;
5422 /* Advance to first of this type */
5423 cprev = &ce->ce_parent->ce_kids;
5424 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
5425 cprev = &ce2->ce_sibs;
5428 /* Skip the -1 entry */
5429 if ( ce->ce_type == Cft_Database ) {
5430 cprev = &ce2->ce_sibs;
5436 /* Remove from old slot */
5437 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
5438 cprev = &ce2->ce_sibs;
5439 *cprev = ce->ce_sibs;
5440 ceold = ce->ce_sibs;
5442 /* Insert into new slot */
5444 for ( i=0; i<ixnew; i++ ) {
5448 cprev = &ce2->ce_sibs;
5450 ce->ce_sibs = *cprev;
5455 /* NOTE: These should be encoded in the OC tables, not inline here */
5456 if ( ce->ce_type == Cft_Database )
5457 backend_db_move( ce->ce_be, ixnew );
5458 else if ( ce->ce_type == Cft_Overlay )
5459 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
5461 if ( ixold < ixnew ) {
5462 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
5465 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
5466 ixold - ixnew, cfb->cb_use_ldif );
5468 op->oq_modrdn = modr;
5471 ldap_pvt_thread_pool_resume( &connection_pool );
5473 send_ldap_result( op, rs );
5478 config_back_delete( Operation *op, SlapReply *rs )
5480 #ifdef SLAP_CONFIG_DELETE
5482 CfEntryInfo *ce, *last, *ce2;
5484 cfb = (CfBackInfo *)op->o_bd->be_private;
5486 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5489 rs->sr_matched = last->ce_entry->e_name.bv_val;
5490 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5491 } else if ( ce->ce_kids ) {
5492 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5493 } else if ( op->o_abandon ) {
5494 rs->sr_err = SLAPD_ABANDON;
5495 } else if ( ce->ce_type == Cft_Overlay ){
5499 ldap_pvt_thread_pool_pause( &connection_pool );
5501 overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
5503 /* remove CfEntryInfo from the siblings list */
5504 if ( ce->ce_parent->ce_kids == ce ) {
5505 ce->ce_parent->ce_kids = ce->ce_sibs;
5507 for ( ce2 = ce->ce_parent->ce_kids ; ce2; ce2 = ce2->ce_sibs ) {
5508 if ( ce2->ce_sibs == ce ) {
5509 ce2->ce_sibs = ce->ce_sibs;
5515 /* remove from underlying database */
5516 if ( cfb->cb_use_ldif ) {
5517 BackendDB *be = op->o_bd;
5518 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5519 struct berval dn, ndn, req_dn, req_ndn;
5521 op->o_bd = &cfb->cb_db;
5525 req_dn = op->o_req_dn;
5526 req_ndn = op->o_req_ndn;
5528 op->o_dn = op->o_bd->be_rootdn;
5529 op->o_ndn = op->o_bd->be_rootndn;
5530 op->o_req_dn = ce->ce_entry->e_name;
5531 op->o_req_ndn = ce->ce_entry->e_nname;
5533 scp = op->o_callback;
5534 op->o_callback = ≻
5535 op->o_bd->be_delete( op, rs );
5537 op->o_callback = scp;
5540 op->o_req_dn = req_dn;
5541 op->o_req_ndn = req_ndn;
5544 /* renumber siblings */
5545 iptr = ber_bvchr( &op->o_req_ndn, '{' ) + 1;
5546 ixold = strtol( iptr, NULL, 0 );
5547 for (ce2 = ce->ce_sibs, count=0; ce2; ce2=ce2->ce_sibs) {
5548 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5549 count+ixold, 0, cfb->cb_use_ldif );
5553 ce->ce_entry->e_private=NULL;
5554 entry_free(ce->ce_entry);
5556 ldap_pvt_thread_pool_resume( &connection_pool );
5558 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5561 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5562 #endif /* SLAP_CONFIG_DELETE */
5563 send_ldap_result( op, rs );
5568 config_back_search( Operation *op, SlapReply *rs )
5571 CfEntryInfo *ce, *last;
5574 cfb = (CfBackInfo *)op->o_bd->be_private;
5576 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5579 rs->sr_matched = last->ce_entry->e_name.bv_val;
5580 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5583 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
5584 ACL_SEARCH, NULL, &mask ))
5586 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
5587 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5589 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5593 switch ( op->ors_scope ) {
5594 case LDAP_SCOPE_BASE:
5595 case LDAP_SCOPE_SUBTREE:
5596 rs->sr_err = config_send( op, rs, ce, 0 );
5599 case LDAP_SCOPE_ONELEVEL:
5600 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
5601 rs->sr_err = config_send( op, rs, ce, 1 );
5610 send_ldap_result( op, rs );
5614 /* no-op, we never free entries */
5615 int config_entry_release(
5620 if ( !e->e_private ) {
5623 return LDAP_SUCCESS;
5626 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
5628 int config_back_entry_get(
5632 AttributeDescription *at,
5637 CfEntryInfo *ce, *last;
5638 int rc = LDAP_NO_SUCH_OBJECT;
5640 cfb = (CfBackInfo *)op->o_bd->be_private;
5642 ce = config_find_base( cfb->cb_root, ndn, &last );
5644 *ent = ce->ce_entry;
5647 if ( oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
5648 rc = LDAP_NO_SUCH_ATTRIBUTE;
5658 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
5659 ConfigTable *ct, ConfigArgs *c )
5663 for (; at && *at; at++) {
5664 /* Skip the naming attr */
5665 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
5667 for (i=0;ct[i].name;i++) {
5668 if (ct[i].ad == (*at)->sat_ad) {
5669 rc = config_get_vals(&ct[i], c);
5670 /* NOTE: tolerate that config_get_vals()
5671 * returns success with no values */
5672 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
5673 if ( c->rvalue_nvals )
5674 rc = attr_merge(e, ct[i].ad, c->rvalue_vals,
5677 slap_syntax_validate_func *validate =
5678 ct[i].ad->ad_type->sat_syntax->ssyn_validate;
5681 for ( j=0; c->rvalue_vals[j].bv_val; j++ ) {
5682 rc = ordered_value_validate( ct[i].ad,
5683 &c->rvalue_vals[j], LDAP_MOD_ADD );
5685 Debug( LDAP_DEBUG_ANY,
5686 "config_build_attrs: error %d on %s value #%d\n",
5687 rc, ct[i].ad->ad_cname.bv_val, j );
5693 rc = attr_merge_normalize(e, ct[i].ad,
5694 c->rvalue_vals, NULL);
5696 ber_bvarray_free( c->rvalue_nvals );
5697 ber_bvarray_free( c->rvalue_vals );
5699 Debug( LDAP_DEBUG_ANY,
5700 "config_build_attrs: error %d on %s\n",
5701 rc, ct[i].ad->ad_cname.bv_val, 0 );
5713 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
5714 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
5716 Entry *e = entry_alloc();
5717 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5719 struct berval ad_name;
5720 AttributeDescription *ad = NULL;
5723 const char *text = "";
5727 CfEntryInfo *ceprev = NULL;
5729 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
5732 ce->ce_type = main->co_type;
5733 ce->ce_parent = parent;
5735 pdn = parent->ce_entry->e_nname;
5736 if ( parent->ce_kids && parent->ce_kids->ce_type <= ce->ce_type )
5737 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
5738 ceprev->ce_type <= ce->ce_type;
5739 ceprev = ceprev->ce_sibs );
5744 ce->ce_private = c->ca_private;
5748 build_new_dn( &e->e_name, &pdn, rdn, NULL );
5749 ber_dupbv( &e->e_nname, &e->e_name );
5751 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
5752 main->co_name, NULL );
5754 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
5755 extra->co_name, NULL );
5756 ptr = strchr(rdn->bv_val, '=');
5757 ad_name.bv_val = rdn->bv_val;
5758 ad_name.bv_len = ptr - rdn->bv_val;
5759 rc = slap_bv2ad( &ad_name, &ad, &text );
5764 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
5765 attr_merge_normalize_one(e, ad, &val, NULL );
5768 c->table = main->co_type;
5769 if ( oc->soc_required ) {
5770 rc = config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
5771 if ( rc ) goto fail;
5774 if ( oc->soc_allowed ) {
5775 rc = config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
5776 if ( rc ) goto fail;
5781 c->table = extra->co_type;
5782 if ( oc->soc_required ) {
5783 rc = config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
5784 if ( rc ) goto fail;
5787 if ( oc->soc_allowed ) {
5788 rc = config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
5789 if ( rc ) goto fail;
5793 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5794 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->cr_msg,
5795 sizeof(c->cr_msg), op ? op->o_tmpmemctx : NULL );
5796 if ( rc != LDAP_SUCCESS ) {
5798 Debug( LDAP_DEBUG_ANY,
5799 "config_build_entry: build \"%s\" failed: \"%s\"\n",
5800 rdn->bv_val, text, 0);
5803 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
5806 op->ora_modlist = NULL;
5807 slap_add_opattrs( op, NULL, NULL, 0, 0 );
5808 if ( !op->o_noop ) {
5809 op->o_bd->be_add( op, rs );
5810 if ( ( rs->sr_err != LDAP_SUCCESS )
5811 && (rs->sr_err != LDAP_ALREADY_EXISTS) ) {
5817 ce->ce_sibs = ceprev->ce_sibs;
5818 ceprev->ce_sibs = ce;
5819 } else if ( parent ) {
5820 ce->ce_sibs = parent->ce_kids;
5821 parent->ce_kids = ce;
5828 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
5829 Operation *op, SlapReply *rs )
5832 ConfigFile *cf = c->ca_private;
5834 struct berval bv, rdn;
5836 for (; cf; cf=cf->c_sibs, c->depth++) {
5837 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
5838 !cf->c_om_head && !cf->c_syn_head ) continue;
5839 c->value_dn.bv_val = c->log;
5840 LUTIL_SLASHPATH( cf->c_file.bv_val );
5841 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
5846 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
5848 ptr = strchr( bv.bv_val, '.' );
5850 bv.bv_len = ptr - bv.bv_val;
5851 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
5852 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
5853 /* FIXME: how can indicate error? */
5856 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
5858 c->value_dn.bv_len += bv.bv_len;
5859 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
5863 e = config_build_entry( op, rs, ceparent, c, &rdn,
5864 &CFOC_SCHEMA, NULL );
5867 } else if ( e && cf->c_kids ) {
5868 c->ca_private = cf->c_kids;
5869 config_build_schema_inc( c, e->e_private, op, rs );
5875 #ifdef SLAPD_MODULES
5878 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
5879 Operation *op, SlapReply *rs )
5884 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
5885 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
5887 c->value_dn.bv_val = c->log;
5888 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
5889 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
5890 /* FIXME: how can indicate error? */
5894 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
5903 config_check_schema(Operation *op, CfBackInfo *cfb)
5905 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
5907 CfEntryInfo *ce, *last;
5910 /* If there's no root entry, we must be in the midst of converting */
5911 if ( !cfb->cb_root )
5914 /* Make sure the main schema entry exists */
5915 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
5922 /* Make sure it's up to date */
5923 if ( cf_om_tail != om_sys_tail ) {
5924 a = attr_find( e->e_attrs, cfAd_om );
5926 if ( a->a_nvals != a->a_vals )
5927 ber_bvarray_free( a->a_nvals );
5928 ber_bvarray_free( a->a_vals );
5933 oidm_unparse( &bv, NULL, NULL, 1 );
5934 attr_merge_normalize( e, cfAd_om, bv, NULL );
5935 ber_bvarray_free( bv );
5936 cf_om_tail = om_sys_tail;
5938 if ( cf_at_tail != at_sys_tail ) {
5939 a = attr_find( e->e_attrs, cfAd_attr );
5941 if ( a->a_nvals != a->a_vals )
5942 ber_bvarray_free( a->a_nvals );
5943 ber_bvarray_free( a->a_vals );
5948 at_unparse( &bv, NULL, NULL, 1 );
5949 attr_merge_normalize( e, cfAd_attr, bv, NULL );
5950 ber_bvarray_free( bv );
5951 cf_at_tail = at_sys_tail;
5953 if ( cf_oc_tail != oc_sys_tail ) {
5954 a = attr_find( e->e_attrs, cfAd_oc );
5956 if ( a->a_nvals != a->a_vals )
5957 ber_bvarray_free( a->a_nvals );
5958 ber_bvarray_free( a->a_vals );
5963 oc_unparse( &bv, NULL, NULL, 1 );
5964 attr_merge_normalize( e, cfAd_oc, bv, NULL );
5965 ber_bvarray_free( bv );
5966 cf_oc_tail = oc_sys_tail;
5968 if ( cf_syn_tail != syn_sys_tail ) {
5969 a = attr_find( e->e_attrs, cfAd_syntax );
5971 if ( a->a_nvals != a->a_vals )
5972 ber_bvarray_free( a->a_nvals );
5973 ber_bvarray_free( a->a_vals );
5978 syn_unparse( &bv, NULL, NULL, 1 );
5979 attr_merge_normalize( e, cfAd_syntax, bv, NULL );
5980 ber_bvarray_free( bv );
5981 cf_syn_tail = syn_sys_tail;
5984 SlapReply rs = {REP_RESULT};
5985 c.ca_private = NULL;
5986 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
5987 &CFOC_SCHEMA, NULL );
5992 ce->ce_private = cfb->cb_config;
5993 cf_at_tail = at_sys_tail;
5994 cf_oc_tail = oc_sys_tail;
5995 cf_om_tail = om_sys_tail;
5996 cf_syn_tail = syn_sys_tail;
6001 static const char *defacl[] = {
6002 NULL, "to", "*", "by", "*", "none", NULL
6006 config_back_db_open( BackendDB *be, ConfigReply *cr )
6008 CfBackInfo *cfb = be->be_private;
6011 CfEntryInfo *ce, *ceparent;
6015 Connection conn = {0};
6016 OperationBuffer opbuf;
6018 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
6019 SlapReply rs = {REP_RESULT};
6020 void *thrctx = NULL;
6022 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
6024 /* If we have no explicitly configured ACLs, don't just use
6025 * the global ACLs. Explicitly deny access to everything.
6027 if ( !be->be_acl ) {
6028 parse_acl(be, "config_back_db_open", 0, 6, (char **)defacl, 0 );
6031 thrctx = ldap_pvt_thread_pool_context();
6032 connection_fake_init( &conn, &opbuf, thrctx );
6035 op->o_tag = LDAP_REQ_ADD;
6036 op->o_callback = &cb;
6037 op->o_bd = &cfb->cb_db;
6038 op->o_dn = op->o_bd->be_rootdn;
6039 op->o_ndn = op->o_bd->be_rootndn;
6041 if ( !cfb->cb_use_ldif ) {
6045 /* If we read the config from back-ldif, do some quick sanity checks */
6046 if ( cfb->cb_got_ldif ) {
6047 return config_check_schema( op, cfb );
6050 /* create root of tree */
6052 c.ca_private = cfb->cb_config;
6054 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
6064 #ifdef SLAPD_MODULES
6065 /* Create Module nodes... */
6066 if ( modpaths.mp_loads ) {
6067 if ( config_build_modules( &c, ceparent, op, &rs ) ){
6073 /* Create schema nodes... cn=schema will contain the hardcoded core
6074 * schema, read-only. Child objects will contain runtime loaded schema
6078 c.ca_private = NULL;
6079 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
6084 ce->ce_private = cfb->cb_config;
6085 cf_at_tail = at_sys_tail;
6086 cf_oc_tail = oc_sys_tail;
6087 cf_om_tail = om_sys_tail;
6088 cf_syn_tail = syn_sys_tail;
6090 /* Create schema nodes for included schema... */
6091 if ( cfb->cb_config->c_kids ) {
6093 c.ca_private = cfb->cb_config->c_kids;
6094 if (config_build_schema_inc( &c, ce, op, &rs )) {
6099 /* Create backend nodes. Skip if they don't provide a cf_table.
6100 * There usually aren't any of these.
6104 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
6105 if (!bi->bi_cf_ocs) {
6106 /* If it only supports the old config mech, complain. */
6107 if ( bi->bi_config ) {
6108 Debug( LDAP_DEBUG_ANY,
6109 "WARNING: No dynamic config support for backend %s.\n",
6110 bi->bi_type, 0, 0 );
6115 if (!bi->bi_private) continue;
6118 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6119 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
6120 if ( rdn.bv_len >= sizeof( c.log ) ) {
6121 /* FIXME: holler ... */ ;
6124 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
6131 /* Create database nodes... */
6132 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
6133 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
6134 for ( i = -1, be = frontendDB ; be;
6135 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
6136 slap_overinfo *oi = NULL;
6138 if ( overlay_is_over( be )) {
6139 oi = be->bd_info->bi_private;
6145 /* If this backend supports the old config mechanism, but not
6146 * the new mech, complain.
6148 if ( !be->be_cf_ocs && bi->bi_db_config ) {
6149 Debug( LDAP_DEBUG_ANY,
6150 "WARNING: No dynamic config support for database %s.\n",
6151 bi->bi_type, 0, 0 );
6155 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6156 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
6158 if ( rdn.bv_len >= sizeof( c.log ) ) {
6159 /* FIXME: holler ... */ ;
6163 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
6169 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd )
6170 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
6171 /* Iterate through overlays */
6176 voidList *vl, *v0 = NULL;
6178 /* overlays are in LIFO order, must reverse stack */
6179 for (on=oi->oi_list; on; on=on->on_next) {
6180 vl = ch_malloc( sizeof( voidList ));
6185 for (j=0; vl; j++,vl=v0) {
6189 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
6190 Debug( LDAP_DEBUG_ANY,
6191 "WARNING: No dynamic config support for overlay %s.\n",
6192 on->on_bi.bi_type, 0, 0 );
6196 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6197 "%s=" SLAP_X_ORDERED_FMT "%s",
6198 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
6199 if ( rdn.bv_len >= sizeof( c.log ) ) {
6200 /* FIXME: holler ... */ ;
6204 oe = config_build_entry( op, &rs, ce, &c, &rdn,
6205 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
6209 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd )
6210 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
6215 ldap_pvt_thread_pool_context_reset( thrctx );
6217 if ( unsupp && cfb->cb_use_ldif ) {
6218 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
6219 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
6226 cfb_free_cffile( ConfigFile *cf )
6230 for (; cf; cf=next) {
6233 cfb_free_cffile( cf->c_kids );
6234 ch_free( cf->c_file.bv_val );
6235 ber_bvarray_free( cf->c_dseFiles );
6241 cfb_free_entries( CfEntryInfo *ce )
6245 for (; ce; ce=next) {
6248 cfb_free_entries( ce->ce_kids );
6249 ce->ce_entry->e_private = NULL;
6250 entry_free( ce->ce_entry );
6256 config_back_db_close( BackendDB *be, ConfigReply *cr )
6258 CfBackInfo *cfb = be->be_private;
6260 cfb_free_entries( cfb->cb_root );
6261 cfb->cb_root = NULL;
6263 if ( cfb->cb_db.bd_info ) {
6264 backend_shutdown( &cfb->cb_db );
6271 config_back_db_destroy( BackendDB *be, ConfigReply *cr )
6273 CfBackInfo *cfb = be->be_private;
6275 cfb_free_cffile( cfb->cb_config );
6277 ch_free( cfdir.bv_val );
6279 avl_free( CfOcTree, NULL );
6281 if ( cfb->cb_db.bd_info ) {
6282 cfb->cb_db.be_suffix = NULL;
6283 cfb->cb_db.be_nsuffix = NULL;
6284 BER_BVZERO( &cfb->cb_db.be_rootdn );
6285 BER_BVZERO( &cfb->cb_db.be_rootndn );
6287 backend_destroy_one( &cfb->cb_db, 0 );
6296 config_back_db_init( BackendDB *be, ConfigReply* cr )
6302 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
6303 cfn = cfb->cb_config;
6304 be->be_private = cfb;
6306 ber_dupbv( &be->be_rootdn, &config_rdn );
6307 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
6308 ber_dupbv( &dn, &be->be_rootdn );
6309 ber_bvarray_add( &be->be_suffix, &dn );
6310 ber_dupbv( &dn, &be->be_rootdn );
6311 ber_bvarray_add( &be->be_nsuffix, &dn );
6313 /* Hide from namingContexts */
6314 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
6316 /* Check ACLs on content of Adds by default */
6317 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_ACL_ADD;
6323 config_back_destroy( BackendInfo *bi )
6325 ldif_must_b64_encode_release();
6330 config_tool_entry_open( BackendDB *be, int mode )
6332 CfBackInfo *cfb = be->be_private;
6333 BackendInfo *bi = cfb->cb_db.bd_info;
6335 if ( bi && bi->bi_tool_entry_open )
6336 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
6343 config_tool_entry_close( BackendDB *be )
6345 CfBackInfo *cfb = be->be_private;
6346 BackendInfo *bi = cfb->cb_db.bd_info;
6348 if ( bi && bi->bi_tool_entry_close )
6349 return bi->bi_tool_entry_close( &cfb->cb_db );
6355 config_tool_entry_first( BackendDB *be )
6357 CfBackInfo *cfb = be->be_private;
6358 BackendInfo *bi = cfb->cb_db.bd_info;
6360 if ( bi && bi->bi_tool_entry_first )
6361 return bi->bi_tool_entry_first( &cfb->cb_db );
6367 config_tool_entry_next( BackendDB *be )
6369 CfBackInfo *cfb = be->be_private;
6370 BackendInfo *bi = cfb->cb_db.bd_info;
6372 if ( bi && bi->bi_tool_entry_next )
6373 return bi->bi_tool_entry_next( &cfb->cb_db );
6379 config_tool_entry_get( BackendDB *be, ID id )
6381 CfBackInfo *cfb = be->be_private;
6382 BackendInfo *bi = cfb->cb_db.bd_info;
6384 if ( bi && bi->bi_tool_entry_get )
6385 return bi->bi_tool_entry_get( &cfb->cb_db, id );
6390 static int entry_put_got_frontend=0;
6391 static int entry_put_got_config=0;
6393 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
6395 CfBackInfo *cfb = be->be_private;
6396 BackendInfo *bi = cfb->cb_db.bd_info;
6398 struct berval rdn, vals[ 2 ];
6400 OperationBuffer opbuf;
6402 Connection conn = {0};
6403 Operation *op = NULL;
6407 /* Create entry for frontend database if it does not exist already */
6408 if ( !entry_put_got_frontend ) {
6409 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
6410 STRLENOF( "olcDatabase" ))) {
6411 if ( strncmp( e->e_nname.bv_val +
6412 STRLENOF( "olcDatabase" ), "={-1}frontend",
6413 STRLENOF( "={-1}frontend" )) &&
6414 strncmp( e->e_nname.bv_val +
6415 STRLENOF( "olcDatabase" ), "=frontend",
6416 STRLENOF( "=frontend" ))) {
6418 vals[1].bv_val = NULL;
6419 memset( &ca, 0, sizeof(ConfigArgs));
6421 ca.bi = frontendDB->bd_info;
6422 ca.be->be_cf_ocs = &CFOC_FRONTEND;
6423 rdn.bv_val = ca.log;
6424 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
6425 "%s=" SLAP_X_ORDERED_FMT "%s",
6426 cfAd_database->ad_cname.bv_val, -1,
6428 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
6429 &CFOC_DATABASE, ca.be->be_cf_ocs );
6430 thrctx = ldap_pvt_thread_pool_context();
6431 connection_fake_init2( &conn, &opbuf, thrctx,0 );
6433 op->o_bd = &cfb->cb_db;
6434 op->o_tag = LDAP_REQ_ADD;
6436 op->o_dn = be->be_rootdn;
6437 op->o_ndn = be->be_rootndn;
6438 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
6439 if ( rc != LDAP_SUCCESS ) {
6440 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
6441 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
6445 if ( ce && bi && bi->bi_tool_entry_put &&
6446 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
6447 entry_put_got_frontend++;
6449 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
6450 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
6454 entry_put_got_frontend++;
6459 /* Create entry for config database if it does not exist already */
6460 if ( !entry_put_got_config && !isFrontend ) {
6461 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
6462 STRLENOF( "olcDatabase" ))) {
6463 if ( strncmp( e->e_nname.bv_val +
6464 STRLENOF( "olcDatabase" ), "={0}config",
6465 STRLENOF( "={0}config" )) &&
6466 strncmp( e->e_nname.bv_val +
6467 STRLENOF( "olcDatabase" ), "=config",
6468 STRLENOF( "=config" )) ) {
6470 vals[1].bv_val = NULL;
6471 memset( &ca, 0, sizeof(ConfigArgs));
6472 ca.be = LDAP_STAILQ_FIRST( &backendDB );
6473 ca.bi = ca.be->bd_info;
6474 rdn.bv_val = ca.log;
6475 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
6476 "%s=" SLAP_X_ORDERED_FMT "%s",
6477 cfAd_database->ad_cname.bv_val, 0,
6479 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
6482 thrctx = ldap_pvt_thread_pool_context();
6483 connection_fake_init2( &conn, &opbuf, thrctx,0 );
6485 op->o_bd = &cfb->cb_db;
6486 op->o_tag = LDAP_REQ_ADD;
6487 op->o_dn = be->be_rootdn;
6488 op->o_ndn = be->be_rootndn;
6491 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
6492 if ( rc != LDAP_SUCCESS ) {
6493 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
6494 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
6497 if (ce && bi && bi->bi_tool_entry_put &&
6498 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
6499 entry_put_got_config++;
6501 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
6502 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
6506 entry_put_got_config++;
6510 if ( bi && bi->bi_tool_entry_put &&
6511 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
6512 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
6519 AttributeDescription **desc;
6521 { "attribute", &cfAd_attr },
6522 { "backend", &cfAd_backend },
6523 { "database", &cfAd_database },
6524 { "include", &cfAd_include },
6525 { "ldapsyntax", &cfAd_syntax },
6526 { "objectclass", &cfAd_oc },
6527 { "objectidentifier", &cfAd_om },
6528 { "overlay", &cfAd_overlay },
6533 * add / delete: all types that may be added or deleted must use an
6534 * X-ORDERED attributeType for their RDN. Adding and deleting entries
6535 * should automatically renumber the index of any siblings as needed,
6536 * so that no gaps in the numbering sequence exist after the add/delete
6538 * What can be added:
6540 * backend objects for backend-specific config directives
6544 * delete: probably no support this time around.
6546 * modrdn: generally not done. Will be invoked automatically by add/
6547 * delete to update numbering sequence. Perform as an explicit operation
6548 * so that the renumbering effect may be replicated. Subtree rename must
6549 * be supported, since renumbering a database will affect all its child
6552 * modify: must be fully supported.
6556 config_back_initialize( BackendInfo *bi )
6558 ConfigTable *ct = config_back_cf_table;
6562 AttributeDescription *ad = NULL;
6564 static char *controls[] = {
6565 LDAP_CONTROL_MANAGEDSAIT,
6569 /* Make sure we don't exceed the bits reserved for userland */
6570 config_check_userland( CFG_LAST );
6572 bi->bi_controls = controls;
6577 bi->bi_destroy = config_back_destroy;
6579 bi->bi_db_init = config_back_db_init;
6580 bi->bi_db_config = 0;
6581 bi->bi_db_open = config_back_db_open;
6582 bi->bi_db_close = config_back_db_close;
6583 bi->bi_db_destroy = config_back_db_destroy;
6585 bi->bi_op_bind = config_back_bind;
6586 bi->bi_op_unbind = 0;
6587 bi->bi_op_search = config_back_search;
6588 bi->bi_op_compare = 0;
6589 bi->bi_op_modify = config_back_modify;
6590 bi->bi_op_modrdn = config_back_modrdn;
6591 bi->bi_op_add = config_back_add;
6592 bi->bi_op_delete = config_back_delete;
6593 bi->bi_op_abandon = 0;
6595 bi->bi_extended = 0;
6597 bi->bi_chk_referrals = 0;
6599 bi->bi_access_allowed = slap_access_allowed;
6601 bi->bi_connection_init = 0;
6602 bi->bi_connection_destroy = 0;
6604 bi->bi_entry_release_rw = config_entry_release;
6605 bi->bi_entry_get_rw = config_back_entry_get;
6607 bi->bi_tool_entry_open = config_tool_entry_open;
6608 bi->bi_tool_entry_close = config_tool_entry_close;
6609 bi->bi_tool_entry_first = config_tool_entry_first;
6610 bi->bi_tool_entry_next = config_tool_entry_next;
6611 bi->bi_tool_entry_get = config_tool_entry_get;
6612 bi->bi_tool_entry_put = config_tool_entry_put;
6615 argv[ 0 ] = "slapd";
6621 for (i=0; OidMacros[i].name; i++ ) {
6622 argv[1] = OidMacros[i].name;
6623 argv[2] = OidMacros[i].oid;
6624 parse_oidm( &ca, 0, NULL );
6627 bi->bi_cf_ocs = cf_ocs;
6629 i = config_register_schema( ct, cf_ocs );
6632 i = slap_str2ad( "olcDatabase", &olcDatabaseDummy[0].ad, &text );
6635 /* setup olcRootPW to be base64-encoded when written in LDIF form;
6636 * basically, we don't care if it fails */
6637 i = slap_str2ad( "olcRootPW", &ad, &text );
6639 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
6640 "warning, unable to get \"olcRootPW\" "
6641 "attribute description: %d: %s\n",
6644 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
6645 ad->ad_type->sat_oid );
6648 /* set up the notable AttributeDescriptions */
6650 for (;ct->name;ct++) {
6651 if (strcmp(ct->name, ads[i].name)) continue;
6652 *ads[i].desc = ct->ad;
6654 if (!ads[i].name) break;