From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id C352F1FF15E for ; Mon, 27 Oct 2025 11:31:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CCC8EF25; Mon, 27 Oct 2025 11:32:09 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Mon, 27 Oct 2025 11:31:22 +0100 Message-ID: <20251027103123.101013-3-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251027103123.101013-1-c.ebner@proxmox.com> References: <20251027103123.101013-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761561084799 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.043 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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. [proxmox.com, datastore.rs] Subject: [pbs-devel] [PATCH proxmox-backup stable-3 v2 2/3] api: admin: datastore: factor out 'get_group_owner' 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" From: Dominik Csapak and change the `eprintln` to a `log::warn` Signed-off-by: Dominik Csapak Link: https://lore.proxmox.com/20251008134344.3512958-6-d.csapak@proxmox.com (cherry picked from commit 9af3b391b6c465371b895e3d7b81b3fcc640feb6) Signed-off-by: Christian Ebner --- changes since version 1: - include cherry-picked commit digest and missing signed-off trailer src/api2/admin/datastore.rs | 47 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 1f097a555..9535c3417 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -213,18 +213,8 @@ fn backup_group_to_group_list_item( auth_id: &Authid, list_all: bool, ) -> Option { - let owner = match datastore.get_owner(ns, group.as_ref()) { - Ok(auth_id) => auth_id, - Err(err) => { - eprintln!( - "Failed to get owner of group '{}' in {} - {}", - group.group(), - print_store_and_ns(datastore.name(), ns), - err - ); - return None; - } - }; + let owner = get_group_owner(datastore.name(), ns, &group)?; + if !list_all && check_backup_owner(&owner, auth_id).is_err() { return None; } @@ -492,6 +482,25 @@ pub async fn list_snapshots( .map_err(|err| format_err!("failed to await blocking task: {err}"))? } +fn get_group_owner( + store: &str, + ns: &BackupNamespace, + group: &pbs_datastore::BackupGroup, +) -> Option { + match group.get_owner() { + Ok(auth_id) => Some(auth_id), + Err(err) => { + log::warn!( + "Failed to get owner of group '{}' in {} - {}", + group.group(), + print_store_and_ns(store, ns), + err + ); + None + } + } +} + /// This must not run in a main worker thread as it potentially does tons of I/O. unsafe fn list_snapshots_blocking( store: String, @@ -605,17 +614,9 @@ unsafe fn list_snapshots_blocking( }; groups.iter().try_fold(Vec::new(), |mut snapshots, group| { - let owner = match group.get_owner() { - Ok(auth_id) => auth_id, - Err(err) => { - eprintln!( - "Failed to get owner of group '{}' in {} - {}", - group.group(), - print_store_and_ns(&store, &ns), - err - ); - return Ok(snapshots); - } + let owner = match get_group_owner(&store, &ns, group) { + Some(auth_id) => auth_id, + None => return Ok(snapshots), }; if !list_all && check_backup_owner(&owner, &auth_id).is_err() { -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel