explain_setresgid(3)

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

✨ explain_setresgid(3) β€” Library Functions Manual ✨

okay bestie, gather round πŸ’– this is the manual page for explain_setresgid(3), living happily in the Library Functions Manual section of your man pages, and it's literally the glow-up your error messages have been waiting for.


🌸 NAME 🌸

explain_setresgid β€” the function that explains your setresgid(2) errors πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <libexplain/setresgid.h>
const char *explain_setresgid(gid_t rgid, gid_t egid, gid_t sgid);
const char *explain_errno_setresgid(int errnum, gid_t rgid, gid_t egid,
gid_t sgid);
void explain_message_setresgid(char *message, int message_size, gid_t
rgid, gid_t egid, gid_t sgid);
void explain_message_errno_setresgid(char *message, int message_size,
int errnum, gid_t rgid, gid_t egid, gid_t sgid);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, these functions are the whole point of the page: you use them to get actual explanations for errors that come back from the setresgid(2) system call. no more cryptic vibes, no more guessing ✨

πŸ’– explain_setresgid

const char *explain_setresgid(gid_t rgid, gid_t egid, gid_t sgid);

explain_setresgid is the main character here β€” you call it to get an explanation of an error returned by the setresgid(2) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better and point at the underlying cause in more detail πŸ”₯

the errno global variable is what gets used to obtain the error value that's gonna be decoded, iykyk.

  • rgid β€” the original rgid, exactly as passed to the setresgid(2) system call.
  • egid β€” the original egid, exactly as passed to the setresgid(2) system call.
  • sgid β€” the original sgid, exactly as passed to the setresgid(2) system call.

Returns:

the message explaining the error. πŸ’« this message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.

Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. no cap, plan accordingly 😭

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

if (setresgid(rgid, egid, sgid) < 0)
{
    fprintf(stderr, "%s\n", explain_setresgid(rgid, egid, sgid));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_setresgid_or_die(3) function 🫢

🌈 explain_errno_setresgid

const char *explain_errno_setresgid(int errnum, gid_t rgid, gid_t egid,
gid_t sgid);

explain_errno_setresgid does the exact same job β€” obtain an explanation of an error returned by the setresgid(2) system call β€” and again, the least the message will contain is the value of strerror(errno), but usually it will do much better and indicate the underlying cause in more detail πŸ’…

  • errnum β€” the error value to be decoded, usually obtained from the errno global variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. so grab it early, bestie ⏰
  • rgid β€” the original rgid, exactly as passed to the setresgid(2) system call.
  • egid β€” the original egid, exactly as passed to the setresgid(2) system call.
  • sgid β€” the original sgid, exactly as passed to the setresgid(2) system call.

Returns:

the message explaining the error. πŸ’« this message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.

Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. πŸ’€

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

if (setresgid(rgid, egid, sgid) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_setresgid(err, rgid,
    egid, sgid));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_setresgid_or_die(3) function 🫢

🧚 explain_message_setresgid

void explain_message_setresgid(char *message, int message_size, gid_t
rgid, gid_t egid, gid_t sgid);

explain_message_setresgid gets you an explanation of an error returned by the setresgid(2) system call β€” same deal, the least the message will contain is the value of strerror(errno), but usually it will do much better and indicate the underlying cause in more detail ✨

the errno global variable is what's used to obtain the error value to be decoded.

  • message β€” the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe πŸ‘‘ (look at her go)
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • rgid β€” the original rgid, exactly as passed to the setresgid(2) system call.
  • egid β€” the original egid, exactly as passed to the setresgid(2) system call.
  • sgid β€” the original sgid, exactly as passed to the setresgid(2) system call.

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

if (setresgid(rgid, egid, sgid) < 0)
{
    char message[3000];
    explain_message_setresgid(message, sizeof(message), rgid,
    egid, sgid);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_setresgid_or_die(3) function 🫢

πŸ’œ explain_message_errno_setresgid

void explain_message_errno_setresgid(char *message, int message_size,
int errnum, gid_t rgid, gid_t egid, gid_t sgid);

explain_message_errno_setresgid is here to obtain an explanation of an error returned by the setresgid(2) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail 🌸

  • message β€” the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe πŸ‘‘
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • errnum β€” the error value to be decoded, usually obtained from the errno global variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno 😭
  • rgid β€” the original rgid, exactly as passed to the setresgid(2) system call.
  • egid β€” the original egid, exactly as passed to the setresgid(2) system call.
  • sgid β€” the original sgid, exactly as passed to the setresgid(2) system call.

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

if (setresgid(rgid, egid, sgid) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_setresgid(message, sizeof(message),
    err, rgid, egid, sgid);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_setresgid_or_die(3) function 🫢


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page, bestie, you ate πŸ’–

this is libexplain version 1.4, and the copyright belongs to Copyright (C) 2012 Peter Miller. iconic, periodt. πŸŽ€βœ¨

and yeah, it's explain_setresgid(3) all the way down, mwah πŸ’…πŸ¦‹

πŸ“¦ where this page comes from