From 12c3f85507a07edf8e028fa84b8c34631b327590 Mon Sep 17 00:00:00 2001 From: Miccah Date: Wed, 5 May 2021 06:20:11 -0500 Subject: [PATCH] os: add getuid and geteuid (#10002) --- vlib/builtin/cfns.c.v | 4 ++++ vlib/os/os_nix.c.v | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/vlib/builtin/cfns.c.v b/vlib/builtin/cfns.c.v index 4ef0312cd9..6f347a55df 100644 --- a/vlib/builtin/cfns.c.v +++ b/vlib/builtin/cfns.c.v @@ -75,6 +75,10 @@ fn C.pclose(stream &C.FILE) int [trusted] fn C.getpid() int +fn C.getuid() int + +fn C.geteuid() int + fn C.system(cmd &char) int fn C.posix_spawn(child_pid &int, path &char, file_actions voidptr, attrp voidptr, argv &&char, envp &&char) int diff --git a/vlib/os/os_nix.c.v b/vlib/os/os_nix.c.v index 9766779b6d..777a8e2027 100644 --- a/vlib/os/os_nix.c.v +++ b/vlib/os/os_nix.c.v @@ -332,6 +332,16 @@ pub fn getpid() int { return C.getpid() } +[inline] +pub fn getuid() int { + return C.getuid() +} + +[inline] +pub fn geteuid() int { + return C.geteuid() +} + // Turns the given bit on or off, depending on the `enable` parameter pub fn posix_set_permission_bit(path_s string, mode u32, enable bool) { mut s := C.stat{}