1 /* bconfig.c - the config backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2010 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>
28 #include <ac/unistd.h>
33 #include "slapi/slapi.h"
41 #define CONFIG_RDN "cn=config"
42 #define SCHEMA_RDN "cn=schema"
44 static struct berval config_rdn = BER_BVC(CONFIG_RDN);
45 static struct berval schema_rdn = BER_BVC(SCHEMA_RDN);
47 extern int slap_DN_strict; /* dn.c */
50 typedef struct modpath_s {
51 struct modpath_s *mp_next;
52 struct berval mp_path;
56 static ModPaths modpaths, *modlast = &modpaths, *modcur = &modpaths;
59 typedef struct ConfigFile {
60 struct ConfigFile *c_sibs;
61 struct ConfigFile *c_kids;
63 AttributeType *c_at_head, *c_at_tail;
64 ContentRule *c_cr_head, *c_cr_tail;
65 ObjectClass *c_oc_head, *c_oc_tail;
66 OidMacro *c_om_head, *c_om_tail;
67 Syntax *c_syn_head, *c_syn_tail;
72 ConfigFile *cb_config;
74 BackendDB cb_db; /* underlying database */
79 static CfBackInfo cfBackInfo;
81 static char *passwd_salt;
83 static char *logfileName;
84 #ifdef SLAP_AUTH_REWRITE
85 static BerVarray authz_rewrites;
88 static struct berval cfdir;
91 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
92 *cfAd_include, *cfAd_attr, *cfAd_oc, *cfAd_om, *cfAd_syntax;
94 static ConfigFile *cfn;
96 static Avlnode *CfOcTree;
98 /* System schema state */
99 extern AttributeType *at_sys_tail; /* at.c */
100 extern ObjectClass *oc_sys_tail; /* oc.c */
101 extern OidMacro *om_sys_tail; /* oidm.c */
102 extern Syntax *syn_sys_tail; /* syntax.c */
103 static AttributeType *cf_at_tail;
104 static ObjectClass *cf_oc_tail;
105 static OidMacro *cf_om_tail;
106 static Syntax *cf_syn_tail;
108 static int config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca,
109 SlapReply *rs, int *renumber, Operation *op );
111 static int config_check_schema( Operation *op, CfBackInfo *cfb );
113 static ConfigDriver config_fname;
114 static ConfigDriver config_cfdir;
115 static ConfigDriver config_generic;
116 static ConfigDriver config_search_base;
117 static ConfigDriver config_passwd_hash;
118 static ConfigDriver config_schema_dn;
119 static ConfigDriver config_sizelimit;
120 static ConfigDriver config_timelimit;
121 static ConfigDriver config_overlay;
122 static ConfigDriver config_subordinate;
123 static ConfigDriver config_suffix;
124 #ifdef LDAP_TCP_BUFFER
125 static ConfigDriver config_tcp_buffer;
126 #endif /* LDAP_TCP_BUFFER */
127 static ConfigDriver config_rootdn;
128 static ConfigDriver config_rootpw;
129 static ConfigDriver config_restrict;
130 static ConfigDriver config_allows;
131 static ConfigDriver config_disallows;
132 static ConfigDriver config_requires;
133 static ConfigDriver config_security;
134 static ConfigDriver config_referral;
135 static ConfigDriver config_loglevel;
136 static ConfigDriver config_updatedn;
137 static ConfigDriver config_updateref;
138 static ConfigDriver config_extra_attrs;
139 static ConfigDriver config_include;
140 static ConfigDriver config_obsolete;
142 static ConfigDriver config_tls_option;
143 static ConfigDriver config_tls_config;
145 extern ConfigDriver syncrepl_config;
153 CFG_TLS_PROTOCOL_MIN,
206 static OidRec OidMacros[] = {
207 /* OpenLDAProot:1.12.2 */
208 { "OLcfg", "1.3.6.1.4.1.4203.1.12.2" },
209 { "OLcfgAt", "OLcfg:3" },
210 { "OLcfgGlAt", "OLcfgAt:0" },
211 { "OLcfgBkAt", "OLcfgAt:1" },
212 { "OLcfgDbAt", "OLcfgAt:2" },
213 { "OLcfgOvAt", "OLcfgAt:3" },
214 { "OLcfgCtAt", "OLcfgAt:4" }, /* contrib modules */
215 { "OLcfgOc", "OLcfg:4" },
216 { "OLcfgGlOc", "OLcfgOc:0" },
217 { "OLcfgBkOc", "OLcfgOc:1" },
218 { "OLcfgDbOc", "OLcfgOc:2" },
219 { "OLcfgOvOc", "OLcfgOc:3" },
220 { "OLcfgCtOc", "OLcfgOc:4" }, /* contrib modules */
222 /* Syntaxes. We should just start using the standard names and
223 * document that they are predefined and available for users
224 * to reference in their own schema. Defining schema without
225 * OID macros is for masochists...
227 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
228 { "OMsBoolean", "OMsyn:7" },
229 { "OMsDN", "OMsyn:12" },
230 { "OMsDirectoryString", "OMsyn:15" },
231 { "OMsIA5String", "OMsyn:26" },
232 { "OMsInteger", "OMsyn:27" },
233 { "OMsOID", "OMsyn:38" },
234 { "OMsOctetString", "OMsyn:40" },
239 * Backend/Database registry
241 * OLcfg{Bk|Db}{Oc|At}:0 -> common
242 * OLcfg{Bk|Db}{Oc|At}:1 -> back-bdb(/back-hdb)
243 * OLcfg{Bk|Db}{Oc|At}:2 -> back-ldif
244 * OLcfg{Bk|Db}{Oc|At}:3 -> back-ldap
245 * OLcfg{Bk|Db}{Oc|At}:4 -> back-monitor
246 * OLcfg{Bk|Db}{Oc|At}:5 -> back-relay
247 * OLcfg{Bk|Db}{Oc|At}:6 -> back-sql
248 * OLcfg{Bk|Db}{Oc|At}:7 -> back-sock
254 * OLcfgOv{Oc|At}:1 -> syncprov
255 * OLcfgOv{Oc|At}:2 -> pcache
256 * OLcfgOv{Oc|At}:3 -> chain
257 * OLcfgOv{Oc|At}:4 -> accesslog
258 * OLcfgOv{Oc|At}:5 -> valsort
259 * OLcfgOv{Oc|At}:7 -> distproc
260 * OLcfgOv{Oc|At}:8 -> dynlist
261 * OLcfgOv{Oc|At}:9 -> dds
262 * OLcfgOv{Oc|At}:10 -> unique
263 * OLcfgOv{Oc|At}:11 -> refint
264 * OLcfgOv{Oc|At}:12 -> ppolicy
265 * OLcfgOv{Oc|At}:13 -> constraint
266 * OLcfgOv{Oc|At}:14 -> translucent
267 * OLcfgOv{Oc|At}:15 -> auditlog
268 * OLcfgOv{Oc|At}:16 -> rwm
269 * OLcfgOv{Oc|At}:17 -> dyngroup
270 * OLcfgOv{Oc|At}:18 -> memberof
271 * OLcfgOv{Oc|At}:19 -> collect
272 * OLcfgOv{Oc|At}:20 -> retcode
273 * OLcfgOv{Oc|At}:21 -> sssvlv
276 /* alphabetical ordering */
278 static ConfigTable config_back_cf_table[] = {
279 /* This attr is read-only */
280 { "", "", 0, 0, 0, ARG_MAGIC,
281 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
282 "DESC 'File for slapd configuration directives' "
283 "EQUALITY caseIgnoreMatch "
284 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
285 { "", "", 0, 0, 0, ARG_MAGIC,
286 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
287 "DESC 'Directory for slapd configuration backend' "
288 "EQUALITY caseIgnoreMatch "
289 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
290 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
291 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
292 "DESC 'Access Control List' "
293 "EQUALITY caseIgnoreMatch "
294 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
295 { "add_content_acl", NULL, 0, 0, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_ACL_ADD,
296 &config_generic, "( OLcfgGlAt:86 NAME 'olcAddContentAcl' "
297 "DESC 'Check ACLs against content of Add ops' "
298 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
299 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
300 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
301 "DESC 'Allowed set of deprecated features' "
302 "EQUALITY caseIgnoreMatch "
303 "SYNTAX OMsDirectoryString )", NULL, NULL },
304 { "argsfile", "file", 2, 2, 0, ARG_STRING,
305 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
306 "DESC 'File for slapd command line options' "
307 "EQUALITY caseIgnoreMatch "
308 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
309 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
310 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
311 "EQUALITY caseIgnoreMatch "
312 "SYNTAX OMsDirectoryString )", NULL, NULL },
313 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
314 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
315 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
316 "DESC 'OpenLDAP attributeTypes' "
317 "EQUALITY caseIgnoreMatch "
318 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
320 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
321 #ifdef SLAP_AUTH_REWRITE
322 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
326 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
327 "EQUALITY caseIgnoreMatch "
328 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
329 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
330 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
331 "EQUALITY caseIgnoreMatch "
332 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
333 { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
334 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
335 "EQUALITY caseIgnoreMatch "
336 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
337 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
338 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
339 "DESC 'A type of backend' "
340 "EQUALITY caseIgnoreMatch "
341 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
343 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
344 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
345 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
346 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
347 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
348 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
349 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
350 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
351 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
352 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
353 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
354 "DESC 'The backend type for a database instance' "
355 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
356 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
357 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
358 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
359 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
360 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
361 "EQUALITY caseIgnoreMatch "
362 "SYNTAX OMsDirectoryString )", NULL, NULL },
363 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
364 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
365 "DESC 'OpenLDAP DIT content rules' "
366 "EQUALITY caseIgnoreMatch "
367 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
369 { "extra_attrs", "attrlist", 2, 2, 0, ARG_DB|ARG_MAGIC,
370 &config_extra_attrs, "( OLcfgDbAt:0.20 NAME 'olcExtraAttrs' "
371 "EQUALITY caseIgnoreMatch "
372 "SYNTAX OMsDirectoryString )", NULL, NULL },
373 { "gentlehup", "on|off", 2, 2, 0,
375 ARG_ON_OFF, &global_gentlehup,
379 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
380 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
381 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
382 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
383 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
384 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
385 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
386 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
387 { "include", "file", 2, 2, 0, ARG_MAGIC,
388 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
389 "SUP labeledURI )", NULL, NULL },
390 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
391 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
392 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
393 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
394 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
395 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
396 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
397 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
398 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
399 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
400 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
401 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
402 { "index_intlen", "len", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_IX_INTLEN,
403 &config_generic, "( OLcfgGlAt:84 NAME 'olcIndexIntLen' "
404 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
405 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
406 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
407 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
408 { "ldapsyntax", "syntax", 2, 0, 0,
409 ARG_PAREN|ARG_MAGIC|CFG_SYNTAX,
410 &config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
411 "DESC 'OpenLDAP ldapSyntax' "
412 "EQUALITY caseIgnoreMatch "
413 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
415 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
416 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
417 "EQUALITY caseIgnoreMatch "
418 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
419 { "listener-threads", "count", 2, 0, 0,
423 ARG_UINT|ARG_MAGIC|CFG_LTHREADS, &config_generic,
425 "( OLcfgGlAt:93 NAME 'olcListenerThreads' "
426 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
427 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
428 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
429 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
430 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
431 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
432 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
433 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
434 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
435 "EQUALITY caseIgnoreMatch "
436 "SYNTAX OMsDirectoryString )", NULL, NULL },
437 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
438 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
439 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
440 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
441 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
442 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
443 { "moduleload", "file", 2, 0, 0,
445 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
449 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
450 "EQUALITY caseIgnoreMatch "
451 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
452 { "modulepath", "path", 2, 2, 0,
454 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
458 "( OLcfgGlAt:31 NAME 'olcModulePath' "
459 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
460 { "monitoring", "TRUE|FALSE", 2, 2, 0,
461 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
462 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
463 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
464 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
465 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
466 "DESC 'OpenLDAP object classes' "
467 "EQUALITY caseIgnoreMatch "
468 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
470 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
471 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
472 "EQUALITY caseIgnoreMatch "
473 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
474 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
475 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
476 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
477 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
478 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
479 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
480 { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
481 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
482 "EQUALITY caseIgnoreMatch "
483 "SYNTAX OMsDirectoryString )", NULL, NULL },
484 { "pidfile", "file", 2, 2, 0, ARG_STRING,
485 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
486 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
487 { "plugin", NULL, 0, 0, 0,
489 ARG_MAGIC|CFG_PLUGIN, &config_generic,
493 "( OLcfgGlAt:38 NAME 'olcPlugin' "
494 "EQUALITY caseIgnoreMatch "
495 "SYNTAX OMsDirectoryString )", NULL, NULL },
496 { "pluginlog", "filename", 2, 2, 0,
498 ARG_STRING, &slapi_log_file,
502 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
503 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
504 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
505 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
506 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
507 { "referral", "url", 2, 2, 0, ARG_MAGIC,
508 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
509 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
510 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
511 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
512 "EQUALITY caseIgnoreMatch "
513 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
514 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
515 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
516 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
517 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
518 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
519 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
520 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
521 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
522 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
523 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
524 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
525 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
526 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
527 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
528 "EQUALITY caseIgnoreMatch "
529 "SYNTAX OMsDirectoryString )", NULL, NULL },
530 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
531 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
532 "EQUALITY caseIgnoreMatch "
533 "SYNTAX OMsDirectoryString )", NULL, NULL },
534 { "reverse-lookup", "on|off", 2, 2, 0,
535 #ifdef SLAPD_RLOOKUPS
536 ARG_ON_OFF, &use_reverse_lookup,
540 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
541 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
542 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
543 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
544 "EQUALITY distinguishedNameMatch "
545 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
546 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
547 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
548 "EQUALITY caseIgnoreMatch "
549 "SYNTAX OMsDirectoryString )", NULL, NULL },
550 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
551 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
552 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
553 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
554 &config_generic, NULL, NULL, NULL },
555 { "sasl-auxprops", NULL, 2, 0, 0,
556 #ifdef HAVE_CYRUS_SASL
557 ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
561 "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
562 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
563 { "sasl-auxprops-dontusecopy", NULL, 2, 0, 0,
564 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
565 ARG_MAGIC|CFG_AZDUC, &config_generic,
569 "( OLcfgGlAt:91 NAME 'olcSaslAuxpropsDontUseCopy' "
570 "EQUALITY caseIgnoreMatch "
571 "SYNTAX OMsDirectoryString )", NULL, NULL },
572 { "sasl-auxprops-dontusecopy-ignore", "true|FALSE", 2, 0, 0,
573 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
574 ARG_ON_OFF|CFG_AZDUC_IGNORE, &slap_dontUseCopy_ignore,
578 "( OLcfgGlAt:92 NAME 'olcSaslAuxpropsDontUseCopyIgnore' "
579 "EQUALITY booleanMatch "
580 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
581 { "sasl-host", "host", 2, 2, 0,
582 #ifdef HAVE_CYRUS_SASL
583 ARG_STRING|ARG_UNIQUE, &sasl_host,
587 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
588 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
589 { "sasl-realm", "realm", 2, 2, 0,
590 #ifdef HAVE_CYRUS_SASL
591 ARG_STRING|ARG_UNIQUE, &global_realm,
595 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
596 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
597 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
598 &config_generic, NULL, NULL, NULL },
599 { "sasl-secprops", "properties", 2, 2, 0,
600 #ifdef HAVE_CYRUS_SASL
601 ARG_MAGIC|CFG_SASLSECP, &config_generic,
605 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
606 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
607 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
608 &config_generic, NULL, NULL, NULL },
609 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
610 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
611 "EQUALITY distinguishedNameMatch "
612 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
613 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
614 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
615 "EQUALITY caseIgnoreMatch "
616 "SYNTAX OMsDirectoryString )", NULL, NULL },
617 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
618 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
619 "EQUALITY caseIgnoreMatch "
620 "SYNTAX OMsDirectoryString )", NULL, NULL },
621 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
622 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
623 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
624 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
625 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
626 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
627 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
628 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
629 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
630 { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
631 &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
632 "DESC 'Attributes whose values will always be sorted' "
633 "EQUALITY caseIgnoreMatch "
634 "SYNTAX OMsDirectoryString )", NULL, NULL },
635 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
636 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
637 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
638 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
639 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
640 "EQUALITY distinguishedNameMatch "
641 "SYNTAX OMsDN )", NULL, NULL },
642 { "sync_use_subentry", NULL, 0, 0, 0, ARG_ON_OFF|ARG_DB|ARG_MAGIC|CFG_SYNC_SUBENTRY,
643 &config_generic, "( OLcfgDbAt:0.19 NAME 'olcSyncUseSubentry' "
644 "DESC 'Store sync context in a subentry' "
645 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
646 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
647 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
648 "EQUALITY caseIgnoreMatch "
649 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
650 { "tcp-buffer", "[listener=<listener>] [{read|write}=]size", 0, 0, 0,
651 #ifndef LDAP_TCP_BUFFER
653 #else /* LDAP_TCP_BUFFER */
654 ARG_MAGIC, &config_tcp_buffer,
655 #endif /* LDAP_TCP_BUFFER */
656 "( OLcfgGlAt:90 NAME 'olcTCPBuffer' "
657 "DESC 'Custom TCP buffer size' "
658 "SYNTAX OMsDirectoryString )", NULL, NULL },
659 { "threads", "count", 2, 2, 0,
663 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
665 "( OLcfgGlAt:66 NAME 'olcThreads' "
666 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
667 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
668 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
669 "SYNTAX OMsDirectoryString )", NULL, NULL },
670 { "TLSCACertificateFile", NULL, 0, 0, 0,
672 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
676 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
677 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
678 { "TLSCACertificatePath", NULL, 0, 0, 0,
680 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
684 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
685 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
686 { "TLSCertificateFile", NULL, 0, 0, 0,
688 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
692 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
693 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
694 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
696 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
700 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
701 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
702 { "TLSCipherSuite", NULL, 0, 0, 0,
704 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
708 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
709 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
710 { "TLSCRLCheck", NULL, 0, 0, 0,
711 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
712 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
716 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
717 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
718 { "TLSCRLFile", NULL, 0, 0, 0,
719 #if defined(HAVE_GNUTLS)
720 CFG_TLS_CRL_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
724 "( OLcfgGlAt:82 NAME 'olcTLSCRLFile' "
725 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
726 { "TLSRandFile", NULL, 0, 0, 0,
728 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
732 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
733 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
734 { "TLSVerifyClient", NULL, 0, 0, 0,
736 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
740 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
741 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
742 { "TLSDHParamFile", NULL, 0, 0, 0,
744 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
748 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
749 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
750 { "TLSProtocolMin", NULL, 0, 0, 0,
752 CFG_TLS_PROTOCOL_MIN|ARG_STRING|ARG_MAGIC, &config_tls_config,
756 "( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' "
757 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
758 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
759 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
760 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
761 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
762 NULL, NULL, NULL, NULL },
763 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
764 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
765 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
766 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
767 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
768 "EQUALITY caseIgnoreMatch "
769 "SUP labeledURI )", NULL, NULL },
770 { "writetimeout", "timeout", 2, 2, 0, ARG_INT,
771 &global_writetimeout, "( OLcfgGlAt:88 NAME 'olcWriteTimeout' "
772 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
773 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
774 NULL, NULL, NULL, NULL }
777 /* Need to no-op this keyword for dynamic config */
778 ConfigTable olcDatabaseDummy[] = {
779 { "", "", 0, 0, 0, ARG_IGNORED,
780 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
781 "DESC 'The backend type for a database instance' "
782 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
783 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
786 /* Routines to check if a child can be added to this type */
787 static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
788 cfAddBackend, cfAddModule, cfAddOverlay;
790 /* NOTE: be careful when defining array members
791 * that can be conditionally compiled */
792 #define CFOC_GLOBAL cf_ocs[1]
793 #define CFOC_SCHEMA cf_ocs[2]
794 #define CFOC_BACKEND cf_ocs[3]
795 #define CFOC_DATABASE cf_ocs[4]
796 #define CFOC_OVERLAY cf_ocs[5]
797 #define CFOC_INCLUDE cf_ocs[6]
798 #define CFOC_FRONTEND cf_ocs[7]
800 #define CFOC_MODULE cf_ocs[8]
801 #endif /* SLAPD_MODULES */
803 static ConfigOCs cf_ocs[] = {
806 "DESC 'OpenLDAP configuration object' "
807 "ABSTRACT SUP top )", Cft_Abstract, NULL },
810 "DESC 'OpenLDAP Global configuration options' "
811 "SUP olcConfig STRUCTURAL "
812 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
813 "olcAttributeOptions $ olcAuthIDRewrite $ "
814 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
815 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
816 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
817 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
818 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcIndexIntLen $ "
819 "olcLocalSSF $ olcLogFile $ olcLogLevel $ "
820 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
821 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
822 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
824 "olcSaslAuxprops $ olcSaslAuxpropsDontUseCopy $ olcSaslAuxpropsDontUseCopyIgnore $ "
825 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
826 "olcSecurity $ olcServerID $ olcSizeLimit $ "
827 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
829 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
830 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
831 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
832 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
833 "olcTLSCRLFile $ olcToolThreads $ olcWriteTimeout $ "
834 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
835 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
837 "NAME 'olcSchemaConfig' "
838 "DESC 'OpenLDAP schema object' "
839 "SUP olcConfig STRUCTURAL "
840 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
841 "olcObjectClasses $ olcDitContentRules $ olcLdapSyntaxes ) )",
842 Cft_Schema, NULL, cfAddSchema },
844 "NAME 'olcBackendConfig' "
845 "DESC 'OpenLDAP Backend-specific options' "
846 "SUP olcConfig STRUCTURAL "
847 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
849 "NAME 'olcDatabaseConfig' "
850 "DESC 'OpenLDAP Database-specific options' "
851 "SUP olcConfig STRUCTURAL "
853 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
854 "olcAddContentAcl $ olcLastMod $ olcLimits $ "
855 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
856 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
857 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
858 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncUseSubentry $ olcSyncrepl $ "
859 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
860 "olcMonitoring $ olcExtraAttrs ) )",
861 Cft_Database, NULL, cfAddDatabase },
863 "NAME 'olcOverlayConfig' "
864 "DESC 'OpenLDAP Overlay-specific options' "
865 "SUP olcConfig STRUCTURAL "
866 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
868 "NAME 'olcIncludeFile' "
869 "DESC 'OpenLDAP configuration include file' "
870 "SUP olcConfig STRUCTURAL "
872 "MAY ( cn $ olcRootDSE ) )",
873 /* Used to be Cft_Include, that def has been removed */
874 Cft_Abstract, NULL, cfAddInclude },
875 /* This should be STRUCTURAL like all the other database classes, but
876 * that would mean inheriting all of the olcDatabaseConfig attributes,
877 * which causes them to be merged twice in config_build_entry.
880 "NAME 'olcFrontendConfig' "
881 "DESC 'OpenLDAP frontend configuration' "
883 "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
884 Cft_Database, NULL, NULL },
887 "NAME 'olcModuleList' "
888 "DESC 'OpenLDAP dynamic module info' "
889 "SUP olcConfig STRUCTURAL "
890 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
891 Cft_Module, NULL, cfAddModule },
896 typedef struct ServerID {
897 struct ServerID *si_next;
898 struct berval si_url;
902 static ServerID *sid_list;
904 typedef struct voidList {
905 struct voidList *vl_next;
909 typedef struct ADlist {
910 struct ADlist *al_next;
911 AttributeDescription *al_desc;
914 static ADlist *sortVals;
917 config_generic(ConfigArgs *c) {
920 if ( c->op == SLAP_CONFIG_EMIT ) {
924 c->value_int = ldap_pvt_thread_get_concurrency();
927 c->value_int = connection_pool_max;
930 c->value_int = slap_tool_thread_max;
933 c->value_uint = slapd_daemon_threads;
937 c->value_string = ch_strdup( passwd_salt );
942 if ( c->be->be_limits ) {
946 for ( i=0; c->be->be_limits[i]; i++ ) {
947 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
948 if ( bv.bv_len >= sizeof( buf ) ) {
949 ber_bvarray_free_x( c->rvalue_vals, NULL );
950 c->rvalue_vals = NULL;
954 bv.bv_val = buf + bv.bv_len;
955 limits_unparse( c->be->be_limits[i], &bv,
956 sizeof( buf ) - ( bv.bv_val - buf ) );
957 bv.bv_len += bv.bv_val - buf;
959 value_add_one( &c->rvalue_vals, &bv );
962 if ( !c->rvalue_vals ) rc = 1;
965 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
968 c->value_string = ch_strdup( slap_sasl_getpolicy());
971 slap_sasl_regexp_unparse( &c->rvalue_vals );
972 if ( !c->rvalue_vals ) rc = 1;
974 #ifdef HAVE_CYRUS_SASL
975 #ifdef SLAP_AUXPROP_DONTUSECOPY
977 static int duc_done = 0;
979 /* take the opportunity to initialize with known values */
981 struct berval duc[] = { BER_BVC("cmusaslsecretOTP"), BER_BVNULL };
984 for ( i = 0; !BER_BVISNULL( &duc[ i ] ); i++ ) {
985 const char *text = NULL;
986 AttributeDescription *ad = NULL;
988 if ( slap_bv2ad( &duc[ i ], &ad, &text ) == LDAP_SUCCESS ) {
990 if ( slap_dontUseCopy_propnames ) {
993 for ( j = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ j ] ); j++ ) {
994 if ( bvmatch( &slap_dontUseCopy_propnames[ j ], &ad->ad_cname ) ) {
1001 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1009 if ( slap_dontUseCopy_propnames != NULL ) {
1010 ber_bvarray_dup_x( &c->rvalue_vals, slap_dontUseCopy_propnames, NULL );
1015 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1016 case CFG_SASLSECP: {
1017 struct berval bv = BER_BVNULL;
1018 slap_sasl_secprops_unparse( &bv );
1019 if ( !BER_BVISNULL( &bv )) {
1020 ber_bvarray_add( &c->rvalue_vals, &bv );
1028 c->value_int = c->be->be_max_deref_depth;
1031 if ( SLAP_DBHIDDEN( c->be )) {
1038 ConfigFile *cf = c->ca_private;
1040 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1041 else if ( cf->c_om_head )
1042 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
1044 if ( !c->rvalue_vals )
1049 ad_unparse_options( &c->rvalue_vals );
1052 ConfigFile *cf = c->ca_private;
1054 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1055 else if ( cf->c_oc_head )
1056 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
1058 if ( !c->rvalue_vals )
1063 ConfigFile *cf = c->ca_private;
1065 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1066 else if ( cf->c_at_head )
1067 at_unparse( &c->rvalue_vals, cf->c_at_head,
1069 if ( !c->rvalue_vals )
1074 ConfigFile *cf = c->ca_private;
1076 syn_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1077 else if ( cf->c_syn_head )
1078 syn_unparse( &c->rvalue_vals, cf->c_syn_head,
1079 cf->c_syn_tail, 0 );
1080 if ( !c->rvalue_vals )
1085 ConfigFile *cf = c->ca_private;
1087 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1088 else if ( cf->c_cr_head )
1089 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
1091 if ( !c->rvalue_vals )
1098 char *src, *dst, ibuf[11];
1099 struct berval bv, abv;
1100 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
1101 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1102 if ( abv.bv_len >= sizeof( ibuf ) ) {
1103 ber_bvarray_free_x( c->rvalue_vals, NULL );
1104 c->rvalue_vals = NULL;
1108 acl_unparse( a, &bv );
1109 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
1110 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
1111 /* Turn TAB / EOL into plain space */
1112 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
1113 if (isspace((unsigned char)*src)) *dst++ = ' ';
1117 if (dst[-1] == ' ') {
1121 abv.bv_len = dst - abv.bv_val;
1122 ber_bvarray_add( &c->rvalue_vals, &abv );
1128 c->value_int = (SLAP_DBACL_ADD(c->be) != 0);
1131 ConfigFile *cf = c->ca_private;
1132 if ( cf->c_dseFiles ) {
1133 value_add( &c->rvalue_vals, cf->c_dseFiles );
1144 for ( si = sid_list; si; si=si->si_next ) {
1145 assert( si->si_num >= 0 && si->si_num <= SLAP_SYNC_SID_MAX );
1146 if ( !BER_BVISEMPTY( &si->si_url )) {
1147 bv.bv_len = si->si_url.bv_len + 6;
1148 bv.bv_val = ch_malloc( bv.bv_len );
1149 bv.bv_len = sprintf( bv.bv_val, "%d %s", si->si_num,
1150 si->si_url.bv_val );
1151 ber_bvarray_add( &c->rvalue_vals, &bv );
1155 bv.bv_len = sprintf( buf, "%d", si->si_num );
1156 value_add_one( &c->rvalue_vals, &bv );
1165 c->value_string = ch_strdup( logfileName );
1170 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
1172 case CFG_SYNC_SUBENTRY:
1173 c->value_int = (SLAP_SYNC_SUBENTRY(c->be) != 0);
1175 case CFG_MIRRORMODE:
1176 if ( SLAP_SHADOW(c->be))
1177 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
1181 case CFG_MONITORING:
1182 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
1184 case CFG_SSTR_IF_MAX:
1185 c->value_uint = index_substr_if_maxlen;
1187 case CFG_SSTR_IF_MIN:
1188 c->value_uint = index_substr_if_minlen;
1191 c->value_int = index_intlen;
1193 case CFG_SORTVALS: {
1196 for ( sv = sortVals; sv; sv = sv->al_next ) {
1197 value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
1201 #ifdef SLAPD_MODULES
1203 ModPaths *mp = c->ca_private;
1206 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
1209 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
1210 SLAP_X_ORDERED_FMT "%s", i,
1211 mp->mp_loads[i].bv_val );
1212 if ( bv.bv_len >= sizeof( c->log ) ) {
1213 ber_bvarray_free_x( c->rvalue_vals, NULL );
1214 c->rvalue_vals = NULL;
1217 value_add_one( &c->rvalue_vals, &bv );
1221 rc = c->rvalue_vals ? 0 : 1;
1225 ModPaths *mp = c->ca_private;
1226 if ( !BER_BVISNULL( &mp->mp_path ))
1227 value_add_one( &c->rvalue_vals, &mp->mp_path );
1229 rc = c->rvalue_vals ? 0 : 1;
1235 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1236 if ( !c->rvalue_vals ) rc = 1;
1239 #ifdef SLAP_AUTH_REWRITE
1241 if ( authz_rewrites ) {
1242 struct berval bv, idx;
1247 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1248 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1249 if ( idx.bv_len >= sizeof( ibuf ) ) {
1250 ber_bvarray_free_x( c->rvalue_vals, NULL );
1251 c->rvalue_vals = NULL;
1254 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1255 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1256 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1257 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1258 authz_rewrites[i].bv_val,
1259 authz_rewrites[i].bv_len + 1 );
1260 ber_bvarray_add( &c->rvalue_vals, &bv );
1263 if ( !c->rvalue_vals ) rc = 1;
1270 } else if ( c->op == LDAP_MOD_DELETE ) {
1273 /* single-valued attrs, no-ops */
1282 case CFG_MIRRORMODE:
1283 case CFG_MONITORING:
1285 case CFG_SSTR_IF_MAX:
1286 case CFG_SSTR_IF_MIN:
1288 case CFG_SYNC_SUBENTRY:
1291 /* no-ops, requires slapd restart */
1296 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1299 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
1301 if ( c->valx < 0 ) {
1302 if ( slap_dontUseCopy_propnames != NULL ) {
1303 ber_bvarray_free( slap_dontUseCopy_propnames );
1304 slap_dontUseCopy_propnames = NULL;
1310 if ( slap_dontUseCopy_propnames == NULL ) {
1315 for ( i = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i ] ) && i < c->valx; i++ );
1316 if ( i < c->valx ) {
1320 ber_memfree( slap_dontUseCopy_propnames[ i ].bv_val );
1321 for ( ; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i + 1 ] ); i++ ) {
1322 slap_dontUseCopy_propnames[ i ] = slap_dontUseCopy_propnames[ i + 1 ];
1324 BER_BVZERO( &slap_dontUseCopy_propnames[ i ] );
1327 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1329 ch_free( passwd_salt );
1334 ch_free( logfileName );
1342 case CFG_SERVERID: {
1343 ServerID *si, **sip;
1345 for ( i=0, si = sid_list, sip = &sid_list;
1346 si; si = *sip, i++ ) {
1347 if ( c->valx == -1 || i == c->valx ) {
1359 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1363 index_intlen = SLAP_INDEX_INTLEN_DEFAULT;
1364 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1365 SLAP_INDEX_INTLEN_DEFAULT );
1369 if ( c->valx < 0 ) {
1370 acl_destroy( c->be->be_acl );
1371 c->be->be_acl = NULL;
1374 AccessControl **prev, *a;
1376 for (i=0, prev = &c->be->be_acl; i < c->valx;
1379 prev = &a->acl_next;
1382 *prev = a->acl_next;
1389 /* Can be NULL when undoing a failed add */
1390 if ( c->ca_entry ) {
1391 ce = c->ca_entry->e_private;
1392 /* can't modify the hardcoded schema */
1393 if ( ce->ce_parent->ce_type == Cft_Global )
1397 cfn = c->ca_private;
1398 if ( c->valx < 0 ) {
1401 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1403 if ( oc == cfn->c_oc_tail )
1406 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1408 ObjectClass *oc, *prev = NULL;
1410 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1415 if ( cfn->c_oc_tail == oc ) {
1416 cfn->c_oc_tail = prev;
1418 if ( cfn->c_oc_head == oc ) {
1420 cfn->c_oc_head = oc;
1427 /* Can be NULL when undoing a failed add */
1428 if ( c->ca_entry ) {
1429 ce = c->ca_entry->e_private;
1430 /* can't modify the hardcoded schema */
1431 if ( ce->ce_parent->ce_type == Cft_Global )
1435 cfn = c->ca_private;
1436 if ( c->valx < 0 ) {
1439 for( at = cfn->c_at_head; at; at_next( &at )) {
1441 if ( at == cfn->c_at_tail )
1444 cfn->c_at_head = cfn->c_at_tail = NULL;
1446 AttributeType *at, *prev = NULL;
1448 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1453 if ( cfn->c_at_tail == at ) {
1454 cfn->c_at_tail = prev;
1456 if ( cfn->c_at_head == at ) {
1458 cfn->c_at_head = at;
1465 /* Can be NULL when undoing a failed add */
1466 if ( c->ca_entry ) {
1467 ce = c->ca_entry->e_private;
1468 /* can't modify the hardcoded schema */
1469 if ( ce->ce_parent->ce_type == Cft_Global )
1473 cfn = c->ca_private;
1474 if ( c->valx < 0 ) {
1477 for( syn = cfn->c_syn_head; syn; syn_next( &syn )) {
1479 if ( syn == cfn->c_syn_tail )
1482 cfn->c_syn_head = cfn->c_syn_tail = NULL;
1484 Syntax *syn, *prev = NULL;
1486 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++) {
1491 if ( cfn->c_syn_tail == syn ) {
1492 cfn->c_syn_tail = prev;
1494 if ( cfn->c_syn_head == syn ) {
1496 cfn->c_syn_head = syn;
1501 if ( c->valx < 0 ) {
1503 for ( sv = sortVals; sv; sv = sortVals ) {
1504 sortVals = sv->al_next;
1505 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1512 for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
1513 prev = &sv->al_next;
1516 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1517 *prev = sv->al_next;
1523 /* FIXME: there is no limits_free function */
1524 if ( c->valx < 0 ) {
1525 limits_destroy( c->be->be_limits );
1526 c->be->be_limits = NULL;
1531 if ( c->be->be_limits ) {
1532 for ( num = 0; c->be->be_limits[ num ]; num++ )
1536 if ( c->valx >= num ) {
1541 limits_destroy( c->be->be_limits );
1542 c->be->be_limits = NULL;
1545 limits_free_one( c->be->be_limits[ c->valx ] );
1547 for ( cnt = c->valx; cnt < num; cnt++ ) {
1548 c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
1555 /* FIXME: there is no ad_option_free function */
1557 /* FIXME: there is no way to remove attributes added by
1571 if(!(c->bi = backend_info(c->argv[1]))) {
1572 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1573 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1574 c->log, c->cr_msg, c->argv[1] );
1581 /* NOTE: config is always the first backend!
1583 if ( !strcasecmp( c->argv[1], "config" )) {
1584 c->be = LDAP_STAILQ_FIRST(&backendDB);
1585 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1588 c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply);
1590 if ( c->cr_msg[0] == 0 )
1591 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1592 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n", c->log, c->cr_msg, c->argv[1] );
1599 ldap_pvt_thread_set_concurrency(c->value_int);
1603 if ( c->value_int < 2 ) {
1604 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1605 "threads=%d smaller than minimum value 2",
1607 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1608 c->log, c->cr_msg, 0 );
1611 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1612 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1613 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1614 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1615 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1616 c->log, c->cr_msg, 0 );
1618 if ( slapMode & SLAP_SERVER_MODE )
1619 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1620 connection_pool_max = c->value_int; /* save for reference */
1624 if ( slapMode & SLAP_TOOL_MODE )
1625 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1626 slap_tool_thread_max = c->value_int; /* save for reference */
1631 /* use a power of two */
1632 while (c->value_uint > 1) {
1633 c->value_uint >>= 1;
1637 slapd_daemon_mask = mask;
1638 slapd_daemon_threads = mask+1;
1643 if ( passwd_salt ) ch_free( passwd_salt );
1644 passwd_salt = c->value_string;
1645 lutil_salt_format(passwd_salt);
1649 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1655 c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1657 c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1661 ch_free(c->value_string);
1662 if (slap_sasl_setpolicy( c->argv[1] )) {
1663 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
1664 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1665 c->log, c->cr_msg, c->argv[1] );
1671 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1675 #ifdef HAVE_CYRUS_SASL
1676 #ifdef SLAP_AUXPROP_DONTUSECOPY
1680 for ( arg = 1; arg < c->argc; arg++ ) {
1681 int duplicate = 0, err;
1682 AttributeDescription *ad = NULL;
1683 const char *text = NULL;
1685 err = slap_str2ad( c->argv[ arg ], &ad, &text );
1686 if ( err != LDAP_SUCCESS ) {
1687 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") unknown (err=%d \"%s\"; ignored)",
1688 c->argv[0], arg, c->argv[ arg ], err, text );
1689 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1690 c->log, c->cr_msg, 0 );
1693 if ( slap_dontUseCopy_propnames != NULL ) {
1694 for ( cnt = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ cnt ] ); cnt++ ) {
1695 if ( bvmatch( &slap_dontUseCopy_propnames[ cnt ], &ad->ad_cname ) ) {
1703 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") already defined (ignored)",
1704 c->argv[0], arg, ad->ad_cname.bv_val);
1705 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1706 c->log, c->cr_msg, 0 );
1710 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1715 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1719 char *txt = slap_sasl_secprops( c->argv[1] );
1721 snprintf( c->cr_msg, sizeof(c->cr_msg), "<%s> %s",
1723 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0 );
1731 c->be->be_max_deref_depth = c->value_int;
1737 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1738 cfn = c->ca_private;
1739 if(parse_oidm(c, 1, &om))
1741 if (!cfn->c_om_head) cfn->c_om_head = om;
1742 cfn->c_om_tail = om;
1747 ObjectClass *oc, *prev;
1749 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1750 cfn = c->ca_private;
1751 if ( c->valx < 0 ) {
1752 prev = cfn->c_oc_tail;
1755 /* If adding anything after the first, prev is easy */
1758 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1763 /* If adding the first, and head exists, find its prev */
1764 if (cfn->c_oc_head) {
1765 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1770 /* else prev is NULL, append to end of global list */
1772 if(parse_oc(c, &oc, prev)) return(1);
1773 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1774 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1779 AttributeType *at, *prev;
1781 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1782 cfn = c->ca_private;
1783 if ( c->valx < 0 ) {
1784 prev = cfn->c_at_tail;
1787 /* If adding anything after the first, prev is easy */
1790 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1795 /* If adding the first, and head exists, find its prev */
1796 if (cfn->c_at_head) {
1797 for ( at_start( &at ); at != cfn->c_at_head; ) {
1802 /* else prev is NULL, append to end of global list */
1804 if(parse_at(c, &at, prev)) return(1);
1805 if (!cfn->c_at_head) cfn->c_at_head = at;
1806 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1813 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1814 cfn = c->ca_private;
1815 if ( c->valx < 0 ) {
1816 prev = cfn->c_syn_tail;
1819 /* If adding anything after the first, prev is easy */
1822 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
1827 /* If adding the first, and head exists, find its prev */
1828 if (cfn->c_syn_head) {
1829 for ( syn_start( &syn ); syn != cfn->c_syn_head; ) {
1834 /* else prev is NULL, append to end of global list */
1836 if ( parse_syn( c, &syn, prev ) ) return(1);
1837 if ( !cfn->c_syn_head ) cfn->c_syn_head = syn;
1838 if ( cfn->c_syn_tail == prev ) cfn->c_syn_tail = syn;
1845 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1846 cfn = c->ca_private;
1847 if(parse_cr(c, &cr)) return(1);
1848 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1849 cfn->c_cr_tail = cr;
1854 ad_define_option(NULL, NULL, 0);
1855 for(i = 1; i < c->argc; i++)
1856 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1861 if ( c->value_int < SLAP_INDEX_INTLEN_DEFAULT )
1862 c->value_int = SLAP_INDEX_INTLEN_DEFAULT;
1863 else if ( c->value_int > 255 )
1865 index_intlen = c->value_int;
1866 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1870 case CFG_SORTVALS: {
1871 ADlist *svnew = NULL, *svtail, *sv;
1873 for ( i = 1; i < c->argc; i++ ) {
1874 AttributeDescription *ad = NULL;
1878 rc = slap_str2ad( c->argv[i], &ad, &text );
1880 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
1883 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1884 c->log, c->cr_msg, c->argv[i] );
1885 for ( sv = svnew; sv; sv = svnew ) {
1886 svnew = sv->al_next;
1891 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
1892 ad->ad_type->sat_single_value ) {
1893 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
1895 goto sortval_reject;
1897 sv = ch_malloc( sizeof( ADlist ));
1902 svtail->al_next = sv;
1907 for ( sv = svnew; sv; sv = sv->al_next )
1908 sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
1909 for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
1911 sv->al_next = svnew;
1918 /* Don't append to the global ACL if we're on a specific DB */
1920 if ( c->valx == -1 ) {
1923 for ( a=c->be->be_acl; a; a = a->acl_next )
1926 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1933 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_ACL_ADD;
1935 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_ACL_ADD;
1939 if(root_dse_read_file(c->argv[1])) {
1940 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> could not read file", c->argv[0] );
1941 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1942 c->log, c->cr_msg, c->argv[1] );
1947 ber_str2bv( c->argv[1], 0, 1, &bv );
1948 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1949 cfn = c->ca_private;
1950 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1956 ServerID *si, **sip;
1959 if (( lutil_atoi( &num, c->argv[1] ) &&
1960 lutil_atoix( &num, c->argv[1], 16 )) ||
1961 num < 0 || num > SLAP_SYNC_SID_MAX )
1963 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1964 "<%s> illegal server ID", c->argv[0] );
1965 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1966 c->log, c->cr_msg, c->argv[1] );
1969 /* only one value allowed if no URL is given */
1970 if ( c->argc > 2 ) {
1973 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1974 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1975 "<%s> only one server ID allowed now", c->argv[0] );
1976 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1977 c->log, c->cr_msg, c->argv[1] );
1981 if ( ldap_url_parse( c->argv[2], &lud )) {
1982 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1983 "<%s> invalid URL", c->argv[0] );
1984 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1985 c->log, c->cr_msg, c->argv[2] );
1988 len = strlen( c->argv[2] );
1989 si = ch_malloc( sizeof(ServerID) + len + 1 );
1990 si->si_url.bv_val = (char *)(si+1);
1991 si->si_url.bv_len = len;
1992 strcpy( si->si_url.bv_val, c->argv[2] );
1995 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1996 "<%s> unqualified server ID not allowed now", c->argv[0] );
1997 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1998 c->log, c->cr_msg, c->argv[1] );
2001 si = ch_malloc( sizeof(ServerID) );
2002 BER_BVZERO( &si->si_url );
2003 slap_serverID = num;
2004 Debug( LDAP_DEBUG_CONFIG,
2006 c->log, slap_serverID, 0 );
2010 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
2013 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
2014 Listener *l = config_check_my_url( c->argv[2], lud );
2016 slap_serverID = si->si_num;
2017 Debug( LDAP_DEBUG_CONFIG,
2018 "%s: SID=0x%03x (listener=%s)\n",
2019 c->log, slap_serverID,
2024 ldap_free_urldesc( lud );
2028 if ( logfileName ) ch_free( logfileName );
2029 logfileName = c->value_string;
2030 logfile = fopen(logfileName, "w");
2031 if(logfile) lutil_debug_file(logfile);
2035 if(SLAP_NOLASTMODCMD(c->be)) {
2036 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> not available for %s database",
2037 c->argv[0], c->be->bd_info->bi_type );
2038 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2039 c->log, c->cr_msg, 0 );
2043 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
2045 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
2048 case CFG_MIRRORMODE:
2049 if(c->value_int && !SLAP_SHADOW(c->be)) {
2050 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database is not a shadow",
2052 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2053 c->log, c->cr_msg, 0 );
2057 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
2059 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
2062 case CFG_MONITORING:
2064 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
2066 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
2071 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
2073 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
2076 case CFG_SYNC_SUBENTRY:
2078 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SYNC_SUBENTRY;
2080 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SYNC_SUBENTRY;
2083 case CFG_SSTR_IF_MAX:
2084 if (c->value_uint < index_substr_if_minlen) {
2085 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2086 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2087 c->log, c->cr_msg, c->value_int );
2090 index_substr_if_maxlen = c->value_uint;
2093 case CFG_SSTR_IF_MIN:
2094 if (c->value_uint > index_substr_if_maxlen) {
2095 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2096 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2097 c->log, c->cr_msg, c->value_int );
2100 index_substr_if_minlen = c->value_uint;
2103 #ifdef SLAPD_MODULES
2105 /* If we're just adding a module on an existing modpath,
2106 * make sure we've selected the current path.
2108 if ( c->op == LDAP_MOD_ADD && c->ca_private && modcur != c->ca_private ) {
2109 modcur = c->ca_private;
2110 /* This should never fail */
2111 if ( module_path( modcur->mp_path.bv_val )) {
2112 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> module path no longer valid",
2114 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2115 c->log, c->cr_msg, modcur->mp_path.bv_val );
2119 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
2121 /* Record this load on the current path */
2125 if ( c->op == SLAP_CONFIG_ADD ) {
2126 ptr = c->line + STRLENOF("moduleload");
2127 while (!isspace((unsigned char) *ptr)) ptr++;
2128 while (isspace((unsigned char) *ptr)) ptr++;
2132 ber_str2bv(ptr, 0, 1, &bv);
2133 ber_bvarray_add( &modcur->mp_loads, &bv );
2135 /* Check for any new hardcoded schema */
2136 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
2137 config_check_schema( NULL, &cfBackInfo );
2142 if(module_path(c->argv[1])) return(1);
2143 /* Record which path was used with each module */
2147 if (!modpaths.mp_loads) {
2150 mp = ch_malloc( sizeof( ModPaths ));
2151 modlast->mp_next = mp;
2153 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
2155 mp->mp_loads = NULL;
2166 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
2168 slapi_plugins_used++;
2172 #ifdef SLAP_AUTH_REWRITE
2178 if ( c->op == LDAP_MOD_ADD ) {
2182 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
2186 if ( c->argc > 1 ) {
2189 /* quote all args but the first */
2190 line = ldap_charray2str( c->argv, "\" \"" );
2191 ber_str2bv( line, 0, 0, &bv );
2192 s = ber_bvchr( &bv, '"' );
2193 assert( s != NULL );
2194 /* move the trailing quote of argv[0] to the end */
2195 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
2196 bv.bv_val[ bv.bv_len - 1 ] = '"';
2199 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
2202 ber_bvarray_add( &authz_rewrites, &bv );
2204 if ( c->op == LDAP_MOD_ADD ) {
2214 Debug( LDAP_DEBUG_ANY,
2215 "%s: unknown CFG_TYPE %d.\n",
2216 c->log, c->type, 0 );
2225 config_fname(ConfigArgs *c) {
2226 if(c->op == SLAP_CONFIG_EMIT) {
2227 if (c->ca_private) {
2228 ConfigFile *cf = c->ca_private;
2229 value_add_one( &c->rvalue_vals, &cf->c_file );
2238 config_cfdir(ConfigArgs *c) {
2239 if(c->op == SLAP_CONFIG_EMIT) {
2240 if ( !BER_BVISEMPTY( &cfdir )) {
2241 value_add_one( &c->rvalue_vals, &cfdir );
2250 config_search_base(ConfigArgs *c) {
2251 if(c->op == SLAP_CONFIG_EMIT) {
2253 if (!BER_BVISEMPTY(&default_search_base)) {
2254 value_add_one(&c->rvalue_vals, &default_search_base);
2255 value_add_one(&c->rvalue_nvals, &default_search_nbase);
2259 } else if( c->op == LDAP_MOD_DELETE ) {
2260 ch_free( default_search_base.bv_val );
2261 ch_free( default_search_nbase.bv_val );
2262 BER_BVZERO( &default_search_base );
2263 BER_BVZERO( &default_search_nbase );
2267 if(c->bi || c->be != frontendDB) {
2268 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
2269 "prior to any backend or database definition\n",
2274 if(default_search_nbase.bv_len) {
2275 free(default_search_base.bv_val);
2276 free(default_search_nbase.bv_val);
2279 default_search_base = c->value_dn;
2280 default_search_nbase = c->value_ndn;
2284 /* For RE23 compatibility we allow this in the global entry
2285 * but we now defer it to the frontend entry to allow modules
2286 * to load new hash types.
2289 config_passwd_hash(ConfigArgs *c) {
2291 if (c->op == SLAP_CONFIG_EMIT) {
2293 /* Don't generate it in the global entry */
2294 if ( c->table == Cft_Global )
2296 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
2297 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
2298 value_add_one(&c->rvalue_vals, &bv);
2301 } else if ( c->op == LDAP_MOD_DELETE ) {
2302 /* Deleting from global is a no-op, only the frontendDB entry matters */
2303 if ( c->table == Cft_Global )
2305 if ( c->valx < 0 ) {
2306 ldap_charray_free( default_passwd_hash );
2307 default_passwd_hash = NULL;
2310 ch_free( default_passwd_hash[i] );
2311 for (; default_passwd_hash[i]; i++ )
2312 default_passwd_hash[i] = default_passwd_hash[i+1];
2316 for(i = 1; i < c->argc; i++) {
2317 if(!lutil_passwd_scheme(c->argv[i])) {
2318 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
2319 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2320 c->log, c->cr_msg, c->argv[i]);
2322 ldap_charray_add(&default_passwd_hash, c->argv[i]);
2325 if(!default_passwd_hash) {
2326 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
2327 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2328 c->log, c->cr_msg, 0 );
2335 config_schema_dn(ConfigArgs *c) {
2336 if ( c->op == SLAP_CONFIG_EMIT ) {
2338 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
2339 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
2340 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
2344 } else if ( c->op == LDAP_MOD_DELETE ) {
2345 ch_free( c->be->be_schemadn.bv_val );
2346 ch_free( c->be->be_schemandn.bv_val );
2347 BER_BVZERO( &c->be->be_schemadn );
2348 BER_BVZERO( &c->be->be_schemandn );
2351 ch_free( c->be->be_schemadn.bv_val );
2352 ch_free( c->be->be_schemandn.bv_val );
2353 c->be->be_schemadn = c->value_dn;
2354 c->be->be_schemandn = c->value_ndn;
2359 config_sizelimit(ConfigArgs *c) {
2361 struct slap_limits_set *lim = &c->be->be_def_limit;
2362 if (c->op == SLAP_CONFIG_EMIT) {
2367 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
2368 if ( !BER_BVISEMPTY( &bv ))
2369 value_add_one( &c->rvalue_vals, &bv );
2373 } else if ( c->op == LDAP_MOD_DELETE ) {
2374 /* Reset to defaults or values from frontend */
2375 if ( c->be == frontendDB ) {
2376 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
2377 lim->lms_s_hard = 0;
2378 lim->lms_s_unchecked = -1;
2380 lim->lms_s_pr_hide = 0;
2381 lim->lms_s_pr_total = 0;
2383 lim->lms_s_soft = frontendDB->be_def_limit.lms_s_soft;
2384 lim->lms_s_hard = frontendDB->be_def_limit.lms_s_hard;
2385 lim->lms_s_unchecked = frontendDB->be_def_limit.lms_s_unchecked;
2386 lim->lms_s_pr = frontendDB->be_def_limit.lms_s_pr;
2387 lim->lms_s_pr_hide = frontendDB->be_def_limit.lms_s_pr_hide;
2388 lim->lms_s_pr_total = frontendDB->be_def_limit.lms_s_pr_total;
2392 for(i = 1; i < c->argc; i++) {
2393 if(!strncasecmp(c->argv[i], "size", 4)) {
2394 rc = limits_parse_one(c->argv[i], lim);
2396 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2397 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2398 c->log, c->cr_msg, c->argv[i]);
2402 if(!strcasecmp(c->argv[i], "unlimited")) {
2403 lim->lms_s_soft = -1;
2405 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
2406 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2407 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2408 c->log, c->cr_msg, c->argv[i]);
2412 lim->lms_s_hard = 0;
2417 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2418 /* This is a modification to the global limits apply it to
2419 * the other databases as needed */
2420 AttributeDescription *ad=NULL;
2421 const char *text = NULL;
2422 CfEntryInfo *ce = c->ca_entry->e_private;
2424 slap_str2ad(c->argv[0], &ad, &text);
2425 /* if we got here... */
2426 assert( ad != NULL );
2428 if ( ce->ce_type == Cft_Global ){
2431 for (; ce; ce=ce->ce_sibs) {
2432 Entry *dbe = ce->ce_entry;
2433 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2434 && (!attr_find(dbe->e_attrs, ad)) ) {
2435 ce->ce_be->be_def_limit.lms_s_soft = lim->lms_s_soft;
2436 ce->ce_be->be_def_limit.lms_s_hard = lim->lms_s_hard;
2437 ce->ce_be->be_def_limit.lms_s_unchecked =lim->lms_s_unchecked;
2438 ce->ce_be->be_def_limit.lms_s_pr =lim->lms_s_pr;
2439 ce->ce_be->be_def_limit.lms_s_pr_hide =lim->lms_s_pr_hide;
2440 ce->ce_be->be_def_limit.lms_s_pr_total =lim->lms_s_pr_total;
2448 config_timelimit(ConfigArgs *c) {
2450 struct slap_limits_set *lim = &c->be->be_def_limit;
2451 if (c->op == SLAP_CONFIG_EMIT) {
2456 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
2457 if ( !BER_BVISEMPTY( &bv ))
2458 value_add_one( &c->rvalue_vals, &bv );
2462 } else if ( c->op == LDAP_MOD_DELETE ) {
2463 /* Reset to defaults or values from frontend */
2464 if ( c->be == frontendDB ) {
2465 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
2466 lim->lms_t_hard = 0;
2468 lim->lms_t_soft = frontendDB->be_def_limit.lms_t_soft;
2469 lim->lms_t_hard = frontendDB->be_def_limit.lms_t_hard;
2473 for(i = 1; i < c->argc; i++) {
2474 if(!strncasecmp(c->argv[i], "time", 4)) {
2475 rc = limits_parse_one(c->argv[i], lim);
2477 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2478 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2479 c->log, c->cr_msg, c->argv[i]);
2483 if(!strcasecmp(c->argv[i], "unlimited")) {
2484 lim->lms_t_soft = -1;
2486 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
2487 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2488 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2489 c->log, c->cr_msg, c->argv[i]);
2493 lim->lms_t_hard = 0;
2498 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2499 /* This is a modification to the global limits apply it to
2500 * the other databases as needed */
2501 AttributeDescription *ad=NULL;
2502 const char *text = NULL;
2503 CfEntryInfo *ce = c->ca_entry->e_private;
2505 slap_str2ad(c->argv[0], &ad, &text);
2506 /* if we got here... */
2507 assert( ad != NULL );
2509 if ( ce->ce_type == Cft_Global ){
2512 for (; ce; ce=ce->ce_sibs) {
2513 Entry *dbe = ce->ce_entry;
2514 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2515 && (!attr_find(dbe->e_attrs, ad)) ) {
2516 ce->ce_be->be_def_limit.lms_t_soft = lim->lms_t_soft;
2517 ce->ce_be->be_def_limit.lms_t_hard = lim->lms_t_hard;
2525 config_overlay(ConfigArgs *c) {
2526 if (c->op == SLAP_CONFIG_EMIT) {
2528 } else if ( c->op == LDAP_MOD_DELETE ) {
2531 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
2532 c->valx, &c->bi, &c->reply)) {
2534 Debug( LDAP_DEBUG_ANY,
2535 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
2536 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
2538 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi, &c->reply)) {
2545 config_subordinate(ConfigArgs *c)
2551 case SLAP_CONFIG_EMIT:
2552 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
2555 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
2556 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
2559 value_add_one( &c->rvalue_vals, &bv );
2563 case LDAP_MOD_DELETE:
2564 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2565 glue_sub_del( c->be );
2567 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2572 case SLAP_CONFIG_ADD:
2573 if ( c->be->be_nsuffix == NULL ) {
2575 snprintf( c->cr_msg, sizeof( c->cr_msg),
2576 "subordinate configuration needs a suffix" );
2577 Debug( LDAP_DEBUG_ANY,
2579 c->log, c->cr_msg, 0 );
2584 if ( c->argc == 2 ) {
2585 if ( strcasecmp( c->argv[1], "advertise" ) == 0 ) {
2588 } else if ( strcasecmp( c->argv[1], "TRUE" ) != 0 ) {
2590 snprintf( c->cr_msg, sizeof( c->cr_msg),
2591 "subordinate must be \"TRUE\" or \"advertise\"" );
2592 Debug( LDAP_DEBUG_ANY,
2593 "%s: suffix \"%s\": %s.\n",
2594 c->log, c->be->be_suffix[0].bv_val, c->cr_msg );
2600 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2608 * [listener=<listener>] [{read|write}=]<size>
2611 #ifdef LDAP_TCP_BUFFER
2612 static BerVarray tcp_buffer;
2615 #define SLAP_TCP_RMEM (0x1U)
2616 #define SLAP_TCP_WMEM (0x2U)
2619 tcp_buffer_parse( struct berval *val, int argc, char **argv,
2620 int *size, int *rw, Listener **l )
2622 int i, rc = LDAP_SUCCESS;
2623 LDAPURLDesc *lud = NULL;
2626 if ( val != NULL && argv == NULL ) {
2627 char *s = val->bv_val;
2629 argv = ldap_str2charray( s, " \t" );
2630 if ( argv == NULL ) {
2636 if ( strncasecmp( argv[ i ], "listener=", STRLENOF( "listener=" ) )
2639 char *url = argv[ i ] + STRLENOF( "listener=" );
2641 if ( ldap_url_parse( url, &lud ) ) {
2642 rc = LDAP_INVALID_SYNTAX;
2646 *l = config_check_my_url( url, lud );
2648 rc = LDAP_NO_SUCH_ATTRIBUTE;
2656 if ( strncasecmp( ptr, "read=", STRLENOF( "read=" ) ) == 0 ) {
2657 *rw |= SLAP_TCP_RMEM;
2658 ptr += STRLENOF( "read=" );
2660 } else if ( strncasecmp( ptr, "write=", STRLENOF( "write=" ) ) == 0 ) {
2661 *rw |= SLAP_TCP_WMEM;
2662 ptr += STRLENOF( "write=" );
2665 *rw |= ( SLAP_TCP_RMEM | SLAP_TCP_WMEM );
2668 /* accept any base */
2669 if ( lutil_atoix( size, ptr, 0 ) ) {
2670 rc = LDAP_INVALID_SYNTAX;
2675 if ( val != NULL && argv != NULL ) {
2676 ldap_charray_free( argv );
2679 if ( lud != NULL ) {
2680 ldap_free_urldesc( lud );
2687 tcp_buffer_delete_one( struct berval *val )
2690 int size = -1, rw = 0;
2693 rc = tcp_buffer_parse( val, 0, NULL, &size, &rw, &l );
2700 Listener **ll = slapd_get_listeners();
2702 for ( i = 0; ll[ i ] != NULL; i++ ) {
2703 if ( ll[ i ] == l ) break;
2706 if ( ll[ i ] == NULL ) {
2707 return LDAP_NO_SUCH_ATTRIBUTE;
2710 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = -1;
2711 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = -1;
2713 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2714 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = -1;
2715 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = -1;
2719 /* NOTE: this affects listeners without a specific setting,
2720 * does not reset all listeners. If a listener without
2721 * specific settings was assigned a buffer because of
2722 * a global setting, it will not be reset. In any case,
2723 * buffer changes will only take place at restart. */
2724 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = -1;
2725 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = -1;
2732 tcp_buffer_delete( BerVarray vals )
2736 for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ ) {
2737 tcp_buffer_delete_one( &vals[ i ] );
2744 tcp_buffer_unparse( int size, int rw, Listener *l, struct berval *val )
2746 char buf[sizeof("2147483648")], *ptr;
2748 /* unparse for later use */
2749 val->bv_len = snprintf( buf, sizeof( buf ), "%d", size );
2751 val->bv_len += STRLENOF( "listener=" " " ) + l->sl_url.bv_len;
2754 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2755 if ( rw & SLAP_TCP_RMEM ) {
2756 val->bv_len += STRLENOF( "read=" );
2757 } else if ( rw & SLAP_TCP_WMEM ) {
2758 val->bv_len += STRLENOF( "write=" );
2762 val->bv_val = SLAP_MALLOC( val->bv_len + 1 );
2767 ptr = lutil_strcopy( ptr, "listener=" );
2768 ptr = lutil_strncopy( ptr, l->sl_url.bv_val, l->sl_url.bv_len );
2772 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2773 if ( rw & SLAP_TCP_RMEM ) {
2774 ptr = lutil_strcopy( ptr, "read=" );
2775 } else if ( rw & SLAP_TCP_WMEM ) {
2776 ptr = lutil_strcopy( ptr, "write=" );
2780 ptr = lutil_strcopy( ptr, buf );
2783 assert( val->bv_val + val->bv_len == ptr );
2785 return LDAP_SUCCESS;
2789 tcp_buffer_add_one( int argc, char **argv )
2792 int size = -1, rw = 0;
2798 rc = tcp_buffer_parse( NULL, argc, argv, &size, &rw, &l );
2803 /* unparse for later use */
2804 rc = tcp_buffer_unparse( size, rw, l, &val );
2805 if ( rc != LDAP_SUCCESS ) {
2809 /* use parsed values */
2812 Listener **ll = slapd_get_listeners();
2814 for ( i = 0; ll[ i ] != NULL; i++ ) {
2815 if ( ll[ i ] == l ) break;
2818 if ( ll[ i ] == NULL ) {
2819 return LDAP_NO_SUCH_ATTRIBUTE;
2822 /* buffer only applies to TCP listeners;
2823 * we do not do any check here, and delegate them
2824 * to setsockopt(2) */
2825 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = size;
2826 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = size;
2828 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2829 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = size;
2830 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = size;
2834 /* NOTE: this affects listeners without a specific setting,
2835 * does not set all listeners */
2836 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = size;
2837 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = size;
2840 tcp_buffer = SLAP_REALLOC( tcp_buffer, sizeof( struct berval ) * ( tcp_buffer_num + 2 ) );
2842 tcp_buffer[ tcp_buffer_num ] = val;
2845 BER_BVZERO( &tcp_buffer[ tcp_buffer_num ] );
2851 config_tcp_buffer( ConfigArgs *c )
2853 if ( c->op == SLAP_CONFIG_EMIT ) {
2854 if ( tcp_buffer == NULL || BER_BVISNULL( &tcp_buffer[ 0 ] ) ) {
2857 value_add( &c->rvalue_vals, tcp_buffer );
2858 value_add( &c->rvalue_nvals, tcp_buffer );
2860 } else if ( c->op == LDAP_MOD_DELETE ) {
2862 tcp_buffer_delete( tcp_buffer );
2863 ber_bvarray_free( tcp_buffer );
2869 int size = -1, rw = 0;
2872 struct berval val = BER_BVNULL;
2876 if ( tcp_buffer_num == 0 ) {
2881 rc = tcp_buffer_parse( NULL, c->argc - 1, &c->argv[ 1 ], &size, &rw, &l );
2886 /* unparse for later use */
2887 rc = tcp_buffer_unparse( size, rw, l, &val );
2888 if ( rc != LDAP_SUCCESS ) {
2892 for ( i = 0; !BER_BVISNULL( &tcp_buffer[ i ] ); i++ ) {
2893 if ( bvmatch( &tcp_buffer[ i ], &val ) ) {
2898 if ( BER_BVISNULL( &tcp_buffer[ i ] ) ) {
2904 tcp_buffer_delete_one( &tcp_buffer[ i ] );
2905 ber_memfree( tcp_buffer[ i ].bv_val );
2906 for ( ; i < tcp_buffer_num; i++ ) {
2907 tcp_buffer[ i ] = tcp_buffer[ i + 1 ];
2912 if ( !BER_BVISNULL( &val ) ) {
2913 SLAP_FREE( val.bv_val );
2921 rc = tcp_buffer_add_one( c->argc - 1, &c->argv[ 1 ] );
2923 snprintf( c->cr_msg, sizeof( c->cr_msg ),
2924 "<%s> unable to add value #%d",
2925 c->argv[0], tcp_buffer_num );
2926 Debug( LDAP_DEBUG_ANY, "%s: %s\n",
2927 c->log, c->cr_msg, 0 );
2934 #endif /* LDAP_TCP_BUFFER */
2937 config_suffix(ConfigArgs *c)
2940 struct berval pdn, ndn;
2941 char *notallowed = NULL;
2943 if ( c->be == frontendDB ) {
2944 notallowed = "frontend";
2946 } else if ( SLAP_MONITOR(c->be) ) {
2947 notallowed = "monitor";
2949 } else if ( SLAP_CONFIG(c->be) ) {
2950 notallowed = "config";
2953 if ( notallowed != NULL ) {
2954 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2958 case LDAP_MOD_DELETE:
2959 case LDAP_MOD_REPLACE:
2960 case LDAP_MOD_INCREMENT:
2961 case SLAP_CONFIG_ADD:
2962 if ( !BER_BVISNULL( &c->value_dn ) ) {
2963 snprintf( buf, sizeof( buf ), "<%s> ",
2964 c->value_dn.bv_val );
2967 Debug(LDAP_DEBUG_ANY,
2968 "%s: suffix %snot allowed in %s database.\n",
2969 c->log, buf, notallowed );
2972 case SLAP_CONFIG_EMIT:
2973 /* don't complain when emitting... */
2977 /* FIXME: don't know what values may be valid;
2978 * please remove assertion, or add legal values
2979 * to either block */
2987 if (c->op == SLAP_CONFIG_EMIT) {
2988 if ( c->be->be_suffix == NULL
2989 || BER_BVISNULL( &c->be->be_suffix[0] ) )
2993 value_add( &c->rvalue_vals, c->be->be_suffix );
2994 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
2997 } else if ( c->op == LDAP_MOD_DELETE ) {
2998 if ( c->valx < 0 ) {
2999 ber_bvarray_free( c->be->be_suffix );
3000 ber_bvarray_free( c->be->be_nsuffix );
3001 c->be->be_suffix = NULL;
3002 c->be->be_nsuffix = NULL;
3005 ch_free( c->be->be_suffix[i].bv_val );
3006 ch_free( c->be->be_nsuffix[i].bv_val );
3008 c->be->be_suffix[i] = c->be->be_suffix[i+1];
3009 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
3011 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
3016 #ifdef SLAPD_MONITOR_DN
3017 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
3018 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> DN is reserved for monitoring slapd",
3020 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3021 c->log, c->cr_msg, SLAPD_MONITOR_DN);
3026 if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
3027 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
3028 c->argv[0], c->be->bd_info->bi_type );
3029 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3030 c->log, c->cr_msg, 0);
3037 if (SLAP_DBHIDDEN( c->be ))
3040 tbe = select_backend(&ndn, 0);
3042 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
3048 BackendDB *b2 = tbe;
3050 /* Does tbe precede be? */
3051 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
3054 char *type = tbe->bd_info->bi_type;
3056 if ( overlay_is_over( tbe ) ) {
3057 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
3058 type = oi->oi_orig->bi_type;
3061 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> namingContext \"%s\" "
3062 "already served by a preceding %s database",
3063 c->argv[0], pdn.bv_val, type );
3064 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
3065 c->log, c->cr_msg, tbe->be_suffix[0].bv_val);
3071 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
3072 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
3073 "base provided \"%s\" (assuming okay)\n",
3074 c->log, default_search_base.bv_val, 0);
3076 ber_bvarray_add(&c->be->be_suffix, &pdn);
3077 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
3082 config_rootdn(ConfigArgs *c) {
3083 if (c->op == SLAP_CONFIG_EMIT) {
3084 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3085 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
3086 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
3091 } else if ( c->op == LDAP_MOD_DELETE ) {
3092 ch_free( c->be->be_rootdn.bv_val );
3093 ch_free( c->be->be_rootndn.bv_val );
3094 BER_BVZERO( &c->be->be_rootdn );
3095 BER_BVZERO( &c->be->be_rootndn );
3098 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3099 ch_free( c->be->be_rootdn.bv_val );
3100 ch_free( c->be->be_rootndn.bv_val );
3102 c->be->be_rootdn = c->value_dn;
3103 c->be->be_rootndn = c->value_ndn;
3108 config_rootpw(ConfigArgs *c) {
3111 if (c->op == SLAP_CONFIG_EMIT) {
3112 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
3113 /* don't copy, because "rootpw" is marked
3115 c->value_bv = c->be->be_rootpw;
3119 } else if ( c->op == LDAP_MOD_DELETE ) {
3120 ch_free( c->be->be_rootpw.bv_val );
3121 BER_BVZERO( &c->be->be_rootpw );
3125 tbe = select_backend(&c->be->be_rootndn, 0);
3127 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> can only be set when rootdn is under suffix",
3129 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3130 c->log, c->cr_msg, 0);
3133 if ( !BER_BVISNULL( &c->be->be_rootpw ))
3134 ch_free( c->be->be_rootpw.bv_val );
3135 c->be->be_rootpw = c->value_bv;
3140 config_restrict(ConfigArgs *c) {
3141 slap_mask_t restrictops = 0;
3143 slap_verbmasks restrictable_ops[] = {
3144 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
3145 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
3146 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
3147 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
3148 { BER_BVC("modrdn"), 0 },
3149 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
3150 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
3151 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
3152 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
3153 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
3154 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
3155 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
3156 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
3157 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
3158 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
3159 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
3163 if (c->op == SLAP_CONFIG_EMIT) {
3164 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
3166 } else if ( c->op == LDAP_MOD_DELETE ) {
3168 c->be->be_restrictops = 0;
3170 restrictops = verb_to_mask( c->line, restrictable_ops );
3171 c->be->be_restrictops ^= restrictops;
3175 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
3177 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown operation", c->argv[0] );
3178 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3179 c->log, c->cr_msg, c->argv[i]);
3182 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
3183 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
3184 c->be->be_restrictops |= restrictops;
3189 config_allows(ConfigArgs *c) {
3190 slap_mask_t allows = 0;
3192 slap_verbmasks allowable_ops[] = {
3193 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
3194 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
3195 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
3196 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
3197 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
3200 if (c->op == SLAP_CONFIG_EMIT) {
3201 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
3202 } else if ( c->op == LDAP_MOD_DELETE ) {
3206 allows = verb_to_mask( c->line, allowable_ops );
3207 global_allows ^= allows;
3211 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
3213 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3214 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3215 c->log, c->cr_msg, c->argv[i]);
3218 global_allows |= allows;
3223 config_disallows(ConfigArgs *c) {
3224 slap_mask_t disallows = 0;
3226 slap_verbmasks disallowable_ops[] = {
3227 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
3228 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
3229 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
3230 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
3231 { BER_BVC("proxy_authz_non_critical"), SLAP_DISALLOW_PROXY_AUTHZ_N_CRIT },
3232 { BER_BVC("dontusecopy_non_critical"), SLAP_DISALLOW_DONTUSECOPY_N_CRIT },
3235 if (c->op == SLAP_CONFIG_EMIT) {
3236 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
3237 } else if ( c->op == LDAP_MOD_DELETE ) {
3239 global_disallows = 0;
3241 disallows = verb_to_mask( c->line, disallowable_ops );
3242 global_disallows ^= disallows;
3246 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
3248 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3249 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3250 c->log, c->cr_msg, c->argv[i]);
3253 global_disallows |= disallows;
3258 config_requires(ConfigArgs *c) {
3259 slap_mask_t requires = frontendDB->be_requires;
3260 int i, argc = c->argc;
3261 char **argv = c->argv;
3263 slap_verbmasks requires_ops[] = {
3264 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
3265 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
3266 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
3267 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
3268 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
3271 if (c->op == SLAP_CONFIG_EMIT) {
3272 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
3273 } else if ( c->op == LDAP_MOD_DELETE ) {
3275 c->be->be_requires = 0;
3277 requires = verb_to_mask( c->line, requires_ops );
3278 c->be->be_requires ^= requires;
3282 /* "none" can only be first, to wipe out default/global values */
3283 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
3288 i = verbs_to_mask(argc, argv, requires_ops, &requires);
3290 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
3291 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
3292 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3293 c->log, c->cr_msg, 0);
3295 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
3296 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3297 c->log, c->cr_msg, c->argv[i]);
3301 c->be->be_requires = requires;
3306 config_extra_attrs(ConfigArgs *c)
3308 assert( c->be != NULL );
3310 if ( c->op == SLAP_CONFIG_EMIT ) {
3313 if ( c->be->be_extra_anlist == NULL ) {
3317 for ( i = 0; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3318 value_add_one( &c->rvalue_vals, &c->be->be_extra_anlist[i].an_name );
3321 } else if ( c->op == LDAP_MOD_DELETE ) {
3322 if ( c->be->be_extra_anlist == NULL ) {
3326 if ( c->valx < 0 ) {
3327 anlist_free( c->be->be_extra_anlist, 1, NULL );
3328 c->be->be_extra_anlist = NULL;
3333 for ( i = 0; i < c->valx && !BER_BVISNULL( &c->be->be_extra_anlist[i + 1].an_name ); i++ )
3336 if ( BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ) ) {
3340 ch_free( c->be->be_extra_anlist[i].an_name.bv_val );
3342 for ( ; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3343 c->be->be_extra_anlist[i] = c->be->be_extra_anlist[i + 1];
3348 c->be->be_extra_anlist = str2anlist( c->be->be_extra_anlist, c->argv[1], " ,\t" );
3349 if ( c->be->be_extra_anlist == NULL ) {
3357 static slap_verbmasks *loglevel_ops;
3360 loglevel_init( void )
3362 slap_verbmasks lo[] = {
3363 { BER_BVC("Any"), (slap_mask_t) LDAP_DEBUG_ANY },
3364 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
3365 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
3366 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
3367 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
3368 { BER_BVC("BER"), LDAP_DEBUG_BER },
3369 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
3370 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
3371 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
3372 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
3373 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
3374 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
3375 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
3376 #if 0 /* no longer used (nor supported) */
3377 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
3378 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
3380 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
3381 { BER_BVC("None"), LDAP_DEBUG_NONE },
3385 return slap_verbmasks_init( &loglevel_ops, lo );
3389 loglevel_destroy( void )
3391 if ( loglevel_ops ) {
3392 (void)slap_verbmasks_destroy( loglevel_ops );
3394 loglevel_ops = NULL;
3397 static slap_mask_t loglevel_ignore[] = { -1, 0 };
3400 slap_loglevel_register( slap_mask_t m, struct berval *s )
3404 if ( loglevel_ops == NULL ) {
3408 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
3411 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
3419 slap_loglevel_get( struct berval *s, int *l )
3424 if ( loglevel_ops == NULL ) {
3428 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3429 m |= loglevel_ops[ i ].mask;
3432 for ( i = 1; m & i; i <<= 1 )
3439 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
3442 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
3453 str2loglevel( const char *s, int *l )
3457 if ( loglevel_ops == NULL ) {
3461 i = verb_to_mask( s, loglevel_ops );
3463 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
3467 *l = loglevel_ops[ i ].mask;
3473 loglevel2str( int l )
3475 struct berval bv = BER_BVNULL;
3477 loglevel2bv( l, &bv );
3483 loglevel2bv( int l, struct berval *bv )
3485 if ( loglevel_ops == NULL ) {
3491 return enum_to_verb( loglevel_ops, l, bv ) == -1;
3495 loglevel2bvarray( int l, BerVarray *bva )
3497 if ( loglevel_ops == NULL ) {
3501 return mask_to_verbs( loglevel_ops, l, bva );
3505 loglevel_print( FILE *out )
3509 if ( loglevel_ops == NULL ) {
3513 fprintf( out, "Installed log subsystems:\n\n" );
3514 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3515 unsigned mask = loglevel_ops[ i ].mask & 0xffffffffUL;
3517 (mask == ((slap_mask_t) -1 & 0xffffffffUL)
3518 ? "\t%-30s (-1, 0xffffffff)\n" : "\t%-30s (%u, 0x%x)\n"),
3519 loglevel_ops[ i ].word.bv_val, mask, mask );
3522 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
3523 "by specific code\n\n" );
3528 static int config_syslog;
3531 config_loglevel(ConfigArgs *c) {
3534 if ( loglevel_ops == NULL ) {
3538 if (c->op == SLAP_CONFIG_EMIT) {
3539 /* Get default or commandline slapd setting */
3540 if ( ldap_syslog && !config_syslog )
3541 config_syslog = ldap_syslog;
3542 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
3544 } else if ( c->op == LDAP_MOD_DELETE ) {
3548 int level = verb_to_mask( c->line, loglevel_ops );
3549 config_syslog ^= level;
3551 if ( slapMode & SLAP_SERVER_MODE ) {
3552 ldap_syslog = config_syslog;
3557 for( i=1; i < c->argc; i++ ) {
3560 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
3561 if( lutil_atoix( &level, c->argv[i], 0 ) != 0 ) {
3562 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
3563 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3564 c->log, c->cr_msg, c->argv[i]);
3568 if ( str2loglevel( c->argv[i], &level ) ) {
3569 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown level", c->argv[0] );
3570 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3571 c->log, c->cr_msg, c->argv[i]);
3575 /* Explicitly setting a zero clears all the levels */
3577 config_syslog |= level;
3581 if ( slapMode & SLAP_SERVER_MODE ) {
3582 ldap_syslog = config_syslog;
3588 config_referral(ConfigArgs *c) {
3590 if (c->op == SLAP_CONFIG_EMIT) {
3591 if ( default_referral ) {
3592 value_add( &c->rvalue_vals, default_referral );
3597 } else if ( c->op == LDAP_MOD_DELETE ) {
3598 if ( c->valx < 0 ) {
3599 ber_bvarray_free( default_referral );
3600 default_referral = NULL;
3603 ch_free( default_referral[i].bv_val );
3604 for (; default_referral[i].bv_val; i++ )
3605 default_referral[i] = default_referral[i+1];
3609 if(validate_global_referral(c->argv[1])) {
3610 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3611 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3612 c->log, c->cr_msg, c->argv[1]);
3616 ber_str2bv(c->argv[1], 0, 0, &val);
3617 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
3625 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
3626 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
3627 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
3628 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
3629 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
3630 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
3631 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
3632 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
3633 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
3638 config_security(ConfigArgs *c) {
3639 slap_ssf_set_t *set = &c->be->be_ssf_set;
3642 if (c->op == SLAP_CONFIG_EMIT) {
3648 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
3649 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
3652 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
3653 if ( bv.bv_len >= sizeof( numbuf ) ) {
3654 ber_bvarray_free_x( c->rvalue_vals, NULL );
3655 c->rvalue_vals = NULL;
3659 bv.bv_len += sec_keys[i].key.bv_len;
3660 bv.bv_val = ch_malloc( bv.bv_len + 1);
3661 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
3662 strcpy( next, numbuf );
3663 ber_bvarray_add( &c->rvalue_vals, &bv );
3668 for(i = 1; i < c->argc; i++) {
3669 slap_ssf_t *tgt = NULL;
3671 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
3672 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
3673 sec_keys[j].key.bv_len)) {
3674 src = c->argv[i] + sec_keys[j].key.bv_len;
3675 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
3680 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown factor", c->argv[0] );
3681 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3682 c->log, c->cr_msg, c->argv[i]);
3686 if ( lutil_atou( tgt, src ) != 0 ) {
3687 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse factor", c->argv[0] );
3688 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3689 c->log, c->cr_msg, c->argv[i]);
3697 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
3701 for (; !BER_BVISNULL( &an->an_name ); an++) {
3702 /* if buflen == 0, assume the buffer size has been
3703 * already checked otherwise */
3704 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
3705 if ( comma ) *ptr++ = ',';
3706 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
3713 config_updatedn(ConfigArgs *c) {
3714 if (c->op == SLAP_CONFIG_EMIT) {
3715 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
3716 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
3717 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
3721 } else if ( c->op == LDAP_MOD_DELETE ) {
3722 ch_free( c->be->be_update_ndn.bv_val );
3723 BER_BVZERO( &c->be->be_update_ndn );
3724 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
3727 if(SLAP_SHADOW(c->be)) {
3728 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database already shadowed", c->argv[0] );
3729 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3730 c->log, c->cr_msg, 0);
3734 ber_memfree_x( c->value_dn.bv_val, NULL );
3735 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
3736 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
3738 c->be->be_update_ndn = c->value_ndn;
3739 BER_BVZERO( &c->value_dn );
3740 BER_BVZERO( &c->value_ndn );
3742 return config_slurp_shadow( c );
3746 config_shadow( ConfigArgs *c, slap_mask_t flag )
3748 char *notallowed = NULL;
3750 if ( c->be == frontendDB ) {
3751 notallowed = "frontend";
3753 } else if ( SLAP_MONITOR(c->be) ) {
3754 notallowed = "monitor";
3757 if ( notallowed != NULL ) {
3758 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
3762 if ( SLAP_SHADOW(c->be) ) {
3763 /* if already shadow, only check consistency */
3764 if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
3765 Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%lx.\n",
3771 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
3778 config_updateref(ConfigArgs *c) {
3780 if (c->op == SLAP_CONFIG_EMIT) {
3781 if ( c->be->be_update_refs ) {
3782 value_add( &c->rvalue_vals, c->be->be_update_refs );
3787 } else if ( c->op == LDAP_MOD_DELETE ) {
3788 if ( c->valx < 0 ) {
3789 ber_bvarray_free( c->be->be_update_refs );
3790 c->be->be_update_refs = NULL;
3793 ch_free( c->be->be_update_refs[i].bv_val );
3794 for (; c->be->be_update_refs[i].bv_val; i++)
3795 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
3799 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
3800 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> must appear after syncrepl or updatedn",
3802 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3803 c->log, c->cr_msg, 0);
3807 if(validate_global_referral(c->argv[1])) {
3808 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3809 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3810 c->log, c->cr_msg, c->argv[1]);
3813 ber_str2bv(c->argv[1], 0, 0, &val);
3814 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
3819 config_obsolete(ConfigArgs *c) {
3820 if (c->op == SLAP_CONFIG_EMIT)
3823 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> keyword is obsolete (ignored)",
3825 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0);
3830 config_include(ConfigArgs *c) {
3831 int savelineno = c->lineno;
3834 ConfigFile *cfsave = cfn;
3835 ConfigFile *cf2 = NULL;
3837 /* Leftover from RE23. No dynamic config for include files */
3838 if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
3841 cf = ch_calloc( 1, sizeof(ConfigFile));
3842 if ( cfn->c_kids ) {
3843 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
3849 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
3850 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
3851 c->lineno = savelineno - 1;
3854 if ( cf2 ) cf2->c_sibs = NULL;
3855 else cfn->c_kids = NULL;
3856 ch_free( cf->c_file.bv_val );
3866 config_tls_cleanup(ConfigArgs *c) {
3869 if ( slap_tls_ld ) {
3872 ldap_pvt_tls_ctx_free( slap_tls_ctx );
3874 /* Force new ctx to be created */
3875 rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
3877 /* The ctx's refcount is bumped up here */
3878 ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
3879 /* This is a no-op if it's already loaded */
3880 load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
3887 config_tls_option(ConfigArgs *c) {
3889 LDAP *ld = slap_tls_ld;
3891 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
3892 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
3893 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
3894 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
3895 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
3896 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
3897 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
3899 case CFG_TLS_CRL_FILE: flag = LDAP_OPT_X_TLS_CRLFILE; break;
3901 default: Debug(LDAP_DEBUG_ANY, "%s: "
3902 "unknown tls_option <0x%x>\n",
3903 c->log, c->type, 0);
3906 if (c->op == SLAP_CONFIG_EMIT) {
3907 return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3908 } else if ( c->op == LDAP_MOD_DELETE ) {
3909 c->cleanup = config_tls_cleanup;
3910 return ldap_pvt_tls_set_option( ld, flag, NULL );
3912 ch_free(c->value_string);
3913 c->cleanup = config_tls_cleanup;
3914 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3917 /* FIXME: this ought to be provided by libldap */
3919 config_tls_config(ConfigArgs *c) {
3922 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
3923 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
3924 case CFG_TLS_PROTOCOL_MIN: flag = LDAP_OPT_X_TLS_PROTOCOL_MIN; break;
3926 Debug(LDAP_DEBUG_ANY, "%s: "
3927 "unknown tls_option <0x%x>\n",
3928 c->log, c->type, 0);
3931 if (c->op == SLAP_CONFIG_EMIT) {
3932 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3933 } else if ( c->op == LDAP_MOD_DELETE ) {
3935 c->cleanup = config_tls_cleanup;
3936 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3938 ch_free( c->value_string );
3939 c->cleanup = config_tls_cleanup;
3940 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3941 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3942 Debug(LDAP_DEBUG_ANY, "%s: "
3943 "unable to parse %s \"%s\"\n",
3944 c->log, c->argv[0], c->argv[1] );
3947 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
3949 return(ldap_pvt_tls_config(slap_tls_ld, flag, c->argv[1]));
3954 static CfEntryInfo *
3955 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
3965 if ( dn_match( &root->ce_entry->e_nname, dn ))
3968 c = dn->bv_val+dn->bv_len;
3969 for (;*c != ',';c--);
3973 for (--c;c>dn->bv_val && *c != ',';c--);
3977 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
3979 root = root->ce_kids;
3981 for (;root;root=root->ce_sibs) {
3982 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
3983 if ( cdn.bv_val == dn->bv_val ) {
3993 typedef struct setup_cookie {
4003 config_ldif_resp( Operation *op, SlapReply *rs )
4005 if ( rs->sr_type == REP_SEARCH ) {
4006 setup_cookie *sc = op->o_callback->sc_private;
4009 sc->cfb->cb_got_ldif = 1;
4010 /* Does the frontend exist? */
4011 if ( !sc->got_frontend ) {
4012 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
4013 "olcDatabase", STRLENOF( "olcDatabase" )))
4015 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4016 STRLENOF( "olcDatabase" ), "={-1}frontend",
4017 STRLENOF( "={-1}frontend" )))
4021 sc->ca->be = frontendDB;
4022 sc->ca->bi = frontendDB->bd_info;
4023 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
4024 rdn.bv_val = sc->ca->log;
4025 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4026 "%s=" SLAP_X_ORDERED_FMT "%s",
4027 cfAd_database->ad_cname.bv_val, -1,
4028 sc->ca->bi->bi_type);
4030 sc->frontend = config_build_entry( op, rs,
4031 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
4032 sc->ca->be->be_cf_ocs );
4042 dnParent( &rs->sr_entry->e_nname, &pdn );
4044 /* Does the configDB exist? */
4045 if ( sc->got_frontend && !sc->got_config &&
4046 !strncmp( rs->sr_entry->e_nname.bv_val,
4047 "olcDatabase", STRLENOF( "olcDatabase" )) &&
4048 dn_match( &config_rdn, &pdn ) )
4050 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4051 STRLENOF( "olcDatabase" ), "={0}config",
4052 STRLENOF( "={0}config" )))
4056 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
4057 sc->ca->bi = sc->ca->be->bd_info;
4058 rdn.bv_val = sc->ca->log;
4059 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4060 "%s=" SLAP_X_ORDERED_FMT "%s",
4061 cfAd_database->ad_cname.bv_val, 0,
4062 sc->ca->bi->bi_type);
4064 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
4065 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
4072 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
4073 if ( rs->sr_err != LDAP_SUCCESS ) {
4074 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
4075 rs->sr_entry->e_name.bv_val, sc->ca->cr_msg, 0 );
4081 /* Configure and read the underlying back-ldif store */
4083 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
4084 CfBackInfo *cfb = be->be_private;
4090 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
4091 Connection conn = {0};
4092 OperationBuffer opbuf;
4094 SlapReply rs = {REP_RESULT};
4095 Filter filter = { LDAP_FILTER_PRESENT };
4096 struct berval filterstr = BER_BVC("(objectclass=*)");
4099 /* Is the config directory available? */
4100 if ( stat( dir, &st ) < 0 ) {
4101 /* No, so don't bother using the backing store.
4102 * All changes will be in-memory only.
4107 cfb->cb_db.bd_info = backend_info( "ldif" );
4108 if ( !cfb->cb_db.bd_info )
4109 return 0; /* FIXME: eventually this will be a fatal error */
4111 if ( backend_db_init( "ldif", &cfb->cb_db, -1, NULL ) == NULL )
4114 cfb->cb_db.be_suffix = be->be_suffix;
4115 cfb->cb_db.be_nsuffix = be->be_nsuffix;
4117 /* The suffix is always "cn=config". The underlying DB's rootdn
4118 * is always the same as the suffix.
4120 cfb->cb_db.be_rootdn = be->be_suffix[0];
4121 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
4123 ber_str2bv( dir, 0, 1, &cfdir );
4128 argv[0] = "directory";
4129 argv[1] = (char *)dir;
4134 c.table = Cft_Database;
4136 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
4140 if ( config_add_vals( ct, &c ))
4143 if ( backend_startup_one( &cfb->cb_db, &c.reply ))
4147 void *thrctx = ldap_pvt_thread_pool_context();
4150 connection_fake_init( &conn, &opbuf, thrctx );
4153 filter.f_desc = slap_schema.si_ad_objectClass;
4155 op->o_tag = LDAP_REQ_SEARCH;
4157 op->ors_filter = &filter;
4158 op->ors_filterstr = filterstr;
4159 op->ors_scope = LDAP_SCOPE_SUBTREE;
4161 op->o_dn = c.be->be_rootdn;
4162 op->o_ndn = c.be->be_rootndn;
4164 op->o_req_dn = be->be_suffix[0];
4165 op->o_req_ndn = be->be_nsuffix[0];
4167 op->ors_tlimit = SLAP_NO_LIMIT;
4168 op->ors_slimit = SLAP_NO_LIMIT;
4170 op->ors_attrs = slap_anlist_all_attributes;
4171 op->ors_attrsonly = 0;
4173 op->o_callback = &cb;
4176 cb.sc_private = ≻
4177 sc.got_frontend = 0;
4182 op->o_bd = &cfb->cb_db;
4184 /* Allow unknown attrs in DNs */
4185 prev_DN_strict = slap_DN_strict;
4188 rc = op->o_bd->be_search( op, &rs );
4190 /* Restore normal DN validation */
4191 slap_DN_strict = prev_DN_strict;
4193 op->o_tag = LDAP_REQ_ADD;
4194 if ( rc == LDAP_SUCCESS && sc.frontend ) {
4195 op->ora_e = sc.frontend;
4196 rc = op->o_bd->be_add( op, &rs );
4198 if ( rc == LDAP_SUCCESS && sc.config ) {
4199 op->ora_e = sc.config;
4200 rc = op->o_bd->be_add( op, &rs );
4202 ldap_pvt_thread_pool_context_reset( thrctx );
4205 /* ITS#4194 - only use if it's present, or we're converting. */
4206 if ( !readit || rc == LDAP_SUCCESS )
4207 cfb->cb_use_ldif = 1;
4213 CfOc_cmp( const void *c1, const void *c2 ) {
4214 const ConfigOCs *co1 = c1;
4215 const ConfigOCs *co2 = c2;
4217 return ber_bvcmp( co1->co_name, co2->co_name );
4221 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
4224 i = init_config_attrs( ct );
4227 /* set up the objectclasses */
4228 i = init_config_ocs( ocs );
4231 for (i=0; ocs[i].co_def; i++) {
4232 if ( ocs[i].co_oc ) {
4233 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
4234 if ( !ocs[i].co_table )
4235 ocs[i].co_table = ct;
4236 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
4243 read_config(const char *fname, const char *dir) {
4246 const char *cfdir, *cfname;
4249 /* Setup the config backend */
4250 be = backend_db_init( "config", NULL, 0, NULL );
4254 cfb = be->be_private;
4255 be->be_dfltaccess = ACL_NONE;
4257 /* If no .conf, or a dir was specified, setup the dir */
4258 if ( !fname || dir ) {
4260 /* If explicitly given, check for existence */
4263 if ( stat( dir, &st ) < 0 ) {
4264 Debug( LDAP_DEBUG_ANY,
4265 "invalid config directory %s, error %d\n",
4271 cfdir = SLAPD_DEFAULT_CONFIGDIR;
4273 /* if fname is defaulted, try reading .d */
4274 rc = config_setup_ldif( be, cfdir, !fname );
4277 /* It may be OK if the base object doesn't exist yet. */
4278 if ( rc != LDAP_NO_SUCH_OBJECT )
4280 /* ITS#4194: But if dir was specified and no fname,
4281 * then we were supposed to read the dir. Unless we're
4282 * trying to slapadd the dir...
4284 if ( dir && !fname ) {
4285 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
4287 /* Assume it's slapadd with a config dir, let it continue */
4289 cfb->cb_got_ldif = 1;
4290 cfb->cb_use_ldif = 1;
4295 /* If we read the config from back-ldif, nothing to do here */
4296 if ( cfb->cb_got_ldif ) {
4305 cfname = SLAPD_DEFAULT_CONFIGFILE;
4307 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
4310 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
4313 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
4314 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
4315 &frontendDB->be_schemadn );
4316 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
4317 if ( rc != LDAP_SUCCESS ) {
4318 Debug(LDAP_DEBUG_ANY, "read_config: "
4319 "unable to normalize default schema DN \"%s\"\n",
4320 frontendDB->be_schemadn.bv_val, 0, 0 );
4321 /* must not happen */
4329 config_back_bind( Operation *op, SlapReply *rs )
4331 if ( be_isroot_pw( op ) ) {
4332 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
4333 /* frontend sends result */
4334 return LDAP_SUCCESS;
4337 rs->sr_err = LDAP_INVALID_CREDENTIALS;
4338 send_ldap_result( op, rs );
4344 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
4348 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
4350 rs->sr_attrs = op->ors_attrs;
4351 rs->sr_entry = ce->ce_entry;
4353 rc = send_search_entry( op, rs );
4354 if ( rc != LDAP_SUCCESS ) {
4358 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
4359 if ( ce->ce_kids ) {
4360 rc = config_send( op, rs, ce->ce_kids, 1 );
4361 if ( rc ) return rc;
4364 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
4365 rc = config_send( op, rs, ce, 0 );
4373 static ConfigTable *
4374 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
4379 for (j=0; j<nocs; j++) {
4380 for (i=0; colst[j]->co_table[i].name; i++)
4381 if ( colst[j]->co_table[i].ad == ad ) {
4382 ca->table = colst[j]->co_type;
4383 return &colst[j]->co_table[i];
4389 /* Sort the attributes of the entry according to the order defined
4390 * in the objectclass, with required attributes occurring before
4391 * allowed attributes. For any attributes with sequencing dependencies
4392 * (e.g., rootDN must be defined after suffix) the objectclass must
4393 * list the attributes in the desired sequence.
4396 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
4398 Attribute *a, *head = NULL, *tail = NULL, **prev;
4401 for (i=0; i<nocs; i++) {
4402 if ( colst[i]->co_oc->soc_required ) {
4403 AttributeType **at = colst[i]->co_oc->soc_required;
4404 for (j=0; at[j]; j++) {
4405 for (a=e->e_attrs, prev=&e->e_attrs; a;
4406 prev = &(*prev)->a_next, a=a->a_next) {
4407 if ( a->a_desc == at[j]->sat_ad ) {
4421 if ( colst[i]->co_oc->soc_allowed ) {
4422 AttributeType **at = colst[i]->co_oc->soc_allowed;
4423 for (j=0; at[j]; j++) {
4424 for (a=e->e_attrs, prev=&e->e_attrs; a;
4425 prev = &(*prev)->a_next, a=a->a_next) {
4426 if ( a->a_desc == at[j]->sat_ad ) {
4442 tail->a_next = e->e_attrs;
4448 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
4450 Attribute *a = NULL;
4451 AttributeDescription *ad;
4461 Modifications *ml = ptr;
4463 vals = ml->sml_values;
4466 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
4467 rc = ordered_value_sort( a, 1 );
4469 snprintf(ca->cr_msg, sizeof( ca->cr_msg ), "ordered_value_sort failed on attr %s\n",
4470 ad->ad_cname.bv_val );
4474 for ( i=0; vals[i].bv_val; i++ ) {
4475 ca->line = vals[i].bv_val;
4476 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
4477 ca->line[0] == '{' ) {
4478 char *idx = strchr( ca->line, '}' );
4479 if ( idx ) ca->line = idx+1;
4481 rc = config_parse_vals( ct, ca, i );
4490 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
4493 struct berval rtype, rval;
4495 AttributeDescription *ad = NULL;
4497 dnRdn( &e->e_name, rdn );
4498 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
4499 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
4500 rtype.bv_val = rdn->bv_val;
4501 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
4504 slap_bv2ad( &rtype, &ad, &rs->sr_text );
4505 a = attr_find( e->e_attrs, ad );
4506 if (!a ) return LDAP_NAMING_VIOLATION;
4513 config_rename_kids( CfEntryInfo *ce )
4516 struct berval rdn, nrdn;
4518 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
4519 struct berval newdn, newndn;
4520 dnRdn ( &ce2->ce_entry->e_name, &rdn );
4521 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
4522 build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
4523 build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
4524 free( ce2->ce_entry->e_name.bv_val );
4525 free( ce2->ce_entry->e_nname.bv_val );
4526 ce2->ce_entry->e_name = newdn;
4527 ce2->ce_entry->e_nname = newndn;
4528 config_rename_kids( ce2 );
4533 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
4534 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
4535 struct berval *nnewrdn, int use_ldif )
4539 struct berval odn, ondn;
4543 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
4544 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
4547 free( a->a_vals[0].bv_val );
4548 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
4549 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
4550 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
4551 strcpy( a->a_vals[0].bv_val, ptr1 );
4553 if ( a->a_nvals != a->a_vals ) {
4554 free( a->a_nvals[0].bv_val );
4555 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
4556 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
4557 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
4558 strcpy( a->a_nvals[0].bv_val, ptr1 );
4561 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
4562 BackendDB *be = op->o_bd;
4563 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4564 struct berval dn, ndn, xdn, xndn;
4566 op->o_bd = &cfb->cb_db;
4568 /* Save current rootdn; use the underlying DB's rootdn */
4572 xndn = op->o_req_ndn;
4573 op->o_dn = op->o_bd->be_rootdn;
4574 op->o_ndn = op->o_bd->be_rootndn;
4576 op->o_req_ndn = ondn;
4578 scp = op->o_callback;
4579 op->o_callback = ≻
4580 op->orr_newrdn = *newrdn;
4581 op->orr_nnewrdn = *nnewrdn;
4582 op->orr_newSup = NULL;
4583 op->orr_nnewSup = NULL;
4584 op->orr_deleteoldrdn = 1;
4585 op->orr_modlist = NULL;
4586 slap_modrdn2mods( op, rs );
4587 slap_mods_opattrs( op, &op->orr_modlist, 1 );
4588 rc = op->o_bd->be_modrdn( op, rs );
4589 slap_mods_free( op->orr_modlist, 1 );
4592 op->o_callback = scp;
4596 op->o_req_ndn = xndn;
4599 free( ondn.bv_val );
4601 config_rename_kids( e->e_private );
4606 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
4607 Entry *e, int idx, int tailindex, int use_ldif )
4609 struct berval ival, newrdn, nnewrdn;
4612 char ibuf[32], *ptr1, *ptr2 = NULL;
4615 rc = config_rename_attr( rs, e, &rdn, &a );
4616 if ( rc ) return rc;
4619 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
4620 if ( ival.bv_len >= sizeof( ibuf ) ) {
4621 return LDAP_NAMING_VIOLATION;
4624 newrdn.bv_len = rdn.bv_len + ival.bv_len;
4625 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
4628 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
4629 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4632 ptr2 = ber_bvchr( &rdn, '}' );
4636 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
4638 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
4639 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
4640 a->a_desc->ad_cname.bv_len );
4642 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4643 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
4647 /* Do the equivalent of ModRDN */
4648 /* Replace DN / NDN */
4649 newrdn.bv_len = ptr1 - newrdn.bv_val;
4650 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
4651 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
4653 free( nnewrdn.bv_val );
4654 free( newrdn.bv_val );
4659 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
4660 SlapReply *rs, int *renum, int *ibase )
4663 int index = -1, gotindex = 0, nsibs, rc = 0;
4664 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
4665 char *ptr1, *ptr2 = NULL;
4668 if ( renum ) *renum = 0;
4670 /* These entries don't get indexed/renumbered */
4671 if ( ce_type == Cft_Global ) return 0;
4672 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
4674 if ( ce_type == Cft_Module )
4677 /* See if the rdn has an index already */
4678 dnRdn( &e->e_name, &rdn );
4679 if ( ce_type == Cft_Database ) {
4680 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
4681 "frontend", STRLENOF("frontend") ))
4683 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
4684 "config", STRLENOF("config") ))
4687 ptr1 = ber_bvchr( &e->e_name, '{' );
4688 if ( ptr1 && ptr1 < &e->e_name.bv_val[ rdn.bv_len ] ) {
4690 ptr2 = strchr( ptr1, '}' );
4691 if ( !ptr2 || ptr2 > &e->e_name.bv_val[ rdn.bv_len ] )
4692 return LDAP_NAMING_VIOLATION;
4693 if ( ptr2-ptr1 == 1)
4694 return LDAP_NAMING_VIOLATION;
4696 index = strtol( ptr1 + 1, &next, 10 );
4697 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
4698 return LDAP_NAMING_VIOLATION;
4701 /* Special case, we allow -1 for the frontendDB */
4702 if ( index != -1 || !isfrontend )
4703 return LDAP_NAMING_VIOLATION;
4705 if ( isconfig && index != 0 ){
4706 return LDAP_NAMING_VIOLATION;
4710 /* count related kids */
4711 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
4712 if ( ce->ce_type == ce_type ) nsibs++;
4715 /* account for -1 frontend */
4716 if ( ce_type == Cft_Database )
4719 if ( index != nsibs ) {
4721 if ( index < nsibs ) {
4722 if ( tailindex ) return LDAP_NAMING_VIOLATION;
4723 /* Siblings need to be renumbered */
4724 if ( index != -1 || !isfrontend )
4728 /* config DB is always "0" */
4729 if ( isconfig && index == -1 ) {
4732 if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
4736 /* just make index = nsibs */
4738 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
4741 if ( ibase ) *ibase = index;
4742 if ( renum ) *renum = renumber;
4747 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
4752 co.co_name = &oc->soc_cname;
4753 cop = avl_find( CfOcTree, &co, CfOc_cmp );
4757 /* check for duplicates */
4758 for ( i = 0; i < *nocs; i++ ) {
4759 if ( *copp && (*copp)[i] == cop ) {
4765 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
4766 if ( tmp == NULL ) {
4770 (*copp)[*nocs] = cop;
4775 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
4776 if ( count_oc( *sups, copp, nocs ) ) {
4785 count_ocs( Attribute *oc_at, int *nocs )
4788 ConfigOCs **colst = NULL;
4792 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
4796 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
4798 assert( oc != NULL );
4799 if ( count_oc( oc, &colst, nocs ) ) {
4809 cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4811 /* Leftover from RE23. Never parse this entry */
4812 return LDAP_COMPARE_TRUE;
4816 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4820 /* This entry is hardcoded, don't re-parse it */
4821 if ( p->ce_type == Cft_Global ) {
4822 cfn = p->ce_private;
4823 ca->ca_private = cfn;
4824 return LDAP_COMPARE_TRUE;
4826 if ( p->ce_type != Cft_Schema )
4827 return LDAP_CONSTRAINT_VIOLATION;
4829 cfn = ch_calloc( 1, sizeof(ConfigFile) );
4830 ca->ca_private = cfn;
4831 cfo = p->ce_private;
4832 cfn->c_sibs = cfo->c_kids;
4834 return LDAP_SUCCESS;
4838 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4840 if ( p->ce_type != Cft_Global ) {
4841 return LDAP_CONSTRAINT_VIOLATION;
4843 /* config must be {0}, nothing else allowed */
4844 if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
4845 strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
4846 return LDAP_CONSTRAINT_VIOLATION;
4848 ca->be = frontendDB; /* just to get past check_vals */
4849 return LDAP_SUCCESS;
4853 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4855 if ( p->ce_type != Cft_Global ) {
4856 return LDAP_CONSTRAINT_VIOLATION;
4858 return LDAP_SUCCESS;
4862 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4864 if ( p->ce_type != Cft_Global ) {
4865 return LDAP_CONSTRAINT_VIOLATION;
4867 return LDAP_SUCCESS;
4871 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4873 if ( p->ce_type != Cft_Database ) {
4874 return LDAP_CONSTRAINT_VIOLATION;
4877 return LDAP_SUCCESS;
4881 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
4886 AttributeDescription *ad;
4892 if ( cfn->c_cr_head ) {
4893 struct berval bv = BER_BVC("olcDitContentRules");
4895 slap_bv2ad( &bv, &ad, &text );
4896 ct = config_find_table( colst, nocs, ad, ca );
4897 config_del_vals( ct, ca );
4899 if ( cfn->c_oc_head ) {
4900 struct berval bv = BER_BVC("olcObjectClasses");
4902 slap_bv2ad( &bv, &ad, &text );
4903 ct = config_find_table( colst, nocs, ad, ca );
4904 config_del_vals( ct, ca );
4906 if ( cfn->c_at_head ) {
4907 struct berval bv = BER_BVC("olcAttributeTypes");
4909 slap_bv2ad( &bv, &ad, &text );
4910 ct = config_find_table( colst, nocs, ad, ca );
4911 config_del_vals( ct, ca );
4913 if ( cfn->c_syn_head ) {
4914 struct berval bv = BER_BVC("olcLdapSyntaxes");
4916 slap_bv2ad( &bv, &ad, &text );
4917 ct = config_find_table( colst, nocs, ad, ca );
4918 config_del_vals( ct, ca );
4920 if ( cfn->c_om_head ) {
4921 struct berval bv = BER_BVC("olcObjectIdentifier");
4923 slap_bv2ad( &bv, &ad, &text );
4924 ct = config_find_table( colst, nocs, ad, ca );
4925 config_del_vals( ct, ca );
4927 cfo = p->ce_private;
4928 cfo->c_kids = cfn->c_sibs;
4933 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
4935 int rc = LDAP_CONSTRAINT_VIOLATION;
4938 if ( (*cop)->co_ldadd ) {
4939 rc = (*cop)->co_ldadd( last, e, ca );
4940 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4945 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
4946 ConfigOCs co = { 0 };
4948 co.co_name = &(*ocp)->soc_cname;
4949 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
4950 if ( *cop == NULL ) {
4954 rc = config_add_oc( cop, last, e, ca );
4955 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4963 /* Parse an LDAP entry into config directives */
4965 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
4966 int *renum, Operation *op )
4968 CfEntryInfo *ce, *last = NULL;
4969 ConfigOCs co, *coptr, **colst;
4970 Attribute *a, *oc_at, *soc_at;
4971 int i, ibase = -1, nocs, rc = 0;
4974 char *ptr, *log_prefix = op ? op->o_log_prefix : "";
4976 memset( ca, 0, sizeof(ConfigArgs));
4978 /* Make sure parent exists and entry does not. But allow
4979 * Databases and Overlays to be inserted. Don't do any
4980 * auto-renumbering if manageDSAit control is present.
4982 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
4984 if ( ( op && op->o_managedsait ) ||
4985 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
4986 ce->ce_type != Cft_Module ) )
4988 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4989 "DN=\"%s\" already exists\n",
4990 log_prefix, e->e_name.bv_val, 0 );
4991 /* global schema ignores all writes */
4992 if ( ce->ce_type == Cft_Schema && ce->ce_parent->ce_type == Cft_Global )
4993 return LDAP_COMPARE_TRUE;
4994 return LDAP_ALREADY_EXISTS;
4998 dnParent( &e->e_nname, &pdn );
5000 /* If last is NULL, the new entry is the root/suffix entry,
5001 * otherwise last should be the parent.
5003 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
5005 rs->sr_matched = last->ce_entry->e_name.bv_val;
5007 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5008 "DN=\"%s\" not child of DN=\"%s\"\n",
5009 log_prefix, e->e_name.bv_val,
5010 last->ce_entry->e_name.bv_val );
5011 return LDAP_NO_SUCH_OBJECT;
5015 /* No parent, must be root. This will never happen... */
5016 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
5017 return LDAP_NO_SUCH_OBJECT;
5020 if ( last && !access_allowed( op, last->ce_entry,
5021 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
5023 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5024 "DN=\"%s\" no write access to \"children\" of parent\n",
5025 log_prefix, e->e_name.bv_val, 0 );
5026 return LDAP_INSUFFICIENT_ACCESS;
5030 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5032 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5033 "DN=\"%s\" no objectClass\n",
5034 log_prefix, e->e_name.bv_val, 0 );
5035 return LDAP_OBJECT_CLASS_VIOLATION;
5038 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5040 ObjectClass *soc = NULL;
5041 char textbuf[ SLAP_TEXT_BUFLEN ];
5042 const char *text = textbuf;
5044 /* FIXME: check result */
5045 rc = structural_class( oc_at->a_nvals, &soc, NULL,
5046 &text, textbuf, sizeof(textbuf), NULL );
5047 if ( rc != LDAP_SUCCESS ) {
5048 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5049 "DN=\"%s\" no structural objectClass (%s)\n",
5050 log_prefix, e->e_name.bv_val, text );
5053 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
5054 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5055 if ( soc_at == NULL ) {
5056 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5057 "DN=\"%s\" no structural objectClass; "
5058 "unable to merge computed class %s\n",
5059 log_prefix, e->e_name.bv_val,
5060 soc->soc_cname.bv_val );
5061 return LDAP_OBJECT_CLASS_VIOLATION;
5064 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5065 "DN=\"%s\" no structural objectClass; "
5066 "computed objectClass %s merged\n",
5067 log_prefix, e->e_name.bv_val,
5068 soc->soc_cname.bv_val );
5071 /* Fake the coordinates based on whether we're part of an
5072 * LDAP Add or if reading the config dir
5075 ca->fname = "slapd";
5078 ca->fname = cfdir.bv_val;
5083 co.co_name = &soc_at->a_nvals[0];
5084 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
5085 if ( coptr == NULL ) {
5086 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5087 "DN=\"%s\" no structural objectClass in configuration table\n",
5088 log_prefix, e->e_name.bv_val, 0 );
5089 return LDAP_OBJECT_CLASS_VIOLATION;
5092 /* Only the root can be Cft_Global, everything else must
5093 * have a parent. Only limited nesting arrangements are allowed.
5095 rc = LDAP_CONSTRAINT_VIOLATION;
5096 if ( coptr->co_type == Cft_Global && !last ) {
5097 cfn = cfb->cb_config;
5098 ca->ca_private = cfn;
5099 ca->be = frontendDB; /* just to get past check_vals */
5103 colst = count_ocs( oc_at, &nocs );
5105 /* Check whether the Add is allowed by its parent, and do
5106 * any necessary arg setup
5109 rc = config_add_oc( &coptr, last, e, ca );
5110 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5111 for ( i = 0; i<nocs; i++ ) {
5112 /* Already checked these */
5113 if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
5115 if ( colst[i]->co_ldadd &&
5116 ( rc = colst[i]->co_ldadd( last, e, ca ))
5117 != LDAP_CONSTRAINT_VIOLATION ) {
5123 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5124 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5125 "DN=\"%s\" no structural objectClass add function\n",
5126 log_prefix, e->e_name.bv_val, 0 );
5127 return LDAP_OBJECT_CLASS_VIOLATION;
5131 /* Add the entry but don't parse it, we already have its contents */
5132 if ( rc == LDAP_COMPARE_TRUE ) {
5137 if ( rc != LDAP_SUCCESS )
5140 /* Parse all the values and check for simple syntax errors before
5141 * performing any set actions.
5143 * If doing an LDAPadd, check for indexed names and any necessary
5144 * renaming/renumbering. Entries that don't need indexed names are
5145 * ignored. Entries that need an indexed name and arrive without one
5146 * are assigned to the end. Entries that arrive with an index may
5147 * cause the following entries to be renumbered/bumped down.
5149 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
5150 * don't allow Adding an entry with an index that's already in use.
5151 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
5153 * These entries can have auto-assigned indexes (appended to the end)
5154 * but only the other types support auto-renumbering of siblings.
5157 rc = check_name_index( last, coptr->co_type, e, rs, renum,
5162 if ( renum && *renum && coptr->co_type != Cft_Database &&
5163 coptr->co_type != Cft_Overlay )
5165 snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
5166 "operation requires sibling renumbering" );
5167 rc = LDAP_UNWILLING_TO_PERFORM;
5172 init_config_argv( ca );
5174 /* Make sure we process attrs in the required order */
5175 sort_attrs( e, colst, nocs );
5177 for ( a = e->e_attrs; a; a = a->a_next ) {
5178 if ( a == oc_at ) continue;
5179 ct = config_find_table( colst, nocs, a->a_desc, ca );
5180 if ( !ct ) continue; /* user data? */
5181 rc = check_vals( ct, ca, a, 1 );
5182 if ( rc ) goto done_noop;
5185 /* Basic syntax checks are OK. Do the actual settings. */
5186 for ( a=e->e_attrs; a; a=a->a_next ) {
5187 if ( a == oc_at ) continue;
5188 ct = config_find_table( colst, nocs, a->a_desc, ca );
5189 if ( !ct ) continue; /* user data? */
5190 for (i=0; a->a_vals[i].bv_val; i++) {
5193 ca->line = a->a_vals[i].bv_val;
5194 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
5195 ptr = strchr( ca->line, '}' );
5197 iptr = strchr( ca->line, '{' );
5201 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
5203 ca->valx = strtol( iptr+1, NULL, 0 );
5208 rc = config_parse_add( ct, ca, i );
5216 /* Newly added databases and overlays need to be started up */
5217 if ( CONFIG_ONLINE_ADD( ca )) {
5218 if ( coptr->co_type == Cft_Database ) {
5219 rc = backend_startup_one( ca->be, &ca->reply );
5221 } else if ( coptr->co_type == Cft_Overlay ) {
5222 if ( ca->bi->bi_db_open ) {
5223 BackendInfo *bi_orig = ca->be->bd_info;
5224 ca->be->bd_info = ca->bi;
5225 rc = ca->bi->bi_db_open( ca->be, &ca->reply );
5226 ca->be->bd_info = bi_orig;
5228 } else if ( ca->cleanup ) {
5229 rc = ca->cleanup( ca );
5232 if (ca->cr_msg[0] == '\0')
5233 snprintf( ca->cr_msg, sizeof( ca->cr_msg ), "<%s> failed startup", ca->argv[0] );
5235 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
5236 ca->log, ca->cr_msg, ca->argv[1] );
5243 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5244 ce->ce_parent = last;
5245 ce->ce_entry = entry_dup( e );
5246 ce->ce_entry->e_private = ce;
5247 ce->ce_type = coptr->co_type;
5250 ce->ce_private = ca->ca_private;
5251 ca->ca_entry = ce->ce_entry;
5254 } else if ( last->ce_kids ) {
5255 CfEntryInfo *c2, **cprev;
5257 /* Advance to first of this type */
5258 cprev = &last->ce_kids;
5259 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
5260 cprev = &c2->ce_sibs;
5263 /* Account for the (-1) frontendDB entry */
5264 if ( ce->ce_type == Cft_Database ) {
5265 if ( ca->be == frontendDB )
5267 else if ( ibase != -1 )
5272 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
5273 cprev = &c2->ce_sibs;
5279 for ( i=0; i<ibase; i++ ) {
5281 cprev = &c2->ce_sibs;
5284 ce->ce_sibs = *cprev;
5292 if ( (coptr->co_type == Cft_Database) && ca->be ) {
5293 if ( ca->be != frontendDB )
5294 backend_destroy_one( ca->be, 1 );
5295 } else if ( (coptr->co_type == Cft_Overlay) && ca->bi ) {
5296 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
5297 } else if ( coptr->co_type == Cft_Schema ) {
5298 schema_destroy_one( ca, colst, nocs, last );
5303 ch_free( ca->argv );
5304 if ( colst ) ch_free( colst );
5308 #define BIGTMP 10000
5310 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5311 int base, int rebase, int max, int use_ldif )
5313 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
5314 ConfigType etype = ce->ce_type;
5315 int count = 0, rc = 0;
5317 /* Reverse ce list */
5318 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
5319 if (ce2->ce_type != etype) {
5324 ce2->ce_sibs = cetmp;
5327 if ( max && count >= max ) {
5333 /* Move original to a temp name until increments are done */
5335 ce->ce_entry->e_private = NULL;
5336 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5337 base+BIGTMP, 0, use_ldif );
5338 ce->ce_entry->e_private = ce;
5340 /* start incrementing */
5341 for (ce2=cetmp; ce2; ce2=ce3) {
5343 ce2->ce_sibs = cerem;
5346 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5347 count+base, 0, use_ldif );
5351 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5352 base, 0, use_ldif );
5357 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5358 CfEntryInfo *ce2, int old, int use_ldif )
5362 /* Renumber original to a temp value */
5363 ce->ce_entry->e_private = NULL;
5364 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5365 old+BIGTMP, 0, use_ldif );
5366 ce->ce_entry->e_private = ce;
5368 /* start decrementing */
5369 for (; ce2 != ce; ce2=ce2->ce_sibs) {
5370 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5371 count+old, 0, use_ldif );
5374 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5375 count+old, 0, use_ldif );
5378 /* Parse an LDAP entry into config directives, then store in underlying
5382 config_back_add( Operation *op, SlapReply *rs )
5388 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
5389 NULL, ACL_WADD, NULL )) {
5390 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5395 * Check for attribute ACL
5397 if ( !acl_check_modlist( op, op->ora_e, op->orm_modlist )) {
5398 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5399 rs->sr_text = "no write access to attribute";
5403 cfb = (CfBackInfo *)op->o_bd->be_private;
5405 /* add opattrs for syncprov */
5407 char textbuf[SLAP_TEXT_BUFLEN];
5408 size_t textlen = sizeof textbuf;
5409 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1, NULL,
5410 &rs->sr_text, textbuf, sizeof( textbuf ) );
5411 if ( rs->sr_err != LDAP_SUCCESS )
5413 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
5414 if ( rs->sr_err != LDAP_SUCCESS ) {
5415 Debug( LDAP_DEBUG_TRACE,
5416 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
5417 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
5422 if ( op->o_abandon ) {
5423 rs->sr_err = SLAPD_ABANDON;
5426 ldap_pvt_thread_pool_pause( &connection_pool );
5429 * 1) check for existence of entry
5430 * 2) check for sibling renumbering
5431 * 3) perform internal add
5432 * 4) perform any necessary renumbering
5433 * 5) store entry in underlying database
5435 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
5436 if ( rs->sr_err != LDAP_SUCCESS ) {
5437 rs->sr_text = ca.cr_msg;
5442 CfEntryInfo *ce = ca.ca_entry->e_private;
5443 req_add_s addr = op->oq_add;
5444 op->o_tag = LDAP_REQ_MODRDN;
5445 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
5446 op->o_tag = LDAP_REQ_ADD;
5448 if ( rs->sr_err != LDAP_SUCCESS ) {
5453 if ( cfb->cb_use_ldif ) {
5454 BackendDB *be = op->o_bd;
5455 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5456 struct berval dn, ndn;
5458 op->o_bd = &cfb->cb_db;
5460 /* Save current rootdn; use the underlying DB's rootdn */
5463 op->o_dn = op->o_bd->be_rootdn;
5464 op->o_ndn = op->o_bd->be_rootndn;
5466 scp = op->o_callback;
5467 op->o_callback = ≻
5468 op->o_bd->be_add( op, rs );
5470 op->o_callback = scp;
5476 ldap_pvt_thread_pool_resume( &connection_pool );
5479 { int repl = op->o_dont_replicate;
5480 if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
5481 rs->sr_err = LDAP_SUCCESS;
5482 op->o_dont_replicate = 1;
5484 send_ldap_result( op, rs );
5485 op->o_dont_replicate = repl;
5487 slap_graduate_commit_csn( op );
5491 typedef struct delrec {
5492 struct delrec *next;
5498 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
5504 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
5505 ca->line[0] == '{' )
5507 char *ptr = strchr( ca->line + 1, '}' );
5511 ca->valx = strtol( ca->line + 1, &next, 0 );
5512 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
5518 rc = config_parse_add( ct, ca, i );
5526 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
5529 int rc = LDAP_UNWILLING_TO_PERFORM;
5531 Entry *e = ce->ce_entry;
5532 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
5537 delrec *dels = NULL, *deltail = NULL;
5539 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5540 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
5542 colst = count_ocs( oc_at, &nocs );
5544 /* make sure add/del flags are clear; should always be true */
5545 for ( s = save_attrs; s; s = s->a_next ) {
5546 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
5549 e->e_attrs = attrs_dup( e->e_attrs );
5551 init_config_argv( ca );
5554 ca->ca_private = ce->ce_private;
5556 ca->fname = "slapd";
5558 strcpy( ca->log, "back-config" );
5560 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
5561 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5562 switch (ml->sml_op) {
5563 case LDAP_MOD_DELETE:
5564 case LDAP_MOD_REPLACE: {
5565 BerVarray vals = NULL, nvals = NULL;
5567 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
5569 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot delete %s",
5570 ml->sml_desc->ad_cname.bv_val );
5573 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5574 vals = ml->sml_values;
5575 nvals = ml->sml_nvalues;
5576 ml->sml_values = NULL;
5577 ml->sml_nvalues = NULL;
5579 /* If we're deleting by values, remember the indexes of the
5580 * values we deleted.
5582 if ( ct && ml->sml_values ) {
5584 i = ml->sml_numvals;
5585 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
5596 rc = modify_delete_vindex(e, &ml->sml_mod,
5597 get_permissiveModify(op),
5598 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg), idx );
5599 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5600 ml->sml_values = vals;
5601 ml->sml_nvalues = nvals;
5606 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5609 case SLAP_MOD_SOFTADD: {
5610 int mop = ml->sml_op;
5612 ml->sml_op = LDAP_MOD_ADD;
5614 if ( ct->arg_type & ARG_NO_INSERT ) {
5615 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
5617 navals = a->a_numvals;
5620 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
5621 if ( ml->sml_values[i].bv_val[0] == '{' &&
5624 char *next, *val = ml->sml_values[i].bv_val + 1;
5627 j = strtol( val, &next, 0 );
5628 if ( next == val || next[ 0 ] != '}' || j < navals ) {
5630 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot insert %s",
5631 ml->sml_desc->ad_cname.bv_val );
5635 rc = check_vals( ct, ca, ml, 0 );
5636 if ( rc ) goto out_noop;
5639 rc = modify_add_values(e, &ml->sml_mod,
5640 get_permissiveModify(op),
5641 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5643 /* If value already exists, show success here
5644 * and ignore this operation down below.
5646 if ( mop == SLAP_MOD_SOFTADD ) {
5647 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
5657 case LDAP_MOD_INCREMENT: /* FIXME */
5662 if(rc != LDAP_SUCCESS) break;
5665 if ( rc == LDAP_SUCCESS) {
5666 /* check that the entry still obeys the schema */
5667 rc = entry_schema_check(op, e, NULL, 0, 0, NULL,
5668 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5670 if ( rc ) goto out_noop;
5672 /* Basic syntax checks are OK. Do the actual settings. */
5673 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5674 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5675 if ( !ct ) continue;
5677 s = attr_find( save_attrs, ml->sml_desc );
5678 a = attr_find( e->e_attrs, ml->sml_desc );
5680 switch (ml->sml_op) {
5681 case LDAP_MOD_DELETE:
5682 case LDAP_MOD_REPLACE: {
5683 BerVarray vals = NULL, nvals = NULL;
5686 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5687 vals = ml->sml_values;
5688 nvals = ml->sml_nvalues;
5689 ml->sml_values = NULL;
5690 ml->sml_nvalues = NULL;
5693 if ( ml->sml_values )
5696 /* If we didn't delete the whole attribute */
5697 if ( ml->sml_values && a ) {
5698 struct berval *mvals;
5701 if ( ml->sml_nvalues )
5702 mvals = ml->sml_nvalues;
5704 mvals = ml->sml_values;
5706 /* use the indexes we saved up above */
5707 for (i=0; i < d->nidx; i++) {
5708 struct berval bv = *mvals++;
5709 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
5710 bv.bv_val[0] == '{' ) {
5711 ptr = strchr( bv.bv_val, '}' ) + 1;
5712 bv.bv_len -= ptr - bv.bv_val;
5715 ca->line = bv.bv_val;
5716 ca->valx = d->idx[i];
5717 config_parse_vals(ct, ca, d->idx[i] );
5718 rc = config_del_vals( ct, ca );
5719 if ( rc != LDAP_SUCCESS ) break;
5721 s->a_flags |= SLAP_ATTR_IXDEL;
5722 for (j=i+1; j < d->nidx; j++)
5723 if ( d->idx[j] >d->idx[i] )
5730 rc = config_del_vals( ct, ca );
5731 if ( rc ) rc = LDAP_OTHER;
5733 s->a_flags |= SLAP_ATTR_IXDEL;
5735 if ( ml->sml_values ) {
5740 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5741 ml->sml_values = vals;
5742 ml->sml_nvalues = nvals;
5744 if ( !vals || rc != LDAP_SUCCESS )
5747 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5750 for (i=0; ml->sml_values[i].bv_val; i++) {
5751 ca->line = ml->sml_values[i].bv_val;
5753 rc = config_modify_add( ct, ca, ml->sml_desc, i );
5756 a->a_flags |= SLAP_ATTR_IXADD;
5763 /* Undo for a failed operation */
5764 if ( rc != LDAP_SUCCESS ) {
5765 ConfigReply msg = ca->reply;
5766 for ( s = save_attrs; s; s = s->a_next ) {
5767 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
5768 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5769 ct = config_find_table( colst, nocs, s->a_desc, ca );
5770 a = attr_find( e->e_attrs, s->a_desc );
5772 /* clear the flag so the add check below will skip it */
5773 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5777 config_del_vals( ct, ca );
5779 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5780 ca->line = s->a_vals[i].bv_val;
5782 config_modify_add( ct, ca, s->a_desc, i );
5786 for ( a = e->e_attrs; a; a = a->a_next ) {
5787 if ( a->a_flags & SLAP_ATTR_IXADD ) {
5788 ct = config_find_table( colst, nocs, a->a_desc, ca );
5792 config_del_vals( ct, ca );
5793 s = attr_find( save_attrs, a->a_desc );
5795 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5796 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5797 ca->line = s->a_vals[i].bv_val;
5799 config_modify_add( ct, ca, s->a_desc, i );
5810 if ( rc == LDAP_SUCCESS ) {
5811 attrs_free( save_attrs );
5813 attrs_free( e->e_attrs );
5814 e->e_attrs = save_attrs;
5816 ch_free( ca->argv );
5817 if ( colst ) ch_free( colst );
5819 deltail = dels->next;
5828 config_back_modify( Operation *op, SlapReply *rs )
5831 CfEntryInfo *ce, *last;
5833 ConfigArgs ca = {0};
5836 AttributeDescription *rad = NULL;
5839 cfb = (CfBackInfo *)op->o_bd->be_private;
5841 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5844 rs->sr_matched = last->ce_entry->e_name.bv_val;
5845 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5849 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
5850 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5854 /* Get type of RDN */
5855 rdn = ce->ce_entry->e_nname;
5856 ptr = strchr( rdn.bv_val, '=' );
5857 rdn.bv_len = ptr - rdn.bv_val;
5858 slap_bv2ad( &rdn, &rad, &rs->sr_text );
5860 /* Some basic validation... */
5861 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5862 /* Don't allow Modify of RDN; must use ModRdn for that. */
5863 if ( ml->sml_desc == rad ) {
5864 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
5865 rs->sr_text = "Use modrdn to change the entry name";
5868 /* Internal update of contextCSN? */
5869 if ( ml->sml_desc == slap_schema.si_ad_contextCSN && op->o_conn->c_conn_idx == -1 ) {
5875 slap_mods_opattrs( op, &op->orm_modlist, 1 );
5878 if ( op->o_abandon ) {
5879 rs->sr_err = SLAPD_ABANDON;
5882 ldap_pvt_thread_pool_pause( &connection_pool );
5886 * 1) perform the Modify on the cached Entry.
5887 * 2) verify that the Entry still satisfies the schema.
5888 * 3) perform the individual config operations.
5889 * 4) store Modified entry in underlying LDIF backend.
5891 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
5893 rs->sr_text = ca.cr_msg;
5894 } else if ( cfb->cb_use_ldif ) {
5895 BackendDB *be = op->o_bd;
5896 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5897 struct berval dn, ndn;
5899 op->o_bd = &cfb->cb_db;
5903 op->o_dn = op->o_bd->be_rootdn;
5904 op->o_ndn = op->o_bd->be_rootndn;
5906 scp = op->o_callback;
5907 op->o_callback = ≻
5908 op->o_bd->be_modify( op, rs );
5910 op->o_callback = scp;
5916 ldap_pvt_thread_pool_resume( &connection_pool );
5918 send_ldap_result( op, rs );
5919 slap_graduate_commit_csn( op );
5924 config_back_modrdn( Operation *op, SlapReply *rs )
5927 CfEntryInfo *ce, *last;
5931 cfb = (CfBackInfo *)op->o_bd->be_private;
5933 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5936 rs->sr_matched = last->ce_entry->e_name.bv_val;
5937 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5940 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
5941 NULL, ACL_WRITE, NULL )) {
5942 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5946 if ( ce->ce_parent )
5947 parent = ce->ce_parent->ce_entry;
5949 parent = (Entry *)&slap_entry_root;
5950 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
5951 NULL, ACL_WRITE, NULL )) {
5952 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5957 /* We don't allow moving objects to new parents.
5958 * Generally we only allow reordering a set of ordered entries.
5960 if ( op->orr_newSup ) {
5961 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5965 /* If newRDN == oldRDN, quietly succeed */
5966 dnRdn( &op->o_req_ndn, &rdn );
5967 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
5968 rs->sr_err = LDAP_SUCCESS;
5972 /* Current behavior, subject to change as needed:
5974 * For backends and overlays, we only allow renumbering.
5975 * For schema, we allow renaming with the same number.
5976 * Otherwise, the op is not allowed.
5979 if ( ce->ce_type == Cft_Schema ) {
5983 /* Can't alter the main cn=schema entry */
5984 if ( ce->ce_parent->ce_type == Cft_Global ) {
5985 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5986 rs->sr_text = "renaming not allowed for this entry";
5990 /* We could support this later if desired */
5991 ptr1 = ber_bvchr( &rdn, '}' );
5992 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5993 len = ptr1 - rdn.bv_val;
5994 if ( len != ptr2 - op->orr_newrdn.bv_val ||
5995 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
5996 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5997 rs->sr_text = "schema reordering not supported";
6000 } else if ( ce->ce_type == Cft_Database ||
6001 ce->ce_type == Cft_Overlay ) {
6002 char *ptr1, *ptr2, *iptr1, *iptr2;
6005 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
6006 if ( *iptr2 != '{' ) {
6007 rs->sr_err = LDAP_NAMING_VIOLATION;
6008 rs->sr_text = "new ordering index is required";
6012 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
6013 ptr1 = ber_bvchr( &rdn, '}' );
6014 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
6016 rs->sr_err = LDAP_NAMING_VIOLATION;
6017 rs->sr_text = "new ordering index is required";
6021 len1 = ptr1 - rdn.bv_val;
6022 len2 = ptr2 - op->orr_newrdn.bv_val;
6024 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
6025 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
6026 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6027 rs->sr_text = "changing database/overlay type not allowed";
6030 ixold = strtol( iptr1, NULL, 0 );
6031 ixnew = strtol( iptr2, &ptr1, 0 );
6032 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
6033 rs->sr_err = LDAP_NAMING_VIOLATION;
6036 /* config DB is always 0, cannot be changed */
6037 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
6038 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
6042 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6043 rs->sr_text = "renaming not supported for this entry";
6047 if ( op->o_abandon ) {
6048 rs->sr_err = SLAPD_ABANDON;
6051 ldap_pvt_thread_pool_pause( &connection_pool );
6053 if ( ce->ce_type == Cft_Schema ) {
6054 req_modrdn_s modr = op->oq_modrdn;
6057 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
6058 if ( rs->sr_err == LDAP_SUCCESS ) {
6059 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
6060 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
6063 op->oq_modrdn = modr;
6065 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
6066 req_modrdn_s modr = op->oq_modrdn;
6069 /* Advance to first of this type */
6070 cprev = &ce->ce_parent->ce_kids;
6071 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
6072 cprev = &ce2->ce_sibs;
6075 /* Skip the -1 entry */
6076 if ( ce->ce_type == Cft_Database ) {
6077 cprev = &ce2->ce_sibs;
6083 /* Remove from old slot */
6084 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
6085 cprev = &ce2->ce_sibs;
6086 *cprev = ce->ce_sibs;
6087 ceold = ce->ce_sibs;
6089 /* Insert into new slot */
6091 for ( i=0; i<ixnew; i++ ) {
6095 cprev = &ce2->ce_sibs;
6097 ce->ce_sibs = *cprev;
6102 /* NOTE: These should be encoded in the OC tables, not inline here */
6103 if ( ce->ce_type == Cft_Database )
6104 backend_db_move( ce->ce_be, ixnew );
6105 else if ( ce->ce_type == Cft_Overlay )
6106 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
6108 if ( ixold < ixnew ) {
6109 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
6112 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
6113 ixold - ixnew, cfb->cb_use_ldif );
6115 op->oq_modrdn = modr;
6118 ldap_pvt_thread_pool_resume( &connection_pool );
6120 send_ldap_result( op, rs );
6125 config_back_delete( Operation *op, SlapReply *rs )
6127 #ifdef SLAP_CONFIG_DELETE
6129 CfEntryInfo *ce, *last, *ce2;
6131 cfb = (CfBackInfo *)op->o_bd->be_private;
6133 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6136 rs->sr_matched = last->ce_entry->e_name.bv_val;
6137 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6138 } else if ( ce->ce_kids ) {
6139 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6140 } else if ( op->o_abandon ) {
6141 rs->sr_err = SLAPD_ABANDON;
6142 } else if ( ce->ce_type == Cft_Overlay || ce->ce_type == Cft_Database ){
6146 ldap_pvt_thread_pool_pause( &connection_pool );
6148 if ( ce->ce_type == Cft_Overlay ){
6149 if ( SLAP_ISGLOBALOVERLAY(ce->ce_be ) ) {
6150 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6151 rs->sr_text = "Cannot delete global overlays";
6152 ldap_pvt_thread_pool_resume( &connection_pool );
6154 } else if ( ce->ce_be == op->o_bd->bd_self ) {
6155 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6156 rs->sr_text = "Cannot delete cn=config overlays";
6157 ldap_pvt_thread_pool_resume( &connection_pool );
6160 overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
6162 } else { /* Cft_Database*/
6163 if ( ce->ce_be == frontendDB || ce->ce_be == op->o_bd ){
6164 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6165 rs->sr_text = "Cannot delete config or frontend database";
6166 ldap_pvt_thread_pool_resume( &connection_pool );
6169 if ( ce->ce_be->bd_info->bi_db_close ) {
6170 ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
6172 backend_destroy_one( ce->ce_be, 1);
6175 /* remove CfEntryInfo from the siblings list */
6176 if ( ce->ce_parent->ce_kids == ce ) {
6177 ce->ce_parent->ce_kids = ce->ce_sibs;
6179 for ( ce2 = ce->ce_parent->ce_kids ; ce2; ce2 = ce2->ce_sibs ) {
6180 if ( ce2->ce_sibs == ce ) {
6181 ce2->ce_sibs = ce->ce_sibs;
6187 /* remove from underlying database */
6188 if ( cfb->cb_use_ldif ) {
6189 BackendDB *be = op->o_bd;
6190 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
6191 struct berval dn, ndn, req_dn, req_ndn;
6193 op->o_bd = &cfb->cb_db;
6197 req_dn = op->o_req_dn;
6198 req_ndn = op->o_req_ndn;
6200 op->o_dn = op->o_bd->be_rootdn;
6201 op->o_ndn = op->o_bd->be_rootndn;
6202 op->o_req_dn = ce->ce_entry->e_name;
6203 op->o_req_ndn = ce->ce_entry->e_nname;
6205 scp = op->o_callback;
6206 op->o_callback = ≻
6207 op->o_bd->be_delete( op, rs );
6209 op->o_callback = scp;
6212 op->o_req_dn = req_dn;
6213 op->o_req_ndn = req_ndn;
6216 /* renumber siblings */
6217 iptr = ber_bvchr( &op->o_req_ndn, '{' ) + 1;
6218 ixold = strtol( iptr, NULL, 0 );
6219 for (ce2 = ce->ce_sibs, count=0; ce2; ce2=ce2->ce_sibs) {
6220 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
6221 count+ixold, 0, cfb->cb_use_ldif );
6225 ce->ce_entry->e_private=NULL;
6226 entry_free(ce->ce_entry);
6228 ldap_pvt_thread_pool_resume( &connection_pool );
6230 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6233 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6234 #endif /* SLAP_CONFIG_DELETE */
6236 send_ldap_result( op, rs );
6241 config_back_search( Operation *op, SlapReply *rs )
6244 CfEntryInfo *ce, *last;
6247 cfb = (CfBackInfo *)op->o_bd->be_private;
6249 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6252 rs->sr_matched = last->ce_entry->e_name.bv_val;
6253 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6256 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
6257 ACL_SEARCH, NULL, &mask ))
6259 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
6260 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6262 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
6266 switch ( op->ors_scope ) {
6267 case LDAP_SCOPE_BASE:
6268 case LDAP_SCOPE_SUBTREE:
6269 rs->sr_err = config_send( op, rs, ce, 0 );
6272 case LDAP_SCOPE_ONELEVEL:
6273 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
6274 rs->sr_err = config_send( op, rs, ce, 1 );
6283 send_ldap_result( op, rs );
6287 /* no-op, we never free entries */
6288 int config_entry_release(
6293 if ( !e->e_private ) {
6296 return LDAP_SUCCESS;
6299 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
6301 int config_back_entry_get(
6305 AttributeDescription *at,
6310 CfEntryInfo *ce, *last;
6311 int rc = LDAP_NO_SUCH_OBJECT;
6313 cfb = (CfBackInfo *)op->o_bd->be_private;
6315 ce = config_find_base( cfb->cb_root, ndn, &last );
6317 *ent = ce->ce_entry;
6320 if ( oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
6321 rc = LDAP_NO_SUCH_ATTRIBUTE;
6331 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
6332 ConfigTable *ct, ConfigArgs *c )
6336 for (; at && *at; at++) {
6337 /* Skip the naming attr */
6338 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
6340 for (i=0;ct[i].name;i++) {
6341 if (ct[i].ad == (*at)->sat_ad) {
6342 rc = config_get_vals(&ct[i], c);
6343 /* NOTE: tolerate that config_get_vals()
6344 * returns success with no values */
6345 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
6346 if ( c->rvalue_nvals )
6347 rc = attr_merge(e, ct[i].ad, c->rvalue_vals,
6350 slap_syntax_validate_func *validate =
6351 ct[i].ad->ad_type->sat_syntax->ssyn_validate;
6354 for ( j=0; c->rvalue_vals[j].bv_val; j++ ) {
6355 rc = ordered_value_validate( ct[i].ad,
6356 &c->rvalue_vals[j], LDAP_MOD_ADD );
6358 Debug( LDAP_DEBUG_ANY,
6359 "config_build_attrs: error %d on %s value #%d\n",
6360 rc, ct[i].ad->ad_cname.bv_val, j );
6366 rc = attr_merge_normalize(e, ct[i].ad,
6367 c->rvalue_vals, NULL);
6369 ber_bvarray_free( c->rvalue_nvals );
6370 ber_bvarray_free( c->rvalue_vals );
6372 Debug( LDAP_DEBUG_ANY,
6373 "config_build_attrs: error %d on %s\n",
6374 rc, ct[i].ad->ad_cname.bv_val, 0 );
6386 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
6387 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
6389 Entry *e = entry_alloc();
6390 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
6392 struct berval ad_name;
6393 AttributeDescription *ad = NULL;
6396 const char *text = "";
6400 CfEntryInfo *ceprev = NULL;
6402 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
6405 ce->ce_type = main->co_type;
6406 ce->ce_parent = parent;
6408 pdn = parent->ce_entry->e_nname;
6409 if ( parent->ce_kids && parent->ce_kids->ce_type <= ce->ce_type )
6410 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
6411 ceprev->ce_type <= ce->ce_type;
6412 ceprev = ceprev->ce_sibs );
6417 ce->ce_private = c->ca_private;
6421 build_new_dn( &e->e_name, &pdn, rdn, NULL );
6422 ber_dupbv( &e->e_nname, &e->e_name );
6424 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6425 main->co_name, NULL );
6427 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6428 extra->co_name, NULL );
6429 ptr = strchr(rdn->bv_val, '=');
6430 ad_name.bv_val = rdn->bv_val;
6431 ad_name.bv_len = ptr - rdn->bv_val;
6432 rc = slap_bv2ad( &ad_name, &ad, &text );
6437 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
6438 attr_merge_normalize_one(e, ad, &val, NULL );
6441 c->table = main->co_type;
6442 if ( oc->soc_required ) {
6443 rc = config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
6444 if ( rc ) goto fail;
6447 if ( oc->soc_allowed ) {
6448 rc = config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
6449 if ( rc ) goto fail;
6454 c->table = extra->co_type;
6455 if ( oc->soc_required ) {
6456 rc = config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
6457 if ( rc ) goto fail;
6460 if ( oc->soc_allowed ) {
6461 rc = config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
6462 if ( rc ) goto fail;
6466 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
6467 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->cr_msg,
6468 sizeof(c->cr_msg), op ? op->o_tmpmemctx : NULL );
6469 if ( rc != LDAP_SUCCESS ) {
6471 Debug( LDAP_DEBUG_ANY,
6472 "config_build_entry: build \"%s\" failed: \"%s\"\n",
6473 rdn->bv_val, text, 0);
6476 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
6479 op->ora_modlist = NULL;
6480 slap_add_opattrs( op, NULL, NULL, 0, 0 );
6481 if ( !op->o_noop ) {
6482 op->o_bd->be_add( op, rs );
6483 if ( ( rs->sr_err != LDAP_SUCCESS )
6484 && (rs->sr_err != LDAP_ALREADY_EXISTS) ) {
6490 ce->ce_sibs = ceprev->ce_sibs;
6491 ceprev->ce_sibs = ce;
6492 } else if ( parent ) {
6493 ce->ce_sibs = parent->ce_kids;
6494 parent->ce_kids = ce;
6501 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
6502 Operation *op, SlapReply *rs )
6505 ConfigFile *cf = c->ca_private;
6507 struct berval bv, rdn;
6509 for (; cf; cf=cf->c_sibs, c->depth++) {
6510 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
6511 !cf->c_om_head && !cf->c_syn_head ) continue;
6512 c->value_dn.bv_val = c->log;
6513 LUTIL_SLASHPATH( cf->c_file.bv_val );
6514 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
6519 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
6521 ptr = strchr( bv.bv_val, '.' );
6523 bv.bv_len = ptr - bv.bv_val;
6524 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
6525 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6526 /* FIXME: how can indicate error? */
6529 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
6531 c->value_dn.bv_len += bv.bv_len;
6532 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
6536 e = config_build_entry( op, rs, ceparent, c, &rdn,
6537 &CFOC_SCHEMA, NULL );
6540 } else if ( e && cf->c_kids ) {
6541 c->ca_private = cf->c_kids;
6542 config_build_schema_inc( c, e->e_private, op, rs );
6548 #ifdef SLAPD_MODULES
6551 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
6552 Operation *op, SlapReply *rs )
6557 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
6558 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
6560 c->value_dn.bv_val = c->log;
6561 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
6562 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6563 /* FIXME: how can indicate error? */
6567 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
6576 config_check_schema(Operation *op, CfBackInfo *cfb)
6578 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
6580 CfEntryInfo *ce, *last;
6583 /* If there's no root entry, we must be in the midst of converting */
6584 if ( !cfb->cb_root )
6587 /* Make sure the main schema entry exists */
6588 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
6595 /* Make sure it's up to date */
6596 if ( cf_om_tail != om_sys_tail ) {
6597 a = attr_find( e->e_attrs, cfAd_om );
6599 if ( a->a_nvals != a->a_vals )
6600 ber_bvarray_free( a->a_nvals );
6601 ber_bvarray_free( a->a_vals );
6606 oidm_unparse( &bv, NULL, NULL, 1 );
6607 attr_merge_normalize( e, cfAd_om, bv, NULL );
6608 ber_bvarray_free( bv );
6609 cf_om_tail = om_sys_tail;
6611 if ( cf_at_tail != at_sys_tail ) {
6612 a = attr_find( e->e_attrs, cfAd_attr );
6614 if ( a->a_nvals != a->a_vals )
6615 ber_bvarray_free( a->a_nvals );
6616 ber_bvarray_free( a->a_vals );
6621 at_unparse( &bv, NULL, NULL, 1 );
6622 attr_merge_normalize( e, cfAd_attr, bv, NULL );
6623 ber_bvarray_free( bv );
6624 cf_at_tail = at_sys_tail;
6626 if ( cf_oc_tail != oc_sys_tail ) {
6627 a = attr_find( e->e_attrs, cfAd_oc );
6629 if ( a->a_nvals != a->a_vals )
6630 ber_bvarray_free( a->a_nvals );
6631 ber_bvarray_free( a->a_vals );
6636 oc_unparse( &bv, NULL, NULL, 1 );
6637 attr_merge_normalize( e, cfAd_oc, bv, NULL );
6638 ber_bvarray_free( bv );
6639 cf_oc_tail = oc_sys_tail;
6641 if ( cf_syn_tail != syn_sys_tail ) {
6642 a = attr_find( e->e_attrs, cfAd_syntax );
6644 if ( a->a_nvals != a->a_vals )
6645 ber_bvarray_free( a->a_nvals );
6646 ber_bvarray_free( a->a_vals );
6651 syn_unparse( &bv, NULL, NULL, 1 );
6652 attr_merge_normalize( e, cfAd_syntax, bv, NULL );
6653 ber_bvarray_free( bv );
6654 cf_syn_tail = syn_sys_tail;
6657 SlapReply rs = {REP_RESULT};
6658 c.ca_private = NULL;
6659 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
6660 &CFOC_SCHEMA, NULL );
6665 ce->ce_private = cfb->cb_config;
6666 cf_at_tail = at_sys_tail;
6667 cf_oc_tail = oc_sys_tail;
6668 cf_om_tail = om_sys_tail;
6669 cf_syn_tail = syn_sys_tail;
6674 static const char *defacl[] = {
6675 NULL, "to", "*", "by", "*", "none", NULL
6679 config_back_db_open( BackendDB *be, ConfigReply *cr )
6681 CfBackInfo *cfb = be->be_private;
6684 CfEntryInfo *ce, *ceparent;
6688 Connection conn = {0};
6689 OperationBuffer opbuf;
6691 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
6692 SlapReply rs = {REP_RESULT};
6693 void *thrctx = NULL;
6695 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
6697 /* If we have no explicitly configured ACLs, don't just use
6698 * the global ACLs. Explicitly deny access to everything.
6700 if ( !be->be_acl ) {
6701 parse_acl(be, "config_back_db_open", 0, 6, (char **)defacl, 0 );
6704 thrctx = ldap_pvt_thread_pool_context();
6705 connection_fake_init( &conn, &opbuf, thrctx );
6708 op->o_tag = LDAP_REQ_ADD;
6709 op->o_callback = &cb;
6710 op->o_bd = &cfb->cb_db;
6711 op->o_dn = op->o_bd->be_rootdn;
6712 op->o_ndn = op->o_bd->be_rootndn;
6714 if ( !cfb->cb_use_ldif ) {
6718 /* If we read the config from back-ldif, do some quick sanity checks */
6719 if ( cfb->cb_got_ldif ) {
6720 return config_check_schema( op, cfb );
6723 /* create root of tree */
6725 c.ca_private = cfb->cb_config;
6727 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
6737 #ifdef SLAPD_MODULES
6738 /* Create Module nodes... */
6739 if ( modpaths.mp_loads ) {
6740 if ( config_build_modules( &c, ceparent, op, &rs ) ){
6746 /* Create schema nodes... cn=schema will contain the hardcoded core
6747 * schema, read-only. Child objects will contain runtime loaded schema
6751 c.ca_private = NULL;
6752 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
6757 ce->ce_private = cfb->cb_config;
6758 cf_at_tail = at_sys_tail;
6759 cf_oc_tail = oc_sys_tail;
6760 cf_om_tail = om_sys_tail;
6761 cf_syn_tail = syn_sys_tail;
6763 /* Create schema nodes for included schema... */
6764 if ( cfb->cb_config->c_kids ) {
6766 c.ca_private = cfb->cb_config->c_kids;
6767 if (config_build_schema_inc( &c, ce, op, &rs )) {
6772 /* Create backend nodes. Skip if they don't provide a cf_table.
6773 * There usually aren't any of these.
6777 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
6778 if (!bi->bi_cf_ocs) {
6779 /* If it only supports the old config mech, complain. */
6780 if ( bi->bi_config ) {
6781 Debug( LDAP_DEBUG_ANY,
6782 "WARNING: No dynamic config support for backend %s.\n",
6783 bi->bi_type, 0, 0 );
6788 if (!bi->bi_private) continue;
6791 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6792 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
6793 if ( rdn.bv_len >= sizeof( c.log ) ) {
6794 /* FIXME: holler ... */ ;
6797 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
6804 /* Create database nodes... */
6805 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
6806 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
6807 for ( i = -1, be = frontendDB ; be;
6808 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
6809 slap_overinfo *oi = NULL;
6811 if ( overlay_is_over( be )) {
6812 oi = be->bd_info->bi_private;
6818 /* If this backend supports the old config mechanism, but not
6819 * the new mech, complain.
6821 if ( !be->be_cf_ocs && bi->bi_db_config ) {
6822 Debug( LDAP_DEBUG_ANY,
6823 "WARNING: No dynamic config support for database %s.\n",
6824 bi->bi_type, 0, 0 );
6828 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6829 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
6831 if ( rdn.bv_len >= sizeof( c.log ) ) {
6832 /* FIXME: holler ... */ ;
6836 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
6842 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd )
6843 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
6844 /* Iterate through overlays */
6849 voidList *vl, *v0 = NULL;
6851 /* overlays are in LIFO order, must reverse stack */
6852 for (on=oi->oi_list; on; on=on->on_next) {
6853 vl = ch_malloc( sizeof( voidList ));
6858 for (j=0; vl; j++,vl=v0) {
6862 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
6863 Debug( LDAP_DEBUG_ANY,
6864 "WARNING: No dynamic config support for overlay %s.\n",
6865 on->on_bi.bi_type, 0, 0 );
6869 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6870 "%s=" SLAP_X_ORDERED_FMT "%s",
6871 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
6872 if ( rdn.bv_len >= sizeof( c.log ) ) {
6873 /* FIXME: holler ... */ ;
6877 oe = config_build_entry( op, &rs, ce, &c, &rdn,
6878 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
6882 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd )
6883 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
6888 ldap_pvt_thread_pool_context_reset( thrctx );
6890 if ( unsupp && cfb->cb_use_ldif ) {
6891 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
6892 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
6899 cfb_free_cffile( ConfigFile *cf )
6903 for (; cf; cf=next) {
6906 cfb_free_cffile( cf->c_kids );
6907 ch_free( cf->c_file.bv_val );
6908 ber_bvarray_free( cf->c_dseFiles );
6914 cfb_free_entries( CfEntryInfo *ce )
6918 for (; ce; ce=next) {
6921 cfb_free_entries( ce->ce_kids );
6922 ce->ce_entry->e_private = NULL;
6923 entry_free( ce->ce_entry );
6929 config_back_db_close( BackendDB *be, ConfigReply *cr )
6931 CfBackInfo *cfb = be->be_private;
6933 cfb_free_entries( cfb->cb_root );
6934 cfb->cb_root = NULL;
6936 if ( cfb->cb_db.bd_info ) {
6937 backend_shutdown( &cfb->cb_db );
6944 config_back_db_destroy( BackendDB *be, ConfigReply *cr )
6946 CfBackInfo *cfb = be->be_private;
6948 cfb_free_cffile( cfb->cb_config );
6950 ch_free( cfdir.bv_val );
6952 avl_free( CfOcTree, NULL );
6954 if ( cfb->cb_db.bd_info ) {
6955 cfb->cb_db.be_suffix = NULL;
6956 cfb->cb_db.be_nsuffix = NULL;
6957 BER_BVZERO( &cfb->cb_db.be_rootdn );
6958 BER_BVZERO( &cfb->cb_db.be_rootndn );
6960 backend_destroy_one( &cfb->cb_db, 0 );
6969 config_back_db_init( BackendDB *be, ConfigReply* cr )
6975 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
6976 cfn = cfb->cb_config;
6977 be->be_private = cfb;
6979 ber_dupbv( &be->be_rootdn, &config_rdn );
6980 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
6981 ber_dupbv( &dn, &be->be_rootdn );
6982 ber_bvarray_add( &be->be_suffix, &dn );
6983 ber_dupbv( &dn, &be->be_rootdn );
6984 ber_bvarray_add( &be->be_nsuffix, &dn );
6986 /* Hide from namingContexts */
6987 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
6989 /* Check ACLs on content of Adds by default */
6990 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_ACL_ADD;
6996 config_back_destroy( BackendInfo *bi )
6998 ldif_must_b64_encode_release();
7003 config_tool_entry_open( BackendDB *be, int mode )
7005 CfBackInfo *cfb = be->be_private;
7006 BackendInfo *bi = cfb->cb_db.bd_info;
7008 if ( bi && bi->bi_tool_entry_open )
7009 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
7016 config_tool_entry_close( BackendDB *be )
7018 CfBackInfo *cfb = be->be_private;
7019 BackendInfo *bi = cfb->cb_db.bd_info;
7021 if ( bi && bi->bi_tool_entry_close )
7022 return bi->bi_tool_entry_close( &cfb->cb_db );
7028 config_tool_entry_first( BackendDB *be )
7030 CfBackInfo *cfb = be->be_private;
7031 BackendInfo *bi = cfb->cb_db.bd_info;
7033 if ( bi && bi->bi_tool_entry_first ) {
7034 return bi->bi_tool_entry_first( &cfb->cb_db );
7036 if ( bi && bi->bi_tool_entry_first_x ) {
7037 return bi->bi_tool_entry_first_x( &cfb->cb_db,
7038 NULL, LDAP_SCOPE_DEFAULT, NULL );
7044 config_tool_entry_first_x(
7046 struct berval *base,
7050 CfBackInfo *cfb = be->be_private;
7051 BackendInfo *bi = cfb->cb_db.bd_info;
7053 if ( bi && bi->bi_tool_entry_first_x ) {
7054 return bi->bi_tool_entry_first_x( &cfb->cb_db, base, scope, f );
7060 config_tool_entry_next( BackendDB *be )
7062 CfBackInfo *cfb = be->be_private;
7063 BackendInfo *bi = cfb->cb_db.bd_info;
7065 if ( bi && bi->bi_tool_entry_next )
7066 return bi->bi_tool_entry_next( &cfb->cb_db );
7072 config_tool_entry_get( BackendDB *be, ID id )
7074 CfBackInfo *cfb = be->be_private;
7075 BackendInfo *bi = cfb->cb_db.bd_info;
7077 if ( bi && bi->bi_tool_entry_get )
7078 return bi->bi_tool_entry_get( &cfb->cb_db, id );
7083 static int entry_put_got_frontend=0;
7084 static int entry_put_got_config=0;
7086 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
7088 CfBackInfo *cfb = be->be_private;
7089 BackendInfo *bi = cfb->cb_db.bd_info;
7091 struct berval rdn, vals[ 2 ];
7093 OperationBuffer opbuf;
7095 Connection conn = {0};
7096 Operation *op = NULL;
7100 /* Create entry for frontend database if it does not exist already */
7101 if ( !entry_put_got_frontend ) {
7102 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7103 STRLENOF( "olcDatabase" ))) {
7104 if ( strncmp( e->e_nname.bv_val +
7105 STRLENOF( "olcDatabase" ), "={-1}frontend",
7106 STRLENOF( "={-1}frontend" )) &&
7107 strncmp( e->e_nname.bv_val +
7108 STRLENOF( "olcDatabase" ), "=frontend",
7109 STRLENOF( "=frontend" ))) {
7111 vals[1].bv_val = NULL;
7112 memset( &ca, 0, sizeof(ConfigArgs));
7114 ca.bi = frontendDB->bd_info;
7115 ca.be->be_cf_ocs = &CFOC_FRONTEND;
7116 rdn.bv_val = ca.log;
7117 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7118 "%s=" SLAP_X_ORDERED_FMT "%s",
7119 cfAd_database->ad_cname.bv_val, -1,
7121 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
7122 &CFOC_DATABASE, ca.be->be_cf_ocs );
7123 thrctx = ldap_pvt_thread_pool_context();
7124 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7126 op->o_bd = &cfb->cb_db;
7127 op->o_tag = LDAP_REQ_ADD;
7129 op->o_dn = be->be_rootdn;
7130 op->o_ndn = be->be_rootndn;
7131 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7132 if ( rc != LDAP_SUCCESS ) {
7133 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7134 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7138 if ( ce && bi && bi->bi_tool_entry_put &&
7139 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7140 entry_put_got_frontend++;
7142 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7143 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7147 entry_put_got_frontend++;
7152 /* Create entry for config database if it does not exist already */
7153 if ( !entry_put_got_config && !isFrontend ) {
7154 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7155 STRLENOF( "olcDatabase" ))) {
7156 if ( strncmp( e->e_nname.bv_val +
7157 STRLENOF( "olcDatabase" ), "={0}config",
7158 STRLENOF( "={0}config" )) &&
7159 strncmp( e->e_nname.bv_val +
7160 STRLENOF( "olcDatabase" ), "=config",
7161 STRLENOF( "=config" )) ) {
7163 vals[1].bv_val = NULL;
7164 memset( &ca, 0, sizeof(ConfigArgs));
7165 ca.be = LDAP_STAILQ_FIRST( &backendDB );
7166 ca.bi = ca.be->bd_info;
7167 rdn.bv_val = ca.log;
7168 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7169 "%s=" SLAP_X_ORDERED_FMT "%s",
7170 cfAd_database->ad_cname.bv_val, 0,
7172 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
7175 thrctx = ldap_pvt_thread_pool_context();
7176 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7178 op->o_bd = &cfb->cb_db;
7179 op->o_tag = LDAP_REQ_ADD;
7180 op->o_dn = be->be_rootdn;
7181 op->o_ndn = be->be_rootndn;
7184 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7185 if ( rc != LDAP_SUCCESS ) {
7186 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7187 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7190 if (ce && bi && bi->bi_tool_entry_put &&
7191 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7192 entry_put_got_config++;
7194 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7195 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7199 entry_put_got_config++;
7203 if ( bi && bi->bi_tool_entry_put &&
7204 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
7205 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
7212 AttributeDescription **desc;
7214 { "attribute", &cfAd_attr },
7215 { "backend", &cfAd_backend },
7216 { "database", &cfAd_database },
7217 { "include", &cfAd_include },
7218 { "ldapsyntax", &cfAd_syntax },
7219 { "objectclass", &cfAd_oc },
7220 { "objectidentifier", &cfAd_om },
7221 { "overlay", &cfAd_overlay },
7226 * add / delete: all types that may be added or deleted must use an
7227 * X-ORDERED attributeType for their RDN. Adding and deleting entries
7228 * should automatically renumber the index of any siblings as needed,
7229 * so that no gaps in the numbering sequence exist after the add/delete
7231 * What can be added:
7233 * backend objects for backend-specific config directives
7237 * delete: probably no support this time around.
7239 * modrdn: generally not done. Will be invoked automatically by add/
7240 * delete to update numbering sequence. Perform as an explicit operation
7241 * so that the renumbering effect may be replicated. Subtree rename must
7242 * be supported, since renumbering a database will affect all its child
7245 * modify: must be fully supported.
7249 config_back_initialize( BackendInfo *bi )
7251 ConfigTable *ct = config_back_cf_table;
7255 AttributeDescription *ad = NULL;
7257 static char *controls[] = {
7258 LDAP_CONTROL_MANAGEDSAIT,
7262 /* Make sure we don't exceed the bits reserved for userland */
7263 config_check_userland( CFG_LAST );
7265 bi->bi_controls = controls;
7270 bi->bi_destroy = config_back_destroy;
7272 bi->bi_db_init = config_back_db_init;
7273 bi->bi_db_config = 0;
7274 bi->bi_db_open = config_back_db_open;
7275 bi->bi_db_close = config_back_db_close;
7276 bi->bi_db_destroy = config_back_db_destroy;
7278 bi->bi_op_bind = config_back_bind;
7279 bi->bi_op_unbind = 0;
7280 bi->bi_op_search = config_back_search;
7281 bi->bi_op_compare = 0;
7282 bi->bi_op_modify = config_back_modify;
7283 bi->bi_op_modrdn = config_back_modrdn;
7284 bi->bi_op_add = config_back_add;
7285 bi->bi_op_delete = config_back_delete;
7286 bi->bi_op_abandon = 0;
7288 bi->bi_extended = 0;
7290 bi->bi_chk_referrals = 0;
7292 bi->bi_access_allowed = slap_access_allowed;
7294 bi->bi_connection_init = 0;
7295 bi->bi_connection_destroy = 0;
7297 bi->bi_entry_release_rw = config_entry_release;
7298 bi->bi_entry_get_rw = config_back_entry_get;
7300 bi->bi_tool_entry_open = config_tool_entry_open;
7301 bi->bi_tool_entry_close = config_tool_entry_close;
7302 bi->bi_tool_entry_first = config_tool_entry_first;
7303 bi->bi_tool_entry_first_x = config_tool_entry_first_x;
7304 bi->bi_tool_entry_next = config_tool_entry_next;
7305 bi->bi_tool_entry_get = config_tool_entry_get;
7306 bi->bi_tool_entry_put = config_tool_entry_put;
7309 argv[ 0 ] = "slapd";
7315 for (i=0; OidMacros[i].name; i++ ) {
7316 argv[1] = OidMacros[i].name;
7317 argv[2] = OidMacros[i].oid;
7318 parse_oidm( &ca, 0, NULL );
7321 bi->bi_cf_ocs = cf_ocs;
7323 i = config_register_schema( ct, cf_ocs );
7326 i = slap_str2ad( "olcDatabase", &olcDatabaseDummy[0].ad, &text );
7329 /* setup olcRootPW to be base64-encoded when written in LDIF form;
7330 * basically, we don't care if it fails */
7331 i = slap_str2ad( "olcRootPW", &ad, &text );
7333 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
7334 "warning, unable to get \"olcRootPW\" "
7335 "attribute description: %d: %s\n",
7338 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
7339 ad->ad_type->sat_oid );
7342 /* set up the notable AttributeDescriptions */
7344 for (;ct->name;ct++) {
7345 if (strcmp(ct->name, ads[i].name)) continue;
7346 *ads[i].desc = ct->ad;
7348 if (!ads[i].name) break;