- Change the nfsmount.conf file to define v3 as the default protocol

version.
- Make sure versions set on the command line override version set in
    nfsmount.conf
- Make version rollbacks still work when versions are set in nfsmount.conf
This commit is contained in:
Steve Dickson 2009-10-01 11:50:39 +00:00
parent 1e5327b6dd
commit 2f3279563d
4 changed files with 126 additions and 6 deletions

View File

@ -0,0 +1,70 @@
diff -up nfs-utils-1.2.0/utils/mount/configfile.c.orig nfs-utils-1.2.0/utils/mount/configfile.c
--- nfs-utils-1.2.0/utils/mount/configfile.c.orig 2009-09-30 13:57:48.647286000 -0400
+++ nfs-utils-1.2.0/utils/mount/configfile.c 2009-09-30 14:50:05.365468000 -0400
@@ -198,6 +198,15 @@ int inline check_vers(char *mopt, char *
}
return 0;
}
+int inline vers_is_set(char *mopt)
+{
+ int i;
+
+ for (i=0; versions[i]; i++)
+ if (strncasecmp(mopt, versions[i], strlen(versions[i])) == 0)
+ return 1;
+ return 0;
+}
/*
* Parse the given section of the configuration
* file to if there are any mount options set.
@@ -256,6 +265,8 @@ conf_parse_mntopts(char *section, char *
conf_free_list(list);
}
+int do_version_negation;
+
/*
* Concatenate options from the configuration file with the
* given options by building a link list of options from the
@@ -326,6 +337,8 @@ char *conf_get_mntopts(char *spec, char
strcat(config_opts, ",");
}
SLIST_FOREACH(entry, &head, entries) {
+ if (vers_is_set(entry->opt))
+ do_version_negation = 1;
strcat(config_opts, entry->opt);
strcat(config_opts, ",");
}
diff -up nfs-utils-1.2.0/utils/mount/stropts.c.orig nfs-utils-1.2.0/utils/mount/stropts.c
--- nfs-utils-1.2.0/utils/mount/stropts.c.orig 2009-09-30 13:57:48.613288000 -0400
+++ nfs-utils-1.2.0/utils/mount/stropts.c 2009-09-30 14:59:56.716461000 -0400
@@ -588,6 +588,7 @@ out_fail:
po_destroy(options);
return result;
}
+extern int do_version_negation;
/*
* This is a single pass through the fg/bg loop.
@@ -607,12 +608,20 @@ static int nfs_try_mount(struct nfsmount
if (errno != EPROTONOSUPPORT)
break;
}
- case 2:
case 3:
+ if (do_version_negation)
+ po_remove_all(mi->options, "nfsvers");
+ case 2:
result = nfs_try_mount_v3v2(mi);
break;
case 4:
result = nfs_try_mount_v4(mi);
+ if (do_version_negation && !result) {
+ if (errno == EPROTONOSUPPORT) {
+ po_remove_all(mi->options, "nfsvers");
+ result = nfs_try_mount_v3v2(mi);
+ }
+ }
break;
default:
errno = EIO;

View File

@ -0,0 +1,36 @@
diff -up nfs-utils-1.2.0/utils/mount/configfile.c.orig nfs-utils-1.2.0/utils/mount/configfile.c
--- nfs-utils-1.2.0/utils/mount/configfile.c.orig 2009-09-30 11:38:53.745992000 -0400
+++ nfs-utils-1.2.0/utils/mount/configfile.c 2009-09-30 13:49:38.480625000 -0400
@@ -185,6 +185,19 @@ void free_all(void)
free(entry);
}
}
+static char *versions[] = {"v2", "v3", "v4", "vers", "nfsvers", NULL};
+int inline check_vers(char *mopt, char *field)
+{
+ int i;
+
+ if (strcasecmp(field, "nfsvers") == 0 ||
+ strcasecmp(field, "vers") == 0) {
+ for (i=0; versions[i]; i++)
+ if (strncasecmp(mopt, versions[i], strlen(versions[i])) == 0)
+ return 1;
+ }
+ return 0;
+}
/*
* Parse the given section of the configuration
* file to if there are any mount options set.
@@ -207,6 +220,12 @@ conf_parse_mntopts(char *section, char *
snprintf(buf, BUFSIZ, "%s=", node->field);
if (opts && strcasestr(opts, buf) != NULL)
continue;
+ /*
+ * Protocol verions can be set in a number of ways
+ */
+ if (opts && check_vers(opts, node->field))
+ continue;
+
if (lookup_entry(node->field) != NULL)
continue;
buf[0] = '\0';

View File

@ -1,6 +1,6 @@
diff -up nfs-utils-1.2.0/utils/mount/nfsmount.conf.orig nfs-utils-1.2.0/utils/mount/nfsmount.conf
--- nfs-utils-1.2.0/utils/mount/nfsmount.conf.orig 2009-09-29 18:48:47.000000000 -0400
+++ nfs-utils-1.2.0/utils/mount/nfsmount.conf 2009-09-29 19:02:06.000000000 -0400
--- nfs-utils-1.2.0/utils/mount/nfsmount.conf.orig 2009-09-30 11:32:14.148326000 -0400
+++ nfs-utils-1.2.0/utils/mount/nfsmount.conf 2009-09-30 11:35:24.714787000 -0400
@@ -24,12 +24,12 @@
# All reads and writes to the 'nfsserver.foo.com' server
# will be done with 32k (32768 bytes) block sizes.
@ -13,13 +13,13 @@ diff -up nfs-utils-1.2.0/utils/mount/nfsmount.conf.orig nfs-utils-1.2.0/utils/mo
-# Protocol Version [2,3]
-# Nfsvers=3
+# Protocol Version [2,3,4]
+#Nfsvers=3
+Nfsvers=3
# Network Transport [Udp,Tcp,Rdma]
# Proto=Tcp
#
diff -up nfs-utils-1.2.0/utils/mount/stropts.c.orig nfs-utils-1.2.0/utils/mount/stropts.c
--- nfs-utils-1.2.0/utils/mount/stropts.c.orig 2009-09-29 18:48:47.000000000 -0400
+++ nfs-utils-1.2.0/utils/mount/stropts.c 2009-09-29 19:01:10.000000000 -0400
--- nfs-utils-1.2.0/utils/mount/stropts.c.orig 2009-09-30 11:32:14.214327000 -0400
+++ nfs-utils-1.2.0/utils/mount/stropts.c 2009-09-30 11:34:35.841020000 -0400
@@ -601,7 +601,7 @@ static int nfs_try_mount(struct nfsmount
switch (mi->version) {

View File

@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser
Name: nfs-utils
URL: http://sourceforge.net/projects/nfs
Version: 1.2.0
Release: 13%{?dist}
Release: 14%{?dist}
Epoch: 1
# group all 32bit related archs
@ -32,6 +32,9 @@ Patch106: nfs-utils-1.2.0-mount-vers4.patch
Patch200: nfs-utils-1.2.0-v4root-rel6.patch
Patch300: nfs-utils-1.2.0-mntconf-vers.patch
Patch301: nfs-utils-1.2.0-mntconf-negation.patch
Group: System Environment/Daemons
Provides: exportfs = %{epoch}:%{version}-%{release}
Provides: nfsstat = %{epoch}:%{version}-%{release}
@ -92,6 +95,9 @@ This package also contains the mount.nfs and umount.nfs program.
%patch200 -p1
%patch300 -p1
%patch301 -p1
# Remove .orig files
find . -name "*.orig" | xargs rm -f
@ -262,6 +268,14 @@ fi
%attr(4755,root,root) /sbin/umount.nfs4
%changelog
* Wed Sep 30 2009 Steve Dickson <steved@redhat.com> 1.2.0-14
- Change the nfsmount.conf file to define v3 as the default
protocol version.
- Make sure versions set on the command line override version
set in nfsmount.conf
- Make version rollbacks still work when versions are set in
nfsmount.conf
* Tue Sep 29 2009 Steve Dickson <steved@redhat.com> 1.2.0-13
- Added upstream 1.2.1-rc5 patch
- mount.nfs: Support negotiation between v4, v3, and v2