rendered paste body#!/usr/bin/perl
# by: nnm
# email: nnm.one@gmail.com
# do whatever with it
#fixLine
sub fLi {
if(length($_[0]) <= 7) {
return "\t\t";
} else {
return "\t";
}
}
open( MSGLOG, "/var/log/messages" ) or
die "Cannot open file: $!";
print("when? operation denied? command name source/target_context\n");
print("=========================================================================================\n");
while( $line = <MSGLOG> ) {
if($line =~ /^(.{15}).*\ avc:..(.*).for..(.*)$/) {
# show time of occurrance
$time = $1;
($time) = map{s/\ +/-/g;$_;}($time);
print($time."\t");
# $2 is operation
@adc = split(/\ /, $2);
print($adc[3]);
print(fLi($adc[3]));
# allow/deny?
if($adc[0] == "denied") { print("x\t"); }
# remove " from $3 and put the string in a hash and print "command"
$ctx = $3;
$ctx =~ s/\"//g;
my %context = split(/[= ]/, $ctx);
print($context{comm});
print(fLi($context{comm}));
# print "name"
print($context{name}."\n");
## S/Tcontext
print("\t\t\t\t\t\t source: ".$context{scontext}."\n");
print("\t\t\t\t\t\t target: ".$context{tcontext}."\n");
print("-----------------------------------------------------------------------------------------\n");
#foreach my $k (keys %context) {
# print "$k: $context{$k}\n";
#}
}
}
close MSGLOG;