public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root
@ 2020-11-12  9:03 Fabian Ebner
  2020-11-12  9:03 ` [pbs-devel] [PATCH proxmox-backup 2/3] pxar: include .pxarexclude files in the archive Fabian Ebner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Fabian Ebner @ 2020-11-12  9:03 UTC (permalink / raw)
  To: pbs-devel

There is no leading slash in an entry's full_path, causing an anchored
exclude at the root level to fail, e.g. having "/name" as the content of the
file archive/root/.pxarexclude didn't match the file archive/root/name

Fix this by prepending a leading slash before matching.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/pxar/create.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/pxar/create.rs b/src/pxar/create.rs
index a16005ce..7c8e3edb 100644
--- a/src/pxar/create.rs
+++ b/src/pxar/create.rs
@@ -443,9 +443,10 @@ impl<'a, 'b> Archiver<'a, 'b> {
                 Err(err) => bail!("stat failed on {:?}: {}", full_path, err),
             };
 
+            let match_path = PathBuf::from("/").join(full_path.clone());
             if self
                 .patterns
-                .matches(full_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)
             {
                 continue;
-- 
2.20.1





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/3] pxar: include .pxarexclude files in the archive
  2020-11-12  9:03 [pbs-devel] [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root Fabian Ebner
@ 2020-11-12  9:03 ` Fabian Ebner
  2020-11-12  9:03 ` [pbs-devel] [PATCH proxmox-backup 3/3] pxar: only generate .pxarexclude-cli if there were CLI parameters Fabian Ebner
  2020-11-12 10:31 ` [pbs-devel] applied series: [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root Wolfgang Bumiller
  2 siblings, 0 replies; 5+ messages in thread
From: Fabian Ebner @ 2020-11-12  9:03 UTC (permalink / raw)
  To: pbs-devel

The documentation states:
.pxarexclude files are treated as regular files and will be included in the
backup archive.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

Or should I rather change the documentation?

 src/pxar/create.rs | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/src/pxar/create.rs b/src/pxar/create.rs
index 7c8e3edb..1615a504 100644
--- a/src/pxar/create.rs
+++ b/src/pxar/create.rs
@@ -425,10 +425,6 @@ impl<'a, 'b> Archiver<'a, 'b> {
                 continue;
             }
 
-            if file_name_bytes == b".pxarexclude" {
-                continue;
-            }
-
             let os_file_name = OsStr::from_bytes(file_name_bytes);
             assert_single_path_component(os_file_name)?;
             let full_path = self.path.join(os_file_name);
-- 
2.20.1





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 3/3] pxar: only generate .pxarexclude-cli if there were CLI parameters
  2020-11-12  9:03 [pbs-devel] [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root Fabian Ebner
  2020-11-12  9:03 ` [pbs-devel] [PATCH proxmox-backup 2/3] pxar: include .pxarexclude files in the archive Fabian Ebner
@ 2020-11-12  9:03 ` Fabian Ebner
  2020-11-12 10:22   ` Wolfgang Bumiller
  2020-11-12 10:31 ` [pbs-devel] applied series: [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root Wolfgang Bumiller
  2 siblings, 1 reply; 5+ messages in thread
From: Fabian Ebner @ 2020-11-12  9:03 UTC (permalink / raw)
  To: pbs-devel

previously a .pxarexclude entry in the root of the archive caused the file to
be generated as well, because the patterns are read before calling
generate_directory_file_list and within the function it wasn't possible to
distinguish between a pattern coming from the CLI and a pattern coming from
archive/root/.pxarexclude

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/pxar/create.rs | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/pxar/create.rs b/src/pxar/create.rs
index 1615a504..c907a8e0 100644
--- a/src/pxar/create.rs
+++ b/src/pxar/create.rs
@@ -237,7 +237,15 @@ impl<'a, 'b> Archiver<'a, 'b> {
         let old_patterns_count = self.patterns.len();
         self.read_pxar_excludes(dir.as_raw_fd())?;
 
-        let file_list = self.generate_directory_file_list(&mut dir, is_root)?;
+        let mut file_list = self.generate_directory_file_list(&mut dir, is_root)?;
+
+        if is_root && old_patterns_count > 0 {
+            file_list.push(FileListEntry {
+                name: CString::new(".pxarexclude-cli").unwrap(),
+                path: PathBuf::new(),
+                stat: unsafe { std::mem::zeroed() },
+            });
+        }
 
         let dir_fd = dir.as_raw_fd();
 
@@ -404,14 +412,6 @@ impl<'a, 'b> Archiver<'a, 'b> {
 
         let mut file_list = Vec::new();
 
-        if is_root && !self.patterns.is_empty() {
-            file_list.push(FileListEntry {
-                name: CString::new(".pxarexclude-cli").unwrap(),
-                path: PathBuf::new(),
-                stat: unsafe { std::mem::zeroed() },
-            });
-        }
-
         for file in dir.iter() {
             let file = file?;
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup 3/3] pxar: only generate .pxarexclude-cli if there were CLI parameters
  2020-11-12  9:03 ` [pbs-devel] [PATCH proxmox-backup 3/3] pxar: only generate .pxarexclude-cli if there were CLI parameters Fabian Ebner
@ 2020-11-12 10:22   ` Wolfgang Bumiller
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Bumiller @ 2020-11-12 10:22 UTC (permalink / raw)
  To: Fabian Ebner; +Cc: pbs-devel

series looks good to me, one thing though below:

On Thu, Nov 12, 2020 at 10:03:52AM +0100, Fabian Ebner wrote:
> previously a .pxarexclude entry in the root of the archive caused the file to
> be generated as well, because the patterns are read before calling
> generate_directory_file_list and within the function it wasn't possible to
> distinguish between a pattern coming from the CLI and a pattern coming from
> archive/root/.pxarexclude
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  src/pxar/create.rs | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/src/pxar/create.rs b/src/pxar/create.rs
> index 1615a504..c907a8e0 100644
> --- a/src/pxar/create.rs
> +++ b/src/pxar/create.rs
> @@ -237,7 +237,15 @@ impl<'a, 'b> Archiver<'a, 'b> {
>          let old_patterns_count = self.patterns.len();

Doesn't a similar issue still happen in encode_pxarexcludes_cli() since
we call it later below with `self.patterns` already extended by the
current `.pxarexclude` file? May have to pass `old_patterns_count` along
to it?

>          self.read_pxar_excludes(dir.as_raw_fd())?;
>  
> -        let file_list = self.generate_directory_file_list(&mut dir, is_root)?;
> +        let mut file_list = self.generate_directory_file_list(&mut dir, is_root)?;
> +
> +        if is_root && old_patterns_count > 0 {
> +            file_list.push(FileListEntry {
> +                name: CString::new(".pxarexclude-cli").unwrap(),
> +                path: PathBuf::new(),
> +                stat: unsafe { std::mem::zeroed() },
> +            });
> +        }
>  
>          let dir_fd = dir.as_raw_fd();
>  
> @@ -404,14 +412,6 @@ impl<'a, 'b> Archiver<'a, 'b> {
>  
>          let mut file_list = Vec::new();
>  
> -        if is_root && !self.patterns.is_empty() {
> -            file_list.push(FileListEntry {
> -                name: CString::new(".pxarexclude-cli").unwrap(),
> -                path: PathBuf::new(),
> -                stat: unsafe { std::mem::zeroed() },
> -            });
> -        }
> -
>          for file in dir.iter() {
>              let file = file?;
>  
> -- 
> 2.20.1




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pbs-devel] applied series: [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root
  2020-11-12  9:03 [pbs-devel] [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root Fabian Ebner
  2020-11-12  9:03 ` [pbs-devel] [PATCH proxmox-backup 2/3] pxar: include .pxarexclude files in the archive Fabian Ebner
  2020-11-12  9:03 ` [pbs-devel] [PATCH proxmox-backup 3/3] pxar: only generate .pxarexclude-cli if there were CLI parameters Fabian Ebner
@ 2020-11-12 10:31 ` Wolfgang Bumiller
  2 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Bumiller @ 2020-11-12 10:31 UTC (permalink / raw)
  To: Fabian Ebner; +Cc: pbs-devel

applied series

On Thu, Nov 12, 2020 at 10:03:50AM +0100, Fabian Ebner wrote:
> There is no leading slash in an entry's full_path, causing an anchored
> exclude at the root level to fail, e.g. having "/name" as the content of the
> file archive/root/.pxarexclude didn't match the file archive/root/name
> 
> Fix this by prepending a leading slash before matching.
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  src/pxar/create.rs | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pxar/create.rs b/src/pxar/create.rs
> index a16005ce..7c8e3edb 100644
> --- a/src/pxar/create.rs
> +++ b/src/pxar/create.rs
> @@ -443,9 +443,10 @@ impl<'a, 'b> Archiver<'a, 'b> {
>                  Err(err) => bail!("stat failed on {:?}: {}", full_path, err),
>              };
>  
> +            let match_path = PathBuf::from("/").join(full_path.clone());
>              if self
>                  .patterns
> -                .matches(full_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)
>              {
>                  continue;
> -- 
> 2.20.1




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-12 10:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12  9:03 [pbs-devel] [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root Fabian Ebner
2020-11-12  9:03 ` [pbs-devel] [PATCH proxmox-backup 2/3] pxar: include .pxarexclude files in the archive Fabian Ebner
2020-11-12  9:03 ` [pbs-devel] [PATCH proxmox-backup 3/3] pxar: only generate .pxarexclude-cli if there were CLI parameters Fabian Ebner
2020-11-12 10:22   ` Wolfgang Bumiller
2020-11-12 10:31 ` [pbs-devel] applied series: [PATCH proxmox-backup 1/3] pxar: fix anchored exclusion at archive root Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal