Blame SOURCES/autofs-5.0.7-lib-defaults-use-WITH_LDAP-conditional-around-LDAP-types.patch

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