summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/InodeMetadata.cpp
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-10-01 12:03:46 +0000
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-11 19:55:37 -0700
commitfa692e13f944a5808ddc9c50e4e8015487c3ae0c (patch)
treef4620dbeb2dbfcea0f4ded11c55090710c0f933b /Kernel/FileSystem/InodeMetadata.cpp
parent3472c84d14b66e8e0d1481299fbc33f6e8b7bb50 (diff)
downloadserenity-fa692e13f944a5808ddc9c50e4e8015487c3ae0c.zip
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.
Diffstat (limited to 'Kernel/FileSystem/InodeMetadata.cpp')
-rw-r--r--Kernel/FileSystem/InodeMetadata.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/Kernel/FileSystem/InodeMetadata.cpp b/Kernel/FileSystem/InodeMetadata.cpp
index fc70ad8b7f..5ac40e7eba 100644
--- a/Kernel/FileSystem/InodeMetadata.cpp
+++ b/Kernel/FileSystem/InodeMetadata.cpp
@@ -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());
}
}