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

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