SETRESUID(2)
β¨ SETRESUID(2) β¨
okay bestie, so this one lives in the System Calls Manual and it's all about getresgid, getresuid, setresgid and setresuid β aka getting or setting your real, effective and saved user or group ID. yes it's four functions in one page, they're a package deal, we love a bundle π
π LIBRARY
Standard C Library (libc, -lc)
link it, love it, that's the vibe π«Ά
πΈ SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
int
getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
int
getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
int
setresgid(gid_t rgid, gid_t egid, gid_t sgid);
int
setresuid(uid_t ruid, uid_t euid, uid_t suid);
π DESCRIPTION
So the setresuid() system call sets the real, effective and saved user IDs of the current process. and its sibling setresgid()? same energy but for the real, effective and saved group IDs. slay, symmetrical queen π
Privileged processes can set these IDs to literally any values they want, no questions asked β main character privileges fr fr. Unprivileged processes though? they're on a leash: each of the new IDs must match one of the current IDs. that's the rule, no cap.
Passing -1 as an argument means "leave this one alone bestie" β that corresponding value stays unchanged. iconic behaviour honestly π
And on the flip side, getresgid() and getresuid() retrieve the real, effective and saved group and user IDs of the current process, respectively. they're the readers, the setters set, the getters get, it's giving balance β¨
π₯ RETURN VALUES
If everything goes great: you get 0. clean. flawless. ate.
If it does NOT go great: you get -1 and the global variable errno gets set to tell you exactly what went wrong. π
π ERRORS
[EPERM]β the calling process was not privileged and tried to change one or more IDs to a value that wasn't the current real ID, the current effective ID, nor the current saved ID. so rude of it to even try π[EFAULT]β an address passed togetresgid()orgetresuid()was invalid. bad pointer, bad vibes, blocked π«
π SEE ALSO
getegid(2), geteuid(2), getgid(2), getuid(2), issetugid(2), setgid(2), setregid(2), setreuid(2), setuid(2)
the whole ID-adjacent friend group, go say hi π¦
π HISTORY
These functions first appeared in HP-UX. old money, honestly π
okay that's the whole page bestie, go forth and set your IDs responsibly π«Ά periodt πβ¨
this one's from the Debian crew, dated February 7, 2015 β mwah, thank you for your service, SETRESUID(2) forever π
πΈ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2000 Sheldon Hearn. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms