4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
33 #include <bsm/libbsm.h>
35 #include <tsol/label.h>
37 #include "adt_event.h"
44 #define TEXT_DOMAIN "SYS_TEST"
48 * values for adt_session_model
49 * In the session model, the session and process are unrelated, so
50 * such things as the supplementary group token make no sense. In
51 * the process model, the process and session are the same.
53 #define ADT_SESSION_MODEL 1
54 #define ADT_PROCESS_MODEL 0
56 #define ADT_HAVE_MASK 0x01
57 #define ADT_HAVE_TID 0x02
58 #define ADT_HAVE_AUID 0x04
59 #define ADT_HAVE_ASID 0x08
60 #define ADT_HAVE_IDS 0x10
61 #define ADT_HAVE_ALL (uint32_t)\
62 (ADT_HAVE_MASK | ADT_HAVE_TID | ADT_HAVE_AUID | ADT_HAVE_ASID |\
66 * dummy token types for privilege
68 #define ADT_AUT_PRIV_L -100 /* limit set */
69 #define ADT_AUT_PRIV_I -101 /* inherited set */
70 #define ADT_AUT_PRIV_E -102 /* effective set */
71 #define ADT_CMD_ALT -103 /* dummy token type for alternate command */
72 #define ADT_IN_PEER -104 /* peer address in_addr and in_port */
73 #define ADT_IN_REMOTE -105 /* specified address in_addr */
75 enum adt_generic
{ADT_GENERIC
}; /* base for text enums */
77 typedef struct adt_internal_state adt_internal_state_t
;
79 union union_of_events
{
80 union adt_event_data d0
;
84 * The order of the lists MUST match the order in
85 * struct msg_text adt_msg_text that is generated by
86 * auditxml in adt_xlate.c.
95 enum datatype
{ADT_UNDEFINED
= 0,
114 ADT_CHAR2STAR
, /* char ** */
121 typedef enum datatype datatype_t
;
124 enum adt_generic msg_selector
;
133 uint32_t *tuint32star
;
144 au_tid_addr_t
*ttermid
;
145 priv_set_t
*tprivstar
;
150 struct adt_event_state
{
151 union union_of_events ae_event_data
;
153 /* above is user's area; below is internal. Order matters */
155 uint_t ae_check
; /* see adt_internal_state */
157 au_event_t ae_event_id
; /* external id */
158 au_event_t ae_internal_id
; /* translated */
159 int ae_rc
; /* exit token rc */
160 int ae_type
; /* exit error type */
161 struct adt_internal_state
*ae_session
;
165 datatype_t dd_datatype
; /* input data type */
166 size_t dd_input_size
; /* input data size */
168 typedef struct datadefs datadef
;
170 typedef void (* adt_token_func_t
)(datadef
*, void *, int,
171 struct adt_event_state
*, char *);
173 typedef char *(* adt_msg_func_t
)(enum adt_generic
);
175 #define ADT_VALID 0xAAAA5555
177 struct adt_internal_state
{
178 uint32_t as_check
; /* == ADT_VALID when created, */
179 /* == zero when freed */
185 struct auditinfo_addr as_info
;
188 * ai_mask.am_success pre-selection mask
190 * ai_termid .at_port terminal id
192 * .ai_termid.at_addr[0]
193 * .ai_termid.at_addr[1]
194 * .ai_termid.at_addr[2]
195 * .ai_termid.at_addr[3]
198 int as_audit_state
; /* audit state */
200 * data above this line is exported / imported
201 * To maintain upward compatibility, the above structures
202 * can't change, so for version 2, all changes will need
203 * to be added here and the old format (above) maintained.
206 uint32_t as_have_user_data
;
208 uint32_t as_kernel_audit_policy
;
209 int as_session_model
;
210 adt_session_flags_t as_flags
;
212 m_label_t
*as_label
; /* if is_system_labeled */
213 adt_translation_t
**as_xlate
;
214 void (*as_preload
)(au_event_t
, adt_event_data_t
*);
219 * version number changes when adt_internal_state's export portion
222 #define PROTOCOL_VERSION_1 1
223 #define PROTOCOL_VERSION_2 2
226 * most recent version is at the top; down level consumers are
227 * expected to search down via "prev_offsetX" to a version they
228 * understand. "v1" is first, "v0" is used to illustrate correct
229 * order for future use.
232 struct adt_export_v2
{
238 uint32_t ax_mask_success
;
239 uint32_t ax_mask_failure
;
246 size32_t ax_label_len
; /* 0, unlabeled */
247 /* char ax_label[ax_label_len]; if, is_system_labeled */
249 struct adt_export_v1
{
255 uint32_t ax_mask_success
;
256 uint32_t ax_mask_failure
;
262 uint32_t ax_size_of_tsol_data
; /* zero for non-TSOL systems */
268 struct export_header
{
270 int32_t ax_buffer_length
;
271 struct export_link ax_link
;
274 struct adt_export_data
{
275 struct export_header ax_header
;
277 struct adt_export_v2 ax_v2
;
279 * end of version 2 data
281 struct export_link ax_next_v1
;
282 struct adt_export_v1 ax_v1
;
284 * end of version 1 data
285 * struct export_link ax_next_A;
286 * data for older version
287 * struct adt_export_v0 ax_v0;
289 struct export_link ax_last
; /* terminator */
293 * struct entry defines rows in tables defined in adt_xlate.c
297 char en_token_id
; /* token id */
298 int en_count_types
; /* # of input fields for this token */
299 datadef
*en_type_def
; /* field type and size of each input */
300 struct entry
*en_next_token
; /* linked list pointer */
301 size_t en_offset
; /* offset into structure for input */
302 int en_required
; /* if 1, always output a token */
303 int en_tsol
; /* if 1, reserved if for TX */
304 char *en_msg_format
; /* pointer to sprintf format string */
308 int tx_offsetsCalculated
; /* eponymous */
309 au_event_t tx_external_event
; /* event id, external view */
310 au_event_t tx_internal_event
; /* event id, internal view */
311 int tx_entries
; /* array size of entry array */
312 struct entry
*tx_first_entry
; /* start of linked list */
313 struct entry
*tx_top_entry
; /* first array element */
318 adt_token_func_t jmp_to
;
328 extern struct msg_text adt_msg_text
[];
330 extern void adt_write_syslog(const char *, int);
331 extern void adt_token_open(struct adt_event_state
*);
332 extern int adt_token_close(struct adt_event_state
*);
333 extern void adt_generate_token(struct entry
*, void *,
334 struct adt_event_state
*);
335 extern void *adt_adjust_address(void *, size_t, size_t);
341 #endif /* _BSM_XLATE_H */