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
249 * OLcfg{Bk|Db}{Oc|At}:8 -> back-null
255 * OLcfgOv{Oc|At}:1 -> syncprov
256 * OLcfgOv{Oc|At}:2 -> pcache
257 * OLcfgOv{Oc|At}:3 -> chain
258 * OLcfgOv{Oc|At}:4 -> accesslog
259 * OLcfgOv{Oc|At}:5 -> valsort
260 * OLcfgOv{Oc|At}:7 -> distproc
261 * OLcfgOv{Oc|At}:8 -> dynlist
262 * OLcfgOv{Oc|At}:9 -> dds
263 * OLcfgOv{Oc|At}:10 -> unique
264 * OLcfgOv{Oc|At}:11 -> refint
265 * OLcfgOv{Oc|At}:12 -> ppolicy
266 * OLcfgOv{Oc|At}:13 -> constraint
267 * OLcfgOv{Oc|At}:14 -> translucent
268 * OLcfgOv{Oc|At}:15 -> auditlog
269 * OLcfgOv{Oc|At}:16 -> rwm
270 * OLcfgOv{Oc|At}:17 -> dyngroup
271 * OLcfgOv{Oc|At}:18 -> memberof
272 * OLcfgOv{Oc|At}:19 -> collect
273 * OLcfgOv{Oc|At}:20 -> retcode
274 * OLcfgOv{Oc|At}:21 -> sssvlv
277 /* alphabetical ordering */
279 static ConfigTable config_back_cf_table[] = {
280 /* This attr is read-only */
281 { "", "", 0, 0, 0, ARG_MAGIC,
282 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
283 "DESC 'File for slapd configuration directives' "
284 "EQUALITY caseIgnoreMatch "
285 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
286 { "", "", 0, 0, 0, ARG_MAGIC,
287 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
288 "DESC 'Directory for slapd configuration backend' "
289 "EQUALITY caseIgnoreMatch "
290 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
291 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
292 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
293 "DESC 'Access Control List' "
294 "EQUALITY caseIgnoreMatch "
295 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
296 { "add_content_acl", NULL, 0, 0, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_ACL_ADD,
297 &config_generic, "( OLcfgGlAt:86 NAME 'olcAddContentAcl' "
298 "DESC 'Check ACLs against content of Add ops' "
299 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
300 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
301 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
302 "DESC 'Allowed set of deprecated features' "
303 "EQUALITY caseIgnoreMatch "
304 "SYNTAX OMsDirectoryString )", NULL, NULL },
305 { "argsfile", "file", 2, 2, 0, ARG_STRING,
306 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
307 "DESC 'File for slapd command line options' "
308 "EQUALITY caseIgnoreMatch "
309 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
310 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
311 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
312 "EQUALITY caseIgnoreMatch "
313 "SYNTAX OMsDirectoryString )", NULL, NULL },
314 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
315 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
316 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
317 "DESC 'OpenLDAP attributeTypes' "
318 "EQUALITY caseIgnoreMatch "
319 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
321 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
322 #ifdef SLAP_AUTH_REWRITE
323 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
327 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
328 "EQUALITY caseIgnoreMatch "
329 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
330 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
331 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
332 "EQUALITY caseIgnoreMatch "
333 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
334 { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
335 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
336 "EQUALITY caseIgnoreMatch "
337 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
338 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
339 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
340 "DESC 'A type of backend' "
341 "EQUALITY caseIgnoreMatch "
342 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
344 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
345 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
346 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
347 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
348 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
349 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
350 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
351 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
352 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
353 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
354 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
355 "DESC 'The backend type for a database instance' "
356 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
357 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
358 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
359 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
360 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
361 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
362 "EQUALITY caseIgnoreMatch "
363 "SYNTAX OMsDirectoryString )", NULL, NULL },
364 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
365 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
366 "DESC 'OpenLDAP DIT content rules' "
367 "EQUALITY caseIgnoreMatch "
368 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
370 { "extra_attrs", "attrlist", 2, 2, 0, ARG_DB|ARG_MAGIC,
371 &config_extra_attrs, "( OLcfgDbAt:0.20 NAME 'olcExtraAttrs' "
372 "EQUALITY caseIgnoreMatch "
373 "SYNTAX OMsDirectoryString )", NULL, NULL },
374 { "gentlehup", "on|off", 2, 2, 0,
376 ARG_ON_OFF, &global_gentlehup,
380 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
381 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
382 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
383 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
384 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
385 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
386 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
387 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
388 { "include", "file", 2, 2, 0, ARG_MAGIC,
389 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
390 "SUP labeledURI )", NULL, NULL },
391 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
392 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
393 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
394 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
395 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
396 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
397 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
398 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
399 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
400 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
401 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
402 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
403 { "index_intlen", "len", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_IX_INTLEN,
404 &config_generic, "( OLcfgGlAt:84 NAME 'olcIndexIntLen' "
405 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
406 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
407 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
408 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
409 { "ldapsyntax", "syntax", 2, 0, 0,
410 ARG_PAREN|ARG_MAGIC|CFG_SYNTAX,
411 &config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
412 "DESC 'OpenLDAP ldapSyntax' "
413 "EQUALITY caseIgnoreMatch "
414 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
416 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
417 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
418 "EQUALITY caseIgnoreMatch "
419 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
420 { "listener-threads", "count", 2, 0, 0,
424 ARG_UINT|ARG_MAGIC|CFG_LTHREADS, &config_generic,
426 "( OLcfgGlAt:93 NAME 'olcListenerThreads' "
427 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
428 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
429 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
430 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
431 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
432 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
433 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
434 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
435 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
436 "EQUALITY caseIgnoreMatch "
437 "SYNTAX OMsDirectoryString )", NULL, NULL },
438 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
439 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
440 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
441 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
442 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
443 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
444 { "moduleload", "file", 2, 0, 0,
446 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
450 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
451 "EQUALITY caseIgnoreMatch "
452 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
453 { "modulepath", "path", 2, 2, 0,
455 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
459 "( OLcfgGlAt:31 NAME 'olcModulePath' "
460 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
461 { "monitoring", "TRUE|FALSE", 2, 2, 0,
462 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
463 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
464 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
465 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
466 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
467 "DESC 'OpenLDAP object classes' "
468 "EQUALITY caseIgnoreMatch "
469 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
471 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
472 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
473 "EQUALITY caseIgnoreMatch "
474 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
475 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
476 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
477 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
478 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
479 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
480 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
481 { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
482 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
483 "EQUALITY caseIgnoreMatch "
484 "SYNTAX OMsDirectoryString )", NULL, NULL },
485 { "pidfile", "file", 2, 2, 0, ARG_STRING,
486 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
487 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
488 { "plugin", NULL, 0, 0, 0,
490 ARG_MAGIC|CFG_PLUGIN, &config_generic,
494 "( OLcfgGlAt:38 NAME 'olcPlugin' "
495 "EQUALITY caseIgnoreMatch "
496 "SYNTAX OMsDirectoryString )", NULL, NULL },
497 { "pluginlog", "filename", 2, 2, 0,
499 ARG_STRING, &slapi_log_file,
503 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
504 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
505 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
506 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
507 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
508 { "referral", "url", 2, 2, 0, ARG_MAGIC,
509 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
510 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
511 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
512 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
513 "EQUALITY caseIgnoreMatch "
514 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
515 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
516 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
517 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
518 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
519 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
520 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
521 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
522 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
523 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
524 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
525 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
526 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
527 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
528 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
529 "EQUALITY caseIgnoreMatch "
530 "SYNTAX OMsDirectoryString )", NULL, NULL },
531 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
532 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
533 "EQUALITY caseIgnoreMatch "
534 "SYNTAX OMsDirectoryString )", NULL, NULL },
535 { "reverse-lookup", "on|off", 2, 2, 0,
536 #ifdef SLAPD_RLOOKUPS
537 ARG_ON_OFF, &use_reverse_lookup,
541 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
542 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
543 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
544 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
545 "EQUALITY distinguishedNameMatch "
546 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
547 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
548 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
549 "EQUALITY caseIgnoreMatch "
550 "SYNTAX OMsDirectoryString )", NULL, NULL },
551 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
552 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
553 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
554 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
555 &config_generic, NULL, NULL, NULL },
556 { "sasl-auxprops", NULL, 2, 0, 0,
557 #ifdef HAVE_CYRUS_SASL
558 ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
562 "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
563 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
564 { "sasl-auxprops-dontusecopy", NULL, 2, 0, 0,
565 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
566 ARG_MAGIC|CFG_AZDUC, &config_generic,
570 "( OLcfgGlAt:91 NAME 'olcSaslAuxpropsDontUseCopy' "
571 "EQUALITY caseIgnoreMatch "
572 "SYNTAX OMsDirectoryString )", NULL, NULL },
573 { "sasl-auxprops-dontusecopy-ignore", "true|FALSE", 2, 0, 0,
574 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
575 ARG_ON_OFF|CFG_AZDUC_IGNORE, &slap_dontUseCopy_ignore,
579 "( OLcfgGlAt:92 NAME 'olcSaslAuxpropsDontUseCopyIgnore' "
580 "EQUALITY booleanMatch "
581 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
582 { "sasl-host", "host", 2, 2, 0,
583 #ifdef HAVE_CYRUS_SASL
584 ARG_STRING|ARG_UNIQUE, &sasl_host,
588 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
589 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
590 { "sasl-realm", "realm", 2, 2, 0,
591 #ifdef HAVE_CYRUS_SASL
592 ARG_STRING|ARG_UNIQUE, &global_realm,
596 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
597 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
598 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
599 &config_generic, NULL, NULL, NULL },
600 { "sasl-secprops", "properties", 2, 2, 0,
601 #ifdef HAVE_CYRUS_SASL
602 ARG_MAGIC|CFG_SASLSECP, &config_generic,
606 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
607 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
608 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
609 &config_generic, NULL, NULL, NULL },
610 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
611 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
612 "EQUALITY distinguishedNameMatch "
613 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
614 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
615 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
616 "EQUALITY caseIgnoreMatch "
617 "SYNTAX OMsDirectoryString )", NULL, NULL },
618 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
619 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
620 "EQUALITY caseIgnoreMatch "
621 "SYNTAX OMsDirectoryString )", NULL, NULL },
622 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
623 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
624 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
625 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
626 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
627 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
628 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
629 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
630 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
631 { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
632 &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
633 "DESC 'Attributes whose values will always be sorted' "
634 "EQUALITY caseIgnoreMatch "
635 "SYNTAX OMsDirectoryString )", NULL, NULL },
636 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
637 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
638 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
639 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
640 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
641 "EQUALITY distinguishedNameMatch "
642 "SYNTAX OMsDN )", NULL, NULL },
643 { "sync_use_subentry", NULL, 0, 0, 0, ARG_ON_OFF|ARG_DB|ARG_MAGIC|CFG_SYNC_SUBENTRY,
644 &config_generic, "( OLcfgDbAt:0.19 NAME 'olcSyncUseSubentry' "
645 "DESC 'Store sync context in a subentry' "
646 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
647 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
648 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
649 "EQUALITY caseIgnoreMatch "
650 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
651 { "tcp-buffer", "[listener=<listener>] [{read|write}=]size", 0, 0, 0,
652 #ifndef LDAP_TCP_BUFFER
654 #else /* LDAP_TCP_BUFFER */
655 ARG_MAGIC, &config_tcp_buffer,
656 #endif /* LDAP_TCP_BUFFER */
657 "( OLcfgGlAt:90 NAME 'olcTCPBuffer' "
658 "DESC 'Custom TCP buffer size' "
659 "SYNTAX OMsDirectoryString )", NULL, NULL },
660 { "threads", "count", 2, 2, 0,
664 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
666 "( OLcfgGlAt:66 NAME 'olcThreads' "
667 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
668 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
669 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
670 "SYNTAX OMsDirectoryString )", NULL, NULL },
671 { "TLSCACertificateFile", NULL, 0, 0, 0,
673 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
677 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
678 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
679 { "TLSCACertificatePath", NULL, 0, 0, 0,
681 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
685 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
686 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
687 { "TLSCertificateFile", NULL, 0, 0, 0,
689 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
693 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
694 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
695 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
697 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
701 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
702 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
703 { "TLSCipherSuite", NULL, 0, 0, 0,
705 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
709 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
710 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
711 { "TLSCRLCheck", NULL, 0, 0, 0,
712 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
713 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
717 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
718 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
719 { "TLSCRLFile", NULL, 0, 0, 0,
720 #if defined(HAVE_GNUTLS)
721 CFG_TLS_CRL_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
725 "( OLcfgGlAt:82 NAME 'olcTLSCRLFile' "
726 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
727 { "TLSRandFile", NULL, 0, 0, 0,
729 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
733 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
734 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
735 { "TLSVerifyClient", NULL, 0, 0, 0,
737 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
741 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
742 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
743 { "TLSDHParamFile", NULL, 0, 0, 0,
745 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
749 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
750 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
751 { "TLSProtocolMin", NULL, 0, 0, 0,
753 CFG_TLS_PROTOCOL_MIN|ARG_STRING|ARG_MAGIC, &config_tls_config,
757 "( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' "
758 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
759 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
760 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
761 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
762 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
763 NULL, NULL, NULL, NULL },
764 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
765 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
766 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
767 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
768 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
769 "EQUALITY caseIgnoreMatch "
770 "SUP labeledURI )", NULL, NULL },
771 { "writetimeout", "timeout", 2, 2, 0, ARG_INT,
772 &global_writetimeout, "( OLcfgGlAt:88 NAME 'olcWriteTimeout' "
773 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
774 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
775 NULL, NULL, NULL, NULL }
778 /* Need to no-op this keyword for dynamic config */
779 ConfigTable olcDatabaseDummy[] = {
780 { "", "", 0, 0, 0, ARG_IGNORED,
781 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
782 "DESC 'The backend type for a database instance' "
783 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
784 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
787 /* Routines to check if a child can be added to this type */
788 static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
789 cfAddBackend, cfAddModule, cfAddOverlay;
791 /* NOTE: be careful when defining array members
792 * that can be conditionally compiled */
793 #define CFOC_GLOBAL cf_ocs[1]
794 #define CFOC_SCHEMA cf_ocs[2]
795 #define CFOC_BACKEND cf_ocs[3]
796 #define CFOC_DATABASE cf_ocs[4]
797 #define CFOC_OVERLAY cf_ocs[5]
798 #define CFOC_INCLUDE cf_ocs[6]
799 #define CFOC_FRONTEND cf_ocs[7]
801 #define CFOC_MODULE cf_ocs[8]
802 #endif /* SLAPD_MODULES */
804 static ConfigOCs cf_ocs[] = {
807 "DESC 'OpenLDAP configuration object' "
808 "ABSTRACT SUP top )", Cft_Abstract, NULL },
811 "DESC 'OpenLDAP Global configuration options' "
812 "SUP olcConfig STRUCTURAL "
813 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
814 "olcAttributeOptions $ olcAuthIDRewrite $ "
815 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
816 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
817 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
818 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
819 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcIndexIntLen $ "
820 "olcLocalSSF $ olcLogFile $ olcLogLevel $ "
821 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
822 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
823 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
825 "olcSaslAuxprops $ olcSaslAuxpropsDontUseCopy $ olcSaslAuxpropsDontUseCopyIgnore $ "
826 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
827 "olcSecurity $ olcServerID $ olcSizeLimit $ "
828 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
830 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
831 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
832 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
833 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
834 "olcTLSCRLFile $ olcToolThreads $ olcWriteTimeout $ "
835 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
836 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
838 "NAME 'olcSchemaConfig' "
839 "DESC 'OpenLDAP schema object' "
840 "SUP olcConfig STRUCTURAL "
841 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
842 "olcObjectClasses $ olcDitContentRules $ olcLdapSyntaxes ) )",
843 Cft_Schema, NULL, cfAddSchema },
845 "NAME 'olcBackendConfig' "
846 "DESC 'OpenLDAP Backend-specific options' "
847 "SUP olcConfig STRUCTURAL "
848 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
850 "NAME 'olcDatabaseConfig' "
851 "DESC 'OpenLDAP Database-specific options' "
852 "SUP olcConfig STRUCTURAL "
854 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
855 "olcAddContentAcl $ olcLastMod $ olcLimits $ "
856 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
857 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
858 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
859 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncUseSubentry $ olcSyncrepl $ "
860 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
861 "olcMonitoring $ olcExtraAttrs ) )",
862 Cft_Database, NULL, cfAddDatabase },
864 "NAME 'olcOverlayConfig' "
865 "DESC 'OpenLDAP Overlay-specific options' "
866 "SUP olcConfig STRUCTURAL "
867 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
869 "NAME 'olcIncludeFile' "
870 "DESC 'OpenLDAP configuration include file' "
871 "SUP olcConfig STRUCTURAL "
873 "MAY ( cn $ olcRootDSE ) )",
874 /* Used to be Cft_Include, that def has been removed */
875 Cft_Abstract, NULL, cfAddInclude },
876 /* This should be STRUCTURAL like all the other database classes, but
877 * that would mean inheriting all of the olcDatabaseConfig attributes,
878 * which causes them to be merged twice in config_build_entry.
881 "NAME 'olcFrontendConfig' "
882 "DESC 'OpenLDAP frontend configuration' "
884 "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
885 Cft_Database, NULL, NULL },
888 "NAME 'olcModuleList' "
889 "DESC 'OpenLDAP dynamic module info' "
890 "SUP olcConfig STRUCTURAL "
891 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
892 Cft_Module, NULL, cfAddModule },
897 typedef struct ServerID {
898 struct ServerID *si_next;
899 struct berval si_url;
903 static ServerID *sid_list;
905 typedef struct voidList {
906 struct voidList *vl_next;
910 typedef struct ADlist {
911 struct ADlist *al_next;
912 AttributeDescription *al_desc;
915 static ADlist *sortVals;
918 config_generic(ConfigArgs *c) {
921 if ( c->op == SLAP_CONFIG_EMIT ) {
925 c->value_int = ldap_pvt_thread_get_concurrency();
928 c->value_int = connection_pool_max;
931 c->value_int = slap_tool_thread_max;
934 c->value_uint = slapd_daemon_threads;
938 c->value_string = ch_strdup( passwd_salt );
943 if ( c->be->be_limits ) {
947 for ( i=0; c->be->be_limits[i]; i++ ) {
948 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
949 if ( bv.bv_len >= sizeof( buf ) ) {
950 ber_bvarray_free_x( c->rvalue_vals, NULL );
951 c->rvalue_vals = NULL;
955 bv.bv_val = buf + bv.bv_len;
956 limits_unparse( c->be->be_limits[i], &bv,
957 sizeof( buf ) - ( bv.bv_val - buf ) );
958 bv.bv_len += bv.bv_val - buf;
960 value_add_one( &c->rvalue_vals, &bv );
963 if ( !c->rvalue_vals ) rc = 1;
966 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
969 c->value_string = ch_strdup( slap_sasl_getpolicy());
972 slap_sasl_regexp_unparse( &c->rvalue_vals );
973 if ( !c->rvalue_vals ) rc = 1;
975 #ifdef HAVE_CYRUS_SASL
976 #ifdef SLAP_AUXPROP_DONTUSECOPY
978 static int duc_done = 0;
980 /* take the opportunity to initialize with known values */
982 struct berval duc[] = { BER_BVC("cmusaslsecretOTP"), BER_BVNULL };
985 for ( i = 0; !BER_BVISNULL( &duc[ i ] ); i++ ) {
986 const char *text = NULL;
987 AttributeDescription *ad = NULL;
989 if ( slap_bv2ad( &duc[ i ], &ad, &text ) == LDAP_SUCCESS ) {
991 if ( slap_dontUseCopy_propnames ) {
994 for ( j = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ j ] ); j++ ) {
995 if ( bvmatch( &slap_dontUseCopy_propnames[ j ], &ad->ad_cname ) ) {
1002 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1010 if ( slap_dontUseCopy_propnames != NULL ) {
1011 ber_bvarray_dup_x( &c->rvalue_vals, slap_dontUseCopy_propnames, NULL );
1016 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1017 case CFG_SASLSECP: {
1018 struct berval bv = BER_BVNULL;
1019 slap_sasl_secprops_unparse( &bv );
1020 if ( !BER_BVISNULL( &bv )) {
1021 ber_bvarray_add( &c->rvalue_vals, &bv );
1029 c->value_int = c->be->be_max_deref_depth;
1032 if ( SLAP_DBHIDDEN( c->be )) {
1039 ConfigFile *cf = c->ca_private;
1041 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1042 else if ( cf->c_om_head )
1043 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
1045 if ( !c->rvalue_vals )
1050 ad_unparse_options( &c->rvalue_vals );
1053 ConfigFile *cf = c->ca_private;
1055 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1056 else if ( cf->c_oc_head )
1057 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
1059 if ( !c->rvalue_vals )
1064 ConfigFile *cf = c->ca_private;
1066 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1067 else if ( cf->c_at_head )
1068 at_unparse( &c->rvalue_vals, cf->c_at_head,
1070 if ( !c->rvalue_vals )
1075 ConfigFile *cf = c->ca_private;
1077 syn_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1078 else if ( cf->c_syn_head )
1079 syn_unparse( &c->rvalue_vals, cf->c_syn_head,
1080 cf->c_syn_tail, 0 );
1081 if ( !c->rvalue_vals )
1086 ConfigFile *cf = c->ca_private;
1088 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1089 else if ( cf->c_cr_head )
1090 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
1092 if ( !c->rvalue_vals )
1099 char *src, *dst, ibuf[11];
1100 struct berval bv, abv;
1101 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
1102 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1103 if ( abv.bv_len >= sizeof( ibuf ) ) {
1104 ber_bvarray_free_x( c->rvalue_vals, NULL );
1105 c->rvalue_vals = NULL;
1109 acl_unparse( a, &bv );
1110 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
1111 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
1112 /* Turn TAB / EOL into plain space */
1113 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
1114 if (isspace((unsigned char)*src)) *dst++ = ' ';
1118 if (dst[-1] == ' ') {
1122 abv.bv_len = dst - abv.bv_val;
1123 ber_bvarray_add( &c->rvalue_vals, &abv );
1129 c->value_int = (SLAP_DBACL_ADD(c->be) != 0);
1132 ConfigFile *cf = c->ca_private;
1133 if ( cf->c_dseFiles ) {
1134 value_add( &c->rvalue_vals, cf->c_dseFiles );
1145 for ( si = sid_list; si; si=si->si_next ) {
1146 assert( si->si_num >= 0 && si->si_num <= SLAP_SYNC_SID_MAX );
1147 if ( !BER_BVISEMPTY( &si->si_url )) {
1148 bv.bv_len = si->si_url.bv_len + 6;
1149 bv.bv_val = ch_malloc( bv.bv_len );
1150 bv.bv_len = sprintf( bv.bv_val, "%d %s", si->si_num,
1151 si->si_url.bv_val );
1152 ber_bvarray_add( &c->rvalue_vals, &bv );
1156 bv.bv_len = sprintf( buf, "%d", si->si_num );
1157 value_add_one( &c->rvalue_vals, &bv );
1166 c->value_string = ch_strdup( logfileName );
1171 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
1173 case CFG_SYNC_SUBENTRY:
1174 c->value_int = (SLAP_SYNC_SUBENTRY(c->be) != 0);
1176 case CFG_MIRRORMODE:
1177 if ( SLAP_SHADOW(c->be))
1178 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
1182 case CFG_MONITORING:
1183 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
1185 case CFG_SSTR_IF_MAX:
1186 c->value_uint = index_substr_if_maxlen;
1188 case CFG_SSTR_IF_MIN:
1189 c->value_uint = index_substr_if_minlen;
1192 c->value_int = index_intlen;
1194 case CFG_SORTVALS: {
1197 for ( sv = sortVals; sv; sv = sv->al_next ) {
1198 value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
1202 #ifdef SLAPD_MODULES
1204 ModPaths *mp = c->ca_private;
1207 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
1210 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
1211 SLAP_X_ORDERED_FMT "%s", i,
1212 mp->mp_loads[i].bv_val );
1213 if ( bv.bv_len >= sizeof( c->log ) ) {
1214 ber_bvarray_free_x( c->rvalue_vals, NULL );
1215 c->rvalue_vals = NULL;
1218 value_add_one( &c->rvalue_vals, &bv );
1222 rc = c->rvalue_vals ? 0 : 1;
1226 ModPaths *mp = c->ca_private;
1227 if ( !BER_BVISNULL( &mp->mp_path ))
1228 value_add_one( &c->rvalue_vals, &mp->mp_path );
1230 rc = c->rvalue_vals ? 0 : 1;
1236 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1237 if ( !c->rvalue_vals ) rc = 1;
1240 #ifdef SLAP_AUTH_REWRITE
1242 if ( authz_rewrites ) {
1243 struct berval bv, idx;
1248 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1249 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1250 if ( idx.bv_len >= sizeof( ibuf ) ) {
1251 ber_bvarray_free_x( c->rvalue_vals, NULL );
1252 c->rvalue_vals = NULL;
1255 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1256 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1257 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1258 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1259 authz_rewrites[i].bv_val,
1260 authz_rewrites[i].bv_len + 1 );
1261 ber_bvarray_add( &c->rvalue_vals, &bv );
1264 if ( !c->rvalue_vals ) rc = 1;
1271 } else if ( c->op == LDAP_MOD_DELETE ) {
1274 /* single-valued attrs, no-ops */
1283 case CFG_MIRRORMODE:
1284 case CFG_MONITORING:
1286 case CFG_SSTR_IF_MAX:
1287 case CFG_SSTR_IF_MIN:
1289 case CFG_SYNC_SUBENTRY:
1292 /* no-ops, requires slapd restart */
1297 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1300 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
1302 if ( c->valx < 0 ) {
1303 if ( slap_dontUseCopy_propnames != NULL ) {
1304 ber_bvarray_free( slap_dontUseCopy_propnames );
1305 slap_dontUseCopy_propnames = NULL;
1311 if ( slap_dontUseCopy_propnames == NULL ) {
1316 for ( i = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i ] ) && i < c->valx; i++ );
1317 if ( i < c->valx ) {
1321 ber_memfree( slap_dontUseCopy_propnames[ i ].bv_val );
1322 for ( ; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i + 1 ] ); i++ ) {
1323 slap_dontUseCopy_propnames[ i ] = slap_dontUseCopy_propnames[ i + 1 ];
1325 BER_BVZERO( &slap_dontUseCopy_propnames[ i ] );
1328 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1330 ch_free( passwd_salt );
1335 ch_free( logfileName );
1343 case CFG_SERVERID: {
1344 ServerID *si, **sip;
1346 for ( i=0, si = sid_list, sip = &sid_list;
1347 si; si = *sip, i++ ) {
1348 if ( c->valx == -1 || i == c->valx ) {
1360 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1364 index_intlen = SLAP_INDEX_INTLEN_DEFAULT;
1365 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1366 SLAP_INDEX_INTLEN_DEFAULT );
1370 if ( c->valx < 0 ) {
1371 acl_destroy( c->be->be_acl );
1372 c->be->be_acl = NULL;
1375 AccessControl **prev, *a;
1377 for (i=0, prev = &c->be->be_acl; i < c->valx;
1380 prev = &a->acl_next;
1383 *prev = a->acl_next;
1390 /* Can be NULL when undoing a failed add */
1391 if ( c->ca_entry ) {
1392 ce = c->ca_entry->e_private;
1393 /* can't modify the hardcoded schema */
1394 if ( ce->ce_parent->ce_type == Cft_Global )
1398 cfn = c->ca_private;
1399 if ( c->valx < 0 ) {
1402 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1404 if ( oc == cfn->c_oc_tail )
1407 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1409 ObjectClass *oc, *prev = NULL;
1411 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1416 if ( cfn->c_oc_tail == oc ) {
1417 cfn->c_oc_tail = prev;
1419 if ( cfn->c_oc_head == oc ) {
1421 cfn->c_oc_head = oc;
1428 /* Can be NULL when undoing a failed add */
1429 if ( c->ca_entry ) {
1430 ce = c->ca_entry->e_private;
1431 /* can't modify the hardcoded schema */
1432 if ( ce->ce_parent->ce_type == Cft_Global )
1436 cfn = c->ca_private;
1437 if ( c->valx < 0 ) {
1440 for( at = cfn->c_at_head; at; at_next( &at )) {
1442 if ( at == cfn->c_at_tail )
1445 cfn->c_at_head = cfn->c_at_tail = NULL;
1447 AttributeType *at, *prev = NULL;
1449 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1454 if ( cfn->c_at_tail == at ) {
1455 cfn->c_at_tail = prev;
1457 if ( cfn->c_at_head == at ) {
1459 cfn->c_at_head = at;
1466 /* Can be NULL when undoing a failed add */
1467 if ( c->ca_entry ) {
1468 ce = c->ca_entry->e_private;
1469 /* can't modify the hardcoded schema */
1470 if ( ce->ce_parent->ce_type == Cft_Global )
1474 cfn = c->ca_private;
1475 if ( c->valx < 0 ) {
1478 for( syn = cfn->c_syn_head; syn; syn_next( &syn )) {
1480 if ( syn == cfn->c_syn_tail )
1483 cfn->c_syn_head = cfn->c_syn_tail = NULL;
1485 Syntax *syn, *prev = NULL;
1487 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++) {
1492 if ( cfn->c_syn_tail == syn ) {
1493 cfn->c_syn_tail = prev;
1495 if ( cfn->c_syn_head == syn ) {
1497 cfn->c_syn_head = syn;
1502 if ( c->valx < 0 ) {
1504 for ( sv = sortVals; sv; sv = sortVals ) {
1505 sortVals = sv->al_next;
1506 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1513 for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
1514 prev = &sv->al_next;
1517 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1518 *prev = sv->al_next;
1524 /* FIXME: there is no limits_free function */
1525 if ( c->valx < 0 ) {
1526 limits_destroy( c->be->be_limits );
1527 c->be->be_limits = NULL;
1532 if ( c->be->be_limits ) {
1533 for ( num = 0; c->be->be_limits[ num ]; num++ )
1537 if ( c->valx >= num ) {
1542 limits_destroy( c->be->be_limits );
1543 c->be->be_limits = NULL;
1546 limits_free_one( c->be->be_limits[ c->valx ] );
1548 for ( cnt = c->valx; cnt < num; cnt++ ) {
1549 c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
1556 /* FIXME: there is no ad_option_free function */
1558 /* FIXME: there is no way to remove attributes added by
1572 if(!(c->bi = backend_info(c->argv[1]))) {
1573 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1574 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1575 c->log, c->cr_msg, c->argv[1] );
1582 /* NOTE: config is always the first backend!
1584 if ( !strcasecmp( c->argv[1], "config" )) {
1585 c->be = LDAP_STAILQ_FIRST(&backendDB);
1586 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1589 c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply);
1591 if ( c->cr_msg[0] == 0 )
1592 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1593 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n", c->log, c->cr_msg, c->argv[1] );
1600 ldap_pvt_thread_set_concurrency(c->value_int);
1604 if ( c->value_int < 2 ) {
1605 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1606 "threads=%d smaller than minimum value 2",
1608 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1609 c->log, c->cr_msg, 0 );
1612 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1613 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1614 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1615 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1616 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1617 c->log, c->cr_msg, 0 );
1619 if ( slapMode & SLAP_SERVER_MODE )
1620 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1621 connection_pool_max = c->value_int; /* save for reference */
1625 if ( slapMode & SLAP_TOOL_MODE )
1626 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1627 slap_tool_thread_max = c->value_int; /* save for reference */
1632 /* use a power of two */
1633 while (c->value_uint > 1) {
1634 c->value_uint >>= 1;
1638 slapd_daemon_mask = mask;
1639 slapd_daemon_threads = mask+1;
1644 if ( passwd_salt ) ch_free( passwd_salt );
1645 passwd_salt = c->value_string;
1646 lutil_salt_format(passwd_salt);
1650 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1656 c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1658 c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1662 ch_free(c->value_string);
1663 if (slap_sasl_setpolicy( c->argv[1] )) {
1664 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
1665 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1666 c->log, c->cr_msg, c->argv[1] );
1672 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1676 #ifdef HAVE_CYRUS_SASL
1677 #ifdef SLAP_AUXPROP_DONTUSECOPY
1681 for ( arg = 1; arg < c->argc; arg++ ) {
1682 int duplicate = 0, err;
1683 AttributeDescription *ad = NULL;
1684 const char *text = NULL;
1686 err = slap_str2ad( c->argv[ arg ], &ad, &text );
1687 if ( err != LDAP_SUCCESS ) {
1688 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") unknown (err=%d \"%s\"; ignored)",
1689 c->argv[0], arg, c->argv[ arg ], err, text );
1690 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1691 c->log, c->cr_msg, 0 );
1694 if ( slap_dontUseCopy_propnames != NULL ) {
1695 for ( cnt = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ cnt ] ); cnt++ ) {
1696 if ( bvmatch( &slap_dontUseCopy_propnames[ cnt ], &ad->ad_cname ) ) {
1704 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") already defined (ignored)",
1705 c->argv[0], arg, ad->ad_cname.bv_val);
1706 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1707 c->log, c->cr_msg, 0 );
1711 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1716 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1720 char *txt = slap_sasl_secprops( c->argv[1] );
1722 snprintf( c->cr_msg, sizeof(c->cr_msg), "<%s> %s",
1724 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0 );
1732 c->be->be_max_deref_depth = c->value_int;
1738 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1739 cfn = c->ca_private;
1740 if(parse_oidm(c, 1, &om))
1742 if (!cfn->c_om_head) cfn->c_om_head = om;
1743 cfn->c_om_tail = om;
1748 ObjectClass *oc, *prev;
1750 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1751 cfn = c->ca_private;
1752 if ( c->valx < 0 ) {
1753 prev = cfn->c_oc_tail;
1756 /* If adding anything after the first, prev is easy */
1759 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1764 /* If adding the first, and head exists, find its prev */
1765 if (cfn->c_oc_head) {
1766 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1771 /* else prev is NULL, append to end of global list */
1773 if(parse_oc(c, &oc, prev)) return(1);
1774 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1775 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1780 AttributeType *at, *prev;
1782 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1783 cfn = c->ca_private;
1784 if ( c->valx < 0 ) {
1785 prev = cfn->c_at_tail;
1788 /* If adding anything after the first, prev is easy */
1791 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1796 /* If adding the first, and head exists, find its prev */
1797 if (cfn->c_at_head) {
1798 for ( at_start( &at ); at != cfn->c_at_head; ) {
1803 /* else prev is NULL, append to end of global list */
1805 if(parse_at(c, &at, prev)) return(1);
1806 if (!cfn->c_at_head) cfn->c_at_head = at;
1807 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1814 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1815 cfn = c->ca_private;
1816 if ( c->valx < 0 ) {
1817 prev = cfn->c_syn_tail;
1820 /* If adding anything after the first, prev is easy */
1823 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
1828 /* If adding the first, and head exists, find its prev */
1829 if (cfn->c_syn_head) {
1830 for ( syn_start( &syn ); syn != cfn->c_syn_head; ) {
1835 /* else prev is NULL, append to end of global list */
1837 if ( parse_syn( c, &syn, prev ) ) return(1);
1838 if ( !cfn->c_syn_head ) cfn->c_syn_head = syn;
1839 if ( cfn->c_syn_tail == prev ) cfn->c_syn_tail = syn;
1846 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1847 cfn = c->ca_private;
1848 if(parse_cr(c, &cr)) return(1);
1849 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1850 cfn->c_cr_tail = cr;
1855 ad_define_option(NULL, NULL, 0);
1856 for(i = 1; i < c->argc; i++)
1857 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1862 if ( c->value_int < SLAP_INDEX_INTLEN_DEFAULT )
1863 c->value_int = SLAP_INDEX_INTLEN_DEFAULT;
1864 else if ( c->value_int > 255 )
1866 index_intlen = c->value_int;
1867 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1871 case CFG_SORTVALS: {
1872 ADlist *svnew = NULL, *svtail, *sv;
1874 for ( i = 1; i < c->argc; i++ ) {
1875 AttributeDescription *ad = NULL;
1879 rc = slap_str2ad( c->argv[i], &ad, &text );
1881 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
1884 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1885 c->log, c->cr_msg, c->argv[i] );
1886 for ( sv = svnew; sv; sv = svnew ) {
1887 svnew = sv->al_next;
1892 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
1893 ad->ad_type->sat_single_value ) {
1894 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
1896 goto sortval_reject;
1898 sv = ch_malloc( sizeof( ADlist ));
1903 svtail->al_next = sv;
1908 for ( sv = svnew; sv; sv = sv->al_next )
1909 sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
1910 for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
1912 sv->al_next = svnew;
1919 /* Don't append to the global ACL if we're on a specific DB */
1921 if ( c->valx == -1 ) {
1924 for ( a=c->be->be_acl; a; a = a->acl_next )
1927 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1934 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_ACL_ADD;
1936 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_ACL_ADD;
1940 if(root_dse_read_file(c->argv[1])) {
1941 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> could not read file", c->argv[0] );
1942 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1943 c->log, c->cr_msg, c->argv[1] );
1948 ber_str2bv( c->argv[1], 0, 1, &bv );
1949 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1950 cfn = c->ca_private;
1951 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1957 ServerID *si, **sip;
1960 if (( lutil_atoi( &num, c->argv[1] ) &&
1961 lutil_atoix( &num, c->argv[1], 16 )) ||
1962 num < 0 || num > SLAP_SYNC_SID_MAX )
1964 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1965 "<%s> illegal server ID", c->argv[0] );
1966 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1967 c->log, c->cr_msg, c->argv[1] );
1970 /* only one value allowed if no URL is given */
1971 if ( c->argc > 2 ) {
1974 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1975 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1976 "<%s> only one server ID allowed now", c->argv[0] );
1977 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1978 c->log, c->cr_msg, c->argv[1] );
1982 if ( ldap_url_parse( c->argv[2], &lud )) {
1983 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1984 "<%s> invalid URL", c->argv[0] );
1985 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1986 c->log, c->cr_msg, c->argv[2] );
1989 len = strlen( c->argv[2] );
1990 si = ch_malloc( sizeof(ServerID) + len + 1 );
1991 si->si_url.bv_val = (char *)(si+1);
1992 si->si_url.bv_len = len;
1993 strcpy( si->si_url.bv_val, c->argv[2] );
1996 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1997 "<%s> unqualified server ID not allowed now", c->argv[0] );
1998 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1999 c->log, c->cr_msg, c->argv[1] );
2002 si = ch_malloc( sizeof(ServerID) );
2003 BER_BVZERO( &si->si_url );
2004 slap_serverID = num;
2005 Debug( LDAP_DEBUG_CONFIG,
2007 c->log, slap_serverID, 0 );
2011 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
2014 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
2015 Listener *l = config_check_my_url( c->argv[2], lud );
2017 slap_serverID = si->si_num;
2018 Debug( LDAP_DEBUG_CONFIG,
2019 "%s: SID=0x%03x (listener=%s)\n",
2020 c->log, slap_serverID,
2025 ldap_free_urldesc( lud );
2029 if ( logfileName ) ch_free( logfileName );
2030 logfileName = c->value_string;
2031 logfile = fopen(logfileName, "w");
2032 if(logfile) lutil_debug_file(logfile);
2036 if(SLAP_NOLASTMODCMD(c->be)) {
2037 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> not available for %s database",
2038 c->argv[0], c->be->bd_info->bi_type );
2039 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2040 c->log, c->cr_msg, 0 );
2044 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
2046 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
2049 case CFG_MIRRORMODE:
2050 if(c->value_int && !SLAP_SHADOW(c->be)) {
2051 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database is not a shadow",
2053 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2054 c->log, c->cr_msg, 0 );
2058 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
2060 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
2063 case CFG_MONITORING:
2065 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
2067 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
2072 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
2074 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
2077 case CFG_SYNC_SUBENTRY:
2079 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SYNC_SUBENTRY;
2081 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SYNC_SUBENTRY;
2084 case CFG_SSTR_IF_MAX:
2085 if (c->value_uint < index_substr_if_minlen) {
2086 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2087 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2088 c->log, c->cr_msg, c->value_int );
2091 index_substr_if_maxlen = c->value_uint;
2094 case CFG_SSTR_IF_MIN:
2095 if (c->value_uint > index_substr_if_maxlen) {
2096 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2097 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2098 c->log, c->cr_msg, c->value_int );
2101 index_substr_if_minlen = c->value_uint;
2104 #ifdef SLAPD_MODULES
2106 /* If we're just adding a module on an existing modpath,
2107 * make sure we've selected the current path.
2109 if ( c->op == LDAP_MOD_ADD && c->ca_private && modcur != c->ca_private ) {
2110 modcur = c->ca_private;
2111 /* This should never fail */
2112 if ( module_path( modcur->mp_path.bv_val )) {
2113 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> module path no longer valid",
2115 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2116 c->log, c->cr_msg, modcur->mp_path.bv_val );
2120 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
2122 /* Record this load on the current path */
2126 if ( c->op == SLAP_CONFIG_ADD ) {
2127 ptr = c->line + STRLENOF("moduleload");
2128 while (!isspace((unsigned char) *ptr)) ptr++;
2129 while (isspace((unsigned char) *ptr)) ptr++;
2133 ber_str2bv(ptr, 0, 1, &bv);
2134 ber_bvarray_add( &modcur->mp_loads, &bv );
2136 /* Check for any new hardcoded schema */
2137 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
2138 config_check_schema( NULL, &cfBackInfo );
2143 if(module_path(c->argv[1])) return(1);
2144 /* Record which path was used with each module */
2148 if (!modpaths.mp_loads) {
2151 mp = ch_malloc( sizeof( ModPaths ));
2152 modlast->mp_next = mp;
2154 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
2156 mp->mp_loads = NULL;
2167 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
2169 slapi_plugins_used++;
2173 #ifdef SLAP_AUTH_REWRITE
2179 if ( c->op == LDAP_MOD_ADD ) {
2183 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
2187 if ( c->argc > 1 ) {
2190 /* quote all args but the first */
2191 line = ldap_charray2str( c->argv, "\" \"" );
2192 ber_str2bv( line, 0, 0, &bv );
2193 s = ber_bvchr( &bv, '"' );
2194 assert( s != NULL );
2195 /* move the trailing quote of argv[0] to the end */
2196 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
2197 bv.bv_val[ bv.bv_len - 1 ] = '"';
2200 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
2203 ber_bvarray_add( &authz_rewrites, &bv );
2205 if ( c->op == LDAP_MOD_ADD ) {
2215 Debug( LDAP_DEBUG_ANY,
2216 "%s: unknown CFG_TYPE %d.\n",
2217 c->log, c->type, 0 );
2226 config_fname(ConfigArgs *c) {
2227 if(c->op == SLAP_CONFIG_EMIT) {
2228 if (c->ca_private) {
2229 ConfigFile *cf = c->ca_private;
2230 value_add_one( &c->rvalue_vals, &cf->c_file );
2239 config_cfdir(ConfigArgs *c) {
2240 if(c->op == SLAP_CONFIG_EMIT) {
2241 if ( !BER_BVISEMPTY( &cfdir )) {
2242 value_add_one( &c->rvalue_vals, &cfdir );
2251 config_search_base(ConfigArgs *c) {
2252 if(c->op == SLAP_CONFIG_EMIT) {
2254 if (!BER_BVISEMPTY(&default_search_base)) {
2255 value_add_one(&c->rvalue_vals, &default_search_base);
2256 value_add_one(&c->rvalue_nvals, &default_search_nbase);
2260 } else if( c->op == LDAP_MOD_DELETE ) {
2261 ch_free( default_search_base.bv_val );
2262 ch_free( default_search_nbase.bv_val );
2263 BER_BVZERO( &default_search_base );
2264 BER_BVZERO( &default_search_nbase );
2268 if(c->bi || c->be != frontendDB) {
2269 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
2270 "prior to any backend or database definition\n",
2275 if(default_search_nbase.bv_len) {
2276 free(default_search_base.bv_val);
2277 free(default_search_nbase.bv_val);
2280 default_search_base = c->value_dn;
2281 default_search_nbase = c->value_ndn;
2285 /* For RE23 compatibility we allow this in the global entry
2286 * but we now defer it to the frontend entry to allow modules
2287 * to load new hash types.
2290 config_passwd_hash(ConfigArgs *c) {
2292 if (c->op == SLAP_CONFIG_EMIT) {
2294 /* Don't generate it in the global entry */
2295 if ( c->table == Cft_Global )
2297 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
2298 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
2299 value_add_one(&c->rvalue_vals, &bv);
2302 } else if ( c->op == LDAP_MOD_DELETE ) {
2303 /* Deleting from global is a no-op, only the frontendDB entry matters */
2304 if ( c->table == Cft_Global )
2306 if ( c->valx < 0 ) {
2307 ldap_charray_free( default_passwd_hash );
2308 default_passwd_hash = NULL;
2311 ch_free( default_passwd_hash[i] );
2312 for (; default_passwd_hash[i]; i++ )
2313 default_passwd_hash[i] = default_passwd_hash[i+1];
2317 for(i = 1; i < c->argc; i++) {
2318 if(!lutil_passwd_scheme(c->argv[i])) {
2319 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
2320 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2321 c->log, c->cr_msg, c->argv[i]);
2323 ldap_charray_add(&default_passwd_hash, c->argv[i]);
2326 if(!default_passwd_hash) {
2327 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
2328 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2329 c->log, c->cr_msg, 0 );
2336 config_schema_dn(ConfigArgs *c) {
2337 if ( c->op == SLAP_CONFIG_EMIT ) {
2339 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
2340 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
2341 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
2345 } else if ( c->op == LDAP_MOD_DELETE ) {
2346 ch_free( c->be->be_schemadn.bv_val );
2347 ch_free( c->be->be_schemandn.bv_val );
2348 BER_BVZERO( &c->be->be_schemadn );
2349 BER_BVZERO( &c->be->be_schemandn );
2352 ch_free( c->be->be_schemadn.bv_val );
2353 ch_free( c->be->be_schemandn.bv_val );
2354 c->be->be_schemadn = c->value_dn;
2355 c->be->be_schemandn = c->value_ndn;
2360 config_sizelimit(ConfigArgs *c) {
2362 struct slap_limits_set *lim = &c->be->be_def_limit;
2363 if (c->op == SLAP_CONFIG_EMIT) {
2368 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
2369 if ( !BER_BVISEMPTY( &bv ))
2370 value_add_one( &c->rvalue_vals, &bv );
2374 } else if ( c->op == LDAP_MOD_DELETE ) {
2375 /* Reset to defaults or values from frontend */
2376 if ( c->be == frontendDB ) {
2377 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
2378 lim->lms_s_hard = 0;
2379 lim->lms_s_unchecked = -1;
2381 lim->lms_s_pr_hide = 0;
2382 lim->lms_s_pr_total = 0;
2384 lim->lms_s_soft = frontendDB->be_def_limit.lms_s_soft;
2385 lim->lms_s_hard = frontendDB->be_def_limit.lms_s_hard;
2386 lim->lms_s_unchecked = frontendDB->be_def_limit.lms_s_unchecked;
2387 lim->lms_s_pr = frontendDB->be_def_limit.lms_s_pr;
2388 lim->lms_s_pr_hide = frontendDB->be_def_limit.lms_s_pr_hide;
2389 lim->lms_s_pr_total = frontendDB->be_def_limit.lms_s_pr_total;
2393 for(i = 1; i < c->argc; i++) {
2394 if(!strncasecmp(c->argv[i], "size", 4)) {
2395 rc = limits_parse_one(c->argv[i], lim);
2397 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2398 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2399 c->log, c->cr_msg, c->argv[i]);
2403 if(!strcasecmp(c->argv[i], "unlimited")) {
2404 lim->lms_s_soft = -1;
2406 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
2407 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2408 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2409 c->log, c->cr_msg, c->argv[i]);
2413 lim->lms_s_hard = 0;
2418 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2419 /* This is a modification to the global limits apply it to
2420 * the other databases as needed */
2421 AttributeDescription *ad=NULL;
2422 const char *text = NULL;
2423 CfEntryInfo *ce = c->ca_entry->e_private;
2425 slap_str2ad(c->argv[0], &ad, &text);
2426 /* if we got here... */
2427 assert( ad != NULL );
2429 if ( ce->ce_type == Cft_Global ){
2432 for (; ce; ce=ce->ce_sibs) {
2433 Entry *dbe = ce->ce_entry;
2434 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2435 && (!attr_find(dbe->e_attrs, ad)) ) {
2436 ce->ce_be->be_def_limit.lms_s_soft = lim->lms_s_soft;
2437 ce->ce_be->be_def_limit.lms_s_hard = lim->lms_s_hard;
2438 ce->ce_be->be_def_limit.lms_s_unchecked =lim->lms_s_unchecked;
2439 ce->ce_be->be_def_limit.lms_s_pr =lim->lms_s_pr;
2440 ce->ce_be->be_def_limit.lms_s_pr_hide =lim->lms_s_pr_hide;
2441 ce->ce_be->be_def_limit.lms_s_pr_total =lim->lms_s_pr_total;
2449 config_timelimit(ConfigArgs *c) {
2451 struct slap_limits_set *lim = &c->be->be_def_limit;
2452 if (c->op == SLAP_CONFIG_EMIT) {
2457 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
2458 if ( !BER_BVISEMPTY( &bv ))
2459 value_add_one( &c->rvalue_vals, &bv );
2463 } else if ( c->op == LDAP_MOD_DELETE ) {
2464 /* Reset to defaults or values from frontend */
2465 if ( c->be == frontendDB ) {
2466 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
2467 lim->lms_t_hard = 0;
2469 lim->lms_t_soft = frontendDB->be_def_limit.lms_t_soft;
2470 lim->lms_t_hard = frontendDB->be_def_limit.lms_t_hard;
2474 for(i = 1; i < c->argc; i++) {
2475 if(!strncasecmp(c->argv[i], "time", 4)) {
2476 rc = limits_parse_one(c->argv[i], lim);
2478 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2479 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2480 c->log, c->cr_msg, c->argv[i]);
2484 if(!strcasecmp(c->argv[i], "unlimited")) {
2485 lim->lms_t_soft = -1;
2487 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
2488 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2489 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2490 c->log, c->cr_msg, c->argv[i]);
2494 lim->lms_t_hard = 0;
2499 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2500 /* This is a modification to the global limits apply it to
2501 * the other databases as needed */
2502 AttributeDescription *ad=NULL;
2503 const char *text = NULL;
2504 CfEntryInfo *ce = c->ca_entry->e_private;
2506 slap_str2ad(c->argv[0], &ad, &text);
2507 /* if we got here... */
2508 assert( ad != NULL );
2510 if ( ce->ce_type == Cft_Global ){
2513 for (; ce; ce=ce->ce_sibs) {
2514 Entry *dbe = ce->ce_entry;
2515 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2516 && (!attr_find(dbe->e_attrs, ad)) ) {
2517 ce->ce_be->be_def_limit.lms_t_soft = lim->lms_t_soft;
2518 ce->ce_be->be_def_limit.lms_t_hard = lim->lms_t_hard;
2526 config_overlay(ConfigArgs *c) {
2527 if (c->op == SLAP_CONFIG_EMIT) {
2529 } else if ( c->op == LDAP_MOD_DELETE ) {
2532 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
2533 c->valx, &c->bi, &c->reply)) {
2535 Debug( LDAP_DEBUG_ANY,
2536 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
2537 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
2539 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi, &c->reply)) {
2546 config_subordinate(ConfigArgs *c)
2552 case SLAP_CONFIG_EMIT:
2553 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
2556 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
2557 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
2560 value_add_one( &c->rvalue_vals, &bv );
2564 case LDAP_MOD_DELETE:
2565 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2566 glue_sub_del( c->be );
2568 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2573 case SLAP_CONFIG_ADD:
2574 if ( c->be->be_nsuffix == NULL ) {
2576 snprintf( c->cr_msg, sizeof( c->cr_msg),
2577 "subordinate configuration needs a suffix" );
2578 Debug( LDAP_DEBUG_ANY,
2580 c->log, c->cr_msg, 0 );
2585 if ( c->argc == 2 ) {
2586 if ( strcasecmp( c->argv[1], "advertise" ) == 0 ) {
2589 } else if ( strcasecmp( c->argv[1], "TRUE" ) != 0 ) {
2591 snprintf( c->cr_msg, sizeof( c->cr_msg),
2592 "subordinate must be \"TRUE\" or \"advertise\"" );
2593 Debug( LDAP_DEBUG_ANY,
2594 "%s: suffix \"%s\": %s.\n",
2595 c->log, c->be->be_suffix[0].bv_val, c->cr_msg );
2601 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2609 * [listener=<listener>] [{read|write}=]<size>
2612 #ifdef LDAP_TCP_BUFFER
2613 static BerVarray tcp_buffer;
2616 #define SLAP_TCP_RMEM (0x1U)
2617 #define SLAP_TCP_WMEM (0x2U)
2620 tcp_buffer_parse( struct berval *val, int argc, char **argv,
2621 int *size, int *rw, Listener **l )
2623 int i, rc = LDAP_SUCCESS;
2624 LDAPURLDesc *lud = NULL;
2627 if ( val != NULL && argv == NULL ) {
2628 char *s = val->bv_val;
2630 argv = ldap_str2charray( s, " \t" );
2631 if ( argv == NULL ) {
2637 if ( strncasecmp( argv[ i ], "listener=", STRLENOF( "listener=" ) )
2640 char *url = argv[ i ] + STRLENOF( "listener=" );
2642 if ( ldap_url_parse( url, &lud ) ) {
2643 rc = LDAP_INVALID_SYNTAX;
2647 *l = config_check_my_url( url, lud );
2649 rc = LDAP_NO_SUCH_ATTRIBUTE;
2657 if ( strncasecmp( ptr, "read=", STRLENOF( "read=" ) ) == 0 ) {
2658 *rw |= SLAP_TCP_RMEM;
2659 ptr += STRLENOF( "read=" );
2661 } else if ( strncasecmp( ptr, "write=", STRLENOF( "write=" ) ) == 0 ) {
2662 *rw |= SLAP_TCP_WMEM;
2663 ptr += STRLENOF( "write=" );
2666 *rw |= ( SLAP_TCP_RMEM | SLAP_TCP_WMEM );
2669 /* accept any base */
2670 if ( lutil_atoix( size, ptr, 0 ) ) {
2671 rc = LDAP_INVALID_SYNTAX;
2676 if ( val != NULL && argv != NULL ) {
2677 ldap_charray_free( argv );
2680 if ( lud != NULL ) {
2681 ldap_free_urldesc( lud );
2688 tcp_buffer_delete_one( struct berval *val )
2691 int size = -1, rw = 0;
2694 rc = tcp_buffer_parse( val, 0, NULL, &size, &rw, &l );
2701 Listener **ll = slapd_get_listeners();
2703 for ( i = 0; ll[ i ] != NULL; i++ ) {
2704 if ( ll[ i ] == l ) break;
2707 if ( ll[ i ] == NULL ) {
2708 return LDAP_NO_SUCH_ATTRIBUTE;
2711 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = -1;
2712 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = -1;
2714 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2715 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = -1;
2716 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = -1;
2720 /* NOTE: this affects listeners without a specific setting,
2721 * does not reset all listeners. If a listener without
2722 * specific settings was assigned a buffer because of
2723 * a global setting, it will not be reset. In any case,
2724 * buffer changes will only take place at restart. */
2725 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = -1;
2726 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = -1;
2733 tcp_buffer_delete( BerVarray vals )
2737 for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ ) {
2738 tcp_buffer_delete_one( &vals[ i ] );
2745 tcp_buffer_unparse( int size, int rw, Listener *l, struct berval *val )
2747 char buf[sizeof("2147483648")], *ptr;
2749 /* unparse for later use */
2750 val->bv_len = snprintf( buf, sizeof( buf ), "%d", size );
2752 val->bv_len += STRLENOF( "listener=" " " ) + l->sl_url.bv_len;
2755 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2756 if ( rw & SLAP_TCP_RMEM ) {
2757 val->bv_len += STRLENOF( "read=" );
2758 } else if ( rw & SLAP_TCP_WMEM ) {
2759 val->bv_len += STRLENOF( "write=" );
2763 val->bv_val = SLAP_MALLOC( val->bv_len + 1 );
2768 ptr = lutil_strcopy( ptr, "listener=" );
2769 ptr = lutil_strncopy( ptr, l->sl_url.bv_val, l->sl_url.bv_len );
2773 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2774 if ( rw & SLAP_TCP_RMEM ) {
2775 ptr = lutil_strcopy( ptr, "read=" );
2776 } else if ( rw & SLAP_TCP_WMEM ) {
2777 ptr = lutil_strcopy( ptr, "write=" );
2781 ptr = lutil_strcopy( ptr, buf );
2784 assert( val->bv_val + val->bv_len == ptr );
2786 return LDAP_SUCCESS;
2790 tcp_buffer_add_one( int argc, char **argv )
2793 int size = -1, rw = 0;
2799 rc = tcp_buffer_parse( NULL, argc, argv, &size, &rw, &l );
2804 /* unparse for later use */
2805 rc = tcp_buffer_unparse( size, rw, l, &val );
2806 if ( rc != LDAP_SUCCESS ) {
2810 /* use parsed values */
2813 Listener **ll = slapd_get_listeners();
2815 for ( i = 0; ll[ i ] != NULL; i++ ) {
2816 if ( ll[ i ] == l ) break;
2819 if ( ll[ i ] == NULL ) {
2820 return LDAP_NO_SUCH_ATTRIBUTE;
2823 /* buffer only applies to TCP listeners;
2824 * we do not do any check here, and delegate them
2825 * to setsockopt(2) */
2826 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = size;
2827 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = size;
2829 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2830 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = size;
2831 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = size;
2835 /* NOTE: this affects listeners without a specific setting,
2836 * does not set all listeners */
2837 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = size;
2838 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = size;
2841 tcp_buffer = SLAP_REALLOC( tcp_buffer, sizeof( struct berval ) * ( tcp_buffer_num + 2 ) );
2843 tcp_buffer[ tcp_buffer_num ] = val;
2846 BER_BVZERO( &tcp_buffer[ tcp_buffer_num ] );
2852 config_tcp_buffer( ConfigArgs *c )
2854 if ( c->op == SLAP_CONFIG_EMIT ) {
2855 if ( tcp_buffer == NULL || BER_BVISNULL( &tcp_buffer[ 0 ] ) ) {
2858 value_add( &c->rvalue_vals, tcp_buffer );
2859 value_add( &c->rvalue_nvals, tcp_buffer );
2861 } else if ( c->op == LDAP_MOD_DELETE ) {
2863 tcp_buffer_delete( tcp_buffer );
2864 ber_bvarray_free( tcp_buffer );
2870 int size = -1, rw = 0;
2873 struct berval val = BER_BVNULL;
2877 if ( tcp_buffer_num == 0 ) {
2882 rc = tcp_buffer_parse( NULL, c->argc - 1, &c->argv[ 1 ], &size, &rw, &l );
2887 /* unparse for later use */
2888 rc = tcp_buffer_unparse( size, rw, l, &val );
2889 if ( rc != LDAP_SUCCESS ) {
2893 for ( i = 0; !BER_BVISNULL( &tcp_buffer[ i ] ); i++ ) {
2894 if ( bvmatch( &tcp_buffer[ i ], &val ) ) {
2899 if ( BER_BVISNULL( &tcp_buffer[ i ] ) ) {
2905 tcp_buffer_delete_one( &tcp_buffer[ i ] );
2906 ber_memfree( tcp_buffer[ i ].bv_val );
2907 for ( ; i < tcp_buffer_num; i++ ) {
2908 tcp_buffer[ i ] = tcp_buffer[ i + 1 ];
2913 if ( !BER_BVISNULL( &val ) ) {
2914 SLAP_FREE( val.bv_val );
2922 rc = tcp_buffer_add_one( c->argc - 1, &c->argv[ 1 ] );
2924 snprintf( c->cr_msg, sizeof( c->cr_msg ),
2925 "<%s> unable to add value #%d",
2926 c->argv[0], tcp_buffer_num );
2927 Debug( LDAP_DEBUG_ANY, "%s: %s\n",
2928 c->log, c->cr_msg, 0 );
2935 #endif /* LDAP_TCP_BUFFER */
2938 config_suffix(ConfigArgs *c)
2941 struct berval pdn, ndn;
2942 char *notallowed = NULL;
2944 if ( c->be == frontendDB ) {
2945 notallowed = "frontend";
2947 } else if ( SLAP_MONITOR(c->be) ) {
2948 notallowed = "monitor";
2950 } else if ( SLAP_CONFIG(c->be) ) {
2951 notallowed = "config";
2954 if ( notallowed != NULL ) {
2955 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2959 case LDAP_MOD_DELETE:
2960 case LDAP_MOD_REPLACE:
2961 case LDAP_MOD_INCREMENT:
2962 case SLAP_CONFIG_ADD:
2963 if ( !BER_BVISNULL( &c->value_dn ) ) {
2964 snprintf( buf, sizeof( buf ), "<%s> ",
2965 c->value_dn.bv_val );
2968 Debug(LDAP_DEBUG_ANY,
2969 "%s: suffix %snot allowed in %s database.\n",
2970 c->log, buf, notallowed );
2973 case SLAP_CONFIG_EMIT:
2974 /* don't complain when emitting... */
2978 /* FIXME: don't know what values may be valid;
2979 * please remove assertion, or add legal values
2980 * to either block */
2988 if (c->op == SLAP_CONFIG_EMIT) {
2989 if ( c->be->be_suffix == NULL
2990 || BER_BVISNULL( &c->be->be_suffix[0] ) )
2994 value_add( &c->rvalue_vals, c->be->be_suffix );
2995 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
2998 } else if ( c->op == LDAP_MOD_DELETE ) {
2999 if ( c->valx < 0 ) {
3000 ber_bvarray_free( c->be->be_suffix );
3001 ber_bvarray_free( c->be->be_nsuffix );
3002 c->be->be_suffix = NULL;
3003 c->be->be_nsuffix = NULL;
3006 ch_free( c->be->be_suffix[i].bv_val );
3007 ch_free( c->be->be_nsuffix[i].bv_val );
3009 c->be->be_suffix[i] = c->be->be_suffix[i+1];
3010 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
3012 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
3017 #ifdef SLAPD_MONITOR_DN
3018 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
3019 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> DN is reserved for monitoring slapd",
3021 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3022 c->log, c->cr_msg, SLAPD_MONITOR_DN);
3027 if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
3028 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
3029 c->argv[0], c->be->bd_info->bi_type );
3030 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3031 c->log, c->cr_msg, 0);
3038 if (SLAP_DBHIDDEN( c->be ))
3041 tbe = select_backend(&ndn, 0);
3043 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
3049 BackendDB *b2 = tbe;
3051 /* Does tbe precede be? */
3052 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
3055 char *type = tbe->bd_info->bi_type;
3057 if ( overlay_is_over( tbe ) ) {
3058 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
3059 type = oi->oi_orig->bi_type;
3062 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> namingContext \"%s\" "
3063 "already served by a preceding %s database",
3064 c->argv[0], pdn.bv_val, type );
3065 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
3066 c->log, c->cr_msg, tbe->be_suffix[0].bv_val);
3072 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
3073 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
3074 "base provided \"%s\" (assuming okay)\n",
3075 c->log, default_search_base.bv_val, 0);
3077 ber_bvarray_add(&c->be->be_suffix, &pdn);
3078 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
3083 config_rootdn(ConfigArgs *c) {
3084 if (c->op == SLAP_CONFIG_EMIT) {
3085 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3086 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
3087 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
3092 } else if ( c->op == LDAP_MOD_DELETE ) {
3093 ch_free( c->be->be_rootdn.bv_val );
3094 ch_free( c->be->be_rootndn.bv_val );
3095 BER_BVZERO( &c->be->be_rootdn );
3096 BER_BVZERO( &c->be->be_rootndn );
3099 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3100 ch_free( c->be->be_rootdn.bv_val );
3101 ch_free( c->be->be_rootndn.bv_val );
3103 c->be->be_rootdn = c->value_dn;
3104 c->be->be_rootndn = c->value_ndn;
3109 config_rootpw(ConfigArgs *c) {
3112 if (c->op == SLAP_CONFIG_EMIT) {
3113 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
3114 /* don't copy, because "rootpw" is marked
3116 c->value_bv = c->be->be_rootpw;
3120 } else if ( c->op == LDAP_MOD_DELETE ) {
3121 ch_free( c->be->be_rootpw.bv_val );
3122 BER_BVZERO( &c->be->be_rootpw );
3126 tbe = select_backend(&c->be->be_rootndn, 0);
3128 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> can only be set when rootdn is under suffix",
3130 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3131 c->log, c->cr_msg, 0);
3134 if ( !BER_BVISNULL( &c->be->be_rootpw ))
3135 ch_free( c->be->be_rootpw.bv_val );
3136 c->be->be_rootpw = c->value_bv;
3141 config_restrict(ConfigArgs *c) {
3142 slap_mask_t restrictops = 0;
3144 slap_verbmasks restrictable_ops[] = {
3145 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
3146 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
3147 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
3148 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
3149 { BER_BVC("modrdn"), 0 },
3150 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
3151 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
3152 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
3153 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
3154 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
3155 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
3156 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
3157 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
3158 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
3159 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
3160 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
3164 if (c->op == SLAP_CONFIG_EMIT) {
3165 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
3167 } else if ( c->op == LDAP_MOD_DELETE ) {
3169 c->be->be_restrictops = 0;
3171 restrictops = verb_to_mask( c->line, restrictable_ops );
3172 c->be->be_restrictops ^= restrictops;
3176 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
3178 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown operation", c->argv[0] );
3179 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3180 c->log, c->cr_msg, c->argv[i]);
3183 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
3184 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
3185 c->be->be_restrictops |= restrictops;
3190 config_allows(ConfigArgs *c) {
3191 slap_mask_t allows = 0;
3193 slap_verbmasks allowable_ops[] = {
3194 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
3195 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
3196 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
3197 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
3198 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
3201 if (c->op == SLAP_CONFIG_EMIT) {
3202 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
3203 } else if ( c->op == LDAP_MOD_DELETE ) {
3207 allows = verb_to_mask( c->line, allowable_ops );
3208 global_allows ^= allows;
3212 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
3214 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3215 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3216 c->log, c->cr_msg, c->argv[i]);
3219 global_allows |= allows;
3224 config_disallows(ConfigArgs *c) {
3225 slap_mask_t disallows = 0;
3227 slap_verbmasks disallowable_ops[] = {
3228 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
3229 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
3230 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
3231 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
3232 { BER_BVC("proxy_authz_non_critical"), SLAP_DISALLOW_PROXY_AUTHZ_N_CRIT },
3233 { BER_BVC("dontusecopy_non_critical"), SLAP_DISALLOW_DONTUSECOPY_N_CRIT },
3236 if (c->op == SLAP_CONFIG_EMIT) {
3237 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
3238 } else if ( c->op == LDAP_MOD_DELETE ) {
3240 global_disallows = 0;
3242 disallows = verb_to_mask( c->line, disallowable_ops );
3243 global_disallows ^= disallows;
3247 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
3249 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3250 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3251 c->log, c->cr_msg, c->argv[i]);
3254 global_disallows |= disallows;
3259 config_requires(ConfigArgs *c) {
3260 slap_mask_t requires = frontendDB->be_requires;
3261 int i, argc = c->argc;
3262 char **argv = c->argv;
3264 slap_verbmasks requires_ops[] = {
3265 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
3266 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
3267 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
3268 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
3269 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
3272 if (c->op == SLAP_CONFIG_EMIT) {
3273 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
3274 } else if ( c->op == LDAP_MOD_DELETE ) {
3276 c->be->be_requires = 0;
3278 requires = verb_to_mask( c->line, requires_ops );
3279 c->be->be_requires ^= requires;
3283 /* "none" can only be first, to wipe out default/global values */
3284 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
3289 i = verbs_to_mask(argc, argv, requires_ops, &requires);
3291 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
3292 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
3293 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3294 c->log, c->cr_msg, 0);
3296 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
3297 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3298 c->log, c->cr_msg, c->argv[i]);
3302 c->be->be_requires = requires;
3307 config_extra_attrs(ConfigArgs *c)
3309 assert( c->be != NULL );
3311 if ( c->op == SLAP_CONFIG_EMIT ) {
3314 if ( c->be->be_extra_anlist == NULL ) {
3318 for ( i = 0; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3319 value_add_one( &c->rvalue_vals, &c->be->be_extra_anlist[i].an_name );
3322 } else if ( c->op == LDAP_MOD_DELETE ) {
3323 if ( c->be->be_extra_anlist == NULL ) {
3327 if ( c->valx < 0 ) {
3328 anlist_free( c->be->be_extra_anlist, 1, NULL );
3329 c->be->be_extra_anlist = NULL;
3334 for ( i = 0; i < c->valx && !BER_BVISNULL( &c->be->be_extra_anlist[i + 1].an_name ); i++ )
3337 if ( BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ) ) {
3341 ch_free( c->be->be_extra_anlist[i].an_name.bv_val );
3343 for ( ; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3344 c->be->be_extra_anlist[i] = c->be->be_extra_anlist[i + 1];
3349 c->be->be_extra_anlist = str2anlist( c->be->be_extra_anlist, c->argv[1], " ,\t" );
3350 if ( c->be->be_extra_anlist == NULL ) {
3358 static slap_verbmasks *loglevel_ops;
3361 loglevel_init( void )
3363 slap_verbmasks lo[] = {
3364 { BER_BVC("Any"), (slap_mask_t) LDAP_DEBUG_ANY },
3365 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
3366 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
3367 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
3368 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
3369 { BER_BVC("BER"), LDAP_DEBUG_BER },
3370 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
3371 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
3372 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
3373 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
3374 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
3375 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
3376 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
3377 #if 0 /* no longer used (nor supported) */
3378 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
3379 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
3381 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
3382 { BER_BVC("None"), LDAP_DEBUG_NONE },
3386 return slap_verbmasks_init( &loglevel_ops, lo );
3390 loglevel_destroy( void )
3392 if ( loglevel_ops ) {
3393 (void)slap_verbmasks_destroy( loglevel_ops );
3395 loglevel_ops = NULL;
3398 static slap_mask_t loglevel_ignore[] = { -1, 0 };
3401 slap_loglevel_register( slap_mask_t m, struct berval *s )
3405 if ( loglevel_ops == NULL ) {
3409 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
3412 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
3420 slap_loglevel_get( struct berval *s, int *l )
3425 if ( loglevel_ops == NULL ) {
3429 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3430 m |= loglevel_ops[ i ].mask;
3433 for ( i = 1; m & i; i <<= 1 )
3440 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
3443 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
3454 str2loglevel( const char *s, int *l )
3458 if ( loglevel_ops == NULL ) {
3462 i = verb_to_mask( s, loglevel_ops );
3464 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
3468 *l = loglevel_ops[ i ].mask;
3474 loglevel2str( int l )
3476 struct berval bv = BER_BVNULL;
3478 loglevel2bv( l, &bv );
3484 loglevel2bv( int l, struct berval *bv )
3486 if ( loglevel_ops == NULL ) {
3492 return enum_to_verb( loglevel_ops, l, bv ) == -1;
3496 loglevel2bvarray( int l, BerVarray *bva )
3498 if ( loglevel_ops == NULL ) {
3502 return mask_to_verbs( loglevel_ops, l, bva );
3506 loglevel_print( FILE *out )
3510 if ( loglevel_ops == NULL ) {
3514 fprintf( out, "Installed log subsystems:\n\n" );
3515 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3516 unsigned mask = loglevel_ops[ i ].mask & 0xffffffffUL;
3518 (mask == ((slap_mask_t) -1 & 0xffffffffUL)
3519 ? "\t%-30s (-1, 0xffffffff)\n" : "\t%-30s (%u, 0x%x)\n"),
3520 loglevel_ops[ i ].word.bv_val, mask, mask );
3523 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
3524 "by specific code\n\n" );
3529 static int config_syslog;
3532 config_loglevel(ConfigArgs *c) {
3535 if ( loglevel_ops == NULL ) {
3539 if (c->op == SLAP_CONFIG_EMIT) {
3540 /* Get default or commandline slapd setting */
3541 if ( ldap_syslog && !config_syslog )
3542 config_syslog = ldap_syslog;
3543 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
3545 } else if ( c->op == LDAP_MOD_DELETE ) {
3549 int level = verb_to_mask( c->line, loglevel_ops );
3550 config_syslog ^= level;
3552 if ( slapMode & SLAP_SERVER_MODE ) {
3553 ldap_syslog = config_syslog;
3558 for( i=1; i < c->argc; i++ ) {
3561 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
3562 if( lutil_atoix( &level, c->argv[i], 0 ) != 0 ) {
3563 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
3564 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3565 c->log, c->cr_msg, c->argv[i]);
3569 if ( str2loglevel( c->argv[i], &level ) ) {
3570 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown level", c->argv[0] );
3571 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3572 c->log, c->cr_msg, c->argv[i]);
3576 /* Explicitly setting a zero clears all the levels */
3578 config_syslog |= level;
3582 if ( slapMode & SLAP_SERVER_MODE ) {
3583 ldap_syslog = config_syslog;
3589 config_referral(ConfigArgs *c) {
3591 if (c->op == SLAP_CONFIG_EMIT) {
3592 if ( default_referral ) {
3593 value_add( &c->rvalue_vals, default_referral );
3598 } else if ( c->op == LDAP_MOD_DELETE ) {
3599 if ( c->valx < 0 ) {
3600 ber_bvarray_free( default_referral );
3601 default_referral = NULL;
3604 ch_free( default_referral[i].bv_val );
3605 for (; default_referral[i].bv_val; i++ )
3606 default_referral[i] = default_referral[i+1];
3610 if(validate_global_referral(c->argv[1])) {
3611 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3612 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3613 c->log, c->cr_msg, c->argv[1]);
3617 ber_str2bv(c->argv[1], 0, 0, &val);
3618 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
3626 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
3627 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
3628 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
3629 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
3630 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
3631 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
3632 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
3633 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
3634 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
3639 config_security(ConfigArgs *c) {
3640 slap_ssf_set_t *set = &c->be->be_ssf_set;
3643 if (c->op == SLAP_CONFIG_EMIT) {
3649 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
3650 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
3653 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
3654 if ( bv.bv_len >= sizeof( numbuf ) ) {
3655 ber_bvarray_free_x( c->rvalue_vals, NULL );
3656 c->rvalue_vals = NULL;
3660 bv.bv_len += sec_keys[i].key.bv_len;
3661 bv.bv_val = ch_malloc( bv.bv_len + 1);
3662 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
3663 strcpy( next, numbuf );
3664 ber_bvarray_add( &c->rvalue_vals, &bv );
3669 for(i = 1; i < c->argc; i++) {
3670 slap_ssf_t *tgt = NULL;
3672 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
3673 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
3674 sec_keys[j].key.bv_len)) {
3675 src = c->argv[i] + sec_keys[j].key.bv_len;
3676 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
3681 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown factor", c->argv[0] );
3682 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3683 c->log, c->cr_msg, c->argv[i]);
3687 if ( lutil_atou( tgt, src ) != 0 ) {
3688 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse factor", c->argv[0] );
3689 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3690 c->log, c->cr_msg, c->argv[i]);
3698 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
3702 for (; !BER_BVISNULL( &an->an_name ); an++) {
3703 /* if buflen == 0, assume the buffer size has been
3704 * already checked otherwise */
3705 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
3706 if ( comma ) *ptr++ = ',';
3707 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
3714 config_updatedn(ConfigArgs *c) {
3715 if (c->op == SLAP_CONFIG_EMIT) {
3716 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
3717 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
3718 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
3722 } else if ( c->op == LDAP_MOD_DELETE ) {
3723 ch_free( c->be->be_update_ndn.bv_val );
3724 BER_BVZERO( &c->be->be_update_ndn );
3725 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
3728 if(SLAP_SHADOW(c->be)) {
3729 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database already shadowed", c->argv[0] );
3730 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3731 c->log, c->cr_msg, 0);
3735 ber_memfree_x( c->value_dn.bv_val, NULL );
3736 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
3737 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
3739 c->be->be_update_ndn = c->value_ndn;
3740 BER_BVZERO( &c->value_dn );
3741 BER_BVZERO( &c->value_ndn );
3743 return config_slurp_shadow( c );
3747 config_shadow( ConfigArgs *c, slap_mask_t flag )
3749 char *notallowed = NULL;
3751 if ( c->be == frontendDB ) {
3752 notallowed = "frontend";
3754 } else if ( SLAP_MONITOR(c->be) ) {
3755 notallowed = "monitor";
3758 if ( notallowed != NULL ) {
3759 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
3763 if ( SLAP_SHADOW(c->be) ) {
3764 /* if already shadow, only check consistency */
3765 if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
3766 Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%lx.\n",
3772 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
3779 config_updateref(ConfigArgs *c) {
3781 if (c->op == SLAP_CONFIG_EMIT) {
3782 if ( c->be->be_update_refs ) {
3783 value_add( &c->rvalue_vals, c->be->be_update_refs );
3788 } else if ( c->op == LDAP_MOD_DELETE ) {
3789 if ( c->valx < 0 ) {
3790 ber_bvarray_free( c->be->be_update_refs );
3791 c->be->be_update_refs = NULL;
3794 ch_free( c->be->be_update_refs[i].bv_val );
3795 for (; c->be->be_update_refs[i].bv_val; i++)
3796 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
3800 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
3801 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> must appear after syncrepl or updatedn",
3803 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3804 c->log, c->cr_msg, 0);
3808 if(validate_global_referral(c->argv[1])) {
3809 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3810 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3811 c->log, c->cr_msg, c->argv[1]);
3814 ber_str2bv(c->argv[1], 0, 0, &val);
3815 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
3820 config_obsolete(ConfigArgs *c) {
3821 if (c->op == SLAP_CONFIG_EMIT)
3824 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> keyword is obsolete (ignored)",
3826 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0);
3831 config_include(ConfigArgs *c) {
3832 int savelineno = c->lineno;
3835 ConfigFile *cfsave = cfn;
3836 ConfigFile *cf2 = NULL;
3838 /* Leftover from RE23. No dynamic config for include files */
3839 if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
3842 cf = ch_calloc( 1, sizeof(ConfigFile));
3843 if ( cfn->c_kids ) {
3844 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
3850 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
3851 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
3852 c->lineno = savelineno - 1;
3855 if ( cf2 ) cf2->c_sibs = NULL;
3856 else cfn->c_kids = NULL;
3857 ch_free( cf->c_file.bv_val );
3867 config_tls_cleanup(ConfigArgs *c) {
3870 if ( slap_tls_ld ) {
3873 ldap_pvt_tls_ctx_free( slap_tls_ctx );
3875 /* Force new ctx to be created */
3876 rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
3878 /* The ctx's refcount is bumped up here */
3879 ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
3880 /* This is a no-op if it's already loaded */
3881 load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
3888 config_tls_option(ConfigArgs *c) {
3890 LDAP *ld = slap_tls_ld;
3892 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
3893 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
3894 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
3895 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
3896 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
3897 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
3898 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
3900 case CFG_TLS_CRL_FILE: flag = LDAP_OPT_X_TLS_CRLFILE; break;
3902 default: Debug(LDAP_DEBUG_ANY, "%s: "
3903 "unknown tls_option <0x%x>\n",
3904 c->log, c->type, 0);
3907 if (c->op == SLAP_CONFIG_EMIT) {
3908 return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3909 } else if ( c->op == LDAP_MOD_DELETE ) {
3910 c->cleanup = config_tls_cleanup;
3911 return ldap_pvt_tls_set_option( ld, flag, NULL );
3913 ch_free(c->value_string);
3914 c->cleanup = config_tls_cleanup;
3915 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3918 /* FIXME: this ought to be provided by libldap */
3920 config_tls_config(ConfigArgs *c) {
3923 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
3924 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
3925 case CFG_TLS_PROTOCOL_MIN: flag = LDAP_OPT_X_TLS_PROTOCOL_MIN; break;
3927 Debug(LDAP_DEBUG_ANY, "%s: "
3928 "unknown tls_option <0x%x>\n",
3929 c->log, c->type, 0);
3932 if (c->op == SLAP_CONFIG_EMIT) {
3933 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3934 } else if ( c->op == LDAP_MOD_DELETE ) {
3936 c->cleanup = config_tls_cleanup;
3937 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3939 ch_free( c->value_string );
3940 c->cleanup = config_tls_cleanup;
3941 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3942 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3943 Debug(LDAP_DEBUG_ANY, "%s: "
3944 "unable to parse %s \"%s\"\n",
3945 c->log, c->argv[0], c->argv[1] );
3948 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
3950 return(ldap_pvt_tls_config(slap_tls_ld, flag, c->argv[1]));
3955 static CfEntryInfo *
3956 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
3966 if ( dn_match( &root->ce_entry->e_nname, dn ))
3969 c = dn->bv_val+dn->bv_len;
3970 for (;*c != ',';c--);
3974 for (--c;c>dn->bv_val && *c != ',';c--);
3978 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
3980 root = root->ce_kids;
3982 for (;root;root=root->ce_sibs) {
3983 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
3984 if ( cdn.bv_val == dn->bv_val ) {
3994 typedef struct setup_cookie {
4004 config_ldif_resp( Operation *op, SlapReply *rs )
4006 if ( rs->sr_type == REP_SEARCH ) {
4007 setup_cookie *sc = op->o_callback->sc_private;
4010 sc->cfb->cb_got_ldif = 1;
4011 /* Does the frontend exist? */
4012 if ( !sc->got_frontend ) {
4013 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
4014 "olcDatabase", STRLENOF( "olcDatabase" )))
4016 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4017 STRLENOF( "olcDatabase" ), "={-1}frontend",
4018 STRLENOF( "={-1}frontend" )))
4022 sc->ca->be = frontendDB;
4023 sc->ca->bi = frontendDB->bd_info;
4024 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
4025 rdn.bv_val = sc->ca->log;
4026 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4027 "%s=" SLAP_X_ORDERED_FMT "%s",
4028 cfAd_database->ad_cname.bv_val, -1,
4029 sc->ca->bi->bi_type);
4031 sc->frontend = config_build_entry( op, rs,
4032 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
4033 sc->ca->be->be_cf_ocs );
4043 dnParent( &rs->sr_entry->e_nname, &pdn );
4045 /* Does the configDB exist? */
4046 if ( sc->got_frontend && !sc->got_config &&
4047 !strncmp( rs->sr_entry->e_nname.bv_val,
4048 "olcDatabase", STRLENOF( "olcDatabase" )) &&
4049 dn_match( &config_rdn, &pdn ) )
4051 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4052 STRLENOF( "olcDatabase" ), "={0}config",
4053 STRLENOF( "={0}config" )))
4057 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
4058 sc->ca->bi = sc->ca->be->bd_info;
4059 rdn.bv_val = sc->ca->log;
4060 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4061 "%s=" SLAP_X_ORDERED_FMT "%s",
4062 cfAd_database->ad_cname.bv_val, 0,
4063 sc->ca->bi->bi_type);
4065 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
4066 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
4073 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
4074 if ( rs->sr_err != LDAP_SUCCESS ) {
4075 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
4076 rs->sr_entry->e_name.bv_val, sc->ca->cr_msg, 0 );
4082 /* Configure and read the underlying back-ldif store */
4084 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
4085 CfBackInfo *cfb = be->be_private;
4091 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
4092 Connection conn = {0};
4093 OperationBuffer opbuf;
4095 SlapReply rs = {REP_RESULT};
4096 Filter filter = { LDAP_FILTER_PRESENT };
4097 struct berval filterstr = BER_BVC("(objectclass=*)");
4100 /* Is the config directory available? */
4101 if ( stat( dir, &st ) < 0 ) {
4102 /* No, so don't bother using the backing store.
4103 * All changes will be in-memory only.
4108 cfb->cb_db.bd_info = backend_info( "ldif" );
4109 if ( !cfb->cb_db.bd_info )
4110 return 0; /* FIXME: eventually this will be a fatal error */
4112 if ( backend_db_init( "ldif", &cfb->cb_db, -1, NULL ) == NULL )
4115 cfb->cb_db.be_suffix = be->be_suffix;
4116 cfb->cb_db.be_nsuffix = be->be_nsuffix;
4118 /* The suffix is always "cn=config". The underlying DB's rootdn
4119 * is always the same as the suffix.
4121 cfb->cb_db.be_rootdn = be->be_suffix[0];
4122 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
4124 ber_str2bv( dir, 0, 1, &cfdir );
4129 argv[0] = "directory";
4130 argv[1] = (char *)dir;
4135 c.table = Cft_Database;
4137 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
4141 if ( config_add_vals( ct, &c ))
4144 if ( backend_startup_one( &cfb->cb_db, &c.reply ))
4148 void *thrctx = ldap_pvt_thread_pool_context();
4151 connection_fake_init( &conn, &opbuf, thrctx );
4154 filter.f_desc = slap_schema.si_ad_objectClass;
4156 op->o_tag = LDAP_REQ_SEARCH;
4158 op->ors_filter = &filter;
4159 op->ors_filterstr = filterstr;
4160 op->ors_scope = LDAP_SCOPE_SUBTREE;
4162 op->o_dn = c.be->be_rootdn;
4163 op->o_ndn = c.be->be_rootndn;
4165 op->o_req_dn = be->be_suffix[0];
4166 op->o_req_ndn = be->be_nsuffix[0];
4168 op->ors_tlimit = SLAP_NO_LIMIT;
4169 op->ors_slimit = SLAP_NO_LIMIT;
4171 op->ors_attrs = slap_anlist_all_attributes;
4172 op->ors_attrsonly = 0;
4174 op->o_callback = &cb;
4177 cb.sc_private = ≻
4178 sc.got_frontend = 0;
4183 op->o_bd = &cfb->cb_db;
4185 /* Allow unknown attrs in DNs */
4186 prev_DN_strict = slap_DN_strict;
4189 rc = op->o_bd->be_search( op, &rs );
4191 /* Restore normal DN validation */
4192 slap_DN_strict = prev_DN_strict;
4194 op->o_tag = LDAP_REQ_ADD;
4195 if ( rc == LDAP_SUCCESS && sc.frontend ) {
4196 op->ora_e = sc.frontend;
4197 rc = op->o_bd->be_add( op, &rs );
4199 if ( rc == LDAP_SUCCESS && sc.config ) {
4200 op->ora_e = sc.config;
4201 rc = op->o_bd->be_add( op, &rs );
4203 ldap_pvt_thread_pool_context_reset( thrctx );
4206 /* ITS#4194 - only use if it's present, or we're converting. */
4207 if ( !readit || rc == LDAP_SUCCESS )
4208 cfb->cb_use_ldif = 1;
4214 CfOc_cmp( const void *c1, const void *c2 ) {
4215 const ConfigOCs *co1 = c1;
4216 const ConfigOCs *co2 = c2;
4218 return ber_bvcmp( co1->co_name, co2->co_name );
4222 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
4225 i = init_config_attrs( ct );
4228 /* set up the objectclasses */
4229 i = init_config_ocs( ocs );
4232 for (i=0; ocs[i].co_def; i++) {
4233 if ( ocs[i].co_oc ) {
4234 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
4235 if ( !ocs[i].co_table )
4236 ocs[i].co_table = ct;
4237 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
4244 read_config(const char *fname, const char *dir) {
4247 const char *cfdir, *cfname;
4250 /* Setup the config backend */
4251 be = backend_db_init( "config", NULL, 0, NULL );
4255 cfb = be->be_private;
4256 be->be_dfltaccess = ACL_NONE;
4258 /* If no .conf, or a dir was specified, setup the dir */
4259 if ( !fname || dir ) {
4261 /* If explicitly given, check for existence */
4264 if ( stat( dir, &st ) < 0 ) {
4265 Debug( LDAP_DEBUG_ANY,
4266 "invalid config directory %s, error %d\n",
4272 cfdir = SLAPD_DEFAULT_CONFIGDIR;
4274 /* if fname is defaulted, try reading .d */
4275 rc = config_setup_ldif( be, cfdir, !fname );
4278 /* It may be OK if the base object doesn't exist yet. */
4279 if ( rc != LDAP_NO_SUCH_OBJECT )
4281 /* ITS#4194: But if dir was specified and no fname,
4282 * then we were supposed to read the dir. Unless we're
4283 * trying to slapadd the dir...
4285 if ( dir && !fname ) {
4286 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
4288 /* Assume it's slapadd with a config dir, let it continue */
4290 cfb->cb_got_ldif = 1;
4291 cfb->cb_use_ldif = 1;
4296 /* If we read the config from back-ldif, nothing to do here */
4297 if ( cfb->cb_got_ldif ) {
4306 cfname = SLAPD_DEFAULT_CONFIGFILE;
4308 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
4311 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
4314 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
4315 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
4316 &frontendDB->be_schemadn );
4317 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
4318 if ( rc != LDAP_SUCCESS ) {
4319 Debug(LDAP_DEBUG_ANY, "read_config: "
4320 "unable to normalize default schema DN \"%s\"\n",
4321 frontendDB->be_schemadn.bv_val, 0, 0 );
4322 /* must not happen */
4330 config_back_bind( Operation *op, SlapReply *rs )
4332 if ( be_isroot_pw( op ) ) {
4333 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
4334 /* frontend sends result */
4335 return LDAP_SUCCESS;
4338 rs->sr_err = LDAP_INVALID_CREDENTIALS;
4339 send_ldap_result( op, rs );
4345 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
4349 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
4351 rs->sr_attrs = op->ors_attrs;
4352 rs->sr_entry = ce->ce_entry;
4354 rc = send_search_entry( op, rs );
4355 if ( rc != LDAP_SUCCESS ) {
4359 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
4360 if ( ce->ce_kids ) {
4361 rc = config_send( op, rs, ce->ce_kids, 1 );
4362 if ( rc ) return rc;
4365 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
4366 rc = config_send( op, rs, ce, 0 );
4374 static ConfigTable *
4375 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
4380 for (j=0; j<nocs; j++) {
4381 for (i=0; colst[j]->co_table[i].name; i++)
4382 if ( colst[j]->co_table[i].ad == ad ) {
4383 ca->table = colst[j]->co_type;
4384 return &colst[j]->co_table[i];
4390 /* Sort the attributes of the entry according to the order defined
4391 * in the objectclass, with required attributes occurring before
4392 * allowed attributes. For any attributes with sequencing dependencies
4393 * (e.g., rootDN must be defined after suffix) the objectclass must
4394 * list the attributes in the desired sequence.
4397 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
4399 Attribute *a, *head = NULL, *tail = NULL, **prev;
4402 for (i=0; i<nocs; i++) {
4403 if ( colst[i]->co_oc->soc_required ) {
4404 AttributeType **at = colst[i]->co_oc->soc_required;
4405 for (j=0; at[j]; j++) {
4406 for (a=e->e_attrs, prev=&e->e_attrs; a;
4407 prev = &(*prev)->a_next, a=a->a_next) {
4408 if ( a->a_desc == at[j]->sat_ad ) {
4422 if ( colst[i]->co_oc->soc_allowed ) {
4423 AttributeType **at = colst[i]->co_oc->soc_allowed;
4424 for (j=0; at[j]; j++) {
4425 for (a=e->e_attrs, prev=&e->e_attrs; a;
4426 prev = &(*prev)->a_next, a=a->a_next) {
4427 if ( a->a_desc == at[j]->sat_ad ) {
4443 tail->a_next = e->e_attrs;
4449 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
4451 Attribute *a = NULL;
4452 AttributeDescription *ad;
4462 Modifications *ml = ptr;
4464 vals = ml->sml_values;
4467 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
4468 rc = ordered_value_sort( a, 1 );
4470 snprintf(ca->cr_msg, sizeof( ca->cr_msg ), "ordered_value_sort failed on attr %s\n",
4471 ad->ad_cname.bv_val );
4475 for ( i=0; vals[i].bv_val; i++ ) {
4476 ca->line = vals[i].bv_val;
4477 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
4478 ca->line[0] == '{' ) {
4479 char *idx = strchr( ca->line, '}' );
4480 if ( idx ) ca->line = idx+1;
4482 rc = config_parse_vals( ct, ca, i );
4491 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
4494 struct berval rtype, rval;
4496 AttributeDescription *ad = NULL;
4498 dnRdn( &e->e_name, rdn );
4499 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
4500 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
4501 rtype.bv_val = rdn->bv_val;
4502 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
4505 slap_bv2ad( &rtype, &ad, &rs->sr_text );
4506 a = attr_find( e->e_attrs, ad );
4507 if (!a ) return LDAP_NAMING_VIOLATION;
4514 config_rename_kids( CfEntryInfo *ce )
4517 struct berval rdn, nrdn;
4519 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
4520 struct berval newdn, newndn;
4521 dnRdn ( &ce2->ce_entry->e_name, &rdn );
4522 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
4523 build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
4524 build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
4525 free( ce2->ce_entry->e_name.bv_val );
4526 free( ce2->ce_entry->e_nname.bv_val );
4527 ce2->ce_entry->e_name = newdn;
4528 ce2->ce_entry->e_nname = newndn;
4529 config_rename_kids( ce2 );
4534 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
4535 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
4536 struct berval *nnewrdn, int use_ldif )
4540 struct berval odn, ondn;
4544 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
4545 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
4548 free( a->a_vals[0].bv_val );
4549 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
4550 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
4551 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
4552 strcpy( a->a_vals[0].bv_val, ptr1 );
4554 if ( a->a_nvals != a->a_vals ) {
4555 free( a->a_nvals[0].bv_val );
4556 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
4557 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
4558 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
4559 strcpy( a->a_nvals[0].bv_val, ptr1 );
4562 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
4563 BackendDB *be = op->o_bd;
4564 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4565 struct berval dn, ndn, xdn, xndn;
4567 op->o_bd = &cfb->cb_db;
4569 /* Save current rootdn; use the underlying DB's rootdn */
4573 xndn = op->o_req_ndn;
4574 op->o_dn = op->o_bd->be_rootdn;
4575 op->o_ndn = op->o_bd->be_rootndn;
4577 op->o_req_ndn = ondn;
4579 scp = op->o_callback;
4580 op->o_callback = ≻
4581 op->orr_newrdn = *newrdn;
4582 op->orr_nnewrdn = *nnewrdn;
4583 op->orr_newSup = NULL;
4584 op->orr_nnewSup = NULL;
4585 op->orr_deleteoldrdn = 1;
4586 op->orr_modlist = NULL;
4587 slap_modrdn2mods( op, rs );
4588 slap_mods_opattrs( op, &op->orr_modlist, 1 );
4589 rc = op->o_bd->be_modrdn( op, rs );
4590 slap_mods_free( op->orr_modlist, 1 );
4593 op->o_callback = scp;
4597 op->o_req_ndn = xndn;
4600 free( ondn.bv_val );
4602 config_rename_kids( e->e_private );
4607 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
4608 Entry *e, int idx, int tailindex, int use_ldif )
4610 struct berval ival, newrdn, nnewrdn;
4613 char ibuf[32], *ptr1, *ptr2 = NULL;
4616 rc = config_rename_attr( rs, e, &rdn, &a );
4617 if ( rc ) return rc;
4620 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
4621 if ( ival.bv_len >= sizeof( ibuf ) ) {
4622 return LDAP_NAMING_VIOLATION;
4625 newrdn.bv_len = rdn.bv_len + ival.bv_len;
4626 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
4629 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
4630 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4633 ptr2 = ber_bvchr( &rdn, '}' );
4637 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
4639 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
4640 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
4641 a->a_desc->ad_cname.bv_len );
4643 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4644 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
4648 /* Do the equivalent of ModRDN */
4649 /* Replace DN / NDN */
4650 newrdn.bv_len = ptr1 - newrdn.bv_val;
4651 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
4652 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
4654 free( nnewrdn.bv_val );
4655 free( newrdn.bv_val );
4660 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
4661 SlapReply *rs, int *renum, int *ibase )
4664 int index = -1, gotindex = 0, nsibs, rc = 0;
4665 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
4666 char *ptr1, *ptr2 = NULL;
4669 if ( renum ) *renum = 0;
4671 /* These entries don't get indexed/renumbered */
4672 if ( ce_type == Cft_Global ) return 0;
4673 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
4675 if ( ce_type == Cft_Module )
4678 /* See if the rdn has an index already */
4679 dnRdn( &e->e_name, &rdn );
4680 if ( ce_type == Cft_Database ) {
4681 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
4682 "frontend", STRLENOF("frontend") ))
4684 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
4685 "config", STRLENOF("config") ))
4688 ptr1 = ber_bvchr( &e->e_name, '{' );
4689 if ( ptr1 && ptr1 < &e->e_name.bv_val[ rdn.bv_len ] ) {
4691 ptr2 = strchr( ptr1, '}' );
4692 if ( !ptr2 || ptr2 > &e->e_name.bv_val[ rdn.bv_len ] )
4693 return LDAP_NAMING_VIOLATION;
4694 if ( ptr2-ptr1 == 1)
4695 return LDAP_NAMING_VIOLATION;
4697 index = strtol( ptr1 + 1, &next, 10 );
4698 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
4699 return LDAP_NAMING_VIOLATION;
4702 /* Special case, we allow -1 for the frontendDB */
4703 if ( index != -1 || !isfrontend )
4704 return LDAP_NAMING_VIOLATION;
4706 if ( isconfig && index != 0 ){
4707 return LDAP_NAMING_VIOLATION;
4711 /* count related kids */
4712 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
4713 if ( ce->ce_type == ce_type ) nsibs++;
4716 /* account for -1 frontend */
4717 if ( ce_type == Cft_Database )
4720 if ( index != nsibs ) {
4722 if ( index < nsibs ) {
4723 if ( tailindex ) return LDAP_NAMING_VIOLATION;
4724 /* Siblings need to be renumbered */
4725 if ( index != -1 || !isfrontend )
4729 /* config DB is always "0" */
4730 if ( isconfig && index == -1 ) {
4733 if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
4737 /* just make index = nsibs */
4739 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
4742 if ( ibase ) *ibase = index;
4743 if ( renum ) *renum = renumber;
4748 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
4753 co.co_name = &oc->soc_cname;
4754 cop = avl_find( CfOcTree, &co, CfOc_cmp );
4758 /* check for duplicates */
4759 for ( i = 0; i < *nocs; i++ ) {
4760 if ( *copp && (*copp)[i] == cop ) {
4766 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
4767 if ( tmp == NULL ) {
4771 (*copp)[*nocs] = cop;
4776 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
4777 if ( count_oc( *sups, copp, nocs ) ) {
4786 count_ocs( Attribute *oc_at, int *nocs )
4789 ConfigOCs **colst = NULL;
4793 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
4797 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
4799 assert( oc != NULL );
4800 if ( count_oc( oc, &colst, nocs ) ) {
4810 cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4812 /* Leftover from RE23. Never parse this entry */
4813 return LDAP_COMPARE_TRUE;
4817 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4821 /* This entry is hardcoded, don't re-parse it */
4822 if ( p->ce_type == Cft_Global ) {
4823 cfn = p->ce_private;
4824 ca->ca_private = cfn;
4825 return LDAP_COMPARE_TRUE;
4827 if ( p->ce_type != Cft_Schema )
4828 return LDAP_CONSTRAINT_VIOLATION;
4830 cfn = ch_calloc( 1, sizeof(ConfigFile) );
4831 ca->ca_private = cfn;
4832 cfo = p->ce_private;
4833 cfn->c_sibs = cfo->c_kids;
4835 return LDAP_SUCCESS;
4839 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4841 if ( p->ce_type != Cft_Global ) {
4842 return LDAP_CONSTRAINT_VIOLATION;
4844 /* config must be {0}, nothing else allowed */
4845 if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
4846 strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
4847 return LDAP_CONSTRAINT_VIOLATION;
4849 ca->be = frontendDB; /* just to get past check_vals */
4850 return LDAP_SUCCESS;
4854 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4856 if ( p->ce_type != Cft_Global ) {
4857 return LDAP_CONSTRAINT_VIOLATION;
4859 return LDAP_SUCCESS;
4863 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4865 if ( p->ce_type != Cft_Global ) {
4866 return LDAP_CONSTRAINT_VIOLATION;
4868 return LDAP_SUCCESS;
4872 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4874 if ( p->ce_type != Cft_Database ) {
4875 return LDAP_CONSTRAINT_VIOLATION;
4878 return LDAP_SUCCESS;
4882 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
4887 AttributeDescription *ad;
4893 if ( cfn->c_cr_head ) {
4894 struct berval bv = BER_BVC("olcDitContentRules");
4896 slap_bv2ad( &bv, &ad, &text );
4897 ct = config_find_table( colst, nocs, ad, ca );
4898 config_del_vals( ct, ca );
4900 if ( cfn->c_oc_head ) {
4901 struct berval bv = BER_BVC("olcObjectClasses");
4903 slap_bv2ad( &bv, &ad, &text );
4904 ct = config_find_table( colst, nocs, ad, ca );
4905 config_del_vals( ct, ca );
4907 if ( cfn->c_at_head ) {
4908 struct berval bv = BER_BVC("olcAttributeTypes");
4910 slap_bv2ad( &bv, &ad, &text );
4911 ct = config_find_table( colst, nocs, ad, ca );
4912 config_del_vals( ct, ca );
4914 if ( cfn->c_syn_head ) {
4915 struct berval bv = BER_BVC("olcLdapSyntaxes");
4917 slap_bv2ad( &bv, &ad, &text );
4918 ct = config_find_table( colst, nocs, ad, ca );
4919 config_del_vals( ct, ca );
4921 if ( cfn->c_om_head ) {
4922 struct berval bv = BER_BVC("olcObjectIdentifier");
4924 slap_bv2ad( &bv, &ad, &text );
4925 ct = config_find_table( colst, nocs, ad, ca );
4926 config_del_vals( ct, ca );
4928 cfo = p->ce_private;
4929 cfo->c_kids = cfn->c_sibs;
4934 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
4936 int rc = LDAP_CONSTRAINT_VIOLATION;
4939 if ( (*cop)->co_ldadd ) {
4940 rc = (*cop)->co_ldadd( last, e, ca );
4941 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4946 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
4947 ConfigOCs co = { 0 };
4949 co.co_name = &(*ocp)->soc_cname;
4950 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
4951 if ( *cop == NULL ) {
4955 rc = config_add_oc( cop, last, e, ca );
4956 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4964 /* Parse an LDAP entry into config directives */
4966 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
4967 int *renum, Operation *op )
4969 CfEntryInfo *ce, *last = NULL;
4970 ConfigOCs co, *coptr, **colst;
4971 Attribute *a, *oc_at, *soc_at;
4972 int i, ibase = -1, nocs, rc = 0;
4975 char *ptr, *log_prefix = op ? op->o_log_prefix : "";
4977 memset( ca, 0, sizeof(ConfigArgs));
4979 /* Make sure parent exists and entry does not. But allow
4980 * Databases and Overlays to be inserted. Don't do any
4981 * auto-renumbering if manageDSAit control is present.
4983 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
4985 if ( ( op && op->o_managedsait ) ||
4986 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
4987 ce->ce_type != Cft_Module ) )
4989 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4990 "DN=\"%s\" already exists\n",
4991 log_prefix, e->e_name.bv_val, 0 );
4992 /* global schema ignores all writes */
4993 if ( ce->ce_type == Cft_Schema && ce->ce_parent->ce_type == Cft_Global )
4994 return LDAP_COMPARE_TRUE;
4995 return LDAP_ALREADY_EXISTS;
4999 dnParent( &e->e_nname, &pdn );
5001 /* If last is NULL, the new entry is the root/suffix entry,
5002 * otherwise last should be the parent.
5004 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
5006 rs->sr_matched = last->ce_entry->e_name.bv_val;
5008 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5009 "DN=\"%s\" not child of DN=\"%s\"\n",
5010 log_prefix, e->e_name.bv_val,
5011 last->ce_entry->e_name.bv_val );
5012 return LDAP_NO_SUCH_OBJECT;
5016 /* No parent, must be root. This will never happen... */
5017 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
5018 return LDAP_NO_SUCH_OBJECT;
5021 if ( last && !access_allowed( op, last->ce_entry,
5022 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
5024 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5025 "DN=\"%s\" no write access to \"children\" of parent\n",
5026 log_prefix, e->e_name.bv_val, 0 );
5027 return LDAP_INSUFFICIENT_ACCESS;
5031 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5033 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5034 "DN=\"%s\" no objectClass\n",
5035 log_prefix, e->e_name.bv_val, 0 );
5036 return LDAP_OBJECT_CLASS_VIOLATION;
5039 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5041 ObjectClass *soc = NULL;
5042 char textbuf[ SLAP_TEXT_BUFLEN ];
5043 const char *text = textbuf;
5045 /* FIXME: check result */
5046 rc = structural_class( oc_at->a_nvals, &soc, NULL,
5047 &text, textbuf, sizeof(textbuf), NULL );
5048 if ( rc != LDAP_SUCCESS ) {
5049 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5050 "DN=\"%s\" no structural objectClass (%s)\n",
5051 log_prefix, e->e_name.bv_val, text );
5054 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
5055 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5056 if ( soc_at == NULL ) {
5057 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5058 "DN=\"%s\" no structural objectClass; "
5059 "unable to merge computed class %s\n",
5060 log_prefix, e->e_name.bv_val,
5061 soc->soc_cname.bv_val );
5062 return LDAP_OBJECT_CLASS_VIOLATION;
5065 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5066 "DN=\"%s\" no structural objectClass; "
5067 "computed objectClass %s merged\n",
5068 log_prefix, e->e_name.bv_val,
5069 soc->soc_cname.bv_val );
5072 /* Fake the coordinates based on whether we're part of an
5073 * LDAP Add or if reading the config dir
5076 ca->fname = "slapd";
5079 ca->fname = cfdir.bv_val;
5084 co.co_name = &soc_at->a_nvals[0];
5085 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
5086 if ( coptr == NULL ) {
5087 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5088 "DN=\"%s\" no structural objectClass in configuration table\n",
5089 log_prefix, e->e_name.bv_val, 0 );
5090 return LDAP_OBJECT_CLASS_VIOLATION;
5093 /* Only the root can be Cft_Global, everything else must
5094 * have a parent. Only limited nesting arrangements are allowed.
5096 rc = LDAP_CONSTRAINT_VIOLATION;
5097 if ( coptr->co_type == Cft_Global && !last ) {
5098 cfn = cfb->cb_config;
5099 ca->ca_private = cfn;
5100 ca->be = frontendDB; /* just to get past check_vals */
5104 colst = count_ocs( oc_at, &nocs );
5106 /* Check whether the Add is allowed by its parent, and do
5107 * any necessary arg setup
5110 rc = config_add_oc( &coptr, last, e, ca );
5111 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5112 for ( i = 0; i<nocs; i++ ) {
5113 /* Already checked these */
5114 if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
5116 if ( colst[i]->co_ldadd &&
5117 ( rc = colst[i]->co_ldadd( last, e, ca ))
5118 != LDAP_CONSTRAINT_VIOLATION ) {
5124 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5125 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5126 "DN=\"%s\" no structural objectClass add function\n",
5127 log_prefix, e->e_name.bv_val, 0 );
5128 return LDAP_OBJECT_CLASS_VIOLATION;
5132 /* Add the entry but don't parse it, we already have its contents */
5133 if ( rc == LDAP_COMPARE_TRUE ) {
5138 if ( rc != LDAP_SUCCESS )
5141 /* Parse all the values and check for simple syntax errors before
5142 * performing any set actions.
5144 * If doing an LDAPadd, check for indexed names and any necessary
5145 * renaming/renumbering. Entries that don't need indexed names are
5146 * ignored. Entries that need an indexed name and arrive without one
5147 * are assigned to the end. Entries that arrive with an index may
5148 * cause the following entries to be renumbered/bumped down.
5150 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
5151 * don't allow Adding an entry with an index that's already in use.
5152 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
5154 * These entries can have auto-assigned indexes (appended to the end)
5155 * but only the other types support auto-renumbering of siblings.
5158 rc = check_name_index( last, coptr->co_type, e, rs, renum,
5163 if ( renum && *renum && coptr->co_type != Cft_Database &&
5164 coptr->co_type != Cft_Overlay )
5166 snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
5167 "operation requires sibling renumbering" );
5168 rc = LDAP_UNWILLING_TO_PERFORM;
5173 init_config_argv( ca );
5175 /* Make sure we process attrs in the required order */
5176 sort_attrs( e, colst, nocs );
5178 for ( a = e->e_attrs; a; a = a->a_next ) {
5179 if ( a == oc_at ) continue;
5180 ct = config_find_table( colst, nocs, a->a_desc, ca );
5181 if ( !ct ) continue; /* user data? */
5182 rc = check_vals( ct, ca, a, 1 );
5183 if ( rc ) goto done_noop;
5186 /* Basic syntax checks are OK. Do the actual settings. */
5187 for ( a=e->e_attrs; a; a=a->a_next ) {
5188 if ( a == oc_at ) continue;
5189 ct = config_find_table( colst, nocs, a->a_desc, ca );
5190 if ( !ct ) continue; /* user data? */
5191 for (i=0; a->a_vals[i].bv_val; i++) {
5194 ca->line = a->a_vals[i].bv_val;
5195 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
5196 ptr = strchr( ca->line, '}' );
5198 iptr = strchr( ca->line, '{' );
5202 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
5204 ca->valx = strtol( iptr+1, NULL, 0 );
5209 rc = config_parse_add( ct, ca, i );
5217 /* Newly added databases and overlays need to be started up */
5218 if ( CONFIG_ONLINE_ADD( ca )) {
5219 if ( coptr->co_type == Cft_Database ) {
5220 rc = backend_startup_one( ca->be, &ca->reply );
5222 } else if ( coptr->co_type == Cft_Overlay ) {
5223 if ( ca->bi->bi_db_open ) {
5224 BackendInfo *bi_orig = ca->be->bd_info;
5225 ca->be->bd_info = ca->bi;
5226 rc = ca->bi->bi_db_open( ca->be, &ca->reply );
5227 ca->be->bd_info = bi_orig;
5229 } else if ( ca->cleanup ) {
5230 rc = ca->cleanup( ca );
5233 if (ca->cr_msg[0] == '\0')
5234 snprintf( ca->cr_msg, sizeof( ca->cr_msg ), "<%s> failed startup", ca->argv[0] );
5236 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
5237 ca->log, ca->cr_msg, ca->argv[1] );
5244 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5245 ce->ce_parent = last;
5246 ce->ce_entry = entry_dup( e );
5247 ce->ce_entry->e_private = ce;
5248 ce->ce_type = coptr->co_type;
5251 ce->ce_private = ca->ca_private;
5252 ca->ca_entry = ce->ce_entry;
5255 } else if ( last->ce_kids ) {
5256 CfEntryInfo *c2, **cprev;
5258 /* Advance to first of this type */
5259 cprev = &last->ce_kids;
5260 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
5261 cprev = &c2->ce_sibs;
5264 /* Account for the (-1) frontendDB entry */
5265 if ( ce->ce_type == Cft_Database ) {
5266 if ( ca->be == frontendDB )
5268 else if ( ibase != -1 )
5273 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
5274 cprev = &c2->ce_sibs;
5280 for ( i=0; i<ibase; i++ ) {
5282 cprev = &c2->ce_sibs;
5285 ce->ce_sibs = *cprev;
5293 if ( (coptr->co_type == Cft_Database) && ca->be ) {
5294 if ( ca->be != frontendDB )
5295 backend_destroy_one( ca->be, 1 );
5296 } else if ( (coptr->co_type == Cft_Overlay) && ca->bi ) {
5297 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
5298 } else if ( coptr->co_type == Cft_Schema ) {
5299 schema_destroy_one( ca, colst, nocs, last );
5304 ch_free( ca->argv );
5305 if ( colst ) ch_free( colst );
5309 #define BIGTMP 10000
5311 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5312 int base, int rebase, int max, int use_ldif )
5314 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
5315 ConfigType etype = ce->ce_type;
5316 int count = 0, rc = 0;
5318 /* Reverse ce list */
5319 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
5320 if (ce2->ce_type != etype) {
5325 ce2->ce_sibs = cetmp;
5328 if ( max && count >= max ) {
5334 /* Move original to a temp name until increments are done */
5336 ce->ce_entry->e_private = NULL;
5337 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5338 base+BIGTMP, 0, use_ldif );
5339 ce->ce_entry->e_private = ce;
5341 /* start incrementing */
5342 for (ce2=cetmp; ce2; ce2=ce3) {
5344 ce2->ce_sibs = cerem;
5347 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5348 count+base, 0, use_ldif );
5352 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5353 base, 0, use_ldif );
5358 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5359 CfEntryInfo *ce2, int old, int use_ldif )
5363 /* Renumber original to a temp value */
5364 ce->ce_entry->e_private = NULL;
5365 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5366 old+BIGTMP, 0, use_ldif );
5367 ce->ce_entry->e_private = ce;
5369 /* start decrementing */
5370 for (; ce2 != ce; ce2=ce2->ce_sibs) {
5371 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5372 count+old, 0, use_ldif );
5375 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5376 count+old, 0, use_ldif );
5379 /* Parse an LDAP entry into config directives, then store in underlying
5383 config_back_add( Operation *op, SlapReply *rs )
5389 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
5390 NULL, ACL_WADD, NULL )) {
5391 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5396 * Check for attribute ACL
5398 if ( !acl_check_modlist( op, op->ora_e, op->orm_modlist )) {
5399 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5400 rs->sr_text = "no write access to attribute";
5404 cfb = (CfBackInfo *)op->o_bd->be_private;
5406 /* add opattrs for syncprov */
5408 char textbuf[SLAP_TEXT_BUFLEN];
5409 size_t textlen = sizeof textbuf;
5410 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1, NULL,
5411 &rs->sr_text, textbuf, sizeof( textbuf ) );
5412 if ( rs->sr_err != LDAP_SUCCESS )
5414 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
5415 if ( rs->sr_err != LDAP_SUCCESS ) {
5416 Debug( LDAP_DEBUG_TRACE,
5417 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
5418 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
5423 if ( op->o_abandon ) {
5424 rs->sr_err = SLAPD_ABANDON;
5427 ldap_pvt_thread_pool_pause( &connection_pool );
5430 * 1) check for existence of entry
5431 * 2) check for sibling renumbering
5432 * 3) perform internal add
5433 * 4) perform any necessary renumbering
5434 * 5) store entry in underlying database
5436 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
5437 if ( rs->sr_err != LDAP_SUCCESS ) {
5438 rs->sr_text = ca.cr_msg;
5443 CfEntryInfo *ce = ca.ca_entry->e_private;
5444 req_add_s addr = op->oq_add;
5445 op->o_tag = LDAP_REQ_MODRDN;
5446 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
5447 op->o_tag = LDAP_REQ_ADD;
5449 if ( rs->sr_err != LDAP_SUCCESS ) {
5454 if ( cfb->cb_use_ldif ) {
5455 BackendDB *be = op->o_bd;
5456 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5457 struct berval dn, ndn;
5459 op->o_bd = &cfb->cb_db;
5461 /* Save current rootdn; use the underlying DB's rootdn */
5464 op->o_dn = op->o_bd->be_rootdn;
5465 op->o_ndn = op->o_bd->be_rootndn;
5467 scp = op->o_callback;
5468 op->o_callback = ≻
5469 op->o_bd->be_add( op, rs );
5471 op->o_callback = scp;
5477 ldap_pvt_thread_pool_resume( &connection_pool );
5480 { int repl = op->o_dont_replicate;
5481 if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
5482 rs->sr_err = LDAP_SUCCESS;
5483 op->o_dont_replicate = 1;
5485 send_ldap_result( op, rs );
5486 op->o_dont_replicate = repl;
5488 slap_graduate_commit_csn( op );
5492 typedef struct delrec {
5493 struct delrec *next;
5499 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
5505 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
5506 ca->line[0] == '{' )
5508 char *ptr = strchr( ca->line + 1, '}' );
5512 ca->valx = strtol( ca->line + 1, &next, 0 );
5513 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
5519 rc = config_parse_add( ct, ca, i );
5527 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
5530 int rc = LDAP_UNWILLING_TO_PERFORM;
5532 Entry *e = ce->ce_entry;
5533 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
5538 delrec *dels = NULL, *deltail = NULL;
5540 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5541 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
5543 colst = count_ocs( oc_at, &nocs );
5545 /* make sure add/del flags are clear; should always be true */
5546 for ( s = save_attrs; s; s = s->a_next ) {
5547 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
5550 e->e_attrs = attrs_dup( e->e_attrs );
5552 init_config_argv( ca );
5555 ca->ca_private = ce->ce_private;
5557 ca->fname = "slapd";
5559 strcpy( ca->log, "back-config" );
5561 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
5562 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5563 switch (ml->sml_op) {
5564 case LDAP_MOD_DELETE:
5565 case LDAP_MOD_REPLACE:
5566 case SLAP_MOD_SOFTDEL:
5568 BerVarray vals = NULL, nvals = NULL;
5570 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
5572 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot delete %s",
5573 ml->sml_desc->ad_cname.bv_val );
5576 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5577 vals = ml->sml_values;
5578 nvals = ml->sml_nvalues;
5579 ml->sml_values = NULL;
5580 ml->sml_nvalues = NULL;
5582 /* If we're deleting by values, remember the indexes of the
5583 * values we deleted.
5585 if ( ct && ml->sml_values ) {
5587 i = ml->sml_numvals;
5588 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
5599 rc = modify_delete_vindex(e, &ml->sml_mod,
5600 get_permissiveModify(op),
5601 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg), idx );
5602 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5603 ml->sml_values = vals;
5604 ml->sml_nvalues = nvals;
5606 if ( rc == LDAP_NO_SUCH_ATTRIBUTE && ml->sml_op == SLAP_MOD_SOFTDEL )
5610 /* FIXME: check rc before fallthru? */
5614 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5616 case SLAP_MOD_ADD_IF_NOT_PRESENT:
5617 if ( ml->sml_op == SLAP_MOD_ADD_IF_NOT_PRESENT
5618 && attr_find( e->e_attrs, ml->sml_desc ) )
5625 case SLAP_MOD_SOFTADD: {
5626 int mop = ml->sml_op;
5628 ml->sml_op = LDAP_MOD_ADD;
5630 if ( ct->arg_type & ARG_NO_INSERT ) {
5631 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
5633 navals = a->a_numvals;
5636 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
5637 if ( ml->sml_values[i].bv_val[0] == '{' &&
5640 char *next, *val = ml->sml_values[i].bv_val + 1;
5643 j = strtol( val, &next, 0 );
5644 if ( next == val || next[ 0 ] != '}' || j < navals ) {
5646 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot insert %s",
5647 ml->sml_desc->ad_cname.bv_val );
5651 rc = check_vals( ct, ca, ml, 0 );
5652 if ( rc ) goto out_noop;
5655 rc = modify_add_values(e, &ml->sml_mod,
5656 get_permissiveModify(op),
5657 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5659 /* If value already exists, show success here
5660 * and ignore this operation down below.
5662 if ( mop == SLAP_MOD_SOFTADD ) {
5663 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
5673 case LDAP_MOD_INCREMENT: /* FIXME */
5678 if(rc != LDAP_SUCCESS) break;
5681 if ( rc == LDAP_SUCCESS) {
5682 /* check that the entry still obeys the schema */
5683 rc = entry_schema_check(op, e, NULL, 0, 0, NULL,
5684 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5686 if ( rc ) goto out_noop;
5688 /* Basic syntax checks are OK. Do the actual settings. */
5689 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5690 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5691 if ( !ct ) continue;
5693 s = attr_find( save_attrs, ml->sml_desc );
5694 a = attr_find( e->e_attrs, ml->sml_desc );
5696 switch (ml->sml_op) {
5697 case LDAP_MOD_DELETE:
5698 case LDAP_MOD_REPLACE: {
5699 BerVarray vals = NULL, nvals = NULL;
5702 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5703 vals = ml->sml_values;
5704 nvals = ml->sml_nvalues;
5705 ml->sml_values = NULL;
5706 ml->sml_nvalues = NULL;
5709 if ( ml->sml_values )
5712 /* If we didn't delete the whole attribute */
5713 if ( ml->sml_values && a ) {
5714 struct berval *mvals;
5717 if ( ml->sml_nvalues )
5718 mvals = ml->sml_nvalues;
5720 mvals = ml->sml_values;
5722 /* use the indexes we saved up above */
5723 for (i=0; i < d->nidx; i++) {
5724 struct berval bv = *mvals++;
5725 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
5726 bv.bv_val[0] == '{' ) {
5727 ptr = strchr( bv.bv_val, '}' ) + 1;
5728 bv.bv_len -= ptr - bv.bv_val;
5731 ca->line = bv.bv_val;
5732 ca->valx = d->idx[i];
5733 config_parse_vals(ct, ca, d->idx[i] );
5734 rc = config_del_vals( ct, ca );
5735 if ( rc != LDAP_SUCCESS ) break;
5737 s->a_flags |= SLAP_ATTR_IXDEL;
5738 for (j=i+1; j < d->nidx; j++)
5739 if ( d->idx[j] >d->idx[i] )
5746 rc = config_del_vals( ct, ca );
5747 if ( rc ) rc = LDAP_OTHER;
5749 s->a_flags |= SLAP_ATTR_IXDEL;
5751 if ( ml->sml_values ) {
5756 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5757 ml->sml_values = vals;
5758 ml->sml_nvalues = nvals;
5760 if ( !vals || rc != LDAP_SUCCESS )
5763 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5766 for (i=0; ml->sml_values[i].bv_val; i++) {
5767 ca->line = ml->sml_values[i].bv_val;
5769 rc = config_modify_add( ct, ca, ml->sml_desc, i );
5772 a->a_flags |= SLAP_ATTR_IXADD;
5779 /* Undo for a failed operation */
5780 if ( rc != LDAP_SUCCESS ) {
5781 ConfigReply msg = ca->reply;
5782 for ( s = save_attrs; s; s = s->a_next ) {
5783 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
5784 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5785 ct = config_find_table( colst, nocs, s->a_desc, ca );
5786 a = attr_find( e->e_attrs, s->a_desc );
5788 /* clear the flag so the add check below will skip it */
5789 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5793 config_del_vals( ct, ca );
5795 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5796 ca->line = s->a_vals[i].bv_val;
5798 config_modify_add( ct, ca, s->a_desc, i );
5802 for ( a = e->e_attrs; a; a = a->a_next ) {
5803 if ( a->a_flags & SLAP_ATTR_IXADD ) {
5804 ct = config_find_table( colst, nocs, a->a_desc, ca );
5808 config_del_vals( ct, ca );
5809 s = attr_find( save_attrs, a->a_desc );
5811 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5812 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5813 ca->line = s->a_vals[i].bv_val;
5815 config_modify_add( ct, ca, s->a_desc, i );
5826 if ( rc == LDAP_SUCCESS ) {
5827 attrs_free( save_attrs );
5830 attrs_free( e->e_attrs );
5831 e->e_attrs = save_attrs;
5833 ch_free( ca->argv );
5834 if ( colst ) ch_free( colst );
5836 deltail = dels->next;
5845 config_back_modify( Operation *op, SlapReply *rs )
5848 CfEntryInfo *ce, *last;
5850 ConfigArgs ca = {0};
5853 AttributeDescription *rad = NULL;
5856 cfb = (CfBackInfo *)op->o_bd->be_private;
5858 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5861 rs->sr_matched = last->ce_entry->e_name.bv_val;
5862 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5866 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
5867 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5871 /* Get type of RDN */
5872 rdn = ce->ce_entry->e_nname;
5873 ptr = strchr( rdn.bv_val, '=' );
5874 rdn.bv_len = ptr - rdn.bv_val;
5875 rs->sr_err = slap_bv2ad( &rdn, &rad, &rs->sr_text );
5876 if ( rs->sr_err != LDAP_SUCCESS ) {
5880 /* Some basic validation... */
5881 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5882 /* Don't allow Modify of RDN; must use ModRdn for that. */
5883 if ( ml->sml_desc == rad ) {
5884 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
5885 rs->sr_text = "Use modrdn to change the entry name";
5888 /* Internal update of contextCSN? */
5889 if ( ml->sml_desc == slap_schema.si_ad_contextCSN && op->o_conn->c_conn_idx == -1 ) {
5895 slap_mods_opattrs( op, &op->orm_modlist, 1 );
5898 if ( op->o_abandon ) {
5899 rs->sr_err = SLAPD_ABANDON;
5902 ldap_pvt_thread_pool_pause( &connection_pool );
5906 * 1) perform the Modify on the cached Entry.
5907 * 2) verify that the Entry still satisfies the schema.
5908 * 3) perform the individual config operations.
5909 * 4) store Modified entry in underlying LDIF backend.
5911 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
5913 rs->sr_text = ca.cr_msg;
5914 } else if ( cfb->cb_use_ldif ) {
5915 BackendDB *be = op->o_bd;
5916 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5917 struct berval dn, ndn;
5919 op->o_bd = &cfb->cb_db;
5923 op->o_dn = op->o_bd->be_rootdn;
5924 op->o_ndn = op->o_bd->be_rootndn;
5926 scp = op->o_callback;
5927 op->o_callback = ≻
5928 op->o_bd->be_modify( op, rs );
5930 op->o_callback = scp;
5936 ldap_pvt_thread_pool_resume( &connection_pool );
5938 send_ldap_result( op, rs );
5939 slap_graduate_commit_csn( op );
5944 config_back_modrdn( Operation *op, SlapReply *rs )
5947 CfEntryInfo *ce, *last;
5951 cfb = (CfBackInfo *)op->o_bd->be_private;
5953 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5956 rs->sr_matched = last->ce_entry->e_name.bv_val;
5957 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5960 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
5961 NULL, ACL_WRITE, NULL )) {
5962 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5966 if ( ce->ce_parent )
5967 parent = ce->ce_parent->ce_entry;
5969 parent = (Entry *)&slap_entry_root;
5970 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
5971 NULL, ACL_WRITE, NULL )) {
5972 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5977 /* We don't allow moving objects to new parents.
5978 * Generally we only allow reordering a set of ordered entries.
5980 if ( op->orr_newSup ) {
5981 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5985 /* If newRDN == oldRDN, quietly succeed */
5986 dnRdn( &op->o_req_ndn, &rdn );
5987 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
5988 rs->sr_err = LDAP_SUCCESS;
5992 /* Current behavior, subject to change as needed:
5994 * For backends and overlays, we only allow renumbering.
5995 * For schema, we allow renaming with the same number.
5996 * Otherwise, the op is not allowed.
5999 if ( ce->ce_type == Cft_Schema ) {
6003 /* Can't alter the main cn=schema entry */
6004 if ( ce->ce_parent->ce_type == Cft_Global ) {
6005 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6006 rs->sr_text = "renaming not allowed for this entry";
6010 /* We could support this later if desired */
6011 ptr1 = ber_bvchr( &rdn, '}' );
6012 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
6013 len = ptr1 - rdn.bv_val;
6014 if ( len != ptr2 - op->orr_newrdn.bv_val ||
6015 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
6016 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6017 rs->sr_text = "schema reordering not supported";
6020 } else if ( ce->ce_type == Cft_Database ||
6021 ce->ce_type == Cft_Overlay ) {
6022 char *ptr1, *ptr2, *iptr1, *iptr2;
6025 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
6026 if ( *iptr2 != '{' ) {
6027 rs->sr_err = LDAP_NAMING_VIOLATION;
6028 rs->sr_text = "new ordering index is required";
6032 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
6033 ptr1 = ber_bvchr( &rdn, '}' );
6034 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
6036 rs->sr_err = LDAP_NAMING_VIOLATION;
6037 rs->sr_text = "new ordering index is required";
6041 len1 = ptr1 - rdn.bv_val;
6042 len2 = ptr2 - op->orr_newrdn.bv_val;
6044 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
6045 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
6046 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6047 rs->sr_text = "changing database/overlay type not allowed";
6050 ixold = strtol( iptr1, NULL, 0 );
6051 ixnew = strtol( iptr2, &ptr1, 0 );
6052 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
6053 rs->sr_err = LDAP_NAMING_VIOLATION;
6056 /* config DB is always 0, cannot be changed */
6057 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
6058 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
6062 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6063 rs->sr_text = "renaming not supported for this entry";
6067 if ( op->o_abandon ) {
6068 rs->sr_err = SLAPD_ABANDON;
6071 ldap_pvt_thread_pool_pause( &connection_pool );
6073 if ( ce->ce_type == Cft_Schema ) {
6074 req_modrdn_s modr = op->oq_modrdn;
6077 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
6078 if ( rs->sr_err == LDAP_SUCCESS ) {
6079 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
6080 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
6083 op->oq_modrdn = modr;
6085 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
6086 req_modrdn_s modr = op->oq_modrdn;
6089 /* Advance to first of this type */
6090 cprev = &ce->ce_parent->ce_kids;
6091 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
6092 cprev = &ce2->ce_sibs;
6095 /* Skip the -1 entry */
6096 if ( ce->ce_type == Cft_Database ) {
6097 cprev = &ce2->ce_sibs;
6103 /* Remove from old slot */
6104 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
6105 cprev = &ce2->ce_sibs;
6106 *cprev = ce->ce_sibs;
6107 ceold = ce->ce_sibs;
6109 /* Insert into new slot */
6111 for ( i=0; i<ixnew; i++ ) {
6115 cprev = &ce2->ce_sibs;
6117 ce->ce_sibs = *cprev;
6122 /* NOTE: These should be encoded in the OC tables, not inline here */
6123 if ( ce->ce_type == Cft_Database )
6124 backend_db_move( ce->ce_be, ixnew );
6125 else if ( ce->ce_type == Cft_Overlay )
6126 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
6128 if ( ixold < ixnew ) {
6129 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
6132 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
6133 ixold - ixnew, cfb->cb_use_ldif );
6135 op->oq_modrdn = modr;
6138 ldap_pvt_thread_pool_resume( &connection_pool );
6140 send_ldap_result( op, rs );
6145 config_back_delete( Operation *op, SlapReply *rs )
6147 #ifdef SLAP_CONFIG_DELETE
6149 CfEntryInfo *ce, *last, *ce2;
6151 cfb = (CfBackInfo *)op->o_bd->be_private;
6153 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6156 rs->sr_matched = last->ce_entry->e_name.bv_val;
6157 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6158 } else if ( ce->ce_kids ) {
6159 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6160 } else if ( op->o_abandon ) {
6161 rs->sr_err = SLAPD_ABANDON;
6162 } else if ( ce->ce_type == Cft_Overlay || ce->ce_type == Cft_Database ){
6166 ldap_pvt_thread_pool_pause( &connection_pool );
6168 if ( ce->ce_type == Cft_Overlay ){
6169 if ( SLAP_ISGLOBALOVERLAY(ce->ce_be ) ) {
6170 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6171 rs->sr_text = "Cannot delete global overlays";
6172 ldap_pvt_thread_pool_resume( &connection_pool );
6174 } else if ( ce->ce_be == op->o_bd->bd_self ) {
6175 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6176 rs->sr_text = "Cannot delete cn=config overlays";
6177 ldap_pvt_thread_pool_resume( &connection_pool );
6180 overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
6182 } else { /* Cft_Database*/
6183 if ( ce->ce_be == frontendDB || ce->ce_be == op->o_bd ){
6184 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6185 rs->sr_text = "Cannot delete config or frontend database";
6186 ldap_pvt_thread_pool_resume( &connection_pool );
6189 if ( ce->ce_be->bd_info->bi_db_close ) {
6190 ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
6192 backend_destroy_one( ce->ce_be, 1);
6195 /* remove CfEntryInfo from the siblings list */
6196 if ( ce->ce_parent->ce_kids == ce ) {
6197 ce->ce_parent->ce_kids = ce->ce_sibs;
6199 for ( ce2 = ce->ce_parent->ce_kids ; ce2; ce2 = ce2->ce_sibs ) {
6200 if ( ce2->ce_sibs == ce ) {
6201 ce2->ce_sibs = ce->ce_sibs;
6207 /* remove from underlying database */
6208 if ( cfb->cb_use_ldif ) {
6209 BackendDB *be = op->o_bd;
6210 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
6211 struct berval dn, ndn, req_dn, req_ndn;
6213 op->o_bd = &cfb->cb_db;
6217 req_dn = op->o_req_dn;
6218 req_ndn = op->o_req_ndn;
6220 op->o_dn = op->o_bd->be_rootdn;
6221 op->o_ndn = op->o_bd->be_rootndn;
6222 op->o_req_dn = ce->ce_entry->e_name;
6223 op->o_req_ndn = ce->ce_entry->e_nname;
6225 scp = op->o_callback;
6226 op->o_callback = ≻
6227 op->o_bd->be_delete( op, rs );
6229 op->o_callback = scp;
6232 op->o_req_dn = req_dn;
6233 op->o_req_ndn = req_ndn;
6236 /* renumber siblings */
6237 iptr = ber_bvchr( &op->o_req_ndn, '{' ) + 1;
6238 ixold = strtol( iptr, NULL, 0 );
6239 for (ce2 = ce->ce_sibs, count=0; ce2; ce2=ce2->ce_sibs) {
6240 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
6241 count+ixold, 0, cfb->cb_use_ldif );
6245 ce->ce_entry->e_private=NULL;
6246 entry_free(ce->ce_entry);
6248 ldap_pvt_thread_pool_resume( &connection_pool );
6250 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6253 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6254 #endif /* SLAP_CONFIG_DELETE */
6256 send_ldap_result( op, rs );
6261 config_back_search( Operation *op, SlapReply *rs )
6264 CfEntryInfo *ce, *last;
6267 cfb = (CfBackInfo *)op->o_bd->be_private;
6269 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6272 rs->sr_matched = last->ce_entry->e_name.bv_val;
6273 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6276 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
6277 ACL_SEARCH, NULL, &mask ))
6279 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
6280 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6282 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
6286 switch ( op->ors_scope ) {
6287 case LDAP_SCOPE_BASE:
6288 case LDAP_SCOPE_SUBTREE:
6289 rs->sr_err = config_send( op, rs, ce, 0 );
6292 case LDAP_SCOPE_ONELEVEL:
6293 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
6294 rs->sr_err = config_send( op, rs, ce, 1 );
6303 send_ldap_result( op, rs );
6307 /* no-op, we never free entries */
6308 int config_entry_release(
6313 if ( !e->e_private ) {
6316 return LDAP_SUCCESS;
6319 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
6321 int config_back_entry_get(
6325 AttributeDescription *at,
6330 CfEntryInfo *ce, *last;
6331 int rc = LDAP_NO_SUCH_OBJECT;
6333 cfb = (CfBackInfo *)op->o_bd->be_private;
6335 ce = config_find_base( cfb->cb_root, ndn, &last );
6337 *ent = ce->ce_entry;
6340 if ( oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
6341 rc = LDAP_NO_SUCH_ATTRIBUTE;
6351 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
6352 ConfigTable *ct, ConfigArgs *c )
6356 for (; at && *at; at++) {
6357 /* Skip the naming attr */
6358 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
6360 for (i=0;ct[i].name;i++) {
6361 if (ct[i].ad == (*at)->sat_ad) {
6362 rc = config_get_vals(&ct[i], c);
6363 /* NOTE: tolerate that config_get_vals()
6364 * returns success with no values */
6365 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
6366 if ( c->rvalue_nvals )
6367 rc = attr_merge(e, ct[i].ad, c->rvalue_vals,
6370 slap_syntax_validate_func *validate =
6371 ct[i].ad->ad_type->sat_syntax->ssyn_validate;
6374 for ( j=0; c->rvalue_vals[j].bv_val; j++ ) {
6375 rc = ordered_value_validate( ct[i].ad,
6376 &c->rvalue_vals[j], LDAP_MOD_ADD );
6378 Debug( LDAP_DEBUG_ANY,
6379 "config_build_attrs: error %d on %s value #%d\n",
6380 rc, ct[i].ad->ad_cname.bv_val, j );
6386 rc = attr_merge_normalize(e, ct[i].ad,
6387 c->rvalue_vals, NULL);
6389 ber_bvarray_free( c->rvalue_nvals );
6390 ber_bvarray_free( c->rvalue_vals );
6392 Debug( LDAP_DEBUG_ANY,
6393 "config_build_attrs: error %d on %s\n",
6394 rc, ct[i].ad->ad_cname.bv_val, 0 );
6405 /* currently (2010) does not access rs except possibly writing rs->sr_err */
6408 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
6409 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
6411 Entry *e = entry_alloc();
6412 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
6414 struct berval ad_name;
6415 AttributeDescription *ad = NULL;
6418 const char *text = "";
6422 CfEntryInfo *ceprev = NULL;
6424 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
6427 ce->ce_type = main->co_type;
6428 ce->ce_parent = parent;
6430 pdn = parent->ce_entry->e_nname;
6431 if ( parent->ce_kids && parent->ce_kids->ce_type <= ce->ce_type )
6432 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
6433 ceprev->ce_type <= ce->ce_type;
6434 ceprev = ceprev->ce_sibs );
6439 ce->ce_private = c->ca_private;
6443 build_new_dn( &e->e_name, &pdn, rdn, NULL );
6444 ber_dupbv( &e->e_nname, &e->e_name );
6446 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6447 main->co_name, NULL );
6449 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6450 extra->co_name, NULL );
6451 ptr = strchr(rdn->bv_val, '=');
6452 ad_name.bv_val = rdn->bv_val;
6453 ad_name.bv_len = ptr - rdn->bv_val;
6454 rc = slap_bv2ad( &ad_name, &ad, &text );
6459 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
6460 attr_merge_normalize_one(e, ad, &val, NULL );
6463 c->table = main->co_type;
6464 if ( oc->soc_required ) {
6465 rc = config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
6466 if ( rc ) goto fail;
6469 if ( oc->soc_allowed ) {
6470 rc = config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
6471 if ( rc ) goto fail;
6476 c->table = extra->co_type;
6477 if ( oc->soc_required ) {
6478 rc = config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
6479 if ( rc ) goto fail;
6482 if ( oc->soc_allowed ) {
6483 rc = config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
6484 if ( rc ) goto fail;
6488 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
6489 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->cr_msg,
6490 sizeof(c->cr_msg), op ? op->o_tmpmemctx : NULL );
6491 if ( rc != LDAP_SUCCESS ) {
6493 Debug( LDAP_DEBUG_ANY,
6494 "config_build_entry: build \"%s\" failed: \"%s\"\n",
6495 rdn->bv_val, text, 0);
6498 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
6501 op->ora_modlist = NULL;
6502 slap_add_opattrs( op, NULL, NULL, 0, 0 );
6503 if ( !op->o_noop ) {
6504 SlapReply rs2 = {REP_RESULT};
6505 op->o_bd->be_add( op, &rs2 );
6506 rs->sr_err = rs2.sr_err;
6507 rs_assert_done( &rs2 );
6508 if ( ( rs2.sr_err != LDAP_SUCCESS )
6509 && (rs2.sr_err != LDAP_ALREADY_EXISTS) ) {
6515 ce->ce_sibs = ceprev->ce_sibs;
6516 ceprev->ce_sibs = ce;
6517 } else if ( parent ) {
6518 ce->ce_sibs = parent->ce_kids;
6519 parent->ce_kids = ce;
6526 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
6527 Operation *op, SlapReply *rs )
6530 ConfigFile *cf = c->ca_private;
6532 struct berval bv, rdn;
6534 for (; cf; cf=cf->c_sibs, c->depth++) {
6535 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
6536 !cf->c_om_head && !cf->c_syn_head ) continue;
6537 c->value_dn.bv_val = c->log;
6538 LUTIL_SLASHPATH( cf->c_file.bv_val );
6539 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
6544 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
6546 ptr = strchr( bv.bv_val, '.' );
6548 bv.bv_len = ptr - bv.bv_val;
6549 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
6550 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6551 /* FIXME: how can indicate error? */
6554 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
6556 c->value_dn.bv_len += bv.bv_len;
6557 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
6561 e = config_build_entry( op, rs, ceparent, c, &rdn,
6562 &CFOC_SCHEMA, NULL );
6565 } else if ( e && cf->c_kids ) {
6566 c->ca_private = cf->c_kids;
6567 config_build_schema_inc( c, e->e_private, op, rs );
6573 #ifdef SLAPD_MODULES
6576 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
6577 Operation *op, SlapReply *rs )
6582 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
6583 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
6585 c->value_dn.bv_val = c->log;
6586 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
6587 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6588 /* FIXME: how can indicate error? */
6592 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
6601 config_check_schema(Operation *op, CfBackInfo *cfb)
6603 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
6605 CfEntryInfo *ce, *last;
6608 /* If there's no root entry, we must be in the midst of converting */
6609 if ( !cfb->cb_root )
6612 /* Make sure the main schema entry exists */
6613 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
6620 /* Make sure it's up to date */
6621 if ( cf_om_tail != om_sys_tail ) {
6622 a = attr_find( e->e_attrs, cfAd_om );
6624 if ( a->a_nvals != a->a_vals )
6625 ber_bvarray_free( a->a_nvals );
6626 ber_bvarray_free( a->a_vals );
6631 oidm_unparse( &bv, NULL, NULL, 1 );
6632 attr_merge_normalize( e, cfAd_om, bv, NULL );
6633 ber_bvarray_free( bv );
6634 cf_om_tail = om_sys_tail;
6636 if ( cf_at_tail != at_sys_tail ) {
6637 a = attr_find( e->e_attrs, cfAd_attr );
6639 if ( a->a_nvals != a->a_vals )
6640 ber_bvarray_free( a->a_nvals );
6641 ber_bvarray_free( a->a_vals );
6646 at_unparse( &bv, NULL, NULL, 1 );
6647 attr_merge_normalize( e, cfAd_attr, bv, NULL );
6648 ber_bvarray_free( bv );
6649 cf_at_tail = at_sys_tail;
6651 if ( cf_oc_tail != oc_sys_tail ) {
6652 a = attr_find( e->e_attrs, cfAd_oc );
6654 if ( a->a_nvals != a->a_vals )
6655 ber_bvarray_free( a->a_nvals );
6656 ber_bvarray_free( a->a_vals );
6661 oc_unparse( &bv, NULL, NULL, 1 );
6662 attr_merge_normalize( e, cfAd_oc, bv, NULL );
6663 ber_bvarray_free( bv );
6664 cf_oc_tail = oc_sys_tail;
6666 if ( cf_syn_tail != syn_sys_tail ) {
6667 a = attr_find( e->e_attrs, cfAd_syntax );
6669 if ( a->a_nvals != a->a_vals )
6670 ber_bvarray_free( a->a_nvals );
6671 ber_bvarray_free( a->a_vals );
6676 syn_unparse( &bv, NULL, NULL, 1 );
6677 attr_merge_normalize( e, cfAd_syntax, bv, NULL );
6678 ber_bvarray_free( bv );
6679 cf_syn_tail = syn_sys_tail;
6682 SlapReply rs = {REP_RESULT};
6683 c.ca_private = NULL;
6684 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
6685 &CFOC_SCHEMA, NULL );
6690 ce->ce_private = cfb->cb_config;
6691 cf_at_tail = at_sys_tail;
6692 cf_oc_tail = oc_sys_tail;
6693 cf_om_tail = om_sys_tail;
6694 cf_syn_tail = syn_sys_tail;
6699 static const char *defacl[] = {
6700 NULL, "to", "*", "by", "*", "none", NULL
6704 config_back_db_open( BackendDB *be, ConfigReply *cr )
6706 CfBackInfo *cfb = be->be_private;
6709 CfEntryInfo *ce, *ceparent;
6713 Connection conn = {0};
6714 OperationBuffer opbuf;
6716 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
6717 SlapReply rs = {REP_RESULT};
6718 void *thrctx = NULL;
6720 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
6722 /* If we have no explicitly configured ACLs, don't just use
6723 * the global ACLs. Explicitly deny access to everything.
6725 if ( !be->be_acl ) {
6726 parse_acl(be, "config_back_db_open", 0, 6, (char **)defacl, 0 );
6729 thrctx = ldap_pvt_thread_pool_context();
6730 connection_fake_init( &conn, &opbuf, thrctx );
6733 op->o_tag = LDAP_REQ_ADD;
6734 op->o_callback = &cb;
6735 op->o_bd = &cfb->cb_db;
6736 op->o_dn = op->o_bd->be_rootdn;
6737 op->o_ndn = op->o_bd->be_rootndn;
6739 if ( !cfb->cb_use_ldif ) {
6743 /* If we read the config from back-ldif, do some quick sanity checks */
6744 if ( cfb->cb_got_ldif ) {
6745 return config_check_schema( op, cfb );
6748 /* create root of tree */
6750 c.ca_private = cfb->cb_config;
6752 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
6762 #ifdef SLAPD_MODULES
6763 /* Create Module nodes... */
6764 if ( modpaths.mp_loads ) {
6765 if ( config_build_modules( &c, ceparent, op, &rs ) ){
6771 /* Create schema nodes... cn=schema will contain the hardcoded core
6772 * schema, read-only. Child objects will contain runtime loaded schema
6776 c.ca_private = NULL;
6777 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
6782 ce->ce_private = cfb->cb_config;
6783 cf_at_tail = at_sys_tail;
6784 cf_oc_tail = oc_sys_tail;
6785 cf_om_tail = om_sys_tail;
6786 cf_syn_tail = syn_sys_tail;
6788 /* Create schema nodes for included schema... */
6789 if ( cfb->cb_config->c_kids ) {
6792 c.ca_private = cfb->cb_config->c_kids;
6793 rc = config_build_schema_inc( &c, ce, op, &rs );
6799 /* Create backend nodes. Skip if they don't provide a cf_table.
6800 * There usually aren't any of these.
6804 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
6805 if (!bi->bi_cf_ocs) {
6806 /* If it only supports the old config mech, complain. */
6807 if ( bi->bi_config ) {
6808 Debug( LDAP_DEBUG_ANY,
6809 "WARNING: No dynamic config support for backend %s.\n",
6810 bi->bi_type, 0, 0 );
6815 if (!bi->bi_private) continue;
6818 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6819 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
6820 if ( rdn.bv_len >= sizeof( c.log ) ) {
6821 /* FIXME: holler ... */ ;
6824 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
6831 /* Create database nodes... */
6832 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
6833 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
6834 for ( i = -1, be = frontendDB ; be;
6835 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
6836 slap_overinfo *oi = NULL;
6838 if ( overlay_is_over( be )) {
6839 oi = be->bd_info->bi_private;
6845 /* If this backend supports the old config mechanism, but not
6846 * the new mech, complain.
6848 if ( !be->be_cf_ocs && bi->bi_db_config ) {
6849 Debug( LDAP_DEBUG_ANY,
6850 "WARNING: No dynamic config support for database %s.\n",
6851 bi->bi_type, 0, 0 );
6855 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6856 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
6858 if ( rdn.bv_len >= sizeof( c.log ) ) {
6859 /* FIXME: holler ... */ ;
6863 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
6869 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd )
6870 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
6871 /* Iterate through overlays */
6876 voidList *vl, *v0 = NULL;
6878 /* overlays are in LIFO order, must reverse stack */
6879 for (on=oi->oi_list; on; on=on->on_next) {
6880 vl = ch_malloc( sizeof( voidList ));
6885 for (j=0; vl; j++,vl=v0) {
6889 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
6890 Debug( LDAP_DEBUG_ANY,
6891 "WARNING: No dynamic config support for overlay %s.\n",
6892 on->on_bi.bi_type, 0, 0 );
6896 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6897 "%s=" SLAP_X_ORDERED_FMT "%s",
6898 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
6899 if ( rdn.bv_len >= sizeof( c.log ) ) {
6900 /* FIXME: holler ... */ ;
6904 oe = config_build_entry( op, &rs, ce, &c, &rdn,
6905 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
6909 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd )
6910 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
6915 ldap_pvt_thread_pool_context_reset( thrctx );
6917 if ( unsupp && cfb->cb_use_ldif ) {
6918 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
6919 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
6926 cfb_free_cffile( ConfigFile *cf )
6930 for (; cf; cf=next) {
6933 cfb_free_cffile( cf->c_kids );
6934 ch_free( cf->c_file.bv_val );
6935 ber_bvarray_free( cf->c_dseFiles );
6941 cfb_free_entries( CfEntryInfo *ce )
6945 for (; ce; ce=next) {
6948 cfb_free_entries( ce->ce_kids );
6949 ce->ce_entry->e_private = NULL;
6950 entry_free( ce->ce_entry );
6956 config_back_db_close( BackendDB *be, ConfigReply *cr )
6958 CfBackInfo *cfb = be->be_private;
6960 cfb_free_entries( cfb->cb_root );
6961 cfb->cb_root = NULL;
6963 if ( cfb->cb_db.bd_info ) {
6964 backend_shutdown( &cfb->cb_db );
6971 config_back_db_destroy( BackendDB *be, ConfigReply *cr )
6973 CfBackInfo *cfb = be->be_private;
6975 cfb_free_cffile( cfb->cb_config );
6977 ch_free( cfdir.bv_val );
6979 avl_free( CfOcTree, NULL );
6981 if ( cfb->cb_db.bd_info ) {
6982 cfb->cb_db.be_suffix = NULL;
6983 cfb->cb_db.be_nsuffix = NULL;
6984 BER_BVZERO( &cfb->cb_db.be_rootdn );
6985 BER_BVZERO( &cfb->cb_db.be_rootndn );
6987 backend_destroy_one( &cfb->cb_db, 0 );
6996 config_back_db_init( BackendDB *be, ConfigReply* cr )
7002 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
7003 cfn = cfb->cb_config;
7004 be->be_private = cfb;
7006 ber_dupbv( &be->be_rootdn, &config_rdn );
7007 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
7008 ber_dupbv( &dn, &be->be_rootdn );
7009 ber_bvarray_add( &be->be_suffix, &dn );
7010 ber_dupbv( &dn, &be->be_rootdn );
7011 ber_bvarray_add( &be->be_nsuffix, &dn );
7013 /* Hide from namingContexts */
7014 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
7016 /* Check ACLs on content of Adds by default */
7017 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_ACL_ADD;
7023 config_back_destroy( BackendInfo *bi )
7025 ldif_must_b64_encode_release();
7030 config_tool_entry_open( BackendDB *be, int mode )
7032 CfBackInfo *cfb = be->be_private;
7033 BackendInfo *bi = cfb->cb_db.bd_info;
7035 if ( bi && bi->bi_tool_entry_open )
7036 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
7043 config_tool_entry_close( BackendDB *be )
7045 CfBackInfo *cfb = be->be_private;
7046 BackendInfo *bi = cfb->cb_db.bd_info;
7048 if ( bi && bi->bi_tool_entry_close )
7049 return bi->bi_tool_entry_close( &cfb->cb_db );
7055 config_tool_entry_first( BackendDB *be )
7057 CfBackInfo *cfb = be->be_private;
7058 BackendInfo *bi = cfb->cb_db.bd_info;
7060 if ( bi && bi->bi_tool_entry_first ) {
7061 return bi->bi_tool_entry_first( &cfb->cb_db );
7063 if ( bi && bi->bi_tool_entry_first_x ) {
7064 return bi->bi_tool_entry_first_x( &cfb->cb_db,
7065 NULL, LDAP_SCOPE_DEFAULT, NULL );
7071 config_tool_entry_first_x(
7073 struct berval *base,
7077 CfBackInfo *cfb = be->be_private;
7078 BackendInfo *bi = cfb->cb_db.bd_info;
7080 if ( bi && bi->bi_tool_entry_first_x ) {
7081 return bi->bi_tool_entry_first_x( &cfb->cb_db, base, scope, f );
7087 config_tool_entry_next( BackendDB *be )
7089 CfBackInfo *cfb = be->be_private;
7090 BackendInfo *bi = cfb->cb_db.bd_info;
7092 if ( bi && bi->bi_tool_entry_next )
7093 return bi->bi_tool_entry_next( &cfb->cb_db );
7099 config_tool_entry_get( BackendDB *be, ID id )
7101 CfBackInfo *cfb = be->be_private;
7102 BackendInfo *bi = cfb->cb_db.bd_info;
7104 if ( bi && bi->bi_tool_entry_get )
7105 return bi->bi_tool_entry_get( &cfb->cb_db, id );
7110 static int entry_put_got_frontend=0;
7111 static int entry_put_got_config=0;
7113 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
7115 CfBackInfo *cfb = be->be_private;
7116 BackendInfo *bi = cfb->cb_db.bd_info;
7118 struct berval rdn, vals[ 2 ];
7120 OperationBuffer opbuf;
7122 Connection conn = {0};
7123 Operation *op = NULL;
7127 /* Create entry for frontend database if it does not exist already */
7128 if ( !entry_put_got_frontend ) {
7129 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7130 STRLENOF( "olcDatabase" ))) {
7131 if ( strncmp( e->e_nname.bv_val +
7132 STRLENOF( "olcDatabase" ), "={-1}frontend",
7133 STRLENOF( "={-1}frontend" )) &&
7134 strncmp( e->e_nname.bv_val +
7135 STRLENOF( "olcDatabase" ), "=frontend",
7136 STRLENOF( "=frontend" ))) {
7138 vals[1].bv_val = NULL;
7139 memset( &ca, 0, sizeof(ConfigArgs));
7141 ca.bi = frontendDB->bd_info;
7142 ca.be->be_cf_ocs = &CFOC_FRONTEND;
7143 rdn.bv_val = ca.log;
7144 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7145 "%s=" SLAP_X_ORDERED_FMT "%s",
7146 cfAd_database->ad_cname.bv_val, -1,
7148 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
7149 &CFOC_DATABASE, ca.be->be_cf_ocs );
7150 thrctx = ldap_pvt_thread_pool_context();
7151 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7153 op->o_bd = &cfb->cb_db;
7154 op->o_tag = LDAP_REQ_ADD;
7156 op->o_dn = be->be_rootdn;
7157 op->o_ndn = be->be_rootndn;
7158 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7159 if ( rc != LDAP_SUCCESS ) {
7160 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7161 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7165 if ( ce && bi && bi->bi_tool_entry_put &&
7166 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7167 entry_put_got_frontend++;
7169 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7170 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7174 entry_put_got_frontend++;
7179 /* Create entry for config database if it does not exist already */
7180 if ( !entry_put_got_config && !isFrontend ) {
7181 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7182 STRLENOF( "olcDatabase" ))) {
7183 if ( strncmp( e->e_nname.bv_val +
7184 STRLENOF( "olcDatabase" ), "={0}config",
7185 STRLENOF( "={0}config" )) &&
7186 strncmp( e->e_nname.bv_val +
7187 STRLENOF( "olcDatabase" ), "=config",
7188 STRLENOF( "=config" )) ) {
7190 vals[1].bv_val = NULL;
7191 memset( &ca, 0, sizeof(ConfigArgs));
7192 ca.be = LDAP_STAILQ_FIRST( &backendDB );
7193 ca.bi = ca.be->bd_info;
7194 rdn.bv_val = ca.log;
7195 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7196 "%s=" SLAP_X_ORDERED_FMT "%s",
7197 cfAd_database->ad_cname.bv_val, 0,
7199 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
7202 thrctx = ldap_pvt_thread_pool_context();
7203 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7205 op->o_bd = &cfb->cb_db;
7206 op->o_tag = LDAP_REQ_ADD;
7207 op->o_dn = be->be_rootdn;
7208 op->o_ndn = be->be_rootndn;
7211 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7212 if ( rc != LDAP_SUCCESS ) {
7213 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7214 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7217 if (ce && bi && bi->bi_tool_entry_put &&
7218 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7219 entry_put_got_config++;
7221 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7222 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7226 entry_put_got_config++;
7230 if ( bi && bi->bi_tool_entry_put &&
7231 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
7232 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
7239 AttributeDescription **desc;
7241 { "attribute", &cfAd_attr },
7242 { "backend", &cfAd_backend },
7243 { "database", &cfAd_database },
7244 { "include", &cfAd_include },
7245 { "ldapsyntax", &cfAd_syntax },
7246 { "objectclass", &cfAd_oc },
7247 { "objectidentifier", &cfAd_om },
7248 { "overlay", &cfAd_overlay },
7253 * add / delete: all types that may be added or deleted must use an
7254 * X-ORDERED attributeType for their RDN. Adding and deleting entries
7255 * should automatically renumber the index of any siblings as needed,
7256 * so that no gaps in the numbering sequence exist after the add/delete
7258 * What can be added:
7260 * backend objects for backend-specific config directives
7264 * delete: probably no support this time around.
7266 * modrdn: generally not done. Will be invoked automatically by add/
7267 * delete to update numbering sequence. Perform as an explicit operation
7268 * so that the renumbering effect may be replicated. Subtree rename must
7269 * be supported, since renumbering a database will affect all its child
7272 * modify: must be fully supported.
7276 config_back_initialize( BackendInfo *bi )
7278 ConfigTable *ct = config_back_cf_table;
7282 AttributeDescription *ad = NULL;
7284 static char *controls[] = {
7285 LDAP_CONTROL_MANAGEDSAIT,
7289 /* Make sure we don't exceed the bits reserved for userland */
7290 config_check_userland( CFG_LAST );
7292 bi->bi_controls = controls;
7297 bi->bi_destroy = config_back_destroy;
7299 bi->bi_db_init = config_back_db_init;
7300 bi->bi_db_config = 0;
7301 bi->bi_db_open = config_back_db_open;
7302 bi->bi_db_close = config_back_db_close;
7303 bi->bi_db_destroy = config_back_db_destroy;
7305 bi->bi_op_bind = config_back_bind;
7306 bi->bi_op_unbind = 0;
7307 bi->bi_op_search = config_back_search;
7308 bi->bi_op_compare = 0;
7309 bi->bi_op_modify = config_back_modify;
7310 bi->bi_op_modrdn = config_back_modrdn;
7311 bi->bi_op_add = config_back_add;
7312 bi->bi_op_delete = config_back_delete;
7313 bi->bi_op_abandon = 0;
7315 bi->bi_extended = 0;
7317 bi->bi_chk_referrals = 0;
7319 bi->bi_access_allowed = slap_access_allowed;
7321 bi->bi_connection_init = 0;
7322 bi->bi_connection_destroy = 0;
7324 bi->bi_entry_release_rw = config_entry_release;
7325 bi->bi_entry_get_rw = config_back_entry_get;
7327 bi->bi_tool_entry_open = config_tool_entry_open;
7328 bi->bi_tool_entry_close = config_tool_entry_close;
7329 bi->bi_tool_entry_first = config_tool_entry_first;
7330 bi->bi_tool_entry_first_x = config_tool_entry_first_x;
7331 bi->bi_tool_entry_next = config_tool_entry_next;
7332 bi->bi_tool_entry_get = config_tool_entry_get;
7333 bi->bi_tool_entry_put = config_tool_entry_put;
7336 argv[ 0 ] = "slapd";
7342 for (i=0; OidMacros[i].name; i++ ) {
7343 argv[1] = OidMacros[i].name;
7344 argv[2] = OidMacros[i].oid;
7345 parse_oidm( &ca, 0, NULL );
7348 bi->bi_cf_ocs = cf_ocs;
7350 i = config_register_schema( ct, cf_ocs );
7353 i = slap_str2ad( "olcDatabase", &olcDatabaseDummy[0].ad, &text );
7356 /* setup olcRootPW to be base64-encoded when written in LDIF form;
7357 * basically, we don't care if it fails */
7358 i = slap_str2ad( "olcRootPW", &ad, &text );
7360 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
7361 "warning, unable to get \"olcRootPW\" "
7362 "attribute description: %d: %s\n",
7365 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
7366 ad->ad_type->sat_oid );
7369 /* set up the notable AttributeDescriptions */
7371 for (;ct->name;ct++) {
7372 if (strcmp(ct->name, ads[i].name)) continue;
7373 *ads[i].desc = ct->ad;
7375 if (!ads[i].name) break;