mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:48:14 +00:00
Kernel: Strip SUID+SGID bits from file when written to or chowned
Fixes #1624.
This commit is contained in:
parent
040ba77d44
commit
53d0ca2ad8
6 changed files with 36 additions and 0 deletions
|
@ -217,4 +217,19 @@ void Inode::set_metadata_dirty(bool metadata_dirty)
|
|||
}
|
||||
}
|
||||
|
||||
KResult Inode::prepare_to_write_data()
|
||||
{
|
||||
// FIXME: It's a poor design that filesystems are expected to call this before writing out data.
|
||||
// We should funnel everything through an interface at the VFS layer so this can happen from a single place.
|
||||
LOCKER(m_lock);
|
||||
if (fs().is_readonly())
|
||||
return KResult(-EROFS);
|
||||
auto metadata = this->metadata();
|
||||
if (metadata.is_setuid() || metadata.is_setgid()) {
|
||||
dbg() << "Inode::prepare_to_write_data(): Stripping SUID/SGID bits from " << identifier();
|
||||
return chmod(metadata.mode & ~(04000 | 02000));
|
||||
}
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue