[pbs-devel] [PATCH proxmox-backup] pxar: create: add entry: fix anchored path pattern matching

Fabian Ebner f.ebner at proxmox.com
Mon Mar 28 13:11:03 CEST 2022


Similar to 874bd545 ("pxar: fix anchored exclusion at archive root"),
but this time for inclusion. Because of the inconsistency, it could
happen that a file included in generate_directory_file_list() got
excluded in add_entry(), e.g. with a .pxarexclude file like
> *
> !/supposed-to-be-included

Reported-by: Dominik Csapak <d.csapak at proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

An alternative would be to remove the path pattern matching from
add_entry() entirely. AFAICT, it's only called with the files generated
by generate_directory_file_list() anyways.

 pbs-client/src/pxar/create.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index 9f3b0576..8dcb192d 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -549,9 +549,10 @@ impl Archiver {
 
         let metadata = get_metadata(fd.as_raw_fd(), stat, self.flags(), self.fs_magic, &mut self.fs_feature_flags)?;
 
+        let match_path = PathBuf::from("/").join(self.path.clone());
         if self
             .patterns
-            .matches(self.path.as_os_str().as_bytes(), Some(stat.st_mode as u32))
+            .matches(match_path.as_os_str().as_bytes(), Some(stat.st_mode as u32))
             == Some(MatchType::Exclude)
         {
             return Ok(());
-- 
2.30.2






More information about the pbs-devel mailing list