SETAUDIT(2)

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

πŸ’– 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