SETAUDIT(2)
π SETAUDIT(2) β System Calls Manual π
okay bestie, buckle up, we're doing the setaudit page from the System Calls Manual and it's literally all about telling the kernel who you are for auditing purposes. no cap.
β¨ NAME β¨
setaudit, setaudit_addr β set audit session state
πΈ SYNOPSIS πΈ
#include <bsm/audit.h>
int
setaudit(auditinfo_t *auditinfo);
int
setaudit_addr(auditinfo_addr_t *auditinfo_addr, u_int length);
π¦ DESCRIPTION π¦
So the setaudit() system call sets the active audit session state for the current process, using the auditinfo_t that auditinfo points at. And then setaudit_addr() is the glow-up version β it sets extended state via auditinfo_addr and length.
The auditinfo_t data structure is defined like this:
struct auditinfo {
au_id_t ai_auid; /* Audit user ID */
au_mask_t ai_mask; /* Audit masks */
au_tid_t ai_termid; /* Terminal ID */
au_asid_t ai_asid; /* Audit session ID */
};
typedef struct auditinfo auditinfo_t;
The ai_auid variable is holding the audit identifier, and that's the thing that gets recorded in the audit log for every single event the process causes. every one. it's giving very much "noted, tracked, documented" energy π
The au_mask_t data structure defines the bit mask for auditing successful and failed events, pulled out of the predefined list of event classes. here's what it looks like:
struct au_mask {
unsigned int am_success; /* success bits */
unsigned int am_failure; /* failure bits */
};
typedef struct au_mask au_mask_t;
The au_termid_t data structure defines the Terminal ID that gets recorded with every event caused by the process. defined as:
struct au_tid {
dev_t port;
u_int32_t machine;
};
typedef struct au_tid au_tid_t;
The ai_asid variable contains the audit session ID, which β you guessed it β is recorded with every event the process causes.
Now, the setaudit_addr() system call uses the expanded auditinfo_addr_t data structure, and the whole point of it is that it supports Terminal IDs with larger addresses, like the ones used in IP version 6. it's defined as follows:
struct auditinfo_addr {
au_id_t ai_auid; /* Audit user ID. */
au_mask_t ai_mask; /* Audit masks. */
au_tid_addr_t ai_termid; /* Terminal ID. */
au_asid_t ai_asid; /* Audit session ID. */
};
typedef struct auditinfo_addr auditinfo_addr_t;
And the au_tid_addr_t data structure β which includes a larger address storage field plus an additional field with the type of address stored β goes like this:
struct au_tid_addr {
dev_t at_port;
u_int32_t at_type;
u_int32_t at_addr[4];
};
typedef struct au_tid_addr au_tid_addr_t;
π¨ real talk: these system calls require an appropriate privilege to complete. you can't just walk in here and set audit state, bestie. permission first, always. π¨
β RETURN VALUES β
The setaudit() and setaudit_addr() functions return the value 0 if successful β slay, we love a zero. otherwise the value -1 is returned and the global variable errno is set to indicate the error. π
π ERRORS π
[EFAULT]β A failure occurred while data transferred to or from the kernel failed.[EINVAL]β Illegal argument was passed by a system call.[EPERM]β The process does not have sufficient permission to complete the operation.
π SEE ALSO π
audit(2), auditon(2), getaudit(2), getauid(2), setauid(2), libbsm(3)
π 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. iconic lineage honestly β¨
π«Ά AUTHORS π«Ά
This software was created by McAfee Research, the security research division of McAfee, Inc., under contract to Apple Computer Inc. Additional authors include Wayne Salamon, Robert Watson, and SPARTA Inc.
The Basic Security Module (BSM) interface to audit records and audit event stream format were defined by Sun Microsystems.
This manual page was written by Robert Watson <rwatson@FreeBSD.org>.
and that's the whole page bestie, we ate and left no crumbs ππ this lil Debian edition dropped April 19, 2005 (yes, it's vintage, it's a classic, it's basically a collector's item π) and it's the SETAUDIT(2) page, mwah π
β¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2005 Robert N. M. Watson
- Copyright (c) 2008 Apple Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms