Fix renaming broken symbolic link
Closes: #212 The fix is simply to not follow links when opening a file to be renamed. O_NOFOLLOW, a non-POSIX extension, does exactly that while not needing renameat or openat.
This commit is contained in:
committed by
Josh Megnauth
parent
adc8f9f3b3
commit
55c2e5b8ea
@@ -908,7 +908,10 @@ impl Pal for Sys {
|
||||
let newpath = newpath.to_str().map_err(|_| Errno(EINVAL))?;
|
||||
let newpath = canonicalize(newpath).map_err(|_| Errno(EINVAL))?;
|
||||
|
||||
let file = File::open(oldpath, fcntl::O_PATH | fcntl::O_CLOEXEC)?;
|
||||
let file = File::open(
|
||||
oldpath,
|
||||
fcntl::O_NOFOLLOW | fcntl::O_PATH | fcntl::O_CLOEXEC,
|
||||
)?;
|
||||
syscall::frename(*file as usize, newpath)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user