Problem
The audit subsystem is part of the kernel. Therefore, no user
process or daemon is associated with it. (The auditd daemon only
reads and compacts collection files created by the audit subsystem.)
Is there any way to determine if the audit subsystem is enabled in
the kernel? Solution
Follow the procedure below.NOTE: You must have the development system to compile this program.---cut paste glue---
/*
* This program requires read access on /unix and /dev/kmem.
*
* Compile: cc -o audit_query audit_query.c
*
*/
#include <stdio.h>
#include <sys/types.h>
#include <nlist.h>
#include <fcntl.h>#ifndef UNIX
#define UNIX "/unix"
#endif
#ifndef KMEM
#define KMEM "/dev/kmem"
#endif
#define OFFSET 0x1 /* audit_control.auditing field */void error(char*);
struct nlist nl[2]; /* aud_cont, NULL */main(int argc, char** argv)
{
int fd, enable_flag;nl[0].n_name = "aud_cont"; nl[1].n_name = NULL; if (nlist(UNIX, nl) == -1) error(UNIX); if ((fd = open(KMEM, O_RDONLY)) == -1) error(KMEM);
lseek(fd, nl[0].n_value + OFFSET, 0);
read(fd, &enable_flag, 1);
if (enable_flag)
printf("Audit subsystem is enabled\n");
else
printf("Audit subsystem is disabled\n");
}void error(char *s) { perror(s); exit(1); } /* end of program */