From patchwork Tue Jun 28 18:25:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 925722 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5SIgqZ7004724 for ; Tue, 28 Jun 2011 18:42:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760482Ab1F1S2G (ORCPT ); Tue, 28 Jun 2011 14:28:06 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:44869 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760483Ab1F1SZf (ORCPT ); Tue, 28 Jun 2011 14:25:35 -0400 Received: by iyb12 with SMTP id 12so373005iyb.19 for ; Tue, 28 Jun 2011 11:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:subject:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=TKNA6Ra9yHKHSKIhjJw3vEcGUADEUVjm4arAP9qBM18=; b=ZlC9dJJSb2QkiiiB6VfOaEngoevav/LFFFdtaEgqlRgxB9+iEJupMtOFeOvKUMPsL8 uKKNdZguOx6ZGPBCDtZxMPA0vsMq0OPSoEu5WLpsA95JeQMT9ctH4EjxQYtai74T/ya0 PyMY6pGTpAwXdbop8ADhS4dodK1riFNP2O3Pk= Received: by 10.42.158.130 with SMTP id h2mr9336998icx.199.1309285533844; Tue, 28 Jun 2011 11:25:33 -0700 (PDT) Received: from seurat.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net [99.26.161.222]) by mx.google.com with ESMTPS id ly7sm336351icb.0.2011.06.28.11.25.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Jun 2011 11:25:33 -0700 (PDT) From: Chuck Lever Subject: [PATCH 1/2] NFS: Clean up nfs_walk_authlist() To: linux-nfs@vger.kernel.org Date: Tue, 28 Jun 2011 14:25:31 -0400 Message-ID: <20110628182530.2866.58433.stgit@seurat.1015granger.net> In-Reply-To: <20110628181324.2866.98154.stgit@seurat.1015granger.net> References: <20110628181324.2866.98154.stgit@seurat.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 28 Jun 2011 18:42:56 +0000 (UTC) Clean up: Add common exit labels in preparation for the following patch. Clarify comments. Rename variable for clarity. Signed-off-by: Chuck Lever --- fs/nfs/super.c | 45 +++++++++++++++++++++++---------------------- 1 files changed, 23 insertions(+), 22 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfs/super.c b/fs/nfs/super.c index ce40e5c..4625a4c 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -1541,15 +1541,19 @@ out_security_failure: } /* - * Match the requested auth flavors with the list returned by - * the server. Returns zero and sets the mount's authentication - * flavor on success; returns -EACCES if server does not support - * the requested flavor. + * Match the requested auth flavors with the list returned by the + * server. args->auth_flavors contains a list of security flavors + * to check for. The caller has already set up the list of flavors + * with the default (usually AUTH_SYS). + * + * Returns zero on success; the authentication flavor in args-> + * auth_flavors[0] should be used for this mount. Otherwise, returns + * -EACCES if server does not support the requested flavor. */ static int nfs_walk_authlist(struct nfs_parsed_mount_data *args, - struct nfs_mount_request *request) + struct nfs_mount_request *server) { - unsigned int i, j, server_authlist_len = *(request->auth_flav_len); + unsigned int i, j, server_authlist_len = *(server->auth_flav_len); /* * Certain releases of Linux's mountd return an empty @@ -1559,31 +1563,28 @@ static int nfs_walk_authlist(struct nfs_parsed_mount_data *args, * if the returned flavor list is empty. */ if (server_authlist_len == 0) - return 0; + goto out; /* - * We avoid sophisticated negotiating here, as there are - * plenty of cases where we can get it wrong, providing - * either too little or too much security. - * - * RFC 2623, section 2.7 suggests we SHOULD prefer the - * flavor listed first. However, some servers list - * AUTH_NULL first. Our caller plants AUTH_SYS, the - * preferred default, in args->auth_flavors[0] if user - * didn't specify sec= mount option. + * RFC 2623 section 2.7 says "... a NFS client SHOULD use + * the first flavor in the list that it supports, on the + * assumption that the best access is provided by the first + * flavor." */ for (i = 0; i < args->auth_flavor_len; i++) for (j = 0; j < server_authlist_len; j++) - if (args->auth_flavors[i] == request->auth_flavs[j]) { - dfprintk(MOUNT, "NFS: using auth flavor %d\n", - request->auth_flavs[j]); - args->auth_flavors[0] = request->auth_flavs[j]; - return 0; + if (args->auth_flavors[i] == server->auth_flavs[j]) { + args->auth_flavors[0] = server->auth_flavs[j]; + goto out; } dfprintk(MOUNT, "NFS: server does not support requested auth flavor\n"); - nfs_umount(request); + nfs_umount(server); return -EACCES; + +out: + dfprintk(MOUNT, "NFS: using auth flavor %d\n", args->auth_flavors[0]); + return 0; } /*