PRISON_CHECK(9)

✨ PRISON_CHECK(9) ✨

okay so bestie, we're in the Kernel Developer's Manual section 9 today and the vibes are immaculate πŸ’… this one's a little function that does exactly one thing and does it slayfully: it tells you whether two credentials are living in the same jail or not. jail as in FreeBSD jail, not jail jail, don't be weird about it πŸ™ˆ


πŸŽ€ NAME πŸŽ€

prison_check β€” determine if two credentials belong to the same jail

like literally that's it, that's the whole job description, she's a one-trick pony and her trick is iconic πŸ¦‹


🌸 SYNOPSIS 🌸

#include <sys/jail.h>

int
prison_check(struct ucred *cred1, struct ucred *cred2);

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea πŸ“ β€” this function can be used to determine if the two credentials cred1 and cred2 belong to the same jail.

that's it. that's the function. she looks at two struct ucred * pointers, and she tells you if they're jail-mates or not. main character energy, zero drama, no cap πŸ‘‘


πŸ”₯ RETURN VALUES πŸ”₯

okay this is the part where you actually have to pay attention, bestie, because the return value is a lil quirky 😭

  • ESRCH β€” returned if cred1 has been jailed, and cred1 and cred2 do not belong to the same jail. so like: one of them is in a jail, and the two of them aren't in the same one. that's the sad path πŸ’€
  • zero β€” in all other cases, prison_check() returns zero. yes, all of them. every single other combination. zero. that's your happy path 🫢
⚠️ read that again slowly: it's not a simple true/false. the error only fires when cred1 is jailed and the two aren't in the same jail. everything else β€” including cred1 not being jailed at all β€” is a zero. iykyk ✨

πŸ¦‹ SEE ALSO πŸ¦‹


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

this lil masterpiece comes from the Debian crew, dated December 11, 2003 β€” yeah she's an elder but she's still serving looks ✨ πŸŽ€πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from