mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
Kernel: Use real UID/GID when checking for file access
This aligns the rest of the system with POSIX, who says that access(2) must check against the real UID and GID, not effective ones.
This commit is contained in:
parent
3472c84d14
commit
fa692e13f9
Notes:
sideshowbarker
2024-07-17 23:00:03 +09:00
Author: https://github.com/sin-ack
Commit: fa692e13f9
Pull-request: https://github.com/SerenityOS/serenity/pull/15428
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/BertalanD
Reviewed-by: https://github.com/linusg
Reviewed-by: https://github.com/timschumi
3 changed files with 20 additions and 12 deletions
|
|
@ -9,19 +9,22 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
bool InodeMetadata::may_read(Credentials const& credentials) const
|
||||
bool InodeMetadata::may_read(Credentials const& credentials, UseEffectiveIDs use_effective_ids) const
|
||||
{
|
||||
return may_read(credentials.euid(), credentials.egid(), credentials.extra_gids());
|
||||
bool eids = use_effective_ids == UseEffectiveIDs::Yes;
|
||||
return may_read(eids ? credentials.euid() : credentials.uid(), eids ? credentials.egid() : credentials.gid(), credentials.extra_gids());
|
||||
}
|
||||
|
||||
bool InodeMetadata::may_write(Credentials const& credentials) const
|
||||
bool InodeMetadata::may_write(Credentials const& credentials, UseEffectiveIDs use_effective_ids) const
|
||||
{
|
||||
return may_write(credentials.euid(), credentials.egid(), credentials.extra_gids());
|
||||
bool eids = use_effective_ids == UseEffectiveIDs::Yes;
|
||||
return may_write(eids ? credentials.euid() : credentials.uid(), eids ? credentials.egid() : credentials.gid(), credentials.extra_gids());
|
||||
}
|
||||
|
||||
bool InodeMetadata::may_execute(Credentials const& credentials) const
|
||||
bool InodeMetadata::may_execute(Credentials const& credentials, UseEffectiveIDs use_effective_ids) const
|
||||
{
|
||||
return may_execute(credentials.euid(), credentials.egid(), credentials.extra_gids());
|
||||
bool eids = use_effective_ids == UseEffectiveIDs::Yes;
|
||||
return may_execute(eids ? credentials.euid() : credentials.uid(), eids ? credentials.egid() : credentials.gid(), credentials.extra_gids());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue