explain_getresuid(3)

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

πŸ’– explain_getresuid β€” the manual, but make it make sense πŸ’–

okay so bestie, you're looking at explain_getresuid(3) from the Library Functions Manual β€” it's a libexplain thing, and it exists to explain getresuid(2) errors to you like a bestie would. no cap.


✨ NAME ✨

explain_getresuid β€” explain getresuid(2) errors 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <libexplain/getresuid.h>
const char *explain_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
const char *explain_errno_getresuid(int errnum, uid_t *ruid, uid_t *euid, uid_t *suid);
void explain_message_getresuid(char *message, int message_size, uid_t *ruid, uid_t *euid, uid_t *suid);
void explain_message_errno_getresuid(char *message, int message_size, int errnum, uid_t *ruid, uid_t *euid, uid_t *suid);

πŸ‘‘ DESCRIPTION πŸ‘‘

these functions? they're your little translators πŸ’…. you hit getresuid(2), it comes back mad, and one of these four hands you a human-readable explanation of what went wrong. it's giving "therapy for syscalls", honestly.

πŸŽ€ explain_getresuid

const char *explain_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);

explain_getresuid is your girl for getting an explanation of an error returned by the getresuid(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. it's the overachiever of the group, and we love that for it. 🫢

the errno global variable will be used to obtain the error value to be decoded.

  • ruid β€” the original ruid, exactly as passed to the getresuid(2) system call. not a copy, not a vibe, the exact one.
  • euid β€” the original euid, exactly as passed to the getresuid(2) system call.
  • suid β€” the original suid, exactly as passed to the getresuid(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. this 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. it's giving "one communal hairbrush", bestie.

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

if (getresuid(ruid, euid, suid) < 0)
{
    fprintf(stderr, "%s\n", explain_getresuid(ruid, euid, suid));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_getresuid_or_die(3) function. ✨


🌸 explain_errno_getresuid

const char *explain_errno_getresuid(int errnum, uid_t *ruid, uid_t *euid, uid_t *suid);

explain_errno_getresuid is used to obtain an explanation of an error returned by the getresuid(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. same energy, but you hand it the errno yourself. πŸ’…

  • 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 yeah, grab it early or it's gone, fr fr.
  • ruid β€” the original ruid, exactly as passed to the getresuid(2) system call.
  • euid β€” the original euid, exactly as passed to the getresuid(2) system call.
  • suid β€” the original suid, exactly as passed to the getresuid(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. this 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 (getresuid(ruid, euid, suid) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_getresuid(err, ruid, euid, suid));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_getresuid_or_die(3) function. πŸ¦‹


πŸ’œ explain_message_getresuid

void explain_message_getresuid(char *message, int message_size, uid_t *ruid, uid_t *euid, uid_t *suid);

explain_message_getresuid is used to obtain an explanation of an error returned by the getresuid(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. you bring your own buffer, and that's the whole glow-up here. πŸŽ€

the errno global variable will be 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. yes bestie, YOU did that. πŸ‘‘
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • ruid β€” the original ruid, exactly as passed to the getresuid(2) system call.
  • euid β€” the original euid, exactly as passed to the getresuid(2) system call.
  • suid β€” the original suid, exactly as passed to the getresuid(2) system call.

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

if (getresuid(ruid, euid, suid) < 0)
{
    char message[3000];
    explain_message_getresuid(message, sizeof(message), ruid, euid, suid);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_getresuid_or_die(3) function. ⭐


🌈 explain_message_errno_getresuid

void explain_message_errno_getresuid(char *message, int message_size, int errnum, uid_t *ruid, uid_t *euid, uid_t *suid);

explain_message_errno_getresuid is used to obtain an explanation of an error returned by the getresuid(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. this one is the full combo: your buffer AND your errno. main character energy, honestly. πŸ’…

  • 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.
  • ruid β€” the original ruid, exactly as passed to the getresuid(2) system call.
  • euid β€” the original euid, exactly as passed to the getresuid(2) system call.
  • suid β€” the original suid, exactly as passed to the getresuid(2) system call.

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

if (getresuid(ruid, euid, suid) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_getresuid(message, sizeof(message), err, ruid, euid, suid);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_getresuid_or_die(3) function. πŸ”₯


πŸ” SEE ALSO πŸ”


libexplain version 1.4 Copyright (C) 2012 Peter Miller


and that's the whole page, bestie πŸ’– that was explain_getresuid(3), brought to you by libexplain version 1.4, copyright (C) 2012 Peter Miller. go forth and decode your errnos, you icon. mwah. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from