fix #4380: stat() is run when file is executed
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>
This commit is contained in:
parent
a13b3d7e1c
commit
c8ed10095d
@ -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!(
|
||||
|
Loading…
x
Reference in New Issue
Block a user