Blame SOURCES/autofs-5.1.1-add-configuration-option-to-use-hostname-in-mounts.patch

019928
autofs-5.1.1 - add configuration option to use fqdn in mounts
019928
019928
From: Ian Kent <raven@themaw.net>
019928
019928
When a server name returns multiple IP addresses autofs uses the IP
019928
address when performing the mount to ensure that the the host proximity
019928
order is respected, and that servers that aren't responding aren't
019928
tried.
019928
019928
But sometimes people need to use the server name for the mount so
019928
add a configuration option to enable that.
019928
019928
Signed-off-by: Ian Kent <raven@themaw.net>
019928
---
019928
 CHANGELOG                      |    1 +
019928
 include/defaults.h             |    3 +++
019928
 lib/defaults.c                 |   18 ++++++++++++++++++
019928
 man/autofs.conf.5.in           |   18 ++++++++++++++++++
019928
 modules/mount_nfs.c            |    3 ++-
019928
 modules/replicated.c           |    6 ++++++
019928
 redhat/autofs.conf.default.in  |    8 ++++++++
019928
 samples/autofs.conf.default.in |    8 ++++++++
019928
 8 files changed, 64 insertions(+), 1 deletion(-)
019928
019928
--- autofs-5.0.7.orig/CHANGELOG
019928
+++ autofs-5.0.7/CHANGELOG
019928
@@ -203,6 +203,7 @@
019928
 - fix use after free in sun parser parse_init().
019928
 - fix use after free in open_lookup().
019928
 - fix typo in autofs_sasl_bind().
019928
+- add configuration option to use fqdn in mounts.
019928
 
019928
 25/07/2012 autofs-5.0.7
019928
 =======================
019928
--- autofs-5.0.7.orig/include/defaults.h
019928
+++ autofs-5.0.7/include/defaults.h
019928
@@ -47,6 +47,8 @@
019928
 
019928
 #define DEFAULT_MAP_HASH_TABLE_SIZE	"1024"
019928
 
019928
+#define DEFAULT_USE_HOSTNAME_FOR_MOUNTS	"0"
019928
+
019928
 /* Config entry flags */
019928
 #define CONF_NONE			0x00000000
019928
 #define CONF_ENV			0x00000001
019928
@@ -162,6 +164,7 @@ unsigned int defaults_get_mount_wait(voi
019928
 unsigned int defaults_get_umount_wait(void);
019928
 const char *defaults_get_auth_conf_file(void);
019928
 unsigned int defaults_get_map_hash_table_size(void);
019928
+unsigned int defaults_use_hostname_for_mounts(void);
019928
 
019928
 unsigned int conf_amd_mount_section_exists(const char *);
019928
 char *conf_amd_get_arch(void);
019928
--- autofs-5.0.7.orig/lib/defaults.c
019928
+++ autofs-5.0.7/lib/defaults.c
019928
@@ -72,6 +72,8 @@
019928
 
019928
 #define NAME_MAP_HASH_TABLE_SIZE	"map_hash_table_size"
019928
 
019928
+#define NAME_USE_HOSTNAME_FOR_MOUNTS	"use_hostname_for_mounts"
019928
+
019928
 #define NAME_AMD_ARCH				"arch"
019928
 #define NAME_AMD_AUTO_ATTRCACHE			"auto_attrcache"
019928
 #define NAME_AMD_AUTO_DIR			"auto_dir"
019928
@@ -334,6 +336,11 @@ static int conf_load_autofs_defaults(voi
019928
 	if (ret == CFG_FAIL)
019928
 		goto error;
019928
 
019928
+	ret = conf_update(sec, NAME_USE_HOSTNAME_FOR_MOUNTS,
019928
+			  DEFAULT_USE_HOSTNAME_FOR_MOUNTS, CONF_ENV);
019928
+	if (ret == CFG_FAIL)
019928
+		goto error;
019928
+
019928
 	/* LDAP_URI and SEARCH_BASE can occur multiple times */
019928
 	while ((co = conf_lookup(sec, NAME_LDAP_URI)))
019928
 		conf_delete(co->section, co->name);
019928
@@ -1700,6 +1707,17 @@ unsigned int defaults_get_map_hash_table
019928
 	return (unsigned int) size;
019928
 }
019928
 
019928
+unsigned int defaults_use_hostname_for_mounts(void)
019928
+{
019928
+	int res;
019928
+
019928
+	res = conf_get_yesno(autofs_gbl_sec, NAME_USE_HOSTNAME_FOR_MOUNTS);
019928
+	if (res < 0)
019928
+		res = atoi(DEFAULT_USE_HOSTNAME_FOR_MOUNTS);
019928
+
019928
+	return res;
019928
+}
019928
+
019928
 unsigned int conf_amd_mount_section_exists(const char *section)
019928
 {
019928
 	return conf_section_exists(section);
019928
--- autofs-5.0.7.orig/man/autofs.conf.5.in
019928
+++ autofs-5.0.7/man/autofs.conf.5.in
019928
@@ -111,6 +111,24 @@ entries, in this case, is usually much l
019928
 in the map. In this last case it would be unusual for the map entry
019928
 cache to grow large enough to warrant increasing the default before
019928
 an event that cleans stale entries, a map re-read for example.
019928
+.TP
019928
+.B use_hostname_for_mounts
019928
+.br
019928
+NFS mounts where the host name resolves to more than one IP address
019928
+are probed for availability and to establish the order in which mounts
019928
+to them should be tried. To ensure that mount attempts are made only
019928
+to hosts that are responding and are tried in the order of hosts with
019928
+the quickest response the IP address of the host needs to be used for
019928
+the mount.
019928
+
019928
+If it is necessary to use the hostname given in the map entry for the
019928
+mount regardless, then set this option to "yes".
019928
+
019928
+Be aware that if this is done there is no defense against the host
019928
+name resolving to one that isn't responding and while the number
019928
+of attempts at a successful mount will correspond to the number of
019928
+addresses the host name resolves to the order will also not correspond
019928
+to fastest responding hosts.
019928
 .SS LDAP Configuration
019928
 .P
019928
 Configuration settings available are:
019928
--- autofs-5.0.7.orig/modules/mount_nfs.c
019928
+++ autofs-5.0.7/modules/mount_nfs.c
019928
@@ -316,7 +316,8 @@ dont_probe:
019928
 
019928
 		/* Not a local host - do an NFS mount */
019928
 
019928
-		if (this->rr && this->addr) {
019928
+		if (this->rr && this->addr &&
019928
+		    !defaults_use_hostname_for_mounts()) {
019928
 			socklen_t len = INET6_ADDRSTRLEN;
019928
 			char n_buf[len + 1];
019928
 			const char *n_addr;
019928
--- autofs-5.0.7.orig/modules/replicated.c
019928
+++ autofs-5.0.7/modules/replicated.c
019928
@@ -667,6 +667,12 @@ int prune_host_list(unsigned logopt, str
019928
 	if (!*list)
019928
 		return 0;
019928
 
019928
+	/* If we're using the host name then there's no point probing
019928
+	 * avialability and respose time.
019928
+	 */
019928
+	if (defaults_use_hostname_for_mounts())
019928
+		return 1;
019928
+
019928
 	/* Use closest hosts to choose NFS version */
019928
 
019928
 	first = *list;
019928
--- autofs-5.0.7.orig/redhat/autofs.conf.default.in
019928
+++ autofs-5.0.7/redhat/autofs.conf.default.in
019928
@@ -142,6 +142,14 @@ mount_nfs_default_protocol = 4
019928
 #
019928
 #map_hash_table_size = 1024
019928
 #
019928
+# use_hostname_for_mounts - nfs mounts where the host name resolves
019928
+# 			 to more than one IP address normally need
019928
+# 			 to use the IP address to esure a mount to
019928
+# 			 a host that isn't responding isn't done.
019928
+# 			 If that behaviour is not wanted then set
019928
+#			 ths to "yes", default is "no".
019928
+#
019928
+#use_hostname_for_mounts = "no"
019928
 #
019928
 # Otions for the amd parser within autofs.
019928
 #
019928
--- autofs-5.0.7.orig/samples/autofs.conf.default.in
019928
+++ autofs-5.0.7/samples/autofs.conf.default.in
019928
@@ -141,6 +141,14 @@ browse_mode = no
019928
 #
019928
 #map_hash_table_size = 1024
019928
 #
019928
+# use_hostname_for_mounts - nfs mounts where the host name resolves
019928
+# 			to more than one IP address normally need
019928
+# 			to use the IP address to esure a mount to
019928
+# 			a host that isn't responding isn't done.
019928
+# 			If that behaviour is not wanted then set
019928
+#			ths to "yes", default is "no".
019928
+#
019928
+#use_hostname_for_mounts = "no"
019928
 #
019928
 # Otions for the amd parser within autofs.
019928
 #