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

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