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

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