aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-lib-defaults-use-WITH_LDAP-conditional-around-LDAP-types.patch
blob: 22e0418e54b2b58a30687b0f2fc27f454cacdd0c (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
124
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
autofs-5.0.7 - lib/defaults.c: use WITH_LDAP conditional around LDAP types

From: Chris Packham <chris.packham@alliedtelesis.co.nz>

Wrap the inclusion of lookup_ldap.h and functions that use ldap_uri or
ldap_schema with the WITH_LDAP conditional. WITH_LDAP is set by the
configure step when LDAP support is not desired. This also allows
compilation on a system that doesn't have any LDAP libraries.
---

 CHANGELOG             |    1 
 include/defaults.h    |   14 +-
 include/lookup_ldap.h |    1 
 lib/defaults.c        |  325 +++++++++++++++++++++++++------------------------
 modules/lookup_ldap.c |    1 
 5 files changed, 175 insertions(+), 167 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index ba1d65b..1130db6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -24,6 +24,7 @@
 - don't use dirent d_type to filter out files in scandir()
 - don't schedule new alarms after readmap.
 - use numeric protocol ids instead of protoent structs.
+- lib/defaults.c: use WITH_LDAP conditional around LDAP types.
 
 25/07/2012 autofs-5.0.7
 =======================
diff --git a/include/defaults.h b/include/defaults.h
index cda2174..871e14b 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -44,8 +44,16 @@
 
 #define DEFAULT_MAP_HASH_TABLE_SIZE	1024
 
+#ifdef WITH_LDAP
 struct ldap_schema;
 struct ldap_searchdn;
+void defaults_free_uris(struct list_head *);
+struct list_head *defaults_get_uris(void);
+struct ldap_schema *defaults_get_default_schema(void);
+void defaults_free_searchdns(struct ldap_searchdn *);
+struct ldap_searchdn *defaults_get_searchdns(void);
+struct ldap_schema *defaults_get_schema(void);
+#endif
 
 unsigned int defaults_read_config(unsigned int);
 const char *defaults_get_master_map(void);
@@ -57,12 +65,6 @@ unsigned int defaults_get_logging(void);
 const char *defaults_get_ldap_server(void);
 unsigned int defaults_get_ldap_timeout(void);
 unsigned int defaults_get_ldap_network_timeout(void);
-struct list_head *defaults_get_uris(void);
-void defaults_free_uris(struct list_head *);
-struct ldap_schema *defaults_get_default_schema(void);
-struct ldap_schema *defaults_get_schema(void);
-struct ldap_searchdn *defaults_get_searchdns(void);
-void defaults_free_searchdns(struct ldap_searchdn *);
 unsigned int defaults_get_mount_nfs_default_proto(void);
 unsigned int defaults_get_append_options(void);
 unsigned int defaults_get_mount_wait(void);
diff --git a/include/lookup_ldap.h b/include/lookup_ldap.h
index e441a61..9a4ce73 100644
--- a/include/lookup_ldap.h
+++ b/include/lookup_ldap.h
@@ -8,7 +8,6 @@
 #include <openssl/evp.h>
 #include <openssl/err.h>
 #include <sasl/sasl.h>
-#include <libxml/tree.h>
 #include <krb5.h>
 #endif
 
diff --git a/lib/defaults.c b/lib/defaults.c
index 5ce71b7..ae1162f 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -17,9 +17,12 @@
 #include <ctype.h>
 #include <string.h>
 
+#include "config.h"
 #include "list.h"
 #include "defaults.h"
+#ifdef WITH_LDAP
 #include "lookup_ldap.h"
+#endif
 #include "log.h"
 #include "automount.h"
 
@@ -197,6 +200,7 @@ static int parse_line(char *line, char **res, char **value)
 	return 1;
 }
 
+#ifdef WITH_LDAP
 void defaults_free_uris(struct list_head *list)
 {
 	struct list_head *next;
@@ -290,166 +294,6 @@ struct list_head *defaults_get_uris(void)
 	return list;
 }
 
-/*
- * Read config env variables and check they have been set.
- *
- * This simple minded routine assumes the config file
- * is valid bourne shell script without spaces around "="
- * and that it has valid values.
- */
-unsigned int defaults_read_config(unsigned int to_syslog)
-{
-	FILE *f;
-	char buf[MAX_LINE_LEN];
-	char *res;
-
-	f = open_fopen_r(DEFAULTS_CONFIG_FILE);
-	if (!f)
-		return 0;
-
-	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
-		char *key, *value;
-
-		if (!parse_line(res, &key, &value))
-			continue;
-
-		if (check_set_config_value(key, ENV_NAME_MASTER_MAP, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_TIMEOUT, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_NEGATIVE_TIMEOUT, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_BROWSE_MODE, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_LOGGING, value, to_syslog) ||
-		    check_set_config_value(key, ENV_LDAP_TIMEOUT, value, to_syslog) ||
-		    check_set_config_value(key, ENV_LDAP_NETWORK_TIMEOUT, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_MAP_OBJ_CLASS, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_ENTRY_OBJ_CLASS, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_MAP_ATTR, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_ENTRY_ATTR, value, to_syslog) ||
-		    check_set_config_value(key, ENV_NAME_VALUE_ATTR, value, to_syslog) ||
-		    check_set_config_value(key, ENV_APPEND_OPTIONS, value, to_syslog) ||
-		    check_set_config_value(key, ENV_MOUNT_WAIT, value, to_syslog) ||
-		    check_set_config_value(key, ENV_UMOUNT_WAIT, value, to_syslog) ||
-		    check_set_config_value(key, ENV_AUTH_CONF_FILE, value, to_syslog) ||
-		    check_set_config_value(key, ENV_MAP_HASH_TABLE_SIZE, value, to_syslog) ||
-		    check_set_config_value(key, ENV_MOUNT_NFS_DEFAULT_PROTOCOL, value, to_syslog))
-			;
-	}
-
-	if (!feof(f) || ferror(f)) {
-		if (!to_syslog) {
-			fprintf(stderr,
-				"fgets returned error %d while reading %s\n",
-				ferror(f), DEFAULTS_CONFIG_FILE);
-		} else {
-			logmsg("fgets returned error %d while reading %s",
-			      ferror(f), DEFAULTS_CONFIG_FILE);
-		}
-		fclose(f);
-		return 0;
-	}
-
-	fclose(f);
-	return 1;
-}
-
-const char *defaults_get_master_map(void)
-{
-	char *master;
-
-	master = get_env_string(ENV_NAME_MASTER_MAP);
-	if (!master)
-		return strdup(default_master_map_name);
-
-	return (const char *) master;
-}
-
-int defaults_master_set(void)
-{
-	char *val = getenv(ENV_NAME_MASTER_MAP);
-	if (!val)
-		return 0;
-
-	return 1;
-}
-
-unsigned int defaults_get_timeout(void)
-{
-	long timeout;
-
-	timeout = get_env_number(ENV_NAME_TIMEOUT);
-	if (timeout < 0)
-		timeout = DEFAULT_TIMEOUT;
-
-	return (unsigned int) timeout;
-}
-
-unsigned int defaults_get_negative_timeout(void)
-{
-	long n_timeout;
-
-	n_timeout = get_env_number(ENV_NAME_NEGATIVE_TIMEOUT);
-	if (n_timeout <= 0)
-		n_timeout = DEFAULT_NEGATIVE_TIMEOUT;
-
-	return (unsigned int) n_timeout;
-}
-
-unsigned int defaults_get_browse_mode(void)
-{
-	int res;
-
-	res = get_env_yesno(ENV_NAME_BROWSE_MODE);
-	if (res < 0)
-		res = DEFAULT_BROWSE_MODE;
-
-	return res;
-}
-
-unsigned int defaults_get_logging(void)
-{
-	char *res;
-	unsigned int logging = DEFAULT_LOGGING;
-
-	res = get_env_string(ENV_NAME_LOGGING);
-	if (!res)
-		return logging;
-
-	if (!strcasecmp(res, "none"))
-		logging = DEFAULT_LOGGING;
-	else {
-		if (!strcasecmp(res, "verbose"))
-			logging |= LOGOPT_VERBOSE;
-
-		if (!strcasecmp(res, "debug"))
-			logging |= LOGOPT_DEBUG;
-	}
-
-	free(res);
-
-	return logging;
-}
-
-unsigned int defaults_get_ldap_timeout(void)
-{
-	int res;
-
-	res = get_env_number(ENV_LDAP_TIMEOUT);
-	if (res < 0)
-		res = DEFAULT_LDAP_TIMEOUT;
-
-	return res;
-}
-
-unsigned int defaults_get_ldap_network_timeout(void)
-{
-	int res;
-
-	res = get_env_number(ENV_LDAP_NETWORK_TIMEOUT);
-	if (res < 0)
-		res = DEFAULT_LDAP_NETWORK_TIMEOUT;
-
-	return res;
-}
-
 struct ldap_schema *defaults_get_default_schema(void)
 {
 	struct ldap_schema *schema;
@@ -645,6 +489,167 @@ struct ldap_schema *defaults_get_schema(void)
 
 	return schema;
 }
+#endif
+
+/*
+ * Read config env variables and check they have been set.
+ *
+ * This simple minded routine assumes the config file
+ * is valid bourne shell script without spaces around "="
+ * and that it has valid values.
+ */
+unsigned int defaults_read_config(unsigned int to_syslog)
+{
+	FILE *f;
+	char buf[MAX_LINE_LEN];
+	char *res;
+
+	f = open_fopen_r(DEFAULTS_CONFIG_FILE);
+	if (!f)
+		return 0;
+
+	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
+		char *key, *value;
+
+		if (!parse_line(res, &key, &value))
+			continue;
+
+		if (check_set_config_value(key, ENV_NAME_MASTER_MAP, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_TIMEOUT, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_NEGATIVE_TIMEOUT, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_BROWSE_MODE, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_LOGGING, value, to_syslog) ||
+		    check_set_config_value(key, ENV_LDAP_TIMEOUT, value, to_syslog) ||
+		    check_set_config_value(key, ENV_LDAP_NETWORK_TIMEOUT, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_MAP_OBJ_CLASS, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_ENTRY_OBJ_CLASS, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_MAP_ATTR, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_ENTRY_ATTR, value, to_syslog) ||
+		    check_set_config_value(key, ENV_NAME_VALUE_ATTR, value, to_syslog) ||
+		    check_set_config_value(key, ENV_APPEND_OPTIONS, value, to_syslog) ||
+		    check_set_config_value(key, ENV_MOUNT_WAIT, value, to_syslog) ||
+		    check_set_config_value(key, ENV_UMOUNT_WAIT, value, to_syslog) ||
+		    check_set_config_value(key, ENV_AUTH_CONF_FILE, value, to_syslog) ||
+		    check_set_config_value(key, ENV_MAP_HASH_TABLE_SIZE, value, to_syslog) ||
+		    check_set_config_value(key, ENV_MOUNT_NFS_DEFAULT_PROTOCOL, value, to_syslog))
+			;
+	}
+
+	if (!feof(f) || ferror(f)) {
+		if (!to_syslog) {
+			fprintf(stderr,
+				"fgets returned error %d while reading %s\n",
+				ferror(f), DEFAULTS_CONFIG_FILE);
+		} else {
+			logmsg("fgets returned error %d while reading %s",
+			      ferror(f), DEFAULTS_CONFIG_FILE);
+		}
+		fclose(f);
+		return 0;
+	}
+
+	fclose(f);
+	return 1;
+}
+
+const char *defaults_get_master_map(void)
+{
+	char *master;
+
+	master = get_env_string(ENV_NAME_MASTER_MAP);
+	if (!master)
+		return strdup(default_master_map_name);
+
+	return (const char *) master;
+}
+
+int defaults_master_set(void)
+{
+	char *val = getenv(ENV_NAME_MASTER_MAP);
+	if (!val)
+		return 0;
+
+	return 1;
+}
+
+unsigned int defaults_get_timeout(void)
+{
+	long timeout;
+
+	timeout = get_env_number(ENV_NAME_TIMEOUT);
+	if (timeout < 0)
+		timeout = DEFAULT_TIMEOUT;
+
+	return (unsigned int) timeout;
+}
+
+unsigned int defaults_get_negative_timeout(void)
+{
+	long n_timeout;
+
+	n_timeout = get_env_number(ENV_NAME_NEGATIVE_TIMEOUT);
+	if (n_timeout <= 0)
+		n_timeout = DEFAULT_NEGATIVE_TIMEOUT;
+
+	return (unsigned int) n_timeout;
+}
+
+unsigned int defaults_get_browse_mode(void)
+{
+	int res;
+
+	res = get_env_yesno(ENV_NAME_BROWSE_MODE);
+	if (res < 0)
+		res = DEFAULT_BROWSE_MODE;
+
+	return res;
+}
+
+unsigned int defaults_get_logging(void)
+{
+	char *res;
+	unsigned int logging = DEFAULT_LOGGING;
+
+	res = get_env_string(ENV_NAME_LOGGING);
+	if (!res)
+		return logging;
+
+	if (!strcasecmp(res, "none"))
+		logging = DEFAULT_LOGGING;
+	else {
+		if (!strcasecmp(res, "verbose"))
+			logging |= LOGOPT_VERBOSE;
+
+		if (!strcasecmp(res, "debug"))
+			logging |= LOGOPT_DEBUG;
+	}
+
+	free(res);
+
+	return logging;
+}
+
+unsigned int defaults_get_ldap_timeout(void)
+{
+	int res;
+
+	res = get_env_number(ENV_LDAP_TIMEOUT);
+	if (res < 0)
+		res = DEFAULT_LDAP_TIMEOUT;
+
+	return res;
+}
+
+unsigned int defaults_get_ldap_network_timeout(void)
+{
+	int res;
+
+	res = get_env_number(ENV_LDAP_NETWORK_TIMEOUT);
+	if (res < 0)
+		res = DEFAULT_LDAP_NETWORK_TIMEOUT;
+
+	return res;
+}
 
 unsigned int defaults_get_mount_nfs_default_proto(void)
 {
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 3bc4dc5..431e50d 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -28,6 +28,7 @@
 #include <arpa/nameser.h>
 #include <resolv.h>
 #include <lber.h>
+#include <libxml/tree.h>
 
 #define MODULE_LOOKUP
 #include "automount.h"