Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1076637lqt; Fri, 7 Jun 2024 07:27:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWgFgChb25BzDHpSBPFws1cZ/thYSPXeVhs3GWyhwy2IuF1JFJ0GW0ooiO1Cdhv75rqZk+bNBt2ZO8AZ/6X6vZU6Cq3n8zdr5xGAbccLw== X-Google-Smtp-Source: AGHT+IHoz8eP8dFhHfQvDxcsVJaDzhbddFRTHzqzxVYBsv3UxwhSiueMTJsJI9+50J8jGhl9dN2Z X-Received: by 2002:a67:fa19:0:b0:48b:c0b3:9d2a with SMTP id ada2fe7eead31-48c276d10aamr2442440137.24.1717770428236; Fri, 07 Jun 2024 07:27:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717770428; cv=pass; d=google.com; s=arc-20160816; b=pH5jw5Y5J+LPdHULVKxIYvEuIjj+cSLaMJajyfwcUqUkgCd6n69wxyxXwzZ3CwMn6x 4FHFUoRjy7HrKhKRTqdGexlCyK2ohmcNdGf0mW+SQ2NghI4Hlwh0EHDXSoJY6/41NPch K52k6CtKfKw1NAVf0kPYroFg7MkXpmU+o9gIGkQl3NefKNCioy3pDArGt9EgWh22SGbL ArazaWuBMtQnkxSzGgDE3tQVqMq4z1jOajyt2rpDaNkiKuuR72eQa2tgxNDMRhW8dBuu lWIKAyR2A6O/PJU/CImyaV4xLLNVTuvkyL4pBPCi09EsjrTNgkFkMCJQOZlCBVX6I6Hk 49+g== 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; bh=WBu4ftenDpGj2LTcihy+HJK+af1mIHEXJBb1XhHAnao=; fh=OUKZWod6C22emJS3X689dwhO5bDgGbDS06P/Z6+EGqk=; b=Gzla3pcQnS4MANs1SeYV69d3d4PxoB6YT+4VZD+2/o/l+I8uR1mnrWr0ka6ujL9cvh jRVg/NSzaG6TL5OrWOlxAE0HSR0lHdEStvuWUDaXKl+2OQc3YoJVfoR346gnf7y2i+3M /2rHmLRHu5NKGvW14Xx0LOy6e7IT7ZFYSB13Ak3COY51hFkNTm4gAT5JH5mM/6D8j/kd arjf6s4U5SxrM+KQfIg5qbeeb5JoTZMGAiuEkrGAodVc5ucp5szYzhv5vv/1EENSTFC4 Z08NEZ4l4YaOcxdMVpmao6ynxl+TqexMFFBiLdjUnXBKMYkZbBuDBtCgtrrPdFfDQLJF Xa1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3591-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3591-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ada2fe7eead31-48c38805079si156232137.303.2024.06.07.07.27.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3591-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3591-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3591-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E941A1C22D1A for ; Fri, 7 Jun 2024 14:27:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9E0E196C7B; Fri, 7 Jun 2024 14:27:00 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 609D6195990 for ; Fri, 7 Jun 2024 14:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770420; cv=none; b=UVjz7BG4CJ2yaR3Te+PmrPFXL1LL+7Qk0qVkifpih246XhsYMO4iYAvpRwEXjmqBlCXOtTAz7i7F2efjjj90aK+uBepI+RgH9GZKKWW8AWkMqtx+jCsWjcWl0t1JdcLwPxzlyJFcqUeE/fBG9XSysUkowKNMmcmQuuN/qhL7xbk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770420; c=relaxed/simple; bh=1s9XtguGzy718U2FTfcxPUJDpoNLfxn/vMir5mGQtR8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RrjEYHFteeHdS+Crq53+CyriRGPRzeud4OIiPSvaHZjo8GrwggdUwn6LMkT68hpJxpkcnTV4GK86GSSMRO8XjLBHuRSk008tH0Ic4owBZtqf4D0qogv7xaqAcw+ok9TGeu28NMYVIO0KTuTesHffoLGuc2YfVHtNGpuivE3hs8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=snitzer.net; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=snitzer.net Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-795186ae3e9so129107185a.0 for ; Fri, 07 Jun 2024 07:26:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717770418; x=1718375218; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WBu4ftenDpGj2LTcihy+HJK+af1mIHEXJBb1XhHAnao=; b=ivnU5rBE9XYyaoeuyJvbvFldDARGMUnctCc+JCDl40YQer1JdaJqrBGHNjG+dZRn/m 0rlcZuqRyFi9Acre6/asWHEE4wdVaKT11TZAUZahJ1Ptg7Wd0oqXmGr+d7pFjWynYMjf zZLuKm6Jh+nYpWgGn8mR9JVp2o4mSGM6YJ4WwtTQHttLnqE+W1LLqVZRW/stpNM71Ljb TvqOXkaDclYO/eSSp5PaNhCruMcFDGihMloy595aouJ0sO9NtP/c2hx9BsYyVJEUW+OK b0S1FQd3tr7rQlqqVb9OtarAM0svKgjLbxUIUF9BFRHpRptr+VidKv5kPSrCNUxsP5h4 yU0Q== X-Gm-Message-State: AOJu0Yw/2OXnvaEDN6lOYct0dzFbaAtUQ1mw/sPpEI2En0QJy23RCbYu Pr4sgtF9ah5v1dJMRqcOrmgr9D+ky+fTQvQiubmMoL/qSv2uSu40Bfx9G9A3ndXB5wEvamAmz+P XY5GHjQ== X-Received: by 2002:a05:620a:2a12:b0:792:b835:19be with SMTP id af79cd13be357-7953c43e61fmr337196985a.43.1717770417908; Fri, 07 Jun 2024 07:26:57 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79532871570sm169137885a.54.2024.06.07.07.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:26:57 -0700 (PDT) From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , snitzer@hammerspace.com Subject: [for-6.11 PATCH 06/29] sunrpc: add rpcauth_map_to_svc_cred Date: Fri, 7 Jun 2024 10:26:23 -0400 Message-ID: <20240607142646.20924-7-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240607142646.20924-1-snitzer@kernel.org> References: <20240607142646.20924-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 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 | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index 61e58327b1aa..5ebf031361a1 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(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..55a03a3bcac2 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -308,6 +308,22 @@ rpcauth_init_credcache(struct rpc_auth *auth) } EXPORT_SYMBOL_GPL(rpcauth_init_credcache); +bool +rpcauth_map_to_svc_cred(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; + svc->cr_principal = NULL; + svc->cr_gss_mech = NULL; + if (cred->group_info) + svc->cr_group_info = get_group_info(cred->group_info); + + return true; +} +EXPORT_SYMBOL_GPL(rpcauth_map_to_svc_cred); + char * rpcauth_stringify_acceptor(struct rpc_cred *cred) { -- 2.44.0