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