diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 3c88ff83d29..5560534ded7 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -303,7 +303,7 @@ int Process::exec(const String& path, Vector&& arguments, Vector return error; } - if (!handle->metadata().mayExecute(m_uid, m_gid)) + if (!handle->metadata().mayExecute(m_euid, m_egid)) return -EACCES; auto elfData = handle->readEntireFile(); @@ -563,6 +563,8 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t parentPID, RingLevel , m_pid(next_pid++) // FIXME: RACE: This variable looks racy! , m_uid(uid) , m_gid(gid) + , m_euid(uid) + , m_egid(gid) , m_state(Runnable) , m_ring(ring) , m_cwd(move(cwd)) @@ -1219,6 +1221,16 @@ gid_t Process::sys$getgid() return m_gid; } +uid_t Process::sys$geteuid() +{ + return m_euid; +} + +gid_t Process::sys$getegid() +{ + return m_egid; +} + pid_t Process::sys$getpid() { return m_pid; diff --git a/Kernel/Process.h b/Kernel/Process.h index c6cb4d49cb7..02d7d21cc52 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -56,8 +56,9 @@ public: TSS32& tss() { return m_tss; } State state() const { return m_state; } uid_t uid() const { return m_uid; } - uid_t gid() const { return m_gid; } - + gid_t gid() const { return m_gid; } + uid_t euid() const { return m_euid; } + gid_t egid() const { return m_egid; } pid_t parentPID() const { return m_parentPID; } const FarPtr& farPtr() const { return m_farPtr; } @@ -91,6 +92,8 @@ public: int sys$tcsetpgrp(int fd, pid_t pgid); uid_t sys$getuid(); gid_t sys$getgid(); + uid_t sys$geteuid(); + gid_t sys$getegid(); pid_t sys$getpid(); int sys$open(const char* path, int options); int sys$close(int fd); @@ -175,6 +178,8 @@ private: pid_t m_pid { 0 }; uid_t m_uid { 0 }; gid_t m_gid { 0 }; + uid_t m_euid { 0 }; + gid_t m_egid { 0 }; pid_t m_sid { 0 }; pid_t m_pgid { 0 }; DWORD m_ticks { 0 }; diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index b9783e9a078..6673246dc50 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -132,6 +132,10 @@ static DWORD handle(RegisterDump& regs, DWORD function, DWORD arg1, DWORD arg2, return current->sys$fork(regs); case Syscall::PosixExecve: return current->sys$execve((const char*)arg1, (const char**)arg2, (const char**)arg3); + case Syscall::PosixGeteuid: + return current->sys$geteuid(); + case Syscall::PosixGetegid: + return current->sys$getegid(); default: kprintf("<%u> int0x80: Unknown function %x requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3); break; diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index 3576c637cfb..5879837521f 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -49,6 +49,8 @@ enum Function { PosixTcgetpgrp = 0x2017, PosixFork = 0x2018, PosixExecve = 0x2019, + PosixGeteuid = 0x2020, + PosixGetegid = 0x2021, }; void initialize(); diff --git a/LibC/unistd.cpp b/LibC/unistd.cpp index 86c9ce237cb..7d1b65f1af2 100644 --- a/LibC/unistd.cpp +++ b/LibC/unistd.cpp @@ -27,6 +27,16 @@ gid_t getgid() return Syscall::invoke(Syscall::PosixGetgid); } +uid_t geteuid() +{ + return Syscall::invoke(Syscall::PosixGeteuid); +} + +gid_t getegid() +{ + return Syscall::invoke(Syscall::PosixGetegid); +} + pid_t getpid() { return Syscall::invoke(Syscall::PosixGetpid); diff --git a/LibC/unistd.h b/LibC/unistd.h index de1fd851803..f304c555fc5 100644 --- a/LibC/unistd.h +++ b/LibC/unistd.h @@ -15,6 +15,8 @@ pid_t setsid(); int setpgid(pid_t pid, pid_t pgid); pid_t getpgid(pid_t); pid_t getpgrp(); +uid_t geteuid(); +gid_t getegid(); uid_t getuid(); gid_t getgid(); pid_t getpid();