mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-14 01:04:38 +03:00
Kernel/LibC: Implement setreuid
This commit is contained in:
parent
81eab1a9d1
commit
60cdbc9397
Notes:
sideshowbarker
2024-07-18 18:52:53 +09:00
Author: https://github.com/Quaker762 Commit: https://github.com/SerenityOS/serenity/commit/60cdbc93970 Pull-request: https://github.com/SerenityOS/serenity/pull/6753 Reviewed-by: https://github.com/awesomekling
@ -79,6 +79,7 @@ namespace Kernel {
|
||||
S(setegid) \
|
||||
S(setuid) \
|
||||
S(setgid) \
|
||||
S(setreuid) \
|
||||
S(setresuid) \
|
||||
S(setresgid) \
|
||||
S(alarm) \
|
||||
|
@ -324,6 +324,7 @@ public:
|
||||
KResultOr<int> sys$setegid(gid_t);
|
||||
KResultOr<int> sys$setuid(uid_t);
|
||||
KResultOr<int> sys$setgid(gid_t);
|
||||
KResultOr<int> sys$setreuid(uid_t, uid_t);
|
||||
KResultOr<int> sys$setresuid(uid_t, uid_t, uid_t);
|
||||
KResultOr<int> sys$setresgid(gid_t, gid_t, gid_t);
|
||||
KResultOr<unsigned> sys$alarm(unsigned seconds);
|
||||
|
@ -73,6 +73,31 @@ KResultOr<int> Process::sys$setgid(gid_t new_gid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
KResultOr<int> Process::sys$setreuid(uid_t new_ruid, uid_t new_euid)
|
||||
{
|
||||
REQUIRE_PROMISE(id);
|
||||
|
||||
if (new_ruid == (uid_t)-1)
|
||||
new_ruid = uid();
|
||||
if (new_euid == (uid_t)-1)
|
||||
new_euid = euid();
|
||||
|
||||
auto ok = [this](uid_t id) { return id == uid() || id == euid() || id == suid(); };
|
||||
if (!ok(new_ruid) || !ok(new_euid))
|
||||
return EPERM;
|
||||
|
||||
if (new_ruid < (uid_t)-1 || new_euid < (uid_t)-1)
|
||||
return EINVAL;
|
||||
|
||||
if (euid() != new_euid)
|
||||
set_dumpable(false);
|
||||
|
||||
ProtectedDataMutationScope scope { *this };
|
||||
m_uid = new_ruid;
|
||||
m_euid = new_euid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
KResultOr<int> Process::sys$setresuid(uid_t new_ruid, uid_t new_euid, uid_t new_suid)
|
||||
{
|
||||
REQUIRE_PROMISE(id);
|
||||
|
@ -555,6 +555,12 @@ int setgid(gid_t gid)
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int setreuid(uid_t ruid, uid_t euid)
|
||||
{
|
||||
int rc = syscall(SC_setreuid, ruid, euid);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int setresuid(uid_t ruid, uid_t euid, uid_t suid)
|
||||
{
|
||||
int rc = syscall(SC_setresuid, ruid, euid, suid);
|
||||
|
@ -74,6 +74,7 @@ int seteuid(uid_t);
|
||||
int setegid(gid_t);
|
||||
int setuid(uid_t);
|
||||
int setgid(gid_t);
|
||||
int setreuid(uid_t, uid_t);
|
||||
int setresuid(uid_t, uid_t, uid_t);
|
||||
int setresgid(gid_t, gid_t, gid_t);
|
||||
pid_t tcgetpgrp(int fd);
|
||||
|
Loading…
Reference in New Issue
Block a user