mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
VFS: Implement sticky bit behavior for rename() and unlink().
Removing entries from a sticky directory is only allowed when you are either the owner of the entry, or the superuser. :^)
This commit is contained in:
parent
a104d7cc93
commit
e4eca17848
1 changed files with 10 additions and 0 deletions
|
@ -326,6 +326,11 @@ KResult VFS::rename(StringView old_path, StringView new_path, Inode& base)
|
|||
if (!old_parent_inode->metadata().may_write(current->process()))
|
||||
return KResult(-EACCES);
|
||||
|
||||
if (old_parent_inode->metadata().is_sticky()) {
|
||||
if (!current->process().is_superuser() && old_inode->metadata().uid != current->process().euid())
|
||||
return KResult(-EACCES);
|
||||
}
|
||||
|
||||
if (!new_inode_or_error.is_error()) {
|
||||
auto new_inode = new_inode_or_error.value();
|
||||
// FIXME: Is this really correct? Check what other systems do.
|
||||
|
@ -436,6 +441,11 @@ KResult VFS::unlink(StringView path, Inode& base)
|
|||
if (!parent_inode->metadata().may_write(current->process()))
|
||||
return KResult(-EACCES);
|
||||
|
||||
if (parent_inode->metadata().is_sticky()) {
|
||||
if (!current->process().is_superuser() && inode->metadata().uid != current->process().euid())
|
||||
return KResult(-EACCES);
|
||||
}
|
||||
|
||||
return parent_inode->remove_child(FileSystemPath(path).basename());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue