AUDIT_SET_PID(3)
π AUDIT_SET_PID β the Linux Audit API, bestie edition π
Okay so real quick, the manual name is AUDIT_SET_PID(3) β it lives in section 3 of the Linux Audit API, and it's about telling the kernel who the audit daemon is. Let's get into it π
β¨ NAME β¨
audit_set_pid β Set audit daemon process ID. That's the whole vibe. One job, does it well π«Ά
πΈ SYNOPSIS πΈ
#include <libaudit.h>
int audit_set_pid(int fd, uint32_t pid, rep_wait_t wmode);
(Yes, the header is <libaudit.h> β copy it exactly, no autocorrect bestie π)
π DESCRIPTION π
So, audit_set_pid tells the kernel what the pid is of the audit daemon. That's it. That's the whole assignment. It's giving "here's my number, kernel, call me" πβ¨
The fd argument is an open descriptor to the audit netlink socket. Like, the actual connection. Don't just pass it some random int, it needs to be a real one π
Now here's the juicy part:
- When
pidis set to0, the kernel will log all events to syslog. Old school. Respect. π - Otherwise, the kernel will try to send events to the netlink connection that has the same pid given by this function. So you're basically pointing the kernel at your socket. Iconic π
And lowkey the kernel has your back: if for some reason the process goes away, the kernel will automatically set the value to 0 itself. Built-in cleanup, no cap π§Ήβ¨
Usually this function is called by the audit daemon and not an external program. So if you're out here calling it from some random little side program... not the move bestie π That's the audit daemon's job, let her cook.
One more thing: if wmode is WAIT_YES, the function will wait for an ACK from the kernel. Synchronous behaviour. It'll just sit there, patiently, waiting for the kernel to say "got it" β³π
π RETURN VALUE π
The return value is <= 0 on error, otherwise it is the netlink sequence id number. So a positive number = we slayed, a zero-or-negative = we did not slay π
Also, this function can have any error that sendto would encounter. Any of them. The whole collection. So don't be surprised if you get something unexpected β it's not a bug, it's just sendto being sendto π
π¦ SEE ALSO π¦
Go read those too, they're part of the extended universe π«Ά
π AUTHOR π
Steve Grubb β the author, the moment, the main character π
Sign-off time bestie β¨ This page came from Red Hat, dated Oct 2006 β vintage, retro, still relevant. Slay forever π ππ
π¦ where this page comes from
- alpine 3.23: audit-doc 4.1.2-r2 Β· LGPL-2.1-or-later
- alpine 3.24: audit-doc 4.1.2-r6 Β· LGPL-2.1-or-later
- arch rolling: audit 4.2.1-1 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- centos-stream 10: audit-libs-devel 4.2.1-3.el10 Β· LGPL-2.0-or-later
- fedora 43: audit-libs-devel 4.1.1-2.fc43 Β· LGPL-2.0-or-later
- fedora 43: audit-libs-devel 4.1.1-2.fc43 Β· LGPL-2.0-or-later
- fedora 43: audit-libs-devel 4.2.1-1.fc43 Β· LGPL-2.0-or-later
- fedora 43: audit-libs-devel 4.2.1-1.fc43 Β· LGPL-2.0-or-later
- fedora 44: audit-libs-devel 4.1.4-1.fc44 Β· LGPL-2.0-or-later
- fedora 44: audit-libs-devel 4.1.4-1.fc44 Β· LGPL-2.0-or-later
- fedora 44: audit-libs-devel 4.2.1-1.fc44 Β· LGPL-2.0-or-later
- fedora 44: audit-libs-devel 4.2.1-1.fc44 Β· LGPL-2.0-or-later
- nixpkgs unstable: audit 4.2.1
- ubuntu resolute: libaudit-dev 1:4.1.2-1build1 Β· GPL-2.0-only
- ubuntu resolute: libaudit-dev 1:4.1.2-1ubuntu0.1 Β· GPL-2.0-only
- ubuntu stonking: libaudit-dev 1:4.1.2-1ubuntu1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms