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 AA6E51FF13E for ; Wed, 01 Jul 2026 16:05:00 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E7C3121429; Wed, 01 Jul 2026 16:04:59 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v3 06/15] pbs-config: use proxmox-product-config helpers Date: Wed, 1 Jul 2026 16:04:03 +0200 Message-ID: <20260701140412.200920-7-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: 1782914661115 X-SPAM-LEVEL: Spam detection results: 1 AWL -1.000 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) KAM_MAILER 2 Automated Mailer Tag Left in Email KAM_SHORT 0.001 Use of a URL Shortener for very short URL 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: 2CGHPY6F2FUIEDEF42BABEVJK3DXHXDV X-Message-ID-Hash: 2CGHPY6F2FUIEDEF42BABEVJK3DXHXDV 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: Avoids expensive user lookups via pbs-config::backup_user(), which internally calls User::from_name() and uses getpwnam_r(3) [0], therefore can involve nsswitch.conf and /etc/passwd parsing requiring several syscalls to do so. [0] https://docs.rs/nix/0.29.0/nix/unistd/struct.User.html#method.from_name Signed-off-by: Christian Ebner --- pbs-config/src/config_version_cache.rs | 2 +- pbs-config/src/encryption_keys.rs | 2 +- pbs-config/src/token_shadow.rs | 8 +------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/pbs-config/src/config_version_cache.rs b/pbs-config/src/config_version_cache.rs index a282da746..5053f6dc6 100644 --- a/pbs-config/src/config_version_cache.rs +++ b/pbs-config/src/config_version_cache.rs @@ -92,7 +92,7 @@ impl ConfigVersionCache { // Actual work of `new`: fn open() -> Result, Error> { - let user = crate::backup_user()?; + let user = proxmox_product_config::get_api_user(); let dir_opts = CreateOptions::new() .perm(Mode::from_bits_truncate(0o770)) diff --git a/pbs-config/src/encryption_keys.rs b/pbs-config/src/encryption_keys.rs index 3f8870254..367ac1e12 100644 --- a/pbs-config/src/encryption_keys.rs +++ b/pbs-config/src/encryption_keys.rs @@ -107,7 +107,7 @@ pub fn store_key(id: &str, key: &KeyConfig) -> Result<(), Error> { bail!("key with id '{id}' already exists."); } - let backup_user = crate::backup_user()?; + let backup_user = proxmox_product_config::get_api_user(); let dir_options = CreateOptions::new() .perm(Mode::from_bits_truncate(0o0750)) .owner(Uid::from_raw(0)) diff --git a/pbs-config/src/token_shadow.rs b/pbs-config/src/token_shadow.rs index 871218411..d931cc6fa 100644 --- a/pbs-config/src/token_shadow.rs +++ b/pbs-config/src/token_shadow.rs @@ -9,7 +9,6 @@ use parking_lot::RwLock; use serde::{Deserialize, Serialize}; use serde_json::{Value, from_value}; -use proxmox_sys::fs::CreateOptions; use proxmox_time::epoch_i64; use pbs_api_types::Authid; @@ -59,12 +58,7 @@ fn read_file() -> Result, Error> { } fn write_file(data: HashMap) -> Result<(), Error> { - let backup_user = crate::backup_user()?; - let options = CreateOptions::new() - .perm(nix::sys::stat::Mode::from_bits_truncate(0o0640)) - .owner(backup_user.uid) - .group(backup_user.gid); - + let options = proxmox_product_config::default_create_options(); let json = serde_json::to_vec(&data)?; proxmox_sys::fs::replace_file(CONF_FILE, &json, options, true) } -- 2.47.3