BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / commit / 03048a95d88cc7a78171393371f5c22a0250a014 / unistd / setuid.c

// Related

OrionLibC

Barry Importing existing Orion LibC 03048a9 (2 years, 2 months ago)
diff --git a/unistd/setuid.c b/unistd/setuid.c
new file mode 100644
index 0000000..7dcca04
--- /dev/null
+++ b/unistd/setuid.c
@@ -0,0 +1,43 @@
+#include <stddef.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+
+/* Set the current process' user id */
+int
+setuid(uid_t uid)
+{
+	int ret;
+	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_SETUID),
+	             "c" (1), "S" (&uid));
+	return ret;
+}
+
+/* Set the current process' effective user id */
+int
+seteuid(uid_t euid)
+{
+	int ret;
+	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_SETEUID),
+	             "c" (1), "S" (&euid));
+	return ret;
+}
+
+/* Set the current process' group id */
+int
+setgid(gid_t gid)
+{
+	int ret;
+	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_SETGID),
+	             "c" (1), "S" (&gid));
+	return ret;
+}
+
+/* Set the current process' effective group id */
+int
+setegid(gid_t egid)
+{
+	int ret;
+	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_SETEGID),
+	             "c" (1), "S" (&egid));
+	return ret;
+}