Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp561902lqs; Thu, 13 Jun 2024 20:44:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmI6KmZhcKX58U99gh5KnN06Dhv6cb10pYqfQ4mDCnP966xim0i2+Np7YakrdtW+iIJDGVpx3yjl0y6LVrcdU6L1Qi9KnmQUa55NHzog== X-Google-Smtp-Source: AGHT+IHaCsATCn+kuilaQ6PVC3s1KvDT5CeFpWOMdEEkeJkp9DLr+O/u1hOlJUa7lKusc03plHOz X-Received: by 2002:a17:90a:bf0a:b0:2c4:ad1a:cfb with SMTP id 98e67ed59e1d1-2c4db24d07bmr1705571a91.16.1718336679759; Thu, 13 Jun 2024 20:44:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718336679; cv=pass; d=google.com; s=arc-20160816; b=eEl0afXHHUGtEpCgbwxRFjBcWWMIveFv97a+9Uv48VgMFXIj6rZ9+oXQu66F/++x7R Xkqkcvk45/GQElgq6NiaQf4p3hDpOTGSQ2SL+GO3Uq3ynkQpfVavpfGwMIrnK8XHVrNb TW0OYg5eRGRZKWk6iJ4zo2vKzxS78go+sMqFJogP3wdpsCsezvGhsG7gmqQQj1nd2Kxl QtocCc6Znt3d2JB1NtDdsZ3AnUREJFu18pmVddEev3/CtbAgNaS4iec/0qsuzxluuJs5 M1AAQuv1F3d0Fo8UPNn1oBvKpuqLNnsd/+SrzIqSm9n5a2Y1CxhF5ru+CLrBLMwAHXY+ Tdnw== 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=EA6BY82xMskTkXXWhe2MUNN8Qdajodz/fzn9kDOuAIU=; fh=+HdF1SWcNPggmowVZtzfZ2+SYSXLLgvZBECjaw6UQek=; b=z1GQjRA21bH0L29+J7HzJHaUfMCSHDxSXnDVt55tEhf0Z5Te2T3rBOS78txxtFs9+j tmFc/HinOsu9bbG4FPGkgLYHZ4V0UZcp71Zop2RmxHmQiqJFegXvpP0cC3q9OS7OAP0T LwuOl9x2PtYMBo9TgxTw3eeQqsSFglVo63OrCBLZzzrG12PjG2JKkD4u+2nndmP01R1h /JNJeJXB5wAzWBjKjH3MOE+cWMEzZL0wD93cuLJuRsgHVcimVhkhKjkePtxXYqoh1sSc grKnD3BjS1xJQtOMtP/hOqOVbJgHrbZGPeRMKYLAu+X14wcJ1R4eFqKufW4Xf1Q2IUDj wJtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=leD085Xs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3804-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3804-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a76a5ba4si4850559a91.119.2024.06.13.20.44.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 20:44:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3804-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=leD085Xs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3804-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3804-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 603302841AE for ; Fri, 14 Jun 2024 03:44:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C93AA262BE; Fri, 14 Jun 2024 03:44:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="leD085Xs" 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 A4A70ECC for ; Fri, 14 Jun 2024 03:44:33 +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=1718336673; cv=none; b=ITz50P99LKOz6VUffy6EEOBTZuLlCfPkqHza4FlgC5ui5sASc+EFe+tpHe5KjiH1wqwP63s0hK3MCW/zSypGgHv5RnvMHBadOSDjz2FnUoElwj4CK04YFOI7UEhArH1iuEcFfb8SZUqXSmKEiPPQHc8TAVKUptetW6r2JZz8dz8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718336673; c=relaxed/simple; bh=tmkERfoTUiJ8+89vv7FT3X2MSkEEVlz9hWozpswzLCE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NKd7NO//q1T5uftCSgJuIG2dE41h2zSX32nIHp0PmkyjYmc6K3nd3gbAdDcD0SpKugicmYpbSaP20EI/UyA61kg2/wOZN5XS5XfVM0yrwnzku7tVgE4IOwlSPzgS4E4C1S6QE0lF4jqca3diqhmZelX6urZaAyvZ0lmI3uyMXRE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=leD085Xs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AB1FC4AF1D; Fri, 14 Jun 2024 03:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718336673; bh=tmkERfoTUiJ8+89vv7FT3X2MSkEEVlz9hWozpswzLCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=leD085Xs335QLOWrZ3kCdaLbdd+Lw+/UsyT311qgBGpp70OrjStw/U7d/gv8S/16P dJCSX8KX03Uv+/STtE09oF2lFCphQTU0+Mfx7wNCg7AqRdzEbWjoeqBlfiKJw2WDh2 UmWNF/Zg9LC47LQfadCL2sfHeLuXUcliNg3B/va2JvT0HpiO3lanTKj30Irr8HQekK 2d0L1/F1NIlXg57E853aODIVUbOkGPZCi0qtlgHUFAn18uadtCwbP/gkdmOrq9FK6J L0FwVdaJ8k4gpA/F4hSPshC3CaQ0te7V0Z02lBDArLHC7KNot3nCoCjqHfVXZyk15S fZroiDvPyI4Dw== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , NeilBrown , snitzer@hammerspace.com Subject: [PATCH v3 04/18] sunrpc: add rpcauth_map_to_svc_cred_local Date: Thu, 13 Jun 2024 23:44:12 -0400 Message-ID: <20240614034426.31043-5-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240614034426.31043-1-snitzer@kernel.org> References: <20240614034426.31043-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 cred to a 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 | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index 61e58327b1aa..872f594a924c 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 *); +void 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..00f12ca779c5 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -308,6 +308,21 @@ rpcauth_init_credcache(struct rpc_auth *auth) } EXPORT_SYMBOL_GPL(rpcauth_init_credcache); +void +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; +} +EXPORT_SYMBOL_GPL(rpcauth_map_to_svc_cred_local); + char * rpcauth_stringify_acceptor(struct rpc_cred *cred) { -- 2.44.0