Blob Blame History Raw
autofs-5.0.7 - check for protocol option

From: Ian Kent <raven@themaw.net>

When a specific protocol is requested in the mount options only
that protocol should be probed for.
---
 modules/mount_nfs.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index 9de8a73..3d2ccea 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -156,6 +156,12 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
 					if (port < 0)
 						port = 0;
 					port_opt = cp;
+				} else if (strncmp("proto=udp", cp, o_len) == 0 ||
+					   strncmp("udp", cp, o_len) == 0) {
+					vers &= ~TCP_SUPPORTED;
+				} else if (strncmp("proto=tcp", cp, o_len) == 0 ||
+					   strncmp("tcp", cp, o_len) == 0) {
+					vers &= ~UDP_SUPPORTED;
 				}
 				/* Check for options that also make sense
 				   with bind mounts */
@@ -167,6 +173,10 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
 			}
 		}
 
+		/* In case both tcp and udp options were given */
+		if ((vers & NFS_PROTO_MASK) == 0)
+			vers |= NFS_PROTO_MASK;
+
 		debug(ap->logopt, MODPREFIX
 		      "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d",
 		      nfsoptions, nobind, nosymlink, ro);