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 B429F1FF396 for ; Thu, 6 Jun 2024 12:09:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0EB83CFF5; Thu, 6 Jun 2024 12:09:33 +0200 (CEST) Date: Thu, 06 Jun 2024 12:09:27 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20240606094449.228306-1-c.ebner@proxmox.com> In-Reply-To: <20240606094449.228306-1-c.ebner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1717668438.2tbev2v16f.astroid@yuna.none> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.058 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 - Subject: Re: [pbs-devel] [PATCH v3 stable-2 pxar] format/decoder/accessor: backport PXAR_FORMAT_VERSION header 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" On June 6, 2024 11:44 am, Christian Ebner wrote: > Backports the PXAR_FORMAT_VERSION header, introduced with version > 0.11 of the pxar library in order to early bail for decoder and > accessor instances not supporting the updated pxar format version. > > Signed-off-by: Christian Ebner > --- > changes since version 2: > - drop unneeded patches on proxmox-backup, the pxar patches already > cover all cases > - drop unneeded failsafe checks on decoder/accessor > > examples/mk-format-hashes.rs | 5 +++++ > src/accessor/mod.rs | 14 +++++++++++++- > src/decoder/mod.rs | 4 ++++ > src/format/mod.rs | 4 ++++ > 4 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/examples/mk-format-hashes.rs b/examples/mk-format-hashes.rs > index 6e00654..afd0924 100644 > --- a/examples/mk-format-hashes.rs > +++ b/examples/mk-format-hashes.rs > @@ -1,6 +1,11 @@ > use pxar::format::hash_filename; > > const CONSTANTS: &[(&str, &str, &str)] = &[ > + ( > + "Pxar format version entry, fallback to version 1 if not present", > + "PXAR_FORMAT_VERSION", > + "__PROXMOX_FORMAT_VERSION__", > + ), > ( > "Beginning of an entry (current version).", > "PXAR_ENTRY", > diff --git a/src/accessor/mod.rs b/src/accessor/mod.rs > index 6a2de73..80bf89b 100644 > --- a/src/accessor/mod.rs > +++ b/src/accessor/mod.rs > @@ -185,11 +185,23 @@ pub(crate) struct AccessorImpl { > } > > impl AccessorImpl { > - pub async fn new(input: T, size: u64) -> io::Result { > + pub async fn new(mut input: T, size: u64) -> io::Result { nit: the mut here is not needed > if size < (size_of::() as u64) { > io_bail!("too small to contain a pxar archive"); > } > > + let header: format::Header = read_entry_at(&mut input, 0).await?; since this takes a regular & > + header.check_header_size()?; > + > + if header.htype == format::PXAR_FORMAT_VERSION { > + let version: u64 = read_entry_at( > + &mut input, and this as well or am I missing something? > + size_of::() as u64, > + ) > + .await?; > + io_bail!("format version {version} not compatible with this client"); > + } > + > Ok(Self { > input, > size, > diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs > index d1fb911..9c74a5c 100644 > --- a/src/decoder/mod.rs > +++ b/src/decoder/mod.rs > @@ -374,6 +374,10 @@ impl DecoderImpl { > self.entry.kind = EntryKind::Hardlink(self.read_hardlink().await?); > > Ok(Some(self.entry.take())) > + } else if header.htype == format::PXAR_FORMAT_VERSION { > + self.current_header = header; > + let version: u64 = seq_read_entry(&mut self.input).await?; > + io_bail!("format version {version} not compatible with this client"); > } else if header.htype == format::PXAR_ENTRY || header.htype == format::PXAR_ENTRY_V1 { > if header.htype == format::PXAR_ENTRY { > self.entry.metadata = Metadata { > diff --git a/src/format/mod.rs b/src/format/mod.rs > index bfea9f6..50d0e26 100644 > --- a/src/format/mod.rs > +++ b/src/format/mod.rs > @@ -6,6 +6,7 @@ > //! item data. > //! > //! An archive contains items in the following order: > +//! * `FORMAT_VERSION` -- (optional for v1), version of encoding format > //! * `ENTRY` -- containing general stat() data and related bits > //! * `XATTR` -- one extended attribute > //! * ... -- more of these when there are multiple defined > @@ -79,6 +80,8 @@ pub mod mode { > } > > // Generated by `cargo run --example mk-format-hashes` > +/// Pxar format version entry, fallback to version 1 if not present > +pub const PXAR_FORMAT_VERSION: u64 = 0x730f6c75df16a40d; > /// Beginning of an entry (current version). > pub const PXAR_ENTRY: u64 = 0xd5956474e588acef; > /// Previous version of the entry struct > @@ -177,6 +180,7 @@ impl Header { > impl Display for Header { > fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { > let readable = match self.htype { > + PXAR_FORMAT_VERSION => "FORMAT_VERSION", > PXAR_FILENAME => "FILENAME", > PXAR_SYMLINK => "SYMLINK", > PXAR_HARDLINK => "HARDLINK", > -- > 2.30.2 > > > > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel > > > _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel