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 C24541FF2F6 for ; Wed, 29 May 2024 17:57:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1B04DA971; Wed, 29 May 2024 17:57:59 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 29 May 2024 17:57:29 +0200 Message-Id: <20240529155729.2545-3-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240529155729.2545-1-c.ebner@proxmox.com> References: <20240529155729.2545-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [tools.rs, extract.rs] Subject: [pbs-devel] [PATCH stable-2 proxmox-backup 2/2] client: pxar: bail on incompatible format versions X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Implementing the change detection mode with reusable file payloads required a breaking change in the pxar file format. Unfortunately, there initial format does not encode a version for clients to check compatibility to. Therefore, a pxar format version entry is introduced in version 2 of the file format. Add a compatibility check based on that entry also for the client, making it possible to bail early when an incompatible archive is encountered. Signed-off-by: Christian Ebner --- pbs-client/src/catalog_shell.rs | 2 +- pbs-client/src/pxar/extract.rs | 3 +++ pbs-client/src/pxar/tools.rs | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pbs-client/src/catalog_shell.rs b/pbs-client/src/catalog_shell.rs index 98af5699..8bb2f3e0 100644 --- a/pbs-client/src/catalog_shell.rs +++ b/pbs-client/src/catalog_shell.rs @@ -767,7 +767,7 @@ impl Shell { let file = Self::walk_pxar_archive(&self.accessor, &mut stack).await?; std::io::stdout() - .write_all(crate::pxar::format_multi_line_entry(file.entry()).as_bytes())?; + .write_all(crate::pxar::format_multi_line_entry(file.entry())?.as_bytes())?; Ok(()) } diff --git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs index f6c1991f..51b2c92c 100644 --- a/pbs-client/src/pxar/extract.rs +++ b/pbs-client/src/pxar/extract.rs @@ -119,6 +119,9 @@ where None => current_match, }; match (did_match, entry.kind()) { + (_, EntryKind::Version(version)) => { + bail!("got format version {version}, incompatible with this client"); + } (_, EntryKind::Directory) => { callback(entry.path()); diff --git a/pbs-client/src/pxar/tools.rs b/pbs-client/src/pxar/tools.rs index 844a0f73..f28289bd 100644 --- a/pbs-client/src/pxar/tools.rs +++ b/pbs-client/src/pxar/tools.rs @@ -146,12 +146,13 @@ pub fn format_single_line_entry(entry: &Entry) -> String { ) } -pub fn format_multi_line_entry(entry: &Entry) -> String { +pub fn format_multi_line_entry(entry: &Entry) -> Result { let mode_string = mode_string(entry); let meta = entry.metadata(); let (size, link, type_name) = match entry.kind() { + EntryKind::Version(version) => bail!("got incompatible format version {version}"), EntryKind::File { size, .. } => (format!("{}", *size), String::new(), "file"), EntryKind::Symlink(link) => ( "0".to_string(), @@ -185,7 +186,7 @@ pub fn format_multi_line_entry(entry: &Entry) -> String { Err(_) => std::borrow::Cow::Owned(format!("{:?}", entry.path())), }; - format!( + Ok(format!( " File: {}{}\n \ Size: {:<13} Type: {}\n\ Access: ({:o}/{}) Uid: {:<5} Gid: {:<5}\n\ @@ -199,5 +200,5 @@ pub fn format_multi_line_entry(entry: &Entry) -> String { meta.stat.uid, meta.stat.gid, format_mtime(&meta.stat.mtime), - ) + )) } -- 2.30.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel