mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 16:24:59 +00:00
VFS: Also respect the sticky bit of the new parent in rename().
Obviously we should not allow overwriting someone else's files in a sticky directory either.
This commit is contained in:
parent
e4eca17848
commit
475a17fa4b
1 changed files with 4 additions and 0 deletions
|
@ -336,6 +336,10 @@ KResult VFS::rename(StringView old_path, StringView new_path, Inode& base)
|
|||
// FIXME: Is this really correct? Check what other systems do.
|
||||
if (new_inode == old_inode)
|
||||
return KSuccess;
|
||||
if (new_parent_inode->metadata().is_sticky()) {
|
||||
if (!current->process().is_superuser() && new_inode->metadata().uid != current->process().euid())
|
||||
return KResult(-EACCES);
|
||||
}
|
||||
if (new_inode->is_directory() && !old_inode->is_directory())
|
||||
return KResult(-EISDIR);
|
||||
auto result = new_parent_inode->remove_child(FileSystemPath(new_path).basename());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue