bconfig.c 112 KB
Newer Older
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* bconfig.c - the config backend */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 *
 * Copyright 2005 The OpenLDAP Foundation.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted only as authorized by the OpenLDAP
 * Public License.
 *
 * A copy of this license is available in the file LICENSE in the
 * top-level directory of the distribution or, alternatively, at
 * <http://www.OpenLDAP.org/license.html>.
 */
/* ACKNOWLEDGEMENTS:
 * This work was originally developed by Howard Chu for inclusion
 * in OpenLDAP Software.
 */

#include "portable.h"

#include <stdio.h>
#include <ac/string.h>
#include <ac/ctype.h>
#include <ac/errno.h>
27
#include <sys/stat.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
28
29
30
31
32
33
34
35
36
37
38
39

#include "slap.h"

#ifdef LDAP_SLAPI
#include "slapi/slapi.h"
#endif

#include <lutil.h>

#include "config.h"

static struct berval config_rdn = BER_BVC("cn=config");
40
41
42
static struct berval schema_rdn = BER_BVC("cn=schema");

#define	IFMT	"{%d}"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
43
44
45
46
47
48
49

#ifdef SLAPD_MODULES
typedef struct modpath_s {
	struct modpath_s *mp_next;
	struct berval mp_path;
	BerVarray mp_loads;
} ModPaths;
50
51

static ModPaths modpaths, *modlast = &modpaths, *modcur = &modpaths;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
52
53
54
55
56
57
#endif

typedef struct ConfigFile {
	struct ConfigFile *c_sibs;
	struct ConfigFile *c_kids;
	struct berval c_file;
58
59
60
61
	AttributeType *c_at_head, *c_at_tail;
	ContentRule *c_cr_head, *c_cr_tail;
	ObjectClass *c_oc_head, *c_oc_tail;
	OidMacro *c_om_head, *c_om_tail;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
62
63
64
65
66
67
	BerVarray c_dseFiles;
} ConfigFile;

typedef struct {
	ConfigFile *cb_config;
	CfEntryInfo *cb_root;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
68
69
	BackendDB	cb_db;	/* underlying database */
	int		cb_got_ldif;
70
	int		cb_use_ldif;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
71
72
73
74
75
76
77
78
79
80
81
82
} CfBackInfo;

/* These do nothing in slapd, they're kept only to make them
 * editable here.
 */
static char *replica_pidFile, *replica_argsFile;
static int replicationInterval;

static char	*passwd_salt;
static char	*logfileName;
static BerVarray authz_rewrites;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
83
84
85
static struct berval cfdir;

/* Private state */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
86
87
88
89
90
static AttributeDescription *cfAd_backend, *cfAd_database, *cfAd_overlay,
	*cfAd_include;

static ConfigFile cf_prv, *cfn = &cf_prv;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
91
92
static Avlnode *CfOcTree;

93
94
static int config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca,
	SlapReply *rs, int *renumber );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
95
96

static ConfigDriver config_fname;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
97
static ConfigDriver config_cfdir;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
static ConfigDriver config_generic;
static ConfigDriver config_search_base;
static ConfigDriver config_passwd_hash;
static ConfigDriver config_schema_dn;
static ConfigDriver config_sizelimit;
static ConfigDriver config_timelimit;
static ConfigDriver config_overlay;
static ConfigDriver config_suffix; 
static ConfigDriver config_deref_depth;
static ConfigDriver config_rootdn;
static ConfigDriver config_rootpw;
static ConfigDriver config_restrict;
static ConfigDriver config_allows;
static ConfigDriver config_disallows;
static ConfigDriver config_requires;
static ConfigDriver config_security;
static ConfigDriver config_referral;
static ConfigDriver config_loglevel;
static ConfigDriver config_replica;
static ConfigDriver config_updatedn;
static ConfigDriver config_updateref;
static ConfigDriver config_include;
#ifdef HAVE_TLS
static ConfigDriver config_tls_option;
static ConfigDriver config_tls_config;
#endif
124
extern ConfigDriver syncrepl_config;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

enum {
	CFG_ACL = 1,
	CFG_BACKEND,
	CFG_DATABASE,
	CFG_TLS_RAND,
	CFG_TLS_CIPHER,
	CFG_TLS_CERT_FILE,
	CFG_TLS_CERT_KEY,
	CFG_TLS_CA_PATH,
	CFG_TLS_CA_FILE,
	CFG_TLS_VERIFY,
	CFG_TLS_CRLCHECK,
	CFG_CONCUR,
	CFG_THREADS,
	CFG_SALT,
	CFG_LIMITS,
	CFG_RO,
	CFG_REWRITE,
	CFG_DEPTH,
	CFG_OID,
	CFG_OC,
	CFG_DIT,
	CFG_ATTR,
	CFG_ATOPT,
	CFG_REPLOG,
	CFG_ROOTDSE,
	CFG_LOGFILE,
	CFG_PLUGIN,
	CFG_MODLOAD,
	CFG_MODPATH,
	CFG_LASTMOD,
	CFG_AZPOLICY,
	CFG_AZREGEXP,
	CFG_SASLSECP,
	CFG_SSTR_IF_MAX,
	CFG_SSTR_IF_MIN,
};

typedef struct {
	char *name, *oid;
} OidRec;

static OidRec OidMacros[] = {
	/* OpenLDAProot:666.11.1 */
	{ "OLcfg", "1.3.6.1.4.1.4203.666.11.1" },
	{ "OLcfgAt", "OLcfg:3" },
172
173
174
175
	{ "OLcfgGlAt", "OLcfgAt:0" },
	{ "OLcfgBkAt", "OLcfgAt:1" },
	{ "OLcfgDbAt", "OLcfgAt:2" },
	{ "OLcfgOvAt", "OLcfgAt:3" },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
176
	{ "OLcfgOc", "OLcfg:4" },
177
178
179
180
	{ "OLcfgGlOc", "OLcfgOc:0" },
	{ "OLcfgBkOc", "OLcfgOc:1" },
	{ "OLcfgDbOc", "OLcfgOc:2" },
	{ "OLcfgOvOc", "OLcfgOc:3" },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
181
	{ "OMsyn", "1.3.6.1.4.1.1466.115.121.1" },
182
	{ "OMsInteger", "OMsyn:27" },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
183
184
185
186
187
188
189
	{ "OMsBoolean", "OMsyn:7" },
	{ "OMsDN", "OMsyn:12" },
	{ "OMsDirectoryString", "OMsyn:15" },
	{ "OMsOctetString", "OMsyn:40" },
	{ NULL, NULL }
};

190
191
192
193
194
195
196
/*
 * OLcfg{Bk|Db}{Oc|At}:0		-> common
 * OLcfg{Bk|Db}{Oc|At}:1		-> bdb
 * OLcfg{Bk|Db}{Oc|At}:2		-> ldif
 * OLcfg{Bk|Db}{Oc|At}:3		-> ldap?
 */

Kurt Zeilenga's avatar
Kurt Zeilenga committed
197
198
/* alphabetical ordering */

199
static ConfigTable config_back_cf_table[] = {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
200
201
	/* This attr is read-only */
	{ "", "", 0, 0, 0, ARG_MAGIC,
202
		&config_fname, "( OLcfgGlAt:78 NAME 'olcConfigFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
203
204
205
			"DESC 'File for slapd configuration directives' "
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
206
	{ "", "", 0, 0, 0, ARG_MAGIC,
207
		&config_cfdir, "( OLcfgGlAt:79 NAME 'olcConfigDir' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
208
209
210
			"DESC 'Directory for slapd configuration backend' "
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
211
	{ "access",	NULL, 0, 0, 0, ARG_MAY_DB|ARG_MAGIC|CFG_ACL,
212
		&config_generic, "( OLcfgGlAt:1 NAME 'olcAccess' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
213
214
215
216
			"DESC 'Access Control List' "
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
	{ "allows",	"features", 2, 0, 5, ARG_PRE_DB|ARG_MAGIC,
217
		&config_allows, "( OLcfgGlAt:2 NAME 'olcAllows' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
218
219
220
221
			"DESC 'Allowed set of deprecated features' "
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString )", NULL, NULL },
	{ "argsfile", "file", 2, 2, 0, ARG_STRING,
222
		&slapd_args_file, "( OLcfgGlAt:3 NAME 'olcArgsFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
223
224
225
			"DESC 'File for slapd command line options' "
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
226
227
228
229
230
231
232
	{ "attribute",	"attribute", 2, 0, 9,
		ARG_PAREN|ARG_MAGIC|CFG_ATTR|ARG_NO_DELETE|ARG_NO_INSERT,
		&config_generic, "( OLcfgGlAt:4 NAME 'olcAttributeTypes' "
			"DESC 'OpenLDAP attributeTypes' "
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
				NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
233
	{ "attributeoptions", NULL, 0, 0, 0, ARG_MAGIC|CFG_ATOPT,
234
		&config_generic, "( OLcfgGlAt:5 NAME 'olcAttributeOptions' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
235
236
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString )", NULL, NULL },
237
	{ "authid-rewrite", NULL, 2, 0, STRLENOF( "authid-rewrite" ),
Kurt Zeilenga's avatar
Kurt Zeilenga committed
238
#ifdef SLAP_AUTH_REWRITE
239
		ARG_MAGIC|CFG_REWRITE|ARG_NO_INSERT, &config_generic,
Kurt Zeilenga's avatar
Kurt Zeilenga committed
240
241
242
#else
		ARG_IGNORED, NULL,
#endif
243
		 "( OLcfgGlAt:6 NAME 'olcAuthIDRewrite' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
244
245
246
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
	{ "authz-policy", "policy", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_AZPOLICY,
247
		&config_generic, "( OLcfgGlAt:7 NAME 'olcAuthzPolicy' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
248
249
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
250
251
	{ "authz-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP|ARG_NO_INSERT,
		&config_generic, "( OLcfgGlAt:8 NAME 'olcAuthzRegexp' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
252
253
254
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
	{ "backend", "type", 2, 2, 0, ARG_PRE_DB|ARG_MAGIC|CFG_BACKEND,
255
		&config_generic, "( OLcfgGlAt:9 NAME 'olcBackend' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
256
257
			"DESC 'A type of backend' "
			"EQUALITY caseIgnoreMatch "
258
259
260
261
			"SYNTAX OMsDirectoryString SINGLE-VALUE X-ORDERED 'SIBLINGS' )",
				NULL, NULL },
	{ "concurrency", "level", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_CONCUR,
		&config_generic, "( OLcfgGlAt:10 NAME 'olcConcurrency' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
262
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
263
	{ "conn_max_pending", "max", 2, 2, 0, ARG_INT,
264
		&slap_conn_max_pending, "( OLcfgGlAt:11 NAME 'olcConnMaxPending' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
265
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
266
	{ "conn_max_pending_auth", "max", 2, 2, 0, ARG_INT,
267
		&slap_conn_max_pending_auth, "( OLcfgGlAt:12 NAME 'olcConnMaxPendingAuth' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
268
269
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "database", "type", 2, 2, 0, ARG_MAGIC|CFG_DATABASE,
270
		&config_generic, "( OLcfgGlAt:13 NAME 'olcDatabase' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
271
			"DESC 'The backend type for a database instance' "
272
			"SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
273
	{ "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_MAGIC,
274
		&config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
275
276
			"SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
	{ "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
277
		&config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
278
279
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString )", NULL, NULL },
280
281
282
283
284
285
	{ "ditcontentrule",	NULL, 0, 0, 0, ARG_MAGIC|CFG_DIT|ARG_NO_DELETE|ARG_NO_INSERT,
		&config_generic, "( OLcfgGlAt:16 NAME 'olcDitContentRules' "
			"DESC 'OpenLDAP DIT content rules' "
			"EQUALITY caseIgnoreMatch "
			"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
			NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
286
287
288
289
290
291
	{ "gentlehup", "on|off", 2, 2, 0,
#ifdef SIGHUP
		ARG_ON_OFF, &global_gentlehup,
#else
		ARG_IGNORED, NULL,
#endif
292
		"( OLcfgGlAt:17 NAME 'olcGentleHUP' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
293
294
			"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
	{ "idletimeout", "timeout", 2, 2, 0, ARG_INT,
295
		&global_idletimeout, "( OLcfgGlAt:18 NAME 'olcIdleTimeout' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
296
297
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "include", "file", 2, 2, 0, ARG_MAGIC,
298
		&config_include, "( OLcfgGlAt:19 NAME 'olcInclude' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
299
300
			"SUP labeledURI )", NULL, NULL },
	{ "index_substr_if_minlen", "min", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MIN,
301
		&config_generic, "( OLcfgGlAt:20 NAME 'olcIndexSubstrIfMinLen' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
302
303
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "index_substr_if_maxlen", "max", 2, 2, 0, ARG_INT|ARG_NONZERO|ARG_MAGIC|CFG_SSTR_IF_MAX,
304
		&config_generic, "( OLcfgGlAt:21 NAME 'olcIndexSubstrIfMaxLen' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
305
306
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "index_substr_any_len", "len", 2, 2, 0, ARG_INT|ARG_NONZERO,
307
		&index_substr_any_len, "( OLcfgGlAt:22 NAME 'olcIndexSubstrAnyLen' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
308
309
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "index_substr_step", "step", 2, 2, 0, ARG_INT|ARG_NONZERO,
310
		&index_substr_any_step, "( OLcfgGlAt:23 NAME 'olcIndexSubstrAnyStep' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
311
312
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "lastmod", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_LASTMOD,
313
		&config_generic, "( OLcfgDbAt:0.4 NAME 'olcLastMod' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
314
315
			"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
	{ "limits", "limits", 2, 0, 0, ARG_DB|ARG_MAGIC|CFG_LIMITS,
316
		&config_generic, "( OLcfgDbAt:0.5 NAME 'olcLimits' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
317
			"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
318
	{ "localSSF", "ssf", 2, 2, 0, ARG_INT,
319
		&local_ssf, "( OLcfgGlAt:26 NAME 'olcLocalSSF' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
320
321
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "logfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_LOGFILE,
322
		&config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
323
324
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "loglevel", "level", 2, 0, 0, ARG_MAGIC,
325
		&config_loglevel, "( OLcfgGlAt:28 NAME 'olcLogLevel' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
326
327
			"SYNTAX OMsDirectoryString )", NULL, NULL },
	{ "maxDerefDepth", "depth", 2, 2, 0, ARG_DB|ARG_INT|ARG_MAGIC|CFG_DEPTH,
328
		&config_generic, "( OLcfgDbAt:0.6 NAME 'olcMaxDerefDepth' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
329
330
331
332
333
334
335
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "moduleload",	"file", 2, 0, 0,
#ifdef SLAPD_MODULES
		ARG_MAGIC|CFG_MODLOAD, &config_generic,
#else
		ARG_IGNORED, NULL,
#endif
336
		"( OLcfgGlAt:30 NAME 'olcModuleLoad' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
337
338
339
			"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
	{ "modulepath", "path", 2, 2, 0,
#ifdef SLAPD_MODULES
340
		ARG_MAGIC|CFG_MODPATH|ARG_NO_DELETE|ARG_NO_INSERT, &config_generic,
Kurt Zeilenga's avatar
Kurt Zeilenga committed
341
342
343
#else
		ARG_IGNORED, NULL,
#endif
344
345
346
347
348
349
350
351
		"( OLcfgGlAt:31 NAME 'olcModulePath' "
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "objectclass", "objectclass", 2, 0, 0, ARG_PAREN|ARG_MAGIC|CFG_OC|ARG_NO_DELETE|ARG_NO_INSERT,
		&config_generic, "( OLcfgGlAt:32 NAME 'olcObjectClasses' "
		"DESC 'OpenLDAP object classes' "
		"EQUALITY caseIgnoreMatch "
		"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
			NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
352
	{ "objectidentifier", NULL,	0, 0, 0, ARG_MAGIC|CFG_OID,
353
		&config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
354
355
			"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
	{ "overlay", "overlay", 2, 2, 0, ARG_MAGIC,
356
357
		&config_overlay, "( OLcfgGlAt:34 NAME 'olcOverlay' "
			"SUP olcDatabase SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
358
	{ "password-crypt-salt-format", "salt", 2, 2, 0, ARG_STRING|ARG_MAGIC|CFG_SALT,
359
		&config_generic, "( OLcfgGlAt:35 NAME 'olcPasswordCryptSaltFormat' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
360
361
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "password-hash", "hash", 2, 2, 0, ARG_MAGIC,
362
		&config_passwd_hash, "( OLcfgGlAt:36 NAME 'olcPasswordHash' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
363
364
			"SYNTAX OMsDirectoryString )", NULL, NULL },
	{ "pidfile", "file", 2, 2, 0, ARG_STRING,
365
		&slapd_pid_file, "( OLcfgGlAt:37 NAME 'olcPidFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
366
367
368
369
370
371
372
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "plugin", NULL, 0, 0, 0,
#ifdef LDAP_SLAPI
		ARG_MAGIC|CFG_PLUGIN, &config_generic,
#else
		ARG_IGNORED, NULL,
#endif
373
		"( OLcfgGlAt:38 NAME 'olcPlugin' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
374
375
376
377
378
379
380
			"SYNTAX OMsDirectoryString )", NULL, NULL },
	{ "pluginlog", "filename", 2, 2, 0,
#ifdef LDAP_SLAPI
		ARG_STRING, &slapi_log_file,
#else
		ARG_IGNORED, NULL,
#endif
381
		"( OLcfgGlAt:39 NAME 'olcPluginLogFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
382
383
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "readonly", "on|off", 2, 2, 0, ARG_MAY_DB|ARG_ON_OFF|ARG_MAGIC|CFG_RO,
384
		&config_generic, "( OLcfgGlAt:40 NAME 'olcReadOnly' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
385
386
			"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
	{ "referral", "url", 2, 2, 0, ARG_MAGIC,
387
		&config_referral, "( OLcfgGlAt:41 NAME 'olcReferral' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
388
389
			"SUP labeledURI SINGLE-VALUE )", NULL, NULL },
	{ "replica", "host or uri", 2, 0, 0, ARG_DB|ARG_MAGIC,
390
		&config_replica, "( OLcfgDbAt:0.7 NAME 'olcReplica' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
391
392
			"SUP labeledURI )", NULL, NULL },
	{ "replica-argsfile", NULL, 0, 0, 0, ARG_STRING,
393
		&replica_argsFile, "( OLcfgGlAt:43 NAME 'olcReplicaArgsFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
394
395
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "replica-pidfile", NULL, 0, 0, 0, ARG_STRING,
396
		&replica_pidFile, "( OLcfgGlAt:44 NAME 'olcReplicaPidFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
397
398
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "replicationInterval", NULL, 0, 0, 0, ARG_INT,
399
		&replicationInterval, "( OLcfgGlAt:45 NAME 'olcReplicationInterval' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
400
401
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "replogfile", "filename", 2, 2, 0, ARG_MAY_DB|ARG_MAGIC|ARG_STRING|CFG_REPLOG,
402
		&config_generic, "( OLcfgGlAt:46 NAME 'olcReplogFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
403
404
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "require", "features", 2, 0, 7, ARG_MAY_DB|ARG_MAGIC,
405
		&config_requires, "( OLcfgGlAt:47 NAME 'olcRequires' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
406
407
			"SYNTAX OMsDirectoryString )", NULL, NULL },
	{ "restrict", "op_list", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
408
		&config_restrict, "( OLcfgGlAt:48 NAME 'olcRestrict' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
409
410
411
412
413
414
415
			"SYNTAX OMsDirectoryString )", NULL, NULL },
	{ "reverse-lookup", "on|off", 2, 2, 0,
#ifdef SLAPD_RLOOKUPS
		ARG_ON_OFF, &use_reverse_lookup,
#else
		ARG_IGNORED, NULL,
#endif
416
		"( OLcfgGlAt:49 NAME 'olcReverseLookup' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
417
418
			"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
	{ "rootdn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
419
		&config_rootdn, "( OLcfgDbAt:0.8 NAME 'olcRootDN' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
420
421
			"SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
	{ "rootDSE", "file", 2, 2, 0, ARG_MAGIC|CFG_ROOTDSE,
422
		&config_generic, "( OLcfgGlAt:51 NAME 'olcRootDSE' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
423
			"SYNTAX OMsDirectoryString )", NULL, NULL },
424
425
426
	{ "rootpw", "password", 2, 2, 0, ARG_BERVAL|ARG_DB|ARG_MAGIC,
		&config_rootpw, "( OLcfgDbAt:0.9 NAME 'olcRootPW' "
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
427
428
429
430
431
432
433
434
	{ "sasl-authz-policy", NULL, 2, 2, 0, ARG_MAGIC|CFG_AZPOLICY,
		&config_generic, NULL, NULL, NULL },
	{ "sasl-host", "host", 2, 2, 0,
#ifdef HAVE_CYRUS_SASL
		ARG_STRING|ARG_UNIQUE, &global_host,
#else
		ARG_IGNORED, NULL,
#endif
435
		"( OLcfgGlAt:53 NAME 'olcSaslHost' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
436
437
438
439
440
441
442
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "sasl-realm", "realm", 2, 2, 0,
#ifdef HAVE_CYRUS_SASL
		ARG_STRING|ARG_UNIQUE, &global_realm,
#else
		ARG_IGNORED, NULL,
#endif
443
		"( OLcfgGlAt:54 NAME 'olcSaslRealm' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
444
445
446
447
448
449
450
451
452
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "sasl-regexp", NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
		&config_generic, NULL, NULL, NULL },
	{ "sasl-secprops", "properties", 2, 2, 0,
#ifdef HAVE_CYRUS_SASL
		ARG_MAGIC|CFG_SASLSECP, &config_generic,
#else
		ARG_IGNORED, NULL,
#endif
453
		"( OLcfgGlAt:56 NAME 'olcSaslSecProps' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
454
455
456
457
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "saslRegexp",	NULL, 3, 3, 0, ARG_MAGIC|CFG_AZREGEXP,
		&config_generic, NULL, NULL, NULL },
	{ "schemadn", "dn", 2, 2, 0, ARG_MAY_DB|ARG_DN|ARG_MAGIC,
458
		&config_schema_dn, "( OLcfgGlAt:58 NAME 'olcSchemaDN' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
459
460
			"SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
	{ "security", "factors", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
461
		&config_security, "( OLcfgGlAt:59 NAME 'olcSecurity' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
462
			"SYNTAX OMsDirectoryString )", NULL, NULL },
463
464
465
	{ "sizelimit", "limit",	2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
		&config_sizelimit, "( OLcfgGlAt:60 NAME 'olcSizeLimit' "
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
466
	{ "sockbuf_max_incoming", "max", 2, 2, 0, ARG_BER_LEN_T,
467
		&sockbuf_max_incoming, "( OLcfgGlAt:61 NAME 'olcSockbufMaxIncoming' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
468
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
469
	{ "sockbuf_max_incoming_auth", "max", 2, 2, 0, ARG_BER_LEN_T,
470
		&sockbuf_max_incoming_auth, "( OLcfgGlAt:62 NAME 'olcSockbufMaxIncomingAuth' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
471
472
473
474
475
476
477
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
	{ "srvtab", "file", 2, 2, 0,
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
		ARG_STRING, &ldap_srvtab,
#else
		ARG_IGNORED, NULL,
#endif
478
		"( OLcfgGlAt:63 NAME 'olcSrvtab' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
479
480
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "suffix",	"suffix", 2, 2, 0, ARG_DB|ARG_DN|ARG_MAGIC,
481
		&config_suffix, "( OLcfgDbAt:0.10 NAME 'olcSuffix' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
482
483
			"SYNTAX OMsDN )", NULL, NULL },
	{ "syncrepl", NULL, 0, 0, 0, ARG_DB|ARG_MAGIC,
484
		&syncrepl_config, "( OLcfgDbAt:0.11 NAME 'olcSyncrepl' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
485
486
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_THREADS,
487
		&config_generic, "( OLcfgGlAt:66 NAME 'olcThreads' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
488
			"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
489
490
491
	{ "timelimit", "limit", 2, 0, 0, ARG_MAY_DB|ARG_MAGIC,
		&config_timelimit, "( OLcfgGlAt:67 NAME 'olcTimeLimit' "
			"SYNTAX OMsDirectoryString )", NULL, NULL },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
492
493
494
495
496
497
	{ "TLSCACertificateFile", NULL, 0, 0, 0,
#ifdef HAVE_TLS
		CFG_TLS_CA_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
#else
		ARG_IGNORED, NULL,
#endif
498
		"( OLcfgGlAt:68 NAME 'olcTLSCACertificateFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
499
500
501
502
503
504
505
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "TLSCACertificatePath", NULL,	0, 0, 0,
#ifdef HAVE_TLS
		CFG_TLS_CA_PATH|ARG_STRING|ARG_MAGIC, &config_tls_option,
#else
		ARG_IGNORED, NULL,
#endif
506
		"( OLcfgGlAt:69 NAME 'olcTLSCACertificatePath' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
507
508
509
510
511
512
513
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "TLSCertificateFile", NULL, 0, 0, 0,
#ifdef HAVE_TLS
		CFG_TLS_CERT_FILE|ARG_STRING|ARG_MAGIC, &config_tls_option,
#else
		ARG_IGNORED, NULL,
#endif
514
		"( OLcfgGlAt:70 NAME 'olcTLSCertificateFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
515
516
517
518
519
520
521
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "TLSCertificateKeyFile", NULL, 0, 0, 0,
#ifdef HAVE_TLS
		CFG_TLS_CERT_KEY|ARG_STRING|ARG_MAGIC, &config_tls_option,
#else
		ARG_IGNORED, NULL,
#endif
522
		"( OLcfgGlAt:71 NAME 'olcTLSCertificateKeyFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
523
524
525
526
527
528
529
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "TLSCipherSuite",	NULL, 0, 0, 0,
#ifdef HAVE_TLS
		CFG_TLS_CIPHER|ARG_STRING|ARG_MAGIC, &config_tls_option,
#else
		ARG_IGNORED, NULL,
#endif
530
		"( OLcfgGlAt:72 NAME 'olcTLSCipherSuite' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
531
532
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "TLSCRLCheck", NULL, 0, 0, 0,
533
#if defined(HAVE_TLS) && defined(HAVE_OPENSSL_CRL)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
534
535
536
537
		CFG_TLS_CRLCHECK|ARG_STRING|ARG_MAGIC, &config_tls_config,
#else
		ARG_IGNORED, NULL,
#endif
538
		"( OLcfgGlAt:73 NAME 'olcTLSCRLCheck' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
539
540
541
542
543
544
545
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "TLSRandFile", NULL, 0, 0, 0,
#ifdef HAVE_TLS
		CFG_TLS_RAND|ARG_STRING|ARG_MAGIC, &config_tls_option,
#else
		ARG_IGNORED, NULL,
#endif
546
		"( OLcfgGlAt:74 NAME 'olcTLSRandFile' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
547
548
549
550
551
552
553
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "TLSVerifyClient", NULL, 0, 0, 0,
#ifdef HAVE_TLS
		CFG_TLS_VERIFY|ARG_STRING|ARG_MAGIC, &config_tls_config,
#else
		ARG_IGNORED, NULL,
#endif
554
		"( OLcfgGlAt:75 NAME 'olcTLSVerifyClient' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
555
556
557
558
			"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
	{ "ucdata-path", "path", 2, 2, 0, ARG_IGNORED,
		NULL, NULL, NULL, NULL },
	{ "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_MAGIC,
559
		&config_updatedn, "( OLcfgDbAt:0.12 NAME 'olcUpdateDN' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
560
561
			"SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
	{ "updateref", "url", 2, 2, 0, ARG_DB|ARG_MAGIC,
562
		&config_updateref, "( OLcfgDbAt:0.13 NAME 'olcUpdateRef' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
563
564
565
566
567
			"SUP labeledURI )", NULL, NULL },
	{ NULL,	NULL, 0, 0, 0, ARG_IGNORED,
		NULL, NULL, NULL, NULL }
};

568
569
570
571
572
573
574
575
576
577
578
579
/* Routines to check if a child can be added to this type */
static ConfigLDAPadd cfAddSchema, cfAddInclude, cfAddDatabase,
	cfAddBackend, cfAddModule, cfAddOverlay;

#define CFOC_GLOBAL	cf_ocs[1]
#define CFOC_SCHEMA	cf_ocs[2]
#define CFOC_BACKEND	cf_ocs[3]
#define CFOC_DATABASE	cf_ocs[4]
#define CFOC_OVERLAY	cf_ocs[5]
#define CFOC_INCLUDE	cf_ocs[6]
#define CFOC_MODULE	cf_ocs[7]

Kurt Zeilenga's avatar
Kurt Zeilenga committed
580
static ConfigOCs cf_ocs[] = {
581
	{ "( OLcfgGlOc:1 "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
582
583
		"NAME 'olcConfig' "
		"DESC 'OpenLDAP configuration object' "
584
585
		"ABSTRACT SUP top )", Cft_Abstract, NULL },
	{ "( OLcfgGlOc:2 "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
586
587
588
		"NAME 'olcGlobal' "
		"DESC 'OpenLDAP Global configuration options' "
		"SUP olcConfig STRUCTURAL "
589
590
591
592
593
594
		"MAY ( cn $ olcConfigFile $ olcConfigDir $ olcAllows $ olcArgsFile $ "
		 "olcAttributeOptions $ olcAuthIDRewrite $ "
		 "olcAuthzPolicy $ olcAuthzRegexp $ olcConcurrency $ "
		 "olcConnMaxPending $ olcConnMaxPendingAuth $ olcDefaultSearchBase $ "
		 "olcDisallows $ olcGentleHUP $ olcIdleTimeout $ "
		 "olcIndexSubstrIfMaxLen $ olcIndexSubstrIfMinLen $ "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
595
		 "olcIndexSubstrAnyLen $ olcIndexSubstrAnyStep $ olcLocalSSF $ "
596
		 "olcLogLevel $ "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
597
		 "olcPasswordCryptSaltFormat $ olcPasswordHash $ olcPidFile $ "
598
		 "olcPluginLogFile $ olcReadOnly $ olcReferral $ "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
599
600
		 "olcReplicaPidFile $ olcReplicaArgsFile $ olcReplicationInterval $ "
		 "olcReplogFile $ olcRequires $ olcRestrict $ olcReverseLookup $ "
601
602
		 "olcRootDSE $ olcRootPW $ "
		 "olcSaslHost $ olcSaslRealm $ olcSaslSecProps $ "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
603
		 "olcSecurity $ olcSizeLimit $ "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
604
605
606
607
		 "olcSockbufMaxIncoming $ olcSockbufMaxIncomingAuth $ olcSrvtab $ "
		 "olcThreads $ olcTimeLimit $ olcTLSCACertificateFile $ "
		 "olcTLSCACertificatePath $ olcTLSCertificateFile $ "
		 "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ "
608
609
		 "olcTLSRandFile $ olcTLSVerifyClient $ "
		 "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ "
610
		 "olcDitContentRules ) )", Cft_Global },
611
612
613
614
615
616
	{ "( OLcfgGlOc:3 "
		"NAME 'olcSchemaConfig' "
		"DESC 'OpenLDAP schema object' "
		"SUP olcConfig STRUCTURAL "
		"MAY ( cn $ olcObjectIdentifier $ olcAttributeTypes $ "
		 "olcObjectClasses $ olcDitContentRules ) )",
617
		 	Cft_Schema, NULL, cfAddSchema },
618
	{ "( OLcfgGlOc:4 "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
619
620
621
		"NAME 'olcBackendConfig' "
		"DESC 'OpenLDAP Backend-specific options' "
		"SUP olcConfig STRUCTURAL "
622
		"MUST olcBackend )", Cft_Backend, NULL, cfAddBackend },
623
	{ "( OLcfgGlOc:5 "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
624
625
626
		"NAME 'olcDatabaseConfig' "
		"DESC 'OpenLDAP Database-specific options' "
		"SUP olcConfig STRUCTURAL "
627
628
		"MUST olcDatabase "
		"MAY ( olcSuffix $ olcAccess $ olcLastMod $ olcLimits $ "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
629
630
		 "olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
		 "olcReplogFile $ olcRequires $ olcRestrict $ olcRootDN $ olcRootPW $ "
631
632
		 "olcSchemaDN $ olcSecurity $ olcSizeLimit $ olcSyncrepl $ "
		 "olcTimeLimit $ olcUpdateDN $ olcUpdateRef ) )",
633
		 	Cft_Database, NULL, cfAddDatabase },
634
635
636
637
	{ "( OLcfgGlOc:6 "
		"NAME 'olcOverlayConfig' "
		"DESC 'OpenLDAP Overlay-specific options' "
		"SUP olcConfig STRUCTURAL "
638
		"MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
639
	{ "( OLcfgGlOc:7 "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
640
641
642
		"NAME 'olcIncludeFile' "
		"DESC 'OpenLDAP configuration include file' "
		"SUP olcConfig STRUCTURAL "
643
644
		"MUST olcInclude "
		"MAY ( cn $ olcRootDSE ) )",
645
		Cft_Include, NULL, cfAddInclude },
646
647
648
649
#ifdef SLAPD_MODULES
	{ "( OLcfgGlOc:8 "
		"NAME 'olcModuleList' "
		"DESC 'OpenLDAP dynamic module info' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
650
		"SUP olcConfig STRUCTURAL "
651
652
		"MAY ( cn $ olcModulePath $ olcModuleLoad ) )",
		Cft_Module, NULL, cfAddModule },
653
654
#endif
	{ NULL, 0, NULL }
Kurt Zeilenga's avatar
Kurt Zeilenga committed
655
656
657
658
659
660
661
};

static int
config_generic(ConfigArgs *c) {
	char *p;
	int i;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
662
	if ( c->op == SLAP_CONFIG_EMIT ) {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
		int rc = 0;
		switch(c->type) {
		case CFG_CONCUR:
			c->value_int = ldap_pvt_thread_get_concurrency();
			break;
		case CFG_THREADS:
			c->value_int = connection_pool_max;
			break;
		case CFG_SALT:
			if ( passwd_salt )
				c->value_string = ch_strdup( passwd_salt );
			else
				rc = 1;
			break;
		case CFG_LIMITS:
			if ( c->be->be_limits ) {
				char buf[4096*3];
				struct berval bv;
				int i;

				for ( i=0; c->be->be_limits[i]; i++ ) {
684
					bv.bv_len = sprintf( buf, IFMT, i );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
					bv.bv_val = buf+bv.bv_len;
					limits_unparse( c->be->be_limits[i], &bv );
					bv.bv_len += bv.bv_val - buf;
					bv.bv_val = buf;
					value_add_one( &c->rvalue_vals, &bv );
				}
			}
			if ( !c->rvalue_vals ) rc = 1;
			break;
		case CFG_RO:
			c->value_int = (c->be->be_restrictops & SLAP_RESTRICT_OP_WRITES) != 0;
			break;
		case CFG_AZPOLICY:
			c->value_string = ch_strdup( slap_sasl_getpolicy());
			break;
		case CFG_AZREGEXP:
			slap_sasl_regexp_unparse( &c->rvalue_vals );
			if ( !c->rvalue_vals ) rc = 1;
			break;
#ifdef HAVE_CYRUS_SASL
		case CFG_SASLSECP: {
			struct berval bv = BER_BVNULL;
			slap_sasl_secprops_unparse( &bv );
			if ( !BER_BVISNULL( &bv )) {
				ber_bvarray_add( &c->rvalue_vals, &bv );
			} else {
				rc = 1;
			}
			}
			break;
#endif
		case CFG_DEPTH:
			c->value_int = c->be->be_max_deref_depth;
			break;
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
		case CFG_OID: {
			ConfigFile *cf = c->private;
			if ( !cf )
				oidm_unparse( &c->rvalue_vals, NULL, NULL, 1 );
			else if ( cf->c_om_head )
				oidm_unparse( &c->rvalue_vals, cf->c_om_head,
					cf->c_om_tail, 0 );
			if ( !c->rvalue_vals )
				rc = 1;
			}
			break;
		case CFG_OC: {
			ConfigFile *cf = c->private;
			if ( !cf )
				oc_unparse( &c->rvalue_vals, NULL, NULL, 1 );
			else if ( cf->c_oc_head )
				oc_unparse( &c->rvalue_vals, cf->c_oc_head,
					cf->c_oc_tail, 0 );
			if ( !c->rvalue_vals )
				rc = 1;
			}
			break;
		case CFG_ATTR: {
			ConfigFile *cf = c->private;
			if ( !cf )
				at_unparse( &c->rvalue_vals, NULL, NULL, 1 );
			else if ( cf->c_at_head )
				at_unparse( &c->rvalue_vals, cf->c_at_head,
					cf->c_at_tail, 0 );
			if ( !c->rvalue_vals )
				rc = 1;
			}
			break;
		case CFG_DIT: {
			ConfigFile *cf = c->private;
			if ( !cf )
				cr_unparse( &c->rvalue_vals, NULL, NULL, 1 );
			else if ( cf->c_cr_head )
				cr_unparse( &c->rvalue_vals, cf->c_cr_head,
					cf->c_cr_tail, 0 );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
759
760
			if ( !c->rvalue_vals )
				rc = 1;
761
			}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
762
			break;
763
			
Kurt Zeilenga's avatar
Kurt Zeilenga committed
764
765
766
767
768
		case CFG_ACL: {
			AccessControl *a;
			char *src, *dst, ibuf[11];
			struct berval bv, abv;
			for (i=0, a=c->be->be_acl; a; i++,a=a->acl_next) {
769
				abv.bv_len = sprintf( ibuf, IFMT, i );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
				acl_unparse( a, &bv );
				abv.bv_val = ch_malloc( abv.bv_len + bv.bv_len + 1 );
				AC_MEMCPY( abv.bv_val, ibuf, abv.bv_len );
				/* Turn TAB / EOL into plain space */
				for (src=bv.bv_val,dst=abv.bv_val+abv.bv_len; *src; src++) {
					if (isspace(*src)) *dst++ = ' ';
					else *dst++ = *src;
				}
				*dst = '\0';
				if (dst[-1] == ' ') {
					dst--;
					*dst = '\0';
				}
				abv.bv_len = dst - abv.bv_val;
				ber_bvarray_add( &c->rvalue_vals, &abv );
			}
			rc = (!i);
			break;
		}
		case CFG_REPLOG:
			if ( c->be->be_replogfile )
				c->value_string = ch_strdup( c->be->be_replogfile );
			break;
		case CFG_ROOTDSE: {
794
			ConfigFile *cf = c->private;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
			if ( cf->c_dseFiles ) {
				value_add( &c->rvalue_vals, cf->c_dseFiles );
			} else {
				rc = 1;
			}
			}
			break;
		case CFG_LOGFILE:
			if ( logfileName )
				c->value_string = ch_strdup( logfileName );
			else
				rc = 1;
			break;
		case CFG_LASTMOD:
			c->value_int = (SLAP_NOLASTMOD(c->be) == 0);
			break;
		case CFG_SSTR_IF_MAX:
			c->value_int = index_substr_if_maxlen;
			break;
		case CFG_SSTR_IF_MIN:
			c->value_int = index_substr_if_minlen;
			break;
#ifdef SLAPD_MODULES
		case CFG_MODLOAD: {
819
820
821
822
			ModPaths *mp = c->private;
			if (mp->mp_loads) {
				int i;
				for (i=0; !BER_BVISNULL(&mp->mp_loads[i]); i++) {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
823
824
					struct berval bv;
					bv.bv_val = c->log;
825
826
					bv.bv_len = sprintf( bv.bv_val, IFMT "%s", i,
						mp->mp_loads[i].bv_val );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
827
828
829
					value_add_one( &c->rvalue_vals, &bv );
				}
			}
830

Kurt Zeilenga's avatar
Kurt Zeilenga committed
831
832
833
834
			rc = c->rvalue_vals ? 0 : 1;
			}
			break;
		case CFG_MODPATH: {
835
			ModPaths *mp = c->private;
836
837
			if ( !BER_BVISNULL( &mp->mp_path ))
				value_add_one( &c->rvalue_vals, &mp->mp_path );
838

Kurt Zeilenga's avatar
Kurt Zeilenga committed
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
			rc = c->rvalue_vals ? 0 : 1;
			}
			break;
#endif
#ifdef LDAP_SLAPI
		case CFG_PLUGIN:
			slapi_int_plugin_unparse( c->be, &c->rvalue_vals );
			if ( !c->rvalue_vals ) rc = 1;
			break;
#endif
#ifdef SLAP_AUTH_REWRITE
		case CFG_REWRITE:
			if ( authz_rewrites ) {
				struct berval bv, idx;
				char ibuf[32];
				int i;

				idx.bv_val = ibuf;
				for ( i=0; !BER_BVISNULL( &authz_rewrites[i] ); i++ ) {
858
					idx.bv_len = sprintf( idx.bv_val, IFMT, i );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
859
860
861
862
863
864
865
866
867
868
869
870
871
872
					bv.bv_len = idx.bv_len + authz_rewrites[i].bv_len;
					bv.bv_val = ch_malloc( bv.bv_len + 1 );
					strcpy( bv.bv_val, idx.bv_val );
					strcpy( bv.bv_val+idx.bv_len, authz_rewrites[i].bv_val );
					ber_bvarray_add( &c->rvalue_vals, &bv );
				}
			}
			if ( !c->rvalue_vals ) rc = 1;
			break;
#endif
		default:
			rc = 1;
		}
		return rc;
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
	} else if ( c->op == LDAP_MOD_DELETE ) {
		int rc = 0;
		switch(c->type) {
		/* single-valued attrs, no-ops */
		case CFG_CONCUR:
		case CFG_THREADS:
		case CFG_RO:
		case CFG_AZPOLICY:
		case CFG_DEPTH:
		case CFG_LASTMOD:
		case CFG_SASLSECP:
		case CFG_SSTR_IF_MAX:
		case CFG_SSTR_IF_MIN:
			break;

		/* no-ops, requires slapd restart */
		case CFG_PLUGIN:
		case CFG_MODLOAD:
		case CFG_AZREGEXP:
		case CFG_REWRITE:
			sprintf(c->log, "change requires slapd restart");
			break;

		case CFG_SALT:
			ch_free( passwd_salt );
			passwd_salt = NULL;
			break;

		case CFG_REPLOG:
			ch_free( c->be->be_replogfile );
			c->be->be_replogfile = NULL;
			break;

		case CFG_LOGFILE:
			ch_free( logfileName );
			logfileName = NULL;
			break;

		case CFG_ACL:
			if ( c->valx < 0 ) {
				AccessControl *end;
				if ( c->be == frontendDB )
					end = NULL;
				else
					end = frontendDB->be_acl;
				acl_destroy( c->be->be_acl, end );
			} else {
				AccessControl **prev, *a;
				int i;
				for (i=0, prev = &c->be->be_acl; i < c->valx;
					i++ ) {
					a = *prev;
					prev = &a->acl_next;
				}
				a = *prev;
				*prev = a->acl_next;
				acl_free( a );
			}
			break;

		case CFG_LIMITS:
			/* FIXME: there is no limits_free function */
		case CFG_ATOPT:
			/* FIXME: there is no ad_option_free function */
		case CFG_ROOTDSE:
			/* FIXME: there is no way to remove attributes added by
				a DSE file */
		case CFG_OID:
		case CFG_OC:
		case CFG_DIT:
		case CFG_ATTR:
		case CFG_MODPATH:
		default:
			rc = 1;
			break;
		}
		return rc;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
950
951
952
	}

 	p = strchr(c->line,'(' /*')'*/);
953

Kurt Zeilenga's avatar
Kurt Zeilenga committed
954
955
956
	switch(c->type) {
		case CFG_BACKEND:
			if(!(c->bi = backend_info(c->argv[1]))) {
957
958
959
				sprintf( c->msg, "<%s> failed init", c->argv[0] );
				Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
					c->log, c->msg, c->argv[1] );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
960
961
962
963
964
965
966
967
968
				return(1);
			}
			break;

		case CFG_DATABASE:
			c->bi = NULL;
			/* NOTE: config is always the first backend!
			 */
			if ( !strcasecmp( c->argv[1], "config" )) {
969
970
971
				c->be = LDAP_STAILQ_FIRST(&backendDB);
			} else if ( !strcasecmp( c->argv[1], "frontend" )) {
				c->be = frontendDB;
972
973
974
975
976
977
978
979
			} else {
				c->be = backend_db_init(c->argv[1]);
				if ( !c->be ) {
					sprintf( c->msg, "<%s> failed init", c->argv[0] );
					Debug(LDAP_DEBUG_ANY, "%s: %s (%s)!\n",
						c->log, c->msg, c->argv[1] );
					return(1);
				}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
			}
			break;

		case CFG_CONCUR:
			ldap_pvt_thread_set_concurrency(c->value_int);
			break;

		case CFG_THREADS:
			ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int);
			connection_pool_max = c->value_int;	/* save for reference */
			break;

		case CFG_SALT:
			if ( passwd_salt ) ch_free( passwd_salt );
			passwd_salt = c->value_string;
			lutil_salt_format(passwd_salt);
			break;

		case CFG_LIMITS:
			if(limits_parse(c->be, c->fname, c->lineno, c->argc, c->argv))
				return(1);
			break;

		case CFG_RO:
			if(c->value_int)
				c->be->be_restrictops |= SLAP_RESTRICT_OP_WRITES;
			else
				c->be->be_restrictops &= ~SLAP_RESTRICT_OP_WRITES;
			break;

		case CFG_AZPOLICY:
			ch_free(c->value_string);
			if (slap_sasl_setpolicy( c->argv[1] )) {
1013
1014
1015
				sprintf( c->msg, "<%s> unable to parse value", c->argv[0] );
				Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
					c->log, c->msg, c->argv[1] );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
				return(1);
			}
			break;
		
		case CFG_AZREGEXP:
			if (slap_sasl_regexp_config( c->argv[1], c->argv[2] ))
				return(1);
			break;
				
#ifdef HAVE_CYRUS_SASL
		case CFG_SASLSECP:
			{
			char *txt = slap_sasl_secprops( c->argv[1] );
			if ( txt ) {
1030
1031
1032
				snprintf( c->msg, sizeof(c->msg), "<%s> %s",
					c->argv[0], txt );
				Debug(LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->msg, 0 );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
				return(1);
			}
			break;
			}
#endif

		case CFG_DEPTH:
			c->be->be_max_deref_depth = c->value_int;
			break;

1043
1044
1045
1046
1047
1048
1049
1050
		case CFG_OID: {
			OidMacro *om;

			if(parse_oidm(c->fname, c->lineno, c->argc, c->argv, 1, &om))
				return(1);
			if (!cfn->c_om_head) cfn->c_om_head = om;
			cfn->c_om_tail = om;
			}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1051
1052
			break;

1053
1054
1055
1056
1057
1058
1059
		case CFG_OC: {
			ObjectClass *oc;

			if(parse_oc(c->fname, c->lineno, p, c->argv, &oc)) return(1);
			if (!cfn->c_oc_head) cfn->c_oc_head = oc;
			cfn->c_oc_tail = oc;
			}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1060
1061
			break;

1062
1063
1064
1065
1066
1067
1068
		case CFG_DIT: {
			ContentRule *cr;

			if(parse_cr(c->fname, c->lineno, p, c->argv, &cr)) return(1);
			if (!cfn->c_cr_head) cfn->c_cr_head = cr;
			cfn->c_cr_tail = cr;
			}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1069
1070
			break;

1071
1072
1073
1074
1075
1076
1077
		case CFG_ATTR: {
			AttributeType *at;

			if(parse_at(c->fname, c->lineno, p, c->argv, &at)) return(1);
			if (!cfn->c_at_head) cfn->c_at_head = at;
			cfn->c_at_tail = at;
			}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
			break;

		case CFG_ATOPT:
			ad_define_option(NULL, NULL, 0);
			for(i = 1; i < c->argc; i++)
				if(ad_define_option(c->argv[i], c->fname, c->lineno))
					return(1);
			break;

		case CFG_ACL:
1088
			parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, c->valx);
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
			break;

		case CFG_REPLOG:
			if(SLAP_MONITOR(c->be)) {
				Debug(LDAP_DEBUG_ANY, "%s: "
					"\"replogfile\" should not be used "
					"inside monitor database\n",
					c->log, 0, 0);
				return(0);	/* FIXME: should this be an error? */
			}

			c->be->be_replogfile = c->value_string;
			break;

		case CFG_ROOTDSE:
			if(read_root_dse_file(c->argv[1])) {
1105
1106
1107
				sprintf( c->msg, "<%s> could not read file", c->argv[0] );
				Debug(LDAP_DEBUG_ANY, "%s: %s %s\n",
					c->log, c->msg, c->argv[1] );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
				return(1);
			}
			{
				struct berval bv;
				ber_str2bv( c->argv[1], 0, 1, &bv );
				ber_bvarray_add( &cfn->c_dseFiles, &bv );
			}
			break;

		case CFG_LOGFILE: {
				FILE *logfile;
				if ( logfileName ) ch_free( logfileName );
				logfileName = c->value_string;
				logfile = fopen(logfileName, "w");
				if(logfile) lutil_debug_file(logfile);
			} break;

		case CFG_LASTMOD:
			if(SLAP_NOLASTMODCMD(c->be)) {
1127
1128
1129
1130
				sprintf( c->msg, "<%s> not available for %s database",
					c->argv[0], c->be->bd_info->bi_type );
				Debug(LDAP_DEBUG_ANY, "%s: %s\n",
					c->log, c->msg, 0 );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
				return(1);
			}
			if(c->value_int)
				SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_NOLASTMOD;
			else
				SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_NOLASTMOD;
			break;

		case CFG_SSTR_IF_MAX:
			if (c->value_int < index_substr_if_minlen) {
1141
1142
1143
				sprintf( c->msg, "<%s> invalid value", c->argv[0] );
				Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
					c->log, c->msg, c->value_int );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1144
1145
1146
1147
1148
1149
1150
				return(1);
			}
			index_substr_if_maxlen = c->value_int;
			break;

		case CFG_SSTR_IF_MIN:
			if (c->value_int > index_substr_if_maxlen) {
1151
1152
1153
				sprintf( c->msg, "<%s> invalid value", c->argv[0] );
				Debug(LDAP_DEBUG_ANY, "%s: %s (%d)\n",
					c->log, c->msg, c->value_int );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1154
1155
1156
1157
1158
1159
1160
				return(1);
			}
			index_substr_if_minlen = c->value_int;
			break;

#ifdef SLAPD_MODULES
		case CFG_MODLOAD:
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1161
1162
1163
			/* If we're just adding a module on an existing modpath,
			 * make sure we've selected the current path.
			 */
1164
			if ( c->op == LDAP_MOD_ADD && c->private && modcur != c->private ) {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
				modcur = c->private;
				/* This should never fail */
				if ( module_path( modcur->mp_path.bv_val )) {
					sprintf( c->msg, "<%s> module path no longer valid",
						c->argv[0] );
					Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
						c->log, c->msg, modcur->mp_path.bv_val );
					return(1);
				}
			}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1175
1176
1177
1178
1179
			if(module_load(c->argv[1], c->argc - 2, (c->argc > 2) ? c->argv + 2 : NULL))
				return(1);
			/* Record this load on the current path */
			{
				struct berval bv;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1180
1181
1182
1183
1184
1185
1186
1187
				char *ptr;
				if ( c->op == SLAP_CONFIG_ADD ) {
					ptr = c->line + STRLENOF("moduleload");
					while (!isspace(*ptr)) ptr++;
					while (isspace(*ptr)) ptr++;
				} else {
					ptr = c->line;
				}
1188
				ber_str2bv(ptr, 0, 1, &bv);
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1189
				ber_bvarray_add( &modcur->mp_loads, &bv );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1190
1191
1192
1193
1194
1195
1196
1197
1198
			}
			break;

		case CFG_MODPATH:
			if(module_path(c->argv[1])) return(1);
			/* Record which path was used with each module */
			{
				ModPaths *mp;

1199
1200
				if (!modpaths.mp_loads) {
					mp = &modpaths;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1201
1202
				} else {
					mp = ch_malloc( sizeof( ModPaths ));
1203
					modlast->mp_next = mp;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1204
1205
1206
1207
				}
				ber_str2bv(c->argv[1], 0, 1, &mp->mp_path);
				mp->mp_next = NULL;
				mp->mp_loads = NULL;
1208
1209
				modlast = mp;
				c->private = mp;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1210
				modcur = mp;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
			}
			
			break;
#endif

#ifdef LDAP_SLAPI
		case CFG_PLUGIN:
			if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS)
				return(1);
			slapi_plugins_used++;
			break;
#endif

#ifdef SLAP_AUTH_REWRITE
		case CFG_REWRITE: {
			struct berval bv;
1227
1228
			char *line;
			
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1229
1230
			if(slap_sasl_rewrite_config(c->fname, c->lineno, c->argc, c->argv))
				return(1);
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247

			if ( c->argc > 1 ) {
				char	*s;

				/* quote all args but the first */
				line = ldap_charray2str( c->argv, "\" \"" );
				ber_str2bv( line, 0, 0, &bv );
				s = strchr( bv.bv_val, '"' );
				assert( s != NULL );
				/* move the trailing quote of argv[0] to the end */
				AC_MEMCPY( s, s + 1, bv.bv_len - ( s - bv.bv_val ) );
				bv.bv_val[ bv.bv_len - 1 ] = '"';

			} else {
				ber_str2bv( c->argv[ 0 ], 0, 1, &bv );
			}
			
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1248
1249
1250
1251
1252
1253
1254
			ber_bvarray_add( &authz_rewrites, &bv );
			}
			break;
#endif


		default:
1255
1256
			Debug( SLAPD_DEBUG_CONFIG_ERROR,
				"%s: unknown CFG_TYPE %d"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1257
				SLAPD_CONF_UNKNOWN_IGNORED ".\n",
1258
				c->log, c->type, 0 );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1259
1260
1261
#ifdef SLAPD_CONF_UNKNOWN_BAILOUT
			return 1;
#endif /* SLAPD_CONF_UNKNOWN_BAILOUT */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1262
1263
1264
1265
1266
1267
1268
1269

	}
	return(0);
}


static int
config_fname(ConfigArgs *c) {
1270
1271
1272
1273
1274
1275
1276
	if(c->op == SLAP_CONFIG_EMIT) {
		if (c->private) {
			ConfigFile *cf = c->private;
			value_add_one( &c->rvalue_vals, &cf->c_file );
			return 0;
		}
		return 1;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1277
	}
1278
	return(0);
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1279
1280
}

Kurt Zeilenga's avatar
Kurt Zeilenga committed
1281
1282
1283
static int
config_cfdir(ConfigArgs *c) {
	if(c->op == SLAP_CONFIG_EMIT) {
1284
1285
1286
1287
1288
		if ( !BER_BVISEMPTY( &cfdir )) {
			value_add_one( &c->rvalue_vals, &cfdir );
			return 0;
		}
		return 1;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1289
	}
1290
	return(0);
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1291
1292
}

Kurt Zeilenga's avatar
Kurt Zeilenga committed
1293
1294
1295
1296
static int
config_search_base(ConfigArgs *c) {
	struct berval dn;

Kurt Zeilenga's avatar
Kurt Zeilenga committed
1297
	if(c->op == SLAP_CONFIG_EMIT) {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1298
1299
1300
1301
1302
1303
1304
		int rc = 1;
		if (!BER_BVISEMPTY(&default_search_base)) {
			value_add_one(&c->rvalue_vals, &default_search_base);
			value_add_one(&c->rvalue_nvals, &default_search_nbase);
			rc = 0;
		}
		return rc;
1305
1306
1307
1308
1309
1310
	} else if( c->op == LDAP_MOD_DELETE ) {
		ch_free( default_search_base.bv_val );
		ch_free( default_search_nbase.bv_val );
		BER_BVZERO( &default_search_base );
		BER_BVZERO( &default_search_nbase );
		return 0;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
	}

	if(c->bi || c->be != frontendDB) {
		Debug(LDAP_DEBUG_ANY, "%s: defaultSearchBase line must appear "
			"prior to any backend or database definition\n",
			c->log, 0, 0);
		return(1);
	}

	if(default_search_nbase.bv_len) {
		free(default_search_base.bv_val);
		free(default_search_nbase.bv_val);
	}

	default_search_base = c->value_dn;
	default_search_nbase = c->value_ndn;
	return(0);
}

static int
config_passwd_hash(ConfigArgs *c) {
	int i;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1333
	if (c->op == SLAP_CONFIG_EMIT) {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1334
1335
1336
1337
1338
1339
		struct berval bv;
		for (i=0; default_passwd_hash && default_passwd_hash[i]; i++) {
			ber_str2bv(default_passwd_hash[i], 0, 0, &bv);
			value_add_one(&c->rvalue_vals, &bv);
		}
		return i ? 0 : 1;
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
	} else if ( c->op == LDAP_MOD_DELETE ) {
		if ( c->valx < 0 ) {
			ldap_charray_free( default_passwd_hash );
			default_passwd_hash = NULL;
		} else {
			i = c->valx;
			ch_free( default_passwd_hash[i] );
			for (; default_passwd_hash[i]; i++ )
				default_passwd_hash[i] = default_passwd_hash[i+1];
		}
		return 0;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1351
1352
1353
1354
1355
1356
1357
1358
1359
	}
	if(default_passwd_hash) {
		Debug(LDAP_DEBUG_ANY, "%s: "
			"already set default password_hash\n",
			c->log, 0, 0);
		return(1);
	}
	for(i = 1; i < c->argc; i++) {
		if(!lutil_passwd_scheme(c->argv[i])) {
1360
1361
1362
			sprintf( c->msg, "<%s> schema not available", c->argv[0] );
			Debug(LDAP_DEBUG_ANY, "%s: %s (%s)\n",
				c->log, c->msg, c->argv[i]);
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1363
1364
1365
1366
		} else {
			ldap_charray_add(&default_passwd_hash, c->argv[i]);
		}
		if(!default_passwd_hash) {
1367
1368
1369
			sprintf( c->msg, "<%s> no valid hashes found", c->argv[0] );
			Debug(LDAP_DEBUG_ANY, "%s: %s\n",
				c->log, c->msg, 0 );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1370
1371
1372
1373
1374
1375
1376
1377
			return(1);
		}
	}
	return(0);
}

static int
config_schema_dn(ConfigArgs *c) {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1378
1379
1380
1381
1382
1383
1384
1385
	if ( c->op == SLAP_CONFIG_EMIT ) {
		int rc = 1;
		if ( !BER_BVISEMPTY( &c->be->be_schemadn )) {
			value_add_one(&c->rvalue_vals, &c->be->be_schemadn);
			value_add_one(&c->rvalue_nvals, &c->be->be_schemandn);
			rc = 0;
		}
		return rc;
1386
1387
1388
1389
1390
1391
	} else if ( c->op == LDAP_MOD_DELETE ) {
		ch_free( c->be->be_schemadn.bv_val );
		ch_free( c->be->be_schemandn.bv_val );
		BER_BVZERO( &c->be->be_schemadn );
		BER_BVZERO( &c->be->be_schemandn );
		return 0;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1392
	}
1393
1394
	ch_free( c->be->be_schemadn.bv_val );
	ch_free( c->be->be_schemandn.bv_val );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
	c->be->be_schemadn = c->value_dn;
	c->be->be_schemandn = c->value_ndn;
	return(0);
}

static int
config_sizelimit(ConfigArgs *c) {
	int i, rc = 0;
	char *next;
	struct slap_limits_set *lim = &c->be->be_def_limit;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1405
	if (c->op == SLAP_CONFIG_EMIT) {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
		char buf[8192];
		struct berval bv;
		bv.bv_val = buf;
		bv.bv_len = 0;
		limits_unparse_one( lim, SLAP_LIMIT_SIZE, &bv );
		if ( !BER_BVISEMPTY( &bv ))
			value_add_one( &c->rvalue_vals, &bv );
		else
			rc = 1;
		return rc;
1416
1417
1418
1419
1420
1421
1422
1423
1424
	} else if ( c->op == LDAP_MOD_DELETE ) {
		/* Reset to defaults */
		lim->lms_s_soft = SLAPD_DEFAULT_SIZELIMIT;
		lim->lms_s_hard = 0;
		lim->lms_s_unchecked = -1;
		lim->lms_s_pr = 0;
		lim->lms_s_pr_hide = 0;
		lim->lms_s_pr_total = 0;
		return 0;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1425
1426
1427
1428
1429
	}
	for(i = 1; i < c->argc; i++) {
		if(!strncasecmp(c->argv[i], "size", 4)) {
			rc = limits_parse_one(c->argv[i], lim);
			if ( rc ) {
1430
1431
1432
				sprintf( c->msg, "<%s> unable to parse value", c->argv[0] );
				Debug(LDAP_DEBUG_ANY, "%s: %s \"%s\"\n",
					c->log, c->msg, c->argv[i]);
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1433
1434
1435
1436
1437
1438
1439
1440
				return(1);
			}
		} else {
			if(!strcasecmp(c->argv[i], "unlimited")) {
				lim->lms_s_soft = -1;
			} else {