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

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