diff --git a/lib/std/c.zig b/lib/std/c.zig index 2a68a68c4d..fc5497a5be 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -10547,6 +10547,8 @@ pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int; pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int; pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int; pub extern "c" fn setpgid(pid: pid_t, pgid: pid_t) c_int; +pub extern "c" fn getuid() uid_t; +pub extern "c" fn geteuid() uid_t; pub extern "c" fn malloc(usize) ?*anyopaque; pub extern "c" fn calloc(usize, usize) ?*anyopaque; diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 211d25a35a..8a5e974625 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -3505,6 +3505,14 @@ pub fn setpgid(pid: pid_t, pgid: pid_t) SetPgidError!void { } } +pub fn getuid() uid_t { + return system.getuid(); +} + +pub fn geteuid() uid_t { + return system.geteuid(); +} + /// Test whether a file descriptor refers to a terminal. pub fn isatty(handle: fd_t) bool { if (native_os == .windows) { diff --git a/lib/std/posix/test.zig b/lib/std/posix/test.zig index 9678bfb261..0efe76e55d 100644 --- a/lib/std/posix/test.zig +++ b/lib/std/posix/test.zig @@ -509,6 +509,12 @@ test "getcwd" { _ = posix.getcwd(&buf) catch undefined; } +test "getuid" { + if (native_os == .windows or native_os == .wasi) return error.SkipZigTest; + _ = posix.getuid(); + _ = posix.geteuid(); +} + test "sigaltstack" { if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;