auditxml_jni revision 2
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER START
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Common Development and Distribution License (the "License").
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# You may not use this file except in compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# auditxml_jni [-d] <xml input file>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# auditxml takes the audit record description (.xml file) and
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# generates the files needed for the Java
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinour $debug = 0; # normal use is to set via the file being parsed.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin # <debug set="on"/> or <debug set="off"/> or <debug/>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin # if the set attribute is omitted, debug state is toggled
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin # Override with appDebug, but toggle won't do what you
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmy $appDebug = 0; # used after return from "new auditxml";
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinDO NOT EDIT. This file is auto generated by the Solaris Audit
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinsystem from adt.xml.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# trim leading/trailing newlines
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# where everything comes from and where it goes:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin generateTableC($event, $eventId, $eventType, undef, $omit);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinprintJavaFiles($jniC, $auditEventJ, $buildPathJ, $mapFile);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin my $jniFile = shift;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin my $mapFile = shift;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin # warning: time_t is equated to jlong since there is no
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ADT_PRIVSTAR omitted -- not implemented and the audit records that
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# use it must be coded to emit no java. We'll cross that bridge
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# when someone in Java land needs to generate a priv token.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 'ADT_TERMIDSTAR' => ['String', 'jstring'], # hostname -> termid
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ADT_UINT32ARRAY omitted; no Java implementation yet
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin $notice =~ s/\n/\n * /gs;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin $notice =~ s/\s+\n/\n/gs;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "../../libbsm/common/adt_xlate.h"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <jni.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "../com/sun/audit/AuditSession.h" /* javah output */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "adt_jni.h"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <stdlib.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <string.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic char *except_class = "java/lang/Exception";
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpackage com.sun.audit;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpublic class AuditEvent {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin protected AuditSession sh; // associated session object
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin public AuditEvent(AuditSession auSession)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin throws Error
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin sh = auSession;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin // Manifest values: keep them in sync with generated <bsm/adt_event.h>.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin // It is generated by \$SRC/lib/libbsm/auditxml
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin public static final int ADT_SUCCESS = 0; // generated
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin public static final int ADT_FAILURE = -1; // generated
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin // See the subclasses of AuditEvent for mapping message codes
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin // to events
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin $notice_map =~ s/\s+\n/\n/gs;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# $notice_map
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin\$mapfile_version 2
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSTUB_OBJECT;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinSYMBOL_VERSION SUNWprivate_1.1 {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin c2j_pointer;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin j2c_pointer;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Java_com_sun_audit_AuditSession_bsmAuditOn;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Java_com_sun_audit_AuditSession_startSession;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Java_com_sun_audit_AuditSession_endSession;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Java_com_sun_audit_AuditSession_dupSession;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Java_com_sun_audit_AuditSession_getSessionId;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Java_com_sun_audit_AuditSession_exportSessionData;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Java_com_sun_audit_AuditSession_sessionAttr;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# One subclass of AuditEvent per audit record...
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin # generate java final int classes to line up with string/enums
my $listValue;
$enumValue++;
$putMethod =~ s/_/_1/g;
my $validSfile = 1;
$validSfile = 0;
my $needCleanupTarget = 0;
my $haveStringDef = 0;
my $haveCDef = 0;
my $haveLengthDef = 0;
my $haveStringArrayDef = 0;
my $cntTermidDef = 0;
my $jniDefine;
my $needLocaleDefined = 0;
my $jniADTalloc;
my $ref2;
my $p_event;
$needLocaleDefined = 1;
$haveLengthDef = 1;
$needCleanupTarget = 1;
$needLocaleDefined = 1;
$jniFreeList .=
$haveLengthDef = 1;
$needCleanupTarget = 1;
$needLocaleDefined = 1;
$haveLengthDef = 1;
$needCleanupTarget = 1;
$haveCDef = 1;
$needLocaleDefined = 1;
$haveStringDef = 1;
$needCleanupTarget = 1;
$needLocaleDefined = 1;
$jniFreeList .=
$haveStringDef = 1;
$haveLengthDef = 1;
$haveStringArrayDef = 1;
$needCleanupTarget = 1;
$needLocaleDefined = 1;
$needCleanupTarget = 1;
$jniDefine .= <<EOF
my $idParameter = $eventId;
$idParameter =~ s/AUE_/ADT_/;
my @allowed = @$allowedIds;
my $idNo = $externalIdNo{$allowed[$i]};
my $jniMethodName = $root . $id;
my $storage;
if $jComment;
my $event = shift;
my $eventId = shift;
my $eventType = shift;
my $eventHeader = shift;
my $omit = shift;
my $entryRef;
my @inputOrder;
$firstTokenIndex = $j;
last;
my $sequence = 0;
$enumGroup =~ s/^msg\s*//i;
my $tsol = 0;
my $token;
my $tokenName;
print STDERR
$sequence++;
$jniEventTable{$eventId} = [\@jniEntryList, $eventType,
my $xlateLabelInc = 0;
my $dataType;
my $dataSize;
my $entryType = ${$entryDef{$type}}[0];
my $typeCount = 1;
$type =~ s/\[\]//;
my $dataType;
my $entryType = ${$entryDef{$dtype}}[0];
$type =~ s/\[\]//;
my $textList = shift;
my $entry;
my @entry;
[\@entry, [$header, $start, $public, $deprecated]];
my $eventListFile = shift;
next if $value < 6000;
$eventCode{$name} = $value;