explain_setreuid_or_die(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

πŸ’– explain_setreuid_or_die(3) πŸ’–

okay bestie, welcome to the explain_setreuid_or_die page β€” it lives in the Library Functions Manual and it's genuinely one of the most helpful little gremlins in libexplain. sit down, grab a boba, we're doing syscalls πŸ§‹βœ¨


✨ NAME ✨

explain_setreuid_or_die β€” set the real and effective user ID and report errors 🫢


🌸 SYNOPSIS 🌸

#include <libexplain/setreuid.h>
void explain_setreuid_or_die(uid_t ruid, uid_t euid);
int explain_setreuid_on_error(uid_t ruid, uid_t euid);

πŸ’… DESCRIPTION πŸ’…

so there's two functions here and they're basically siblings, right? both of them wrap the setreuid(2) system call, and both of them are obsessed with telling you what went wrong.

explain_setreuid_or_die β€” this one calls the setreuid(2) system call. if it fails, it prints an explanation to stderr (which it gets from the explain_setreuid(3) function, iconic), and then the process terminates by calling exit(EXIT_FAILURE). like. it does not come back. it's giving dramatic exit, no notes. πŸ’€

explain_setreuid_on_error β€” same deal, it calls setreuid(2) too. on failure it also prints an explanation to stderr (also courtesy of explain_setreuid(3)), but then it's chill and still returns to the caller. main character energy but polite. πŸŽ€

and the args, since you're gonna ask:

  • ruid β€” the ruid, exactly as to be passed to the setreuid(2) system call. don't get cute with it.
  • euid β€” the euid, exactly as to be passed to the setreuid(2) system call. same energy, same rule. ✨

🌈 RETURN VALUE 🌈

explain_setreuid_or_die only returns on success β€” and for the deets on that, go read setreuid(2). on failure it prints an explanation and exits, so like... it does not return. at all. not even a little. 🫠

explain_setreuid_on_error always returns the value returned by the wrapped setreuid(2) system call. no cap. πŸ’–


πŸ¦‹ EXAMPLE πŸ¦‹

the explain_setreuid_or_die function is intended to be used in a fashion similar to the following example:

explain_setreuid_or_die(ruid, euid);

that's it. that's the whole vibe. slay. πŸ’…βœ¨


πŸ‘‘ SEE ALSO πŸ‘‘


libexplain version 1.4 Copyright (C) 2012 Peter Miller


okay and that's the whole page, bestie πŸ₯ΉπŸ’œ the footer down there just says explain_setreuid_or_die(3) again (the manual name, back for an encore), and everything above came to you from libexplain version 1.4, Copyright (C) 2012 Peter Miller. go forth and set those user IDs responsibly. mwah. 🧚🌸

πŸ“¦ where this page comes from