AU_BSM_TO_ERRNO(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… AU_BSM_TO_ERRNO(3) β€” bestie edition πŸŽ€

okay so this one lives in the Library Functions Manual, specifically the Basic Security Module Library aka libbsm, and you link it with -lbsm. that's the vibe check for today ✨


🌸 NAME 🌸

au_bsm_to_errno, au_errno_to_bsm, au_strerror β€” the three little besties that convert between BSM and local error numbers πŸ¦‹


πŸŽ€ LIBRARY πŸŽ€

Basic Security Module Library (libbsm, -lbsm) πŸ’–


✨ SYNOPSIS ✨

#include <bsm/libbsm.h>

int
au_bsm_to_errno(u_char bsm_error, int *errorp);

u_char
au_errno_to_bsm(int error);

const char *
au_strerror(int bsm_error);

πŸ’… DESCRIPTION πŸ’…

so these interfaces exist to convert between two whole error-number spaces: the local one (errno(2)) and the BSM one you'll find chillin' in BSM return tokens. two worlds, one bridge, iconic 🌈

  • au_bsm_to_errno() β€” takes a BSM error value, bsm_error, and converts it into an errno(2) that gets stored in the integer pointed to by errorp if it works out. 🫢
heads up bestie: this call fails if the BSM error can't be mapped into a local error number, which can totes happen if the return token was generated on a different operating system. literally not our fault 😭
  • au_errno_to_bsm() β€” takes a local errno(2) value and hands back the BSM error number for it. this call cannot fail πŸ’€ instead it returns a BSM error number that tells a later decoder "yeah, this error could not be encoded." graceful, honestly πŸ‘‘
  • au_strerror() β€” converts a BSM error value into a string. usually it converts to a local error number first and then uses the local strerror(3), but it will also work for errors that aren't locally defined. flexible queen 🌟

πŸ”₯ RETURN VALUES πŸ”₯

  • on success, au_bsm_to_errno() returns 0 plus a converted error value ✨
  • on failure, it returns -1 but does not set errno(2). not me dropping the ball on the errno, i know πŸ™ˆ
  • on success, au_strerror() returns a pointer to an error string πŸŽ€
  • on failure, it returns NULL. that's it. that's the whole mood πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

au_to_return(3), au_to_return32(3), au_to_return64(3), libbsm(3) β€” go read those too, iykyk πŸ“š


πŸ¦‹ HISTORY πŸ¦‹

au_bsm_to_errno() and au_errno_to_bsm() were introduced in OpenBSM 1.1. throwback era ngl ⭐


πŸ’œ AUTHORS πŸ’œ

these functions were implemented by Robert Watson under contract to Apple Inc. πŸ“

also: the Basic Security Module (BSM) interface to audit records and the audit event stream format were defined by Sun Microsystems. legends, fr fr β˜€οΈ


πŸ’€ BUGS πŸ’€

au_strerror cannot provide localized strings for errors that aren't available in the local operating system. soz 😭 that's just how it is.


🧚 sign-off 🧚

this cutie came from Debian and the page is dated December 8, 2008 β€” vintage, honestly πŸ’… bye bestie, go audit something πŸŽ€βœ¨

πŸ“¦ where this page comes from