1
Fork 0
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:
Andreas Kling 2019-04-28 23:34:33 +02:00
parent e4eca17848
commit 475a17fa4b

View file

@ -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());