1 /* bconfig.c - the config backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2011 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(/back-ndb)
248 * OLcfg{Bk|Db}{Oc|At}:7 -> back-sock
249 * OLcfg{Bk|Db}{Oc|At}:8 -> back-null
250 * OLcfg{Bk|Db}{Oc|At}:9 -> back-passwd
251 * OLcfg{Bk|Db}{Oc|At}:10 -> back-shell
252 * OLcfg{Bk|Db}{Oc|At}:11 -> back-perl
258 * OLcfgOv{Oc|At}:1 -> syncprov
259 * OLcfgOv{Oc|At}:2 -> pcache
260 * OLcfgOv{Oc|At}:3 -> chain
261 * OLcfgOv{Oc|At}:4 -> accesslog
262 * OLcfgOv{Oc|At}:5 -> valsort
263 * OLcfgOv{Oc|At}:7 -> distproc
264 * OLcfgOv{Oc|At}:8 -> dynlist
265 * OLcfgOv{Oc|At}:9 -> dds
266 * OLcfgOv{Oc|At}:10 -> unique
267 * OLcfgOv{Oc|At}:11 -> refint
268 * OLcfgOv{Oc|At}:12 -> ppolicy
269 * OLcfgOv{Oc|At}:13 -> constraint
270 * OLcfgOv{Oc|At}:14 -> translucent
271 * OLcfgOv{Oc|At}:15 -> auditlog
272 * OLcfgOv{Oc|At}:16 -> rwm
273 * OLcfgOv{Oc|At}:17 -> dyngroup
274 * OLcfgOv{Oc|At}:18 -> memberof
275 * OLcfgOv{Oc|At}:19 -> collect
276 * OLcfgOv{Oc|At}:20 -> retcode
277 * OLcfgOv{Oc|At}:21 -> sssvlv
280 /* alphabetical ordering */
282 static ConfigTable config_back_cf_table[] = {
283 /* This attr is read-only */
284 { "", "", 0, 0, 0, ARG_MAGIC,
285 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
286 "DESC 'File for slapd configuration directives' "
287 "EQUALITY caseIgnoreMatch "
288 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
289 { "", "", 0, 0, 0, ARG_MAGIC,
290 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
291 "DESC 'Directory for slapd configuration backend' "
292 "EQUALITY caseIgnoreMatch "
293 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
294 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
295 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
296 "DESC 'Access Control List' "
297 "EQUALITY caseIgnoreMatch "
298 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
299 { "add_content_acl", NULL, 0, 0, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_ACL_ADD,
300 &config_generic, "( OLcfgGlAt:86 NAME 'olcAddContentAcl' "
301 "DESC 'Check ACLs against content of Add ops' "
302 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
303 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
304 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
305 "DESC 'Allowed set of deprecated features' "
306 "EQUALITY caseIgnoreMatch "
307 "SYNTAX OMsDirectoryString )", NULL, NULL },
308 { "argsfile", "file", 2, 2, 0, ARG_STRING,
309 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
310 "DESC 'File for slapd command line options' "
311 "EQUALITY caseIgnoreMatch "
312 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
313 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
314 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
315 "EQUALITY caseIgnoreMatch "
316 "SYNTAX OMsDirectoryString )", NULL, NULL },
317 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
318 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
319 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
320 "DESC 'OpenLDAP attributeTypes' "
321 "EQUALITY caseIgnoreMatch "
322 "SUBSTR caseIgnoreSubstringsMatch "
323 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
325 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
326 #ifdef SLAP_AUTH_REWRITE
327 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
331 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
332 "EQUALITY caseIgnoreMatch "
333 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
334 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
335 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
336 "EQUALITY caseIgnoreMatch "
337 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
338 { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
339 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
340 "EQUALITY caseIgnoreMatch "
341 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
342 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
343 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
344 "DESC 'A type of backend' "
345 "EQUALITY caseIgnoreMatch "
346 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
348 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
349 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
350 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
351 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
352 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
353 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
354 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
355 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
356 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
357 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
358 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
359 "DESC 'The backend type for a database instance' "
360 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
361 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
362 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
363 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
364 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
365 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
366 "EQUALITY caseIgnoreMatch "
367 "SYNTAX OMsDirectoryString )", NULL, NULL },
368 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
369 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
370 "DESC 'OpenLDAP DIT content rules' "
371 "EQUALITY caseIgnoreMatch "
372 "SUBSTR caseIgnoreSubstringsMatch "
373 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
375 { "extra_attrs", "attrlist", 2, 2, 0, ARG_DB|ARG_MAGIC,
376 &config_extra_attrs, "( OLcfgDbAt:0.20 NAME 'olcExtraAttrs' "
377 "EQUALITY caseIgnoreMatch "
378 "SYNTAX OMsDirectoryString )", NULL, NULL },
379 { "gentlehup", "on|off", 2, 2, 0,
381 ARG_ON_OFF, &global_gentlehup,
385 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
386 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
387 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
388 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
389 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
390 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
391 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
392 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
393 { "include", "file", 2, 2, 0, ARG_MAGIC,
394 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
395 "SUP labeledURI )", NULL, NULL },
396 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
397 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
398 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
399 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
400 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
401 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
402 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
403 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
404 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
405 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
406 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
407 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
408 { "index_intlen", "len", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_IX_INTLEN,
409 &config_generic, "( OLcfgGlAt:84 NAME 'olcIndexIntLen' "
410 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
411 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
412 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
413 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
414 { "ldapsyntax", "syntax", 2, 0, 0,
415 ARG_PAREN|ARG_MAGIC|CFG_SYNTAX,
416 &config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
417 "DESC 'OpenLDAP ldapSyntax' "
418 "EQUALITY caseIgnoreMatch "
419 "SUBSTR caseIgnoreSubstringsMatch "
420 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
422 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
423 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
424 "EQUALITY caseIgnoreMatch "
425 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
426 { "listener-threads", "count", 2, 0, 0,
430 ARG_UINT|ARG_MAGIC|CFG_LTHREADS, &config_generic,
432 "( OLcfgGlAt:93 NAME 'olcListenerThreads' "
433 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
434 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
435 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
436 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
437 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
438 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
439 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
440 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
441 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
442 "EQUALITY caseIgnoreMatch "
443 "SYNTAX OMsDirectoryString )", NULL, NULL },
444 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
445 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
446 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
447 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
448 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
449 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
450 { "moduleload", "file", 2, 0, 0,
452 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
456 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
457 "EQUALITY caseIgnoreMatch "
458 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
459 { "modulepath", "path", 2, 2, 0,
461 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
465 "( OLcfgGlAt:31 NAME 'olcModulePath' "
466 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
467 { "monitoring", "TRUE|FALSE", 2, 2, 0,
468 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
469 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
470 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
471 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
472 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
473 "DESC 'OpenLDAP object classes' "
474 "EQUALITY caseIgnoreMatch "
475 "SUBSTR caseIgnoreSubstringsMatch "
476 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
478 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
479 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
480 "EQUALITY caseIgnoreMatch "
481 "SUBSTR caseIgnoreSubstringsMatch "
482 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
483 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
484 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
485 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
486 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
487 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
488 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
489 { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
490 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
491 "EQUALITY caseIgnoreMatch "
492 "SYNTAX OMsDirectoryString )", NULL, NULL },
493 { "pidfile", "file", 2, 2, 0, ARG_STRING,
494 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
495 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
496 { "plugin", NULL, 0, 0, 0,
498 ARG_MAGIC|CFG_PLUGIN, &config_generic,
502 "( OLcfgGlAt:38 NAME 'olcPlugin' "
503 "EQUALITY caseIgnoreMatch "
504 "SYNTAX OMsDirectoryString )", NULL, NULL },
505 { "pluginlog", "filename", 2, 2, 0,
507 ARG_STRING, &slapi_log_file,
511 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
512 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
513 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
514 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
515 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
516 { "referral", "url", 2, 2, 0, ARG_MAGIC,
517 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
518 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
519 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
520 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
521 "EQUALITY caseIgnoreMatch "
522 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
523 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
524 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
525 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
526 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
527 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
528 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
529 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
530 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
531 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
532 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
533 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
534 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
535 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
536 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
537 "EQUALITY caseIgnoreMatch "
538 "SYNTAX OMsDirectoryString )", NULL, NULL },
539 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
540 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
541 "EQUALITY caseIgnoreMatch "
542 "SYNTAX OMsDirectoryString )", NULL, NULL },
543 { "reverse-lookup", "on|off", 2, 2, 0,
544 #ifdef SLAPD_RLOOKUPS
545 ARG_ON_OFF, &use_reverse_lookup,
549 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
550 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
551 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
552 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
553 "EQUALITY distinguishedNameMatch "
554 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
555 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
556 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
557 "EQUALITY caseIgnoreMatch "
558 "SYNTAX OMsDirectoryString )", NULL, NULL },
559 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
560 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
561 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
562 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
563 &config_generic, NULL, NULL, NULL },
564 { "sasl-auxprops", NULL, 2, 0, 0,
565 #ifdef HAVE_CYRUS_SASL
566 ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
570 "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
571 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
572 { "sasl-auxprops-dontusecopy", NULL, 2, 0, 0,
573 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
574 ARG_MAGIC|CFG_AZDUC, &config_generic,
578 "( OLcfgGlAt:91 NAME 'olcSaslAuxpropsDontUseCopy' "
579 "EQUALITY caseIgnoreMatch "
580 "SYNTAX OMsDirectoryString )", NULL, NULL },
581 { "sasl-auxprops-dontusecopy-ignore", "true|FALSE", 2, 0, 0,
582 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
583 ARG_ON_OFF|CFG_AZDUC_IGNORE, &slap_dontUseCopy_ignore,
587 "( OLcfgGlAt:92 NAME 'olcSaslAuxpropsDontUseCopyIgnore' "
588 "EQUALITY booleanMatch "
589 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
590 { "sasl-host", "host", 2, 2, 0,
591 #ifdef HAVE_CYRUS_SASL
592 ARG_STRING|ARG_UNIQUE, &sasl_host,
596 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
597 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
598 { "sasl-realm", "realm", 2, 2, 0,
599 #ifdef HAVE_CYRUS_SASL
600 ARG_STRING|ARG_UNIQUE, &global_realm,
604 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
605 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
606 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
607 &config_generic, NULL, NULL, NULL },
608 { "sasl-secprops", "properties", 2, 2, 0,
609 #ifdef HAVE_CYRUS_SASL
610 ARG_MAGIC|CFG_SASLSECP, &config_generic,
614 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
615 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
616 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
617 &config_generic, NULL, NULL, NULL },
618 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
619 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
620 "EQUALITY distinguishedNameMatch "
621 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
622 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
623 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
624 "EQUALITY caseIgnoreMatch "
625 "SYNTAX OMsDirectoryString )", NULL, NULL },
626 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
627 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
628 "EQUALITY caseIgnoreMatch "
629 "SYNTAX OMsDirectoryString )", NULL, NULL },
630 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
631 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
632 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
633 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
634 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
635 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
636 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
637 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
638 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
639 { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
640 &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
641 "DESC 'Attributes whose values will always be sorted' "
642 "EQUALITY caseIgnoreMatch "
643 "SYNTAX OMsDirectoryString )", NULL, NULL },
644 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
645 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
646 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
647 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
648 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
649 "EQUALITY distinguishedNameMatch "
650 "SYNTAX OMsDN )", NULL, NULL },
651 { "sync_use_subentry", NULL, 0, 0, 0, ARG_ON_OFF|ARG_DB|ARG_MAGIC|CFG_SYNC_SUBENTRY,
652 &config_generic, "( OLcfgDbAt:0.19 NAME 'olcSyncUseSubentry' "
653 "DESC 'Store sync context in a subentry' "
654 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
655 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
656 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
657 "EQUALITY caseIgnoreMatch "
658 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
659 { "tcp-buffer", "[listener=<listener>] [{read|write}=]size", 0, 0, 0,
660 #ifndef LDAP_TCP_BUFFER
662 #else /* LDAP_TCP_BUFFER */
663 ARG_MAGIC, &config_tcp_buffer,
664 #endif /* LDAP_TCP_BUFFER */
665 "( OLcfgGlAt:90 NAME 'olcTCPBuffer' "
666 "DESC 'Custom TCP buffer size' "
667 "SYNTAX OMsDirectoryString )", NULL, NULL },
668 { "threads", "count", 2, 2, 0,
672 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
674 "( OLcfgGlAt:66 NAME 'olcThreads' "
675 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
676 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
677 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
678 "SYNTAX OMsDirectoryString )", NULL, NULL },
679 { "TLSCACertificateFile", NULL, 0, 0, 0,
681 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
685 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
686 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
687 { "TLSCACertificatePath", NULL, 0, 0, 0,
689 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
693 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
694 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
695 { "TLSCertificateFile", NULL, 0, 0, 0,
697 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
701 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
702 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
703 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
705 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
709 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
710 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
711 { "TLSCipherSuite", NULL, 0, 0, 0,
713 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
717 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
718 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
719 { "TLSCRLCheck", NULL, 0, 0, 0,
720 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
721 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
725 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
726 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
727 { "TLSCRLFile", NULL, 0, 0, 0,
728 #if defined(HAVE_GNUTLS)
729 CFG_TLS_CRL_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
733 "( OLcfgGlAt:82 NAME 'olcTLSCRLFile' "
734 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
735 { "TLSRandFile", NULL, 0, 0, 0,
737 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
741 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
742 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
743 { "TLSVerifyClient", NULL, 0, 0, 0,
745 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
749 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
750 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
751 { "TLSDHParamFile", NULL, 0, 0, 0,
753 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
757 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
758 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
759 { "TLSProtocolMin", NULL, 0, 0, 0,
761 CFG_TLS_PROTOCOL_MIN|ARG_STRING|ARG_MAGIC, &config_tls_config,
765 "( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' "
766 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
767 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
768 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
769 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
770 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
771 NULL, NULL, NULL, NULL },
772 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
773 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
774 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
775 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
776 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
777 "EQUALITY caseIgnoreMatch "
778 "SUP labeledURI )", NULL, NULL },
779 { "writetimeout", "timeout", 2, 2, 0, ARG_INT,
780 &global_writetimeout, "( OLcfgGlAt:88 NAME 'olcWriteTimeout' "
781 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
782 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
783 NULL, NULL, NULL, NULL }
786 /* Need to no-op this keyword for dynamic config */
787 ConfigTable olcDatabaseDummy[] = {
788 { "", "", 0, 0, 0, ARG_IGNORED,
789 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
790 "DESC 'The backend type for a database instance' "
791 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
792 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
795 /* Routines to check if a child can be added to this type */
796 static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
797 cfAddBackend, cfAddModule, cfAddOverlay;
799 /* NOTE: be careful when defining array members
800 * that can be conditionally compiled */
801 #define CFOC_GLOBAL cf_ocs[1]
802 #define CFOC_SCHEMA cf_ocs[2]
803 #define CFOC_BACKEND cf_ocs[3]
804 #define CFOC_DATABASE cf_ocs[4]
805 #define CFOC_OVERLAY cf_ocs[5]
806 #define CFOC_INCLUDE cf_ocs[6]
807 #define CFOC_FRONTEND cf_ocs[7]
809 #define CFOC_MODULE cf_ocs[8]
810 #endif /* SLAPD_MODULES */
812 static ConfigOCs cf_ocs[] = {
815 "DESC 'OpenLDAP configuration object' "
816 "ABSTRACT SUP top )", Cft_Abstract, NULL },
819 "DESC 'OpenLDAP Global configuration options' "
820 "SUP olcConfig STRUCTURAL "
821 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
822 "olcAttributeOptions $ olcAuthIDRewrite $ "
823 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
824 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
825 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
826 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
827 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcIndexIntLen $ "
828 "olcLocalSSF $ olcLogFile $ olcLogLevel $ "
829 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
830 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
831 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
833 "olcSaslAuxprops $ olcSaslAuxpropsDontUseCopy $ olcSaslAuxpropsDontUseCopyIgnore $ "
834 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
835 "olcSecurity $ olcServerID $ olcSizeLimit $ "
836 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
838 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
839 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
840 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
841 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
842 "olcTLSCRLFile $ olcToolThreads $ olcWriteTimeout $ "
843 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
844 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
846 "NAME 'olcSchemaConfig' "
847 "DESC 'OpenLDAP schema object' "
848 "SUP olcConfig STRUCTURAL "
849 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
850 "olcObjectClasses $ olcDitContentRules $ olcLdapSyntaxes ) )",
851 Cft_Schema, NULL, cfAddSchema },
853 "NAME 'olcBackendConfig' "
854 "DESC 'OpenLDAP Backend-specific options' "
855 "SUP olcConfig STRUCTURAL "
856 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
858 "NAME 'olcDatabaseConfig' "
859 "DESC 'OpenLDAP Database-specific options' "
860 "SUP olcConfig STRUCTURAL "
862 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
863 "olcAddContentAcl $ olcLastMod $ olcLimits $ "
864 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
865 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
866 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
867 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncUseSubentry $ olcSyncrepl $ "
868 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
869 "olcMonitoring $ olcExtraAttrs ) )",
870 Cft_Database, NULL, cfAddDatabase },
872 "NAME 'olcOverlayConfig' "
873 "DESC 'OpenLDAP Overlay-specific options' "
874 "SUP olcConfig STRUCTURAL "
875 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
877 "NAME 'olcIncludeFile' "
878 "DESC 'OpenLDAP configuration include file' "
879 "SUP olcConfig STRUCTURAL "
881 "MAY ( cn $ olcRootDSE ) )",
882 /* Used to be Cft_Include, that def has been removed */
883 Cft_Abstract, NULL, cfAddInclude },
884 /* This should be STRUCTURAL like all the other database classes, but
885 * that would mean inheriting all of the olcDatabaseConfig attributes,
886 * which causes them to be merged twice in config_build_entry.
889 "NAME 'olcFrontendConfig' "
890 "DESC 'OpenLDAP frontend configuration' "
892 "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
893 Cft_Database, NULL, NULL },
896 "NAME 'olcModuleList' "
897 "DESC 'OpenLDAP dynamic module info' "
898 "SUP olcConfig STRUCTURAL "
899 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
900 Cft_Module, NULL, cfAddModule },
905 typedef struct ServerID {
906 struct ServerID *si_next;
907 struct berval si_url;
911 static ServerID *sid_list;
913 typedef struct voidList {
914 struct voidList *vl_next;
918 typedef struct ADlist {
919 struct ADlist *al_next;
920 AttributeDescription *al_desc;
923 static ADlist *sortVals;
926 config_generic(ConfigArgs *c) {
929 if ( c->op == SLAP_CONFIG_EMIT ) {
933 c->value_int = ldap_pvt_thread_get_concurrency();
936 c->value_int = connection_pool_max;
939 c->value_int = slap_tool_thread_max;
942 c->value_uint = slapd_daemon_threads;
946 c->value_string = ch_strdup( passwd_salt );
951 if ( c->be->be_limits ) {
955 for ( i=0; c->be->be_limits[i]; i++ ) {
956 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
957 if ( bv.bv_len >= sizeof( buf ) ) {
958 ber_bvarray_free_x( c->rvalue_vals, NULL );
959 c->rvalue_vals = NULL;
963 bv.bv_val = buf + bv.bv_len;
964 limits_unparse( c->be->be_limits[i], &bv,
965 sizeof( buf ) - ( bv.bv_val - buf ) );
966 bv.bv_len += bv.bv_val - buf;
968 value_add_one( &c->rvalue_vals, &bv );
971 if ( !c->rvalue_vals ) rc = 1;
974 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
977 c->value_string = ch_strdup( slap_sasl_getpolicy());
980 slap_sasl_regexp_unparse( &c->rvalue_vals );
981 if ( !c->rvalue_vals ) rc = 1;
983 #ifdef HAVE_CYRUS_SASL
984 #ifdef SLAP_AUXPROP_DONTUSECOPY
986 static int duc_done = 0;
988 /* take the opportunity to initialize with known values */
990 struct berval duc[] = { BER_BVC("cmusaslsecretOTP"), BER_BVNULL };
993 for ( i = 0; !BER_BVISNULL( &duc[ i ] ); i++ ) {
994 const char *text = NULL;
995 AttributeDescription *ad = NULL;
997 if ( slap_bv2ad( &duc[ i ], &ad, &text ) == LDAP_SUCCESS ) {
999 if ( slap_dontUseCopy_propnames ) {
1002 for ( j = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ j ] ); j++ ) {
1003 if ( bvmatch( &slap_dontUseCopy_propnames[ j ], &ad->ad_cname ) ) {
1010 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1018 if ( slap_dontUseCopy_propnames != NULL ) {
1019 ber_bvarray_dup_x( &c->rvalue_vals, slap_dontUseCopy_propnames, NULL );
1024 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1025 case CFG_SASLSECP: {
1026 struct berval bv = BER_BVNULL;
1027 slap_sasl_secprops_unparse( &bv );
1028 if ( !BER_BVISNULL( &bv )) {
1029 ber_bvarray_add( &c->rvalue_vals, &bv );
1037 c->value_int = c->be->be_max_deref_depth;
1040 if ( SLAP_DBHIDDEN( c->be )) {
1047 ConfigFile *cf = c->ca_private;
1049 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1050 else if ( cf->c_om_head )
1051 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
1053 if ( !c->rvalue_vals )
1058 ad_unparse_options( &c->rvalue_vals );
1061 ConfigFile *cf = c->ca_private;
1063 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1064 else if ( cf->c_oc_head )
1065 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
1067 if ( !c->rvalue_vals )
1072 ConfigFile *cf = c->ca_private;
1074 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1075 else if ( cf->c_at_head )
1076 at_unparse( &c->rvalue_vals, cf->c_at_head,
1078 if ( !c->rvalue_vals )
1083 ConfigFile *cf = c->ca_private;
1085 syn_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1086 else if ( cf->c_syn_head )
1087 syn_unparse( &c->rvalue_vals, cf->c_syn_head,
1088 cf->c_syn_tail, 0 );
1089 if ( !c->rvalue_vals )
1094 ConfigFile *cf = c->ca_private;
1096 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1097 else if ( cf->c_cr_head )
1098 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
1100 if ( !c->rvalue_vals )
1107 char *src, *dst, ibuf[11];
1108 struct berval bv, abv;
1109 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
1110 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1111 if ( abv.bv_len >= sizeof( ibuf ) ) {
1112 ber_bvarray_free_x( c->rvalue_vals, NULL );
1113 c->rvalue_vals = NULL;
1117 acl_unparse( a, &bv );
1118 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
1119 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
1120 /* Turn TAB / EOL into plain space */
1121 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
1122 if (isspace((unsigned char)*src)) *dst++ = ' ';
1126 if (dst[-1] == ' ') {
1130 abv.bv_len = dst - abv.bv_val;
1131 ber_bvarray_add( &c->rvalue_vals, &abv );
1137 c->value_int = (SLAP_DBACL_ADD(c->be) != 0);
1140 ConfigFile *cf = c->ca_private;
1141 if ( cf->c_dseFiles ) {
1142 value_add( &c->rvalue_vals, cf->c_dseFiles );
1153 for ( si = sid_list; si; si=si->si_next ) {
1154 assert( si->si_num >= 0 && si->si_num <= SLAP_SYNC_SID_MAX );
1155 if ( !BER_BVISEMPTY( &si->si_url )) {
1156 bv.bv_len = si->si_url.bv_len + 6;
1157 bv.bv_val = ch_malloc( bv.bv_len );
1158 bv.bv_len = sprintf( bv.bv_val, "%d %s", si->si_num,
1159 si->si_url.bv_val );
1160 ber_bvarray_add( &c->rvalue_vals, &bv );
1164 bv.bv_len = sprintf( buf, "%d", si->si_num );
1165 value_add_one( &c->rvalue_vals, &bv );
1174 c->value_string = ch_strdup( logfileName );
1179 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
1181 case CFG_SYNC_SUBENTRY:
1182 c->value_int = (SLAP_SYNC_SUBENTRY(c->be) != 0);
1184 case CFG_MIRRORMODE:
1185 if ( SLAP_SHADOW(c->be))
1186 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
1190 case CFG_MONITORING:
1191 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
1193 case CFG_SSTR_IF_MAX:
1194 c->value_uint = index_substr_if_maxlen;
1196 case CFG_SSTR_IF_MIN:
1197 c->value_uint = index_substr_if_minlen;
1200 c->value_int = index_intlen;
1202 case CFG_SORTVALS: {
1205 for ( sv = sortVals; sv; sv = sv->al_next ) {
1206 value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
1210 #ifdef SLAPD_MODULES
1212 ModPaths *mp = c->ca_private;
1215 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
1218 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
1219 SLAP_X_ORDERED_FMT "%s", i,
1220 mp->mp_loads[i].bv_val );
1221 if ( bv.bv_len >= sizeof( c->log ) ) {
1222 ber_bvarray_free_x( c->rvalue_vals, NULL );
1223 c->rvalue_vals = NULL;
1226 value_add_one( &c->rvalue_vals, &bv );
1230 rc = c->rvalue_vals ? 0 : 1;
1234 ModPaths *mp = c->ca_private;
1235 if ( !BER_BVISNULL( &mp->mp_path ))
1236 value_add_one( &c->rvalue_vals, &mp->mp_path );
1238 rc = c->rvalue_vals ? 0 : 1;
1244 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1245 if ( !c->rvalue_vals ) rc = 1;
1248 #ifdef SLAP_AUTH_REWRITE
1250 if ( authz_rewrites ) {
1251 struct berval bv, idx;
1256 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1257 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1258 if ( idx.bv_len >= sizeof( ibuf ) ) {
1259 ber_bvarray_free_x( c->rvalue_vals, NULL );
1260 c->rvalue_vals = NULL;
1263 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1264 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1265 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1266 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1267 authz_rewrites[i].bv_val,
1268 authz_rewrites[i].bv_len + 1 );
1269 ber_bvarray_add( &c->rvalue_vals, &bv );
1272 if ( !c->rvalue_vals ) rc = 1;
1279 } else if ( c->op == LDAP_MOD_DELETE ) {
1282 /* single-valued attrs, no-ops */
1291 case CFG_MIRRORMODE:
1292 case CFG_MONITORING:
1294 case CFG_SSTR_IF_MAX:
1295 case CFG_SSTR_IF_MIN:
1297 case CFG_SYNC_SUBENTRY:
1300 /* no-ops, requires slapd restart */
1305 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1308 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
1310 if ( c->valx < 0 ) {
1311 if ( slap_dontUseCopy_propnames != NULL ) {
1312 ber_bvarray_free( slap_dontUseCopy_propnames );
1313 slap_dontUseCopy_propnames = NULL;
1319 if ( slap_dontUseCopy_propnames == NULL ) {
1324 for ( i = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i ] ) && i < c->valx; i++ );
1325 if ( i < c->valx ) {
1329 ber_memfree( slap_dontUseCopy_propnames[ i ].bv_val );
1330 for ( ; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i + 1 ] ); i++ ) {
1331 slap_dontUseCopy_propnames[ i ] = slap_dontUseCopy_propnames[ i + 1 ];
1333 BER_BVZERO( &slap_dontUseCopy_propnames[ i ] );
1336 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1338 ch_free( passwd_salt );
1343 ch_free( logfileName );
1351 case CFG_SERVERID: {
1352 ServerID *si, **sip;
1354 for ( i=0, si = sid_list, sip = &sid_list;
1355 si; si = *sip, i++ ) {
1356 if ( c->valx == -1 || i == c->valx ) {
1368 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1372 index_intlen = SLAP_INDEX_INTLEN_DEFAULT;
1373 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1374 SLAP_INDEX_INTLEN_DEFAULT );
1378 if ( c->valx < 0 ) {
1379 acl_destroy( c->be->be_acl );
1380 c->be->be_acl = NULL;
1383 AccessControl **prev, *a;
1385 for (i=0, prev = &c->be->be_acl; i < c->valx;
1388 prev = &a->acl_next;
1391 *prev = a->acl_next;
1398 /* Can be NULL when undoing a failed add */
1399 if ( c->ca_entry ) {
1400 ce = c->ca_entry->e_private;
1401 /* can't modify the hardcoded schema */
1402 if ( ce->ce_parent->ce_type == Cft_Global )
1406 cfn = c->ca_private;
1407 if ( c->valx < 0 ) {
1410 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1412 if ( oc == cfn->c_oc_tail )
1415 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1417 ObjectClass *oc, *prev = NULL;
1419 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1424 if ( cfn->c_oc_tail == oc ) {
1425 cfn->c_oc_tail = prev;
1427 if ( cfn->c_oc_head == oc ) {
1429 cfn->c_oc_head = oc;
1436 /* Can be NULL when undoing a failed add */
1437 if ( c->ca_entry ) {
1438 ce = c->ca_entry->e_private;
1439 /* can't modify the hardcoded schema */
1440 if ( ce->ce_parent->ce_type == Cft_Global )
1444 cfn = c->ca_private;
1445 if ( c->valx < 0 ) {
1448 for( at = cfn->c_at_head; at; at_next( &at )) {
1450 if ( at == cfn->c_at_tail )
1453 cfn->c_at_head = cfn->c_at_tail = NULL;
1455 AttributeType *at, *prev = NULL;
1457 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1462 if ( cfn->c_at_tail == at ) {
1463 cfn->c_at_tail = prev;
1465 if ( cfn->c_at_head == at ) {
1467 cfn->c_at_head = at;
1474 /* Can be NULL when undoing a failed add */
1475 if ( c->ca_entry ) {
1476 ce = c->ca_entry->e_private;
1477 /* can't modify the hardcoded schema */
1478 if ( ce->ce_parent->ce_type == Cft_Global )
1482 cfn = c->ca_private;
1483 if ( c->valx < 0 ) {
1486 for( syn = cfn->c_syn_head; syn; syn_next( &syn )) {
1488 if ( syn == cfn->c_syn_tail )
1491 cfn->c_syn_head = cfn->c_syn_tail = NULL;
1493 Syntax *syn, *prev = NULL;
1495 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++) {
1500 if ( cfn->c_syn_tail == syn ) {
1501 cfn->c_syn_tail = prev;
1503 if ( cfn->c_syn_head == syn ) {
1505 cfn->c_syn_head = syn;
1510 if ( c->valx < 0 ) {
1512 for ( sv = sortVals; sv; sv = sortVals ) {
1513 sortVals = sv->al_next;
1514 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1521 for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
1522 prev = &sv->al_next;
1525 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1526 *prev = sv->al_next;
1532 /* FIXME: there is no limits_free function */
1533 if ( c->valx < 0 ) {
1534 limits_destroy( c->be->be_limits );
1535 c->be->be_limits = NULL;
1540 if ( c->be->be_limits ) {
1541 for ( num = 0; c->be->be_limits[ num ]; num++ )
1545 if ( c->valx >= num ) {
1550 limits_destroy( c->be->be_limits );
1551 c->be->be_limits = NULL;
1554 limits_free_one( c->be->be_limits[ c->valx ] );
1556 for ( cnt = c->valx; cnt < num; cnt++ ) {
1557 c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
1564 /* FIXME: there is no ad_option_free function */
1566 /* FIXME: there is no way to remove attributes added by
1580 if(!(c->bi = backend_info(c->argv[1]))) {
1581 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1582 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1583 c->log, c->cr_msg, c->argv[1] );
1590 /* NOTE: config is always the first backend!
1592 if ( !strcasecmp( c->argv[1], "config" )) {
1593 c->be = LDAP_STAILQ_FIRST(&backendDB);
1594 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1597 c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply);
1599 if ( c->cr_msg[0] == 0 )
1600 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1601 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n", c->log, c->cr_msg, c->argv[1] );
1608 ldap_pvt_thread_set_concurrency(c->value_int);
1612 if ( c->value_int < 2 ) {
1613 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1614 "threads=%d smaller than minimum value 2",
1616 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1617 c->log, c->cr_msg, 0 );
1620 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1621 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1622 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1623 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1624 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1625 c->log, c->cr_msg, 0 );
1627 if ( slapMode & SLAP_SERVER_MODE )
1628 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1629 connection_pool_max = c->value_int; /* save for reference */
1633 if ( slapMode & SLAP_TOOL_MODE )
1634 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1635 slap_tool_thread_max = c->value_int; /* save for reference */
1640 /* use a power of two */
1641 while (c->value_uint > 1) {
1642 c->value_uint >>= 1;
1646 slapd_daemon_mask = mask;
1647 slapd_daemon_threads = mask+1;
1652 if ( passwd_salt ) ch_free( passwd_salt );
1653 passwd_salt = c->value_string;
1654 lutil_salt_format(passwd_salt);
1658 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1664 c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1666 c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1670 ch_free(c->value_string);
1671 if (slap_sasl_setpolicy( c->argv[1] )) {
1672 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
1673 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1674 c->log, c->cr_msg, c->argv[1] );
1680 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1684 #ifdef HAVE_CYRUS_SASL
1685 #ifdef SLAP_AUXPROP_DONTUSECOPY
1689 for ( arg = 1; arg < c->argc; arg++ ) {
1690 int duplicate = 0, err;
1691 AttributeDescription *ad = NULL;
1692 const char *text = NULL;
1694 err = slap_str2ad( c->argv[ arg ], &ad, &text );
1695 if ( err != LDAP_SUCCESS ) {
1696 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") unknown (err=%d \"%s\"; ignored)",
1697 c->argv[0], arg, c->argv[ arg ], err, text );
1698 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1699 c->log, c->cr_msg, 0 );
1702 if ( slap_dontUseCopy_propnames != NULL ) {
1703 for ( cnt = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ cnt ] ); cnt++ ) {
1704 if ( bvmatch( &slap_dontUseCopy_propnames[ cnt ], &ad->ad_cname ) ) {
1712 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") already defined (ignored)",
1713 c->argv[0], arg, ad->ad_cname.bv_val);
1714 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1715 c->log, c->cr_msg, 0 );
1719 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1724 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1728 char *txt = slap_sasl_secprops( c->argv[1] );
1730 snprintf( c->cr_msg, sizeof(c->cr_msg), "<%s> %s",
1732 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0 );
1740 c->be->be_max_deref_depth = c->value_int;
1746 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1747 cfn = c->ca_private;
1748 if(parse_oidm(c, 1, &om))
1750 if (!cfn->c_om_head) cfn->c_om_head = om;
1751 cfn->c_om_tail = om;
1756 ObjectClass *oc, *prev;
1758 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1759 cfn = c->ca_private;
1760 if ( c->valx < 0 ) {
1761 prev = cfn->c_oc_tail;
1764 /* If adding anything after the first, prev is easy */
1767 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1772 /* If adding the first, and head exists, find its prev */
1773 if (cfn->c_oc_head) {
1774 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1779 /* else prev is NULL, append to end of global list */
1781 if(parse_oc(c, &oc, prev)) return(1);
1782 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1783 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1788 AttributeType *at, *prev;
1790 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1791 cfn = c->ca_private;
1792 if ( c->valx < 0 ) {
1793 prev = cfn->c_at_tail;
1796 /* If adding anything after the first, prev is easy */
1799 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1804 /* If adding the first, and head exists, find its prev */
1805 if (cfn->c_at_head) {
1806 for ( at_start( &at ); at != cfn->c_at_head; ) {
1811 /* else prev is NULL, append to end of global list */
1813 if(parse_at(c, &at, prev)) return(1);
1814 if (!cfn->c_at_head) cfn->c_at_head = at;
1815 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1822 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1823 cfn = c->ca_private;
1824 if ( c->valx < 0 ) {
1825 prev = cfn->c_syn_tail;
1828 /* If adding anything after the first, prev is easy */
1831 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
1836 /* If adding the first, and head exists, find its prev */
1837 if (cfn->c_syn_head) {
1838 for ( syn_start( &syn ); syn != cfn->c_syn_head; ) {
1843 /* else prev is NULL, append to end of global list */
1845 if ( parse_syn( c, &syn, prev ) ) return(1);
1846 if ( !cfn->c_syn_head ) cfn->c_syn_head = syn;
1847 if ( cfn->c_syn_tail == prev ) cfn->c_syn_tail = syn;
1854 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1855 cfn = c->ca_private;
1856 if(parse_cr(c, &cr)) return(1);
1857 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1858 cfn->c_cr_tail = cr;
1863 ad_define_option(NULL, NULL, 0);
1864 for(i = 1; i < c->argc; i++)
1865 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1870 if ( c->value_int < SLAP_INDEX_INTLEN_DEFAULT )
1871 c->value_int = SLAP_INDEX_INTLEN_DEFAULT;
1872 else if ( c->value_int > 255 )
1874 index_intlen = c->value_int;
1875 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1879 case CFG_SORTVALS: {
1880 ADlist *svnew = NULL, *svtail, *sv;
1882 for ( i = 1; i < c->argc; i++ ) {
1883 AttributeDescription *ad = NULL;
1887 rc = slap_str2ad( c->argv[i], &ad, &text );
1889 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
1892 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1893 c->log, c->cr_msg, c->argv[i] );
1894 for ( sv = svnew; sv; sv = svnew ) {
1895 svnew = sv->al_next;
1900 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
1901 ad->ad_type->sat_single_value ) {
1902 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
1904 goto sortval_reject;
1906 sv = ch_malloc( sizeof( ADlist ));
1911 svtail->al_next = sv;
1916 for ( sv = svnew; sv; sv = sv->al_next )
1917 sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
1918 for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
1920 sv->al_next = svnew;
1927 /* Don't append to the global ACL if we're on a specific DB */
1929 if ( c->valx == -1 ) {
1932 for ( a=c->be->be_acl; a; a = a->acl_next )
1935 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1942 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_ACL_ADD;
1944 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_ACL_ADD;
1948 if(root_dse_read_file(c->argv[1])) {
1949 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> could not read file", c->argv[0] );
1950 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1951 c->log, c->cr_msg, c->argv[1] );
1956 ber_str2bv( c->argv[1], 0, 1, &bv );
1957 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1958 cfn = c->ca_private;
1959 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1965 ServerID *si, **sip;
1968 if (( lutil_atoi( &num, c->argv[1] ) &&
1969 lutil_atoix( &num, c->argv[1], 16 )) ||
1970 num < 0 || num > SLAP_SYNC_SID_MAX )
1972 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1973 "<%s> illegal server ID", c->argv[0] );
1974 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1975 c->log, c->cr_msg, c->argv[1] );
1978 /* only one value allowed if no URL is given */
1979 if ( c->argc > 2 ) {
1982 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1983 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1984 "<%s> only one server ID allowed now", c->argv[0] );
1985 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1986 c->log, c->cr_msg, c->argv[1] );
1990 if ( ldap_url_parse( c->argv[2], &lud )) {
1991 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1992 "<%s> invalid URL", c->argv[0] );
1993 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1994 c->log, c->cr_msg, c->argv[2] );
1997 len = strlen( c->argv[2] );
1998 si = ch_malloc( sizeof(ServerID) + len + 1 );
1999 si->si_url.bv_val = (char *)(si+1);
2000 si->si_url.bv_len = len;
2001 strcpy( si->si_url.bv_val, c->argv[2] );
2004 snprintf( c->cr_msg, sizeof( c->cr_msg ),
2005 "<%s> unqualified server ID not allowed now", c->argv[0] );
2006 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2007 c->log, c->cr_msg, c->argv[1] );
2010 si = ch_malloc( sizeof(ServerID) );
2011 BER_BVZERO( &si->si_url );
2012 slap_serverID = num;
2013 Debug( LDAP_DEBUG_CONFIG,
2015 c->log, slap_serverID, 0 );
2019 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
2022 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
2023 Listener *l = config_check_my_url( c->argv[2], lud );
2025 slap_serverID = si->si_num;
2026 Debug( LDAP_DEBUG_CONFIG,
2027 "%s: SID=0x%03x (listener=%s)\n",
2028 c->log, slap_serverID,
2033 ldap_free_urldesc( lud );
2037 if ( logfileName ) ch_free( logfileName );
2038 logfileName = c->value_string;
2039 logfile = fopen(logfileName, "w");
2040 if(logfile) lutil_debug_file(logfile);
2044 if(SLAP_NOLASTMODCMD(c->be)) {
2045 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> not available for %s database",
2046 c->argv[0], c->be->bd_info->bi_type );
2047 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2048 c->log, c->cr_msg, 0 );
2052 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
2054 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
2057 case CFG_MIRRORMODE:
2058 if(c->value_int && !SLAP_SHADOW(c->be)) {
2059 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database is not a shadow",
2061 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2062 c->log, c->cr_msg, 0 );
2066 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
2068 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
2071 case CFG_MONITORING:
2073 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
2075 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
2080 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
2082 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
2085 case CFG_SYNC_SUBENTRY:
2087 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SYNC_SUBENTRY;
2089 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SYNC_SUBENTRY;
2092 case CFG_SSTR_IF_MAX:
2093 if (c->value_uint < index_substr_if_minlen) {
2094 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2095 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2096 c->log, c->cr_msg, c->value_int );
2099 index_substr_if_maxlen = c->value_uint;
2102 case CFG_SSTR_IF_MIN:
2103 if (c->value_uint > index_substr_if_maxlen) {
2104 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2105 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2106 c->log, c->cr_msg, c->value_int );
2109 index_substr_if_minlen = c->value_uint;
2112 #ifdef SLAPD_MODULES
2114 /* If we're just adding a module on an existing modpath,
2115 * make sure we've selected the current path.
2117 if ( c->op == LDAP_MOD_ADD && c->ca_private && modcur != c->ca_private ) {
2118 modcur = c->ca_private;
2119 /* This should never fail */
2120 if ( module_path( modcur->mp_path.bv_val )) {
2121 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> module path no longer valid",
2123 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2124 c->log, c->cr_msg, modcur->mp_path.bv_val );
2128 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
2130 /* Record this load on the current path */
2134 if ( c->op == SLAP_CONFIG_ADD ) {
2135 ptr = c->line + STRLENOF("moduleload");
2136 while (!isspace((unsigned char) *ptr)) ptr++;
2137 while (isspace((unsigned char) *ptr)) ptr++;
2141 ber_str2bv(ptr, 0, 1, &bv);
2142 ber_bvarray_add( &modcur->mp_loads, &bv );
2144 /* Check for any new hardcoded schema */
2145 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
2146 config_check_schema( NULL, &cfBackInfo );
2151 if(module_path(c->argv[1])) return(1);
2152 /* Record which path was used with each module */
2156 if (!modpaths.mp_loads) {
2159 mp = ch_malloc( sizeof( ModPaths ));
2160 modlast->mp_next = mp;
2162 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
2164 mp->mp_loads = NULL;
2175 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
2177 slapi_plugins_used++;
2181 #ifdef SLAP_AUTH_REWRITE
2187 if ( c->op == LDAP_MOD_ADD ) {
2191 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
2195 if ( c->argc > 1 ) {
2198 /* quote all args but the first */
2199 line = ldap_charray2str( c->argv, "\" \"" );
2200 ber_str2bv( line, 0, 0, &bv );
2201 s = ber_bvchr( &bv, '"' );
2202 assert( s != NULL );
2203 /* move the trailing quote of argv[0] to the end */
2204 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
2205 bv.bv_val[ bv.bv_len - 1 ] = '"';
2208 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
2211 ber_bvarray_add( &authz_rewrites, &bv );
2213 if ( c->op == LDAP_MOD_ADD ) {
2223 Debug( LDAP_DEBUG_ANY,
2224 "%s: unknown CFG_TYPE %d.\n",
2225 c->log, c->type, 0 );
2234 config_fname(ConfigArgs *c) {
2235 if(c->op == SLAP_CONFIG_EMIT) {
2236 if (c->ca_private) {
2237 ConfigFile *cf = c->ca_private;
2238 value_add_one( &c->rvalue_vals, &cf->c_file );
2247 config_cfdir(ConfigArgs *c) {
2248 if(c->op == SLAP_CONFIG_EMIT) {
2249 if ( !BER_BVISEMPTY( &cfdir )) {
2250 value_add_one( &c->rvalue_vals, &cfdir );
2259 config_search_base(ConfigArgs *c) {
2260 if(c->op == SLAP_CONFIG_EMIT) {
2262 if (!BER_BVISEMPTY(&default_search_base)) {
2263 value_add_one(&c->rvalue_vals, &default_search_base);
2264 value_add_one(&c->rvalue_nvals, &default_search_nbase);
2268 } else if( c->op == LDAP_MOD_DELETE ) {
2269 ch_free( default_search_base.bv_val );
2270 ch_free( default_search_nbase.bv_val );
2271 BER_BVZERO( &default_search_base );
2272 BER_BVZERO( &default_search_nbase );
2276 if(c->bi || c->be != frontendDB) {
2277 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
2278 "prior to any backend or database definition\n",
2283 if(default_search_nbase.bv_len) {
2284 free(default_search_base.bv_val);
2285 free(default_search_nbase.bv_val);
2288 default_search_base = c->value_dn;
2289 default_search_nbase = c->value_ndn;
2293 /* For RE23 compatibility we allow this in the global entry
2294 * but we now defer it to the frontend entry to allow modules
2295 * to load new hash types.
2298 config_passwd_hash(ConfigArgs *c) {
2300 if (c->op == SLAP_CONFIG_EMIT) {
2302 /* Don't generate it in the global entry */
2303 if ( c->table == Cft_Global )
2305 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
2306 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
2307 value_add_one(&c->rvalue_vals, &bv);
2310 } else if ( c->op == LDAP_MOD_DELETE ) {
2311 /* Deleting from global is a no-op, only the frontendDB entry matters */
2312 if ( c->table == Cft_Global )
2314 if ( c->valx < 0 ) {
2315 ldap_charray_free( default_passwd_hash );
2316 default_passwd_hash = NULL;
2319 ch_free( default_passwd_hash[i] );
2320 for (; default_passwd_hash[i]; i++ )
2321 default_passwd_hash[i] = default_passwd_hash[i+1];
2325 for(i = 1; i < c->argc; i++) {
2326 if(!lutil_passwd_scheme(c->argv[i])) {
2327 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
2328 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2329 c->log, c->cr_msg, c->argv[i]);
2331 ldap_charray_add(&default_passwd_hash, c->argv[i]);
2334 if(!default_passwd_hash) {
2335 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
2336 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2337 c->log, c->cr_msg, 0 );
2344 config_schema_dn(ConfigArgs *c) {
2345 if ( c->op == SLAP_CONFIG_EMIT ) {
2347 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
2348 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
2349 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
2353 } else if ( c->op == LDAP_MOD_DELETE ) {
2354 ch_free( c->be->be_schemadn.bv_val );
2355 ch_free( c->be->be_schemandn.bv_val );
2356 BER_BVZERO( &c->be->be_schemadn );
2357 BER_BVZERO( &c->be->be_schemandn );
2360 ch_free( c->be->be_schemadn.bv_val );
2361 ch_free( c->be->be_schemandn.bv_val );
2362 c->be->be_schemadn = c->value_dn;
2363 c->be->be_schemandn = c->value_ndn;
2368 config_sizelimit(ConfigArgs *c) {
2370 struct slap_limits_set *lim = &c->be->be_def_limit;
2371 if (c->op == SLAP_CONFIG_EMIT) {
2376 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
2377 if ( !BER_BVISEMPTY( &bv ))
2378 value_add_one( &c->rvalue_vals, &bv );
2382 } else if ( c->op == LDAP_MOD_DELETE ) {
2383 /* Reset to defaults or values from frontend */
2384 if ( c->be == frontendDB ) {
2385 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
2386 lim->lms_s_hard = 0;
2387 lim->lms_s_unchecked = -1;
2389 lim->lms_s_pr_hide = 0;
2390 lim->lms_s_pr_total = 0;
2392 lim->lms_s_soft = frontendDB->be_def_limit.lms_s_soft;
2393 lim->lms_s_hard = frontendDB->be_def_limit.lms_s_hard;
2394 lim->lms_s_unchecked = frontendDB->be_def_limit.lms_s_unchecked;
2395 lim->lms_s_pr = frontendDB->be_def_limit.lms_s_pr;
2396 lim->lms_s_pr_hide = frontendDB->be_def_limit.lms_s_pr_hide;
2397 lim->lms_s_pr_total = frontendDB->be_def_limit.lms_s_pr_total;
2401 for(i = 1; i < c->argc; i++) {
2402 if(!strncasecmp(c->argv[i], "size", 4)) {
2403 rc = limits_parse_one(c->argv[i], lim);
2405 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2406 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2407 c->log, c->cr_msg, c->argv[i]);
2411 if(!strcasecmp(c->argv[i], "unlimited")) {
2412 lim->lms_s_soft = -1;
2414 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
2415 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2416 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2417 c->log, c->cr_msg, c->argv[i]);
2421 lim->lms_s_hard = 0;
2426 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2427 /* This is a modification to the global limits apply it to
2428 * the other databases as needed */
2429 AttributeDescription *ad=NULL;
2430 const char *text = NULL;
2431 CfEntryInfo *ce = c->ca_entry->e_private;
2433 slap_str2ad(c->argv[0], &ad, &text);
2434 /* if we got here... */
2435 assert( ad != NULL );
2437 if ( ce->ce_type == Cft_Global ){
2440 for (; ce; ce=ce->ce_sibs) {
2441 Entry *dbe = ce->ce_entry;
2442 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2443 && (!attr_find(dbe->e_attrs, ad)) ) {
2444 ce->ce_be->be_def_limit.lms_s_soft = lim->lms_s_soft;
2445 ce->ce_be->be_def_limit.lms_s_hard = lim->lms_s_hard;
2446 ce->ce_be->be_def_limit.lms_s_unchecked =lim->lms_s_unchecked;
2447 ce->ce_be->be_def_limit.lms_s_pr =lim->lms_s_pr;
2448 ce->ce_be->be_def_limit.lms_s_pr_hide =lim->lms_s_pr_hide;
2449 ce->ce_be->be_def_limit.lms_s_pr_total =lim->lms_s_pr_total;
2457 config_timelimit(ConfigArgs *c) {
2459 struct slap_limits_set *lim = &c->be->be_def_limit;
2460 if (c->op == SLAP_CONFIG_EMIT) {
2465 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
2466 if ( !BER_BVISEMPTY( &bv ))
2467 value_add_one( &c->rvalue_vals, &bv );
2471 } else if ( c->op == LDAP_MOD_DELETE ) {
2472 /* Reset to defaults or values from frontend */
2473 if ( c->be == frontendDB ) {
2474 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
2475 lim->lms_t_hard = 0;
2477 lim->lms_t_soft = frontendDB->be_def_limit.lms_t_soft;
2478 lim->lms_t_hard = frontendDB->be_def_limit.lms_t_hard;
2482 for(i = 1; i < c->argc; i++) {
2483 if(!strncasecmp(c->argv[i], "time", 4)) {
2484 rc = limits_parse_one(c->argv[i], lim);
2486 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2487 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2488 c->log, c->cr_msg, c->argv[i]);
2492 if(!strcasecmp(c->argv[i], "unlimited")) {
2493 lim->lms_t_soft = -1;
2495 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
2496 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2497 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2498 c->log, c->cr_msg, c->argv[i]);
2502 lim->lms_t_hard = 0;
2507 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2508 /* This is a modification to the global limits apply it to
2509 * the other databases as needed */
2510 AttributeDescription *ad=NULL;
2511 const char *text = NULL;
2512 CfEntryInfo *ce = c->ca_entry->e_private;
2514 slap_str2ad(c->argv[0], &ad, &text);
2515 /* if we got here... */
2516 assert( ad != NULL );
2518 if ( ce->ce_type == Cft_Global ){
2521 for (; ce; ce=ce->ce_sibs) {
2522 Entry *dbe = ce->ce_entry;
2523 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2524 && (!attr_find(dbe->e_attrs, ad)) ) {
2525 ce->ce_be->be_def_limit.lms_t_soft = lim->lms_t_soft;
2526 ce->ce_be->be_def_limit.lms_t_hard = lim->lms_t_hard;
2534 config_overlay(ConfigArgs *c) {
2535 if (c->op == SLAP_CONFIG_EMIT) {
2537 } else if ( c->op == LDAP_MOD_DELETE ) {
2540 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
2541 c->valx, &c->bi, &c->reply)) {
2543 Debug( LDAP_DEBUG_ANY,
2544 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
2545 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
2547 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi, &c->reply)) {
2554 config_subordinate(ConfigArgs *c)
2560 case SLAP_CONFIG_EMIT:
2561 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
2564 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
2565 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
2568 value_add_one( &c->rvalue_vals, &bv );
2572 case LDAP_MOD_DELETE:
2573 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2574 glue_sub_del( c->be );
2576 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2581 case SLAP_CONFIG_ADD:
2582 if ( c->be->be_nsuffix == NULL ) {
2584 snprintf( c->cr_msg, sizeof( c->cr_msg),
2585 "subordinate configuration needs a suffix" );
2586 Debug( LDAP_DEBUG_ANY,
2588 c->log, c->cr_msg, 0 );
2593 if ( c->argc == 2 ) {
2594 if ( strcasecmp( c->argv[1], "advertise" ) == 0 ) {
2597 } else if ( strcasecmp( c->argv[1], "TRUE" ) != 0 ) {
2599 snprintf( c->cr_msg, sizeof( c->cr_msg),
2600 "subordinate must be \"TRUE\" or \"advertise\"" );
2601 Debug( LDAP_DEBUG_ANY,
2602 "%s: suffix \"%s\": %s.\n",
2603 c->log, c->be->be_suffix[0].bv_val, c->cr_msg );
2609 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2617 * [listener=<listener>] [{read|write}=]<size>
2620 #ifdef LDAP_TCP_BUFFER
2621 static BerVarray tcp_buffer;
2624 #define SLAP_TCP_RMEM (0x1U)
2625 #define SLAP_TCP_WMEM (0x2U)
2628 tcp_buffer_parse( struct berval *val, int argc, char **argv,
2629 int *size, int *rw, Listener **l )
2631 int i, rc = LDAP_SUCCESS;
2632 LDAPURLDesc *lud = NULL;
2635 if ( val != NULL && argv == NULL ) {
2636 char *s = val->bv_val;
2638 argv = ldap_str2charray( s, " \t" );
2639 if ( argv == NULL ) {
2645 if ( strncasecmp( argv[ i ], "listener=", STRLENOF( "listener=" ) )
2648 char *url = argv[ i ] + STRLENOF( "listener=" );
2650 if ( ldap_url_parse( url, &lud ) ) {
2651 rc = LDAP_INVALID_SYNTAX;
2655 *l = config_check_my_url( url, lud );
2657 rc = LDAP_NO_SUCH_ATTRIBUTE;
2665 if ( strncasecmp( ptr, "read=", STRLENOF( "read=" ) ) == 0 ) {
2666 *rw |= SLAP_TCP_RMEM;
2667 ptr += STRLENOF( "read=" );
2669 } else if ( strncasecmp( ptr, "write=", STRLENOF( "write=" ) ) == 0 ) {
2670 *rw |= SLAP_TCP_WMEM;
2671 ptr += STRLENOF( "write=" );
2674 *rw |= ( SLAP_TCP_RMEM | SLAP_TCP_WMEM );
2677 /* accept any base */
2678 if ( lutil_atoix( size, ptr, 0 ) ) {
2679 rc = LDAP_INVALID_SYNTAX;
2684 if ( val != NULL && argv != NULL ) {
2685 ldap_charray_free( argv );
2688 if ( lud != NULL ) {
2689 ldap_free_urldesc( lud );
2696 tcp_buffer_delete_one( struct berval *val )
2699 int size = -1, rw = 0;
2702 rc = tcp_buffer_parse( val, 0, NULL, &size, &rw, &l );
2709 Listener **ll = slapd_get_listeners();
2711 for ( i = 0; ll[ i ] != NULL; i++ ) {
2712 if ( ll[ i ] == l ) break;
2715 if ( ll[ i ] == NULL ) {
2716 return LDAP_NO_SUCH_ATTRIBUTE;
2719 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = -1;
2720 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = -1;
2722 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2723 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = -1;
2724 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = -1;
2728 /* NOTE: this affects listeners without a specific setting,
2729 * does not reset all listeners. If a listener without
2730 * specific settings was assigned a buffer because of
2731 * a global setting, it will not be reset. In any case,
2732 * buffer changes will only take place at restart. */
2733 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = -1;
2734 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = -1;
2741 tcp_buffer_delete( BerVarray vals )
2745 for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ ) {
2746 tcp_buffer_delete_one( &vals[ i ] );
2753 tcp_buffer_unparse( int size, int rw, Listener *l, struct berval *val )
2755 char buf[sizeof("2147483648")], *ptr;
2757 /* unparse for later use */
2758 val->bv_len = snprintf( buf, sizeof( buf ), "%d", size );
2760 val->bv_len += STRLENOF( "listener=" " " ) + l->sl_url.bv_len;
2763 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2764 if ( rw & SLAP_TCP_RMEM ) {
2765 val->bv_len += STRLENOF( "read=" );
2766 } else if ( rw & SLAP_TCP_WMEM ) {
2767 val->bv_len += STRLENOF( "write=" );
2771 val->bv_val = SLAP_MALLOC( val->bv_len + 1 );
2776 ptr = lutil_strcopy( ptr, "listener=" );
2777 ptr = lutil_strncopy( ptr, l->sl_url.bv_val, l->sl_url.bv_len );
2781 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2782 if ( rw & SLAP_TCP_RMEM ) {
2783 ptr = lutil_strcopy( ptr, "read=" );
2784 } else if ( rw & SLAP_TCP_WMEM ) {
2785 ptr = lutil_strcopy( ptr, "write=" );
2789 ptr = lutil_strcopy( ptr, buf );
2792 assert( val->bv_val + val->bv_len == ptr );
2794 return LDAP_SUCCESS;
2798 tcp_buffer_add_one( int argc, char **argv )
2801 int size = -1, rw = 0;
2807 rc = tcp_buffer_parse( NULL, argc, argv, &size, &rw, &l );
2812 /* unparse for later use */
2813 rc = tcp_buffer_unparse( size, rw, l, &val );
2814 if ( rc != LDAP_SUCCESS ) {
2818 /* use parsed values */
2821 Listener **ll = slapd_get_listeners();
2823 for ( i = 0; ll[ i ] != NULL; i++ ) {
2824 if ( ll[ i ] == l ) break;
2827 if ( ll[ i ] == NULL ) {
2828 return LDAP_NO_SUCH_ATTRIBUTE;
2831 /* buffer only applies to TCP listeners;
2832 * we do not do any check here, and delegate them
2833 * to setsockopt(2) */
2834 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = size;
2835 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = size;
2837 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2838 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = size;
2839 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = size;
2843 /* NOTE: this affects listeners without a specific setting,
2844 * does not set all listeners */
2845 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = size;
2846 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = size;
2849 tcp_buffer = SLAP_REALLOC( tcp_buffer, sizeof( struct berval ) * ( tcp_buffer_num + 2 ) );
2851 tcp_buffer[ tcp_buffer_num ] = val;
2854 BER_BVZERO( &tcp_buffer[ tcp_buffer_num ] );
2860 config_tcp_buffer( ConfigArgs *c )
2862 if ( c->op == SLAP_CONFIG_EMIT ) {
2863 if ( tcp_buffer == NULL || BER_BVISNULL( &tcp_buffer[ 0 ] ) ) {
2866 value_add( &c->rvalue_vals, tcp_buffer );
2867 value_add( &c->rvalue_nvals, tcp_buffer );
2869 } else if ( c->op == LDAP_MOD_DELETE ) {
2871 tcp_buffer_delete( tcp_buffer );
2872 ber_bvarray_free( tcp_buffer );
2878 int size = -1, rw = 0;
2881 struct berval val = BER_BVNULL;
2885 if ( tcp_buffer_num == 0 ) {
2890 rc = tcp_buffer_parse( NULL, c->argc - 1, &c->argv[ 1 ], &size, &rw, &l );
2895 /* unparse for later use */
2896 rc = tcp_buffer_unparse( size, rw, l, &val );
2897 if ( rc != LDAP_SUCCESS ) {
2901 for ( i = 0; !BER_BVISNULL( &tcp_buffer[ i ] ); i++ ) {
2902 if ( bvmatch( &tcp_buffer[ i ], &val ) ) {
2907 if ( BER_BVISNULL( &tcp_buffer[ i ] ) ) {
2913 tcp_buffer_delete_one( &tcp_buffer[ i ] );
2914 ber_memfree( tcp_buffer[ i ].bv_val );
2915 for ( ; i < tcp_buffer_num; i++ ) {
2916 tcp_buffer[ i ] = tcp_buffer[ i + 1 ];
2921 if ( !BER_BVISNULL( &val ) ) {
2922 SLAP_FREE( val.bv_val );
2930 rc = tcp_buffer_add_one( c->argc - 1, &c->argv[ 1 ] );
2932 snprintf( c->cr_msg, sizeof( c->cr_msg ),
2933 "<%s> unable to add value #%d",
2934 c->argv[0], tcp_buffer_num );
2935 Debug( LDAP_DEBUG_ANY, "%s: %s\n",
2936 c->log, c->cr_msg, 0 );
2943 #endif /* LDAP_TCP_BUFFER */
2946 config_suffix(ConfigArgs *c)
2949 struct berval pdn, ndn;
2950 char *notallowed = NULL;
2952 if ( c->be == frontendDB ) {
2953 notallowed = "frontend";
2955 } else if ( SLAP_MONITOR(c->be) ) {
2956 notallowed = "monitor";
2958 } else if ( SLAP_CONFIG(c->be) ) {
2959 notallowed = "config";
2962 if ( notallowed != NULL ) {
2963 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2967 case LDAP_MOD_DELETE:
2968 case LDAP_MOD_REPLACE:
2969 case LDAP_MOD_INCREMENT:
2970 case SLAP_CONFIG_ADD:
2971 if ( !BER_BVISNULL( &c->value_dn ) ) {
2972 snprintf( buf, sizeof( buf ), "<%s> ",
2973 c->value_dn.bv_val );
2976 Debug(LDAP_DEBUG_ANY,
2977 "%s: suffix %snot allowed in %s database.\n",
2978 c->log, buf, notallowed );
2981 case SLAP_CONFIG_EMIT:
2982 /* don't complain when emitting... */
2986 /* FIXME: don't know what values may be valid;
2987 * please remove assertion, or add legal values
2988 * to either block */
2996 if (c->op == SLAP_CONFIG_EMIT) {
2997 if ( c->be->be_suffix == NULL
2998 || BER_BVISNULL( &c->be->be_suffix[0] ) )
3002 value_add( &c->rvalue_vals, c->be->be_suffix );
3003 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
3006 } else if ( c->op == LDAP_MOD_DELETE ) {
3007 if ( c->valx < 0 ) {
3008 ber_bvarray_free( c->be->be_suffix );
3009 ber_bvarray_free( c->be->be_nsuffix );
3010 c->be->be_suffix = NULL;
3011 c->be->be_nsuffix = NULL;
3014 ch_free( c->be->be_suffix[i].bv_val );
3015 ch_free( c->be->be_nsuffix[i].bv_val );
3017 c->be->be_suffix[i] = c->be->be_suffix[i+1];
3018 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
3020 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
3025 #ifdef SLAPD_MONITOR_DN
3026 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
3027 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> DN is reserved for monitoring slapd",
3029 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3030 c->log, c->cr_msg, SLAPD_MONITOR_DN);
3035 if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
3036 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
3037 c->argv[0], c->be->bd_info->bi_type );
3038 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3039 c->log, c->cr_msg, 0);
3046 if (SLAP_DBHIDDEN( c->be ))
3049 tbe = select_backend(&ndn, 0);
3051 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
3057 BackendDB *b2 = tbe;
3059 /* Does tbe precede be? */
3060 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
3063 char *type = tbe->bd_info->bi_type;
3065 if ( overlay_is_over( tbe ) ) {
3066 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
3067 type = oi->oi_orig->bi_type;
3070 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> namingContext \"%s\" "
3071 "already served by a preceding %s database",
3072 c->argv[0], pdn.bv_val, type );
3073 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
3074 c->log, c->cr_msg, tbe->be_suffix[0].bv_val);
3080 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
3081 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
3082 "base provided \"%s\" (assuming okay)\n",
3083 c->log, default_search_base.bv_val, 0);
3085 ber_bvarray_add(&c->be->be_suffix, &pdn);
3086 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
3091 config_rootdn(ConfigArgs *c) {
3092 if (c->op == SLAP_CONFIG_EMIT) {
3093 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3094 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
3095 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
3100 } else if ( c->op == LDAP_MOD_DELETE ) {
3101 ch_free( c->be->be_rootdn.bv_val );
3102 ch_free( c->be->be_rootndn.bv_val );
3103 BER_BVZERO( &c->be->be_rootdn );
3104 BER_BVZERO( &c->be->be_rootndn );
3107 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3108 ch_free( c->be->be_rootdn.bv_val );
3109 ch_free( c->be->be_rootndn.bv_val );
3111 c->be->be_rootdn = c->value_dn;
3112 c->be->be_rootndn = c->value_ndn;
3117 config_rootpw(ConfigArgs *c) {
3120 if (c->op == SLAP_CONFIG_EMIT) {
3121 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
3122 /* don't copy, because "rootpw" is marked
3124 c->value_bv = c->be->be_rootpw;
3128 } else if ( c->op == LDAP_MOD_DELETE ) {
3129 ch_free( c->be->be_rootpw.bv_val );
3130 BER_BVZERO( &c->be->be_rootpw );
3134 tbe = select_backend(&c->be->be_rootndn, 0);
3136 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> can only be set when rootdn is under suffix",
3138 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3139 c->log, c->cr_msg, 0);
3142 if ( !BER_BVISNULL( &c->be->be_rootpw ))
3143 ch_free( c->be->be_rootpw.bv_val );
3144 c->be->be_rootpw = c->value_bv;
3149 config_restrict(ConfigArgs *c) {
3150 slap_mask_t restrictops = 0;
3152 slap_verbmasks restrictable_ops[] = {
3153 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
3154 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
3155 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
3156 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
3157 { BER_BVC("modrdn"), 0 },
3158 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
3159 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
3160 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
3161 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
3162 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
3163 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
3164 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
3165 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
3166 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
3167 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
3168 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
3172 if (c->op == SLAP_CONFIG_EMIT) {
3173 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
3175 } else if ( c->op == LDAP_MOD_DELETE ) {
3177 c->be->be_restrictops = 0;
3179 restrictops = verb_to_mask( c->line, restrictable_ops );
3180 c->be->be_restrictops ^= restrictops;
3184 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
3186 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown operation", c->argv[0] );
3187 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3188 c->log, c->cr_msg, c->argv[i]);
3191 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
3192 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
3193 c->be->be_restrictops |= restrictops;
3198 config_allows(ConfigArgs *c) {
3199 slap_mask_t allows = 0;
3201 slap_verbmasks allowable_ops[] = {
3202 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
3203 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
3204 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
3205 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
3206 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
3209 if (c->op == SLAP_CONFIG_EMIT) {
3210 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
3211 } else if ( c->op == LDAP_MOD_DELETE ) {
3215 allows = verb_to_mask( c->line, allowable_ops );
3216 global_allows ^= allows;
3220 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
3222 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3223 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3224 c->log, c->cr_msg, c->argv[i]);
3227 global_allows |= allows;
3232 config_disallows(ConfigArgs *c) {
3233 slap_mask_t disallows = 0;
3235 slap_verbmasks disallowable_ops[] = {
3236 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
3237 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
3238 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
3239 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
3240 { BER_BVC("proxy_authz_non_critical"), SLAP_DISALLOW_PROXY_AUTHZ_N_CRIT },
3241 { BER_BVC("dontusecopy_non_critical"), SLAP_DISALLOW_DONTUSECOPY_N_CRIT },
3244 if (c->op == SLAP_CONFIG_EMIT) {
3245 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
3246 } else if ( c->op == LDAP_MOD_DELETE ) {
3248 global_disallows = 0;
3250 disallows = verb_to_mask( c->line, disallowable_ops );
3251 global_disallows ^= disallows;
3255 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
3257 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3258 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3259 c->log, c->cr_msg, c->argv[i]);
3262 global_disallows |= disallows;
3267 config_requires(ConfigArgs *c) {
3268 slap_mask_t requires = frontendDB->be_requires;
3269 int i, argc = c->argc;
3270 char **argv = c->argv;
3272 slap_verbmasks requires_ops[] = {
3273 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
3274 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
3275 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
3276 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
3277 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
3280 if (c->op == SLAP_CONFIG_EMIT) {
3281 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
3282 } else if ( c->op == LDAP_MOD_DELETE ) {
3284 c->be->be_requires = 0;
3286 requires = verb_to_mask( c->line, requires_ops );
3287 c->be->be_requires ^= requires;
3291 /* "none" can only be first, to wipe out default/global values */
3292 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
3297 i = verbs_to_mask(argc, argv, requires_ops, &requires);
3299 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
3300 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
3301 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3302 c->log, c->cr_msg, 0);
3304 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
3305 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3306 c->log, c->cr_msg, c->argv[i]);
3310 c->be->be_requires = requires;
3315 config_extra_attrs(ConfigArgs *c)
3317 assert( c->be != NULL );
3319 if ( c->op == SLAP_CONFIG_EMIT ) {
3322 if ( c->be->be_extra_anlist == NULL ) {
3326 for ( i = 0; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3327 value_add_one( &c->rvalue_vals, &c->be->be_extra_anlist[i].an_name );
3330 } else if ( c->op == LDAP_MOD_DELETE ) {
3331 if ( c->be->be_extra_anlist == NULL ) {
3335 if ( c->valx < 0 ) {
3336 anlist_free( c->be->be_extra_anlist, 1, NULL );
3337 c->be->be_extra_anlist = NULL;
3342 for ( i = 0; i < c->valx && !BER_BVISNULL( &c->be->be_extra_anlist[i + 1].an_name ); i++ )
3345 if ( BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ) ) {
3349 ch_free( c->be->be_extra_anlist[i].an_name.bv_val );
3351 for ( ; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3352 c->be->be_extra_anlist[i] = c->be->be_extra_anlist[i + 1];
3357 c->be->be_extra_anlist = str2anlist( c->be->be_extra_anlist, c->argv[1], " ,\t" );
3358 if ( c->be->be_extra_anlist == NULL ) {
3366 static slap_verbmasks *loglevel_ops;
3369 loglevel_init( void )
3371 slap_verbmasks lo[] = {
3372 { BER_BVC("Any"), (slap_mask_t) LDAP_DEBUG_ANY },
3373 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
3374 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
3375 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
3376 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
3377 { BER_BVC("BER"), LDAP_DEBUG_BER },
3378 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
3379 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
3380 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
3381 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
3382 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
3383 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
3384 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
3385 #if 0 /* no longer used (nor supported) */
3386 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
3387 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
3389 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
3390 { BER_BVC("None"), LDAP_DEBUG_NONE },
3394 return slap_verbmasks_init( &loglevel_ops, lo );
3398 loglevel_destroy( void )
3400 if ( loglevel_ops ) {
3401 (void)slap_verbmasks_destroy( loglevel_ops );
3403 loglevel_ops = NULL;
3406 static slap_mask_t loglevel_ignore[] = { -1, 0 };
3409 slap_loglevel_register( slap_mask_t m, struct berval *s )
3413 if ( loglevel_ops == NULL ) {
3417 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
3420 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
3428 slap_loglevel_get( struct berval *s, int *l )
3433 if ( loglevel_ops == NULL ) {
3437 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3438 m |= loglevel_ops[ i ].mask;
3441 for ( i = 1; m & i; i <<= 1 )
3448 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
3451 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
3462 str2loglevel( const char *s, int *l )
3466 if ( loglevel_ops == NULL ) {
3470 i = verb_to_mask( s, loglevel_ops );
3472 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
3476 *l = loglevel_ops[ i ].mask;
3482 loglevel2str( int l )
3484 struct berval bv = BER_BVNULL;
3486 loglevel2bv( l, &bv );
3492 loglevel2bv( int l, struct berval *bv )
3494 if ( loglevel_ops == NULL ) {
3500 return enum_to_verb( loglevel_ops, l, bv ) == -1;
3504 loglevel2bvarray( int l, BerVarray *bva )
3506 if ( loglevel_ops == NULL ) {
3510 return mask_to_verbs( loglevel_ops, l, bva );
3514 loglevel_print( FILE *out )
3518 if ( loglevel_ops == NULL ) {
3522 fprintf( out, "Installed log subsystems:\n\n" );
3523 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3524 unsigned mask = loglevel_ops[ i ].mask & 0xffffffffUL;
3526 (mask == ((slap_mask_t) -1 & 0xffffffffUL)
3527 ? "\t%-30s (-1, 0xffffffff)\n" : "\t%-30s (%u, 0x%x)\n"),
3528 loglevel_ops[ i ].word.bv_val, mask, mask );
3531 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
3532 "by specific code\n\n" );
3537 static int config_syslog;
3540 config_loglevel(ConfigArgs *c) {
3543 if ( loglevel_ops == NULL ) {
3547 if (c->op == SLAP_CONFIG_EMIT) {
3548 /* Get default or commandline slapd setting */
3549 if ( ldap_syslog && !config_syslog )
3550 config_syslog = ldap_syslog;
3551 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
3553 } else if ( c->op == LDAP_MOD_DELETE ) {
3557 int level = verb_to_mask( c->line, loglevel_ops );
3558 config_syslog ^= level;
3560 if ( slapMode & SLAP_SERVER_MODE ) {
3561 ldap_syslog = config_syslog;
3566 for( i=1; i < c->argc; i++ ) {
3569 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
3570 if( lutil_atoix( &level, c->argv[i], 0 ) != 0 ) {
3571 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
3572 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3573 c->log, c->cr_msg, c->argv[i]);
3577 if ( str2loglevel( c->argv[i], &level ) ) {
3578 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown level", c->argv[0] );
3579 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3580 c->log, c->cr_msg, c->argv[i]);
3584 /* Explicitly setting a zero clears all the levels */
3586 config_syslog |= level;
3590 if ( slapMode & SLAP_SERVER_MODE ) {
3591 ldap_syslog = config_syslog;
3597 config_referral(ConfigArgs *c) {
3599 if (c->op == SLAP_CONFIG_EMIT) {
3600 if ( default_referral ) {
3601 value_add( &c->rvalue_vals, default_referral );
3606 } else if ( c->op == LDAP_MOD_DELETE ) {
3607 if ( c->valx < 0 ) {
3608 ber_bvarray_free( default_referral );
3609 default_referral = NULL;
3612 ch_free( default_referral[i].bv_val );
3613 for (; default_referral[i].bv_val; i++ )
3614 default_referral[i] = default_referral[i+1];
3618 if(validate_global_referral(c->argv[1])) {
3619 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3620 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3621 c->log, c->cr_msg, c->argv[1]);
3625 ber_str2bv(c->argv[1], 0, 0, &val);
3626 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
3634 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
3635 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
3636 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
3637 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
3638 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
3639 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
3640 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
3641 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
3642 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
3647 config_security(ConfigArgs *c) {
3648 slap_ssf_set_t *set = &c->be->be_ssf_set;
3651 if (c->op == SLAP_CONFIG_EMIT) {
3657 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
3658 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
3661 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
3662 if ( bv.bv_len >= sizeof( numbuf ) ) {
3663 ber_bvarray_free_x( c->rvalue_vals, NULL );
3664 c->rvalue_vals = NULL;
3668 bv.bv_len += sec_keys[i].key.bv_len;
3669 bv.bv_val = ch_malloc( bv.bv_len + 1);
3670 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
3671 strcpy( next, numbuf );
3672 ber_bvarray_add( &c->rvalue_vals, &bv );
3677 for(i = 1; i < c->argc; i++) {
3678 slap_ssf_t *tgt = NULL;
3680 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
3681 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
3682 sec_keys[j].key.bv_len)) {
3683 src = c->argv[i] + sec_keys[j].key.bv_len;
3684 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
3689 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown factor", c->argv[0] );
3690 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3691 c->log, c->cr_msg, c->argv[i]);
3695 if ( lutil_atou( tgt, src ) != 0 ) {
3696 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse factor", c->argv[0] );
3697 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3698 c->log, c->cr_msg, c->argv[i]);
3706 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
3710 for (; !BER_BVISNULL( &an->an_name ); an++) {
3711 /* if buflen == 0, assume the buffer size has been
3712 * already checked otherwise */
3713 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
3714 if ( comma ) *ptr++ = ',';
3715 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
3722 config_updatedn(ConfigArgs *c) {
3723 if (c->op == SLAP_CONFIG_EMIT) {
3724 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
3725 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
3726 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
3730 } else if ( c->op == LDAP_MOD_DELETE ) {
3731 ch_free( c->be->be_update_ndn.bv_val );
3732 BER_BVZERO( &c->be->be_update_ndn );
3733 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
3736 if(SLAP_SHADOW(c->be)) {
3737 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database already shadowed", c->argv[0] );
3738 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3739 c->log, c->cr_msg, 0);
3743 ber_memfree_x( c->value_dn.bv_val, NULL );
3744 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
3745 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
3747 c->be->be_update_ndn = c->value_ndn;
3748 BER_BVZERO( &c->value_dn );
3749 BER_BVZERO( &c->value_ndn );
3751 return config_slurp_shadow( c );
3755 config_shadow( ConfigArgs *c, slap_mask_t flag )
3757 char *notallowed = NULL;
3759 if ( c->be == frontendDB ) {
3760 notallowed = "frontend";
3762 } else if ( SLAP_MONITOR(c->be) ) {
3763 notallowed = "monitor";
3766 if ( notallowed != NULL ) {
3767 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
3771 if ( SLAP_SHADOW(c->be) ) {
3772 /* if already shadow, only check consistency */
3773 if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
3774 Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%lx.\n",
3780 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
3787 config_updateref(ConfigArgs *c) {
3789 if (c->op == SLAP_CONFIG_EMIT) {
3790 if ( c->be->be_update_refs ) {
3791 value_add( &c->rvalue_vals, c->be->be_update_refs );
3796 } else if ( c->op == LDAP_MOD_DELETE ) {
3797 if ( c->valx < 0 ) {
3798 ber_bvarray_free( c->be->be_update_refs );
3799 c->be->be_update_refs = NULL;
3802 ch_free( c->be->be_update_refs[i].bv_val );
3803 for (; c->be->be_update_refs[i].bv_val; i++)
3804 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
3808 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
3809 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> must appear after syncrepl or updatedn",
3811 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3812 c->log, c->cr_msg, 0);
3816 if(validate_global_referral(c->argv[1])) {
3817 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3818 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3819 c->log, c->cr_msg, c->argv[1]);
3822 ber_str2bv(c->argv[1], 0, 0, &val);
3823 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
3828 config_obsolete(ConfigArgs *c) {
3829 if (c->op == SLAP_CONFIG_EMIT)
3832 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> keyword is obsolete (ignored)",
3834 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0);
3839 config_include(ConfigArgs *c) {
3840 int savelineno = c->lineno;
3843 ConfigFile *cfsave = cfn;
3844 ConfigFile *cf2 = NULL;
3846 /* Leftover from RE23. No dynamic config for include files */
3847 if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
3850 cf = ch_calloc( 1, sizeof(ConfigFile));
3851 if ( cfn->c_kids ) {
3852 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
3858 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
3859 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
3860 c->lineno = savelineno - 1;
3863 if ( cf2 ) cf2->c_sibs = NULL;
3864 else cfn->c_kids = NULL;
3865 ch_free( cf->c_file.bv_val );
3875 config_tls_cleanup(ConfigArgs *c) {
3878 if ( slap_tls_ld ) {
3881 ldap_pvt_tls_ctx_free( slap_tls_ctx );
3883 /* Force new ctx to be created */
3884 rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
3886 /* The ctx's refcount is bumped up here */
3887 ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
3888 /* This is a no-op if it's already loaded */
3889 load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
3896 config_tls_option(ConfigArgs *c) {
3898 LDAP *ld = slap_tls_ld;
3900 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
3901 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
3902 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
3903 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
3904 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
3905 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
3906 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
3908 case CFG_TLS_CRL_FILE: flag = LDAP_OPT_X_TLS_CRLFILE; break;
3910 default: Debug(LDAP_DEBUG_ANY, "%s: "
3911 "unknown tls_option <0x%x>\n",
3912 c->log, c->type, 0);
3915 if (c->op == SLAP_CONFIG_EMIT) {
3916 return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3917 } else if ( c->op == LDAP_MOD_DELETE ) {
3918 c->cleanup = config_tls_cleanup;
3919 return ldap_pvt_tls_set_option( ld, flag, NULL );
3921 ch_free(c->value_string);
3922 c->cleanup = config_tls_cleanup;
3923 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3926 /* FIXME: this ought to be provided by libldap */
3928 config_tls_config(ConfigArgs *c) {
3931 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
3932 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
3933 case CFG_TLS_PROTOCOL_MIN: flag = LDAP_OPT_X_TLS_PROTOCOL_MIN; break;
3935 Debug(LDAP_DEBUG_ANY, "%s: "
3936 "unknown tls_option <0x%x>\n",
3937 c->log, c->type, 0);
3940 if (c->op == SLAP_CONFIG_EMIT) {
3941 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3942 } else if ( c->op == LDAP_MOD_DELETE ) {
3944 c->cleanup = config_tls_cleanup;
3945 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3947 ch_free( c->value_string );
3948 c->cleanup = config_tls_cleanup;
3949 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3950 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3951 Debug(LDAP_DEBUG_ANY, "%s: "
3952 "unable to parse %s \"%s\"\n",
3953 c->log, c->argv[0], c->argv[1] );
3956 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
3958 return(ldap_pvt_tls_config(slap_tls_ld, flag, c->argv[1]));
3963 static CfEntryInfo *
3964 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
3974 if ( dn_match( &root->ce_entry->e_nname, dn ))
3977 c = dn->bv_val+dn->bv_len;
3978 for (;*c != ',';c--);
3982 for (--c;c>dn->bv_val && *c != ',';c--);
3986 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
3988 root = root->ce_kids;
3990 for (;root;root=root->ce_sibs) {
3991 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
3992 if ( cdn.bv_val == dn->bv_val ) {
4002 typedef struct setup_cookie {
4012 config_ldif_resp( Operation *op, SlapReply *rs )
4014 if ( rs->sr_type == REP_SEARCH ) {
4015 setup_cookie *sc = op->o_callback->sc_private;
4018 sc->cfb->cb_got_ldif = 1;
4019 /* Does the frontend exist? */
4020 if ( !sc->got_frontend ) {
4021 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
4022 "olcDatabase", STRLENOF( "olcDatabase" )))
4024 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4025 STRLENOF( "olcDatabase" ), "={-1}frontend",
4026 STRLENOF( "={-1}frontend" )))
4030 sc->ca->be = frontendDB;
4031 sc->ca->bi = frontendDB->bd_info;
4032 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
4033 rdn.bv_val = sc->ca->log;
4034 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4035 "%s=" SLAP_X_ORDERED_FMT "%s",
4036 cfAd_database->ad_cname.bv_val, -1,
4037 sc->ca->bi->bi_type);
4039 sc->frontend = config_build_entry( op, rs,
4040 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
4041 sc->ca->be->be_cf_ocs );
4051 dnParent( &rs->sr_entry->e_nname, &pdn );
4053 /* Does the configDB exist? */
4054 if ( sc->got_frontend && !sc->got_config &&
4055 !strncmp( rs->sr_entry->e_nname.bv_val,
4056 "olcDatabase", STRLENOF( "olcDatabase" )) &&
4057 dn_match( &config_rdn, &pdn ) )
4059 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4060 STRLENOF( "olcDatabase" ), "={0}config",
4061 STRLENOF( "={0}config" )))
4065 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
4066 sc->ca->bi = sc->ca->be->bd_info;
4067 rdn.bv_val = sc->ca->log;
4068 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4069 "%s=" SLAP_X_ORDERED_FMT "%s",
4070 cfAd_database->ad_cname.bv_val, 0,
4071 sc->ca->bi->bi_type);
4073 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
4074 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
4081 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
4082 if ( rs->sr_err != LDAP_SUCCESS ) {
4083 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
4084 rs->sr_entry->e_name.bv_val, sc->ca->cr_msg, 0 );
4090 /* Configure and read the underlying back-ldif store */
4092 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
4093 CfBackInfo *cfb = be->be_private;
4099 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
4100 Connection conn = {0};
4101 OperationBuffer opbuf;
4103 SlapReply rs = {REP_RESULT};
4104 Filter filter = { LDAP_FILTER_PRESENT };
4105 struct berval filterstr = BER_BVC("(objectclass=*)");
4108 /* Is the config directory available? */
4109 if ( stat( dir, &st ) < 0 ) {
4110 /* No, so don't bother using the backing store.
4111 * All changes will be in-memory only.
4116 cfb->cb_db.bd_info = backend_info( "ldif" );
4117 if ( !cfb->cb_db.bd_info )
4118 return 0; /* FIXME: eventually this will be a fatal error */
4120 if ( backend_db_init( "ldif", &cfb->cb_db, -1, NULL ) == NULL )
4123 cfb->cb_db.be_suffix = be->be_suffix;
4124 cfb->cb_db.be_nsuffix = be->be_nsuffix;
4126 /* The suffix is always "cn=config". The underlying DB's rootdn
4127 * is always the same as the suffix.
4129 cfb->cb_db.be_rootdn = be->be_suffix[0];
4130 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
4132 ber_str2bv( dir, 0, 1, &cfdir );
4137 argv[0] = "directory";
4138 argv[1] = (char *)dir;
4143 c.table = Cft_Database;
4145 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
4149 if ( config_add_vals( ct, &c ))
4152 if ( backend_startup_one( &cfb->cb_db, &c.reply ))
4156 void *thrctx = ldap_pvt_thread_pool_context();
4159 connection_fake_init( &conn, &opbuf, thrctx );
4162 filter.f_desc = slap_schema.si_ad_objectClass;
4164 op->o_tag = LDAP_REQ_SEARCH;
4166 op->ors_filter = &filter;
4167 op->ors_filterstr = filterstr;
4168 op->ors_scope = LDAP_SCOPE_SUBTREE;
4170 op->o_dn = c.be->be_rootdn;
4171 op->o_ndn = c.be->be_rootndn;
4173 op->o_req_dn = be->be_suffix[0];
4174 op->o_req_ndn = be->be_nsuffix[0];
4176 op->ors_tlimit = SLAP_NO_LIMIT;
4177 op->ors_slimit = SLAP_NO_LIMIT;
4179 op->ors_attrs = slap_anlist_all_attributes;
4180 op->ors_attrsonly = 0;
4182 op->o_callback = &cb;
4185 cb.sc_private = ≻
4186 sc.got_frontend = 0;
4191 op->o_bd = &cfb->cb_db;
4193 /* Allow unknown attrs in DNs */
4194 prev_DN_strict = slap_DN_strict;
4197 rc = op->o_bd->be_search( op, &rs );
4199 /* Restore normal DN validation */
4200 slap_DN_strict = prev_DN_strict;
4202 op->o_tag = LDAP_REQ_ADD;
4203 if ( rc == LDAP_SUCCESS && sc.frontend ) {
4204 rs_reinit( &rs, REP_RESULT );
4205 op->ora_e = sc.frontend;
4206 rc = op->o_bd->be_add( op, &rs );
4208 if ( rc == LDAP_SUCCESS && sc.config ) {
4209 rs_reinit( &rs, REP_RESULT );
4210 op->ora_e = sc.config;
4211 rc = op->o_bd->be_add( op, &rs );
4213 ldap_pvt_thread_pool_context_reset( thrctx );
4216 /* ITS#4194 - only use if it's present, or we're converting. */
4217 if ( !readit || rc == LDAP_SUCCESS )
4218 cfb->cb_use_ldif = 1;
4224 CfOc_cmp( const void *c1, const void *c2 ) {
4225 const ConfigOCs *co1 = c1;
4226 const ConfigOCs *co2 = c2;
4228 return ber_bvcmp( co1->co_name, co2->co_name );
4232 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
4235 i = init_config_attrs( ct );
4238 /* set up the objectclasses */
4239 i = init_config_ocs( ocs );
4242 for (i=0; ocs[i].co_def; i++) {
4243 if ( ocs[i].co_oc ) {
4244 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
4245 if ( !ocs[i].co_table )
4246 ocs[i].co_table = ct;
4247 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
4254 read_config(const char *fname, const char *dir) {
4257 const char *cfdir, *cfname;
4260 /* Setup the config backend */
4261 be = backend_db_init( "config", NULL, 0, NULL );
4265 cfb = be->be_private;
4266 be->be_dfltaccess = ACL_NONE;
4268 /* If no .conf, or a dir was specified, setup the dir */
4269 if ( !fname || dir ) {
4271 /* If explicitly given, check for existence */
4274 if ( stat( dir, &st ) < 0 ) {
4275 Debug( LDAP_DEBUG_ANY,
4276 "invalid config directory %s, error %d\n",
4282 cfdir = SLAPD_DEFAULT_CONFIGDIR;
4284 /* if fname is defaulted, try reading .d */
4285 rc = config_setup_ldif( be, cfdir, !fname );
4288 /* It may be OK if the base object doesn't exist yet. */
4289 if ( rc != LDAP_NO_SUCH_OBJECT )
4291 /* ITS#4194: But if dir was specified and no fname,
4292 * then we were supposed to read the dir. Unless we're
4293 * trying to slapadd the dir...
4295 if ( dir && !fname ) {
4296 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
4298 /* Assume it's slapadd with a config dir, let it continue */
4300 cfb->cb_got_ldif = 1;
4301 cfb->cb_use_ldif = 1;
4306 /* If we read the config from back-ldif, nothing to do here */
4307 if ( cfb->cb_got_ldif ) {
4316 cfname = SLAPD_DEFAULT_CONFIGFILE;
4318 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
4321 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
4324 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
4325 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
4326 &frontendDB->be_schemadn );
4327 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
4328 if ( rc != LDAP_SUCCESS ) {
4329 Debug(LDAP_DEBUG_ANY, "read_config: "
4330 "unable to normalize default schema DN \"%s\"\n",
4331 frontendDB->be_schemadn.bv_val, 0, 0 );
4332 /* must not happen */
4340 config_back_bind( Operation *op, SlapReply *rs )
4342 if ( be_isroot_pw( op ) ) {
4343 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
4344 /* frontend sends result */
4345 return LDAP_SUCCESS;
4348 rs->sr_err = LDAP_INVALID_CREDENTIALS;
4349 send_ldap_result( op, rs );
4355 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
4359 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
4361 rs->sr_attrs = op->ors_attrs;
4362 rs->sr_entry = ce->ce_entry;
4364 rc = send_search_entry( op, rs );
4365 if ( rc != LDAP_SUCCESS ) {
4369 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
4370 if ( ce->ce_kids ) {
4371 rc = config_send( op, rs, ce->ce_kids, 1 );
4372 if ( rc ) return rc;
4375 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
4376 rc = config_send( op, rs, ce, 0 );
4384 static ConfigTable *
4385 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
4390 for (j=0; j<nocs; j++) {
4391 for (i=0; colst[j]->co_table[i].name; i++)
4392 if ( colst[j]->co_table[i].ad == ad ) {
4393 ca->table = colst[j]->co_type;
4394 return &colst[j]->co_table[i];
4400 /* Sort the attributes of the entry according to the order defined
4401 * in the objectclass, with required attributes occurring before
4402 * allowed attributes. For any attributes with sequencing dependencies
4403 * (e.g., rootDN must be defined after suffix) the objectclass must
4404 * list the attributes in the desired sequence.
4407 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
4409 Attribute *a, *head = NULL, *tail = NULL, **prev;
4412 for (i=0; i<nocs; i++) {
4413 if ( colst[i]->co_oc->soc_required ) {
4414 AttributeType **at = colst[i]->co_oc->soc_required;
4415 for (j=0; at[j]; j++) {
4416 for (a=e->e_attrs, prev=&e->e_attrs; a;
4417 prev = &(*prev)->a_next, a=a->a_next) {
4418 if ( a->a_desc == at[j]->sat_ad ) {
4432 if ( colst[i]->co_oc->soc_allowed ) {
4433 AttributeType **at = colst[i]->co_oc->soc_allowed;
4434 for (j=0; at[j]; j++) {
4435 for (a=e->e_attrs, prev=&e->e_attrs; a;
4436 prev = &(*prev)->a_next, a=a->a_next) {
4437 if ( a->a_desc == at[j]->sat_ad ) {
4453 tail->a_next = e->e_attrs;
4459 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
4461 Attribute *a = NULL;
4462 AttributeDescription *ad;
4472 Modifications *ml = ptr;
4474 vals = ml->sml_values;
4477 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
4478 rc = ordered_value_sort( a, 1 );
4480 snprintf(ca->cr_msg, sizeof( ca->cr_msg ), "ordered_value_sort failed on attr %s\n",
4481 ad->ad_cname.bv_val );
4485 for ( i=0; vals[i].bv_val; i++ ) {
4486 ca->line = vals[i].bv_val;
4487 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
4488 ca->line[0] == '{' ) {
4489 char *idx = strchr( ca->line, '}' );
4490 if ( idx ) ca->line = idx+1;
4492 rc = config_parse_vals( ct, ca, i );
4501 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
4504 struct berval rtype, rval;
4506 AttributeDescription *ad = NULL;
4508 dnRdn( &e->e_name, rdn );
4509 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
4510 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
4511 rtype.bv_val = rdn->bv_val;
4512 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
4515 slap_bv2ad( &rtype, &ad, &rs->sr_text );
4516 a = attr_find( e->e_attrs, ad );
4517 if (!a ) return LDAP_NAMING_VIOLATION;
4524 config_rename_kids( CfEntryInfo *ce )
4527 struct berval rdn, nrdn;
4529 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
4530 struct berval newdn, newndn;
4531 dnRdn ( &ce2->ce_entry->e_name, &rdn );
4532 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
4533 build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
4534 build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
4535 free( ce2->ce_entry->e_name.bv_val );
4536 free( ce2->ce_entry->e_nname.bv_val );
4537 ce2->ce_entry->e_name = newdn;
4538 ce2->ce_entry->e_nname = newndn;
4539 config_rename_kids( ce2 );
4544 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
4545 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
4546 struct berval *nnewrdn, int use_ldif )
4550 struct berval odn, ondn;
4554 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
4555 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
4558 free( a->a_vals[0].bv_val );
4559 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
4560 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
4561 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
4562 strcpy( a->a_vals[0].bv_val, ptr1 );
4564 if ( a->a_nvals != a->a_vals ) {
4565 free( a->a_nvals[0].bv_val );
4566 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
4567 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
4568 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
4569 strcpy( a->a_nvals[0].bv_val, ptr1 );
4572 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
4573 BackendDB *be = op->o_bd;
4574 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4575 struct berval dn, ndn, xdn, xndn;
4577 op->o_bd = &cfb->cb_db;
4579 /* Save current rootdn; use the underlying DB's rootdn */
4583 xndn = op->o_req_ndn;
4584 op->o_dn = op->o_bd->be_rootdn;
4585 op->o_ndn = op->o_bd->be_rootndn;
4587 op->o_req_ndn = ondn;
4589 scp = op->o_callback;
4590 op->o_callback = ≻
4591 op->orr_newrdn = *newrdn;
4592 op->orr_nnewrdn = *nnewrdn;
4593 op->orr_newSup = NULL;
4594 op->orr_nnewSup = NULL;
4595 op->orr_deleteoldrdn = 1;
4596 op->orr_modlist = NULL;
4597 slap_modrdn2mods( op, rs );
4598 slap_mods_opattrs( op, &op->orr_modlist, 1 );
4599 rc = op->o_bd->be_modrdn( op, rs );
4600 slap_mods_free( op->orr_modlist, 1 );
4603 op->o_callback = scp;
4607 op->o_req_ndn = xndn;
4610 free( ondn.bv_val );
4612 config_rename_kids( e->e_private );
4617 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
4618 Entry *e, int idx, int tailindex, int use_ldif )
4620 struct berval ival, newrdn, nnewrdn;
4623 char ibuf[32], *ptr1, *ptr2 = NULL;
4626 rc = config_rename_attr( rs, e, &rdn, &a );
4627 if ( rc ) return rc;
4630 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
4631 if ( ival.bv_len >= sizeof( ibuf ) ) {
4632 return LDAP_NAMING_VIOLATION;
4635 newrdn.bv_len = rdn.bv_len + ival.bv_len;
4636 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
4639 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
4640 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4643 ptr2 = ber_bvchr( &rdn, '}' );
4647 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
4649 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
4650 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
4651 a->a_desc->ad_cname.bv_len );
4653 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4654 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
4658 /* Do the equivalent of ModRDN */
4659 /* Replace DN / NDN */
4660 newrdn.bv_len = ptr1 - newrdn.bv_val;
4661 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
4662 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
4664 free( nnewrdn.bv_val );
4665 free( newrdn.bv_val );
4670 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
4671 SlapReply *rs, int *renum, int *ibase )
4674 int index = -1, gotindex = 0, nsibs, rc = 0;
4675 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
4676 char *ptr1, *ptr2 = NULL;
4679 if ( renum ) *renum = 0;
4681 /* These entries don't get indexed/renumbered */
4682 if ( ce_type == Cft_Global ) return 0;
4683 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
4685 if ( ce_type == Cft_Module )
4688 /* See if the rdn has an index already */
4689 dnRdn( &e->e_name, &rdn );
4690 if ( ce_type == Cft_Database ) {
4691 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
4692 "frontend", STRLENOF("frontend") ))
4694 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
4695 "config", STRLENOF("config") ))
4698 ptr1 = ber_bvchr( &e->e_name, '{' );
4699 if ( ptr1 && ptr1 < &e->e_name.bv_val[ rdn.bv_len ] ) {
4701 ptr2 = strchr( ptr1, '}' );
4702 if ( !ptr2 || ptr2 > &e->e_name.bv_val[ rdn.bv_len ] )
4703 return LDAP_NAMING_VIOLATION;
4704 if ( ptr2-ptr1 == 1)
4705 return LDAP_NAMING_VIOLATION;
4707 index = strtol( ptr1 + 1, &next, 10 );
4708 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
4709 return LDAP_NAMING_VIOLATION;
4712 /* Special case, we allow -1 for the frontendDB */
4713 if ( index != -1 || !isfrontend )
4714 return LDAP_NAMING_VIOLATION;
4716 if ( isconfig && index != 0 ){
4717 return LDAP_NAMING_VIOLATION;
4721 /* count related kids */
4722 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
4723 if ( ce->ce_type == ce_type ) nsibs++;
4726 /* account for -1 frontend */
4727 if ( ce_type == Cft_Database )
4730 if ( index != nsibs ) {
4732 if ( index < nsibs ) {
4733 if ( tailindex ) return LDAP_NAMING_VIOLATION;
4734 /* Siblings need to be renumbered */
4735 if ( index != -1 || !isfrontend )
4739 /* config DB is always "0" */
4740 if ( isconfig && index == -1 ) {
4743 if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
4747 /* just make index = nsibs */
4749 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
4752 if ( ibase ) *ibase = index;
4753 if ( renum ) *renum = renumber;
4758 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
4763 co.co_name = &oc->soc_cname;
4764 cop = avl_find( CfOcTree, &co, CfOc_cmp );
4768 /* check for duplicates */
4769 for ( i = 0; i < *nocs; i++ ) {
4770 if ( *copp && (*copp)[i] == cop ) {
4776 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
4777 if ( tmp == NULL ) {
4781 (*copp)[*nocs] = cop;
4786 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
4787 if ( count_oc( *sups, copp, nocs ) ) {
4796 count_ocs( Attribute *oc_at, int *nocs )
4799 ConfigOCs **colst = NULL;
4803 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
4807 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
4809 assert( oc != NULL );
4810 if ( count_oc( oc, &colst, nocs ) ) {
4820 cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4822 /* Leftover from RE23. Never parse this entry */
4823 return LDAP_COMPARE_TRUE;
4827 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4831 /* This entry is hardcoded, don't re-parse it */
4832 if ( p->ce_type == Cft_Global ) {
4833 cfn = p->ce_private;
4834 ca->ca_private = cfn;
4835 return LDAP_COMPARE_TRUE;
4837 if ( p->ce_type != Cft_Schema )
4838 return LDAP_CONSTRAINT_VIOLATION;
4840 cfn = ch_calloc( 1, sizeof(ConfigFile) );
4841 ca->ca_private = cfn;
4842 cfo = p->ce_private;
4843 cfn->c_sibs = cfo->c_kids;
4845 return LDAP_SUCCESS;
4849 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4851 if ( p->ce_type != Cft_Global ) {
4852 return LDAP_CONSTRAINT_VIOLATION;
4854 /* config must be {0}, nothing else allowed */
4855 if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
4856 strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
4857 return LDAP_CONSTRAINT_VIOLATION;
4859 ca->be = frontendDB; /* just to get past check_vals */
4860 return LDAP_SUCCESS;
4864 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4866 if ( p->ce_type != Cft_Global ) {
4867 return LDAP_CONSTRAINT_VIOLATION;
4869 return LDAP_SUCCESS;
4873 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4875 if ( p->ce_type != Cft_Global ) {
4876 return LDAP_CONSTRAINT_VIOLATION;
4878 return LDAP_SUCCESS;
4882 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4884 if ( p->ce_type != Cft_Database ) {
4885 return LDAP_CONSTRAINT_VIOLATION;
4888 return LDAP_SUCCESS;
4892 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
4897 AttributeDescription *ad;
4903 if ( cfn->c_cr_head ) {
4904 struct berval bv = BER_BVC("olcDitContentRules");
4906 slap_bv2ad( &bv, &ad, &text );
4907 ct = config_find_table( colst, nocs, ad, ca );
4908 config_del_vals( ct, ca );
4910 if ( cfn->c_oc_head ) {
4911 struct berval bv = BER_BVC("olcObjectClasses");
4913 slap_bv2ad( &bv, &ad, &text );
4914 ct = config_find_table( colst, nocs, ad, ca );
4915 config_del_vals( ct, ca );
4917 if ( cfn->c_at_head ) {
4918 struct berval bv = BER_BVC("olcAttributeTypes");
4920 slap_bv2ad( &bv, &ad, &text );
4921 ct = config_find_table( colst, nocs, ad, ca );
4922 config_del_vals( ct, ca );
4924 if ( cfn->c_syn_head ) {
4925 struct berval bv = BER_BVC("olcLdapSyntaxes");
4927 slap_bv2ad( &bv, &ad, &text );
4928 ct = config_find_table( colst, nocs, ad, ca );
4929 config_del_vals( ct, ca );
4931 if ( cfn->c_om_head ) {
4932 struct berval bv = BER_BVC("olcObjectIdentifier");
4934 slap_bv2ad( &bv, &ad, &text );
4935 ct = config_find_table( colst, nocs, ad, ca );
4936 config_del_vals( ct, ca );
4938 cfo = p->ce_private;
4939 cfo->c_kids = cfn->c_sibs;
4944 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
4946 int rc = LDAP_CONSTRAINT_VIOLATION;
4949 if ( (*cop)->co_ldadd ) {
4950 rc = (*cop)->co_ldadd( last, e, ca );
4951 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4956 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
4957 ConfigOCs co = { 0 };
4959 co.co_name = &(*ocp)->soc_cname;
4960 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
4961 if ( *cop == NULL ) {
4965 rc = config_add_oc( cop, last, e, ca );
4966 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4974 /* Parse an LDAP entry into config directives */
4976 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
4977 int *renum, Operation *op )
4979 CfEntryInfo *ce, *last = NULL;
4980 ConfigOCs co, *coptr, **colst;
4981 Attribute *a, *oc_at, *soc_at;
4982 int i, ibase = -1, nocs, rc = 0;
4985 char *ptr, *log_prefix = op ? op->o_log_prefix : "";
4987 memset( ca, 0, sizeof(ConfigArgs));
4989 /* Make sure parent exists and entry does not. But allow
4990 * Databases and Overlays to be inserted. Don't do any
4991 * auto-renumbering if manageDSAit control is present.
4993 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
4995 if ( ( op && op->o_managedsait ) ||
4996 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
4997 ce->ce_type != Cft_Module ) )
4999 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5000 "DN=\"%s\" already exists\n",
5001 log_prefix, e->e_name.bv_val, 0 );
5002 /* global schema ignores all writes */
5003 if ( ce->ce_type == Cft_Schema && ce->ce_parent->ce_type == Cft_Global )
5004 return LDAP_COMPARE_TRUE;
5005 return LDAP_ALREADY_EXISTS;
5009 dnParent( &e->e_nname, &pdn );
5011 /* If last is NULL, the new entry is the root/suffix entry,
5012 * otherwise last should be the parent.
5014 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
5016 rs->sr_matched = last->ce_entry->e_name.bv_val;
5018 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5019 "DN=\"%s\" not child of DN=\"%s\"\n",
5020 log_prefix, e->e_name.bv_val,
5021 last->ce_entry->e_name.bv_val );
5022 return LDAP_NO_SUCH_OBJECT;
5026 /* No parent, must be root. This will never happen... */
5027 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
5028 return LDAP_NO_SUCH_OBJECT;
5031 if ( last && !access_allowed( op, last->ce_entry,
5032 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
5034 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5035 "DN=\"%s\" no write access to \"children\" of parent\n",
5036 log_prefix, e->e_name.bv_val, 0 );
5037 return LDAP_INSUFFICIENT_ACCESS;
5041 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5043 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5044 "DN=\"%s\" no objectClass\n",
5045 log_prefix, e->e_name.bv_val, 0 );
5046 return LDAP_OBJECT_CLASS_VIOLATION;
5049 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5051 ObjectClass *soc = NULL;
5052 char textbuf[ SLAP_TEXT_BUFLEN ];
5053 const char *text = textbuf;
5055 /* FIXME: check result */
5056 rc = structural_class( oc_at->a_nvals, &soc, NULL,
5057 &text, textbuf, sizeof(textbuf), NULL );
5058 if ( rc != LDAP_SUCCESS ) {
5059 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5060 "DN=\"%s\" no structural objectClass (%s)\n",
5061 log_prefix, e->e_name.bv_val, text );
5064 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
5065 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5066 if ( soc_at == NULL ) {
5067 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5068 "DN=\"%s\" no structural objectClass; "
5069 "unable to merge computed class %s\n",
5070 log_prefix, e->e_name.bv_val,
5071 soc->soc_cname.bv_val );
5072 return LDAP_OBJECT_CLASS_VIOLATION;
5075 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5076 "DN=\"%s\" no structural objectClass; "
5077 "computed objectClass %s merged\n",
5078 log_prefix, e->e_name.bv_val,
5079 soc->soc_cname.bv_val );
5082 /* Fake the coordinates based on whether we're part of an
5083 * LDAP Add or if reading the config dir
5086 ca->fname = "slapd";
5089 ca->fname = cfdir.bv_val;
5094 co.co_name = &soc_at->a_nvals[0];
5095 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
5096 if ( coptr == NULL ) {
5097 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5098 "DN=\"%s\" no structural objectClass in configuration table\n",
5099 log_prefix, e->e_name.bv_val, 0 );
5100 return LDAP_OBJECT_CLASS_VIOLATION;
5103 /* Only the root can be Cft_Global, everything else must
5104 * have a parent. Only limited nesting arrangements are allowed.
5106 rc = LDAP_CONSTRAINT_VIOLATION;
5107 if ( coptr->co_type == Cft_Global && !last ) {
5108 cfn = cfb->cb_config;
5109 ca->ca_private = cfn;
5110 ca->be = frontendDB; /* just to get past check_vals */
5114 colst = count_ocs( oc_at, &nocs );
5116 /* Check whether the Add is allowed by its parent, and do
5117 * any necessary arg setup
5120 rc = config_add_oc( &coptr, last, e, ca );
5121 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5122 for ( i = 0; i<nocs; i++ ) {
5123 /* Already checked these */
5124 if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
5126 if ( colst[i]->co_ldadd &&
5127 ( rc = colst[i]->co_ldadd( last, e, ca ))
5128 != LDAP_CONSTRAINT_VIOLATION ) {
5134 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5135 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5136 "DN=\"%s\" no structural objectClass add function\n",
5137 log_prefix, e->e_name.bv_val, 0 );
5138 return LDAP_OBJECT_CLASS_VIOLATION;
5142 /* Add the entry but don't parse it, we already have its contents */
5143 if ( rc == LDAP_COMPARE_TRUE ) {
5148 if ( rc != LDAP_SUCCESS )
5151 /* Parse all the values and check for simple syntax errors before
5152 * performing any set actions.
5154 * If doing an LDAPadd, check for indexed names and any necessary
5155 * renaming/renumbering. Entries that don't need indexed names are
5156 * ignored. Entries that need an indexed name and arrive without one
5157 * are assigned to the end. Entries that arrive with an index may
5158 * cause the following entries to be renumbered/bumped down.
5160 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
5161 * don't allow Adding an entry with an index that's already in use.
5162 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
5164 * These entries can have auto-assigned indexes (appended to the end)
5165 * but only the other types support auto-renumbering of siblings.
5168 rc = check_name_index( last, coptr->co_type, e, rs, renum,
5173 if ( renum && *renum && coptr->co_type != Cft_Database &&
5174 coptr->co_type != Cft_Overlay )
5176 snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
5177 "operation requires sibling renumbering" );
5178 rc = LDAP_UNWILLING_TO_PERFORM;
5183 init_config_argv( ca );
5185 /* Make sure we process attrs in the required order */
5186 sort_attrs( e, colst, nocs );
5188 for ( a = e->e_attrs; a; a = a->a_next ) {
5189 if ( a == oc_at ) continue;
5190 ct = config_find_table( colst, nocs, a->a_desc, ca );
5191 if ( !ct ) continue; /* user data? */
5192 rc = check_vals( ct, ca, a, 1 );
5193 if ( rc ) goto done_noop;
5196 /* Basic syntax checks are OK. Do the actual settings. */
5197 for ( a=e->e_attrs; a; a=a->a_next ) {
5198 if ( a == oc_at ) continue;
5199 ct = config_find_table( colst, nocs, a->a_desc, ca );
5200 if ( !ct ) continue; /* user data? */
5201 for (i=0; a->a_vals[i].bv_val; i++) {
5204 ca->line = a->a_vals[i].bv_val;
5205 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
5206 ptr = strchr( ca->line, '}' );
5208 iptr = strchr( ca->line, '{' );
5212 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
5214 ca->valx = strtol( iptr+1, NULL, 0 );
5219 rc = config_parse_add( ct, ca, i );
5227 /* Newly added databases and overlays need to be started up */
5228 if ( CONFIG_ONLINE_ADD( ca )) {
5229 if ( coptr->co_type == Cft_Database ) {
5230 rc = backend_startup_one( ca->be, &ca->reply );
5232 } else if ( coptr->co_type == Cft_Overlay ) {
5233 if ( ca->bi->bi_db_open ) {
5234 BackendInfo *bi_orig = ca->be->bd_info;
5235 ca->be->bd_info = ca->bi;
5236 rc = ca->bi->bi_db_open( ca->be, &ca->reply );
5237 ca->be->bd_info = bi_orig;
5239 } else if ( ca->cleanup ) {
5240 rc = ca->cleanup( ca );
5243 if (ca->cr_msg[0] == '\0')
5244 snprintf( ca->cr_msg, sizeof( ca->cr_msg ), "<%s> failed startup", ca->argv[0] );
5246 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
5247 ca->log, ca->cr_msg, ca->argv[1] );
5254 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5255 ce->ce_parent = last;
5256 ce->ce_entry = entry_dup( e );
5257 ce->ce_entry->e_private = ce;
5258 ce->ce_type = coptr->co_type;
5261 ce->ce_private = ca->ca_private;
5262 ca->ca_entry = ce->ce_entry;
5265 } else if ( last->ce_kids ) {
5266 CfEntryInfo *c2, **cprev;
5268 /* Advance to first of this type */
5269 cprev = &last->ce_kids;
5270 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
5271 cprev = &c2->ce_sibs;
5274 /* Account for the (-1) frontendDB entry */
5275 if ( ce->ce_type == Cft_Database ) {
5276 if ( ca->be == frontendDB )
5278 else if ( ibase != -1 )
5283 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
5284 cprev = &c2->ce_sibs;
5290 for ( i=0; i<ibase; i++ ) {
5292 cprev = &c2->ce_sibs;
5295 ce->ce_sibs = *cprev;
5303 if ( (coptr->co_type == Cft_Database) && ca->be ) {
5304 if ( ca->be != frontendDB )
5305 backend_destroy_one( ca->be, 1 );
5306 } else if ( (coptr->co_type == Cft_Overlay) && ca->bi ) {
5307 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
5308 } else if ( coptr->co_type == Cft_Schema ) {
5309 schema_destroy_one( ca, colst, nocs, last );
5314 ch_free( ca->argv );
5315 if ( colst ) ch_free( colst );
5319 #define BIGTMP 10000
5321 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5322 int base, int rebase, int max, int use_ldif )
5324 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
5325 ConfigType etype = ce->ce_type;
5326 int count = 0, rc = 0;
5328 /* Reverse ce list */
5329 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
5330 if (ce2->ce_type != etype) {
5335 ce2->ce_sibs = cetmp;
5338 if ( max && count >= max ) {
5344 /* Move original to a temp name until increments are done */
5346 ce->ce_entry->e_private = NULL;
5347 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5348 base+BIGTMP, 0, use_ldif );
5349 ce->ce_entry->e_private = ce;
5351 /* start incrementing */
5352 for (ce2=cetmp; ce2; ce2=ce3) {
5354 ce2->ce_sibs = cerem;
5357 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5358 count+base, 0, use_ldif );
5362 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5363 base, 0, use_ldif );
5368 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5369 CfEntryInfo *ce2, int old, int use_ldif )
5373 /* Renumber original to a temp value */
5374 ce->ce_entry->e_private = NULL;
5375 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5376 old+BIGTMP, 0, use_ldif );
5377 ce->ce_entry->e_private = ce;
5379 /* start decrementing */
5380 for (; ce2 != ce; ce2=ce2->ce_sibs) {
5381 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5382 count+old, 0, use_ldif );
5385 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5386 count+old, 0, use_ldif );
5389 /* Parse an LDAP entry into config directives, then store in underlying
5393 config_back_add( Operation *op, SlapReply *rs )
5399 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
5400 NULL, ACL_WADD, NULL )) {
5401 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5406 * Check for attribute ACL
5408 if ( !acl_check_modlist( op, op->ora_e, op->orm_modlist )) {
5409 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5410 rs->sr_text = "no write access to attribute";
5414 cfb = (CfBackInfo *)op->o_bd->be_private;
5416 /* add opattrs for syncprov */
5418 char textbuf[SLAP_TEXT_BUFLEN];
5419 size_t textlen = sizeof textbuf;
5420 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1, NULL,
5421 &rs->sr_text, textbuf, sizeof( textbuf ) );
5422 if ( rs->sr_err != LDAP_SUCCESS )
5424 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
5425 if ( rs->sr_err != LDAP_SUCCESS ) {
5426 Debug( LDAP_DEBUG_TRACE,
5427 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
5428 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
5433 if ( op->o_abandon ) {
5434 rs->sr_err = SLAPD_ABANDON;
5437 ldap_pvt_thread_pool_pause( &connection_pool );
5440 * 1) check for existence of entry
5441 * 2) check for sibling renumbering
5442 * 3) perform internal add
5443 * 4) perform any necessary renumbering
5444 * 5) store entry in underlying database
5446 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
5447 if ( rs->sr_err != LDAP_SUCCESS ) {
5448 rs->sr_text = ca.cr_msg;
5453 CfEntryInfo *ce = ca.ca_entry->e_private;
5454 req_add_s addr = op->oq_add;
5455 op->o_tag = LDAP_REQ_MODRDN;
5456 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
5457 op->o_tag = LDAP_REQ_ADD;
5459 if ( rs->sr_err != LDAP_SUCCESS ) {
5464 if ( cfb->cb_use_ldif ) {
5465 BackendDB *be = op->o_bd;
5466 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5467 struct berval dn, ndn;
5469 op->o_bd = &cfb->cb_db;
5471 /* Save current rootdn; use the underlying DB's rootdn */
5474 op->o_dn = op->o_bd->be_rootdn;
5475 op->o_ndn = op->o_bd->be_rootndn;
5477 scp = op->o_callback;
5478 op->o_callback = ≻
5479 op->o_bd->be_add( op, rs );
5481 op->o_callback = scp;
5487 ldap_pvt_thread_pool_resume( &connection_pool );
5490 { int repl = op->o_dont_replicate;
5491 if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
5492 rs->sr_text = NULL; /* Set after config_add_internal */
5493 rs->sr_err = LDAP_SUCCESS;
5494 op->o_dont_replicate = 1;
5496 send_ldap_result( op, rs );
5497 op->o_dont_replicate = repl;
5499 slap_graduate_commit_csn( op );
5503 typedef struct delrec {
5504 struct delrec *next;
5510 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
5516 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
5517 ca->line[0] == '{' )
5519 char *ptr = strchr( ca->line + 1, '}' );
5523 ca->valx = strtol( ca->line + 1, &next, 0 );
5524 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
5530 rc = config_parse_add( ct, ca, i );
5538 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
5541 int rc = LDAP_UNWILLING_TO_PERFORM;
5543 Entry *e = ce->ce_entry;
5544 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
5549 delrec *dels = NULL, *deltail = NULL;
5551 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5552 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
5554 colst = count_ocs( oc_at, &nocs );
5556 /* make sure add/del flags are clear; should always be true */
5557 for ( s = save_attrs; s; s = s->a_next ) {
5558 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
5561 e->e_attrs = attrs_dup( e->e_attrs );
5563 init_config_argv( ca );
5566 ca->ca_private = ce->ce_private;
5568 ca->fname = "slapd";
5570 strcpy( ca->log, "back-config" );
5572 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
5573 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5574 switch (ml->sml_op) {
5575 case LDAP_MOD_DELETE:
5576 case LDAP_MOD_REPLACE:
5577 case SLAP_MOD_SOFTDEL:
5579 BerVarray vals = NULL, nvals = NULL;
5581 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
5583 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot delete %s",
5584 ml->sml_desc->ad_cname.bv_val );
5587 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5588 vals = ml->sml_values;
5589 nvals = ml->sml_nvalues;
5590 ml->sml_values = NULL;
5591 ml->sml_nvalues = NULL;
5593 /* If we're deleting by values, remember the indexes of the
5594 * values we deleted.
5596 if ( ct && ml->sml_values ) {
5598 i = ml->sml_numvals;
5599 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
5610 rc = modify_delete_vindex(e, &ml->sml_mod,
5611 get_permissiveModify(op),
5612 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg), idx );
5613 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5614 ml->sml_values = vals;
5615 ml->sml_nvalues = nvals;
5617 if ( rc == LDAP_NO_SUCH_ATTRIBUTE && ml->sml_op == SLAP_MOD_SOFTDEL )
5621 /* FIXME: check rc before fallthru? */
5625 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5627 case SLAP_MOD_ADD_IF_NOT_PRESENT:
5628 if ( ml->sml_op == SLAP_MOD_ADD_IF_NOT_PRESENT
5629 && attr_find( e->e_attrs, ml->sml_desc ) )
5636 case SLAP_MOD_SOFTADD: {
5637 int mop = ml->sml_op;
5639 ml->sml_op = LDAP_MOD_ADD;
5641 if ( ct->arg_type & ARG_NO_INSERT ) {
5642 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
5644 navals = a->a_numvals;
5647 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
5648 if ( ml->sml_values[i].bv_val[0] == '{' &&
5651 char *next, *val = ml->sml_values[i].bv_val + 1;
5654 j = strtol( val, &next, 0 );
5655 if ( next == val || next[ 0 ] != '}' || j < navals ) {
5657 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot insert %s",
5658 ml->sml_desc->ad_cname.bv_val );
5662 rc = check_vals( ct, ca, ml, 0 );
5663 if ( rc ) goto out_noop;
5666 rc = modify_add_values(e, &ml->sml_mod,
5667 get_permissiveModify(op),
5668 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5670 /* If value already exists, show success here
5671 * and ignore this operation down below.
5673 if ( mop == SLAP_MOD_SOFTADD ) {
5674 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
5684 case LDAP_MOD_INCREMENT: /* FIXME */
5689 if(rc != LDAP_SUCCESS) break;
5692 if ( rc == LDAP_SUCCESS) {
5693 /* check that the entry still obeys the schema */
5694 rc = entry_schema_check(op, e, NULL, 0, 0, NULL,
5695 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5697 if ( rc ) goto out_noop;
5699 /* Basic syntax checks are OK. Do the actual settings. */
5700 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5701 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5702 if ( !ct ) continue;
5704 s = attr_find( save_attrs, ml->sml_desc );
5705 a = attr_find( e->e_attrs, ml->sml_desc );
5707 switch (ml->sml_op) {
5708 case LDAP_MOD_DELETE:
5709 case LDAP_MOD_REPLACE: {
5710 BerVarray vals = NULL, nvals = NULL;
5713 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5714 vals = ml->sml_values;
5715 nvals = ml->sml_nvalues;
5716 ml->sml_values = NULL;
5717 ml->sml_nvalues = NULL;
5720 if ( ml->sml_values )
5723 /* If we didn't delete the whole attribute */
5724 if ( ml->sml_values && a ) {
5725 struct berval *mvals;
5728 if ( ml->sml_nvalues )
5729 mvals = ml->sml_nvalues;
5731 mvals = ml->sml_values;
5733 /* use the indexes we saved up above */
5734 for (i=0; i < d->nidx; i++) {
5735 struct berval bv = *mvals++;
5736 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
5737 bv.bv_val[0] == '{' ) {
5738 ptr = strchr( bv.bv_val, '}' ) + 1;
5739 bv.bv_len -= ptr - bv.bv_val;
5742 ca->line = bv.bv_val;
5743 ca->valx = d->idx[i];
5744 config_parse_vals(ct, ca, d->idx[i] );
5745 rc = config_del_vals( ct, ca );
5746 if ( rc != LDAP_SUCCESS ) break;
5748 s->a_flags |= SLAP_ATTR_IXDEL;
5749 for (j=i+1; j < d->nidx; j++)
5750 if ( d->idx[j] >d->idx[i] )
5757 rc = config_del_vals( ct, ca );
5758 if ( rc ) rc = LDAP_OTHER;
5760 s->a_flags |= SLAP_ATTR_IXDEL;
5762 if ( ml->sml_values ) {
5767 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5768 ml->sml_values = vals;
5769 ml->sml_nvalues = nvals;
5771 if ( !vals || rc != LDAP_SUCCESS )
5774 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5777 for (i=0; ml->sml_values[i].bv_val; i++) {
5778 ca->line = ml->sml_values[i].bv_val;
5780 rc = config_modify_add( ct, ca, ml->sml_desc, i );
5783 a->a_flags |= SLAP_ATTR_IXADD;
5790 /* Undo for a failed operation */
5791 if ( rc != LDAP_SUCCESS ) {
5792 ConfigReply msg = ca->reply;
5793 for ( s = save_attrs; s; s = s->a_next ) {
5794 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
5795 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5796 ct = config_find_table( colst, nocs, s->a_desc, ca );
5797 a = attr_find( e->e_attrs, s->a_desc );
5799 /* clear the flag so the add check below will skip it */
5800 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5804 config_del_vals( ct, ca );
5806 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5807 ca->line = s->a_vals[i].bv_val;
5809 config_modify_add( ct, ca, s->a_desc, i );
5813 for ( a = e->e_attrs; a; a = a->a_next ) {
5814 if ( a->a_flags & SLAP_ATTR_IXADD ) {
5815 ct = config_find_table( colst, nocs, a->a_desc, ca );
5819 config_del_vals( ct, ca );
5820 s = attr_find( save_attrs, a->a_desc );
5822 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5823 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5824 ca->line = s->a_vals[i].bv_val;
5826 config_modify_add( ct, ca, s->a_desc, i );
5837 if ( rc == LDAP_SUCCESS ) {
5838 attrs_free( save_attrs );
5841 attrs_free( e->e_attrs );
5842 e->e_attrs = save_attrs;
5844 ch_free( ca->argv );
5845 if ( colst ) ch_free( colst );
5847 deltail = dels->next;
5856 config_back_modify( Operation *op, SlapReply *rs )
5859 CfEntryInfo *ce, *last;
5861 ConfigArgs ca = {0};
5864 AttributeDescription *rad = NULL;
5867 cfb = (CfBackInfo *)op->o_bd->be_private;
5869 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5872 rs->sr_matched = last->ce_entry->e_name.bv_val;
5873 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5877 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
5878 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5882 /* Get type of RDN */
5883 rdn = ce->ce_entry->e_nname;
5884 ptr = strchr( rdn.bv_val, '=' );
5885 rdn.bv_len = ptr - rdn.bv_val;
5886 rs->sr_err = slap_bv2ad( &rdn, &rad, &rs->sr_text );
5887 if ( rs->sr_err != LDAP_SUCCESS ) {
5891 /* Some basic validation... */
5892 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5893 /* Don't allow Modify of RDN; must use ModRdn for that. */
5894 if ( ml->sml_desc == rad ) {
5895 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
5896 rs->sr_text = "Use modrdn to change the entry name";
5899 /* Internal update of contextCSN? */
5900 if ( ml->sml_desc == slap_schema.si_ad_contextCSN && op->o_conn->c_conn_idx == -1 ) {
5906 slap_mods_opattrs( op, &op->orm_modlist, 1 );
5909 if ( op->o_abandon ) {
5910 rs->sr_err = SLAPD_ABANDON;
5913 ldap_pvt_thread_pool_pause( &connection_pool );
5917 * 1) perform the Modify on the cached Entry.
5918 * 2) verify that the Entry still satisfies the schema.
5919 * 3) perform the individual config operations.
5920 * 4) store Modified entry in underlying LDIF backend.
5922 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
5924 rs->sr_text = ca.cr_msg;
5925 } else if ( cfb->cb_use_ldif ) {
5926 BackendDB *be = op->o_bd;
5927 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5928 struct berval dn, ndn;
5930 op->o_bd = &cfb->cb_db;
5934 op->o_dn = op->o_bd->be_rootdn;
5935 op->o_ndn = op->o_bd->be_rootndn;
5937 scp = op->o_callback;
5938 op->o_callback = ≻
5939 op->o_bd->be_modify( op, rs );
5941 op->o_callback = scp;
5947 ldap_pvt_thread_pool_resume( &connection_pool );
5949 send_ldap_result( op, rs );
5950 slap_graduate_commit_csn( op );
5955 config_back_modrdn( Operation *op, SlapReply *rs )
5958 CfEntryInfo *ce, *last;
5962 cfb = (CfBackInfo *)op->o_bd->be_private;
5964 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5967 rs->sr_matched = last->ce_entry->e_name.bv_val;
5968 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5971 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
5972 NULL, ACL_WRITE, NULL )) {
5973 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5977 if ( ce->ce_parent )
5978 parent = ce->ce_parent->ce_entry;
5980 parent = (Entry *)&slap_entry_root;
5981 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
5982 NULL, ACL_WRITE, NULL )) {
5983 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5988 /* We don't allow moving objects to new parents.
5989 * Generally we only allow reordering a set of ordered entries.
5991 if ( op->orr_newSup ) {
5992 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5996 /* If newRDN == oldRDN, quietly succeed */
5997 dnRdn( &op->o_req_ndn, &rdn );
5998 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
5999 rs->sr_err = LDAP_SUCCESS;
6003 /* Current behavior, subject to change as needed:
6005 * For backends and overlays, we only allow renumbering.
6006 * For schema, we allow renaming with the same number.
6007 * Otherwise, the op is not allowed.
6010 if ( ce->ce_type == Cft_Schema ) {
6014 /* Can't alter the main cn=schema entry */
6015 if ( ce->ce_parent->ce_type == Cft_Global ) {
6016 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6017 rs->sr_text = "renaming not allowed for this entry";
6021 /* We could support this later if desired */
6022 ptr1 = ber_bvchr( &rdn, '}' );
6023 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
6024 len = ptr1 - rdn.bv_val;
6025 if ( len != ptr2 - op->orr_newrdn.bv_val ||
6026 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
6027 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6028 rs->sr_text = "schema reordering not supported";
6031 } else if ( ce->ce_type == Cft_Database ||
6032 ce->ce_type == Cft_Overlay ) {
6033 char *ptr1, *ptr2, *iptr1, *iptr2;
6036 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
6037 if ( *iptr2 != '{' ) {
6038 rs->sr_err = LDAP_NAMING_VIOLATION;
6039 rs->sr_text = "new ordering index is required";
6043 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
6044 ptr1 = ber_bvchr( &rdn, '}' );
6045 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
6047 rs->sr_err = LDAP_NAMING_VIOLATION;
6048 rs->sr_text = "new ordering index is required";
6052 len1 = ptr1 - rdn.bv_val;
6053 len2 = ptr2 - op->orr_newrdn.bv_val;
6055 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
6056 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
6057 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6058 rs->sr_text = "changing database/overlay type not allowed";
6061 ixold = strtol( iptr1, NULL, 0 );
6062 ixnew = strtol( iptr2, &ptr1, 0 );
6063 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
6064 rs->sr_err = LDAP_NAMING_VIOLATION;
6067 /* config DB is always 0, cannot be changed */
6068 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
6069 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
6073 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6074 rs->sr_text = "renaming not supported for this entry";
6078 if ( op->o_abandon ) {
6079 rs->sr_err = SLAPD_ABANDON;
6082 ldap_pvt_thread_pool_pause( &connection_pool );
6084 if ( ce->ce_type == Cft_Schema ) {
6085 req_modrdn_s modr = op->oq_modrdn;
6088 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
6089 if ( rs->sr_err == LDAP_SUCCESS ) {
6090 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
6091 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
6094 op->oq_modrdn = modr;
6096 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
6097 req_modrdn_s modr = op->oq_modrdn;
6100 /* Advance to first of this type */
6101 cprev = &ce->ce_parent->ce_kids;
6102 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
6103 cprev = &ce2->ce_sibs;
6106 /* Skip the -1 entry */
6107 if ( ce->ce_type == Cft_Database ) {
6108 cprev = &ce2->ce_sibs;
6114 /* Remove from old slot */
6115 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
6116 cprev = &ce2->ce_sibs;
6117 *cprev = ce->ce_sibs;
6118 ceold = ce->ce_sibs;
6120 /* Insert into new slot */
6122 for ( i=0; i<ixnew; i++ ) {
6126 cprev = &ce2->ce_sibs;
6128 ce->ce_sibs = *cprev;
6133 /* NOTE: These should be encoded in the OC tables, not inline here */
6134 if ( ce->ce_type == Cft_Database )
6135 backend_db_move( ce->ce_be, ixnew );
6136 else if ( ce->ce_type == Cft_Overlay )
6137 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
6139 if ( ixold < ixnew ) {
6140 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
6143 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
6144 ixold - ixnew, cfb->cb_use_ldif );
6146 op->oq_modrdn = modr;
6149 ldap_pvt_thread_pool_resume( &connection_pool );
6151 send_ldap_result( op, rs );
6156 config_back_delete( Operation *op, SlapReply *rs )
6158 #ifdef SLAP_CONFIG_DELETE
6160 CfEntryInfo *ce, *last, *ce2;
6162 cfb = (CfBackInfo *)op->o_bd->be_private;
6164 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6167 rs->sr_matched = last->ce_entry->e_name.bv_val;
6168 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6169 } else if ( ce->ce_kids ) {
6170 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6171 } else if ( op->o_abandon ) {
6172 rs->sr_err = SLAPD_ABANDON;
6173 } else if ( ce->ce_type == Cft_Overlay || ce->ce_type == Cft_Database ){
6177 ldap_pvt_thread_pool_pause( &connection_pool );
6179 if ( ce->ce_type == Cft_Overlay ){
6180 if ( SLAP_ISGLOBALOVERLAY(ce->ce_be ) ) {
6181 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6182 rs->sr_text = "Cannot delete global overlays";
6183 ldap_pvt_thread_pool_resume( &connection_pool );
6186 overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi, op );
6188 } else { /* Cft_Database*/
6189 if ( ce->ce_be == frontendDB || ce->ce_be == op->o_bd ){
6190 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6191 rs->sr_text = "Cannot delete config or frontend database";
6192 ldap_pvt_thread_pool_resume( &connection_pool );
6195 if ( ce->ce_be->bd_info->bi_db_close ) {
6196 ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
6198 backend_destroy_one( ce->ce_be, 1);
6201 /* remove CfEntryInfo from the siblings list */
6202 if ( ce->ce_parent->ce_kids == ce ) {
6203 ce->ce_parent->ce_kids = ce->ce_sibs;
6205 for ( ce2 = ce->ce_parent->ce_kids ; ce2; ce2 = ce2->ce_sibs ) {
6206 if ( ce2->ce_sibs == ce ) {
6207 ce2->ce_sibs = ce->ce_sibs;
6213 /* remove from underlying database */
6214 if ( cfb->cb_use_ldif ) {
6215 BackendDB *be = op->o_bd;
6216 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
6217 struct berval dn, ndn, req_dn, req_ndn;
6219 op->o_bd = &cfb->cb_db;
6223 req_dn = op->o_req_dn;
6224 req_ndn = op->o_req_ndn;
6226 op->o_dn = op->o_bd->be_rootdn;
6227 op->o_ndn = op->o_bd->be_rootndn;
6228 op->o_req_dn = ce->ce_entry->e_name;
6229 op->o_req_ndn = ce->ce_entry->e_nname;
6231 scp = op->o_callback;
6232 op->o_callback = ≻
6233 op->o_bd->be_delete( op, rs );
6235 op->o_callback = scp;
6238 op->o_req_dn = req_dn;
6239 op->o_req_ndn = req_ndn;
6242 /* renumber siblings */
6243 iptr = ber_bvchr( &op->o_req_ndn, '{' ) + 1;
6244 ixold = strtol( iptr, NULL, 0 );
6245 for (ce2 = ce->ce_sibs, count=0; ce2; ce2=ce2->ce_sibs) {
6246 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
6247 count+ixold, 0, cfb->cb_use_ldif );
6251 ce->ce_entry->e_private=NULL;
6252 entry_free(ce->ce_entry);
6254 ldap_pvt_thread_pool_resume( &connection_pool );
6256 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6259 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6260 #endif /* SLAP_CONFIG_DELETE */
6262 send_ldap_result( op, rs );
6267 config_back_search( Operation *op, SlapReply *rs )
6270 CfEntryInfo *ce, *last;
6273 cfb = (CfBackInfo *)op->o_bd->be_private;
6275 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6278 rs->sr_matched = last->ce_entry->e_name.bv_val;
6279 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6282 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
6283 ACL_SEARCH, NULL, &mask ))
6285 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
6286 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6288 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
6292 switch ( op->ors_scope ) {
6293 case LDAP_SCOPE_BASE:
6294 case LDAP_SCOPE_SUBTREE:
6295 rs->sr_err = config_send( op, rs, ce, 0 );
6298 case LDAP_SCOPE_ONELEVEL:
6299 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
6300 rs->sr_err = config_send( op, rs, ce, 1 );
6309 send_ldap_result( op, rs );
6313 /* no-op, we never free entries */
6314 int config_entry_release(
6319 if ( !e->e_private ) {
6322 return LDAP_SUCCESS;
6325 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
6327 int config_back_entry_get(
6331 AttributeDescription *at,
6336 CfEntryInfo *ce, *last;
6337 int rc = LDAP_NO_SUCH_OBJECT;
6339 cfb = (CfBackInfo *)op->o_bd->be_private;
6341 ce = config_find_base( cfb->cb_root, ndn, &last );
6343 *ent = ce->ce_entry;
6346 if ( oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
6347 rc = LDAP_NO_SUCH_ATTRIBUTE;
6357 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
6358 ConfigTable *ct, ConfigArgs *c )
6362 for (; at && *at; at++) {
6363 /* Skip the naming attr */
6364 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
6366 for (i=0;ct[i].name;i++) {
6367 if (ct[i].ad == (*at)->sat_ad) {
6368 rc = config_get_vals(&ct[i], c);
6369 /* NOTE: tolerate that config_get_vals()
6370 * returns success with no values */
6371 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
6372 if ( c->rvalue_nvals )
6373 rc = attr_merge(e, ct[i].ad, c->rvalue_vals,
6376 slap_syntax_validate_func *validate =
6377 ct[i].ad->ad_type->sat_syntax->ssyn_validate;
6380 for ( j=0; c->rvalue_vals[j].bv_val; j++ ) {
6381 rc = ordered_value_validate( ct[i].ad,
6382 &c->rvalue_vals[j], LDAP_MOD_ADD );
6384 Debug( LDAP_DEBUG_ANY,
6385 "config_build_attrs: error %d on %s value #%d\n",
6386 rc, ct[i].ad->ad_cname.bv_val, j );
6392 rc = attr_merge_normalize(e, ct[i].ad,
6393 c->rvalue_vals, NULL);
6395 ber_bvarray_free( c->rvalue_nvals );
6396 ber_bvarray_free( c->rvalue_vals );
6398 Debug( LDAP_DEBUG_ANY,
6399 "config_build_attrs: error %d on %s\n",
6400 rc, ct[i].ad->ad_cname.bv_val, 0 );
6411 /* currently (2010) does not access rs except possibly writing rs->sr_err */
6414 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
6415 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
6417 Entry *e = entry_alloc();
6418 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
6420 struct berval ad_name;
6421 AttributeDescription *ad = NULL;
6424 const char *text = "";
6428 CfEntryInfo *ceprev = NULL;
6430 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
6433 ce->ce_type = main->co_type;
6434 ce->ce_parent = parent;
6436 pdn = parent->ce_entry->e_nname;
6437 if ( parent->ce_kids && parent->ce_kids->ce_type <= ce->ce_type )
6438 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
6439 ceprev->ce_type <= ce->ce_type;
6440 ceprev = ceprev->ce_sibs );
6445 ce->ce_private = c->ca_private;
6449 build_new_dn( &e->e_name, &pdn, rdn, NULL );
6450 ber_dupbv( &e->e_nname, &e->e_name );
6452 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6453 main->co_name, NULL );
6455 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6456 extra->co_name, NULL );
6457 ptr = strchr(rdn->bv_val, '=');
6458 ad_name.bv_val = rdn->bv_val;
6459 ad_name.bv_len = ptr - rdn->bv_val;
6460 rc = slap_bv2ad( &ad_name, &ad, &text );
6465 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
6466 attr_merge_normalize_one(e, ad, &val, NULL );
6469 c->table = main->co_type;
6470 if ( oc->soc_required ) {
6471 rc = config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
6472 if ( rc ) goto fail;
6475 if ( oc->soc_allowed ) {
6476 rc = config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
6477 if ( rc ) goto fail;
6482 c->table = extra->co_type;
6483 if ( oc->soc_required ) {
6484 rc = config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
6485 if ( rc ) goto fail;
6488 if ( oc->soc_allowed ) {
6489 rc = config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
6490 if ( rc ) goto fail;
6494 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
6495 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->cr_msg,
6496 sizeof(c->cr_msg), op ? op->o_tmpmemctx : NULL );
6497 if ( rc != LDAP_SUCCESS ) {
6499 Debug( LDAP_DEBUG_ANY,
6500 "config_build_entry: build \"%s\" failed: \"%s\"\n",
6501 rdn->bv_val, text, 0);
6504 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
6507 op->ora_modlist = NULL;
6508 slap_add_opattrs( op, NULL, NULL, 0, 0 );
6509 if ( !op->o_noop ) {
6510 SlapReply rs2 = {REP_RESULT};
6511 op->o_bd->be_add( op, &rs2 );
6512 rs->sr_err = rs2.sr_err;
6513 rs_assert_done( &rs2 );
6514 if ( ( rs2.sr_err != LDAP_SUCCESS )
6515 && (rs2.sr_err != LDAP_ALREADY_EXISTS) ) {
6521 ce->ce_sibs = ceprev->ce_sibs;
6522 ceprev->ce_sibs = ce;
6523 } else if ( parent ) {
6524 ce->ce_sibs = parent->ce_kids;
6525 parent->ce_kids = ce;
6532 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
6533 Operation *op, SlapReply *rs )
6536 ConfigFile *cf = c->ca_private;
6538 struct berval bv, rdn;
6540 for (; cf; cf=cf->c_sibs, c->depth++) {
6541 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
6542 !cf->c_om_head && !cf->c_syn_head ) continue;
6543 c->value_dn.bv_val = c->log;
6544 LUTIL_SLASHPATH( cf->c_file.bv_val );
6545 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
6550 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
6552 ptr = strchr( bv.bv_val, '.' );
6554 bv.bv_len = ptr - bv.bv_val;
6555 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
6556 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6557 /* FIXME: how can indicate error? */
6560 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
6562 c->value_dn.bv_len += bv.bv_len;
6563 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
6567 e = config_build_entry( op, rs, ceparent, c, &rdn,
6568 &CFOC_SCHEMA, NULL );
6571 } else if ( e && cf->c_kids ) {
6572 c->ca_private = cf->c_kids;
6573 config_build_schema_inc( c, e->e_private, op, rs );
6579 #ifdef SLAPD_MODULES
6582 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
6583 Operation *op, SlapReply *rs )
6588 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
6589 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
6591 c->value_dn.bv_val = c->log;
6592 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
6593 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6594 /* FIXME: how can indicate error? */
6598 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
6607 config_check_schema(Operation *op, CfBackInfo *cfb)
6609 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
6611 CfEntryInfo *ce, *last;
6614 /* If there's no root entry, we must be in the midst of converting */
6615 if ( !cfb->cb_root )
6618 /* Make sure the main schema entry exists */
6619 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
6626 /* Make sure it's up to date */
6627 if ( cf_om_tail != om_sys_tail ) {
6628 a = attr_find( e->e_attrs, cfAd_om );
6630 if ( a->a_nvals != a->a_vals )
6631 ber_bvarray_free( a->a_nvals );
6632 ber_bvarray_free( a->a_vals );
6637 oidm_unparse( &bv, NULL, NULL, 1 );
6638 attr_merge_normalize( e, cfAd_om, bv, NULL );
6639 ber_bvarray_free( bv );
6640 cf_om_tail = om_sys_tail;
6642 if ( cf_at_tail != at_sys_tail ) {
6643 a = attr_find( e->e_attrs, cfAd_attr );
6645 if ( a->a_nvals != a->a_vals )
6646 ber_bvarray_free( a->a_nvals );
6647 ber_bvarray_free( a->a_vals );
6652 at_unparse( &bv, NULL, NULL, 1 );
6653 attr_merge_normalize( e, cfAd_attr, bv, NULL );
6654 ber_bvarray_free( bv );
6655 cf_at_tail = at_sys_tail;
6657 if ( cf_oc_tail != oc_sys_tail ) {
6658 a = attr_find( e->e_attrs, cfAd_oc );
6660 if ( a->a_nvals != a->a_vals )
6661 ber_bvarray_free( a->a_nvals );
6662 ber_bvarray_free( a->a_vals );
6667 oc_unparse( &bv, NULL, NULL, 1 );
6668 attr_merge_normalize( e, cfAd_oc, bv, NULL );
6669 ber_bvarray_free( bv );
6670 cf_oc_tail = oc_sys_tail;
6672 if ( cf_syn_tail != syn_sys_tail ) {
6673 a = attr_find( e->e_attrs, cfAd_syntax );
6675 if ( a->a_nvals != a->a_vals )
6676 ber_bvarray_free( a->a_nvals );
6677 ber_bvarray_free( a->a_vals );
6682 syn_unparse( &bv, NULL, NULL, 1 );
6683 attr_merge_normalize( e, cfAd_syntax, bv, NULL );
6684 ber_bvarray_free( bv );
6685 cf_syn_tail = syn_sys_tail;
6688 SlapReply rs = {REP_RESULT};
6689 c.ca_private = NULL;
6690 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
6691 &CFOC_SCHEMA, NULL );
6696 ce->ce_private = cfb->cb_config;
6697 cf_at_tail = at_sys_tail;
6698 cf_oc_tail = oc_sys_tail;
6699 cf_om_tail = om_sys_tail;
6700 cf_syn_tail = syn_sys_tail;
6705 static const char *defacl[] = {
6706 NULL, "to", "*", "by", "*", "none", NULL
6710 config_back_db_open( BackendDB *be, ConfigReply *cr )
6712 CfBackInfo *cfb = be->be_private;
6715 CfEntryInfo *ce, *ceparent;
6719 Connection conn = {0};
6720 OperationBuffer opbuf;
6722 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
6723 SlapReply rs = {REP_RESULT};
6724 void *thrctx = NULL;
6726 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
6728 /* If we have no explicitly configured ACLs, don't just use
6729 * the global ACLs. Explicitly deny access to everything.
6731 if ( !be->bd_self->be_acl ) {
6732 parse_acl(be->bd_self, "config_back_db_open", 0, 6, (char **)defacl, 0 );
6735 thrctx = ldap_pvt_thread_pool_context();
6736 connection_fake_init( &conn, &opbuf, thrctx );
6739 op->o_tag = LDAP_REQ_ADD;
6740 op->o_callback = &cb;
6741 op->o_bd = &cfb->cb_db;
6742 op->o_dn = op->o_bd->be_rootdn;
6743 op->o_ndn = op->o_bd->be_rootndn;
6745 if ( !cfb->cb_use_ldif ) {
6749 /* If we read the config from back-ldif, do some quick sanity checks */
6750 if ( cfb->cb_got_ldif ) {
6751 return config_check_schema( op, cfb );
6754 /* create root of tree */
6756 c.ca_private = cfb->cb_config;
6758 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
6768 #ifdef SLAPD_MODULES
6769 /* Create Module nodes... */
6770 if ( modpaths.mp_loads ) {
6771 if ( config_build_modules( &c, ceparent, op, &rs ) ){
6777 /* Create schema nodes... cn=schema will contain the hardcoded core
6778 * schema, read-only. Child objects will contain runtime loaded schema
6782 c.ca_private = NULL;
6783 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
6788 ce->ce_private = cfb->cb_config;
6789 cf_at_tail = at_sys_tail;
6790 cf_oc_tail = oc_sys_tail;
6791 cf_om_tail = om_sys_tail;
6792 cf_syn_tail = syn_sys_tail;
6794 /* Create schema nodes for included schema... */
6795 if ( cfb->cb_config->c_kids ) {
6798 c.ca_private = cfb->cb_config->c_kids;
6799 rc = config_build_schema_inc( &c, ce, op, &rs );
6805 /* Create backend nodes. Skip if they don't provide a cf_table.
6806 * There usually aren't any of these.
6810 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
6811 if (!bi->bi_cf_ocs) {
6812 /* If it only supports the old config mech, complain. */
6813 if ( bi->bi_config ) {
6814 Debug( LDAP_DEBUG_ANY,
6815 "WARNING: No dynamic config support for backend %s.\n",
6816 bi->bi_type, 0, 0 );
6821 if (!bi->bi_private) continue;
6824 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6825 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
6826 if ( rdn.bv_len >= sizeof( c.log ) ) {
6827 /* FIXME: holler ... */ ;
6830 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
6837 /* Create database nodes... */
6838 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
6839 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
6840 for ( i = -1, be = frontendDB ; be;
6841 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
6842 slap_overinfo *oi = NULL;
6844 if ( overlay_is_over( be )) {
6845 oi = be->bd_info->bi_private;
6851 /* If this backend supports the old config mechanism, but not
6852 * the new mech, complain.
6854 if ( !be->be_cf_ocs && bi->bi_db_config ) {
6855 Debug( LDAP_DEBUG_ANY,
6856 "WARNING: No dynamic config support for database %s.\n",
6857 bi->bi_type, 0, 0 );
6861 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6862 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
6864 if ( rdn.bv_len >= sizeof( c.log ) ) {
6865 /* FIXME: holler ... */ ;
6869 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
6875 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd ) {
6876 rs_reinit( &rs, REP_RESULT );
6877 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
6879 /* Iterate through overlays */
6884 voidList *vl, *v0 = NULL;
6886 /* overlays are in LIFO order, must reverse stack */
6887 for (on=oi->oi_list; on; on=on->on_next) {
6888 vl = ch_malloc( sizeof( voidList ));
6893 for (j=0; vl; j++,vl=v0) {
6897 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
6898 Debug( LDAP_DEBUG_ANY,
6899 "WARNING: No dynamic config support for overlay %s.\n",
6900 on->on_bi.bi_type, 0, 0 );
6904 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6905 "%s=" SLAP_X_ORDERED_FMT "%s",
6906 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
6907 if ( rdn.bv_len >= sizeof( c.log ) ) {
6908 /* FIXME: holler ... */ ;
6912 oe = config_build_entry( op, &rs, ce, &c, &rdn,
6913 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
6917 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd ) {
6918 rs_reinit( &rs, REP_RESULT );
6919 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
6925 ldap_pvt_thread_pool_context_reset( thrctx );
6927 if ( unsupp && cfb->cb_use_ldif ) {
6928 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
6929 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
6936 cfb_free_cffile( ConfigFile *cf )
6940 for (; cf; cf=next) {
6943 cfb_free_cffile( cf->c_kids );
6944 ch_free( cf->c_file.bv_val );
6945 ber_bvarray_free( cf->c_dseFiles );
6951 cfb_free_entries( CfEntryInfo *ce )
6955 for (; ce; ce=next) {
6958 cfb_free_entries( ce->ce_kids );
6959 ce->ce_entry->e_private = NULL;
6960 entry_free( ce->ce_entry );
6966 config_back_db_close( BackendDB *be, ConfigReply *cr )
6968 CfBackInfo *cfb = be->be_private;
6970 cfb_free_entries( cfb->cb_root );
6971 cfb->cb_root = NULL;
6973 if ( cfb->cb_db.bd_info ) {
6974 backend_shutdown( &cfb->cb_db );
6981 config_back_db_destroy( BackendDB *be, ConfigReply *cr )
6983 CfBackInfo *cfb = be->be_private;
6985 cfb_free_cffile( cfb->cb_config );
6987 ch_free( cfdir.bv_val );
6989 avl_free( CfOcTree, NULL );
6991 if ( cfb->cb_db.bd_info ) {
6992 cfb->cb_db.be_suffix = NULL;
6993 cfb->cb_db.be_nsuffix = NULL;
6994 BER_BVZERO( &cfb->cb_db.be_rootdn );
6995 BER_BVZERO( &cfb->cb_db.be_rootndn );
6997 backend_destroy_one( &cfb->cb_db, 0 );
7006 config_back_db_init( BackendDB *be, ConfigReply* cr )
7012 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
7013 cfn = cfb->cb_config;
7014 be->be_private = cfb;
7016 ber_dupbv( &be->be_rootdn, &config_rdn );
7017 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
7018 ber_dupbv( &dn, &be->be_rootdn );
7019 ber_bvarray_add( &be->be_suffix, &dn );
7020 ber_dupbv( &dn, &be->be_rootdn );
7021 ber_bvarray_add( &be->be_nsuffix, &dn );
7023 /* Hide from namingContexts */
7024 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
7026 /* Check ACLs on content of Adds by default */
7027 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_ACL_ADD;
7033 config_back_destroy( BackendInfo *bi )
7035 ldif_must_b64_encode_release();
7040 config_tool_entry_open( BackendDB *be, int mode )
7042 CfBackInfo *cfb = be->be_private;
7043 BackendInfo *bi = cfb->cb_db.bd_info;
7045 if ( bi && bi->bi_tool_entry_open )
7046 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
7053 config_tool_entry_close( BackendDB *be )
7055 CfBackInfo *cfb = be->be_private;
7056 BackendInfo *bi = cfb->cb_db.bd_info;
7058 if ( bi && bi->bi_tool_entry_close )
7059 return bi->bi_tool_entry_close( &cfb->cb_db );
7065 config_tool_entry_first( BackendDB *be )
7067 CfBackInfo *cfb = be->be_private;
7068 BackendInfo *bi = cfb->cb_db.bd_info;
7070 if ( bi && bi->bi_tool_entry_first ) {
7071 return bi->bi_tool_entry_first( &cfb->cb_db );
7073 if ( bi && bi->bi_tool_entry_first_x ) {
7074 return bi->bi_tool_entry_first_x( &cfb->cb_db,
7075 NULL, LDAP_SCOPE_DEFAULT, NULL );
7081 config_tool_entry_first_x(
7083 struct berval *base,
7087 CfBackInfo *cfb = be->be_private;
7088 BackendInfo *bi = cfb->cb_db.bd_info;
7090 if ( bi && bi->bi_tool_entry_first_x ) {
7091 return bi->bi_tool_entry_first_x( &cfb->cb_db, base, scope, f );
7097 config_tool_entry_next( BackendDB *be )
7099 CfBackInfo *cfb = be->be_private;
7100 BackendInfo *bi = cfb->cb_db.bd_info;
7102 if ( bi && bi->bi_tool_entry_next )
7103 return bi->bi_tool_entry_next( &cfb->cb_db );
7109 config_tool_entry_get( BackendDB *be, ID id )
7111 CfBackInfo *cfb = be->be_private;
7112 BackendInfo *bi = cfb->cb_db.bd_info;
7114 if ( bi && bi->bi_tool_entry_get )
7115 return bi->bi_tool_entry_get( &cfb->cb_db, id );
7120 static int entry_put_got_frontend=0;
7121 static int entry_put_got_config=0;
7123 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
7125 CfBackInfo *cfb = be->be_private;
7126 BackendInfo *bi = cfb->cb_db.bd_info;
7128 struct berval rdn, vals[ 2 ];
7130 OperationBuffer opbuf;
7132 Connection conn = {0};
7133 Operation *op = NULL;
7137 /* Create entry for frontend database if it does not exist already */
7138 if ( !entry_put_got_frontend ) {
7139 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7140 STRLENOF( "olcDatabase" ))) {
7141 if ( strncmp( e->e_nname.bv_val +
7142 STRLENOF( "olcDatabase" ), "={-1}frontend",
7143 STRLENOF( "={-1}frontend" )) &&
7144 strncmp( e->e_nname.bv_val +
7145 STRLENOF( "olcDatabase" ), "=frontend",
7146 STRLENOF( "=frontend" ))) {
7148 vals[1].bv_val = NULL;
7149 memset( &ca, 0, sizeof(ConfigArgs));
7151 ca.bi = frontendDB->bd_info;
7152 ca.be->be_cf_ocs = &CFOC_FRONTEND;
7153 rdn.bv_val = ca.log;
7154 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7155 "%s=" SLAP_X_ORDERED_FMT "%s",
7156 cfAd_database->ad_cname.bv_val, -1,
7158 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
7159 &CFOC_DATABASE, ca.be->be_cf_ocs );
7160 thrctx = ldap_pvt_thread_pool_context();
7161 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7163 op->o_bd = &cfb->cb_db;
7164 op->o_tag = LDAP_REQ_ADD;
7166 op->o_dn = be->be_rootdn;
7167 op->o_ndn = be->be_rootndn;
7168 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7169 if ( rc != LDAP_SUCCESS ) {
7170 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7171 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7175 if ( ce && bi && bi->bi_tool_entry_put &&
7176 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7177 entry_put_got_frontend++;
7179 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7180 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7184 entry_put_got_frontend++;
7189 /* Create entry for config database if it does not exist already */
7190 if ( !entry_put_got_config && !isFrontend ) {
7191 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7192 STRLENOF( "olcDatabase" ))) {
7193 if ( strncmp( e->e_nname.bv_val +
7194 STRLENOF( "olcDatabase" ), "={0}config",
7195 STRLENOF( "={0}config" )) &&
7196 strncmp( e->e_nname.bv_val +
7197 STRLENOF( "olcDatabase" ), "=config",
7198 STRLENOF( "=config" )) ) {
7200 vals[1].bv_val = NULL;
7201 memset( &ca, 0, sizeof(ConfigArgs));
7202 ca.be = LDAP_STAILQ_FIRST( &backendDB );
7203 ca.bi = ca.be->bd_info;
7204 rdn.bv_val = ca.log;
7205 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7206 "%s=" SLAP_X_ORDERED_FMT "%s",
7207 cfAd_database->ad_cname.bv_val, 0,
7209 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
7212 thrctx = ldap_pvt_thread_pool_context();
7213 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7215 op->o_bd = &cfb->cb_db;
7216 op->o_tag = LDAP_REQ_ADD;
7217 op->o_dn = be->be_rootdn;
7218 op->o_ndn = be->be_rootndn;
7221 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7222 if ( rc != LDAP_SUCCESS ) {
7223 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7224 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7227 if (ce && bi && bi->bi_tool_entry_put &&
7228 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7229 entry_put_got_config++;
7231 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7232 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7236 entry_put_got_config++;
7240 if ( bi && bi->bi_tool_entry_put &&
7241 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
7242 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
7249 AttributeDescription **desc;
7251 { "attribute", &cfAd_attr },
7252 { "backend", &cfAd_backend },
7253 { "database", &cfAd_database },
7254 { "include", &cfAd_include },
7255 { "ldapsyntax", &cfAd_syntax },
7256 { "objectclass", &cfAd_oc },
7257 { "objectidentifier", &cfAd_om },
7258 { "overlay", &cfAd_overlay },
7263 * add / delete: all types that may be added or deleted must use an
7264 * X-ORDERED attributeType for their RDN. Adding and deleting entries
7265 * should automatically renumber the index of any siblings as needed,
7266 * so that no gaps in the numbering sequence exist after the add/delete
7268 * What can be added:
7270 * backend objects for backend-specific config directives
7274 * delete: probably no support this time around.
7276 * modrdn: generally not done. Will be invoked automatically by add/
7277 * delete to update numbering sequence. Perform as an explicit operation
7278 * so that the renumbering effect may be replicated. Subtree rename must
7279 * be supported, since renumbering a database will affect all its child
7282 * modify: must be fully supported.
7286 config_back_initialize( BackendInfo *bi )
7288 ConfigTable *ct = config_back_cf_table;
7292 AttributeDescription *ad = NULL;
7294 static char *controls[] = {
7295 LDAP_CONTROL_MANAGEDSAIT,
7299 /* Make sure we don't exceed the bits reserved for userland */
7300 config_check_userland( CFG_LAST );
7302 bi->bi_controls = controls;
7307 bi->bi_destroy = config_back_destroy;
7309 bi->bi_db_init = config_back_db_init;
7310 bi->bi_db_config = 0;
7311 bi->bi_db_open = config_back_db_open;
7312 bi->bi_db_close = config_back_db_close;
7313 bi->bi_db_destroy = config_back_db_destroy;
7315 bi->bi_op_bind = config_back_bind;
7316 bi->bi_op_unbind = 0;
7317 bi->bi_op_search = config_back_search;
7318 bi->bi_op_compare = 0;
7319 bi->bi_op_modify = config_back_modify;
7320 bi->bi_op_modrdn = config_back_modrdn;
7321 bi->bi_op_add = config_back_add;
7322 bi->bi_op_delete = config_back_delete;
7323 bi->bi_op_abandon = 0;
7325 bi->bi_extended = 0;
7327 bi->bi_chk_referrals = 0;
7329 bi->bi_access_allowed = slap_access_allowed;
7331 bi->bi_connection_init = 0;
7332 bi->bi_connection_destroy = 0;
7334 bi->bi_entry_release_rw = config_entry_release;
7335 bi->bi_entry_get_rw = config_back_entry_get;
7337 bi->bi_tool_entry_open = config_tool_entry_open;
7338 bi->bi_tool_entry_close = config_tool_entry_close;
7339 bi->bi_tool_entry_first = config_tool_entry_first;
7340 bi->bi_tool_entry_first_x = config_tool_entry_first_x;
7341 bi->bi_tool_entry_next = config_tool_entry_next;
7342 bi->bi_tool_entry_get = config_tool_entry_get;
7343 bi->bi_tool_entry_put = config_tool_entry_put;
7346 argv[ 0 ] = "slapd";
7352 for (i=0; OidMacros[i].name; i++ ) {
7353 argv[1] = OidMacros[i].name;
7354 argv[2] = OidMacros[i].oid;
7355 parse_oidm( &ca, 0, NULL );
7358 bi->bi_cf_ocs = cf_ocs;
7360 i = config_register_schema( ct, cf_ocs );
7363 i = slap_str2ad( "olcDatabase", &olcDatabaseDummy[0].ad, &text );
7366 /* setup olcRootPW to be base64-encoded when written in LDIF form;
7367 * basically, we don't care if it fails */
7368 i = slap_str2ad( "olcRootPW", &ad, &text );
7370 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
7371 "warning, unable to get \"olcRootPW\" "
7372 "attribute description: %d: %s\n",
7375 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
7376 ad->ad_type->sat_oid );
7379 /* set up the notable AttributeDescriptions */
7381 for (;ct->name;ct++) {
7382 if (strcmp(ct->name, ads[i].name)) continue;
7383 *ads[i].desc = ct->ad;
7385 if (!ads[i].name) break;