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 8B52764262 for ; Tue, 6 Oct 2020 12:09:03 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8918D24267 for ; Tue, 6 Oct 2020 12:09:03 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 225E52424B for ; Tue, 6 Oct 2020 12:09:02 +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 E658D45B47 for ; Tue, 6 Oct 2020 12:09:01 +0200 (CEST) From: Thomas Lamprecht To: pbs-devel@lists.proxmox.com Date: Tue, 6 Oct 2020 12:08:53 +0200 Message-Id: <20201006100854.18897-2-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201006100854.18897-1-t.lamprecht@proxmox.com> References: <20201006100854.18897-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.149 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [acl.rs, remote.read, datastore.read] Subject: [pbs-devel] [PATCH backup 2/3] acl: use modified constnamedbitmap macro 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: Tue, 06 Oct 2020 10:09:03 -0000 avoiding the need for reshuffling all bits when a new privilege is added at the start or in the middle of this definition. Signed-off-by: Thomas Lamprecht --- NOTE: depends on the proxmox crate macro 1/3 patch src/config/acl.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/config/acl.rs b/src/config/acl.rs index d31c7a85..67f61976 100644 --- a/src/config/acl.rs +++ b/src/config/acl.rs @@ -12,37 +12,37 @@ use ::serde::{Deserialize, Serialize}; use serde::de::{value, IntoDeserializer}; use proxmox::tools::{fs::replace_file, fs::CreateOptions}; -use proxmox::constnamemap; +use proxmox::constnamedbitmap; use proxmox::api::{api, schema::*}; use crate::api2::types::Userid; // define Privilege bitfield -constnamemap! { +constnamedbitmap! { /// Contains a list of Privileges PRIVILEGES: u64 => { - PRIV_SYS_AUDIT("Sys.Audit") = 1 << 0; - PRIV_SYS_MODIFY("Sys.Modify") = 1 << 1; - PRIV_SYS_POWER_MANAGEMENT("Sys.PowerManagement") = 1 << 2; + PRIV_SYS_AUDIT("Sys.Audit"); + PRIV_SYS_MODIFY("Sys.Modify"); + PRIV_SYS_POWER_MANAGEMENT("Sys.PowerManagement"); - PRIV_DATASTORE_AUDIT("Datastore.Audit") = 1 << 3; - PRIV_DATASTORE_MODIFY("Datastore.Modify") = 1 << 4; - PRIV_DATASTORE_READ("Datastore.Read") = 1 << 5; + PRIV_DATASTORE_AUDIT("Datastore.Audit"); + PRIV_DATASTORE_MODIFY("Datastore.Modify"); + PRIV_DATASTORE_READ("Datastore.Read"); /// Datastore.Backup also requires backup ownership - PRIV_DATASTORE_BACKUP("Datastore.Backup") = 1 << 6; + PRIV_DATASTORE_BACKUP("Datastore.Backup"); /// Datastore.Prune also requires backup ownership - PRIV_DATASTORE_PRUNE("Datastore.Prune") = 1 << 7; + PRIV_DATASTORE_PRUNE("Datastore.Prune"); - PRIV_PERMISSIONS_MODIFY("Permissions.Modify") = 1 << 8; + PRIV_PERMISSIONS_MODIFY("Permissions.Modify"); - PRIV_REMOTE_AUDIT("Remote.Audit") = 1 << 9; - PRIV_REMOTE_MODIFY("Remote.Modify") = 1 << 10; - PRIV_REMOTE_READ("Remote.Read") = 1 << 11; - PRIV_REMOTE_PRUNE("Remote.Prune") = 1 << 12; + PRIV_REMOTE_AUDIT("Remote.Audit"); + PRIV_REMOTE_MODIFY("Remote.Modify"); + PRIV_REMOTE_READ("Remote.Read"); + PRIV_REMOTE_PRUNE("Remote.Prune"); - PRIV_SYS_CONSOLE("Sys.Console") = 1 << 13; + PRIV_SYS_CONSOLE("Sys.Console"); } }