Skip to content

Instantly share code, notes, and snippets.

@jrmuizel
Last active February 9, 2024 17:25
Show Gist options
  • Save jrmuizel/92d3e045313ea09454907df2a9015199 to your computer and use it in GitHub Desktop.
Save jrmuizel/92d3e045313ea09454907df2a9015199 to your computer and use it in GitHub Desktop.
#include <assert.h>
#include <bsm/audit.h>
#include <bsm/audit_session.h>
int main() {
auditinfo_addr_t auditInfo;
int result = getaudit_addr(&auditInfo, sizeof(auditInfo));
assert(result == 0 );
printf("got audit result: %d, uid %d\n", result, auditInfo.ai_auid);
if (auditInfo.ai_flags & AU_SESSION_FLAG_IS_INITIAL) {
printf("AU_SESSION_FLAG_IS_INITIAL\n");
}
if (auditInfo.ai_flags & AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS) {
printf("AU_SESSION_FLAG_HAS_GRAPHIC_ACCESS\n");
}
if (auditInfo.ai_flags & AU_SESSION_FLAG_HAS_TTY) {
printf("AU_SESSION_FLAG_HAS_TTY\n");
}
if (auditInfo.ai_flags & AU_SESSION_FLAG_IS_REMOTE) {
printf("AU_SESSION_FLAG_IS_REMOTE\n");
}
if (auditInfo.ai_flags & AU_SESSION_FLAG_HAS_CONSOLE_ACCESS) {
printf("AU_SESSION_FLAG_HAS_CONSOLE_ACCESS\n");
}
if (auditInfo.ai_flags & AU_SESSION_FLAG_HAS_AUTHENTICATED) {
printf("AU_SESSION_FLAG_HAS_AUTHENTICATED\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment