mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
Kernel/LibC: Implement setreuid
This commit is contained in:
parent
81eab1a9d1
commit
60cdbc9397
5 changed files with 34 additions and 0 deletions
|
@ -79,6 +79,7 @@ namespace Kernel {
|
||||||
S(setegid) \
|
S(setegid) \
|
||||||
S(setuid) \
|
S(setuid) \
|
||||||
S(setgid) \
|
S(setgid) \
|
||||||
|
S(setreuid) \
|
||||||
S(setresuid) \
|
S(setresuid) \
|
||||||
S(setresgid) \
|
S(setresgid) \
|
||||||
S(alarm) \
|
S(alarm) \
|
||||||
|
|
|
@ -324,6 +324,7 @@ public:
|
||||||
KResultOr<int> sys$setegid(gid_t);
|
KResultOr<int> sys$setegid(gid_t);
|
||||||
KResultOr<int> sys$setuid(uid_t);
|
KResultOr<int> sys$setuid(uid_t);
|
||||||
KResultOr<int> sys$setgid(gid_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$setresuid(uid_t, uid_t, uid_t);
|
||||||
KResultOr<int> sys$setresgid(gid_t, gid_t, gid_t);
|
KResultOr<int> sys$setresgid(gid_t, gid_t, gid_t);
|
||||||
KResultOr<unsigned> sys$alarm(unsigned seconds);
|
KResultOr<unsigned> sys$alarm(unsigned seconds);
|
||||||
|
|
|
@ -73,6 +73,31 @@ KResultOr<int> Process::sys$setgid(gid_t new_gid)
|
||||||
return 0;
|
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)
|
KResultOr<int> Process::sys$setresuid(uid_t new_ruid, uid_t new_euid, uid_t new_suid)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(id);
|
REQUIRE_PROMISE(id);
|
||||||
|
|
|
@ -555,6 +555,12 @@ int setgid(gid_t gid)
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__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 setresuid(uid_t ruid, uid_t euid, uid_t suid)
|
||||||
{
|
{
|
||||||
int rc = syscall(SC_setresuid, ruid, euid, suid);
|
int rc = syscall(SC_setresuid, ruid, euid, suid);
|
||||||
|
|
|
@ -74,6 +74,7 @@ int seteuid(uid_t);
|
||||||
int setegid(gid_t);
|
int setegid(gid_t);
|
||||||
int setuid(uid_t);
|
int setuid(uid_t);
|
||||||
int setgid(gid_t);
|
int setgid(gid_t);
|
||||||
|
int setreuid(uid_t, uid_t);
|
||||||
int setresuid(uid_t, uid_t, uid_t);
|
int setresuid(uid_t, uid_t, uid_t);
|
||||||
int setresgid(gid_t, gid_t, gid_t);
|
int setresgid(gid_t, gid_t, gid_t);
|
||||||
pid_t tcgetpgrp(int fd);
|
pid_t tcgetpgrp(int fd);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue