Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp181199lqp; Tue, 11 Jun 2024 20:08:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWD+Qbx6L+qcZA+V+3kNg0m1Hos46pxiqO5mtZSwO3Vw+4SpbTNh8z1Wlpc7GLruF43A+m5STBilafBHjHWEwkouTVAvdaV+1e8cFwdIA== X-Google-Smtp-Source: AGHT+IGd0RrxpYk3CR2Ef6i6LUAAwCq3deFIwy8GAPibBCVGDBt+gxeOIYrOSNf6daVId7F2NoSn X-Received: by 2002:a17:906:3c14:b0:a6e:fb27:8cde with SMTP id a640c23a62f3a-a6f47d523f5mr20722566b.19.1718161687170; Tue, 11 Jun 2024 20:08:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718161687; cv=pass; d=google.com; s=arc-20160816; b=PnHjk+KExhPXecUAqGKWobvxHmmt+1Qupo5cKY/n24FaT3XJc9lrQJE5aBX6N6Eirj EFDSbF5rAg/SM/QK3kq+fBDXaEPlcri4hocprL0WSBAXeqxST0C8nXPU1XemEfco3Ml7 wr9VwUJFoXv94IWAyj8tiNa2rhoZ3+raWbEVsvtpUi9BYwjBK8VEDcrU0aHi0jUB4AWX eWlgRtMSqKxBkEvMWXdcyCbK3wu1We5WW7KwYOvDWUWuJX5/V+9lwVuRpNXqj4I8p2ZI pB2hWyKNlHdVr4SCcHZwHkiL5qYEVj0canUPxta9zyE8XgC5C1fTVQNFdrLx1Pc+yN8h p9hw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=IeIHFtT7C0xv96a53N7ZgOeGt8oYqZMfKUfCwHu++RQ=; fh=+HdF1SWcNPggmowVZtzfZ2+SYSXLLgvZBECjaw6UQek=; b=WqNrh3emNJtMpWbpRp9663UtsXKChFqe9Z/ep007DNUeMambxBJvylXgpzPRz9Dl80 PfLrZ8Ml2gFoOarqeEr8wEbOYFN0TZIx3FwPFD02E2C6czUThJ4GU1pwTMfPYC6MBixg lqvbXi3GbpXl2PZa7BApqTAIdr2wfy1Yr3N9ZDhb/nI2IPbJVkVWjmjedrBRzWbJk6nR APeC7gITDYRaWTYobOHBiAeTIyOOr9xJsLr1kMtXyCADYyJ1asi8YUjhrrdABQpXDSrE /BScyHMhZoh3HEBN8TDxFJiQIy8e879675KyynBPNSfuAkJUFRpsDfdOT3uFqiJnFNmc NkVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tuRNMMUB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6efea88a44si409113666b.488.2024.06.11.20.08.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 20:08:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tuRNMMUB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D1B2E1F22C21 for ; Wed, 12 Jun 2024 03:08:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15BE91DDEB; Wed, 12 Jun 2024 03:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tuRNMMUB" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E503C1D6A5 for ; Wed, 12 Jun 2024 03:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718161680; cv=none; b=GrNtYy+CMr6Sm/HUCQnE0hwm7HyWqLUH1IQmKDYXOx8CUWDyl1xIHfmOlSyFgbRf1pwpO9+rTVF/teI6HhruC8W//cdWaMRm5Dw8je3eAhqAn23+jnQQl6O7Z1DnVDLF3r544ysFlX7KKI7zH9DBc9nx2DxztOYkO8XesIu4Czw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718161680; c=relaxed/simple; bh=vFT0uYJpz+sxIxJhT3VxHIZ3AQfAlFMvKRk7QsI9K+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CvgC5/6tYQBcQ87/HTHNCtWwPWdM4eoTDqG4XJmPu4JTr1tBLDGHuj+E67OtnCyolZ4O5DltgkenCouVBVwoN8CDiwq2TxieOpnwj1WI9FIAAUItdUrRvuVhmp8U1rqbMBZTgsjD+I9SXh+5cqEjPSU2P+LwSkm9yKu0i4TvXJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tuRNMMUB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 414D1C2BD10; Wed, 12 Jun 2024 03:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718161679; bh=vFT0uYJpz+sxIxJhT3VxHIZ3AQfAlFMvKRk7QsI9K+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tuRNMMUBp3GR0UK5IGD7cmwmU1P7tqan6GeyZnPiN5CBJBOBjh6O8c46aYJfR/6Nn XV4nutyeu9ew+c5P8h4MqD0TUbYWqj7mfyYKGspEpXP1VLisI9LJckBqI3eg20qf+5 bWQYf9uGYbdYqyUCOMJuhVUMCpcgAJlV4qbVpzMg9o0GoXnzs0SBGwGX1Y7FPgaVo9 mQzpuCPw4ByAreh9D9tv3J+sA5t4rs5JneE/WrqxWujYZkFNdPOGDvvj9W3l7rNSEZ 4GofwTSc70B7DuE3B5mWZ+pOW4cksojh3W6qSqpKtf+fb59jrNLYTqwue9VRs/DWhf UEOuQHdJlJvAg== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , NeilBrown , snitzer@hammerspace.com Subject: [RFC PATCH v2 04/15] sunrpc: add rpcauth_map_to_svc_cred_local Date: Tue, 11 Jun 2024 23:07:41 -0400 Message-ID: <20240612030752.31754-5-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240612030752.31754-1-snitzer@kernel.org> References: <20240612030752.31754-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Weston Andros Adamson Add new funtion rpcauth_map_to_svc_cred_local which maps a generic rpc_cred to an svc_cred suitable for use in nfsd. This is needed by the localio code to map nfs client creds to nfs server credentials. Signed-off-by: Weston Andros Adamson Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust Signed-off-by: Mike Snitzer --- include/linux/sunrpc/auth.h | 4 ++++ net/sunrpc/auth.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index 61e58327b1aa..f8b561cf78ab 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h @@ -11,6 +11,7 @@ #define _LINUX_SUNRPC_AUTH_H #include +#include #include #include @@ -184,6 +185,9 @@ int rpcauth_uptodatecred(struct rpc_task *); int rpcauth_init_credcache(struct rpc_auth *); void rpcauth_destroy_credcache(struct rpc_auth *); void rpcauth_clear_credcache(struct rpc_cred_cache *); +bool rpcauth_map_to_svc_cred_local(struct rpc_auth *, + const struct cred *, + struct svc_cred *); char * rpcauth_stringify_acceptor(struct rpc_cred *); static inline diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 04534ea537c8..f75728922d57 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -308,6 +308,23 @@ rpcauth_init_credcache(struct rpc_auth *auth) } EXPORT_SYMBOL_GPL(rpcauth_init_credcache); +bool +rpcauth_map_to_svc_cred_local(struct rpc_auth *auth, const struct cred *cred, + struct svc_cred *svc) +{ + svc->cr_uid = cred->uid; + svc->cr_gid = cred->gid; + svc->cr_flavor = auth->au_flavor; + if (cred->group_info) + svc->cr_group_info = get_group_info(cred->group_info); + /* These aren't relevant for local (network is bypassed) */ + svc->cr_principal = NULL; + svc->cr_gss_mech = NULL; + + return true; +} +EXPORT_SYMBOL_GPL(rpcauth_map_to_svc_cred_local); + char * rpcauth_stringify_acceptor(struct rpc_cred *cred) { -- 2.44.0