Kernel/LibC: Add setsid()

This commit is contained in:
Bananymous 2024-08-11 00:58:12 +03:00
parent f08d429851
commit ad645f31d0
4 changed files with 21 additions and 0 deletions

View File

@ -85,6 +85,7 @@ namespace Kernel
BAN::ErrorOr<long> sys_setuid(uid_t);
BAN::ErrorOr<long> sys_setgid(gid_t);
BAN::ErrorOr<long> sys_setsid();
BAN::ErrorOr<long> sys_seteuid(uid_t);
BAN::ErrorOr<long> sys_setegid(gid_t);
BAN::ErrorOr<long> sys_setreuid(uid_t, uid_t);

View File

@ -2001,6 +2001,20 @@ namespace Kernel
return BAN::Error::from_errno(EPERM);
}
BAN::ErrorOr<long> Process::sys_setsid()
{
LockGuard _(m_process_lock);
if (is_session_leader() || m_pid == m_pgrp)
return BAN::Error::from_errno(EPERM);
m_sid = m_pid;
m_pgrp = m_pid;
m_controlling_terminal.clear();
return 0;
}
BAN::ErrorOr<long> Process::sys_seteuid(uid_t uid)
{
if (uid < 0 || uid >= 1'000'000'000)

View File

@ -25,6 +25,7 @@ __BEGIN_DECLS
O(SYS_READ_DIR, readdir) \
O(SYS_SET_UID, setuid) \
O(SYS_SET_GID, setgid) \
O(SYS_SET_SID, setsid) \
O(SYS_SET_EUID, seteuid) \
O(SYS_SET_EGID, setegid) \
O(SYS_SET_REUID, setreuid) \

View File

@ -475,6 +475,11 @@ int setgid(gid_t gid)
return syscall(SYS_SET_GID, gid);
}
int setsid(void)
{
return syscall(SYS_SET_SID);
}
int setreuid(uid_t ruid, uid_t euid)
{
return syscall(SYS_SET_REUID, ruid, euid);