File 0006-Revert-mount-Remove-NFS-v2-support-from-mount.nfs.patch of Package nfs-utils.39260

From ddbfdf083d20a88352ec5d1928f16dce3d387ec5 Mon Sep 17 00:00:00 2001
From: Anthony Iliopoulos <ailiop@suse.com>
Date: Wed, 16 Oct 2024 17:35:52 +0200
Subject: [PATCH] Revert "mount: Remove NFS v2 support from mount.nfs"
References: bsc#1230914

This reverts commit ba79e680b50d18125f4d066a45989b17b71289ea.

---
 utils/mount/configfile.c  |  2 +-
 utils/mount/network.c     |  4 ++--
 utils/mount/nfsmount.conf |  2 +-
 utils/mount/stropts.c     | 10 +---------
 4 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index 1d88cbfcc659..3d3684efa186 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -71,7 +71,7 @@ struct mnt_alias {
 int mnt_alias_sz = (sizeof(mnt_alias_tab)/sizeof(mnt_alias_tab[0]));
 
 static const char *version_keys[] = {
-	"v3", "v4", "vers", "nfsvers", "minorversion", NULL
+	"v2", "v3", "v4", "vers", "nfsvers", "minorversion", NULL
 };
 
 static int strict;
diff --git a/utils/mount/network.c b/utils/mount/network.c
index 01ead49f0008..2e0415aa681f 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -97,7 +97,7 @@ static const char *nfs_transport_opttbl[] = {
 };
 
 static const char *nfs_version_opttbl[] = {
-	"v2", /* no longer supported */
+	"v2",
 	"v3",
 	"v4",
 	"vers",
@@ -1275,7 +1275,7 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v
 	else if (found < 0)
 		return 1;
 	else if (found <= 2 ) {
-		/* v3, v4 */
+		/* v2, v3, v4 */
 		version_val = version_key + 1;
 		version->v_mode = V_SPECIFIC;
 	} else if (found > 2 ) {
diff --git a/utils/mount/nfsmount.conf b/utils/mount/nfsmount.conf
index c498eb80d3ee..51db922f6f45 100644
--- a/utils/mount/nfsmount.conf
+++ b/utils/mount/nfsmount.conf
@@ -28,7 +28,7 @@
 # This statically named section defines global mount 
 # options that can be applied on all NFS mount.
 #
-# Protocol Version [3,4]
+# Protocol Version [2,3,4]
 # This defines the default protocol version which will
 # be used to start the negotiation with the server.
 # Defaultvers=4
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index dbdd11e76b41..1be0f4c811bf 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -357,7 +357,6 @@ static int nfs_insert_sloppy_option(struct mount_options *options)
 
 static int nfs_set_version(struct nfsmount_info *mi)
 {
-
 	if (!nfs_nfs_version(mi->type, mi->options, &mi->version))
 		return 0;
 
@@ -1019,6 +1018,7 @@ static int nfs_try_mount(struct nfsmount_info *mi)
 	}
 
 	switch (mi->version.major) {
+		case 2:
 		case 3:
 			result = nfs_try_mount_v3v2(mi, FALSE);
 			break;
@@ -1249,14 +1249,6 @@ static int nfsmount_start(struct nfsmount_info *mi)
 	if (!nfs_validate_options(mi))
 		return EX_FAIL;
 
-	/* 
-	 * NFS v2 has been deprecated
-	 */
-	if (mi->version.major == 2) {
-		mount_error(mi->spec, mi->node, EOPNOTSUPP);
-		return EX_FAIL;
-	}
-
 	/*
 	 * Avoid retry and negotiation logic when remounting
 	 */
-- 
2.47.0

openSUSE Build Service is sponsored by