2 * Program to trigger the audit daemon with a message that is either:
3 * - Open a new audit log file
4 * - Read the audit control file and take action on it
5 * - Close the audit log file and exit
10 #include <servers/netname.h>
11 #include <mach/message.h>
12 #include <mach/port.h>
13 #include <mach/mach_error.h>
14 #include <mach/host_special_ports.h>
15 #include <servers/bootstrap.h>
17 #include <auditd_control.h>
24 mach_port_t serverPort
;
25 mach_port_t bootstrapPort
;
28 void process(int flags
);
31 * Main routine to process command line options.
33 int main(int argc
, char **argv
)
37 while ((ch
= getopt(argc
, argv
, "nst")) != -1) {
49 flags
= CLOSE_AND_DIE
;
55 "usage: audit -n | -s | -t \n");
65 * Program initialization:
66 * Look up the server port and store it away.
70 if(host_get_audit_control_port(mach_host_self(), &serverPort
) != KERN_SUCCESS
) {
71 fprintf(stderr
, "Cannot get auditd_control\n");
75 printf("Server port is %d\n", serverPort
);
79 * Do all the real work.
80 * Send a message to the audit daemon and check the return code.
82 void process(int flags
)
84 kern_return_t retcode
;
85 retcode
= auditd_control(serverPort
, flags
);
86 if(retcode
!= KERN_SUCCESS
) {
87 mach_error("error doing IPC: ", retcode
);
90 printf("Client call successful\n");