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

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