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
257 * OLcfgOv{Oc|At}:1 -> syncprov
258 * OLcfgOv{Oc|At}:2 -> pcache
259 * OLcfgOv{Oc|At}:3 -> chain
260 * OLcfgOv{Oc|At}:4 -> accesslog
261 * OLcfgOv{Oc|At}:5 -> valsort
262 * OLcfgOv{Oc|At}:7 -> distproc
263 * OLcfgOv{Oc|At}:8 -> dynlist
264 * OLcfgOv{Oc|At}:9 -> dds
265 * OLcfgOv{Oc|At}:10 -> unique
266 * OLcfgOv{Oc|At}:11 -> refint
267 * OLcfgOv{Oc|At}:12 -> ppolicy
268 * OLcfgOv{Oc|At}:13 -> constraint
269 * OLcfgOv{Oc|At}:14 -> translucent
270 * OLcfgOv{Oc|At}:15 -> auditlog
271 * OLcfgOv{Oc|At}:16 -> rwm
272 * OLcfgOv{Oc|At}:17 -> dyngroup
273 * OLcfgOv{Oc|At}:18 -> memberof
274 * OLcfgOv{Oc|At}:19 -> collect
275 * OLcfgOv{Oc|At}:20 -> retcode
276 * OLcfgOv{Oc|At}:21 -> sssvlv
279 /* alphabetical ordering */
281 static ConfigTable config_back_cf_table[] = {
282 /* This attr is read-only */
283 { "", "", 0, 0, 0, ARG_MAGIC,
284 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
285 "DESC 'File for slapd configuration directives' "
286 "EQUALITY caseIgnoreMatch "
287 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
288 { "", "", 0, 0, 0, ARG_MAGIC,
289 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
290 "DESC 'Directory for slapd configuration backend' "
291 "EQUALITY caseIgnoreMatch "
292 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
293 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
294 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
295 "DESC 'Access Control List' "
296 "EQUALITY caseIgnoreMatch "
297 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
298 { "add_content_acl", NULL, 0, 0, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_ACL_ADD,
299 &config_generic, "( OLcfgGlAt:86 NAME 'olcAddContentAcl' "
300 "DESC 'Check ACLs against content of Add ops' "
301 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
302 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
303 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
304 "DESC 'Allowed set of deprecated features' "
305 "EQUALITY caseIgnoreMatch "
306 "SYNTAX OMsDirectoryString )", NULL, NULL },
307 { "argsfile", "file", 2, 2, 0, ARG_STRING,
308 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
309 "DESC 'File for slapd command line options' "
310 "EQUALITY caseIgnoreMatch "
311 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
312 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
313 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
314 "EQUALITY caseIgnoreMatch "
315 "SYNTAX OMsDirectoryString )", NULL, NULL },
316 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
317 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
318 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
319 "DESC 'OpenLDAP attributeTypes' "
320 "EQUALITY caseIgnoreMatch "
321 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
323 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
324 #ifdef SLAP_AUTH_REWRITE
325 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
329 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
330 "EQUALITY caseIgnoreMatch "
331 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
332 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
333 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
334 "EQUALITY caseIgnoreMatch "
335 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
336 { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
337 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
338 "EQUALITY caseIgnoreMatch "
339 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
340 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
341 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
342 "DESC 'A type of backend' "
343 "EQUALITY caseIgnoreMatch "
344 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
346 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
347 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
348 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
349 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
350 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
351 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
352 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
353 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
354 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
355 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
356 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
357 "DESC 'The backend type for a database instance' "
358 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
359 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
360 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
361 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
362 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
363 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
364 "EQUALITY caseIgnoreMatch "
365 "SYNTAX OMsDirectoryString )", NULL, NULL },
366 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
367 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
368 "DESC 'OpenLDAP DIT content rules' "
369 "EQUALITY caseIgnoreMatch "
370 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
372 { "extra_attrs", "attrlist", 2, 2, 0, ARG_DB|ARG_MAGIC,
373 &config_extra_attrs, "( OLcfgDbAt:0.20 NAME 'olcExtraAttrs' "
374 "EQUALITY caseIgnoreMatch "
375 "SYNTAX OMsDirectoryString )", NULL, NULL },
376 { "gentlehup", "on|off", 2, 2, 0,
378 ARG_ON_OFF, &global_gentlehup,
382 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
383 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
384 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
385 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
386 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
387 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
388 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
389 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
390 { "include", "file", 2, 2, 0, ARG_MAGIC,
391 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
392 "SUP labeledURI )", NULL, NULL },
393 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
394 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
395 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
396 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
397 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
398 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
399 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
400 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
401 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
402 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
403 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
404 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
405 { "index_intlen", "len", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_IX_INTLEN,
406 &config_generic, "( OLcfgGlAt:84 NAME 'olcIndexIntLen' "
407 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
408 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
409 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
410 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
411 { "ldapsyntax", "syntax", 2, 0, 0,
412 ARG_PAREN|ARG_MAGIC|CFG_SYNTAX,
413 &config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
414 "DESC 'OpenLDAP ldapSyntax' "
415 "EQUALITY caseIgnoreMatch "
416 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
418 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
419 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
420 "EQUALITY caseIgnoreMatch "
421 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
422 { "listener-threads", "count", 2, 0, 0,
426 ARG_UINT|ARG_MAGIC|CFG_LTHREADS, &config_generic,
428 "( OLcfgGlAt:93 NAME 'olcListenerThreads' "
429 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
430 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
431 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
432 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
433 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
434 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
435 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
436 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
437 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
438 "EQUALITY caseIgnoreMatch "
439 "SYNTAX OMsDirectoryString )", NULL, NULL },
440 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
441 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
442 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
443 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
444 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
445 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
446 { "moduleload", "file", 2, 0, 0,
448 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
452 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
453 "EQUALITY caseIgnoreMatch "
454 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
455 { "modulepath", "path", 2, 2, 0,
457 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
461 "( OLcfgGlAt:31 NAME 'olcModulePath' "
462 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
463 { "monitoring", "TRUE|FALSE", 2, 2, 0,
464 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
465 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
466 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
467 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
468 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
469 "DESC 'OpenLDAP object classes' "
470 "EQUALITY caseIgnoreMatch "
471 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
473 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
474 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
475 "EQUALITY caseIgnoreMatch "
476 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
477 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
478 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
479 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
480 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
481 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
482 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
483 { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
484 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
485 "EQUALITY caseIgnoreMatch "
486 "SYNTAX OMsDirectoryString )", NULL, NULL },
487 { "pidfile", "file", 2, 2, 0, ARG_STRING,
488 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
489 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
490 { "plugin", NULL, 0, 0, 0,
492 ARG_MAGIC|CFG_PLUGIN, &config_generic,
496 "( OLcfgGlAt:38 NAME 'olcPlugin' "
497 "EQUALITY caseIgnoreMatch "
498 "SYNTAX OMsDirectoryString )", NULL, NULL },
499 { "pluginlog", "filename", 2, 2, 0,
501 ARG_STRING, &slapi_log_file,
505 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
506 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
507 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
508 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
509 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
510 { "referral", "url", 2, 2, 0, ARG_MAGIC,
511 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
512 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
513 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
514 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
515 "EQUALITY caseIgnoreMatch "
516 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
517 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
518 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
519 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
520 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
521 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
522 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
523 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
524 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
525 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
526 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
527 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
528 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
529 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
530 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
531 "EQUALITY caseIgnoreMatch "
532 "SYNTAX OMsDirectoryString )", NULL, NULL },
533 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
534 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
535 "EQUALITY caseIgnoreMatch "
536 "SYNTAX OMsDirectoryString )", NULL, NULL },
537 { "reverse-lookup", "on|off", 2, 2, 0,
538 #ifdef SLAPD_RLOOKUPS
539 ARG_ON_OFF, &use_reverse_lookup,
543 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
544 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
545 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
546 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
547 "EQUALITY distinguishedNameMatch "
548 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
549 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
550 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
551 "EQUALITY caseIgnoreMatch "
552 "SYNTAX OMsDirectoryString )", NULL, NULL },
553 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
554 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
555 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
556 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
557 &config_generic, NULL, NULL, NULL },
558 { "sasl-auxprops", NULL, 2, 0, 0,
559 #ifdef HAVE_CYRUS_SASL
560 ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
564 "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
565 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
566 { "sasl-auxprops-dontusecopy", NULL, 2, 0, 0,
567 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
568 ARG_MAGIC|CFG_AZDUC, &config_generic,
572 "( OLcfgGlAt:91 NAME 'olcSaslAuxpropsDontUseCopy' "
573 "EQUALITY caseIgnoreMatch "
574 "SYNTAX OMsDirectoryString )", NULL, NULL },
575 { "sasl-auxprops-dontusecopy-ignore", "true|FALSE", 2, 0, 0,
576 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
577 ARG_ON_OFF|CFG_AZDUC_IGNORE, &slap_dontUseCopy_ignore,
581 "( OLcfgGlAt:92 NAME 'olcSaslAuxpropsDontUseCopyIgnore' "
582 "EQUALITY booleanMatch "
583 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
584 { "sasl-host", "host", 2, 2, 0,
585 #ifdef HAVE_CYRUS_SASL
586 ARG_STRING|ARG_UNIQUE, &sasl_host,
590 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
591 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
592 { "sasl-realm", "realm", 2, 2, 0,
593 #ifdef HAVE_CYRUS_SASL
594 ARG_STRING|ARG_UNIQUE, &global_realm,
598 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
599 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
600 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
601 &config_generic, NULL, NULL, NULL },
602 { "sasl-secprops", "properties", 2, 2, 0,
603 #ifdef HAVE_CYRUS_SASL
604 ARG_MAGIC|CFG_SASLSECP, &config_generic,
608 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
609 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
610 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
611 &config_generic, NULL, NULL, NULL },
612 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
613 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
614 "EQUALITY distinguishedNameMatch "
615 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
616 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
617 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
618 "EQUALITY caseIgnoreMatch "
619 "SYNTAX OMsDirectoryString )", NULL, NULL },
620 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
621 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
622 "EQUALITY caseIgnoreMatch "
623 "SYNTAX OMsDirectoryString )", NULL, NULL },
624 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
625 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
626 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
627 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
628 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
629 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
630 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
631 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
632 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
633 { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
634 &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
635 "DESC 'Attributes whose values will always be sorted' "
636 "EQUALITY caseIgnoreMatch "
637 "SYNTAX OMsDirectoryString )", NULL, NULL },
638 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
639 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
640 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
641 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
642 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
643 "EQUALITY distinguishedNameMatch "
644 "SYNTAX OMsDN )", NULL, NULL },
645 { "sync_use_subentry", NULL, 0, 0, 0, ARG_ON_OFF|ARG_DB|ARG_MAGIC|CFG_SYNC_SUBENTRY,
646 &config_generic, "( OLcfgDbAt:0.19 NAME 'olcSyncUseSubentry' "
647 "DESC 'Store sync context in a subentry' "
648 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
649 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
650 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
651 "EQUALITY caseIgnoreMatch "
652 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
653 { "tcp-buffer", "[listener=<listener>] [{read|write}=]size", 0, 0, 0,
654 #ifndef LDAP_TCP_BUFFER
656 #else /* LDAP_TCP_BUFFER */
657 ARG_MAGIC, &config_tcp_buffer,
658 #endif /* LDAP_TCP_BUFFER */
659 "( OLcfgGlAt:90 NAME 'olcTCPBuffer' "
660 "DESC 'Custom TCP buffer size' "
661 "SYNTAX OMsDirectoryString )", NULL, NULL },
662 { "threads", "count", 2, 2, 0,
666 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
668 "( OLcfgGlAt:66 NAME 'olcThreads' "
669 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
670 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
671 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
672 "SYNTAX OMsDirectoryString )", NULL, NULL },
673 { "TLSCACertificateFile", NULL, 0, 0, 0,
675 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
679 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
680 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
681 { "TLSCACertificatePath", NULL, 0, 0, 0,
683 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
687 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
688 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
689 { "TLSCertificateFile", NULL, 0, 0, 0,
691 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
695 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
696 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
697 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
699 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
703 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
704 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
705 { "TLSCipherSuite", NULL, 0, 0, 0,
707 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
711 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
712 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
713 { "TLSCRLCheck", NULL, 0, 0, 0,
714 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
715 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
719 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
720 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
721 { "TLSCRLFile", NULL, 0, 0, 0,
722 #if defined(HAVE_GNUTLS)
723 CFG_TLS_CRL_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
727 "( OLcfgGlAt:82 NAME 'olcTLSCRLFile' "
728 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
729 { "TLSRandFile", NULL, 0, 0, 0,
731 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
735 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
736 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
737 { "TLSVerifyClient", NULL, 0, 0, 0,
739 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
743 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
744 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
745 { "TLSDHParamFile", NULL, 0, 0, 0,
747 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
751 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
752 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
753 { "TLSProtocolMin", NULL, 0, 0, 0,
755 CFG_TLS_PROTOCOL_MIN|ARG_STRING|ARG_MAGIC, &config_tls_config,
759 "( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' "
760 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
761 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
762 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
763 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
764 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
765 NULL, NULL, NULL, NULL },
766 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
767 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
768 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
769 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
770 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
771 "EQUALITY caseIgnoreMatch "
772 "SUP labeledURI )", NULL, NULL },
773 { "writetimeout", "timeout", 2, 2, 0, ARG_INT,
774 &global_writetimeout, "( OLcfgGlAt:88 NAME 'olcWriteTimeout' "
775 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
776 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
777 NULL, NULL, NULL, NULL }
780 /* Need to no-op this keyword for dynamic config */
781 ConfigTable olcDatabaseDummy[] = {
782 { "", "", 0, 0, 0, ARG_IGNORED,
783 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
784 "DESC 'The backend type for a database instance' "
785 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
786 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
789 /* Routines to check if a child can be added to this type */
790 static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
791 cfAddBackend, cfAddModule, cfAddOverlay;
793 /* NOTE: be careful when defining array members
794 * that can be conditionally compiled */
795 #define CFOC_GLOBAL cf_ocs[1]
796 #define CFOC_SCHEMA cf_ocs[2]
797 #define CFOC_BACKEND cf_ocs[3]
798 #define CFOC_DATABASE cf_ocs[4]
799 #define CFOC_OVERLAY cf_ocs[5]
800 #define CFOC_INCLUDE cf_ocs[6]
801 #define CFOC_FRONTEND cf_ocs[7]
803 #define CFOC_MODULE cf_ocs[8]
804 #endif /* SLAPD_MODULES */
806 static ConfigOCs cf_ocs[] = {
809 "DESC 'OpenLDAP configuration object' "
810 "ABSTRACT SUP top )", Cft_Abstract, NULL },
813 "DESC 'OpenLDAP Global configuration options' "
814 "SUP olcConfig STRUCTURAL "
815 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
816 "olcAttributeOptions $ olcAuthIDRewrite $ "
817 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
818 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
819 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
820 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
821 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcIndexIntLen $ "
822 "olcLocalSSF $ olcLogFile $ olcLogLevel $ "
823 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
824 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
825 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
827 "olcSaslAuxprops $ olcSaslAuxpropsDontUseCopy $ olcSaslAuxpropsDontUseCopyIgnore $ "
828 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
829 "olcSecurity $ olcServerID $ olcSizeLimit $ "
830 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
832 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
833 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
834 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
835 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
836 "olcTLSCRLFile $ olcToolThreads $ olcWriteTimeout $ "
837 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
838 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
840 "NAME 'olcSchemaConfig' "
841 "DESC 'OpenLDAP schema object' "
842 "SUP olcConfig STRUCTURAL "
843 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
844 "olcObjectClasses $ olcDitContentRules $ olcLdapSyntaxes ) )",
845 Cft_Schema, NULL, cfAddSchema },
847 "NAME 'olcBackendConfig' "
848 "DESC 'OpenLDAP Backend-specific options' "
849 "SUP olcConfig STRUCTURAL "
850 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
852 "NAME 'olcDatabaseConfig' "
853 "DESC 'OpenLDAP Database-specific options' "
854 "SUP olcConfig STRUCTURAL "
856 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
857 "olcAddContentAcl $ olcLastMod $ olcLimits $ "
858 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
859 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
860 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
861 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncUseSubentry $ olcSyncrepl $ "
862 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
863 "olcMonitoring $ olcExtraAttrs ) )",
864 Cft_Database, NULL, cfAddDatabase },
866 "NAME 'olcOverlayConfig' "
867 "DESC 'OpenLDAP Overlay-specific options' "
868 "SUP olcConfig STRUCTURAL "
869 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
871 "NAME 'olcIncludeFile' "
872 "DESC 'OpenLDAP configuration include file' "
873 "SUP olcConfig STRUCTURAL "
875 "MAY ( cn $ olcRootDSE ) )",
876 /* Used to be Cft_Include, that def has been removed */
877 Cft_Abstract, NULL, cfAddInclude },
878 /* This should be STRUCTURAL like all the other database classes, but
879 * that would mean inheriting all of the olcDatabaseConfig attributes,
880 * which causes them to be merged twice in config_build_entry.
883 "NAME 'olcFrontendConfig' "
884 "DESC 'OpenLDAP frontend configuration' "
886 "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
887 Cft_Database, NULL, NULL },
890 "NAME 'olcModuleList' "
891 "DESC 'OpenLDAP dynamic module info' "
892 "SUP olcConfig STRUCTURAL "
893 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
894 Cft_Module, NULL, cfAddModule },
899 typedef struct ServerID {
900 struct ServerID *si_next;
901 struct berval si_url;
905 static ServerID *sid_list;
907 typedef struct voidList {
908 struct voidList *vl_next;
912 typedef struct ADlist {
913 struct ADlist *al_next;
914 AttributeDescription *al_desc;
917 static ADlist *sortVals;
920 config_generic(ConfigArgs *c) {
923 if ( c->op == SLAP_CONFIG_EMIT ) {
927 c->value_int = ldap_pvt_thread_get_concurrency();
930 c->value_int = connection_pool_max;
933 c->value_int = slap_tool_thread_max;
936 c->value_uint = slapd_daemon_threads;
940 c->value_string = ch_strdup( passwd_salt );
945 if ( c->be->be_limits ) {
949 for ( i=0; c->be->be_limits[i]; i++ ) {
950 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
951 if ( bv.bv_len >= sizeof( buf ) ) {
952 ber_bvarray_free_x( c->rvalue_vals, NULL );
953 c->rvalue_vals = NULL;
957 bv.bv_val = buf + bv.bv_len;
958 limits_unparse( c->be->be_limits[i], &bv,
959 sizeof( buf ) - ( bv.bv_val - buf ) );
960 bv.bv_len += bv.bv_val - buf;
962 value_add_one( &c->rvalue_vals, &bv );
965 if ( !c->rvalue_vals ) rc = 1;
968 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
971 c->value_string = ch_strdup( slap_sasl_getpolicy());
974 slap_sasl_regexp_unparse( &c->rvalue_vals );
975 if ( !c->rvalue_vals ) rc = 1;
977 #ifdef HAVE_CYRUS_SASL
978 #ifdef SLAP_AUXPROP_DONTUSECOPY
980 static int duc_done = 0;
982 /* take the opportunity to initialize with known values */
984 struct berval duc[] = { BER_BVC("cmusaslsecretOTP"), BER_BVNULL };
987 for ( i = 0; !BER_BVISNULL( &duc[ i ] ); i++ ) {
988 const char *text = NULL;
989 AttributeDescription *ad = NULL;
991 if ( slap_bv2ad( &duc[ i ], &ad, &text ) == LDAP_SUCCESS ) {
993 if ( slap_dontUseCopy_propnames ) {
996 for ( j = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ j ] ); j++ ) {
997 if ( bvmatch( &slap_dontUseCopy_propnames[ j ], &ad->ad_cname ) ) {
1004 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1012 if ( slap_dontUseCopy_propnames != NULL ) {
1013 ber_bvarray_dup_x( &c->rvalue_vals, slap_dontUseCopy_propnames, NULL );
1018 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1019 case CFG_SASLSECP: {
1020 struct berval bv = BER_BVNULL;
1021 slap_sasl_secprops_unparse( &bv );
1022 if ( !BER_BVISNULL( &bv )) {
1023 ber_bvarray_add( &c->rvalue_vals, &bv );
1031 c->value_int = c->be->be_max_deref_depth;
1034 if ( SLAP_DBHIDDEN( c->be )) {
1041 ConfigFile *cf = c->ca_private;
1043 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1044 else if ( cf->c_om_head )
1045 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
1047 if ( !c->rvalue_vals )
1052 ad_unparse_options( &c->rvalue_vals );
1055 ConfigFile *cf = c->ca_private;
1057 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1058 else if ( cf->c_oc_head )
1059 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
1061 if ( !c->rvalue_vals )
1066 ConfigFile *cf = c->ca_private;
1068 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1069 else if ( cf->c_at_head )
1070 at_unparse( &c->rvalue_vals, cf->c_at_head,
1072 if ( !c->rvalue_vals )
1077 ConfigFile *cf = c->ca_private;
1079 syn_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1080 else if ( cf->c_syn_head )
1081 syn_unparse( &c->rvalue_vals, cf->c_syn_head,
1082 cf->c_syn_tail, 0 );
1083 if ( !c->rvalue_vals )
1088 ConfigFile *cf = c->ca_private;
1090 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1091 else if ( cf->c_cr_head )
1092 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
1094 if ( !c->rvalue_vals )
1101 char *src, *dst, ibuf[11];
1102 struct berval bv, abv;
1103 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
1104 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1105 if ( abv.bv_len >= sizeof( ibuf ) ) {
1106 ber_bvarray_free_x( c->rvalue_vals, NULL );
1107 c->rvalue_vals = NULL;
1111 acl_unparse( a, &bv );
1112 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
1113 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
1114 /* Turn TAB / EOL into plain space */
1115 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
1116 if (isspace((unsigned char)*src)) *dst++ = ' ';
1120 if (dst[-1] == ' ') {
1124 abv.bv_len = dst - abv.bv_val;
1125 ber_bvarray_add( &c->rvalue_vals, &abv );
1131 c->value_int = (SLAP_DBACL_ADD(c->be) != 0);
1134 ConfigFile *cf = c->ca_private;
1135 if ( cf->c_dseFiles ) {
1136 value_add( &c->rvalue_vals, cf->c_dseFiles );
1147 for ( si = sid_list; si; si=si->si_next ) {
1148 assert( si->si_num >= 0 && si->si_num <= SLAP_SYNC_SID_MAX );
1149 if ( !BER_BVISEMPTY( &si->si_url )) {
1150 bv.bv_len = si->si_url.bv_len + 6;
1151 bv.bv_val = ch_malloc( bv.bv_len );
1152 bv.bv_len = sprintf( bv.bv_val, "%d %s", si->si_num,
1153 si->si_url.bv_val );
1154 ber_bvarray_add( &c->rvalue_vals, &bv );
1158 bv.bv_len = sprintf( buf, "%d", si->si_num );
1159 value_add_one( &c->rvalue_vals, &bv );
1168 c->value_string = ch_strdup( logfileName );
1173 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
1175 case CFG_SYNC_SUBENTRY:
1176 c->value_int = (SLAP_SYNC_SUBENTRY(c->be) != 0);
1178 case CFG_MIRRORMODE:
1179 if ( SLAP_SHADOW(c->be))
1180 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
1184 case CFG_MONITORING:
1185 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
1187 case CFG_SSTR_IF_MAX:
1188 c->value_uint = index_substr_if_maxlen;
1190 case CFG_SSTR_IF_MIN:
1191 c->value_uint = index_substr_if_minlen;
1194 c->value_int = index_intlen;
1196 case CFG_SORTVALS: {
1199 for ( sv = sortVals; sv; sv = sv->al_next ) {
1200 value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
1204 #ifdef SLAPD_MODULES
1206 ModPaths *mp = c->ca_private;
1209 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
1212 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
1213 SLAP_X_ORDERED_FMT "%s", i,
1214 mp->mp_loads[i].bv_val );
1215 if ( bv.bv_len >= sizeof( c->log ) ) {
1216 ber_bvarray_free_x( c->rvalue_vals, NULL );
1217 c->rvalue_vals = NULL;
1220 value_add_one( &c->rvalue_vals, &bv );
1224 rc = c->rvalue_vals ? 0 : 1;
1228 ModPaths *mp = c->ca_private;
1229 if ( !BER_BVISNULL( &mp->mp_path ))
1230 value_add_one( &c->rvalue_vals, &mp->mp_path );
1232 rc = c->rvalue_vals ? 0 : 1;
1238 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1239 if ( !c->rvalue_vals ) rc = 1;
1242 #ifdef SLAP_AUTH_REWRITE
1244 if ( authz_rewrites ) {
1245 struct berval bv, idx;
1250 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1251 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1252 if ( idx.bv_len >= sizeof( ibuf ) ) {
1253 ber_bvarray_free_x( c->rvalue_vals, NULL );
1254 c->rvalue_vals = NULL;
1257 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1258 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1259 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1260 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1261 authz_rewrites[i].bv_val,
1262 authz_rewrites[i].bv_len + 1 );
1263 ber_bvarray_add( &c->rvalue_vals, &bv );
1266 if ( !c->rvalue_vals ) rc = 1;
1273 } else if ( c->op == LDAP_MOD_DELETE ) {
1276 /* single-valued attrs, no-ops */
1285 case CFG_MIRRORMODE:
1286 case CFG_MONITORING:
1288 case CFG_SSTR_IF_MAX:
1289 case CFG_SSTR_IF_MIN:
1291 case CFG_SYNC_SUBENTRY:
1294 /* no-ops, requires slapd restart */
1299 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1302 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
1304 if ( c->valx < 0 ) {
1305 if ( slap_dontUseCopy_propnames != NULL ) {
1306 ber_bvarray_free( slap_dontUseCopy_propnames );
1307 slap_dontUseCopy_propnames = NULL;
1313 if ( slap_dontUseCopy_propnames == NULL ) {
1318 for ( i = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i ] ) && i < c->valx; i++ );
1319 if ( i < c->valx ) {
1323 ber_memfree( slap_dontUseCopy_propnames[ i ].bv_val );
1324 for ( ; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i + 1 ] ); i++ ) {
1325 slap_dontUseCopy_propnames[ i ] = slap_dontUseCopy_propnames[ i + 1 ];
1327 BER_BVZERO( &slap_dontUseCopy_propnames[ i ] );
1330 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1332 ch_free( passwd_salt );
1337 ch_free( logfileName );
1345 case CFG_SERVERID: {
1346 ServerID *si, **sip;
1348 for ( i=0, si = sid_list, sip = &sid_list;
1349 si; si = *sip, i++ ) {
1350 if ( c->valx == -1 || i == c->valx ) {
1362 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1366 index_intlen = SLAP_INDEX_INTLEN_DEFAULT;
1367 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1368 SLAP_INDEX_INTLEN_DEFAULT );
1372 if ( c->valx < 0 ) {
1373 acl_destroy( c->be->be_acl );
1374 c->be->be_acl = NULL;
1377 AccessControl **prev, *a;
1379 for (i=0, prev = &c->be->be_acl; i < c->valx;
1382 prev = &a->acl_next;
1385 *prev = a->acl_next;
1392 /* Can be NULL when undoing a failed add */
1393 if ( c->ca_entry ) {
1394 ce = c->ca_entry->e_private;
1395 /* can't modify the hardcoded schema */
1396 if ( ce->ce_parent->ce_type == Cft_Global )
1400 cfn = c->ca_private;
1401 if ( c->valx < 0 ) {
1404 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1406 if ( oc == cfn->c_oc_tail )
1409 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1411 ObjectClass *oc, *prev = NULL;
1413 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1418 if ( cfn->c_oc_tail == oc ) {
1419 cfn->c_oc_tail = prev;
1421 if ( cfn->c_oc_head == oc ) {
1423 cfn->c_oc_head = oc;
1430 /* Can be NULL when undoing a failed add */
1431 if ( c->ca_entry ) {
1432 ce = c->ca_entry->e_private;
1433 /* can't modify the hardcoded schema */
1434 if ( ce->ce_parent->ce_type == Cft_Global )
1438 cfn = c->ca_private;
1439 if ( c->valx < 0 ) {
1442 for( at = cfn->c_at_head; at; at_next( &at )) {
1444 if ( at == cfn->c_at_tail )
1447 cfn->c_at_head = cfn->c_at_tail = NULL;
1449 AttributeType *at, *prev = NULL;
1451 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1456 if ( cfn->c_at_tail == at ) {
1457 cfn->c_at_tail = prev;
1459 if ( cfn->c_at_head == at ) {
1461 cfn->c_at_head = at;
1468 /* Can be NULL when undoing a failed add */
1469 if ( c->ca_entry ) {
1470 ce = c->ca_entry->e_private;
1471 /* can't modify the hardcoded schema */
1472 if ( ce->ce_parent->ce_type == Cft_Global )
1476 cfn = c->ca_private;
1477 if ( c->valx < 0 ) {
1480 for( syn = cfn->c_syn_head; syn; syn_next( &syn )) {
1482 if ( syn == cfn->c_syn_tail )
1485 cfn->c_syn_head = cfn->c_syn_tail = NULL;
1487 Syntax *syn, *prev = NULL;
1489 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++) {
1494 if ( cfn->c_syn_tail == syn ) {
1495 cfn->c_syn_tail = prev;
1497 if ( cfn->c_syn_head == syn ) {
1499 cfn->c_syn_head = syn;
1504 if ( c->valx < 0 ) {
1506 for ( sv = sortVals; sv; sv = sortVals ) {
1507 sortVals = sv->al_next;
1508 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1515 for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
1516 prev = &sv->al_next;
1519 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1520 *prev = sv->al_next;
1526 /* FIXME: there is no limits_free function */
1527 if ( c->valx < 0 ) {
1528 limits_destroy( c->be->be_limits );
1529 c->be->be_limits = NULL;
1534 if ( c->be->be_limits ) {
1535 for ( num = 0; c->be->be_limits[ num ]; num++ )
1539 if ( c->valx >= num ) {
1544 limits_destroy( c->be->be_limits );
1545 c->be->be_limits = NULL;
1548 limits_free_one( c->be->be_limits[ c->valx ] );
1550 for ( cnt = c->valx; cnt < num; cnt++ ) {
1551 c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
1558 /* FIXME: there is no ad_option_free function */
1560 /* FIXME: there is no way to remove attributes added by
1574 if(!(c->bi = backend_info(c->argv[1]))) {
1575 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1576 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1577 c->log, c->cr_msg, c->argv[1] );
1584 /* NOTE: config is always the first backend!
1586 if ( !strcasecmp( c->argv[1], "config" )) {
1587 c->be = LDAP_STAILQ_FIRST(&backendDB);
1588 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1591 c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply);
1593 if ( c->cr_msg[0] == 0 )
1594 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1595 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n", c->log, c->cr_msg, c->argv[1] );
1602 ldap_pvt_thread_set_concurrency(c->value_int);
1606 if ( c->value_int < 2 ) {
1607 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1608 "threads=%d smaller than minimum value 2",
1610 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1611 c->log, c->cr_msg, 0 );
1614 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1615 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1616 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1617 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1618 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1619 c->log, c->cr_msg, 0 );
1621 if ( slapMode & SLAP_SERVER_MODE )
1622 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1623 connection_pool_max = c->value_int; /* save for reference */
1627 if ( slapMode & SLAP_TOOL_MODE )
1628 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1629 slap_tool_thread_max = c->value_int; /* save for reference */
1634 /* use a power of two */
1635 while (c->value_uint > 1) {
1636 c->value_uint >>= 1;
1640 slapd_daemon_mask = mask;
1641 slapd_daemon_threads = mask+1;
1646 if ( passwd_salt ) ch_free( passwd_salt );
1647 passwd_salt = c->value_string;
1648 lutil_salt_format(passwd_salt);
1652 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1658 c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1660 c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1664 ch_free(c->value_string);
1665 if (slap_sasl_setpolicy( c->argv[1] )) {
1666 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
1667 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1668 c->log, c->cr_msg, c->argv[1] );
1674 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1678 #ifdef HAVE_CYRUS_SASL
1679 #ifdef SLAP_AUXPROP_DONTUSECOPY
1683 for ( arg = 1; arg < c->argc; arg++ ) {
1684 int duplicate = 0, err;
1685 AttributeDescription *ad = NULL;
1686 const char *text = NULL;
1688 err = slap_str2ad( c->argv[ arg ], &ad, &text );
1689 if ( err != LDAP_SUCCESS ) {
1690 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") unknown (err=%d \"%s\"; ignored)",
1691 c->argv[0], arg, c->argv[ arg ], err, text );
1692 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1693 c->log, c->cr_msg, 0 );
1696 if ( slap_dontUseCopy_propnames != NULL ) {
1697 for ( cnt = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ cnt ] ); cnt++ ) {
1698 if ( bvmatch( &slap_dontUseCopy_propnames[ cnt ], &ad->ad_cname ) ) {
1706 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") already defined (ignored)",
1707 c->argv[0], arg, ad->ad_cname.bv_val);
1708 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1709 c->log, c->cr_msg, 0 );
1713 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1718 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1722 char *txt = slap_sasl_secprops( c->argv[1] );
1724 snprintf( c->cr_msg, sizeof(c->cr_msg), "<%s> %s",
1726 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0 );
1734 c->be->be_max_deref_depth = c->value_int;
1740 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1741 cfn = c->ca_private;
1742 if(parse_oidm(c, 1, &om))
1744 if (!cfn->c_om_head) cfn->c_om_head = om;
1745 cfn->c_om_tail = om;
1750 ObjectClass *oc, *prev;
1752 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1753 cfn = c->ca_private;
1754 if ( c->valx < 0 ) {
1755 prev = cfn->c_oc_tail;
1758 /* If adding anything after the first, prev is easy */
1761 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1766 /* If adding the first, and head exists, find its prev */
1767 if (cfn->c_oc_head) {
1768 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1773 /* else prev is NULL, append to end of global list */
1775 if(parse_oc(c, &oc, prev)) return(1);
1776 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1777 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1782 AttributeType *at, *prev;
1784 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1785 cfn = c->ca_private;
1786 if ( c->valx < 0 ) {
1787 prev = cfn->c_at_tail;
1790 /* If adding anything after the first, prev is easy */
1793 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1798 /* If adding the first, and head exists, find its prev */
1799 if (cfn->c_at_head) {
1800 for ( at_start( &at ); at != cfn->c_at_head; ) {
1805 /* else prev is NULL, append to end of global list */
1807 if(parse_at(c, &at, prev)) return(1);
1808 if (!cfn->c_at_head) cfn->c_at_head = at;
1809 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1816 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1817 cfn = c->ca_private;
1818 if ( c->valx < 0 ) {
1819 prev = cfn->c_syn_tail;
1822 /* If adding anything after the first, prev is easy */
1825 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
1830 /* If adding the first, and head exists, find its prev */
1831 if (cfn->c_syn_head) {
1832 for ( syn_start( &syn ); syn != cfn->c_syn_head; ) {
1837 /* else prev is NULL, append to end of global list */
1839 if ( parse_syn( c, &syn, prev ) ) return(1);
1840 if ( !cfn->c_syn_head ) cfn->c_syn_head = syn;
1841 if ( cfn->c_syn_tail == prev ) cfn->c_syn_tail = syn;
1848 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1849 cfn = c->ca_private;
1850 if(parse_cr(c, &cr)) return(1);
1851 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1852 cfn->c_cr_tail = cr;
1857 ad_define_option(NULL, NULL, 0);
1858 for(i = 1; i < c->argc; i++)
1859 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1864 if ( c->value_int < SLAP_INDEX_INTLEN_DEFAULT )
1865 c->value_int = SLAP_INDEX_INTLEN_DEFAULT;
1866 else if ( c->value_int > 255 )
1868 index_intlen = c->value_int;
1869 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1873 case CFG_SORTVALS: {
1874 ADlist *svnew = NULL, *svtail, *sv;
1876 for ( i = 1; i < c->argc; i++ ) {
1877 AttributeDescription *ad = NULL;
1881 rc = slap_str2ad( c->argv[i], &ad, &text );
1883 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
1886 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1887 c->log, c->cr_msg, c->argv[i] );
1888 for ( sv = svnew; sv; sv = svnew ) {
1889 svnew = sv->al_next;
1894 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
1895 ad->ad_type->sat_single_value ) {
1896 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
1898 goto sortval_reject;
1900 sv = ch_malloc( sizeof( ADlist ));
1905 svtail->al_next = sv;
1910 for ( sv = svnew; sv; sv = sv->al_next )
1911 sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
1912 for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
1914 sv->al_next = svnew;
1921 /* Don't append to the global ACL if we're on a specific DB */
1923 if ( c->valx == -1 ) {
1926 for ( a=c->be->be_acl; a; a = a->acl_next )
1929 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1936 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_ACL_ADD;
1938 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_ACL_ADD;
1942 if(root_dse_read_file(c->argv[1])) {
1943 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> could not read file", c->argv[0] );
1944 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1945 c->log, c->cr_msg, c->argv[1] );
1950 ber_str2bv( c->argv[1], 0, 1, &bv );
1951 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1952 cfn = c->ca_private;
1953 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1959 ServerID *si, **sip;
1962 if (( lutil_atoi( &num, c->argv[1] ) &&
1963 lutil_atoix( &num, c->argv[1], 16 )) ||
1964 num < 0 || num > SLAP_SYNC_SID_MAX )
1966 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1967 "<%s> illegal server ID", c->argv[0] );
1968 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1969 c->log, c->cr_msg, c->argv[1] );
1972 /* only one value allowed if no URL is given */
1973 if ( c->argc > 2 ) {
1976 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1977 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1978 "<%s> only one server ID allowed now", c->argv[0] );
1979 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1980 c->log, c->cr_msg, c->argv[1] );
1984 if ( ldap_url_parse( c->argv[2], &lud )) {
1985 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1986 "<%s> invalid URL", c->argv[0] );
1987 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1988 c->log, c->cr_msg, c->argv[2] );
1991 len = strlen( c->argv[2] );
1992 si = ch_malloc( sizeof(ServerID) + len + 1 );
1993 si->si_url.bv_val = (char *)(si+1);
1994 si->si_url.bv_len = len;
1995 strcpy( si->si_url.bv_val, c->argv[2] );
1998 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1999 "<%s> unqualified server ID not allowed now", c->argv[0] );
2000 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2001 c->log, c->cr_msg, c->argv[1] );
2004 si = ch_malloc( sizeof(ServerID) );
2005 BER_BVZERO( &si->si_url );
2006 slap_serverID = num;
2007 Debug( LDAP_DEBUG_CONFIG,
2009 c->log, slap_serverID, 0 );
2013 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
2016 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
2017 Listener *l = config_check_my_url( c->argv[2], lud );
2019 slap_serverID = si->si_num;
2020 Debug( LDAP_DEBUG_CONFIG,
2021 "%s: SID=0x%03x (listener=%s)\n",
2022 c->log, slap_serverID,
2027 ldap_free_urldesc( lud );
2031 if ( logfileName ) ch_free( logfileName );
2032 logfileName = c->value_string;
2033 logfile = fopen(logfileName, "w");
2034 if(logfile) lutil_debug_file(logfile);
2038 if(SLAP_NOLASTMODCMD(c->be)) {
2039 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> not available for %s database",
2040 c->argv[0], c->be->bd_info->bi_type );
2041 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2042 c->log, c->cr_msg, 0 );
2046 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
2048 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
2051 case CFG_MIRRORMODE:
2052 if(c->value_int && !SLAP_SHADOW(c->be)) {
2053 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database is not a shadow",
2055 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2056 c->log, c->cr_msg, 0 );
2060 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
2062 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
2065 case CFG_MONITORING:
2067 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
2069 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
2074 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
2076 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
2079 case CFG_SYNC_SUBENTRY:
2081 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SYNC_SUBENTRY;
2083 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SYNC_SUBENTRY;
2086 case CFG_SSTR_IF_MAX:
2087 if (c->value_uint < index_substr_if_minlen) {
2088 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2089 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2090 c->log, c->cr_msg, c->value_int );
2093 index_substr_if_maxlen = c->value_uint;
2096 case CFG_SSTR_IF_MIN:
2097 if (c->value_uint > index_substr_if_maxlen) {
2098 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2099 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2100 c->log, c->cr_msg, c->value_int );
2103 index_substr_if_minlen = c->value_uint;
2106 #ifdef SLAPD_MODULES
2108 /* If we're just adding a module on an existing modpath,
2109 * make sure we've selected the current path.
2111 if ( c->op == LDAP_MOD_ADD && c->ca_private && modcur != c->ca_private ) {
2112 modcur = c->ca_private;
2113 /* This should never fail */
2114 if ( module_path( modcur->mp_path.bv_val )) {
2115 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> module path no longer valid",
2117 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2118 c->log, c->cr_msg, modcur->mp_path.bv_val );
2122 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
2124 /* Record this load on the current path */
2128 if ( c->op == SLAP_CONFIG_ADD ) {
2129 ptr = c->line + STRLENOF("moduleload");
2130 while (!isspace((unsigned char) *ptr)) ptr++;
2131 while (isspace((unsigned char) *ptr)) ptr++;
2135 ber_str2bv(ptr, 0, 1, &bv);
2136 ber_bvarray_add( &modcur->mp_loads, &bv );
2138 /* Check for any new hardcoded schema */
2139 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
2140 config_check_schema( NULL, &cfBackInfo );
2145 if(module_path(c->argv[1])) return(1);
2146 /* Record which path was used with each module */
2150 if (!modpaths.mp_loads) {
2153 mp = ch_malloc( sizeof( ModPaths ));
2154 modlast->mp_next = mp;
2156 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
2158 mp->mp_loads = NULL;
2169 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
2171 slapi_plugins_used++;
2175 #ifdef SLAP_AUTH_REWRITE
2181 if ( c->op == LDAP_MOD_ADD ) {
2185 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
2189 if ( c->argc > 1 ) {
2192 /* quote all args but the first */
2193 line = ldap_charray2str( c->argv, "\" \"" );
2194 ber_str2bv( line, 0, 0, &bv );
2195 s = ber_bvchr( &bv, '"' );
2196 assert( s != NULL );
2197 /* move the trailing quote of argv[0] to the end */
2198 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
2199 bv.bv_val[ bv.bv_len - 1 ] = '"';
2202 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
2205 ber_bvarray_add( &authz_rewrites, &bv );
2207 if ( c->op == LDAP_MOD_ADD ) {
2217 Debug( LDAP_DEBUG_ANY,
2218 "%s: unknown CFG_TYPE %d.\n",
2219 c->log, c->type, 0 );
2228 config_fname(ConfigArgs *c) {
2229 if(c->op == SLAP_CONFIG_EMIT) {
2230 if (c->ca_private) {
2231 ConfigFile *cf = c->ca_private;
2232 value_add_one( &c->rvalue_vals, &cf->c_file );
2241 config_cfdir(ConfigArgs *c) {
2242 if(c->op == SLAP_CONFIG_EMIT) {
2243 if ( !BER_BVISEMPTY( &cfdir )) {
2244 value_add_one( &c->rvalue_vals, &cfdir );
2253 config_search_base(ConfigArgs *c) {
2254 if(c->op == SLAP_CONFIG_EMIT) {
2256 if (!BER_BVISEMPTY(&default_search_base)) {
2257 value_add_one(&c->rvalue_vals, &default_search_base);
2258 value_add_one(&c->rvalue_nvals, &default_search_nbase);
2262 } else if( c->op == LDAP_MOD_DELETE ) {
2263 ch_free( default_search_base.bv_val );
2264 ch_free( default_search_nbase.bv_val );
2265 BER_BVZERO( &default_search_base );
2266 BER_BVZERO( &default_search_nbase );
2270 if(c->bi || c->be != frontendDB) {
2271 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
2272 "prior to any backend or database definition\n",
2277 if(default_search_nbase.bv_len) {
2278 free(default_search_base.bv_val);
2279 free(default_search_nbase.bv_val);
2282 default_search_base = c->value_dn;
2283 default_search_nbase = c->value_ndn;
2287 /* For RE23 compatibility we allow this in the global entry
2288 * but we now defer it to the frontend entry to allow modules
2289 * to load new hash types.
2292 config_passwd_hash(ConfigArgs *c) {
2294 if (c->op == SLAP_CONFIG_EMIT) {
2296 /* Don't generate it in the global entry */
2297 if ( c->table == Cft_Global )
2299 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
2300 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
2301 value_add_one(&c->rvalue_vals, &bv);
2304 } else if ( c->op == LDAP_MOD_DELETE ) {
2305 /* Deleting from global is a no-op, only the frontendDB entry matters */
2306 if ( c->table == Cft_Global )
2308 if ( c->valx < 0 ) {
2309 ldap_charray_free( default_passwd_hash );
2310 default_passwd_hash = NULL;
2313 ch_free( default_passwd_hash[i] );
2314 for (; default_passwd_hash[i]; i++ )
2315 default_passwd_hash[i] = default_passwd_hash[i+1];
2319 for(i = 1; i < c->argc; i++) {
2320 if(!lutil_passwd_scheme(c->argv[i])) {
2321 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
2322 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2323 c->log, c->cr_msg, c->argv[i]);
2325 ldap_charray_add(&default_passwd_hash, c->argv[i]);
2328 if(!default_passwd_hash) {
2329 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
2330 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2331 c->log, c->cr_msg, 0 );
2338 config_schema_dn(ConfigArgs *c) {
2339 if ( c->op == SLAP_CONFIG_EMIT ) {
2341 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
2342 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
2343 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
2347 } else if ( c->op == LDAP_MOD_DELETE ) {
2348 ch_free( c->be->be_schemadn.bv_val );
2349 ch_free( c->be->be_schemandn.bv_val );
2350 BER_BVZERO( &c->be->be_schemadn );
2351 BER_BVZERO( &c->be->be_schemandn );
2354 ch_free( c->be->be_schemadn.bv_val );
2355 ch_free( c->be->be_schemandn.bv_val );
2356 c->be->be_schemadn = c->value_dn;
2357 c->be->be_schemandn = c->value_ndn;
2362 config_sizelimit(ConfigArgs *c) {
2364 struct slap_limits_set *lim = &c->be->be_def_limit;
2365 if (c->op == SLAP_CONFIG_EMIT) {
2370 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
2371 if ( !BER_BVISEMPTY( &bv ))
2372 value_add_one( &c->rvalue_vals, &bv );
2376 } else if ( c->op == LDAP_MOD_DELETE ) {
2377 /* Reset to defaults or values from frontend */
2378 if ( c->be == frontendDB ) {
2379 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
2380 lim->lms_s_hard = 0;
2381 lim->lms_s_unchecked = -1;
2383 lim->lms_s_pr_hide = 0;
2384 lim->lms_s_pr_total = 0;
2386 lim->lms_s_soft = frontendDB->be_def_limit.lms_s_soft;
2387 lim->lms_s_hard = frontendDB->be_def_limit.lms_s_hard;
2388 lim->lms_s_unchecked = frontendDB->be_def_limit.lms_s_unchecked;
2389 lim->lms_s_pr = frontendDB->be_def_limit.lms_s_pr;
2390 lim->lms_s_pr_hide = frontendDB->be_def_limit.lms_s_pr_hide;
2391 lim->lms_s_pr_total = frontendDB->be_def_limit.lms_s_pr_total;
2395 for(i = 1; i < c->argc; i++) {
2396 if(!strncasecmp(c->argv[i], "size", 4)) {
2397 rc = limits_parse_one(c->argv[i], lim);
2399 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2400 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2401 c->log, c->cr_msg, c->argv[i]);
2405 if(!strcasecmp(c->argv[i], "unlimited")) {
2406 lim->lms_s_soft = -1;
2408 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
2409 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2410 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2411 c->log, c->cr_msg, c->argv[i]);
2415 lim->lms_s_hard = 0;
2420 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2421 /* This is a modification to the global limits apply it to
2422 * the other databases as needed */
2423 AttributeDescription *ad=NULL;
2424 const char *text = NULL;
2425 CfEntryInfo *ce = c->ca_entry->e_private;
2427 slap_str2ad(c->argv[0], &ad, &text);
2428 /* if we got here... */
2429 assert( ad != NULL );
2431 if ( ce->ce_type == Cft_Global ){
2434 for (; ce; ce=ce->ce_sibs) {
2435 Entry *dbe = ce->ce_entry;
2436 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2437 && (!attr_find(dbe->e_attrs, ad)) ) {
2438 ce->ce_be->be_def_limit.lms_s_soft = lim->lms_s_soft;
2439 ce->ce_be->be_def_limit.lms_s_hard = lim->lms_s_hard;
2440 ce->ce_be->be_def_limit.lms_s_unchecked =lim->lms_s_unchecked;
2441 ce->ce_be->be_def_limit.lms_s_pr =lim->lms_s_pr;
2442 ce->ce_be->be_def_limit.lms_s_pr_hide =lim->lms_s_pr_hide;
2443 ce->ce_be->be_def_limit.lms_s_pr_total =lim->lms_s_pr_total;
2451 config_timelimit(ConfigArgs *c) {
2453 struct slap_limits_set *lim = &c->be->be_def_limit;
2454 if (c->op == SLAP_CONFIG_EMIT) {
2459 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
2460 if ( !BER_BVISEMPTY( &bv ))
2461 value_add_one( &c->rvalue_vals, &bv );
2465 } else if ( c->op == LDAP_MOD_DELETE ) {
2466 /* Reset to defaults or values from frontend */
2467 if ( c->be == frontendDB ) {
2468 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
2469 lim->lms_t_hard = 0;
2471 lim->lms_t_soft = frontendDB->be_def_limit.lms_t_soft;
2472 lim->lms_t_hard = frontendDB->be_def_limit.lms_t_hard;
2476 for(i = 1; i < c->argc; i++) {
2477 if(!strncasecmp(c->argv[i], "time", 4)) {
2478 rc = limits_parse_one(c->argv[i], lim);
2480 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2481 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2482 c->log, c->cr_msg, c->argv[i]);
2486 if(!strcasecmp(c->argv[i], "unlimited")) {
2487 lim->lms_t_soft = -1;
2489 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
2490 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2491 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2492 c->log, c->cr_msg, c->argv[i]);
2496 lim->lms_t_hard = 0;
2501 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2502 /* This is a modification to the global limits apply it to
2503 * the other databases as needed */
2504 AttributeDescription *ad=NULL;
2505 const char *text = NULL;
2506 CfEntryInfo *ce = c->ca_entry->e_private;
2508 slap_str2ad(c->argv[0], &ad, &text);
2509 /* if we got here... */
2510 assert( ad != NULL );
2512 if ( ce->ce_type == Cft_Global ){
2515 for (; ce; ce=ce->ce_sibs) {
2516 Entry *dbe = ce->ce_entry;
2517 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2518 && (!attr_find(dbe->e_attrs, ad)) ) {
2519 ce->ce_be->be_def_limit.lms_t_soft = lim->lms_t_soft;
2520 ce->ce_be->be_def_limit.lms_t_hard = lim->lms_t_hard;
2528 config_overlay(ConfigArgs *c) {
2529 if (c->op == SLAP_CONFIG_EMIT) {
2531 } else if ( c->op == LDAP_MOD_DELETE ) {
2534 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
2535 c->valx, &c->bi, &c->reply)) {
2537 Debug( LDAP_DEBUG_ANY,
2538 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
2539 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
2541 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi, &c->reply)) {
2548 config_subordinate(ConfigArgs *c)
2554 case SLAP_CONFIG_EMIT:
2555 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
2558 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
2559 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
2562 value_add_one( &c->rvalue_vals, &bv );
2566 case LDAP_MOD_DELETE:
2567 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2568 glue_sub_del( c->be );
2570 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2575 case SLAP_CONFIG_ADD:
2576 if ( c->be->be_nsuffix == NULL ) {
2578 snprintf( c->cr_msg, sizeof( c->cr_msg),
2579 "subordinate configuration needs a suffix" );
2580 Debug( LDAP_DEBUG_ANY,
2582 c->log, c->cr_msg, 0 );
2587 if ( c->argc == 2 ) {
2588 if ( strcasecmp( c->argv[1], "advertise" ) == 0 ) {
2591 } else if ( strcasecmp( c->argv[1], "TRUE" ) != 0 ) {
2593 snprintf( c->cr_msg, sizeof( c->cr_msg),
2594 "subordinate must be \"TRUE\" or \"advertise\"" );
2595 Debug( LDAP_DEBUG_ANY,
2596 "%s: suffix \"%s\": %s.\n",
2597 c->log, c->be->be_suffix[0].bv_val, c->cr_msg );
2603 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2611 * [listener=<listener>] [{read|write}=]<size>
2614 #ifdef LDAP_TCP_BUFFER
2615 static BerVarray tcp_buffer;
2618 #define SLAP_TCP_RMEM (0x1U)
2619 #define SLAP_TCP_WMEM (0x2U)
2622 tcp_buffer_parse( struct berval *val, int argc, char **argv,
2623 int *size, int *rw, Listener **l )
2625 int i, rc = LDAP_SUCCESS;
2626 LDAPURLDesc *lud = NULL;
2629 if ( val != NULL && argv == NULL ) {
2630 char *s = val->bv_val;
2632 argv = ldap_str2charray( s, " \t" );
2633 if ( argv == NULL ) {
2639 if ( strncasecmp( argv[ i ], "listener=", STRLENOF( "listener=" ) )
2642 char *url = argv[ i ] + STRLENOF( "listener=" );
2644 if ( ldap_url_parse( url, &lud ) ) {
2645 rc = LDAP_INVALID_SYNTAX;
2649 *l = config_check_my_url( url, lud );
2651 rc = LDAP_NO_SUCH_ATTRIBUTE;
2659 if ( strncasecmp( ptr, "read=", STRLENOF( "read=" ) ) == 0 ) {
2660 *rw |= SLAP_TCP_RMEM;
2661 ptr += STRLENOF( "read=" );
2663 } else if ( strncasecmp( ptr, "write=", STRLENOF( "write=" ) ) == 0 ) {
2664 *rw |= SLAP_TCP_WMEM;
2665 ptr += STRLENOF( "write=" );
2668 *rw |= ( SLAP_TCP_RMEM | SLAP_TCP_WMEM );
2671 /* accept any base */
2672 if ( lutil_atoix( size, ptr, 0 ) ) {
2673 rc = LDAP_INVALID_SYNTAX;
2678 if ( val != NULL && argv != NULL ) {
2679 ldap_charray_free( argv );
2682 if ( lud != NULL ) {
2683 ldap_free_urldesc( lud );
2690 tcp_buffer_delete_one( struct berval *val )
2693 int size = -1, rw = 0;
2696 rc = tcp_buffer_parse( val, 0, NULL, &size, &rw, &l );
2703 Listener **ll = slapd_get_listeners();
2705 for ( i = 0; ll[ i ] != NULL; i++ ) {
2706 if ( ll[ i ] == l ) break;
2709 if ( ll[ i ] == NULL ) {
2710 return LDAP_NO_SUCH_ATTRIBUTE;
2713 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = -1;
2714 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = -1;
2716 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2717 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = -1;
2718 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = -1;
2722 /* NOTE: this affects listeners without a specific setting,
2723 * does not reset all listeners. If a listener without
2724 * specific settings was assigned a buffer because of
2725 * a global setting, it will not be reset. In any case,
2726 * buffer changes will only take place at restart. */
2727 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = -1;
2728 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = -1;
2735 tcp_buffer_delete( BerVarray vals )
2739 for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ ) {
2740 tcp_buffer_delete_one( &vals[ i ] );
2747 tcp_buffer_unparse( int size, int rw, Listener *l, struct berval *val )
2749 char buf[sizeof("2147483648")], *ptr;
2751 /* unparse for later use */
2752 val->bv_len = snprintf( buf, sizeof( buf ), "%d", size );
2754 val->bv_len += STRLENOF( "listener=" " " ) + l->sl_url.bv_len;
2757 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2758 if ( rw & SLAP_TCP_RMEM ) {
2759 val->bv_len += STRLENOF( "read=" );
2760 } else if ( rw & SLAP_TCP_WMEM ) {
2761 val->bv_len += STRLENOF( "write=" );
2765 val->bv_val = SLAP_MALLOC( val->bv_len + 1 );
2770 ptr = lutil_strcopy( ptr, "listener=" );
2771 ptr = lutil_strncopy( ptr, l->sl_url.bv_val, l->sl_url.bv_len );
2775 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2776 if ( rw & SLAP_TCP_RMEM ) {
2777 ptr = lutil_strcopy( ptr, "read=" );
2778 } else if ( rw & SLAP_TCP_WMEM ) {
2779 ptr = lutil_strcopy( ptr, "write=" );
2783 ptr = lutil_strcopy( ptr, buf );
2786 assert( val->bv_val + val->bv_len == ptr );
2788 return LDAP_SUCCESS;
2792 tcp_buffer_add_one( int argc, char **argv )
2795 int size = -1, rw = 0;
2801 rc = tcp_buffer_parse( NULL, argc, argv, &size, &rw, &l );
2806 /* unparse for later use */
2807 rc = tcp_buffer_unparse( size, rw, l, &val );
2808 if ( rc != LDAP_SUCCESS ) {
2812 /* use parsed values */
2815 Listener **ll = slapd_get_listeners();
2817 for ( i = 0; ll[ i ] != NULL; i++ ) {
2818 if ( ll[ i ] == l ) break;
2821 if ( ll[ i ] == NULL ) {
2822 return LDAP_NO_SUCH_ATTRIBUTE;
2825 /* buffer only applies to TCP listeners;
2826 * we do not do any check here, and delegate them
2827 * to setsockopt(2) */
2828 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = size;
2829 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = size;
2831 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2832 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = size;
2833 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = size;
2837 /* NOTE: this affects listeners without a specific setting,
2838 * does not set all listeners */
2839 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = size;
2840 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = size;
2843 tcp_buffer = SLAP_REALLOC( tcp_buffer, sizeof( struct berval ) * ( tcp_buffer_num + 2 ) );
2845 tcp_buffer[ tcp_buffer_num ] = val;
2848 BER_BVZERO( &tcp_buffer[ tcp_buffer_num ] );
2854 config_tcp_buffer( ConfigArgs *c )
2856 if ( c->op == SLAP_CONFIG_EMIT ) {
2857 if ( tcp_buffer == NULL || BER_BVISNULL( &tcp_buffer[ 0 ] ) ) {
2860 value_add( &c->rvalue_vals, tcp_buffer );
2861 value_add( &c->rvalue_nvals, tcp_buffer );
2863 } else if ( c->op == LDAP_MOD_DELETE ) {
2865 tcp_buffer_delete( tcp_buffer );
2866 ber_bvarray_free( tcp_buffer );
2872 int size = -1, rw = 0;
2875 struct berval val = BER_BVNULL;
2879 if ( tcp_buffer_num == 0 ) {
2884 rc = tcp_buffer_parse( NULL, c->argc - 1, &c->argv[ 1 ], &size, &rw, &l );
2889 /* unparse for later use */
2890 rc = tcp_buffer_unparse( size, rw, l, &val );
2891 if ( rc != LDAP_SUCCESS ) {
2895 for ( i = 0; !BER_BVISNULL( &tcp_buffer[ i ] ); i++ ) {
2896 if ( bvmatch( &tcp_buffer[ i ], &val ) ) {
2901 if ( BER_BVISNULL( &tcp_buffer[ i ] ) ) {
2907 tcp_buffer_delete_one( &tcp_buffer[ i ] );
2908 ber_memfree( tcp_buffer[ i ].bv_val );
2909 for ( ; i < tcp_buffer_num; i++ ) {
2910 tcp_buffer[ i ] = tcp_buffer[ i + 1 ];
2915 if ( !BER_BVISNULL( &val ) ) {
2916 SLAP_FREE( val.bv_val );
2924 rc = tcp_buffer_add_one( c->argc - 1, &c->argv[ 1 ] );
2926 snprintf( c->cr_msg, sizeof( c->cr_msg ),
2927 "<%s> unable to add value #%d",
2928 c->argv[0], tcp_buffer_num );
2929 Debug( LDAP_DEBUG_ANY, "%s: %s\n",
2930 c->log, c->cr_msg, 0 );
2937 #endif /* LDAP_TCP_BUFFER */
2940 config_suffix(ConfigArgs *c)
2943 struct berval pdn, ndn;
2944 char *notallowed = NULL;
2946 if ( c->be == frontendDB ) {
2947 notallowed = "frontend";
2949 } else if ( SLAP_MONITOR(c->be) ) {
2950 notallowed = "monitor";
2952 } else if ( SLAP_CONFIG(c->be) ) {
2953 notallowed = "config";
2956 if ( notallowed != NULL ) {
2957 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2961 case LDAP_MOD_DELETE:
2962 case LDAP_MOD_REPLACE:
2963 case LDAP_MOD_INCREMENT:
2964 case SLAP_CONFIG_ADD:
2965 if ( !BER_BVISNULL( &c->value_dn ) ) {
2966 snprintf( buf, sizeof( buf ), "<%s> ",
2967 c->value_dn.bv_val );
2970 Debug(LDAP_DEBUG_ANY,
2971 "%s: suffix %snot allowed in %s database.\n",
2972 c->log, buf, notallowed );
2975 case SLAP_CONFIG_EMIT:
2976 /* don't complain when emitting... */
2980 /* FIXME: don't know what values may be valid;
2981 * please remove assertion, or add legal values
2982 * to either block */
2990 if (c->op == SLAP_CONFIG_EMIT) {
2991 if ( c->be->be_suffix == NULL
2992 || BER_BVISNULL( &c->be->be_suffix[0] ) )
2996 value_add( &c->rvalue_vals, c->be->be_suffix );
2997 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
3000 } else if ( c->op == LDAP_MOD_DELETE ) {
3001 if ( c->valx < 0 ) {
3002 ber_bvarray_free( c->be->be_suffix );
3003 ber_bvarray_free( c->be->be_nsuffix );
3004 c->be->be_suffix = NULL;
3005 c->be->be_nsuffix = NULL;
3008 ch_free( c->be->be_suffix[i].bv_val );
3009 ch_free( c->be->be_nsuffix[i].bv_val );
3011 c->be->be_suffix[i] = c->be->be_suffix[i+1];
3012 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
3014 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
3019 #ifdef SLAPD_MONITOR_DN
3020 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
3021 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> DN is reserved for monitoring slapd",
3023 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3024 c->log, c->cr_msg, SLAPD_MONITOR_DN);
3029 if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
3030 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
3031 c->argv[0], c->be->bd_info->bi_type );
3032 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3033 c->log, c->cr_msg, 0);
3040 if (SLAP_DBHIDDEN( c->be ))
3043 tbe = select_backend(&ndn, 0);
3045 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
3051 BackendDB *b2 = tbe;
3053 /* Does tbe precede be? */
3054 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
3057 char *type = tbe->bd_info->bi_type;
3059 if ( overlay_is_over( tbe ) ) {
3060 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
3061 type = oi->oi_orig->bi_type;
3064 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> namingContext \"%s\" "
3065 "already served by a preceding %s database",
3066 c->argv[0], pdn.bv_val, type );
3067 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
3068 c->log, c->cr_msg, tbe->be_suffix[0].bv_val);
3074 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
3075 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
3076 "base provided \"%s\" (assuming okay)\n",
3077 c->log, default_search_base.bv_val, 0);
3079 ber_bvarray_add(&c->be->be_suffix, &pdn);
3080 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
3085 config_rootdn(ConfigArgs *c) {
3086 if (c->op == SLAP_CONFIG_EMIT) {
3087 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3088 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
3089 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
3094 } else if ( c->op == LDAP_MOD_DELETE ) {
3095 ch_free( c->be->be_rootdn.bv_val );
3096 ch_free( c->be->be_rootndn.bv_val );
3097 BER_BVZERO( &c->be->be_rootdn );
3098 BER_BVZERO( &c->be->be_rootndn );
3101 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3102 ch_free( c->be->be_rootdn.bv_val );
3103 ch_free( c->be->be_rootndn.bv_val );
3105 c->be->be_rootdn = c->value_dn;
3106 c->be->be_rootndn = c->value_ndn;
3111 config_rootpw(ConfigArgs *c) {
3114 if (c->op == SLAP_CONFIG_EMIT) {
3115 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
3116 /* don't copy, because "rootpw" is marked
3118 c->value_bv = c->be->be_rootpw;
3122 } else if ( c->op == LDAP_MOD_DELETE ) {
3123 ch_free( c->be->be_rootpw.bv_val );
3124 BER_BVZERO( &c->be->be_rootpw );
3128 tbe = select_backend(&c->be->be_rootndn, 0);
3130 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> can only be set when rootdn is under suffix",
3132 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3133 c->log, c->cr_msg, 0);
3136 if ( !BER_BVISNULL( &c->be->be_rootpw ))
3137 ch_free( c->be->be_rootpw.bv_val );
3138 c->be->be_rootpw = c->value_bv;
3143 config_restrict(ConfigArgs *c) {
3144 slap_mask_t restrictops = 0;
3146 slap_verbmasks restrictable_ops[] = {
3147 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
3148 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
3149 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
3150 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
3151 { BER_BVC("modrdn"), 0 },
3152 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
3153 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
3154 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
3155 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
3156 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
3157 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
3158 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
3159 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
3160 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
3161 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
3162 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
3166 if (c->op == SLAP_CONFIG_EMIT) {
3167 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
3169 } else if ( c->op == LDAP_MOD_DELETE ) {
3171 c->be->be_restrictops = 0;
3173 restrictops = verb_to_mask( c->line, restrictable_ops );
3174 c->be->be_restrictops ^= restrictops;
3178 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
3180 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown operation", c->argv[0] );
3181 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3182 c->log, c->cr_msg, c->argv[i]);
3185 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
3186 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
3187 c->be->be_restrictops |= restrictops;
3192 config_allows(ConfigArgs *c) {
3193 slap_mask_t allows = 0;
3195 slap_verbmasks allowable_ops[] = {
3196 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
3197 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
3198 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
3199 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
3200 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
3203 if (c->op == SLAP_CONFIG_EMIT) {
3204 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
3205 } else if ( c->op == LDAP_MOD_DELETE ) {
3209 allows = verb_to_mask( c->line, allowable_ops );
3210 global_allows ^= allows;
3214 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
3216 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3217 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3218 c->log, c->cr_msg, c->argv[i]);
3221 global_allows |= allows;
3226 config_disallows(ConfigArgs *c) {
3227 slap_mask_t disallows = 0;
3229 slap_verbmasks disallowable_ops[] = {
3230 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
3231 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
3232 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
3233 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
3234 { BER_BVC("proxy_authz_non_critical"), SLAP_DISALLOW_PROXY_AUTHZ_N_CRIT },
3235 { BER_BVC("dontusecopy_non_critical"), SLAP_DISALLOW_DONTUSECOPY_N_CRIT },
3238 if (c->op == SLAP_CONFIG_EMIT) {
3239 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
3240 } else if ( c->op == LDAP_MOD_DELETE ) {
3242 global_disallows = 0;
3244 disallows = verb_to_mask( c->line, disallowable_ops );
3245 global_disallows ^= disallows;
3249 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
3251 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3252 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3253 c->log, c->cr_msg, c->argv[i]);
3256 global_disallows |= disallows;
3261 config_requires(ConfigArgs *c) {
3262 slap_mask_t requires = frontendDB->be_requires;
3263 int i, argc = c->argc;
3264 char **argv = c->argv;
3266 slap_verbmasks requires_ops[] = {
3267 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
3268 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
3269 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
3270 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
3271 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
3274 if (c->op == SLAP_CONFIG_EMIT) {
3275 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
3276 } else if ( c->op == LDAP_MOD_DELETE ) {
3278 c->be->be_requires = 0;
3280 requires = verb_to_mask( c->line, requires_ops );
3281 c->be->be_requires ^= requires;
3285 /* "none" can only be first, to wipe out default/global values */
3286 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
3291 i = verbs_to_mask(argc, argv, requires_ops, &requires);
3293 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
3294 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
3295 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3296 c->log, c->cr_msg, 0);
3298 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
3299 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3300 c->log, c->cr_msg, c->argv[i]);
3304 c->be->be_requires = requires;
3309 config_extra_attrs(ConfigArgs *c)
3311 assert( c->be != NULL );
3313 if ( c->op == SLAP_CONFIG_EMIT ) {
3316 if ( c->be->be_extra_anlist == NULL ) {
3320 for ( i = 0; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3321 value_add_one( &c->rvalue_vals, &c->be->be_extra_anlist[i].an_name );
3324 } else if ( c->op == LDAP_MOD_DELETE ) {
3325 if ( c->be->be_extra_anlist == NULL ) {
3329 if ( c->valx < 0 ) {
3330 anlist_free( c->be->be_extra_anlist, 1, NULL );
3331 c->be->be_extra_anlist = NULL;
3336 for ( i = 0; i < c->valx && !BER_BVISNULL( &c->be->be_extra_anlist[i + 1].an_name ); i++ )
3339 if ( BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ) ) {
3343 ch_free( c->be->be_extra_anlist[i].an_name.bv_val );
3345 for ( ; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3346 c->be->be_extra_anlist[i] = c->be->be_extra_anlist[i + 1];
3351 c->be->be_extra_anlist = str2anlist( c->be->be_extra_anlist, c->argv[1], " ,\t" );
3352 if ( c->be->be_extra_anlist == NULL ) {
3360 static slap_verbmasks *loglevel_ops;
3363 loglevel_init( void )
3365 slap_verbmasks lo[] = {
3366 { BER_BVC("Any"), (slap_mask_t) LDAP_DEBUG_ANY },
3367 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
3368 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
3369 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
3370 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
3371 { BER_BVC("BER"), LDAP_DEBUG_BER },
3372 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
3373 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
3374 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
3375 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
3376 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
3377 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
3378 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
3379 #if 0 /* no longer used (nor supported) */
3380 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
3381 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
3383 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
3384 { BER_BVC("None"), LDAP_DEBUG_NONE },
3388 return slap_verbmasks_init( &loglevel_ops, lo );
3392 loglevel_destroy( void )
3394 if ( loglevel_ops ) {
3395 (void)slap_verbmasks_destroy( loglevel_ops );
3397 loglevel_ops = NULL;
3400 static slap_mask_t loglevel_ignore[] = { -1, 0 };
3403 slap_loglevel_register( slap_mask_t m, struct berval *s )
3407 if ( loglevel_ops == NULL ) {
3411 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
3414 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
3422 slap_loglevel_get( struct berval *s, int *l )
3427 if ( loglevel_ops == NULL ) {
3431 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3432 m |= loglevel_ops[ i ].mask;
3435 for ( i = 1; m & i; i <<= 1 )
3442 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
3445 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
3456 str2loglevel( const char *s, int *l )
3460 if ( loglevel_ops == NULL ) {
3464 i = verb_to_mask( s, loglevel_ops );
3466 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
3470 *l = loglevel_ops[ i ].mask;
3476 loglevel2str( int l )
3478 struct berval bv = BER_BVNULL;
3480 loglevel2bv( l, &bv );
3486 loglevel2bv( int l, struct berval *bv )
3488 if ( loglevel_ops == NULL ) {
3494 return enum_to_verb( loglevel_ops, l, bv ) == -1;
3498 loglevel2bvarray( int l, BerVarray *bva )
3500 if ( loglevel_ops == NULL ) {
3504 return mask_to_verbs( loglevel_ops, l, bva );
3508 loglevel_print( FILE *out )
3512 if ( loglevel_ops == NULL ) {
3516 fprintf( out, "Installed log subsystems:\n\n" );
3517 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3518 unsigned mask = loglevel_ops[ i ].mask & 0xffffffffUL;
3520 (mask == ((slap_mask_t) -1 & 0xffffffffUL)
3521 ? "\t%-30s (-1, 0xffffffff)\n" : "\t%-30s (%u, 0x%x)\n"),
3522 loglevel_ops[ i ].word.bv_val, mask, mask );
3525 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
3526 "by specific code\n\n" );
3531 static int config_syslog;
3534 config_loglevel(ConfigArgs *c) {
3537 if ( loglevel_ops == NULL ) {
3541 if (c->op == SLAP_CONFIG_EMIT) {
3542 /* Get default or commandline slapd setting */
3543 if ( ldap_syslog && !config_syslog )
3544 config_syslog = ldap_syslog;
3545 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
3547 } else if ( c->op == LDAP_MOD_DELETE ) {
3551 int level = verb_to_mask( c->line, loglevel_ops );
3552 config_syslog ^= level;
3554 if ( slapMode & SLAP_SERVER_MODE ) {
3555 ldap_syslog = config_syslog;
3560 for( i=1; i < c->argc; i++ ) {
3563 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
3564 if( lutil_atoix( &level, c->argv[i], 0 ) != 0 ) {
3565 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
3566 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3567 c->log, c->cr_msg, c->argv[i]);
3571 if ( str2loglevel( c->argv[i], &level ) ) {
3572 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown level", c->argv[0] );
3573 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3574 c->log, c->cr_msg, c->argv[i]);
3578 /* Explicitly setting a zero clears all the levels */
3580 config_syslog |= level;
3584 if ( slapMode & SLAP_SERVER_MODE ) {
3585 ldap_syslog = config_syslog;
3591 config_referral(ConfigArgs *c) {
3593 if (c->op == SLAP_CONFIG_EMIT) {
3594 if ( default_referral ) {
3595 value_add( &c->rvalue_vals, default_referral );
3600 } else if ( c->op == LDAP_MOD_DELETE ) {
3601 if ( c->valx < 0 ) {
3602 ber_bvarray_free( default_referral );
3603 default_referral = NULL;
3606 ch_free( default_referral[i].bv_val );
3607 for (; default_referral[i].bv_val; i++ )
3608 default_referral[i] = default_referral[i+1];
3612 if(validate_global_referral(c->argv[1])) {
3613 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3614 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3615 c->log, c->cr_msg, c->argv[1]);
3619 ber_str2bv(c->argv[1], 0, 0, &val);
3620 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
3628 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
3629 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
3630 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
3631 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
3632 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
3633 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
3634 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
3635 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
3636 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
3641 config_security(ConfigArgs *c) {
3642 slap_ssf_set_t *set = &c->be->be_ssf_set;
3645 if (c->op == SLAP_CONFIG_EMIT) {
3651 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
3652 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
3655 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
3656 if ( bv.bv_len >= sizeof( numbuf ) ) {
3657 ber_bvarray_free_x( c->rvalue_vals, NULL );
3658 c->rvalue_vals = NULL;
3662 bv.bv_len += sec_keys[i].key.bv_len;
3663 bv.bv_val = ch_malloc( bv.bv_len + 1);
3664 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
3665 strcpy( next, numbuf );
3666 ber_bvarray_add( &c->rvalue_vals, &bv );
3671 for(i = 1; i < c->argc; i++) {
3672 slap_ssf_t *tgt = NULL;
3674 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
3675 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
3676 sec_keys[j].key.bv_len)) {
3677 src = c->argv[i] + sec_keys[j].key.bv_len;
3678 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
3683 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown factor", c->argv[0] );
3684 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3685 c->log, c->cr_msg, c->argv[i]);
3689 if ( lutil_atou( tgt, src ) != 0 ) {
3690 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse factor", c->argv[0] );
3691 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3692 c->log, c->cr_msg, c->argv[i]);
3700 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
3704 for (; !BER_BVISNULL( &an->an_name ); an++) {
3705 /* if buflen == 0, assume the buffer size has been
3706 * already checked otherwise */
3707 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
3708 if ( comma ) *ptr++ = ',';
3709 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
3716 config_updatedn(ConfigArgs *c) {
3717 if (c->op == SLAP_CONFIG_EMIT) {
3718 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
3719 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
3720 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
3724 } else if ( c->op == LDAP_MOD_DELETE ) {
3725 ch_free( c->be->be_update_ndn.bv_val );
3726 BER_BVZERO( &c->be->be_update_ndn );
3727 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
3730 if(SLAP_SHADOW(c->be)) {
3731 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database already shadowed", c->argv[0] );
3732 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3733 c->log, c->cr_msg, 0);
3737 ber_memfree_x( c->value_dn.bv_val, NULL );
3738 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
3739 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
3741 c->be->be_update_ndn = c->value_ndn;
3742 BER_BVZERO( &c->value_dn );
3743 BER_BVZERO( &c->value_ndn );
3745 return config_slurp_shadow( c );
3749 config_shadow( ConfigArgs *c, slap_mask_t flag )
3751 char *notallowed = NULL;
3753 if ( c->be == frontendDB ) {
3754 notallowed = "frontend";
3756 } else if ( SLAP_MONITOR(c->be) ) {
3757 notallowed = "monitor";
3760 if ( notallowed != NULL ) {
3761 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
3765 if ( SLAP_SHADOW(c->be) ) {
3766 /* if already shadow, only check consistency */
3767 if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
3768 Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%lx.\n",
3774 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
3781 config_updateref(ConfigArgs *c) {
3783 if (c->op == SLAP_CONFIG_EMIT) {
3784 if ( c->be->be_update_refs ) {
3785 value_add( &c->rvalue_vals, c->be->be_update_refs );
3790 } else if ( c->op == LDAP_MOD_DELETE ) {
3791 if ( c->valx < 0 ) {
3792 ber_bvarray_free( c->be->be_update_refs );
3793 c->be->be_update_refs = NULL;
3796 ch_free( c->be->be_update_refs[i].bv_val );
3797 for (; c->be->be_update_refs[i].bv_val; i++)
3798 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
3802 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
3803 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> must appear after syncrepl or updatedn",
3805 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3806 c->log, c->cr_msg, 0);
3810 if(validate_global_referral(c->argv[1])) {
3811 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3812 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3813 c->log, c->cr_msg, c->argv[1]);
3816 ber_str2bv(c->argv[1], 0, 0, &val);
3817 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
3822 config_obsolete(ConfigArgs *c) {
3823 if (c->op == SLAP_CONFIG_EMIT)
3826 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> keyword is obsolete (ignored)",
3828 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0);
3833 config_include(ConfigArgs *c) {
3834 int savelineno = c->lineno;
3837 ConfigFile *cfsave = cfn;
3838 ConfigFile *cf2 = NULL;
3840 /* Leftover from RE23. No dynamic config for include files */
3841 if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
3844 cf = ch_calloc( 1, sizeof(ConfigFile));
3845 if ( cfn->c_kids ) {
3846 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
3852 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
3853 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
3854 c->lineno = savelineno - 1;
3857 if ( cf2 ) cf2->c_sibs = NULL;
3858 else cfn->c_kids = NULL;
3859 ch_free( cf->c_file.bv_val );
3869 config_tls_cleanup(ConfigArgs *c) {
3872 if ( slap_tls_ld ) {
3875 ldap_pvt_tls_ctx_free( slap_tls_ctx );
3877 /* Force new ctx to be created */
3878 rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
3880 /* The ctx's refcount is bumped up here */
3881 ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
3882 /* This is a no-op if it's already loaded */
3883 load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
3890 config_tls_option(ConfigArgs *c) {
3892 LDAP *ld = slap_tls_ld;
3894 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
3895 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
3896 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
3897 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
3898 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
3899 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
3900 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
3902 case CFG_TLS_CRL_FILE: flag = LDAP_OPT_X_TLS_CRLFILE; break;
3904 default: Debug(LDAP_DEBUG_ANY, "%s: "
3905 "unknown tls_option <0x%x>\n",
3906 c->log, c->type, 0);
3909 if (c->op == SLAP_CONFIG_EMIT) {
3910 return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3911 } else if ( c->op == LDAP_MOD_DELETE ) {
3912 c->cleanup = config_tls_cleanup;
3913 return ldap_pvt_tls_set_option( ld, flag, NULL );
3915 ch_free(c->value_string);
3916 c->cleanup = config_tls_cleanup;
3917 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3920 /* FIXME: this ought to be provided by libldap */
3922 config_tls_config(ConfigArgs *c) {
3925 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
3926 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
3927 case CFG_TLS_PROTOCOL_MIN: flag = LDAP_OPT_X_TLS_PROTOCOL_MIN; break;
3929 Debug(LDAP_DEBUG_ANY, "%s: "
3930 "unknown tls_option <0x%x>\n",
3931 c->log, c->type, 0);
3934 if (c->op == SLAP_CONFIG_EMIT) {
3935 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3936 } else if ( c->op == LDAP_MOD_DELETE ) {
3938 c->cleanup = config_tls_cleanup;
3939 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3941 ch_free( c->value_string );
3942 c->cleanup = config_tls_cleanup;
3943 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3944 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3945 Debug(LDAP_DEBUG_ANY, "%s: "
3946 "unable to parse %s \"%s\"\n",
3947 c->log, c->argv[0], c->argv[1] );
3950 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
3952 return(ldap_pvt_tls_config(slap_tls_ld, flag, c->argv[1]));
3957 static CfEntryInfo *
3958 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
3968 if ( dn_match( &root->ce_entry->e_nname, dn ))
3971 c = dn->bv_val+dn->bv_len;
3972 for (;*c != ',';c--);
3976 for (--c;c>dn->bv_val && *c != ',';c--);
3980 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
3982 root = root->ce_kids;
3984 for (;root;root=root->ce_sibs) {
3985 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
3986 if ( cdn.bv_val == dn->bv_val ) {
3996 typedef struct setup_cookie {
4006 config_ldif_resp( Operation *op, SlapReply *rs )
4008 if ( rs->sr_type == REP_SEARCH ) {
4009 setup_cookie *sc = op->o_callback->sc_private;
4012 sc->cfb->cb_got_ldif = 1;
4013 /* Does the frontend exist? */
4014 if ( !sc->got_frontend ) {
4015 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
4016 "olcDatabase", STRLENOF( "olcDatabase" )))
4018 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4019 STRLENOF( "olcDatabase" ), "={-1}frontend",
4020 STRLENOF( "={-1}frontend" )))
4024 sc->ca->be = frontendDB;
4025 sc->ca->bi = frontendDB->bd_info;
4026 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
4027 rdn.bv_val = sc->ca->log;
4028 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4029 "%s=" SLAP_X_ORDERED_FMT "%s",
4030 cfAd_database->ad_cname.bv_val, -1,
4031 sc->ca->bi->bi_type);
4033 sc->frontend = config_build_entry( op, rs,
4034 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
4035 sc->ca->be->be_cf_ocs );
4045 dnParent( &rs->sr_entry->e_nname, &pdn );
4047 /* Does the configDB exist? */
4048 if ( sc->got_frontend && !sc->got_config &&
4049 !strncmp( rs->sr_entry->e_nname.bv_val,
4050 "olcDatabase", STRLENOF( "olcDatabase" )) &&
4051 dn_match( &config_rdn, &pdn ) )
4053 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4054 STRLENOF( "olcDatabase" ), "={0}config",
4055 STRLENOF( "={0}config" )))
4059 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
4060 sc->ca->bi = sc->ca->be->bd_info;
4061 rdn.bv_val = sc->ca->log;
4062 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4063 "%s=" SLAP_X_ORDERED_FMT "%s",
4064 cfAd_database->ad_cname.bv_val, 0,
4065 sc->ca->bi->bi_type);
4067 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
4068 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
4075 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
4076 if ( rs->sr_err != LDAP_SUCCESS ) {
4077 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
4078 rs->sr_entry->e_name.bv_val, sc->ca->cr_msg, 0 );
4084 /* Configure and read the underlying back-ldif store */
4086 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
4087 CfBackInfo *cfb = be->be_private;
4093 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
4094 Connection conn = {0};
4095 OperationBuffer opbuf;
4097 SlapReply rs = {REP_RESULT};
4098 Filter filter = { LDAP_FILTER_PRESENT };
4099 struct berval filterstr = BER_BVC("(objectclass=*)");
4102 /* Is the config directory available? */
4103 if ( stat( dir, &st ) < 0 ) {
4104 /* No, so don't bother using the backing store.
4105 * All changes will be in-memory only.
4110 cfb->cb_db.bd_info = backend_info( "ldif" );
4111 if ( !cfb->cb_db.bd_info )
4112 return 0; /* FIXME: eventually this will be a fatal error */
4114 if ( backend_db_init( "ldif", &cfb->cb_db, -1, NULL ) == NULL )
4117 cfb->cb_db.be_suffix = be->be_suffix;
4118 cfb->cb_db.be_nsuffix = be->be_nsuffix;
4120 /* The suffix is always "cn=config". The underlying DB's rootdn
4121 * is always the same as the suffix.
4123 cfb->cb_db.be_rootdn = be->be_suffix[0];
4124 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
4126 ber_str2bv( dir, 0, 1, &cfdir );
4131 argv[0] = "directory";
4132 argv[1] = (char *)dir;
4137 c.table = Cft_Database;
4139 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
4143 if ( config_add_vals( ct, &c ))
4146 if ( backend_startup_one( &cfb->cb_db, &c.reply ))
4150 void *thrctx = ldap_pvt_thread_pool_context();
4153 connection_fake_init( &conn, &opbuf, thrctx );
4156 filter.f_desc = slap_schema.si_ad_objectClass;
4158 op->o_tag = LDAP_REQ_SEARCH;
4160 op->ors_filter = &filter;
4161 op->ors_filterstr = filterstr;
4162 op->ors_scope = LDAP_SCOPE_SUBTREE;
4164 op->o_dn = c.be->be_rootdn;
4165 op->o_ndn = c.be->be_rootndn;
4167 op->o_req_dn = be->be_suffix[0];
4168 op->o_req_ndn = be->be_nsuffix[0];
4170 op->ors_tlimit = SLAP_NO_LIMIT;
4171 op->ors_slimit = SLAP_NO_LIMIT;
4173 op->ors_attrs = slap_anlist_all_attributes;
4174 op->ors_attrsonly = 0;
4176 op->o_callback = &cb;
4179 cb.sc_private = ≻
4180 sc.got_frontend = 0;
4185 op->o_bd = &cfb->cb_db;
4187 /* Allow unknown attrs in DNs */
4188 prev_DN_strict = slap_DN_strict;
4191 rc = op->o_bd->be_search( op, &rs );
4193 /* Restore normal DN validation */
4194 slap_DN_strict = prev_DN_strict;
4196 op->o_tag = LDAP_REQ_ADD;
4197 if ( rc == LDAP_SUCCESS && sc.frontend ) {
4198 rs_reinit( &rs, REP_RESULT );
4199 op->ora_e = sc.frontend;
4200 rc = op->o_bd->be_add( op, &rs );
4202 if ( rc == LDAP_SUCCESS && sc.config ) {
4203 rs_reinit( &rs, REP_RESULT );
4204 op->ora_e = sc.config;
4205 rc = op->o_bd->be_add( op, &rs );
4207 ldap_pvt_thread_pool_context_reset( thrctx );
4210 /* ITS#4194 - only use if it's present, or we're converting. */
4211 if ( !readit || rc == LDAP_SUCCESS )
4212 cfb->cb_use_ldif = 1;
4218 CfOc_cmp( const void *c1, const void *c2 ) {
4219 const ConfigOCs *co1 = c1;
4220 const ConfigOCs *co2 = c2;
4222 return ber_bvcmp( co1->co_name, co2->co_name );
4226 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
4229 i = init_config_attrs( ct );
4232 /* set up the objectclasses */
4233 i = init_config_ocs( ocs );
4236 for (i=0; ocs[i].co_def; i++) {
4237 if ( ocs[i].co_oc ) {
4238 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
4239 if ( !ocs[i].co_table )
4240 ocs[i].co_table = ct;
4241 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
4248 read_config(const char *fname, const char *dir) {
4251 const char *cfdir, *cfname;
4254 /* Setup the config backend */
4255 be = backend_db_init( "config", NULL, 0, NULL );
4259 cfb = be->be_private;
4260 be->be_dfltaccess = ACL_NONE;
4262 /* If no .conf, or a dir was specified, setup the dir */
4263 if ( !fname || dir ) {
4265 /* If explicitly given, check for existence */
4268 if ( stat( dir, &st ) < 0 ) {
4269 Debug( LDAP_DEBUG_ANY,
4270 "invalid config directory %s, error %d\n",
4276 cfdir = SLAPD_DEFAULT_CONFIGDIR;
4278 /* if fname is defaulted, try reading .d */
4279 rc = config_setup_ldif( be, cfdir, !fname );
4282 /* It may be OK if the base object doesn't exist yet. */
4283 if ( rc != LDAP_NO_SUCH_OBJECT )
4285 /* ITS#4194: But if dir was specified and no fname,
4286 * then we were supposed to read the dir. Unless we're
4287 * trying to slapadd the dir...
4289 if ( dir && !fname ) {
4290 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
4292 /* Assume it's slapadd with a config dir, let it continue */
4294 cfb->cb_got_ldif = 1;
4295 cfb->cb_use_ldif = 1;
4300 /* If we read the config from back-ldif, nothing to do here */
4301 if ( cfb->cb_got_ldif ) {
4310 cfname = SLAPD_DEFAULT_CONFIGFILE;
4312 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
4315 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
4318 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
4319 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
4320 &frontendDB->be_schemadn );
4321 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
4322 if ( rc != LDAP_SUCCESS ) {
4323 Debug(LDAP_DEBUG_ANY, "read_config: "
4324 "unable to normalize default schema DN \"%s\"\n",
4325 frontendDB->be_schemadn.bv_val, 0, 0 );
4326 /* must not happen */
4334 config_back_bind( Operation *op, SlapReply *rs )
4336 if ( be_isroot_pw( op ) ) {
4337 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
4338 /* frontend sends result */
4339 return LDAP_SUCCESS;
4342 rs->sr_err = LDAP_INVALID_CREDENTIALS;
4343 send_ldap_result( op, rs );
4349 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
4353 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
4355 rs->sr_attrs = op->ors_attrs;
4356 rs->sr_entry = ce->ce_entry;
4358 rc = send_search_entry( op, rs );
4359 if ( rc != LDAP_SUCCESS ) {
4363 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
4364 if ( ce->ce_kids ) {
4365 rc = config_send( op, rs, ce->ce_kids, 1 );
4366 if ( rc ) return rc;
4369 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
4370 rc = config_send( op, rs, ce, 0 );
4378 static ConfigTable *
4379 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
4384 for (j=0; j<nocs; j++) {
4385 for (i=0; colst[j]->co_table[i].name; i++)
4386 if ( colst[j]->co_table[i].ad == ad ) {
4387 ca->table = colst[j]->co_type;
4388 return &colst[j]->co_table[i];
4394 /* Sort the attributes of the entry according to the order defined
4395 * in the objectclass, with required attributes occurring before
4396 * allowed attributes. For any attributes with sequencing dependencies
4397 * (e.g., rootDN must be defined after suffix) the objectclass must
4398 * list the attributes in the desired sequence.
4401 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
4403 Attribute *a, *head = NULL, *tail = NULL, **prev;
4406 for (i=0; i<nocs; i++) {
4407 if ( colst[i]->co_oc->soc_required ) {
4408 AttributeType **at = colst[i]->co_oc->soc_required;
4409 for (j=0; at[j]; j++) {
4410 for (a=e->e_attrs, prev=&e->e_attrs; a;
4411 prev = &(*prev)->a_next, a=a->a_next) {
4412 if ( a->a_desc == at[j]->sat_ad ) {
4426 if ( colst[i]->co_oc->soc_allowed ) {
4427 AttributeType **at = colst[i]->co_oc->soc_allowed;
4428 for (j=0; at[j]; j++) {
4429 for (a=e->e_attrs, prev=&e->e_attrs; a;
4430 prev = &(*prev)->a_next, a=a->a_next) {
4431 if ( a->a_desc == at[j]->sat_ad ) {
4447 tail->a_next = e->e_attrs;
4453 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
4455 Attribute *a = NULL;
4456 AttributeDescription *ad;
4466 Modifications *ml = ptr;
4468 vals = ml->sml_values;
4471 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
4472 rc = ordered_value_sort( a, 1 );
4474 snprintf(ca->cr_msg, sizeof( ca->cr_msg ), "ordered_value_sort failed on attr %s\n",
4475 ad->ad_cname.bv_val );
4479 for ( i=0; vals[i].bv_val; i++ ) {
4480 ca->line = vals[i].bv_val;
4481 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
4482 ca->line[0] == '{' ) {
4483 char *idx = strchr( ca->line, '}' );
4484 if ( idx ) ca->line = idx+1;
4486 rc = config_parse_vals( ct, ca, i );
4495 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
4498 struct berval rtype, rval;
4500 AttributeDescription *ad = NULL;
4502 dnRdn( &e->e_name, rdn );
4503 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
4504 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
4505 rtype.bv_val = rdn->bv_val;
4506 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
4509 slap_bv2ad( &rtype, &ad, &rs->sr_text );
4510 a = attr_find( e->e_attrs, ad );
4511 if (!a ) return LDAP_NAMING_VIOLATION;
4518 config_rename_kids( CfEntryInfo *ce )
4521 struct berval rdn, nrdn;
4523 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
4524 struct berval newdn, newndn;
4525 dnRdn ( &ce2->ce_entry->e_name, &rdn );
4526 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
4527 build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
4528 build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
4529 free( ce2->ce_entry->e_name.bv_val );
4530 free( ce2->ce_entry->e_nname.bv_val );
4531 ce2->ce_entry->e_name = newdn;
4532 ce2->ce_entry->e_nname = newndn;
4533 config_rename_kids( ce2 );
4538 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
4539 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
4540 struct berval *nnewrdn, int use_ldif )
4544 struct berval odn, ondn;
4548 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
4549 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
4552 free( a->a_vals[0].bv_val );
4553 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
4554 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
4555 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
4556 strcpy( a->a_vals[0].bv_val, ptr1 );
4558 if ( a->a_nvals != a->a_vals ) {
4559 free( a->a_nvals[0].bv_val );
4560 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
4561 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
4562 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
4563 strcpy( a->a_nvals[0].bv_val, ptr1 );
4566 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
4567 BackendDB *be = op->o_bd;
4568 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4569 struct berval dn, ndn, xdn, xndn;
4571 op->o_bd = &cfb->cb_db;
4573 /* Save current rootdn; use the underlying DB's rootdn */
4577 xndn = op->o_req_ndn;
4578 op->o_dn = op->o_bd->be_rootdn;
4579 op->o_ndn = op->o_bd->be_rootndn;
4581 op->o_req_ndn = ondn;
4583 scp = op->o_callback;
4584 op->o_callback = ≻
4585 op->orr_newrdn = *newrdn;
4586 op->orr_nnewrdn = *nnewrdn;
4587 op->orr_newSup = NULL;
4588 op->orr_nnewSup = NULL;
4589 op->orr_deleteoldrdn = 1;
4590 op->orr_modlist = NULL;
4591 slap_modrdn2mods( op, rs );
4592 slap_mods_opattrs( op, &op->orr_modlist, 1 );
4593 rc = op->o_bd->be_modrdn( op, rs );
4594 slap_mods_free( op->orr_modlist, 1 );
4597 op->o_callback = scp;
4601 op->o_req_ndn = xndn;
4604 free( ondn.bv_val );
4606 config_rename_kids( e->e_private );
4611 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
4612 Entry *e, int idx, int tailindex, int use_ldif )
4614 struct berval ival, newrdn, nnewrdn;
4617 char ibuf[32], *ptr1, *ptr2 = NULL;
4620 rc = config_rename_attr( rs, e, &rdn, &a );
4621 if ( rc ) return rc;
4624 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
4625 if ( ival.bv_len >= sizeof( ibuf ) ) {
4626 return LDAP_NAMING_VIOLATION;
4629 newrdn.bv_len = rdn.bv_len + ival.bv_len;
4630 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
4633 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
4634 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4637 ptr2 = ber_bvchr( &rdn, '}' );
4641 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
4643 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
4644 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
4645 a->a_desc->ad_cname.bv_len );
4647 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4648 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
4652 /* Do the equivalent of ModRDN */
4653 /* Replace DN / NDN */
4654 newrdn.bv_len = ptr1 - newrdn.bv_val;
4655 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
4656 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
4658 free( nnewrdn.bv_val );
4659 free( newrdn.bv_val );
4664 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
4665 SlapReply *rs, int *renum, int *ibase )
4668 int index = -1, gotindex = 0, nsibs, rc = 0;
4669 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
4670 char *ptr1, *ptr2 = NULL;
4673 if ( renum ) *renum = 0;
4675 /* These entries don't get indexed/renumbered */
4676 if ( ce_type == Cft_Global ) return 0;
4677 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
4679 if ( ce_type == Cft_Module )
4682 /* See if the rdn has an index already */
4683 dnRdn( &e->e_name, &rdn );
4684 if ( ce_type == Cft_Database ) {
4685 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
4686 "frontend", STRLENOF("frontend") ))
4688 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
4689 "config", STRLENOF("config") ))
4692 ptr1 = ber_bvchr( &e->e_name, '{' );
4693 if ( ptr1 && ptr1 < &e->e_name.bv_val[ rdn.bv_len ] ) {
4695 ptr2 = strchr( ptr1, '}' );
4696 if ( !ptr2 || ptr2 > &e->e_name.bv_val[ rdn.bv_len ] )
4697 return LDAP_NAMING_VIOLATION;
4698 if ( ptr2-ptr1 == 1)
4699 return LDAP_NAMING_VIOLATION;
4701 index = strtol( ptr1 + 1, &next, 10 );
4702 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
4703 return LDAP_NAMING_VIOLATION;
4706 /* Special case, we allow -1 for the frontendDB */
4707 if ( index != -1 || !isfrontend )
4708 return LDAP_NAMING_VIOLATION;
4710 if ( isconfig && index != 0 ){
4711 return LDAP_NAMING_VIOLATION;
4715 /* count related kids */
4716 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
4717 if ( ce->ce_type == ce_type ) nsibs++;
4720 /* account for -1 frontend */
4721 if ( ce_type == Cft_Database )
4724 if ( index != nsibs ) {
4726 if ( index < nsibs ) {
4727 if ( tailindex ) return LDAP_NAMING_VIOLATION;
4728 /* Siblings need to be renumbered */
4729 if ( index != -1 || !isfrontend )
4733 /* config DB is always "0" */
4734 if ( isconfig && index == -1 ) {
4737 if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
4741 /* just make index = nsibs */
4743 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
4746 if ( ibase ) *ibase = index;
4747 if ( renum ) *renum = renumber;
4752 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
4757 co.co_name = &oc->soc_cname;
4758 cop = avl_find( CfOcTree, &co, CfOc_cmp );
4762 /* check for duplicates */
4763 for ( i = 0; i < *nocs; i++ ) {
4764 if ( *copp && (*copp)[i] == cop ) {
4770 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
4771 if ( tmp == NULL ) {
4775 (*copp)[*nocs] = cop;
4780 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
4781 if ( count_oc( *sups, copp, nocs ) ) {
4790 count_ocs( Attribute *oc_at, int *nocs )
4793 ConfigOCs **colst = NULL;
4797 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
4801 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
4803 assert( oc != NULL );
4804 if ( count_oc( oc, &colst, nocs ) ) {
4814 cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4816 /* Leftover from RE23. Never parse this entry */
4817 return LDAP_COMPARE_TRUE;
4821 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4825 /* This entry is hardcoded, don't re-parse it */
4826 if ( p->ce_type == Cft_Global ) {
4827 cfn = p->ce_private;
4828 ca->ca_private = cfn;
4829 return LDAP_COMPARE_TRUE;
4831 if ( p->ce_type != Cft_Schema )
4832 return LDAP_CONSTRAINT_VIOLATION;
4834 cfn = ch_calloc( 1, sizeof(ConfigFile) );
4835 ca->ca_private = cfn;
4836 cfo = p->ce_private;
4837 cfn->c_sibs = cfo->c_kids;
4839 return LDAP_SUCCESS;
4843 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4845 if ( p->ce_type != Cft_Global ) {
4846 return LDAP_CONSTRAINT_VIOLATION;
4848 /* config must be {0}, nothing else allowed */
4849 if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
4850 strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
4851 return LDAP_CONSTRAINT_VIOLATION;
4853 ca->be = frontendDB; /* just to get past check_vals */
4854 return LDAP_SUCCESS;
4858 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4860 if ( p->ce_type != Cft_Global ) {
4861 return LDAP_CONSTRAINT_VIOLATION;
4863 return LDAP_SUCCESS;
4867 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4869 if ( p->ce_type != Cft_Global ) {
4870 return LDAP_CONSTRAINT_VIOLATION;
4872 return LDAP_SUCCESS;
4876 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4878 if ( p->ce_type != Cft_Database ) {
4879 return LDAP_CONSTRAINT_VIOLATION;
4882 return LDAP_SUCCESS;
4886 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
4891 AttributeDescription *ad;
4897 if ( cfn->c_cr_head ) {
4898 struct berval bv = BER_BVC("olcDitContentRules");
4900 slap_bv2ad( &bv, &ad, &text );
4901 ct = config_find_table( colst, nocs, ad, ca );
4902 config_del_vals( ct, ca );
4904 if ( cfn->c_oc_head ) {
4905 struct berval bv = BER_BVC("olcObjectClasses");
4907 slap_bv2ad( &bv, &ad, &text );
4908 ct = config_find_table( colst, nocs, ad, ca );
4909 config_del_vals( ct, ca );
4911 if ( cfn->c_at_head ) {
4912 struct berval bv = BER_BVC("olcAttributeTypes");
4914 slap_bv2ad( &bv, &ad, &text );
4915 ct = config_find_table( colst, nocs, ad, ca );
4916 config_del_vals( ct, ca );
4918 if ( cfn->c_syn_head ) {
4919 struct berval bv = BER_BVC("olcLdapSyntaxes");
4921 slap_bv2ad( &bv, &ad, &text );
4922 ct = config_find_table( colst, nocs, ad, ca );
4923 config_del_vals( ct, ca );
4925 if ( cfn->c_om_head ) {
4926 struct berval bv = BER_BVC("olcObjectIdentifier");
4928 slap_bv2ad( &bv, &ad, &text );
4929 ct = config_find_table( colst, nocs, ad, ca );
4930 config_del_vals( ct, ca );
4932 cfo = p->ce_private;
4933 cfo->c_kids = cfn->c_sibs;
4938 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
4940 int rc = LDAP_CONSTRAINT_VIOLATION;
4943 if ( (*cop)->co_ldadd ) {
4944 rc = (*cop)->co_ldadd( last, e, ca );
4945 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4950 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
4951 ConfigOCs co = { 0 };
4953 co.co_name = &(*ocp)->soc_cname;
4954 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
4955 if ( *cop == NULL ) {
4959 rc = config_add_oc( cop, last, e, ca );
4960 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4968 /* Parse an LDAP entry into config directives */
4970 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
4971 int *renum, Operation *op )
4973 CfEntryInfo *ce, *last = NULL;
4974 ConfigOCs co, *coptr, **colst;
4975 Attribute *a, *oc_at, *soc_at;
4976 int i, ibase = -1, nocs, rc = 0;
4979 char *ptr, *log_prefix = op ? op->o_log_prefix : "";
4981 memset( ca, 0, sizeof(ConfigArgs));
4983 /* Make sure parent exists and entry does not. But allow
4984 * Databases and Overlays to be inserted. Don't do any
4985 * auto-renumbering if manageDSAit control is present.
4987 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
4989 if ( ( op && op->o_managedsait ) ||
4990 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
4991 ce->ce_type != Cft_Module ) )
4993 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4994 "DN=\"%s\" already exists\n",
4995 log_prefix, e->e_name.bv_val, 0 );
4996 /* global schema ignores all writes */
4997 if ( ce->ce_type == Cft_Schema && ce->ce_parent->ce_type == Cft_Global )
4998 return LDAP_COMPARE_TRUE;
4999 return LDAP_ALREADY_EXISTS;
5003 dnParent( &e->e_nname, &pdn );
5005 /* If last is NULL, the new entry is the root/suffix entry,
5006 * otherwise last should be the parent.
5008 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
5010 rs->sr_matched = last->ce_entry->e_name.bv_val;
5012 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5013 "DN=\"%s\" not child of DN=\"%s\"\n",
5014 log_prefix, e->e_name.bv_val,
5015 last->ce_entry->e_name.bv_val );
5016 return LDAP_NO_SUCH_OBJECT;
5020 /* No parent, must be root. This will never happen... */
5021 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
5022 return LDAP_NO_SUCH_OBJECT;
5025 if ( last && !access_allowed( op, last->ce_entry,
5026 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
5028 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5029 "DN=\"%s\" no write access to \"children\" of parent\n",
5030 log_prefix, e->e_name.bv_val, 0 );
5031 return LDAP_INSUFFICIENT_ACCESS;
5035 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5037 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5038 "DN=\"%s\" no objectClass\n",
5039 log_prefix, e->e_name.bv_val, 0 );
5040 return LDAP_OBJECT_CLASS_VIOLATION;
5043 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5045 ObjectClass *soc = NULL;
5046 char textbuf[ SLAP_TEXT_BUFLEN ];
5047 const char *text = textbuf;
5049 /* FIXME: check result */
5050 rc = structural_class( oc_at->a_nvals, &soc, NULL,
5051 &text, textbuf, sizeof(textbuf), NULL );
5052 if ( rc != LDAP_SUCCESS ) {
5053 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5054 "DN=\"%s\" no structural objectClass (%s)\n",
5055 log_prefix, e->e_name.bv_val, text );
5058 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
5059 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5060 if ( soc_at == NULL ) {
5061 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5062 "DN=\"%s\" no structural objectClass; "
5063 "unable to merge computed class %s\n",
5064 log_prefix, e->e_name.bv_val,
5065 soc->soc_cname.bv_val );
5066 return LDAP_OBJECT_CLASS_VIOLATION;
5069 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5070 "DN=\"%s\" no structural objectClass; "
5071 "computed objectClass %s merged\n",
5072 log_prefix, e->e_name.bv_val,
5073 soc->soc_cname.bv_val );
5076 /* Fake the coordinates based on whether we're part of an
5077 * LDAP Add or if reading the config dir
5080 ca->fname = "slapd";
5083 ca->fname = cfdir.bv_val;
5088 co.co_name = &soc_at->a_nvals[0];
5089 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
5090 if ( coptr == NULL ) {
5091 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5092 "DN=\"%s\" no structural objectClass in configuration table\n",
5093 log_prefix, e->e_name.bv_val, 0 );
5094 return LDAP_OBJECT_CLASS_VIOLATION;
5097 /* Only the root can be Cft_Global, everything else must
5098 * have a parent. Only limited nesting arrangements are allowed.
5100 rc = LDAP_CONSTRAINT_VIOLATION;
5101 if ( coptr->co_type == Cft_Global && !last ) {
5102 cfn = cfb->cb_config;
5103 ca->ca_private = cfn;
5104 ca->be = frontendDB; /* just to get past check_vals */
5108 colst = count_ocs( oc_at, &nocs );
5110 /* Check whether the Add is allowed by its parent, and do
5111 * any necessary arg setup
5114 rc = config_add_oc( &coptr, last, e, ca );
5115 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5116 for ( i = 0; i<nocs; i++ ) {
5117 /* Already checked these */
5118 if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
5120 if ( colst[i]->co_ldadd &&
5121 ( rc = colst[i]->co_ldadd( last, e, ca ))
5122 != LDAP_CONSTRAINT_VIOLATION ) {
5128 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5129 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5130 "DN=\"%s\" no structural objectClass add function\n",
5131 log_prefix, e->e_name.bv_val, 0 );
5132 return LDAP_OBJECT_CLASS_VIOLATION;
5136 /* Add the entry but don't parse it, we already have its contents */
5137 if ( rc == LDAP_COMPARE_TRUE ) {
5142 if ( rc != LDAP_SUCCESS )
5145 /* Parse all the values and check for simple syntax errors before
5146 * performing any set actions.
5148 * If doing an LDAPadd, check for indexed names and any necessary
5149 * renaming/renumbering. Entries that don't need indexed names are
5150 * ignored. Entries that need an indexed name and arrive without one
5151 * are assigned to the end. Entries that arrive with an index may
5152 * cause the following entries to be renumbered/bumped down.
5154 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
5155 * don't allow Adding an entry with an index that's already in use.
5156 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
5158 * These entries can have auto-assigned indexes (appended to the end)
5159 * but only the other types support auto-renumbering of siblings.
5162 rc = check_name_index( last, coptr->co_type, e, rs, renum,
5167 if ( renum && *renum && coptr->co_type != Cft_Database &&
5168 coptr->co_type != Cft_Overlay )
5170 snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
5171 "operation requires sibling renumbering" );
5172 rc = LDAP_UNWILLING_TO_PERFORM;
5177 init_config_argv( ca );
5179 /* Make sure we process attrs in the required order */
5180 sort_attrs( e, colst, nocs );
5182 for ( a = e->e_attrs; a; a = a->a_next ) {
5183 if ( a == oc_at ) continue;
5184 ct = config_find_table( colst, nocs, a->a_desc, ca );
5185 if ( !ct ) continue; /* user data? */
5186 rc = check_vals( ct, ca, a, 1 );
5187 if ( rc ) goto done_noop;
5190 /* Basic syntax checks are OK. Do the actual settings. */
5191 for ( a=e->e_attrs; a; a=a->a_next ) {
5192 if ( a == oc_at ) continue;
5193 ct = config_find_table( colst, nocs, a->a_desc, ca );
5194 if ( !ct ) continue; /* user data? */
5195 for (i=0; a->a_vals[i].bv_val; i++) {
5198 ca->line = a->a_vals[i].bv_val;
5199 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
5200 ptr = strchr( ca->line, '}' );
5202 iptr = strchr( ca->line, '{' );
5206 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
5208 ca->valx = strtol( iptr+1, NULL, 0 );
5213 rc = config_parse_add( ct, ca, i );
5221 /* Newly added databases and overlays need to be started up */
5222 if ( CONFIG_ONLINE_ADD( ca )) {
5223 if ( coptr->co_type == Cft_Database ) {
5224 rc = backend_startup_one( ca->be, &ca->reply );
5226 } else if ( coptr->co_type == Cft_Overlay ) {
5227 if ( ca->bi->bi_db_open ) {
5228 BackendInfo *bi_orig = ca->be->bd_info;
5229 ca->be->bd_info = ca->bi;
5230 rc = ca->bi->bi_db_open( ca->be, &ca->reply );
5231 ca->be->bd_info = bi_orig;
5233 } else if ( ca->cleanup ) {
5234 rc = ca->cleanup( ca );
5237 if (ca->cr_msg[0] == '\0')
5238 snprintf( ca->cr_msg, sizeof( ca->cr_msg ), "<%s> failed startup", ca->argv[0] );
5240 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
5241 ca->log, ca->cr_msg, ca->argv[1] );
5248 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5249 ce->ce_parent = last;
5250 ce->ce_entry = entry_dup( e );
5251 ce->ce_entry->e_private = ce;
5252 ce->ce_type = coptr->co_type;
5255 ce->ce_private = ca->ca_private;
5256 ca->ca_entry = ce->ce_entry;
5259 } else if ( last->ce_kids ) {
5260 CfEntryInfo *c2, **cprev;
5262 /* Advance to first of this type */
5263 cprev = &last->ce_kids;
5264 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
5265 cprev = &c2->ce_sibs;
5268 /* Account for the (-1) frontendDB entry */
5269 if ( ce->ce_type == Cft_Database ) {
5270 if ( ca->be == frontendDB )
5272 else if ( ibase != -1 )
5277 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
5278 cprev = &c2->ce_sibs;
5284 for ( i=0; i<ibase; i++ ) {
5286 cprev = &c2->ce_sibs;
5289 ce->ce_sibs = *cprev;
5297 if ( (coptr->co_type == Cft_Database) && ca->be ) {
5298 if ( ca->be != frontendDB )
5299 backend_destroy_one( ca->be, 1 );
5300 } else if ( (coptr->co_type == Cft_Overlay) && ca->bi ) {
5301 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
5302 } else if ( coptr->co_type == Cft_Schema ) {
5303 schema_destroy_one( ca, colst, nocs, last );
5308 ch_free( ca->argv );
5309 if ( colst ) ch_free( colst );
5313 #define BIGTMP 10000
5315 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5316 int base, int rebase, int max, int use_ldif )
5318 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
5319 ConfigType etype = ce->ce_type;
5320 int count = 0, rc = 0;
5322 /* Reverse ce list */
5323 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
5324 if (ce2->ce_type != etype) {
5329 ce2->ce_sibs = cetmp;
5332 if ( max && count >= max ) {
5338 /* Move original to a temp name until increments are done */
5340 ce->ce_entry->e_private = NULL;
5341 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5342 base+BIGTMP, 0, use_ldif );
5343 ce->ce_entry->e_private = ce;
5345 /* start incrementing */
5346 for (ce2=cetmp; ce2; ce2=ce3) {
5348 ce2->ce_sibs = cerem;
5351 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5352 count+base, 0, use_ldif );
5356 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5357 base, 0, use_ldif );
5362 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5363 CfEntryInfo *ce2, int old, int use_ldif )
5367 /* Renumber original to a temp value */
5368 ce->ce_entry->e_private = NULL;
5369 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5370 old+BIGTMP, 0, use_ldif );
5371 ce->ce_entry->e_private = ce;
5373 /* start decrementing */
5374 for (; ce2 != ce; ce2=ce2->ce_sibs) {
5375 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5376 count+old, 0, use_ldif );
5379 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5380 count+old, 0, use_ldif );
5383 /* Parse an LDAP entry into config directives, then store in underlying
5387 config_back_add( Operation *op, SlapReply *rs )
5393 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
5394 NULL, ACL_WADD, NULL )) {
5395 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5400 * Check for attribute ACL
5402 if ( !acl_check_modlist( op, op->ora_e, op->orm_modlist )) {
5403 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5404 rs->sr_text = "no write access to attribute";
5408 cfb = (CfBackInfo *)op->o_bd->be_private;
5410 /* add opattrs for syncprov */
5412 char textbuf[SLAP_TEXT_BUFLEN];
5413 size_t textlen = sizeof textbuf;
5414 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1, NULL,
5415 &rs->sr_text, textbuf, sizeof( textbuf ) );
5416 if ( rs->sr_err != LDAP_SUCCESS )
5418 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
5419 if ( rs->sr_err != LDAP_SUCCESS ) {
5420 Debug( LDAP_DEBUG_TRACE,
5421 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
5422 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
5427 if ( op->o_abandon ) {
5428 rs->sr_err = SLAPD_ABANDON;
5431 ldap_pvt_thread_pool_pause( &connection_pool );
5434 * 1) check for existence of entry
5435 * 2) check for sibling renumbering
5436 * 3) perform internal add
5437 * 4) perform any necessary renumbering
5438 * 5) store entry in underlying database
5440 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
5441 if ( rs->sr_err != LDAP_SUCCESS ) {
5442 rs->sr_text = ca.cr_msg;
5447 CfEntryInfo *ce = ca.ca_entry->e_private;
5448 req_add_s addr = op->oq_add;
5449 op->o_tag = LDAP_REQ_MODRDN;
5450 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
5451 op->o_tag = LDAP_REQ_ADD;
5453 if ( rs->sr_err != LDAP_SUCCESS ) {
5458 if ( cfb->cb_use_ldif ) {
5459 BackendDB *be = op->o_bd;
5460 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5461 struct berval dn, ndn;
5463 op->o_bd = &cfb->cb_db;
5465 /* Save current rootdn; use the underlying DB's rootdn */
5468 op->o_dn = op->o_bd->be_rootdn;
5469 op->o_ndn = op->o_bd->be_rootndn;
5471 scp = op->o_callback;
5472 op->o_callback = ≻
5473 op->o_bd->be_add( op, rs );
5475 op->o_callback = scp;
5481 ldap_pvt_thread_pool_resume( &connection_pool );
5484 { int repl = op->o_dont_replicate;
5485 if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
5486 rs->sr_text = NULL; /* Set after config_add_internal */
5487 rs->sr_err = LDAP_SUCCESS;
5488 op->o_dont_replicate = 1;
5490 send_ldap_result( op, rs );
5491 op->o_dont_replicate = repl;
5493 slap_graduate_commit_csn( op );
5497 typedef struct delrec {
5498 struct delrec *next;
5504 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
5510 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
5511 ca->line[0] == '{' )
5513 char *ptr = strchr( ca->line + 1, '}' );
5517 ca->valx = strtol( ca->line + 1, &next, 0 );
5518 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
5524 rc = config_parse_add( ct, ca, i );
5532 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
5535 int rc = LDAP_UNWILLING_TO_PERFORM;
5537 Entry *e = ce->ce_entry;
5538 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
5543 delrec *dels = NULL, *deltail = NULL;
5545 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5546 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
5548 colst = count_ocs( oc_at, &nocs );
5550 /* make sure add/del flags are clear; should always be true */
5551 for ( s = save_attrs; s; s = s->a_next ) {
5552 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
5555 e->e_attrs = attrs_dup( e->e_attrs );
5557 init_config_argv( ca );
5560 ca->ca_private = ce->ce_private;
5562 ca->fname = "slapd";
5564 strcpy( ca->log, "back-config" );
5566 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
5567 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5568 switch (ml->sml_op) {
5569 case LDAP_MOD_DELETE:
5570 case LDAP_MOD_REPLACE:
5571 case SLAP_MOD_SOFTDEL:
5573 BerVarray vals = NULL, nvals = NULL;
5575 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
5577 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot delete %s",
5578 ml->sml_desc->ad_cname.bv_val );
5581 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5582 vals = ml->sml_values;
5583 nvals = ml->sml_nvalues;
5584 ml->sml_values = NULL;
5585 ml->sml_nvalues = NULL;
5587 /* If we're deleting by values, remember the indexes of the
5588 * values we deleted.
5590 if ( ct && ml->sml_values ) {
5592 i = ml->sml_numvals;
5593 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
5604 rc = modify_delete_vindex(e, &ml->sml_mod,
5605 get_permissiveModify(op),
5606 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg), idx );
5607 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5608 ml->sml_values = vals;
5609 ml->sml_nvalues = nvals;
5611 if ( rc == LDAP_NO_SUCH_ATTRIBUTE && ml->sml_op == SLAP_MOD_SOFTDEL )
5615 /* FIXME: check rc before fallthru? */
5619 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5621 case SLAP_MOD_ADD_IF_NOT_PRESENT:
5622 if ( ml->sml_op == SLAP_MOD_ADD_IF_NOT_PRESENT
5623 && attr_find( e->e_attrs, ml->sml_desc ) )
5630 case SLAP_MOD_SOFTADD: {
5631 int mop = ml->sml_op;
5633 ml->sml_op = LDAP_MOD_ADD;
5635 if ( ct->arg_type & ARG_NO_INSERT ) {
5636 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
5638 navals = a->a_numvals;
5641 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
5642 if ( ml->sml_values[i].bv_val[0] == '{' &&
5645 char *next, *val = ml->sml_values[i].bv_val + 1;
5648 j = strtol( val, &next, 0 );
5649 if ( next == val || next[ 0 ] != '}' || j < navals ) {
5651 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot insert %s",
5652 ml->sml_desc->ad_cname.bv_val );
5656 rc = check_vals( ct, ca, ml, 0 );
5657 if ( rc ) goto out_noop;
5660 rc = modify_add_values(e, &ml->sml_mod,
5661 get_permissiveModify(op),
5662 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5664 /* If value already exists, show success here
5665 * and ignore this operation down below.
5667 if ( mop == SLAP_MOD_SOFTADD ) {
5668 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
5678 case LDAP_MOD_INCREMENT: /* FIXME */
5683 if(rc != LDAP_SUCCESS) break;
5686 if ( rc == LDAP_SUCCESS) {
5687 /* check that the entry still obeys the schema */
5688 rc = entry_schema_check(op, e, NULL, 0, 0, NULL,
5689 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5691 if ( rc ) goto out_noop;
5693 /* Basic syntax checks are OK. Do the actual settings. */
5694 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5695 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5696 if ( !ct ) continue;
5698 s = attr_find( save_attrs, ml->sml_desc );
5699 a = attr_find( e->e_attrs, ml->sml_desc );
5701 switch (ml->sml_op) {
5702 case LDAP_MOD_DELETE:
5703 case LDAP_MOD_REPLACE: {
5704 BerVarray vals = NULL, nvals = NULL;
5707 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5708 vals = ml->sml_values;
5709 nvals = ml->sml_nvalues;
5710 ml->sml_values = NULL;
5711 ml->sml_nvalues = NULL;
5714 if ( ml->sml_values )
5717 /* If we didn't delete the whole attribute */
5718 if ( ml->sml_values && a ) {
5719 struct berval *mvals;
5722 if ( ml->sml_nvalues )
5723 mvals = ml->sml_nvalues;
5725 mvals = ml->sml_values;
5727 /* use the indexes we saved up above */
5728 for (i=0; i < d->nidx; i++) {
5729 struct berval bv = *mvals++;
5730 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
5731 bv.bv_val[0] == '{' ) {
5732 ptr = strchr( bv.bv_val, '}' ) + 1;
5733 bv.bv_len -= ptr - bv.bv_val;
5736 ca->line = bv.bv_val;
5737 ca->valx = d->idx[i];
5738 config_parse_vals(ct, ca, d->idx[i] );
5739 rc = config_del_vals( ct, ca );
5740 if ( rc != LDAP_SUCCESS ) break;
5742 s->a_flags |= SLAP_ATTR_IXDEL;
5743 for (j=i+1; j < d->nidx; j++)
5744 if ( d->idx[j] >d->idx[i] )
5751 rc = config_del_vals( ct, ca );
5752 if ( rc ) rc = LDAP_OTHER;
5754 s->a_flags |= SLAP_ATTR_IXDEL;
5756 if ( ml->sml_values ) {
5761 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5762 ml->sml_values = vals;
5763 ml->sml_nvalues = nvals;
5765 if ( !vals || rc != LDAP_SUCCESS )
5768 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5771 for (i=0; ml->sml_values[i].bv_val; i++) {
5772 ca->line = ml->sml_values[i].bv_val;
5774 rc = config_modify_add( ct, ca, ml->sml_desc, i );
5777 a->a_flags |= SLAP_ATTR_IXADD;
5784 /* Undo for a failed operation */
5785 if ( rc != LDAP_SUCCESS ) {
5786 ConfigReply msg = ca->reply;
5787 for ( s = save_attrs; s; s = s->a_next ) {
5788 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
5789 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5790 ct = config_find_table( colst, nocs, s->a_desc, ca );
5791 a = attr_find( e->e_attrs, s->a_desc );
5793 /* clear the flag so the add check below will skip it */
5794 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5798 config_del_vals( ct, ca );
5800 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5801 ca->line = s->a_vals[i].bv_val;
5803 config_modify_add( ct, ca, s->a_desc, i );
5807 for ( a = e->e_attrs; a; a = a->a_next ) {
5808 if ( a->a_flags & SLAP_ATTR_IXADD ) {
5809 ct = config_find_table( colst, nocs, a->a_desc, ca );
5813 config_del_vals( ct, ca );
5814 s = attr_find( save_attrs, a->a_desc );
5816 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5817 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5818 ca->line = s->a_vals[i].bv_val;
5820 config_modify_add( ct, ca, s->a_desc, i );
5831 if ( rc == LDAP_SUCCESS ) {
5832 attrs_free( save_attrs );
5835 attrs_free( e->e_attrs );
5836 e->e_attrs = save_attrs;
5838 ch_free( ca->argv );
5839 if ( colst ) ch_free( colst );
5841 deltail = dels->next;
5850 config_back_modify( Operation *op, SlapReply *rs )
5853 CfEntryInfo *ce, *last;
5855 ConfigArgs ca = {0};
5858 AttributeDescription *rad = NULL;
5861 cfb = (CfBackInfo *)op->o_bd->be_private;
5863 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5866 rs->sr_matched = last->ce_entry->e_name.bv_val;
5867 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5871 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
5872 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5876 /* Get type of RDN */
5877 rdn = ce->ce_entry->e_nname;
5878 ptr = strchr( rdn.bv_val, '=' );
5879 rdn.bv_len = ptr - rdn.bv_val;
5880 rs->sr_err = slap_bv2ad( &rdn, &rad, &rs->sr_text );
5881 if ( rs->sr_err != LDAP_SUCCESS ) {
5885 /* Some basic validation... */
5886 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5887 /* Don't allow Modify of RDN; must use ModRdn for that. */
5888 if ( ml->sml_desc == rad ) {
5889 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
5890 rs->sr_text = "Use modrdn to change the entry name";
5893 /* Internal update of contextCSN? */
5894 if ( ml->sml_desc == slap_schema.si_ad_contextCSN && op->o_conn->c_conn_idx == -1 ) {
5900 slap_mods_opattrs( op, &op->orm_modlist, 1 );
5903 if ( op->o_abandon ) {
5904 rs->sr_err = SLAPD_ABANDON;
5907 ldap_pvt_thread_pool_pause( &connection_pool );
5911 * 1) perform the Modify on the cached Entry.
5912 * 2) verify that the Entry still satisfies the schema.
5913 * 3) perform the individual config operations.
5914 * 4) store Modified entry in underlying LDIF backend.
5916 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
5918 rs->sr_text = ca.cr_msg;
5919 } else if ( cfb->cb_use_ldif ) {
5920 BackendDB *be = op->o_bd;
5921 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5922 struct berval dn, ndn;
5924 op->o_bd = &cfb->cb_db;
5928 op->o_dn = op->o_bd->be_rootdn;
5929 op->o_ndn = op->o_bd->be_rootndn;
5931 scp = op->o_callback;
5932 op->o_callback = ≻
5933 op->o_bd->be_modify( op, rs );
5935 op->o_callback = scp;
5941 ldap_pvt_thread_pool_resume( &connection_pool );
5943 send_ldap_result( op, rs );
5944 slap_graduate_commit_csn( op );
5949 config_back_modrdn( Operation *op, SlapReply *rs )
5952 CfEntryInfo *ce, *last;
5956 cfb = (CfBackInfo *)op->o_bd->be_private;
5958 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5961 rs->sr_matched = last->ce_entry->e_name.bv_val;
5962 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5965 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
5966 NULL, ACL_WRITE, NULL )) {
5967 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5971 if ( ce->ce_parent )
5972 parent = ce->ce_parent->ce_entry;
5974 parent = (Entry *)&slap_entry_root;
5975 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
5976 NULL, ACL_WRITE, NULL )) {
5977 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5982 /* We don't allow moving objects to new parents.
5983 * Generally we only allow reordering a set of ordered entries.
5985 if ( op->orr_newSup ) {
5986 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5990 /* If newRDN == oldRDN, quietly succeed */
5991 dnRdn( &op->o_req_ndn, &rdn );
5992 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
5993 rs->sr_err = LDAP_SUCCESS;
5997 /* Current behavior, subject to change as needed:
5999 * For backends and overlays, we only allow renumbering.
6000 * For schema, we allow renaming with the same number.
6001 * Otherwise, the op is not allowed.
6004 if ( ce->ce_type == Cft_Schema ) {
6008 /* Can't alter the main cn=schema entry */
6009 if ( ce->ce_parent->ce_type == Cft_Global ) {
6010 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6011 rs->sr_text = "renaming not allowed for this entry";
6015 /* We could support this later if desired */
6016 ptr1 = ber_bvchr( &rdn, '}' );
6017 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
6018 len = ptr1 - rdn.bv_val;
6019 if ( len != ptr2 - op->orr_newrdn.bv_val ||
6020 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
6021 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6022 rs->sr_text = "schema reordering not supported";
6025 } else if ( ce->ce_type == Cft_Database ||
6026 ce->ce_type == Cft_Overlay ) {
6027 char *ptr1, *ptr2, *iptr1, *iptr2;
6030 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
6031 if ( *iptr2 != '{' ) {
6032 rs->sr_err = LDAP_NAMING_VIOLATION;
6033 rs->sr_text = "new ordering index is required";
6037 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
6038 ptr1 = ber_bvchr( &rdn, '}' );
6039 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
6041 rs->sr_err = LDAP_NAMING_VIOLATION;
6042 rs->sr_text = "new ordering index is required";
6046 len1 = ptr1 - rdn.bv_val;
6047 len2 = ptr2 - op->orr_newrdn.bv_val;
6049 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
6050 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
6051 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6052 rs->sr_text = "changing database/overlay type not allowed";
6055 ixold = strtol( iptr1, NULL, 0 );
6056 ixnew = strtol( iptr2, &ptr1, 0 );
6057 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
6058 rs->sr_err = LDAP_NAMING_VIOLATION;
6061 /* config DB is always 0, cannot be changed */
6062 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
6063 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
6067 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6068 rs->sr_text = "renaming not supported for this entry";
6072 if ( op->o_abandon ) {
6073 rs->sr_err = SLAPD_ABANDON;
6076 ldap_pvt_thread_pool_pause( &connection_pool );
6078 if ( ce->ce_type == Cft_Schema ) {
6079 req_modrdn_s modr = op->oq_modrdn;
6082 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
6083 if ( rs->sr_err == LDAP_SUCCESS ) {
6084 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
6085 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
6088 op->oq_modrdn = modr;
6090 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
6091 req_modrdn_s modr = op->oq_modrdn;
6094 /* Advance to first of this type */
6095 cprev = &ce->ce_parent->ce_kids;
6096 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
6097 cprev = &ce2->ce_sibs;
6100 /* Skip the -1 entry */
6101 if ( ce->ce_type == Cft_Database ) {
6102 cprev = &ce2->ce_sibs;
6108 /* Remove from old slot */
6109 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
6110 cprev = &ce2->ce_sibs;
6111 *cprev = ce->ce_sibs;
6112 ceold = ce->ce_sibs;
6114 /* Insert into new slot */
6116 for ( i=0; i<ixnew; i++ ) {
6120 cprev = &ce2->ce_sibs;
6122 ce->ce_sibs = *cprev;
6127 /* NOTE: These should be encoded in the OC tables, not inline here */
6128 if ( ce->ce_type == Cft_Database )
6129 backend_db_move( ce->ce_be, ixnew );
6130 else if ( ce->ce_type == Cft_Overlay )
6131 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
6133 if ( ixold < ixnew ) {
6134 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
6137 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
6138 ixold - ixnew, cfb->cb_use_ldif );
6140 op->oq_modrdn = modr;
6143 ldap_pvt_thread_pool_resume( &connection_pool );
6145 send_ldap_result( op, rs );
6150 config_back_delete( Operation *op, SlapReply *rs )
6152 #ifdef SLAP_CONFIG_DELETE
6154 CfEntryInfo *ce, *last, *ce2;
6156 cfb = (CfBackInfo *)op->o_bd->be_private;
6158 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6161 rs->sr_matched = last->ce_entry->e_name.bv_val;
6162 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6163 } else if ( ce->ce_kids ) {
6164 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6165 } else if ( op->o_abandon ) {
6166 rs->sr_err = SLAPD_ABANDON;
6167 } else if ( ce->ce_type == Cft_Overlay || ce->ce_type == Cft_Database ){
6171 ldap_pvt_thread_pool_pause( &connection_pool );
6173 if ( ce->ce_type == Cft_Overlay ){
6174 if ( SLAP_ISGLOBALOVERLAY(ce->ce_be ) ) {
6175 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6176 rs->sr_text = "Cannot delete global overlays";
6177 ldap_pvt_thread_pool_resume( &connection_pool );
6179 } else if ( ce->ce_be == op->o_bd->bd_self ) {
6180 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6181 rs->sr_text = "Cannot delete cn=config overlays";
6182 ldap_pvt_thread_pool_resume( &connection_pool );
6185 overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
6187 } else { /* Cft_Database*/
6188 if ( ce->ce_be == frontendDB || ce->ce_be == op->o_bd ){
6189 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6190 rs->sr_text = "Cannot delete config or frontend database";
6191 ldap_pvt_thread_pool_resume( &connection_pool );
6194 if ( ce->ce_be->bd_info->bi_db_close ) {
6195 ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
6197 backend_destroy_one( ce->ce_be, 1);
6200 /* remove CfEntryInfo from the siblings list */
6201 if ( ce->ce_parent->ce_kids == ce ) {
6202 ce->ce_parent->ce_kids = ce->ce_sibs;
6204 for ( ce2 = ce->ce_parent->ce_kids ; ce2; ce2 = ce2->ce_sibs ) {
6205 if ( ce2->ce_sibs == ce ) {
6206 ce2->ce_sibs = ce->ce_sibs;
6212 /* remove from underlying database */
6213 if ( cfb->cb_use_ldif ) {
6214 BackendDB *be = op->o_bd;
6215 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
6216 struct berval dn, ndn, req_dn, req_ndn;
6218 op->o_bd = &cfb->cb_db;
6222 req_dn = op->o_req_dn;
6223 req_ndn = op->o_req_ndn;
6225 op->o_dn = op->o_bd->be_rootdn;
6226 op->o_ndn = op->o_bd->be_rootndn;
6227 op->o_req_dn = ce->ce_entry->e_name;
6228 op->o_req_ndn = ce->ce_entry->e_nname;
6230 scp = op->o_callback;
6231 op->o_callback = ≻
6232 op->o_bd->be_delete( op, rs );
6234 op->o_callback = scp;
6237 op->o_req_dn = req_dn;
6238 op->o_req_ndn = req_ndn;
6241 /* renumber siblings */
6242 iptr = ber_bvchr( &op->o_req_ndn, '{' ) + 1;
6243 ixold = strtol( iptr, NULL, 0 );
6244 for (ce2 = ce->ce_sibs, count=0; ce2; ce2=ce2->ce_sibs) {
6245 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
6246 count+ixold, 0, cfb->cb_use_ldif );
6250 ce->ce_entry->e_private=NULL;
6251 entry_free(ce->ce_entry);
6253 ldap_pvt_thread_pool_resume( &connection_pool );
6255 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6258 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6259 #endif /* SLAP_CONFIG_DELETE */
6261 send_ldap_result( op, rs );
6266 config_back_search( Operation *op, SlapReply *rs )
6269 CfEntryInfo *ce, *last;
6272 cfb = (CfBackInfo *)op->o_bd->be_private;
6274 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6277 rs->sr_matched = last->ce_entry->e_name.bv_val;
6278 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6281 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
6282 ACL_SEARCH, NULL, &mask ))
6284 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
6285 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6287 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
6291 switch ( op->ors_scope ) {
6292 case LDAP_SCOPE_BASE:
6293 case LDAP_SCOPE_SUBTREE:
6294 rs->sr_err = config_send( op, rs, ce, 0 );
6297 case LDAP_SCOPE_ONELEVEL:
6298 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
6299 rs->sr_err = config_send( op, rs, ce, 1 );
6308 send_ldap_result( op, rs );
6312 /* no-op, we never free entries */
6313 int config_entry_release(
6318 if ( !e->e_private ) {
6321 return LDAP_SUCCESS;
6324 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
6326 int config_back_entry_get(
6330 AttributeDescription *at,
6335 CfEntryInfo *ce, *last;
6336 int rc = LDAP_NO_SUCH_OBJECT;
6338 cfb = (CfBackInfo *)op->o_bd->be_private;
6340 ce = config_find_base( cfb->cb_root, ndn, &last );
6342 *ent = ce->ce_entry;
6345 if ( oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
6346 rc = LDAP_NO_SUCH_ATTRIBUTE;
6356 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
6357 ConfigTable *ct, ConfigArgs *c )
6361 for (; at && *at; at++) {
6362 /* Skip the naming attr */
6363 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
6365 for (i=0;ct[i].name;i++) {
6366 if (ct[i].ad == (*at)->sat_ad) {
6367 rc = config_get_vals(&ct[i], c);
6368 /* NOTE: tolerate that config_get_vals()
6369 * returns success with no values */
6370 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
6371 if ( c->rvalue_nvals )
6372 rc = attr_merge(e, ct[i].ad, c->rvalue_vals,
6375 slap_syntax_validate_func *validate =
6376 ct[i].ad->ad_type->sat_syntax->ssyn_validate;
6379 for ( j=0; c->rvalue_vals[j].bv_val; j++ ) {
6380 rc = ordered_value_validate( ct[i].ad,
6381 &c->rvalue_vals[j], LDAP_MOD_ADD );
6383 Debug( LDAP_DEBUG_ANY,
6384 "config_build_attrs: error %d on %s value #%d\n",
6385 rc, ct[i].ad->ad_cname.bv_val, j );
6391 rc = attr_merge_normalize(e, ct[i].ad,
6392 c->rvalue_vals, NULL);
6394 ber_bvarray_free( c->rvalue_nvals );
6395 ber_bvarray_free( c->rvalue_vals );
6397 Debug( LDAP_DEBUG_ANY,
6398 "config_build_attrs: error %d on %s\n",
6399 rc, ct[i].ad->ad_cname.bv_val, 0 );
6410 /* currently (2010) does not access rs except possibly writing rs->sr_err */
6413 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
6414 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
6416 Entry *e = entry_alloc();
6417 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
6419 struct berval ad_name;
6420 AttributeDescription *ad = NULL;
6423 const char *text = "";
6427 CfEntryInfo *ceprev = NULL;
6429 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
6432 ce->ce_type = main->co_type;
6433 ce->ce_parent = parent;
6435 pdn = parent->ce_entry->e_nname;
6436 if ( parent->ce_kids && parent->ce_kids->ce_type <= ce->ce_type )
6437 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
6438 ceprev->ce_type <= ce->ce_type;
6439 ceprev = ceprev->ce_sibs );
6444 ce->ce_private = c->ca_private;
6448 build_new_dn( &e->e_name, &pdn, rdn, NULL );
6449 ber_dupbv( &e->e_nname, &e->e_name );
6451 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6452 main->co_name, NULL );
6454 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6455 extra->co_name, NULL );
6456 ptr = strchr(rdn->bv_val, '=');
6457 ad_name.bv_val = rdn->bv_val;
6458 ad_name.bv_len = ptr - rdn->bv_val;
6459 rc = slap_bv2ad( &ad_name, &ad, &text );
6464 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
6465 attr_merge_normalize_one(e, ad, &val, NULL );
6468 c->table = main->co_type;
6469 if ( oc->soc_required ) {
6470 rc = config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
6471 if ( rc ) goto fail;
6474 if ( oc->soc_allowed ) {
6475 rc = config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
6476 if ( rc ) goto fail;
6481 c->table = extra->co_type;
6482 if ( oc->soc_required ) {
6483 rc = config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
6484 if ( rc ) goto fail;
6487 if ( oc->soc_allowed ) {
6488 rc = config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
6489 if ( rc ) goto fail;
6493 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
6494 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->cr_msg,
6495 sizeof(c->cr_msg), op ? op->o_tmpmemctx : NULL );
6496 if ( rc != LDAP_SUCCESS ) {
6498 Debug( LDAP_DEBUG_ANY,
6499 "config_build_entry: build \"%s\" failed: \"%s\"\n",
6500 rdn->bv_val, text, 0);
6503 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
6506 op->ora_modlist = NULL;
6507 slap_add_opattrs( op, NULL, NULL, 0, 0 );
6508 if ( !op->o_noop ) {
6509 SlapReply rs2 = {REP_RESULT};
6510 op->o_bd->be_add( op, &rs2 );
6511 rs->sr_err = rs2.sr_err;
6512 rs_assert_done( &rs2 );
6513 if ( ( rs2.sr_err != LDAP_SUCCESS )
6514 && (rs2.sr_err != LDAP_ALREADY_EXISTS) ) {
6520 ce->ce_sibs = ceprev->ce_sibs;
6521 ceprev->ce_sibs = ce;
6522 } else if ( parent ) {
6523 ce->ce_sibs = parent->ce_kids;
6524 parent->ce_kids = ce;
6531 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
6532 Operation *op, SlapReply *rs )
6535 ConfigFile *cf = c->ca_private;
6537 struct berval bv, rdn;
6539 for (; cf; cf=cf->c_sibs, c->depth++) {
6540 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
6541 !cf->c_om_head && !cf->c_syn_head ) continue;
6542 c->value_dn.bv_val = c->log;
6543 LUTIL_SLASHPATH( cf->c_file.bv_val );
6544 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
6549 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
6551 ptr = strchr( bv.bv_val, '.' );
6553 bv.bv_len = ptr - bv.bv_val;
6554 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
6555 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6556 /* FIXME: how can indicate error? */
6559 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
6561 c->value_dn.bv_len += bv.bv_len;
6562 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
6566 e = config_build_entry( op, rs, ceparent, c, &rdn,
6567 &CFOC_SCHEMA, NULL );
6570 } else if ( e && cf->c_kids ) {
6571 c->ca_private = cf->c_kids;
6572 config_build_schema_inc( c, e->e_private, op, rs );
6578 #ifdef SLAPD_MODULES
6581 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
6582 Operation *op, SlapReply *rs )
6587 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
6588 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
6590 c->value_dn.bv_val = c->log;
6591 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
6592 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6593 /* FIXME: how can indicate error? */
6597 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
6606 config_check_schema(Operation *op, CfBackInfo *cfb)
6608 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
6610 CfEntryInfo *ce, *last;
6613 /* If there's no root entry, we must be in the midst of converting */
6614 if ( !cfb->cb_root )
6617 /* Make sure the main schema entry exists */
6618 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
6625 /* Make sure it's up to date */
6626 if ( cf_om_tail != om_sys_tail ) {
6627 a = attr_find( e->e_attrs, cfAd_om );
6629 if ( a->a_nvals != a->a_vals )
6630 ber_bvarray_free( a->a_nvals );
6631 ber_bvarray_free( a->a_vals );
6636 oidm_unparse( &bv, NULL, NULL, 1 );
6637 attr_merge_normalize( e, cfAd_om, bv, NULL );
6638 ber_bvarray_free( bv );
6639 cf_om_tail = om_sys_tail;
6641 if ( cf_at_tail != at_sys_tail ) {
6642 a = attr_find( e->e_attrs, cfAd_attr );
6644 if ( a->a_nvals != a->a_vals )
6645 ber_bvarray_free( a->a_nvals );
6646 ber_bvarray_free( a->a_vals );
6651 at_unparse( &bv, NULL, NULL, 1 );
6652 attr_merge_normalize( e, cfAd_attr, bv, NULL );
6653 ber_bvarray_free( bv );
6654 cf_at_tail = at_sys_tail;
6656 if ( cf_oc_tail != oc_sys_tail ) {
6657 a = attr_find( e->e_attrs, cfAd_oc );
6659 if ( a->a_nvals != a->a_vals )
6660 ber_bvarray_free( a->a_nvals );
6661 ber_bvarray_free( a->a_vals );
6666 oc_unparse( &bv, NULL, NULL, 1 );
6667 attr_merge_normalize( e, cfAd_oc, bv, NULL );
6668 ber_bvarray_free( bv );
6669 cf_oc_tail = oc_sys_tail;
6671 if ( cf_syn_tail != syn_sys_tail ) {
6672 a = attr_find( e->e_attrs, cfAd_syntax );
6674 if ( a->a_nvals != a->a_vals )
6675 ber_bvarray_free( a->a_nvals );
6676 ber_bvarray_free( a->a_vals );
6681 syn_unparse( &bv, NULL, NULL, 1 );
6682 attr_merge_normalize( e, cfAd_syntax, bv, NULL );
6683 ber_bvarray_free( bv );
6684 cf_syn_tail = syn_sys_tail;
6687 SlapReply rs = {REP_RESULT};
6688 c.ca_private = NULL;
6689 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
6690 &CFOC_SCHEMA, NULL );
6695 ce->ce_private = cfb->cb_config;
6696 cf_at_tail = at_sys_tail;
6697 cf_oc_tail = oc_sys_tail;
6698 cf_om_tail = om_sys_tail;
6699 cf_syn_tail = syn_sys_tail;
6704 static const char *defacl[] = {
6705 NULL, "to", "*", "by", "*", "none", NULL
6709 config_back_db_open( BackendDB *be, ConfigReply *cr )
6711 CfBackInfo *cfb = be->be_private;
6714 CfEntryInfo *ce, *ceparent;
6718 Connection conn = {0};
6719 OperationBuffer opbuf;
6721 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
6722 SlapReply rs = {REP_RESULT};
6723 void *thrctx = NULL;
6725 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
6727 /* If we have no explicitly configured ACLs, don't just use
6728 * the global ACLs. Explicitly deny access to everything.
6730 if ( !be->bd_self->be_acl ) {
6731 parse_acl(be->bd_self, "config_back_db_open", 0, 6, (char **)defacl, 0 );
6734 thrctx = ldap_pvt_thread_pool_context();
6735 connection_fake_init( &conn, &opbuf, thrctx );
6738 op->o_tag = LDAP_REQ_ADD;
6739 op->o_callback = &cb;
6740 op->o_bd = &cfb->cb_db;
6741 op->o_dn = op->o_bd->be_rootdn;
6742 op->o_ndn = op->o_bd->be_rootndn;
6744 if ( !cfb->cb_use_ldif ) {
6748 /* If we read the config from back-ldif, do some quick sanity checks */
6749 if ( cfb->cb_got_ldif ) {
6750 return config_check_schema( op, cfb );
6753 /* create root of tree */
6755 c.ca_private = cfb->cb_config;
6757 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
6767 #ifdef SLAPD_MODULES
6768 /* Create Module nodes... */
6769 if ( modpaths.mp_loads ) {
6770 if ( config_build_modules( &c, ceparent, op, &rs ) ){
6776 /* Create schema nodes... cn=schema will contain the hardcoded core
6777 * schema, read-only. Child objects will contain runtime loaded schema
6781 c.ca_private = NULL;
6782 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
6787 ce->ce_private = cfb->cb_config;
6788 cf_at_tail = at_sys_tail;
6789 cf_oc_tail = oc_sys_tail;
6790 cf_om_tail = om_sys_tail;
6791 cf_syn_tail = syn_sys_tail;
6793 /* Create schema nodes for included schema... */
6794 if ( cfb->cb_config->c_kids ) {
6797 c.ca_private = cfb->cb_config->c_kids;
6798 rc = config_build_schema_inc( &c, ce, op, &rs );
6804 /* Create backend nodes. Skip if they don't provide a cf_table.
6805 * There usually aren't any of these.
6809 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
6810 if (!bi->bi_cf_ocs) {
6811 /* If it only supports the old config mech, complain. */
6812 if ( bi->bi_config ) {
6813 Debug( LDAP_DEBUG_ANY,
6814 "WARNING: No dynamic config support for backend %s.\n",
6815 bi->bi_type, 0, 0 );
6820 if (!bi->bi_private) continue;
6823 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6824 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
6825 if ( rdn.bv_len >= sizeof( c.log ) ) {
6826 /* FIXME: holler ... */ ;
6829 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
6836 /* Create database nodes... */
6837 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
6838 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
6839 for ( i = -1, be = frontendDB ; be;
6840 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
6841 slap_overinfo *oi = NULL;
6843 if ( overlay_is_over( be )) {
6844 oi = be->bd_info->bi_private;
6850 /* If this backend supports the old config mechanism, but not
6851 * the new mech, complain.
6853 if ( !be->be_cf_ocs && bi->bi_db_config ) {
6854 Debug( LDAP_DEBUG_ANY,
6855 "WARNING: No dynamic config support for database %s.\n",
6856 bi->bi_type, 0, 0 );
6860 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6861 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
6863 if ( rdn.bv_len >= sizeof( c.log ) ) {
6864 /* FIXME: holler ... */ ;
6868 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
6874 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd ) {
6875 rs_reinit( &rs, REP_RESULT );
6876 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
6878 /* Iterate through overlays */
6883 voidList *vl, *v0 = NULL;
6885 /* overlays are in LIFO order, must reverse stack */
6886 for (on=oi->oi_list; on; on=on->on_next) {
6887 vl = ch_malloc( sizeof( voidList ));
6892 for (j=0; vl; j++,vl=v0) {
6896 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
6897 Debug( LDAP_DEBUG_ANY,
6898 "WARNING: No dynamic config support for overlay %s.\n",
6899 on->on_bi.bi_type, 0, 0 );
6903 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6904 "%s=" SLAP_X_ORDERED_FMT "%s",
6905 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
6906 if ( rdn.bv_len >= sizeof( c.log ) ) {
6907 /* FIXME: holler ... */ ;
6911 oe = config_build_entry( op, &rs, ce, &c, &rdn,
6912 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
6916 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd ) {
6917 rs_reinit( &rs, REP_RESULT );
6918 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
6924 ldap_pvt_thread_pool_context_reset( thrctx );
6926 if ( unsupp && cfb->cb_use_ldif ) {
6927 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
6928 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
6935 cfb_free_cffile( ConfigFile *cf )
6939 for (; cf; cf=next) {
6942 cfb_free_cffile( cf->c_kids );
6943 ch_free( cf->c_file.bv_val );
6944 ber_bvarray_free( cf->c_dseFiles );
6950 cfb_free_entries( CfEntryInfo *ce )
6954 for (; ce; ce=next) {
6957 cfb_free_entries( ce->ce_kids );
6958 ce->ce_entry->e_private = NULL;
6959 entry_free( ce->ce_entry );
6965 config_back_db_close( BackendDB *be, ConfigReply *cr )
6967 CfBackInfo *cfb = be->be_private;
6969 cfb_free_entries( cfb->cb_root );
6970 cfb->cb_root = NULL;
6972 if ( cfb->cb_db.bd_info ) {
6973 backend_shutdown( &cfb->cb_db );
6980 config_back_db_destroy( BackendDB *be, ConfigReply *cr )
6982 CfBackInfo *cfb = be->be_private;
6984 cfb_free_cffile( cfb->cb_config );
6986 ch_free( cfdir.bv_val );
6988 avl_free( CfOcTree, NULL );
6990 if ( cfb->cb_db.bd_info ) {
6991 cfb->cb_db.be_suffix = NULL;
6992 cfb->cb_db.be_nsuffix = NULL;
6993 BER_BVZERO( &cfb->cb_db.be_rootdn );
6994 BER_BVZERO( &cfb->cb_db.be_rootndn );
6996 backend_destroy_one( &cfb->cb_db, 0 );
7005 config_back_db_init( BackendDB *be, ConfigReply* cr )
7011 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
7012 cfn = cfb->cb_config;
7013 be->be_private = cfb;
7015 ber_dupbv( &be->be_rootdn, &config_rdn );
7016 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
7017 ber_dupbv( &dn, &be->be_rootdn );
7018 ber_bvarray_add( &be->be_suffix, &dn );
7019 ber_dupbv( &dn, &be->be_rootdn );
7020 ber_bvarray_add( &be->be_nsuffix, &dn );
7022 /* Hide from namingContexts */
7023 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
7025 /* Check ACLs on content of Adds by default */
7026 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_ACL_ADD;
7032 config_back_destroy( BackendInfo *bi )
7034 ldif_must_b64_encode_release();
7039 config_tool_entry_open( BackendDB *be, int mode )
7041 CfBackInfo *cfb = be->be_private;
7042 BackendInfo *bi = cfb->cb_db.bd_info;
7044 if ( bi && bi->bi_tool_entry_open )
7045 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
7052 config_tool_entry_close( BackendDB *be )
7054 CfBackInfo *cfb = be->be_private;
7055 BackendInfo *bi = cfb->cb_db.bd_info;
7057 if ( bi && bi->bi_tool_entry_close )
7058 return bi->bi_tool_entry_close( &cfb->cb_db );
7064 config_tool_entry_first( BackendDB *be )
7066 CfBackInfo *cfb = be->be_private;
7067 BackendInfo *bi = cfb->cb_db.bd_info;
7069 if ( bi && bi->bi_tool_entry_first ) {
7070 return bi->bi_tool_entry_first( &cfb->cb_db );
7072 if ( bi && bi->bi_tool_entry_first_x ) {
7073 return bi->bi_tool_entry_first_x( &cfb->cb_db,
7074 NULL, LDAP_SCOPE_DEFAULT, NULL );
7080 config_tool_entry_first_x(
7082 struct berval *base,
7086 CfBackInfo *cfb = be->be_private;
7087 BackendInfo *bi = cfb->cb_db.bd_info;
7089 if ( bi && bi->bi_tool_entry_first_x ) {
7090 return bi->bi_tool_entry_first_x( &cfb->cb_db, base, scope, f );
7096 config_tool_entry_next( BackendDB *be )
7098 CfBackInfo *cfb = be->be_private;
7099 BackendInfo *bi = cfb->cb_db.bd_info;
7101 if ( bi && bi->bi_tool_entry_next )
7102 return bi->bi_tool_entry_next( &cfb->cb_db );
7108 config_tool_entry_get( BackendDB *be, ID id )
7110 CfBackInfo *cfb = be->be_private;
7111 BackendInfo *bi = cfb->cb_db.bd_info;
7113 if ( bi && bi->bi_tool_entry_get )
7114 return bi->bi_tool_entry_get( &cfb->cb_db, id );
7119 static int entry_put_got_frontend=0;
7120 static int entry_put_got_config=0;
7122 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
7124 CfBackInfo *cfb = be->be_private;
7125 BackendInfo *bi = cfb->cb_db.bd_info;
7127 struct berval rdn, vals[ 2 ];
7129 OperationBuffer opbuf;
7131 Connection conn = {0};
7132 Operation *op = NULL;
7136 /* Create entry for frontend database if it does not exist already */
7137 if ( !entry_put_got_frontend ) {
7138 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7139 STRLENOF( "olcDatabase" ))) {
7140 if ( strncmp( e->e_nname.bv_val +
7141 STRLENOF( "olcDatabase" ), "={-1}frontend",
7142 STRLENOF( "={-1}frontend" )) &&
7143 strncmp( e->e_nname.bv_val +
7144 STRLENOF( "olcDatabase" ), "=frontend",
7145 STRLENOF( "=frontend" ))) {
7147 vals[1].bv_val = NULL;
7148 memset( &ca, 0, sizeof(ConfigArgs));
7150 ca.bi = frontendDB->bd_info;
7151 ca.be->be_cf_ocs = &CFOC_FRONTEND;
7152 rdn.bv_val = ca.log;
7153 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7154 "%s=" SLAP_X_ORDERED_FMT "%s",
7155 cfAd_database->ad_cname.bv_val, -1,
7157 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
7158 &CFOC_DATABASE, ca.be->be_cf_ocs );
7159 thrctx = ldap_pvt_thread_pool_context();
7160 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7162 op->o_bd = &cfb->cb_db;
7163 op->o_tag = LDAP_REQ_ADD;
7165 op->o_dn = be->be_rootdn;
7166 op->o_ndn = be->be_rootndn;
7167 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7168 if ( rc != LDAP_SUCCESS ) {
7169 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7170 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7174 if ( ce && bi && bi->bi_tool_entry_put &&
7175 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7176 entry_put_got_frontend++;
7178 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7179 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7183 entry_put_got_frontend++;
7188 /* Create entry for config database if it does not exist already */
7189 if ( !entry_put_got_config && !isFrontend ) {
7190 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7191 STRLENOF( "olcDatabase" ))) {
7192 if ( strncmp( e->e_nname.bv_val +
7193 STRLENOF( "olcDatabase" ), "={0}config",
7194 STRLENOF( "={0}config" )) &&
7195 strncmp( e->e_nname.bv_val +
7196 STRLENOF( "olcDatabase" ), "=config",
7197 STRLENOF( "=config" )) ) {
7199 vals[1].bv_val = NULL;
7200 memset( &ca, 0, sizeof(ConfigArgs));
7201 ca.be = LDAP_STAILQ_FIRST( &backendDB );
7202 ca.bi = ca.be->bd_info;
7203 rdn.bv_val = ca.log;
7204 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7205 "%s=" SLAP_X_ORDERED_FMT "%s",
7206 cfAd_database->ad_cname.bv_val, 0,
7208 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
7211 thrctx = ldap_pvt_thread_pool_context();
7212 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7214 op->o_bd = &cfb->cb_db;
7215 op->o_tag = LDAP_REQ_ADD;
7216 op->o_dn = be->be_rootdn;
7217 op->o_ndn = be->be_rootndn;
7220 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7221 if ( rc != LDAP_SUCCESS ) {
7222 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7223 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7226 if (ce && bi && bi->bi_tool_entry_put &&
7227 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7228 entry_put_got_config++;
7230 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7231 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7235 entry_put_got_config++;
7239 if ( bi && bi->bi_tool_entry_put &&
7240 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
7241 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
7248 AttributeDescription **desc;
7250 { "attribute", &cfAd_attr },
7251 { "backend", &cfAd_backend },
7252 { "database", &cfAd_database },
7253 { "include", &cfAd_include },
7254 { "ldapsyntax", &cfAd_syntax },
7255 { "objectclass", &cfAd_oc },
7256 { "objectidentifier", &cfAd_om },
7257 { "overlay", &cfAd_overlay },
7262 * add / delete: all types that may be added or deleted must use an
7263 * X-ORDERED attributeType for their RDN. Adding and deleting entries
7264 * should automatically renumber the index of any siblings as needed,
7265 * so that no gaps in the numbering sequence exist after the add/delete
7267 * What can be added:
7269 * backend objects for backend-specific config directives
7273 * delete: probably no support this time around.
7275 * modrdn: generally not done. Will be invoked automatically by add/
7276 * delete to update numbering sequence. Perform as an explicit operation
7277 * so that the renumbering effect may be replicated. Subtree rename must
7278 * be supported, since renumbering a database will affect all its child
7281 * modify: must be fully supported.
7285 config_back_initialize( BackendInfo *bi )
7287 ConfigTable *ct = config_back_cf_table;
7291 AttributeDescription *ad = NULL;
7293 static char *controls[] = {
7294 LDAP_CONTROL_MANAGEDSAIT,
7298 /* Make sure we don't exceed the bits reserved for userland */
7299 config_check_userland( CFG_LAST );
7301 bi->bi_controls = controls;
7306 bi->bi_destroy = config_back_destroy;
7308 bi->bi_db_init = config_back_db_init;
7309 bi->bi_db_config = 0;
7310 bi->bi_db_open = config_back_db_open;
7311 bi->bi_db_close = config_back_db_close;
7312 bi->bi_db_destroy = config_back_db_destroy;
7314 bi->bi_op_bind = config_back_bind;
7315 bi->bi_op_unbind = 0;
7316 bi->bi_op_search = config_back_search;
7317 bi->bi_op_compare = 0;
7318 bi->bi_op_modify = config_back_modify;
7319 bi->bi_op_modrdn = config_back_modrdn;
7320 bi->bi_op_add = config_back_add;
7321 bi->bi_op_delete = config_back_delete;
7322 bi->bi_op_abandon = 0;
7324 bi->bi_extended = 0;
7326 bi->bi_chk_referrals = 0;
7328 bi->bi_access_allowed = slap_access_allowed;
7330 bi->bi_connection_init = 0;
7331 bi->bi_connection_destroy = 0;
7333 bi->bi_entry_release_rw = config_entry_release;
7334 bi->bi_entry_get_rw = config_back_entry_get;
7336 bi->bi_tool_entry_open = config_tool_entry_open;
7337 bi->bi_tool_entry_close = config_tool_entry_close;
7338 bi->bi_tool_entry_first = config_tool_entry_first;
7339 bi->bi_tool_entry_first_x = config_tool_entry_first_x;
7340 bi->bi_tool_entry_next = config_tool_entry_next;
7341 bi->bi_tool_entry_get = config_tool_entry_get;
7342 bi->bi_tool_entry_put = config_tool_entry_put;
7345 argv[ 0 ] = "slapd";
7351 for (i=0; OidMacros[i].name; i++ ) {
7352 argv[1] = OidMacros[i].name;
7353 argv[2] = OidMacros[i].oid;
7354 parse_oidm( &ca, 0, NULL );
7357 bi->bi_cf_ocs = cf_ocs;
7359 i = config_register_schema( ct, cf_ocs );
7362 i = slap_str2ad( "olcDatabase", &olcDatabaseDummy[0].ad, &text );
7365 /* setup olcRootPW to be base64-encoded when written in LDIF form;
7366 * basically, we don't care if it fails */
7367 i = slap_str2ad( "olcRootPW", &ad, &text );
7369 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
7370 "warning, unable to get \"olcRootPW\" "
7371 "attribute description: %d: %s\n",
7374 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
7375 ad->ad_type->sat_oid );
7378 /* set up the notable AttributeDescriptions */
7380 for (;ct->name;ct++) {
7381 if (strcmp(ct->name, ads[i].name)) continue;
7382 *ads[i].desc = ct->ad;
7384 if (!ads[i].name) break;