use O_EXCL when creating files during extraction

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-06-16 10:33:14 +02:00
parent 98c54240e6
commit 6988b29bdc
2 changed files with 2 additions and 2 deletions

View File

@ -1187,7 +1187,7 @@ impl<'a> ExtractorState<'a> {
std::fs::File::from_raw_fd(nix::fcntl::openat( std::fs::File::from_raw_fd(nix::fcntl::openat(
parent, parent,
entry.file_name(), entry.file_name(),
OFlag::O_CREAT | OFlag::O_WRONLY | OFlag::O_CLOEXEC, OFlag::O_CREAT | OFlag::O_EXCL | OFlag::O_WRONLY | OFlag::O_CLOEXEC,
Mode::from_bits(0o600).unwrap(), Mode::from_bits(0o600).unwrap(),
)?) )?)
}); });

View File

@ -319,7 +319,7 @@ impl Extractor {
std::fs::File::from_raw_fd(nix::fcntl::openat( std::fs::File::from_raw_fd(nix::fcntl::openat(
parent, parent,
file_name, file_name,
OFlag::O_CREAT | OFlag::O_WRONLY | OFlag::O_CLOEXEC, OFlag::O_CREAT | OFlag::O_EXCL | OFlag::O_WRONLY | OFlag::O_CLOEXEC,
Mode::from_bits(0o600).unwrap(), Mode::from_bits(0o600).unwrap(),
)?) )?)
}; };