From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 24A6398D1 for ; Thu, 3 Aug 2023 17:22:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0729E6071 for ; Thu, 3 Aug 2023 17:22:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 3 Aug 2023 17:22:52 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 048664270A for ; Thu, 3 Aug 2023 17:22:52 +0200 (CEST) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Thu, 3 Aug 2023 17:22:38 +0200 Message-Id: <20230803152238.124625-1-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 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: [pbs-devel] [PATH proxmox-backup] fix #4380: stat() is run when file is executed 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: , X-List-Received-Date: Thu, 03 Aug 2023 15:22:56 -0000 When executing `proxmox-backup-client backup ... --exclude "test/test.txt"` it still executed stat() on "test.txt", which won't work when the current user doesn't have access to the file or the parent folder. Now we check if the file is excluded, and if it is not, then we execute stat(). Signed-off-by: Gabriel Goller --- pbs-client/src/pxar/create.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs index 2577cf98..c573c2a3 100644 --- a/pbs-client/src/pxar/create.rs +++ b/pbs-client/src/pxar/create.rs @@ -434,6 +434,15 @@ impl Archiver { assert_single_path_component(os_file_name)?; let full_path = self.path.join(os_file_name); + let match_path = PathBuf::from("/").join(full_path.clone()); + if self + .patterns + .matches(match_path.as_os_str().as_bytes(), None) + == Some(MatchType::Exclude) + { + continue; + } + let stat = match nix::sys::stat::fstatat( dir_fd, file_name.as_c_str(), @@ -444,15 +453,6 @@ impl Archiver { Err(err) => return Err(err).context(format!("stat failed on {:?}", full_path)), }; - let match_path = PathBuf::from("/").join(full_path.clone()); - if self - .patterns - .matches(match_path.as_os_str().as_bytes(), Some(stat.st_mode)) - == Some(MatchType::Exclude) - { - continue; - } - self.entry_counter += 1; if self.entry_counter > self.entry_limit { bail!( -- 2.39.2