1 /* bconfig.c - the config backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2009 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was originally developed by Howard Chu for inclusion
18 * in OpenLDAP Software.
24 #include <ac/string.h>
32 #include "slapi/slapi.h"
40 #define CONFIG_RDN "cn=config"
41 #define SCHEMA_RDN "cn=schema"
43 static struct berval config_rdn = BER_BVC(CONFIG_RDN);
44 static struct berval schema_rdn = BER_BVC(SCHEMA_RDN);
46 extern int slap_DN_strict; /* dn.c */
49 typedef struct modpath_s {
50 struct modpath_s *mp_next;
51 struct berval mp_path;
55 static ModPaths modpaths, *modlast = &modpaths, *modcur = &modpaths;
58 typedef struct ConfigFile {
59 struct ConfigFile *c_sibs;
60 struct ConfigFile *c_kids;
62 AttributeType *c_at_head, *c_at_tail;
63 ContentRule *c_cr_head, *c_cr_tail;
64 ObjectClass *c_oc_head, *c_oc_tail;
65 OidMacro *c_om_head, *c_om_tail;
66 Syntax *c_syn_head, *c_syn_tail;
71 ConfigFile *cb_config;
73 BackendDB cb_db; /* underlying database */
78 static CfBackInfo cfBackInfo;
80 static char *passwd_salt;
82 static char *logfileName;
83 #ifdef SLAP_AUTH_REWRITE
84 static BerVarray authz_rewrites;
87 static struct berval cfdir;
90 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
91 *cfAd_include, *cfAd_attr, *cfAd_oc, *cfAd_om, *cfAd_syntax;
93 static ConfigFile *cfn;
95 static Avlnode *CfOcTree;
97 /* System schema state */
98 extern AttributeType *at_sys_tail; /* at.c */
99 extern ObjectClass *oc_sys_tail; /* oc.c */
100 extern OidMacro *om_sys_tail; /* oidm.c */
101 extern Syntax *syn_sys_tail; /* syntax.c */
102 static AttributeType *cf_at_tail;
103 static ObjectClass *cf_oc_tail;
104 static OidMacro *cf_om_tail;
105 static Syntax *cf_syn_tail;
107 static int config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca,
108 SlapReply *rs, int *renumber, Operation *op );
110 static int config_check_schema( Operation *op, CfBackInfo *cfb );
112 static ConfigDriver config_fname;
113 static ConfigDriver config_cfdir;
114 static ConfigDriver config_generic;
115 static ConfigDriver config_search_base;
116 static ConfigDriver config_passwd_hash;
117 static ConfigDriver config_schema_dn;
118 static ConfigDriver config_sizelimit;
119 static ConfigDriver config_timelimit;
120 static ConfigDriver config_overlay;
121 static ConfigDriver config_subordinate;
122 static ConfigDriver config_suffix;
123 static ConfigDriver config_rootdn;
124 static ConfigDriver config_rootpw;
125 static ConfigDriver config_restrict;
126 static ConfigDriver config_allows;
127 static ConfigDriver config_disallows;
128 static ConfigDriver config_requires;
129 static ConfigDriver config_security;
130 static ConfigDriver config_referral;
131 static ConfigDriver config_loglevel;
132 static ConfigDriver config_updatedn;
133 static ConfigDriver config_updateref;
134 static ConfigDriver config_include;
135 static ConfigDriver config_obsolete;
137 static ConfigDriver config_tls_option;
138 static ConfigDriver config_tls_config;
140 extern ConfigDriver syncrepl_config;
148 CFG_TLS_PROTOCOL_MIN,
197 static OidRec OidMacros[] = {
198 /* OpenLDAProot:1.12.2 */
199 { "OLcfg", "1.3.6.1.4.1.4203.1.12.2" },
200 { "OLcfgAt", "OLcfg:3" },
201 { "OLcfgGlAt", "OLcfgAt:0" },
202 { "OLcfgBkAt", "OLcfgAt:1" },
203 { "OLcfgDbAt", "OLcfgAt:2" },
204 { "OLcfgOvAt", "OLcfgAt:3" },
205 { "OLcfgCtAt", "OLcfgAt:4" }, /* contrib modules */
206 { "OLcfgOc", "OLcfg:4" },
207 { "OLcfgGlOc", "OLcfgOc:0" },
208 { "OLcfgBkOc", "OLcfgOc:1" },
209 { "OLcfgDbOc", "OLcfgOc:2" },
210 { "OLcfgOvOc", "OLcfgOc:3" },
211 { "OLcfgCtOc", "OLcfgOc:4" }, /* contrib modules */
213 /* Syntaxes. We should just start using the standard names and
214 * document that they are predefined and available for users
215 * to reference in their own schema. Defining schema without
216 * OID macros is for masochists...
218 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
219 { "OMsBoolean", "OMsyn:7" },
220 { "OMsDN", "OMsyn:12" },
221 { "OMsDirectoryString", "OMsyn:15" },
222 { "OMsIA5String", "OMsyn:26" },
223 { "OMsInteger", "OMsyn:27" },
224 { "OMsOID", "OMsyn:38" },
225 { "OMsOctetString", "OMsyn:40" },
230 * Backend/Database registry
232 * OLcfg{Bk|Db}{Oc|At}:0 -> common
233 * OLcfg{Bk|Db}{Oc|At}:1 -> back-bdb(/back-hdb)
234 * OLcfg{Bk|Db}{Oc|At}:2 -> back-ldif
235 * OLcfg{Bk|Db}{Oc|At}:3 -> back-ldap
236 * OLcfg{Bk|Db}{Oc|At}:4 -> back-monitor
237 * OLcfg{Bk|Db}{Oc|At}:5 -> back-relay
238 * OLcfg{Bk|Db}{Oc|At}:6 -> back-sql
239 * OLcfg{Bk|Db}{Oc|At}:7 -> back-sock
245 * OLcfgOv{Oc|At}:1 -> syncprov
246 * OLcfgOv{Oc|At}:2 -> pcache
247 * OLcfgOv{Oc|At}:3 -> chain
248 * OLcfgOv{Oc|At}:4 -> accesslog
249 * OLcfgOv{Oc|At}:5 -> valsort
250 * OLcfgOv{Oc|At}:7 -> distproc
251 * OLcfgOv{Oc|At}:8 -> dynlist
252 * OLcfgOv{Oc|At}:9 -> dds
253 * OLcfgOv{Oc|At}:10 -> unique
254 * OLcfgOv{Oc|At}:11 -> refint
255 * OLcfgOv{Oc|At}:12 -> ppolicy
256 * OLcfgOv{Oc|At}:13 -> constraint
257 * OLcfgOv{Oc|At}:14 -> translucent
258 * OLcfgOv{Oc|At}:15 -> auditlog
259 * OLcfgOv{Oc|At}:16 -> rwm
260 * OLcfgOv{Oc|At}:17 -> dyngroup
261 * OLcfgOv{Oc|At}:18 -> memberof
262 * OLcfgOv{Oc|At}:19 -> collect
263 * OLcfgOv{Oc|At}:20 -> retcode
266 /* alphabetical ordering */
268 static ConfigTable config_back_cf_table[] = {
269 /* This attr is read-only */
270 { "", "", 0, 0, 0, ARG_MAGIC,
271 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
272 "DESC 'File for slapd configuration directives' "
273 "EQUALITY caseIgnoreMatch "
274 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
275 { "", "", 0, 0, 0, ARG_MAGIC,
276 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
277 "DESC 'Directory for slapd configuration backend' "
278 "EQUALITY caseIgnoreMatch "
279 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
280 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
281 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
282 "DESC 'Access Control List' "
283 "EQUALITY caseIgnoreMatch "
284 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
285 { "add_content_acl", NULL, 0, 0, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_ACL_ADD,
286 &config_generic, "( OLcfgGlAt:86 NAME 'olcAddContentAcl' "
287 "DESC 'Check ACLs against content of Add ops' "
288 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
289 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
290 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
291 "DESC 'Allowed set of deprecated features' "
292 "EQUALITY caseIgnoreMatch "
293 "SYNTAX OMsDirectoryString )", NULL, NULL },
294 { "argsfile", "file", 2, 2, 0, ARG_STRING,
295 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
296 "DESC 'File for slapd command line options' "
297 "EQUALITY caseIgnoreMatch "
298 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
299 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
300 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
301 "EQUALITY caseIgnoreMatch "
302 "SYNTAX OMsDirectoryString )", NULL, NULL },
303 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
304 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
305 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
306 "DESC 'OpenLDAP attributeTypes' "
307 "EQUALITY caseIgnoreMatch "
308 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
310 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
311 #ifdef SLAP_AUTH_REWRITE
312 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
316 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
317 "EQUALITY caseIgnoreMatch "
318 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
319 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
320 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
321 "EQUALITY caseIgnoreMatch "
322 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
323 { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
324 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
325 "EQUALITY caseIgnoreMatch "
326 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
327 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
328 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
329 "DESC 'A type of backend' "
330 "EQUALITY caseIgnoreMatch "
331 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
333 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
334 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
335 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
336 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
337 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
338 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
339 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
340 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
341 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
342 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
343 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
344 "DESC 'The backend type for a database instance' "
345 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
346 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
347 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
348 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
349 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
350 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
351 "EQUALITY caseIgnoreMatch "
352 "SYNTAX OMsDirectoryString )", NULL, NULL },
353 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
354 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
355 "DESC 'OpenLDAP DIT content rules' "
356 "EQUALITY caseIgnoreMatch "
357 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
359 { "gentlehup", "on|off", 2, 2, 0,
361 ARG_ON_OFF, &global_gentlehup,
365 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
366 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
367 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
368 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
369 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
370 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
371 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
372 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
373 { "include", "file", 2, 2, 0, ARG_MAGIC,
374 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
375 "SUP labeledURI )", NULL, NULL },
376 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
377 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
378 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
379 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
380 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
381 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
382 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
383 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
384 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
385 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
386 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
387 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
388 { "index_intlen", "len", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_IX_INTLEN,
389 &config_generic, "( OLcfgGlAt:84 NAME 'olcIndexIntLen' "
390 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
391 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
392 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
393 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
394 { "ldapsyntax", "syntax", 2, 0, 0,
395 ARG_PAREN|ARG_MAGIC|CFG_SYNTAX,
396 &config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
397 "DESC 'OpenLDAP ldapSyntax' "
398 "EQUALITY caseIgnoreMatch "
399 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
401 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
402 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
403 "EQUALITY caseIgnoreMatch "
404 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
405 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
406 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
407 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
408 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
409 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
410 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
411 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
412 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
413 "EQUALITY caseIgnoreMatch "
414 "SYNTAX OMsDirectoryString )", NULL, NULL },
415 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
416 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
417 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
418 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
419 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
420 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
421 { "moduleload", "file", 2, 0, 0,
423 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
427 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
428 "EQUALITY caseIgnoreMatch "
429 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
430 { "modulepath", "path", 2, 2, 0,
432 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
436 "( OLcfgGlAt:31 NAME 'olcModulePath' "
437 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
438 { "monitoring", "TRUE|FALSE", 2, 2, 0,
439 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
440 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
441 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
442 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
443 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
444 "DESC 'OpenLDAP object classes' "
445 "EQUALITY caseIgnoreMatch "
446 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
448 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
449 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
450 "EQUALITY caseIgnoreMatch "
451 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
452 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
453 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
454 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
455 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
456 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
457 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
458 { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
459 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
460 "EQUALITY caseIgnoreMatch "
461 "SYNTAX OMsDirectoryString )", NULL, NULL },
462 { "pidfile", "file", 2, 2, 0, ARG_STRING,
463 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
464 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
465 { "plugin", NULL, 0, 0, 0,
467 ARG_MAGIC|CFG_PLUGIN, &config_generic,
471 "( OLcfgGlAt:38 NAME 'olcPlugin' "
472 "EQUALITY caseIgnoreMatch "
473 "SYNTAX OMsDirectoryString )", NULL, NULL },
474 { "pluginlog", "filename", 2, 2, 0,
476 ARG_STRING, &slapi_log_file,
480 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
481 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
482 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
483 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
484 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
485 { "referral", "url", 2, 2, 0, ARG_MAGIC,
486 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
487 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
488 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
489 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
490 "EQUALITY caseIgnoreMatch "
491 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
492 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
493 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
494 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
495 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
496 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
497 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
498 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
499 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
500 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
501 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
502 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
503 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
504 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
505 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
506 "EQUALITY caseIgnoreMatch "
507 "SYNTAX OMsDirectoryString )", NULL, NULL },
508 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
509 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
510 "EQUALITY caseIgnoreMatch "
511 "SYNTAX OMsDirectoryString )", NULL, NULL },
512 { "reverse-lookup", "on|off", 2, 2, 0,
513 #ifdef SLAPD_RLOOKUPS
514 ARG_ON_OFF, &use_reverse_lookup,
518 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
519 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
520 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
521 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
522 "EQUALITY distinguishedNameMatch "
523 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
524 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
525 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
526 "EQUALITY caseIgnoreMatch "
527 "SYNTAX OMsDirectoryString )", NULL, NULL },
528 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
529 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
530 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
531 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
532 &config_generic, NULL, NULL, NULL },
533 { "sasl-auxprops", NULL, 2, 0, 0,
534 #ifdef HAVE_CYRUS_SASL
535 ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
539 "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
540 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
541 { "sasl-host", "host", 2, 2, 0,
542 #ifdef HAVE_CYRUS_SASL
543 ARG_STRING|ARG_UNIQUE, &sasl_host,
547 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
548 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
549 { "sasl-realm", "realm", 2, 2, 0,
550 #ifdef HAVE_CYRUS_SASL
551 ARG_STRING|ARG_UNIQUE, &global_realm,
555 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
556 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
557 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
558 &config_generic, NULL, NULL, NULL },
559 { "sasl-secprops", "properties", 2, 2, 0,
560 #ifdef HAVE_CYRUS_SASL
561 ARG_MAGIC|CFG_SASLSECP, &config_generic,
565 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
566 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
567 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
568 &config_generic, NULL, NULL, NULL },
569 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
570 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
571 "EQUALITY distinguishedNameMatch "
572 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
573 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
574 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
575 "EQUALITY caseIgnoreMatch "
576 "SYNTAX OMsDirectoryString )", NULL, NULL },
577 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
578 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
579 "EQUALITY caseIgnoreMatch "
580 "SYNTAX OMsDirectoryString )", NULL, NULL },
581 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
582 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
583 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
584 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
585 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
586 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
587 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
588 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
589 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
590 { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
591 &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
592 "DESC 'Attributes whose values will always be sorted' "
593 "EQUALITY caseIgnoreMatch "
594 "SYNTAX OMsDirectoryString )", NULL, NULL },
595 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
596 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
597 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
598 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
599 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
600 "EQUALITY distinguishedNameMatch "
601 "SYNTAX OMsDN )", NULL, NULL },
602 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
603 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
604 "EQUALITY caseIgnoreMatch "
605 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
606 { "threads", "count", 2, 2, 0,
610 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
612 "( OLcfgGlAt:66 NAME 'olcThreads' "
613 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
614 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
615 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
616 "SYNTAX OMsDirectoryString )", NULL, NULL },
617 { "TLSCACertificateFile", NULL, 0, 0, 0,
619 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
623 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
624 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
625 { "TLSCACertificatePath", NULL, 0, 0, 0,
627 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
631 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
632 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
633 { "TLSCertificateFile", NULL, 0, 0, 0,
635 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
639 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
640 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
641 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
643 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
647 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
648 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
649 { "TLSCipherSuite", NULL, 0, 0, 0,
651 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
655 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
656 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
657 { "TLSCRLCheck", NULL, 0, 0, 0,
658 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
659 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
663 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
664 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
665 { "TLSCRLFile", NULL, 0, 0, 0,
666 #if defined(HAVE_GNUTLS)
667 CFG_TLS_CRL_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
671 "( OLcfgGlAt:82 NAME 'olcTLSCRLFile' "
672 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
673 { "TLSRandFile", NULL, 0, 0, 0,
675 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
679 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
680 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
681 { "TLSVerifyClient", NULL, 0, 0, 0,
683 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
687 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
688 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
689 { "TLSDHParamFile", NULL, 0, 0, 0,
691 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
695 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
696 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
697 { "TLSProtocolMin", NULL, 0, 0, 0,
699 CFG_TLS_PROTOCOL_MIN|ARG_STRING|ARG_MAGIC, &config_tls_config,
703 "( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' "
704 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
705 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
706 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
707 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
708 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
709 NULL, NULL, NULL, NULL },
710 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
711 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
712 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
713 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
714 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
715 "EQUALITY caseIgnoreMatch "
716 "SUP labeledURI )", NULL, NULL },
717 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
718 NULL, NULL, NULL, NULL }
721 /* Need to no-op this keyword for dynamic config */
722 ConfigTable olcDatabaseDummy[] = {
723 { "", "", 0, 0, 0, ARG_IGNORED,
724 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
725 "DESC 'The backend type for a database instance' "
726 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
727 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
730 /* Routines to check if a child can be added to this type */
731 static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
732 cfAddBackend, cfAddModule, cfAddOverlay;
734 /* NOTE: be careful when defining array members
735 * that can be conditionally compiled */
736 #define CFOC_GLOBAL cf_ocs[1]
737 #define CFOC_SCHEMA cf_ocs[2]
738 #define CFOC_BACKEND cf_ocs[3]
739 #define CFOC_DATABASE cf_ocs[4]
740 #define CFOC_OVERLAY cf_ocs[5]
741 #define CFOC_INCLUDE cf_ocs[6]
742 #define CFOC_FRONTEND cf_ocs[7]
744 #define CFOC_MODULE cf_ocs[8]
745 #endif /* SLAPD_MODULES */
747 static ConfigOCs cf_ocs[] = {
750 "DESC 'OpenLDAP configuration object' "
751 "ABSTRACT SUP top )", Cft_Abstract, NULL },
754 "DESC 'OpenLDAP Global configuration options' "
755 "SUP olcConfig STRUCTURAL "
756 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
757 "olcAttributeOptions $ olcAuthIDRewrite $ "
758 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
759 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
760 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
761 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
762 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcIndexIntLen $ "
763 "olcLocalSSF $ olcLogFile $ olcLogLevel $ "
764 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
765 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
766 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
768 "olcSaslAuxprops $ olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
769 "olcSecurity $ olcServerID $ olcSizeLimit $ "
770 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
771 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
772 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
773 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
774 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
775 "olcTLSCRLFile $ olcToolThreads $ "
776 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
777 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
779 "NAME 'olcSchemaConfig' "
780 "DESC 'OpenLDAP schema object' "
781 "SUP olcConfig STRUCTURAL "
782 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
783 "olcObjectClasses $ olcDitContentRules $ olcLdapSyntaxes ) )",
784 Cft_Schema, NULL, cfAddSchema },
786 "NAME 'olcBackendConfig' "
787 "DESC 'OpenLDAP Backend-specific options' "
788 "SUP olcConfig STRUCTURAL "
789 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
791 "NAME 'olcDatabaseConfig' "
792 "DESC 'OpenLDAP Database-specific options' "
793 "SUP olcConfig STRUCTURAL "
795 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
796 "olcAddContentAcl $ olcLastMod $ olcLimits $ "
797 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
798 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
799 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
800 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ "
801 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
803 Cft_Database, NULL, cfAddDatabase },
805 "NAME 'olcOverlayConfig' "
806 "DESC 'OpenLDAP Overlay-specific options' "
807 "SUP olcConfig STRUCTURAL "
808 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
810 "NAME 'olcIncludeFile' "
811 "DESC 'OpenLDAP configuration include file' "
812 "SUP olcConfig STRUCTURAL "
814 "MAY ( cn $ olcRootDSE ) )",
815 /* Used to be Cft_Include, that def has been removed */
816 Cft_Abstract, NULL, cfAddInclude },
817 /* This should be STRUCTURAL like all the other database classes, but
818 * that would mean inheriting all of the olcDatabaseConfig attributes,
819 * which causes them to be merged twice in config_build_entry.
822 "NAME 'olcFrontendConfig' "
823 "DESC 'OpenLDAP frontend configuration' "
825 "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
826 Cft_Database, NULL, NULL },
829 "NAME 'olcModuleList' "
830 "DESC 'OpenLDAP dynamic module info' "
831 "SUP olcConfig STRUCTURAL "
832 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
833 Cft_Module, NULL, cfAddModule },
838 typedef struct ServerID {
839 struct ServerID *si_next;
840 struct berval si_url;
844 static ServerID *sid_list;
846 typedef struct voidList {
847 struct voidList *vl_next;
851 typedef struct ADlist {
852 struct ADlist *al_next;
853 AttributeDescription *al_desc;
856 static ADlist *sortVals;
859 config_generic(ConfigArgs *c) {
862 if ( c->op == SLAP_CONFIG_EMIT ) {
866 c->value_int = ldap_pvt_thread_get_concurrency();
869 c->value_int = connection_pool_max;
872 c->value_int = slap_tool_thread_max;
876 c->value_string = ch_strdup( passwd_salt );
881 if ( c->be->be_limits ) {
885 for ( i=0; c->be->be_limits[i]; i++ ) {
886 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
887 if ( bv.bv_len >= sizeof( buf ) ) {
888 ber_bvarray_free_x( c->rvalue_vals, NULL );
889 c->rvalue_vals = NULL;
893 bv.bv_val = buf + bv.bv_len;
894 limits_unparse( c->be->be_limits[i], &bv,
895 sizeof( buf ) - ( bv.bv_val - buf ) );
896 bv.bv_len += bv.bv_val - buf;
898 value_add_one( &c->rvalue_vals, &bv );
901 if ( !c->rvalue_vals ) rc = 1;
904 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
907 c->value_string = ch_strdup( slap_sasl_getpolicy());
910 slap_sasl_regexp_unparse( &c->rvalue_vals );
911 if ( !c->rvalue_vals ) rc = 1;
913 #ifdef HAVE_CYRUS_SASL
915 struct berval bv = BER_BVNULL;
916 slap_sasl_secprops_unparse( &bv );
917 if ( !BER_BVISNULL( &bv )) {
918 ber_bvarray_add( &c->rvalue_vals, &bv );
926 c->value_int = c->be->be_max_deref_depth;
929 if ( SLAP_DBHIDDEN( c->be )) {
936 ConfigFile *cf = c->ca_private;
938 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
939 else if ( cf->c_om_head )
940 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
942 if ( !c->rvalue_vals )
947 ad_unparse_options( &c->rvalue_vals );
950 ConfigFile *cf = c->ca_private;
952 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
953 else if ( cf->c_oc_head )
954 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
956 if ( !c->rvalue_vals )
961 ConfigFile *cf = c->ca_private;
963 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
964 else if ( cf->c_at_head )
965 at_unparse( &c->rvalue_vals, cf->c_at_head,
967 if ( !c->rvalue_vals )
972 ConfigFile *cf = c->ca_private;
974 syn_unparse( &c->rvalue_vals, NULL, NULL, 1 );
975 else if ( cf->c_syn_head )
976 syn_unparse( &c->rvalue_vals, cf->c_syn_head,
978 if ( !c->rvalue_vals )
983 ConfigFile *cf = c->ca_private;
985 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
986 else if ( cf->c_cr_head )
987 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
989 if ( !c->rvalue_vals )
996 char *src, *dst, ibuf[11];
997 struct berval bv, abv;
998 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
999 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1000 if ( abv.bv_len >= sizeof( ibuf ) ) {
1001 ber_bvarray_free_x( c->rvalue_vals, NULL );
1002 c->rvalue_vals = NULL;
1006 acl_unparse( a, &bv );
1007 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
1008 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
1009 /* Turn TAB / EOL into plain space */
1010 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
1011 if (isspace((unsigned char)*src)) *dst++ = ' ';
1015 if (dst[-1] == ' ') {
1019 abv.bv_len = dst - abv.bv_val;
1020 ber_bvarray_add( &c->rvalue_vals, &abv );
1026 c->value_int = (SLAP_DBACL_ADD(c->be) != 0);
1029 ConfigFile *cf = c->ca_private;
1030 if ( cf->c_dseFiles ) {
1031 value_add( &c->rvalue_vals, cf->c_dseFiles );
1042 for ( si = sid_list; si; si=si->si_next ) {
1043 assert( si->si_num >= 0 && si->si_num <= SLAP_SYNC_SID_MAX );
1044 if ( !BER_BVISEMPTY( &si->si_url )) {
1045 bv.bv_len = si->si_url.bv_len + 6;
1046 bv.bv_val = ch_malloc( bv.bv_len );
1047 bv.bv_len = sprintf( bv.bv_val, "%d %s", si->si_num,
1048 si->si_url.bv_val );
1049 ber_bvarray_add( &c->rvalue_vals, &bv );
1053 bv.bv_len = sprintf( buf, "%d", si->si_num );
1054 value_add_one( &c->rvalue_vals, &bv );
1063 c->value_string = ch_strdup( logfileName );
1068 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
1070 case CFG_MIRRORMODE:
1071 if ( SLAP_SHADOW(c->be))
1072 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
1076 case CFG_MONITORING:
1077 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
1079 case CFG_SSTR_IF_MAX:
1080 c->value_int = index_substr_if_maxlen;
1082 case CFG_SSTR_IF_MIN:
1083 c->value_int = index_substr_if_minlen;
1086 c->value_int = index_intlen;
1088 case CFG_SORTVALS: {
1091 for ( sv = sortVals; sv; sv = sv->al_next ) {
1092 value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
1096 #ifdef SLAPD_MODULES
1098 ModPaths *mp = c->ca_private;
1101 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
1104 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
1105 SLAP_X_ORDERED_FMT "%s", i,
1106 mp->mp_loads[i].bv_val );
1107 if ( bv.bv_len >= sizeof( c->log ) ) {
1108 ber_bvarray_free_x( c->rvalue_vals, NULL );
1109 c->rvalue_vals = NULL;
1112 value_add_one( &c->rvalue_vals, &bv );
1116 rc = c->rvalue_vals ? 0 : 1;
1120 ModPaths *mp = c->ca_private;
1121 if ( !BER_BVISNULL( &mp->mp_path ))
1122 value_add_one( &c->rvalue_vals, &mp->mp_path );
1124 rc = c->rvalue_vals ? 0 : 1;
1130 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1131 if ( !c->rvalue_vals ) rc = 1;
1134 #ifdef SLAP_AUTH_REWRITE
1136 if ( authz_rewrites ) {
1137 struct berval bv, idx;
1142 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1143 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1144 if ( idx.bv_len >= sizeof( ibuf ) ) {
1145 ber_bvarray_free_x( c->rvalue_vals, NULL );
1146 c->rvalue_vals = NULL;
1149 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1150 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1151 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1152 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1153 authz_rewrites[i].bv_val,
1154 authz_rewrites[i].bv_len + 1 );
1155 ber_bvarray_add( &c->rvalue_vals, &bv );
1158 if ( !c->rvalue_vals ) rc = 1;
1165 } else if ( c->op == LDAP_MOD_DELETE ) {
1168 /* single-valued attrs, no-ops */
1176 case CFG_MIRRORMODE:
1177 case CFG_MONITORING:
1179 case CFG_SSTR_IF_MAX:
1180 case CFG_SSTR_IF_MIN:
1184 /* no-ops, requires slapd restart */
1189 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1193 ch_free( passwd_salt );
1198 ch_free( logfileName );
1206 case CFG_SERVERID: {
1207 ServerID *si, **sip;
1209 for ( i=0, si = sid_list, sip = &sid_list;
1210 si; si = *sip, i++ ) {
1211 if ( c->valx == -1 || i == c->valx ) {
1223 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1227 index_intlen = SLAP_INDEX_INTLEN_DEFAULT;
1228 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1229 SLAP_INDEX_INTLEN_DEFAULT );
1233 if ( c->valx < 0 ) {
1234 acl_destroy( c->be->be_acl );
1235 c->be->be_acl = NULL;
1238 AccessControl **prev, *a;
1240 for (i=0, prev = &c->be->be_acl; i < c->valx;
1243 prev = &a->acl_next;
1246 *prev = a->acl_next;
1253 /* Can be NULL when undoing a failed add */
1254 if ( c->ca_entry ) {
1255 ce = c->ca_entry->e_private;
1256 /* can't modify the hardcoded schema */
1257 if ( ce->ce_parent->ce_type == Cft_Global )
1261 cfn = c->ca_private;
1262 if ( c->valx < 0 ) {
1265 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1267 if ( oc == cfn->c_oc_tail )
1270 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1272 ObjectClass *oc, *prev = NULL;
1274 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1279 if ( cfn->c_oc_tail == oc ) {
1280 cfn->c_oc_tail = prev;
1282 if ( cfn->c_oc_head == oc ) {
1284 cfn->c_oc_head = oc;
1291 /* Can be NULL when undoing a failed add */
1292 if ( c->ca_entry ) {
1293 ce = c->ca_entry->e_private;
1294 /* can't modify the hardcoded schema */
1295 if ( ce->ce_parent->ce_type == Cft_Global )
1299 cfn = c->ca_private;
1300 if ( c->valx < 0 ) {
1303 for( at = cfn->c_at_head; at; at_next( &at )) {
1305 if ( at == cfn->c_at_tail )
1308 cfn->c_at_head = cfn->c_at_tail = NULL;
1310 AttributeType *at, *prev = NULL;
1312 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1317 if ( cfn->c_at_tail == at ) {
1318 cfn->c_at_tail = prev;
1320 if ( cfn->c_at_head == at ) {
1322 cfn->c_at_head = at;
1329 /* Can be NULL when undoing a failed add */
1330 if ( c->ca_entry ) {
1331 ce = c->ca_entry->e_private;
1332 /* can't modify the hardcoded schema */
1333 if ( ce->ce_parent->ce_type == Cft_Global )
1337 cfn = c->ca_private;
1338 if ( c->valx < 0 ) {
1341 for( syn = cfn->c_syn_head; syn; syn_next( &syn )) {
1343 if ( syn == cfn->c_syn_tail )
1346 cfn->c_syn_head = cfn->c_syn_tail = NULL;
1348 Syntax *syn, *prev = NULL;
1350 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++) {
1355 if ( cfn->c_syn_tail == syn ) {
1356 cfn->c_syn_tail = prev;
1358 if ( cfn->c_syn_head == syn ) {
1360 cfn->c_syn_head = syn;
1365 if ( c->valx < 0 ) {
1367 for ( sv = sortVals; sv; sv = sortVals ) {
1368 sortVals = sv->al_next;
1369 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1376 for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
1377 prev = &sv->al_next;
1380 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1381 *prev = sv->al_next;
1387 /* FIXME: there is no limits_free function */
1389 /* FIXME: there is no ad_option_free function */
1391 /* FIXME: there is no way to remove attributes added by
1405 if(!(c->bi = backend_info(c->argv[1]))) {
1406 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1407 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1408 c->log, c->cr_msg, c->argv[1] );
1415 /* NOTE: config is always the first backend!
1417 if ( !strcasecmp( c->argv[1], "config" )) {
1418 c->be = LDAP_STAILQ_FIRST(&backendDB);
1419 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1422 c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply);
1424 if ( c->cr_msg[0] == 0 )
1425 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1426 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n", c->log, c->cr_msg, c->argv[1] );
1433 ldap_pvt_thread_set_concurrency(c->value_int);
1437 if ( c->value_int < 2 ) {
1438 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1439 "threads=%d smaller than minimum value 2",
1441 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1442 c->log, c->cr_msg, 0 );
1445 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1446 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1447 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1448 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1449 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1450 c->log, c->cr_msg, 0 );
1452 if ( slapMode & SLAP_SERVER_MODE )
1453 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1454 connection_pool_max = c->value_int; /* save for reference */
1458 if ( slapMode & SLAP_TOOL_MODE )
1459 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1460 slap_tool_thread_max = c->value_int; /* save for reference */
1464 if ( passwd_salt ) ch_free( passwd_salt );
1465 passwd_salt = c->value_string;
1466 lutil_salt_format(passwd_salt);
1470 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1476 c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1478 c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1482 ch_free(c->value_string);
1483 if (slap_sasl_setpolicy( c->argv[1] )) {
1484 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
1485 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1486 c->log, c->cr_msg, c->argv[1] );
1492 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1496 #ifdef HAVE_CYRUS_SASL
1499 char *txt = slap_sasl_secprops( c->argv[1] );
1501 snprintf( c->cr_msg, sizeof(c->cr_msg), "<%s> %s",
1503 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0 );
1511 c->be->be_max_deref_depth = c->value_int;
1517 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1518 cfn = c->ca_private;
1519 if(parse_oidm(c, 1, &om))
1521 if (!cfn->c_om_head) cfn->c_om_head = om;
1522 cfn->c_om_tail = om;
1527 ObjectClass *oc, *prev;
1529 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1530 cfn = c->ca_private;
1531 if ( c->valx < 0 ) {
1532 prev = cfn->c_oc_tail;
1535 /* If adding anything after the first, prev is easy */
1538 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1543 /* If adding the first, and head exists, find its prev */
1544 if (cfn->c_oc_head) {
1545 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1550 /* else prev is NULL, append to end of global list */
1552 if(parse_oc(c, &oc, prev)) return(1);
1553 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1554 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1559 AttributeType *at, *prev;
1561 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1562 cfn = c->ca_private;
1563 if ( c->valx < 0 ) {
1564 prev = cfn->c_at_tail;
1567 /* If adding anything after the first, prev is easy */
1570 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1575 /* If adding the first, and head exists, find its prev */
1576 if (cfn->c_at_head) {
1577 for ( at_start( &at ); at != cfn->c_at_head; ) {
1582 /* else prev is NULL, append to end of global list */
1584 if(parse_at(c, &at, prev)) return(1);
1585 if (!cfn->c_at_head) cfn->c_at_head = at;
1586 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1593 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1594 cfn = c->ca_private;
1595 if ( c->valx < 0 ) {
1596 prev = cfn->c_syn_tail;
1599 /* If adding anything after the first, prev is easy */
1602 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
1607 /* If adding the first, and head exists, find its prev */
1608 if (cfn->c_syn_head) {
1609 for ( syn_start( &syn ); syn != cfn->c_syn_head; ) {
1614 /* else prev is NULL, append to end of global list */
1616 if ( parse_syn( c, &syn, prev ) ) return(1);
1617 if ( !cfn->c_syn_head ) cfn->c_syn_head = syn;
1618 if ( cfn->c_syn_tail == prev ) cfn->c_syn_tail = syn;
1625 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1626 cfn = c->ca_private;
1627 if(parse_cr(c, &cr)) return(1);
1628 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1629 cfn->c_cr_tail = cr;
1634 ad_define_option(NULL, NULL, 0);
1635 for(i = 1; i < c->argc; i++)
1636 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1641 if ( c->value_int < SLAP_INDEX_INTLEN_DEFAULT )
1642 c->value_int = SLAP_INDEX_INTLEN_DEFAULT;
1643 else if ( c->value_int > 255 )
1645 index_intlen = c->value_int;
1646 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1650 case CFG_SORTVALS: {
1651 ADlist *svnew = NULL, *svtail, *sv;
1653 for ( i = 1; i < c->argc; i++ ) {
1654 AttributeDescription *ad = NULL;
1658 rc = slap_str2ad( c->argv[i], &ad, &text );
1660 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
1663 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1664 c->log, c->cr_msg, c->argv[i] );
1665 for ( sv = svnew; sv; sv = svnew ) {
1666 svnew = sv->al_next;
1671 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
1672 ad->ad_type->sat_single_value ) {
1673 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
1675 goto sortval_reject;
1677 sv = ch_malloc( sizeof( ADlist ));
1682 svtail->al_next = sv;
1687 for ( sv = svnew; sv; sv = sv->al_next )
1688 sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
1689 for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
1691 sv->al_next = svnew;
1698 /* Don't append to the global ACL if we're on a specific DB */
1700 if ( c->valx == -1 ) {
1703 for ( a=c->be->be_acl; a; a = a->acl_next )
1706 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1713 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_ACL_ADD;
1715 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_ACL_ADD;
1719 if(root_dse_read_file(c->argv[1])) {
1720 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> could not read file", c->argv[0] );
1721 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1722 c->log, c->cr_msg, c->argv[1] );
1727 ber_str2bv( c->argv[1], 0, 1, &bv );
1728 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1729 cfn = c->ca_private;
1730 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1736 ServerID *si, **sip;
1739 if ( lutil_atoi( &num, c->argv[1] ) ||
1740 num < 0 || num > SLAP_SYNC_SID_MAX )
1742 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1743 "<%s> illegal server ID", c->argv[0] );
1744 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1745 c->log, c->cr_msg, c->argv[1] );
1748 /* only one value allowed if no URL is given */
1749 if ( c->argc > 2 ) {
1752 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1753 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1754 "<%s> only one server ID allowed now", c->argv[0] );
1755 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1756 c->log, c->cr_msg, c->argv[1] );
1760 if ( ldap_url_parse( c->argv[2], &lud )) {
1761 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1762 "<%s> invalid URL", c->argv[0] );
1763 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1764 c->log, c->cr_msg, c->argv[2] );
1767 len = strlen( c->argv[2] );
1768 si = ch_malloc( sizeof(ServerID) + len + 1 );
1769 si->si_url.bv_val = (char *)(si+1);
1770 si->si_url.bv_len = len;
1771 strcpy( si->si_url.bv_val, c->argv[2] );
1774 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1775 "<%s> unqualified server ID not allowed now", c->argv[0] );
1776 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1777 c->log, c->cr_msg, c->argv[1] );
1780 si = ch_malloc( sizeof(ServerID) );
1781 BER_BVZERO( &si->si_url );
1782 slap_serverID = num;
1783 Debug( LDAP_DEBUG_CONFIG,
1785 c->log, slap_serverID, 0 );
1789 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
1792 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
1793 Listener **l = slapd_get_listeners();
1796 /* Try a straight compare with Listener strings */
1797 for ( i=0; l && l[i]; i++ ) {
1798 if ( !strcasecmp( c->argv[2], l[i]->sl_url.bv_val )) {
1804 /* If hostname is empty, or is localhost, or matches
1805 * our hostname, this serverID refers to this host.
1806 * Compare it against listeners and ports.
1808 if ( !isMe && ( !lud->lud_host || !lud->lud_host[0] ||
1809 !strncasecmp("localhost", lud->lud_host,
1810 STRLENOF("localhost")) ||
1811 !strcasecmp( global_host, lud->lud_host ))) {
1813 for ( i=0; l && l[i]; i++ ) {
1815 ldap_url_parse( l[i]->sl_url.bv_val, &lu2 );
1817 if ( strcasecmp( lud->lud_scheme,
1820 if ( lud->lud_port != lu2->lud_port )
1822 /* Listener on ANY address */
1823 if ( !lu2->lud_host || !lu2->lud_host[0] ) {
1827 /* URL on ANY address */
1828 if ( !lud->lud_host || !lud->lud_host[0] ) {
1832 /* Listener has specific host, must
1835 if ( !strcasecmp( lud->lud_host,
1841 ldap_free_urldesc( lu2 );
1848 slap_serverID = si->si_num;
1849 Debug( LDAP_DEBUG_CONFIG,
1850 "%s: SID=%d (listener=%s)\n",
1851 c->log, slap_serverID,
1852 l[i]->sl_url.bv_val );
1856 ldap_free_urldesc( lud );
1860 if ( logfileName ) ch_free( logfileName );
1861 logfileName = c->value_string;
1862 logfile = fopen(logfileName, "w");
1863 if(logfile) lutil_debug_file(logfile);
1867 if(SLAP_NOLASTMODCMD(c->be)) {
1868 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> not available for %s database",
1869 c->argv[0], c->be->bd_info->bi_type );
1870 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1871 c->log, c->cr_msg, 0 );
1875 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
1877 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
1880 case CFG_MIRRORMODE:
1881 if(!SLAP_SHADOW(c->be)) {
1882 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database is not a shadow",
1884 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1885 c->log, c->cr_msg, 0 );
1889 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
1891 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
1894 case CFG_MONITORING:
1896 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
1898 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
1903 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
1905 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
1908 case CFG_SSTR_IF_MAX:
1909 if (c->value_int < index_substr_if_minlen) {
1910 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
1911 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
1912 c->log, c->cr_msg, c->value_int );
1915 index_substr_if_maxlen = c->value_int;
1918 case CFG_SSTR_IF_MIN:
1919 if (c->value_int > index_substr_if_maxlen) {
1920 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
1921 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
1922 c->log, c->cr_msg, c->value_int );
1925 index_substr_if_minlen = c->value_int;
1928 #ifdef SLAPD_MODULES
1930 /* If we're just adding a module on an existing modpath,
1931 * make sure we've selected the current path.
1933 if ( c->op == LDAP_MOD_ADD && c->ca_private && modcur != c->ca_private ) {
1934 modcur = c->ca_private;
1935 /* This should never fail */
1936 if ( module_path( modcur->mp_path.bv_val )) {
1937 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> module path no longer valid",
1939 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
1940 c->log, c->cr_msg, modcur->mp_path.bv_val );
1944 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
1946 /* Record this load on the current path */
1950 if ( c->op == SLAP_CONFIG_ADD ) {
1951 ptr = c->line + STRLENOF("moduleload");
1952 while (!isspace((unsigned char) *ptr)) ptr++;
1953 while (isspace((unsigned char) *ptr)) ptr++;
1957 ber_str2bv(ptr, 0, 1, &bv);
1958 ber_bvarray_add( &modcur->mp_loads, &bv );
1960 /* Check for any new hardcoded schema */
1961 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
1962 config_check_schema( NULL, &cfBackInfo );
1967 if(module_path(c->argv[1])) return(1);
1968 /* Record which path was used with each module */
1972 if (!modpaths.mp_loads) {
1975 mp = ch_malloc( sizeof( ModPaths ));
1976 modlast->mp_next = mp;
1978 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
1980 mp->mp_loads = NULL;
1991 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
1993 slapi_plugins_used++;
1997 #ifdef SLAP_AUTH_REWRITE
2002 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
2005 if ( c->argc > 1 ) {
2008 /* quote all args but the first */
2009 line = ldap_charray2str( c->argv, "\" \"" );
2010 ber_str2bv( line, 0, 0, &bv );
2011 s = ber_bvchr( &bv, '"' );
2012 assert( s != NULL );
2013 /* move the trailing quote of argv[0] to the end */
2014 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
2015 bv.bv_val[ bv.bv_len - 1 ] = '"';
2018 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
2021 ber_bvarray_add( &authz_rewrites, &bv );
2028 Debug( LDAP_DEBUG_ANY,
2029 "%s: unknown CFG_TYPE %d.\n",
2030 c->log, c->type, 0 );
2039 config_fname(ConfigArgs *c) {
2040 if(c->op == SLAP_CONFIG_EMIT) {
2041 if (c->ca_private) {
2042 ConfigFile *cf = c->ca_private;
2043 value_add_one( &c->rvalue_vals, &cf->c_file );
2052 config_cfdir(ConfigArgs *c) {
2053 if(c->op == SLAP_CONFIG_EMIT) {
2054 if ( !BER_BVISEMPTY( &cfdir )) {
2055 value_add_one( &c->rvalue_vals, &cfdir );
2064 config_search_base(ConfigArgs *c) {
2065 if(c->op == SLAP_CONFIG_EMIT) {
2067 if (!BER_BVISEMPTY(&default_search_base)) {
2068 value_add_one(&c->rvalue_vals, &default_search_base);
2069 value_add_one(&c->rvalue_nvals, &default_search_nbase);
2073 } else if( c->op == LDAP_MOD_DELETE ) {
2074 ch_free( default_search_base.bv_val );
2075 ch_free( default_search_nbase.bv_val );
2076 BER_BVZERO( &default_search_base );
2077 BER_BVZERO( &default_search_nbase );
2081 if(c->bi || c->be != frontendDB) {
2082 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
2083 "prior to any backend or database definition\n",
2088 if(default_search_nbase.bv_len) {
2089 free(default_search_base.bv_val);
2090 free(default_search_nbase.bv_val);
2093 default_search_base = c->value_dn;
2094 default_search_nbase = c->value_ndn;
2098 /* For RE23 compatibility we allow this in the global entry
2099 * but we now defer it to the frontend entry to allow modules
2100 * to load new hash types.
2103 config_passwd_hash(ConfigArgs *c) {
2105 if (c->op == SLAP_CONFIG_EMIT) {
2107 /* Don't generate it in the global entry */
2108 if ( c->table == Cft_Global )
2110 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
2111 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
2112 value_add_one(&c->rvalue_vals, &bv);
2115 } else if ( c->op == LDAP_MOD_DELETE ) {
2116 /* Deleting from global is a no-op, only the frontendDB entry matters */
2117 if ( c->table == Cft_Global )
2119 if ( c->valx < 0 ) {
2120 ldap_charray_free( default_passwd_hash );
2121 default_passwd_hash = NULL;
2124 ch_free( default_passwd_hash[i] );
2125 for (; default_passwd_hash[i]; i++ )
2126 default_passwd_hash[i] = default_passwd_hash[i+1];
2130 for(i = 1; i < c->argc; i++) {
2131 if(!lutil_passwd_scheme(c->argv[i])) {
2132 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
2133 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2134 c->log, c->cr_msg, c->argv[i]);
2136 ldap_charray_add(&default_passwd_hash, c->argv[i]);
2139 if(!default_passwd_hash) {
2140 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
2141 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2142 c->log, c->cr_msg, 0 );
2149 config_schema_dn(ConfigArgs *c) {
2150 if ( c->op == SLAP_CONFIG_EMIT ) {
2152 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
2153 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
2154 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
2158 } else if ( c->op == LDAP_MOD_DELETE ) {
2159 ch_free( c->be->be_schemadn.bv_val );
2160 ch_free( c->be->be_schemandn.bv_val );
2161 BER_BVZERO( &c->be->be_schemadn );
2162 BER_BVZERO( &c->be->be_schemandn );
2165 ch_free( c->be->be_schemadn.bv_val );
2166 ch_free( c->be->be_schemandn.bv_val );
2167 c->be->be_schemadn = c->value_dn;
2168 c->be->be_schemandn = c->value_ndn;
2173 config_sizelimit(ConfigArgs *c) {
2175 struct slap_limits_set *lim = &c->be->be_def_limit;
2176 if (c->op == SLAP_CONFIG_EMIT) {
2181 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
2182 if ( !BER_BVISEMPTY( &bv ))
2183 value_add_one( &c->rvalue_vals, &bv );
2187 } else if ( c->op == LDAP_MOD_DELETE ) {
2188 /* Reset to defaults */
2189 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
2190 lim->lms_s_hard = 0;
2191 lim->lms_s_unchecked = -1;
2193 lim->lms_s_pr_hide = 0;
2194 lim->lms_s_pr_total = 0;
2197 for(i = 1; i < c->argc; i++) {
2198 if(!strncasecmp(c->argv[i], "size", 4)) {
2199 rc = limits_parse_one(c->argv[i], lim);
2201 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2202 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2203 c->log, c->cr_msg, c->argv[i]);
2207 if(!strcasecmp(c->argv[i], "unlimited")) {
2208 lim->lms_s_soft = -1;
2210 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
2211 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2212 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2213 c->log, c->cr_msg, c->argv[i]);
2217 lim->lms_s_hard = 0;
2224 config_timelimit(ConfigArgs *c) {
2226 struct slap_limits_set *lim = &c->be->be_def_limit;
2227 if (c->op == SLAP_CONFIG_EMIT) {
2232 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
2233 if ( !BER_BVISEMPTY( &bv ))
2234 value_add_one( &c->rvalue_vals, &bv );
2238 } else if ( c->op == LDAP_MOD_DELETE ) {
2239 /* Reset to defaults */
2240 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
2241 lim->lms_t_hard = 0;
2244 for(i = 1; i < c->argc; i++) {
2245 if(!strncasecmp(c->argv[i], "time", 4)) {
2246 rc = limits_parse_one(c->argv[i], lim);
2248 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2249 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2250 c->log, c->cr_msg, c->argv[i]);
2254 if(!strcasecmp(c->argv[i], "unlimited")) {
2255 lim->lms_t_soft = -1;
2257 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
2258 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2259 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2260 c->log, c->cr_msg, c->argv[i]);
2264 lim->lms_t_hard = 0;
2271 config_overlay(ConfigArgs *c) {
2272 if (c->op == SLAP_CONFIG_EMIT) {
2274 } else if ( c->op == LDAP_MOD_DELETE ) {
2277 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
2278 c->valx, &c->bi, &c->reply)) {
2280 Debug( LDAP_DEBUG_ANY,
2281 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
2282 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
2284 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi, &c->reply)) {
2291 config_subordinate(ConfigArgs *c)
2297 case SLAP_CONFIG_EMIT:
2298 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
2301 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
2302 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
2305 value_add_one( &c->rvalue_vals, &bv );
2309 case LDAP_MOD_DELETE:
2310 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2311 glue_sub_del( c->be );
2313 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2318 case SLAP_CONFIG_ADD:
2319 advertise = ( c->argc == 2 && !strcasecmp( c->argv[1], "advertise" ));
2320 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2327 config_suffix(ConfigArgs *c)
2330 struct berval pdn, ndn;
2331 char *notallowed = NULL;
2333 if ( c->be == frontendDB ) {
2334 notallowed = "frontend";
2336 } else if ( SLAP_MONITOR(c->be) ) {
2337 notallowed = "monitor";
2339 } else if ( SLAP_CONFIG(c->be) ) {
2340 notallowed = "config";
2343 if ( notallowed != NULL ) {
2344 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2348 case LDAP_MOD_DELETE:
2349 case LDAP_MOD_REPLACE:
2350 case LDAP_MOD_INCREMENT:
2351 case SLAP_CONFIG_ADD:
2352 if ( !BER_BVISNULL( &c->value_dn ) ) {
2353 snprintf( buf, sizeof( buf ), "<%s> ",
2354 c->value_dn.bv_val );
2357 Debug(LDAP_DEBUG_ANY,
2358 "%s: suffix %snot allowed in %s database.\n",
2359 c->log, buf, notallowed );
2362 case SLAP_CONFIG_EMIT:
2363 /* don't complain when emitting... */
2367 /* FIXME: don't know what values may be valid;
2368 * please remove assertion, or add legal values
2369 * to either block */
2377 if (c->op == SLAP_CONFIG_EMIT) {
2378 if ( c->be->be_suffix == NULL
2379 || BER_BVISNULL( &c->be->be_suffix[0] ) )
2383 value_add( &c->rvalue_vals, c->be->be_suffix );
2384 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
2387 } else if ( c->op == LDAP_MOD_DELETE ) {
2388 if ( c->valx < 0 ) {
2389 ber_bvarray_free( c->be->be_suffix );
2390 ber_bvarray_free( c->be->be_nsuffix );
2391 c->be->be_suffix = NULL;
2392 c->be->be_nsuffix = NULL;
2395 ch_free( c->be->be_suffix[i].bv_val );
2396 ch_free( c->be->be_nsuffix[i].bv_val );
2398 c->be->be_suffix[i] = c->be->be_suffix[i+1];
2399 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
2401 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
2406 #ifdef SLAPD_MONITOR_DN
2407 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
2408 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> DN is reserved for monitoring slapd",
2410 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2411 c->log, c->cr_msg, SLAPD_MONITOR_DN);
2416 if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
2417 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
2418 c->argv[0], c->be->bd_info->bi_type );
2419 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2420 c->log, c->cr_msg, 0);
2427 if (SLAP_DBHIDDEN( c->be ))
2430 tbe = select_backend(&ndn, 0);
2432 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
2438 BackendDB *b2 = tbe;
2440 /* Does tbe precede be? */
2441 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
2444 char *type = tbe->bd_info->bi_type;
2446 if ( overlay_is_over( tbe ) ) {
2447 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
2448 type = oi->oi_orig->bi_type;
2451 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> namingContext \"%s\" "
2452 "already served by a preceding %s database",
2453 c->argv[0], pdn.bv_val, type );
2454 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
2455 c->log, c->cr_msg, tbe->be_suffix[0].bv_val);
2461 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
2462 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
2463 "base provided \"%s\" (assuming okay)\n",
2464 c->log, default_search_base.bv_val, 0);
2466 ber_bvarray_add(&c->be->be_suffix, &pdn);
2467 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
2472 config_rootdn(ConfigArgs *c) {
2473 if (c->op == SLAP_CONFIG_EMIT) {
2474 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
2475 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
2476 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
2481 } else if ( c->op == LDAP_MOD_DELETE ) {
2482 ch_free( c->be->be_rootdn.bv_val );
2483 ch_free( c->be->be_rootndn.bv_val );
2484 BER_BVZERO( &c->be->be_rootdn );
2485 BER_BVZERO( &c->be->be_rootndn );
2488 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
2489 ch_free( c->be->be_rootdn.bv_val );
2490 ch_free( c->be->be_rootndn.bv_val );
2492 c->be->be_rootdn = c->value_dn;
2493 c->be->be_rootndn = c->value_ndn;
2498 config_rootpw(ConfigArgs *c) {
2501 if (c->op == SLAP_CONFIG_EMIT) {
2502 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
2503 /* don't copy, because "rootpw" is marked
2505 c->value_bv = c->be->be_rootpw;
2509 } else if ( c->op == LDAP_MOD_DELETE ) {
2510 ch_free( c->be->be_rootpw.bv_val );
2511 BER_BVZERO( &c->be->be_rootpw );
2515 tbe = select_backend(&c->be->be_rootndn, 0);
2517 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> can only be set when rootdn is under suffix",
2519 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2520 c->log, c->cr_msg, 0);
2523 if ( !BER_BVISNULL( &c->be->be_rootpw ))
2524 ch_free( c->be->be_rootpw.bv_val );
2525 c->be->be_rootpw = c->value_bv;
2530 config_restrict(ConfigArgs *c) {
2531 slap_mask_t restrictops = 0;
2533 slap_verbmasks restrictable_ops[] = {
2534 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
2535 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
2536 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
2537 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
2538 { BER_BVC("modrdn"), 0 },
2539 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
2540 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
2541 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
2542 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
2543 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
2544 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
2545 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
2546 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
2547 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
2548 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
2549 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
2553 if (c->op == SLAP_CONFIG_EMIT) {
2554 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
2556 } else if ( c->op == LDAP_MOD_DELETE ) {
2558 c->be->be_restrictops = 0;
2560 restrictops = verb_to_mask( c->line, restrictable_ops );
2561 c->be->be_restrictops ^= restrictops;
2565 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
2567 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown operation", c->argv[0] );
2568 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2569 c->log, c->cr_msg, c->argv[i]);
2572 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
2573 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
2574 c->be->be_restrictops |= restrictops;
2579 config_allows(ConfigArgs *c) {
2580 slap_mask_t allows = 0;
2582 slap_verbmasks allowable_ops[] = {
2583 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
2584 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
2585 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
2586 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
2587 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
2590 if (c->op == SLAP_CONFIG_EMIT) {
2591 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
2592 } else if ( c->op == LDAP_MOD_DELETE ) {
2596 allows = verb_to_mask( c->line, allowable_ops );
2597 global_allows ^= allows;
2601 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
2603 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
2604 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2605 c->log, c->cr_msg, c->argv[i]);
2608 global_allows |= allows;
2613 config_disallows(ConfigArgs *c) {
2614 slap_mask_t disallows = 0;
2616 slap_verbmasks disallowable_ops[] = {
2617 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
2618 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
2619 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
2620 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
2621 { BER_BVC("proxy_authz_non_critical"), SLAP_DISALLOW_PROXY_AUTHZ_N_CRIT },
2622 { BER_BVC("dontusecopy_non_critical"), SLAP_DISALLOW_DONTUSECOPY_N_CRIT },
2625 if (c->op == SLAP_CONFIG_EMIT) {
2626 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
2627 } else if ( c->op == LDAP_MOD_DELETE ) {
2629 global_disallows = 0;
2631 disallows = verb_to_mask( c->line, disallowable_ops );
2632 global_disallows ^= disallows;
2636 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
2638 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
2639 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
2640 c->log, c->cr_msg, c->argv[i]);
2643 global_disallows |= disallows;
2648 config_requires(ConfigArgs *c) {
2649 slap_mask_t requires = frontendDB->be_requires;
2650 int i, argc = c->argc;
2651 char **argv = c->argv;
2653 slap_verbmasks requires_ops[] = {
2654 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
2655 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
2656 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
2657 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
2658 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
2661 if (c->op == SLAP_CONFIG_EMIT) {
2662 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
2663 } else if ( c->op == LDAP_MOD_DELETE ) {
2665 c->be->be_requires = 0;
2667 requires = verb_to_mask( c->line, requires_ops );
2668 c->be->be_requires ^= requires;
2672 /* "none" can only be first, to wipe out default/global values */
2673 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
2678 i = verbs_to_mask(argc, argv, requires_ops, &requires);
2680 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
2681 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
2682 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2683 c->log, c->cr_msg, 0);
2685 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
2686 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2687 c->log, c->cr_msg, c->argv[i]);
2691 c->be->be_requires = requires;
2695 static slap_verbmasks *loglevel_ops;
2698 loglevel_init( void )
2700 slap_verbmasks lo[] = {
2701 { BER_BVC("Any"), -1 },
2702 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
2703 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
2704 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
2705 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
2706 { BER_BVC("BER"), LDAP_DEBUG_BER },
2707 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
2708 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
2709 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
2710 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
2711 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
2712 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
2713 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
2714 #if 0 /* no longer used (nor supported) */
2715 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
2716 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
2718 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
2719 { BER_BVC("None"), LDAP_DEBUG_NONE },
2723 return slap_verbmasks_init( &loglevel_ops, lo );
2727 loglevel_destroy( void )
2729 if ( loglevel_ops ) {
2730 (void)slap_verbmasks_destroy( loglevel_ops );
2732 loglevel_ops = NULL;
2735 static slap_mask_t loglevel_ignore[] = { -1, 0 };
2738 slap_loglevel_register( slap_mask_t m, struct berval *s )
2742 if ( loglevel_ops == NULL ) {
2746 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
2749 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
2757 slap_loglevel_get( struct berval *s, int *l )
2762 if ( loglevel_ops == NULL ) {
2766 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
2767 m |= loglevel_ops[ i ].mask;
2770 for ( i = 1; m & i; i <<= 1 )
2777 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
2780 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
2791 str2loglevel( const char *s, int *l )
2795 if ( loglevel_ops == NULL ) {
2799 i = verb_to_mask( s, loglevel_ops );
2801 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
2805 *l = loglevel_ops[ i ].mask;
2811 loglevel2str( int l )
2813 struct berval bv = BER_BVNULL;
2815 loglevel2bv( l, &bv );
2821 loglevel2bv( int l, struct berval *bv )
2823 if ( loglevel_ops == NULL ) {
2829 return enum_to_verb( loglevel_ops, l, bv ) == -1;
2833 loglevel2bvarray( int l, BerVarray *bva )
2835 if ( loglevel_ops == NULL ) {
2839 return mask_to_verbs( loglevel_ops, l, bva );
2843 loglevel_print( FILE *out )
2847 if ( loglevel_ops == NULL ) {
2851 fprintf( out, "Installed log subsystems:\n\n" );
2852 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
2853 fprintf( out, "\t%-30s (%lu)\n",
2854 loglevel_ops[ i ].word.bv_val,
2855 loglevel_ops[ i ].mask );
2858 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
2859 "by specific code\n\n" );
2864 static int config_syslog;
2867 config_loglevel(ConfigArgs *c) {
2870 if ( loglevel_ops == NULL ) {
2874 if (c->op == SLAP_CONFIG_EMIT) {
2875 /* Get default or commandline slapd setting */
2876 if ( ldap_syslog && !config_syslog )
2877 config_syslog = ldap_syslog;
2878 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
2880 } else if ( c->op == LDAP_MOD_DELETE ) {
2884 int level = verb_to_mask( c->line, loglevel_ops );
2885 config_syslog ^= level;
2887 if ( slapMode & SLAP_SERVER_MODE ) {
2888 ldap_syslog = config_syslog;
2893 for( i=1; i < c->argc; i++ ) {
2896 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
2897 if( lutil_atoi( &level, c->argv[i] ) != 0 ) {
2898 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
2899 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2900 c->log, c->cr_msg, c->argv[i]);
2904 if ( str2loglevel( c->argv[i], &level ) ) {
2905 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown level", c->argv[0] );
2906 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2907 c->log, c->cr_msg, c->argv[i]);
2911 /* Explicitly setting a zero clears all the levels */
2913 config_syslog |= level;
2917 if ( slapMode & SLAP_SERVER_MODE ) {
2918 ldap_syslog = config_syslog;
2924 config_referral(ConfigArgs *c) {
2926 if (c->op == SLAP_CONFIG_EMIT) {
2927 if ( default_referral ) {
2928 value_add( &c->rvalue_vals, default_referral );
2933 } else if ( c->op == LDAP_MOD_DELETE ) {
2934 if ( c->valx < 0 ) {
2935 ber_bvarray_free( default_referral );
2936 default_referral = NULL;
2939 ch_free( default_referral[i].bv_val );
2940 for (; default_referral[i].bv_val; i++ )
2941 default_referral[i] = default_referral[i+1];
2945 if(validate_global_referral(c->argv[1])) {
2946 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
2947 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2948 c->log, c->cr_msg, c->argv[1]);
2952 ber_str2bv(c->argv[1], 0, 0, &val);
2953 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
2961 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
2962 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
2963 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
2964 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
2965 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
2966 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
2967 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
2968 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
2969 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
2974 config_security(ConfigArgs *c) {
2975 slap_ssf_set_t *set = &c->be->be_ssf_set;
2978 if (c->op == SLAP_CONFIG_EMIT) {
2984 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
2985 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
2988 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
2989 if ( bv.bv_len >= sizeof( numbuf ) ) {
2990 ber_bvarray_free_x( c->rvalue_vals, NULL );
2991 c->rvalue_vals = NULL;
2995 bv.bv_len += sec_keys[i].key.bv_len;
2996 bv.bv_val = ch_malloc( bv.bv_len + 1);
2997 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
2998 strcpy( next, numbuf );
2999 ber_bvarray_add( &c->rvalue_vals, &bv );
3004 for(i = 1; i < c->argc; i++) {
3005 slap_ssf_t *tgt = NULL;
3007 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
3008 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
3009 sec_keys[j].key.bv_len)) {
3010 src = c->argv[i] + sec_keys[j].key.bv_len;
3011 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
3016 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown factor", c->argv[0] );
3017 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3018 c->log, c->cr_msg, c->argv[i]);
3022 if ( lutil_atou( tgt, src ) != 0 ) {
3023 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse factor", c->argv[0] );
3024 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3025 c->log, c->cr_msg, c->argv[i]);
3033 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
3037 for (; !BER_BVISNULL( &an->an_name ); an++) {
3038 /* if buflen == 0, assume the buffer size has been
3039 * already checked otherwise */
3040 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
3041 if ( comma ) *ptr++ = ',';
3042 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
3049 config_updatedn(ConfigArgs *c) {
3050 if (c->op == SLAP_CONFIG_EMIT) {
3051 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
3052 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
3053 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
3057 } else if ( c->op == LDAP_MOD_DELETE ) {
3058 ch_free( c->be->be_update_ndn.bv_val );
3059 BER_BVZERO( &c->be->be_update_ndn );
3060 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
3063 if(SLAP_SHADOW(c->be)) {
3064 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database already shadowed", c->argv[0] );
3065 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3066 c->log, c->cr_msg, 0);
3070 ber_memfree_x( c->value_dn.bv_val, NULL );
3071 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
3072 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
3074 c->be->be_update_ndn = c->value_ndn;
3075 BER_BVZERO( &c->value_dn );
3076 BER_BVZERO( &c->value_ndn );
3078 return config_slurp_shadow( c );
3082 config_shadow( ConfigArgs *c, int flag )
3084 char *notallowed = NULL;
3086 if ( c->be == frontendDB ) {
3087 notallowed = "frontend";
3089 } else if ( SLAP_MONITOR(c->be) ) {
3090 notallowed = "monitor";
3093 if ( notallowed != NULL ) {
3094 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
3098 if ( SLAP_SHADOW(c->be) ) {
3099 /* if already shadow, only check consistency */
3100 if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
3101 Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%x.\n", c->log, flag, 0 );
3106 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
3113 config_updateref(ConfigArgs *c) {
3115 if (c->op == SLAP_CONFIG_EMIT) {
3116 if ( c->be->be_update_refs ) {
3117 value_add( &c->rvalue_vals, c->be->be_update_refs );
3122 } else if ( c->op == LDAP_MOD_DELETE ) {
3123 if ( c->valx < 0 ) {
3124 ber_bvarray_free( c->be->be_update_refs );
3125 c->be->be_update_refs = NULL;
3128 ch_free( c->be->be_update_refs[i].bv_val );
3129 for (; c->be->be_update_refs[i].bv_val; i++)
3130 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
3134 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
3135 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> must appear after syncrepl or updatedn",
3137 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3138 c->log, c->cr_msg, 0);
3142 if(validate_global_referral(c->argv[1])) {
3143 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3144 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3145 c->log, c->cr_msg, c->argv[1]);
3148 ber_str2bv(c->argv[1], 0, 0, &val);
3149 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
3154 config_obsolete(ConfigArgs *c) {
3155 if (c->op == SLAP_CONFIG_EMIT)
3158 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> keyword is obsolete (ignored)",
3160 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0);
3165 config_include(ConfigArgs *c) {
3166 int savelineno = c->lineno;
3169 ConfigFile *cfsave = cfn;
3170 ConfigFile *cf2 = NULL;
3172 /* Leftover from RE23. No dynamic config for include files */
3173 if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
3176 cf = ch_calloc( 1, sizeof(ConfigFile));
3177 if ( cfn->c_kids ) {
3178 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
3184 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
3185 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
3186 c->lineno = savelineno - 1;
3189 if ( cf2 ) cf2->c_sibs = NULL;
3190 else cfn->c_kids = NULL;
3191 ch_free( cf->c_file.bv_val );
3201 config_tls_cleanup(ConfigArgs *c) {
3204 if ( slap_tls_ld ) {
3207 ldap_pvt_tls_ctx_free( slap_tls_ctx );
3209 /* Force new ctx to be created */
3210 rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
3212 /* The ctx's refcount is bumped up here */
3213 ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
3214 /* This is a no-op if it's already loaded */
3215 load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
3222 config_tls_option(ConfigArgs *c) {
3224 LDAP *ld = slap_tls_ld;
3226 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
3227 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
3228 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
3229 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
3230 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
3231 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
3232 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
3234 case CFG_TLS_CRL_FILE: flag = LDAP_OPT_X_TLS_CRLFILE; break;
3236 default: Debug(LDAP_DEBUG_ANY, "%s: "
3237 "unknown tls_option <0x%x>\n",
3238 c->log, c->type, 0);
3241 if (c->op == SLAP_CONFIG_EMIT) {
3242 return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3243 } else if ( c->op == LDAP_MOD_DELETE ) {
3244 c->cleanup = config_tls_cleanup;
3245 return ldap_pvt_tls_set_option( ld, flag, NULL );
3247 ch_free(c->value_string);
3248 c->cleanup = config_tls_cleanup;
3249 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3252 /* FIXME: this ought to be provided by libldap */
3254 config_tls_config(ConfigArgs *c) {
3257 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
3258 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
3259 case CFG_TLS_PROTOCOL_MIN: flag = LDAP_OPT_X_TLS_PROTOCOL_MIN; break;
3261 Debug(LDAP_DEBUG_ANY, "%s: "
3262 "unknown tls_option <0x%x>\n",
3263 c->log, c->type, 0);
3266 if (c->op == SLAP_CONFIG_EMIT) {
3267 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3268 } else if ( c->op == LDAP_MOD_DELETE ) {
3270 c->cleanup = config_tls_cleanup;
3271 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3273 ch_free( c->value_string );
3274 c->cleanup = config_tls_cleanup;
3275 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3276 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3277 Debug(LDAP_DEBUG_ANY, "%s: "
3278 "unable to parse %s \"%s\"\n",
3279 c->log, c->argv[0], c->argv[1] );
3282 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
3284 return(ldap_int_tls_config(slap_tls_ld, flag, c->argv[1]));
3289 static CfEntryInfo *
3290 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
3300 if ( dn_match( &root->ce_entry->e_nname, dn ))
3303 c = dn->bv_val+dn->bv_len;
3304 for (;*c != ',';c--);
3308 for (--c;c>dn->bv_val && *c != ',';c--);
3312 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
3314 root = root->ce_kids;
3316 for (;root;root=root->ce_sibs) {
3317 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
3318 if ( cdn.bv_val == dn->bv_val ) {
3328 typedef struct setup_cookie {
3338 config_ldif_resp( Operation *op, SlapReply *rs )
3340 if ( rs->sr_type == REP_SEARCH ) {
3341 setup_cookie *sc = op->o_callback->sc_private;
3344 sc->cfb->cb_got_ldif = 1;
3345 /* Does the frontend exist? */
3346 if ( !sc->got_frontend ) {
3347 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
3348 "olcDatabase", STRLENOF( "olcDatabase" )))
3350 if ( strncmp( rs->sr_entry->e_nname.bv_val +
3351 STRLENOF( "olcDatabase" ), "={-1}frontend",
3352 STRLENOF( "={-1}frontend" )))
3356 sc->ca->be = frontendDB;
3357 sc->ca->bi = frontendDB->bd_info;
3358 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
3359 rdn.bv_val = sc->ca->log;
3360 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
3361 "%s=" SLAP_X_ORDERED_FMT "%s",
3362 cfAd_database->ad_cname.bv_val, -1,
3363 sc->ca->bi->bi_type);
3365 sc->frontend = config_build_entry( op, rs,
3366 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
3367 sc->ca->be->be_cf_ocs );
3377 dnParent( &rs->sr_entry->e_nname, &pdn );
3379 /* Does the configDB exist? */
3380 if ( sc->got_frontend && !sc->got_config &&
3381 !strncmp( rs->sr_entry->e_nname.bv_val,
3382 "olcDatabase", STRLENOF( "olcDatabase" )) &&
3383 dn_match( &config_rdn, &pdn ) )
3385 if ( strncmp( rs->sr_entry->e_nname.bv_val +
3386 STRLENOF( "olcDatabase" ), "={0}config",
3387 STRLENOF( "={0}config" )))
3391 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
3392 sc->ca->bi = sc->ca->be->bd_info;
3393 rdn.bv_val = sc->ca->log;
3394 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
3395 "%s=" SLAP_X_ORDERED_FMT "%s",
3396 cfAd_database->ad_cname.bv_val, 0,
3397 sc->ca->bi->bi_type);
3399 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
3400 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
3407 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
3408 if ( rs->sr_err != LDAP_SUCCESS ) {
3409 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
3410 rs->sr_entry->e_name.bv_val, sc->ca->cr_msg, 0 );
3416 /* Configure and read the underlying back-ldif store */
3418 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
3419 CfBackInfo *cfb = be->be_private;
3425 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
3426 Connection conn = {0};
3427 OperationBuffer opbuf;
3429 SlapReply rs = {REP_RESULT};
3430 Filter filter = { LDAP_FILTER_PRESENT };
3431 struct berval filterstr = BER_BVC("(objectclass=*)");
3434 /* Is the config directory available? */
3435 if ( stat( dir, &st ) < 0 ) {
3436 /* No, so don't bother using the backing store.
3437 * All changes will be in-memory only.
3442 cfb->cb_db.bd_info = backend_info( "ldif" );
3443 if ( !cfb->cb_db.bd_info )
3444 return 0; /* FIXME: eventually this will be a fatal error */
3446 if ( backend_db_init( "ldif", &cfb->cb_db, -1, NULL ) == NULL )
3449 cfb->cb_db.be_suffix = be->be_suffix;
3450 cfb->cb_db.be_nsuffix = be->be_nsuffix;
3452 /* The suffix is always "cn=config". The underlying DB's rootdn
3453 * is always the same as the suffix.
3455 cfb->cb_db.be_rootdn = be->be_suffix[0];
3456 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
3458 ber_str2bv( dir, 0, 1, &cfdir );
3463 argv[0] = "directory";
3464 argv[1] = (char *)dir;
3469 c.table = Cft_Database;
3471 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
3475 if ( config_add_vals( ct, &c ))
3478 if ( backend_startup_one( &cfb->cb_db, &c.reply ))
3482 void *thrctx = ldap_pvt_thread_pool_context();
3485 connection_fake_init( &conn, &opbuf, thrctx );
3488 filter.f_desc = slap_schema.si_ad_objectClass;
3490 op->o_tag = LDAP_REQ_SEARCH;
3492 op->ors_filter = &filter;
3493 op->ors_filterstr = filterstr;
3494 op->ors_scope = LDAP_SCOPE_SUBTREE;
3496 op->o_dn = c.be->be_rootdn;
3497 op->o_ndn = c.be->be_rootndn;
3499 op->o_req_dn = be->be_suffix[0];
3500 op->o_req_ndn = be->be_nsuffix[0];
3502 op->ors_tlimit = SLAP_NO_LIMIT;
3503 op->ors_slimit = SLAP_NO_LIMIT;
3505 op->ors_attrs = slap_anlist_all_attributes;
3506 op->ors_attrsonly = 0;
3508 op->o_callback = &cb;
3511 cb.sc_private = ≻
3512 sc.got_frontend = 0;
3517 op->o_bd = &cfb->cb_db;
3519 /* Allow unknown attrs in DNs */
3520 prev_DN_strict = slap_DN_strict;
3523 rc = op->o_bd->be_search( op, &rs );
3525 /* Restore normal DN validation */
3526 slap_DN_strict = prev_DN_strict;
3528 op->o_tag = LDAP_REQ_ADD;
3529 if ( rc == LDAP_SUCCESS && sc.frontend ) {
3530 op->ora_e = sc.frontend;
3531 rc = op->o_bd->be_add( op, &rs );
3533 if ( rc == LDAP_SUCCESS && sc.config ) {
3534 op->ora_e = sc.config;
3535 rc = op->o_bd->be_add( op, &rs );
3537 ldap_pvt_thread_pool_context_reset( thrctx );
3540 /* ITS#4194 - only use if it's present, or we're converting. */
3541 if ( !readit || rc == LDAP_SUCCESS )
3542 cfb->cb_use_ldif = 1;
3548 CfOc_cmp( const void *c1, const void *c2 ) {
3549 const ConfigOCs *co1 = c1;
3550 const ConfigOCs *co2 = c2;
3552 return ber_bvcmp( co1->co_name, co2->co_name );
3556 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
3559 i = init_config_attrs( ct );
3562 /* set up the objectclasses */
3563 i = init_config_ocs( ocs );
3566 for (i=0; ocs[i].co_def; i++) {
3567 if ( ocs[i].co_oc ) {
3568 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
3569 if ( !ocs[i].co_table )
3570 ocs[i].co_table = ct;
3571 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
3578 read_config(const char *fname, const char *dir) {
3581 const char *cfdir, *cfname;
3584 /* Setup the config backend */
3585 be = backend_db_init( "config", NULL, 0, NULL );
3589 cfb = be->be_private;
3590 be->be_dfltaccess = ACL_NONE;
3592 /* If no .conf, or a dir was specified, setup the dir */
3593 if ( !fname || dir ) {
3595 /* If explicitly given, check for existence */
3598 if ( stat( dir, &st ) < 0 ) {
3599 Debug( LDAP_DEBUG_ANY,
3600 "invalid config directory %s, error %d\n",
3606 cfdir = SLAPD_DEFAULT_CONFIGDIR;
3608 /* if fname is defaulted, try reading .d */
3609 rc = config_setup_ldif( be, cfdir, !fname );
3612 /* It may be OK if the base object doesn't exist yet. */
3613 if ( rc != LDAP_NO_SUCH_OBJECT )
3615 /* ITS#4194: But if dir was specified and no fname,
3616 * then we were supposed to read the dir. Unless we're
3617 * trying to slapadd the dir...
3619 if ( dir && !fname ) {
3620 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
3622 /* Assume it's slapadd with a config dir, let it continue */
3624 cfb->cb_got_ldif = 1;
3625 cfb->cb_use_ldif = 1;
3630 /* If we read the config from back-ldif, nothing to do here */
3631 if ( cfb->cb_got_ldif ) {
3640 cfname = SLAPD_DEFAULT_CONFIGFILE;
3642 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
3645 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
3648 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
3649 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
3650 &frontendDB->be_schemadn );
3651 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
3652 if ( rc != LDAP_SUCCESS ) {
3653 Debug(LDAP_DEBUG_ANY, "read_config: "
3654 "unable to normalize default schema DN \"%s\"\n",
3655 frontendDB->be_schemadn.bv_val, 0, 0 );
3656 /* must not happen */
3664 config_back_bind( Operation *op, SlapReply *rs )
3666 if ( be_isroot_pw( op ) ) {
3667 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
3668 /* frontend sends result */
3669 return LDAP_SUCCESS;
3672 rs->sr_err = LDAP_INVALID_CREDENTIALS;
3673 send_ldap_result( op, rs );
3679 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
3683 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
3685 rs->sr_attrs = op->ors_attrs;
3686 rs->sr_entry = ce->ce_entry;
3688 rc = send_search_entry( op, rs );
3689 if ( rc != LDAP_SUCCESS ) {
3693 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
3694 if ( ce->ce_kids ) {
3695 rc = config_send( op, rs, ce->ce_kids, 1 );
3696 if ( rc ) return rc;
3699 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
3700 rc = config_send( op, rs, ce, 0 );
3708 static ConfigTable *
3709 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
3714 for (j=0; j<nocs; j++) {
3715 for (i=0; colst[j]->co_table[i].name; i++)
3716 if ( colst[j]->co_table[i].ad == ad ) {
3717 ca->table = colst[j]->co_type;
3718 return &colst[j]->co_table[i];
3724 /* Sort the attributes of the entry according to the order defined
3725 * in the objectclass, with required attributes occurring before
3726 * allowed attributes. For any attributes with sequencing dependencies
3727 * (e.g., rootDN must be defined after suffix) the objectclass must
3728 * list the attributes in the desired sequence.
3731 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
3733 Attribute *a, *head = NULL, *tail = NULL, **prev;
3736 for (i=0; i<nocs; i++) {
3737 if ( colst[i]->co_oc->soc_required ) {
3738 AttributeType **at = colst[i]->co_oc->soc_required;
3739 for (j=0; at[j]; j++) {
3740 for (a=e->e_attrs, prev=&e->e_attrs; a;
3741 prev = &(*prev)->a_next, a=a->a_next) {
3742 if ( a->a_desc == at[j]->sat_ad ) {
3756 if ( colst[i]->co_oc->soc_allowed ) {
3757 AttributeType **at = colst[i]->co_oc->soc_allowed;
3758 for (j=0; at[j]; j++) {
3759 for (a=e->e_attrs, prev=&e->e_attrs; a;
3760 prev = &(*prev)->a_next, a=a->a_next) {
3761 if ( a->a_desc == at[j]->sat_ad ) {
3777 tail->a_next = e->e_attrs;
3783 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
3785 Attribute *a = NULL;
3786 AttributeDescription *ad;
3796 Modifications *ml = ptr;
3798 vals = ml->sml_values;
3801 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
3802 rc = ordered_value_sort( a, 1 );
3804 snprintf(ca->cr_msg, sizeof( ca->cr_msg ), "ordered_value_sort failed on attr %s\n",
3805 ad->ad_cname.bv_val );
3809 for ( i=0; vals[i].bv_val; i++ ) {
3810 ca->line = vals[i].bv_val;
3811 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
3812 ca->line[0] == '{' ) {
3813 char *idx = strchr( ca->line, '}' );
3814 if ( idx ) ca->line = idx+1;
3816 rc = config_parse_vals( ct, ca, i );
3825 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
3828 struct berval rtype, rval;
3830 AttributeDescription *ad = NULL;
3832 dnRdn( &e->e_name, rdn );
3833 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
3834 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
3835 rtype.bv_val = rdn->bv_val;
3836 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
3839 slap_bv2ad( &rtype, &ad, &rs->sr_text );
3840 a = attr_find( e->e_attrs, ad );
3841 if (!a ) return LDAP_NAMING_VIOLATION;
3848 config_rename_kids( CfEntryInfo *ce )
3851 struct berval rdn, nrdn;
3853 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
3854 struct berval newdn, newndn;
3855 dnRdn ( &ce2->ce_entry->e_name, &rdn );
3856 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
3857 build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
3858 build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
3859 free( ce2->ce_entry->e_name.bv_val );
3860 free( ce2->ce_entry->e_nname.bv_val );
3861 ce2->ce_entry->e_name = newdn;
3862 ce2->ce_entry->e_nname = newndn;
3863 config_rename_kids( ce2 );
3868 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
3869 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
3870 struct berval *nnewrdn, int use_ldif )
3874 struct berval odn, ondn;
3878 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
3879 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
3882 free( a->a_vals[0].bv_val );
3883 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
3884 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
3885 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
3886 strcpy( a->a_vals[0].bv_val, ptr1 );
3888 if ( a->a_nvals != a->a_vals ) {
3889 free( a->a_nvals[0].bv_val );
3890 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
3891 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
3892 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
3893 strcpy( a->a_nvals[0].bv_val, ptr1 );
3896 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
3897 BackendDB *be = op->o_bd;
3898 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
3899 struct berval dn, ndn, xdn, xndn;
3901 op->o_bd = &cfb->cb_db;
3903 /* Save current rootdn; use the underlying DB's rootdn */
3907 xndn = op->o_req_ndn;
3908 op->o_dn = op->o_bd->be_rootdn;
3909 op->o_ndn = op->o_bd->be_rootndn;
3911 op->o_req_ndn = ondn;
3913 scp = op->o_callback;
3914 op->o_callback = ≻
3915 op->orr_newrdn = *newrdn;
3916 op->orr_nnewrdn = *nnewrdn;
3917 op->orr_newSup = NULL;
3918 op->orr_nnewSup = NULL;
3919 op->orr_deleteoldrdn = 1;
3920 op->orr_modlist = NULL;
3921 slap_modrdn2mods( op, rs );
3922 slap_mods_opattrs( op, &op->orr_modlist, 1 );
3923 rc = op->o_bd->be_modrdn( op, rs );
3924 slap_mods_free( op->orr_modlist, 1 );
3927 op->o_callback = scp;
3931 op->o_req_ndn = xndn;
3934 free( ondn.bv_val );
3936 config_rename_kids( e->e_private );
3941 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
3942 Entry *e, int idx, int tailindex, int use_ldif )
3944 struct berval ival, newrdn, nnewrdn;
3947 char ibuf[32], *ptr1, *ptr2 = NULL;
3950 rc = config_rename_attr( rs, e, &rdn, &a );
3951 if ( rc ) return rc;
3954 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
3955 if ( ival.bv_len >= sizeof( ibuf ) ) {
3956 return LDAP_NAMING_VIOLATION;
3959 newrdn.bv_len = rdn.bv_len + ival.bv_len;
3960 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
3963 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
3964 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
3967 ptr2 = ber_bvchr( &rdn, '}' );
3971 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
3973 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
3974 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
3975 a->a_desc->ad_cname.bv_len );
3977 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
3978 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
3982 /* Do the equivalent of ModRDN */
3983 /* Replace DN / NDN */
3984 newrdn.bv_len = ptr1 - newrdn.bv_val;
3985 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
3986 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
3988 free( nnewrdn.bv_val );
3989 free( newrdn.bv_val );
3994 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
3995 SlapReply *rs, int *renum, int *ibase )
3998 int index = -1, gotindex = 0, nsibs, rc = 0;
3999 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
4000 char *ptr1, *ptr2 = NULL;
4003 if ( renum ) *renum = 0;
4005 /* These entries don't get indexed/renumbered */
4006 if ( ce_type == Cft_Global ) return 0;
4007 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
4009 if ( ce_type == Cft_Module )
4012 /* See if the rdn has an index already */
4013 dnRdn( &e->e_name, &rdn );
4014 if ( ce_type == Cft_Database ) {
4015 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
4016 "frontend", STRLENOF("frontend") ))
4018 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
4019 "config", STRLENOF("config") ))
4022 ptr1 = ber_bvchr( &e->e_name, '{' );
4023 if ( ptr1 && ptr1 < &e->e_name.bv_val[ rdn.bv_len ] ) {
4025 ptr2 = strchr( ptr1, '}' );
4026 if ( !ptr2 || ptr2 > &e->e_name.bv_val[ rdn.bv_len ] )
4027 return LDAP_NAMING_VIOLATION;
4028 if ( ptr2-ptr1 == 1)
4029 return LDAP_NAMING_VIOLATION;
4031 index = strtol( ptr1 + 1, &next, 10 );
4032 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
4033 return LDAP_NAMING_VIOLATION;
4036 /* Special case, we allow -1 for the frontendDB */
4037 if ( index != -1 || !isfrontend )
4038 return LDAP_NAMING_VIOLATION;
4040 if ( isconfig && index != 0 ){
4041 return LDAP_NAMING_VIOLATION;
4045 /* count related kids */
4046 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
4047 if ( ce->ce_type == ce_type ) nsibs++;
4050 /* account for -1 frontend */
4051 if ( ce_type == Cft_Database )
4054 if ( index != nsibs ) {
4056 if ( index < nsibs ) {
4057 if ( tailindex ) return LDAP_NAMING_VIOLATION;
4058 /* Siblings need to be renumbered */
4059 if ( index != -1 || !isfrontend )
4063 /* config DB is always "0" */
4064 if ( isconfig && index == -1 ) {
4067 if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
4071 /* just make index = nsibs */
4073 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
4076 if ( ibase ) *ibase = index;
4077 if ( renum ) *renum = renumber;
4082 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
4087 co.co_name = &oc->soc_cname;
4088 cop = avl_find( CfOcTree, &co, CfOc_cmp );
4092 /* check for duplicates */
4093 for ( i = 0; i < *nocs; i++ ) {
4094 if ( *copp && (*copp)[i] == cop ) {
4100 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
4101 if ( tmp == NULL ) {
4105 (*copp)[*nocs] = cop;
4110 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
4111 if ( count_oc( *sups, copp, nocs ) ) {
4120 count_ocs( Attribute *oc_at, int *nocs )
4123 ConfigOCs **colst = NULL;
4127 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
4131 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
4133 assert( oc != NULL );
4134 if ( count_oc( oc, &colst, nocs ) ) {
4144 cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4146 /* Leftover from RE23. Never parse this entry */
4147 return LDAP_COMPARE_TRUE;
4151 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4155 /* This entry is hardcoded, don't re-parse it */
4156 if ( p->ce_type == Cft_Global ) {
4157 cfn = p->ce_private;
4158 ca->ca_private = cfn;
4159 return LDAP_COMPARE_TRUE;
4161 if ( p->ce_type != Cft_Schema )
4162 return LDAP_CONSTRAINT_VIOLATION;
4164 cfn = ch_calloc( 1, sizeof(ConfigFile) );
4165 ca->ca_private = cfn;
4166 cfo = p->ce_private;
4167 cfn->c_sibs = cfo->c_kids;
4169 return LDAP_SUCCESS;
4173 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4175 if ( p->ce_type != Cft_Global ) {
4176 return LDAP_CONSTRAINT_VIOLATION;
4178 /* config must be {0}, nothing else allowed */
4179 if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
4180 strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
4181 return LDAP_CONSTRAINT_VIOLATION;
4183 ca->be = frontendDB; /* just to get past check_vals */
4184 return LDAP_SUCCESS;
4188 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4190 if ( p->ce_type != Cft_Global ) {
4191 return LDAP_CONSTRAINT_VIOLATION;
4193 return LDAP_SUCCESS;
4197 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4199 if ( p->ce_type != Cft_Global ) {
4200 return LDAP_CONSTRAINT_VIOLATION;
4202 return LDAP_SUCCESS;
4206 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4208 if ( p->ce_type != Cft_Database ) {
4209 return LDAP_CONSTRAINT_VIOLATION;
4212 return LDAP_SUCCESS;
4216 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
4221 AttributeDescription *ad;
4226 if ( cfn->c_cr_head ) {
4227 struct berval bv = BER_BVC("olcDitContentRules");
4229 slap_bv2ad( &bv, &ad, &text );
4230 ct = config_find_table( colst, nocs, ad, ca );
4231 config_del_vals( ct, ca );
4233 if ( cfn->c_oc_head ) {
4234 struct berval bv = BER_BVC("olcObjectClasses");
4236 slap_bv2ad( &bv, &ad, &text );
4237 ct = config_find_table( colst, nocs, ad, ca );
4238 config_del_vals( ct, ca );
4240 if ( cfn->c_at_head ) {
4241 struct berval bv = BER_BVC("olcAttributeTypes");
4243 slap_bv2ad( &bv, &ad, &text );
4244 ct = config_find_table( colst, nocs, ad, ca );
4245 config_del_vals( ct, ca );
4247 if ( cfn->c_syn_head ) {
4248 struct berval bv = BER_BVC("olcLdapSyntaxes");
4250 slap_bv2ad( &bv, &ad, &text );
4251 ct = config_find_table( colst, nocs, ad, ca );
4252 config_del_vals( ct, ca );
4254 if ( cfn->c_om_head ) {
4255 struct berval bv = BER_BVC("olcObjectIdentifier");
4257 slap_bv2ad( &bv, &ad, &text );
4258 ct = config_find_table( colst, nocs, ad, ca );
4259 config_del_vals( ct, ca );
4261 cfo = p->ce_private;
4262 cfo->c_kids = cfn->c_sibs;
4267 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
4269 int rc = LDAP_CONSTRAINT_VIOLATION;
4272 if ( (*cop)->co_ldadd ) {
4273 rc = (*cop)->co_ldadd( last, e, ca );
4274 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4279 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
4280 ConfigOCs co = { 0 };
4282 co.co_name = &(*ocp)->soc_cname;
4283 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
4284 if ( *cop == NULL ) {
4288 rc = config_add_oc( cop, last, e, ca );
4289 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4297 /* Parse an LDAP entry into config directives */
4299 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
4300 int *renum, Operation *op )
4302 CfEntryInfo *ce, *last = NULL;
4303 ConfigOCs co, *coptr, **colst;
4304 Attribute *a, *oc_at, *soc_at;
4305 int i, ibase = -1, nocs, rc = 0;
4308 char *ptr, *log_prefix = op ? op->o_log_prefix : "";
4310 memset( ca, 0, sizeof(ConfigArgs));
4312 /* Make sure parent exists and entry does not. But allow
4313 * Databases and Overlays to be inserted. Don't do any
4314 * auto-renumbering if manageDSAit control is present.
4316 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
4318 if ( ( op && op->o_managedsait ) ||
4319 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
4320 ce->ce_type != Cft_Module ) )
4322 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4323 "DN=\"%s\" already exists\n",
4324 log_prefix, e->e_name.bv_val, 0 );
4325 return LDAP_ALREADY_EXISTS;
4329 dnParent( &e->e_nname, &pdn );
4331 /* If last is NULL, the new entry is the root/suffix entry,
4332 * otherwise last should be the parent.
4334 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
4336 rs->sr_matched = last->ce_entry->e_name.bv_val;
4338 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4339 "DN=\"%s\" not child of DN=\"%s\"\n",
4340 log_prefix, e->e_name.bv_val,
4341 last->ce_entry->e_name.bv_val );
4342 return LDAP_NO_SUCH_OBJECT;
4346 /* No parent, must be root. This will never happen... */
4347 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
4348 return LDAP_NO_SUCH_OBJECT;
4351 if ( last && !access_allowed( op, last->ce_entry,
4352 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
4354 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4355 "DN=\"%s\" no write access to \"children\" of parent\n",
4356 log_prefix, e->e_name.bv_val, 0 );
4357 return LDAP_INSUFFICIENT_ACCESS;
4361 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
4363 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4364 "DN=\"%s\" no objectClass\n",
4365 log_prefix, e->e_name.bv_val, 0 );
4366 return LDAP_OBJECT_CLASS_VIOLATION;
4369 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
4371 ObjectClass *soc = NULL;
4372 char textbuf[ SLAP_TEXT_BUFLEN ];
4373 const char *text = textbuf;
4375 /* FIXME: check result */
4376 rc = structural_class( oc_at->a_nvals, &soc, NULL,
4377 &text, textbuf, sizeof(textbuf), NULL );
4378 if ( rc != LDAP_SUCCESS ) {
4379 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4380 "DN=\"%s\" no structural objectClass (%s)\n",
4381 log_prefix, e->e_name.bv_val, text );
4384 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
4385 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
4386 if ( soc_at == NULL ) {
4387 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4388 "DN=\"%s\" no structural objectClass; "
4389 "unable to merge computed class %s\n",
4390 log_prefix, e->e_name.bv_val,
4391 soc->soc_cname.bv_val );
4392 return LDAP_OBJECT_CLASS_VIOLATION;
4395 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4396 "DN=\"%s\" no structural objectClass; "
4397 "computed objectClass %s merged\n",
4398 log_prefix, e->e_name.bv_val,
4399 soc->soc_cname.bv_val );
4402 /* Fake the coordinates based on whether we're part of an
4403 * LDAP Add or if reading the config dir
4406 ca->fname = "slapd";
4409 ca->fname = cfdir.bv_val;
4414 co.co_name = &soc_at->a_nvals[0];
4415 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
4416 if ( coptr == NULL ) {
4417 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4418 "DN=\"%s\" no structural objectClass in configuration table\n",
4419 log_prefix, e->e_name.bv_val, 0 );
4420 return LDAP_OBJECT_CLASS_VIOLATION;
4423 /* Only the root can be Cft_Global, everything else must
4424 * have a parent. Only limited nesting arrangements are allowed.
4426 rc = LDAP_CONSTRAINT_VIOLATION;
4427 if ( coptr->co_type == Cft_Global && !last ) {
4428 cfn = cfb->cb_config;
4429 ca->ca_private = cfn;
4430 ca->be = frontendDB; /* just to get past check_vals */
4434 colst = count_ocs( oc_at, &nocs );
4436 /* Check whether the Add is allowed by its parent, and do
4437 * any necessary arg setup
4440 rc = config_add_oc( &coptr, last, e, ca );
4441 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
4442 for ( i = 0; i<nocs; i++ ) {
4443 /* Already checked these */
4444 if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
4446 if ( colst[i]->co_ldadd &&
4447 ( rc = colst[i]->co_ldadd( last, e, ca ))
4448 != LDAP_CONSTRAINT_VIOLATION ) {
4454 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
4455 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4456 "DN=\"%s\" no structural objectClass add function\n",
4457 log_prefix, e->e_name.bv_val, 0 );
4458 return LDAP_OBJECT_CLASS_VIOLATION;
4462 /* Add the entry but don't parse it, we already have its contents */
4463 if ( rc == LDAP_COMPARE_TRUE ) {
4468 if ( rc != LDAP_SUCCESS )
4471 /* Parse all the values and check for simple syntax errors before
4472 * performing any set actions.
4474 * If doing an LDAPadd, check for indexed names and any necessary
4475 * renaming/renumbering. Entries that don't need indexed names are
4476 * ignored. Entries that need an indexed name and arrive without one
4477 * are assigned to the end. Entries that arrive with an index may
4478 * cause the following entries to be renumbered/bumped down.
4480 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
4481 * don't allow Adding an entry with an index that's already in use.
4482 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
4484 * These entries can have auto-assigned indexes (appended to the end)
4485 * but only the other types support auto-renumbering of siblings.
4488 rc = check_name_index( last, coptr->co_type, e, rs, renum,
4493 if ( renum && *renum && coptr->co_type != Cft_Database &&
4494 coptr->co_type != Cft_Overlay )
4496 snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
4497 "operation requires sibling renumbering" );
4498 rc = LDAP_UNWILLING_TO_PERFORM;
4503 init_config_argv( ca );
4505 /* Make sure we process attrs in the required order */
4506 sort_attrs( e, colst, nocs );
4508 for ( a = e->e_attrs; a; a = a->a_next ) {
4509 if ( a == oc_at ) continue;
4510 ct = config_find_table( colst, nocs, a->a_desc, ca );
4511 if ( !ct ) continue; /* user data? */
4512 rc = check_vals( ct, ca, a, 1 );
4513 if ( rc ) goto done_noop;
4516 /* Basic syntax checks are OK. Do the actual settings. */
4517 for ( a=e->e_attrs; a; a=a->a_next ) {
4518 if ( a == oc_at ) continue;
4519 ct = config_find_table( colst, nocs, a->a_desc, ca );
4520 if ( !ct ) continue; /* user data? */
4521 for (i=0; a->a_vals[i].bv_val; i++) {
4524 ca->line = a->a_vals[i].bv_val;
4525 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
4526 ptr = strchr( ca->line, '}' );
4528 iptr = strchr( ca->line, '{' );
4532 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
4534 ca->valx = strtol( iptr+1, NULL, 0 );
4539 rc = config_parse_add( ct, ca, i );
4547 /* Newly added databases and overlays need to be started up */
4548 if ( CONFIG_ONLINE_ADD( ca )) {
4549 if ( colst[0]->co_type == Cft_Database ) {
4550 rc = backend_startup_one( ca->be, &ca->reply );
4552 } else if ( colst[0]->co_type == Cft_Overlay ) {
4553 if ( ca->bi->bi_db_open ) {
4554 BackendInfo *bi_orig = ca->be->bd_info;
4555 ca->be->bd_info = ca->bi;
4556 rc = ca->bi->bi_db_open( ca->be, &ca->reply );
4557 ca->be->bd_info = bi_orig;
4559 } else if ( ca->cleanup ) {
4560 rc = ca->cleanup( ca );
4563 if (ca->cr_msg[0] == '\0')
4564 snprintf( ca->cr_msg, sizeof( ca->cr_msg ), "<%s> failed startup", ca->argv[0] );
4566 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
4567 ca->log, ca->cr_msg, ca->argv[1] );
4574 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
4575 ce->ce_parent = last;
4576 ce->ce_entry = entry_dup( e );
4577 ce->ce_entry->e_private = ce;
4578 ce->ce_type = colst[0]->co_type;
4581 ce->ce_private = ca->ca_private;
4582 ca->ca_entry = ce->ce_entry;
4585 } else if ( last->ce_kids ) {
4586 CfEntryInfo *c2, **cprev;
4588 /* Advance to first of this type */
4589 cprev = &last->ce_kids;
4590 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
4591 cprev = &c2->ce_sibs;
4594 /* Account for the (-1) frontendDB entry */
4595 if ( ce->ce_type == Cft_Database ) {
4596 if ( ca->be == frontendDB )
4598 else if ( ibase != -1 )
4603 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
4604 cprev = &c2->ce_sibs;
4610 for ( i=0; i<ibase; i++ ) {
4612 cprev = &c2->ce_sibs;
4615 ce->ce_sibs = *cprev;
4623 if ( (colst[0]->co_type == Cft_Database) && ca->be ) {
4624 if ( ca->be != frontendDB )
4625 backend_destroy_one( ca->be, 1 );
4626 } else if ( (colst[0]->co_type == Cft_Overlay) && ca->bi ) {
4627 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
4628 } else if ( colst[0]->co_type == Cft_Schema ) {
4629 schema_destroy_one( ca, colst, nocs, last );
4634 ch_free( ca->argv );
4635 if ( colst ) ch_free( colst );
4639 #define BIGTMP 10000
4641 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
4642 int base, int rebase, int max, int use_ldif )
4644 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
4645 ConfigType etype = ce->ce_type;
4646 int count = 0, rc = 0;
4648 /* Reverse ce list */
4649 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
4650 if (ce2->ce_type != etype) {
4655 ce2->ce_sibs = cetmp;
4658 if ( max && count >= max ) {
4664 /* Move original to a temp name until increments are done */
4666 ce->ce_entry->e_private = NULL;
4667 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4668 base+BIGTMP, 0, use_ldif );
4669 ce->ce_entry->e_private = ce;
4671 /* start incrementing */
4672 for (ce2=cetmp; ce2; ce2=ce3) {
4674 ce2->ce_sibs = cerem;
4677 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
4678 count+base, 0, use_ldif );
4682 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4683 base, 0, use_ldif );
4688 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
4689 CfEntryInfo *ce2, int old, int use_ldif )
4693 /* Renumber original to a temp value */
4694 ce->ce_entry->e_private = NULL;
4695 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4696 old+BIGTMP, 0, use_ldif );
4697 ce->ce_entry->e_private = ce;
4699 /* start decrementing */
4700 for (; ce2 != ce; ce2=ce2->ce_sibs) {
4701 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
4702 count+old, 0, use_ldif );
4705 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
4706 count+old, 0, use_ldif );
4709 /* Parse an LDAP entry into config directives, then store in underlying
4713 config_back_add( Operation *op, SlapReply *rs )
4719 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
4720 NULL, ACL_WADD, NULL )) {
4721 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4726 * Check for attribute ACL
4728 if ( !acl_check_modlist( op, op->ora_e, op->orm_modlist )) {
4729 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
4730 rs->sr_text = "no write access to attribute";
4734 cfb = (CfBackInfo *)op->o_bd->be_private;
4736 /* add opattrs for syncprov */
4738 char textbuf[SLAP_TEXT_BUFLEN];
4739 size_t textlen = sizeof textbuf;
4740 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1, NULL,
4741 &rs->sr_text, textbuf, sizeof( textbuf ) );
4742 if ( rs->sr_err != LDAP_SUCCESS )
4744 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
4745 if ( rs->sr_err != LDAP_SUCCESS ) {
4746 Debug( LDAP_DEBUG_TRACE,
4747 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
4748 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
4753 ldap_pvt_thread_pool_pause( &connection_pool );
4756 * 1) check for existence of entry
4757 * 2) check for sibling renumbering
4758 * 3) perform internal add
4759 * 4) perform any necessary renumbering
4760 * 5) store entry in underlying database
4762 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
4763 if ( rs->sr_err != LDAP_SUCCESS ) {
4764 rs->sr_text = ca.cr_msg;
4769 CfEntryInfo *ce = ca.ca_entry->e_private;
4770 req_add_s addr = op->oq_add;
4771 op->o_tag = LDAP_REQ_MODRDN;
4772 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
4773 op->o_tag = LDAP_REQ_ADD;
4775 if ( rs->sr_err != LDAP_SUCCESS ) {
4780 if ( cfb->cb_use_ldif ) {
4781 BackendDB *be = op->o_bd;
4782 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4783 struct berval dn, ndn;
4785 op->o_bd = &cfb->cb_db;
4787 /* Save current rootdn; use the underlying DB's rootdn */
4790 op->o_dn = op->o_bd->be_rootdn;
4791 op->o_ndn = op->o_bd->be_rootndn;
4793 scp = op->o_callback;
4794 op->o_callback = ≻
4795 op->o_bd->be_add( op, rs );
4797 op->o_callback = scp;
4803 ldap_pvt_thread_pool_resume( &connection_pool );
4806 send_ldap_result( op, rs );
4807 slap_graduate_commit_csn( op );
4811 typedef struct delrec {
4812 struct delrec *next;
4818 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
4824 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
4825 ca->line[0] == '{' )
4827 char *ptr = strchr( ca->line + 1, '}' );
4831 ca->valx = strtol( ca->line + 1, &next, 0 );
4832 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
4838 rc = config_parse_add( ct, ca, i );
4846 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
4849 int rc = LDAP_UNWILLING_TO_PERFORM;
4851 Entry *e = ce->ce_entry;
4852 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
4857 delrec *dels = NULL, *deltail = NULL;
4859 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
4860 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
4862 colst = count_ocs( oc_at, &nocs );
4864 /* make sure add/del flags are clear; should always be true */
4865 for ( s = save_attrs; s; s = s->a_next ) {
4866 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
4869 e->e_attrs = attrs_dup( e->e_attrs );
4871 init_config_argv( ca );
4874 ca->ca_private = ce->ce_private;
4876 ca->fname = "slapd";
4878 strcpy( ca->log, "back-config" );
4880 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
4881 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
4882 switch (ml->sml_op) {
4883 case LDAP_MOD_DELETE:
4884 case LDAP_MOD_REPLACE: {
4885 BerVarray vals = NULL, nvals = NULL;
4887 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
4889 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot delete %s",
4890 ml->sml_desc->ad_cname.bv_val );
4893 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4894 vals = ml->sml_values;
4895 nvals = ml->sml_nvalues;
4896 ml->sml_values = NULL;
4897 ml->sml_nvalues = NULL;
4899 /* If we're deleting by values, remember the indexes of the
4900 * values we deleted.
4902 if ( ct && ml->sml_values ) {
4904 i = ml->sml_numvals;
4905 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
4916 rc = modify_delete_vindex(e, &ml->sml_mod,
4917 get_permissiveModify(op),
4918 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg), idx );
4919 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
4920 ml->sml_values = vals;
4921 ml->sml_nvalues = nvals;
4926 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
4929 case SLAP_MOD_SOFTADD: {
4930 int mop = ml->sml_op;
4932 ml->sml_op = LDAP_MOD_ADD;
4934 if ( ct->arg_type & ARG_NO_INSERT ) {
4935 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
4937 navals = a->a_numvals;
4940 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
4941 if ( ml->sml_values[i].bv_val[0] == '{' &&
4944 char *next, *val = ml->sml_values[i].bv_val + 1;
4947 j = strtol( val, &next, 0 );
4948 if ( next == val || next[ 0 ] != '}' || j < navals ) {
4950 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot insert %s",
4951 ml->sml_desc->ad_cname.bv_val );
4955 rc = check_vals( ct, ca, ml, 0 );
4956 if ( rc ) goto out_noop;
4959 rc = modify_add_values(e, &ml->sml_mod,
4960 get_permissiveModify(op),
4961 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
4963 /* If value already exists, show success here
4964 * and ignore this operation down below.
4966 if ( mop == SLAP_MOD_SOFTADD ) {
4967 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
4977 case LDAP_MOD_INCREMENT: /* FIXME */
4982 if(rc != LDAP_SUCCESS) break;
4985 if ( rc == LDAP_SUCCESS) {
4986 /* check that the entry still obeys the schema */
4987 rc = entry_schema_check(op, e, NULL, 0, 0, NULL,
4988 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
4990 if ( rc ) goto out_noop;
4992 /* Basic syntax checks are OK. Do the actual settings. */
4993 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
4994 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
4995 if ( !ct ) continue;
4997 s = attr_find( save_attrs, ml->sml_desc );
4998 a = attr_find( e->e_attrs, ml->sml_desc );
5000 switch (ml->sml_op) {
5001 case LDAP_MOD_DELETE:
5002 case LDAP_MOD_REPLACE: {
5003 BerVarray vals = NULL, nvals = NULL;
5006 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5007 vals = ml->sml_values;
5008 nvals = ml->sml_nvalues;
5009 ml->sml_values = NULL;
5010 ml->sml_nvalues = NULL;
5013 if ( ml->sml_values )
5016 /* If we didn't delete the whole attribute */
5017 if ( ml->sml_values && a ) {
5018 struct berval *mvals;
5021 if ( ml->sml_nvalues )
5022 mvals = ml->sml_nvalues;
5024 mvals = ml->sml_values;
5026 /* use the indexes we saved up above */
5027 for (i=0; i < d->nidx; i++) {
5028 struct berval bv = *mvals++;
5029 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
5030 bv.bv_val[0] == '{' ) {
5031 ptr = strchr( bv.bv_val, '}' ) + 1;
5032 bv.bv_len -= ptr - bv.bv_val;
5035 ca->line = bv.bv_val;
5036 ca->valx = d->idx[i];
5037 rc = config_del_vals( ct, ca );
5038 if ( rc != LDAP_SUCCESS ) break;
5040 s->a_flags |= SLAP_ATTR_IXDEL;
5041 for (j=i+1; j < d->nidx; j++)
5042 if ( d->idx[j] >d->idx[i] )
5048 rc = config_del_vals( ct, ca );
5049 if ( rc ) rc = LDAP_OTHER;
5051 s->a_flags |= SLAP_ATTR_IXDEL;
5053 if ( ml->sml_values ) {
5058 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5059 ml->sml_values = vals;
5060 ml->sml_nvalues = nvals;
5062 if ( !vals || rc != LDAP_SUCCESS )
5065 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5068 for (i=0; ml->sml_values[i].bv_val; i++) {
5069 ca->line = ml->sml_values[i].bv_val;
5071 rc = config_modify_add( ct, ca, ml->sml_desc, i );
5074 a->a_flags |= SLAP_ATTR_IXADD;
5081 /* Undo for a failed operation */
5082 if ( rc != LDAP_SUCCESS ) {
5083 ConfigReply msg = ca->reply;
5084 for ( s = save_attrs; s; s = s->a_next ) {
5085 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
5086 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5087 ct = config_find_table( colst, nocs, s->a_desc, ca );
5088 a = attr_find( e->e_attrs, s->a_desc );
5090 /* clear the flag so the add check below will skip it */
5091 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5094 config_del_vals( ct, ca );
5096 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5097 ca->line = s->a_vals[i].bv_val;
5099 config_modify_add( ct, ca, s->a_desc, i );
5103 for ( a = e->e_attrs; a; a = a->a_next ) {
5104 if ( a->a_flags & SLAP_ATTR_IXADD ) {
5105 ct = config_find_table( colst, nocs, a->a_desc, ca );
5108 config_del_vals( ct, ca );
5109 s = attr_find( save_attrs, a->a_desc );
5111 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5112 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5113 ca->line = s->a_vals[i].bv_val;
5115 config_modify_add( ct, ca, s->a_desc, i );
5126 if ( rc == LDAP_SUCCESS ) {
5127 attrs_free( save_attrs );
5129 attrs_free( e->e_attrs );
5130 e->e_attrs = save_attrs;
5132 ch_free( ca->argv );
5133 if ( colst ) ch_free( colst );
5135 deltail = dels->next;
5144 config_back_modify( Operation *op, SlapReply *rs )
5147 CfEntryInfo *ce, *last;
5149 ConfigArgs ca = {0};
5152 AttributeDescription *rad = NULL;
5155 cfb = (CfBackInfo *)op->o_bd->be_private;
5157 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5160 rs->sr_matched = last->ce_entry->e_name.bv_val;
5161 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5165 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
5166 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5170 /* Get type of RDN */
5171 rdn = ce->ce_entry->e_nname;
5172 ptr = strchr( rdn.bv_val, '=' );
5173 rdn.bv_len = ptr - rdn.bv_val;
5174 slap_bv2ad( &rdn, &rad, &rs->sr_text );
5176 /* Some basic validation... */
5177 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5178 /* Don't allow Modify of RDN; must use ModRdn for that. */
5179 if ( ml->sml_desc == rad ) {
5180 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
5181 rs->sr_text = "Use modrdn to change the entry name";
5184 /* Internal update of contextCSN? */
5185 if ( ml->sml_desc == slap_schema.si_ad_contextCSN && op->o_conn->c_conn_idx == -1 ) {
5191 slap_mods_opattrs( op, &op->orm_modlist, 1 );
5194 ldap_pvt_thread_pool_pause( &connection_pool );
5197 * 1) perform the Modify on the cached Entry.
5198 * 2) verify that the Entry still satisfies the schema.
5199 * 3) perform the individual config operations.
5200 * 4) store Modified entry in underlying LDIF backend.
5202 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
5204 rs->sr_text = ca.cr_msg;
5205 } else if ( cfb->cb_use_ldif ) {
5206 BackendDB *be = op->o_bd;
5207 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5208 struct berval dn, ndn;
5210 op->o_bd = &cfb->cb_db;
5214 op->o_dn = op->o_bd->be_rootdn;
5215 op->o_ndn = op->o_bd->be_rootndn;
5217 scp = op->o_callback;
5218 op->o_callback = ≻
5219 op->o_bd->be_modify( op, rs );
5221 op->o_callback = scp;
5227 ldap_pvt_thread_pool_resume( &connection_pool );
5229 send_ldap_result( op, rs );
5230 slap_graduate_commit_csn( op );
5235 config_back_modrdn( Operation *op, SlapReply *rs )
5238 CfEntryInfo *ce, *last;
5242 cfb = (CfBackInfo *)op->o_bd->be_private;
5244 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5247 rs->sr_matched = last->ce_entry->e_name.bv_val;
5248 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5251 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
5252 NULL, ACL_WRITE, NULL )) {
5253 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5257 if ( ce->ce_parent )
5258 parent = ce->ce_parent->ce_entry;
5260 parent = (Entry *)&slap_entry_root;
5261 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
5262 NULL, ACL_WRITE, NULL )) {
5263 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5268 /* We don't allow moving objects to new parents.
5269 * Generally we only allow reordering a set of ordered entries.
5271 if ( op->orr_newSup ) {
5272 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5276 /* If newRDN == oldRDN, quietly succeed */
5277 dnRdn( &op->o_req_ndn, &rdn );
5278 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
5279 rs->sr_err = LDAP_SUCCESS;
5283 /* Current behavior, subject to change as needed:
5285 * For backends and overlays, we only allow renumbering.
5286 * For schema, we allow renaming with the same number.
5287 * Otherwise, the op is not allowed.
5290 if ( ce->ce_type == Cft_Schema ) {
5294 /* Can't alter the main cn=schema entry */
5295 if ( ce->ce_parent->ce_type == Cft_Global ) {
5296 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5297 rs->sr_text = "renaming not allowed for this entry";
5301 /* We could support this later if desired */
5302 ptr1 = ber_bvchr( &rdn, '}' );
5303 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5304 len = ptr1 - rdn.bv_val;
5305 if ( len != ptr2 - op->orr_newrdn.bv_val ||
5306 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
5307 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5308 rs->sr_text = "schema reordering not supported";
5311 } else if ( ce->ce_type == Cft_Database ||
5312 ce->ce_type == Cft_Overlay ) {
5313 char *ptr1, *ptr2, *iptr1, *iptr2;
5316 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
5317 if ( *iptr2 != '{' ) {
5318 rs->sr_err = LDAP_NAMING_VIOLATION;
5319 rs->sr_text = "new ordering index is required";
5323 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
5324 ptr1 = ber_bvchr( &rdn, '}' );
5325 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5327 rs->sr_err = LDAP_NAMING_VIOLATION;
5328 rs->sr_text = "new ordering index is required";
5332 len1 = ptr1 - rdn.bv_val;
5333 len2 = ptr2 - op->orr_newrdn.bv_val;
5335 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
5336 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
5337 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5338 rs->sr_text = "changing database/overlay type not allowed";
5341 ixold = strtol( iptr1, NULL, 0 );
5342 ixnew = strtol( iptr2, &ptr1, 0 );
5343 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
5344 rs->sr_err = LDAP_NAMING_VIOLATION;
5347 /* config DB is always 0, cannot be changed */
5348 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
5349 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
5353 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5354 rs->sr_text = "renaming not supported for this entry";
5358 ldap_pvt_thread_pool_pause( &connection_pool );
5360 if ( ce->ce_type == Cft_Schema ) {
5361 req_modrdn_s modr = op->oq_modrdn;
5364 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
5365 if ( rs->sr_err == LDAP_SUCCESS ) {
5366 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
5367 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
5370 op->oq_modrdn = modr;
5372 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
5373 req_modrdn_s modr = op->oq_modrdn;
5376 /* Advance to first of this type */
5377 cprev = &ce->ce_parent->ce_kids;
5378 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
5379 cprev = &ce2->ce_sibs;
5382 /* Skip the -1 entry */
5383 if ( ce->ce_type == Cft_Database ) {
5384 cprev = &ce2->ce_sibs;
5390 /* Remove from old slot */
5391 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
5392 cprev = &ce2->ce_sibs;
5393 *cprev = ce->ce_sibs;
5394 ceold = ce->ce_sibs;
5396 /* Insert into new slot */
5398 for ( i=0; i<ixnew; i++ ) {
5402 cprev = &ce2->ce_sibs;
5404 ce->ce_sibs = *cprev;
5409 /* NOTE: These should be encoded in the OC tables, not inline here */
5410 if ( ce->ce_type == Cft_Database )
5411 backend_db_move( ce->ce_be, ixnew );
5412 else if ( ce->ce_type == Cft_Overlay )
5413 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
5415 if ( ixold < ixnew ) {
5416 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
5419 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
5420 ixold - ixnew, cfb->cb_use_ldif );
5422 op->oq_modrdn = modr;
5425 ldap_pvt_thread_pool_resume( &connection_pool );
5427 send_ldap_result( op, rs );
5432 config_back_delete( Operation *op, SlapReply *rs )
5434 #ifdef SLAP_CONFIG_DELETE
5436 CfEntryInfo *ce, *last, *ce2;
5438 cfb = (CfBackInfo *)op->o_bd->be_private;
5440 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5443 rs->sr_matched = last->ce_entry->e_name.bv_val;
5444 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5445 } else if ( ce->ce_kids ) {
5446 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5447 } else if ( ce->ce_type == Cft_Overlay ){
5451 ldap_pvt_thread_pool_pause( &connection_pool );
5453 overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
5455 /* remove CfEntryInfo from the siblings list */
5456 if ( ce->ce_parent->ce_kids == ce ) {
5457 ce->ce_parent->ce_kids = ce->ce_sibs;
5459 for ( ce2 = ce->ce_parent->ce_kids ; ce2; ce2 = ce2->ce_sibs ) {
5460 if ( ce2->ce_sibs == ce ) {
5461 ce2->ce_sibs = ce->ce_sibs;
5467 /* remove from underlying database */
5468 if ( cfb->cb_use_ldif ) {
5469 BackendDB *be = op->o_bd;
5470 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5471 struct berval dn, ndn, req_dn, req_ndn;
5473 op->o_bd = &cfb->cb_db;
5477 req_dn = op->o_req_dn;
5478 req_ndn = op->o_req_ndn;
5480 op->o_dn = op->o_bd->be_rootdn;
5481 op->o_ndn = op->o_bd->be_rootndn;
5482 op->o_req_dn = ce->ce_entry->e_name;
5483 op->o_req_ndn = ce->ce_entry->e_nname;
5485 scp = op->o_callback;
5486 op->o_callback = ≻
5487 op->o_bd->be_delete( op, rs );
5489 op->o_callback = scp;
5492 op->o_req_dn = req_dn;
5493 op->o_req_ndn = req_ndn;
5496 /* renumber siblings */
5497 iptr = ber_bvchr( &op->o_req_ndn, '{' ) + 1;
5498 ixold = strtol( iptr, NULL, 0 );
5499 for (ce2 = ce->ce_sibs, count=0; ce2; ce2=ce2->ce_sibs) {
5500 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5501 count+ixold, 0, cfb->cb_use_ldif );
5505 ce->ce_entry->e_private=NULL;
5506 entry_free(ce->ce_entry);
5508 ldap_pvt_thread_pool_resume( &connection_pool );
5510 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5513 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5514 #endif /* SLAP_CONFIG_DELETE */
5515 send_ldap_result( op, rs );
5520 config_back_search( Operation *op, SlapReply *rs )
5523 CfEntryInfo *ce, *last;
5526 cfb = (CfBackInfo *)op->o_bd->be_private;
5528 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5531 rs->sr_matched = last->ce_entry->e_name.bv_val;
5532 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5535 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
5536 ACL_SEARCH, NULL, &mask ))
5538 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
5539 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5541 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5545 switch ( op->ors_scope ) {
5546 case LDAP_SCOPE_BASE:
5547 case LDAP_SCOPE_SUBTREE:
5548 rs->sr_err = config_send( op, rs, ce, 0 );
5551 case LDAP_SCOPE_ONELEVEL:
5552 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
5553 rs->sr_err = config_send( op, rs, ce, 1 );
5562 send_ldap_result( op, rs );
5566 /* no-op, we never free entries */
5567 int config_entry_release(
5572 if ( !e->e_private ) {
5575 return LDAP_SUCCESS;
5578 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
5580 int config_back_entry_get(
5584 AttributeDescription *at,
5589 CfEntryInfo *ce, *last;
5590 int rc = LDAP_NO_SUCH_OBJECT;
5592 cfb = (CfBackInfo *)op->o_bd->be_private;
5594 ce = config_find_base( cfb->cb_root, ndn, &last );
5596 *ent = ce->ce_entry;
5599 if ( oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
5600 rc = LDAP_NO_SUCH_ATTRIBUTE;
5610 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
5611 ConfigTable *ct, ConfigArgs *c )
5615 for (; at && *at; at++) {
5616 /* Skip the naming attr */
5617 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
5619 for (i=0;ct[i].name;i++) {
5620 if (ct[i].ad == (*at)->sat_ad) {
5621 rc = config_get_vals(&ct[i], c);
5622 /* NOTE: tolerate that config_get_vals()
5623 * returns success with no values */
5624 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
5625 if ( c->rvalue_nvals )
5626 rc = attr_merge(e, ct[i].ad, c->rvalue_vals,
5629 slap_syntax_validate_func *validate =
5630 ct[i].ad->ad_type->sat_syntax->ssyn_validate;
5633 for ( j=0; c->rvalue_vals[j].bv_val; j++ ) {
5634 rc = ordered_value_validate( ct[i].ad,
5635 &c->rvalue_vals[j], LDAP_MOD_ADD );
5637 Debug( LDAP_DEBUG_ANY,
5638 "config_build_attrs: error %d on %s value #%d\n",
5639 rc, ct[i].ad->ad_cname.bv_val, j );
5645 rc = attr_merge_normalize(e, ct[i].ad,
5646 c->rvalue_vals, NULL);
5648 ber_bvarray_free( c->rvalue_nvals );
5649 ber_bvarray_free( c->rvalue_vals );
5651 Debug( LDAP_DEBUG_ANY,
5652 "config_build_attrs: error %d on %s\n",
5653 rc, ct[i].ad->ad_cname.bv_val, 0 );
5665 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
5666 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
5668 Entry *e = entry_alloc();
5669 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5671 struct berval ad_name;
5672 AttributeDescription *ad = NULL;
5675 const char *text = "";
5679 CfEntryInfo *ceprev = NULL;
5681 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
5684 ce->ce_type = main->co_type;
5685 ce->ce_parent = parent;
5687 pdn = parent->ce_entry->e_nname;
5688 if ( parent->ce_kids && parent->ce_kids->ce_type <= ce->ce_type )
5689 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
5690 ceprev->ce_type <= ce->ce_type;
5691 ceprev = ceprev->ce_sibs );
5696 ce->ce_private = c->ca_private;
5700 build_new_dn( &e->e_name, &pdn, rdn, NULL );
5701 ber_dupbv( &e->e_nname, &e->e_name );
5703 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
5704 main->co_name, NULL );
5706 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
5707 extra->co_name, NULL );
5708 ptr = strchr(rdn->bv_val, '=');
5709 ad_name.bv_val = rdn->bv_val;
5710 ad_name.bv_len = ptr - rdn->bv_val;
5711 rc = slap_bv2ad( &ad_name, &ad, &text );
5716 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
5717 attr_merge_normalize_one(e, ad, &val, NULL );
5720 c->table = main->co_type;
5721 if ( oc->soc_required ) {
5722 rc = config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
5723 if ( rc ) goto fail;
5726 if ( oc->soc_allowed ) {
5727 rc = config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
5728 if ( rc ) goto fail;
5733 c->table = extra->co_type;
5734 if ( oc->soc_required ) {
5735 rc = config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
5736 if ( rc ) goto fail;
5739 if ( oc->soc_allowed ) {
5740 rc = config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
5741 if ( rc ) goto fail;
5745 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5746 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->cr_msg,
5747 sizeof(c->cr_msg), op ? op->o_tmpmemctx : NULL );
5748 if ( rc != LDAP_SUCCESS ) {
5750 Debug( LDAP_DEBUG_ANY,
5751 "config_build_entry: build \"%s\" failed: \"%s\"\n",
5752 rdn->bv_val, text, 0);
5755 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
5758 op->ora_modlist = NULL;
5759 slap_add_opattrs( op, NULL, NULL, 0, 0 );
5760 if ( !op->o_noop ) {
5761 op->o_bd->be_add( op, rs );
5762 if ( ( rs->sr_err != LDAP_SUCCESS )
5763 && (rs->sr_err != LDAP_ALREADY_EXISTS) ) {
5769 ce->ce_sibs = ceprev->ce_sibs;
5770 ceprev->ce_sibs = ce;
5771 } else if ( parent ) {
5772 ce->ce_sibs = parent->ce_kids;
5773 parent->ce_kids = ce;
5780 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
5781 Operation *op, SlapReply *rs )
5784 ConfigFile *cf = c->ca_private;
5786 struct berval bv, rdn;
5788 for (; cf; cf=cf->c_sibs, c->depth++) {
5789 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
5790 !cf->c_om_head && !cf->c_syn_head ) continue;
5791 c->value_dn.bv_val = c->log;
5792 LUTIL_SLASHPATH( cf->c_file.bv_val );
5793 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
5798 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
5800 ptr = strchr( bv.bv_val, '.' );
5802 bv.bv_len = ptr - bv.bv_val;
5803 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
5804 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
5805 /* FIXME: how can indicate error? */
5808 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
5810 c->value_dn.bv_len += bv.bv_len;
5811 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
5815 e = config_build_entry( op, rs, ceparent, c, &rdn,
5816 &CFOC_SCHEMA, NULL );
5819 } else if ( e && cf->c_kids ) {
5820 c->ca_private = cf->c_kids;
5821 config_build_schema_inc( c, e->e_private, op, rs );
5827 #ifdef SLAPD_MODULES
5830 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
5831 Operation *op, SlapReply *rs )
5836 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
5837 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
5839 c->value_dn.bv_val = c->log;
5840 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
5841 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
5842 /* FIXME: how can indicate error? */
5846 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
5855 config_check_schema(Operation *op, CfBackInfo *cfb)
5857 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
5859 CfEntryInfo *ce, *last;
5862 /* If there's no root entry, we must be in the midst of converting */
5863 if ( !cfb->cb_root )
5866 /* Make sure the main schema entry exists */
5867 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
5874 /* Make sure it's up to date */
5875 if ( cf_om_tail != om_sys_tail ) {
5876 a = attr_find( e->e_attrs, cfAd_om );
5878 if ( a->a_nvals != a->a_vals )
5879 ber_bvarray_free( a->a_nvals );
5880 ber_bvarray_free( a->a_vals );
5885 oidm_unparse( &bv, NULL, NULL, 1 );
5886 attr_merge_normalize( e, cfAd_om, bv, NULL );
5887 ber_bvarray_free( bv );
5888 cf_om_tail = om_sys_tail;
5890 if ( cf_at_tail != at_sys_tail ) {
5891 a = attr_find( e->e_attrs, cfAd_attr );
5893 if ( a->a_nvals != a->a_vals )
5894 ber_bvarray_free( a->a_nvals );
5895 ber_bvarray_free( a->a_vals );
5900 at_unparse( &bv, NULL, NULL, 1 );
5901 attr_merge_normalize( e, cfAd_attr, bv, NULL );
5902 ber_bvarray_free( bv );
5903 cf_at_tail = at_sys_tail;
5905 if ( cf_oc_tail != oc_sys_tail ) {
5906 a = attr_find( e->e_attrs, cfAd_oc );
5908 if ( a->a_nvals != a->a_vals )
5909 ber_bvarray_free( a->a_nvals );
5910 ber_bvarray_free( a->a_vals );
5915 oc_unparse( &bv, NULL, NULL, 1 );
5916 attr_merge_normalize( e, cfAd_oc, bv, NULL );
5917 ber_bvarray_free( bv );
5918 cf_oc_tail = oc_sys_tail;
5920 if ( cf_syn_tail != syn_sys_tail ) {
5921 a = attr_find( e->e_attrs, cfAd_syntax );
5923 if ( a->a_nvals != a->a_vals )
5924 ber_bvarray_free( a->a_nvals );
5925 ber_bvarray_free( a->a_vals );
5930 syn_unparse( &bv, NULL, NULL, 1 );
5931 attr_merge_normalize( e, cfAd_syntax, bv, NULL );
5932 ber_bvarray_free( bv );
5933 cf_syn_tail = syn_sys_tail;
5936 SlapReply rs = {REP_RESULT};
5937 c.ca_private = NULL;
5938 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
5939 &CFOC_SCHEMA, NULL );
5944 ce->ce_private = cfb->cb_config;
5945 cf_at_tail = at_sys_tail;
5946 cf_oc_tail = oc_sys_tail;
5947 cf_om_tail = om_sys_tail;
5948 cf_syn_tail = syn_sys_tail;
5953 static const char *defacl[] = {
5954 NULL, "to", "*", "by", "*", "none", NULL
5958 config_back_db_open( BackendDB *be, ConfigReply *cr )
5960 CfBackInfo *cfb = be->be_private;
5963 CfEntryInfo *ce, *ceparent;
5967 Connection conn = {0};
5968 OperationBuffer opbuf;
5970 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
5971 SlapReply rs = {REP_RESULT};
5972 void *thrctx = NULL;
5974 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
5976 /* If we have no explicitly configured ACLs, don't just use
5977 * the global ACLs. Explicitly deny access to everything.
5979 if ( !be->be_acl ) {
5980 parse_acl(be, "config_back_db_open", 0, 6, (char **)defacl, 0 );
5983 thrctx = ldap_pvt_thread_pool_context();
5984 connection_fake_init( &conn, &opbuf, thrctx );
5987 op->o_tag = LDAP_REQ_ADD;
5988 op->o_callback = &cb;
5989 op->o_bd = &cfb->cb_db;
5990 op->o_dn = op->o_bd->be_rootdn;
5991 op->o_ndn = op->o_bd->be_rootndn;
5993 if ( !cfb->cb_use_ldif ) {
5997 /* If we read the config from back-ldif, do some quick sanity checks */
5998 if ( cfb->cb_got_ldif ) {
5999 return config_check_schema( op, cfb );
6002 /* create root of tree */
6004 c.ca_private = cfb->cb_config;
6006 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
6016 #ifdef SLAPD_MODULES
6017 /* Create Module nodes... */
6018 if ( modpaths.mp_loads ) {
6019 if ( config_build_modules( &c, ceparent, op, &rs ) ){
6025 /* Create schema nodes... cn=schema will contain the hardcoded core
6026 * schema, read-only. Child objects will contain runtime loaded schema
6030 c.ca_private = NULL;
6031 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
6036 ce->ce_private = cfb->cb_config;
6037 cf_at_tail = at_sys_tail;
6038 cf_oc_tail = oc_sys_tail;
6039 cf_om_tail = om_sys_tail;
6040 cf_syn_tail = syn_sys_tail;
6042 /* Create schema nodes for included schema... */
6043 if ( cfb->cb_config->c_kids ) {
6045 c.ca_private = cfb->cb_config->c_kids;
6046 if (config_build_schema_inc( &c, ce, op, &rs )) {
6051 /* Create backend nodes. Skip if they don't provide a cf_table.
6052 * There usually aren't any of these.
6056 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
6057 if (!bi->bi_cf_ocs) {
6058 /* If it only supports the old config mech, complain. */
6059 if ( bi->bi_config ) {
6060 Debug( LDAP_DEBUG_ANY,
6061 "WARNING: No dynamic config support for backend %s.\n",
6062 bi->bi_type, 0, 0 );
6067 if (!bi->bi_private) continue;
6070 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6071 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
6072 if ( rdn.bv_len >= sizeof( c.log ) ) {
6073 /* FIXME: holler ... */ ;
6076 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
6083 /* Create database nodes... */
6084 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
6085 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
6086 for ( i = -1, be = frontendDB ; be;
6087 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
6088 slap_overinfo *oi = NULL;
6090 if ( overlay_is_over( be )) {
6091 oi = be->bd_info->bi_private;
6097 /* If this backend supports the old config mechanism, but not
6098 * the new mech, complain.
6100 if ( !be->be_cf_ocs && bi->bi_db_config ) {
6101 Debug( LDAP_DEBUG_ANY,
6102 "WARNING: No dynamic config support for database %s.\n",
6103 bi->bi_type, 0, 0 );
6107 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6108 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
6110 if ( rdn.bv_len >= sizeof( c.log ) ) {
6111 /* FIXME: holler ... */ ;
6115 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
6121 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd )
6122 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
6123 /* Iterate through overlays */
6128 voidList *vl, *v0 = NULL;
6130 /* overlays are in LIFO order, must reverse stack */
6131 for (on=oi->oi_list; on; on=on->on_next) {
6132 vl = ch_malloc( sizeof( voidList ));
6137 for (j=0; vl; j++,vl=v0) {
6141 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
6142 Debug( LDAP_DEBUG_ANY,
6143 "WARNING: No dynamic config support for overlay %s.\n",
6144 on->on_bi.bi_type, 0, 0 );
6148 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6149 "%s=" SLAP_X_ORDERED_FMT "%s",
6150 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
6151 if ( rdn.bv_len >= sizeof( c.log ) ) {
6152 /* FIXME: holler ... */ ;
6156 oe = config_build_entry( op, &rs, ce, &c, &rdn,
6157 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
6161 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd )
6162 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
6167 ldap_pvt_thread_pool_context_reset( thrctx );
6169 if ( unsupp && cfb->cb_use_ldif ) {
6170 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
6171 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
6178 cfb_free_cffile( ConfigFile *cf )
6182 for (; cf; cf=next) {
6185 cfb_free_cffile( cf->c_kids );
6186 ch_free( cf->c_file.bv_val );
6187 ber_bvarray_free( cf->c_dseFiles );
6193 cfb_free_entries( CfEntryInfo *ce )
6197 for (; ce; ce=next) {
6200 cfb_free_entries( ce->ce_kids );
6201 ce->ce_entry->e_private = NULL;
6202 entry_free( ce->ce_entry );
6208 config_back_db_close( BackendDB *be, ConfigReply *cr )
6210 CfBackInfo *cfb = be->be_private;
6212 cfb_free_entries( cfb->cb_root );
6213 cfb->cb_root = NULL;
6215 if ( cfb->cb_db.bd_info ) {
6216 backend_shutdown( &cfb->cb_db );
6223 config_back_db_destroy( BackendDB *be, ConfigReply *cr )
6225 CfBackInfo *cfb = be->be_private;
6227 cfb_free_cffile( cfb->cb_config );
6229 ch_free( cfdir.bv_val );
6231 avl_free( CfOcTree, NULL );
6233 if ( cfb->cb_db.bd_info ) {
6234 cfb->cb_db.be_suffix = NULL;
6235 cfb->cb_db.be_nsuffix = NULL;
6236 BER_BVZERO( &cfb->cb_db.be_rootdn );
6237 BER_BVZERO( &cfb->cb_db.be_rootndn );
6239 backend_destroy_one( &cfb->cb_db, 0 );
6248 config_back_db_init( BackendDB *be, ConfigReply* cr )
6254 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
6255 cfn = cfb->cb_config;
6256 be->be_private = cfb;
6258 ber_dupbv( &be->be_rootdn, &config_rdn );
6259 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
6260 ber_dupbv( &dn, &be->be_rootdn );
6261 ber_bvarray_add( &be->be_suffix, &dn );
6262 ber_dupbv( &dn, &be->be_rootdn );
6263 ber_bvarray_add( &be->be_nsuffix, &dn );
6265 /* Hide from namingContexts */
6266 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
6268 /* Check ACLs on content of Adds by default */
6269 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_ACL_ADD;
6275 config_back_destroy( BackendInfo *bi )
6277 ldif_must_b64_encode_release();
6282 config_tool_entry_open( BackendDB *be, int mode )
6284 CfBackInfo *cfb = be->be_private;
6285 BackendInfo *bi = cfb->cb_db.bd_info;
6287 if ( bi && bi->bi_tool_entry_open )
6288 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
6295 config_tool_entry_close( BackendDB *be )
6297 CfBackInfo *cfb = be->be_private;
6298 BackendInfo *bi = cfb->cb_db.bd_info;
6300 if ( bi && bi->bi_tool_entry_close )
6301 return bi->bi_tool_entry_close( &cfb->cb_db );
6307 config_tool_entry_first( BackendDB *be )
6309 CfBackInfo *cfb = be->be_private;
6310 BackendInfo *bi = cfb->cb_db.bd_info;
6312 if ( bi && bi->bi_tool_entry_first )
6313 return bi->bi_tool_entry_first( &cfb->cb_db );
6319 config_tool_entry_next( BackendDB *be )
6321 CfBackInfo *cfb = be->be_private;
6322 BackendInfo *bi = cfb->cb_db.bd_info;
6324 if ( bi && bi->bi_tool_entry_next )
6325 return bi->bi_tool_entry_next( &cfb->cb_db );
6331 config_tool_entry_get( BackendDB *be, ID id )
6333 CfBackInfo *cfb = be->be_private;
6334 BackendInfo *bi = cfb->cb_db.bd_info;
6336 if ( bi && bi->bi_tool_entry_get )
6337 return bi->bi_tool_entry_get( &cfb->cb_db, id );
6342 static int entry_put_got_frontend=0;
6343 static int entry_put_got_config=0;
6345 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
6347 CfBackInfo *cfb = be->be_private;
6348 BackendInfo *bi = cfb->cb_db.bd_info;
6350 struct berval rdn, vals[ 2 ];
6352 OperationBuffer opbuf;
6354 Connection conn = {0};
6355 Operation *op = NULL;
6359 /* Create entry for frontend database if it does not exist already */
6360 if ( !entry_put_got_frontend ) {
6361 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
6362 STRLENOF( "olcDatabase" ))) {
6363 if ( strncmp( e->e_nname.bv_val +
6364 STRLENOF( "olcDatabase" ), "={-1}frontend",
6365 STRLENOF( "={-1}frontend" )) &&
6366 strncmp( e->e_nname.bv_val +
6367 STRLENOF( "olcDatabase" ), "=frontend",
6368 STRLENOF( "=frontend" ))) {
6370 vals[1].bv_val = NULL;
6371 memset( &ca, 0, sizeof(ConfigArgs));
6373 ca.bi = frontendDB->bd_info;
6374 ca.be->be_cf_ocs = &CFOC_FRONTEND;
6375 rdn.bv_val = ca.log;
6376 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
6377 "%s=" SLAP_X_ORDERED_FMT "%s",
6378 cfAd_database->ad_cname.bv_val, -1,
6380 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
6381 &CFOC_DATABASE, ca.be->be_cf_ocs );
6382 thrctx = ldap_pvt_thread_pool_context();
6383 connection_fake_init2( &conn, &opbuf, thrctx,0 );
6385 op->o_bd = &cfb->cb_db;
6386 op->o_tag = LDAP_REQ_ADD;
6388 op->o_dn = be->be_rootdn;
6389 op->o_ndn = be->be_rootndn;
6390 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
6391 if ( rc != LDAP_SUCCESS ) {
6392 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
6393 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
6397 if ( ce && bi && bi->bi_tool_entry_put &&
6398 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
6399 entry_put_got_frontend++;
6401 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
6402 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
6406 entry_put_got_frontend++;
6411 /* Create entry for config database if it does not exist already */
6412 if ( !entry_put_got_config && !isFrontend ) {
6413 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
6414 STRLENOF( "olcDatabase" ))) {
6415 if ( strncmp( e->e_nname.bv_val +
6416 STRLENOF( "olcDatabase" ), "={0}config",
6417 STRLENOF( "={0}config" )) &&
6418 strncmp( e->e_nname.bv_val +
6419 STRLENOF( "olcDatabase" ), "=config",
6420 STRLENOF( "=config" )) ) {
6422 vals[1].bv_val = NULL;
6423 memset( &ca, 0, sizeof(ConfigArgs));
6424 ca.be = LDAP_STAILQ_FIRST( &backendDB );
6425 ca.bi = ca.be->bd_info;
6426 rdn.bv_val = ca.log;
6427 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
6428 "%s=" SLAP_X_ORDERED_FMT "%s",
6429 cfAd_database->ad_cname.bv_val, 0,
6431 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
6434 thrctx = ldap_pvt_thread_pool_context();
6435 connection_fake_init2( &conn, &opbuf, thrctx,0 );
6437 op->o_bd = &cfb->cb_db;
6438 op->o_tag = LDAP_REQ_ADD;
6439 op->o_dn = be->be_rootdn;
6440 op->o_ndn = be->be_rootndn;
6443 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
6444 if ( rc != LDAP_SUCCESS ) {
6445 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
6446 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
6449 if (ce && bi && bi->bi_tool_entry_put &&
6450 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
6451 entry_put_got_config++;
6453 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
6454 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
6458 entry_put_got_config++;
6462 if ( bi && bi->bi_tool_entry_put &&
6463 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
6464 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
6471 AttributeDescription **desc;
6473 { "attribute", &cfAd_attr },
6474 { "backend", &cfAd_backend },
6475 { "database", &cfAd_database },
6476 { "include", &cfAd_include },
6477 { "ldapsyntax", &cfAd_syntax },
6478 { "objectclass", &cfAd_oc },
6479 { "objectidentifier", &cfAd_om },
6480 { "overlay", &cfAd_overlay },
6485 * add / delete: all types that may be added or deleted must use an
6486 * X-ORDERED attributeType for their RDN. Adding and deleting entries
6487 * should automatically renumber the index of any siblings as needed,
6488 * so that no gaps in the numbering sequence exist after the add/delete
6490 * What can be added:
6492 * backend objects for backend-specific config directives
6496 * delete: probably no support this time around.
6498 * modrdn: generally not done. Will be invoked automatically by add/
6499 * delete to update numbering sequence. Perform as an explicit operation
6500 * so that the renumbering effect may be replicated. Subtree rename must
6501 * be supported, since renumbering a database will affect all its child
6504 * modify: must be fully supported.
6508 config_back_initialize( BackendInfo *bi )
6510 ConfigTable *ct = config_back_cf_table;
6514 AttributeDescription *ad = NULL;
6516 static char *controls[] = {
6517 LDAP_CONTROL_MANAGEDSAIT,
6521 /* Make sure we don't exceed the bits reserved for userland */
6522 config_check_userland( CFG_LAST );
6524 bi->bi_controls = controls;
6529 bi->bi_destroy = config_back_destroy;
6531 bi->bi_db_init = config_back_db_init;
6532 bi->bi_db_config = 0;
6533 bi->bi_db_open = config_back_db_open;
6534 bi->bi_db_close = config_back_db_close;
6535 bi->bi_db_destroy = config_back_db_destroy;
6537 bi->bi_op_bind = config_back_bind;
6538 bi->bi_op_unbind = 0;
6539 bi->bi_op_search = config_back_search;
6540 bi->bi_op_compare = 0;
6541 bi->bi_op_modify = config_back_modify;
6542 bi->bi_op_modrdn = config_back_modrdn;
6543 bi->bi_op_add = config_back_add;
6544 bi->bi_op_delete = config_back_delete;
6545 bi->bi_op_abandon = 0;
6547 bi->bi_extended = 0;
6549 bi->bi_chk_referrals = 0;
6551 bi->bi_access_allowed = slap_access_allowed;
6553 bi->bi_connection_init = 0;
6554 bi->bi_connection_destroy = 0;
6556 bi->bi_entry_release_rw = config_entry_release;
6557 bi->bi_entry_get_rw = config_back_entry_get;
6559 bi->bi_tool_entry_open = config_tool_entry_open;
6560 bi->bi_tool_entry_close = config_tool_entry_close;
6561 bi->bi_tool_entry_first = config_tool_entry_first;
6562 bi->bi_tool_entry_next = config_tool_entry_next;
6563 bi->bi_tool_entry_get = config_tool_entry_get;
6564 bi->bi_tool_entry_put = config_tool_entry_put;
6567 argv[ 0 ] = "slapd";
6573 for (i=0; OidMacros[i].name; i++ ) {
6574 argv[1] = OidMacros[i].name;
6575 argv[2] = OidMacros[i].oid;
6576 parse_oidm( &ca, 0, NULL );
6579 bi->bi_cf_ocs = cf_ocs;
6581 i = config_register_schema( ct, cf_ocs );
6584 i = slap_str2ad( "olcDatabase", &olcDatabaseDummy[0].ad, &text );
6587 /* setup olcRootPW to be base64-encoded when written in LDIF form;
6588 * basically, we don't care if it fails */
6589 i = slap_str2ad( "olcRootPW", &ad, &text );
6591 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
6592 "warning, unable to get \"olcRootPW\" "
6593 "attribute description: %d: %s\n",
6596 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
6597 ad->ad_type->sat_oid );
6600 /* set up the notable AttributeDescriptions */
6602 for (;ct->name;ct++) {
6603 if (strcmp(ct->name, ads[i].name)) continue;
6604 *ads[i].desc = ct->ad;
6606 if (!ads[i].name) break;