1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

Kernel: Add sid and pgid to Credentials

There are places in the kernel that would like to have access
to `pgid` credentials in certain circumstances.

I haven't found any use cases for `sid` yet, but `sid` and `pgid` are
both changed with `sys$setpgid`, so it seemed sensical to add it.

In Linux, `man 7 credentials` also mentions both the session id and
process group id, so this isn't unprecedented.
This commit is contained in:
yyny 2022-12-19 21:21:51 +01:00 committed by Andreas Kling
parent 456a8436b5
commit 9ca979846c
6 changed files with 62 additions and 18 deletions

View file

@ -14,7 +14,7 @@ namespace Kernel {
class Credentials final : public AtomicRefCounted<Credentials> {
public:
static ErrorOr<NonnullRefPtr<Credentials>> create(UserID uid, GroupID gid, UserID euid, GroupID egid, UserID suid, GroupID sgid, Span<GroupID const> extra_gids);
static ErrorOr<NonnullRefPtr<Credentials>> create(UserID uid, GroupID gid, UserID euid, GroupID egid, UserID suid, GroupID sgid, Span<GroupID const> extra_gids, SessionID sid, ProcessGroupID pgid);
~Credentials();
bool is_superuser() const { return euid() == 0; }
@ -26,11 +26,13 @@ public:
UserID suid() const { return m_suid; }
GroupID sgid() const { return m_sgid; }
Span<GroupID const> extra_gids() const { return m_extra_gids.span(); }
SessionID sid() const { return m_sid; };
ProcessGroupID pgid() const { return m_pgid; }
bool in_group(GroupID) const;
private:
Credentials(UserID uid, GroupID gid, UserID euid, GroupID egid, UserID suid, GroupID sgid, FixedArray<GroupID> extra_gids);
Credentials(UserID uid, GroupID gid, UserID euid, GroupID egid, UserID suid, GroupID sgid, FixedArray<GroupID> extra_gids, SessionID sid, ProcessGroupID pgid);
UserID m_uid;
GroupID m_gid;
@ -39,6 +41,8 @@ private:
UserID m_suid;
GroupID m_sgid;
FixedArray<GroupID> m_extra_gids;
SessionID m_sid;
ProcessGroupID m_pgid;
};
}