mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Add geteuid() and getegid().
There's no support for set-uid or set-gid executables yet so these don't actually do anything. It's just nice to get the boilerplate stuff in.
This commit is contained in:
parent
60a8144b68
commit
e4611248c4
Notes:
sideshowbarker
2024-07-19 18:33:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e4611248c43
6 changed files with 38 additions and 3 deletions
|
@ -303,7 +303,7 @@ int Process::exec(const String& path, Vector<String>&& arguments, Vector<String>
|
|||
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;
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -49,6 +49,8 @@ enum Function {
|
|||
PosixTcgetpgrp = 0x2017,
|
||||
PosixFork = 0x2018,
|
||||
PosixExecve = 0x2019,
|
||||
PosixGeteuid = 0x2020,
|
||||
PosixGetegid = 0x2021,
|
||||
};
|
||||
|
||||
void initialize();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue