From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D97D86A2FF for ; Thu, 16 Sep 2021 10:25:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CD351222DC for ; Thu, 16 Sep 2021 10:25:40 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 62303222D3 for ; Thu, 16 Sep 2021 10:25:40 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 36409448D3; Thu, 16 Sep 2021 10:25:40 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Thu, 16 Sep 2021 10:25:38 +0200 Message-Id: <20210916082538.825118-1-dietmar@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.673 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox] impl UserInformation for std::sync::Arc X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2021 08:25:40 -0000 --- proxmox/src/api/permission.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/proxmox/src/api/permission.rs b/proxmox/src/api/permission.rs index 5792c8f..b55bcd5 100644 --- a/proxmox/src/api/permission.rs +++ b/proxmox/src/api/permission.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use std::fmt; +use std::ops::Deref; /// Access permission #[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))] @@ -72,6 +73,18 @@ pub trait UserInformation { fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64; } +impl UserInformation for std::sync::Arc { + fn is_superuser(&self, userid: &str) -> bool { + self.deref().is_superuser(userid) + } + fn is_group_member(&self, userid: &str, group: &str) -> bool { + self.deref().is_group_member(userid, group) + } + fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64 { + self.deref().lookup_privs(userid, path) + } +} + /// Example implementation to check access permissions /// /// This implementation supports URI variables in Privilege path -- 2.30.2