From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 8D1951FF13E for ; Wed, 01 Jul 2026 16:05:08 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 3279821472; Wed, 01 Jul 2026 16:05:02 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v3 09/15] pbs-datastore: use general helpers for file lock create options Date: Wed, 1 Jul 2026 16:04:06 +0200 Message-ID: <20260701140412.200920-10-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260701140412.200920-1-c.ebner@proxmox.com> References: <20260701140412.200920-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782914661877 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.050 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: BF5LQMC54OB4DRJL43VZY5CFYSAJDZ2U X-Message-ID-Hash: BF5LQMC54OB4DRJL43VZY5CFYSAJDZ2U X-MailFrom: c.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of using local implementations, use the helpers provided by the proxmox-product-config crate for consistency. By this the backup user lookup is avoided as well, using the globally cached information instead. Signed-off-by: Christian Ebner --- pbs-datastore/src/move_journal.rs | 11 ++--------- pbs-datastore/src/task_tracking.rs | 7 +------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/pbs-datastore/src/move_journal.rs b/pbs-datastore/src/move_journal.rs index a31001541..a678115d4 100644 --- a/pbs-datastore/src/move_journal.rs +++ b/pbs-datastore/src/move_journal.rs @@ -48,11 +48,8 @@ use std::path::{Path, PathBuf}; use std::time::Duration; use anyhow::{Context, Error, bail, format_err}; -use nix::sys::stat::Mode; -use proxmox_sys::fs::{CreateOptions, open_file_locked}; - -use pbs_config::backup_user; +use proxmox_sys::fs::open_file_locked; use crate::backup_info::DATASTORE_LOCKS_DIR; @@ -78,11 +75,7 @@ fn ensure_parent(path: &Path) -> Result<(), Error> { fn open_locked_exclusive(path: &Path, timeout: Duration) -> Result { ensure_parent(path)?; - let user = backup_user()?; - let options = CreateOptions::new() - .perm(Mode::from_bits_truncate(0o660)) - .owner(user.uid) - .group(user.gid); + let options = proxmox_product_config::lockfile_create_options(); open_file_locked(path, timeout, true, options) .with_context(|| format!("failed to acquire exclusive move-journal lock at {path:?}")) } diff --git a/pbs-datastore/src/task_tracking.rs b/pbs-datastore/src/task_tracking.rs index d4cc076aa..3d7bf3e44 100644 --- a/pbs-datastore/src/task_tracking.rs +++ b/pbs-datastore/src/task_tracking.rs @@ -35,14 +35,9 @@ struct TaskOperations { } fn open_lock_file(name: &str) -> Result<(std::fs::File, CreateOptions), Error> { - let user = pbs_config::backup_user()?; - let lock_path = PathBuf::from(format!("{}/{}.lock", crate::ACTIVE_OPERATIONS_DIR, name)); - let options = CreateOptions::new() - .group(user.gid) - .owner(user.uid) - .perm(nix::sys::stat::Mode::from_bits_truncate(0o660)); + let options = proxmox_product_config::lockfile_create_options(); let timeout = std::time::Duration::new(10, 0); -- 2.47.3