auditxml.pm 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 my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my @kid = $obj->getKids(); # kids of event are entry or allowed_types
c0c79a3f09914f35651895ffc111883455b7f62dtz # separate kids into classes and create hash of entries and an
c0c79a3f09914f35651895ffc111883455b7f62dtz # array of includes
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined $internal) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined $commentKid) {
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined ($external)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $entry{$kidId} = [$external, $kid, $tokenId, $format, $comment];
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "no external attributes defined for $id/$kidId\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz } # handle event id translation...
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (defined $internalName) {
c0c79a3f09914f35651895ffc111883455b7f62dtz @allowed_types = (@allowed_types, split(/\s*,\s*/, $content));
c0c79a3f09914f35651895ffc111883455b7f62dtz# return id
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# return internal name if it exists, else id
c0c79a3f09914f35651895ffc111883455b7f62dtz# getNextEntry reads from 'entryList' destructively
c0c79a3f09914f35651895ffc111883455b7f62dtz# but resets when the list after the list is emptied
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz return undef;
c0c79a3f09914f35651895ffc111883455b7f62dtz return ($pkg->getEntry($id)); # getEntry returns an array
c0c79a3f09914f35651895ffc111883455b7f62dtz# getEntryIds returns list of all ids from entryList
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# getEntry returns a selected entry for the current event
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# getNextInclude reads from 'include' destructively
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# getIncludes returns list of 'include'
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# return a reference to the list of event id's allowed for
c0c79a3f09914f35651895ffc111883455b7f62dtz# this generic event
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined ($internal)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz# getEntries returns a list of all entry references
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $super = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "$uniqueId{$idNo} and $id have the same id ($idNo)\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz# putDef is called at the end of an <event></event> block, so
c0c79a3f09914f35651895ffc111883455b7f62dtz# it sees a completed object.
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $context = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz return undef;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $ref = $pkg->{$context} = new externalEvent($id, $obj);
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz return shift->{'title'};
c0c79a3f09914f35651895ffc111883455b7f62dtz return shift->{'program'};
c0c79a3f09914f35651895ffc111883455b7f62dtz return shift->{'see'};
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# this isn't fully implemented; just a skeleton
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $header = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $start = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $public = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $deprecated = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined ($msgId)) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "invalid tag in <msg_list> block: $class\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# destructive read of @msg...
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz return undef unless @msg;
c0c79a3f09914f35651895ffc111883455b7f62dtz# returns all msgs
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# These aren't internal state because the callback functions don't
c0c79a3f09914f35651895ffc111883455b7f62dtz# have the object handle.
c0c79a3f09914f35651895ffc111883455b7f62dtz%externalToInternal = (); # map external event name to internal event name
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz # do not use register() for debug because register generates extra
c0c79a3f09914f35651895ffc111883455b7f62dtz # debug information
c0c79a3f09914f35651895ffc111883455b7f62dtz xmlHandlers::registerStartCallback('debug', \&debugStart);
c0c79a3f09914f35651895ffc111883455b7f62dtz# local function -- register both the auditxml function and the
c0c79a3f09914f35651895ffc111883455b7f62dtz# xmlHandler callback
c0c79a3f09914f35651895ffc111883455b7f62dtz my $localName = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $startFunction = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $endFunction = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz xmlHandlers::registerStartCallback($localName, \&completed);
c0c79a3f09914f35651895ffc111883455b7f62dtz xmlHandlers::registerEndCallback($localName, \&completed);
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $callbackSource = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz print "*** $callbackSource: $class", (defined ($id)) ? "= $id\n" : "\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz print "*** $attribute = $attributes{$attribute}\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "no auditxml function defined for $class\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz# getNextEvent reads from @event destructively. 'firstEvent' could
c0c79a3f09914f35651895ffc111883455b7f62dtz# be used to make a copy from which to read.
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz return undef unless (@event);
c0c79a3f09914f35651895ffc111883455b7f62dtz# returns all event ids
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# returns event for id
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# getNextToken reads from @token destructively. 'firstToken' could
c0c79a3f09914f35651895ffc111883455b7f62dtz# be used to make a copy from which to read.
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz return undef unless (@token);
c0c79a3f09914f35651895ffc111883455b7f62dtz# return token Ids
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# getNextMsgId reads from @msg_list destructively.
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz return undef unless (@msg_list);
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $pkg = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $id = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz unless ($id) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz unless (defined $id) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "event element is missing required id attribute\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz my $internalName = $event{$id}->putDef($obj, 'external');
c0c79a3f09914f35651895ffc111883455b7f62dtz $externalToInternal{$id} = $internalName if $internalName;
c0c79a3f09914f35651895ffc111883455b7f62dtz# class method
c0c79a3f09914f35651895ffc111883455b7f62dtz#sub getInternalName {
c0c79a3f09914f35651895ffc111883455b7f62dtz# my $name = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# return $externalToInternal{$name};
c0c79a3f09914f35651895ffc111883455b7f62dtz#sub include {
c0c79a3f09914f35651895ffc111883455b7f62dtz# my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# my $id = $obj->getAttr('id');
c0c79a3f09914f35651895ffc111883455b7f62dtz# if (defined $id) {
c0c79a3f09914f35651895ffc111883455b7f62dtz# print "include = $id\n" if $main::debug;
c0c79a3f09914f35651895ffc111883455b7f62dtz# print STDERR "include element is missing required id attribute\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined $id) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "token element is missing required id attribute\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined $id) {
c0c79a3f09914f35651895ffc111883455b7f62dtz $msg_list{$id} = new messageList($obj, $id, $header, $start,
c0c79a3f09914f35651895ffc111883455b7f62dtz "msg_list element is missing required id attribute\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz# my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz# Service name was dropped during PSARC review
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz elsif (defined $name) {
c0c79a3f09914f35651895ffc111883455b7f62dtz elsif (defined $id) {
c0c79a3f09914f35651895ffc111883455b7f62dtz print STDERR "missing both name and id for a service entry\n";
c0c79a3f09914f35651895ffc111883455b7f62dtz#sub getServices {
c0c79a3f09914f35651895ffc111883455b7f62dtz# return %service;
c0c79a3f09914f35651895ffc111883455b7f62dtz# <debug set="on"> or <debug set="off"> or <debug>
c0c79a3f09914f35651895ffc111883455b7f62dtz# if the set attribute is omitted, debug state is toggled
c0c79a3f09914f35651895ffc111883455b7f62dtz# debugStart / debugEnd are used to insure debug state is
c0c79a3f09914f35651895ffc111883455b7f62dtz# scoped to the block between <debug> and </debug>
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (defined $state) {
c0c79a3f09914f35651895ffc111883455b7f62dtz my $obj = shift;