authorgravatar for 123909576+blurrycat@users.noreply.github.comblurrycat <123909576+blurrycat@users.noreply.github.com> 2025-03-27 08:58:27+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-03-27 07:58:27+00:00
logfb188c3d18a744cb98fc361aeeb8e8796066868b
tree171dd8df55851a6ae36eb81416718e15ec972bdb
parentdc66f4384f5ab4210f57f3fd37fd96cdd2823782
signaturebadge-check Signed by PGP key B5690EEEBB952194

std.posix: add getuid()/geteuid()


3 files changed, 16 insertions(+), 0 deletions(-)

lib/std/c.zig+2
......@@ -10547,6 +10547,8 @@ pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int;
1054710547pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int;
1054810548pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int;
1054910549pub extern "c" fn setpgid(pid: pid_t, pgid: pid_t) c_int;
10550pub extern "c" fn getuid() uid_t;
10551pub extern "c" fn geteuid() uid_t;
1055010552
1055110553pub extern "c" fn malloc(usize) ?*anyopaque;
1055210554pub extern "c" fn calloc(usize, usize) ?*anyopaque;
lib/std/posix.zig+8
......@@ -3505,6 +3505,14 @@ pub fn setpgid(pid: pid_t, pgid: pid_t) SetPgidError!void {
35053505 }
35063506}
35073507
3508pub fn getuid() uid_t {
3509 return system.getuid();
3510}
3511
3512pub fn geteuid() uid_t {
3513 return system.geteuid();
3514}
3515
35083516/// Test whether a file descriptor refers to a terminal.
35093517pub fn isatty(handle: fd_t) bool {
35103518 if (native_os == .windows) {
lib/std/posix/test.zig+6
......@@ -509,6 +509,12 @@ test "getcwd" {
509509 _ = posix.getcwd(&buf) catch undefined;
510510}
511511
512test "getuid" {
513 if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;
514 _ = posix.getuid();
515 _ = posix.geteuid();
516}
517
512518test "sigaltstack" {
513519 if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;
514520