diff --git a/libs/libc/include/unistd.h b/libs/libc/include/unistd.h index ff770cc3..26bb30ce 100644 --- a/libs/libc/include/unistd.h +++ b/libs/libc/include/unistd.h @@ -50,6 +50,18 @@ extern "C" /* Returns the current process' effective group ID. */ gid_t getegid(void); + /* Sets the current process' real and effective user IDs. */ + int setuid(uid_t uid); + + /* Sets the current process' effective user ID. */ + int seteuid(uid_t uid); + + /* Sets the current process' real and effective group IDs. */ + int setgid(gid_t gid); + + /* Sets the current process' effective group ID. */ + int setegid(gid_t gid); + /* Terminates the program with the status code status. */ __lc_noreturn void _exit(int status); diff --git a/libs/libc/src/unistd.cpp b/libs/libc/src/unistd.cpp index ab4c9421..a781339f 100644 --- a/libs/libc/src/unistd.cpp +++ b/libs/libc/src/unistd.cpp @@ -58,6 +58,26 @@ extern "C" return (gid_t)getprocid(ID_EGID); } + int setuid(uid_t uid) + { + return (int)__lc_fast_syscall2(SYS_setuid, uid, uid); + } + + int seteuid(uid_t uid) + { + return (int)__lc_fast_syscall2(SYS_setuid, getprocid(ID_UID), uid); + } + + int setgid(gid_t gid) + { + return (int)__lc_fast_syscall2(SYS_setgid, gid, gid); + } + + int setegid(gid_t gid) + { + return (int)__lc_fast_syscall2(SYS_setgid, getprocid(ID_GID), gid); + } + unsigned int sleep(unsigned int seconds) { return msleep(seconds * 1000);