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 50D881FF137 for ; Tue, 31 Mar 2026 16:05:08 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CE5771EDBC; Tue, 31 Mar 2026 16:05:35 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH proxmox-backup v2] fix #5247: relative paths in exclude patterns. From: Wolfgang Bumiller To: Manuel Federanko In-Reply-To: <20260330081110.8527-1-m.federanko@proxmox.com> References: <20260330081110.8527-1-m.federanko@proxmox.com> Date: Tue, 31 Mar 2026 16:04:55 +0200 Message-Id: <177496589589.113663.12113566106144305854.b4-review@b4> X-Mailer: b4 0.15.1 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774965842166 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.415 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 1 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 1 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 1 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: QB63FM5F7UT2Y2QELRQ3ROON3YRA5LYB X-Message-ID-Hash: QB63FM5F7UT2Y2QELRQ3ROON3YRA5LYB X-MailFrom: w.bumiller@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: On Mon, 30 Mar 2026 10:11:10 +0200, Manuel Federanko wrote: > Patterns which start with ./ or for that matter contain /../ or similar > constructs will never match, since they get compared to sanitized paths > from directory traversal, sanitize those patterns too. Implement this > for both .pxarexclude files and the --exclude command line option. > Log a warning if a path was sanitized that was provided via --exclude. In the `.pxarexclude` case, logging may make sense as well IMO. As for `--exclude`, I wonder we should just *bail* instead? Although that might "break" some automated otherwise-working-but-probably-too-big backups, so we can't... (although for `foo/../bar` it's *really* tempting...) > > > diff --git a/pbs-client/src/pxar/tools.rs b/pbs-client/src/pxar/tools.rs > index 475c08ad3..7ad4009fe 100644 > --- a/pbs-client/src/pxar/tools.rs > +++ b/pbs-client/src/pxar/tools.rs > @@ -76,6 +76,37 @@ fn assert_single_path_component_do(path: &Path) -> Result<(), Error> { > Ok(()) > } > > +pub fn normalize_lexically + ?Sized>(path: &S) -> PathBuf { (Note: the monomorphization from v1 was actually fine, but if the `_do` variant is only used by this one function it could live *inside* here.) > + // FIXME: Once std::path::normalize_lexically is stabilized we can > + // switch to that > + use std::path::Component; > + > + let path = Path::new(path); > + let has_trailing_slash = path > + .as_os_str() > + .as_encoded_bytes() > + .last() > + .copied() > + .is_some_and(|c: u8| c == std::path::MAIN_SEPARATOR_STR.bytes().last().unwrap()); Could just use .as_encoded_bytes() .ends_with(MAIN_SEPARATOR_STR.as_bytes()) --