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");
41 typedef struct modpath_s {
42 struct modpath_s *mp_next;
43 struct berval mp_path;
48 typedef struct ConfigFile {
49 struct ConfigFile *c_sibs;
50 struct ConfigFile *c_kids;
59 typedef struct CfOcInfo {
60 struct berval *co_name;
61 ConfigTable *co_table;
65 typedef struct CfEntryInfo {
66 struct CfEntryInfo *ce_sibs;
67 struct CfEntryInfo *ce_kids;
75 ConfigFile *cb_config;
77 BackendDB *cb_be; /* config backend */
78 BackendDB cb_db; /* underlying database */
82 /* These do nothing in slapd, they're kept only to make them
85 static char *replica_pidFile, *replica_argsFile;
86 static int replicationInterval;
88 static char *passwd_salt;
89 static char *logfileName;
90 static BerVarray authz_rewrites;
92 static struct berval cfdir;
95 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
98 static ObjectClass *cfOc_schema, *cfOc_global, *cfOc_backend, *cfOc_database,
99 *cfOc_include, *cfOc_overlay;
101 static ConfigFile cf_prv, *cfn = &cf_prv;
103 static Avlnode *CfOcTree;
105 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
106 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
107 static void syncrepl_unparse LDAP_P (( syncinfo_t *, struct berval *));
108 static int config_add_internal( CfBackInfo *cfb, Entry *e, SlapReply *rs );
110 static ConfigDriver config_fname;
111 static ConfigDriver config_cfdir;
112 static ConfigDriver config_generic;
113 static ConfigDriver config_search_base;
114 static ConfigDriver config_passwd_hash;
115 static ConfigDriver config_schema_dn;
116 static ConfigDriver config_sizelimit;
117 static ConfigDriver config_timelimit;
118 static ConfigDriver config_limits;
119 static ConfigDriver config_overlay;
120 static ConfigDriver config_suffix;
121 static ConfigDriver config_deref_depth;
122 static ConfigDriver config_rootdn;
123 static ConfigDriver config_rootpw;
124 static ConfigDriver config_restrict;
125 static ConfigDriver config_allows;
126 static ConfigDriver config_disallows;
127 static ConfigDriver config_requires;
128 static ConfigDriver config_security;
129 static ConfigDriver config_referral;
130 static ConfigDriver config_loglevel;
131 static ConfigDriver config_syncrepl;
132 static ConfigDriver config_replica;
133 static ConfigDriver config_updatedn;
134 static ConfigDriver config_updateref;
135 static ConfigDriver config_include;
137 static ConfigDriver config_tls_option;
138 static ConfigDriver config_tls_config;
187 static OidRec OidMacros[] = {
188 /* OpenLDAProot:666.11.1 */
189 { "OLcfg", "1.3.6.1.4.1.4203.666.11.1" },
190 { "OLcfgAt", "OLcfg:3" },
191 { "OLcfgOc", "OLcfg:4" },
192 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
193 { "OMsInteger", "OMsyn:2" },
194 { "OMsBoolean", "OMsyn:7" },
195 { "OMsDN", "OMsyn:12" },
196 { "OMsDirectoryString", "OMsyn:15" },
197 { "OMsOctetString", "OMsyn:40" },
201 /* alphabetical ordering */
203 ConfigTable config_back_cf_table[] = {
204 /* This attr is read-only */
205 { "", "", 0, 0, 0, ARG_MAGIC,
206 &config_fname, "( OLcfgAt:78 NAME 'olcConfigFile' "
207 "DESC 'File for slapd configuration directives' "
208 "EQUALITY caseIgnoreMatch "
209 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
210 { "", "", 0, 0, 0, ARG_MAGIC,
211 &config_cfdir, "( OLcfgAt:79 NAME 'olcConfigDir' "
212 "DESC 'Directory for slapd configuration backend' "
213 "EQUALITY caseIgnoreMatch "
214 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
215 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
216 &config_generic, "( OLcfgAt:1 NAME 'olcAccess' "
217 "DESC 'Access Control List' "
218 "EQUALITY caseIgnoreMatch "
219 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
220 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
221 &config_allows, "( OLcfgAt:2 NAME 'olcAllows' "
222 "DESC 'Allowed set of deprecated features' "
223 "EQUALITY caseIgnoreMatch "
224 "SYNTAX OMsDirectoryString )", NULL, NULL },
225 { "argsfile", "file", 2, 2, 0, ARG_STRING,
226 &slapd_args_file, "( OLcfgAt:3 NAME 'olcArgsFile' "
227 "DESC 'File for slapd command line options' "
228 "EQUALITY caseIgnoreMatch "
229 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
230 /* Use standard 'attributeTypes' attr */
231 { "attribute", "attribute", 2, 0, 9, ARG_PAREN|ARG_MAGIC|CFG_ATTR,
232 &config_generic, NULL, NULL, NULL },
233 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
234 &config_generic, "( OLcfgAt:5 NAME 'olcAttributeOptions' "
235 "EQUALITY caseIgnoreMatch "
236 "SYNTAX OMsDirectoryString )", NULL, NULL },
237 { "authid-rewrite", NULL, 2, 0, 0,
238 #ifdef SLAP_AUTH_REWRITE
239 ARG_MAGIC|CFG_REWRITE, &config_generic,
243 "( OLcfgAt:6 NAME 'olcAuthIDRewrite' "
244 "EQUALITY caseIgnoreMatch "
245 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
246 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
247 &config_generic, "( OLcfgAt:7 NAME 'olcAuthzPolicy' "
248 "EQUALITY caseIgnoreMatch "
249 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
250 { "authz-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
251 &config_generic, "( OLcfgAt:8 NAME 'olcAuthzRegexp' "
252 "EQUALITY caseIgnoreMatch "
253 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
254 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
255 &config_generic, "( OLcfgAt:9 NAME 'olcBackend' "
256 "DESC 'A type of backend' "
257 "EQUALITY caseIgnoreMatch "
258 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
259 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
260 &config_generic, "( OLcfgAt:10 NAME 'olcConcurrency' "
261 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
262 { "conn_max_pending", "max", 2, 2, 0, ARG_INT,
263 &slap_conn_max_pending, "( OLcfgAt:11 NAME 'olcConnMaxPending' "
264 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
265 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
266 &slap_conn_max_pending_auth, "( OLcfgAt:12 NAME 'olcConnMaxPendingAuth' "
267 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
268 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
269 &config_generic, "( OLcfgAt:13 NAME 'olcDatabase' "
270 "DESC 'The backend type for a database instance' "
271 "SUP olcBackend X-ORDERED 'VALUES' )", NULL, NULL },
272 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_MAGIC,
273 &config_search_base, "( OLcfgAt:14 NAME 'olcDefaultSearchBase' "
274 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
275 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
276 &config_disallows, "( OLcfgAt:15 NAME 'olcDisallows' "
277 "EQUALITY caseIgnoreMatch "
278 "SYNTAX OMsDirectoryString )", NULL, NULL },
279 /* use standard schema */
280 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT,
281 &config_generic, NULL, NULL, NULL },
282 { "gentlehup", "on|off", 2, 2, 0,
284 ARG_ON_OFF, &global_gentlehup,
288 "( OLcfgAt:17 NAME 'olcGentleHUP' "
289 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
290 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
291 &global_idletimeout, "( OLcfgAt:18 NAME 'olcIdleTimeout' "
292 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
293 /* XXX -- special case? */
294 { "include", "file", 2, 2, 0, ARG_MAGIC,
295 &config_include, "( OLcfgAt:19 NAME 'olcInclude' "
296 "SUP labeledURI )", NULL, NULL },
297 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
298 &config_generic, "( OLcfgAt:20 NAME 'olcIndexSubstrIfMinLen' "
299 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
300 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
301 &config_generic, "( OLcfgAt:21 NAME 'olcIndexSubstrIfMaxLen' "
302 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
303 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
304 &index_substr_any_len, "( OLcfgAt:22 NAME 'olcIndexSubstrAnyLen' "
305 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
306 { "index_substr_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
307 &index_substr_any_step, "( OLcfgAt:23 NAME 'olcIndexSubstrAnyStep' "
308 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
309 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
310 &config_generic, "( OLcfgAt:24 NAME 'olcLastMod' "
311 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
312 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
313 &config_generic, "( OLcfgAt:25 NAME 'olcLimits' "
314 "SYNTAX OMsDirectoryString )", NULL, NULL },
315 { "localSSF", "ssf", 2, 2, 0, ARG_INT,
316 &local_ssf, "( OLcfgAt:26 NAME 'olcLocalSSF' "
317 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
318 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
319 &config_generic, "( OLcfgAt:27 NAME 'olcLogFile' "
320 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
321 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
322 &config_loglevel, "( OLcfgAt:28 NAME 'olcLogLevel' "
323 "SYNTAX OMsDirectoryString )", NULL, NULL },
324 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
325 &config_generic, "( OLcfgAt:29 NAME 'olcMaxDerefDepth' "
326 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
327 { "moduleload", "file", 2, 0, 0,
329 ARG_MAGIC|CFG_MODLOAD, &config_generic,
333 "( OLcfgAt:30 NAME 'olcModuleLoad' "
334 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
335 { "modulepath", "path", 2, 2, 0,
337 ARG_MAGIC|CFG_MODPATH, &config_generic,
341 "( OLcfgAt:31 NAME 'olcModulePath' "
342 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
343 /* use standard schema */
344 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
345 &config_generic, NULL, NULL, NULL },
346 { "objectidentifier", NULL, 0, 0, 0, ARG_MAGIC|CFG_OID,
347 &config_generic, "( OLcfgAt:33 NAME 'olcObjectIdentifier' "
348 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
349 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
350 &config_overlay, "( OLcfgAt:34 NAME 'olcOverlay' "
351 "SUP olcDatabase X-ORDERED 'VALUES' )", NULL, NULL },
352 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
353 &config_generic, "( OLcfgAt:35 NAME 'olcPasswordCryptSaltFormat' "
354 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
355 { "password-hash", "hash", 2, 2, 0, ARG_MAGIC,
356 &config_passwd_hash, "( OLcfgAt:36 NAME 'olcPasswordHash' "
357 "SYNTAX OMsDirectoryString )", NULL, NULL },
358 { "pidfile", "file", 2, 2, 0, ARG_STRING,
359 &slapd_pid_file, "( OLcfgAt:37 NAME 'olcPidFile' "
360 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
361 { "plugin", NULL, 0, 0, 0,
363 ARG_MAGIC|CFG_PLUGIN, &config_generic,
367 "( OLcfgAt:38 NAME 'olcPlugin' "
368 "SYNTAX OMsDirectoryString )", NULL, NULL },
369 { "pluginlog", "filename", 2, 2, 0,
371 ARG_STRING, &slapi_log_file,
375 "( OLcfgAt:39 NAME 'olcPluginLogFile' "
376 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
377 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
378 &config_generic, "( OLcfgAt:40 NAME 'olcReadOnly' "
379 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
380 { "referral", "url", 2, 2, 0, ARG_MAGIC,
381 &config_referral, "( OLcfgAt:41 NAME 'olcReferral' "
382 "SUP labeledURI SINGLE-VALUE )", NULL, NULL },
383 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
384 &config_replica, "( OLcfgAt:42 NAME 'olcReplica' "
385 "SUP labeledURI )", NULL, NULL },
386 { "replica-argsfile", NULL, 0, 0, 0, ARG_STRING,
387 &replica_argsFile, "( OLcfgAt:43 NAME 'olcReplicaArgsFile' "
388 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
389 { "replica-pidfile", NULL, 0, 0, 0, ARG_STRING,
390 &replica_pidFile, "( OLcfgAt:44 NAME 'olcReplicaPidFile' "
391 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
392 { "replicationInterval", NULL, 0, 0, 0, ARG_INT,
393 &replicationInterval, "( OLcfgAt:45 NAME 'olcReplicationInterval' "
394 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
395 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLOG,
396 &config_generic, "( OLcfgAt:46 NAME 'olcReplogFile' "
397 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
398 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
399 &config_requires, "( OLcfgAt:47 NAME 'olcRequires' "
400 "SYNTAX OMsDirectoryString )", NULL, NULL },
401 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
402 &config_restrict, "( OLcfgAt:48 NAME 'olcRestrict' "
403 "SYNTAX OMsDirectoryString )", NULL, NULL },
404 { "reverse-lookup", "on|off", 2, 2, 0,
405 #ifdef SLAPD_RLOOKUPS
406 ARG_ON_OFF, &use_reverse_lookup,
410 "( OLcfgAt:49 NAME 'olcReverseLookup' "
411 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
412 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
413 &config_rootdn, "( OLcfgAt:50 NAME 'olcRootDN' "
414 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
415 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
416 &config_generic, "( OLcfgAt:51 NAME 'olcRootDSE' "
417 "SYNTAX OMsDirectoryString )", NULL, NULL },
418 { "rootpw", "password", 2, 2, 0, ARG_STRING|ARG_DB|ARG_MAGIC,
419 &config_rootpw, "( OLcfgAt:52 NAME 'olcRootPW' "
420 "SYNTAX OMsOctetString SINGLE-VALUE )", NULL, NULL },
421 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
422 &config_generic, NULL, NULL, NULL },
423 { "sasl-host", "host", 2, 2, 0,
424 #ifdef HAVE_CYRUS_SASL
425 ARG_STRING|ARG_UNIQUE, &global_host,
429 "( OLcfgAt:53 NAME 'olcSaslHost' "
430 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
431 { "sasl-realm", "realm", 2, 2, 0,
432 #ifdef HAVE_CYRUS_SASL
433 ARG_STRING|ARG_UNIQUE, &global_realm,
437 "( OLcfgAt:54 NAME 'olcSaslRealm' "
438 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
439 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
440 &config_generic, NULL, NULL, NULL },
441 { "sasl-secprops", "properties", 2, 2, 0,
442 #ifdef HAVE_CYRUS_SASL
443 ARG_MAGIC|CFG_SASLSECP, &config_generic,
447 "( OLcfgAt:56 NAME 'olcSaslSecProps' "
448 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
449 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
450 &config_generic, NULL, NULL, NULL },
451 { "schemacheck", "on|off", 2, 2, 0, ARG_ON_OFF|ARG_MAGIC|CFG_CHECK,
452 &config_generic, "( OLcfgAt:57 NAME 'olcSchemaCheck' "
453 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
454 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_MAGIC,
455 &config_schema_dn, "( OLcfgAt:58 NAME 'olcSchemaDN' "
456 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
457 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
458 &config_security, "( OLcfgAt:59 NAME 'olcSecurity' "
459 "SYNTAX OMsDirectoryString )", NULL, NULL },
460 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_SIZE,
461 &config_sizelimit, "( OLcfgAt:60 NAME 'olcSizeLimit' "
462 "SYNTAX OMsInteger )", NULL, NULL },
463 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
464 &sockbuf_max_incoming, "( OLcfgAt:61 NAME 'olcSockbufMaxIncoming' "
465 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
466 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
467 &sockbuf_max_incoming_auth, "( OLcfgAt:62 NAME 'olcSockbufMaxIncomingAuth' "
468 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
469 { "srvtab", "file", 2, 2, 0,
470 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
471 ARG_STRING, &ldap_srvtab,
475 "( OLcfgAt:63 NAME 'olcSrvtab' "
476 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
477 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
478 &config_suffix, "( OLcfgAt:64 NAME 'olcSuffix' "
479 "SYNTAX OMsDN )", NULL, NULL },
480 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
481 &config_syncrepl, "( OLcfgAt:65 NAME 'olcSyncrepl' "
482 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
483 { "threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_THREADS,
484 &config_generic, "( OLcfgAt:66 NAME 'olcThreads' "
485 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
486 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_TIME,
487 &config_timelimit, "( OLcfgAt:67 NAME 'olcTimeLimit' "
488 "SYNTAX OMsInteger )", NULL, NULL },
489 { "TLSCACertificateFile", NULL, 0, 0, 0,
491 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
495 "( OLcfgAt:68 NAME 'olcTLSCACertificateFile' "
496 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
497 { "TLSCACertificatePath", NULL, 0, 0, 0,
499 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
503 "( OLcfgAt:69 NAME 'olcTLSCACertificatePath' "
504 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
505 { "TLSCertificateFile", NULL, 0, 0, 0,
507 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
511 "( OLcfgAt:70 NAME 'olcTLSCertificateFile' "
512 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
513 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
515 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
519 "( OLcfgAt:71 NAME 'olcTLSCertificateKeyFile' "
520 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
521 { "TLSCipherSuite", NULL, 0, 0, 0,
523 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
527 "( OLcfgAt:72 NAME 'olcTLSCipherSuite' "
528 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
529 { "TLSCRLCheck", NULL, 0, 0, 0,
531 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
535 "( OLcfgAt:73 NAME 'olcTLSCRLCheck' "
536 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
537 { "TLSRandFile", NULL, 0, 0, 0,
539 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
543 "( OLcfgAt:74 NAME 'olcTLSRandFile' "
544 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
545 { "TLSVerifyClient", NULL, 0, 0, 0,
547 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
551 "( OLcfgAt:75 NAME 'olcTLSVerifyClient' "
552 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
553 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
554 NULL, NULL, NULL, NULL },
555 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_MAGIC,
556 &config_updatedn, "( OLcfgAt:76 NAME 'olcUpdateDN' "
557 "SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
558 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
559 &config_updateref, "( OLcfgAt:77 NAME 'olcUpdateRef' "
560 "SUP labeledURI )", NULL, NULL },
561 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
562 NULL, NULL, NULL, NULL }
565 static ConfigOCs cf_ocs[] = {
568 "DESC 'OpenLDAP configuration object' "
570 "MAY ( cn $ olcConfigFile ) )", Cft_Abstract, NULL },
573 "DESC 'OpenLDAP Global configuration options' "
574 "SUP olcConfig STRUCTURAL "
575 "MAY ( olcConfigDir $ olcAllows $ olcArgsFile $ olcAttributeOptions $ "
576 "olcAuthIDRewrite $ olcAuthzPolicy $ olcAuthzRegexp $ "
577 "olcConcurrency $ olcConnMaxPending $ olcConnMaxPendingAuth $ "
578 "olcDefaultSearchBase $ olcDisallows $ olcGentleHUP $ "
579 "olcIdleTimeout $ olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
580 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcLocalSSF $ "
581 "olcLogLevel $ olcModuleLoad $ olcModulePath $ olcObjectIdentifier $ "
582 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
583 "olcPlugin $ olcPluginLogFile $ olcReadOnly $ olcReferral $ "
584 "olcReplicaPidFile $ olcReplicaArgsFile $ olcReplicationInterval $ "
585 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
586 "olcRootDSE $ olcRootPW $ olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
587 "olcSchemaCheck $ olcSchemaDN $ olcSecurity $ olcSizeLimit $ "
588 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ olcSrvtab $ "
589 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
590 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
591 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
592 "olcTLSRandFile $ olcTLSVerifyClient ) )", Cft_Global, &cfOc_global },
594 "NAME 'olcSchemaConfig' "
595 "DESC 'OpenLDAP schema object' "
596 "SUP olcConfig STRUCTURAL "
597 "MAY ( olcObjectIdentifier $ attributeTypes $ objectClasses $ "
598 "ditContentRules ) )", Cft_Schema, &cfOc_schema },
600 "NAME 'olcBackendConfig' "
601 "DESC 'OpenLDAP Backend-specific options' "
602 "SUP olcConfig STRUCTURAL "
603 "MAY ( olcBackend ) )", Cft_Backend, &cfOc_backend },
605 "NAME 'olcDatabaseConfig' "
606 "DESC 'OpenLDAP Database-specific options' "
607 "SUP olcConfig STRUCTURAL "
608 "MAY ( olcDatabase $ olcAccess $ olcLastMod $ olcLimits $ "
609 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
610 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
611 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSuffix $ olcSyncrepl $ "
612 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )",
613 Cft_Database, &cfOc_database },
615 "NAME 'olcOverlayConfig' "
616 "DESC 'OpenLDAP Overlay-specific options' "
617 "SUP olcConfig STRUCTURAL "
618 "MAY ( olcOverlay ) )", Cft_Overlay, &cfOc_overlay },
620 "NAME 'olcIncludeFile' "
621 "DESC 'OpenLDAP configuration include file' "
622 "SUP olcConfig STRUCTURAL "
623 "MAY ( olcInclude $ olcModuleLoad $ olcModulePath $ olcRootDSE ) )",
624 Cft_Include, &cfOc_include },
629 config_generic(ConfigArgs *c) {
633 if ( c->op == SLAP_CONFIG_EMIT ) {
637 c->value_int = ldap_pvt_thread_get_concurrency();
640 c->value_int = connection_pool_max;
644 c->value_string = ch_strdup( passwd_salt );
649 if ( c->be->be_limits ) {
654 for ( i=0; c->be->be_limits[i]; i++ ) {
655 bv.bv_len = sprintf( buf, "{%d}", i );
656 bv.bv_val = buf+bv.bv_len;
657 limits_unparse( c->be->be_limits[i], &bv );
658 bv.bv_len += bv.bv_val - buf;
660 value_add_one( &c->rvalue_vals, &bv );
663 if ( !c->rvalue_vals ) rc = 1;
666 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_OP_WRITES) != 0;
669 c->value_string = ch_strdup( slap_sasl_getpolicy());
672 slap_sasl_regexp_unparse( &c->rvalue_vals );
673 if ( !c->rvalue_vals ) rc = 1;
675 #ifdef HAVE_CYRUS_SASL
677 struct berval bv = BER_BVNULL;
678 slap_sasl_secprops_unparse( &bv );
679 if ( !BER_BVISNULL( &bv )) {
680 ber_bvarray_add( &c->rvalue_vals, &bv );
688 c->value_int = c->be->be_max_deref_depth;
691 oidm_unparse( &c->rvalue_vals );
692 if ( !c->rvalue_vals )
696 c->value_int = global_schemacheck;
700 char *src, *dst, ibuf[11];
701 struct berval bv, abv;
702 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
703 abv.bv_len = sprintf( ibuf, "{%x}", i );
704 acl_unparse( a, &bv );
705 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
706 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
707 /* Turn TAB / EOL into plain space */
708 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
709 if (isspace(*src)) *dst++ = ' ';
713 if (dst[-1] == ' ') {
717 abv.bv_len = dst - abv.bv_val;
718 ber_bvarray_add( &c->rvalue_vals, &abv );
724 if ( c->be->be_replogfile )
725 c->value_string = ch_strdup( c->be->be_replogfile );
728 ConfigFile *cf = (ConfigFile *)c->line;
729 if ( cf->c_dseFiles ) {
730 value_add( &c->rvalue_vals, cf->c_dseFiles );
738 c->value_string = ch_strdup( logfileName );
743 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
745 case CFG_SSTR_IF_MAX:
746 c->value_int = index_substr_if_maxlen;
748 case CFG_SSTR_IF_MIN:
749 c->value_int = index_substr_if_minlen;
753 ConfigFile *cf = (ConfigFile *)c->line;
755 for (i=0, mp=&cf->c_modpaths; mp; mp=mp->mp_next, i++) {
757 if (!mp->mp_loads) continue;
758 for (j=0; !BER_BVISNULL(&mp->mp_loads[j]); j++) {
761 bv.bv_len = sprintf( bv.bv_val, "{%d}{%d}%s", i, j,
762 mp->mp_loads[j].bv_val );
763 value_add_one( &c->rvalue_vals, &bv );
766 rc = c->rvalue_vals ? 0 : 1;
770 ConfigFile *cf = (ConfigFile *)c->line;
772 for (i=0, mp=&cf->c_modpaths; mp; mp=mp->mp_next, i++) {
774 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
777 bv.bv_len = sprintf( bv.bv_val, "{%d}%s", i,
778 mp->mp_path.bv_val );
779 value_add_one( &c->rvalue_vals, &bv );
781 rc = c->rvalue_vals ? 0 : 1;
787 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
788 if ( !c->rvalue_vals ) rc = 1;
791 #ifdef SLAP_AUTH_REWRITE
793 if ( authz_rewrites ) {
794 struct berval bv, idx;
799 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
800 idx.bv_len = sprintf( idx.bv_val, "{%d}", i );
801 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
802 bv.bv_val = ch_malloc( bv.bv_len + 1 );
803 strcpy( bv.bv_val, idx.bv_val );
804 strcpy( bv.bv_val+idx.bv_len, authz_rewrites[i].bv_val );
805 ber_bvarray_add( &c->rvalue_vals, &bv );
808 if ( !c->rvalue_vals ) rc = 1;
817 p = strchr(c->line,'(' /*')'*/);
820 if(!(c->bi = backend_info(c->argv[1]))) {
821 Debug(LDAP_DEBUG_ANY, "%s: "
822 "backend %s failed init!\n", c->log, c->argv[1], 0);
829 /* NOTE: config is always the first backend!
831 if ( !strcasecmp( c->argv[1], "config" )) {
833 } else if ( !strcasecmp( c->argv[1], "frontend" )) {
835 } else if(!(c->be = backend_db_init(c->argv[1]))) {
836 Debug(LDAP_DEBUG_ANY, "%s: "
837 "database %s failed init!\n", c->log, c->argv[1], 0);
843 ldap_pvt_thread_set_concurrency(c->value_int);
847 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
848 connection_pool_max = c->value_int; /* save for reference */
852 if ( passwd_salt ) ch_free( passwd_salt );
853 passwd_salt = c->value_string;
854 lutil_salt_format(passwd_salt);
858 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
864 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
866 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
870 ch_free(c->value_string);
871 if (slap_sasl_setpolicy( c->argv[1] )) {
872 Debug(LDAP_DEBUG_ANY, "%s: unable to parse value \"%s\" in"
873 " \"authz-policy <policy>\"\n",
874 c->log, c->argv[1], 0 );
880 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
884 #ifdef HAVE_CYRUS_SASL
887 char *txt = slap_sasl_secprops( c->argv[1] );
889 Debug(LDAP_DEBUG_ANY, "%s: sasl-secprops: %s\n",
898 c->be->be_max_deref_depth = c->value_int;
902 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv)) return(0);
906 if(parse_oc(c->fname, c->lineno, p, c->argv)) return(1);
910 if(parse_cr(c->fname, c->lineno, p, c->argv)) return(1);
914 if(parse_at(c->fname, c->lineno, p, c->argv)) return(1);
918 ad_define_option(NULL, NULL, 0);
919 for(i = 1; i < c->argc; i++)
920 if(ad_define_option(c->argv[i], c->fname, c->lineno))
925 global_schemacheck = c->value_int;
926 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: "
927 "schema checking disabled! your mileage may vary!\n",
932 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
936 if(SLAP_MONITOR(c->be)) {
937 Debug(LDAP_DEBUG_ANY, "%s: "
938 "\"replogfile\" should not be used "
939 "inside monitor database\n",
941 return(0); /* FIXME: should this be an error? */
944 c->be->be_replogfile = c->value_string;
948 if(read_root_dse_file(c->argv[1])) {
949 Debug(LDAP_DEBUG_ANY, "%s: "
950 "could not read \"rootDSE <filename>\" line\n",
956 ber_str2bv( c->argv[1], 0, 1, &bv );
957 ber_bvarray_add( &cfn->c_dseFiles, &bv );
963 if ( logfileName ) ch_free( logfileName );
964 logfileName = c->value_string;
965 logfile = fopen(logfileName, "w");
966 if(logfile) lutil_debug_file(logfile);
970 if(SLAP_NOLASTMODCMD(c->be)) {
971 Debug(LDAP_DEBUG_ANY, "%s: "
972 "lastmod not available for %s databases\n",
973 c->log, c->be->bd_info->bi_type, 0);
977 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
979 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
982 case CFG_SSTR_IF_MAX:
983 if (c->value_int < index_substr_if_minlen) {
984 Debug(LDAP_DEBUG_ANY, "%s: "
985 "invalid max value (%d)\n",
986 c->log, c->value_int, 0 );
989 index_substr_if_maxlen = c->value_int;
992 case CFG_SSTR_IF_MIN:
993 if (c->value_int > index_substr_if_maxlen) {
994 Debug(LDAP_DEBUG_ANY, "%s: "
995 "invalid min value (%d)\n",
996 c->log, c->value_int, 0 );
999 index_substr_if_minlen = c->value_int;
1002 #ifdef SLAPD_MODULES
1004 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
1006 /* Record this load on the current path */
1009 ber_str2bv(c->line, 0, 1, &bv);
1010 ber_bvarray_add( &cfn->c_modlast->mp_loads, &bv );
1015 if(module_path(c->argv[1])) return(1);
1016 /* Record which path was used with each module */
1020 if (!cfn->c_modpaths.mp_loads) {
1021 mp = &cfn->c_modpaths;
1023 mp = ch_malloc( sizeof( ModPaths ));
1024 cfn->c_modlast->mp_next = mp;
1026 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
1028 mp->mp_loads = NULL;
1029 cfn->c_modlast = mp;
1037 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
1039 slapi_plugins_used++;
1043 #ifdef SLAP_AUTH_REWRITE
1046 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
1048 ber_str2bv( c->line, 0, 1, &bv );
1049 ber_bvarray_add( &authz_rewrites, &bv );
1056 Debug(LDAP_DEBUG_ANY, "%s: unknown CFG_TYPE %d"
1057 "(ignored)\n", c->log, c->type, 0);
1065 config_fname(ConfigArgs *c) {
1066 if(c->op == SLAP_CONFIG_EMIT) {
1068 ConfigFile *cf = (ConfigFile *)c->line;
1069 value_add_one( &c->rvalue_vals, &cf->c_file );
1078 config_cfdir(ConfigArgs *c) {
1079 if(c->op == SLAP_CONFIG_EMIT) {
1080 value_add_one( &c->rvalue_vals, &cfdir );
1087 config_search_base(ConfigArgs *c) {
1090 if(c->op == SLAP_CONFIG_EMIT) {
1092 if (!BER_BVISEMPTY(&default_search_base)) {
1093 value_add_one(&c->rvalue_vals, &default_search_base);
1094 value_add_one(&c->rvalue_nvals, &default_search_nbase);
1100 if(c->bi || c->be != frontendDB) {
1101 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
1102 "prior to any backend or database definition\n",
1107 if(default_search_nbase.bv_len) {
1108 Debug(LDAP_DEBUG_ANY, "%s: "
1109 "default search base \"%s\" already defined "
1110 "(discarding old)\n",
1111 c->log, default_search_base.bv_val, 0);
1112 free(default_search_base.bv_val);
1113 free(default_search_nbase.bv_val);
1116 default_search_base = c->value_dn;
1117 default_search_nbase = c->value_ndn;
1122 config_passwd_hash(ConfigArgs *c) {
1124 if (c->op == SLAP_CONFIG_EMIT) {
1126 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
1127 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
1128 value_add_one(&c->rvalue_vals, &bv);
1132 if(default_passwd_hash) {
1133 Debug(LDAP_DEBUG_ANY, "%s: "
1134 "already set default password_hash\n",
1138 for(i = 1; i < c->argc; i++) {
1139 if(!lutil_passwd_scheme(c->argv[i])) {
1140 Debug(LDAP_DEBUG_ANY, "%s: "
1141 "password scheme \"%s\" not available\n",
1142 c->log, c->argv[i], 0);
1144 ldap_charray_add(&default_passwd_hash, c->argv[i]);
1146 if(!default_passwd_hash) {
1147 Debug(LDAP_DEBUG_ANY, "%s: no valid hashes found\n",
1156 config_schema_dn(ConfigArgs *c) {
1157 if ( c->op == SLAP_CONFIG_EMIT ) {
1159 if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
1160 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
1161 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
1166 c->be->be_schemadn = c->value_dn;
1167 c->be->be_schemandn = c->value_ndn;
1172 config_sizelimit(ConfigArgs *c) {
1175 struct slap_limits_set *lim = &c->be->be_def_limit;
1176 if (c->op == SLAP_CONFIG_EMIT) {
1181 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv );
1182 if ( !BER_BVISEMPTY( &bv ))
1183 value_add_one( &c->rvalue_vals, &bv );
1188 for(i = 1; i < c->argc; i++) {
1189 if(!strncasecmp(c->argv[i], "size", 4)) {
1190 rc = limits_parse_one(c->argv[i], lim);
1192 Debug(LDAP_DEBUG_ANY, "%s: "
1193 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
1194 c->log, c->argv[i], 0);
1198 if(!strcasecmp(c->argv[i], "unlimited")) {
1199 lim->lms_s_soft = -1;
1201 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
1202 if(next == c->argv[i]) {
1203 Debug(LDAP_DEBUG_ANY, "%s: "
1204 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
1205 c->log, c->argv[i], 0);
1207 } else if(next[0] != '\0') {
1208 Debug(LDAP_DEBUG_ANY, "%s: "
1209 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
1213 lim->lms_s_hard = 0;
1220 config_timelimit(ConfigArgs *c) {
1223 struct slap_limits_set *lim = &c->be->be_def_limit;
1224 if (c->op == SLAP_CONFIG_EMIT) {
1229 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv );
1230 if ( !BER_BVISEMPTY( &bv ))
1231 value_add_one( &c->rvalue_vals, &bv );
1236 for(i = 1; i < c->argc; i++) {
1237 if(!strncasecmp(c->argv[i], "time", 4)) {
1238 rc = limits_parse_one(c->argv[i], lim);
1240 Debug(LDAP_DEBUG_ANY, "%s: "
1241 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
1242 c->log, c->argv[i], 0);
1246 if(!strcasecmp(c->argv[i], "unlimited")) {
1247 lim->lms_t_soft = -1;
1249 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
1250 if(next == c->argv[i]) {
1251 Debug(LDAP_DEBUG_ANY, "%s: "
1252 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
1253 c->log, c->argv[i], 0);
1255 } else if(next[0] != '\0') {
1256 Debug(LDAP_DEBUG_ANY, "%s: "
1257 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
1261 lim->lms_t_hard = 0;
1268 config_overlay(ConfigArgs *c) {
1269 if (c->op == SLAP_CONFIG_EMIT) {
1272 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
1274 Debug(LDAP_DEBUG_ANY, "%s: (optional) %s overlay \"%s\" configuration failed (ignored)\n",
1275 c->log, c->be == frontendDB ? "global " : "", c->argv[1][1]);
1276 } else if(overlay_config(c->be, c->argv[1])) {
1283 config_suffix(ConfigArgs *c) {
1285 struct berval pdn, ndn;
1288 if (c->be == frontendDB) return 1;
1290 if (c->op == SLAP_CONFIG_EMIT) {
1291 if (!BER_BVISNULL( &c->be->be_suffix[0] )) {
1292 value_add( &c->rvalue_vals, c->be->be_suffix );
1293 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
1299 #ifdef SLAPD_MONITOR_DN
1300 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
1301 Debug(LDAP_DEBUG_ANY, "%s: "
1302 "\"%s\" is reserved for monitoring slapd\n",
1303 c->log, SLAPD_MONITOR_DN, 0);
1310 tbe = select_backend(&ndn, 0, 0);
1312 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by this backend! (ignored)\n",
1317 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by a preceding backend \"%s\"\n",
1318 c->log, tbe->be_suffix[0].bv_val, 0);
1322 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
1323 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
1324 "base provided \"%s\" (assuming okay)\n",
1325 c->log, default_search_base.bv_val, 0);
1327 ber_bvarray_add(&c->be->be_suffix, &pdn);
1328 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
1333 config_rootdn(ConfigArgs *c) {
1334 if (c->op == SLAP_CONFIG_EMIT) {
1335 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
1336 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
1337 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
1343 c->be->be_rootdn = c->value_dn;
1344 c->be->be_rootndn = c->value_ndn;
1349 config_rootpw(ConfigArgs *c) {
1351 if (c->op == SLAP_CONFIG_EMIT) {
1352 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
1353 c->value_string=c->be->be_rootpw.bv_val;
1359 tbe = select_backend(&c->be->be_rootndn, 0, 0);
1361 Debug(LDAP_DEBUG_ANY, "%s: "
1362 "rootpw can only be set when rootdn is under suffix\n",
1366 ber_str2bv(c->value_string, 0, 0, &c->be->be_rootpw);
1371 config_restrict(ConfigArgs *c) {
1372 slap_mask_t restrictops = 0;
1374 slap_verbmasks restrictable_ops[] = {
1375 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
1376 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
1377 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
1378 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
1379 { BER_BVC("modrdn"), 0 },
1380 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
1381 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
1382 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
1383 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
1384 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
1385 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
1386 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
1387 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
1388 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
1389 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
1393 if (c->op == SLAP_CONFIG_EMIT) {
1394 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
1397 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
1399 Debug(LDAP_DEBUG_ANY, "%s: "
1400 "unknown operation %s in \"restrict <features>\" line\n",
1401 c->log, c->argv[i], 0);
1404 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
1405 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
1406 c->be->be_restrictops |= restrictops;
1411 config_allows(ConfigArgs *c) {
1412 slap_mask_t allows = 0;
1414 slap_verbmasks allowable_ops[] = {
1415 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
1416 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
1417 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
1418 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
1421 if (c->op == SLAP_CONFIG_EMIT) {
1422 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
1424 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
1426 Debug(LDAP_DEBUG_ANY, "%s: "
1427 "unknown feature %s in \"allow <features>\" line\n",
1428 c->log, c->argv[i], 0);
1431 global_allows |= allows;
1436 config_disallows(ConfigArgs *c) {
1437 slap_mask_t disallows = 0;
1439 slap_verbmasks disallowable_ops[] = {
1440 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
1441 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
1442 { BER_BVC("bind_krb4"), SLAP_DISALLOW_BIND_KRBV4 },
1443 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
1444 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
1447 if (c->op == SLAP_CONFIG_EMIT) {
1448 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
1450 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
1452 Debug(LDAP_DEBUG_ANY, "%s: "
1453 "unknown feature %s in \"disallow <features>\" line\n",
1454 c->log, c->argv[i], 0);
1457 global_disallows |= disallows;
1462 config_requires(ConfigArgs *c) {
1463 slap_mask_t requires = 0;
1465 slap_verbmasks requires_ops[] = {
1466 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
1467 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
1468 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
1469 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
1470 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
1473 if (c->op == SLAP_CONFIG_EMIT) {
1474 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
1476 i = verbs_to_mask(c->argc, c->argv, requires_ops, &requires);
1478 Debug(LDAP_DEBUG_ANY, "%s: "
1479 "unknown feature %s in \"require <features>\" line\n",
1480 c->log, c->argv[i], 0);
1483 c->be->be_requires = requires;
1488 config_loglevel(ConfigArgs *c) {
1491 slap_verbmasks loglevel_ops[] = {
1492 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
1493 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
1494 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
1495 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
1496 { BER_BVC("BER"), LDAP_DEBUG_BER },
1497 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
1498 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
1499 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
1500 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
1501 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
1502 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
1503 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
1504 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
1505 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
1506 { BER_BVC("Any"), -1 },
1510 if (c->op == SLAP_CONFIG_EMIT) {
1511 return mask_to_verbs( loglevel_ops, ldap_syslog, &c->rvalue_vals );
1516 for( i=1; i < c->argc; i++ ) {
1519 if ( isdigit( c->argv[i][0] ) ) {
1520 level = strtol( c->argv[i], &next, 10 );
1521 if ( next == NULL || next[0] != '\0' ) {
1522 Debug( LDAP_DEBUG_ANY,
1523 "%s: unable to parse level \"%s\" "
1524 "in \"loglevel <level> [...]\" line.\n",
1525 c->log, c->argv[i], 0);
1529 int j = verb_to_mask(c->argv[i], loglevel_ops);
1530 if(BER_BVISNULL(&loglevel_ops[j].word)) {
1531 Debug( LDAP_DEBUG_ANY,
1532 "%s: unknown level \"%s\" "
1533 "in \"loglevel <level> [...]\" line.\n",
1534 c->log, c->argv[i], 0);
1537 level = loglevel_ops[j].mask;
1539 ldap_syslog |= level;
1545 config_syncrepl(ConfigArgs *c) {
1546 if (c->op == SLAP_CONFIG_EMIT) {
1547 if ( c->be->be_syncinfo ) {
1549 syncrepl_unparse( c->be->be_syncinfo, &bv );
1550 ber_bvarray_add( &c->rvalue_vals, &bv );
1555 if(SLAP_SHADOW(c->be)) {
1556 Debug(LDAP_DEBUG_ANY, "%s: "
1557 "syncrepl: database already shadowed.\n",
1560 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1563 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1568 config_referral(ConfigArgs *c) {
1569 struct berval vals[2];
1570 if (c->op == SLAP_CONFIG_EMIT) {
1571 if ( default_referral ) {
1572 value_add( &c->rvalue_vals, default_referral );
1578 if(validate_global_referral(c->argv[1])) {
1579 Debug(LDAP_DEBUG_ANY, "%s: "
1580 "invalid URL (%s) in \"referral\" line.\n",
1581 c->log, c->argv[1], 0);
1585 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1586 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1587 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1595 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
1596 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
1597 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
1598 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
1599 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
1600 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
1601 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
1602 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
1603 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
1608 config_security(ConfigArgs *c) {
1609 slap_ssf_set_t *set = &c->be->be_ssf_set;
1612 if (c->op == SLAP_CONFIG_EMIT) {
1618 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
1619 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
1622 bv.bv_len = sprintf( numbuf, "%u", *tgt );
1623 bv.bv_len += sec_keys[i].key.bv_len;
1624 bv.bv_val = ch_malloc( bv.bv_len + 1);
1625 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
1626 strcpy( next, numbuf );
1627 ber_bvarray_add( &c->rvalue_vals, &bv );
1632 for(i = 1; i < c->argc; i++) {
1633 slap_ssf_t *tgt = NULL;
1635 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
1636 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
1637 sec_keys[j].key.bv_len)) {
1638 src = c->argv[i] + sec_keys[j].key.bv_len;
1639 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
1644 Debug(LDAP_DEBUG_ANY, "%s: "
1645 "unknown factor %s in \"security <factors>\" line\n",
1646 c->log, c->argv[i], 0);
1650 *tgt = strtol(src, &next, 10);
1651 if(next == NULL || next[0] != '\0' ) {
1652 Debug(LDAP_DEBUG_ANY, "%s: "
1653 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1654 c->log, c->argv[i], 0);
1662 anlist_unparse( AttributeName *an, char *ptr ) {
1665 for (; !BER_BVISNULL( &an->an_name ); an++) {
1666 if ( comma ) *ptr++ = ',';
1667 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
1674 replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
1678 struct berval bc = {0};
1681 len = sprintf(numbuf, "{%d}", i );
1683 len += strlen( ri->ri_uri ) + STRLENOF("uri=");
1684 if ( ri->ri_nsuffix ) {
1685 for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
1686 len += ri->ri_nsuffix[i].bv_len + STRLENOF(" suffix=\"\"");
1689 if ( ri->ri_attrs ) {
1690 len += STRLENOF("attr");
1691 if ( ri->ri_exclude ) len++;
1692 for (i=0; !BER_BVISNULL( &ri->ri_attrs[i].an_name ); i++) {
1693 len += 1 + ri->ri_attrs[i].an_name.bv_len;
1696 bindconf_unparse( &ri->ri_bindconf, &bc );
1699 bv->bv_val = ch_malloc(len + 1);
1702 ptr = lutil_strcopy( bv->bv_val, numbuf );
1703 ptr = lutil_strcopy( ptr, "uri=" );
1704 ptr = lutil_strcopy( ptr, ri->ri_uri );
1706 if ( ri->ri_nsuffix ) {
1707 for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
1708 ptr = lutil_strcopy( ptr, " suffix=\"" );
1709 ptr = lutil_strcopy( ptr, ri->ri_nsuffix[i].bv_val );
1713 if ( ri->ri_attrs ) {
1714 ptr = lutil_strcopy( ptr, "attr" );
1715 if ( ri->ri_exclude ) *ptr++ = '!';
1717 ptr = anlist_unparse( ri->ri_attrs, ptr );
1720 strcpy( ptr, bc.bv_val );
1721 ch_free( bc.bv_val );
1726 config_replica(ConfigArgs *c) {
1727 int i, nr = -1, len;
1728 char *replicahost, *replicauri;
1731 if (c->op == SLAP_CONFIG_EMIT) {
1732 if (c->be->be_replica) {
1734 for (i=0;c->be->be_replica[i]; i++) {
1735 replica_unparse( c->be->be_replica[i], i, &bv );
1736 ber_bvarray_add( &c->rvalue_vals, &bv );
1742 if(SLAP_MONITOR(c->be)) {
1743 Debug(LDAP_DEBUG_ANY, "%s: "
1744 "\"replica\" should not be used inside monitor database\n",
1746 return(0); /* FIXME: should this be an error? */
1749 for(i = 1; i < c->argc; i++) {
1750 if(!strncasecmp(c->argv[i], "host=", STRLENOF("host="))) {
1751 replicahost = c->argv[i] + STRLENOF("host=");
1752 len = strlen( replicahost );
1753 replicauri = ch_malloc( len + STRLENOF("ldap://") + 1 );
1754 sprintf( replicauri, "ldap://%s", replicahost );
1755 replicahost = replicauri + STRLENOF( "ldap://");
1756 nr = add_replica_info(c->be, replicauri, replicahost);
1758 } else if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) {
1759 if(ldap_url_parse(c->argv[i] + STRLENOF("uri="), &ludp) != LDAP_SUCCESS) {
1760 Debug(LDAP_DEBUG_ANY, "%s: "
1761 "replica line contains invalid "
1762 "uri definition.\n", c->log, 0, 0);
1765 if(!ludp->lud_host) {
1766 Debug(LDAP_DEBUG_ANY, "%s: "
1767 "replica line contains invalid "
1768 "uri definition - missing hostname.\n",
1772 ldap_free_urldesc(ludp);
1773 replicauri = c->argv[i] + STRLENOF("uri=");
1774 replicauri = ch_strdup( replicauri );
1775 replicahost = strchr( replicauri, '/' );
1777 nr = add_replica_info(c->be, replicauri, replicahost);
1782 Debug(LDAP_DEBUG_ANY, "%s: "
1783 "missing host or uri in \"replica\" line\n",
1786 } else if(nr == -1) {
1787 Debug(LDAP_DEBUG_ANY, "%s: "
1788 "unable to add replica \"%s\"\n",
1789 c->log, replicauri, 0);
1792 for(i = 1; i < c->argc; i++) {
1793 if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
1794 switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) {
1796 Debug(LDAP_DEBUG_ANY, "%s: "
1797 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1798 c->log, c->argv[i] + STRLENOF("suffix="), 0);
1801 Debug(LDAP_DEBUG_ANY, "%s: "
1802 "unable to normalize suffix in \"replica\" line (ignored)\n",
1807 } else if(!strncasecmp(c->argv[i], "attr", STRLENOF("attr"))) {
1809 char *arg = c->argv[i] + STRLENOF("attr");
1817 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1818 Debug(LDAP_DEBUG_ANY, "%s: "
1819 "attribute \"%s\" in \"replica\" line is unknown\n",
1820 c->log, arg + 1, 0);
1823 } else if ( bindconf_parse( c->argv[i],
1824 &c->be->be_replica[nr]->ri_bindconf ) ) {
1833 config_updatedn(ConfigArgs *c) {
1836 if (c->op == SLAP_CONFIG_EMIT) {
1837 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
1838 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
1839 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
1844 if(SLAP_SHADOW(c->be)) {
1845 Debug(LDAP_DEBUG_ANY, "%s: "
1846 "updatedn: database already shadowed.\n",
1851 ber_str2bv(c->argv[1], 0, 0, &dn);
1853 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1855 if(rc != LDAP_SUCCESS) {
1856 Debug(LDAP_DEBUG_ANY, "%s: "
1857 "updatedn DN is invalid: %d (%s)\n",
1858 c->log, rc, ldap_err2string( rc ));
1862 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1867 config_updateref(ConfigArgs *c) {
1868 struct berval vals[2];
1869 if (c->op == SLAP_CONFIG_EMIT) {
1870 if ( c->be->be_update_refs ) {
1871 value_add( &c->rvalue_vals, c->be->be_update_refs );
1877 if(!SLAP_SHADOW(c->be)) {
1878 Debug(LDAP_DEBUG_ANY, "%s: "
1879 "updateref line must come after syncrepl or updatedn.\n",
1884 if(validate_global_referral(c->argv[1])) {
1885 Debug(LDAP_DEBUG_ANY, "%s: "
1886 "invalid URL (%s) in \"updateref\" line.\n",
1887 c->log, c->argv[1], 0);
1890 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1891 vals[1].bv_val = NULL;
1892 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1897 config_include(ConfigArgs *c) {
1898 unsigned long savelineno = c->lineno;
1901 ConfigFile *cfsave = cfn;
1902 ConfigFile *cf2 = NULL;
1903 if (c->op == SLAP_CONFIG_EMIT) {
1906 cf = ch_calloc( 1, sizeof(ConfigFile));
1907 #ifdef SLAPD_MODULES
1908 cf->c_modlast = &cf->c_modpaths;
1910 if ( cfn->c_kids ) {
1911 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
1917 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
1918 rc = read_config_file(c->argv[1], c->depth + 1, c);
1919 c->lineno = savelineno - 1;
1922 if ( cf2 ) cf2->c_sibs = NULL;
1923 else cfn->c_kids = NULL;
1924 ch_free( cf->c_file.bv_val );
1932 config_tls_option(ConfigArgs *c) {
1935 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
1936 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
1937 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
1938 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
1939 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
1940 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
1941 default: Debug(LDAP_DEBUG_ANY, "%s: "
1942 "unknown tls_option <%x>\n",
1943 c->log, c->type, 0);
1945 if (c->op == SLAP_CONFIG_EMIT) {
1946 return ldap_pvt_tls_get_option( NULL, flag, &c->value_string );
1948 ch_free(c->value_string);
1949 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
1952 /* FIXME: this ought to be provided by libldap */
1954 config_tls_config(ConfigArgs *c) {
1956 slap_verbmasks crlkeys[] = {
1957 { BER_BVC("none"), LDAP_OPT_X_TLS_CRL_NONE },
1958 { BER_BVC("peer"), LDAP_OPT_X_TLS_CRL_PEER },
1959 { BER_BVC("all"), LDAP_OPT_X_TLS_CRL_ALL },
1962 slap_verbmasks vfykeys[] = {
1963 { BER_BVC("never"), LDAP_OPT_X_TLS_NEVER },
1964 { BER_BVC("demand"), LDAP_OPT_X_TLS_DEMAND },
1965 { BER_BVC("try"), LDAP_OPT_X_TLS_TRY },
1966 { BER_BVC("hard"), LDAP_OPT_X_TLS_HARD },
1970 #ifdef HAVE_OPENSSL_CRL
1971 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; keys = crlkeys;
1974 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; keys = vfykeys;
1976 default: Debug(LDAP_DEBUG_ANY, "%s: "
1977 "unknown tls_option <%x>\n",
1978 c->log, c->type, 0);
1980 if (c->op == SLAP_CONFIG_EMIT) {
1981 ldap_pvt_tls_get_option( NULL, flag, &c->value_int );
1982 for (i=0; !BER_BVISNULL(&keys[i].word); i++) {
1983 if (keys[i].mask == c->value_int) {
1984 c->value_string = ch_strdup( keys[i].word.bv_val );
1990 ch_free( c->value_string );
1991 if(isdigit((unsigned char)c->argv[1][0])) {
1992 i = atoi(c->argv[1]);
1993 return(ldap_pvt_tls_set_option(NULL, flag, &i));
1995 return(ldap_int_tls_config(NULL, flag, c->argv[1]));
2010 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
2013 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
2017 si->si_bindconf.sb_tls = SB_TLS_OFF;
2018 si->si_bindconf.sb_method = LDAP_AUTH_SIMPLE;
2019 si->si_schemachecking = 0;
2020 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
2021 &si->si_filterstr );
2022 si->si_base.bv_val = NULL;
2023 si->si_scope = LDAP_SCOPE_SUBTREE;
2024 si->si_attrsonly = 0;
2025 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
2026 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
2027 si->si_attrs = NULL;
2028 si->si_allattrs = 0;
2029 si->si_allopattrs = 0;
2030 si->si_exattrs = NULL;
2031 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2032 si->si_interval = 86400;
2033 si->si_retryinterval = NULL;
2034 si->si_retrynum_init = NULL;
2035 si->si_retrynum = NULL;
2036 si->si_manageDSAit = 0;
2040 si->si_presentlist = NULL;
2041 LDAP_LIST_INIT( &si->si_nonpresentlist );
2042 ldap_pvt_thread_mutex_init( &si->si_mutex );
2044 rc = parse_syncrepl_line( cargv, cargc, si );
2047 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2048 syncinfo_free( si );
2051 Debug( LDAP_DEBUG_CONFIG,
2052 "Config: ** successfully added syncrepl \"%s\"\n",
2053 BER_BVISNULL( &si->si_provideruri ) ?
2054 "(null)" : si->si_provideruri.bv_val, 0, 0 );
2055 if ( !si->si_schemachecking ) {
2056 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2059 be->be_syncinfo = si;
2064 /* NOTE: used & documented in slapd.conf(5) */
2066 #define PROVIDERSTR "provider"
2067 #define TYPESTR "type"
2068 #define INTERVALSTR "interval"
2069 #define SEARCHBASESTR "searchbase"
2070 #define FILTERSTR "filter"
2071 #define SCOPESTR "scope"
2072 #define ATTRSSTR "attrs"
2073 #define ATTRSONLYSTR "attrsonly"
2074 #define SLIMITSTR "sizelimit"
2075 #define TLIMITSTR "timelimit"
2076 #define SCHEMASTR "schemachecking"
2078 /* FIXME: undocumented */
2079 #define OLDAUTHCSTR "bindprincipal"
2080 #define EXATTRSSTR "exattrs"
2081 #define RETRYSTR "retry"
2084 #define LASTMODSTR "lastmod"
2085 #define LMGENSTR "gen"
2086 #define LMNOSTR "no"
2087 #define LMREQSTR "req"
2088 #define SRVTABSTR "srvtab"
2089 #define SUFFIXSTR "suffix"
2090 #define MANAGEDSAITSTR "manageDSAit"
2093 #define GOT_ID 0x0001
2094 #define GOT_PROVIDER 0x0002
2097 #define GOT_ALL (GOT_ID|GOT_PROVIDER)
2103 { BER_BVC("base"), LDAP_SCOPE_BASE },
2104 { BER_BVC("one"), LDAP_SCOPE_ONELEVEL },
2105 #ifdef LDAP_SCOPE_SUBORDINATE
2106 { BER_BVC("children"), LDAP_SCOPE_SUBORDINATE },
2107 { BER_BVC("subordinate"), 0 },
2109 { BER_BVC("sub"), LDAP_SCOPE_SUBTREE },
2114 parse_syncrepl_line(
2124 for ( i = 1; i < cargc; i++ ) {
2125 if ( !strncasecmp( cargv[ i ], IDSTR "=",
2126 STRLENOF( IDSTR "=" ) ) )
2129 /* '\0' string terminator accounts for '=' */
2130 val = cargv[ i ] + STRLENOF( IDSTR "=" );
2132 if ( tmp >= 1000 || tmp < 0 ) {
2133 fprintf( stderr, "Error: parse_syncrepl_line: "
2134 "syncrepl id %d is out of range [0..999]\n", tmp );
2139 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
2140 STRLENOF( PROVIDERSTR "=" ) ) )
2142 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
2143 ber_str2bv( val, 0, 1, &si->si_provideruri );
2144 gots |= GOT_PROVIDER;
2145 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
2146 STRLENOF( SCHEMASTR "=" ) ) )
2148 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
2149 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
2150 si->si_schemachecking = 1;
2151 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
2152 si->si_schemachecking = 0;
2154 si->si_schemachecking = 1;
2156 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
2157 STRLENOF( FILTERSTR "=" ) ) )
2159 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
2160 ber_str2bv( val, 0, 1, &si->si_filterstr );
2161 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
2162 STRLENOF( SEARCHBASESTR "=" ) ) )
2167 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
2168 if ( si->si_base.bv_val ) {
2169 ch_free( si->si_base.bv_val );
2171 ber_str2bv( val, 0, 0, &bv );
2172 rc = dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL );
2173 if ( rc != LDAP_SUCCESS ) {
2174 fprintf( stderr, "Invalid base DN \"%s\": %d (%s)\n",
2175 val, rc, ldap_err2string( rc ) );
2178 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
2179 STRLENOF( SCOPESTR "=" ) ) )
2182 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
2183 for ( j=0; !BER_BVISNULL(&scopes[j].key); j++ ) {
2184 if (!strncasecmp( val, scopes[j].key.bv_val,
2185 scopes[j].key.bv_len )) {
2186 while (!scopes[j].val) j--;
2187 si->si_scope = scopes[j].val;
2191 if ( BER_BVISNULL(&scopes[j].key) ) {
2192 fprintf( stderr, "Error: parse_syncrepl_line: "
2193 "unknown scope \"%s\"\n", val);
2196 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
2197 STRLENOF( ATTRSONLYSTR "=" ) ) )
2199 si->si_attrsonly = 1;
2200 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
2201 STRLENOF( ATTRSSTR "=" ) ) )
2203 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
2204 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
2206 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2207 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
2208 if ( si->si_anlist == NULL ) {
2209 ch_free( attr_fname );
2212 si->si_anfile = attr_fname;
2214 char *str, *s, *next;
2215 char delimstr[] = " ,\t";
2216 str = ch_strdup( val );
2217 for ( s = ldap_pvt_strtok( str, delimstr, &next );
2219 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
2221 if ( strlen(s) == 1 && *s == '*' ) {
2222 si->si_allattrs = 1;
2223 *(val + ( s - str )) = delimstr[0];
2225 if ( strlen(s) == 1 && *s == '+' ) {
2226 si->si_allopattrs = 1;
2227 *(val + ( s - str )) = delimstr[0];
2231 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
2232 if ( si->si_anlist == NULL ) {
2236 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
2237 STRLENOF( EXATTRSSTR "=" ) ) )
2239 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
2240 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
2242 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2243 si->si_exanlist = file2anlist(
2244 si->si_exanlist, attr_fname, " ,\t" );
2245 if ( si->si_exanlist == NULL ) {
2246 ch_free( attr_fname );
2249 ch_free( attr_fname );
2251 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
2252 if ( si->si_exanlist == NULL ) {
2256 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
2257 STRLENOF( TYPESTR "=" ) ) )
2259 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
2260 if ( !strncasecmp( val, "refreshOnly",
2261 STRLENOF("refreshOnly") ))
2263 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2264 } else if ( !strncasecmp( val, "refreshAndPersist",
2265 STRLENOF("refreshAndPersist") ))
2267 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
2268 si->si_interval = 60;
2270 fprintf( stderr, "Error: parse_syncrepl_line: "
2271 "unknown sync type \"%s\"\n", val);
2274 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
2275 STRLENOF( INTERVALSTR "=" ) ) )
2277 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
2278 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
2279 si->si_interval = 0;
2287 hstr = strchr( dstr, ':' );
2288 if ( hstr == NULL ) {
2289 fprintf( stderr, "Error: parse_syncrepl_line: "
2290 "invalid interval \"%s\"\n", val );
2294 mstr = strchr( hstr, ':' );
2295 if ( mstr == NULL ) {
2296 fprintf( stderr, "Error: parse_syncrepl_line: "
2297 "invalid interval \"%s\"\n", val );
2301 sstr = strchr( mstr, ':' );
2302 if ( sstr == NULL ) {
2303 fprintf( stderr, "Error: parse_syncrepl_line: "
2304 "invalid interval \"%s\"\n", val );
2313 if (( hh > 24 ) || ( hh < 0 ) ||
2314 ( mm > 60 ) || ( mm < 0 ) ||
2315 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2316 fprintf( stderr, "Error: parse_syncrepl_line: "
2317 "invalid interval \"%s\"\n", val );
2320 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2322 if ( si->si_interval < 0 ) {
2323 fprintf( stderr, "Error: parse_syncrepl_line: "
2324 "invalid interval \"%ld\"\n",
2325 (long) si->si_interval);
2328 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2329 STRLENOF( RETRYSTR "=" ) ) )
2334 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2335 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2336 retry_list[0] = NULL;
2338 slap_str2clist( &retry_list, val, " ,\t" );
2340 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2344 "Error: incomplete syncrepl retry list\n" );
2345 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2346 ch_free( retry_list[k] );
2348 ch_free( retry_list );
2349 exit( EXIT_FAILURE );
2351 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2352 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2353 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2354 for ( j = 0; j < n; j++ ) {
2355 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2356 if ( *retry_list[j*2+1] == '+' ) {
2357 si->si_retrynum_init[j] = -1;
2358 si->si_retrynum[j] = -1;
2362 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2363 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2366 si->si_retrynum_init[j] = -2;
2367 si->si_retrynum[j] = -2;
2368 si->si_retryinterval[j] = 0;
2370 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2371 ch_free( retry_list[k] );
2373 ch_free( retry_list );
2374 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2375 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2377 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2378 si->si_manageDSAit = atoi( val );
2379 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2380 STRLENOF( SLIMITSTR "=") ) )
2382 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2383 si->si_slimit = atoi( val );
2384 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2385 STRLENOF( TLIMITSTR "=" ) ) )
2387 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2388 si->si_tlimit = atoi( val );
2389 } else if ( bindconf_parse( cargv[i], &si->si_bindconf )) {
2390 fprintf( stderr, "Error: parse_syncrepl_line: "
2391 "unknown keyword \"%s\"\n", cargv[ i ] );
2396 if ( gots != GOT_ALL ) {
2398 "Error: Malformed \"syncrepl\" line in slapd config file" );
2406 syncrepl_unparse( syncinfo_t *si, struct berval *bv )
2409 char buf[BUFSIZ*2], *ptr;
2412 bindconf_unparse( &si->si_bindconf, &bc );
2414 ptr += sprintf( ptr, IDSTR "=%03d " PROVIDERSTR "=%s",
2415 si->si_rid, si->si_provideruri.bv_val );
2416 if ( !BER_BVISNULL( &bc )) {
2417 ptr = lutil_strcopy( ptr, bc.bv_val );
2420 if ( !BER_BVISEMPTY( &si->si_filterstr )) {
2421 ptr = lutil_strcopy( ptr, " " FILTERSTR "=\"" );
2422 ptr = lutil_strcopy( ptr, si->si_filterstr.bv_val );
2425 if ( !BER_BVISNULL( &si->si_base )) {
2426 ptr = lutil_strcopy( ptr, " " SEARCHBASESTR "=\"" );
2427 ptr = lutil_strcopy( ptr, si->si_base.bv_val );
2430 for (i=0; !BER_BVISNULL(&scopes[i].key);i++) {
2431 if ( si->si_scope == scopes[i].val ) {
2432 ptr = lutil_strcopy( ptr, " " SCOPESTR "=" );
2433 ptr = lutil_strcopy( ptr, scopes[i].key.bv_val );
2437 if ( si->si_attrsonly ) {
2438 ptr = lutil_strcopy( ptr, " " ATTRSONLYSTR "=yes" );
2440 if ( si->si_anfile ) {
2441 ptr = lutil_strcopy( ptr, " " ATTRSSTR "=:include:" );
2442 ptr = lutil_strcopy( ptr, si->si_anfile );
2443 } else if ( si->si_allattrs || si->si_allopattrs ||
2444 ( si->si_anlist && !BER_BVISNULL(&si->si_anlist[0].an_name) )) {
2446 ptr = lutil_strcopy( ptr, " " ATTRSSTR "=\"" );
2448 ptr = anlist_unparse( si->si_anlist, ptr );
2449 if ( si->si_allattrs ) {
2450 if ( old != ptr ) *ptr++ = ',';
2453 if ( si->si_allopattrs ) {
2454 if ( old != ptr ) *ptr++ = ',';
2459 if ( si->si_exanlist && !BER_BVISNULL(&si->si_exanlist[0].an_name) ) {
2460 ptr = lutil_strcopy( ptr, " " EXATTRSSTR "=" );
2461 ptr = anlist_unparse( si->si_exanlist, ptr );
2463 ptr = lutil_strcopy( ptr, " " SCHEMASTR "=" );
2464 ptr = lutil_strcopy( ptr, si->si_schemachecking ? "on" : "off" );
2466 ptr = lutil_strcopy( ptr, " " TYPESTR "=" );
2467 ptr = lutil_strcopy( ptr, si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ?
2468 "refreshAndPersist" : "refreshOnly" );
2470 if ( si->si_type == LDAP_SYNC_REFRESH_ONLY ) {
2473 dd = si->si_interval;
2480 ptr = lutil_strcopy( ptr, " " INTERVALSTR "=" );
2481 ptr += sprintf( ptr, "%02d:%02d:%02d:%02d", dd, hh, mm, ss );
2482 } else if ( si->si_retryinterval ) {
2484 ptr = lutil_strcopy( ptr, " " RETRYSTR "=\"" );
2485 for (i=0; si->si_retryinterval[i]; i++) {
2486 if ( space ) *ptr++ = ' ';
2488 ptr += sprintf( ptr, "%d", si->si_retryinterval[i] );
2489 if ( si->si_retrynum_init[i] == -1 )
2492 ptr += sprintf( ptr, "%d", si->si_retrynum_init );
2497 #if 0 /* FIXME: unused in syncrepl.c, should remove it */
2498 ptr = lutil_strcopy( ptr, " " MANAGEDSAITSTR "=" );
2499 ptr += sprintf( ptr, "%d", si->si_manageDSAit );
2502 if ( si->si_slimit ) {
2503 ptr = lutil_strcopy( ptr, " " SLIMITSTR "=" );
2504 ptr += sprintf( ptr, "%d", si->si_slimit );
2507 if ( si->si_tlimit ) {
2508 ptr = lutil_strcopy( ptr, " " TLIMITSTR "=" );
2509 ptr += sprintf( ptr, "%d", si->si_tlimit );
2511 bc.bv_len = ptr - buf;
2513 ber_dupbv( bv, &bc );
2516 static CfEntryInfo *
2517 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
2527 if ( dn_match( &root->ce_entry->e_nname, dn ))
2530 c = dn->bv_val+dn->bv_len;
2531 for (;*c != ',';c--);
2535 for (--c;c>dn->bv_val && *c != ',';c--);
2539 cdn.bv_len = dn->bv_len - (c-dn->bv_val);
2541 root = root->ce_kids;
2543 for (;root;root=root->ce_sibs) {
2544 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
2545 if ( cdn.bv_val == dn->bv_val ) {
2556 config_ldif_resp( Operation *op, SlapReply *rs )
2558 if ( rs->sr_type == REP_SEARCH ) {
2559 CfBackInfo *cfb = op->o_callback->sc_private;
2561 cfb->cb_got_ldif = 1;
2562 rs->sr_err = config_add_internal( cfb, rs->sr_entry, NULL );
2567 /* Configure and read the underlying back-ldif store */
2569 config_setup_ldif( BackendDB *be, const char *dir ) {
2570 CfBackInfo *cfb = be->be_private;
2575 slap_callback cb = { NULL, config_ldif_resp, NULL, NULL };
2576 Connection conn = {0};
2577 char opbuf[OPERATION_BUFFER_SIZE];
2579 SlapReply rs = {REP_RESULT};
2580 Filter filter = { LDAP_FILTER_PRESENT };
2581 struct berval filterstr = BER_BVC("(objectclass=*)");
2583 cfb->cb_db.bd_info = backend_info( "ldif" );
2584 if ( !cfb->cb_db.bd_info )
2585 return 0; /* FIXME: eventually this will be a fatal error */
2587 if ( cfb->cb_db.bd_info->bi_db_init( &cfb->cb_db )) return 1;
2589 /* Mark that back-ldif type is in use */
2590 cfb->cb_db.bd_info->bi_nDB++;
2592 cfb->cb_db.be_suffix = be->be_suffix;
2593 cfb->cb_db.be_nsuffix = be->be_nsuffix;
2594 cfb->cb_db.be_rootdn = be->be_rootdn;
2595 cfb->cb_db.be_rootndn = be->be_rootndn;
2597 ber_str2bv( dir, 0, 1, &cfdir );
2602 argv[0] = "directory";
2603 argv[1] = (char *)dir;
2607 ct = config_find_keyword( c.be->be_cf_table, &c );
2611 if ( config_add_vals( ct, &c ))
2614 if ( backend_startup_one( &cfb->cb_db ))
2617 op = (Operation *)opbuf;
2618 connection_fake_init( &conn, op, cfb );
2620 filter.f_desc = slap_schema.si_ad_objectClass;
2622 op->o_tag = LDAP_REQ_SEARCH;
2624 op->ors_filter = &filter;
2625 op->ors_filterstr = filterstr;
2626 op->ors_scope = LDAP_SCOPE_SUBTREE;
2628 op->o_dn = be->be_rootdn;
2629 op->o_ndn = be->be_rootndn;
2631 op->o_req_dn = be->be_suffix[0];
2632 op->o_req_ndn = be->be_nsuffix[0];
2634 op->ors_tlimit = SLAP_NO_LIMIT;
2635 op->ors_slimit = SLAP_NO_LIMIT;
2637 op->ors_attrs = slap_anlist_all_attributes;
2638 op->ors_attrsonly = 0;
2640 op->o_callback = &cb;
2641 cb.sc_private = cfb;
2643 op->o_bd = &cfb->cb_db;
2644 op->o_bd->be_search( op, &rs );
2650 CfOcInfo_cmp( const void *c1, const void *c2 ) {
2651 const CfOcInfo *co1 = c1;
2652 const CfOcInfo *co2 = c2;
2654 return ber_bvcmp( co1->co_name, co2->co_name );
2658 config_register_schema(ConfigTable *ct, ConfigOCs *ocs) {
2662 i = init_config_attrs( ct );
2665 /* set up the objectclasses */
2666 i = init_config_ocs( ocs );
2669 for (i=0; ocs[i].def; i++) {
2671 co = ch_malloc( sizeof(CfOcInfo) );
2672 co->co_name = &(*ocs[i].oc)->soc_cname;
2674 co->co_type = ocs[i].cft;
2675 avl_insert( &CfOcTree, co, CfOcInfo_cmp, avl_dup_error );
2682 read_config(const char *fname, const char *dir) {
2686 /* Setup the config backend */
2687 be = backend_db_init( "config" );
2691 /* Setup the underlying back-ldif backend */
2692 if ( config_setup_ldif( be, dir ))
2696 /* If we read the config from back-ldif, nothing to do here */
2697 cfb = be->be_private;
2698 if ( cfb->cb_got_ldif )
2701 ber_str2bv( fname, 0, 1, &cf_prv.c_file );
2703 return read_config_file(fname, 0, NULL);
2707 config_back_bind( Operation *op, SlapReply *rs )
2709 if ( op->orb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op )) {
2710 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
2711 /* frontend sends result */
2712 return LDAP_SUCCESS;
2715 rs->sr_err = LDAP_INVALID_CREDENTIALS;
2716 send_ldap_result( op, rs );
2722 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
2726 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
2728 rs->sr_attrs = op->ors_attrs;
2729 rs->sr_entry = ce->ce_entry;
2730 rc = send_search_entry( op, rs );
2732 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
2733 if ( ce->ce_kids ) {
2734 rc = config_send( op, rs, ce->ce_kids, 1 );
2735 if ( rc ) return rc;
2738 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
2739 rc = config_send( op, rs, ce, 0 );
2747 static ConfigTable *
2748 config_find_table( CfOcInfo *co, AttributeDescription *ad )
2752 for (i=0; co->co_table[i].name; i++)
2753 if ( co->co_table[i].ad == ad )
2754 return &co->co_table[i];
2758 /* Sort the values in an X-ORDERED attribute.
2759 * If the values have no index, leave them in their given order.
2760 * If the values have indexes, sort them and then strip the index.
2761 * If some are indexed and some are not, return Error.
2763 * FIXME: This function probably belongs in the frontend somewhere,
2764 * like slap_mods_check.
2767 sort_vals( Attribute *a )
2770 int index = 0, noindex = 0;
2772 /* count attrs, look for index */
2773 for (i=0; a->a_vals[i].bv_val; i++) {
2774 if ( a->a_vals[i].bv_val[0] == '{' ) {
2777 ptr = strchr( a->a_vals[i].bv_val, '}' );
2778 if ( !ptr || !ptr[1] )
2779 return LDAP_INVALID_SYNTAX;
2781 return LDAP_INVALID_SYNTAX;
2785 return LDAP_INVALID_SYNTAX;
2790 int vals = i, *indexes, j, idx;
2791 struct berval tmp, ntmp;
2794 /* Strip index from normalized values */
2795 if ( !a->a_nvals || a->a_vals == a->a_nvals ) {
2796 a->a_nvals = ch_malloc( (vals+1)*sizeof(struct berval));
2797 for ( i=0; i<vals; i++ ) {
2798 ptr = strchr(a->a_vals[i].bv_val, '}') + 1;
2799 a->a_nvals[i].bv_len = a->a_vals[i].bv_len -
2800 (ptr - a->a_vals[i].bv_val);
2801 a->a_nvals[i].bv_val = ch_malloc( a->a_nvals[i].bv_len + 1);
2802 strcpy(a->a_nvals[i].bv_val, ptr );
2805 for ( i=0; i<vals; i++ ) {
2806 ptr = strchr(a->a_nvals[i].bv_val, '}') + 1;
2807 a->a_nvals[i].bv_len -= ptr - a->a_nvals[i].bv_val;
2808 strcpy(a->a_nvals[i].bv_val, ptr);
2812 indexes = ch_malloc( vals * sizeof(int) );
2813 for ( i=0; i<vals; i++)
2814 indexes[i] = atoi(a->a_vals[i].bv_val+1);
2816 /* Insertion sort */
2817 for ( i=1; i<vals; i++ ) {
2820 ntmp = a->a_nvals[i];
2822 while ((j > 0) && (indexes[j-1] > idx)) {
2823 indexes[j] = indexes[j-1];
2824 a->a_vals[j] = a->a_vals[j-1];
2825 a->a_nvals[j] = a->a_nvals[j-1];
2830 a->a_nvals[j] = ntmp;
2837 check_attr( ConfigTable *ct, ConfigArgs *ca, Attribute *a )
2841 if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED ) {
2842 rc = sort_vals( a );
2846 for ( i=0; a->a_nvals[i].bv_val; i++ ) {
2847 ca->line = a->a_nvals[i].bv_val;
2848 rc = config_parse_vals( ct, ca, i );
2855 /* Parse an LDAP entry into config directives */
2857 config_add_internal( CfBackInfo *cfb, Entry *e, SlapReply *rs )
2859 CfEntryInfo *ce, *last;
2860 CfOcInfo co, *coptr, **colst = NULL;
2861 Attribute *a, *oc_at, *type_attr;
2862 AttributeDescription *type_ad = NULL;
2864 ConfigArgs ca = {0};
2867 ConfigTable *ct, *type_ct = NULL;
2869 /* Make sure parent exists and entry does not */
2870 ce = config_find_base( cfb->cb_root, &e->e_nname, &last );
2872 return LDAP_ALREADY_EXISTS;
2874 dnParent( &e->e_nname, &pdn );
2876 /* If last is NULL, the new entry is the root/suffix entry,
2877 * otherwise last should be the parent.
2879 if ( last && !dn_match( &last->ce_entry->e_nname, &pdn )) {
2881 rs->sr_matched = last->ce_entry->e_name.bv_val;
2882 return LDAP_NO_SUCH_OBJECT;
2885 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
2886 if ( !oc_at ) return LDAP_OBJECT_CLASS_VIOLATION;
2888 /* count the objectclasses */
2889 for ( i=0; oc_at->a_nvals[i].bv_val; i++ );
2891 colst = (CfOcInfo **)ch_malloc( nocs * sizeof(CfOcInfo *));
2893 for ( i=0, j=0; i<nocs; i++) {
2894 co.co_name = &oc_at->a_nvals[i];
2895 coptr = avl_find( CfOcTree, &co, CfOcInfo_cmp );
2897 /* ignore non-config objectclasses. probably should be
2898 * an error, general data doesn't belong here.
2900 if ( !coptr ) continue;
2902 /* Ignore the root objectclass, it has no implementation.
2904 if ( coptr->co_type == Cft_Abstract ) continue;
2909 /* Only the root can be Cft_Global, everything else must
2910 * have a parent. Only limited nesting arrangements are allowed.
2912 switch( colst[0]->co_type ) {
2915 rc = LDAP_CONSTRAINT_VIOLATION;
2923 if ( !last || ( last->ce_type != Cft_Global &&
2924 last->ce_type != colst[0]->co_type )) {
2925 rc = LDAP_CONSTRAINT_VIOLATION;
2930 if ( !last || ( last->ce_type != Cft_Global &&
2931 last->ce_type != Cft_Database &&
2932 last->ce_type != colst[0]->co_type )) {
2933 rc = LDAP_CONSTRAINT_VIOLATION;
2939 /* Parse all the values and check for simple syntax errors before
2940 * performing any set actions.
2942 switch (colst[0]->co_type) {
2943 case Cft_Global: /* */
2948 if ( last->ce_type == Cft_Backend )
2949 ca.bi = last->ce_bi;
2951 type_ad = cfAd_backend;
2954 if ( last->ce_type == Cft_Database ) {
2955 ca.be = last->ce_be;
2957 type_ad = cfAd_database;
2958 /* dummy, just to get past check_attr */
2964 ca.be = last->ce_be;
2965 type_ad = cfAd_overlay;
2968 if ( !rs ) /* ignored */
2970 type_ad = cfAd_include;
2972 init_config_argv( &ca );
2974 type_attr = attr_find( e->e_attrs, type_ad );
2976 rc = LDAP_OBJECT_CLASS_VIOLATION;
2979 for ( i=0; i<nocs; i++ ) {
2980 type_ct = config_find_table( colst[i], type_ad );
2981 if ( type_ct ) break;
2984 rc = LDAP_OBJECT_CLASS_VIOLATION;
2987 rc = check_attr( type_ct, &ca, type_attr );
2988 if ( rc ) goto leave;
2990 for ( a=e->e_attrs; a; a=a->a_next ) {
2991 if ( a == type_attr || a == oc_at ) continue;
2993 for ( i=0; i<nocs; i++ ) {
2994 ct = config_find_table( colst[i], a->a_desc );
2997 if ( !ct ) continue; /* user data? */
2998 rc = check_attr( ct, &ca, a );
2999 if ( rc ) goto leave;
3002 /* Basic syntax checks are OK. Do the actual settings. */
3004 ca.line = type_attr->a_nvals[0].bv_val;
3005 rc = config_parse_add( type_ct, &ca, 0 );
3006 if ( rc ) goto leave;
3008 for ( a=e->e_attrs; a; a=a->a_next ) {
3009 if ( a == type_attr || a == oc_at ) continue;
3011 for ( i=0; i<nocs; i++ ) {
3012 ct = config_find_table( colst[i], a->a_desc );
3015 if ( !ct ) continue; /* user data? */
3016 for (i=0; a->a_nvals[i].bv_val; i++) {
3017 ca.line = a->a_nvals[i].bv_val;
3018 rc = config_parse_add( ct, &ca, i );
3019 if ( rc ) goto leave;
3022 ce = ch_calloc( 1, sizeof(CfEntryInfo) );
3023 ce->ce_entry = entry_dup( e );
3024 ce->ce_entry->e_private = ce;
3025 ce->ce_type = colst[0]->co_type;
3028 } else if ( last->ce_kids ) {
3031 for (c2=last->ce_kids; c2 && c2->ce_sibs; c2 = c2->ce_sibs);
3039 if ( colst ) ch_free( colst );
3043 /* Parse an LDAP entry into config directives, then store in underlying
3047 config_back_add( Operation *op, SlapReply *rs )
3050 CfEntryInfo *ce, *last;
3052 if ( !be_isroot( op ) ) {
3053 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3054 send_ldap_result( op, rs );
3057 cfb = (CfBackInfo *)op->o_bd->be_private;
3059 ldap_pvt_thread_pool_pause( &connection_pool );
3062 * 1) check for existence of entry
3063 * 2) perform internal add
3064 * 3) store entry in underlying database
3067 ldap_pvt_thread_pool_resume( &connection_pool );
3070 send_ldap_result( op, rs );
3075 config_back_modify( Operation *op, SlapReply *rs )
3078 CfEntryInfo *ce, *last;
3080 if ( !be_isroot( op ) ) {
3081 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3082 send_ldap_result( op, rs );
3085 cfb = (CfBackInfo *)op->o_bd->be_private;
3087 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
3090 rs->sr_matched = last->ce_entry->e_name.bv_val;
3091 rs->sr_err = LDAP_NO_SUCH_OBJECT;
3094 ldap_pvt_thread_pool_pause( &connection_pool );
3097 * 1) perform the Modify on the cached Entry.
3098 * 2) verify that the Entry still satisfies the schema.
3099 * 3) perform the individual config operations.
3100 * 4) store Modified entry in underlying LDIF backend.
3102 ldap_pvt_thread_pool_resume( &connection_pool );
3104 send_ldap_result( op, rs );
3109 config_back_search( Operation *op, SlapReply *rs )
3112 CfEntryInfo *ce, *last;
3115 if ( !be_isroot( op ) ) {
3116 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
3117 send_ldap_result( op, rs );
3120 cfb = (CfBackInfo *)op->o_bd->be_private;
3122 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
3125 rs->sr_matched = last->ce_entry->e_name.bv_val;
3126 rs->sr_err = LDAP_NO_SUCH_OBJECT;
3129 switch ( op->ors_scope ) {
3130 case LDAP_SCOPE_BASE:
3131 case LDAP_SCOPE_SUBTREE:
3132 config_send( op, rs, ce, 0 );
3135 case LDAP_SCOPE_ONELEVEL:
3136 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
3137 config_send( op, rs, ce, 1 );
3142 rs->sr_err = LDAP_SUCCESS;
3144 send_ldap_result( op, rs );
3149 config_alloc_entry( struct berval *pdn, struct berval *rdn )
3151 Entry *e = ch_calloc( 1, sizeof(Entry) );
3152 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
3155 build_new_dn( &e->e_name, pdn, rdn, NULL );
3156 ber_dupbv( &e->e_nname, &e->e_name );
3165 config_build_entry( ConfigArgs *c, Entry *e, ObjectClass *oc,
3166 struct berval *rdn, ConfigTable *ct, int table )
3168 struct berval vals[2];
3169 struct berval ad_name;
3170 AttributeDescription *ad = NULL;
3174 char textbuf[SLAP_TEXT_BUFLEN];
3175 size_t textlen = sizeof(textbuf);
3179 BER_BVZERO( &vals[1] );
3181 vals[0] = oc->soc_cname;
3182 attr_merge(e, slap_schema.si_ad_objectClass, vals, NULL );
3183 ptr = strchr(rdn->bv_val, '=');
3184 ad_name.bv_val = rdn->bv_val;
3185 ad_name.bv_len = ptr - rdn->bv_val;
3186 rc = slap_bv2ad( &ad_name, &ad, &text );
3190 vals[0].bv_val = ptr+1;
3191 vals[0].bv_len = rdn->bv_len - (vals[0].bv_val - rdn->bv_val);
3192 attr_merge(e, ad, vals, NULL );
3194 for (at=oc->soc_required; at && *at; at++) {
3195 /* Skip the naming attr */
3196 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
3198 for (i=0;ct[i].name;i++) {
3199 if (ct[i].ad == (*at)->sat_ad) {
3200 rc = config_get_vals(&ct[i], c);
3201 if (rc == LDAP_SUCCESS) {
3202 attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
3203 ber_bvarray_free( c->rvalue_nvals );
3204 ber_bvarray_free( c->rvalue_vals );
3211 for (at=oc->soc_allowed; at && *at; at++) {
3212 /* Skip the naming attr */
3213 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
3215 for (i=0;ct[i].name;i++) {
3216 if (ct[i].ad == (*at)->sat_ad) {
3217 rc = config_get_vals(&ct[i], c);
3218 if (rc == LDAP_SUCCESS) {
3219 attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
3220 ber_bvarray_free( c->rvalue_nvals );
3221 ber_bvarray_free( c->rvalue_vals );
3229 if ( table == BI_TABLE )
3230 ct = c->bi->bi_cf_table;
3232 ct = c->be->be_cf_table;
3233 for (;ct && ct->name;ct++) {
3234 if (!ct->ad) continue;
3235 rc = config_get_vals(ct, c);
3236 if (rc == LDAP_SUCCESS) {
3237 attr_merge(e, ct->ad, c->rvalue_vals, c->rvalue_nvals);
3241 oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
3242 rc = structural_class(oc_at->a_vals, vals, NULL, &text, textbuf, textlen);
3243 BER_BVZERO( &vals[1] );
3244 attr_merge(e, slap_schema.si_ad_structuralObjectClass, vals, NULL );
3249 static CfEntryInfo *
3250 config_build_includes( ConfigArgs *c, Entry *parent,
3251 Operation *op, SlapReply *rs )
3255 ConfigFile *cf = (ConfigFile *)c->line;
3256 CfEntryInfo *ce, *ceparent, *ceprev;
3258 ceparent = parent->e_private;
3260 for (i=0; cf; cf=cf->c_sibs, i++) {
3261 c->value_dn.bv_val = c->log;
3262 c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=include{%d}", i);
3263 e = config_alloc_entry( &parent->e_nname, &c->value_dn );
3264 c->line = (char *)cf;
3265 config_build_entry( c, e, cfOc_include, &c->value_dn,
3266 c->bi->bi_cf_table, NO_TABLE );
3268 op->o_bd->be_add( op, rs );
3270 ce->ce_type = Cft_Include;
3272 if ( !ceparent->ce_kids ) {
3273 ceparent->ce_kids = ce;
3275 ceprev->ce_sibs = ce;
3279 c->line = (char *)cf->c_kids;
3280 config_build_includes( c, e, op, rs );
3287 config_back_db_open( BackendDB *be )
3289 CfBackInfo *cfb = be->be_private;
3292 CfEntryInfo *ce, *ceparent, *ceprev;
3298 Connection conn = {0};
3299 char opbuf[OPERATION_BUFFER_SIZE];
3301 slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
3302 SlapReply rs = {REP_RESULT};
3304 /* If we read the config from back-ldif, nothing to do here */
3305 if ( cfb->cb_got_ldif )
3308 op = (Operation *)opbuf;
3309 connection_fake_init( &conn, op, cfb );
3311 op->o_dn = be->be_rootdn;
3312 op->o_ndn = be->be_rootndn;
3314 op->o_tag = LDAP_REQ_ADD;
3315 op->o_callback = &cb;
3316 op->o_bd = &cfb->cb_db;
3318 /* create root of tree */
3320 e = config_alloc_entry( NULL, &rdn );
3325 c.line = (char *)cfb->cb_config;
3326 ct = c.bi->bi_cf_table;
3327 config_build_entry( &c, e, cfOc_global, &rdn, ct, NO_TABLE );
3329 op->o_bd->be_add( op, &rs );
3330 ce->ce_type = Cft_Global;
3336 /* Create schema nodes... cn=schema will contain the hardcoded core
3337 * schema, read-only. Child objects will contain runtime loaded schema
3341 /* Create includeFile nodes... */
3342 if ( cfb->cb_config->c_kids ) {
3343 c.line = (char *)cfb->cb_config->c_kids;
3344 ceprev = config_build_includes( &c, parent, op, &rs );
3347 /* Create backend nodes. Skip if they don't provide a cf_table.
3348 * There usually aren't any of these.
3353 for (i=0; i<nBackendInfo; i++, bi++) {
3354 if (!bi->bi_cf_table) continue;
3355 if (!bi->bi_private) continue;
3358 rdn.bv_len = sprintf(rdn.bv_val, "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
3359 e = config_alloc_entry( &parent->e_nname, &rdn );
3361 ce->ce_type = Cft_Backend;
3364 config_build_entry( &c, e, cfOc_backend, &rdn, ct, BI_TABLE );
3366 op->o_bd->be_add( op, &rs );
3367 if ( !ceparent->ce_kids ) {
3368 ceparent->ce_kids = ce;
3370 ceprev->ce_sibs = ce;
3375 /* Create database nodes... */
3376 for (i=0; i<nBackendDB; i++) {
3377 slap_overinfo *oi = NULL;
3381 bptr = &backendDB[i];
3383 if ( overlay_is_over( bptr )) {
3384 oi = bptr->bd_info->bi_private;
3390 rdn.bv_len = sprintf(rdn.bv_val, "%s={%0x}%s", cfAd_database->ad_cname.bv_val,
3392 e = config_alloc_entry( &parent->e_nname, &rdn );
3396 ce->ce_type = Cft_Database;
3399 config_build_entry( &c, e, cfOc_database, &rdn, ct, BE_TABLE );
3401 op->o_bd->be_add( op, &rs );
3402 if ( !ceparent->ce_kids ) {
3403 ceparent->ce_kids = ce;
3405 ceprev->ce_sibs = ce;
3408 /* Iterate through overlays */
3412 CfEntryInfo *opar = ce, *oprev = NULL;
3415 for (j=0,on=oi->oi_list; on; j++,on=on->on_next) {
3417 rdn.bv_len = sprintf(rdn.bv_val, "%s={%0x}%s",
3418 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
3419 oe = config_alloc_entry( &e->e_nname, &rdn );
3423 ce->ce_type = Cft_Overlay;
3426 config_build_entry( &c, oe, cfOc_overlay, &rdn, ct, BI_TABLE );
3428 op->o_bd->be_add( op, &rs );
3429 if ( !opar->ce_kids ) {
3432 oprev->ce_sibs = ce;
3443 config_back_db_destroy( Backend *be )
3445 free( be->be_private );
3450 config_back_db_init( Backend *be )
3455 cfb = ch_calloc( 1, sizeof(CfBackInfo));
3456 cfb->cb_config = &cf_prv;
3458 be->be_private = cfb;
3460 ber_dupbv( &be->be_rootdn, &config_rdn );
3461 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
3462 ber_dupbv( &dn, &be->be_rootdn );
3463 ber_bvarray_add( &be->be_suffix, &dn );
3464 ber_dupbv( &dn, &be->be_rootdn );
3465 ber_bvarray_add( &be->be_nsuffix, &dn );
3467 /* Hide from namingContexts */
3468 SLAP_BFLAGS(be) |= SLAP_BFLAG_CONFIG;
3475 AttributeDescription **desc;
3476 AttributeDescription *sub;
3478 { "attribute", NULL, NULL },
3479 { "backend", &cfAd_backend, NULL },
3480 { "database", &cfAd_database, NULL },
3481 { "ditcontentrule", NULL, NULL },
3482 { "include", &cfAd_include, NULL },
3483 { "objectclass", NULL, NULL },
3484 { "overlay", &cfAd_overlay, NULL },
3485 { NULL, NULL, NULL }
3489 * add / delete: all types that may be added or deleted must use an
3490 * X-ORDERED attributeType for their RDN. Adding and deleting entries
3491 * should automatically renumber the index of any siblings as needed,
3492 * so that no gaps in the numbering sequence exist after the add/delete
3494 * What can be added:
3496 * backend objects for backend-specific config directives
3500 * delete: probably no support this time around.
3502 * modrdn: generally not done. Will be invoked automatically by add/
3503 * delete to update numbering sequence. Perform as an explicit operation
3504 * so that the renumbering effect may be replicated. Subtree rename must
3505 * be supported, since renumbering a database will affect all its child
3508 * modify: must be fully supported.
3512 config_back_initialize( BackendInfo *bi )
3514 ConfigTable *ct = config_back_cf_table;
3523 bi->bi_db_init = config_back_db_init;
3524 bi->bi_db_config = 0;
3525 bi->bi_db_open = config_back_db_open;
3526 bi->bi_db_close = 0;
3527 bi->bi_db_destroy = config_back_db_destroy;
3529 bi->bi_op_bind = config_back_bind;
3530 bi->bi_op_unbind = 0;
3531 bi->bi_op_search = config_back_search;
3532 bi->bi_op_compare = 0;
3533 bi->bi_op_modify = config_back_modify;
3534 bi->bi_op_modrdn = 0;
3536 bi->bi_op_delete = 0;
3537 bi->bi_op_abandon = 0;
3539 bi->bi_extended = 0;
3541 bi->bi_chk_referrals = 0;
3543 bi->bi_connection_init = 0;
3544 bi->bi_connection_destroy = 0;
3547 for (i=0; OidMacros[i].name; i++ ) {
3548 argv[1] = OidMacros[i].name;
3549 argv[2] = OidMacros[i].oid;
3550 parse_oidm( "slapd", i, 3, argv );
3553 bi->bi_cf_table = ct;
3555 i = config_register_schema( ct, cf_ocs );
3558 /* set up the notable AttributeDescriptions */
3559 ads[0].sub = slap_schema.si_ad_attributeTypes;
3560 ads[3].sub = slap_schema.si_ad_ditContentRules;
3561 ads[5].sub = slap_schema.si_ad_objectClasses;
3564 for (;ct->name;ct++) {
3565 if (strcmp(ct->name, ads[i].name)) continue;
3567 ct->ad = ads[i].sub;
3569 *ads[i].desc = ct->ad;
3572 if (!ads[i].name) break;