1 /* bconfig.c - the config backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2010 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was originally developed by Howard Chu for inclusion
18 * in OpenLDAP Software.
24 #include <ac/string.h>
28 #include <ac/unistd.h>
33 #include "slapi/slapi.h"
41 #define CONFIG_RDN "cn=config"
42 #define SCHEMA_RDN "cn=schema"
44 static struct berval config_rdn = BER_BVC(CONFIG_RDN);
45 static struct berval schema_rdn = BER_BVC(SCHEMA_RDN);
47 extern int slap_DN_strict; /* dn.c */
50 typedef struct modpath_s {
51 struct modpath_s *mp_next;
52 struct berval mp_path;
56 static ModPaths modpaths, *modlast = &modpaths, *modcur = &modpaths;
59 typedef struct ConfigFile {
60 struct ConfigFile *c_sibs;
61 struct ConfigFile *c_kids;
63 AttributeType *c_at_head, *c_at_tail;
64 ContentRule *c_cr_head, *c_cr_tail;
65 ObjectClass *c_oc_head, *c_oc_tail;
66 OidMacro *c_om_head, *c_om_tail;
67 Syntax *c_syn_head, *c_syn_tail;
72 ConfigFile *cb_config;
74 BackendDB cb_db; /* underlying database */
79 static CfBackInfo cfBackInfo;
81 static char *passwd_salt;
83 static char *logfileName;
84 #ifdef SLAP_AUTH_REWRITE
85 static BerVarray authz_rewrites;
88 static struct berval cfdir;
91 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
92 *cfAd_include, *cfAd_attr, *cfAd_oc, *cfAd_om, *cfAd_syntax;
94 static ConfigFile *cfn;
96 static Avlnode *CfOcTree;
98 /* System schema state */
99 extern AttributeType *at_sys_tail; /* at.c */
100 extern ObjectClass *oc_sys_tail; /* oc.c */
101 extern OidMacro *om_sys_tail; /* oidm.c */
102 extern Syntax *syn_sys_tail; /* syntax.c */
103 static AttributeType *cf_at_tail;
104 static ObjectClass *cf_oc_tail;
105 static OidMacro *cf_om_tail;
106 static Syntax *cf_syn_tail;
108 static int config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca,
109 SlapReply *rs, int *renumber, Operation *op );
111 static int config_check_schema( Operation *op, CfBackInfo *cfb );
113 static ConfigDriver config_fname;
114 static ConfigDriver config_cfdir;
115 static ConfigDriver config_generic;
116 static ConfigDriver config_search_base;
117 static ConfigDriver config_passwd_hash;
118 static ConfigDriver config_schema_dn;
119 static ConfigDriver config_sizelimit;
120 static ConfigDriver config_timelimit;
121 static ConfigDriver config_overlay;
122 static ConfigDriver config_subordinate;
123 static ConfigDriver config_suffix;
124 #ifdef LDAP_TCP_BUFFER
125 static ConfigDriver config_tcp_buffer;
126 #endif /* LDAP_TCP_BUFFER */
127 static ConfigDriver config_rootdn;
128 static ConfigDriver config_rootpw;
129 static ConfigDriver config_restrict;
130 static ConfigDriver config_allows;
131 static ConfigDriver config_disallows;
132 static ConfigDriver config_requires;
133 static ConfigDriver config_security;
134 static ConfigDriver config_referral;
135 static ConfigDriver config_loglevel;
136 static ConfigDriver config_updatedn;
137 static ConfigDriver config_updateref;
138 static ConfigDriver config_extra_attrs;
139 static ConfigDriver config_include;
140 static ConfigDriver config_obsolete;
142 static ConfigDriver config_tls_option;
143 static ConfigDriver config_tls_config;
145 extern ConfigDriver syncrepl_config;
153 CFG_TLS_PROTOCOL_MIN,
205 static OidRec OidMacros[] = {
206 /* OpenLDAProot:1.12.2 */
207 { "OLcfg", "1.3.6.1.4.1.4203.1.12.2" },
208 { "OLcfgAt", "OLcfg:3" },
209 { "OLcfgGlAt", "OLcfgAt:0" },
210 { "OLcfgBkAt", "OLcfgAt:1" },
211 { "OLcfgDbAt", "OLcfgAt:2" },
212 { "OLcfgOvAt", "OLcfgAt:3" },
213 { "OLcfgCtAt", "OLcfgAt:4" }, /* contrib modules */
214 { "OLcfgOc", "OLcfg:4" },
215 { "OLcfgGlOc", "OLcfgOc:0" },
216 { "OLcfgBkOc", "OLcfgOc:1" },
217 { "OLcfgDbOc", "OLcfgOc:2" },
218 { "OLcfgOvOc", "OLcfgOc:3" },
219 { "OLcfgCtOc", "OLcfgOc:4" }, /* contrib modules */
221 /* Syntaxes. We should just start using the standard names and
222 * document that they are predefined and available for users
223 * to reference in their own schema. Defining schema without
224 * OID macros is for masochists...
226 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
227 { "OMsBoolean", "OMsyn:7" },
228 { "OMsDN", "OMsyn:12" },
229 { "OMsDirectoryString", "OMsyn:15" },
230 { "OMsIA5String", "OMsyn:26" },
231 { "OMsInteger", "OMsyn:27" },
232 { "OMsOID", "OMsyn:38" },
233 { "OMsOctetString", "OMsyn:40" },
238 * Backend/Database registry
240 * OLcfg{Bk|Db}{Oc|At}:0 -> common
241 * OLcfg{Bk|Db}{Oc|At}:1 -> back-bdb(/back-hdb)
242 * OLcfg{Bk|Db}{Oc|At}:2 -> back-ldif
243 * OLcfg{Bk|Db}{Oc|At}:3 -> back-ldap
244 * OLcfg{Bk|Db}{Oc|At}:4 -> back-monitor
245 * OLcfg{Bk|Db}{Oc|At}:5 -> back-relay
246 * OLcfg{Bk|Db}{Oc|At}:6 -> back-sql
247 * OLcfg{Bk|Db}{Oc|At}:7 -> back-sock
253 * OLcfgOv{Oc|At}:1 -> syncprov
254 * OLcfgOv{Oc|At}:2 -> pcache
255 * OLcfgOv{Oc|At}:3 -> chain
256 * OLcfgOv{Oc|At}:4 -> accesslog
257 * OLcfgOv{Oc|At}:5 -> valsort
258 * OLcfgOv{Oc|At}:7 -> distproc
259 * OLcfgOv{Oc|At}:8 -> dynlist
260 * OLcfgOv{Oc|At}:9 -> dds
261 * OLcfgOv{Oc|At}:10 -> unique
262 * OLcfgOv{Oc|At}:11 -> refint
263 * OLcfgOv{Oc|At}:12 -> ppolicy
264 * OLcfgOv{Oc|At}:13 -> constraint
265 * OLcfgOv{Oc|At}:14 -> translucent
266 * OLcfgOv{Oc|At}:15 -> auditlog
267 * OLcfgOv{Oc|At}:16 -> rwm
268 * OLcfgOv{Oc|At}:17 -> dyngroup
269 * OLcfgOv{Oc|At}:18 -> memberof
270 * OLcfgOv{Oc|At}:19 -> collect
271 * OLcfgOv{Oc|At}:20 -> retcode
272 * OLcfgOv{Oc|At}:21 -> sssvlv
275 /* alphabetical ordering */
277 static ConfigTable config_back_cf_table[] = {
278 /* This attr is read-only */
279 { "", "", 0, 0, 0, ARG_MAGIC,
280 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
281 "DESC 'File for slapd configuration directives' "
282 "EQUALITY caseIgnoreMatch "
283 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
284 { "", "", 0, 0, 0, ARG_MAGIC,
285 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
286 "DESC 'Directory for slapd configuration backend' "
287 "EQUALITY caseIgnoreMatch "
288 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
289 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
290 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
291 "DESC 'Access Control List' "
292 "EQUALITY caseIgnoreMatch "
293 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
294 { "add_content_acl", NULL, 0, 0, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_ACL_ADD,
295 &config_generic, "( OLcfgGlAt:86 NAME 'olcAddContentAcl' "
296 "DESC 'Check ACLs against content of Add ops' "
297 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
298 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
299 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
300 "DESC 'Allowed set of deprecated features' "
301 "EQUALITY caseIgnoreMatch "
302 "SYNTAX OMsDirectoryString )", NULL, NULL },
303 { "argsfile", "file", 2, 2, 0, ARG_STRING,
304 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
305 "DESC 'File for slapd command line options' "
306 "EQUALITY caseIgnoreMatch "
307 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
308 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
309 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
310 "EQUALITY caseIgnoreMatch "
311 "SYNTAX OMsDirectoryString )", NULL, NULL },
312 { "attribute", "attribute", 2, 0, STRLENOF( "attribute" ),
313 ARG_PAREN|ARG_MAGIC|CFG_ATTR,
314 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
315 "DESC 'OpenLDAP attributeTypes' "
316 "EQUALITY caseIgnoreMatch "
317 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
319 { "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
320 #ifdef SLAP_AUTH_REWRITE
321 ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
325 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
326 "EQUALITY caseIgnoreMatch "
327 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
328 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
329 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
330 "EQUALITY caseIgnoreMatch "
331 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
332 { "authz-regexp", "regexp> <DN", 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
333 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
334 "EQUALITY caseIgnoreMatch "
335 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
336 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
337 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
338 "DESC 'A type of backend' "
339 "EQUALITY caseIgnoreMatch "
340 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
342 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
343 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
344 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
345 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
346 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
347 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
348 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
349 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
350 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
351 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
352 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
353 "DESC 'The backend type for a database instance' "
354 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
355 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
356 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
357 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
358 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
359 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
360 "EQUALITY caseIgnoreMatch "
361 "SYNTAX OMsDirectoryString )", NULL, NULL },
362 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
363 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
364 "DESC 'OpenLDAP DIT content rules' "
365 "EQUALITY caseIgnoreMatch "
366 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
368 { "extra_attrs", "attrlist", 2, 2, 0, ARG_DB|ARG_MAGIC,
369 &config_extra_attrs, "( OLcfgDbAt:0.20 NAME 'olcExtraAttrs' "
370 "EQUALITY caseIgnoreMatch "
371 "SYNTAX OMsDirectoryString )", NULL, NULL },
372 { "gentlehup", "on|off", 2, 2, 0,
374 ARG_ON_OFF, &global_gentlehup,
378 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
379 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
380 { "hidden", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_HIDDEN,
381 &config_generic, "( OLcfgDbAt:0.17 NAME 'olcHidden' "
382 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
383 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
384 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
385 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
386 { "include", "file", 2, 2, 0, ARG_MAGIC,
387 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
388 "SUP labeledURI )", NULL, NULL },
389 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
390 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
391 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
392 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_UINT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
393 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
394 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
395 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
396 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
397 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
398 { "index_substr_any_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
399 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
400 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
401 { "index_intlen", "len", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_IX_INTLEN,
402 &config_generic, "( OLcfgGlAt:84 NAME 'olcIndexIntLen' "
403 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
404 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
405 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
406 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
407 { "ldapsyntax", "syntax", 2, 0, 0,
408 ARG_PAREN|ARG_MAGIC|CFG_SYNTAX,
409 &config_generic, "( OLcfgGlAt:85 NAME 'olcLdapSyntaxes' "
410 "DESC 'OpenLDAP ldapSyntax' "
411 "EQUALITY caseIgnoreMatch "
412 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
414 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
415 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
416 "EQUALITY caseIgnoreMatch "
417 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
418 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
419 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
420 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
421 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
422 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
423 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
424 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
425 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
426 "EQUALITY caseIgnoreMatch "
427 "SYNTAX OMsDirectoryString )", NULL, NULL },
428 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
429 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
430 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
431 { "mirrormode", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_MIRRORMODE,
432 &config_generic, "( OLcfgDbAt:0.16 NAME 'olcMirrorMode' "
433 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
434 { "moduleload", "file", 2, 0, 0,
436 ARG_MAGIC|CFG_MODLOAD|ARG_NO_DELETE, &config_generic,
440 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
441 "EQUALITY caseIgnoreMatch "
442 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
443 { "modulepath", "path", 2, 2, 0,
445 ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
449 "( OLcfgGlAt:31 NAME 'olcModulePath' "
450 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
451 { "monitoring", "TRUE|FALSE", 2, 2, 0,
452 ARG_MAGIC|CFG_MONITORING|ARG_DB|ARG_ON_OFF, &config_generic,
453 "( OLcfgDbAt:0.18 NAME 'olcMonitoring' "
454 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
455 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
456 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
457 "DESC 'OpenLDAP object classes' "
458 "EQUALITY caseIgnoreMatch "
459 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
461 { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
462 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
463 "EQUALITY caseIgnoreMatch "
464 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
465 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
466 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
467 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
468 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
469 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
470 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
471 { "password-hash", "hash", 2, 0, 0, ARG_MAGIC,
472 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
473 "EQUALITY caseIgnoreMatch "
474 "SYNTAX OMsDirectoryString )", NULL, NULL },
475 { "pidfile", "file", 2, 2, 0, ARG_STRING,
476 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
477 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
478 { "plugin", NULL, 0, 0, 0,
480 ARG_MAGIC|CFG_PLUGIN, &config_generic,
484 "( OLcfgGlAt:38 NAME 'olcPlugin' "
485 "EQUALITY caseIgnoreMatch "
486 "SYNTAX OMsDirectoryString )", NULL, NULL },
487 { "pluginlog", "filename", 2, 2, 0,
489 ARG_STRING, &slapi_log_file,
493 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
494 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
495 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
496 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
497 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
498 { "referral", "url", 2, 2, 0, ARG_MAGIC,
499 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
500 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
501 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
502 &config_obsolete, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
503 "EQUALITY caseIgnoreMatch "
504 "SUP labeledURI X-ORDERED 'VALUES' )", NULL, NULL },
505 { "replica-argsfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
506 &config_obsolete, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
507 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
508 { "replica-pidfile", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
509 &config_obsolete, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
510 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
511 { "replicationInterval", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC,
512 &config_obsolete, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
513 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
514 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC,
515 &config_obsolete, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
516 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
517 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
518 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
519 "EQUALITY caseIgnoreMatch "
520 "SYNTAX OMsDirectoryString )", NULL, NULL },
521 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
522 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
523 "EQUALITY caseIgnoreMatch "
524 "SYNTAX OMsDirectoryString )", NULL, NULL },
525 { "reverse-lookup", "on|off", 2, 2, 0,
526 #ifdef SLAPD_RLOOKUPS
527 ARG_ON_OFF, &use_reverse_lookup,
531 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
532 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
533 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
534 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
535 "EQUALITY distinguishedNameMatch "
536 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
537 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
538 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
539 "EQUALITY caseIgnoreMatch "
540 "SYNTAX OMsDirectoryString )", NULL, NULL },
541 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
542 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
543 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
544 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
545 &config_generic, NULL, NULL, NULL },
546 { "sasl-auxprops", NULL, 2, 0, 0,
547 #ifdef HAVE_CYRUS_SASL
548 ARG_STRING|ARG_UNIQUE, &slap_sasl_auxprops,
552 "( OLcfgGlAt:89 NAME 'olcSaslAuxprops' "
553 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
554 { "sasl-auxprops-dontusecopy", NULL, 2, 0, 0,
555 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
556 ARG_MAGIC|CFG_AZDUC, &config_generic,
560 "( OLcfgGlAt:91 NAME 'olcSaslAuxpropsDontUseCopy' "
561 "EQUALITY caseIgnoreMatch "
562 "SYNTAX OMsDirectoryString )", NULL, NULL },
563 { "sasl-auxprops-dontusecopy-ignore", "true|FALSE", 2, 0, 0,
564 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
565 ARG_ON_OFF|CFG_AZDUC_IGNORE, &slap_dontUseCopy_ignore,
569 "( OLcfgGlAt:92 NAME 'olcSaslAuxpropsDontUseCopyIgnore' "
570 "EQUALITY booleanMatch "
571 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
572 { "sasl-host", "host", 2, 2, 0,
573 #ifdef HAVE_CYRUS_SASL
574 ARG_STRING|ARG_UNIQUE, &sasl_host,
578 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
579 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
580 { "sasl-realm", "realm", 2, 2, 0,
581 #ifdef HAVE_CYRUS_SASL
582 ARG_STRING|ARG_UNIQUE, &global_realm,
586 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
587 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
588 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
589 &config_generic, NULL, NULL, NULL },
590 { "sasl-secprops", "properties", 2, 2, 0,
591 #ifdef HAVE_CYRUS_SASL
592 ARG_MAGIC|CFG_SASLSECP, &config_generic,
596 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
597 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
598 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
599 &config_generic, NULL, NULL, NULL },
600 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
601 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
602 "EQUALITY distinguishedNameMatch "
603 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
604 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
605 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
606 "EQUALITY caseIgnoreMatch "
607 "SYNTAX OMsDirectoryString )", NULL, NULL },
608 { "serverID", "number> <[URI]", 2, 3, 0, ARG_MAGIC|CFG_SERVERID,
609 &config_generic, "( OLcfgGlAt:81 NAME 'olcServerID' "
610 "EQUALITY caseIgnoreMatch "
611 "SYNTAX OMsDirectoryString )", NULL, NULL },
612 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
613 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
614 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
615 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
616 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
617 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
618 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
619 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
620 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
621 { "sortvals", "attr", 2, 0, 0, ARG_MAGIC|CFG_SORTVALS,
622 &config_generic, "( OLcfgGlAt:83 NAME 'olcSortVals' "
623 "DESC 'Attributes whose values will always be sorted' "
624 "EQUALITY caseIgnoreMatch "
625 "SYNTAX OMsDirectoryString )", NULL, NULL },
626 { "subordinate", "[advertise]", 1, 2, 0, ARG_DB|ARG_MAGIC,
627 &config_subordinate, "( OLcfgDbAt:0.15 NAME 'olcSubordinate' "
628 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
629 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
630 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
631 "EQUALITY distinguishedNameMatch "
632 "SYNTAX OMsDN )", NULL, NULL },
633 { "sync_use_subentry", NULL, 0, 0, 0, ARG_ON_OFF|ARG_DB|ARG_MAGIC|CFG_SYNC_SUBENTRY,
634 &config_generic, "( OLcfgDbAt:0.19 NAME 'olcSyncUseSubentry' "
635 "DESC 'Store sync context in a subentry' "
636 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
637 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
638 &syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
639 "EQUALITY caseIgnoreMatch "
640 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
641 { "tcp-buffer", "[listener=<listener>] [{read|write}=]size", 0, 0, 0,
642 #ifndef LDAP_TCP_BUFFER
644 #else /* LDAP_TCP_BUFFER */
645 ARG_MAGIC, &config_tcp_buffer,
646 #endif /* LDAP_TCP_BUFFER */
647 "( OLcfgGlAt:90 NAME 'olcTCPBuffer' "
648 "DESC 'Custom TCP buffer size' "
649 "SYNTAX OMsDirectoryString )", NULL, NULL },
650 { "threads", "count", 2, 2, 0,
654 ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic,
656 "( OLcfgGlAt:66 NAME 'olcThreads' "
657 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
658 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
659 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
660 "SYNTAX OMsDirectoryString )", NULL, NULL },
661 { "TLSCACertificateFile", NULL, 0, 0, 0,
663 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
667 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
668 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
669 { "TLSCACertificatePath", NULL, 0, 0, 0,
671 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
675 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
676 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
677 { "TLSCertificateFile", NULL, 0, 0, 0,
679 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
683 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
684 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
685 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
687 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
691 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
692 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
693 { "TLSCipherSuite", NULL, 0, 0, 0,
695 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
699 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
700 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
701 { "TLSCRLCheck", NULL, 0, 0, 0,
702 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
703 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
707 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
708 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
709 { "TLSCRLFile", NULL, 0, 0, 0,
710 #if defined(HAVE_GNUTLS)
711 CFG_TLS_CRL_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
715 "( OLcfgGlAt:82 NAME 'olcTLSCRLFile' "
716 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
717 { "TLSRandFile", NULL, 0, 0, 0,
719 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
723 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
724 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
725 { "TLSVerifyClient", NULL, 0, 0, 0,
727 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
731 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
732 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
733 { "TLSDHParamFile", NULL, 0, 0, 0,
735 CFG_TLS_DH_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
739 "( OLcfgGlAt:77 NAME 'olcTLSDHParamFile' "
740 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
741 { "TLSProtocolMin", NULL, 0, 0, 0,
743 CFG_TLS_PROTOCOL_MIN|ARG_STRING|ARG_MAGIC, &config_tls_config,
747 "( OLcfgGlAt:87 NAME 'olcTLSProtocolMin' "
748 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
749 { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS,
750 &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' "
751 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
752 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
753 NULL, NULL, NULL, NULL },
754 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
755 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
756 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
757 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
758 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
759 "EQUALITY caseIgnoreMatch "
760 "SUP labeledURI )", NULL, NULL },
761 { "writetimeout", "timeout", 2, 2, 0, ARG_INT,
762 &global_writetimeout, "( OLcfgGlAt:88 NAME 'olcWriteTimeout' "
763 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
764 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
765 NULL, NULL, NULL, NULL }
768 /* Need to no-op this keyword for dynamic config */
769 ConfigTable olcDatabaseDummy[] = {
770 { "", "", 0, 0, 0, ARG_IGNORED,
771 NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
772 "DESC 'The backend type for a database instance' "
773 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
774 { NULL, NULL, 0, 0, 0, ARG_IGNORED }
777 /* Routines to check if a child can be added to this type */
778 static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
779 cfAddBackend, cfAddModule, cfAddOverlay;
781 /* NOTE: be careful when defining array members
782 * that can be conditionally compiled */
783 #define CFOC_GLOBAL cf_ocs[1]
784 #define CFOC_SCHEMA cf_ocs[2]
785 #define CFOC_BACKEND cf_ocs[3]
786 #define CFOC_DATABASE cf_ocs[4]
787 #define CFOC_OVERLAY cf_ocs[5]
788 #define CFOC_INCLUDE cf_ocs[6]
789 #define CFOC_FRONTEND cf_ocs[7]
791 #define CFOC_MODULE cf_ocs[8]
792 #endif /* SLAPD_MODULES */
794 static ConfigOCs cf_ocs[] = {
797 "DESC 'OpenLDAP configuration object' "
798 "ABSTRACT SUP top )", Cft_Abstract, NULL },
801 "DESC 'OpenLDAP Global configuration options' "
802 "SUP olcConfig STRUCTURAL "
803 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
804 "olcAttributeOptions $ olcAuthIDRewrite $ "
805 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
806 "olcConnMaxPending $ olcConnMaxPendingAuth $ "
807 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
808 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
809 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcIndexIntLen $ "
810 "olcLocalSSF $ olcLogFile $ olcLogLevel $ "
811 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
812 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
813 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
815 "olcSaslAuxprops $ olcSaslAuxpropsDontUseCopy $ olcSaslAuxpropsDontUseCopyIgnore $ "
816 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
817 "olcSecurity $ olcServerID $ olcSizeLimit $ "
818 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ "
820 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
821 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
822 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
823 "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamFile $ "
824 "olcTLSCRLFile $ olcToolThreads $ olcWriteTimeout $ "
825 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
826 "olcDitContentRules $ olcLdapSyntaxes ) )", Cft_Global },
828 "NAME 'olcSchemaConfig' "
829 "DESC 'OpenLDAP schema object' "
830 "SUP olcConfig STRUCTURAL "
831 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
832 "olcObjectClasses $ olcDitContentRules $ olcLdapSyntaxes ) )",
833 Cft_Schema, NULL, cfAddSchema },
835 "NAME 'olcBackendConfig' "
836 "DESC 'OpenLDAP Backend-specific options' "
837 "SUP olcConfig STRUCTURAL "
838 "MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
840 "NAME 'olcDatabaseConfig' "
841 "DESC 'OpenLDAP Database-specific options' "
842 "SUP olcConfig STRUCTURAL "
844 "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
845 "olcAddContentAcl $ olcLastMod $ olcLimits $ "
846 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
847 "olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
848 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
849 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncUseSubentry $ olcSyncrepl $ "
850 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef $ olcMirrorMode $ "
851 "olcMonitoring $ olcExtraAttrs ) )",
852 Cft_Database, NULL, cfAddDatabase },
854 "NAME 'olcOverlayConfig' "
855 "DESC 'OpenLDAP Overlay-specific options' "
856 "SUP olcConfig STRUCTURAL "
857 "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
859 "NAME 'olcIncludeFile' "
860 "DESC 'OpenLDAP configuration include file' "
861 "SUP olcConfig STRUCTURAL "
863 "MAY ( cn $ olcRootDSE ) )",
864 /* Used to be Cft_Include, that def has been removed */
865 Cft_Abstract, NULL, cfAddInclude },
866 /* This should be STRUCTURAL like all the other database classes, but
867 * that would mean inheriting all of the olcDatabaseConfig attributes,
868 * which causes them to be merged twice in config_build_entry.
871 "NAME 'olcFrontendConfig' "
872 "DESC 'OpenLDAP frontend configuration' "
874 "MAY ( olcDefaultSearchBase $ olcPasswordHash $ olcSortVals ) )",
875 Cft_Database, NULL, NULL },
878 "NAME 'olcModuleList' "
879 "DESC 'OpenLDAP dynamic module info' "
880 "SUP olcConfig STRUCTURAL "
881 "MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
882 Cft_Module, NULL, cfAddModule },
887 typedef struct ServerID {
888 struct ServerID *si_next;
889 struct berval si_url;
893 static ServerID *sid_list;
895 typedef struct voidList {
896 struct voidList *vl_next;
900 typedef struct ADlist {
901 struct ADlist *al_next;
902 AttributeDescription *al_desc;
905 static ADlist *sortVals;
908 config_generic(ConfigArgs *c) {
911 if ( c->op == SLAP_CONFIG_EMIT ) {
915 c->value_int = ldap_pvt_thread_get_concurrency();
918 c->value_int = connection_pool_max;
921 c->value_int = slap_tool_thread_max;
925 c->value_string = ch_strdup( passwd_salt );
930 if ( c->be->be_limits ) {
934 for ( i=0; c->be->be_limits[i]; i++ ) {
935 bv.bv_len = snprintf( buf, sizeof( buf ), SLAP_X_ORDERED_FMT, i );
936 if ( bv.bv_len >= sizeof( buf ) ) {
937 ber_bvarray_free_x( c->rvalue_vals, NULL );
938 c->rvalue_vals = NULL;
942 bv.bv_val = buf + bv.bv_len;
943 limits_unparse( c->be->be_limits[i], &bv,
944 sizeof( buf ) - ( bv.bv_val - buf ) );
945 bv.bv_len += bv.bv_val - buf;
947 value_add_one( &c->rvalue_vals, &bv );
950 if ( !c->rvalue_vals ) rc = 1;
953 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_READONLY);
956 c->value_string = ch_strdup( slap_sasl_getpolicy());
959 slap_sasl_regexp_unparse( &c->rvalue_vals );
960 if ( !c->rvalue_vals ) rc = 1;
962 #ifdef HAVE_CYRUS_SASL
963 #ifdef SLAP_AUXPROP_DONTUSECOPY
965 static int duc_done = 0;
967 /* take the opportunity to initialize with known values */
969 struct berval duc[] = { BER_BVC("cmusaslsecretOTP"), BER_BVNULL };
972 for ( i = 0; !BER_BVISNULL( &duc[ i ] ); i++ ) {
973 const char *text = NULL;
974 AttributeDescription *ad = NULL;
976 if ( slap_bv2ad( &duc[ i ], &ad, &text ) == LDAP_SUCCESS ) {
978 if ( slap_dontUseCopy_propnames ) {
981 for ( j = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ j ] ); j++ ) {
982 if ( bvmatch( &slap_dontUseCopy_propnames[ j ], &ad->ad_cname ) ) {
989 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
997 if ( slap_dontUseCopy_propnames != NULL ) {
998 ber_bvarray_dup_x( &c->rvalue_vals, slap_dontUseCopy_propnames, NULL );
1003 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1004 case CFG_SASLSECP: {
1005 struct berval bv = BER_BVNULL;
1006 slap_sasl_secprops_unparse( &bv );
1007 if ( !BER_BVISNULL( &bv )) {
1008 ber_bvarray_add( &c->rvalue_vals, &bv );
1016 c->value_int = c->be->be_max_deref_depth;
1019 if ( SLAP_DBHIDDEN( c->be )) {
1026 ConfigFile *cf = c->ca_private;
1028 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1029 else if ( cf->c_om_head )
1030 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
1032 if ( !c->rvalue_vals )
1037 ad_unparse_options( &c->rvalue_vals );
1040 ConfigFile *cf = c->ca_private;
1042 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1043 else if ( cf->c_oc_head )
1044 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
1046 if ( !c->rvalue_vals )
1051 ConfigFile *cf = c->ca_private;
1053 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1054 else if ( cf->c_at_head )
1055 at_unparse( &c->rvalue_vals, cf->c_at_head,
1057 if ( !c->rvalue_vals )
1062 ConfigFile *cf = c->ca_private;
1064 syn_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1065 else if ( cf->c_syn_head )
1066 syn_unparse( &c->rvalue_vals, cf->c_syn_head,
1067 cf->c_syn_tail, 0 );
1068 if ( !c->rvalue_vals )
1073 ConfigFile *cf = c->ca_private;
1075 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
1076 else if ( cf->c_cr_head )
1077 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
1079 if ( !c->rvalue_vals )
1086 char *src, *dst, ibuf[11];
1087 struct berval bv, abv;
1088 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
1089 abv.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1090 if ( abv.bv_len >= sizeof( ibuf ) ) {
1091 ber_bvarray_free_x( c->rvalue_vals, NULL );
1092 c->rvalue_vals = NULL;
1096 acl_unparse( a, &bv );
1097 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
1098 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
1099 /* Turn TAB / EOL into plain space */
1100 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
1101 if (isspace((unsigned char)*src)) *dst++ = ' ';
1105 if (dst[-1] == ' ') {
1109 abv.bv_len = dst - abv.bv_val;
1110 ber_bvarray_add( &c->rvalue_vals, &abv );
1116 c->value_int = (SLAP_DBACL_ADD(c->be) != 0);
1119 ConfigFile *cf = c->ca_private;
1120 if ( cf->c_dseFiles ) {
1121 value_add( &c->rvalue_vals, cf->c_dseFiles );
1132 for ( si = sid_list; si; si=si->si_next ) {
1133 assert( si->si_num >= 0 && si->si_num <= SLAP_SYNC_SID_MAX );
1134 if ( !BER_BVISEMPTY( &si->si_url )) {
1135 bv.bv_len = si->si_url.bv_len + 6;
1136 bv.bv_val = ch_malloc( bv.bv_len );
1137 bv.bv_len = sprintf( bv.bv_val, "%d %s", si->si_num,
1138 si->si_url.bv_val );
1139 ber_bvarray_add( &c->rvalue_vals, &bv );
1143 bv.bv_len = sprintf( buf, "%d", si->si_num );
1144 value_add_one( &c->rvalue_vals, &bv );
1153 c->value_string = ch_strdup( logfileName );
1158 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
1160 case CFG_SYNC_SUBENTRY:
1161 c->value_int = (SLAP_SYNC_SUBENTRY(c->be) != 0);
1163 case CFG_MIRRORMODE:
1164 if ( SLAP_SHADOW(c->be))
1165 c->value_int = (SLAP_SINGLE_SHADOW(c->be) == 0);
1169 case CFG_MONITORING:
1170 c->value_int = (SLAP_DBMONITORING(c->be) != 0);
1172 case CFG_SSTR_IF_MAX:
1173 c->value_uint = index_substr_if_maxlen;
1175 case CFG_SSTR_IF_MIN:
1176 c->value_uint = index_substr_if_minlen;
1179 c->value_int = index_intlen;
1181 case CFG_SORTVALS: {
1184 for ( sv = sortVals; sv; sv = sv->al_next ) {
1185 value_add_one( &c->rvalue_vals, &sv->al_desc->ad_cname );
1189 #ifdef SLAPD_MODULES
1191 ModPaths *mp = c->ca_private;
1194 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
1197 bv.bv_len = snprintf( bv.bv_val, sizeof( c->log ),
1198 SLAP_X_ORDERED_FMT "%s", i,
1199 mp->mp_loads[i].bv_val );
1200 if ( bv.bv_len >= sizeof( c->log ) ) {
1201 ber_bvarray_free_x( c->rvalue_vals, NULL );
1202 c->rvalue_vals = NULL;
1205 value_add_one( &c->rvalue_vals, &bv );
1209 rc = c->rvalue_vals ? 0 : 1;
1213 ModPaths *mp = c->ca_private;
1214 if ( !BER_BVISNULL( &mp->mp_path ))
1215 value_add_one( &c->rvalue_vals, &mp->mp_path );
1217 rc = c->rvalue_vals ? 0 : 1;
1223 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
1224 if ( !c->rvalue_vals ) rc = 1;
1227 #ifdef SLAP_AUTH_REWRITE
1229 if ( authz_rewrites ) {
1230 struct berval bv, idx;
1235 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
1236 idx.bv_len = snprintf( idx.bv_val, sizeof( ibuf ), SLAP_X_ORDERED_FMT, i );
1237 if ( idx.bv_len >= sizeof( ibuf ) ) {
1238 ber_bvarray_free_x( c->rvalue_vals, NULL );
1239 c->rvalue_vals = NULL;
1242 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
1243 bv.bv_val = ch_malloc( bv.bv_len + 1 );
1244 AC_MEMCPY( bv.bv_val, idx.bv_val, idx.bv_len );
1245 AC_MEMCPY( &bv.bv_val[ idx.bv_len ],
1246 authz_rewrites[i].bv_val,
1247 authz_rewrites[i].bv_len + 1 );
1248 ber_bvarray_add( &c->rvalue_vals, &bv );
1251 if ( !c->rvalue_vals ) rc = 1;
1258 } else if ( c->op == LDAP_MOD_DELETE ) {
1261 /* single-valued attrs, no-ops */
1269 case CFG_MIRRORMODE:
1270 case CFG_MONITORING:
1272 case CFG_SSTR_IF_MAX:
1273 case CFG_SSTR_IF_MIN:
1275 case CFG_SYNC_SUBENTRY:
1278 /* no-ops, requires slapd restart */
1283 snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
1286 #if defined(HAVE_CYRUS_SASL) && defined(SLAP_AUXPROP_DONTUSECOPY)
1288 if ( c->valx < 0 ) {
1289 if ( slap_dontUseCopy_propnames != NULL ) {
1290 ber_bvarray_free( slap_dontUseCopy_propnames );
1291 slap_dontUseCopy_propnames = NULL;
1297 if ( slap_dontUseCopy_propnames == NULL ) {
1302 for ( i = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i ] ) && i < c->valx; i++ );
1303 if ( i < c->valx ) {
1307 ber_memfree( slap_dontUseCopy_propnames[ i ].bv_val );
1308 for ( ; !BER_BVISNULL( &slap_dontUseCopy_propnames[ i + 1 ] ); i++ ) {
1309 slap_dontUseCopy_propnames[ i ] = slap_dontUseCopy_propnames[ i + 1 ];
1311 BER_BVZERO( &slap_dontUseCopy_propnames[ i ] );
1314 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1316 ch_free( passwd_salt );
1321 ch_free( logfileName );
1329 case CFG_SERVERID: {
1330 ServerID *si, **sip;
1332 for ( i=0, si = sid_list, sip = &sid_list;
1333 si; si = *sip, i++ ) {
1334 if ( c->valx == -1 || i == c->valx ) {
1346 c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
1350 index_intlen = SLAP_INDEX_INTLEN_DEFAULT;
1351 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1352 SLAP_INDEX_INTLEN_DEFAULT );
1356 if ( c->valx < 0 ) {
1357 acl_destroy( c->be->be_acl );
1358 c->be->be_acl = NULL;
1361 AccessControl **prev, *a;
1363 for (i=0, prev = &c->be->be_acl; i < c->valx;
1366 prev = &a->acl_next;
1369 *prev = a->acl_next;
1376 /* Can be NULL when undoing a failed add */
1377 if ( c->ca_entry ) {
1378 ce = c->ca_entry->e_private;
1379 /* can't modify the hardcoded schema */
1380 if ( ce->ce_parent->ce_type == Cft_Global )
1384 cfn = c->ca_private;
1385 if ( c->valx < 0 ) {
1388 for( oc = cfn->c_oc_head; oc; oc_next( &oc )) {
1390 if ( oc == cfn->c_oc_tail )
1393 cfn->c_oc_head = cfn->c_oc_tail = NULL;
1395 ObjectClass *oc, *prev = NULL;
1397 for ( i=0, oc=cfn->c_oc_head; i<c->valx; i++) {
1402 if ( cfn->c_oc_tail == oc ) {
1403 cfn->c_oc_tail = prev;
1405 if ( cfn->c_oc_head == oc ) {
1407 cfn->c_oc_head = oc;
1414 /* Can be NULL when undoing a failed add */
1415 if ( c->ca_entry ) {
1416 ce = c->ca_entry->e_private;
1417 /* can't modify the hardcoded schema */
1418 if ( ce->ce_parent->ce_type == Cft_Global )
1422 cfn = c->ca_private;
1423 if ( c->valx < 0 ) {
1426 for( at = cfn->c_at_head; at; at_next( &at )) {
1428 if ( at == cfn->c_at_tail )
1431 cfn->c_at_head = cfn->c_at_tail = NULL;
1433 AttributeType *at, *prev = NULL;
1435 for ( i=0, at=cfn->c_at_head; i<c->valx; i++) {
1440 if ( cfn->c_at_tail == at ) {
1441 cfn->c_at_tail = prev;
1443 if ( cfn->c_at_head == at ) {
1445 cfn->c_at_head = at;
1452 /* Can be NULL when undoing a failed add */
1453 if ( c->ca_entry ) {
1454 ce = c->ca_entry->e_private;
1455 /* can't modify the hardcoded schema */
1456 if ( ce->ce_parent->ce_type == Cft_Global )
1460 cfn = c->ca_private;
1461 if ( c->valx < 0 ) {
1464 for( syn = cfn->c_syn_head; syn; syn_next( &syn )) {
1466 if ( syn == cfn->c_syn_tail )
1469 cfn->c_syn_head = cfn->c_syn_tail = NULL;
1471 Syntax *syn, *prev = NULL;
1473 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++) {
1478 if ( cfn->c_syn_tail == syn ) {
1479 cfn->c_syn_tail = prev;
1481 if ( cfn->c_syn_head == syn ) {
1483 cfn->c_syn_head = syn;
1488 if ( c->valx < 0 ) {
1490 for ( sv = sortVals; sv; sv = sortVals ) {
1491 sortVals = sv->al_next;
1492 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1499 for ( prev = &sortVals, sv = sortVals; i < c->valx; i++ ) {
1500 prev = &sv->al_next;
1503 sv->al_desc->ad_type->sat_flags &= ~SLAP_AT_SORTED_VAL;
1504 *prev = sv->al_next;
1510 /* FIXME: there is no limits_free function */
1511 if ( c->valx < 0 ) {
1512 limits_destroy( c->be->be_limits );
1513 c->be->be_limits = NULL;
1518 if ( c->be->be_limits ) {
1519 for ( num = 0; c->be->be_limits[ num ]; num++ )
1523 if ( c->valx >= num ) {
1528 limits_destroy( c->be->be_limits );
1529 c->be->be_limits = NULL;
1532 limits_free_one( c->be->be_limits[ c->valx ] );
1534 for ( cnt = c->valx; cnt < num; cnt++ ) {
1535 c->be->be_limits[ cnt ] = c->be->be_limits[ cnt + 1 ];
1542 /* FIXME: there is no ad_option_free function */
1544 /* FIXME: there is no way to remove attributes added by
1558 if(!(c->bi = backend_info(c->argv[1]))) {
1559 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1560 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
1561 c->log, c->cr_msg, c->argv[1] );
1568 /* NOTE: config is always the first backend!
1570 if ( !strcasecmp( c->argv[1], "config" )) {
1571 c->be = LDAP_STAILQ_FIRST(&backendDB);
1572 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
1575 c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply);
1577 if ( c->cr_msg[0] == 0 )
1578 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> failed init", c->argv[0] );
1579 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n", c->log, c->cr_msg, c->argv[1] );
1586 ldap_pvt_thread_set_concurrency(c->value_int);
1590 if ( c->value_int < 2 ) {
1591 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1592 "threads=%d smaller than minimum value 2",
1594 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1595 c->log, c->cr_msg, 0 );
1598 } else if ( c->value_int > 2 * SLAP_MAX_WORKER_THREADS ) {
1599 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1600 "warning, threads=%d larger than twice the default (2*%d=%d); YMMV",
1601 c->value_int, SLAP_MAX_WORKER_THREADS, 2 * SLAP_MAX_WORKER_THREADS );
1602 Debug(LDAP_DEBUG_ANY, "%s: %s.\n",
1603 c->log, c->cr_msg, 0 );
1605 if ( slapMode & SLAP_SERVER_MODE )
1606 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1607 connection_pool_max = c->value_int; /* save for reference */
1611 if ( slapMode & SLAP_TOOL_MODE )
1612 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
1613 slap_tool_thread_max = c->value_int; /* save for reference */
1617 if ( passwd_salt ) ch_free( passwd_salt );
1618 passwd_salt = c->value_string;
1619 lutil_salt_format(passwd_salt);
1623 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
1629 c->be->be_restrictops |= SLAP_RESTRICT_READONLY;
1631 c->be->be_restrictops &= ~SLAP_RESTRICT_READONLY;
1635 ch_free(c->value_string);
1636 if (slap_sasl_setpolicy( c->argv[1] )) {
1637 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
1638 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
1639 c->log, c->cr_msg, c->argv[1] );
1645 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
1649 #ifdef HAVE_CYRUS_SASL
1650 #ifdef SLAP_AUXPROP_DONTUSECOPY
1654 for ( arg = 1; arg < c->argc; arg++ ) {
1655 int duplicate = 0, err;
1656 AttributeDescription *ad = NULL;
1657 const char *text = NULL;
1659 err = slap_str2ad( c->argv[ arg ], &ad, &text );
1660 if ( err != LDAP_SUCCESS ) {
1661 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") unknown (err=%d \"%s\"; ignored)",
1662 c->argv[0], arg, c->argv[ arg ], err, text );
1663 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1664 c->log, c->cr_msg, 0 );
1667 if ( slap_dontUseCopy_propnames != NULL ) {
1668 for ( cnt = 0; !BER_BVISNULL( &slap_dontUseCopy_propnames[ cnt ] ); cnt++ ) {
1669 if ( bvmatch( &slap_dontUseCopy_propnames[ cnt ], &ad->ad_cname ) ) {
1677 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s>: attr #%d (\"%s\") already defined (ignored)",
1678 c->argv[0], arg, ad->ad_cname.bv_val);
1679 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
1680 c->log, c->cr_msg, 0 );
1684 value_add_one( &slap_dontUseCopy_propnames, &ad->ad_cname );
1689 #endif /* SLAP_AUXPROP_DONTUSECOPY */
1693 char *txt = slap_sasl_secprops( c->argv[1] );
1695 snprintf( c->cr_msg, sizeof(c->cr_msg), "<%s> %s",
1697 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0 );
1705 c->be->be_max_deref_depth = c->value_int;
1711 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1712 cfn = c->ca_private;
1713 if(parse_oidm(c, 1, &om))
1715 if (!cfn->c_om_head) cfn->c_om_head = om;
1716 cfn->c_om_tail = om;
1721 ObjectClass *oc, *prev;
1723 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1724 cfn = c->ca_private;
1725 if ( c->valx < 0 ) {
1726 prev = cfn->c_oc_tail;
1729 /* If adding anything after the first, prev is easy */
1732 for (i=0, oc = cfn->c_oc_head; i<c->valx; i++) {
1737 /* If adding the first, and head exists, find its prev */
1738 if (cfn->c_oc_head) {
1739 for ( oc_start( &oc ); oc != cfn->c_oc_head; ) {
1744 /* else prev is NULL, append to end of global list */
1746 if(parse_oc(c, &oc, prev)) return(1);
1747 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1748 if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
1753 AttributeType *at, *prev;
1755 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1756 cfn = c->ca_private;
1757 if ( c->valx < 0 ) {
1758 prev = cfn->c_at_tail;
1761 /* If adding anything after the first, prev is easy */
1764 for (i=0, at = cfn->c_at_head; i<c->valx; i++) {
1769 /* If adding the first, and head exists, find its prev */
1770 if (cfn->c_at_head) {
1771 for ( at_start( &at ); at != cfn->c_at_head; ) {
1776 /* else prev is NULL, append to end of global list */
1778 if(parse_at(c, &at, prev)) return(1);
1779 if (!cfn->c_at_head) cfn->c_at_head = at;
1780 if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
1787 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1788 cfn = c->ca_private;
1789 if ( c->valx < 0 ) {
1790 prev = cfn->c_syn_tail;
1793 /* If adding anything after the first, prev is easy */
1796 for ( i = 0, syn = cfn->c_syn_head; i < c->valx; i++ ) {
1801 /* If adding the first, and head exists, find its prev */
1802 if (cfn->c_syn_head) {
1803 for ( syn_start( &syn ); syn != cfn->c_syn_head; ) {
1808 /* else prev is NULL, append to end of global list */
1810 if ( parse_syn( c, &syn, prev ) ) return(1);
1811 if ( !cfn->c_syn_head ) cfn->c_syn_head = syn;
1812 if ( cfn->c_syn_tail == prev ) cfn->c_syn_tail = syn;
1819 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1820 cfn = c->ca_private;
1821 if(parse_cr(c, &cr)) return(1);
1822 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1823 cfn->c_cr_tail = cr;
1828 ad_define_option(NULL, NULL, 0);
1829 for(i = 1; i < c->argc; i++)
1830 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1835 if ( c->value_int < SLAP_INDEX_INTLEN_DEFAULT )
1836 c->value_int = SLAP_INDEX_INTLEN_DEFAULT;
1837 else if ( c->value_int > 255 )
1839 index_intlen = c->value_int;
1840 index_intlen_strlen = SLAP_INDEX_INTLEN_STRLEN(
1844 case CFG_SORTVALS: {
1845 ADlist *svnew = NULL, *svtail, *sv;
1847 for ( i = 1; i < c->argc; i++ ) {
1848 AttributeDescription *ad = NULL;
1852 rc = slap_str2ad( c->argv[i], &ad, &text );
1854 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown attribute type #%d",
1857 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1858 c->log, c->cr_msg, c->argv[i] );
1859 for ( sv = svnew; sv; sv = svnew ) {
1860 svnew = sv->al_next;
1865 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) ||
1866 ad->ad_type->sat_single_value ) {
1867 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> inappropriate attribute type #%d",
1869 goto sortval_reject;
1871 sv = ch_malloc( sizeof( ADlist ));
1876 svtail->al_next = sv;
1881 for ( sv = svnew; sv; sv = sv->al_next )
1882 sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
1883 for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
1885 sv->al_next = svnew;
1892 /* Don't append to the global ACL if we're on a specific DB */
1894 if ( c->valx == -1 ) {
1897 for ( a=c->be->be_acl; a; a = a->acl_next )
1900 if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) {
1907 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_ACL_ADD;
1909 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_ACL_ADD;
1913 if(root_dse_read_file(c->argv[1])) {
1914 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> could not read file", c->argv[0] );
1915 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1916 c->log, c->cr_msg, c->argv[1] );
1921 ber_str2bv( c->argv[1], 0, 1, &bv );
1922 if ( c->op == LDAP_MOD_ADD && c->ca_private && cfn != c->ca_private )
1923 cfn = c->ca_private;
1924 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1930 ServerID *si, **sip;
1933 if (( lutil_atoi( &num, c->argv[1] ) &&
1934 lutil_atoix( &num, c->argv[1], 16 )) ||
1935 num < 0 || num > SLAP_SYNC_SID_MAX )
1937 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1938 "<%s> illegal server ID", c->argv[0] );
1939 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1940 c->log, c->cr_msg, c->argv[1] );
1943 /* only one value allowed if no URL is given */
1944 if ( c->argc > 2 ) {
1947 if ( sid_list && BER_BVISEMPTY( &sid_list->si_url )) {
1948 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1949 "<%s> only one server ID allowed now", c->argv[0] );
1950 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1951 c->log, c->cr_msg, c->argv[1] );
1955 if ( ldap_url_parse( c->argv[2], &lud )) {
1956 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1957 "<%s> invalid URL", c->argv[0] );
1958 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1959 c->log, c->cr_msg, c->argv[2] );
1962 len = strlen( c->argv[2] );
1963 si = ch_malloc( sizeof(ServerID) + len + 1 );
1964 si->si_url.bv_val = (char *)(si+1);
1965 si->si_url.bv_len = len;
1966 strcpy( si->si_url.bv_val, c->argv[2] );
1969 snprintf( c->cr_msg, sizeof( c->cr_msg ),
1970 "<%s> unqualified server ID not allowed now", c->argv[0] );
1971 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
1972 c->log, c->cr_msg, c->argv[1] );
1975 si = ch_malloc( sizeof(ServerID) );
1976 BER_BVZERO( &si->si_url );
1977 slap_serverID = num;
1978 Debug( LDAP_DEBUG_CONFIG,
1980 c->log, slap_serverID, 0 );
1984 for ( sip = &sid_list; *sip; sip = &(*sip)->si_next );
1987 if (( slapMode & SLAP_SERVER_MODE ) && c->argc > 2 ) {
1988 Listener *l = config_check_my_url( c->argv[2], lud );
1990 slap_serverID = si->si_num;
1991 Debug( LDAP_DEBUG_CONFIG,
1992 "%s: SID=0x%03x (listener=%s)\n",
1993 c->log, slap_serverID,
1998 ldap_free_urldesc( lud );
2002 if ( logfileName ) ch_free( logfileName );
2003 logfileName = c->value_string;
2004 logfile = fopen(logfileName, "w");
2005 if(logfile) lutil_debug_file(logfile);
2009 if(SLAP_NOLASTMODCMD(c->be)) {
2010 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> not available for %s database",
2011 c->argv[0], c->be->bd_info->bi_type );
2012 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2013 c->log, c->cr_msg, 0 );
2017 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
2019 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
2022 case CFG_MIRRORMODE:
2023 if(c->value_int && !SLAP_SHADOW(c->be)) {
2024 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database is not a shadow",
2026 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2027 c->log, c->cr_msg, 0 );
2031 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SINGLE_SHADOW;
2033 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SINGLE_SHADOW;
2036 case CFG_MONITORING:
2038 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_MONITORING;
2040 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
2045 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
2047 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_HIDDEN;
2050 case CFG_SYNC_SUBENTRY:
2052 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_SYNC_SUBENTRY;
2054 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_SYNC_SUBENTRY;
2057 case CFG_SSTR_IF_MAX:
2058 if (c->value_uint < index_substr_if_minlen) {
2059 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2060 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2061 c->log, c->cr_msg, c->value_int );
2064 index_substr_if_maxlen = c->value_uint;
2067 case CFG_SSTR_IF_MIN:
2068 if (c->value_uint > index_substr_if_maxlen) {
2069 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid value", c->argv[0] );
2070 Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
2071 c->log, c->cr_msg, c->value_int );
2074 index_substr_if_minlen = c->value_uint;
2077 #ifdef SLAPD_MODULES
2079 /* If we're just adding a module on an existing modpath,
2080 * make sure we've selected the current path.
2082 if ( c->op == LDAP_MOD_ADD && c->ca_private && modcur != c->ca_private ) {
2083 modcur = c->ca_private;
2084 /* This should never fail */
2085 if ( module_path( modcur->mp_path.bv_val )) {
2086 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> module path no longer valid",
2088 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2089 c->log, c->cr_msg, modcur->mp_path.bv_val );
2093 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
2095 /* Record this load on the current path */
2099 if ( c->op == SLAP_CONFIG_ADD ) {
2100 ptr = c->line + STRLENOF("moduleload");
2101 while (!isspace((unsigned char) *ptr)) ptr++;
2102 while (isspace((unsigned char) *ptr)) ptr++;
2106 ber_str2bv(ptr, 0, 1, &bv);
2107 ber_bvarray_add( &modcur->mp_loads, &bv );
2109 /* Check for any new hardcoded schema */
2110 if ( c->op == LDAP_MOD_ADD && CONFIG_ONLINE_ADD( c )) {
2111 config_check_schema( NULL, &cfBackInfo );
2116 if(module_path(c->argv[1])) return(1);
2117 /* Record which path was used with each module */
2121 if (!modpaths.mp_loads) {
2124 mp = ch_malloc( sizeof( ModPaths ));
2125 modlast->mp_next = mp;
2127 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
2129 mp->mp_loads = NULL;
2140 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
2142 slapi_plugins_used++;
2146 #ifdef SLAP_AUTH_REWRITE
2152 if ( c->op == LDAP_MOD_ADD ) {
2156 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
2160 if ( c->argc > 1 ) {
2163 /* quote all args but the first */
2164 line = ldap_charray2str( c->argv, "\" \"" );
2165 ber_str2bv( line, 0, 0, &bv );
2166 s = ber_bvchr( &bv, '"' );
2167 assert( s != NULL );
2168 /* move the trailing quote of argv[0] to the end */
2169 AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
2170 bv.bv_val[ bv.bv_len - 1 ] = '"';
2173 ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
2176 ber_bvarray_add( &authz_rewrites, &bv );
2178 if ( c->op == LDAP_MOD_ADD ) {
2188 Debug( LDAP_DEBUG_ANY,
2189 "%s: unknown CFG_TYPE %d.\n",
2190 c->log, c->type, 0 );
2199 config_fname(ConfigArgs *c) {
2200 if(c->op == SLAP_CONFIG_EMIT) {
2201 if (c->ca_private) {
2202 ConfigFile *cf = c->ca_private;
2203 value_add_one( &c->rvalue_vals, &cf->c_file );
2212 config_cfdir(ConfigArgs *c) {
2213 if(c->op == SLAP_CONFIG_EMIT) {
2214 if ( !BER_BVISEMPTY( &cfdir )) {
2215 value_add_one( &c->rvalue_vals, &cfdir );
2224 config_search_base(ConfigArgs *c) {
2225 if(c->op == SLAP_CONFIG_EMIT) {
2227 if (!BER_BVISEMPTY(&default_search_base)) {
2228 value_add_one(&c->rvalue_vals, &default_search_base);
2229 value_add_one(&c->rvalue_nvals, &default_search_nbase);
2233 } else if( c->op == LDAP_MOD_DELETE ) {
2234 ch_free( default_search_base.bv_val );
2235 ch_free( default_search_nbase.bv_val );
2236 BER_BVZERO( &default_search_base );
2237 BER_BVZERO( &default_search_nbase );
2241 if(c->bi || c->be != frontendDB) {
2242 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
2243 "prior to any backend or database definition\n",
2248 if(default_search_nbase.bv_len) {
2249 free(default_search_base.bv_val);
2250 free(default_search_nbase.bv_val);
2253 default_search_base = c->value_dn;
2254 default_search_nbase = c->value_ndn;
2258 /* For RE23 compatibility we allow this in the global entry
2259 * but we now defer it to the frontend entry to allow modules
2260 * to load new hash types.
2263 config_passwd_hash(ConfigArgs *c) {
2265 if (c->op == SLAP_CONFIG_EMIT) {
2267 /* Don't generate it in the global entry */
2268 if ( c->table == Cft_Global )
2270 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
2271 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
2272 value_add_one(&c->rvalue_vals, &bv);
2275 } else if ( c->op == LDAP_MOD_DELETE ) {
2276 /* Deleting from global is a no-op, only the frontendDB entry matters */
2277 if ( c->table == Cft_Global )
2279 if ( c->valx < 0 ) {
2280 ldap_charray_free( default_passwd_hash );
2281 default_passwd_hash = NULL;
2284 ch_free( default_passwd_hash[i] );
2285 for (; default_passwd_hash[i]; i++ )
2286 default_passwd_hash[i] = default_passwd_hash[i+1];
2290 for(i = 1; i < c->argc; i++) {
2291 if(!lutil_passwd_scheme(c->argv[i])) {
2292 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> scheme not available", c->argv[0] );
2293 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2294 c->log, c->cr_msg, c->argv[i]);
2296 ldap_charray_add(&default_passwd_hash, c->argv[i]);
2299 if(!default_passwd_hash) {
2300 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> no valid hashes found", c->argv[0] );
2301 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
2302 c->log, c->cr_msg, 0 );
2309 config_schema_dn(ConfigArgs *c) {
2310 if ( c->op == SLAP_CONFIG_EMIT ) {
2312 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
2313 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
2314 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
2318 } else if ( c->op == LDAP_MOD_DELETE ) {
2319 ch_free( c->be->be_schemadn.bv_val );
2320 ch_free( c->be->be_schemandn.bv_val );
2321 BER_BVZERO( &c->be->be_schemadn );
2322 BER_BVZERO( &c->be->be_schemandn );
2325 ch_free( c->be->be_schemadn.bv_val );
2326 ch_free( c->be->be_schemandn.bv_val );
2327 c->be->be_schemadn = c->value_dn;
2328 c->be->be_schemandn = c->value_ndn;
2333 config_sizelimit(ConfigArgs *c) {
2335 struct slap_limits_set *lim = &c->be->be_def_limit;
2336 if (c->op == SLAP_CONFIG_EMIT) {
2341 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv, sizeof( buf ) );
2342 if ( !BER_BVISEMPTY( &bv ))
2343 value_add_one( &c->rvalue_vals, &bv );
2347 } else if ( c->op == LDAP_MOD_DELETE ) {
2348 /* Reset to defaults or values from frontend */
2349 if ( c->be == frontendDB ) {
2350 lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
2351 lim->lms_s_hard = 0;
2352 lim->lms_s_unchecked = -1;
2354 lim->lms_s_pr_hide = 0;
2355 lim->lms_s_pr_total = 0;
2357 lim->lms_s_soft = frontendDB->be_def_limit.lms_s_soft;
2358 lim->lms_s_hard = frontendDB->be_def_limit.lms_s_hard;
2359 lim->lms_s_unchecked = frontendDB->be_def_limit.lms_s_unchecked;
2360 lim->lms_s_pr = frontendDB->be_def_limit.lms_s_pr;
2361 lim->lms_s_pr_hide = frontendDB->be_def_limit.lms_s_pr_hide;
2362 lim->lms_s_pr_total = frontendDB->be_def_limit.lms_s_pr_total;
2366 for(i = 1; i < c->argc; i++) {
2367 if(!strncasecmp(c->argv[i], "size", 4)) {
2368 rc = limits_parse_one(c->argv[i], lim);
2370 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2371 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2372 c->log, c->cr_msg, c->argv[i]);
2376 if(!strcasecmp(c->argv[i], "unlimited")) {
2377 lim->lms_s_soft = -1;
2379 if ( lutil_atoix( &lim->lms_s_soft, c->argv[i], 0 ) != 0 ) {
2380 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2381 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2382 c->log, c->cr_msg, c->argv[i]);
2386 lim->lms_s_hard = 0;
2391 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2392 /* This is a modification to the global limits apply it to
2393 * the other databases as needed */
2394 AttributeDescription *ad=NULL;
2395 const char *text = NULL;
2396 CfEntryInfo *ce = c->ca_entry->e_private;
2398 slap_str2ad(c->argv[0], &ad, &text);
2399 /* if we got here... */
2400 assert( ad != NULL );
2402 if ( ce->ce_type == Cft_Global ){
2405 for (; ce; ce=ce->ce_sibs) {
2406 Entry *dbe = ce->ce_entry;
2407 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2408 && (!attr_find(dbe->e_attrs, ad)) ) {
2409 ce->ce_be->be_def_limit.lms_s_soft = lim->lms_s_soft;
2410 ce->ce_be->be_def_limit.lms_s_hard = lim->lms_s_hard;
2411 ce->ce_be->be_def_limit.lms_s_unchecked =lim->lms_s_unchecked;
2412 ce->ce_be->be_def_limit.lms_s_pr =lim->lms_s_pr;
2413 ce->ce_be->be_def_limit.lms_s_pr_hide =lim->lms_s_pr_hide;
2414 ce->ce_be->be_def_limit.lms_s_pr_total =lim->lms_s_pr_total;
2422 config_timelimit(ConfigArgs *c) {
2424 struct slap_limits_set *lim = &c->be->be_def_limit;
2425 if (c->op == SLAP_CONFIG_EMIT) {
2430 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv, sizeof( buf ) );
2431 if ( !BER_BVISEMPTY( &bv ))
2432 value_add_one( &c->rvalue_vals, &bv );
2436 } else if ( c->op == LDAP_MOD_DELETE ) {
2437 /* Reset to defaults or values from frontend */
2438 if ( c->be == frontendDB ) {
2439 lim->lms_t_soft = SLAPD_DEFAULT_TIMELIMIT;
2440 lim->lms_t_hard = 0;
2442 lim->lms_t_soft = frontendDB->be_def_limit.lms_t_soft;
2443 lim->lms_t_hard = frontendDB->be_def_limit.lms_t_hard;
2447 for(i = 1; i < c->argc; i++) {
2448 if(!strncasecmp(c->argv[i], "time", 4)) {
2449 rc = limits_parse_one(c->argv[i], lim);
2451 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse value", c->argv[0] );
2452 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2453 c->log, c->cr_msg, c->argv[i]);
2457 if(!strcasecmp(c->argv[i], "unlimited")) {
2458 lim->lms_t_soft = -1;
2460 if ( lutil_atoix( &lim->lms_t_soft, c->argv[i], 0 ) != 0 ) {
2461 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse limit", c->argv[0]);
2462 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
2463 c->log, c->cr_msg, c->argv[i]);
2467 lim->lms_t_hard = 0;
2472 if ( ( c->be == frontendDB ) && ( c->ca_entry ) ) {
2473 /* This is a modification to the global limits apply it to
2474 * the other databases as needed */
2475 AttributeDescription *ad=NULL;
2476 const char *text = NULL;
2477 CfEntryInfo *ce = c->ca_entry->e_private;
2479 slap_str2ad(c->argv[0], &ad, &text);
2480 /* if we got here... */
2481 assert( ad != NULL );
2483 if ( ce->ce_type == Cft_Global ){
2486 for (; ce; ce=ce->ce_sibs) {
2487 Entry *dbe = ce->ce_entry;
2488 if ( (ce->ce_type == Cft_Database) && (ce->ce_be != frontendDB)
2489 && (!attr_find(dbe->e_attrs, ad)) ) {
2490 ce->ce_be->be_def_limit.lms_t_soft = lim->lms_t_soft;
2491 ce->ce_be->be_def_limit.lms_t_hard = lim->lms_t_hard;
2499 config_overlay(ConfigArgs *c) {
2500 if (c->op == SLAP_CONFIG_EMIT) {
2502 } else if ( c->op == LDAP_MOD_DELETE ) {
2505 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1],
2506 c->valx, &c->bi, &c->reply)) {
2508 Debug( LDAP_DEBUG_ANY,
2509 "%s: (optional) %s overlay \"%s\" configuration failed.\n",
2510 c->log, c->be == frontendDB ? "global " : "", &c->argv[1][1]);
2512 } else if(overlay_config(c->be, c->argv[1], c->valx, &c->bi, &c->reply)) {
2519 config_subordinate(ConfigArgs *c)
2525 case SLAP_CONFIG_EMIT:
2526 if ( SLAP_GLUE_SUBORDINATE( c->be )) {
2529 bv.bv_val = SLAP_GLUE_ADVERTISE( c->be ) ? "advertise" : "TRUE";
2530 bv.bv_len = SLAP_GLUE_ADVERTISE( c->be ) ? STRLENOF("advertise") :
2533 value_add_one( &c->rvalue_vals, &bv );
2537 case LDAP_MOD_DELETE:
2538 if ( !c->line || strcasecmp( c->line, "advertise" )) {
2539 glue_sub_del( c->be );
2541 SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_GLUE_ADVERTISE;
2546 case SLAP_CONFIG_ADD:
2547 if ( c->be->be_nsuffix == NULL ) {
2549 snprintf( c->cr_msg, sizeof( c->cr_msg),
2550 "subordinate configuration needs a suffix" );
2551 Debug( LDAP_DEBUG_ANY,
2553 c->log, c->cr_msg, 0 );
2558 if ( c->argc == 2 ) {
2559 if ( strcasecmp( c->argv[1], "advertise" ) == 0 ) {
2562 } else if ( strcasecmp( c->argv[1], "TRUE" ) != 0 ) {
2564 snprintf( c->cr_msg, sizeof( c->cr_msg),
2565 "subordinate must be \"TRUE\" or \"advertise\"" );
2566 Debug( LDAP_DEBUG_ANY,
2567 "%s: suffix \"%s\": %s.\n",
2568 c->log, c->be->be_suffix[0].bv_val, c->cr_msg );
2574 rc = glue_sub_add( c->be, advertise, CONFIG_ONLINE_ADD( c ));
2582 * [listener=<listener>] [{read|write}=]<size>
2585 #ifdef LDAP_TCP_BUFFER
2586 static BerVarray tcp_buffer;
2589 #define SLAP_TCP_RMEM (0x1U)
2590 #define SLAP_TCP_WMEM (0x2U)
2593 tcp_buffer_parse( struct berval *val, int argc, char **argv,
2594 int *size, int *rw, Listener **l )
2596 int i, rc = LDAP_SUCCESS;
2597 LDAPURLDesc *lud = NULL;
2600 if ( val != NULL && argv == NULL ) {
2601 char *s = val->bv_val;
2603 argv = ldap_str2charray( s, " \t" );
2604 if ( argv == NULL ) {
2610 if ( strncasecmp( argv[ i ], "listener=", STRLENOF( "listener=" ) )
2613 char *url = argv[ i ] + STRLENOF( "listener=" );
2615 if ( ldap_url_parse( url, &lud ) ) {
2616 rc = LDAP_INVALID_SYNTAX;
2620 *l = config_check_my_url( url, lud );
2622 rc = LDAP_NO_SUCH_ATTRIBUTE;
2630 if ( strncasecmp( ptr, "read=", STRLENOF( "read=" ) ) == 0 ) {
2631 *rw |= SLAP_TCP_RMEM;
2632 ptr += STRLENOF( "read=" );
2634 } else if ( strncasecmp( ptr, "write=", STRLENOF( "write=" ) ) == 0 ) {
2635 *rw |= SLAP_TCP_WMEM;
2636 ptr += STRLENOF( "write=" );
2639 *rw |= ( SLAP_TCP_RMEM | SLAP_TCP_WMEM );
2642 /* accept any base */
2643 if ( lutil_atoix( size, ptr, 0 ) ) {
2644 rc = LDAP_INVALID_SYNTAX;
2649 if ( val != NULL && argv != NULL ) {
2650 ldap_charray_free( argv );
2653 if ( lud != NULL ) {
2654 ldap_free_urldesc( lud );
2661 tcp_buffer_delete_one( struct berval *val )
2664 int size = -1, rw = 0;
2667 rc = tcp_buffer_parse( val, 0, NULL, &size, &rw, &l );
2674 Listener **ll = slapd_get_listeners();
2676 for ( i = 0; ll[ i ] != NULL; i++ ) {
2677 if ( ll[ i ] == l ) break;
2680 if ( ll[ i ] == NULL ) {
2681 return LDAP_NO_SUCH_ATTRIBUTE;
2684 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = -1;
2685 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = -1;
2687 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2688 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = -1;
2689 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = -1;
2693 /* NOTE: this affects listeners without a specific setting,
2694 * does not reset all listeners. If a listener without
2695 * specific settings was assigned a buffer because of
2696 * a global setting, it will not be reset. In any case,
2697 * buffer changes will only take place at restart. */
2698 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = -1;
2699 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = -1;
2706 tcp_buffer_delete( BerVarray vals )
2710 for ( i = 0; !BER_BVISNULL( &vals[ i ] ); i++ ) {
2711 tcp_buffer_delete_one( &vals[ i ] );
2718 tcp_buffer_unparse( int size, int rw, Listener *l, struct berval *val )
2720 char buf[sizeof("2147483648")], *ptr;
2722 /* unparse for later use */
2723 val->bv_len = snprintf( buf, sizeof( buf ), "%d", size );
2725 val->bv_len += STRLENOF( "listener=" " " ) + l->sl_url.bv_len;
2728 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2729 if ( rw & SLAP_TCP_RMEM ) {
2730 val->bv_len += STRLENOF( "read=" );
2731 } else if ( rw & SLAP_TCP_WMEM ) {
2732 val->bv_len += STRLENOF( "write=" );
2736 val->bv_val = SLAP_MALLOC( val->bv_len + 1 );
2741 ptr = lutil_strcopy( ptr, "listener=" );
2742 ptr = lutil_strncopy( ptr, l->sl_url.bv_val, l->sl_url.bv_len );
2746 if ( rw != ( SLAP_TCP_RMEM | SLAP_TCP_WMEM ) ) {
2747 if ( rw & SLAP_TCP_RMEM ) {
2748 ptr = lutil_strcopy( ptr, "read=" );
2749 } else if ( rw & SLAP_TCP_WMEM ) {
2750 ptr = lutil_strcopy( ptr, "write=" );
2754 ptr = lutil_strcopy( ptr, buf );
2757 assert( val->bv_val + val->bv_len == ptr );
2759 return LDAP_SUCCESS;
2763 tcp_buffer_add_one( int argc, char **argv )
2766 int size = -1, rw = 0;
2772 rc = tcp_buffer_parse( NULL, argc, argv, &size, &rw, &l );
2777 /* unparse for later use */
2778 rc = tcp_buffer_unparse( size, rw, l, &val );
2779 if ( rc != LDAP_SUCCESS ) {
2783 /* use parsed values */
2786 Listener **ll = slapd_get_listeners();
2788 for ( i = 0; ll[ i ] != NULL; i++ ) {
2789 if ( ll[ i ] == l ) break;
2792 if ( ll[ i ] == NULL ) {
2793 return LDAP_NO_SUCH_ATTRIBUTE;
2796 /* buffer only applies to TCP listeners;
2797 * we do not do any check here, and delegate them
2798 * to setsockopt(2) */
2799 if ( rw & SLAP_TCP_RMEM ) l->sl_tcp_rmem = size;
2800 if ( rw & SLAP_TCP_WMEM ) l->sl_tcp_wmem = size;
2802 for ( i++ ; ll[ i ] != NULL && bvmatch( &l->sl_url, &ll[ i ]->sl_url ); i++ ) {
2803 if ( rw & SLAP_TCP_RMEM ) ll[ i ]->sl_tcp_rmem = size;
2804 if ( rw & SLAP_TCP_WMEM ) ll[ i ]->sl_tcp_wmem = size;
2808 /* NOTE: this affects listeners without a specific setting,
2809 * does not set all listeners */
2810 if ( rw & SLAP_TCP_RMEM ) slapd_tcp_rmem = size;
2811 if ( rw & SLAP_TCP_WMEM ) slapd_tcp_wmem = size;
2814 tcp_buffer = SLAP_REALLOC( tcp_buffer, sizeof( struct berval ) * ( tcp_buffer_num + 2 ) );
2816 tcp_buffer[ tcp_buffer_num ] = val;
2819 BER_BVZERO( &tcp_buffer[ tcp_buffer_num ] );
2825 config_tcp_buffer( ConfigArgs *c )
2827 if ( c->op == SLAP_CONFIG_EMIT ) {
2828 if ( tcp_buffer == NULL || BER_BVISNULL( &tcp_buffer[ 0 ] ) ) {
2831 value_add( &c->rvalue_vals, tcp_buffer );
2832 value_add( &c->rvalue_nvals, tcp_buffer );
2834 } else if ( c->op == LDAP_MOD_DELETE ) {
2836 tcp_buffer_delete( tcp_buffer );
2837 ber_bvarray_free( tcp_buffer );
2843 int size = -1, rw = 0;
2846 struct berval val = BER_BVNULL;
2850 if ( tcp_buffer_num == 0 ) {
2855 rc = tcp_buffer_parse( NULL, c->argc - 1, &c->argv[ 1 ], &size, &rw, &l );
2860 /* unparse for later use */
2861 rc = tcp_buffer_unparse( size, rw, l, &val );
2862 if ( rc != LDAP_SUCCESS ) {
2866 for ( i = 0; !BER_BVISNULL( &tcp_buffer[ i ] ); i++ ) {
2867 if ( bvmatch( &tcp_buffer[ i ], &val ) ) {
2872 if ( BER_BVISNULL( &tcp_buffer[ i ] ) ) {
2878 tcp_buffer_delete_one( &tcp_buffer[ i ] );
2879 ber_memfree( tcp_buffer[ i ].bv_val );
2880 for ( ; i < tcp_buffer_num; i++ ) {
2881 tcp_buffer[ i ] = tcp_buffer[ i + 1 ];
2886 if ( !BER_BVISNULL( &val ) ) {
2887 SLAP_FREE( val.bv_val );
2895 rc = tcp_buffer_add_one( c->argc - 1, &c->argv[ 1 ] );
2897 snprintf( c->cr_msg, sizeof( c->cr_msg ),
2898 "<%s> unable to add value #%d",
2899 c->argv[0], tcp_buffer_num );
2900 Debug( LDAP_DEBUG_ANY, "%s: %s\n",
2901 c->log, c->cr_msg, 0 );
2908 #endif /* LDAP_TCP_BUFFER */
2911 config_suffix(ConfigArgs *c)
2914 struct berval pdn, ndn;
2915 char *notallowed = NULL;
2917 if ( c->be == frontendDB ) {
2918 notallowed = "frontend";
2920 } else if ( SLAP_MONITOR(c->be) ) {
2921 notallowed = "monitor";
2923 } else if ( SLAP_CONFIG(c->be) ) {
2924 notallowed = "config";
2927 if ( notallowed != NULL ) {
2928 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
2932 case LDAP_MOD_DELETE:
2933 case LDAP_MOD_REPLACE:
2934 case LDAP_MOD_INCREMENT:
2935 case SLAP_CONFIG_ADD:
2936 if ( !BER_BVISNULL( &c->value_dn ) ) {
2937 snprintf( buf, sizeof( buf ), "<%s> ",
2938 c->value_dn.bv_val );
2941 Debug(LDAP_DEBUG_ANY,
2942 "%s: suffix %snot allowed in %s database.\n",
2943 c->log, buf, notallowed );
2946 case SLAP_CONFIG_EMIT:
2947 /* don't complain when emitting... */
2951 /* FIXME: don't know what values may be valid;
2952 * please remove assertion, or add legal values
2953 * to either block */
2961 if (c->op == SLAP_CONFIG_EMIT) {
2962 if ( c->be->be_suffix == NULL
2963 || BER_BVISNULL( &c->be->be_suffix[0] ) )
2967 value_add( &c->rvalue_vals, c->be->be_suffix );
2968 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
2971 } else if ( c->op == LDAP_MOD_DELETE ) {
2972 if ( c->valx < 0 ) {
2973 ber_bvarray_free( c->be->be_suffix );
2974 ber_bvarray_free( c->be->be_nsuffix );
2975 c->be->be_suffix = NULL;
2976 c->be->be_nsuffix = NULL;
2979 ch_free( c->be->be_suffix[i].bv_val );
2980 ch_free( c->be->be_nsuffix[i].bv_val );
2982 c->be->be_suffix[i] = c->be->be_suffix[i+1];
2983 c->be->be_nsuffix[i] = c->be->be_nsuffix[i+1];
2985 } while ( !BER_BVISNULL( &c->be->be_suffix[i] ) );
2990 #ifdef SLAPD_MONITOR_DN
2991 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
2992 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> DN is reserved for monitoring slapd",
2994 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
2995 c->log, c->cr_msg, SLAPD_MONITOR_DN);
3000 if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) {
3001 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend",
3002 c->argv[0], c->be->bd_info->bi_type );
3003 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3004 c->log, c->cr_msg, 0);
3011 if (SLAP_DBHIDDEN( c->be ))
3014 tbe = select_backend(&ndn, 0);
3016 Debug( LDAP_DEBUG_ANY, "%s: suffix already served by this backend!.\n",
3022 BackendDB *b2 = tbe;
3024 /* Does tbe precede be? */
3025 while (( b2 = LDAP_STAILQ_NEXT(b2, be_next )) && b2 && b2 != c->be );
3028 char *type = tbe->bd_info->bi_type;
3030 if ( overlay_is_over( tbe ) ) {
3031 slap_overinfo *oi = (slap_overinfo *)tbe->bd_info->bi_private;
3032 type = oi->oi_orig->bi_type;
3035 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> namingContext \"%s\" "
3036 "already served by a preceding %s database",
3037 c->argv[0], pdn.bv_val, type );
3038 Debug(LDAP_DEBUG_ANY, "%s: %s serving namingContext \"%s\"\n",
3039 c->log, c->cr_msg, tbe->be_suffix[0].bv_val);
3045 if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
3046 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
3047 "base provided \"%s\" (assuming okay)\n",
3048 c->log, default_search_base.bv_val, 0);
3050 ber_bvarray_add(&c->be->be_suffix, &pdn);
3051 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
3056 config_rootdn(ConfigArgs *c) {
3057 if (c->op == SLAP_CONFIG_EMIT) {
3058 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3059 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
3060 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
3065 } else if ( c->op == LDAP_MOD_DELETE ) {
3066 ch_free( c->be->be_rootdn.bv_val );
3067 ch_free( c->be->be_rootndn.bv_val );
3068 BER_BVZERO( &c->be->be_rootdn );
3069 BER_BVZERO( &c->be->be_rootndn );
3072 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
3073 ch_free( c->be->be_rootdn.bv_val );
3074 ch_free( c->be->be_rootndn.bv_val );
3076 c->be->be_rootdn = c->value_dn;
3077 c->be->be_rootndn = c->value_ndn;
3082 config_rootpw(ConfigArgs *c) {
3085 if (c->op == SLAP_CONFIG_EMIT) {
3086 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
3087 /* don't copy, because "rootpw" is marked
3089 c->value_bv = c->be->be_rootpw;
3093 } else if ( c->op == LDAP_MOD_DELETE ) {
3094 ch_free( c->be->be_rootpw.bv_val );
3095 BER_BVZERO( &c->be->be_rootpw );
3099 tbe = select_backend(&c->be->be_rootndn, 0);
3101 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> can only be set when rootdn is under suffix",
3103 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3104 c->log, c->cr_msg, 0);
3107 if ( !BER_BVISNULL( &c->be->be_rootpw ))
3108 ch_free( c->be->be_rootpw.bv_val );
3109 c->be->be_rootpw = c->value_bv;
3114 config_restrict(ConfigArgs *c) {
3115 slap_mask_t restrictops = 0;
3117 slap_verbmasks restrictable_ops[] = {
3118 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
3119 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
3120 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
3121 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
3122 { BER_BVC("modrdn"), 0 },
3123 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
3124 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
3125 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
3126 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
3127 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
3128 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
3129 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
3130 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
3131 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
3132 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
3133 { BER_BVC("all"), SLAP_RESTRICT_OP_ALL },
3137 if (c->op == SLAP_CONFIG_EMIT) {
3138 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
3140 } else if ( c->op == LDAP_MOD_DELETE ) {
3142 c->be->be_restrictops = 0;
3144 restrictops = verb_to_mask( c->line, restrictable_ops );
3145 c->be->be_restrictops ^= restrictops;
3149 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
3151 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown operation", c->argv[0] );
3152 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3153 c->log, c->cr_msg, c->argv[i]);
3156 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
3157 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
3158 c->be->be_restrictops |= restrictops;
3163 config_allows(ConfigArgs *c) {
3164 slap_mask_t allows = 0;
3166 slap_verbmasks allowable_ops[] = {
3167 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
3168 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
3169 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
3170 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
3171 { BER_BVC("proxy_authz_anon"), SLAP_ALLOW_PROXY_AUTHZ_ANON },
3174 if (c->op == SLAP_CONFIG_EMIT) {
3175 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
3176 } else if ( c->op == LDAP_MOD_DELETE ) {
3180 allows = verb_to_mask( c->line, allowable_ops );
3181 global_allows ^= allows;
3185 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
3187 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3188 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3189 c->log, c->cr_msg, c->argv[i]);
3192 global_allows |= allows;
3197 config_disallows(ConfigArgs *c) {
3198 slap_mask_t disallows = 0;
3200 slap_verbmasks disallowable_ops[] = {
3201 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
3202 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
3203 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
3204 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
3205 { BER_BVC("proxy_authz_non_critical"), SLAP_DISALLOW_PROXY_AUTHZ_N_CRIT },
3206 { BER_BVC("dontusecopy_non_critical"), SLAP_DISALLOW_DONTUSECOPY_N_CRIT },
3209 if (c->op == SLAP_CONFIG_EMIT) {
3210 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
3211 } else if ( c->op == LDAP_MOD_DELETE ) {
3213 global_disallows = 0;
3215 disallows = verb_to_mask( c->line, disallowable_ops );
3216 global_disallows ^= disallows;
3220 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
3222 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature", c->argv[0] );
3223 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3224 c->log, c->cr_msg, c->argv[i]);
3227 global_disallows |= disallows;
3232 config_requires(ConfigArgs *c) {
3233 slap_mask_t requires = frontendDB->be_requires;
3234 int i, argc = c->argc;
3235 char **argv = c->argv;
3237 slap_verbmasks requires_ops[] = {
3238 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
3239 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
3240 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
3241 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
3242 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
3245 if (c->op == SLAP_CONFIG_EMIT) {
3246 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
3247 } else if ( c->op == LDAP_MOD_DELETE ) {
3249 c->be->be_requires = 0;
3251 requires = verb_to_mask( c->line, requires_ops );
3252 c->be->be_requires ^= requires;
3256 /* "none" can only be first, to wipe out default/global values */
3257 if ( strcasecmp( c->argv[ 1 ], "none" ) == 0 ) {
3262 i = verbs_to_mask(argc, argv, requires_ops, &requires);
3264 if (strcasecmp( c->argv[ i ], "none" ) == 0 ) {
3265 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> \"none\" (#%d) must be listed first", c->argv[0], i - 1 );
3266 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3267 c->log, c->cr_msg, 0);
3269 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown feature #%d", c->argv[0], i - 1 );
3270 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3271 c->log, c->cr_msg, c->argv[i]);
3275 c->be->be_requires = requires;
3280 config_extra_attrs(ConfigArgs *c)
3282 assert( c->be != NULL );
3284 if ( c->op == SLAP_CONFIG_EMIT ) {
3287 if ( c->be->be_extra_anlist == NULL ) {
3291 for ( i = 0; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3292 value_add_one( &c->rvalue_vals, &c->be->be_extra_anlist[i].an_name );
3295 } else if ( c->op == LDAP_MOD_DELETE ) {
3296 if ( c->be->be_extra_anlist == NULL ) {
3300 if ( c->valx < 0 ) {
3301 anlist_free( c->be->be_extra_anlist, 1, NULL );
3302 c->be->be_extra_anlist = NULL;
3307 for ( i = 0; i < c->valx && !BER_BVISNULL( &c->be->be_extra_anlist[i + 1].an_name ); i++ )
3310 if ( BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ) ) {
3314 ch_free( c->be->be_extra_anlist[i].an_name.bv_val );
3316 for ( ; !BER_BVISNULL( &c->be->be_extra_anlist[i].an_name ); i++ ) {
3317 c->be->be_extra_anlist[i] = c->be->be_extra_anlist[i + 1];
3322 c->be->be_extra_anlist = str2anlist( c->be->be_extra_anlist, c->argv[1], " ,\t" );
3323 if ( c->be->be_extra_anlist == NULL ) {
3331 static slap_verbmasks *loglevel_ops;
3334 loglevel_init( void )
3336 slap_verbmasks lo[] = {
3337 { BER_BVC("Any"), (slap_mask_t) LDAP_DEBUG_ANY },
3338 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
3339 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
3340 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
3341 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
3342 { BER_BVC("BER"), LDAP_DEBUG_BER },
3343 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
3344 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
3345 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
3346 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
3347 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
3348 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
3349 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
3350 #if 0 /* no longer used (nor supported) */
3351 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
3352 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
3354 { BER_BVC("Sync"), LDAP_DEBUG_SYNC },
3355 { BER_BVC("None"), LDAP_DEBUG_NONE },
3359 return slap_verbmasks_init( &loglevel_ops, lo );
3363 loglevel_destroy( void )
3365 if ( loglevel_ops ) {
3366 (void)slap_verbmasks_destroy( loglevel_ops );
3368 loglevel_ops = NULL;
3371 static slap_mask_t loglevel_ignore[] = { -1, 0 };
3374 slap_loglevel_register( slap_mask_t m, struct berval *s )
3378 if ( loglevel_ops == NULL ) {
3382 rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
3385 Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%lu, \"%s\") failed\n",
3393 slap_loglevel_get( struct berval *s, int *l )
3398 if ( loglevel_ops == NULL ) {
3402 for ( m = 0, i = 1; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3403 m |= loglevel_ops[ i ].mask;
3406 for ( i = 1; m & i; i <<= 1 )
3413 rc = slap_verbmasks_append( &loglevel_ops, i, s, loglevel_ignore );
3416 Debug( LDAP_DEBUG_ANY, "slap_loglevel_get(%lu, \"%s\") failed\n",
3427 str2loglevel( const char *s, int *l )
3431 if ( loglevel_ops == NULL ) {
3435 i = verb_to_mask( s, loglevel_ops );
3437 if ( BER_BVISNULL( &loglevel_ops[ i ].word ) ) {
3441 *l = loglevel_ops[ i ].mask;
3447 loglevel2str( int l )
3449 struct berval bv = BER_BVNULL;
3451 loglevel2bv( l, &bv );
3457 loglevel2bv( int l, struct berval *bv )
3459 if ( loglevel_ops == NULL ) {
3465 return enum_to_verb( loglevel_ops, l, bv ) == -1;
3469 loglevel2bvarray( int l, BerVarray *bva )
3471 if ( loglevel_ops == NULL ) {
3475 return mask_to_verbs( loglevel_ops, l, bva );
3479 loglevel_print( FILE *out )
3483 if ( loglevel_ops == NULL ) {
3487 fprintf( out, "Installed log subsystems:\n\n" );
3488 for ( i = 0; !BER_BVISNULL( &loglevel_ops[ i ].word ); i++ ) {
3489 unsigned mask = loglevel_ops[ i ].mask & 0xffffffffUL;
3491 (mask == ((slap_mask_t) -1 & 0xffffffffUL)
3492 ? "\t%-30s (-1, 0xffffffff)\n" : "\t%-30s (%u, 0x%x)\n"),
3493 loglevel_ops[ i ].word.bv_val, mask, mask );
3496 fprintf( out, "\nNOTE: custom log subsystems may be later installed "
3497 "by specific code\n\n" );
3502 static int config_syslog;
3505 config_loglevel(ConfigArgs *c) {
3508 if ( loglevel_ops == NULL ) {
3512 if (c->op == SLAP_CONFIG_EMIT) {
3513 /* Get default or commandline slapd setting */
3514 if ( ldap_syslog && !config_syslog )
3515 config_syslog = ldap_syslog;
3516 return loglevel2bvarray( config_syslog, &c->rvalue_vals );
3518 } else if ( c->op == LDAP_MOD_DELETE ) {
3522 int level = verb_to_mask( c->line, loglevel_ops );
3523 config_syslog ^= level;
3525 if ( slapMode & SLAP_SERVER_MODE ) {
3526 ldap_syslog = config_syslog;
3531 for( i=1; i < c->argc; i++ ) {
3534 if ( isdigit((unsigned char)c->argv[i][0]) || c->argv[i][0] == '-' ) {
3535 if( lutil_atoix( &level, c->argv[i], 0 ) != 0 ) {
3536 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse level", c->argv[0] );
3537 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3538 c->log, c->cr_msg, c->argv[i]);
3542 if ( str2loglevel( c->argv[i], &level ) ) {
3543 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown level", c->argv[0] );
3544 Debug( LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3545 c->log, c->cr_msg, c->argv[i]);
3549 /* Explicitly setting a zero clears all the levels */
3551 config_syslog |= level;
3555 if ( slapMode & SLAP_SERVER_MODE ) {
3556 ldap_syslog = config_syslog;
3562 config_referral(ConfigArgs *c) {
3564 if (c->op == SLAP_CONFIG_EMIT) {
3565 if ( default_referral ) {
3566 value_add( &c->rvalue_vals, default_referral );
3571 } else if ( c->op == LDAP_MOD_DELETE ) {
3572 if ( c->valx < 0 ) {
3573 ber_bvarray_free( default_referral );
3574 default_referral = NULL;
3577 ch_free( default_referral[i].bv_val );
3578 for (; default_referral[i].bv_val; i++ )
3579 default_referral[i] = default_referral[i+1];
3583 if(validate_global_referral(c->argv[1])) {
3584 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3585 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3586 c->log, c->cr_msg, c->argv[1]);
3590 ber_str2bv(c->argv[1], 0, 0, &val);
3591 if(value_add_one(&default_referral, &val)) return(LDAP_OTHER);
3599 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
3600 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
3601 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
3602 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
3603 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
3604 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
3605 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
3606 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
3607 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
3612 config_security(ConfigArgs *c) {
3613 slap_ssf_set_t *set = &c->be->be_ssf_set;
3616 if (c->op == SLAP_CONFIG_EMIT) {
3622 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
3623 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
3626 bv.bv_len = snprintf( numbuf, sizeof( numbuf ), "%u", *tgt );
3627 if ( bv.bv_len >= sizeof( numbuf ) ) {
3628 ber_bvarray_free_x( c->rvalue_vals, NULL );
3629 c->rvalue_vals = NULL;
3633 bv.bv_len += sec_keys[i].key.bv_len;
3634 bv.bv_val = ch_malloc( bv.bv_len + 1);
3635 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
3636 strcpy( next, numbuf );
3637 ber_bvarray_add( &c->rvalue_vals, &bv );
3642 for(i = 1; i < c->argc; i++) {
3643 slap_ssf_t *tgt = NULL;
3645 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
3646 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
3647 sec_keys[j].key.bv_len)) {
3648 src = c->argv[i] + sec_keys[j].key.bv_len;
3649 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
3654 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unknown factor", c->argv[0] );
3655 Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
3656 c->log, c->cr_msg, c->argv[i]);
3660 if ( lutil_atou( tgt, src ) != 0 ) {
3661 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> unable to parse factor", c->argv[0] );
3662 Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
3663 c->log, c->cr_msg, c->argv[i]);
3671 anlist_unparse( AttributeName *an, char *ptr, ber_len_t buflen ) {
3675 for (; !BER_BVISNULL( &an->an_name ); an++) {
3676 /* if buflen == 0, assume the buffer size has been
3677 * already checked otherwise */
3678 if ( buflen > 0 && buflen - ( ptr - start ) < comma + an->an_name.bv_len ) return NULL;
3679 if ( comma ) *ptr++ = ',';
3680 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
3687 config_updatedn(ConfigArgs *c) {
3688 if (c->op == SLAP_CONFIG_EMIT) {
3689 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
3690 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
3691 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
3695 } else if ( c->op == LDAP_MOD_DELETE ) {
3696 ch_free( c->be->be_update_ndn.bv_val );
3697 BER_BVZERO( &c->be->be_update_ndn );
3698 SLAP_DBFLAGS(c->be) ^= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
3701 if(SLAP_SHADOW(c->be)) {
3702 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> database already shadowed", c->argv[0] );
3703 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3704 c->log, c->cr_msg, 0);
3708 ber_memfree_x( c->value_dn.bv_val, NULL );
3709 if ( !BER_BVISNULL( &c->be->be_update_ndn ) ) {
3710 ber_memfree_x( c->be->be_update_ndn.bv_val, NULL );
3712 c->be->be_update_ndn = c->value_ndn;
3713 BER_BVZERO( &c->value_dn );
3714 BER_BVZERO( &c->value_ndn );
3716 return config_slurp_shadow( c );
3720 config_shadow( ConfigArgs *c, slap_mask_t flag )
3722 char *notallowed = NULL;
3724 if ( c->be == frontendDB ) {
3725 notallowed = "frontend";
3727 } else if ( SLAP_MONITOR(c->be) ) {
3728 notallowed = "monitor";
3731 if ( notallowed != NULL ) {
3732 Debug( LDAP_DEBUG_ANY, "%s: %s database cannot be shadow.\n", c->log, notallowed, 0 );
3736 if ( SLAP_SHADOW(c->be) ) {
3737 /* if already shadow, only check consistency */
3738 if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
3739 Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%lx.\n",
3745 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
3752 config_updateref(ConfigArgs *c) {
3754 if (c->op == SLAP_CONFIG_EMIT) {
3755 if ( c->be->be_update_refs ) {
3756 value_add( &c->rvalue_vals, c->be->be_update_refs );
3761 } else if ( c->op == LDAP_MOD_DELETE ) {
3762 if ( c->valx < 0 ) {
3763 ber_bvarray_free( c->be->be_update_refs );
3764 c->be->be_update_refs = NULL;
3767 ch_free( c->be->be_update_refs[i].bv_val );
3768 for (; c->be->be_update_refs[i].bv_val; i++)
3769 c->be->be_update_refs[i] = c->be->be_update_refs[i+1];
3773 if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
3774 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> must appear after syncrepl or updatedn",
3776 Debug(LDAP_DEBUG_ANY, "%s: %s\n",
3777 c->log, c->cr_msg, 0);
3781 if(validate_global_referral(c->argv[1])) {
3782 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid URL", c->argv[0] );
3783 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
3784 c->log, c->cr_msg, c->argv[1]);
3787 ber_str2bv(c->argv[1], 0, 0, &val);
3788 if(value_add_one(&c->be->be_update_refs, &val)) return(LDAP_OTHER);
3793 config_obsolete(ConfigArgs *c) {
3794 if (c->op == SLAP_CONFIG_EMIT)
3797 snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> keyword is obsolete (ignored)",
3799 Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg, 0);
3804 config_include(ConfigArgs *c) {
3805 int savelineno = c->lineno;
3808 ConfigFile *cfsave = cfn;
3809 ConfigFile *cf2 = NULL;
3811 /* Leftover from RE23. No dynamic config for include files */
3812 if ( c->op == SLAP_CONFIG_EMIT || c->op == LDAP_MOD_DELETE )
3815 cf = ch_calloc( 1, sizeof(ConfigFile));
3816 if ( cfn->c_kids ) {
3817 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
3823 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
3824 rc = read_config_file(c->argv[1], c->depth + 1, c, config_back_cf_table);
3825 c->lineno = savelineno - 1;
3828 if ( cf2 ) cf2->c_sibs = NULL;
3829 else cfn->c_kids = NULL;
3830 ch_free( cf->c_file.bv_val );
3840 config_tls_cleanup(ConfigArgs *c) {
3843 if ( slap_tls_ld ) {
3846 ldap_pvt_tls_ctx_free( slap_tls_ctx );
3848 /* Force new ctx to be created */
3849 rc = ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
3851 /* The ctx's refcount is bumped up here */
3852 ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
3853 /* This is a no-op if it's already loaded */
3854 load_extop( &slap_EXOP_START_TLS, 0, starttls_extop );
3861 config_tls_option(ConfigArgs *c) {
3863 LDAP *ld = slap_tls_ld;
3865 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; ld = NULL; break;
3866 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
3867 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
3868 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
3869 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
3870 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
3871 case CFG_TLS_DH_FILE: flag = LDAP_OPT_X_TLS_DHFILE; break;
3873 case CFG_TLS_CRL_FILE: flag = LDAP_OPT_X_TLS_CRLFILE; break;
3875 default: Debug(LDAP_DEBUG_ANY, "%s: "
3876 "unknown tls_option <0x%x>\n",
3877 c->log, c->type, 0);
3880 if (c->op == SLAP_CONFIG_EMIT) {
3881 return ldap_pvt_tls_get_option( ld, flag, &c->value_string );
3882 } else if ( c->op == LDAP_MOD_DELETE ) {
3883 c->cleanup = config_tls_cleanup;
3884 return ldap_pvt_tls_set_option( ld, flag, NULL );
3886 ch_free(c->value_string);
3887 c->cleanup = config_tls_cleanup;
3888 return(ldap_pvt_tls_set_option(ld, flag, c->argv[1]));
3891 /* FIXME: this ought to be provided by libldap */
3893 config_tls_config(ConfigArgs *c) {
3896 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; break;
3897 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; break;
3898 case CFG_TLS_PROTOCOL_MIN: flag = LDAP_OPT_X_TLS_PROTOCOL_MIN; break;
3900 Debug(LDAP_DEBUG_ANY, "%s: "
3901 "unknown tls_option <0x%x>\n",
3902 c->log, c->type, 0);
3905 if (c->op == SLAP_CONFIG_EMIT) {
3906 return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
3907 } else if ( c->op == LDAP_MOD_DELETE ) {
3909 c->cleanup = config_tls_cleanup;
3910 return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
3912 ch_free( c->value_string );
3913 c->cleanup = config_tls_cleanup;
3914 if ( isdigit( (unsigned char)c->argv[1][0] ) ) {
3915 if ( lutil_atoi( &i, c->argv[1] ) != 0 ) {
3916 Debug(LDAP_DEBUG_ANY, "%s: "
3917 "unable to parse %s \"%s\"\n",
3918 c->log, c->argv[0], c->argv[1] );
3921 return(ldap_pvt_tls_set_option(slap_tls_ld, flag, &i));
3923 return(ldap_pvt_tls_config(slap_tls_ld, flag, c->argv[1]));
3928 static CfEntryInfo *
3929 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
3939 if ( dn_match( &root->ce_entry->e_nname, dn ))
3942 c = dn->bv_val+dn->bv_len;
3943 for (;*c != ',';c--);
3947 for (--c;c>dn->bv_val && *c != ',';c--);
3951 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
3953 root = root->ce_kids;
3955 for (;root;root=root->ce_sibs) {
3956 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
3957 if ( cdn.bv_val == dn->bv_val ) {
3967 typedef struct setup_cookie {
3977 config_ldif_resp( Operation *op, SlapReply *rs )
3979 if ( rs->sr_type == REP_SEARCH ) {
3980 setup_cookie *sc = op->o_callback->sc_private;
3983 sc->cfb->cb_got_ldif = 1;
3984 /* Does the frontend exist? */
3985 if ( !sc->got_frontend ) {
3986 if ( !strncmp( rs->sr_entry->e_nname.bv_val,
3987 "olcDatabase", STRLENOF( "olcDatabase" )))
3989 if ( strncmp( rs->sr_entry->e_nname.bv_val +
3990 STRLENOF( "olcDatabase" ), "={-1}frontend",
3991 STRLENOF( "={-1}frontend" )))
3995 sc->ca->be = frontendDB;
3996 sc->ca->bi = frontendDB->bd_info;
3997 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
3998 rdn.bv_val = sc->ca->log;
3999 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4000 "%s=" SLAP_X_ORDERED_FMT "%s",
4001 cfAd_database->ad_cname.bv_val, -1,
4002 sc->ca->bi->bi_type);
4004 sc->frontend = config_build_entry( op, rs,
4005 sc->cfb->cb_root, sc->ca, &rdn, &CFOC_DATABASE,
4006 sc->ca->be->be_cf_ocs );
4016 dnParent( &rs->sr_entry->e_nname, &pdn );
4018 /* Does the configDB exist? */
4019 if ( sc->got_frontend && !sc->got_config &&
4020 !strncmp( rs->sr_entry->e_nname.bv_val,
4021 "olcDatabase", STRLENOF( "olcDatabase" )) &&
4022 dn_match( &config_rdn, &pdn ) )
4024 if ( strncmp( rs->sr_entry->e_nname.bv_val +
4025 STRLENOF( "olcDatabase" ), "={0}config",
4026 STRLENOF( "={0}config" )))
4030 sc->ca->be = LDAP_STAILQ_FIRST( &backendDB );
4031 sc->ca->bi = sc->ca->be->bd_info;
4032 rdn.bv_val = sc->ca->log;
4033 rdn.bv_len = snprintf(rdn.bv_val, sizeof( sc->ca->log ),
4034 "%s=" SLAP_X_ORDERED_FMT "%s",
4035 cfAd_database->ad_cname.bv_val, 0,
4036 sc->ca->bi->bi_type);
4038 sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
4039 sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
4046 rs->sr_err = config_add_internal( sc->cfb, rs->sr_entry, sc->ca, NULL, NULL, NULL );
4047 if ( rs->sr_err != LDAP_SUCCESS ) {
4048 Debug( LDAP_DEBUG_ANY, "config error processing %s: %s\n",
4049 rs->sr_entry->e_name.bv_val, sc->ca->cr_msg, 0 );
4055 /* Configure and read the underlying back-ldif store */
4057 config_setup_ldif( BackendDB *be, const char *dir, int readit ) {
4058 CfBackInfo *cfb = be->be_private;
4064 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
4065 Connection conn = {0};
4066 OperationBuffer opbuf;
4068 SlapReply rs = {REP_RESULT};
4069 Filter filter = { LDAP_FILTER_PRESENT };
4070 struct berval filterstr = BER_BVC("(objectclass=*)");
4073 /* Is the config directory available? */
4074 if ( stat( dir, &st ) < 0 ) {
4075 /* No, so don't bother using the backing store.
4076 * All changes will be in-memory only.
4081 cfb->cb_db.bd_info = backend_info( "ldif" );
4082 if ( !cfb->cb_db.bd_info )
4083 return 0; /* FIXME: eventually this will be a fatal error */
4085 if ( backend_db_init( "ldif", &cfb->cb_db, -1, NULL ) == NULL )
4088 cfb->cb_db.be_suffix = be->be_suffix;
4089 cfb->cb_db.be_nsuffix = be->be_nsuffix;
4091 /* The suffix is always "cn=config". The underlying DB's rootdn
4092 * is always the same as the suffix.
4094 cfb->cb_db.be_rootdn = be->be_suffix[0];
4095 cfb->cb_db.be_rootndn = be->be_nsuffix[0];
4097 ber_str2bv( dir, 0, 1, &cfdir );
4102 argv[0] = "directory";
4103 argv[1] = (char *)dir;
4108 c.table = Cft_Database;
4110 ct = config_find_keyword( c.be->be_cf_ocs->co_table, &c );
4114 if ( config_add_vals( ct, &c ))
4117 if ( backend_startup_one( &cfb->cb_db, &c.reply ))
4121 void *thrctx = ldap_pvt_thread_pool_context();
4124 connection_fake_init( &conn, &opbuf, thrctx );
4127 filter.f_desc = slap_schema.si_ad_objectClass;
4129 op->o_tag = LDAP_REQ_SEARCH;
4131 op->ors_filter = &filter;
4132 op->ors_filterstr = filterstr;
4133 op->ors_scope = LDAP_SCOPE_SUBTREE;
4135 op->o_dn = c.be->be_rootdn;
4136 op->o_ndn = c.be->be_rootndn;
4138 op->o_req_dn = be->be_suffix[0];
4139 op->o_req_ndn = be->be_nsuffix[0];
4141 op->ors_tlimit = SLAP_NO_LIMIT;
4142 op->ors_slimit = SLAP_NO_LIMIT;
4144 op->ors_attrs = slap_anlist_all_attributes;
4145 op->ors_attrsonly = 0;
4147 op->o_callback = &cb;
4150 cb.sc_private = ≻
4151 sc.got_frontend = 0;
4156 op->o_bd = &cfb->cb_db;
4158 /* Allow unknown attrs in DNs */
4159 prev_DN_strict = slap_DN_strict;
4162 rc = op->o_bd->be_search( op, &rs );
4164 /* Restore normal DN validation */
4165 slap_DN_strict = prev_DN_strict;
4167 op->o_tag = LDAP_REQ_ADD;
4168 if ( rc == LDAP_SUCCESS && sc.frontend ) {
4169 op->ora_e = sc.frontend;
4170 rc = op->o_bd->be_add( op, &rs );
4172 if ( rc == LDAP_SUCCESS && sc.config ) {
4173 op->ora_e = sc.config;
4174 rc = op->o_bd->be_add( op, &rs );
4176 ldap_pvt_thread_pool_context_reset( thrctx );
4179 /* ITS#4194 - only use if it's present, or we're converting. */
4180 if ( !readit || rc == LDAP_SUCCESS )
4181 cfb->cb_use_ldif = 1;
4187 CfOc_cmp( const void *c1, const void *c2 ) {
4188 const ConfigOCs *co1 = c1;
4189 const ConfigOCs *co2 = c2;
4191 return ber_bvcmp( co1->co_name, co2->co_name );
4195 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
4198 i = init_config_attrs( ct );
4201 /* set up the objectclasses */
4202 i = init_config_ocs( ocs );
4205 for (i=0; ocs[i].co_def; i++) {
4206 if ( ocs[i].co_oc ) {
4207 ocs[i].co_name = &ocs[i].co_oc->soc_cname;
4208 if ( !ocs[i].co_table )
4209 ocs[i].co_table = ct;
4210 avl_insert( &CfOcTree, &ocs[i], CfOc_cmp, avl_dup_error );
4217 read_config(const char *fname, const char *dir) {
4220 const char *cfdir, *cfname;
4223 /* Setup the config backend */
4224 be = backend_db_init( "config", NULL, 0, NULL );
4228 cfb = be->be_private;
4229 be->be_dfltaccess = ACL_NONE;
4231 /* If no .conf, or a dir was specified, setup the dir */
4232 if ( !fname || dir ) {
4234 /* If explicitly given, check for existence */
4237 if ( stat( dir, &st ) < 0 ) {
4238 Debug( LDAP_DEBUG_ANY,
4239 "invalid config directory %s, error %d\n",
4245 cfdir = SLAPD_DEFAULT_CONFIGDIR;
4247 /* if fname is defaulted, try reading .d */
4248 rc = config_setup_ldif( be, cfdir, !fname );
4251 /* It may be OK if the base object doesn't exist yet. */
4252 if ( rc != LDAP_NO_SUCH_OBJECT )
4254 /* ITS#4194: But if dir was specified and no fname,
4255 * then we were supposed to read the dir. Unless we're
4256 * trying to slapadd the dir...
4258 if ( dir && !fname ) {
4259 if ( slapMode & (SLAP_SERVER_MODE|SLAP_TOOL_READMAIN|SLAP_TOOL_READONLY))
4261 /* Assume it's slapadd with a config dir, let it continue */
4263 cfb->cb_got_ldif = 1;
4264 cfb->cb_use_ldif = 1;
4269 /* If we read the config from back-ldif, nothing to do here */
4270 if ( cfb->cb_got_ldif ) {
4279 cfname = SLAPD_DEFAULT_CONFIGFILE;
4281 rc = read_config_file(cfname, 0, NULL, config_back_cf_table);
4284 ber_str2bv( cfname, 0, 1, &cfb->cb_config->c_file );
4287 if ( rc == 0 && BER_BVISNULL( &frontendDB->be_schemadn ) ) {
4288 ber_str2bv( SLAPD_SCHEMA_DN, STRLENOF( SLAPD_SCHEMA_DN ), 1,
4289 &frontendDB->be_schemadn );
4290 rc = dnNormalize( 0, NULL, NULL, &frontendDB->be_schemadn, &frontendDB->be_schemandn, NULL );
4291 if ( rc != LDAP_SUCCESS ) {
4292 Debug(LDAP_DEBUG_ANY, "read_config: "
4293 "unable to normalize default schema DN \"%s\"\n",
4294 frontendDB->be_schemadn.bv_val, 0, 0 );
4295 /* must not happen */
4303 config_back_bind( Operation *op, SlapReply *rs )
4305 if ( be_isroot_pw( op ) ) {
4306 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
4307 /* frontend sends result */
4308 return LDAP_SUCCESS;
4311 rs->sr_err = LDAP_INVALID_CREDENTIALS;
4312 send_ldap_result( op, rs );
4318 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
4322 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
4324 rs->sr_attrs = op->ors_attrs;
4325 rs->sr_entry = ce->ce_entry;
4327 rc = send_search_entry( op, rs );
4328 if ( rc != LDAP_SUCCESS ) {
4332 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
4333 if ( ce->ce_kids ) {
4334 rc = config_send( op, rs, ce->ce_kids, 1 );
4335 if ( rc ) return rc;
4338 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
4339 rc = config_send( op, rs, ce, 0 );
4347 static ConfigTable *
4348 config_find_table( ConfigOCs **colst, int nocs, AttributeDescription *ad,
4353 for (j=0; j<nocs; j++) {
4354 for (i=0; colst[j]->co_table[i].name; i++)
4355 if ( colst[j]->co_table[i].ad == ad ) {
4356 ca->table = colst[j]->co_type;
4357 return &colst[j]->co_table[i];
4363 /* Sort the attributes of the entry according to the order defined
4364 * in the objectclass, with required attributes occurring before
4365 * allowed attributes. For any attributes with sequencing dependencies
4366 * (e.g., rootDN must be defined after suffix) the objectclass must
4367 * list the attributes in the desired sequence.
4370 sort_attrs( Entry *e, ConfigOCs **colst, int nocs )
4372 Attribute *a, *head = NULL, *tail = NULL, **prev;
4375 for (i=0; i<nocs; i++) {
4376 if ( colst[i]->co_oc->soc_required ) {
4377 AttributeType **at = colst[i]->co_oc->soc_required;
4378 for (j=0; at[j]; j++) {
4379 for (a=e->e_attrs, prev=&e->e_attrs; a;
4380 prev = &(*prev)->a_next, a=a->a_next) {
4381 if ( a->a_desc == at[j]->sat_ad ) {
4395 if ( colst[i]->co_oc->soc_allowed ) {
4396 AttributeType **at = colst[i]->co_oc->soc_allowed;
4397 for (j=0; at[j]; j++) {
4398 for (a=e->e_attrs, prev=&e->e_attrs; a;
4399 prev = &(*prev)->a_next, a=a->a_next) {
4400 if ( a->a_desc == at[j]->sat_ad ) {
4416 tail->a_next = e->e_attrs;
4422 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
4424 Attribute *a = NULL;
4425 AttributeDescription *ad;
4435 Modifications *ml = ptr;
4437 vals = ml->sml_values;
4440 if ( a && ( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL )) {
4441 rc = ordered_value_sort( a, 1 );
4443 snprintf(ca->cr_msg, sizeof( ca->cr_msg ), "ordered_value_sort failed on attr %s\n",
4444 ad->ad_cname.bv_val );
4448 for ( i=0; vals[i].bv_val; i++ ) {
4449 ca->line = vals[i].bv_val;
4450 if (( ad->ad_type->sat_flags & SLAP_AT_ORDERED_VAL ) &&
4451 ca->line[0] == '{' ) {
4452 char *idx = strchr( ca->line, '}' );
4453 if ( idx ) ca->line = idx+1;
4455 rc = config_parse_vals( ct, ca, i );
4464 config_rename_attr( SlapReply *rs, Entry *e, struct berval *rdn,
4467 struct berval rtype, rval;
4469 AttributeDescription *ad = NULL;
4471 dnRdn( &e->e_name, rdn );
4472 rval.bv_val = strchr(rdn->bv_val, '=' ) + 1;
4473 rval.bv_len = rdn->bv_len - (rval.bv_val - rdn->bv_val);
4474 rtype.bv_val = rdn->bv_val;
4475 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
4478 slap_bv2ad( &rtype, &ad, &rs->sr_text );
4479 a = attr_find( e->e_attrs, ad );
4480 if (!a ) return LDAP_NAMING_VIOLATION;
4487 config_rename_kids( CfEntryInfo *ce )
4490 struct berval rdn, nrdn;
4492 for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
4493 struct berval newdn, newndn;
4494 dnRdn ( &ce2->ce_entry->e_name, &rdn );
4495 dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
4496 build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
4497 build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
4498 free( ce2->ce_entry->e_name.bv_val );
4499 free( ce2->ce_entry->e_nname.bv_val );
4500 ce2->ce_entry->e_name = newdn;
4501 ce2->ce_entry->e_nname = newndn;
4502 config_rename_kids( ce2 );
4507 config_rename_one( Operation *op, SlapReply *rs, Entry *e,
4508 CfEntryInfo *parent, Attribute *a, struct berval *newrdn,
4509 struct berval *nnewrdn, int use_ldif )
4513 struct berval odn, ondn;
4517 build_new_dn( &e->e_name, &parent->ce_entry->e_name, newrdn, NULL );
4518 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname, nnewrdn, NULL );
4521 free( a->a_vals[0].bv_val );
4522 ptr1 = strchr( newrdn->bv_val, '=' ) + 1;
4523 a->a_vals[0].bv_len = newrdn->bv_len - (ptr1 - newrdn->bv_val);
4524 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
4525 strcpy( a->a_vals[0].bv_val, ptr1 );
4527 if ( a->a_nvals != a->a_vals ) {
4528 free( a->a_nvals[0].bv_val );
4529 ptr1 = strchr( nnewrdn->bv_val, '=' ) + 1;
4530 a->a_nvals[0].bv_len = nnewrdn->bv_len - (ptr1 - nnewrdn->bv_val);
4531 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
4532 strcpy( a->a_nvals[0].bv_val, ptr1 );
4535 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
4536 BackendDB *be = op->o_bd;
4537 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
4538 struct berval dn, ndn, xdn, xndn;
4540 op->o_bd = &cfb->cb_db;
4542 /* Save current rootdn; use the underlying DB's rootdn */
4546 xndn = op->o_req_ndn;
4547 op->o_dn = op->o_bd->be_rootdn;
4548 op->o_ndn = op->o_bd->be_rootndn;
4550 op->o_req_ndn = ondn;
4552 scp = op->o_callback;
4553 op->o_callback = ≻
4554 op->orr_newrdn = *newrdn;
4555 op->orr_nnewrdn = *nnewrdn;
4556 op->orr_newSup = NULL;
4557 op->orr_nnewSup = NULL;
4558 op->orr_deleteoldrdn = 1;
4559 op->orr_modlist = NULL;
4560 slap_modrdn2mods( op, rs );
4561 slap_mods_opattrs( op, &op->orr_modlist, 1 );
4562 rc = op->o_bd->be_modrdn( op, rs );
4563 slap_mods_free( op->orr_modlist, 1 );
4566 op->o_callback = scp;
4570 op->o_req_ndn = xndn;
4573 free( ondn.bv_val );
4575 config_rename_kids( e->e_private );
4580 config_renumber_one( Operation *op, SlapReply *rs, CfEntryInfo *parent,
4581 Entry *e, int idx, int tailindex, int use_ldif )
4583 struct berval ival, newrdn, nnewrdn;
4586 char ibuf[32], *ptr1, *ptr2 = NULL;
4589 rc = config_rename_attr( rs, e, &rdn, &a );
4590 if ( rc ) return rc;
4593 ival.bv_len = snprintf( ibuf, sizeof( ibuf ), SLAP_X_ORDERED_FMT, idx );
4594 if ( ival.bv_len >= sizeof( ibuf ) ) {
4595 return LDAP_NAMING_VIOLATION;
4598 newrdn.bv_len = rdn.bv_len + ival.bv_len;
4599 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
4602 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
4603 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4606 ptr2 = ber_bvchr( &rdn, '}' );
4610 ptr2 = rdn.bv_val + a->a_desc->ad_cname.bv_len + 1;
4612 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
4613 ptr1 = lutil_strncopy( newrdn.bv_val, a->a_desc->ad_cname.bv_val,
4614 a->a_desc->ad_cname.bv_len );
4616 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
4617 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
4621 /* Do the equivalent of ModRDN */
4622 /* Replace DN / NDN */
4623 newrdn.bv_len = ptr1 - newrdn.bv_val;
4624 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
4625 rc = config_rename_one( op, rs, e, parent, a, &newrdn, &nnewrdn, use_ldif );
4627 free( nnewrdn.bv_val );
4628 free( newrdn.bv_val );
4633 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
4634 SlapReply *rs, int *renum, int *ibase )
4637 int index = -1, gotindex = 0, nsibs, rc = 0;
4638 int renumber = 0, tailindex = 0, isfrontend = 0, isconfig = 0;
4639 char *ptr1, *ptr2 = NULL;
4642 if ( renum ) *renum = 0;
4644 /* These entries don't get indexed/renumbered */
4645 if ( ce_type == Cft_Global ) return 0;
4646 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
4648 if ( ce_type == Cft_Module )
4651 /* See if the rdn has an index already */
4652 dnRdn( &e->e_name, &rdn );
4653 if ( ce_type == Cft_Database ) {
4654 if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("frontend"),
4655 "frontend", STRLENOF("frontend") ))
4657 else if ( !strncmp( rdn.bv_val + rdn.bv_len - STRLENOF("config"),
4658 "config", STRLENOF("config") ))
4661 ptr1 = ber_bvchr( &e->e_name, '{' );
4662 if ( ptr1 && ptr1 < &e->e_name.bv_val[ rdn.bv_len ] ) {
4664 ptr2 = strchr( ptr1, '}' );
4665 if ( !ptr2 || ptr2 > &e->e_name.bv_val[ rdn.bv_len ] )
4666 return LDAP_NAMING_VIOLATION;
4667 if ( ptr2-ptr1 == 1)
4668 return LDAP_NAMING_VIOLATION;
4670 index = strtol( ptr1 + 1, &next, 10 );
4671 if ( next == ptr1 + 1 || next[ 0 ] != '}' ) {
4672 return LDAP_NAMING_VIOLATION;
4675 /* Special case, we allow -1 for the frontendDB */
4676 if ( index != -1 || !isfrontend )
4677 return LDAP_NAMING_VIOLATION;
4679 if ( isconfig && index != 0 ){
4680 return LDAP_NAMING_VIOLATION;
4684 /* count related kids */
4685 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
4686 if ( ce->ce_type == ce_type ) nsibs++;
4689 /* account for -1 frontend */
4690 if ( ce_type == Cft_Database )
4693 if ( index != nsibs ) {
4695 if ( index < nsibs ) {
4696 if ( tailindex ) return LDAP_NAMING_VIOLATION;
4697 /* Siblings need to be renumbered */
4698 if ( index != -1 || !isfrontend )
4702 /* config DB is always "0" */
4703 if ( isconfig && index == -1 ) {
4706 if (( !isfrontend && index == -1 ) || ( index > nsibs ) ){
4710 /* just make index = nsibs */
4712 rc = config_renumber_one( NULL, rs, parent, e, index, tailindex, 0 );
4715 if ( ibase ) *ibase = index;
4716 if ( renum ) *renum = renumber;
4721 count_oc( ObjectClass *oc, ConfigOCs ***copp, int *nocs )
4726 co.co_name = &oc->soc_cname;
4727 cop = avl_find( CfOcTree, &co, CfOc_cmp );
4731 /* check for duplicates */
4732 for ( i = 0; i < *nocs; i++ ) {
4733 if ( *copp && (*copp)[i] == cop ) {
4739 ConfigOCs **tmp = ch_realloc( *copp, (*nocs + 1)*sizeof( ConfigOCs * ) );
4740 if ( tmp == NULL ) {
4744 (*copp)[*nocs] = cop;
4749 for ( sups = oc->soc_sups; sups && *sups; sups++ ) {
4750 if ( count_oc( *sups, copp, nocs ) ) {
4759 count_ocs( Attribute *oc_at, int *nocs )
4762 ConfigOCs **colst = NULL;
4766 for ( i = 0; !BER_BVISNULL( &oc_at->a_nvals[i] ); i++ )
4770 ObjectClass *oc = oc_bvfind( &oc_at->a_nvals[i] );
4772 assert( oc != NULL );
4773 if ( count_oc( oc, &colst, nocs ) ) {
4783 cfAddInclude( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4785 /* Leftover from RE23. Never parse this entry */
4786 return LDAP_COMPARE_TRUE;
4790 cfAddSchema( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
4794 /* This entry is hardcoded, don't re-parse it */
4795 if ( p->ce_type == Cft_Global ) {
4796 cfn = p->ce_private;
4797 ca->ca_private = cfn;
4798 return LDAP_COMPARE_TRUE;
4800 if ( p->ce_type != Cft_Schema )
4801 return LDAP_CONSTRAINT_VIOLATION;
4803 cfn = ch_calloc( 1, sizeof(ConfigFile) );
4804 ca->ca_private = cfn;
4805 cfo = p->ce_private;
4806 cfn->c_sibs = cfo->c_kids;
4808 return LDAP_SUCCESS;
4812 cfAddDatabase( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4814 if ( p->ce_type != Cft_Global ) {
4815 return LDAP_CONSTRAINT_VIOLATION;
4817 /* config must be {0}, nothing else allowed */
4818 if ( !strncmp( e->e_nname.bv_val, "olcDatabase={0}", STRLENOF("olcDatabase={0}")) &&
4819 strncmp( e->e_nname.bv_val + STRLENOF("olcDatabase={0}"), "config,", STRLENOF("config,") )) {
4820 return LDAP_CONSTRAINT_VIOLATION;
4822 ca->be = frontendDB; /* just to get past check_vals */
4823 return LDAP_SUCCESS;
4827 cfAddBackend( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4829 if ( p->ce_type != Cft_Global ) {
4830 return LDAP_CONSTRAINT_VIOLATION;
4832 return LDAP_SUCCESS;
4836 cfAddModule( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4838 if ( p->ce_type != Cft_Global ) {
4839 return LDAP_CONSTRAINT_VIOLATION;
4841 return LDAP_SUCCESS;
4845 cfAddOverlay( CfEntryInfo *p, Entry *e, struct config_args_s *ca )
4847 if ( p->ce_type != Cft_Database ) {
4848 return LDAP_CONSTRAINT_VIOLATION;
4851 return LDAP_SUCCESS;
4855 schema_destroy_one( ConfigArgs *ca, ConfigOCs **colst, int nocs,
4860 AttributeDescription *ad;
4866 if ( cfn->c_cr_head ) {
4867 struct berval bv = BER_BVC("olcDitContentRules");
4869 slap_bv2ad( &bv, &ad, &text );
4870 ct = config_find_table( colst, nocs, ad, ca );
4871 config_del_vals( ct, ca );
4873 if ( cfn->c_oc_head ) {
4874 struct berval bv = BER_BVC("olcObjectClasses");
4876 slap_bv2ad( &bv, &ad, &text );
4877 ct = config_find_table( colst, nocs, ad, ca );
4878 config_del_vals( ct, ca );
4880 if ( cfn->c_at_head ) {
4881 struct berval bv = BER_BVC("olcAttributeTypes");
4883 slap_bv2ad( &bv, &ad, &text );
4884 ct = config_find_table( colst, nocs, ad, ca );
4885 config_del_vals( ct, ca );
4887 if ( cfn->c_syn_head ) {
4888 struct berval bv = BER_BVC("olcLdapSyntaxes");
4890 slap_bv2ad( &bv, &ad, &text );
4891 ct = config_find_table( colst, nocs, ad, ca );
4892 config_del_vals( ct, ca );
4894 if ( cfn->c_om_head ) {
4895 struct berval bv = BER_BVC("olcObjectIdentifier");
4897 slap_bv2ad( &bv, &ad, &text );
4898 ct = config_find_table( colst, nocs, ad, ca );
4899 config_del_vals( ct, ca );
4901 cfo = p->ce_private;
4902 cfo->c_kids = cfn->c_sibs;
4907 config_add_oc( ConfigOCs **cop, CfEntryInfo *last, Entry *e, ConfigArgs *ca )
4909 int rc = LDAP_CONSTRAINT_VIOLATION;
4912 if ( (*cop)->co_ldadd ) {
4913 rc = (*cop)->co_ldadd( last, e, ca );
4914 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4919 for ( ocp = (*cop)->co_oc->soc_sups; ocp && *ocp; ocp++ ) {
4920 ConfigOCs co = { 0 };
4922 co.co_name = &(*ocp)->soc_cname;
4923 *cop = avl_find( CfOcTree, &co, CfOc_cmp );
4924 if ( *cop == NULL ) {
4928 rc = config_add_oc( cop, last, e, ca );
4929 if ( rc != LDAP_CONSTRAINT_VIOLATION ) {
4937 /* Parse an LDAP entry into config directives */
4939 config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs,
4940 int *renum, Operation *op )
4942 CfEntryInfo *ce, *last = NULL;
4943 ConfigOCs co, *coptr, **colst;
4944 Attribute *a, *oc_at, *soc_at;
4945 int i, ibase = -1, nocs, rc = 0;
4948 char *ptr, *log_prefix = op ? op->o_log_prefix : "";
4950 memset( ca, 0, sizeof(ConfigArgs));
4952 /* Make sure parent exists and entry does not. But allow
4953 * Databases and Overlays to be inserted. Don't do any
4954 * auto-renumbering if manageDSAit control is present.
4956 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
4958 if ( ( op && op->o_managedsait ) ||
4959 ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay &&
4960 ce->ce_type != Cft_Module ) )
4962 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4963 "DN=\"%s\" already exists\n",
4964 log_prefix, e->e_name.bv_val, 0 );
4965 /* global schema ignores all writes */
4966 if ( ce->ce_type == Cft_Schema && ce->ce_parent->ce_type == Cft_Global )
4967 return LDAP_COMPARE_TRUE;
4968 return LDAP_ALREADY_EXISTS;
4972 dnParent( &e->e_nname, &pdn );
4974 /* If last is NULL, the new entry is the root/suffix entry,
4975 * otherwise last should be the parent.
4977 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) {
4979 rs->sr_matched = last->ce_entry->e_name.bv_val;
4981 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4982 "DN=\"%s\" not child of DN=\"%s\"\n",
4983 log_prefix, e->e_name.bv_val,
4984 last->ce_entry->e_name.bv_val );
4985 return LDAP_NO_SUCH_OBJECT;
4989 /* No parent, must be root. This will never happen... */
4990 if ( !last && !be_isroot( op ) && !be_shadow_update( op ) ) {
4991 return LDAP_NO_SUCH_OBJECT;
4994 if ( last && !access_allowed( op, last->ce_entry,
4995 slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) )
4997 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
4998 "DN=\"%s\" no write access to \"children\" of parent\n",
4999 log_prefix, e->e_name.bv_val, 0 );
5000 return LDAP_INSUFFICIENT_ACCESS;
5004 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5006 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5007 "DN=\"%s\" no objectClass\n",
5008 log_prefix, e->e_name.bv_val, 0 );
5009 return LDAP_OBJECT_CLASS_VIOLATION;
5012 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5014 ObjectClass *soc = NULL;
5015 char textbuf[ SLAP_TEXT_BUFLEN ];
5016 const char *text = textbuf;
5018 /* FIXME: check result */
5019 rc = structural_class( oc_at->a_nvals, &soc, NULL,
5020 &text, textbuf, sizeof(textbuf), NULL );
5021 if ( rc != LDAP_SUCCESS ) {
5022 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5023 "DN=\"%s\" no structural objectClass (%s)\n",
5024 log_prefix, e->e_name.bv_val, text );
5027 attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, NULL );
5028 soc_at = attr_find( e->e_attrs, slap_schema.si_ad_structuralObjectClass );
5029 if ( soc_at == NULL ) {
5030 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5031 "DN=\"%s\" no structural objectClass; "
5032 "unable to merge computed class %s\n",
5033 log_prefix, e->e_name.bv_val,
5034 soc->soc_cname.bv_val );
5035 return LDAP_OBJECT_CLASS_VIOLATION;
5038 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5039 "DN=\"%s\" no structural objectClass; "
5040 "computed objectClass %s merged\n",
5041 log_prefix, e->e_name.bv_val,
5042 soc->soc_cname.bv_val );
5045 /* Fake the coordinates based on whether we're part of an
5046 * LDAP Add or if reading the config dir
5049 ca->fname = "slapd";
5052 ca->fname = cfdir.bv_val;
5057 co.co_name = &soc_at->a_nvals[0];
5058 coptr = avl_find( CfOcTree, &co, CfOc_cmp );
5059 if ( coptr == NULL ) {
5060 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5061 "DN=\"%s\" no structural objectClass in configuration table\n",
5062 log_prefix, e->e_name.bv_val, 0 );
5063 return LDAP_OBJECT_CLASS_VIOLATION;
5066 /* Only the root can be Cft_Global, everything else must
5067 * have a parent. Only limited nesting arrangements are allowed.
5069 rc = LDAP_CONSTRAINT_VIOLATION;
5070 if ( coptr->co_type == Cft_Global && !last ) {
5071 cfn = cfb->cb_config;
5072 ca->ca_private = cfn;
5073 ca->be = frontendDB; /* just to get past check_vals */
5077 colst = count_ocs( oc_at, &nocs );
5079 /* Check whether the Add is allowed by its parent, and do
5080 * any necessary arg setup
5083 rc = config_add_oc( &coptr, last, e, ca );
5084 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5085 for ( i = 0; i<nocs; i++ ) {
5086 /* Already checked these */
5087 if ( colst[i]->co_oc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
5089 if ( colst[i]->co_ldadd &&
5090 ( rc = colst[i]->co_ldadd( last, e, ca ))
5091 != LDAP_CONSTRAINT_VIOLATION ) {
5097 if ( rc == LDAP_CONSTRAINT_VIOLATION ) {
5098 Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: "
5099 "DN=\"%s\" no structural objectClass add function\n",
5100 log_prefix, e->e_name.bv_val, 0 );
5101 return LDAP_OBJECT_CLASS_VIOLATION;
5105 /* Add the entry but don't parse it, we already have its contents */
5106 if ( rc == LDAP_COMPARE_TRUE ) {
5111 if ( rc != LDAP_SUCCESS )
5114 /* Parse all the values and check for simple syntax errors before
5115 * performing any set actions.
5117 * If doing an LDAPadd, check for indexed names and any necessary
5118 * renaming/renumbering. Entries that don't need indexed names are
5119 * ignored. Entries that need an indexed name and arrive without one
5120 * are assigned to the end. Entries that arrive with an index may
5121 * cause the following entries to be renumbered/bumped down.
5123 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
5124 * don't allow Adding an entry with an index that's already in use.
5125 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
5127 * These entries can have auto-assigned indexes (appended to the end)
5128 * but only the other types support auto-renumbering of siblings.
5131 rc = check_name_index( last, coptr->co_type, e, rs, renum,
5136 if ( renum && *renum && coptr->co_type != Cft_Database &&
5137 coptr->co_type != Cft_Overlay )
5139 snprintf( ca->cr_msg, sizeof( ca->cr_msg ),
5140 "operation requires sibling renumbering" );
5141 rc = LDAP_UNWILLING_TO_PERFORM;
5146 init_config_argv( ca );
5148 /* Make sure we process attrs in the required order */
5149 sort_attrs( e, colst, nocs );
5151 for ( a = e->e_attrs; a; a = a->a_next ) {
5152 if ( a == oc_at ) continue;
5153 ct = config_find_table( colst, nocs, a->a_desc, ca );
5154 if ( !ct ) continue; /* user data? */
5155 rc = check_vals( ct, ca, a, 1 );
5156 if ( rc ) goto done_noop;
5159 /* Basic syntax checks are OK. Do the actual settings. */
5160 for ( a=e->e_attrs; a; a=a->a_next ) {
5161 if ( a == oc_at ) continue;
5162 ct = config_find_table( colst, nocs, a->a_desc, ca );
5163 if ( !ct ) continue; /* user data? */
5164 for (i=0; a->a_vals[i].bv_val; i++) {
5167 ca->line = a->a_vals[i].bv_val;
5168 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
5169 ptr = strchr( ca->line, '}' );
5171 iptr = strchr( ca->line, '{' );
5175 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED_SIB ) {
5177 ca->valx = strtol( iptr+1, NULL, 0 );
5182 rc = config_parse_add( ct, ca, i );
5190 /* Newly added databases and overlays need to be started up */
5191 if ( CONFIG_ONLINE_ADD( ca )) {
5192 if ( coptr->co_type == Cft_Database ) {
5193 rc = backend_startup_one( ca->be, &ca->reply );
5195 } else if ( coptr->co_type == Cft_Overlay ) {
5196 if ( ca->bi->bi_db_open ) {
5197 BackendInfo *bi_orig = ca->be->bd_info;
5198 ca->be->bd_info = ca->bi;
5199 rc = ca->bi->bi_db_open( ca->be, &ca->reply );
5200 ca->be->bd_info = bi_orig;
5202 } else if ( ca->cleanup ) {
5203 rc = ca->cleanup( ca );
5206 if (ca->cr_msg[0] == '\0')
5207 snprintf( ca->cr_msg, sizeof( ca->cr_msg ), "<%s> failed startup", ca->argv[0] );
5209 Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
5210 ca->log, ca->cr_msg, ca->argv[1] );
5217 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
5218 ce->ce_parent = last;
5219 ce->ce_entry = entry_dup( e );
5220 ce->ce_entry->e_private = ce;
5221 ce->ce_type = coptr->co_type;
5224 ce->ce_private = ca->ca_private;
5225 ca->ca_entry = ce->ce_entry;
5228 } else if ( last->ce_kids ) {
5229 CfEntryInfo *c2, **cprev;
5231 /* Advance to first of this type */
5232 cprev = &last->ce_kids;
5233 for ( c2 = *cprev; c2 && c2->ce_type < ce->ce_type; ) {
5234 cprev = &c2->ce_sibs;
5237 /* Account for the (-1) frontendDB entry */
5238 if ( ce->ce_type == Cft_Database ) {
5239 if ( ca->be == frontendDB )
5241 else if ( ibase != -1 )
5246 for (c2 = *cprev; c2 && c2->ce_type == ce->ce_type;) {
5247 cprev = &c2->ce_sibs;
5253 for ( i=0; i<ibase; i++ ) {
5255 cprev = &c2->ce_sibs;
5258 ce->ce_sibs = *cprev;
5266 if ( (coptr->co_type == Cft_Database) && ca->be ) {
5267 if ( ca->be != frontendDB )
5268 backend_destroy_one( ca->be, 1 );
5269 } else if ( (coptr->co_type == Cft_Overlay) && ca->bi ) {
5270 overlay_destroy_one( ca->be, (slap_overinst *)ca->bi );
5271 } else if ( coptr->co_type == Cft_Schema ) {
5272 schema_destroy_one( ca, colst, nocs, last );
5277 ch_free( ca->argv );
5278 if ( colst ) ch_free( colst );
5282 #define BIGTMP 10000
5284 config_rename_add( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5285 int base, int rebase, int max, int use_ldif )
5287 CfEntryInfo *ce2, *ce3, *cetmp = NULL, *cerem = NULL;
5288 ConfigType etype = ce->ce_type;
5289 int count = 0, rc = 0;
5291 /* Reverse ce list */
5292 for (ce2 = ce->ce_sibs;ce2;ce2 = ce3) {
5293 if (ce2->ce_type != etype) {
5298 ce2->ce_sibs = cetmp;
5301 if ( max && count >= max ) {
5307 /* Move original to a temp name until increments are done */
5309 ce->ce_entry->e_private = NULL;
5310 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5311 base+BIGTMP, 0, use_ldif );
5312 ce->ce_entry->e_private = ce;
5314 /* start incrementing */
5315 for (ce2=cetmp; ce2; ce2=ce3) {
5317 ce2->ce_sibs = cerem;
5320 rc = config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5321 count+base, 0, use_ldif );
5325 rc = config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5326 base, 0, use_ldif );
5331 config_rename_del( Operation *op, SlapReply *rs, CfEntryInfo *ce,
5332 CfEntryInfo *ce2, int old, int use_ldif )
5336 /* Renumber original to a temp value */
5337 ce->ce_entry->e_private = NULL;
5338 config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5339 old+BIGTMP, 0, use_ldif );
5340 ce->ce_entry->e_private = ce;
5342 /* start decrementing */
5343 for (; ce2 != ce; ce2=ce2->ce_sibs) {
5344 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
5345 count+old, 0, use_ldif );
5348 return config_renumber_one( op, rs, ce->ce_parent, ce->ce_entry,
5349 count+old, 0, use_ldif );
5352 /* Parse an LDAP entry into config directives, then store in underlying
5356 config_back_add( Operation *op, SlapReply *rs )
5362 if ( !access_allowed( op, op->ora_e, slap_schema.si_ad_entry,
5363 NULL, ACL_WADD, NULL )) {
5364 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5369 * Check for attribute ACL
5371 if ( !acl_check_modlist( op, op->ora_e, op->orm_modlist )) {
5372 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5373 rs->sr_text = "no write access to attribute";
5377 cfb = (CfBackInfo *)op->o_bd->be_private;
5379 /* add opattrs for syncprov */
5381 char textbuf[SLAP_TEXT_BUFLEN];
5382 size_t textlen = sizeof textbuf;
5383 rs->sr_err = entry_schema_check(op, op->ora_e, NULL, 0, 1, NULL,
5384 &rs->sr_text, textbuf, sizeof( textbuf ) );
5385 if ( rs->sr_err != LDAP_SUCCESS )
5387 rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
5388 if ( rs->sr_err != LDAP_SUCCESS ) {
5389 Debug( LDAP_DEBUG_TRACE,
5390 LDAP_XSTRING(config_back_add) ": entry failed op attrs add: "
5391 "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
5396 if ( op->o_abandon ) {
5397 rs->sr_err = SLAPD_ABANDON;
5400 ldap_pvt_thread_pool_pause( &connection_pool );
5403 * 1) check for existence of entry
5404 * 2) check for sibling renumbering
5405 * 3) perform internal add
5406 * 4) perform any necessary renumbering
5407 * 5) store entry in underlying database
5409 rs->sr_err = config_add_internal( cfb, op->ora_e, &ca, rs, &renumber, op );
5410 if ( rs->sr_err != LDAP_SUCCESS ) {
5411 rs->sr_text = ca.cr_msg;
5416 CfEntryInfo *ce = ca.ca_entry->e_private;
5417 req_add_s addr = op->oq_add;
5418 op->o_tag = LDAP_REQ_MODRDN;
5419 rs->sr_err = config_rename_add( op, rs, ce, ca.valx, 0, 0, cfb->cb_use_ldif );
5420 op->o_tag = LDAP_REQ_ADD;
5422 if ( rs->sr_err != LDAP_SUCCESS ) {
5427 if ( cfb->cb_use_ldif ) {
5428 BackendDB *be = op->o_bd;
5429 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5430 struct berval dn, ndn;
5432 op->o_bd = &cfb->cb_db;
5434 /* Save current rootdn; use the underlying DB's rootdn */
5437 op->o_dn = op->o_bd->be_rootdn;
5438 op->o_ndn = op->o_bd->be_rootndn;
5440 scp = op->o_callback;
5441 op->o_callback = ≻
5442 op->o_bd->be_add( op, rs );
5444 op->o_callback = scp;
5450 ldap_pvt_thread_pool_resume( &connection_pool );
5453 { int repl = op->o_dont_replicate;
5454 if ( rs->sr_err == LDAP_COMPARE_TRUE ) {
5455 rs->sr_err = LDAP_SUCCESS;
5456 op->o_dont_replicate = 1;
5458 send_ldap_result( op, rs );
5459 op->o_dont_replicate = repl;
5461 slap_graduate_commit_csn( op );
5465 typedef struct delrec {
5466 struct delrec *next;
5472 config_modify_add( ConfigTable *ct, ConfigArgs *ca, AttributeDescription *ad,
5478 if (ad->ad_type->sat_flags & SLAP_AT_ORDERED &&
5479 ca->line[0] == '{' )
5481 char *ptr = strchr( ca->line + 1, '}' );
5485 ca->valx = strtol( ca->line + 1, &next, 0 );
5486 if ( next == ca->line + 1 || next[ 0 ] != '}' ) {
5492 rc = config_parse_add( ct, ca, i );
5500 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
5503 int rc = LDAP_UNWILLING_TO_PERFORM;
5505 Entry *e = ce->ce_entry;
5506 Attribute *save_attrs = e->e_attrs, *oc_at, *s, *a;
5511 delrec *dels = NULL, *deltail = NULL;
5513 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
5514 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
5516 colst = count_ocs( oc_at, &nocs );
5518 /* make sure add/del flags are clear; should always be true */
5519 for ( s = save_attrs; s; s = s->a_next ) {
5520 s->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
5523 e->e_attrs = attrs_dup( e->e_attrs );
5525 init_config_argv( ca );
5528 ca->ca_private = ce->ce_private;
5530 ca->fname = "slapd";
5532 strcpy( ca->log, "back-config" );
5534 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
5535 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5536 switch (ml->sml_op) {
5537 case LDAP_MOD_DELETE:
5538 case LDAP_MOD_REPLACE: {
5539 BerVarray vals = NULL, nvals = NULL;
5541 if ( ct && ( ct->arg_type & ARG_NO_DELETE )) {
5543 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot delete %s",
5544 ml->sml_desc->ad_cname.bv_val );
5547 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5548 vals = ml->sml_values;
5549 nvals = ml->sml_nvalues;
5550 ml->sml_values = NULL;
5551 ml->sml_nvalues = NULL;
5553 /* If we're deleting by values, remember the indexes of the
5554 * values we deleted.
5556 if ( ct && ml->sml_values ) {
5558 i = ml->sml_numvals;
5559 d = ch_malloc( sizeof(delrec) + (i - 1)* sizeof(int));
5570 rc = modify_delete_vindex(e, &ml->sml_mod,
5571 get_permissiveModify(op),
5572 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg), idx );
5573 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5574 ml->sml_values = vals;
5575 ml->sml_nvalues = nvals;
5580 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5583 case SLAP_MOD_SOFTADD: {
5584 int mop = ml->sml_op;
5586 ml->sml_op = LDAP_MOD_ADD;
5588 if ( ct->arg_type & ARG_NO_INSERT ) {
5589 Attribute *a = attr_find( e->e_attrs, ml->sml_desc );
5591 navals = a->a_numvals;
5594 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
5595 if ( ml->sml_values[i].bv_val[0] == '{' &&
5598 char *next, *val = ml->sml_values[i].bv_val + 1;
5601 j = strtol( val, &next, 0 );
5602 if ( next == val || next[ 0 ] != '}' || j < navals ) {
5604 snprintf(ca->cr_msg, sizeof(ca->cr_msg), "cannot insert %s",
5605 ml->sml_desc->ad_cname.bv_val );
5609 rc = check_vals( ct, ca, ml, 0 );
5610 if ( rc ) goto out_noop;
5613 rc = modify_add_values(e, &ml->sml_mod,
5614 get_permissiveModify(op),
5615 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5617 /* If value already exists, show success here
5618 * and ignore this operation down below.
5620 if ( mop == SLAP_MOD_SOFTADD ) {
5621 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
5631 case LDAP_MOD_INCREMENT: /* FIXME */
5636 if(rc != LDAP_SUCCESS) break;
5639 if ( rc == LDAP_SUCCESS) {
5640 /* check that the entry still obeys the schema */
5641 rc = entry_schema_check(op, e, NULL, 0, 0, NULL,
5642 &rs->sr_text, ca->cr_msg, sizeof(ca->cr_msg) );
5644 if ( rc ) goto out_noop;
5646 /* Basic syntax checks are OK. Do the actual settings. */
5647 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5648 ct = config_find_table( colst, nocs, ml->sml_desc, ca );
5649 if ( !ct ) continue;
5651 s = attr_find( save_attrs, ml->sml_desc );
5652 a = attr_find( e->e_attrs, ml->sml_desc );
5654 switch (ml->sml_op) {
5655 case LDAP_MOD_DELETE:
5656 case LDAP_MOD_REPLACE: {
5657 BerVarray vals = NULL, nvals = NULL;
5660 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5661 vals = ml->sml_values;
5662 nvals = ml->sml_nvalues;
5663 ml->sml_values = NULL;
5664 ml->sml_nvalues = NULL;
5667 if ( ml->sml_values )
5670 /* If we didn't delete the whole attribute */
5671 if ( ml->sml_values && a ) {
5672 struct berval *mvals;
5675 if ( ml->sml_nvalues )
5676 mvals = ml->sml_nvalues;
5678 mvals = ml->sml_values;
5680 /* use the indexes we saved up above */
5681 for (i=0; i < d->nidx; i++) {
5682 struct berval bv = *mvals++;
5683 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED &&
5684 bv.bv_val[0] == '{' ) {
5685 ptr = strchr( bv.bv_val, '}' ) + 1;
5686 bv.bv_len -= ptr - bv.bv_val;
5689 ca->line = bv.bv_val;
5690 ca->valx = d->idx[i];
5691 config_parse_vals(ct, ca, d->idx[i] );
5692 rc = config_del_vals( ct, ca );
5693 if ( rc != LDAP_SUCCESS ) break;
5695 s->a_flags |= SLAP_ATTR_IXDEL;
5696 for (j=i+1; j < d->nidx; j++)
5697 if ( d->idx[j] >d->idx[i] )
5704 rc = config_del_vals( ct, ca );
5705 if ( rc ) rc = LDAP_OTHER;
5707 s->a_flags |= SLAP_ATTR_IXDEL;
5709 if ( ml->sml_values ) {
5714 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
5715 ml->sml_values = vals;
5716 ml->sml_nvalues = nvals;
5718 if ( !vals || rc != LDAP_SUCCESS )
5721 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
5724 for (i=0; ml->sml_values[i].bv_val; i++) {
5725 ca->line = ml->sml_values[i].bv_val;
5727 rc = config_modify_add( ct, ca, ml->sml_desc, i );
5730 a->a_flags |= SLAP_ATTR_IXADD;
5737 /* Undo for a failed operation */
5738 if ( rc != LDAP_SUCCESS ) {
5739 ConfigReply msg = ca->reply;
5740 for ( s = save_attrs; s; s = s->a_next ) {
5741 if ( s->a_flags & SLAP_ATTR_IXDEL ) {
5742 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5743 ct = config_find_table( colst, nocs, s->a_desc, ca );
5744 a = attr_find( e->e_attrs, s->a_desc );
5746 /* clear the flag so the add check below will skip it */
5747 a->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5751 config_del_vals( ct, ca );
5753 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5754 ca->line = s->a_vals[i].bv_val;
5756 config_modify_add( ct, ca, s->a_desc, i );
5760 for ( a = e->e_attrs; a; a = a->a_next ) {
5761 if ( a->a_flags & SLAP_ATTR_IXADD ) {
5762 ct = config_find_table( colst, nocs, a->a_desc, ca );
5766 config_del_vals( ct, ca );
5767 s = attr_find( save_attrs, a->a_desc );
5769 s->a_flags &= ~(SLAP_ATTR_IXDEL|SLAP_ATTR_IXADD);
5770 for ( i=0; !BER_BVISNULL( &s->a_vals[i] ); i++ ) {
5771 ca->line = s->a_vals[i].bv_val;
5773 config_modify_add( ct, ca, s->a_desc, i );
5784 if ( rc == LDAP_SUCCESS ) {
5785 attrs_free( save_attrs );
5787 attrs_free( e->e_attrs );
5788 e->e_attrs = save_attrs;
5790 ch_free( ca->argv );
5791 if ( colst ) ch_free( colst );
5793 deltail = dels->next;
5802 config_back_modify( Operation *op, SlapReply *rs )
5805 CfEntryInfo *ce, *last;
5807 ConfigArgs ca = {0};
5810 AttributeDescription *rad = NULL;
5813 cfb = (CfBackInfo *)op->o_bd->be_private;
5815 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5818 rs->sr_matched = last->ce_entry->e_name.bv_val;
5819 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5823 if ( !acl_check_modlist( op, ce->ce_entry, op->orm_modlist )) {
5824 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5828 /* Get type of RDN */
5829 rdn = ce->ce_entry->e_nname;
5830 ptr = strchr( rdn.bv_val, '=' );
5831 rdn.bv_len = ptr - rdn.bv_val;
5832 slap_bv2ad( &rdn, &rad, &rs->sr_text );
5834 /* Some basic validation... */
5835 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
5836 /* Don't allow Modify of RDN; must use ModRdn for that. */
5837 if ( ml->sml_desc == rad ) {
5838 rs->sr_err = LDAP_NOT_ALLOWED_ON_RDN;
5839 rs->sr_text = "Use modrdn to change the entry name";
5842 /* Internal update of contextCSN? */
5843 if ( ml->sml_desc == slap_schema.si_ad_contextCSN && op->o_conn->c_conn_idx == -1 ) {
5849 slap_mods_opattrs( op, &op->orm_modlist, 1 );
5852 if ( op->o_abandon ) {
5853 rs->sr_err = SLAPD_ABANDON;
5856 ldap_pvt_thread_pool_pause( &connection_pool );
5860 * 1) perform the Modify on the cached Entry.
5861 * 2) verify that the Entry still satisfies the schema.
5862 * 3) perform the individual config operations.
5863 * 4) store Modified entry in underlying LDIF backend.
5865 rs->sr_err = config_modify_internal( ce, op, rs, &ca );
5867 rs->sr_text = ca.cr_msg;
5868 } else if ( cfb->cb_use_ldif ) {
5869 BackendDB *be = op->o_bd;
5870 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
5871 struct berval dn, ndn;
5873 op->o_bd = &cfb->cb_db;
5877 op->o_dn = op->o_bd->be_rootdn;
5878 op->o_ndn = op->o_bd->be_rootndn;
5880 scp = op->o_callback;
5881 op->o_callback = ≻
5882 op->o_bd->be_modify( op, rs );
5884 op->o_callback = scp;
5890 ldap_pvt_thread_pool_resume( &connection_pool );
5892 send_ldap_result( op, rs );
5893 slap_graduate_commit_csn( op );
5898 config_back_modrdn( Operation *op, SlapReply *rs )
5901 CfEntryInfo *ce, *last;
5905 cfb = (CfBackInfo *)op->o_bd->be_private;
5907 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
5910 rs->sr_matched = last->ce_entry->e_name.bv_val;
5911 rs->sr_err = LDAP_NO_SUCH_OBJECT;
5914 if ( !access_allowed( op, ce->ce_entry, slap_schema.si_ad_entry,
5915 NULL, ACL_WRITE, NULL )) {
5916 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5920 if ( ce->ce_parent )
5921 parent = ce->ce_parent->ce_entry;
5923 parent = (Entry *)&slap_entry_root;
5924 if ( !access_allowed( op, parent, slap_schema.si_ad_children,
5925 NULL, ACL_WRITE, NULL )) {
5926 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
5931 /* We don't allow moving objects to new parents.
5932 * Generally we only allow reordering a set of ordered entries.
5934 if ( op->orr_newSup ) {
5935 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5939 /* If newRDN == oldRDN, quietly succeed */
5940 dnRdn( &op->o_req_ndn, &rdn );
5941 if ( dn_match( &rdn, &op->orr_nnewrdn )) {
5942 rs->sr_err = LDAP_SUCCESS;
5946 /* Current behavior, subject to change as needed:
5948 * For backends and overlays, we only allow renumbering.
5949 * For schema, we allow renaming with the same number.
5950 * Otherwise, the op is not allowed.
5953 if ( ce->ce_type == Cft_Schema ) {
5957 /* Can't alter the main cn=schema entry */
5958 if ( ce->ce_parent->ce_type == Cft_Global ) {
5959 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5960 rs->sr_text = "renaming not allowed for this entry";
5964 /* We could support this later if desired */
5965 ptr1 = ber_bvchr( &rdn, '}' );
5966 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5967 len = ptr1 - rdn.bv_val;
5968 if ( len != ptr2 - op->orr_newrdn.bv_val ||
5969 strncmp( rdn.bv_val, op->orr_newrdn.bv_val, len )) {
5970 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
5971 rs->sr_text = "schema reordering not supported";
5974 } else if ( ce->ce_type == Cft_Database ||
5975 ce->ce_type == Cft_Overlay ) {
5976 char *ptr1, *ptr2, *iptr1, *iptr2;
5979 iptr2 = ber_bvchr( &op->orr_newrdn, '=' ) + 1;
5980 if ( *iptr2 != '{' ) {
5981 rs->sr_err = LDAP_NAMING_VIOLATION;
5982 rs->sr_text = "new ordering index is required";
5986 iptr1 = ber_bvchr( &rdn, '{' ) + 1;
5987 ptr1 = ber_bvchr( &rdn, '}' );
5988 ptr2 = ber_bvchr( &op->orr_newrdn, '}' );
5990 rs->sr_err = LDAP_NAMING_VIOLATION;
5991 rs->sr_text = "new ordering index is required";
5995 len1 = ptr1 - rdn.bv_val;
5996 len2 = ptr2 - op->orr_newrdn.bv_val;
5998 if ( rdn.bv_len - len1 != op->orr_newrdn.bv_len - len2 ||
5999 strncmp( ptr1, ptr2, rdn.bv_len - len1 )) {
6000 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6001 rs->sr_text = "changing database/overlay type not allowed";
6004 ixold = strtol( iptr1, NULL, 0 );
6005 ixnew = strtol( iptr2, &ptr1, 0 );
6006 if ( ptr1 != ptr2 || ixold < 0 || ixnew < 0 ) {
6007 rs->sr_err = LDAP_NAMING_VIOLATION;
6010 /* config DB is always 0, cannot be changed */
6011 if ( ce->ce_type == Cft_Database && ( ixold == 0 || ixnew == 0 )) {
6012 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
6016 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6017 rs->sr_text = "renaming not supported for this entry";
6021 if ( op->o_abandon ) {
6022 rs->sr_err = SLAPD_ABANDON;
6025 ldap_pvt_thread_pool_pause( &connection_pool );
6027 if ( ce->ce_type == Cft_Schema ) {
6028 req_modrdn_s modr = op->oq_modrdn;
6031 rs->sr_err = config_rename_attr( rs, ce->ce_entry, &rdn, &a );
6032 if ( rs->sr_err == LDAP_SUCCESS ) {
6033 rs->sr_err = config_rename_one( op, rs, ce->ce_entry,
6034 ce->ce_parent, a, &op->orr_newrdn, &op->orr_nnewrdn,
6037 op->oq_modrdn = modr;
6039 CfEntryInfo *ce2, *cebase, **cprev, **cbprev, *ceold;
6040 req_modrdn_s modr = op->oq_modrdn;
6043 /* Advance to first of this type */
6044 cprev = &ce->ce_parent->ce_kids;
6045 for ( ce2 = *cprev; ce2 && ce2->ce_type != ce->ce_type; ) {
6046 cprev = &ce2->ce_sibs;
6049 /* Skip the -1 entry */
6050 if ( ce->ce_type == Cft_Database ) {
6051 cprev = &ce2->ce_sibs;
6057 /* Remove from old slot */
6058 for ( ce2 = *cprev; ce2 && ce2 != ce; ce2 = ce2->ce_sibs )
6059 cprev = &ce2->ce_sibs;
6060 *cprev = ce->ce_sibs;
6061 ceold = ce->ce_sibs;
6063 /* Insert into new slot */
6065 for ( i=0; i<ixnew; i++ ) {
6069 cprev = &ce2->ce_sibs;
6071 ce->ce_sibs = *cprev;
6076 /* NOTE: These should be encoded in the OC tables, not inline here */
6077 if ( ce->ce_type == Cft_Database )
6078 backend_db_move( ce->ce_be, ixnew );
6079 else if ( ce->ce_type == Cft_Overlay )
6080 overlay_move( ce->ce_be, (slap_overinst *)ce->ce_bi, ixnew );
6082 if ( ixold < ixnew ) {
6083 rs->sr_err = config_rename_del( op, rs, ce, ceold, ixold,
6086 rs->sr_err = config_rename_add( op, rs, ce, ixnew, 1,
6087 ixold - ixnew, cfb->cb_use_ldif );
6089 op->oq_modrdn = modr;
6092 ldap_pvt_thread_pool_resume( &connection_pool );
6094 send_ldap_result( op, rs );
6099 config_back_delete( Operation *op, SlapReply *rs )
6101 #ifdef SLAP_CONFIG_DELETE
6103 CfEntryInfo *ce, *last, *ce2;
6105 cfb = (CfBackInfo *)op->o_bd->be_private;
6107 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6110 rs->sr_matched = last->ce_entry->e_name.bv_val;
6111 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6112 } else if ( ce->ce_kids ) {
6113 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6114 } else if ( op->o_abandon ) {
6115 rs->sr_err = SLAPD_ABANDON;
6116 } else if ( ce->ce_type == Cft_Overlay || ce->ce_type == Cft_Database ){
6120 ldap_pvt_thread_pool_pause( &connection_pool );
6122 if ( ce->ce_type == Cft_Overlay ){
6123 if ( SLAP_ISGLOBALOVERLAY(ce->ce_be ) ) {
6124 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6125 rs->sr_text = "Cannot delete global overlays";
6126 ldap_pvt_thread_pool_resume( &connection_pool );
6128 } else if ( ce->ce_be == op->o_bd->bd_self ) {
6129 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6130 rs->sr_text = "Cannot delete cn=config overlays";
6131 ldap_pvt_thread_pool_resume( &connection_pool );
6134 overlay_remove( ce->ce_be, (slap_overinst *)ce->ce_bi );
6136 } else { /* Cft_Database*/
6137 if ( ce->ce_be == frontendDB || ce->ce_be == op->o_bd ){
6138 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6139 rs->sr_text = "Cannot delete config or frontend database";
6140 ldap_pvt_thread_pool_resume( &connection_pool );
6143 if ( ce->ce_be->bd_info->bi_db_close ) {
6144 ce->ce_be->bd_info->bi_db_close( ce->ce_be, NULL );
6146 backend_destroy_one( ce->ce_be, 1);
6149 /* remove CfEntryInfo from the siblings list */
6150 if ( ce->ce_parent->ce_kids == ce ) {
6151 ce->ce_parent->ce_kids = ce->ce_sibs;
6153 for ( ce2 = ce->ce_parent->ce_kids ; ce2; ce2 = ce2->ce_sibs ) {
6154 if ( ce2->ce_sibs == ce ) {
6155 ce2->ce_sibs = ce->ce_sibs;
6161 /* remove from underlying database */
6162 if ( cfb->cb_use_ldif ) {
6163 BackendDB *be = op->o_bd;
6164 slap_callback sc = { NULL, slap_null_cb, NULL, NULL }, *scp;
6165 struct berval dn, ndn, req_dn, req_ndn;
6167 op->o_bd = &cfb->cb_db;
6171 req_dn = op->o_req_dn;
6172 req_ndn = op->o_req_ndn;
6174 op->o_dn = op->o_bd->be_rootdn;
6175 op->o_ndn = op->o_bd->be_rootndn;
6176 op->o_req_dn = ce->ce_entry->e_name;
6177 op->o_req_ndn = ce->ce_entry->e_nname;
6179 scp = op->o_callback;
6180 op->o_callback = ≻
6181 op->o_bd->be_delete( op, rs );
6183 op->o_callback = scp;
6186 op->o_req_dn = req_dn;
6187 op->o_req_ndn = req_ndn;
6190 /* renumber siblings */
6191 iptr = ber_bvchr( &op->o_req_ndn, '{' ) + 1;
6192 ixold = strtol( iptr, NULL, 0 );
6193 for (ce2 = ce->ce_sibs, count=0; ce2; ce2=ce2->ce_sibs) {
6194 config_renumber_one( op, rs, ce2->ce_parent, ce2->ce_entry,
6195 count+ixold, 0, cfb->cb_use_ldif );
6199 ce->ce_entry->e_private=NULL;
6200 entry_free(ce->ce_entry);
6202 ldap_pvt_thread_pool_resume( &connection_pool );
6204 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6207 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
6208 #endif /* SLAP_CONFIG_DELETE */
6210 send_ldap_result( op, rs );
6215 config_back_search( Operation *op, SlapReply *rs )
6218 CfEntryInfo *ce, *last;
6221 cfb = (CfBackInfo *)op->o_bd->be_private;
6223 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
6226 rs->sr_matched = last->ce_entry->e_name.bv_val;
6227 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6230 if ( !access_allowed_mask( op, ce->ce_entry, slap_schema.si_ad_entry, NULL,
6231 ACL_SEARCH, NULL, &mask ))
6233 if ( !ACL_GRANT( mask, ACL_DISCLOSE )) {
6234 rs->sr_err = LDAP_NO_SUCH_OBJECT;
6236 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
6240 switch ( op->ors_scope ) {
6241 case LDAP_SCOPE_BASE:
6242 case LDAP_SCOPE_SUBTREE:
6243 rs->sr_err = config_send( op, rs, ce, 0 );
6246 case LDAP_SCOPE_ONELEVEL:
6247 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
6248 rs->sr_err = config_send( op, rs, ce, 1 );
6257 send_ldap_result( op, rs );
6261 /* no-op, we never free entries */
6262 int config_entry_release(
6267 if ( !e->e_private ) {
6270 return LDAP_SUCCESS;
6273 /* return LDAP_SUCCESS IFF we can retrieve the specified entry.
6275 int config_back_entry_get(
6279 AttributeDescription *at,
6284 CfEntryInfo *ce, *last;
6285 int rc = LDAP_NO_SUCH_OBJECT;
6287 cfb = (CfBackInfo *)op->o_bd->be_private;
6289 ce = config_find_base( cfb->cb_root, ndn, &last );
6291 *ent = ce->ce_entry;
6294 if ( oc && !is_entry_objectclass_or_sub( *ent, oc ) ) {
6295 rc = LDAP_NO_SUCH_ATTRIBUTE;
6305 config_build_attrs( Entry *e, AttributeType **at, AttributeDescription *ad,
6306 ConfigTable *ct, ConfigArgs *c )
6310 for (; at && *at; at++) {
6311 /* Skip the naming attr */
6312 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
6314 for (i=0;ct[i].name;i++) {
6315 if (ct[i].ad == (*at)->sat_ad) {
6316 rc = config_get_vals(&ct[i], c);
6317 /* NOTE: tolerate that config_get_vals()
6318 * returns success with no values */
6319 if (rc == LDAP_SUCCESS && c->rvalue_vals != NULL ) {
6320 if ( c->rvalue_nvals )
6321 rc = attr_merge(e, ct[i].ad, c->rvalue_vals,
6324 slap_syntax_validate_func *validate =
6325 ct[i].ad->ad_type->sat_syntax->ssyn_validate;
6328 for ( j=0; c->rvalue_vals[j].bv_val; j++ ) {
6329 rc = ordered_value_validate( ct[i].ad,
6330 &c->rvalue_vals[j], LDAP_MOD_ADD );
6332 Debug( LDAP_DEBUG_ANY,
6333 "config_build_attrs: error %d on %s value #%d\n",
6334 rc, ct[i].ad->ad_cname.bv_val, j );
6340 rc = attr_merge_normalize(e, ct[i].ad,
6341 c->rvalue_vals, NULL);
6343 ber_bvarray_free( c->rvalue_nvals );
6344 ber_bvarray_free( c->rvalue_vals );
6346 Debug( LDAP_DEBUG_ANY,
6347 "config_build_attrs: error %d on %s\n",
6348 rc, ct[i].ad->ad_cname.bv_val, 0 );
6360 config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
6361 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra )
6363 Entry *e = entry_alloc();
6364 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
6366 struct berval ad_name;
6367 AttributeDescription *ad = NULL;
6370 const char *text = "";
6374 CfEntryInfo *ceprev = NULL;
6376 Debug( LDAP_DEBUG_TRACE, "config_build_entry: \"%s\"\n", rdn->bv_val, 0, 0);
6379 ce->ce_type = main->co_type;
6380 ce->ce_parent = parent;
6382 pdn = parent->ce_entry->e_nname;
6383 if ( parent->ce_kids && parent->ce_kids->ce_type <= ce->ce_type )
6384 for ( ceprev = parent->ce_kids; ceprev->ce_sibs &&
6385 ceprev->ce_type <= ce->ce_type;
6386 ceprev = ceprev->ce_sibs );
6391 ce->ce_private = c->ca_private;
6395 build_new_dn( &e->e_name, &pdn, rdn, NULL );
6396 ber_dupbv( &e->e_nname, &e->e_name );
6398 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6399 main->co_name, NULL );
6401 attr_merge_normalize_one(e, slap_schema.si_ad_objectClass,
6402 extra->co_name, NULL );
6403 ptr = strchr(rdn->bv_val, '=');
6404 ad_name.bv_val = rdn->bv_val;
6405 ad_name.bv_len = ptr - rdn->bv_val;
6406 rc = slap_bv2ad( &ad_name, &ad, &text );
6411 val.bv_len = rdn->bv_len - (val.bv_val - rdn->bv_val);
6412 attr_merge_normalize_one(e, ad, &val, NULL );
6415 c->table = main->co_type;
6416 if ( oc->soc_required ) {
6417 rc = config_build_attrs( e, oc->soc_required, ad, main->co_table, c );
6418 if ( rc ) goto fail;
6421 if ( oc->soc_allowed ) {
6422 rc = config_build_attrs( e, oc->soc_allowed, ad, main->co_table, c );
6423 if ( rc ) goto fail;
6428 c->table = extra->co_type;
6429 if ( oc->soc_required ) {
6430 rc = config_build_attrs( e, oc->soc_required, ad, extra->co_table, c );
6431 if ( rc ) goto fail;
6434 if ( oc->soc_allowed ) {
6435 rc = config_build_attrs( e, oc->soc_allowed, ad, extra->co_table, c );
6436 if ( rc ) goto fail;
6440 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
6441 rc = structural_class(oc_at->a_vals, &oc, NULL, &text, c->cr_msg,
6442 sizeof(c->cr_msg), op ? op->o_tmpmemctx : NULL );
6443 if ( rc != LDAP_SUCCESS ) {
6445 Debug( LDAP_DEBUG_ANY,
6446 "config_build_entry: build \"%s\" failed: \"%s\"\n",
6447 rdn->bv_val, text, 0);
6450 attr_merge_normalize_one(e, slap_schema.si_ad_structuralObjectClass, &oc->soc_cname, NULL );
6453 op->ora_modlist = NULL;
6454 slap_add_opattrs( op, NULL, NULL, 0, 0 );
6455 if ( !op->o_noop ) {
6456 op->o_bd->be_add( op, rs );
6457 if ( ( rs->sr_err != LDAP_SUCCESS )
6458 && (rs->sr_err != LDAP_ALREADY_EXISTS) ) {
6464 ce->ce_sibs = ceprev->ce_sibs;
6465 ceprev->ce_sibs = ce;
6466 } else if ( parent ) {
6467 ce->ce_sibs = parent->ce_kids;
6468 parent->ce_kids = ce;
6475 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
6476 Operation *op, SlapReply *rs )
6479 ConfigFile *cf = c->ca_private;
6481 struct berval bv, rdn;
6483 for (; cf; cf=cf->c_sibs, c->depth++) {
6484 if ( !cf->c_at_head && !cf->c_cr_head && !cf->c_oc_head &&
6485 !cf->c_om_head && !cf->c_syn_head ) continue;
6486 c->value_dn.bv_val = c->log;
6487 LUTIL_SLASHPATH( cf->c_file.bv_val );
6488 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
6493 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
6495 ptr = strchr( bv.bv_val, '.' );
6497 bv.bv_len = ptr - bv.bv_val;
6498 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=" SLAP_X_ORDERED_FMT, c->depth);
6499 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6500 /* FIXME: how can indicate error? */
6503 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
6505 c->value_dn.bv_len += bv.bv_len;
6506 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
6510 e = config_build_entry( op, rs, ceparent, c, &rdn,
6511 &CFOC_SCHEMA, NULL );
6514 } else if ( e && cf->c_kids ) {
6515 c->ca_private = cf->c_kids;
6516 config_build_schema_inc( c, e->e_private, op, rs );
6522 #ifdef SLAPD_MODULES
6525 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
6526 Operation *op, SlapReply *rs )
6531 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
6532 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
6534 c->value_dn.bv_val = c->log;
6535 c->value_dn.bv_len = snprintf(c->value_dn.bv_val, sizeof( c->log ), "cn=module" SLAP_X_ORDERED_FMT, i);
6536 if ( c->value_dn.bv_len >= sizeof( c->log ) ) {
6537 /* FIXME: how can indicate error? */
6541 if ( ! config_build_entry( op, rs, ceparent, c, &c->value_dn, &CFOC_MODULE, NULL )) {
6550 config_check_schema(Operation *op, CfBackInfo *cfb)
6552 struct berval schema_dn = BER_BVC(SCHEMA_RDN "," CONFIG_RDN);
6554 CfEntryInfo *ce, *last;
6557 /* If there's no root entry, we must be in the midst of converting */
6558 if ( !cfb->cb_root )
6561 /* Make sure the main schema entry exists */
6562 ce = config_find_base( cfb->cb_root, &schema_dn, &last );
6569 /* Make sure it's up to date */
6570 if ( cf_om_tail != om_sys_tail ) {
6571 a = attr_find( e->e_attrs, cfAd_om );
6573 if ( a->a_nvals != a->a_vals )
6574 ber_bvarray_free( a->a_nvals );
6575 ber_bvarray_free( a->a_vals );
6580 oidm_unparse( &bv, NULL, NULL, 1 );
6581 attr_merge_normalize( e, cfAd_om, bv, NULL );
6582 ber_bvarray_free( bv );
6583 cf_om_tail = om_sys_tail;
6585 if ( cf_at_tail != at_sys_tail ) {
6586 a = attr_find( e->e_attrs, cfAd_attr );
6588 if ( a->a_nvals != a->a_vals )
6589 ber_bvarray_free( a->a_nvals );
6590 ber_bvarray_free( a->a_vals );
6595 at_unparse( &bv, NULL, NULL, 1 );
6596 attr_merge_normalize( e, cfAd_attr, bv, NULL );
6597 ber_bvarray_free( bv );
6598 cf_at_tail = at_sys_tail;
6600 if ( cf_oc_tail != oc_sys_tail ) {
6601 a = attr_find( e->e_attrs, cfAd_oc );
6603 if ( a->a_nvals != a->a_vals )
6604 ber_bvarray_free( a->a_nvals );
6605 ber_bvarray_free( a->a_vals );
6610 oc_unparse( &bv, NULL, NULL, 1 );
6611 attr_merge_normalize( e, cfAd_oc, bv, NULL );
6612 ber_bvarray_free( bv );
6613 cf_oc_tail = oc_sys_tail;
6615 if ( cf_syn_tail != syn_sys_tail ) {
6616 a = attr_find( e->e_attrs, cfAd_syntax );
6618 if ( a->a_nvals != a->a_vals )
6619 ber_bvarray_free( a->a_nvals );
6620 ber_bvarray_free( a->a_vals );
6625 syn_unparse( &bv, NULL, NULL, 1 );
6626 attr_merge_normalize( e, cfAd_syntax, bv, NULL );
6627 ber_bvarray_free( bv );
6628 cf_syn_tail = syn_sys_tail;
6631 SlapReply rs = {REP_RESULT};
6632 c.ca_private = NULL;
6633 e = config_build_entry( op, &rs, cfb->cb_root, &c, &schema_rdn,
6634 &CFOC_SCHEMA, NULL );
6639 ce->ce_private = cfb->cb_config;
6640 cf_at_tail = at_sys_tail;
6641 cf_oc_tail = oc_sys_tail;
6642 cf_om_tail = om_sys_tail;
6643 cf_syn_tail = syn_sys_tail;
6648 static const char *defacl[] = {
6649 NULL, "to", "*", "by", "*", "none", NULL
6653 config_back_db_open( BackendDB *be, ConfigReply *cr )
6655 CfBackInfo *cfb = be->be_private;
6658 CfEntryInfo *ce, *ceparent;
6662 Connection conn = {0};
6663 OperationBuffer opbuf;
6665 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
6666 SlapReply rs = {REP_RESULT};
6667 void *thrctx = NULL;
6669 Debug( LDAP_DEBUG_TRACE, "config_back_db_open\n", 0, 0, 0);
6671 /* If we have no explicitly configured ACLs, don't just use
6672 * the global ACLs. Explicitly deny access to everything.
6674 if ( !be->be_acl ) {
6675 parse_acl(be, "config_back_db_open", 0, 6, (char **)defacl, 0 );
6678 thrctx = ldap_pvt_thread_pool_context();
6679 connection_fake_init( &conn, &opbuf, thrctx );
6682 op->o_tag = LDAP_REQ_ADD;
6683 op->o_callback = &cb;
6684 op->o_bd = &cfb->cb_db;
6685 op->o_dn = op->o_bd->be_rootdn;
6686 op->o_ndn = op->o_bd->be_rootndn;
6688 if ( !cfb->cb_use_ldif ) {
6692 /* If we read the config from back-ldif, do some quick sanity checks */
6693 if ( cfb->cb_got_ldif ) {
6694 return config_check_schema( op, cfb );
6697 /* create root of tree */
6699 c.ca_private = cfb->cb_config;
6701 e = config_build_entry( op, &rs, NULL, &c, &rdn, &CFOC_GLOBAL, NULL );
6711 #ifdef SLAPD_MODULES
6712 /* Create Module nodes... */
6713 if ( modpaths.mp_loads ) {
6714 if ( config_build_modules( &c, ceparent, op, &rs ) ){
6720 /* Create schema nodes... cn=schema will contain the hardcoded core
6721 * schema, read-only. Child objects will contain runtime loaded schema
6725 c.ca_private = NULL;
6726 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_SCHEMA, NULL );
6731 ce->ce_private = cfb->cb_config;
6732 cf_at_tail = at_sys_tail;
6733 cf_oc_tail = oc_sys_tail;
6734 cf_om_tail = om_sys_tail;
6735 cf_syn_tail = syn_sys_tail;
6737 /* Create schema nodes for included schema... */
6738 if ( cfb->cb_config->c_kids ) {
6740 c.ca_private = cfb->cb_config->c_kids;
6741 if (config_build_schema_inc( &c, ce, op, &rs )) {
6746 /* Create backend nodes. Skip if they don't provide a cf_table.
6747 * There usually aren't any of these.
6751 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
6752 if (!bi->bi_cf_ocs) {
6753 /* If it only supports the old config mech, complain. */
6754 if ( bi->bi_config ) {
6755 Debug( LDAP_DEBUG_ANY,
6756 "WARNING: No dynamic config support for backend %s.\n",
6757 bi->bi_type, 0, 0 );
6762 if (!bi->bi_private) continue;
6765 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6766 "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
6767 if ( rdn.bv_len >= sizeof( c.log ) ) {
6768 /* FIXME: holler ... */ ;
6771 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_BACKEND,
6778 /* Create database nodes... */
6779 frontendDB->be_cf_ocs = &CFOC_FRONTEND;
6780 LDAP_STAILQ_NEXT(frontendDB, be_next) = LDAP_STAILQ_FIRST(&backendDB);
6781 for ( i = -1, be = frontendDB ; be;
6782 i++, be = LDAP_STAILQ_NEXT( be, be_next )) {
6783 slap_overinfo *oi = NULL;
6785 if ( overlay_is_over( be )) {
6786 oi = be->bd_info->bi_private;
6792 /* If this backend supports the old config mechanism, but not
6793 * the new mech, complain.
6795 if ( !be->be_cf_ocs && bi->bi_db_config ) {
6796 Debug( LDAP_DEBUG_ANY,
6797 "WARNING: No dynamic config support for database %s.\n",
6798 bi->bi_type, 0, 0 );
6802 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6803 "%s=" SLAP_X_ORDERED_FMT "%s", cfAd_database->ad_cname.bv_val,
6805 if ( rdn.bv_len >= sizeof( c.log ) ) {
6806 /* FIXME: holler ... */ ;
6810 e = config_build_entry( op, &rs, ceparent, &c, &rdn, &CFOC_DATABASE,
6816 if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd )
6817 be->be_cf_ocs->co_cfadd( op, &rs, e, &c );
6818 /* Iterate through overlays */
6823 voidList *vl, *v0 = NULL;
6825 /* overlays are in LIFO order, must reverse stack */
6826 for (on=oi->oi_list; on; on=on->on_next) {
6827 vl = ch_malloc( sizeof( voidList ));
6832 for (j=0; vl; j++,vl=v0) {
6836 if ( on->on_bi.bi_db_config && !on->on_bi.bi_cf_ocs ) {
6837 Debug( LDAP_DEBUG_ANY,
6838 "WARNING: No dynamic config support for overlay %s.\n",
6839 on->on_bi.bi_type, 0, 0 );
6843 rdn.bv_len = snprintf(rdn.bv_val, sizeof( c.log ),
6844 "%s=" SLAP_X_ORDERED_FMT "%s",
6845 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
6846 if ( rdn.bv_len >= sizeof( c.log ) ) {
6847 /* FIXME: holler ... */ ;
6851 oe = config_build_entry( op, &rs, ce, &c, &rdn,
6852 &CFOC_OVERLAY, c.bi->bi_cf_ocs );
6856 if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd )
6857 c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c );
6862 ldap_pvt_thread_pool_context_reset( thrctx );
6864 if ( unsupp && cfb->cb_use_ldif ) {
6865 Debug( LDAP_DEBUG_ANY, "\nWARNING: The converted cn=config "
6866 "directory is incomplete and may not work.\n\n", 0, 0, 0 );
6873 cfb_free_cffile( ConfigFile *cf )
6877 for (; cf; cf=next) {
6880 cfb_free_cffile( cf->c_kids );
6881 ch_free( cf->c_file.bv_val );
6882 ber_bvarray_free( cf->c_dseFiles );
6888 cfb_free_entries( CfEntryInfo *ce )
6892 for (; ce; ce=next) {
6895 cfb_free_entries( ce->ce_kids );
6896 ce->ce_entry->e_private = NULL;
6897 entry_free( ce->ce_entry );
6903 config_back_db_close( BackendDB *be, ConfigReply *cr )
6905 CfBackInfo *cfb = be->be_private;
6907 cfb_free_entries( cfb->cb_root );
6908 cfb->cb_root = NULL;
6910 if ( cfb->cb_db.bd_info ) {
6911 backend_shutdown( &cfb->cb_db );
6918 config_back_db_destroy( BackendDB *be, ConfigReply *cr )
6920 CfBackInfo *cfb = be->be_private;
6922 cfb_free_cffile( cfb->cb_config );
6924 ch_free( cfdir.bv_val );
6926 avl_free( CfOcTree, NULL );
6928 if ( cfb->cb_db.bd_info ) {
6929 cfb->cb_db.be_suffix = NULL;
6930 cfb->cb_db.be_nsuffix = NULL;
6931 BER_BVZERO( &cfb->cb_db.be_rootdn );
6932 BER_BVZERO( &cfb->cb_db.be_rootndn );
6934 backend_destroy_one( &cfb->cb_db, 0 );
6943 config_back_db_init( BackendDB *be, ConfigReply* cr )
6949 cfb->cb_config = ch_calloc( 1, sizeof(ConfigFile));
6950 cfn = cfb->cb_config;
6951 be->be_private = cfb;
6953 ber_dupbv( &be->be_rootdn, &config_rdn );
6954 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
6955 ber_dupbv( &dn, &be->be_rootdn );
6956 ber_bvarray_add( &be->be_suffix, &dn );
6957 ber_dupbv( &dn, &be->be_rootdn );
6958 ber_bvarray_add( &be->be_nsuffix, &dn );
6960 /* Hide from namingContexts */
6961 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
6963 /* Check ACLs on content of Adds by default */
6964 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_ACL_ADD;
6970 config_back_destroy( BackendInfo *bi )
6972 ldif_must_b64_encode_release();
6977 config_tool_entry_open( BackendDB *be, int mode )
6979 CfBackInfo *cfb = be->be_private;
6980 BackendInfo *bi = cfb->cb_db.bd_info;
6982 if ( bi && bi->bi_tool_entry_open )
6983 return bi->bi_tool_entry_open( &cfb->cb_db, mode );
6990 config_tool_entry_close( BackendDB *be )
6992 CfBackInfo *cfb = be->be_private;
6993 BackendInfo *bi = cfb->cb_db.bd_info;
6995 if ( bi && bi->bi_tool_entry_close )
6996 return bi->bi_tool_entry_close( &cfb->cb_db );
7002 config_tool_entry_first( BackendDB *be )
7004 CfBackInfo *cfb = be->be_private;
7005 BackendInfo *bi = cfb->cb_db.bd_info;
7007 if ( bi && bi->bi_tool_entry_first ) {
7008 return bi->bi_tool_entry_first( &cfb->cb_db );
7010 if ( bi && bi->bi_tool_entry_first_x ) {
7011 return bi->bi_tool_entry_first_x( &cfb->cb_db,
7012 NULL, LDAP_SCOPE_DEFAULT, NULL );
7018 config_tool_entry_first_x(
7020 struct berval *base,
7024 CfBackInfo *cfb = be->be_private;
7025 BackendInfo *bi = cfb->cb_db.bd_info;
7027 if ( bi && bi->bi_tool_entry_first_x ) {
7028 return bi->bi_tool_entry_first_x( &cfb->cb_db, base, scope, f );
7034 config_tool_entry_next( BackendDB *be )
7036 CfBackInfo *cfb = be->be_private;
7037 BackendInfo *bi = cfb->cb_db.bd_info;
7039 if ( bi && bi->bi_tool_entry_next )
7040 return bi->bi_tool_entry_next( &cfb->cb_db );
7046 config_tool_entry_get( BackendDB *be, ID id )
7048 CfBackInfo *cfb = be->be_private;
7049 BackendInfo *bi = cfb->cb_db.bd_info;
7051 if ( bi && bi->bi_tool_entry_get )
7052 return bi->bi_tool_entry_get( &cfb->cb_db, id );
7057 static int entry_put_got_frontend=0;
7058 static int entry_put_got_config=0;
7060 config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
7062 CfBackInfo *cfb = be->be_private;
7063 BackendInfo *bi = cfb->cb_db.bd_info;
7065 struct berval rdn, vals[ 2 ];
7067 OperationBuffer opbuf;
7069 Connection conn = {0};
7070 Operation *op = NULL;
7074 /* Create entry for frontend database if it does not exist already */
7075 if ( !entry_put_got_frontend ) {
7076 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7077 STRLENOF( "olcDatabase" ))) {
7078 if ( strncmp( e->e_nname.bv_val +
7079 STRLENOF( "olcDatabase" ), "={-1}frontend",
7080 STRLENOF( "={-1}frontend" )) &&
7081 strncmp( e->e_nname.bv_val +
7082 STRLENOF( "olcDatabase" ), "=frontend",
7083 STRLENOF( "=frontend" ))) {
7085 vals[1].bv_val = NULL;
7086 memset( &ca, 0, sizeof(ConfigArgs));
7088 ca.bi = frontendDB->bd_info;
7089 ca.be->be_cf_ocs = &CFOC_FRONTEND;
7090 rdn.bv_val = ca.log;
7091 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7092 "%s=" SLAP_X_ORDERED_FMT "%s",
7093 cfAd_database->ad_cname.bv_val, -1,
7095 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn,
7096 &CFOC_DATABASE, ca.be->be_cf_ocs );
7097 thrctx = ldap_pvt_thread_pool_context();
7098 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7100 op->o_bd = &cfb->cb_db;
7101 op->o_tag = LDAP_REQ_ADD;
7103 op->o_dn = be->be_rootdn;
7104 op->o_ndn = be->be_rootndn;
7105 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7106 if ( rc != LDAP_SUCCESS ) {
7107 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7108 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7112 if ( ce && bi && bi->bi_tool_entry_put &&
7113 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7114 entry_put_got_frontend++;
7116 text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
7117 text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
7121 entry_put_got_frontend++;
7126 /* Create entry for config database if it does not exist already */
7127 if ( !entry_put_got_config && !isFrontend ) {
7128 if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
7129 STRLENOF( "olcDatabase" ))) {
7130 if ( strncmp( e->e_nname.bv_val +
7131 STRLENOF( "olcDatabase" ), "={0}config",
7132 STRLENOF( "={0}config" )) &&
7133 strncmp( e->e_nname.bv_val +
7134 STRLENOF( "olcDatabase" ), "=config",
7135 STRLENOF( "=config" )) ) {
7137 vals[1].bv_val = NULL;
7138 memset( &ca, 0, sizeof(ConfigArgs));
7139 ca.be = LDAP_STAILQ_FIRST( &backendDB );
7140 ca.bi = ca.be->bd_info;
7141 rdn.bv_val = ca.log;
7142 rdn.bv_len = snprintf(rdn.bv_val, sizeof( ca.log ),
7143 "%s=" SLAP_X_ORDERED_FMT "%s",
7144 cfAd_database->ad_cname.bv_val, 0,
7146 ce = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE,
7149 thrctx = ldap_pvt_thread_pool_context();
7150 connection_fake_init2( &conn, &opbuf, thrctx,0 );
7152 op->o_bd = &cfb->cb_db;
7153 op->o_tag = LDAP_REQ_ADD;
7154 op->o_dn = be->be_rootdn;
7155 op->o_ndn = be->be_rootndn;
7158 rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
7159 if ( rc != LDAP_SUCCESS ) {
7160 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7161 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7164 if (ce && bi && bi->bi_tool_entry_put &&
7165 bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
7166 entry_put_got_config++;
7168 text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
7169 text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
7173 entry_put_got_config++;
7177 if ( bi && bi->bi_tool_entry_put &&
7178 config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
7179 return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
7186 AttributeDescription **desc;
7188 { "attribute", &cfAd_attr },
7189 { "backend", &cfAd_backend },
7190 { "database", &cfAd_database },
7191 { "include", &cfAd_include },
7192 { "ldapsyntax", &cfAd_syntax },
7193 { "objectclass", &cfAd_oc },
7194 { "objectidentifier", &cfAd_om },
7195 { "overlay", &cfAd_overlay },
7200 * add / delete: all types that may be added or deleted must use an
7201 * X-ORDERED attributeType for their RDN. Adding and deleting entries
7202 * should automatically renumber the index of any siblings as needed,
7203 * so that no gaps in the numbering sequence exist after the add/delete
7205 * What can be added:
7207 * backend objects for backend-specific config directives
7211 * delete: probably no support this time around.
7213 * modrdn: generally not done. Will be invoked automatically by add/
7214 * delete to update numbering sequence. Perform as an explicit operation
7215 * so that the renumbering effect may be replicated. Subtree rename must
7216 * be supported, since renumbering a database will affect all its child
7219 * modify: must be fully supported.
7223 config_back_initialize( BackendInfo *bi )
7225 ConfigTable *ct = config_back_cf_table;
7229 AttributeDescription *ad = NULL;
7231 static char *controls[] = {
7232 LDAP_CONTROL_MANAGEDSAIT,
7236 /* Make sure we don't exceed the bits reserved for userland */
7237 config_check_userland( CFG_LAST );
7239 bi->bi_controls = controls;
7244 bi->bi_destroy = config_back_destroy;
7246 bi->bi_db_init = config_back_db_init;
7247 bi->bi_db_config = 0;
7248 bi->bi_db_open = config_back_db_open;
7249 bi->bi_db_close = config_back_db_close;
7250 bi->bi_db_destroy = config_back_db_destroy;
7252 bi->bi_op_bind = config_back_bind;
7253 bi->bi_op_unbind = 0;
7254 bi->bi_op_search = config_back_search;
7255 bi->bi_op_compare = 0;
7256 bi->bi_op_modify = config_back_modify;
7257 bi->bi_op_modrdn = config_back_modrdn;
7258 bi->bi_op_add = config_back_add;
7259 bi->bi_op_delete = config_back_delete;
7260 bi->bi_op_abandon = 0;
7262 bi->bi_extended = 0;
7264 bi->bi_chk_referrals = 0;
7266 bi->bi_access_allowed = slap_access_allowed;
7268 bi->bi_connection_init = 0;
7269 bi->bi_connection_destroy = 0;
7271 bi->bi_entry_release_rw = config_entry_release;
7272 bi->bi_entry_get_rw = config_back_entry_get;
7274 bi->bi_tool_entry_open = config_tool_entry_open;
7275 bi->bi_tool_entry_close = config_tool_entry_close;
7276 bi->bi_tool_entry_first = config_tool_entry_first;
7277 bi->bi_tool_entry_first_x = config_tool_entry_first_x;
7278 bi->bi_tool_entry_next = config_tool_entry_next;
7279 bi->bi_tool_entry_get = config_tool_entry_get;
7280 bi->bi_tool_entry_put = config_tool_entry_put;
7283 argv[ 0 ] = "slapd";
7289 for (i=0; OidMacros[i].name; i++ ) {
7290 argv[1] = OidMacros[i].name;
7291 argv[2] = OidMacros[i].oid;
7292 parse_oidm( &ca, 0, NULL );
7295 bi->bi_cf_ocs = cf_ocs;
7297 i = config_register_schema( ct, cf_ocs );
7300 i = slap_str2ad( "olcDatabase", &olcDatabaseDummy[0].ad, &text );
7303 /* setup olcRootPW to be base64-encoded when written in LDIF form;
7304 * basically, we don't care if it fails */
7305 i = slap_str2ad( "olcRootPW", &ad, &text );
7307 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
7308 "warning, unable to get \"olcRootPW\" "
7309 "attribute description: %d: %s\n",
7312 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
7313 ad->ad_type->sat_oid );
7316 /* set up the notable AttributeDescriptions */
7318 for (;ct->name;ct++) {
7319 if (strcmp(ct->name, ads[i].name)) continue;
7320 *ads[i].desc = ct->ad;
7322 if (!ads[i].name) break;