AUDIT_GET_SESSION(3)
π AUDIT_GET_SESSION π
okay bestie, gather round, we're doing libaudit today and honestly? this one is a little cutie. it's audit_get_session, a member of the Linux Audit API, and it's here to hand you a program's login session id. no cap. π
πΈ NAME πΈ
audit_get_session β get a program's login session id value π
β¨ SYNOPSIS β¨
#include <libaudit.h>
uint32_t audit_get_session(void);
like, that's the whole thing. no arguments. she takes nothing and gives you a number. main character energy fr. π
π¦ DESCRIPTION π¦
so basically, this function returns the task's session id attribute. that's it. that's the tea. ββ¨
π RETURN VALUE π
here's where it gets a lil spicy, so pay attention bestie:
- if the session id was set, you get the session id value back. slay. π
- if the session id is unset, it will return a
-1. BUT β and this is the plot twist β the return type isuint32_t, which is an unsigned type. so instead of seeing-1like a normal human, you will see the converted value instead. π it's giving "technically correct but emotionally confusing."
not me getting a giant number when I wanted a -1 π that's just how unsigned math works, babes.
π₯ ERRORS π₯
okay so, failure mode check:
- this function returns
-2on failure. yes, a whole different number.-2, not-1. iconic, honestly. π - additionally, in the event of a real error,
errnowould be set. - the function can set
errnobased on failures ofopen,read, orstrtoul. so if one of those three is having a bad day,errnois gonna tell you about it.
so if you see -2, something actually broke. if you see the converted giant number, nothing broke β the session id is just unset. different vibes entirely. π«Ά
π SEE ALSO π
audit_getloginuid(3)β her sister function, go say hi π¦
π AUTHOR π
Steve Grubb β thank you for your service, king π«‘π
that's the whole page bestie, go forth and audit responsibly. β¨
this lil writeup came to you from Red Hat, dated Dec 2016, and it's the AUDIT_GET_SESSION(3) page from the Linux Audit API family. mwah, bye! ππΈπ
π¦ 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