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