public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>
Subject: [pbs-devel] applied: [PATH proxmox-backup] fix #4380: stat() is run when file is executed
Date: Fri, 04 Aug 2023 09:59:21 +0200	[thread overview]
Message-ID: <1691135264.qvg52bo6b9.astroid@yuna.none> (raw)
In-Reply-To: <20230803152238.124625-1-g.goller@proxmox.com>

although a somewhat rare edge case, this does improve things a bit!

there is still a stray

 failed to open file: ".pxarexclude": access denied

if the client encounters a dir with +r, but -x, even if all of the dirs
entries are excluded..

I guess we could actually skip iterating with a more meaningful error
message if we lack -x? or just check that all dir entries (which we get
thanks to +r) of that dir are excluded by the patterns we already have
at that point, instead of attempting to read the contained patterns and
then recursively iterate over the dir's entries?

On August 3, 2023 5:22 pm, Gabriel Goller wrote:
> 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 <g.goller@proxmox.com>
> ---
>  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
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




      parent reply	other threads:[~2023-08-04  7:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 15:22 [pbs-devel] " Gabriel Goller
2023-08-04  7:42 ` Fiona Ebner
     [not found]   ` <d4bf032e-42c0-a0d7-5702-07aa9e230690@proxmox.com>
2023-08-04  8:20     ` Fiona Ebner
2023-08-04  8:35       ` Fabian Grünbichler
2023-08-04  8:21   ` Fabian Grünbichler
2023-08-04  8:52     ` Fiona Ebner
2023-08-04 12:08       ` Wolfgang Bumiller
2023-08-04  7:59 ` Fabian Grünbichler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1691135264.qvg52bo6b9.astroid@yuna.none \
    --to=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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