Close hostile recovery and concurrency gaps
This commit is contained in:
parent
696dae610a
commit
3f9b1b3543
1 changed files with 306 additions and 113 deletions
|
|
@ -1597,7 +1597,10 @@ fn ensure_owned_directory(path: &Path, uid: u32) -> Result<PathBuf, Configuratio
|
|||
let mut current = open_absolute_directory(&existing_canonical)?;
|
||||
let mut canonical = existing_canonical;
|
||||
for component in missing.into_iter().rev() {
|
||||
rustix::fs::mkdirat(¤t, &component, Mode::RWXU).map_err(io_error)?;
|
||||
match rustix::fs::mkdirat(¤t, &component, Mode::RWXU) {
|
||||
Ok(()) | Err(rustix::io::Errno::EXIST) => {}
|
||||
Err(error) => return Err(io_error(error)),
|
||||
}
|
||||
let next = openat2(
|
||||
¤t,
|
||||
&component,
|
||||
|
|
|
|||
Loading…
Reference in a new issue