File: fix-nfs4-mounts-in-auto-net.patch

package info (click to toggle)
autofs 5.1.8-2%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,864 kB
  • sloc: ansic: 35,535; yacc: 1,819; lex: 1,124; sh: 627; makefile: 541
file content (70 lines) | stat: -rw-r--r-- 2,126 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Description: Fix nfs4/nfs mounting via autofs in auto.net.
Author: David Mohr <bugs@da.mcbf.net>

--- a/samples/auto.net
+++ b/samples/auto.net
@@ -11,29 +11,44 @@
 # add "nonstrict" to make it OK for some filesystems to not mount
 # choose one of the two lines below depending on the NFS version in your
 # environment
-opts="-fstype=nfs,hard,nodev,nosuid"
-#opts="-fstype=nfs4,hard,nodev,nosuid,async"
 
-for P in /bin /sbin /usr/bin /usr/sbin
-do
-	for M in showmount kshowmount
+[ -f /etc/default/autofs ] && . /etc/default/autofs
+
+if [ -z "$MOUNT_NFS_DEFAULT_PROTOCOL" -o "$MOUNT_NFS_DEFAULT_PROTOCOL" == "3" ]; then
+	# Showmount comes in a number of names and varieties.  "showmount" is
+	# typically an older version which accepts the '--no-headers' flag
+	# but ignores it.  "kshowmount" is the newer version installed with knfsd,
+	# which both accepts and acts on the '--no-headers' flag.
+	#SHOWMOUNT="kshowmount --no-headers -e $key"
+	#SHOWMOUNT="showmount -e $key | tail -n +2"
+
+	for P in /bin /sbin /usr/bin /usr/sbin
 	do
-		if [ -x $P/$M ]
-		then
-			SMNT=$P/$M
-			break 2
-		fi
+		for M in showmount kshowmount
+		do
+			if [ -x $P/$M ]
+			then
+				SMNT=$P/$M
+				break
+			fi
+		done
 	done
-done
 
-[ -x $SMNT ] || exit 1
+	[ -x $SMNT ] || exit 1
+
+	# Newer distributions get this right
+	SHOWMOUNT="$SMNT --no-headers -e $key"
 
-# Newer distributions get this right
-SHOWMOUNT="$SMNT --no-headers -e $key"
+	$SHOWMOUNT | LC_ALL=C cut -d' ' -f1 | LC_ALL=C sort -u | \
+		awk -v key="$key" -v opts="$opts" -- '
+		BEGIN	{ ORS=""; first=1 }
+			{ if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 }
+		END	{ if (!first) print "\n"; else exit 1 }
+		' | sed 's/#/\\#/g'
+	opts="-fstype=nfs,hard,intr,nodev,nosuid"
+else
+	# NFSv4
+	opts="-fstype=nfs4,hard,intr,nodev,nosuid,async"
 
-$SHOWMOUNT | LC_ALL=C cut -d' ' -f1 | LC_ALL=C sort -u | \
-	awk -v key="$key" -v opts="$opts" -- '
-	BEGIN	{ ORS=""; first=1 }
-		{ if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 }
-	END	{ if (!first) print "\n"; else exit 1 }
-	' | sed 's/#/\\#/g'
+	echo "$opts $key:/"
+fi