AU_OPEN(3)
π AU_OPEN(3) β create and commit audit records π
ok so this is a page from the Library Functions Manual β yes bestie, Β§3, the library-calls section β and it's the whole squad of audit-record functions: au_close, au_close_buffer, au_close_token, au_open, and au_write. They literally create and commit audit records. that's the vibe. π
β¨ LIBRARY β¨
Basic Security Module Library β that's libbsm, and you link it with -lbsm. π«Ά
πΈ SYNOPSIS πΈ
#include <bsm/libbsm.h>
int
au_open(void);
int
au_write(int d, token_t *tok);
int
au_close(int d, int keep, short event);
int
au_close_buffer(int d, short event, u_char *buffer, size_t *buflen);
int
au_close_token(token_t *tok, u_char *buffer, size_t *buflen);
π¦ DESCRIPTION π¦
so these interfaces let your app allocate audit records, build a record out of a whole series of tokens, and then commit that record to the system event log. β¨ and there's a little bonus extension API too, which commits the record to an in-memory buffer instead of the system audit log β because sometimes you just wanna keep it in RAM, yk?
au_open()β allocates a brand-new audit record descriptor. fresh out the box, no cap. πau_write()β adds a token to an audit descriptor you already allocated. big important thing here: once a token has been successfully added to a record, the caller no longer owns the token memory, so you do not need to free it yourself with a call toau_free_token(3). it's not yours anymore bestie, let it go. πau_close()β commits an audit record to the system audit log, or abandons it. either way, all resources associated with the record get released. thekeepargument decides which: a value ofAU_TO_WRITEmeans the record gets committed, andAU_TO_NO_WRITEmeans it gets abandoned. when the record is committed, a BSM header gets inserted before the tokens you added (using the event identifier you pass inevent), plus a trailer gets tacked on the end. π
heads up: committing a record to the system audit log requires privilege. the system said what it said. π₯
au_close_buffer()β writes the resulting record into an in-memory buffer of size*buflen, and it writes the filled buffer length right back into that same variable. multitasking icon. theeventargument is the event identifier used in the record header. βau_close_token()β generates the BSM stream output for a single token,tok, in the buffer you pass asbuffer. the initial buffer size and the resulting data size both go through*buflen. and btw,au_close_token()will free the token before returning β so don't you dare double free it. π
π RETURN VALUES π
au_open()β returns a non-negative audit record descriptor number on success, or a negative value on failure, with the error info tucked intoerrno. πau_write(),au_close(),au_close_buffer(), andau_close_token()β all return0on success, or a negative value on failure, again with the error info inerrno.
π SEE ALSO π
π§ HISTORY π§
the OpenBSM implementation was created by McAfee Research β that's the security division of McAfee Inc. β under contract to Apple Computer, Inc., in 2004. β¨ then it got adopted by the TrustedBSD Project as the foundation for the OpenBSM distribution. glow-up fr fr. π
π 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. π«Ά
and the Basic Security Module (BSM) interface to audit records and the audit event stream format were defined by Sun Microsystems. legends only. π
π BUGS π
ok so currently, au_open() does not reserve the kernel resources necessary to commit the record to the trail. on systems supporting au_close(), that call will just block until resources are available to commit the record. π
and here's the scary part: this leads to the possibility of an action being permitted without the record being guaranteed to go to disk. yikes. ideally, au_open() would reserve resources necessary to commit any submitted record, and release them on au_close(). that's the dream, but not the current reality. π
okay that's the whole page bestie, go forth and audit responsibly π¦π β¨
sign-off time: this lovely page came to you via Debian, dated March 4, 2006, and yes it's still serving looks. bye pookie! π
π¦ where this page comes from
- nixos 26.05: openbsm 1.1
- nixpkgs unstable: openbsm 1.1
- Copyright (c) 2006 Robert N. M. Watson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms