libc: Implement getuid, geteuid, getgid, getegid

This commit is contained in:
apio 2022-10-28 17:24:28 +02:00
parent 1c4f1ab867
commit 17671fd435
2 changed files with 32 additions and 0 deletions

View File

@ -38,6 +38,18 @@ extern "C"
/* Returns the current process' parent's process ID. */ /* Returns the current process' parent's process ID. */
pid_t getppid(void); pid_t getppid(void);
/* Returns the current process' real user ID. */
uid_t getuid(void);
/* Returns the current process' effective user ID. */
uid_t geteuid(void);
/* Returns the current process' real group ID. */
gid_t getgid(void);
/* Returns the current process' effective group ID. */
gid_t getegid(void);
/* Terminates the program with the status code status. */ /* Terminates the program with the status code status. */
__lc_noreturn void _exit(int status); __lc_noreturn void _exit(int status);

View File

@ -38,6 +38,26 @@ extern "C"
return getprocid(ID_PPID); return getprocid(ID_PPID);
} }
uid_t getuid(void)
{
return (uid_t)getprocid(ID_UID);
}
uid_t geteuid(void)
{
return (uid_t)getprocid(ID_EUID);
}
gid_t getgid(void)
{
return (gid_t)getprocid(ID_GID);
}
gid_t getegid(void)
{
return (gid_t)getprocid(ID_EGID);
}
unsigned int sleep(unsigned int seconds) unsigned int sleep(unsigned int seconds)
{ {
return msleep(seconds * 1000); return msleep(seconds * 1000);