#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# auditrecord - display one or more audit records
require 5.8.4;
use strict;
use warnings;
use locale;
my $errString =
gettext("$0 takes no arguments other than switches.\n");
usage();
exit (1);
}
usage();
exit (1);
}
my %options;
if (defined($callFilter)) {
$callFilter = qr/\b$callFilter\b/;
} else {
$callFilter = qr//;
}
# the calls to readControl and readUser are for debug; they are not
# needed for generation of record formats. 'ignore' means if there
# is no permission to read the file, don't die, just soldier on.
# $error is L10N'd by $parse
if ($debug) {
# verify audit_control content
# verify audit_user content
# check audit_event, audit_display_attr
}
# check for invalid class to -c option if supplied
if (defined $options{'classFilter'}) {
my $isInvalidClass = 0;
foreach (split(/\s*,\s*/, $options{'classFilter'})) {
unless (exists $class{$_}) {
printf STDERR "$invalidClass\n", $_;
$isInvalidClass = 1;
}
}
exit (1) if $isInvalidClass;
}
if ($html) {
writeHTML();
} else {
writeASCII();
}
exit (0);
# writeASCII -- collect what's been read from various sources and
# output the formatted audit records
sub writeASCII {
my $label;
my $errString;
my $description;
my @case;
next if ($skipThisClass);
next if ($name eq 'undefined');
next unless $description =~ $callFilter;
$~ = 'nameLine';
write;
$~ = 'wrapped1';
while ($note) {
write;
}
next if ($skip);
$~ = 'threeColumns';
my $rows = $#col1;
$rows = $#col2 if ($#col2 > $rows);
$rows = $#col3 if ($#col3 > $rows);
for (my $i = 0; $i <= $rows; $i++) {
write;
}
$col1 = 'event ID';
write;
$col1 = 'class';
$col3 = "($mask)";
write;
my $haveFormat = 0;
my $caseElement;
foreach $caseElement (@case) {
# $note1 is the "case" description
# $note2 is a "note"
$~ = 'wrapped1';
while ($note) {
write;
}
unless (defined($format)) {
"missing format field: %s");
next;
}
unless ($format eq 'none') {
$haveFormat = 1;
my $item;
$~ = 'twoColumns';
@comment);
write;
$~ = "col2Wrapped";
while ($col2) {
write;
}
}
}
if ($note2) {
$~ = 'space';
write;
$~ = 'wrapped1';
while ($note) {
write;
}
}
}
unless ($haveFormat) {
$~ = 'wrapped1';
write;
}
}
}
# writeHTML -- collect what's been read from various sources
# and output the formatted audit records
#
sub writeHTML {
my $label;
my $description;
my @case;
print qq{
<html>
<head>
</head>
};
startTable(); # by generating multiple tables
next if ($skipThisClass);
my $description;
next if ($name eq 'undefined');
next unless $description =~ $callFilter;
$tableRows++;
if ($tableRows > 50) {
endTable();
startTable();
$tableRows = 0;
}
$description =~ s/\s*;\s*/<br>/g;
if ($callName) {
}
print qq{
<tr bgcolor="#C0C0C0">
</tr>
<tr>
</tr>
<tr>
<pre>
};
$~ = 'wrapped2';
while ($note) {
write;
}
next if ($skip);
my $haveFormat = 0;
my $caseElement;
foreach $caseElement (@case) {
$~ = 'wrapped2';
while ($note) {
write;
}
unless (defined($format)) {
"Missing format field: %s\n");
next;
}
unless ($format eq 'none') {
$haveFormat = 1;
my $item;
$~ = 'twoColumns';
@comment);
write;
}
}
if ($note2) {
$~ = 'space';
write;
$~ = 'wrapped2';
while ($note) {
write;
}
}
}
unless ($haveFormat) {
$~ = 'wrapped2';
$note = 'No format information available';
write;
}
print q{
</pre>
</td/>
</tr>
};
}
endTable();
}
sub startTable {
print q{
<tr bgcolor="#C0C0C0">
</tr>
<tr>
<tr>
<tr>
</tr>
};
}
sub endTable {
print q{
</table>
</body>
</html>
};
}
# classToMask: One, given a class list, it calculates the mask; Two,
# it checks to see if every item on the class list is marked for
# skipping, and if so, sets a flag.
sub classToMask {
my $classList = shift;
my $label = shift;
my $mask = 0;
my $skipThisClass = 0;
my $thisClass;
"%s not found in audit_class. Omitting %s\n");
$label);
next;
}
}
return ($skipThisClass, $mask);
}
# getAttributes: Combine fields from %event and %attr; a description
# in the attribute file overrides a description from audit_event
sub getAttributes {
my $label = shift;
my $desc = shift; # description from audit_event
if ($description eq 'none') {
if ($desc eq 'blank') {
$description = '';
} else {
$description = $desc;
}
}
} else {
}
}
# getCallInfo: the system call or program name for an audit record can
# usually be derived from the event name; %attr provides exceptions to
# this rule
sub getCallInfo {
my $id = shift;
my $name = shift;
my $desc = shift;
my $callType;
my $callName;
my $description;
if ($name) {
if ($id < 6000) {
$callType = 'system call';
} else {
$callType = 'program';
}
} else {
$callType = '';
$callName = '';
}
$description = '';
}
# getFormatList: determine the order and details of kernel vs user
# audit records. If the first token is "head" then the token list
# is explicit, otherwise the header, subject and return are implied.
sub getFormatList {
my $format = shift;
my $id = shift;
my $list;
}
elsif ($format eq 'kernel') {
} elsif ($format eq 'user') {
} elsif ($id < 6000) {
} else {
}
return ($list);
}
# getFormatLine: the arguments from the attribute 'format' are
# expanded to their printable form and also paired with a comment if
# one exists
sub getFormatLine {
my $arg = shift;
my $label = shift;
my @comment = @_;
my $isOption = 0;
my $cmt = -1;
}
} else {
}
if ($cmt > -1) {
"missing comment for %s %s token %d\n");
$cmt);
} else {
}
} else {
$comment = '';
}
}
}
sub usage {
print "$0 [ -d ] [ -h ] {[ -a ] | [ -e event ] |\n";
print "\t[ -c class ] | [-i id ] | [ -p program ] |\n";
print "\t[ -s syscall ]}\n";
}
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.
@<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.
@<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$col2
.
.
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$note
.
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$note
.