2N/A# The contents of this file are subject to the terms of the 2N/A# Common Development and Distribution License (the "License"). 2N/A# You may not use this file except in compliance with the License. 2N/A# See the License for the specific language governing permissions 2N/A# and limitations under the License. 2N/A# When distributing Covered Code, include this CDDL HEADER in each 2N/A# If applicable, add the following below this CDDL HEADER, with the 2N/A# fields enclosed by brackets "[]" replaced with your own identifying 2N/A# information: Portions Copyright [yyyy] [name of copyright owner] 2N/A# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A# auditxml takes the audit record description (.xml file) and 2N/A# generates the files needed for the C audit api. 2N/AUsage: $prog [options] <xml-input-file> 2N/A -d Enable debug output 2N/A -e pfx Internal event prefix (default: AUE) 2N/A -i pfx Interface prefix (default: adt) 2N/A External event prefix is uppercase version of this string. 2N/A -o dir Output directory (default: current dir) 2N/Aour $debug =
0;
# normal use is to set via the file being parsed. 2N/A # <debug set="on"/> or <debug set="off"/> or <debug/> 2N/A # if the set attribute is omitted, debug state is toggled 2N/A # Override with appDebug, but toggle won't do what you 2N/A # set to 3 for all errors. 2N/A# Process command-line options 2N/Aif (!getopts('de:i:o:') || $#ARGV != 0) { 2N/A# where everything comes from and where it goes: 2N/A The contents of this file are subject to the terms of the 2N/A Common Development and Distribution License (the \"License\"). 2N/A You may not use this file except in compliance with the License. 2N/A See the License for the specific language governing permissions 2N/A and limitations under the License. 2N/A When distributing Covered Code, include this CDDL HEADER in each 2N/A If applicable, add the following below this CDDL HEADER, with the 2N/A fields enclosed by brackets \"[]\" replaced with your own identifying 2N/A information: Portions Copyright [yyyy] [name of copyright owner] 2N/A Copyright (c) 2007, $cYear, Oracle and/or its affiliates. All rights reserved. 2N/A DO NOT EDIT. This file is auto generated by the Solaris Audit 2N/A # header file for API use 2N/A # c file table for translation 2N/A#include <bsm/libbsm.h> 2N/A#include <adt_xlate.h> 2N/A print Cfile "/* Internal data type definitions */\n\n"; 2N/A print Cfile "\n/* External event structure to internal event structure", 2N/A print Cfile "\t0,\n"; # tx_offsetsCalculated = 0 2N/A print Cfile "adt_translation_t *${pfx_adt}_xlate_table[$count] = {\n"; 2N/A # generate the Event preload() function 2N/A${pfx_adt}_preload(au_event_t event_id, adt_event_data_t *event_data) 2N/A event_data->$id.$fieldName = $default; 2N/A#include <bsm/$include> 2N/A * adt_put_event() status values. Positive values are for kernel-generated 2N/A * failure, -1 for user-space. For ADT_SUCCESS, the adt_put_event() return_val 2N/A * is not used; the convention is to set it to ADT_SUCCESS. 2N/A#define ADT_SUCCESS 0 2N/A#define ADT_FAILURE -1 2N/A # ensure whole line does not exceed 80 chars 2N/A # 77 = 80 - length(" */") 2N/A # strip off double tab so that comment can be longer 2N/A # shorten eline; don't mind where the spaces are removed, it is 2N/A # only $eline length which matters 2N/A # here we use negative length in substr to leave off from the 2N/A # right side; 74 = 77 - length("...") 2N/A # strip off part of last word (already cut) 2N/A # generate defines for external event names 2N/A $l = 5 - int(($l + 8)/8); 2N/A # generate per-event structures 2N/A print Hfile "\tint\tdummy;\t/* not used */\n"; 2N/A # don't print duplicate error message 2N/A#ifndef ${pfx_ADT}_PRIVATE 2N/A#define ${pfx_ADT}_PRIVATE 2N/A * These interfaces are project private and will change without 2N/A * notice as needed for the Solaris Audit project. 2N/Aextern void adt_get_auid(const adt_session_data_t *, au_id_t *); 2N/Aextern void adt_set_auid(const adt_session_data_t *, const au_id_t); 2N/Aextern void adt_get_mask(const adt_session_data_t *, au_mask_t *); 2N/Aextern void adt_set_mask(const adt_session_data_t *, const au_mask_t *); 2N/Aextern void adt_get_termid(const adt_session_data_t *, au_tid_addr_t *); 2N/Aextern void adt_set_termid(const adt_session_data_t *, 2N/A const au_tid_addr_t *); 2N/Aextern void adt_get_asid(const adt_session_data_t *, au_asid_t *); 2N/Aextern void adt_set_asid(const adt_session_data_t *, const au_asid_t); 2N/Aextern au_asid_t adt_get_unique_id(au_id_t); 2N/Aextern void adt_load_table(const adt_session_data_t *, adt_translation_t **, 2N/A void (*preload)(au_event_t, adt_event_data_t *)); 2N/Aextern void ${pfx_adt}_preload(au_event_t, adt_event_data_t *); 2N/Aextern adt_translation_t *${pfx_adt}_xlate_table[]; 2N/A#endif /* $adt_event_n */ 2N/A # tokenTypes are the ones that are actually defined 2N/A # 'acl' => 'AUT_ACL', # not defined 2N/A # 'arbitrary' => 'AUT_ARBITRARY', # not defined 2N/A # 'atom' => 'AUT_XATOM', # not defined 2N/A 'attr' => 'AUT_ATTR64', 2N/A # 'colormap' => 'AUT_XCOLORMAP', # not defined 2N/A 'command' => 'AUT_CMD', 2N/A 'command_alt' => 'ADT_CMD_ALT', # dummy token id 2N/A # 'cursor' => 'AUT_XCURSOR', # not defined 2N/A # 'date' => 'AUT_TEXT', # not used 2N/A # 'exec_args' => 'AUT_EXEC_ARGS', # not defined 2N/A # 'exec_env' => 'AUT_EXEC_ENV', # not defined 2N/A # 'exit' => 'AUT_EXIT', # not defined 2N/A # 'font' => 'AUT_XFONT', # not defined 2N/A 'fmri' => 'AUT_FMRI', 2N/A # 'gc' => 'AUT_XGC', # not defined 2N/A # 'groups' => 'AUT_GROUPS', # not defined 2N/A # 'header' => 'AUT_HEADER', # not defined 2N/A 'in_peer' => 'ADT_IN_PEER', # dummy token id 2N/A 'in_remote' => 'ADT_IN_REMOTE', # dummy token id 2N/A # 'ipc' => 'AUT_IPC', # not defined 2N/A # 'ipc_perm' => 'AUT_IPC_PERM', # not defined 2N/A 'iport' => 'AUT_IPORT', 2N/A 'label' => 'AUT_LABEL', 2N/A 'newgroups' => 'AUT_NEWGROUPS', 2N/A # 'opaque' => 'AUT_OPAQUE', # not defined 2N/A 'path' => 'AUT_PATH', 2N/A 'path_list' => '-AUT_PATH', # dummy token id 2N/A # 'pixmap' => 'AUT_XPIXMAP', # not defined 2N/A 'process' => 'AUT_PROCESS', 2N/A 'priv_effective' => 'ADT_AUT_PRIV_E', # dummy token id 2N/A 'priv_limit' => 'ADT_AUT_PRIV_L', # dummy token id 2N/A 'priv_inherit' => 'ADT_AUT_PRIV_I', # dummy token id 2N/A 'return' => 'AUT_RETURN', 2N/A # 'seq' => 'AUT_SEQ', # not defined 2N/A # 'socket' => 'AUT_SOCKET', # not defined 2N/A # 'socket-inet' => 'AUT_SOCKET_INET', 2N/A 'subject' => 'AUT_SUBJECT', 2N/A 'text' => 'AUT_TEXT', 2N/A # 'trailer' => 'AUT_TRAILER', # not defined 2N/A 'uauth' => 'AUT_UAUTH', 2N/A 'user' => 'AUT_USER', 2N/A 'xclient' => 'AUT_XCLIENT', 2N/A # 'xobj' => 'AUT_XOBJ', # not defined 2N/A # 'xproto' => 'AUT_XPROTO', # not defined 2N/A 'zonename' => 'AUT_ZONENAME' 2N/A # needs to be used by translate table 2N/A my $i; # walk down the inputOrder list once 2N/A my $k = 1; # discover next in line 2N/A my $l = 0; # who should point to next in line 2N/A else { # default order -- input order same as output 2N/A # does this map belong in the xml source? (at least the defaults?) 2N/A # fill in the default value only if it is other than zero. 2N/A # base type adt name, default value 2N/A 'uint_t' => ['ADT_UINT32', ''], 2N/A 'int' => ['ADT_INT', ''], 2N/A 'int32_t' => ['ADT_INT32', ''], 2N/A 'uid_t' => ['ADT_UID', 'AU_NOAUDITID'], 2N/A 'gid_t' => ['ADT_GID', 'AU_NOAUDITID'], 2N/A 'uid_t*' => ['ADT_UIDSTAR', ''], 2N/A 'gid_t*' => ['ADT_GIDSTAR', ''], 2N/A 'char' => ['ADT_CHAR', ''], 2N/A 'char*' => ['ADT_CHARSTAR', ''], 2N/A 'char**' => ['ADT_CHAR2STAR', ''], 2N/A 'long' => ['ADT_LONG', ''], 2N/A 'pid_t' => ['ADT_PID', ''], 2N/A 'priv_set_t*' => ['ADT_PRIVSTAR', ''], 2N/A 'ulong_t' => ['ADT_ULONG', ''], 2N/A 'uint16_t', => ['ADT_UINT16', ''], 2N/A 'uint32_t' => ['ADT_UINT32', ''], 2N/A 'uint32_t*' => ['ADT_UINT32STAR', ''], 2N/A 'uint32_t[]' => ['ADT_UINT32ARRAY', ''], 2N/A 'uint64_t' => ['ADT_UINT64', ''], 2N/A 'uint64_t*' => ['ADT_UINT64STAR', ''], 2N/A 'm_label_t*' => ['ADT_MLABELSTAR', ''], 2N/A 'fd_t' => ['ADT_FD', '-1'], 2N/A 'adt_stat_t*' => ['ADT_STATSTAR', ''], 2N/A # the list handling should be a simple loop with a loop of one 2N/A # falling out naturally. 2N/A # "EOL" is where a comma should go unless end of list 2N/A } else { # is a list 2N/A "number of data types ($dataType) does not match number of ids ", 2N/A for ($i = 0; $i <= $#type; $i++) { 2N/A my @Hfile = (); # potentially sparse array of file handles 2N/A my @HfileName = (); # parallel array to Hfile, file name (not path)