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 3F5891FF173 for ; Mon, 27 Jan 2025 11:51:09 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6AB5B1F52D; Mon, 27 Jan 2025 11:51:07 +0100 (CET) Date: Mon, 27 Jan 2025 11:50:58 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20250127092440.112816-1-m.sandoval@proxmox.com> In-Reply-To: <20250127092440.112816-1-m.sandoval@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1737974900.rrc2tx3i97.astroid@yuna.none> X-SPAM-LEVEL: Spam detection results: 1 AWL 0.000 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 FSL_BULK_SIG 0.001 Bulk signature with no Unsubscribe KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RAZOR2_CF_RANGE_51_100 1.886 Razor2 gives confidence level above 50% RAZOR2_CHECK 0.922 Listed in Razor2 (http://razor.sf.net/) 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [185.199.108.153, 185.199.109.153, 185.199.110.153, 185.199.111.153] Subject: Re: [pbs-devel] [PATCH backup v2 1/2] use truncate whenever we create files 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 January 27, 2025 10:24 am, Maximiliano Sandoval wrote: > Fixes the suspicious_open_options clippy lint, for example: > > ``` > warning: file opened with `create`, but `truncate` behavior not defined > --> src/api2/tape/restore.rs:1713:18 > | > 1713 | .create(true) > | ^^^^^^^^^^^^- help: add: `.truncate(true)` > | > = help: if you intend to overwrite an existing file entirely, call `.truncate(true)` > = help: if you instead know that you may want to keep some parts of the old file, call `.truncate(false)` > = help: alternatively, use `.append(true)` to append to the file instead of overwriting it > = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_open_options > ``` > > Signed-off-by: Maximiliano Sandoval > --- > Differences from v1: > - Do not add truncate/create when create_new is used > > pbs-client/src/pxar/extract.rs | 1 + > src/api2/tape/restore.rs | 1 + > src/server/sync.rs | 1 + > 3 files changed, 3 insertions(+) > > diff --git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs > index 64754006..1f017d81 100644 > --- a/pbs-client/src/pxar/extract.rs > +++ b/pbs-client/src/pxar/extract.rs > @@ -135,6 +135,7 @@ where > if let Some(entry) = prelude { > let mut prelude_file = OpenOptions::new() > .create(true) > + .truncate(true) this is not correct, this is a (special) file that is restored, so it should probably be handled like regular files are - if overwrite is set, truncate, else, create_new .. > .write(true) > .open(path) > .with_context(|| format!("error creating prelude file '{path:?}'"))?; > diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs > index 93a6053b..2cc1baab 100644 > --- a/src/api2/tape/restore.rs > +++ b/src/api2/tape/restore.rs > @@ -1711,6 +1711,7 @@ fn try_restore_snapshot_archive( > let mut tmpfile = std::fs::OpenOptions::new() > .write(true) > .create(true) > + .truncate(true) > .read(true) > .open(&tmp_path) > .map_err(|err| format_err!("restore {:?} failed - {}", tmp_path, err))?; > diff --git a/src/server/sync.rs b/src/server/sync.rs > index 5e3fbdcd..4dd46c5a 100644 > --- a/src/server/sync.rs > +++ b/src/server/sync.rs > @@ -159,6 +159,7 @@ impl SyncSourceReader for RemoteSourceReader { > let tmpfile = std::fs::OpenOptions::new() > .write(true) > .create(true) > + .truncate(true) > .read(true) > .open(&tmp_path)?; > > -- > 2.39.5 > > > > _______________________________________________ > 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