AU_MASK(3)

πŸ“¦
version 1.1 Β· 2 versions
, in nixos 26.05, nixpkgs unstable

πŸ’… au_mask β€” bestie's guide to audit mask conversions ✨

okay so this page is from the Library Functions Manual, and it lives in section 3 (au_mask(3)) β€” it's the glow-up guide to the au_preselect, getauditflagsbin and getauditflagschar girlies. buckle up πŸŽ€


🌸 NAME 🌸

au_preselect, getauditflagsbin, getauditflagschar β€” the trio that converts between the string and numeric values of audit masks. literally the translators of the audit world 🫢


πŸ¦‹ LIBRARY πŸ¦‹

Basic Security Module Library β€” libbsm, and you link it with -lbsm. iconic. πŸ’–


✨ SYNOPSIS ✨

#include <bsm/libbsm.h>

int
au_preselect(au_event_t event, au_mask_t *mask_p, int sorf, int flag);

int
getauditflagsbin(char *auditstr, au_mask_t *masks);

int
getauditflagschar(char *auditstr, au_mask_t *masks, int verbose);

no cap, that's the whole vibe check right there πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

these interfaces are here to support processing of an audit mask β€” that's a thing of type au_mask_t, iykyk β€” and they handle the conversion between numeric and text formats, plus figuring out whether or not a mask actually matches an event. three jobs, all slaying. πŸ”₯

🧚 au_preselect()

this one calculates whether or not the audit event passed via event is matched by the audit mask passed via mask_p.

the sorf argument tells it whether or not to consider the event as a success β€” if the AU_PRS_SUCCESS flag is set β€” or failure β€” if the AU_PRS_FAILURE flag is set.

and then the flag argument accepts extra arguments that influence the behavior of au_preselect(), specifically:

  • AU_PRS_REREAD β€” causes the event to be re-looked up rather than read from the cache πŸ‘€
  • AU_PRS_USECACHE β€” forces use of the cache ⚑

πŸ“ getauditflagsbin()

converts a string representation of an audit mask β€” passed via a character string that auditstr points to β€” and returns the resulting mask, if it's valid, via *masks. love that for us πŸ’…

🌈 getauditflagschar()

takes the audit event mask passed via *masks and converts it to a character string in a buffer pointed to by auditstr. πŸŽ€

⚠️ bestie please read the "BUGS" section about how to provide a buffer of sufficient size. this is not a drill 😭

if the verbose flag is set, the class description string retrieved from audit_class(5) gets used; otherwise it's the two-character class name. two modes, both valid, we stan. ✨


πŸŽ€ IMPLEMENTATION NOTES πŸŽ€

au_preselect() makes implicit use of various audit database routines, and it may influence the behavior of simultaneous or interleaved processing of those databases by other code. so like… it's not just vibing in its own lane, it's lowkey touching shared state. noted. πŸ’€


πŸ‘‘ RETURN VALUES πŸ‘‘

au_preselect()

  • returns 0 on success
  • returns -1 if there's a failure looking up the event type or other database access β€” in which case errno will be set to indicate the error
  • returns 1 if the event is matched; 0 if it's not

getauditflagsbin() and getauditflagschar()

  • return the value 0 if successful
  • otherwise the value -1 is returned and the global variable errno is set to indicate the error

periodt. πŸ“Œ


πŸ” SEE ALSO πŸ”


⭐ HISTORY ⭐

the OpenBSM implementation was created by McAfee Research β€” the security division of McAfee Inc. β€” under contract to Apple Computer, Inc., in 2004. πŸ—“οΈ it was subsequently adopted by the TrustedBSD Project as the foundation for the OpenBSM distribution. a real main-character origin story ngl πŸ’–


🫢 AUTHORS 🫢

this software was created by Robert Watson, Wayne Salamon, and Suresh Krishnaswamy for McAfee Research, the security research division of McAfee, Inc., under contract to Apple Computer, Inc. absolute icons, all three of them. πŸ‘‘

and the Basic Security Module (BSM) interface to audit records and the audit event stream format were defined by Sun Microsystems. the OGs. 🌞


πŸ’€ BUGS πŸ’€

  • the errno variable may not always be properly set in the event of an error. πŸ™ˆ like, it might, but don't count on it.
  • getauditflagschar() does not provide a way to indicate how long the character buffer is, in order to detect overflow. 😭 as a result, the caller must always provide a buffer of sufficient length for any possible mask β€” which may be calculated as three times the number of non-zero bits in the mask argument in the event non-verbose class names are used, and is not trivially predictable for verbose class names. this API should be replaced with a more robust one. 🚩
🚨 fr fr, do the math before you pass that buffer. this is the dangerous part of the page.

okay that's the whole thing! stay safe out there with your audit masks, bestie πŸ’œβœ¨

β€” cute little sign-off: this page came from Debian, dated April 19, 2005, and yeah the header said AU_MASK(3) at the top and the same down at the bottom. mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from