From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A3B971FF137 for ; Tue, 31 Mar 2026 16:47:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 026732CD; Tue, 31 Mar 2026 16:48:20 +0200 (CEST) Message-ID: <1fcc11ea-e66c-414e-a6f4-9ab43d0dae87@proxmox.com> Date: Tue, 31 Mar 2026 16:48:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH proxmox-backup v2] fix #5247: relative paths in exclude patterns. To: Wolfgang Bumiller References: <20260330081110.8527-1-m.federanko@proxmox.com> <177496589589.113663.12113566106144305854.b4-review@b4> Content-Language: en-US From: Manuel Federanko In-Reply-To: <177496589589.113663.12113566106144305854.b4-review@b4> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774968439285 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.976 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 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: SX4QDWBKLFQW3C5HZDYTEKMK2DQGFNTZ X-Message-ID-Hash: SX4QDWBKLFQW3C5HZDYTEKMK2DQGFNTZ X-MailFrom: m.federanko@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 2026-03-31 4:04 PM, Wolfgang Bumiller wrote: > 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. ack > 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...) I'm a bit undecided, maybe log a warning with a deprecation notice that this will lead to an error in the future? Same goes for the cli option now that I'm thinking about it. >> >> >> 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()) ack, will change in v3 once warning/bailing has been decided