explain_setresuid(3)

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

πŸ’– explain_setresuid(3) β€” Library Functions Manual πŸ’–

okay bestie, sit down, hydrate, because we're about to make setresuid(2) errors make sense. this little cutie lives in section 3 (library functions) and its whole job is explaining why your setresuid(2) call said no. no cap. 🫢


✨ NAME ✨

explain_setresuid β€” explain setresuid(2) errors πŸ’…


🌸 SYNOPSIS 🌸

#include <libexplain/setresuid.h>
const char *explain_setresuid(uid_t ruid, uid_t euid, uid_t suid);
const char *explain_errno_setresuid(int errnum, uid_t ruid, uid_t euid,
uid_t suid);
void explain_message_setresuid(char *message, int message_size, uid_t
ruid, uid_t euid, uid_t suid);
void explain_message_errno_setresuid(char *message, int message_size,
int errnum, uid_t ruid, uid_t euid, uid_t suid);

πŸ¦‹ DESCRIPTION πŸ¦‹

these functions are your emotional support translators πŸ’œ they hand you explanations for errors that the setresuid(2) system call throws back at you. it's giving "why is my syscall mad at me" but with answers.


🌈 explain_setresuid 🌈

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

explain_setresuid gets you an explanation of an error returned by the setresuid(2) system call. the least you're gonna get is the value of strerror(errno), but usually it does so much better than that and tells you the actual underlying cause in more detail. main character behavior tbh. πŸ‘‘

the errno global variable is what it uses to grab the error value it's gonna decode.

  • ruid β€” the original ruid, exactly as passed to the setresuid(2) system call.
  • euid β€” the original euid, exactly as passed to the setresuid(2) system call.
  • suid β€” the original suid, exactly as passed to the setresuid(2) system call.

Returns:

the message explaining the error. this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it gets overwritten by the next call to any libexplain function that shares this buffer β€” including other threads. so yeah. πŸ‘€

Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library do too. not me finding out the hard way 😭

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

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

the above code example is available pre-packaged as the explain_setresuid_or_die(3) function. obsessed with the convenience honestly. ✨


πŸ’œ explain_errno_setresuid πŸ’œ

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

explain_errno_setresuid gets you an explanation of an error returned by the setresuid(2) system call. again, the least the message contains is the value of strerror(errno), but usually it does way better and points at the underlying cause in more detail. πŸ”

  • errnum β€” the error value to be decoded, usually grabbed from the errno global variable right before this function is called. this is necessary if you need to run any code between the system call being explained and this function, because so many libc functions will mess with the value of errno. fr fr, guard that value. 🫢
  • ruid β€” the original ruid, exactly as passed to the setresuid(2) system call.
  • euid β€” the original euid, exactly as passed to the setresuid(2) system call.
  • suid β€” the original suid, exactly as passed to the setresuid(2) system call.

Returns:

the message explaining the error. this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function that 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 do the same.

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

if (setresuid(ruid, euid, suid) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_setresuid(err, ruid,
    euid, suid));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_setresuid_or_die(3) function. 🌟


πŸŽ€ explain_message_setresuid πŸŽ€

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

explain_message_setresuid gets you an explanation of an error returned by the setresuid(2) system call. yes, the least the message will contain is the value of strerror(errno), but usually it does much better and tells you the underlying cause in more detail. she's thorough. πŸ’…

the errno global variable is what it uses to get 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. slay. 🧚
  • 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 setresuid(2) system call.
  • euid β€” the original euid, exactly as passed to the setresuid(2) system call.
  • suid β€” the original suid, exactly as passed to the setresuid(2) system call.

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

if (setresuid(ruid, euid, suid) < 0)
{
    char message[3000];
    explain_message_setresuid(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_setresuid_or_die(3) function. πŸ“


🌈 explain_message_errno_setresuid 🌈

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

explain_message_errno_setresuid gets you an explanation of an error returned by the setresuid(2) system call. the least the message will contain is the value of strerror(errno), but usually it does much better and indicates the underlying cause in more detail. iconic, 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 setresuid(2) system call.
  • euid β€” the original euid, exactly as passed to the setresuid(2) system call.
  • suid β€” the original suid, exactly as passed to the setresuid(2) system call.

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

if (setresuid(ruid, euid, suid) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_setresuid(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_setresuid_or_die(3) function. πŸ’–


πŸ‘‘ SEE ALSO πŸ‘‘


libexplain version 1.4 Copyright (C) 2012 Peter Miller


and that's the whole page bestie, go forth and debug your user IDs with main character energy πŸ’–βœ¨πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ‘‘ β€” with love from the section 3 girlies, explain_setresuid(3), no cap, periodt. πŸŽ€

πŸ“¦ where this page comes from