3 # Copyright (c) 2012, Sine Nomine Associates
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 readsysvmq - example program to read the sysvmq audit log
28 This is an example script to read the OpenAFS fileserver System V message queue
29 (sysvmq) based audit log. The OpenAFS fileserver writed to the sysv message
30 queue audit log when it is started with the C<-audit-interface sysvmq> option
31 in conjuntion with the C<-auditlog> option.
39 The path of the sysvmq audit log. This should match the path given in the
40 fileserver C<-auditlog> command line option.
50 Copyright (c) 2012, Sine Nomine Associates
57 use IPC::SysV qw(S_IRUSR ftok);
59 if (scalar @ARGV != 1) {
60 print("usage: $0 <auditlog-path>\n");
66 my $mqkey = ftok($path, 1);
67 unless (defined $mqkey) {
68 die "$path does not exist\n";
71 my $mqid = msgget($mqkey, S_IRUSR);
72 unless (defined $mqid) {
73 die "message queue $mqkey ($path) cannot be opened\n";
77 my ($msg, $msgtype, $msgtext);
79 if (msgrcv($mqid, $msg, $msgsize, 0, 0)) {
80 ($msgtype, $msgtext) = unpack("i! a*", $msg);