autofs-5.0.4 - add nfs mount protocol default configuration option
From: Ian Kent <raven@themaw.net>
Add configuration option MOUNT_NFS_DEFAULT_PROTOCOL with default of 3.
Since the default mount protocol used by mount.nfs(8) will change to
NFS version 4 at some point, and because we can't identify the default
automatically, we need to be able to set it in our configuration.
This will only make a difference for replicated map entries as
availability probing isn't used for single host map entries.
---
CHANGELOG | 1 +
include/defaults.h | 2 ++
lib/defaults.c | 15 ++++++++++++++-
man/auto.master.5.in | 6 ++++++
modules/mount_nfs.c | 8 +++++---
redhat/autofs.sysconfig.in | 10 ++++++++++
samples/autofs.conf.default.in | 10 ++++++++++
7 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index ad74b7d..0ce2a56 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -25,6 +25,7 @@
- add check for alternate libtirpc library for libtirpc tsd workaround.
- cleanup configure defines for libtirpc.
- add WITH_LIBTIRPC to -V status report.
+- add nfs mount protocol default configuration option.
4/11/2008 autofs-5.0.4
-----------------------
diff --git a/include/defaults.h b/include/defaults.h
index 9a2430f..9bf16e5 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -37,6 +37,7 @@
#define DEFAULT_ENTRY_ATTR "cn"
#define DEFAULT_VALUE_ATTR "nisMapEntry"
+#define DEFAULT_NFS_MOUNT_PROTOCOL 3
#define DEFAULT_APPEND_OPTIONS 1
#define DEFAULT_AUTH_CONF_FILE AUTOFS_MAP_DIR "/autofs_ldap_auth.conf"
@@ -61,6 +62,7 @@ struct ldap_schema *defaults_get_default_schema(void);
struct ldap_schema *defaults_get_schema(void);
struct ldap_searchdn *defaults_get_searchdns(void);
void defaults_free_searchdns(struct ldap_searchdn *);
+unsigned int defaults_get_mount_nfs_default_proto(void);
unsigned int defaults_get_append_options(void);
unsigned int defaults_get_umount_wait(void);
const char *defaults_get_auth_conf_file(void);
diff --git a/lib/defaults.c b/lib/defaults.c
index e507a59..17164bd 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -45,6 +45,7 @@
#define ENV_NAME_ENTRY_ATTR "ENTRY_ATTRIBUTE"
#define ENV_NAME_VALUE_ATTR "VALUE_ATTRIBUTE"
+#define ENV_MOUNT_NFS_DEFAULT_PROTOCOL "MOUNT_NFS_DEFAULT_PROTOCOL"
#define ENV_APPEND_OPTIONS "APPEND_OPTIONS"
#define ENV_UMOUNT_WAIT "UMOUNT_WAIT"
#define ENV_AUTH_CONF_FILE "AUTH_CONF_FILE"
@@ -326,7 +327,8 @@ unsigned int defaults_read_config(unsigned int to_syslog)
check_set_config_value(key, ENV_APPEND_OPTIONS, value, to_syslog) ||
check_set_config_value(key, ENV_UMOUNT_WAIT, value, to_syslog) ||
check_set_config_value(key, ENV_AUTH_CONF_FILE, value, to_syslog) ||
- check_set_config_value(key, ENV_MAP_HASH_TABLE_SIZE, value, to_syslog))
+ check_set_config_value(key, ENV_MAP_HASH_TABLE_SIZE, value, to_syslog) ||
+ check_set_config_value(key, ENV_MOUNT_NFS_DEFAULT_PROTOCOL, value, to_syslog))
;
}
@@ -643,6 +645,17 @@ struct ldap_schema *defaults_get_schema(void)
return schema;
}
+unsigned int defaults_get_mount_nfs_default_proto(void)
+{
+ long proto;
+
+ proto = get_env_number(ENV_MOUNT_NFS_DEFAULT_PROTOCOL);
+ if (proto < 2 || proto > 4)
+ proto = DEFAULT_NFS_MOUNT_PROTOCOL;
+
+ return (unsigned int) proto;
+}
+
unsigned int defaults_get_append_options(void)
{
int res;
diff --git a/man/auto.master.5.in b/man/auto.master.5.in
index 9cc5f02..aaa6324 100644
--- a/man/auto.master.5.in
+++ b/man/auto.master.5.in
@@ -183,6 +183,12 @@ but it is the best we can do.
.B BROWSE_MODE
Maps are browsable by default (program default "yes").
.TP
+.B MOUNT_NFS_DEFAULT_PROTOCOL
+Specify the default protocol used by mount.nfs(8) (program default 3). Since
+we can't identify this default automatically we need to set it in the autofs
+configuration. This option will only make a difference for replicated map
+entries as availability probing isn't used for single host map entries.
+.TP
.B APPEND_OPTIONS
Determine whether global options, given on the command line or per mount
in the master map, are appended to map entry options or if the map entry
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index 4f3f514..14d3850 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -61,7 +61,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
char fullpath[PATH_MAX];
char buf[MAX_ERR_BUF];
struct host *this, *hosts = NULL;
- unsigned int vers;
+ unsigned int mount_default_proto, vers;
char *nfsoptions = NULL;
unsigned int random_selection = ap->flags & MOUNT_FLAG_RANDOM_SELECT;
int len, status, err, existed = 1;
@@ -130,10 +130,12 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
nfsoptions, nosymlink, ro);
}
+ mount_default_proto = defaults_get_mount_nfs_default_proto();
+ vers = NFS_VERS_MASK | NFS_PROTO_MASK;
if (strcmp(fstype, "nfs4") == 0)
vers = NFS4_VERS_MASK | TCP_SUPPORTED;
- else
- vers = NFS_VERS_MASK | NFS_PROTO_MASK;
+ else if (mount_default_proto == 4)
+ vers = vers | NFS4_VERS_MASK;
if (!parse_location(ap->logopt, &hosts, what)) {
info(ap->logopt, MODPREFIX "no hosts available");
diff --git a/redhat/autofs.sysconfig.in b/redhat/autofs.sysconfig.in
index fe36f45..04e521c 100644
--- a/redhat/autofs.sysconfig.in
+++ b/redhat/autofs.sysconfig.in
@@ -22,6 +22,16 @@ TIMEOUT=300
#
BROWSE_MODE="no"
#
+# MOUNT_NFS_DEFAULT_PROTOCOL - specify the default protocol used by
+# mount.nfs(8). Since we can't identify
+# the default automatically we need to
+# set it in our configuration. This will
+# only make a difference for replicated
+# map entries as availability probing isn't
+# used for single host map entries.
+#
+#MOUNT_NFS_DEFAULT_PROTOCOL=3
+#
# APPEND_OPTIONS - append to global options instead of replace.
#
#APPEND_OPTIONS="yes"
diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in
index 4496738..52d18ec 100644
--- a/samples/autofs.conf.default.in
+++ b/samples/autofs.conf.default.in
@@ -22,6 +22,16 @@ TIMEOUT=300
#
BROWSE_MODE="no"
#
+# MOUNT_NFS_DEFAULT_PROTOCOL - specify the default protocol used by
+# mount.nfs(8). Since we can't identify
+# the default automatically we need to
+# set it in our configuration. This will
+# only make a difference for replicated
+# map entries as availability probing isn't
+# used for single host map entries.
+#
+#MOUNT_NFS_DEFAULT_PROTOCOL=3
+#
# APPEND_OPTIONS - append to global options instead of replace.
#
#APPEND_OPTIONS="yes"