Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add set/getuid and set/getgid syscalls


Also my editor may or may not have stripped some whitespace...
---
lib/sys/sys+linux-x64.myr | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/lib/sys/sys+linux-x64.myr b/lib/sys/sys+linux-x64.myr
index 627974b9..c01eb6a4 100644
--- a/lib/sys/sys+linux-x64.myr
+++ b/lib/sys/sys+linux-x64.myr
@@ -242,7 +242,7 @@ pkg sys =
const Mprotwr : mprot = 0x2
const Mprotexec : mprot = 0x4
const Mprotrw : mprot = 0x3 /* convenience */
-
+
/* mmap options */
const Mshared : mopt = 0x1
const Mpriv : mopt = 0x2
@@ -337,7 +337,7 @@ pkg sys =
const Epollwakeup : epollevttype = 1 << 29
const Epolloneshot : epollevttype = 1 << 30
const Epolledge : epollevttype = 1 << 31
-
+
/* futex ops */
const Futexwait : futexop = 0
const Futexwake : futexop = 1
@@ -791,7 +791,7 @@ pkg sys =
tls : byte#, \
ctid : pid#, \
ptreg : byte#, \
- fn : void# \ /* we need a raw pointer */
+ fn : void# \ /* we need a raw pointer */
-> pid)
const wait4 : (pid:pid, loc:int32#, opt : int64, usage:rusage# -> int64)
const waitpid : (pid:pid, loc:int32#, opt : int64 -> int64)
@@ -863,6 +863,12 @@ pkg sys =
const clock_settime : (clk : clock, ts : timespec# -> int32)
const nanosleep : (req : timespec#, rem : timespec# -> int32)

+ /* user/group management */
+ const getuid : ( -> uint32)
+ const getgid : ( -> uint32)
+ const setuid : (uid : uint32 -> int32)
+ const setgid : (gid : uint32 -> int32)
+
/* system information */
const uname : (buf : utsname# -> int)

@@ -870,7 +876,7 @@ pkg sys =
extern var __cenvp : byte##
;;

-/*
+/*
wraps a syscall argument, converting it to 64 bits for the syscall function.
This is the same as casting, but more concise than writing a cast to int64.
*/
@@ -922,7 +928,7 @@ const execve = {cmd, args, env
/*
copy the env.
of course we fucking have to duplicate this code everywhere,
- since we want to stack allocate...
+ since we want to stack allocate...
*/
ep = alloca((env.len + 1)*sizeof(byte#))
cenv = (ep : byte##)[:env.len]
@@ -1006,6 +1012,12 @@ const clock_gettime = {clk, ts; -> (syscall(Sysclock_gettime, clockid(clk), a(ts
const clock_settime = {clk, ts; -> (syscall(Sysclock_settime, clockid(clk), a(ts)) : int32)}
const nanosleep = {req, rem; -> (syscall(Sysnanosleep, a(req), a(rem)) : int32)}

+/* user/group management */
+const getuid = {; -> (syscall(Sysgetuid) : uint32)}
+const getgid = {; -> (syscall(Sysgetgid) : uint32)}
+const setuid = {uid; -> (syscall(Syssetuid, a(uid)) : int32)}
+const setgid = {gid; -> (syscall(Syssetgid, a(gid)) : int32)}
+
/* system information */
const uname = {buf; -> (syscall(Sysuname, buf) : int)}

--
2.13.3


---
Ryan (ライアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
http://refi64.com/

Follow-Ups:
Re: [PATCH] Add set/getuid and set/getgid syscallsOri Bernstein <ori@xxxxxxxxxxxxxx>