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 7E9A81FF135 for ; Sun, 19 Apr 2026 23:08:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D61B117628; Sun, 19 Apr 2026 23:08:21 +0200 (CEST) From: Thomas Lamprecht To: c.ebner@proxmox.com Subject: Re: [PATCH proxmox-backup v3 10/30] sync: add helper to check encryption key acls and load key Date: Sun, 19 Apr 2026 22:41:52 +0200 Message-ID: <20260419210610.3915597-3-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260414125923.892345-11-c.ebner@proxmox.com> References: <20260419210610.3915597-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776632780490 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.001 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 Message-ID-Hash: 5G22VCTIGGHU34QZXH7EP4IBE4DR3D2C X-Message-ID-Hash: 5G22VCTIGGHU34QZXH7EP4IBE4DR3D2C X-MailFrom: t.lamprecht@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 CC: pbs-devel@lists.proxmox.com 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: Am 14.04.26 um 14:59 schrieb Christian Ebner: > diff --git a/src/server/sync.rs b/src/server/sync.rs > > +/// Helper to check user having access to the given encryption key and loading > +/// the it using the passphrase from the config. Two small doc nits: - "loading the it" - typo, should be "and loading it". - "using the passphrase from the config" might be slightly misleading. > +pub(crate) fn check_privs_and_load_key_config( > + key_id: &str, > + user: &Authid, > + fail_on_archived: bool, > +) -> Result>, Error> { > + ... > + let key_config = pbs_config::encryption_keys::load_key_config(key_id, fail_on_archived)?; > + // pass empty passphrase to get raw key material of unprotected key > + let (enc_key, _created, fingerprint) = key_config.decrypt(&|| Ok(Vec::new()))?; > + ... > + Ok(Some(crypt_config)) > +} The return type is Option> but it seems that the function never actually returns Ok(None), it's eithers Some() on success or an Err() on failure. Caller like PullParameters::new, PushParameters::new, or sync_user_can_access_optional_key then have basically dead code handling the None case. It's probably fine to just drop the Option wrapper and return Result, Error> directly. > + user_info.check_privs( > + user, > + &["system", "encryption-keys", key_id], > + PRIV_SYS_MODIFY, > + true, > + )?; Using PRIV_SYS_MODIFY here feels somewhat heavy for the "use a key for sync" operation - SYS_MODIFY traditionally gates config-modifying actions, while using a key to encrypt/decrypt is more of a "read/use" semantic. Not a blocker since it's consistent with the other endpoints in the series, but worth a design consideration for whether a dedicated privilege (or PRIV_SYS_AUDIT for use-only) would fit better long-term (can definitively be checked only after this landed first, no point in bloating up the scope now to much).