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 #define CONFIG_DN "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 CfEntryInfo {
60 struct CfEntryInfo *ce_sibs;
61 struct CfEntryInfo *ce_kids;
68 ConfigFile *cb_config;
72 /* These do nothing in slapd, they're kept only to make them
75 static char *replica_pidFile, *replica_argsFile;
76 static int replicationInterval;
78 static char *passwd_salt;
79 static char *logfileName;
80 static BerVarray authz_rewrites;
82 static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
85 static ObjectClass *cfOc_global, *cfOc_backend, *cfOc_database,
86 *cfOc_include, *cfOc_overlay;
88 static ConfigFile cf_prv, *cfn = &cf_prv;
90 static int add_syncrepl LDAP_P(( Backend *, char **, int ));
91 static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
92 static void syncrepl_unparse LDAP_P (( syncinfo_t *, struct berval *));
94 static ConfigDriver config_fname;
95 static ConfigDriver config_generic;
96 static ConfigDriver config_search_base;
97 static ConfigDriver config_passwd_hash;
98 static ConfigDriver config_schema_dn;
99 static ConfigDriver config_sizelimit;
100 static ConfigDriver config_timelimit;
101 static ConfigDriver config_limits;
102 static ConfigDriver config_overlay;
103 static ConfigDriver config_suffix;
104 static ConfigDriver config_deref_depth;
105 static ConfigDriver config_rootdn;
106 static ConfigDriver config_rootpw;
107 static ConfigDriver config_restrict;
108 static ConfigDriver config_allows;
109 static ConfigDriver config_disallows;
110 static ConfigDriver config_requires;
111 static ConfigDriver config_security;
112 static ConfigDriver config_referral;
113 static ConfigDriver config_loglevel;
114 static ConfigDriver config_syncrepl;
115 static ConfigDriver config_replica;
116 static ConfigDriver config_updatedn;
117 static ConfigDriver config_updateref;
118 static ConfigDriver config_include;
120 static ConfigDriver config_tls_option;
121 static ConfigDriver config_tls_config;
170 static OidRec OidMacros[] = {
171 /* OpenLDAProot:666.11.1 */
172 { "OLcfg", "1.3.6.1.4.1.4203.666.11.1" },
173 { "OLcfgAt", "OLcfg:3" },
174 { "OLcfgOc", "OLcfg:4" },
175 { "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
176 { "OMsInteger", "OMsyn:2" },
177 { "OMsBoolean", "OMsyn:7" },
178 { "OMsDN", "OMsyn:12" },
179 { "OMsDirectoryString", "OMsyn:15" },
180 { "OMsOctetString", "OMsyn:40" },
184 /* alphabetical ordering */
186 ConfigTable config_back_cf_table[] = {
187 /* This attr is read-only */
188 { "", "", 0, 0, 0, ARG_MAGIC,
189 &config_fname, "( OLcfgAt:78 NAME 'olcConfigFile' "
190 "DESC 'File for slapd configuration directives' "
191 "EQUALITY caseIgnoreMatch "
192 "SYNTAX OMsDirectoryString )", NULL, NULL },
193 { "access", NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
194 &config_generic, "( OLcfgAt:1 NAME 'olcAccess' "
195 "DESC 'Access Control List' "
196 "EQUALITY caseIgnoreMatch "
197 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
198 { "allows", "features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
199 &config_allows, "( OLcfgAt:2 NAME 'olcAllows' "
200 "DESC 'Allowed set of deprecated features' "
201 "EQUALITY caseIgnoreMatch "
202 "SYNTAX OMsDirectoryString )", NULL, NULL },
203 { "argsfile", "file", 2, 2, 0, ARG_STRING,
204 &slapd_args_file, "( OLcfgAt:3 NAME 'olcArgsFile' "
205 "DESC 'File for slapd command line options' "
206 "EQUALITY caseIgnoreMatch "
207 "SYNTAX OMsDirectoryString )", NULL, NULL },
208 /* Use standard 'attributeTypes' attr */
209 { "attribute", "attribute", 2, 0, 9, ARG_PAREN|ARG_MAGIC|CFG_ATTR,
210 &config_generic, NULL, NULL, NULL },
211 { "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
212 &config_generic, "( OLcfgAt:5 NAME 'olcAttributeOptions' "
213 "EQUALITY caseIgnoreMatch "
214 "SYNTAX OMsDirectoryString )", NULL, NULL },
215 { "authid-rewrite", NULL, 2, 0, 0,
216 #ifdef SLAP_AUTH_REWRITE
217 ARG_MAGIC|CFG_REWRITE, &config_generic,
221 "( OLcfgAt:6 NAME 'olcAuthIDRewrite' "
222 "EQUALITY caseIgnoreMatch "
223 "SYNTAX OMsDirectoryString )", NULL, NULL },
224 { "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
225 &config_generic, "( OLcfgAt:7 NAME 'olcAuthzPolicy' "
226 "EQUALITY caseIgnoreMatch "
227 "SYNTAX OMsDirectoryString )", NULL, NULL },
228 { "authz-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
229 &config_generic, "( OLcfgAt:8 NAME 'olcAuthzRegexp' "
230 "EQUALITY caseIgnoreMatch "
231 "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
232 { "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
233 &config_generic, "( OLcfgAt:9 NAME 'olcBackend' "
234 "DESC 'A type of backend' "
235 "EQUALITY caseIgnoreMatch "
236 "SYNTAX OMsDirectoryString )", NULL, NULL },
237 { "concurrency", "level", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_CONCUR,
238 &config_generic, "( OLcfgAt:10 NAME 'olcConcurrency' "
239 "SYNTAX OMsInteger )", NULL, NULL },
240 { "conn_max_pending", "max", 2, 2, 0, ARG_LONG,
241 &slap_conn_max_pending, "( OLcfgAt:11 NAME 'olcConnMaxPending' "
242 "SYNTAX OMsInteger )", NULL, NULL },
243 { "conn_max_pending_auth", "max", 2, 2, 0, ARG_LONG,
244 &slap_conn_max_pending_auth, "( OLcfgAt:12 NAME 'olcConnMaxPendingAuth' "
245 "SYNTAX OMsInteger )", NULL, NULL },
246 { "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
247 &config_generic, "( OLcfgAt:13 NAME 'olcDatabase' "
248 "DESC 'The backend type for a database instance' "
249 "SUP olcBackend )", NULL, NULL },
250 { "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_MAGIC,
251 &config_search_base, "( OLcfgAt:14 NAME 'olcDefaultSearchBase' "
252 "SYNTAX OMsDN )", NULL, NULL },
253 { "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
254 &config_disallows, "( OLcfgAt:15 NAME 'olcDisallows' "
255 "EQUALITY caseIgnoreMatch "
256 "SYNTAX OMsDirectoryString )", NULL, NULL },
257 /* use standard schema */
258 { "ditcontentrule", NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT,
259 &config_generic, NULL, NULL, NULL },
260 { "gentlehup", "on|off", 2, 2, 0,
262 ARG_ON_OFF, &global_gentlehup,
266 "( OLcfgAt:17 NAME 'olcGentleHUP' "
267 "SYNTAX OMsBoolean )", NULL, NULL },
268 { "idletimeout", "timeout", 2, 2, 0, ARG_INT,
269 &global_idletimeout, "( OLcfgAt:18 NAME 'olcIdleTimeout' "
270 "SYNTAX OMsInteger )", NULL, NULL },
271 /* XXX -- special case? */
272 { "include", "file", 2, 2, 0, ARG_MAGIC,
273 &config_include, "( OLcfgAt:19 NAME 'olcInclude' "
274 "SUP labeledURI )", NULL, NULL },
275 { "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
276 &config_generic, "( OLcfgAt:20 NAME 'olcIndexSubstrIfMinLen' "
277 "SYNTAX OMsInteger )", NULL, NULL },
278 { "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
279 &config_generic, "( OLcfgAt:21 NAME 'olcIndexSubstrIfMaxLen' "
280 "SYNTAX OMsInteger )", NULL, NULL },
281 { "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
282 &index_substr_any_len, "( OLcfgAt:22 NAME 'olcIndexSubstrAnyLen' "
283 "SYNTAX OMsInteger )", NULL, NULL },
284 { "index_substr_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
285 &index_substr_any_step, "( OLcfgAt:23 NAME 'olcIndexSubstrAnyStep' "
286 "SYNTAX OMsInteger )", NULL, NULL },
287 { "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
288 &config_generic, "( OLcfgAt:24 NAME 'olcLastMod' "
289 "SYNTAX OMsBoolean )", NULL, NULL },
290 { "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
291 &config_generic, "( OLcfgAt:25 NAME 'olcLimits' "
292 "SYNTAX OMsDirectoryString )", NULL, NULL },
293 { "localSSF", "ssf", 2, 2, 0, ARG_LONG,
294 &local_ssf, "( OLcfgAt:26 NAME 'olcLocalSSF' "
295 "SYNTAX OMsInteger )", NULL, NULL },
296 { "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
297 &config_generic, "( OLcfgAt:27 NAME 'olcLogFile' "
298 "SYNTAX OMsDirectoryString )", NULL, NULL },
299 { "loglevel", "level", 2, 0, 0, ARG_MAGIC,
300 &config_loglevel, "( OLcfgAt:28 NAME 'olcLogLevel' "
301 "SYNTAX OMsDirectoryString )", NULL, NULL },
302 { "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
303 &config_generic, "( OLcfgAt:29 NAME 'olcMaxDerefDepth' "
304 "SYNTAX OMsInteger )", NULL, NULL },
305 { "moduleload", "file", 2, 0, 0,
307 ARG_MAGIC|CFG_MODLOAD, &config_generic,
311 "( OLcfgAt:30 NAME 'olcModuleLoad' "
312 "SYNTAX OMsDirectoryString )", NULL, NULL },
313 { "modulepath", "path", 2, 2, 0,
315 ARG_MAGIC|CFG_MODPATH, &config_generic,
319 "( OLcfgAt:31 NAME 'olcModulePath' "
320 "SYNTAX OMsDirectoryString )", NULL, NULL },
321 /* use standard schema */
322 { "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC,
323 &config_generic, NULL, NULL, NULL },
324 { "objectidentifier", NULL, 0, 0, 0, ARG_MAGIC|CFG_OID,
325 &config_generic, "( OLcfgAt:33 NAME 'olcObjectIdentifier' "
326 "SYNTAX OMsDirectoryString )", NULL, NULL },
327 { "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
328 &config_overlay, "( OLcfgAt:34 NAME 'olcOverlay' "
329 "SUP olcDatabase )", NULL, NULL },
330 { "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
331 &config_generic, "( OLcfgAt:35 NAME 'olcPasswordCryptSaltFormat' "
332 "SYNTAX OMsDirectoryString )", NULL, NULL },
333 { "password-hash", "hash", 2, 2, 0, ARG_MAGIC,
334 &config_passwd_hash, "( OLcfgAt:36 NAME 'olcPasswordHash' "
335 "SYNTAX OMsDirectoryString )", NULL, NULL },
336 { "pidfile", "file", 2, 2, 0, ARG_STRING,
337 &slapd_pid_file, "( OLcfgAt:37 NAME 'olcPidFile' "
338 "SYNTAX OMsDirectoryString )", NULL, NULL },
339 { "plugin", NULL, 0, 0, 0,
341 ARG_MAGIC|CFG_PLUGIN, &config_generic,
345 "( OLcfgAt:38 NAME 'olcPlugin' "
346 "SYNTAX OMsDirectoryString )", NULL, NULL },
347 { "pluginlog", "filename", 2, 2, 0,
349 ARG_STRING, &slapi_log_file,
353 "( OLcfgAt:39 NAME 'olcPluginLogFile' "
354 "SYNTAX OMsDirectoryString )", NULL, NULL },
355 { "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
356 &config_generic, "( OLcfgAt:40 NAME 'olcReadOnly' "
357 "SYNTAX OMsBoolean )", NULL, NULL },
358 { "referral", "url", 2, 2, 0, ARG_MAGIC,
359 &config_referral, "( OLcfgAt:41 NAME 'olcReferral' "
360 "SUP labeledURI )", NULL, NULL },
361 { "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
362 &config_replica, "( OLcfgAt:42 NAME 'olcReplica' "
363 "SUP labeledURI )", NULL, NULL },
364 { "replica-argsfile", NULL, 0, 0, 0, ARG_STRING,
365 &replica_argsFile, "( OLcfgAt:43 NAME 'olcReplicaArgsFile' "
366 "SYNTAX OMsDirectoryString )", NULL, NULL },
367 { "replica-pidfile", NULL, 0, 0, 0, ARG_STRING,
368 &replica_pidFile, "( OLcfgAt:44 NAME 'olcReplicaPidFile' "
369 "SYNTAX OMsDirectoryString )", NULL, NULL },
370 { "replicationInterval", NULL, 0, 0, 0, ARG_INT,
371 &replicationInterval, "( OLcfgAt:45 NAME 'olcReplicationInterval' "
372 "SYNTAX OMsInteger )", NULL, NULL },
373 { "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLOG,
374 &config_generic, "( OLcfgAt:46 NAME 'olcReplogFile' "
375 "SYNTAX OMsDirectoryString )", NULL, NULL },
376 { "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
377 &config_requires, "( OLcfgAt:47 NAME 'olcRequires' "
378 "SYNTAX OMsDirectoryString )", NULL, NULL },
379 { "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
380 &config_restrict, "( OLcfgAt:48 NAME 'olcRestrict' "
381 "SYNTAX OMsDirectoryString )", NULL, NULL },
382 { "reverse-lookup", "on|off", 2, 2, 0,
383 #ifdef SLAPD_RLOOKUPS
384 ARG_ON_OFF, &use_reverse_lookup,
388 "( OLcfgAt:49 NAME 'olcReverseLookup' "
389 "SYNTAX OMsBoolean )", NULL, NULL },
390 { "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
391 &config_rootdn, "( OLcfgAt:50 NAME 'olcRootDN' "
392 "SYNTAX OMsDN )", NULL, NULL },
393 { "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
394 &config_generic, "( OLcfgAt:51 NAME 'olcRootDSE' "
395 "SYNTAX OMsDirectoryString )", NULL, NULL },
396 { "rootpw", "password", 2, 2, 0, ARG_STRING|ARG_DB|ARG_MAGIC,
397 &config_rootpw, "( OLcfgAt:52 NAME 'olcRootPW' "
398 "SYNTAX OMsOctetString )", NULL, NULL },
399 { "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
400 &config_generic, NULL, NULL, NULL },
401 { "sasl-host", "host", 2, 2, 0,
402 #ifdef HAVE_CYRUS_SASL
403 ARG_STRING|ARG_UNIQUE, &global_host,
407 "( OLcfgAt:53 NAME 'olcSaslHost' "
408 "SYNTAX OMsDirectoryString )", NULL, NULL },
409 { "sasl-realm", "realm", 2, 2, 0,
410 #ifdef HAVE_CYRUS_SASL
411 ARG_STRING|ARG_UNIQUE, &global_realm,
415 "( OLcfgAt:54 NAME 'olcSaslRealm' "
416 "SYNTAX OMsDirectoryString )", NULL, NULL },
417 { "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
418 &config_generic, NULL, NULL, NULL },
419 { "sasl-secprops", "properties", 2, 2, 0,
420 #ifdef HAVE_CYRUS_SASL
421 ARG_MAGIC|CFG_SASLSECP, &config_generic,
425 "( OLcfgAt:56 NAME 'olcSaslSecProps' "
426 "SYNTAX OMsDirectoryString )", NULL, NULL },
427 { "saslRegexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
428 &config_generic, NULL, NULL, NULL },
429 { "schemacheck", "on|off", 2, 2, 0, ARG_ON_OFF|ARG_MAGIC|CFG_CHECK,
430 &config_generic, "( OLcfgAt:57 NAME 'olcSchemaCheck' "
431 "SYNTAX OMsBoolean )", NULL, NULL },
432 { "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_MAGIC,
433 &config_schema_dn, "( OLcfgAt:58 NAME 'olcSchemaDN' "
434 "SYNTAX OMsDN )", NULL, NULL },
435 { "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
436 &config_security, "( OLcfgAt:59 NAME 'olcSecurity' "
437 "SYNTAX OMsDirectoryString )", NULL, NULL },
438 { "sizelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_SIZE,
439 &config_sizelimit, "( OLcfgAt:60 NAME 'olcSizeLimit' "
440 "SYNTAX OMsInteger )", NULL, NULL },
441 { "sockbuf_max_incoming", "max", 2, 2, 0, ARG_LONG,
442 &sockbuf_max_incoming, "( OLcfgAt:61 NAME 'olcSockbufMaxIncoming' "
443 "SYNTAX OMsInteger )", NULL, NULL },
444 { "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_LONG,
445 &sockbuf_max_incoming_auth, "( OLcfgAt:62 NAME 'olcSockbufMaxIncomingAuth' "
446 "SYNTAX OMsInteger )", NULL, NULL },
447 { "srvtab", "file", 2, 2, 0,
448 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
449 ARG_STRING, &ldap_srvtab,
453 "( OLcfgAt:63 NAME 'olcSrvtab' "
454 "SYNTAX OMsDirectoryString )", NULL, NULL },
455 { "suffix", "suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
456 &config_suffix, "( OLcfgAt:64 NAME 'olcSuffix' "
457 "SYNTAX OMsDN )", NULL, NULL },
458 { "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
459 &config_syncrepl, "( OLcfgAt:65 NAME 'olcSyncrepl' "
460 "SYNTAX OMsDirectoryString )", NULL, NULL },
461 { "threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_THREADS,
462 &config_generic, "( OLcfgAt:66 NAME 'olcThreads' "
463 "SYNTAX OMsInteger )", NULL, NULL },
464 { "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_TIME,
465 &config_timelimit, "( OLcfgAt:67 NAME 'olcTimeLimit' "
466 "SYNTAX OMsInteger )", NULL, NULL },
467 { "TLSCACertificateFile", NULL, 0, 0, 0,
469 CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
473 "( OLcfgAt:68 NAME 'olcTLSCACertificateFile' "
474 "SYNTAX OMsDirectoryString )", NULL, NULL },
475 { "TLSCACertificatePath", NULL, 0, 0, 0,
477 CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
481 "( OLcfgAt:69 NAME 'olcTLSCACertificatePath' "
482 "SYNTAX OMsDirectoryString )", NULL, NULL },
483 { "TLSCertificateFile", NULL, 0, 0, 0,
485 CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
489 "( OLcfgAt:70 NAME 'olcTLSCertificateFile' "
490 "SYNTAX OMsDirectoryString )", NULL, NULL },
491 { "TLSCertificateKeyFile", NULL, 0, 0, 0,
493 CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
497 "( OLcfgAt:71 NAME 'olcTLSCertificateKeyFile' "
498 "SYNTAX OMsDirectoryString )", NULL, NULL },
499 { "TLSCipherSuite", NULL, 0, 0, 0,
501 CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
505 "( OLcfgAt:72 NAME 'olcTLSCipherSuite' "
506 "SYNTAX OMsDirectoryString )", NULL, NULL },
507 { "TLSCRLCheck", NULL, 0, 0, 0,
509 CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
513 "( OLcfgAt:73 NAME 'olcTLSCRLCheck' "
514 "SYNTAX OMsDirectoryString )", NULL, NULL },
515 { "TLSRandFile", NULL, 0, 0, 0,
517 CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
521 "( OLcfgAt:74 NAME 'olcTLSRandFile' "
522 "SYNTAX OMsDirectoryString )", NULL, NULL },
523 { "TLSVerifyClient", NULL, 0, 0, 0,
525 CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
529 "( OLcfgAt:75 NAME 'olcTLSVerifyClient' "
530 "SYNTAX OMsDirectoryString )", NULL, NULL },
531 { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
532 NULL, NULL, NULL, NULL },
533 { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_MAGIC,
534 &config_updatedn, "( OLcfgAt:76 NAME 'olcUpdateDN' "
535 "SYNTAX OMsDN )", NULL, NULL },
536 { "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
537 &config_updateref, "( OLcfgAt:77 NAME 'olcUpdateRef' "
538 "SUP labeledURI )", NULL, NULL },
539 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
540 NULL, NULL, NULL, NULL }
543 static ConfigOCs cf_ocs[] = {
546 "DESC 'OpenLDAP configuration object' "
548 "MAY ( cn $ olcConfigFile ) )", NULL },
551 "DESC 'OpenLDAP Global configuration options' "
552 "SUP olcConfig STRUCTURAL "
553 "MAY ( olcAccess $ olcAllows $ olcArgsFile $ olcAttributeOptions $ "
554 "olcAuthIDRewrite $ olcAuthzPolicy $ olcAuthzRegexp $ "
555 "olcConcurrency $ olcConnMaxPending $ olcConnMaxPendingAuth $ "
556 "olcDefaultSearchBase $ olcDisallows $ olcGentleHUP $ "
557 "olcIdleTimeout $ olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
558 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcLocalSSF $ "
559 "olcLogLevel $ olcModuleLoad $ olcModulePath $ olcObjectIdentifier $ "
560 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
561 "olcPlugin $ olcPluginLogFile $ olcReadOnly $ olcReferral $ "
562 "olcReplicaPidFile $ olcReplicaArgsFile $ olcReplicationInterval $ "
563 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
564 "olcRootDSE $ olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
565 "olcSchemaCheck $ olcSchemaDN $ olcSecurity $ olcSizeLimit $ "
566 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ olcSrvtab $ "
567 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
568 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
569 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
570 "olcTLSRandFile $ olcTLSVerifyClient ) )", &cfOc_global },
572 "NAME 'olcBackendConfig' "
573 "DESC 'OpenLDAP Backend-specific options' "
574 "SUP olcConfig STRUCTURAL "
575 "MAY ( olcBackend ) )", &cfOc_backend },
577 "NAME 'olcDatabaseConfig' "
578 "DESC 'OpenLDAP Database-specific options' "
579 "SUP olcConfig STRUCTURAL "
580 "MAY ( olcAccess $ olcDatabase $ olcLastMod $ olcLimits $ "
581 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
582 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
583 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSuffix $ olcSyncrepl $ "
584 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )", &cfOc_database },
586 "NAME 'olcIncludeFile' "
587 "DESC 'OpenLDAP configuration include file' "
588 "SUP olcConfig STRUCTURAL "
589 "MAY ( olcInclude $ olcModuleLoad $ olcModulePath $ olcRootDSE ) )",
592 "NAME 'olcOverlayConfig' "
593 "DESC 'OpenLDAP Overlay-specific options' "
594 "SUP olcConfig STRUCTURAL "
595 "MAY ( olcOverlay ) )", &cfOc_overlay },
600 config_generic(ConfigArgs *c) {
608 c->value_int = ldap_pvt_thread_get_concurrency();
611 c->value_int = connection_pool_max;
615 c->value_string = ch_strdup( passwd_salt );
620 if ( c->be->be_limits ) {
625 for ( i=0; c->be->be_limits[i]; i++ ) {
626 bv.bv_len = sprintf( buf, "{%d}", i );
627 bv.bv_val = buf+bv.bv_len;
628 limits_unparse( c->be->be_limits[i], &bv );
629 bv.bv_len += bv.bv_val - buf;
631 value_add_one( &c->rvalue_vals, &bv );
634 if ( !c->rvalue_vals ) rc = 1;
637 c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_OP_WRITES) != 0;
640 c->value_string = ch_strdup( slap_sasl_getpolicy());
643 slap_sasl_regexp_unparse( &c->rvalue_vals );
644 if ( !c->rvalue_vals ) rc = 1;
646 #ifdef HAVE_CYRUS_SASL
648 struct berval bv = BER_BVNULL;
649 slap_sasl_secprops_unparse( &bv );
650 if ( !BER_BVISNULL( &bv )) {
651 ber_bvarray_add( &c->rvalue_vals, &bv );
659 c->value_int = c->be->be_max_deref_depth;
662 oidm_unparse( &c->rvalue_vals );
663 if ( !c->rvalue_vals )
667 c->value_int = global_schemacheck;
671 char *src, *dst, ibuf[11];
672 struct berval bv, abv;
673 for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
674 abv.bv_len = sprintf( ibuf, "{%x}", i );
675 acl_unparse( a, &bv );
676 abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
677 AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
678 /* Turn TAB / EOL into plain space */
679 for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
680 if (isspace(*src)) *dst++ = ' ';
684 if (dst[-1] == ' ') {
688 abv.bv_len = dst - abv.bv_val;
689 ber_bvarray_add( &c->rvalue_vals, &abv );
695 if ( c->be->be_replogfile )
696 c->value_string = ch_strdup( c->be->be_replogfile );
699 ConfigFile *cf = (ConfigFile *)c->line;
700 if ( cf->c_dseFiles ) {
701 value_add( &c->rvalue_vals, cf->c_dseFiles );
709 c->value_string = ch_strdup( logfileName );
714 c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
716 case CFG_SSTR_IF_MAX:
717 c->value_int = index_substr_if_maxlen;
719 case CFG_SSTR_IF_MIN:
720 c->value_int = index_substr_if_minlen;
724 ConfigFile *cf = (ConfigFile *)c->line;
726 for (i=0, mp=&cf->c_modpaths; mp; mp=mp->mp_next, i++) {
728 if (!mp->mp_loads) continue;
729 for (j=0; !BER_BVISNULL(&mp->mp_loads[j]); j++) {
732 bv.bv_len = sprintf( bv.bv_val, "{%d}{%d}%s", i, j,
733 mp->mp_loads[j].bv_val );
734 value_add_one( &c->rvalue_vals, &bv );
737 rc = c->rvalue_vals ? 0 : 1;
741 ConfigFile *cf = (ConfigFile *)c->line;
743 for (i=0, mp=&cf->c_modpaths; mp; mp=mp->mp_next, i++) {
745 if ( BER_BVISNULL( &mp->mp_path ) && !mp->mp_loads )
748 bv.bv_len = sprintf( bv.bv_val, "{%d}%s", i,
749 mp->mp_path.bv_val );
750 value_add_one( &c->rvalue_vals, &bv );
752 rc = c->rvalue_vals ? 0 : 1;
758 slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
759 if ( !c->rvalue_vals ) rc = 1;
762 #ifdef SLAP_AUTH_REWRITE
764 if ( authz_rewrites ) {
765 struct berval bv, idx;
770 for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
771 idx.bv_len = sprintf( idx.bv_val, "{%d}", i );
772 bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
773 bv.bv_val = ch_malloc( bv.bv_len + 1 );
774 strcpy( bv.bv_val, idx.bv_val );
775 strcpy( bv.bv_val+idx.bv_len, authz_rewrites[i].bv_val );
776 ber_bvarray_add( &c->rvalue_vals, &bv );
779 if ( !c->rvalue_vals ) rc = 1;
788 p = strchr(c->line,'(' /*')'*/);
791 if(!(c->bi = backend_info(c->argv[1]))) {
792 Debug(LDAP_DEBUG_ANY, "%s: "
793 "backend %s failed init!\n", c->log, c->argv[1], 0);
800 /* NOTE: config is always the first backend!
802 if ( !strcasecmp( c->argv[1], "config" )) {
804 } else if(!(c->be = backend_db_init(c->argv[1]))) {
805 Debug(LDAP_DEBUG_ANY, "%s: "
806 "database %s failed init!\n", c->log, c->argv[1], 0);
812 ldap_pvt_thread_set_concurrency(c->value_int);
816 ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
817 connection_pool_max = c->value_int; /* save for reference */
821 if ( passwd_salt ) ch_free( passwd_salt );
822 passwd_salt = c->value_string;
823 lutil_salt_format(passwd_salt);
827 if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
833 c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
835 c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
839 ch_free(c->value_string);
840 if (slap_sasl_setpolicy( c->argv[1] )) {
841 Debug(LDAP_DEBUG_ANY, "%s: unable to parse value \"%s\" in"
842 " \"authz-policy <policy>\"\n",
843 c->log, c->argv[1], 0 );
849 if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
853 #ifdef HAVE_CYRUS_SASL
856 char *txt = slap_sasl_secprops( c->argv[1] );
858 Debug(LDAP_DEBUG_ANY, "%s: sasl-secprops: %s\n",
867 c->be->be_max_deref_depth = c->value_int;
871 if(parse_oidm(c->fname, c->lineno, c->argc, c->argv)) return(1);
875 if(parse_oc(c->fname, c->lineno, p, c->argv)) return(1);
879 if(parse_cr(c->fname, c->lineno, p, c->argv)) return(1);
883 if(parse_at(c->fname, c->lineno, p, c->argv)) return(1);
887 ad_define_option(NULL, NULL, 0);
888 for(i = 1; i < c->argc; i++)
889 if(ad_define_option(c->argv[i], c->fname, c->lineno))
894 global_schemacheck = c->value_int;
895 if(!global_schemacheck) Debug(LDAP_DEBUG_ANY, "%s: "
896 "schema checking disabled! your mileage may vary!\n",
901 parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv);
905 if(SLAP_MONITOR(c->be)) {
906 Debug(LDAP_DEBUG_ANY, "%s: "
907 "\"replogfile\" should not be used "
908 "inside monitor database\n",
910 return(0); /* FIXME: should this be an error? */
913 c->be->be_replogfile = c->value_string;
917 if(read_root_dse_file(c->argv[1])) {
918 Debug(LDAP_DEBUG_ANY, "%s: "
919 "could not read \"rootDSE <filename>\" line\n",
925 ber_str2bv( c->argv[1], 0, 1, &bv );
926 ber_bvarray_add( &cfn->c_dseFiles, &bv );
932 if ( logfileName ) ch_free( logfileName );
933 logfileName = c->value_string;
934 logfile = fopen(logfileName, "w");
935 if(logfile) lutil_debug_file(logfile);
939 if(SLAP_NOLASTMODCMD(c->be)) {
940 Debug(LDAP_DEBUG_ANY, "%s: "
941 "lastmod not available for %s databases\n",
942 c->log, c->be->bd_info->bi_type, 0);
946 SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
948 SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
951 case CFG_SSTR_IF_MAX:
952 if (c->value_int < index_substr_if_minlen) {
953 Debug(LDAP_DEBUG_ANY, "%s: "
954 "invalid max value (%d)\n",
955 c->log, c->value_int, 0 );
958 index_substr_if_maxlen = c->value_int;
961 case CFG_SSTR_IF_MIN:
962 if (c->value_int > index_substr_if_maxlen) {
963 Debug(LDAP_DEBUG_ANY, "%s: "
964 "invalid min value (%d)\n",
965 c->log, c->value_int, 0 );
968 index_substr_if_minlen = c->value_int;
973 if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
975 /* Record this load on the current path */
978 ber_str2bv(c->line, 0, 1, &bv);
979 ber_bvarray_add( &cfn->c_modlast->mp_loads, &bv );
984 if(module_path(c->argv[1])) return(1);
985 /* Record which path was used with each module */
989 if (!cfn->c_modpaths.mp_loads) {
990 mp = &cfn->c_modpaths;
992 mp = ch_malloc( sizeof( ModPaths ));
993 cfn->c_modlast->mp_next = mp;
995 ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
1006 if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
1008 slapi_plugins_used++;
1012 #ifdef SLAP_AUTH_REWRITE
1015 if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
1017 ber_str2bv( c->line, 0, 1, &bv );
1018 ber_bvarray_add( &authz_rewrites, &bv );
1025 Debug(LDAP_DEBUG_ANY, "%s: unknown CFG_TYPE %d"
1026 "(ignored)\n", c->log, c->type, 0);
1034 config_fname(ConfigArgs *c) {
1035 if(c->emit && c->line) {
1036 ConfigFile *cf = (ConfigFile *)c->line;
1037 value_add_one( &c->rvalue_vals, &cf->c_file );
1044 config_search_base(ConfigArgs *c) {
1049 if (!BER_BVISEMPTY(&default_search_base)) {
1050 value_add_one(&c->rvalue_vals, &default_search_base);
1051 value_add_one(&c->rvalue_nvals, &default_search_nbase);
1057 if(c->bi || c->be != frontendDB) {
1058 Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
1059 "prior to any backend or database definition\n",
1064 if(default_search_nbase.bv_len) {
1065 Debug(LDAP_DEBUG_ANY, "%s: "
1066 "default search base \"%s\" already defined "
1067 "(discarding old)\n",
1068 c->log, default_search_base.bv_val, 0);
1069 free(default_search_base.bv_val);
1070 free(default_search_nbase.bv_val);
1073 default_search_base = c->value_dn;
1074 default_search_nbase = c->value_ndn;
1079 config_passwd_hash(ConfigArgs *c) {
1083 for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
1084 ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
1085 value_add_one(&c->rvalue_vals, &bv);
1089 if(default_passwd_hash) {
1090 Debug(LDAP_DEBUG_ANY, "%s: "
1091 "already set default password_hash\n",
1095 for(i = 1; i < c->argc; i++) {
1096 if(!lutil_passwd_scheme(c->argv[i])) {
1097 Debug(LDAP_DEBUG_ANY, "%s: "
1098 "password scheme \"%s\" not available\n",
1099 c->log, c->argv[i], 0);
1101 ldap_charray_add(&default_passwd_hash, c->argv[i]);
1103 if(!default_passwd_hash) {
1104 Debug(LDAP_DEBUG_ANY, "%s: no valid hashes found\n",
1113 config_schema_dn(ConfigArgs *c) {
1117 value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
1118 value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
1121 c->be->be_schemadn = c->value_dn;
1122 c->be->be_schemandn = c->value_ndn;
1127 config_sizelimit(ConfigArgs *c) {
1130 struct slap_limits_set *lim = &c->be->be_def_limit;
1136 limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv );
1137 if ( !BER_BVISEMPTY( &bv ))
1138 value_add_one( &c->rvalue_vals, &bv );
1143 for(i = 1; i < c->argc; i++) {
1144 if(!strncasecmp(c->argv[i], "size", 4)) {
1145 rc = limits_parse_one(c->argv[i], lim);
1147 Debug(LDAP_DEBUG_ANY, "%s: "
1148 "unable to parse value \"%s\" in \"sizelimit <limit>\" line\n",
1149 c->log, c->argv[i], 0);
1153 if(!strcasecmp(c->argv[i], "unlimited")) {
1154 lim->lms_s_soft = -1;
1156 lim->lms_s_soft = strtol(c->argv[i], &next, 0);
1157 if(next == c->argv[i]) {
1158 Debug(LDAP_DEBUG_ANY, "%s: "
1159 "unable to parse limit \"%s\" in \"sizelimit <limit>\" line\n",
1160 c->log, c->argv[i], 0);
1162 } else if(next[0] != '\0') {
1163 Debug(LDAP_DEBUG_ANY, "%s: "
1164 "trailing chars \"%s\" in \"sizelimit <limit>\" line (ignored)\n",
1168 lim->lms_s_hard = 0;
1175 config_timelimit(ConfigArgs *c) {
1178 struct slap_limits_set *lim = &c->be->be_def_limit;
1184 limits_unparse_one( lim, SLAP_LIMIT_TIME, &bv );
1185 if ( !BER_BVISEMPTY( &bv ))
1186 value_add_one( &c->rvalue_vals, &bv );
1191 for(i = 1; i < c->argc; i++) {
1192 if(!strncasecmp(c->argv[i], "time", 4)) {
1193 rc = limits_parse_one(c->argv[i], lim);
1195 Debug(LDAP_DEBUG_ANY, "%s: "
1196 "unable to parse value \"%s\" in \"timelimit <limit>\" line\n",
1197 c->log, c->argv[i], 0);
1201 if(!strcasecmp(c->argv[i], "unlimited")) {
1202 lim->lms_t_soft = -1;
1204 lim->lms_t_soft = strtol(c->argv[i], &next, 0);
1205 if(next == c->argv[i]) {
1206 Debug(LDAP_DEBUG_ANY, "%s: "
1207 "unable to parse limit \"%s\" in \"timelimit <limit>\" line\n",
1208 c->log, c->argv[i], 0);
1210 } else if(next[0] != '\0') {
1211 Debug(LDAP_DEBUG_ANY, "%s: "
1212 "trailing chars \"%s\" in \"timelimit <limit>\" line (ignored)\n",
1216 lim->lms_t_hard = 0;
1223 config_overlay(ConfigArgs *c) {
1227 if(c->argv[1][0] == '-' && overlay_config(c->be, &c->argv[1][1])) {
1229 Debug(LDAP_DEBUG_ANY, "%s: (optional) %s overlay \"%s\" configuration failed (ignored)\n",
1230 c->log, c->be == frontendDB ? "global " : "", c->argv[1][1]);
1231 } else if(overlay_config(c->be, c->argv[1])) {
1238 config_suffix(ConfigArgs *c) {
1240 struct berval pdn, ndn;
1243 if ( !BER_BVISNULL( &c->be->be_suffix[0] )) {
1244 value_add( &c->rvalue_vals, c->be->be_suffix );
1245 value_add( &c->rvalue_nvals, c->be->be_nsuffix );
1251 #ifdef SLAPD_MONITOR_DN
1252 if(!strcasecmp(c->argv[1], SLAPD_MONITOR_DN)) {
1253 Debug(LDAP_DEBUG_ANY, "%s: "
1254 "\"%s\" is reserved for monitoring slapd\n",
1255 c->log, SLAPD_MONITOR_DN, 0);
1262 tbe = select_backend(&ndn, 0, 0);
1264 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by this backend! (ignored)\n",
1269 Debug(LDAP_DEBUG_ANY, "%s: suffix already served by a preceding backend \"%s\"\n",
1270 c->log, tbe->be_suffix[0].bv_val, 0);
1274 } else if(pdn.bv_len == 0 && default_search_nbase.bv_len) {
1275 Debug(LDAP_DEBUG_ANY, "%s: suffix DN empty and default search "
1276 "base provided \"%s\" (assuming okay)\n",
1277 c->log, default_search_base.bv_val, 0);
1279 ber_bvarray_add(&c->be->be_suffix, &pdn);
1280 ber_bvarray_add(&c->be->be_nsuffix, &ndn);
1285 config_rootdn(ConfigArgs *c) {
1287 if ( !BER_BVISNULL( &c->be->be_rootdn )) {
1288 value_add_one(&c->rvalue_vals, &c->be->be_rootdn);
1289 value_add_one(&c->rvalue_nvals, &c->be->be_rootndn);
1295 c->be->be_rootdn = c->value_dn;
1296 c->be->be_rootndn = c->value_ndn;
1301 config_rootpw(ConfigArgs *c) {
1304 if (!BER_BVISEMPTY(&c->be->be_rootpw)) {
1305 c->value_string=ch_strdup("*");
1311 tbe = select_backend(&c->be->be_rootndn, 0, 0);
1313 Debug(LDAP_DEBUG_ANY, "%s: "
1314 "rootpw can only be set when rootdn is under suffix\n",
1318 ber_str2bv(c->value_string, 0, 0, &c->be->be_rootpw);
1323 config_restrict(ConfigArgs *c) {
1324 slap_mask_t restrictops = 0;
1326 slap_verbmasks restrictable_ops[] = {
1327 { BER_BVC("bind"), SLAP_RESTRICT_OP_BIND },
1328 { BER_BVC("add"), SLAP_RESTRICT_OP_ADD },
1329 { BER_BVC("modify"), SLAP_RESTRICT_OP_MODIFY },
1330 { BER_BVC("rename"), SLAP_RESTRICT_OP_RENAME },
1331 { BER_BVC("modrdn"), 0 },
1332 { BER_BVC("delete"), SLAP_RESTRICT_OP_DELETE },
1333 { BER_BVC("search"), SLAP_RESTRICT_OP_SEARCH },
1334 { BER_BVC("compare"), SLAP_RESTRICT_OP_COMPARE },
1335 { BER_BVC("read"), SLAP_RESTRICT_OP_READS },
1336 { BER_BVC("write"), SLAP_RESTRICT_OP_WRITES },
1337 { BER_BVC("extended"), SLAP_RESTRICT_OP_EXTENDED },
1338 { BER_BVC("extended=" LDAP_EXOP_START_TLS ), SLAP_RESTRICT_EXOP_START_TLS },
1339 { BER_BVC("extended=" LDAP_EXOP_MODIFY_PASSWD ), SLAP_RESTRICT_EXOP_MODIFY_PASSWD },
1340 { BER_BVC("extended=" LDAP_EXOP_X_WHO_AM_I ), SLAP_RESTRICT_EXOP_WHOAMI },
1341 { BER_BVC("extended=" LDAP_EXOP_X_CANCEL ), SLAP_RESTRICT_EXOP_CANCEL },
1346 return mask_to_verbs( restrictable_ops, c->be->be_restrictops,
1349 i = verbs_to_mask( c->argc, c->argv, restrictable_ops, &restrictops );
1351 Debug(LDAP_DEBUG_ANY, "%s: "
1352 "unknown operation %s in \"restrict <features>\" line\n",
1353 c->log, c->argv[i], 0);
1356 if ( restrictops & SLAP_RESTRICT_OP_EXTENDED )
1357 restrictops &= ~SLAP_RESTRICT_EXOP_MASK;
1358 c->be->be_restrictops |= restrictops;
1363 config_allows(ConfigArgs *c) {
1364 slap_mask_t allows = 0;
1366 slap_verbmasks allowable_ops[] = {
1367 { BER_BVC("bind_v2"), SLAP_ALLOW_BIND_V2 },
1368 { BER_BVC("bind_anon_cred"), SLAP_ALLOW_BIND_ANON_CRED },
1369 { BER_BVC("bind_anon_dn"), SLAP_ALLOW_BIND_ANON_DN },
1370 { BER_BVC("update_anon"), SLAP_ALLOW_UPDATE_ANON },
1374 return mask_to_verbs( allowable_ops, global_allows, &c->rvalue_vals );
1376 i = verbs_to_mask(c->argc, c->argv, allowable_ops, &allows);
1378 Debug(LDAP_DEBUG_ANY, "%s: "
1379 "unknown feature %s in \"allow <features>\" line\n",
1380 c->log, c->argv[i], 0);
1383 global_allows |= allows;
1388 config_disallows(ConfigArgs *c) {
1389 slap_mask_t disallows = 0;
1391 slap_verbmasks disallowable_ops[] = {
1392 { BER_BVC("bind_anon"), SLAP_DISALLOW_BIND_ANON },
1393 { BER_BVC("bind_simple"), SLAP_DISALLOW_BIND_SIMPLE },
1394 { BER_BVC("bind_krb4"), SLAP_DISALLOW_BIND_KRBV4 },
1395 { BER_BVC("tls_2_anon"), SLAP_DISALLOW_TLS_2_ANON },
1396 { BER_BVC("tls_authc"), SLAP_DISALLOW_TLS_AUTHC },
1400 return mask_to_verbs( disallowable_ops, global_disallows, &c->rvalue_vals );
1402 i = verbs_to_mask(c->argc, c->argv, disallowable_ops, &disallows);
1404 Debug(LDAP_DEBUG_ANY, "%s: "
1405 "unknown feature %s in \"disallow <features>\" line\n",
1406 c->log, c->argv[i], 0);
1409 global_disallows |= disallows;
1414 config_requires(ConfigArgs *c) {
1415 slap_mask_t requires = 0;
1417 slap_verbmasks requires_ops[] = {
1418 { BER_BVC("bind"), SLAP_REQUIRE_BIND },
1419 { BER_BVC("LDAPv3"), SLAP_REQUIRE_LDAP_V3 },
1420 { BER_BVC("authc"), SLAP_REQUIRE_AUTHC },
1421 { BER_BVC("sasl"), SLAP_REQUIRE_SASL },
1422 { BER_BVC("strong"), SLAP_REQUIRE_STRONG },
1426 return mask_to_verbs( requires_ops, c->be->be_requires, &c->rvalue_vals );
1428 i = verbs_to_mask(c->argc, c->argv, requires_ops, &requires);
1430 Debug(LDAP_DEBUG_ANY, "%s: "
1431 "unknown feature %s in \"require <features>\" line\n",
1432 c->log, c->argv[i], 0);
1435 c->be->be_requires = requires;
1440 config_loglevel(ConfigArgs *c) {
1443 slap_verbmasks loglevel_ops[] = {
1444 { BER_BVC("Trace"), LDAP_DEBUG_TRACE },
1445 { BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
1446 { BER_BVC("Args"), LDAP_DEBUG_ARGS },
1447 { BER_BVC("Conns"), LDAP_DEBUG_CONNS },
1448 { BER_BVC("BER"), LDAP_DEBUG_BER },
1449 { BER_BVC("Filter"), LDAP_DEBUG_FILTER },
1450 { BER_BVC("Config"), LDAP_DEBUG_CONFIG },
1451 { BER_BVC("ACL"), LDAP_DEBUG_ACL },
1452 { BER_BVC("Stats"), LDAP_DEBUG_STATS },
1453 { BER_BVC("Stats2"), LDAP_DEBUG_STATS2 },
1454 { BER_BVC("Shell"), LDAP_DEBUG_SHELL },
1455 { BER_BVC("Parse"), LDAP_DEBUG_PARSE },
1456 { BER_BVC("Cache"), LDAP_DEBUG_CACHE },
1457 { BER_BVC("Index"), LDAP_DEBUG_INDEX },
1458 { BER_BVC("Any"), -1 },
1463 return mask_to_verbs( loglevel_ops, ldap_syslog, &c->rvalue_vals );
1468 for( i=1; i < c->argc; i++ ) {
1471 if ( isdigit( c->argv[i][0] ) ) {
1472 level = strtol( c->argv[i], &next, 10 );
1473 if ( next == NULL || next[0] != '\0' ) {
1474 Debug( LDAP_DEBUG_ANY,
1475 "%s: unable to parse level \"%s\" "
1476 "in \"loglevel <level> [...]\" line.\n",
1477 c->log, c->argv[i], 0);
1481 int j = verb_to_mask(c->argv[i], loglevel_ops);
1482 if(BER_BVISNULL(&loglevel_ops[j].word)) {
1483 Debug( LDAP_DEBUG_ANY,
1484 "%s: unknown level \"%s\" "
1485 "in \"loglevel <level> [...]\" line.\n",
1486 c->log, c->argv[i], 0);
1489 level = loglevel_ops[j].mask;
1491 ldap_syslog |= level;
1497 config_syncrepl(ConfigArgs *c) {
1499 if ( c->be->be_syncinfo ) {
1501 syncrepl_unparse( c->be->be_syncinfo, &bv );
1502 ber_bvarray_add( &c->rvalue_vals, &bv );
1507 if(SLAP_SHADOW(c->be)) {
1508 Debug(LDAP_DEBUG_ANY, "%s: "
1509 "syncrepl: database already shadowed.\n",
1512 } else if(add_syncrepl(c->be, c->argv, c->argc)) {
1515 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SYNC_SHADOW);
1520 config_referral(ConfigArgs *c) {
1521 struct berval vals[2];
1523 if ( default_referral ) {
1524 value_add( &c->rvalue_vals, default_referral );
1530 if(validate_global_referral(c->argv[1])) {
1531 Debug(LDAP_DEBUG_ANY, "%s: "
1532 "invalid URL (%s) in \"referral\" line.\n",
1533 c->log, c->argv[1], 0);
1537 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1538 vals[1].bv_val = NULL; vals[1].bv_len = 0;
1539 if(value_add(&default_referral, vals)) return(LDAP_OTHER);
1547 { BER_BVC("ssf="), offsetof(slap_ssf_set_t, sss_ssf) },
1548 { BER_BVC("transport="), offsetof(slap_ssf_set_t, sss_transport) },
1549 { BER_BVC("tls="), offsetof(slap_ssf_set_t, sss_tls) },
1550 { BER_BVC("sasl="), offsetof(slap_ssf_set_t, sss_sasl) },
1551 { BER_BVC("update_ssf="), offsetof(slap_ssf_set_t, sss_update_ssf) },
1552 { BER_BVC("update_transport="), offsetof(slap_ssf_set_t, sss_update_transport) },
1553 { BER_BVC("update_tls="), offsetof(slap_ssf_set_t, sss_update_tls) },
1554 { BER_BVC("update_sasl="), offsetof(slap_ssf_set_t, sss_update_sasl) },
1555 { BER_BVC("simple_bind="), offsetof(slap_ssf_set_t, sss_simple_bind) },
1560 config_security(ConfigArgs *c) {
1561 slap_ssf_set_t *set = &c->be->be_ssf_set;
1570 for (i=0; !BER_BVISNULL( &sec_keys[i].key ); i++) {
1571 tgt = (slap_ssf_t *)((char *)set + sec_keys[i].off);
1574 bv.bv_len = sprintf( numbuf, "%u", *tgt );
1575 bv.bv_len += sec_keys[i].key.bv_len;
1576 bv.bv_val = ch_malloc( bv.bv_len + 1);
1577 next = lutil_strcopy( bv.bv_val, sec_keys[i].key.bv_val );
1578 strcpy( next, numbuf );
1579 ber_bvarray_add( &c->rvalue_vals, &bv );
1584 for(i = 1; i < c->argc; i++) {
1585 slap_ssf_t *tgt = NULL;
1587 for ( j=0; !BER_BVISNULL( &sec_keys[j].key ); j++ ) {
1588 if(!strncasecmp(c->argv[i], sec_keys[j].key.bv_val,
1589 sec_keys[j].key.bv_len)) {
1590 src = c->argv[i] + sec_keys[j].key.bv_len;
1591 tgt = (slap_ssf_t *)((char *)set + sec_keys[j].off);
1596 Debug(LDAP_DEBUG_ANY, "%s: "
1597 "unknown factor %s in \"security <factors>\" line\n",
1598 c->log, c->argv[i], 0);
1602 *tgt = strtol(src, &next, 10);
1603 if(next == NULL || next[0] != '\0' ) {
1604 Debug(LDAP_DEBUG_ANY, "%s: "
1605 "unable to parse factor \"%s\" in \"security <factors>\" line\n",
1606 c->log, c->argv[i], 0);
1614 anlist_unparse( AttributeName *an, char *ptr ) {
1617 for (; !BER_BVISNULL( &an->an_name ); an++) {
1618 if ( comma ) *ptr++ = ',';
1619 ptr = lutil_strcopy( ptr, an->an_name.bv_val );
1626 replica_unparse( struct slap_replica_info *ri, int i, struct berval *bv )
1630 struct berval bc = {0};
1633 len = sprintf(numbuf, "{%d}", i );
1635 len += strlen( ri->ri_uri ) + STRLENOF("uri=");
1636 if ( ri->ri_nsuffix ) {
1637 for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
1638 len += ri->ri_nsuffix[i].bv_len + STRLENOF(" suffix=\"\"");
1641 if ( ri->ri_attrs ) {
1642 len += STRLENOF("attr");
1643 if ( ri->ri_exclude ) len++;
1644 for (i=0; !BER_BVISNULL( &ri->ri_attrs[i].an_name ); i++) {
1645 len += 1 + ri->ri_attrs[i].an_name.bv_len;
1648 bindconf_unparse( &ri->ri_bindconf, &bc );
1651 bv->bv_val = ch_malloc(len + 1);
1654 ptr = lutil_strcopy( bv->bv_val, numbuf );
1655 ptr = lutil_strcopy( ptr, "uri=" );
1656 ptr = lutil_strcopy( ptr, ri->ri_uri );
1658 if ( ri->ri_nsuffix ) {
1659 for (i=0; !BER_BVISNULL( &ri->ri_nsuffix[i] ); i++) {
1660 ptr = lutil_strcopy( ptr, " suffix=\"" );
1661 ptr = lutil_strcopy( ptr, ri->ri_nsuffix[i].bv_val );
1665 if ( ri->ri_attrs ) {
1666 ptr = lutil_strcopy( ptr, "attr" );
1667 if ( ri->ri_exclude ) *ptr++ = '!';
1669 ptr = anlist_unparse( ri->ri_attrs, ptr );
1672 strcpy( ptr, bc.bv_val );
1673 ch_free( bc.bv_val );
1678 config_replica(ConfigArgs *c) {
1679 int i, nr = -1, len;
1680 char *replicahost, *replicauri;
1684 if (c->be->be_replica) {
1686 for (i=0;c->be->be_replica[i]; i++) {
1687 replica_unparse( c->be->be_replica[i], i, &bv );
1688 ber_bvarray_add( &c->rvalue_vals, &bv );
1694 if(SLAP_MONITOR(c->be)) {
1695 Debug(LDAP_DEBUG_ANY, "%s: "
1696 "\"replica\" should not be used inside monitor database\n",
1698 return(0); /* FIXME: should this be an error? */
1701 for(i = 1; i < c->argc; i++) {
1702 if(!strncasecmp(c->argv[i], "host=", STRLENOF("host="))) {
1703 replicahost = c->argv[i] + STRLENOF("host=");
1704 len = strlen( replicahost );
1705 replicauri = ch_malloc( len + STRLENOF("ldap://") + 1 );
1706 sprintf( replicauri, "ldap://%s", replicahost );
1707 replicahost = replicauri + STRLENOF( "ldap://");
1708 nr = add_replica_info(c->be, replicauri, replicahost);
1710 } else if(!strncasecmp(c->argv[i], "uri=", STRLENOF("uri="))) {
1711 if(ldap_url_parse(c->argv[i] + STRLENOF("uri="), &ludp) != LDAP_SUCCESS) {
1712 Debug(LDAP_DEBUG_ANY, "%s: "
1713 "replica line contains invalid "
1714 "uri definition.\n", c->log, 0, 0);
1717 if(!ludp->lud_host) {
1718 Debug(LDAP_DEBUG_ANY, "%s: "
1719 "replica line contains invalid "
1720 "uri definition - missing hostname.\n",
1724 ldap_free_urldesc(ludp);
1725 replicauri = c->argv[i] + STRLENOF("uri=");
1726 replicauri = ch_strdup( replicauri );
1727 replicahost = strchr( replicauri, '/' );
1729 nr = add_replica_info(c->be, replicauri, replicahost);
1734 Debug(LDAP_DEBUG_ANY, "%s: "
1735 "missing host or uri in \"replica\" line\n",
1738 } else if(nr == -1) {
1739 Debug(LDAP_DEBUG_ANY, "%s: "
1740 "unable to add replica \"%s\"\n",
1741 c->log, replicauri, 0);
1744 for(i = 1; i < c->argc; i++) {
1745 if(!strncasecmp(c->argv[i], "suffix=", STRLENOF( "suffix="))) {
1746 switch(add_replica_suffix(c->be, nr, c->argv[i] + STRLENOF("suffix="))) {
1748 Debug(LDAP_DEBUG_ANY, "%s: "
1749 "suffix \"%s\" in \"replica\" line is not valid for backend (ignored)\n",
1750 c->log, c->argv[i] + STRLENOF("suffix="), 0);
1753 Debug(LDAP_DEBUG_ANY, "%s: "
1754 "unable to normalize suffix in \"replica\" line (ignored)\n",
1759 } else if(!strncasecmp(c->argv[i], "attr", STRLENOF("attr"))) {
1761 char *arg = c->argv[i] + STRLENOF("attr");
1769 if(add_replica_attrs(c->be, nr, arg + 1, exclude)) {
1770 Debug(LDAP_DEBUG_ANY, "%s: "
1771 "attribute \"%s\" in \"replica\" line is unknown\n",
1772 c->log, arg + 1, 0);
1775 } else if ( bindconf_parse( c->argv[i],
1776 &c->be->be_replica[nr]->ri_bindconf ) ) {
1785 config_updatedn(ConfigArgs *c) {
1789 if (!BER_BVISEMPTY(&c->be->be_update_ndn)) {
1790 value_add_one(&c->rvalue_vals, &c->be->be_update_ndn);
1791 value_add_one(&c->rvalue_nvals, &c->be->be_update_ndn);
1796 if(SLAP_SHADOW(c->be)) {
1797 Debug(LDAP_DEBUG_ANY, "%s: "
1798 "updatedn: database already shadowed.\n",
1803 ber_str2bv(c->argv[1], 0, 0, &dn);
1805 rc = dnNormalize(0, NULL, NULL, &dn, &c->be->be_update_ndn, NULL);
1807 if(rc != LDAP_SUCCESS) {
1808 Debug(LDAP_DEBUG_ANY, "%s: "
1809 "updatedn DN is invalid: %d (%s)\n",
1810 c->log, rc, ldap_err2string( rc ));
1814 SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SLURP_SHADOW);
1819 config_updateref(ConfigArgs *c) {
1820 struct berval vals[2];
1822 if ( c->be->be_update_refs ) {
1823 value_add( &c->rvalue_vals, c->be->be_update_refs );
1829 if(!SLAP_SHADOW(c->be)) {
1830 Debug(LDAP_DEBUG_ANY, "%s: "
1831 "updateref line must come after syncrepl or updatedn.\n",
1836 if(validate_global_referral(c->argv[1])) {
1837 Debug(LDAP_DEBUG_ANY, "%s: "
1838 "invalid URL (%s) in \"updateref\" line.\n",
1839 c->log, c->argv[1], 0);
1842 ber_str2bv(c->argv[1], 0, 0, &vals[0]);
1843 vals[1].bv_val = NULL;
1844 if(value_add(&c->be->be_update_refs, vals)) return(LDAP_OTHER);
1849 config_include(ConfigArgs *c) {
1850 unsigned long savelineno = c->lineno;
1853 ConfigFile *cfsave = cfn;
1854 ConfigFile *cf2 = NULL;
1858 cf = ch_calloc( 1, sizeof(ConfigFile));
1859 #ifdef SLAPD_MODULES
1860 cf->c_modlast = &cf->c_modpaths;
1862 if ( cfn->c_kids ) {
1863 for (cf2=cfn->c_kids; cf2 && cf2->c_sibs; cf2=cf2->c_sibs) ;
1869 rc = read_config_file(c->argv[1], c->depth + 1, c);
1870 c->lineno = savelineno - 1;
1873 if ( cf2 ) cf2->c_sibs = NULL;
1874 else cfn->c_kids = NULL;
1877 ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
1884 config_tls_option(ConfigArgs *c) {
1887 case CFG_TLS_RAND: flag = LDAP_OPT_X_TLS_RANDOM_FILE; break;
1888 case CFG_TLS_CIPHER: flag = LDAP_OPT_X_TLS_CIPHER_SUITE; break;
1889 case CFG_TLS_CERT_FILE: flag = LDAP_OPT_X_TLS_CERTFILE; break;
1890 case CFG_TLS_CERT_KEY: flag = LDAP_OPT_X_TLS_KEYFILE; break;
1891 case CFG_TLS_CA_PATH: flag = LDAP_OPT_X_TLS_CACERTDIR; break;
1892 case CFG_TLS_CA_FILE: flag = LDAP_OPT_X_TLS_CACERTFILE; break;
1893 default: Debug(LDAP_DEBUG_ANY, "%s: "
1894 "unknown tls_option <%x>\n",
1895 c->log, c->type, 0);
1898 return ldap_pvt_tls_get_option( NULL, flag, &c->value_string );
1900 ch_free(c->value_string);
1901 return(ldap_pvt_tls_set_option(NULL, flag, c->argv[1]));
1904 /* FIXME: this ought to be provided by libldap */
1906 config_tls_config(ConfigArgs *c) {
1908 slap_verbmasks crlkeys[] = {
1909 { BER_BVC("none"), LDAP_OPT_X_TLS_CRL_NONE },
1910 { BER_BVC("peer"), LDAP_OPT_X_TLS_CRL_PEER },
1911 { BER_BVC("all"), LDAP_OPT_X_TLS_CRL_ALL },
1914 slap_verbmasks vfykeys[] = {
1915 { BER_BVC("never"), LDAP_OPT_X_TLS_NEVER },
1916 { BER_BVC("demand"), LDAP_OPT_X_TLS_DEMAND },
1917 { BER_BVC("try"), LDAP_OPT_X_TLS_TRY },
1918 { BER_BVC("hard"), LDAP_OPT_X_TLS_HARD },
1922 #ifdef HAVE_OPENSSL_CRL
1923 case CFG_TLS_CRLCHECK: flag = LDAP_OPT_X_TLS_CRLCHECK; keys = crlkeys;
1926 case CFG_TLS_VERIFY: flag = LDAP_OPT_X_TLS_REQUIRE_CERT; keys = vfykeys;
1928 default: Debug(LDAP_DEBUG_ANY, "%s: "
1929 "unknown tls_option <%x>\n",
1930 c->log, c->type, 0);
1933 ldap_pvt_tls_get_option( NULL, flag, &c->value_int );
1934 for (i=0; !BER_BVISNULL(&keys[i].word); i++) {
1935 if (keys[i].mask == c->value_int) {
1936 c->value_string = ch_strdup( keys[i].word.bv_val );
1942 ch_free( c->value_string );
1943 if(isdigit((unsigned char)c->argv[1][0])) {
1944 i = atoi(c->argv[1]);
1945 return(ldap_pvt_tls_set_option(NULL, flag, &i));
1947 return(ldap_int_tls_config(NULL, flag, c->argv[1]));
1962 si = (syncinfo_t *) ch_calloc( 1, sizeof( syncinfo_t ) );
1965 Debug( LDAP_DEBUG_ANY, "out of memory in add_syncrepl\n", 0, 0, 0 );
1969 si->si_bindconf.sb_tls = SB_TLS_OFF;
1970 si->si_bindconf.sb_method = LDAP_AUTH_SIMPLE;
1971 si->si_schemachecking = 0;
1972 ber_str2bv( "(objectclass=*)", STRLENOF("(objectclass=*)"), 1,
1973 &si->si_filterstr );
1974 si->si_base.bv_val = NULL;
1975 si->si_scope = LDAP_SCOPE_SUBTREE;
1976 si->si_attrsonly = 0;
1977 si->si_anlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1978 si->si_exanlist = (AttributeName *) ch_calloc( 1, sizeof( AttributeName ));
1979 si->si_attrs = NULL;
1980 si->si_allattrs = 0;
1981 si->si_allopattrs = 0;
1982 si->si_exattrs = NULL;
1983 si->si_type = LDAP_SYNC_REFRESH_ONLY;
1984 si->si_interval = 86400;
1985 si->si_retryinterval = NULL;
1986 si->si_retrynum_init = NULL;
1987 si->si_retrynum = NULL;
1988 si->si_manageDSAit = 0;
1992 si->si_presentlist = NULL;
1993 LDAP_LIST_INIT( &si->si_nonpresentlist );
1994 ldap_pvt_thread_mutex_init( &si->si_mutex );
1996 rc = parse_syncrepl_line( cargv, cargc, si );
1999 Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
2000 syncinfo_free( si );
2003 Debug( LDAP_DEBUG_CONFIG,
2004 "Config: ** successfully added syncrepl \"%s\"\n",
2005 BER_BVISNULL( &si->si_provideruri ) ?
2006 "(null)" : si->si_provideruri.bv_val, 0, 0 );
2007 if ( !si->si_schemachecking ) {
2008 SLAP_DBFLAGS(be) |= SLAP_DBFLAG_NO_SCHEMA_CHECK;
2011 be->be_syncinfo = si;
2016 /* NOTE: used & documented in slapd.conf(5) */
2018 #define PROVIDERSTR "provider"
2019 #define TYPESTR "type"
2020 #define INTERVALSTR "interval"
2021 #define SEARCHBASESTR "searchbase"
2022 #define FILTERSTR "filter"
2023 #define SCOPESTR "scope"
2024 #define ATTRSSTR "attrs"
2025 #define ATTRSONLYSTR "attrsonly"
2026 #define SLIMITSTR "sizelimit"
2027 #define TLIMITSTR "timelimit"
2028 #define SCHEMASTR "schemachecking"
2030 /* FIXME: undocumented */
2031 #define OLDAUTHCSTR "bindprincipal"
2032 #define EXATTRSSTR "exattrs"
2033 #define RETRYSTR "retry"
2036 #define LASTMODSTR "lastmod"
2037 #define LMGENSTR "gen"
2038 #define LMNOSTR "no"
2039 #define LMREQSTR "req"
2040 #define SRVTABSTR "srvtab"
2041 #define SUFFIXSTR "suffix"
2042 #define MANAGEDSAITSTR "manageDSAit"
2045 #define GOT_ID 0x0001
2046 #define GOT_PROVIDER 0x0002
2049 #define GOT_ALL (GOT_ID|GOT_PROVIDER)
2055 { BER_BVC("base"), LDAP_SCOPE_BASE },
2056 { BER_BVC("one"), LDAP_SCOPE_ONELEVEL },
2057 #ifdef LDAP_SCOPE_SUBORDINATE
2058 { BER_BVC("children"), LDAP_SCOPE_SUBORDINATE },
2059 { BER_BVC("subordinate"), 0 },
2061 { BER_BVC("sub"), LDAP_SCOPE_SUBTREE },
2066 parse_syncrepl_line(
2076 for ( i = 1; i < cargc; i++ ) {
2077 if ( !strncasecmp( cargv[ i ], IDSTR "=",
2078 STRLENOF( IDSTR "=" ) ) )
2081 /* '\0' string terminator accounts for '=' */
2082 val = cargv[ i ] + STRLENOF( IDSTR "=" );
2084 if ( tmp >= 1000 || tmp < 0 ) {
2085 fprintf( stderr, "Error: parse_syncrepl_line: "
2086 "syncrepl id %d is out of range [0..999]\n", tmp );
2091 } else if ( !strncasecmp( cargv[ i ], PROVIDERSTR "=",
2092 STRLENOF( PROVIDERSTR "=" ) ) )
2094 val = cargv[ i ] + STRLENOF( PROVIDERSTR "=" );
2095 ber_str2bv( val, 0, 1, &si->si_provideruri );
2096 gots |= GOT_PROVIDER;
2097 } else if ( !strncasecmp( cargv[ i ], SCHEMASTR "=",
2098 STRLENOF( SCHEMASTR "=" ) ) )
2100 val = cargv[ i ] + STRLENOF( SCHEMASTR "=" );
2101 if ( !strncasecmp( val, "on", STRLENOF( "on" ) )) {
2102 si->si_schemachecking = 1;
2103 } else if ( !strncasecmp( val, "off", STRLENOF( "off" ) ) ) {
2104 si->si_schemachecking = 0;
2106 si->si_schemachecking = 1;
2108 } else if ( !strncasecmp( cargv[ i ], FILTERSTR "=",
2109 STRLENOF( FILTERSTR "=" ) ) )
2111 val = cargv[ i ] + STRLENOF( FILTERSTR "=" );
2112 ber_str2bv( val, 0, 1, &si->si_filterstr );
2113 } else if ( !strncasecmp( cargv[ i ], SEARCHBASESTR "=",
2114 STRLENOF( SEARCHBASESTR "=" ) ) )
2119 val = cargv[ i ] + STRLENOF( SEARCHBASESTR "=" );
2120 if ( si->si_base.bv_val ) {
2121 ch_free( si->si_base.bv_val );
2123 ber_str2bv( val, 0, 0, &bv );
2124 rc = dnNormalize( 0, NULL, NULL, &bv, &si->si_base, NULL );
2125 if ( rc != LDAP_SUCCESS ) {
2126 fprintf( stderr, "Invalid base DN \"%s\": %d (%s)\n",
2127 val, rc, ldap_err2string( rc ) );
2130 } else if ( !strncasecmp( cargv[ i ], SCOPESTR "=",
2131 STRLENOF( SCOPESTR "=" ) ) )
2134 val = cargv[ i ] + STRLENOF( SCOPESTR "=" );
2135 for ( j=0; !BER_BVISNULL(&scopes[j].key); j++ ) {
2136 if (!strncasecmp( val, scopes[j].key.bv_val,
2137 scopes[j].key.bv_len )) {
2138 while (!scopes[j].val) j--;
2139 si->si_scope = scopes[j].val;
2143 if ( BER_BVISNULL(&scopes[j].key) ) {
2144 fprintf( stderr, "Error: parse_syncrepl_line: "
2145 "unknown scope \"%s\"\n", val);
2148 } else if ( !strncasecmp( cargv[ i ], ATTRSONLYSTR "=",
2149 STRLENOF( ATTRSONLYSTR "=" ) ) )
2151 si->si_attrsonly = 1;
2152 } else if ( !strncasecmp( cargv[ i ], ATTRSSTR "=",
2153 STRLENOF( ATTRSSTR "=" ) ) )
2155 val = cargv[ i ] + STRLENOF( ATTRSSTR "=" );
2156 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") ) ) {
2158 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2159 si->si_anlist = file2anlist( si->si_anlist, attr_fname, " ,\t" );
2160 if ( si->si_anlist == NULL ) {
2161 ch_free( attr_fname );
2164 si->si_anfile = attr_fname;
2166 char *str, *s, *next;
2167 char delimstr[] = " ,\t";
2168 str = ch_strdup( val );
2169 for ( s = ldap_pvt_strtok( str, delimstr, &next );
2171 s = ldap_pvt_strtok( NULL, delimstr, &next ) )
2173 if ( strlen(s) == 1 && *s == '*' ) {
2174 si->si_allattrs = 1;
2175 *(val + ( s - str )) = delimstr[0];
2177 if ( strlen(s) == 1 && *s == '+' ) {
2178 si->si_allopattrs = 1;
2179 *(val + ( s - str )) = delimstr[0];
2183 si->si_anlist = str2anlist( si->si_anlist, val, " ,\t" );
2184 if ( si->si_anlist == NULL ) {
2188 } else if ( !strncasecmp( cargv[ i ], EXATTRSSTR "=",
2189 STRLENOF( EXATTRSSTR "=" ) ) )
2191 val = cargv[ i ] + STRLENOF( EXATTRSSTR "=" );
2192 if ( !strncasecmp( val, ":include:", STRLENOF(":include:") )) {
2194 attr_fname = ch_strdup( val + STRLENOF(":include:") );
2195 si->si_exanlist = file2anlist(
2196 si->si_exanlist, attr_fname, " ,\t" );
2197 if ( si->si_exanlist == NULL ) {
2198 ch_free( attr_fname );
2201 ch_free( attr_fname );
2203 si->si_exanlist = str2anlist( si->si_exanlist, val, " ,\t" );
2204 if ( si->si_exanlist == NULL ) {
2208 } else if ( !strncasecmp( cargv[ i ], TYPESTR "=",
2209 STRLENOF( TYPESTR "=" ) ) )
2211 val = cargv[ i ] + STRLENOF( TYPESTR "=" );
2212 if ( !strncasecmp( val, "refreshOnly",
2213 STRLENOF("refreshOnly") ))
2215 si->si_type = LDAP_SYNC_REFRESH_ONLY;
2216 } else if ( !strncasecmp( val, "refreshAndPersist",
2217 STRLENOF("refreshAndPersist") ))
2219 si->si_type = LDAP_SYNC_REFRESH_AND_PERSIST;
2220 si->si_interval = 60;
2222 fprintf( stderr, "Error: parse_syncrepl_line: "
2223 "unknown sync type \"%s\"\n", val);
2226 } else if ( !strncasecmp( cargv[ i ], INTERVALSTR "=",
2227 STRLENOF( INTERVALSTR "=" ) ) )
2229 val = cargv[ i ] + STRLENOF( INTERVALSTR "=" );
2230 if ( si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ) {
2231 si->si_interval = 0;
2239 hstr = strchr( dstr, ':' );
2240 if ( hstr == NULL ) {
2241 fprintf( stderr, "Error: parse_syncrepl_line: "
2242 "invalid interval \"%s\"\n", val );
2246 mstr = strchr( hstr, ':' );
2247 if ( mstr == NULL ) {
2248 fprintf( stderr, "Error: parse_syncrepl_line: "
2249 "invalid interval \"%s\"\n", val );
2253 sstr = strchr( mstr, ':' );
2254 if ( sstr == NULL ) {
2255 fprintf( stderr, "Error: parse_syncrepl_line: "
2256 "invalid interval \"%s\"\n", val );
2265 if (( hh > 24 ) || ( hh < 0 ) ||
2266 ( mm > 60 ) || ( mm < 0 ) ||
2267 ( ss > 60 ) || ( ss < 0 ) || ( dd < 0 )) {
2268 fprintf( stderr, "Error: parse_syncrepl_line: "
2269 "invalid interval \"%s\"\n", val );
2272 si->si_interval = (( dd * 24 + hh ) * 60 + mm ) * 60 + ss;
2274 if ( si->si_interval < 0 ) {
2275 fprintf( stderr, "Error: parse_syncrepl_line: "
2276 "invalid interval \"%ld\"\n",
2277 (long) si->si_interval);
2280 } else if ( !strncasecmp( cargv[ i ], RETRYSTR "=",
2281 STRLENOF( RETRYSTR "=" ) ) )
2286 val = cargv[ i ] + STRLENOF( RETRYSTR "=" );
2287 retry_list = (char **) ch_calloc( 1, sizeof( char * ));
2288 retry_list[0] = NULL;
2290 slap_str2clist( &retry_list, val, " ,\t" );
2292 for ( k = 0; retry_list && retry_list[k]; k++ ) ;
2296 "Error: incomplete syncrepl retry list\n" );
2297 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2298 ch_free( retry_list[k] );
2300 ch_free( retry_list );
2301 exit( EXIT_FAILURE );
2303 si->si_retryinterval = (time_t *) ch_calloc( n + 1, sizeof( time_t ));
2304 si->si_retrynum = (int *) ch_calloc( n + 1, sizeof( int ));
2305 si->si_retrynum_init = (int *) ch_calloc( n + 1, sizeof( int ));
2306 for ( j = 0; j < n; j++ ) {
2307 si->si_retryinterval[j] = atoi( retry_list[j*2] );
2308 if ( *retry_list[j*2+1] == '+' ) {
2309 si->si_retrynum_init[j] = -1;
2310 si->si_retrynum[j] = -1;
2314 si->si_retrynum_init[j] = atoi( retry_list[j*2+1] );
2315 si->si_retrynum[j] = atoi( retry_list[j*2+1] );
2318 si->si_retrynum_init[j] = -2;
2319 si->si_retrynum[j] = -2;
2320 si->si_retryinterval[j] = 0;
2322 for ( k = 0; retry_list && retry_list[k]; k++ ) {
2323 ch_free( retry_list[k] );
2325 ch_free( retry_list );
2326 } else if ( !strncasecmp( cargv[ i ], MANAGEDSAITSTR "=",
2327 STRLENOF( MANAGEDSAITSTR "=" ) ) )
2329 val = cargv[ i ] + STRLENOF( MANAGEDSAITSTR "=" );
2330 si->si_manageDSAit = atoi( val );
2331 } else if ( !strncasecmp( cargv[ i ], SLIMITSTR "=",
2332 STRLENOF( SLIMITSTR "=") ) )
2334 val = cargv[ i ] + STRLENOF( SLIMITSTR "=" );
2335 si->si_slimit = atoi( val );
2336 } else if ( !strncasecmp( cargv[ i ], TLIMITSTR "=",
2337 STRLENOF( TLIMITSTR "=" ) ) )
2339 val = cargv[ i ] + STRLENOF( TLIMITSTR "=" );
2340 si->si_tlimit = atoi( val );
2341 } else if ( bindconf_parse( cargv[i], &si->si_bindconf )) {
2342 fprintf( stderr, "Error: parse_syncrepl_line: "
2343 "unknown keyword \"%s\"\n", cargv[ i ] );
2348 if ( gots != GOT_ALL ) {
2350 "Error: Malformed \"syncrepl\" line in slapd config file" );
2358 syncrepl_unparse( syncinfo_t *si, struct berval *bv )
2361 char buf[BUFSIZ*2], *ptr;
2364 bindconf_unparse( &si->si_bindconf, &bc );
2366 ptr += sprintf( ptr, IDSTR "=%03d " PROVIDERSTR "=%s",
2367 si->si_rid, si->si_provideruri.bv_val );
2368 if ( !BER_BVISNULL( &bc )) {
2369 ptr = lutil_strcopy( ptr, bc.bv_val );
2372 if ( !BER_BVISEMPTY( &si->si_filterstr )) {
2373 ptr = lutil_strcopy( ptr, " " FILTERSTR "=\"" );
2374 ptr = lutil_strcopy( ptr, si->si_filterstr.bv_val );
2377 if ( !BER_BVISNULL( &si->si_base )) {
2378 ptr = lutil_strcopy( ptr, " " SEARCHBASESTR "=\"" );
2379 ptr = lutil_strcopy( ptr, si->si_base.bv_val );
2382 for (i=0; !BER_BVISNULL(&scopes[i].key);i++) {
2383 if ( si->si_scope == scopes[i].val ) {
2384 ptr = lutil_strcopy( ptr, " " SCOPESTR "=" );
2385 ptr = lutil_strcopy( ptr, scopes[i].key.bv_val );
2389 if ( si->si_attrsonly ) {
2390 ptr = lutil_strcopy( ptr, " " ATTRSONLYSTR "=yes" );
2392 if ( si->si_anfile ) {
2393 ptr = lutil_strcopy( ptr, " " ATTRSSTR "=:include:" );
2394 ptr = lutil_strcopy( ptr, si->si_anfile );
2395 } else if ( si->si_allattrs || si->si_allopattrs ||
2396 ( si->si_anlist && !BER_BVISNULL(&si->si_anlist[0].an_name) )) {
2398 ptr = lutil_strcopy( ptr, " " ATTRSSTR "=\"" );
2400 ptr = anlist_unparse( si->si_anlist, ptr );
2401 if ( si->si_allattrs ) {
2402 if ( old != ptr ) *ptr++ = ',';
2405 if ( si->si_allopattrs ) {
2406 if ( old != ptr ) *ptr++ = ',';
2411 if ( si->si_exanlist && !BER_BVISNULL(&si->si_exanlist[0].an_name) ) {
2412 ptr = lutil_strcopy( ptr, " " EXATTRSSTR "=" );
2413 ptr = anlist_unparse( si->si_exanlist, ptr );
2415 ptr = lutil_strcopy( ptr, " " SCHEMASTR "=" );
2416 ptr = lutil_strcopy( ptr, si->si_schemachecking ? "on" : "off" );
2418 ptr = lutil_strcopy( ptr, " " TYPESTR "=" );
2419 ptr = lutil_strcopy( ptr, si->si_type == LDAP_SYNC_REFRESH_AND_PERSIST ?
2420 "refreshAndPersist" : "refreshOnly" );
2422 if ( si->si_type == LDAP_SYNC_REFRESH_ONLY ) {
2425 dd = si->si_interval;
2432 ptr = lutil_strcopy( ptr, " " INTERVALSTR "=" );
2433 ptr += sprintf( ptr, "%02d:%02d:%02d:%02d", dd, hh, mm, ss );
2434 } else if ( si->si_retryinterval ) {
2436 ptr = lutil_strcopy( ptr, " " RETRYSTR "=\"" );
2437 for (i=0; si->si_retryinterval[i]; i++) {
2438 if ( space ) *ptr++ = ' ';
2440 ptr += sprintf( ptr, "%d", si->si_retryinterval[i] );
2441 if ( si->si_retrynum_init[i] == -1 )
2444 ptr += sprintf( ptr, "%d", si->si_retrynum_init );
2449 #if 0 /* FIXME: unused in syncrepl.c, should remove it */
2450 ptr = lutil_strcopy( ptr, " " MANAGEDSAITSTR "=" );
2451 ptr += sprintf( ptr, "%d", si->si_manageDSAit );
2454 if ( si->si_slimit ) {
2455 ptr = lutil_strcopy( ptr, " " SLIMITSTR "=" );
2456 ptr += sprintf( ptr, "%d", si->si_slimit );
2459 if ( si->si_tlimit ) {
2460 ptr = lutil_strcopy( ptr, " " TLIMITSTR "=" );
2461 ptr += sprintf( ptr, "%d", si->si_tlimit );
2463 bc.bv_len = ptr - buf;
2465 ber_dupbv( bv, &bc );
2470 read_config(const char *fname, int depth) {
2472 if ( !backend_db_init( "config" ))
2475 ber_str2bv( fname, 0, 1, &cf_prv.c_file );
2476 return read_config_file(fname, depth, NULL);
2480 config_back_bind( Operation *op, SlapReply *rs )
2482 if ( op->orb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op )) {
2483 ber_dupbv( &op->orb_edn, be_root_dn( op->o_bd ));
2484 /* frontend sends result */
2485 return LDAP_SUCCESS;
2488 rs->sr_err = LDAP_INVALID_CREDENTIALS;
2489 send_ldap_result( op, rs );
2494 static CfEntryInfo *
2495 config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last )
2500 if ( dn_match( &root->ce_entry->e_nname, dn ))
2503 c = dn->bv_val+dn->bv_len;
2504 for (;*c != ',';c--);
2508 for (--c;c>dn->bv_val && *c != ',';c--);
2512 cdn.bv_len = dn->bv_len - (c-dn->bv_val);
2514 root = root->ce_kids;
2516 for (;root;root=root->ce_sibs) {
2517 if ( dn_match( &root->ce_entry->e_nname, &cdn )) {
2518 if ( cdn.bv_val == dn->bv_val ) {
2529 config_send( Operation *op, SlapReply *rs, CfEntryInfo *ce, int depth )
2533 if ( test_filter( op, ce->ce_entry, op->ors_filter ) == LDAP_COMPARE_TRUE )
2535 rs->sr_attrs = op->ors_attrs;
2536 rs->sr_entry = ce->ce_entry;
2537 rc = send_search_entry( op, rs );
2539 if ( op->ors_scope == LDAP_SCOPE_SUBTREE ) {
2540 if ( ce->ce_kids ) {
2541 rc = config_send( op, rs, ce->ce_kids, 1 );
2542 if ( rc ) return rc;
2545 for (ce=ce->ce_sibs; ce; ce=ce->ce_sibs) {
2546 rc = config_send( op, rs, ce, 0 );
2555 config_back_search( Operation *op, SlapReply *rs )
2558 CfEntryInfo *ce, *last;
2561 if ( !be_isroot( op ) ) {
2562 rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
2563 send_ldap_result( op, rs );
2566 cfb = (CfBackInfo *)op->o_bd->be_private;
2568 ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last );
2571 rs->sr_matched = last->ce_entry->e_name.bv_val;
2572 rs->sr_err = LDAP_NO_SUCH_OBJECT;
2575 switch ( op->ors_scope ) {
2576 case LDAP_SCOPE_BASE:
2577 case LDAP_SCOPE_SUBTREE:
2578 config_send( op, rs, ce, 0 );
2581 case LDAP_SCOPE_ONELEVEL:
2582 for (ce = ce->ce_kids; ce; ce=ce->ce_sibs) {
2583 config_send( op, rs, ce, 1 );
2588 rs->sr_err = LDAP_SUCCESS;
2590 send_ldap_result( op, rs );
2595 config_alloc_entry( struct berval *pdn, struct berval *rdn )
2597 Entry *e = ch_calloc( 1, sizeof(Entry) );
2598 CfEntryInfo *ce = ch_calloc( 1, sizeof(CfEntryInfo) );
2601 build_new_dn( &e->e_name, pdn, rdn, NULL );
2602 ber_dupbv( &e->e_nname, &e->e_name );
2611 config_build_entry( ConfigArgs *c, Entry *e, ObjectClass *oc,
2612 struct berval *rdn, ConfigTable *ct, int table )
2614 struct berval vals[2];
2615 struct berval ad_name;
2616 AttributeDescription *ad = NULL;
2622 BER_BVZERO( &vals[1] );
2624 vals[0] = oc->soc_cname;
2625 attr_merge(e, slap_schema.si_ad_objectClass, vals, NULL );
2626 ptr = strchr(rdn->bv_val, '=');
2627 ad_name.bv_val = rdn->bv_val;
2628 ad_name.bv_len = ptr - rdn->bv_val;
2629 rc = slap_bv2ad( &ad_name, &ad, &text );
2633 vals[0].bv_val = ptr+1;
2634 vals[0].bv_len = rdn->bv_len - (vals[0].bv_val - rdn->bv_val);
2635 attr_merge(e, ad, vals, NULL );
2637 for (at=oc->soc_allowed;*at;at++) {
2638 /* Skip the naming attr */
2639 if ((*at)->sat_ad == ad || (*at)->sat_ad == slap_schema.si_ad_cn )
2641 for (i=0;ct[i].name;i++) {
2642 if (ct[i].ad == (*at)->sat_ad)
2645 rc = config_get_vals(&ct[i], c);
2646 if (rc == LDAP_SUCCESS) {
2647 attr_merge(e, ct[i].ad, c->rvalue_vals, c->rvalue_nvals);
2648 ber_bvarray_free( c->rvalue_nvals );
2649 ber_bvarray_free( c->rvalue_vals );
2654 if ( table == BI_TABLE )
2655 ct = c->bi->bi_cf_table;
2657 ct = c->be->be_cf_table;
2658 for (;ct && ct->name;ct++) {
2659 if (!ct->ad) continue;
2660 rc = config_get_vals(ct, c);
2661 if (rc == LDAP_SUCCESS) {
2662 attr_merge(e, ct->ad, c->rvalue_vals, c->rvalue_nvals);
2670 static CfEntryInfo *
2671 config_build_includes( ConfigArgs *c, Entry *parent )
2675 ConfigFile *cf = (ConfigFile *)c->line;
2676 CfEntryInfo *ce, *ceparent, *ceprev;
2678 ceparent = parent->e_private;
2680 for (i=0; cf; cf=cf->c_sibs, i++) {
2681 c->value_dn.bv_val = c->log;
2682 c->value_dn.bv_len = sprintf(c->value_dn.bv_val, "cn=include{%d}", i);
2683 e = config_alloc_entry( &parent->e_nname, &c->value_dn );
2684 c->line = (char *)cf;
2685 config_build_entry( c, e, cfOc_include, &c->value_dn,
2686 c->bi->bi_cf_table, NO_TABLE );
2688 if ( !ceparent->ce_kids ) {
2689 ceparent->ce_kids = ce;
2691 ceprev->ce_sibs = ce;
2695 c->line = (char *)cf->c_kids;
2696 config_build_includes( c, e );
2703 config_back_db_open( BackendDB *be )
2705 CfBackInfo *cfb = be->be_private;
2708 CfEntryInfo *ce, *ceparent, *ceprev;
2715 /* create root of tree */
2716 ber_str2bv( CONFIG_DN, STRLENOF( CONFIG_DN ), 0, &rdn );
2717 e = config_alloc_entry( NULL, &rdn );
2722 c.line = (char *)cfb->cb_config;
2723 ct = c.bi->bi_cf_table;
2724 config_build_entry( &c, e, cfOc_global, &rdn, ct, NO_TABLE );
2729 /* Create includeFile nodes... */
2730 if ( cfb->cb_config->c_kids ) {
2731 c.line = (char *)cfb->cb_config->c_kids;
2732 ceprev = config_build_includes( &c, parent );
2735 /* Create backend nodes. Skip if they don't provide a cf_table.
2736 * There usually aren't any of these.
2741 for (i=0; i<nBackendInfo; i++, bi++) {
2742 if (!bi->bi_cf_table) continue;
2743 if (!bi->bi_private) continue;
2746 rdn.bv_len = sprintf(rdn.bv_val, "%s=%s", cfAd_backend->ad_cname.bv_val, bi->bi_type);
2747 e = config_alloc_entry( &parent->e_nname, &rdn );
2751 config_build_entry( &c, e, cfOc_backend, &rdn, ct, BI_TABLE );
2752 if ( !ceparent->ce_kids ) {
2753 ceparent->ce_kids = ce;
2755 ceprev->ce_sibs = ce;
2760 /* Create database nodes... */
2761 for (i=0; i<nBackendDB; i++) {
2762 slap_overinfo *oi = NULL;
2766 bptr = &backendDB[i];
2768 if ( overlay_is_over( bptr )) {
2769 oi = bptr->bd_info->bi_private;
2775 rdn.bv_len = sprintf(rdn.bv_val, "%s={%0x}%s", cfAd_database->ad_cname.bv_val,
2777 e = config_alloc_entry( &parent->e_nname, &rdn );
2783 config_build_entry( &c, e, cfOc_database, &rdn, ct, BE_TABLE );
2784 if ( !ceparent->ce_kids ) {
2785 ceparent->ce_kids = ce;
2787 ceprev->ce_sibs = ce;
2790 /* Iterate through overlays */
2794 CfEntryInfo *opar = ce, *oprev = NULL;
2797 for (j=0,on=oi->oi_list; on; j++,on=on->on_next) {
2799 rdn.bv_len = sprintf(rdn.bv_val, "%s={%0x}%s",
2800 cfAd_overlay->ad_cname.bv_val, j, on->on_bi.bi_type );
2801 oe = config_alloc_entry( &e->e_nname, &rdn );
2807 config_build_entry( &c, oe, cfOc_overlay, &rdn, ct, BI_TABLE );
2808 if ( !opar->ce_kids ) {
2811 oprev->ce_sibs = ce;
2822 config_back_db_destroy( Backend *be )
2824 free( be->be_private );
2829 config_back_db_init( Backend *be )
2834 cfb = ch_calloc( 1, sizeof(CfBackInfo));
2835 cfb->cb_config = &cf_prv;
2836 be->be_private = cfb;
2838 ber_str2bv( CONFIG_DN, 0, 1, &be->be_rootdn );
2839 ber_dupbv( &be->be_rootndn, &be->be_rootdn );
2840 ber_dupbv( &dn, &be->be_rootdn );
2841 ber_bvarray_add( &be->be_suffix, &dn );
2842 ber_dupbv( &dn, &be->be_rootdn );
2843 ber_bvarray_add( &be->be_nsuffix, &dn );
2850 AttributeDescription **desc;
2851 AttributeDescription *sub;
2853 { "attribute", NULL, NULL },
2854 { "backend", &cfAd_backend, NULL },
2855 { "database", &cfAd_database, NULL },
2856 { "ditcontentrule", NULL, NULL },
2857 { "include", &cfAd_include, NULL },
2858 { "objectclass", NULL, NULL },
2859 { "overlay", &cfAd_overlay, NULL },
2860 { NULL, NULL, NULL }
2864 config_back_initialize( BackendInfo *bi )
2866 ConfigTable *ct = config_back_cf_table;
2875 bi->bi_db_init = config_back_db_init;
2876 bi->bi_db_config = 0;
2877 bi->bi_db_open = config_back_db_open;
2878 bi->bi_db_close = 0;
2879 bi->bi_db_destroy = config_back_db_destroy;
2881 bi->bi_op_bind = config_back_bind;
2882 bi->bi_op_unbind = 0;
2883 bi->bi_op_search = config_back_search;
2884 bi->bi_op_compare = 0;
2885 bi->bi_op_modify = 0;
2886 bi->bi_op_modrdn = 0;
2888 bi->bi_op_delete = 0;
2889 bi->bi_op_abandon = 0;
2891 bi->bi_extended = 0;
2893 bi->bi_chk_referrals = 0;
2895 bi->bi_connection_init = 0;
2896 bi->bi_connection_destroy = 0;
2899 for (i=0; OidMacros[i].name; i++ ) {
2900 argv[1] = OidMacros[i].name;
2901 argv[2] = OidMacros[i].oid;
2902 parse_oidm( "slapd", i, 3, argv );
2905 i = init_config_attrs( ct );
2908 /* set up the notable AttributeDescriptions */
2909 ads[0].sub = slap_schema.si_ad_attributeTypes;
2910 ads[3].sub = slap_schema.si_ad_ditContentRules;
2911 ads[5].sub = slap_schema.si_ad_objectClasses;
2913 bi->bi_cf_table = ct;
2916 for (;ct->name;ct++) {
2917 if (strcmp(ct->name, ads[i].name)) continue;
2919 ct->ad = ads[i].sub;
2921 *ads[i].desc = ct->ad;
2924 if (!ads[i].name) break;
2927 /* set up the objectclasses */
2928 i = init_config_ocs( cf_ocs );