add setresuid/setresgid functions (nonstandard)
authorRich Felker <dalias@aerifal.cx>
Sun, 3 Apr 2011 20:20:57 +0000 (16:20 -0400)
committerRich Felker <dalias@aerifal.cx>
Sun, 3 Apr 2011 20:20:57 +0000 (16:20 -0400)
include/unistd.h
src/unistd/setresgid.c [new file with mode: 0644]
src/unistd/setresuid.c [new file with mode: 0644]

index a35611140f0cc54964ce4ddeb739aeb74af8290b..35df1cd5f23b451a6e6b36e9ec0ac54c72ab23c7 100644 (file)
@@ -154,6 +154,8 @@ int sethostname(const char *, size_t);
 int usleep(unsigned);
 unsigned ualarm(unsigned, unsigned);
 int setgroups(int, const gid_t []);
+int setresuid(uid_t, uid_t, uid_t);
+int setresgid(gid_t, gid_t, gid_t);
 #endif
 
 #define _XOPEN_VERSION          700
diff --git a/src/unistd/setresgid.c b/src/unistd/setresgid.c
new file mode 100644 (file)
index 0000000..3c85a82
--- /dev/null
@@ -0,0 +1,10 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
+{
+       if (libc.rsyscall) return libc.rsyscall(__NR_setresgid, rgid, egid, sgid, 0, 0, 0);
+       return syscall(SYS_setresgid, rgid, egid, sgid);
+}
diff --git a/src/unistd/setresuid.c b/src/unistd/setresuid.c
new file mode 100644 (file)
index 0000000..376ce40
--- /dev/null
@@ -0,0 +1,10 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include "syscall.h"
+#include "libc.h"
+
+int setresuid(uid_t ruid, uid_t euid, uid_t suid)
+{
+       if (libc.rsyscall) return libc.rsyscall(__NR_setresuid, ruid, euid, suid, 0, 0, 0);
+       return syscall(SYS_setresuid, ruid, euid, suid);
+}