auditxml revision c0c79a3f09914f35651895ffc111883455b7f62d
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# CDDL HEADER START
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# The contents of this file are subject to the terms of the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# Common Development and Distribution License (the "License").
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# You may not use this file except in compliance with the License.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# See the License for the specific language governing permissions
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# and limitations under the License.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# When distributing Covered Code, include this CDDL HEADER in each
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# If applicable, add the following below this CDDL HEADER, with the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# fields enclosed by brackets "[]" replaced with your own identifying
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# CDDL HEADER END
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# Use is subject to license terms.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# ident "%Z%%M% %I% %E% SMI"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# auditxml [-d] <xml input file>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# auditxml takes the audit record description (.xml file) and
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# generates the files needed for the C audit api.
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncour $debug = 0; # normal use is to set via the file being parsed.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # <debug set="on"/> or <debug set="off"/> or <debug/>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # if the set attribute is omitted, debug state is toggled
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # Override with appDebug, but toggle won't do what you
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncmy $appDebug = 0; # used after return from "new auditxml";
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncDO NOT EDIT. This file is auto generated by the Solaris Audit
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# trim leading/trailing newlines
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# where everything comes from and where it goes:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync generateAPIFile($event, $eventId, $eventType, $eventHeader, $idNo)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync generateTableC($event, $eventId, $eventType, $eventHeader, $omit);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync generateMsgLists($textList); # enum -> text mappings
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "can't open output file ($file): $!\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $notice =~ s/\n/\n * /gs;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $notice =~ s/\s+\n/\n/gs;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <bsm/libbsm.h>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <adt_xlate.h>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <libintl.h>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "/* Internal data type definitions */\n\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\n/* External event structure to internal event structure */\n\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($ref1, $eventType, $firstToken, $eventHeader) =
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "static struct entry $structName\[$count\] = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "static struct translation X_$externalRoot = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\t&XX_$externalRoot\[$firstToken\],\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "expected entry for $eventId but none found\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "struct translation *xlate_table[$count] = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncadt_preload(au_event_t event_id, adt_event_data_t *event_data)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync switch (event_id) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync case $adtID:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync event_data->$lcid.$fieldName = $default;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* message lists */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($header, $start, $public, $deprecated) = @$headref;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@listName, [$listName, $listLength - 1, $start, $public]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "/* Deprecated message list */\n" if ($deprecated);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "static char *msg_$listName\[$listLength] = {\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Cfile "\nstruct msg_text adt_msg_text[", $#listName + 1,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $notice =~ s/\n/\n * /gs;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $notice =~ s/\s+\n/\n/gs;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifndef $adt_event_n
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define $adt_event_n
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <bsm/$include>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef __cplusplus
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern "C" {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * adt_put_event() status values. Positive values are for kernel-generated
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * failure, -1 for user-space. For ADT_SUCCESS, the adt_put_event() return_val
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * is not used; the convention is to set it to ADT_SUCCESS.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define ADT_SUCCESS 0
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define ADT_FAILURE -1
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($header, $start, $public, $deprecated) = @$headref;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "/* Deprecated message list */\n" if $deprecated;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "#define\tADT_$shortName\t$start\n" if $start;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $text = "(no token will be generated)" unless $text;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "\tADT_$shortName", "_$id$start\t/* $text */\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "missing header selection for $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $l = length($eventId) + 8; # label plus preceding #define\t
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $l = 1 if $l < 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "missing id number for $eventId\n" unless $idNo;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "$eventId is missing the header assignment\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "\nstruct $dataId {\t/* $externalId */\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print Hfile "typedef struct $dataId $eventId","_t;\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifndef ADT_PRIVATE
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define ADT_PRIVATE
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * These interfaces are project private and will change without
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * notice as needed for the BSM API project.
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_get_auid(const adt_session_data_t *, au_id_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_set_auid(const adt_session_data_t *, const au_id_t);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_get_mask(const adt_session_data_t *, au_mask_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_set_mask(const adt_session_data_t *, const au_mask_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_get_termid(const adt_session_data_t *, au_tid_addr_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_set_termid(const adt_session_data_t *,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync const au_tid_addr_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_get_asid(const adt_session_data_t *, au_asid_t *);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncextern void adt_set_asid(const adt_session_data_t *, const au_asid_t);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef __cplusplus
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif /* $adt_event_n */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'priv_effective' => 'ADT_AUT_PRIV_E', # dummy token id
a180a41bba1d50822df23fff0099e90b86638b89vboxsync 'priv_inherit' => 'ADT_AUT_PRIV_I', # dummy token id
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "No external object captured for event $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $nameTranslation{$eventId} = $external->getInternalName();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "No internal object captured for event $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $firstTokenIndex = 0; # djdj not used yet, djdj BUG!
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ($internal->isReorder()) { # prescan the entry list to get the token order
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else { # default order -- input order same as output
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $j = $i + 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "token id $tokenId not implemented\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync formatTableEntry ('', $tokenId, $eventId, '', 0, 0, $tokenOrder[$sequence],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType =~ s/\s+//g; # remove blanks (char * => char*)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "token id $tokenId not implemented\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "$tokenId is an unimplemented token ($entryId in $eventId)\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync formatTableEntry($entryId, $tokenName, $eventId, $dataType, $required,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateEventTable{$eventId} = [\@xlateEntryList, $eventType, $firstTokenIndex,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my ($id, $token, $eventId, $type, $required, $tsol, $sequence, $format, $enumGroup,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # does this map belong in the xml source? (at least the defaults?)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # fill in the default value only if it is other than zero.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my %entryDef = ( 'au_asid_t' => ['ADT_UINT32', ''],
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # the list handling should be a simple loop with a loop of one
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unless ($type =~ /,/) { # if list, then generate sequence of entries
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $type =~ s/\[\]//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$id, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "$type is not an implemented data type\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateTypeList, "datadef\t$xlateLabel\[1\] =\t$xlateLine;");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync # "EOL" is where a comma should go unless end of list
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateLine = "{$token,\t1,\t$xlateLabelRef,\t$sequence,\n" .
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $jniId = shift @jniId;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $id = shift @id;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $type =~ s/\[\]//;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $sizeString = "$arraySize * " . $sizeString if $arraySize;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateType, "\{$entryType, $sizeString ($type)\}");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$jniId, $entryType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$jniId, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateType, "\{$entryType, sizeof ($type)\}");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$jniId, $entryType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@xlateType, "\{$dataType, sizeof (au_tid_addr_t *)\}");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync push (@jniLine, [$jniId, $dataType, $format, $enumGroup, $required]);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "$dtype is not an implemented data type\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $xlateArray = "\[$typeCount\] =\t{" . join(",\n\t\t\t\t", @xlateType) . "};";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $xlateArray = "datadef\t$xlateLabel" . $xlateArray;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "{$token,\t$typeCount,\t&$xlateLabel\[0\],\t$sequence,\n" .
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "event $eventId is of type $eventType\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync while (($extEntry, $entry, $tokenId, $format) = $external->getNextEntry()) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "undefined entry id for external $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (defined (my $token = $doc->getToken($tokenId))) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync print STDERR "no type defined for external tag for $eventId\n";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "number of data types ($dataType) does not match number of ids ($entryId)",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $#id = $#type;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $#type = $#id;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line .= "$primitive\t$dereference$id[$i];\t/* $option */";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $dataType =~ s/^msg\s*//i;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line .= "enum adt_$dataType" . "\t$entryId;\t/* $option */";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync $line .= "$primitive\t$dereference$entryId;\t/* $option */";
a180a41bba1d50822df23fff0099e90b86638b89vboxsync [\@entry, [$header, $start, $public, $deprecated]];
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# $header = 0 is a special case; it is for adt_event.h
a180a41bba1d50822df23fff0099e90b86638b89vboxsync# $header > 0 creates adt_event_N.h, where N = $header
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my $outfile = shift; # path to an adt_event_N.h file
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @Hfile = (); # potentially sparse array of file handles
a180a41bba1d50822df23fff0099e90b86638b89vboxsync my @HfileName = (); # parallel array to Hfile, file name (not path)