1 /* bconfig.c - the config backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005 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>
31 #include "slapi/slapi.h"
38 static struct berval config_rdn = BER_BVC("cn=config");
39 static struct berval schema_rdn = BER_BVC("cn=schema");
44 typedef struct modpath_s {
45 struct modpath_s *mp_next;
46 struct berval mp_path;
50 static ModPaths modpaths, *modlast = &modpaths, *modcur = &modpaths;
53 typedef struct ConfigFile {
54 struct ConfigFile *c_sibs;
55 struct ConfigFile *c_kids;
57 AttributeType *c_at_head, *c_at_tail;
58 ContentRule *c_cr_head, *c_cr_tail;
59 ObjectClass *c_oc_head, *c_oc_tail;
60 OidMacro *c_om_head, *c_om_tail;
64 typedef struct CfOcInfo {
65 struct berval *co_name;
66 ConfigTable *co_table;
71 typedef struct CfEntryInfo {
72 struct CfEntryInfo *ce_parent;
73 struct CfEntryInfo *ce_sibs;
74 struct CfEntryInfo *ce_kids;
82 ConfigFile *cb_config;
84 BackendDB cb_db; /* underlying database */
88 /* These do nothing in slapd, they're kept only to make them
91 static char *replica_pidFile, *replica_argsFile;
92 static int replicationInterval;
94 static char *passwd_salt;
95 static char *logfileName;
96 static BerVarray authz_rewrites;
98 static struct berval cfdir;
101 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
104 static ObjectClass *cfOc_schema, *cfOc_global, *cfOc_backend, *cfOc_database,
105 *cfOc_include, *cfOc_overlay, *cfOc_module;
107 static ConfigFile cf_prv, *cfn = &cf_prv;
109 static Avlnode *CfOcTree;
111 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
112 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
113 static void syncrepl_unparse LDAP_P (( syncinfo_t *, struct berval *));
114 static int config_add_internal( CfBackInfo *cfb, Entry *e, SlapReply *rs,
117 static ConfigDriver config_fname;
118 static ConfigDriver config_cfdir;
119 static ConfigDriver config_generic;
120 static ConfigDriver config_search_base;
121 static ConfigDriver config_passwd_hash;
122 static ConfigDriver config_schema_dn;
123 static ConfigDriver config_sizelimit;
124 static ConfigDriver config_timelimit;
125 static ConfigDriver config_limits;
126 static ConfigDriver config_overlay;
127 static ConfigDriver config_suffix;
128 static ConfigDriver config_deref_depth;
129 static ConfigDriver config_rootdn;
130 static ConfigDriver config_rootpw;
131 static ConfigDriver config_restrict;
132 static ConfigDriver config_allows;
133 static ConfigDriver config_disallows;
134 static ConfigDriver config_requires;
135 static ConfigDriver config_security;
136 static ConfigDriver config_referral;
137 static ConfigDriver config_loglevel;
138 static ConfigDriver config_syncrepl;
139 static ConfigDriver config_replica;
140 static ConfigDriver config_updatedn;
141 static ConfigDriver config_updateref;
142 static ConfigDriver config_include;
144 static ConfigDriver config_tls_option;
145 static ConfigDriver config_tls_config;
194 static OidRec OidMacros[] = {
195 /* OpenLDAProot:666.11.1 */
196 { "OLcfg", "1.3.6.1.4.1.4203.666.11.1" },
197 { "OLcfgAt", "OLcfg:3" },
198 { "OLcfgGlAt", "OLcfgAt:0" },
199 { "OLcfgBkAt", "OLcfgAt:1" },
200 { "OLcfgDbAt", "OLcfgAt:2" },
201 { "OLcfgOvAt", "OLcfgAt:3" },
202 { "OLcfgOc", "OLcfg:4" },
203 { "OLcfgGlOc", "OLcfgOc:0" },
204 { "OLcfgBkOc", "OLcfgOc:1" },
205 { "OLcfgDbOc", "OLcfgOc:2" },
206 { "OLcfgOvOc", "OLcfgOc:3" },
207 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
208 { "OMsInteger", "OMsyn:27" },
209 { "OMsBoolean", "OMsyn:7" },
210 { "OMsDN", "OMsyn:12" },
211 { "OMsDirectoryString", "OMsyn:15" },
212 { "OMsOctetString", "OMsyn:40" },
217 * OLcfg{Bk|Db}{Oc|At}:0 -> common
218 * OLcfg{Bk|Db}{Oc|At}:1 -> bdb
219 * OLcfg{Bk|Db}{Oc|At}:2 -> ldif
220 * OLcfg{Bk|Db}{Oc|At}:3 -> ldap?
223 /* alphabetical ordering */
225 ConfigTable config_back_cf_table[] = {
226 /* This attr is read-only */
227 { "", "", 0, 0, 0, ARG_MAGIC,
228 &config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
229 "DESC 'File for slapd configuration directives' "
230 "EQUALITY caseIgnoreMatch "
231 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
232 { "", "", 0, 0, 0, ARG_MAGIC,
233 &config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
234 "DESC 'Directory for slapd configuration backend' "
235 "EQUALITY caseIgnoreMatch "
236 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
237 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
238 &config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
239 "DESC 'Access Control List' "
240 "EQUALITY caseIgnoreMatch "
241 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
242 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
243 &config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
244 "DESC 'Allowed set of deprecated features' "
245 "EQUALITY caseIgnoreMatch "
246 "SYNTAX OMsDirectoryString )", NULL, NULL },
247 { "argsfile", "file", 2, 2, 0, ARG_STRING,
248 &slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
249 "DESC 'File for slapd command line options' "
250 "EQUALITY caseIgnoreMatch "
251 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
252 { "attribute", "attribute", 2, 0, 9, ARG_PAREN|ARG_MAGIC|CFG_ATTR,
253 &config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
254 "DESC 'OpenLDAP attributeTypes' "
255 "EQUALITY caseIgnoreMatch "
256 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
258 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
259 &config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
260 "EQUALITY caseIgnoreMatch "
261 "SYNTAX OMsDirectoryString )", NULL, NULL },
262 { "authid-rewrite", NULL, 2, 0, 0,
263 #ifdef SLAP_AUTH_REWRITE
264 ARG_MAGIC|CFG_REWRITE, &config_generic,
268 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
269 "EQUALITY caseIgnoreMatch "
270 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
271 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
272 &config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
273 "EQUALITY caseIgnoreMatch "
274 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
275 { "authz-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
276 &config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
277 "EQUALITY caseIgnoreMatch "
278 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
279 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
280 &config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
281 "DESC 'A type of backend' "
282 "EQUALITY caseIgnoreMatch "
283 "SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
285 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
286 &config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
287 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
288 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
289 &slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
290 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
291 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
292 &slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
293 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
294 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
295 &config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
296 "DESC 'The backend type for a database instance' "
297 "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
298 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_MAGIC,
299 &config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
300 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
301 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
302 &config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
303 "EQUALITY caseIgnoreMatch "
304 "SYNTAX OMsDirectoryString )", NULL, NULL },
305 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT,
306 &config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
307 "DESC 'OpenLDAP DIT content rules' "
308 "EQUALITY caseIgnoreMatch "
309 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
311 { "gentlehup", "on|off", 2, 2, 0,
313 ARG_ON_OFF, &global_gentlehup,
317 "( OLcfgGlAt:17 NAME 'olcGentleHUP' "
318 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
319 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
320 &global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
321 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
322 /* XXX -- special case? */
323 { "include", "file", 2, 2, 0, ARG_MAGIC,
324 &config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
325 "SUP labeledURI )", NULL, NULL },
326 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
327 &config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
328 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
329 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
330 &config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
331 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
332 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
333 &index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
334 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
335 { "index_substr_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
336 &index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
337 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
338 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
339 &config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
340 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
341 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
342 &config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
343 "SYNTAX OMsDirectoryString )", NULL, NULL },
344 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
345 &local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
346 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
347 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
348 &config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
349 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
350 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
351 &config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
352 "SYNTAX OMsDirectoryString )", NULL, NULL },
353 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
354 &config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
355 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
356 { "moduleload", "file", 2, 0, 0,
358 ARG_MAGIC|CFG_MODLOAD, &config_generic,
362 "( OLcfgGlAt:30 NAME 'olcModuleLoad' "
363 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
364 { "modulepath", "path", 2, 2, 0,
366 ARG_MAGIC|CFG_MODPATH, &config_generic,
370 "( OLcfgGlAt:31 NAME 'olcModulePath' "
371 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
372 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
373 &config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
374 "DESC 'OpenLDAP object classes' "
375 "EQUALITY caseIgnoreMatch "
376 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
378 { "objectidentifier", NULL, 0, 0, 0, ARG_MAGIC|CFG_OID,
379 &config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
380 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
381 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
382 &config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
383 "SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
384 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
385 &config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
386 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
387 { "password-hash", "hash", 2, 2, 0, ARG_MAGIC,
388 &config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
389 "SYNTAX OMsDirectoryString )", NULL, NULL },
390 { "pidfile", "file", 2, 2, 0, ARG_STRING,
391 &slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
392 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
393 { "plugin", NULL, 0, 0, 0,
395 ARG_MAGIC|CFG_PLUGIN, &config_generic,
399 "( OLcfgGlAt:38 NAME 'olcPlugin' "
400 "SYNTAX OMsDirectoryString )", NULL, NULL },
401 { "pluginlog", "filename", 2, 2, 0,
403 ARG_STRING, &slapi_log_file,
407 "( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
408 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
409 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
410 &config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
411 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
412 { "referral", "url", 2, 2, 0, ARG_MAGIC,
413 &config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
414 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
415 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
416 &config_replica, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
417 "SUP labeledURI )", NULL, NULL },
418 { "replica-argsfile", NULL, 0, 0, 0, ARG_STRING,
419 &replica_argsFile, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
420 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
421 { "replica-pidfile", NULL, 0, 0, 0, ARG_STRING,
422 &replica_pidFile, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
423 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
424 { "replicationInterval", NULL, 0, 0, 0, ARG_INT,
425 &replicationInterval, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
426 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
427 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLOG,
428 &config_generic, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
429 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
430 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
431 &config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
432 "SYNTAX OMsDirectoryString )", NULL, NULL },
433 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
434 &config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
435 "SYNTAX OMsDirectoryString )", NULL, NULL },
436 { "reverse-lookup", "on|off", 2, 2, 0,
437 #ifdef SLAPD_RLOOKUPS
438 ARG_ON_OFF, &use_reverse_lookup,
442 "( OLcfgGlAt:49 NAME 'olcReverseLookup' "
443 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
444 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
445 &config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
446 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
447 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
448 &config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
449 "SYNTAX OMsDirectoryString )", NULL, NULL },
450 { "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
451 &config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
452 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
453 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
454 &config_generic, NULL, NULL, NULL },
455 { "sasl-host", "host", 2, 2, 0,
456 #ifdef HAVE_CYRUS_SASL
457 ARG_STRING|ARG_UNIQUE, &global_host,
461 "( OLcfgGlAt:53 NAME 'olcSaslHost' "
462 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
463 { "sasl-realm", "realm", 2, 2, 0,
464 #ifdef HAVE_CYRUS_SASL
465 ARG_STRING|ARG_UNIQUE, &global_realm,
469 "( OLcfgGlAt:54 NAME 'olcSaslRealm' "
470 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
471 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
472 &config_generic, NULL, NULL, NULL },
473 { "sasl-secprops", "properties", 2, 2, 0,
474 #ifdef HAVE_CYRUS_SASL
475 ARG_MAGIC|CFG_SASLSECP, &config_generic,
479 "( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
480 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
481 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
482 &config_generic, NULL, NULL, NULL },
483 { "schemacheck", "on|off", 2, 2, 0, ARG_ON_OFF|ARG_MAGIC|CFG_CHECK,
484 &config_generic, "( OLcfgGlAt:57 NAME 'olcSchemaCheck' "
485 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
486 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_MAGIC,
487 &config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
488 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
489 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
490 &config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
491 "SYNTAX OMsDirectoryString )", NULL, NULL },
492 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_SIZE,
493 &config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
494 "SYNTAX OMsInteger )", NULL, NULL },
495 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
496 &sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
497 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
498 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
499 &sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
500 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
501 { "srvtab", "file", 2, 2, 0,
502 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
503 ARG_STRING, &ldap_srvtab,
507 "( OLcfgGlAt:63 NAME 'olcSrvtab' "
508 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
509 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
510 &config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
511 "SYNTAX OMsDN )", NULL, NULL },
512 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
513 &config_syncrepl, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
514 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
515 { "threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_THREADS,
516 &config_generic, "( OLcfgGlAt:66 NAME 'olcThreads' "
517 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
518 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_TIME,
519 &config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
520 "SYNTAX OMsInteger )", NULL, NULL },
521 { "TLSCACertificateFile", NULL, 0, 0, 0,
523 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
527 "( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
528 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
529 { "TLSCACertificatePath", NULL, 0, 0, 0,
531 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
535 "( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
536 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
537 { "TLSCertificateFile", NULL, 0, 0, 0,
539 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
543 "( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
544 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
545 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
547 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
551 "( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
552 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
553 { "TLSCipherSuite", NULL, 0, 0, 0,
555 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
559 "( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
560 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
561 { "TLSCRLCheck", NULL, 0, 0, 0,
562 #if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
563 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
567 "( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
568 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
569 { "TLSRandFile", NULL, 0, 0, 0,
571 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
575 "( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
576 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
577 { "TLSVerifyClient", NULL, 0, 0, 0,
579 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
583 "( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
584 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
585 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
586 NULL, NULL, NULL, NULL },
587 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_MAGIC,
588 &config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
589 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
590 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
591 &config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
592 "SUP labeledURI )", NULL, NULL },
593 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
594 NULL, NULL, NULL, NULL }
597 static ConfigOCs cf_ocs[] = {
600 "DESC 'OpenLDAP configuration object' "
601 "ABSTRACT SUP top )", Cft_Abstract, NULL },
604 "DESC 'OpenLDAP Global configuration options' "
605 "SUP olcConfig STRUCTURAL "
606 "MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
607 "olcAttributeOptions $ olcAuthIDRewrite $ "
608 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
609 "olcConnMaxPending $ olcConnMaxPendingAuth $ olcDefaultSearchBase $ "
610 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
611 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
612 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcLocalSSF $ "
613 "olcLogLevel $ olcModulePath $ "
614 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
615 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
616 "olcReplicaPidFile $ olcReplicaArgsFile $ olcReplicationInterval $ "
617 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
618 "olcRootDSE $ olcRootPW $ "
619 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
620 "olcSchemaCheck $ olcSecurity $ olcSizeLimit $ "
621 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ olcSrvtab $ "
622 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
623 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
624 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
625 "olcTLSRandFile $ olcTLSVerifyClient $ "
626 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
627 "olcDitContentRules ) )", Cft_Global, &cfOc_global },
629 "NAME 'olcSchemaConfig' "
630 "DESC 'OpenLDAP schema object' "
631 "SUP olcConfig STRUCTURAL "
632 "MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
633 "olcObjectClasses $ olcDitContentRules ) )",
634 Cft_Schema, &cfOc_schema },
636 "NAME 'olcBackendConfig' "
637 "DESC 'OpenLDAP Backend-specific options' "
638 "SUP olcConfig STRUCTURAL "
639 "MUST olcBackend )", Cft_Backend, &cfOc_backend },
641 "NAME 'olcDatabaseConfig' "
642 "DESC 'OpenLDAP Database-specific options' "
643 "SUP olcConfig STRUCTURAL "
645 "MAY ( olcSuffix $ olcAccess $ olcLastMod $ olcLimits $ "
646 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
647 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
648 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ "
649 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )",
650 Cft_Database, &cfOc_database },
652 "NAME 'olcOverlayConfig' "
653 "DESC 'OpenLDAP Overlay-specific options' "
654 "SUP olcConfig STRUCTURAL "
655 "MUST olcOverlay )", Cft_Overlay, &cfOc_overlay },
657 "NAME 'olcIncludeFile' "
658 "DESC 'OpenLDAP configuration include file' "
659 "SUP olcConfig STRUCTURAL "
661 "MAY ( cn $ olcRootDSE ) )",
662 Cft_Include, &cfOc_include },
665 "NAME 'olcModuleList' "
666 "DESC 'OpenLDAP dynamic module info' "
667 "SUP olcConfig STRUCTURAL "
668 "MUST olcModuleLoad "
669 "MAY cn )", Cft_Module, &cfOc_module },
675 config_generic(ConfigArgs *c) {
679 if ( c->op == SLAP_CONFIG_EMIT ) {
683 c->value_int = ldap_pvt_thread_get_concurrency();
686 c->value_int = connection_pool_max;
690 c->value_string = ch_strdup( passwd_salt );
695 if ( c->be->be_limits ) {
700 for ( i=0; c->be->be_limits[i]; i++ ) {
701 bv.bv_len = sprintf( buf, IFMT, i );
702 bv.bv_val = buf+bv.bv_len;
703 limits_unparse( c->be->be_limits[i], &bv );
704 bv.bv_len += bv.bv_val - buf;
706 value_add_one( &c->rvalue_vals, &bv );
709 if ( !c->rvalue_vals ) rc = 1;
712 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_OP_WRITES) != 0;
715 c->value_string = ch_strdup( slap_sasl_getpolicy());
718 slap_sasl_regexp_unparse( &c->rvalue_vals );
719 if ( !c->rvalue_vals ) rc = 1;
721 #ifdef HAVE_CYRUS_SASL
723 struct berval bv = BER_BVNULL;
724 slap_sasl_secprops_unparse( &bv );
725 if ( !BER_BVISNULL( &bv )) {
726 ber_bvarray_add( &c->rvalue_vals, &bv );
734 c->value_int = c->be->be_max_deref_depth;
737 ConfigFile *cf = c->private;
739 oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
740 else if ( cf->c_om_head )
741 oidm_unparse( &c->rvalue_vals, cf->c_om_head,
743 if ( !c->rvalue_vals )
748 ConfigFile *cf = c->private;
750 oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
751 else if ( cf->c_oc_head )
752 oc_unparse( &c->rvalue_vals, cf->c_oc_head,
754 if ( !c->rvalue_vals )
759 ConfigFile *cf = c->private;
761 at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
762 else if ( cf->c_at_head )
763 at_unparse( &c->rvalue_vals, cf->c_at_head,
765 if ( !c->rvalue_vals )
770 ConfigFile *cf = c->private;
772 cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
773 else if ( cf->c_cr_head )
774 cr_unparse( &c->rvalue_vals, cf->c_cr_head,
776 if ( !c->rvalue_vals )
782 c->value_int = global_schemacheck;
786 char *src, *dst, ibuf[11];
787 struct berval bv, abv;
788 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
789 abv.bv_len = sprintf( ibuf, IFMT, i );
790 acl_unparse( a, &bv );
791 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
792 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
793 /* Turn TAB / EOL into plain space */
794 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
795 if (isspace(*src)) *dst++ = ' ';
799 if (dst[-1] == ' ') {
803 abv.bv_len = dst - abv.bv_val;
804 ber_bvarray_add( &c->rvalue_vals, &abv );
810 if ( c->be->be_replogfile )
811 c->value_string = ch_strdup( c->be->be_replogfile );
814 ConfigFile *cf = c->private;
815 if ( cf->c_dseFiles ) {
816 value_add( &c->rvalue_vals, cf->c_dseFiles );
824 c->value_string = ch_strdup( logfileName );
829 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
831 case CFG_SSTR_IF_MAX:
832 c->value_int = index_substr_if_maxlen;
834 case CFG_SSTR_IF_MIN:
835 c->value_int = index_substr_if_minlen;
839 ModPaths *mp = c->private;
842 for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
845 bv.bv_len = sprintf( bv.bv_val, IFMT "%s", i,
846 mp->mp_loads[i].bv_val );
847 value_add_one( &c->rvalue_vals, &bv );
851 rc = c->rvalue_vals ? 0 : 1;
856 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
858 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
861 bv.bv_len = sprintf( bv.bv_val, IFMT "%s", i,
862 mp->mp_path.bv_val );
863 value_add_one( &c->rvalue_vals, &bv );
865 rc = c->rvalue_vals ? 0 : 1;
871 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
872 if ( !c->rvalue_vals ) rc = 1;
875 #ifdef SLAP_AUTH_REWRITE
877 if ( authz_rewrites ) {
878 struct berval bv, idx;
883 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
884 idx.bv_len = sprintf( idx.bv_val, IFMT, i );
885 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
886 bv.bv_val = ch_malloc( bv.bv_len + 1 );
887 strcpy( bv.bv_val, idx.bv_val );
888 strcpy( bv.bv_val+idx.bv_len, authz_rewrites[i].bv_val );
889 ber_bvarray_add( &c->rvalue_vals, &bv );
892 if ( !c->rvalue_vals ) rc = 1;
901 p = strchr(c->line,'(' /*')'*/);
902 if ( c->op == LDAP_MOD_DELETE ) {
910 ldap_pvt_thread_set_concurrency(c->value_int);
917 if(!(c->bi = backend_info(c->argv[1]))) {
918 Debug(LDAP_DEBUG_ANY, "%s: "
919 "backend %s failed init!\n", c->log, c->argv[1], 0);
926 /* NOTE: config is always the first backend!
928 if ( !strcasecmp( c->argv[1], "config" )) {
929 c->be = LDAP_STAILQ_FIRST(&backendDB);
930 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
932 } else if(!(c->be = backend_db_init(c->argv[1]))) {
933 Debug(LDAP_DEBUG_ANY, "%s: "
934 "database %s failed init!\n", c->log, c->argv[1], 0);
940 ldap_pvt_thread_set_concurrency(c->value_int);
944 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
945 connection_pool_max = c->value_int; /* save for reference */
949 if ( passwd_salt ) ch_free( passwd_salt );
950 passwd_salt = c->value_string;
951 lutil_salt_format(passwd_salt);
955 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
961 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
963 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
967 ch_free(c->value_string);
968 if (slap_sasl_setpolicy( c->argv[1] )) {
969 Debug(LDAP_DEBUG_ANY, "%s: unable to parse value \"%s\" in"
970 " \"authz-policy <policy>\"\n",
971 c->log, c->argv[1], 0 );
977 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
981 #ifdef HAVE_CYRUS_SASL
984 char *txt = slap_sasl_secprops( c->argv[1] );
986 Debug(LDAP_DEBUG_ANY, "%s: sasl-secprops: %s\n",
995 c->be->be_max_deref_depth = c->value_int;
1001 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv, 1, &om))
1003 if (!cfn->c_om_head) cfn->c_om_head = om;
1004 cfn->c_om_tail = om;
1011 if(parse_oc(c->fname, c->lineno, p, c->argv, &oc)) return(1);
1012 if (!cfn->c_oc_head) cfn->c_oc_head = oc;
1013 cfn->c_oc_tail = oc;
1020 if(parse_cr(c->fname, c->lineno, p, c->argv, &cr)) return(1);
1021 if (!cfn->c_cr_head) cfn->c_cr_head = cr;
1022 cfn->c_cr_tail = cr;
1029 if(parse_at(c->fname, c->lineno, p, c->argv, &at)) return(1);
1030 if (!cfn->c_at_head) cfn->c_at_head = at;
1031 cfn->c_at_tail = at;
1036 ad_define_option(NULL, NULL, 0);
1037 for(i = 1; i < c->argc; i++)
1038 if(ad_define_option(c->argv[i], c->fname, c->lineno))
1043 global_schemacheck = c->value_int;
1044 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: "
1045 "schema checking disabled! your mileage may vary!\n",
1050 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
1054 if(SLAP_MONITOR(c->be)) {
1055 Debug(LDAP_DEBUG_ANY, "%s: "
1056 "\"replogfile\" should not be used "
1057 "inside monitor database\n",
1059 return(0); /* FIXME: should this be an error? */
1062 c->be->be_replogfile = c->value_string;
1066 if(read_root_dse_file(c->argv[1])) {
1067 Debug(LDAP_DEBUG_ANY, "%s: "
1068 "could not read \"rootDSE <filename>\" line\n",
1074 ber_str2bv( c->argv[1], 0, 1, &bv );
1075 ber_bvarray_add( &cfn->c_dseFiles, &bv );
1081 if ( logfileName ) ch_free( logfileName );
1082 logfileName = c->value_string;
1083 logfile = fopen(logfileName, "w");
1084 if(logfile) lutil_debug_file(logfile);
1088 if(SLAP_NOLASTMODCMD(c->be)) {
1089 Debug(LDAP_DEBUG_ANY, "%s: "
1090 "lastmod not available for %s databases\n",
1091 c->log, c->be->bd_info->bi_type, 0);
1095 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
1097 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
1100 case CFG_SSTR_IF_MAX:
1101 if (c->value_int < index_substr_if_minlen) {
1102 Debug(LDAP_DEBUG_ANY, "%s: "
1103 "invalid max value (%d)\n",
1104 c->log, c->value_int, 0 );
1107 index_substr_if_maxlen = c->value_int;
1110 case CFG_SSTR_IF_MIN:
1111 if (c->value_int > index_substr_if_maxlen) {
1112 Debug(LDAP_DEBUG_ANY, "%s: "
1113 "invalid min value (%d)\n",
1114 c->log, c->value_int, 0 );
1117 index_substr_if_minlen = c->value_int;
1120 #ifdef SLAPD_MODULES
1122 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
1124 /* Record this load on the current path */
1127 char *ptr = c->line + STRLENOF("moduleload");
1128 while (!isspace(*ptr)) ptr++;
1129 while (isspace(*ptr)) ptr++;
1130 ber_str2bv(ptr, 0, 1, &bv);
1131 ber_bvarray_add( &modcur->mp_loads, &bv );
1136 if(module_path(c->argv[1])) return(1);
1137 /* Record which path was used with each module */
1141 if (!modpaths.mp_loads) {
1144 mp = ch_malloc( sizeof( ModPaths ));
1145 modlast->mp_next = mp;
1147 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
1149 mp->mp_loads = NULL;
1151 if ( c->op == SLAP_CONFIG_ADD )
1160 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
1162 slapi_plugins_used++;
1166 #ifdef SLAP_AUTH_REWRITE
1169 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
1171 ber_str2bv( c->line, 0, 1, &bv );
1172 ber_bvarray_add( &authz_rewrites, &bv );
1179 Debug(LDAP_DEBUG_ANY, "%s: unknown CFG_TYPE %d"
1180 "(ignored)\n", c->log, c->type, 0);
1188 config_fname(ConfigArgs *c) {
1189 if(c->op == SLAP_CONFIG_EMIT) {
1191 ConfigFile *cf = c->private;
1192 value_add_one( &c->rvalue_vals, &cf->c_file );
1201 config_cfdir(ConfigArgs *c) {
1202 if(c->op == SLAP_CONFIG_EMIT) {
1203 value_add_one( &c->rvalue_vals, &cfdir );
1210 config_search_base(ConfigArgs *c) {
1213 if(c->op == SLAP_CONFIG_EMIT) {
1215 if (!BER_BVISEMPTY(&default_search_base)) {
1216 value_add_one(&c->rvalue_vals, &default_search_base);
1217 value_add_one(&c->rvalue_nvals, &default_search_nbase);
1223 if(c->bi || c->be != frontendDB) {
1224 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
1225 "prior to any backend or database definition\n",
1230 if(default_search_nbase.bv_len) {
1231 Debug(LDAP_DEBUG_ANY, "%s: "
1232 "default search base \"%s\" already defined "
1233 "(discarding old)\n",
1234 c->log, default_search_base.bv_val, 0);
1235 free(default_search_base.bv_val);
1236 free(default_search_nbase.bv_val);
1239 default_search_base = c->value_dn;
1240 default_search_nbase = c->value_ndn;
1245 config_passwd_hash(ConfigArgs *c) {
1247 if (c->op == SLAP_CONFIG_EMIT) {
1249 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
1250 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
1251 value_add_one(&c->rvalue_vals, &bv);
1255 if(default_passwd_hash) {
1256 Debug(LDAP_DEBUG_ANY, "%s: "
1257 "already set default password_hash\n",
1261 for(i = 1; i < c->argc; i++) {
1262 if(!lutil_passwd_scheme(c->argv[i])) {
1263 Debug(LDAP_DEBUG_ANY, "%s: "
1264 "password scheme \"%s\" not available\n",
1265 c->log, c->argv[i], 0);
1267 ldap_charray_add(&default_passwd_hash, c->argv[i]);
1269 if(!default_passwd_hash) {
1270 Debug(LDAP_DEBUG_ANY, "%s: no valid hashes found\n",
1279 config_schema_dn(ConfigArgs *c) {
1280 if ( c->op == SLAP_CONFIG_EMIT ) {
1282 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
1283 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
1284 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
1289 c->be->be_schemadn = c->value_dn;
1290 c->be->be_schemandn = c->value_ndn;
1295 config_sizelimit(ConfigArgs *c) {
1298 struct slap_limits_set *lim = &c->be->be_def_limit;
1299 if (c->op == SLAP_CONFIG_EMIT) {
1304 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv );
1305 if ( !BER_BVISEMPTY( &bv ))
1306 value_add_one( &c->rvalue_vals, &bv );
1311 for(i = 1; i < c->argc; i++) {
1312 if(!strncasecmp(c->argv[i], "size", 4)) {
1313 rc = limits_parse_one(c->argv[i], lim);
1315 Debug(LDAP_DEBUG_ANY, "%s: "
1316 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
1317 c->log, c->argv[i], 0);
1321 if(!strcasecmp(c->argv[i], "unlimited")) {
1322 lim->lms_s_soft = -1;
1324 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
1325 if(next == c->argv[i]) {
1326 Debug(LDAP_DEBUG_ANY, "%s: "
1327 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
1328 c->log, c->argv[i], 0);
1330 } else if(next[0] != '\0') {
1331 Debug(LDAP_DEBUG_ANY, "%s: "
1332 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
1336 lim->lms_s_hard = 0;
1343 config_timelimit(ConfigArgs *c) {
1346 struct slap_limits_set *lim = &c->be->be_def_limit;
1347 if (c->op == SLAP_CONFIG_EMIT) {
1352 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv );
1353 if ( !BER_BVISEMPTY( &bv ))
1354 value_add_one( &c->rvalue_vals, &bv );
1359 for(i = 1; i < c->argc; i++) {
1360 if(!strncasecmp(c->argv[i], "time", 4)) {
1361 rc = limits_parse_one(c->argv[i], lim);
1363 Debug(LDAP_DEBUG_ANY, "%s: "
1364 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
1365 c->log, c->argv[i], 0);
1369 if(!strcasecmp(c->argv[i], "unlimited")) {
1370 lim->lms_t_soft = -1;
1372 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
1373 if(next == c->argv[i]) {
1374 Debug(LDAP_DEBUG_ANY, "%s: "
1375 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
1376 c->log, c->argv[i], 0);
1378 } else if(next[0] != '\0') {
1379 Debug(LDAP_DEBUG_ANY, "%s: "
1380 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
1384 lim->lms_t_hard = 0;
1391 config_overlay(ConfigArgs *c) {
1392 if (c->op == SLAP_CONFIG_EMIT) {
1395 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
1397 Debug(LDAP_DEBUG_ANY, "%s: (optional) %s overlay \"%s\" configuration failed (ignored)\n",
1398 c->log, c->be == frontendDB ? "global " : "", c->argv[1][1]);
1399 } else if(overlay_config(c->be, c->argv[1])) {
1406 config_suffix(ConfigArgs *c) {
1408 struct berval pdn, ndn;
1411 if (c->be == frontendDB || SLAP_MONITOR(c->be) ||
1412 SLAP_CONFIG(c->be)) return 1;
1414 if (c->op == SLAP_CONFIG_EMIT) {
1415 if ( c->be->be_suffix == NULL
1416 || BER_BVISNULL( &c->be->be_suffix[0] ) )
1420 value_add( &c->rvalue_vals, c->be->be_suffix );
1421 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
1425 #ifdef SLAPD_MONITOR_DN
1426 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
1427 Debug(LDAP_DEBUG_ANY, "%s: "
1428 "\"%s\" is reserved for monitoring slapd\n",
1429 c->log, SLAPD_MONITOR_DN, 0);
1436 tbe = select_backend(&ndn, 0, 0);
1438 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by this backend! (ignored)\n",
1443 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by a preceding backend \"%s\"\n",
1444 c->log, tbe->be_suffix[0].bv_val, 0);
1448 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
1449 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
1450 "base provided \"%s\" (assuming okay)\n",
1451 c->log, default_search_base.bv_val, 0);
1453 ber_bvarray_add(&c->be->be_suffix, &pdn);
1454 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
1459 config_rootdn(ConfigArgs *c) {
1460 if (c->op == SLAP_CONFIG_EMIT) {
1461 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
1462 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
1463 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
1469 c->be->be_rootdn = c->value_dn;
1470 c->be->be_rootndn = c->value_ndn;
1475 config_rootpw(ConfigArgs *c) {
1477 if (c->op == SLAP_CONFIG_EMIT) {
1478 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
1479 ber_dupbv( &c->value_bv, &c->be->be_rootpw);
1485 tbe = select_backend(&c->be->be_rootndn, 0, 0);
1487 Debug(LDAP_DEBUG_ANY, "%s: "
1488 "rootpw can only be set when rootdn is under suffix\n",
1492 c->be->be_rootpw = c->value_bv;
1497 config_restrict(ConfigArgs *c) {
1498 slap_mask_t restrictops = 0;
1500 slap_verbmasks restrictable_ops[] = {
1501 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
1502 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
1503 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
1504 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
1505 { BER_BVC("modrdn"), 0 },
1506 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
1507 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
1508 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
1509 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
1510 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
1511 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
1512 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
1513 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
1514 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
1515 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
1519 if (c->op == SLAP_CONFIG_EMIT) {
1520 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
1523 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
1525 Debug(LDAP_DEBUG_ANY, "%s: "
1526 "unknown operation %s in \"restrict <features>\" line\n",
1527 c->log, c->argv[i], 0);
1530 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
1531 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
1532 c->be->be_restrictops |= restrictops;
1537 config_allows(ConfigArgs *c) {
1538 slap_mask_t allows = 0;
1540 slap_verbmasks allowable_ops[] = {
1541 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
1542 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
1543 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
1544 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
1547 if (c->op == SLAP_CONFIG_EMIT) {
1548 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
1550 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
1552 Debug(LDAP_DEBUG_ANY, "%s: "
1553 "unknown feature %s in \"allow <features>\" line\n",
1554 c->log, c->argv[i], 0);
1557 global_allows |= allows;
1562 config_disallows(ConfigArgs *c) {
1563 slap_mask_t disallows = 0;
1565 slap_verbmasks disallowable_ops[] = {
1566 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
1567 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
1568 { BER_BVC("bind_krb4"), SLAP_DISALLOW_BIND_KRBV4 },
1569 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
1570 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
1573 if (c->op == SLAP_CONFIG_EMIT) {
1574 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
1576 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
1578 Debug(LDAP_DEBUG_ANY, "%s: "
1579 "unknown feature %s in \"disallow <features>\" line\n",
1580 c->log, c->argv[i], 0);
1583 global_disallows |= disallows;
1588 config_requires(ConfigArgs *c) {
1589 slap_mask_t requires = 0;
1591 slap_verbmasks requires_ops[] = {
1592 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
1593 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
1594 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
1595 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
1596 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
1599 if (c->op == SLAP_CONFIG_EMIT) {
1600 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
1602 i = verbs_to_mask(c->argc, c->argv, requires_ops, &requires);
1604 Debug(LDAP_DEBUG_ANY, "%s: "
1605 "unknown feature %s in \"require <features>\" line\n",
1606 c->log, c->argv[i], 0);
1609 c->be->be_requires = requires;
1614 config_loglevel(ConfigArgs *c) {
1617 slap_verbmasks loglevel_ops[] = {
1618 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
1619 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
1620 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
1621 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
1622 { BER_BVC("BER"), LDAP_DEBUG_BER },
1623 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
1624 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
1625 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
1626 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
1627 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
1628 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
1629 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
1630 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
1631 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
1632 { BER_BVC("Any"), -1 },
1636 if (c->op == SLAP_CONFIG_EMIT) {
1637 return mask_to_verbs( loglevel_ops, ldap_syslog, &c->rvalue_vals );
1642 for( i=1; i < c->argc; i++ ) {
1645 if ( isdigit( c->argv[i][0] ) ) {
1646 level = strtol( c->argv[i], &next, 10 );
1647 if ( next == NULL || next[0] != '\0' ) {
1648 Debug( LDAP_DEBUG_ANY,
1649 "%s: unable to parse level \"%s\" "
1650 "in \"loglevel <level> [...]\" line.\n",
1651 c->log, c->argv[i], 0);
1655 int j = verb_to_mask(c->argv[i], loglevel_ops);
1656 if(BER_BVISNULL(&loglevel_ops[j].word)) {
1657 Debug( LDAP_DEBUG_ANY,
1658 "%s: unknown level \"%s\" "
1659 "in \"loglevel <level> [...]\" line.\n",
1660 c->log, c->argv[i], 0);
1663 level = loglevel_ops[j].mask;
1665 ldap_syslog |= level;
1671 config_syncrepl(ConfigArgs *c) {
1672 if (c->op == SLAP_CONFIG_EMIT) {
1673 if ( c->be->be_syncinfo ) {
1675 syncrepl_unparse( c->be->be_syncinfo, &bv );
1676 ber_bvarray_add( &c->rvalue_vals, &bv );
1681 if(SLAP_SHADOW(c->be)) {
1682 Debug(LDAP_DEBUG_ANY, "%s: "
1683 "syncrepl: database already shadowed.\n",
1686 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1689 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1694 config_referral(ConfigArgs *c) {
1695 struct berval vals[2];
1696 if (c->op == SLAP_CONFIG_EMIT) {
1697 if ( default_referral ) {
1698 value_add( &c->rvalue_vals, default_referral );
1704 if(validate_global_referral(c->argv[1])) {
1705 Debug(LDAP_DEBUG_ANY, "%s: "
1706 "invalid URL (%s) in \"referral\" line.\n",
1707 c->log, c->argv[1], 0);
1711 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1712 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1713 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1721 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
1722 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
1723 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
1724 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
1725 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
1726 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
1727 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
1728 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
1729 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
1734 config_security(ConfigArgs *c) {
1735 slap_ssf_set_t *set = &c->be->be_ssf_set;
1738 if (c->op == SLAP_CONFIG_EMIT) {
1744 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
1745 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
1748 bv.bv_len = sprintf( numbuf, "%u", *tgt );
1749 bv.bv_len += sec_keys[i].key.bv_len;
1750 bv.bv_val = ch_malloc( bv.bv_len + 1);
1751 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
1752 strcpy( next, numbuf );
1753 ber_bvarray_add( &c->rvalue_vals, &bv );
1758 for(i = 1; i < c->argc; i++) {
1759 slap_ssf_t *tgt = NULL;
1761 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
1762 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
1763 sec_keys[j].key.bv_len)) {
1764 src = c->argv[i] + sec_keys[j].key.bv_len;
1765 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
1770 Debug(LDAP_DEBUG_ANY, "%s: "
1771 "unknown factor %s in \"security <factors>\" line\n",
1772 c->log, c->argv[i], 0);
1776 *tgt = strtol(src, &next, 10);
1777 if(next == NULL || next[0] != '\0' ) {
1778 Debug(LDAP_DEBUG_ANY, "%s: "
1779 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1780 c->log, c->argv[i], 0);
1788 anlist_unparse( AttributeName *an, char *ptr ) {
1791 for (; !BER_BVISNULL( &an->an_name ); an++) {
1792 if ( comma ) *ptr++ = ',';
1793 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
1800 replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
1804 struct berval bc = {0};
1807 len = sprintf(numbuf, IFMT, i );
1809 len += strlen( ri->ri_uri ) + STRLENOF("uri=");
1810 if ( ri->ri_nsuffix ) {
1811 for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
1812 len += ri->ri_nsuffix[i].bv_len + STRLENOF(" suffix=\"\"");
1815 if ( ri->ri_attrs ) {
1816 len += STRLENOF("attr");
1817 if ( ri->ri_exclude ) len++;
1818 for (i=0; !BER_BVISNULL( &ri->ri_attrs[i].an_name ); i++) {
1819 len += 1 + ri->ri_attrs[i].an_name.bv_len;
1822 bindconf_unparse( &ri->ri_bindconf, &bc );
1825 bv->bv_val = ch_malloc(len + 1);
1828 ptr = lutil_strcopy( bv->bv_val, numbuf );
1829 ptr = lutil_strcopy( ptr, "uri=" );
1830 ptr = lutil_strcopy( ptr, ri->ri_uri );
1832 if ( ri->ri_nsuffix ) {
1833 for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
1834 ptr = lutil_strcopy( ptr, " suffix=\"" );
1835 ptr = lutil_strcopy( ptr, ri->ri_nsuffix[i].bv_val );
1839 if ( ri->ri_attrs ) {
1840 ptr = lutil_strcopy( ptr, "attr" );
1841 if ( ri->ri_exclude ) *ptr++ = '!';
1843 ptr = anlist_unparse( ri->ri_attrs, ptr );
1846 strcpy( ptr, bc.bv_val );
1847 ch_free( bc.bv_val );
1852 config_replica(ConfigArgs *c) {
1853 int i, nr = -1, len;
1854 char *replicahost, *replicauri;
1857 if (c->op == SLAP_CONFIG_EMIT) {
1858 if (c->be->be_replica) {
1860 for (i=0;c->be->be_replica[i]; i++) {
1861 replica_unparse( c->be->be_replica[i], i, &bv );
1862 ber_bvarray_add( &c->rvalue_vals, &bv );
1868 if(SLAP_MONITOR(c->be)) {
1869 Debug(LDAP_DEBUG_ANY, "%s: "
1870 "\"replica\" should not be used inside monitor database\n",
1872 return(0); /* FIXME: should this be an error? */
1875 for(i = 1; i < c->argc; i++) {
1876 if(!strncasecmp(c->argv[i], "host=", STRLENOF("host="))) {
1877 replicahost = c->argv[i] + STRLENOF("host=");
1878 len = strlen( replicahost );
1879 replicauri = ch_malloc( len + STRLENOF("ldap://") + 1 );
1880 sprintf( replicauri, "ldap://%s", replicahost );
1881 replicahost = replicauri + STRLENOF( "ldap://");
1882 nr = add_replica_info(c->be, replicauri, replicahost);
1884 } else if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) {
1885 if(ldap_url_parse(c->argv[i] + STRLENOF("uri="), &ludp) != LDAP_SUCCESS) {
1886 Debug(LDAP_DEBUG_ANY, "%s: "
1887 "replica line contains invalid "
1888 "uri definition.\n", c->log, 0, 0);
1891 if(!ludp->lud_host) {
1892 Debug(LDAP_DEBUG_ANY, "%s: "
1893 "replica line contains invalid "
1894 "uri definition - missing hostname.\n",
1898 ldap_free_urldesc(ludp);
1899 replicauri = c->argv[i] + STRLENOF("uri=");
1900 replicauri = ch_strdup( replicauri );
1901 replicahost = strchr( replicauri, '/' );
1903 nr = add_replica_info(c->be, replicauri, replicahost);
1908 Debug(LDAP_DEBUG_ANY, "%s: "
1909 "missing host or uri in \"replica\" line\n",
1912 } else if(nr == -1) {
1913 Debug(LDAP_DEBUG_ANY, "%s: "
1914 "unable to add replica \"%s\"\n",
1915 c->log, replicauri, 0);
1918 for(i = 1; i < c->argc; i++) {
1919 if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
1920 switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) {
1922 Debug(LDAP_DEBUG_ANY, "%s: "
1923 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1924 c->log, c->argv[i] + STRLENOF("suffix="), 0);
1927 Debug(LDAP_DEBUG_ANY, "%s: "
1928 "unable to normalize suffix in \"replica\" line (ignored)\n",
1933 } else if(!strncasecmp(c->argv[i], "attr", STRLENOF("attr"))) {
1935 char *arg = c->argv[i] + STRLENOF("attr");
1943 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1944 Debug(LDAP_DEBUG_ANY, "%s: "
1945 "attribute \"%s\" in \"replica\" line is unknown\n",
1946 c->log, arg + 1, 0);
1949 } else if ( bindconf_parse( c->argv[i],
1950 &c->be->be_replica[nr]->ri_bindconf ) ) {
1959 config_updatedn(ConfigArgs *c) {
1962 if (c->op == SLAP_CONFIG_EMIT) {
1963 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
1964 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
1965 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
1970 if(SLAP_SHADOW(c->be)) {
1971 Debug(LDAP_DEBUG_ANY, "%s: "
1972 "updatedn: database already shadowed.\n",
1977 ber_str2bv(c->argv[1], 0, 0, &dn);
1979 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1981 if(rc != LDAP_SUCCESS) {
1982 Debug(LDAP_DEBUG_ANY, "%s: "
1983 "updatedn DN is invalid: %d (%s)\n",
1984 c->log, rc, ldap_err2string( rc ));
1988 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1993 config_updateref(ConfigArgs *c) {
1994 struct berval vals[2];
1995 if (c->op == SLAP_CONFIG_EMIT) {
1996 if ( c->be->be_update_refs ) {
1997 value_add( &c->rvalue_vals, c->be->be_update_refs );
2003 if(!SLAP_SHADOW(c->be)) {
2004 Debug(LDAP_DEBUG_ANY, "%s: "
2005 "updateref line must come after syncrepl or updatedn.\n",
2010 if(validate_global_referral(c->argv[1])) {
2011 Debug(LDAP_DEBUG_ANY, "%s: "
2012 "invalid URL (%s) in \"updateref\" line.\n",
2013 c->log, c->argv[1], 0);
2016 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
2017 vals[1].bv_val = NULL;
2018 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
2023 config_include(ConfigArgs *c) {
2024 unsigned long savelineno = c->lineno;
2027 ConfigFile *cfsave = cfn;
2028 ConfigFile *cf2 = NULL;
2029 if (c->op == SLAP_CONFIG_EMIT) {
2031 ConfigFile *cf = c->private;
2032 value_add_one( &c->rvalue_vals, &cf->c_file );
2037 cf = ch_calloc( 1, sizeof(ConfigFile));
2038 if ( cfn->c_kids ) {
2039 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
2045 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
2046 rc = read_config_file(c->argv[1], c->depth + 1, c);
2047 c->lineno = savelineno - 1;
2050 if ( cf2 ) cf2->c_sibs = NULL;
2051 else cfn->c_kids = NULL;
2052 ch_free( cf->c_file.bv_val );
2060 config_tls_option(ConfigArgs *c) {
2063 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
2064 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
2065 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
2066 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
2067 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
2068 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
2069 default: Debug(LDAP_DEBUG_ANY, "%s: "
2070 "unknown tls_option <0x%x>\n",
2071 c->log, c->type, 0);
2073 if (c->op == SLAP_CONFIG_EMIT) {
2074 return ldap_pvt_tls_get_option( NULL, flag, &c->value_string );
2076 ch_free(c->value_string);
2077 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
2080 /* FIXME: this ought to be provided by libldap */
2082 config_tls_config(ConfigArgs *c) {
2084 slap_verbmasks crlkeys[] = {
2085 { BER_BVC("none"), LDAP_OPT_X_TLS_CRL_NONE },
2086 { BER_BVC("peer"), LDAP_OPT_X_TLS_CRL_PEER },
2087 { BER_BVC("all"), LDAP_OPT_X_TLS_CRL_ALL },
2090 slap_verbmasks vfykeys[] = {
2091 { BER_BVC("never"), LDAP_OPT_X_TLS_NEVER },
2092 { BER_BVC("demand"), LDAP_OPT_X_TLS_DEMAND },
2093 { BER_BVC("try"), LDAP_OPT_X_TLS_TRY },
2094 { BER_BVC("hard"), LDAP_OPT_X_TLS_HARD },
2098 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; keys = crlkeys; break;
2099 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; keys = vfykeys; break;
2101 Debug(LDAP_DEBUG_ANY, "%s: "
2102 "unknown tls_option <0x%x>\n",
2103 c->log, c->type, 0);
2105 if (c->op == SLAP_CONFIG_EMIT) {
2106 ldap_pvt_tls_get_option( NULL, flag, &c->value_int );
2107 for (i=0; !BER_BVISNULL(&keys[i].word); i++) {
2108 if (keys[i].mask == c->value_int) {
2109 c->value_string = ch_strdup( keys[i].word.bv_val );
2115 ch_free( c->value_string );
2116 if(isdigit((unsigned char)c->argv[1][0])) {
2117 i = atoi(c->argv[1]);
2118 return(ldap_pvt_tls_set_option(NULL, flag, &i));
2120 return(ldap_int_tls_config(NULL, flag, c->argv[1]));
2135 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2138 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2142 si->si_bindconf.sb_tls = SB_TLS_OFF;
2143 si->si_bindconf.sb_method = LDAP_AUTH_SIMPLE;
2144 si->si_schemachecking = 0;
2145 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
2146 &si->si_filterstr );
2147 si->si_base.bv_val = NULL;
2148 si->si_scope = LDAP_SCOPE_SUBTREE;
2149 si->si_attrsonly = 0;
2150 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
2151 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
2152 si->si_attrs = NULL;
2153 si->si_allattrs = 0;
2154 si->si_allopattrs = 0;
2155 si->si_exattrs = NULL;
2156 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2157 si->si_interval = 86400;
2158 si->si_retryinterval = NULL;
2159 si->si_retrynum_init = NULL;
2160 si->si_retrynum = NULL;
2161 si->si_manageDSAit = 0;
2165 si->si_presentlist = NULL;
2166 LDAP_LIST_INIT( &si->si_nonpresentlist );
2167 ldap_pvt_thread_mutex_init( &si->si_mutex );
2169 rc = parse_syncrepl_line( cargv, cargc, si );
2172 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2173 syncinfo_free( si );
2176 Debug( LDAP_DEBUG_CONFIG,
2177 "Config: ** successfully added syncrepl \"%s\"\n",
2178 BER_BVISNULL( &si->si_provideruri ) ?
2179 "(null)" : si->si_provideruri.bv_val, 0, 0 );
2180 if ( !si->si_schemachecking ) {
2181 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2184 be->be_syncinfo = si;
2189 /* NOTE: used & documented in slapd.conf(5) */
2191 #define PROVIDERSTR "provider"
2192 #define TYPESTR "type"
2193 #define INTERVALSTR "interval"
2194 #define SEARCHBASESTR "searchbase"
2195 #define FILTERSTR "filter"
2196 #define SCOPESTR "scope"
2197 #define ATTRSSTR "attrs"
2198 #define ATTRSONLYSTR "attrsonly"
2199 #define SLIMITSTR "sizelimit"
2200 #define TLIMITSTR "timelimit"
2201 #define SCHEMASTR "schemachecking"
2203 /* FIXME: undocumented */
2204 #define OLDAUTHCSTR "bindprincipal"
2205 #define EXATTRSSTR "exattrs"
2206 #define RETRYSTR "retry"
2209 #define LASTMODSTR "lastmod"
2210 #define LMGENSTR "gen"
2211 #define LMNOSTR "no"
2212 #define LMREQSTR "req"
2213 #define SRVTABSTR "srvtab"
2214 #define SUFFIXSTR "suffix"
2215 #define MANAGEDSAITSTR "manageDSAit"
2218 #define GOT_ID 0x0001
2219 #define GOT_PROVIDER 0x0002
2222 #define GOT_ALL (GOT_ID|GOT_PROVIDER)
2228 { BER_BVC("base"), LDAP_SCOPE_BASE },
2229 { BER_BVC("one"), LDAP_SCOPE_ONELEVEL },
2230 #ifdef LDAP_SCOPE_SUBORDINATE
2231 { BER_BVC("children"), LDAP_SCOPE_SUBORDINATE },
2232 { BER_BVC("subordinate"), 0 },
2234 { BER_BVC("sub"), LDAP_SCOPE_SUBTREE },
2239 parse_syncrepl_line(
2249 for ( i = 1; i < cargc; i++ ) {
2250 if ( !strncasecmp( cargv[ i ], IDSTR "=",
2251 STRLENOF( IDSTR "=" ) ) )
2254 /* '\0' string terminator accounts for '=' */
2255 val = cargv[ i ] + STRLENOF( IDSTR "=" );
2257 if ( tmp >= 1000 || tmp < 0 ) {
2258 fprintf( stderr, "Error: parse_syncrepl_line: "
2259 "syncrepl id %d is out of range [0..999]\n", tmp );
2264 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
2265 STRLENOF( PROVIDERSTR "=" ) ) )
2267 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
2268 ber_str2bv( val, 0, 1, &si->si_provideruri );
2269 gots |= GOT_PROVIDER;
2270 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
2271 STRLENOF( SCHEMASTR "=" ) ) )
2273 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
2274 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
2275 si->si_schemachecking = 1;
2276 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
2277 si->si_schemachecking = 0;
2279 si->si_schemachecking = 1;
2281 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
2282 STRLENOF( FILTERSTR "=" ) ) )
2284 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
2285 ber_str2bv( val, 0, 1, &si->si_filterstr );
2286 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
2287 STRLENOF( SEARCHBASESTR "=" ) ) )
2292 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
2293 if ( si->si_base.bv_val ) {
2294 ch_free( si->si_base.bv_val );
2296 ber_str2bv( val, 0, 0, &bv );
2297 rc = dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL );
2298 if ( rc != LDAP_SUCCESS ) {
2299 fprintf( stderr, "Invalid base DN \"%s\": %d (%s)\n",
2300 val, rc, ldap_err2string( rc ) );
2303 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
2304 STRLENOF( SCOPESTR "=" ) ) )
2307 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
2308 for ( j=0; !BER_BVISNULL(&scopes[j].key); j++ ) {
2309 if (!strncasecmp( val, scopes[j].key.bv_val,
2310 scopes[j].key.bv_len )) {
2311 while (!scopes[j].val) j--;
2312 si->si_scope = scopes[j].val;
2316 if ( BER_BVISNULL(&scopes[j].key) ) {
2317 fprintf( stderr, "Error: parse_syncrepl_line: "
2318 "unknown scope \"%s\"\n", val);
2321 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
2322 STRLENOF( ATTRSONLYSTR "=" ) ) )
2324 si->si_attrsonly = 1;
2325 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
2326 STRLENOF( ATTRSSTR "=" ) ) )
2328 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
2329 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
2331 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2332 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
2333 if ( si->si_anlist == NULL ) {
2334 ch_free( attr_fname );
2337 si->si_anfile = attr_fname;
2339 char *str, *s, *next;
2340 char delimstr[] = " ,\t";
2341 str = ch_strdup( val );
2342 for ( s = ldap_pvt_strtok( str, delimstr, &next );
2344 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
2346 if ( strlen(s) == 1 && *s == '*' ) {
2347 si->si_allattrs = 1;
2348 *(val + ( s - str )) = delimstr[0];
2350 if ( strlen(s) == 1 && *s == '+' ) {
2351 si->si_allopattrs = 1;
2352 *(val + ( s - str )) = delimstr[0];
2356 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
2357 if ( si->si_anlist == NULL ) {
2361 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
2362 STRLENOF( EXATTRSSTR "=" ) ) )
2364 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
2365 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
2367 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2368 si->si_exanlist = file2anlist(
2369 si->si_exanlist, attr_fname, " ,\t" );
2370 if ( si->si_exanlist == NULL ) {
2371 ch_free( attr_fname );
2374 ch_free( attr_fname );
2376 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
2377 if ( si->si_exanlist == NULL ) {
2381 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
2382 STRLENOF( TYPESTR "=" ) ) )
2384 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
2385 if ( !strncasecmp( val, "refreshOnly",
2386 STRLENOF("refreshOnly") ))
2388 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2389 } else if ( !strncasecmp( val, "refreshAndPersist",
2390 STRLENOF("refreshAndPersist") ))
2392 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
2393 si->si_interval = 60;
2395 fprintf( stderr, "Error: parse_syncrepl_line: "
2396 "unknown sync type \"%s\"\n", val);
2399 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
2400 STRLENOF( INTERVALSTR "=" ) ) )
2402 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
2403 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
2404 si->si_interval = 0;
2412 hstr = strchr( dstr, ':' );
2413 if ( hstr == NULL ) {
2414 fprintf( stderr, "Error: parse_syncrepl_line: "
2415 "invalid interval \"%s\"\n", val );
2419 mstr = strchr( hstr, ':' );
2420 if ( mstr == NULL ) {
2421 fprintf( stderr, "Error: parse_syncrepl_line: "
2422 "invalid interval \"%s\"\n", val );
2426 sstr = strchr( mstr, ':' );
2427 if ( sstr == NULL ) {
2428 fprintf( stderr, "Error: parse_syncrepl_line: "
2429 "invalid interval \"%s\"\n", val );
2438 if (( hh > 24 ) || ( hh < 0 ) ||
2439 ( mm > 60 ) || ( mm < 0 ) ||
2440 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2441 fprintf( stderr, "Error: parse_syncrepl_line: "
2442 "invalid interval \"%s\"\n", val );
2445 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2447 if ( si->si_interval < 0 ) {
2448 fprintf( stderr, "Error: parse_syncrepl_line: "
2449 "invalid interval \"%ld\"\n",
2450 (long) si->si_interval);
2453 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2454 STRLENOF( RETRYSTR "=" ) ) )
2459 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2460 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2461 retry_list[0] = NULL;
2463 slap_str2clist( &retry_list, val, " ,\t" );
2465 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2469 "Error: incomplete syncrepl retry list\n" );
2470 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2471 ch_free( retry_list[k] );
2473 ch_free( retry_list );
2474 exit( EXIT_FAILURE );
2476 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2477 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2478 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2479 for ( j = 0; j < n; j++ ) {
2480 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2481 if ( *retry_list[j*2+1] == '+' ) {
2482 si->si_retrynum_init[j] = -1;
2483 si->si_retrynum[j] = -1;
2487 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2488 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2491 si->si_retrynum_init[j] = -2;
2492 si->si_retrynum[j] = -2;
2493 si->si_retryinterval[j] = 0;
2495 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2496 ch_free( retry_list[k] );
2498 ch_free( retry_list );
2499 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2500 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2502 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2503 si->si_manageDSAit = atoi( val );
2504 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2505 STRLENOF( SLIMITSTR "=") ) )
2507 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2508 si->si_slimit = atoi( val );
2509 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2510 STRLENOF( TLIMITSTR "=" ) ) )
2512 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2513 si->si_tlimit = atoi( val );
2514 } else if ( bindconf_parse( cargv[i], &si->si_bindconf )) {
2515 fprintf( stderr, "Error: parse_syncrepl_line: "
2516 "unknown keyword \"%s\"\n", cargv[ i ] );
2521 if ( gots != GOT_ALL ) {
2523 "Error: Malformed \"syncrepl\" line in slapd config file" );
2531 syncrepl_unparse( syncinfo_t *si, struct berval *bv )
2534 char buf[BUFSIZ*2], *ptr;
2537 bindconf_unparse( &si->si_bindconf, &bc );
2539 ptr += sprintf( ptr, IDSTR "=%03d " PROVIDERSTR "=%s",
2540 si->si_rid, si->si_provideruri.bv_val );
2541 if ( !BER_BVISNULL( &bc )) {
2542 ptr = lutil_strcopy( ptr, bc.bv_val );
2545 if ( !BER_BVISEMPTY( &si->si_filterstr )) {
2546 ptr = lutil_strcopy( ptr, " " FILTERSTR "=\"" );
2547 ptr = lutil_strcopy( ptr, si->si_filterstr.bv_val );
2550 if ( !BER_BVISNULL( &si->si_base )) {
2551 ptr = lutil_strcopy( ptr, " " SEARCHBASESTR "=\"" );
2552 ptr = lutil_strcopy( ptr, si->si_base.bv_val );
2555 for (i=0; !BER_BVISNULL(&scopes[i].key);i++) {
2556 if ( si->si_scope == scopes[i].val ) {
2557 ptr = lutil_strcopy( ptr, " " SCOPESTR "=" );
2558 ptr = lutil_strcopy( ptr, scopes[i].key.bv_val );
2562 if ( si->si_attrsonly ) {
2563 ptr = lutil_strcopy( ptr, " " ATTRSONLYSTR "=yes" );
2565 if ( si->si_anfile ) {
2566 ptr = lutil_strcopy( ptr, " " ATTRSSTR "=:include:" );
2567 ptr = lutil_strcopy( ptr, si->si_anfile );
2568 } else if ( si->si_allattrs || si->si_allopattrs ||
2569 ( si->si_anlist && !BER_BVISNULL(&si->si_anlist[0].an_name) )) {
2571 ptr = lutil_strcopy( ptr, " " ATTRSSTR "=\"" );
2573 ptr = anlist_unparse( si->si_anlist, ptr );
2574 if ( si->si_allattrs ) {
2575 if ( old != ptr ) *ptr++ = ',';
2578 if ( si->si_allopattrs ) {
2579 if ( old != ptr ) *ptr++ = ',';
2584 if ( si->si_exanlist && !BER_BVISNULL(&si->si_exanlist[0].an_name) ) {
2585 ptr = lutil_strcopy( ptr, " " EXATTRSSTR "=" );
2586 ptr = anlist_unparse( si->si_exanlist, ptr );
2588 ptr = lutil_strcopy( ptr, " " SCHEMASTR "=" );
2589 ptr = lutil_strcopy( ptr, si->si_schemachecking ? "on" : "off" );
2591 ptr = lutil_strcopy( ptr, " " TYPESTR "=" );
2592 ptr = lutil_strcopy( ptr, si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ?
2593 "refreshAndPersist" : "refreshOnly" );
2595 if ( si->si_type == LDAP_SYNC_REFRESH_ONLY ) {
2598 dd = si->si_interval;
2605 ptr = lutil_strcopy( ptr, " " INTERVALSTR "=" );
2606 ptr += sprintf( ptr, "%02d:%02d:%02d:%02d", dd, hh, mm, ss );
2607 } else if ( si->si_retryinterval ) {
2609 ptr = lutil_strcopy( ptr, " " RETRYSTR "=\"" );
2610 for (i=0; si->si_retryinterval[i]; i++) {
2611 if ( space ) *ptr++ = ' ';
2613 ptr += sprintf( ptr, "%d", si->si_retryinterval[i] );
2614 if ( si->si_retrynum_init[i] == -1 )
2617 ptr += sprintf( ptr, "%d", si->si_retrynum_init );
2622 #if 0 /* FIXME: unused in syncrepl.c, should remove it */
2623 ptr = lutil_strcopy( ptr, " " MANAGEDSAITSTR "=" );
2624 ptr += sprintf( ptr, "%d", si->si_manageDSAit );
2627 if ( si->si_slimit ) {
2628 ptr = lutil_strcopy( ptr, " " SLIMITSTR "=" );
2629 ptr += sprintf( ptr, "%d", si->si_slimit );
2632 if ( si->si_tlimit ) {
2633 ptr = lutil_strcopy( ptr, " " TLIMITSTR "=" );
2634 ptr += sprintf( ptr, "%d", si->si_tlimit );
2636 bc.bv_len = ptr - buf;
2638 ber_dupbv( bv, &bc );
2641 static CfEntryInfo *
2642 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
2652 if ( dn_match( &root->ce_entry->e_nname, dn ))
2655 c = dn->bv_val+dn->bv_len;
2656 for (;*c != ',';c--);
2660 for (--c;c>dn->bv_val && *c != ',';c--);
2664 cdn.bv_len = dn->bv_len - (cdn.bv_val - dn->bv_val);
2666 root = root->ce_kids;
2668 for (;root;root=root->ce_sibs) {
2669 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
2670 if ( cdn.bv_val == dn->bv_val ) {
2681 config_ldif_resp( Operation *op, SlapReply *rs )
2683 if ( rs->sr_type == REP_SEARCH ) {
2684 CfBackInfo *cfb = op->o_callback->sc_private;
2686 cfb->cb_got_ldif = 1;
2687 rs->sr_err = config_add_internal( cfb, rs->sr_entry, NULL, NULL );
2692 /* Configure and read the underlying back-ldif store */
2694 config_setup_ldif( BackendDB *be, const char *dir ) {
2695 CfBackInfo *cfb = be->be_private;
2700 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
2701 Connection conn = {0};
2702 char opbuf[OPERATION_BUFFER_SIZE];
2704 SlapReply rs = {REP_RESULT};
2705 Filter filter = { LDAP_FILTER_PRESENT };
2706 struct berval filterstr = BER_BVC("(objectclass=*)");
2708 cfb->cb_db.bd_info = backend_info( "ldif" );
2709 if ( !cfb->cb_db.bd_info )
2710 return 0; /* FIXME: eventually this will be a fatal error */
2712 if ( cfb->cb_db.bd_info->bi_db_init( &cfb->cb_db )) return 1;
2714 /* Mark that back-ldif type is in use */
2715 cfb->cb_db.bd_info->bi_nDB++;
2717 cfb->cb_db.be_suffix = be->be_suffix;
2718 cfb->cb_db.be_nsuffix = be->be_nsuffix;
2719 cfb->cb_db.be_rootdn = be->be_rootdn;
2720 cfb->cb_db.be_rootndn = be->be_rootndn;
2722 ber_str2bv( dir, 0, 1, &cfdir );
2727 argv[0] = "directory";
2728 argv[1] = (char *)dir;
2732 ct = config_find_keyword( c.be->be_cf_table, &c );
2736 if ( config_add_vals( ct, &c ))
2739 if ( backend_startup_one( &cfb->cb_db ))
2742 op = (Operation *)opbuf;
2743 connection_fake_init( &conn, op, cfb );
2745 filter.f_desc = slap_schema.si_ad_objectClass;
2747 op->o_tag = LDAP_REQ_SEARCH;
2749 op->ors_filter = &filter;
2750 op->ors_filterstr = filterstr;
2751 op->ors_scope = LDAP_SCOPE_SUBTREE;
2753 op->o_dn = be->be_rootdn;
2754 op->o_ndn = be->be_rootndn;
2756 op->o_req_dn = be->be_suffix[0];
2757 op->o_req_ndn = be->be_nsuffix[0];
2759 op->ors_tlimit = SLAP_NO_LIMIT;
2760 op->ors_slimit = SLAP_NO_LIMIT;
2762 op->ors_attrs = slap_anlist_all_attributes;
2763 op->ors_attrsonly = 0;
2765 op->o_callback = &cb;
2766 cb.sc_private = cfb;
2768 op->o_bd = &cfb->cb_db;
2769 op->o_bd->be_search( op, &rs );
2775 CfOcInfo_cmp( const void *c1, const void *c2 ) {
2776 const CfOcInfo *co1 = c1;
2777 const CfOcInfo *co2 = c2;
2779 return ber_bvcmp( co1->co_name, co2->co_name );
2783 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
2787 i = init_config_attrs( ct );
2790 /* set up the objectclasses */
2791 i = init_config_ocs( ocs );
2794 for (i=0; ocs[i].def; i++) {
2796 co = ch_malloc( sizeof(CfOcInfo) );
2797 co->co_oc = *ocs[i].oc;
2798 co->co_name = &co->co_oc->soc_cname;
2800 co->co_type = ocs[i].cft;
2801 avl_insert( &CfOcTree, co, CfOcInfo_cmp, avl_dup_error );
2808 read_config(const char *fname, const char *dir) {
2812 /* Setup the config backend */
2813 be = backend_db_init( "config" );
2817 cfb = be->be_private;
2819 /* Setup the underlying back-ldif backend */
2820 if ( config_setup_ldif( be, dir ))
2823 #ifdef SLAP_USE_CONFDIR
2824 /* If we read the config from back-ldif, nothing to do here */
2825 if ( cfb->cb_got_ldif )
2828 ber_str2bv( fname, 0, 1, &cf_prv.c_file );
2830 return read_config_file(fname, 0, NULL);
2834 config_back_bind( Operation *op, SlapReply *rs )
2836 if ( op->orb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op )) {
2837 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
2838 /* frontend sends result */
2839 return LDAP_SUCCESS;
2842 rs->sr_err = LDAP_INVALID_CREDENTIALS;
2843 send_ldap_result( op, rs );
2849 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
2853 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
2855 rs->sr_attrs = op->ors_attrs;
2856 rs->sr_entry = ce->ce_entry;
2857 rc = send_search_entry( op, rs );
2859 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
2860 if ( ce->ce_kids ) {
2861 rc = config_send( op, rs, ce->ce_kids, 1 );
2862 if ( rc ) return rc;
2865 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
2866 rc = config_send( op, rs, ce, 0 );
2874 static ConfigTable *
2875 config_find_table( CfOcInfo **colst, int nocs, AttributeDescription *ad )
2879 for (j=0; j<nocs; j++) {
2880 for (i=0; colst[j]->co_table[i].name; i++)
2881 if ( colst[j]->co_table[i].ad == ad )
2882 return &colst[j]->co_table[i];
2887 /* Sort the values in an X-ORDERED VALUES attribute.
2888 * If the values have no index, leave them in their given order.
2889 * If the values have indexes, sort them.
2890 * If some are indexed and some are not, return Error.
2892 * FIXME: This function probably belongs in the frontend somewhere,
2893 * like slap_mods_check.
2896 sort_vals( Attribute *a )
2899 int index = 0, noindex = 0;
2901 /* count attrs, look for index */
2902 for (i=0; a->a_vals[i].bv_val; i++) {
2903 if ( a->a_vals[i].bv_val[0] == '{' ) {
2906 ptr = strchr( a->a_vals[i].bv_val, '}' );
2907 if ( !ptr || !ptr[1] )
2908 return LDAP_INVALID_SYNTAX;
2910 return LDAP_INVALID_SYNTAX;
2914 return LDAP_INVALID_SYNTAX;
2919 int vals = i, *indexes, j, idx;
2920 struct berval tmp, ntmp;
2924 /* Strip index from normalized values */
2925 if ( !a->a_nvals || a->a_vals == a->a_nvals ) {
2926 a->a_nvals = ch_malloc( (vals+1)*sizeof(struct berval));
2927 BER_BVZERO(a->a_nvals+vals);
2928 for ( i=0; i<vals; i++ ) {
2929 ptr = strchr(a->a_vals[i].bv_val, '}') + 1;
2930 a->a_nvals[i].bv_len = a->a_vals[i].bv_len -
2931 (ptr - a->a_vals[i].bv_val);
2932 a->a_nvals[i].bv_val = ch_malloc( a->a_nvals[i].bv_len + 1);
2933 strcpy(a->a_nvals[i].bv_val, ptr );
2936 for ( i=0; i<vals; i++ ) {
2937 ptr = strchr(a->a_nvals[i].bv_val, '}') + 1;
2938 a->a_nvals[i].bv_len -= ptr - a->a_nvals[i].bv_val;
2939 strcpy(a->a_nvals[i].bv_val, ptr);
2944 indexes = ch_malloc( vals * sizeof(int) );
2945 for ( i=0; i<vals; i++)
2946 indexes[i] = atoi(a->a_vals[i].bv_val+1);
2948 /* Insertion sort */
2949 for ( i=1; i<vals; i++ ) {
2952 ntmp = a->a_nvals[i];
2954 while ((j > 0) && (indexes[j-1] > idx)) {
2955 indexes[j] = indexes[j-1];
2956 a->a_vals[j] = a->a_vals[j-1];
2957 a->a_nvals[j] = a->a_nvals[j-1];
2962 a->a_nvals[j] = ntmp;
2968 /* Sort the attributes of the entry according to the order defined
2969 * in the objectclass, with required attributes occurring before
2970 * allowed attributes. For any attributes with sequencing dependencies
2971 * (e.g., rootDN must be defined after suffix) the objectclass must
2972 * list the attributes in the desired sequence.
2975 sort_attrs( Entry *e, CfOcInfo **colst, int nocs )
2977 Attribute *a, *head = NULL, *tail = NULL, **prev;
2980 for (i=0; i<nocs; i++) {
2981 if ( colst[i]->co_oc->soc_required ) {
2982 AttributeType **at = colst[i]->co_oc->soc_required;
2983 for (j=0; at[j]; j++) {
2984 for (a=e->e_attrs, prev=&e->e_attrs; a;
2985 prev = &(*prev)->a_next, a=a->a_next) {
2986 if ( a->a_desc == at[j]->sat_ad ) {
3000 if ( colst[i]->co_oc->soc_allowed ) {
3001 AttributeType **at = colst[i]->co_oc->soc_allowed;
3002 for (j=0; at[j]; j++) {
3003 for (a=e->e_attrs, prev=&e->e_attrs; a;
3004 prev = &(*prev)->a_next, a=a->a_next) {
3005 if ( a->a_desc == at[j]->sat_ad ) {
3021 tail->a_next = e->e_attrs;
3027 check_vals( ConfigTable *ct, ConfigArgs *ca, void *ptr, int isAttr )
3029 Attribute *a = NULL;
3030 AttributeDescription *ad;
3033 int i, rc = 0, sort = 0;
3040 Modifications *ml = ptr;
3042 vals = ml->sml_values;
3045 if ( a && ad->ad_type->sat_flags & SLAP_AT_ORDERED ) {
3047 rc = sort_vals( a );
3051 for ( i=0; vals[i].bv_val; i++ ) {
3052 ca->line = vals[i].bv_val;
3054 char *idx = strchr( ca->line, '}' );
3055 if ( idx ) ca->line = idx+1;
3057 rc = config_parse_vals( ct, ca, i );
3065 check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
3066 SlapReply *rs, int *renum )
3069 int index = -1, gotindex = 0, nsibs;
3070 int renumber = 0, tailindex = 0;
3074 if ( renum ) *renum = 0;
3076 /* These entries don't get indexed/renumbered */
3077 if ( ce_type == Cft_Global ) return 0;
3078 if ( ce_type == Cft_Schema && parent->ce_type == Cft_Global ) return 0;
3080 if ( ce_type == Cft_Include || ce_type == Cft_Module )
3083 /* See if the rdn has an index already */
3084 dnRdn( &e->e_name, &rdn );
3085 ptr1 = strchr( e->e_name.bv_val, '{' );
3086 if ( ptr1 && ptr1 - e->e_name.bv_val < rdn.bv_len ) {
3087 ptr2 = strchr( ptr1, '}' );
3088 if (!ptr2 || ptr2 - e->e_name.bv_val > rdn.bv_len)
3089 return LDAP_NAMING_VIOLATION;
3090 if ( ptr2-ptr1 == 1)
3091 return LDAP_NAMING_VIOLATION;
3093 index = atoi(ptr1+1);
3095 return LDAP_NAMING_VIOLATION;
3098 /* count related kids */
3099 for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
3100 if ( ce->ce_type == ce_type ) nsibs++;
3103 if ( index != nsibs ) {
3105 if ( index < nsibs ) {
3106 if ( tailindex ) return LDAP_NAMING_VIOLATION;
3107 /* Siblings need to be renumbered */
3112 struct berval ival, newrdn, nnewrdn;
3113 struct berval rtype, rval;
3115 AttributeDescription *ad = NULL;
3119 rval.bv_val = strchr(rdn.bv_val, '=' ) + 1;
3120 rval.bv_len = rdn.bv_len - (rval.bv_val - rdn.bv_val);
3121 rtype.bv_val = rdn.bv_val;
3122 rtype.bv_len = rval.bv_val - rtype.bv_val - 1;
3125 slap_bv2ad( &rtype, &ad, &text );
3126 a = attr_find( e->e_attrs, ad );
3127 if (!a ) return LDAP_NAMING_VIOLATION;
3130 ival.bv_len = sprintf( ibuf, IFMT, nsibs );
3132 newrdn.bv_len = rdn.bv_len + ival.bv_len;
3133 newrdn.bv_val = ch_malloc( newrdn.bv_len+1 );
3136 ptr1 = lutil_strncopy( newrdn.bv_val, rdn.bv_val, rdn.bv_len );
3137 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
3144 xlen = rdn.bv_len - (ptr2 - rdn.bv_val);
3146 ptr1 = lutil_strncopy( newrdn.bv_val, rtype.bv_val,
3149 ptr1 = lutil_strcopy( ptr1, ival.bv_val );
3150 ptr1 = lutil_strncopy( ptr1, ptr2, xlen );
3154 /* Do the equivalent of ModRDN */
3155 /* Replace DN / NDN */
3156 newrdn.bv_len = ptr1 - newrdn.bv_val;
3157 rdnNormalize( 0, NULL, NULL, &newrdn, &nnewrdn, NULL );
3158 free( e->e_name.bv_val );
3159 build_new_dn( &e->e_name, &parent->ce_entry->e_name,
3161 free( e->e_nname.bv_val );
3162 build_new_dn( &e->e_nname, &parent->ce_entry->e_nname,
3166 free( a->a_vals[0].bv_val );
3167 ptr1 = strchr( newrdn.bv_val, '=' ) + 1;
3168 a->a_vals[0].bv_len = newrdn.bv_len - (ptr1 - newrdn.bv_val);
3169 a->a_vals[0].bv_val = ch_malloc( a->a_vals[0].bv_len + 1 );
3170 strcpy( a->a_vals[0].bv_val, ptr1 );
3172 if ( a->a_nvals != a->a_vals ) {
3173 free( a->a_nvals[0].bv_val );
3174 ptr1 = strchr( nnewrdn.bv_val, '=' ) + 1;
3175 a->a_nvals[0].bv_len = nnewrdn.bv_len - (ptr1 - nnewrdn.bv_val);
3176 a->a_nvals[0].bv_val = ch_malloc( a->a_nvals[0].bv_len + 1 );
3177 strcpy( a->a_nvals[0].bv_val, ptr1 );
3179 free( nnewrdn.bv_val );
3180 free( newrdn.bv_val );
3183 if ( renum ) *renum = renumber;
3188 count_ocs( Attribute *oc_at, int *nocs )
3191 CfOcInfo co, *coptr, **colst;
3193 /* count the objectclasses */
3194 for ( i=0; oc_at->a_nvals[i].bv_val; i++ );
3196 colst = (CfOcInfo **)ch_malloc( n * sizeof(CfOcInfo *));
3198 for ( i=0, j=0; i<n; i++) {
3199 co.co_name = &oc_at->a_nvals[i];
3200 coptr = avl_find( CfOcTree, &co, CfOcInfo_cmp );
3202 /* ignore non-config objectclasses. probably should be
3203 * an error, general data doesn't belong here.
3205 if ( !coptr ) continue;
3207 /* Ignore the root objectclass, it has no implementation.
3209 if ( coptr->co_type == Cft_Abstract ) continue;
3216 /* Only the root can be Cft_Global, everything else must
3217 /* Parse an LDAP entry into config directives */
3219 config_add_internal( CfBackInfo *cfb, Entry *e, SlapReply *rs, int *renum )
3221 CfEntryInfo *ce, *last;
3223 Attribute *a, *oc_at, *type_attr;
3224 AttributeDescription *type_ad = NULL;
3226 ConfigArgs ca = {0};
3228 ConfigTable *ct, *type_ct = NULL;
3231 /* Make sure parent exists and entry does not */
3232 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
3234 return LDAP_ALREADY_EXISTS;
3236 dnParent( &e->e_nname, &pdn );
3238 /* If last is NULL, the new entry is the root/suffix entry,
3239 * otherwise last should be the parent.
3241 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn )) {
3243 rs->sr_matched = last->ce_entry->e_name.bv_val;
3244 return LDAP_NO_SUCH_OBJECT;
3247 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
3248 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
3250 colst = count_ocs( oc_at, &nocs );
3252 /* Only the root can be Cft_Global, everything else must
3253 * have a parent. Only limited nesting arrangements are allowed.
3255 switch( colst[0]->co_type ) {
3258 rc = LDAP_CONSTRAINT_VIOLATION;
3266 if ( !last || ( last->ce_type != Cft_Global &&
3267 last->ce_type != colst[0]->co_type )) {
3268 rc = LDAP_CONSTRAINT_VIOLATION;
3273 if ( !last || ( last->ce_type != Cft_Global &&
3274 last->ce_type != Cft_Database &&
3275 last->ce_type != colst[0]->co_type )) {
3276 rc = LDAP_CONSTRAINT_VIOLATION;
3280 #ifdef SLAPD_MODULES
3282 if ( !last || last->ce_type != Cft_Global ) {
3283 rc = LDAP_CONSTRAINT_VIOLATION;
3290 sort_attrs( e, colst, nocs );
3292 /* Parse all the values and check for simple syntax errors before
3293 * performing any set actions.
3295 switch (colst[0]->co_type) {
3297 /* The cn=schema entry is all hardcoded, so never reparse it */
3298 if (last->ce_type == Cft_Global )
3302 ca.be = LDAP_STAILQ_FIRST(&backendDB);
3306 if ( last->ce_type == Cft_Backend )
3307 ca.bi = last->ce_bi;
3309 type_ad = cfAd_backend;
3312 if ( last->ce_type == Cft_Database ) {
3313 ca.be = last->ce_be;
3315 type_ad = cfAd_database;
3316 /* dummy, just to get past check_attr */
3322 ca.be = last->ce_be;
3323 type_ad = cfAd_overlay;
3328 nocs = 0; /* ignored */
3331 type_ad = cfAd_include;
3333 #ifdef SLAPD_MODULES
3337 ptr = strchr( e->e_name.bv_val, '{' );
3339 rc = LDAP_NAMING_VIOLATION;
3343 for (i=0, mp=&modpaths; mp && i<j; mp=mp->mp_next);
3344 /* There is no corresponding modpath for this load? */
3346 rc = LDAP_NAMING_VIOLATION;
3349 module_path( mp->mp_path.bv_val );
3356 /* If doing an LDAPadd, check for indexed names and any necessary
3357 * renaming/renumbering. Entries that don't need indexed names are
3358 * ignored. Entries that need an indexed name and arrive without one
3359 * are assigned to the end. Entries that arrive with an index may
3360 * cause the following entries to be renumbered/bumped down.
3362 * Note that "pseudo-indexed" entries (cn=Include{xx}, cn=Module{xx})
3363 * don't allow Adding an entry with an index that's already in use.
3364 * This is flagged as an error (LDAP_ALREADY_EXISTS) up above.
3366 * These entries can have auto-assigned indexes (appended to the end)
3367 * but only the other types support auto-renumbering of siblings.
3369 rc = check_name_index( last, colst[0]->co_type, e, rs, renum );
3373 init_config_argv( &ca );
3375 type_attr = attr_find( e->e_attrs, type_ad );
3377 rc = LDAP_OBJECT_CLASS_VIOLATION;
3380 type_ct = config_find_table( colst, nocs, type_ad );
3382 rc = LDAP_OBJECT_CLASS_VIOLATION;
3385 rc = check_vals( type_ct, &ca, type_attr, 1);
3386 if ( rc ) goto leave;
3388 for ( a=e->e_attrs; a; a=a->a_next ) {
3389 if ( a == type_attr || a == oc_at ) continue;
3390 ct = config_find_table( colst, nocs, a->a_desc );
3391 if ( !ct ) continue; /* user data? */
3392 rc = check_vals( ct, &ca, a, 1 );
3393 if ( rc ) goto leave;
3396 /* Basic syntax checks are OK. Do the actual settings. */
3398 ca.line = type_attr->a_vals[0].bv_val;
3399 if ( type_ad->ad_type->sat_flags & SLAP_AT_ORDERED ) {
3400 ptr = strchr( ca.line, '}' );
3401 if ( ptr ) ca.line = ptr+1;
3404 rc = config_parse_add( type_ct, &ca );
3410 for ( a=e->e_attrs; a; a=a->a_next ) {
3411 if ( a == type_attr || a == oc_at ) continue;
3412 ct = config_find_table( colst, nocs, a->a_desc );
3413 if ( !ct ) continue; /* user data? */
3414 for (i=0; a->a_vals[i].bv_val; i++) {
3415 ca.line = a->a_vals[i].bv_val;
3416 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
3417 ptr = strchr( ca.line, '}' );
3418 if ( ptr ) ca.line = ptr+1;
3421 rc = config_parse_add( ct, &ca );
3429 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
3430 ce->ce_parent = last;
3431 ce->ce_entry = entry_dup( e );
3432 ce->ce_entry->e_private = ce;
3433 ce->ce_type = colst[0]->co_type;
3438 } else if ( last->ce_kids ) {
3441 for (c2=last->ce_kids; c2 && c2->ce_sibs; c2 = c2->ce_sibs);
3450 if ( colst ) ch_free( colst );
3454 /* Parse an LDAP entry into config directives, then store in underlying
3458 config_back_add( Operation *op, SlapReply *rs )
3461 CfEntryInfo *ce, *last;
3464 if ( !be_isroot( op ) ) {
3465 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3469 cfb = (CfBackInfo *)op->o_bd->be_private;
3471 ldap_pvt_thread_pool_pause( &connection_pool );
3474 * 1) check for existence of entry
3475 * 2) check for sibling renumbering
3476 * 3) perform internal add
3477 * 4) store entry in underlying database
3478 * 5) perform any necessary renumbering
3480 rs->sr_err = config_add_internal( cfb, op->ora_e, rs, &renumber );
3481 if ( rs->sr_err == LDAP_SUCCESS ) {
3482 BackendDB *be = op->o_bd;
3483 slap_callback sc = { NULL, slap_null_cb, NULL, NULL };
3484 op->o_bd = &cfb->cb_db;
3485 sc.sc_next = op->o_callback;
3486 op->o_callback = ≻
3487 op->o_bd->be_add( op, rs );
3489 op->o_callback = sc.sc_next;
3494 ldap_pvt_thread_pool_resume( &connection_pool );
3497 send_ldap_result( op, rs );
3502 config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs,
3503 char *textbuf, int textsize )
3505 CfBackInfo *cfb = (CfBackInfo *)op->o_bd->be_private;
3506 int rc = LDAP_UNWILLING_TO_PERFORM;
3508 Entry *e = ce->ce_entry;
3509 Attribute *save_attrs = e->e_attrs, *oc_at;
3510 ConfigArgs ca = {0};
3516 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
3517 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
3519 colst = count_ocs( oc_at, &nocs );
3521 e->e_attrs = attrs_dup( e->e_attrs );
3523 init_config_argv( &ca );
3527 for (ml = op->orm_modlist; ml; ml=ml->sml_next) {
3528 switch (ml->sml_op) {
3529 case LDAP_MOD_DELETE:
3530 case LDAP_MOD_REPLACE: {
3531 BerVarray vals = NULL, nvals;
3532 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
3533 vals = ml->sml_values;
3534 nvals = ml->sml_nvalues;
3535 ml->sml_values = NULL;
3536 ml->sml_nvalues = NULL;
3538 rc = modify_delete_values(e, &ml->sml_mod,
3539 get_permissiveModify(op),
3540 &rs->sr_text, textbuf, textsize );
3541 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
3542 ml->sml_values = vals;
3543 ml->sml_nvalues = nvals;
3548 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
3551 case SLAP_MOD_SOFTADD: {
3552 int mop = ml->sml_op;
3553 ml->sml_op = LDAP_MOD_ADD;
3554 for ( i=0; !BER_BVISNULL( &ml->sml_values[i] ); i++ ) {
3555 ct = config_find_table( colst, nocs, ml->sml_desc );
3556 if ( !ct ) continue;
3557 rc = check_vals( ct, &ca, ml, 0 );
3560 rc = modify_add_values(e, &ml->sml_mod,
3561 get_permissiveModify(op),
3562 &rs->sr_text, textbuf, textsize );
3564 /* If value already exists, show success here
3565 * and ignore this operation down below.
3567 if ( mop == SLAP_MOD_SOFTADD ) {
3568 if ( rc == LDAP_TYPE_OR_VALUE_EXISTS )
3578 case LDAP_MOD_INCREMENT: /* FIXME */
3583 if(rc != LDAP_SUCCESS) break;
3586 if(rc == LDAP_SUCCESS) {
3587 /* check that the entry still obeys the schema */
3588 rc = entry_schema_check(op->o_bd, e, NULL,
3589 &rs->sr_text, textbuf, textsize );
3591 if ( rc == LDAP_SUCCESS ) {
3592 /* Basic syntax checks are OK. Do the actual settings. */
3593 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
3594 /* Ignore single-value deletes */
3595 if ( is_at_single_value( ml->sml_desc->ad_type ) &&
3596 ml->sml_op == LDAP_MOD_DELETE ) continue;
3598 ct = config_find_table( colst, nocs, ml->sml_desc );
3599 if ( !ct ) continue;
3601 switch (ml->sml_op) {
3602 case LDAP_MOD_DELETE:
3603 case LDAP_MOD_REPLACE: {
3604 BerVarray vals = NULL, nvals;
3605 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
3606 vals = ml->sml_values;
3607 nvals = ml->sml_nvalues;
3608 ml->sml_values = NULL;
3609 ml->sml_nvalues = NULL;
3612 rc = config_del_vals( ct, &ca, ml->sml_values );
3614 if ( ml->sml_op == LDAP_MOD_REPLACE ) {
3615 ml->sml_values = vals;
3616 ml->sml_nvalues = nvals;
3621 /* FALLTHRU: LDAP_MOD_REPLACE && vals */
3624 for (i=0; ml->sml_values[i].bv_val; i++) {
3625 ca.line = ml->sml_values[i].bv_val;
3626 if ( ml->sml_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
3627 ptr = strchr( ca.line, '}' );
3628 if ( ptr ) ca.line = ptr+1;
3631 rc = config_parse_add( ct, &ca );
3644 if ( rc == LDAP_SUCCESS ) {
3645 attrs_free( save_attrs );
3647 attrs_free( e->e_attrs );
3648 e->e_attrs = save_attrs;
3651 if ( colst ) ch_free( colst );
3657 config_back_modify( Operation *op, SlapReply *rs )
3660 CfEntryInfo *ce, *last;
3662 char textbuf[SLAP_TEXT_BUFLEN];
3665 AttributeDescription *rad = NULL;
3667 if ( !be_isroot( op ) ) {
3668 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3672 cfb = (CfBackInfo *)op->o_bd->be_private;
3674 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
3677 rs->sr_matched = last->ce_entry->e_name.bv_val;
3678 rs->sr_err = LDAP_NO_SUCH_OBJECT;
3682 /* Get type of RDN */
3683 rdn = ce->ce_entry->e_nname;
3684 ptr = strchr( rdn.bv_val, '=' );
3685 rdn.bv_len = ptr - rdn.bv_val;
3686 slap_bv2ad( &rdn, &rad, &rs->sr_text );
3688 /* Some basic validation... */
3689 for ( ml = op->orm_modlist; ml; ml = ml->sml_next ) {
3690 /* Braindead single-value check - the ADD must immediately follow
3691 * the DELETE. We don't check that there's only one ADD; for multiple
3692 * ADDs only the last one will be saved. The drivers don't distinguish
3695 if ( is_at_single_value( ml->sml_desc->ad_type )) {
3696 if (( ml->sml_op == LDAP_MOD_DELETE &&
3697 ( !ml->sml_next || ml->sml_next->sml_desc != ml->sml_desc ||
3698 ml->sml_next->sml_op != LDAP_MOD_ADD )) ||
3700 /* Also check for REPLACE with no values */
3701 ( ml->sml_op == LDAP_MOD_REPLACE && !ml->sml_values )) {
3702 rs->sr_err = LDAP_CONSTRAINT_VIOLATION;
3703 rs->sr_text = "Single-Value Delete must be followed by Add";
3707 /* Don't allow Modify of RDN; must use ModRdn for that. */
3708 if ( ml->sml_desc == rad ) {
3709 rs->sr_err = LDAP_OBJECT_CLASS_VIOLATION;
3710 rs->sr_text = "Use modrdn to change the entry name";
3715 ldap_pvt_thread_pool_pause( &connection_pool );
3718 * 1) perform the Modify on the cached Entry.
3719 * 2) verify that the Entry still satisfies the schema.
3720 * 3) perform the individual config operations.
3721 * 4) store Modified entry in underlying LDIF backend.
3723 rs->sr_err = config_modify_internal( ce, op, rs, textbuf, sizeof(textbuf) );
3725 ldap_pvt_thread_pool_resume( &connection_pool );
3727 send_ldap_result( op, rs );
3732 config_back_modrdn( Operation *op, SlapReply *rs )
3735 CfEntryInfo *ce, *last;
3737 if ( !be_isroot( op ) ) {
3738 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3742 cfb = (CfBackInfo *)op->o_bd->be_private;
3744 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
3747 rs->sr_matched = last->ce_entry->e_name.bv_val;
3748 rs->sr_err = LDAP_NO_SUCH_OBJECT;
3752 /* We don't allow moving objects to new parents.
3753 * Generally we only allow reordering a set of ordered entries.
3755 if ( op->orr_newSup ) {
3756 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
3759 ldap_pvt_thread_pool_pause( &connection_pool );
3761 ldap_pvt_thread_pool_resume( &connection_pool );
3763 send_ldap_result( op, rs );
3768 config_back_search( Operation *op, SlapReply *rs )
3771 CfEntryInfo *ce, *last;
3774 if ( !be_isroot( op ) ) {
3775 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3779 cfb = (CfBackInfo *)op->o_bd->be_private;
3781 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
3784 rs->sr_matched = last->ce_entry->e_name.bv_val;
3785 rs->sr_err = LDAP_NO_SUCH_OBJECT;
3788 switch ( op->ors_scope ) {
3789 case LDAP_SCOPE_BASE:
3790 case LDAP_SCOPE_SUBTREE:
3791 config_send( op, rs, ce, 0 );
3794 case LDAP_SCOPE_ONELEVEL:
3795 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
3796 config_send( op, rs, ce, 1 );
3801 rs->sr_err = LDAP_SUCCESS;
3803 send_ldap_result( op, rs );
3808 config_alloc_entry( CfEntryInfo *parent, struct berval *rdn )
3810 Entry *e = ch_calloc( 1, sizeof(Entry) );
3811 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
3816 ce->ce_parent = parent;
3818 pdn = parent->ce_entry->e_nname;
3823 build_new_dn( &e->e_name, &pdn, rdn, NULL );
3824 ber_dupbv( &e->e_nname, &e->e_name );
3833 config_build_entry( ConfigArgs *c, Entry *e, ObjectClass *oc,
3834 struct berval *rdn, ConfigTable *ct, int table )
3836 struct berval vals[2];
3837 struct berval ad_name;
3838 AttributeDescription *ad = NULL;
3842 char textbuf[SLAP_TEXT_BUFLEN];
3843 size_t textlen = sizeof(textbuf);
3847 BER_BVZERO( &vals[1] );
3849 vals[0] = oc->soc_cname;
3850 attr_merge(e, slap_schema.si_ad_objectClass, vals, NULL );
3851 ptr = strchr(rdn->bv_val, '=');
3852 ad_name.bv_val = rdn->bv_val;
3853 ad_name.bv_len = ptr - rdn->bv_val;
3854 rc = slap_bv2ad( &ad_name, &ad, &text );
3858 vals[0].bv_val = ptr+1;
3859 vals[0].bv_len = rdn->bv_len - (vals[0].bv_val - rdn->bv_val);
3860 attr_merge(e, ad, vals, NULL );
3862 for (at=oc->soc_required; at && *at; at++) {
3863 /* Skip the naming attr */
3864 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
3866 for (i=0;ct[i].name;i++) {
3867 if (ct[i].ad == (*at)->sat_ad) {
3868 rc = config_get_vals(&ct[i], c);
3869 if (rc == LDAP_SUCCESS) {
3870 attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
3871 ber_bvarray_free( c->rvalue_nvals );
3872 ber_bvarray_free( c->rvalue_vals );
3879 for (at=oc->soc_allowed; at && *at; at++) {
3880 /* Skip the naming attr */
3881 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
3883 for (i=0;ct[i].name;i++) {
3884 if (ct[i].ad == (*at)->sat_ad) {
3885 rc = config_get_vals(&ct[i], c);
3886 if (rc == LDAP_SUCCESS) {
3887 attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
3888 ber_bvarray_free( c->rvalue_nvals );
3889 ber_bvarray_free( c->rvalue_vals );
3897 if ( table == BI_TABLE )
3898 ct = c->bi->bi_cf_table;
3900 ct = c->be->be_cf_table;
3901 for (;ct && ct->name;ct++) {
3902 if (!ct->ad) continue;
3903 rc = config_get_vals(ct, c);
3904 if (rc == LDAP_SUCCESS) {
3905 attr_merge(e, ct->ad, c->rvalue_vals, c->rvalue_nvals);
3909 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
3910 rc = structural_class(oc_at->a_vals, vals, NULL, &text, textbuf, textlen);
3911 BER_BVZERO( &vals[1] );
3912 attr_merge(e, slap_schema.si_ad_structuralObjectClass, vals, NULL );
3918 config_build_schema_inc( ConfigArgs *c, CfEntryInfo *ceparent,
3919 Operation *op, SlapReply *rs )
3922 ConfigFile *cf = c->private;
3923 CfEntryInfo *ce, *ceprev;
3927 if ( ceparent->ce_kids ) {
3928 for ( ceprev = ceparent->ce_kids; ceprev->ce_sibs;
3929 ceprev = ceprev->ce_sibs );
3932 for (; cf; cf=cf->c_sibs, c->depth++) {
3933 c->value_dn.bv_val = c->log;
3934 bv.bv_val = strrchr(cf->c_file.bv_val, LDAP_DIRSEP[0]);
3939 bv.bv_len = cf->c_file.bv_len - (bv.bv_val - cf->c_file.bv_val);
3941 ptr = strchr( bv.bv_val, '.' );
3943 bv.bv_len = ptr - bv.bv_val;
3944 c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=" IFMT, c->depth);
3945 strncpy( c->value_dn.bv_val + c->value_dn.bv_len, bv.bv_val,
3947 c->value_dn.bv_len += bv.bv_len;
3948 c->value_dn.bv_val[c->value_dn.bv_len] ='\0';
3950 e = config_alloc_entry( ceparent, &c->value_dn );
3952 config_build_entry( c, e, cfOc_schema, &c->value_dn,
3953 c->bi->bi_cf_table, NO_TABLE );
3955 ce->ce_type = Cft_Schema;
3957 op->o_bd->be_add( op, rs );
3959 if ( !ceparent->ce_kids ) {
3960 ceparent->ce_kids = ce;
3962 ceprev->ce_sibs = ce;
3966 c->private = cf->c_kids;
3967 config_build_schema_inc( c, ceparent, op, rs );
3972 static CfEntryInfo *
3973 config_build_includes( ConfigArgs *c, CfEntryInfo *ceparent,
3974 Operation *op, SlapReply *rs )
3978 ConfigFile *cf = c->private;
3979 CfEntryInfo *ce, *ceprev;
3981 if ( ceparent->ce_kids ) {
3982 for ( ceprev = ceparent->ce_kids; ceprev->ce_sibs;
3983 ceprev = ceprev->ce_sibs );
3986 for (i=0; cf; cf=cf->c_sibs, i++) {
3987 c->value_dn.bv_val = c->log;
3988 c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=include" IFMT, i);
3989 e = config_alloc_entry( ceparent, &c->value_dn );
3991 config_build_entry( c, e, cfOc_include, &c->value_dn,
3992 c->bi->bi_cf_table, NO_TABLE );
3994 op->o_bd->be_add( op, rs );
3996 ce->ce_type = Cft_Include;
3998 if ( !ceparent->ce_kids ) {
3999 ceparent->ce_kids = ce;
4001 ceprev->ce_sibs = ce;
4005 c->private = cf->c_kids;
4006 config_build_includes( c, ce, op, rs );
4012 #ifdef SLAPD_MODULES
4014 static CfEntryInfo *
4015 config_build_modules( ConfigArgs *c, CfEntryInfo *ceparent,
4016 Operation *op, SlapReply *rs )
4020 CfEntryInfo *ce, *ceprev;
4023 if ( ceparent->ce_kids ) {
4024 for ( ceprev = ceparent->ce_kids; ceprev->ce_sibs;
4025 ceprev = ceprev->ce_sibs );
4028 for (i=0, mp=&modpaths; mp; mp=mp->mp_next, i++) {
4029 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
4031 c->value_dn.bv_val = c->log;
4032 c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=module" IFMT, i);
4033 e = config_alloc_entry( ceparent, &c->value_dn );
4035 ce->ce_type = Cft_Include;
4037 config_build_entry( c, e, cfOc_module, &c->value_dn,
4038 c->bi->bi_cf_table, NO_TABLE );
4040 op->o_bd->be_add( op, rs );
4042 if ( !ceparent->ce_kids ) {
4043 ceparent->ce_kids = ce;
4045 ceprev->ce_sibs = ce;
4054 config_back_db_open( BackendDB *be )
4056 CfBackInfo *cfb = be->be_private;
4059 CfEntryInfo *ce, *ceparent, *ceprev;
4065 Connection conn = {0};
4066 char opbuf[OPERATION_BUFFER_SIZE];
4068 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
4069 SlapReply rs = {REP_RESULT};
4071 /* If we read the config from back-ldif, nothing to do here */
4072 if ( cfb->cb_got_ldif )
4075 op = (Operation *)opbuf;
4076 connection_fake_init( &conn, op, cfb );
4078 op->o_dn = be->be_rootdn;
4079 op->o_ndn = be->be_rootndn;
4081 op->o_tag = LDAP_REQ_ADD;
4082 op->o_callback = &cb;
4083 op->o_bd = &cfb->cb_db;
4085 /* create root of tree */
4087 e = config_alloc_entry( NULL, &rdn );
4089 ce->ce_type = Cft_Global;
4093 c.private = cfb->cb_config;
4094 ct = c.bi->bi_cf_table;
4095 config_build_entry( &c, e, cfOc_global, &rdn, ct, NO_TABLE );
4097 op->o_bd->be_add( op, &rs );
4103 /* Create schema nodes... cn=schema will contain the hardcoded core
4104 * schema, read-only. Child objects will contain runtime loaded schema
4108 e = config_alloc_entry( ceparent, &rdn );
4110 ce->ce_type = Cft_Schema;
4112 config_build_entry( &c, e, cfOc_schema, &rdn, ct, NO_TABLE );
4114 op->o_bd->be_add( op, &rs );
4115 if ( !ceparent->ce_kids ) {
4116 ceparent->ce_kids = ce;
4118 ceprev->ce_sibs = ce;
4122 /* Create includeFile nodes and schema nodes for included schema... */
4123 if ( cfb->cb_config->c_kids ) {
4125 c.private = cfb->cb_config->c_kids;
4126 config_build_schema_inc( &c, ce, op, &rs );
4127 c.private = cfb->cb_config->c_kids;
4128 ceprev = config_build_includes( &c, ceparent, op, &rs );
4131 #ifdef SLAPD_MODULES
4132 /* Create Module nodes... */
4133 if ( modpaths.mp_loads ) {
4134 ceprev = config_build_modules( &c, ceparent, op, &rs );
4138 /* Create backend nodes. Skip if they don't provide a cf_table.
4139 * There usually aren't any of these.
4143 LDAP_STAILQ_FOREACH( bi, &backendInfo, bi_next) {
4144 if (!bi->bi_cf_table) continue;
4145 if (!bi->bi_private) continue;
4148 rdn.bv_len = sprintf(rdn.bv_val, "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
4149 e = config_alloc_entry( ceparent, &rdn );
4151 ce->ce_type = Cft_Backend;
4154 config_build_entry( &c, e, cfOc_backend, &rdn, ct, BI_TABLE );
4156 op->o_bd->be_add( op, &rs );
4157 if ( !ceparent->ce_kids ) {
4158 ceparent->ce_kids = ce;
4160 ceprev->ce_sibs = ce;
4165 /* Create database nodes... */
4167 LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
4168 slap_overinfo *oi = NULL;
4175 if ( overlay_is_over( bptr )) {
4176 oi = bptr->bd_info->bi_private;
4182 rdn.bv_len = sprintf(rdn.bv_val, "%s=" IFMT "%s", cfAd_database->ad_cname.bv_val,
4184 e = config_alloc_entry( ceparent, &rdn );
4188 ce->ce_type = Cft_Database;
4191 config_build_entry( &c, e, cfOc_database, &rdn, ct, BE_TABLE );
4193 op->o_bd->be_add( op, &rs );
4194 if ( !ceparent->ce_kids ) {
4195 ceparent->ce_kids = ce;
4197 ceprev->ce_sibs = ce;
4200 /* Iterate through overlays */
4204 CfEntryInfo *opar = ce, *oprev = NULL;
4207 for (j=0,on=oi->oi_list; on; j++,on=on->on_next) {
4209 rdn.bv_len = sprintf(rdn.bv_val, "%s=" IFMT "%s",
4210 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
4211 oe = config_alloc_entry( opar, &rdn );
4215 ce->ce_type = Cft_Overlay;
4218 config_build_entry( &c, oe, cfOc_overlay, &rdn, ct, BI_TABLE );
4220 op->o_bd->be_add( op, &rs );
4221 if ( !opar->ce_kids ) {
4224 oprev->ce_sibs = ce;
4235 config_back_db_destroy( Backend *be )
4237 free( be->be_private );
4242 config_back_db_init( Backend *be )
4247 cfb = ch_calloc( 1, sizeof(CfBackInfo));
4248 cfb->cb_config = &cf_prv;
4249 be->be_private = cfb;
4251 ber_dupbv( &be->be_rootdn, &config_rdn );
4252 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
4253 ber_dupbv( &dn, &be->be_rootdn );
4254 ber_bvarray_add( &be->be_suffix, &dn );
4255 ber_dupbv( &dn, &be->be_rootdn );
4256 ber_bvarray_add( &be->be_nsuffix, &dn );
4258 /* Hide from namingContexts */
4259 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
4265 config_back_destroy( BackendInfo *bi )
4267 ldif_must_b64_encode_release();
4273 AttributeDescription **desc;
4275 { "backend", &cfAd_backend },
4276 { "database", &cfAd_database },
4277 { "include", &cfAd_include },
4278 { "overlay", &cfAd_overlay },
4283 * add / delete: all types that may be added or deleted must use an
4284 * X-ORDERED attributeType for their RDN. Adding and deleting entries
4285 * should automatically renumber the index of any siblings as needed,
4286 * so that no gaps in the numbering sequence exist after the add/delete
4288 * What can be added:
4290 * backend objects for backend-specific config directives
4294 * delete: probably no support this time around.
4296 * modrdn: generally not done. Will be invoked automatically by add/
4297 * delete to update numbering sequence. Perform as an explicit operation
4298 * so that the renumbering effect may be replicated. Subtree rename must
4299 * be supported, since renumbering a database will affect all its child
4302 * modify: must be fully supported.
4306 config_back_initialize( BackendInfo *bi )
4308 ConfigTable *ct = config_back_cf_table;
4311 AttributeDescription *ad = NULL;
4313 static char *controls[] = {
4314 LDAP_CONTROL_MANAGEDSAIT,
4318 bi->bi_controls = controls;
4323 bi->bi_destroy = config_back_destroy;
4325 bi->bi_db_init = config_back_db_init;
4326 bi->bi_db_config = 0;
4327 bi->bi_db_open = config_back_db_open;
4328 bi->bi_db_close = 0;
4329 bi->bi_db_destroy = config_back_db_destroy;
4331 bi->bi_op_bind = config_back_bind;
4332 bi->bi_op_unbind = 0;
4333 bi->bi_op_search = config_back_search;
4334 bi->bi_op_compare = 0;
4335 bi->bi_op_modify = config_back_modify;
4336 bi->bi_op_modrdn = config_back_modrdn;
4337 bi->bi_op_add = config_back_add;
4338 bi->bi_op_delete = 0;
4339 bi->bi_op_abandon = 0;
4341 bi->bi_extended = 0;
4343 bi->bi_chk_referrals = 0;
4345 #ifdef SLAP_OVERLAY_ACCESS
4346 bi->bi_access_allowed = slap_access_always_allowed;
4347 #endif /* SLAP_OVERLAY_ACCESS */
4349 bi->bi_connection_init = 0;
4350 bi->bi_connection_destroy = 0;
4353 for (i=0; OidMacros[i].name; i++ ) {
4354 argv[1] = OidMacros[i].name;
4355 argv[2] = OidMacros[i].oid;
4356 parse_oidm( "slapd", i, 3, argv, 0, NULL );
4359 bi->bi_cf_table = ct;
4361 i = config_register_schema( ct, cf_ocs );
4364 /* setup olcRootPW to be base64-encoded when written in LDIF form;
4365 * basically, we don't care if it fails */
4366 i = slap_str2ad( "olcRootPW", &ad, &text );
4368 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
4369 "warning, unable to get \"olcRootPW\" "
4370 "attribute description: %d: %s\n",
4373 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
4374 ad->ad_type->sat_oid );
4377 /* set up the notable AttributeDescriptions */
4379 for (;ct->name;ct++) {
4380 if (strcmp(ct->name, ads[i].name)) continue;
4381 *ads[i].desc = ct->ad;
4383 if (!ads[i].name) break;