explain_setregid_or_die(3)

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

πŸ’– explain_setregid_or_die(3) πŸ’–

okay bestie, welcome to the libexplain manual, section 3 (that's Library Functions, for the uninitiated ✨). this one's all about explain_setregid_or_die β€” she sets your real and/or effective group ID, and if anything goes sideways she tells you why before she dips. iconic behaviour, honestly.


🌸 NAME 🌸

explain_setregid_or_die β€” set real and/or effective group ID and report errors 🫢


✨ SYNOPSIS ✨

#include <libexplain/setregid.h>
void explain_setregid_or_die(gid_t rgid, gid_t egid);
int explain_setregid_on_error(gid_t rgid, gid_t egid);

πŸ’… DESCRIPTION πŸ’…

so there's these two functions and they're basically sisters, okay. both of them call the setregid(2) system call. the difference is what they do when things go wrong.

the explain_setregid_or_die function is used to call the setregid(2) system call. on failure, an explanation gets printed to stderr β€” and that explanation comes straight from the explain_setregid(3) function β€” and then the process terminates by calling exit(EXIT_FAILURE). yeah. she does not play. it's giving "we ride at dawn or we don't ride at all" πŸ’€

the explain_setregid_on_error function is used to call the setregid(2) system call too. on failure, an explanation also gets printed to stderr, also obtained from the explain_setregid(3) function β€” but this one still returns to the caller. she's the chill sister. she tells you what happened and lets you keep going 🧚

now the args, and yes you have to get these exactly right:

  • rgid β€” the rgid, exactly as to be passed to the setregid(2) system call.
  • egid β€” the egid, exactly as to be passed to the setregid(2) system call.
literally just pass them through unchanged, bestie. no remixing, no editing, no "improving". pass them exactly as they are. πŸ‘‘

πŸ¦‹ RETURN VALUE πŸ¦‹

the explain_setregid_or_die function only returns on success β€” see setregid(2) for more information. on failure, it prints an explanation and exits. it does not return. like, at all. that's the whole bit. no cap. 😭

the explain_setregid_on_error function always returns the value return by the wrapped setregid(2) system call.


πŸŽ€ EXAMPLE πŸŽ€

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

explain_setregid_or_die(rgid, egid);

look at her go. so clean. so demure. so mindful. ⭐


🌈 SEE ALSO 🌈


libexplain version 1.4

Copyright (C) 2012 Peter Miller


okay that's the whole page, you ate that fr fr πŸ’–βœ¨ go set some group IDs responsibly, bestie β€” and remember, one of these functions will literally end your whole process if you fumble it, so choose wisely 🫢🌸 this has been the explain_setregid_or_die(3) page, brought to you by libexplain version 1.4, copyright (C) 2012 Peter Miller. slay. πŸ’…πŸŽ€

πŸ“¦ where this page comes from