walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
2038fc4
commit 3c1bb23c0379864722e79d19f74c180edcf2c36e
2038fc4
Author: bc Wong <bcwong@cisco.com>
2038fc4
Date:   Tue Mar 18 09:30:44 2008 -0400
2038fc4
2038fc4
    There were 2 things wrong with auth flavour ordering:
2038fc4
    - Mountd used to advertise AUTH_NULL as the first flavour on
2038fc4
      the list, which means that it prefers AUTH_NULL to anything
2038fc4
      else (as per RFC 2623 section 2.7).
2038fc4
    - Mount.nfs used to scan the returned list in reverse order,
2038fc4
      and stopping at the first AUTH_NULL or AUTH_SYS encountered.
2038fc4
      If a server advertises (AUTH_SYS, AUTH_NULL), it will by
2038fc4
      default choose AUTH_NULL and have degraded access.
2038fc4
    
2038fc4
    I've fixed mount.nfs to scan from the beginning. For mountd,
2038fc4
    it does not advertise AUTH_NULL anymore. This is necessary
2038fc4
    to avoid backward compatibility issue. If AUTH_NULL appears
2038fc4
    in the list, either the new or the old client will choose
2038fc4
    that over AUTH_SYS.
2038fc4
    
2038fc4
    Tested the server/client combination against the previous
2038fc4
    versions, as well as Solaris and FreeBSD.
2038fc4
    
2038fc4
    Signed-off-by: bc Wong <bcwong@cisco.com>
2038fc4
    Signed-off-by: Steve Dickson <steved@redhat.com>
2038fc4
2038fc4
--- nfs-utils-1.1.2/utils/mount/nfsmount.c.orig	2008-03-14 11:46:29.000000000 -0400
2038fc4
+++ nfs-utils-1.1.2/utils/mount/nfsmount.c	2008-03-25 10:18:09.333839000 -0400
2038fc4
@@ -738,7 +738,7 @@ nfsmount(const char *spec, const char *n
2038fc4
 #if NFS_MOUNT_VERSION >= 4
2038fc4
 		mountres3_ok *mountres;
2038fc4
 		fhandle3 *fhandle;
2038fc4
-		int i, *flavor, yum = 0;
2038fc4
+		int i,  n_flavors, *flavor, yum = 0;
2038fc4
 		if (mntres.nfsv3.fhs_status != 0) {
2038fc4
 			nfs_error(_("%s: %s:%s failed, reason given by server: %s"),
2038fc4
 					progname, hostname, dirname,
2038fc4
@@ -747,13 +747,16 @@ nfsmount(const char *spec, const char *n
2038fc4
 		}
2038fc4
 #if NFS_MOUNT_VERSION >= 5
2038fc4
 		mountres = &mntres.nfsv3.mountres3_u.mountinfo;
2038fc4
-		i = mountres->auth_flavors.auth_flavors_len;
2038fc4
-		if (i <= 0)
2038fc4
+		n_flavors = mountres->auth_flavors.auth_flavors_len;
2038fc4
+		if (n_flavors <= 0)
2038fc4
 			goto noauth_flavors;
2038fc4
 
2038fc4
 		flavor = mountres->auth_flavors.auth_flavors_val;
2038fc4
-		while (--i >= 0) {
2038fc4
-			/* If no flavour requested, use first simple
2038fc4
+		for (i = 0; i < n_flavors; ++i) {
2038fc4
+			/*
2038fc4
+			 * Per RFC2623, section 2.7, we should prefer the
2038fc4
+			 * flavour listed first.
2038fc4
+			 * If no flavour requested, use the first simple
2038fc4
 			 * flavour that is offered.
2038fc4
 			 */
2038fc4
 			if (! (data.flags & NFS_MOUNT_SECFLAVOUR) &&
2038fc4
--- nfs-utils-1.1.2/utils/mountd/mountd.c.orig	2008-03-14 11:46:29.000000000 -0400
2038fc4
+++ nfs-utils-1.1.2/utils/mountd/mountd.c	2008-03-25 10:18:09.339833000 -0400
2038fc4
@@ -342,7 +342,14 @@ mount_mnt_3_svc(struct svc_req *rqstp, d
2038fc4
 #define AUTH_GSS_KRB5 390003
2038fc4
 #define AUTH_GSS_KRB5I 390004
2038fc4
 #define AUTH_GSS_KRB5P 390005
2038fc4
-	static int	flavors[] = { AUTH_NULL, AUTH_UNIX, AUTH_GSS_KRB5, AUTH_GSS_KRB5I, AUTH_GSS_KRB5P};
2038fc4
+	static int	flavors[] = { AUTH_UNIX, AUTH_GSS_KRB5, AUTH_GSS_KRB5I, AUTH_GSS_KRB5P};
2038fc4
+	/*
2038fc4
+	 * We should advertise the preferred flavours first. (See RFC 2623
2038fc4
+	 * section 2.7.) AUTH_UNIX is arbitrarily ranked over the GSS's.
2038fc4
+	 * AUTH_NULL is dropped from the list to avoid backward compatibility
2038fc4
+	 * issue with older Linux clients, who inspect the list in reversed
2038fc4
+	 * order.
2038fc4
+	 */
2038fc4
 	struct nfs_fh_len *fh;
2038fc4
 
2038fc4
 	xlog(D_CALL, "MNT3(%s) called", *path);