AUDIT_SUBMIT(3)
β¨ NAME β¨
okay bestie, this is AUDIT_SUBMIT(3) from the Library Functions Manual, and audit_submit is literally the general purpose audit record submission function. no cap, that's the whole gig π«Ά
π LIBRARY π
it lives in the Basic Security Module Library (libbsm, -lbsm) β iconic, we love a specialized library π
π SYNOPSIS π
#include <bsm/libbsm.h>
int
audit_submit(short au_event, au_id_t auid, char status, int reterr,
const char * restrict format, ...);
π DESCRIPTION π
audit_submit() is your generic programming interface for audit record submission. the record it makes has a header, a subject token, an optional text token, a return token, and a trailer. it's giving full audit ensemble, fr fr β¨
- the header contains the event class specified by
au_event. - the subject token is generated based on
auid. - the return token depends on the
statusandreterrarguments. real talk: unlike the argument toau_to_return,reterrshould be a local rather than BSM error number β do not mix those up, bestie π - optionally, a text token gets created as part of this record.
the text token output is under the control of a format string. that string specifies how the subsequent arguments β or arguments accessed via the variable-length argument facilities of stdarg(3) β are converted for output. if format is NULL, then no text token is created in the audit record. periodt. π
important vibe check:audit_submit()assumes thatsetaudit(2)orsetaudit_addr(2)has already been called. as a direct result, the terminal ID for the subject will be retrieved from the kernel viagetaudit(2)orgetaudit_addr(2). iykyk π
π₯ RETURN VALUES π₯
if successful, audit_submit will return zero β slay. otherwise, -1 is returned, and the global variable errno is set to indicate the error. so check that errno, okay? π«Ά
π§ EXAMPLES π§
okay so here's the example, and it's lowkey main character energy: audit_bad_su tries getaudit_addr() first, falls back to getaudit() when it gets ENOSYS, then calls audit_submit() with AUE_su, EPERM, and a format string. iconic behavior, ngl π
#include <bsm/audit.h>
#include <bsm/libbsm.h>
#include <bsm/audit_uevents.h>
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
void
audit_bad_su(char *from_login, char *to_login)
{
struct auditinfo_addr aia;
struct auditinfo ai;
au_id_t aid;
int error;
error = getaudit_addr(&aia, sizeof(aia));
if (error < 0 && errno == ENOSYS) {
error = getaudit(&ai);
if (error < 0)
err(1, "getaudit");
aid = ai.ai_auid;
} else if (error < 0)
err(1, "getaudit_addr");
else
aid = aia.ai_auid;
error = audit_submit(AUE_su, aid, EPERM, 1,
"bad su from %s to %s", from_login, to_login);
if (error != 0)
err(1, "audit_submit");
}
will generate the following audit record:
header,94,1,su(1),0,Mon Apr 17 23:23:59 2006, + 271 msec
subject,root,root,wheel,root,wheel,652,652,0,0.0.0.0
text,bad su from from csjp to root
return,failure : Operation not permitted,1
trailer,94
πΈ SEE ALSO πΈ
π HISTORY π
the audit_submit() function first appeared in OpenBSM version 1.0. OpenBSM 1.0 was introduced in FreeBSD 7.0. a whole era, honestly β
π AUTHORS π
the audit_submit() function was written by Christian S.J. Peron <csjp@FreeBSD.org>. thank you for your service, king π«‘
mwah π β this page is from Debian, dated January 18, 2008, and the manual is AUDIT_SUBMIT(3). byeee π¦
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2006 Christian S.J. Peron
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms