17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 58c3c55e7Spaulson * Common Development and Distribution License (the "License"). 68c3c55e7Spaulson * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 227c478bd9Sstevel@tonic-gate * adt_xlate.h 237c478bd9Sstevel@tonic-gate * 24*91b2cbb3Sgww * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 257c478bd9Sstevel@tonic-gate * 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #ifndef _BSM_XLATE_H 297c478bd9Sstevel@tonic-gate #define _BSM_XLATE_H 307c478bd9Sstevel@tonic-gate 310ad2061eSgww #include <priv.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <bsm/libbsm.h> 340ad2061eSgww 35c529a23fSgww #include <tsol/label.h> 367c478bd9Sstevel@tonic-gate 370ad2061eSgww #include "adt_event.h" 380ad2061eSgww 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifndef TEXT_DOMAIN 447c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * values for adt_session_model 497c478bd9Sstevel@tonic-gate * In the session model, the session and process are unrelated, so 507c478bd9Sstevel@tonic-gate * such things as the supplementary group token make no sense. In 517c478bd9Sstevel@tonic-gate * the process model, the process and session are the same. 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate #define ADT_SESSION_MODEL 1 547c478bd9Sstevel@tonic-gate #define ADT_PROCESS_MODEL 0 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #define ADT_HAVE_MASK 0x01 577c478bd9Sstevel@tonic-gate #define ADT_HAVE_TID 0x02 587c478bd9Sstevel@tonic-gate #define ADT_HAVE_AUID 0x04 597c478bd9Sstevel@tonic-gate #define ADT_HAVE_ASID 0x08 608c3c55e7Spaulson #define ADT_HAVE_IDS 0x10 617c478bd9Sstevel@tonic-gate #define ADT_HAVE_ALL (uint32_t)\ 627c478bd9Sstevel@tonic-gate (ADT_HAVE_MASK | ADT_HAVE_TID | ADT_HAVE_AUID | ADT_HAVE_ASID |\ 637c478bd9Sstevel@tonic-gate ADT_HAVE_IDS) 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * dummy token types for privilege 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate #define ADT_AUT_PRIV_L -100 /* limit set */ 697c478bd9Sstevel@tonic-gate #define ADT_AUT_PRIV_I -101 /* inherited set */ 707c478bd9Sstevel@tonic-gate #define ADT_AUT_PRIV_E -102 /* effective set */ 7111bc41c8Sgww #define ADT_CMD_ALT -103 /* dummy token type for alternate command */ 72f72effdeSgww #define ADT_IN_PEER -104 /* peer address in_addr and in_port */ 7311bc41c8Sgww #define ADT_IN_REMOTE -105 /* specified address in_addr */ 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate enum adt_generic {ADT_GENERIC}; /* base for text enums */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate typedef struct adt_internal_state adt_internal_state_t; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate union union_of_events { 807c478bd9Sstevel@tonic-gate union adt_event_data d0; 817c478bd9Sstevel@tonic-gate }; 82a76042b7SWyllys Ingersoll 83a76042b7SWyllys Ingersoll /* 84a76042b7SWyllys Ingersoll * The order of the lists MUST match the order in 85a76042b7SWyllys Ingersoll * struct msg_text adt_msg_text that is generated by 86a76042b7SWyllys Ingersoll * auditxml in adt_xlate.c. 87a76042b7SWyllys Ingersoll */ 887c478bd9Sstevel@tonic-gate enum adt_msg_list { 897c478bd9Sstevel@tonic-gate ADT_LIST_FAIL_PAM, 907c478bd9Sstevel@tonic-gate ADT_LIST_FAIL_VALUE, 916a3b10dbStz204579 ADT_LIST_LOGIN_TEXT, 92a76042b7SWyllys Ingersoll ADT_LIST_TPM_E, 93a76042b7SWyllys Ingersoll ADT_LIST_UADMIN_FCN}; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate enum datatype {ADT_UNDEFINED = 0, 967c478bd9Sstevel@tonic-gate ADT_DATE, 977c478bd9Sstevel@tonic-gate ADT_MSG, 987c478bd9Sstevel@tonic-gate ADT_UINT, 997c478bd9Sstevel@tonic-gate ADT_INT, 1007c478bd9Sstevel@tonic-gate ADT_INT32, 1017c478bd9Sstevel@tonic-gate ADT_UINT16, 1027c478bd9Sstevel@tonic-gate ADT_UINT32, 1037c478bd9Sstevel@tonic-gate ADT_UINT32STAR, 1047c478bd9Sstevel@tonic-gate ADT_UINT32ARRAY, 1057c478bd9Sstevel@tonic-gate ADT_UID, 1067c478bd9Sstevel@tonic-gate ADT_GID, 1077c478bd9Sstevel@tonic-gate ADT_UIDSTAR, 1087c478bd9Sstevel@tonic-gate ADT_GIDSTAR, 1097c478bd9Sstevel@tonic-gate ADT_UINT64, 1107c478bd9Sstevel@tonic-gate ADT_LONG, 1117c478bd9Sstevel@tonic-gate ADT_ULONG, 1127c478bd9Sstevel@tonic-gate ADT_CHAR, 1137c478bd9Sstevel@tonic-gate ADT_CHARSTAR, 1147c478bd9Sstevel@tonic-gate ADT_CHAR2STAR, /* char ** */ 1157c478bd9Sstevel@tonic-gate ADT_PID, 1167c478bd9Sstevel@tonic-gate ADT_PRIVSTAR, 1176af17881Sgww ADT_TERMIDSTAR, 11869987563Ssabdar ADT_MLABELSTAR, 11969987563Ssabdar ADT_FD 1207c478bd9Sstevel@tonic-gate }; 1217c478bd9Sstevel@tonic-gate typedef enum datatype datatype_t; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate union convert { 1247c478bd9Sstevel@tonic-gate enum adt_generic msg_selector; 1257c478bd9Sstevel@tonic-gate boolean_t tbool; 1267c478bd9Sstevel@tonic-gate uint_t tuint; 1277c478bd9Sstevel@tonic-gate int tint; 1287c478bd9Sstevel@tonic-gate int32_t tint32; 1297c478bd9Sstevel@tonic-gate uint16_t tuint16; 1307c478bd9Sstevel@tonic-gate uint32_t tuint32; 1317c478bd9Sstevel@tonic-gate uint64_t tuint64; 1327c478bd9Sstevel@tonic-gate int32_t *tint32star; 1337c478bd9Sstevel@tonic-gate uint32_t *tuint32star; 1347c478bd9Sstevel@tonic-gate uid_t tuid; 1357c478bd9Sstevel@tonic-gate gid_t tgid; 1367c478bd9Sstevel@tonic-gate uid_t *tuidstar; 1377c478bd9Sstevel@tonic-gate gid_t *tgidstar; 1387c478bd9Sstevel@tonic-gate pid_t tpid; 1397c478bd9Sstevel@tonic-gate long tlong; 1407c478bd9Sstevel@tonic-gate ulong_t tulong; 1417c478bd9Sstevel@tonic-gate char tchar; 1427c478bd9Sstevel@tonic-gate char *tcharstar; 1437c478bd9Sstevel@tonic-gate char **tchar2star; 1447c478bd9Sstevel@tonic-gate au_tid_addr_t *ttermid; 1457c478bd9Sstevel@tonic-gate priv_set_t *tprivstar; 1466af17881Sgww m_label_t *tm_label; 14769987563Ssabdar fd_t tfd; 1487c478bd9Sstevel@tonic-gate }; 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate struct adt_event_state { 1517c478bd9Sstevel@tonic-gate union union_of_events ae_event_data; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* above is user's area; below is internal. Order matters */ 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate uint_t ae_check; /* see adt_internal_state */ 1567c478bd9Sstevel@tonic-gate int ae_event_handle; 1577c478bd9Sstevel@tonic-gate au_event_t ae_event_id; /* external id */ 1587c478bd9Sstevel@tonic-gate au_event_t ae_internal_id; /* translated */ 1597c478bd9Sstevel@tonic-gate int ae_rc; /* exit token rc */ 1607c478bd9Sstevel@tonic-gate int ae_type; /* exit error type */ 1617c478bd9Sstevel@tonic-gate struct adt_internal_state *ae_session; 1627c478bd9Sstevel@tonic-gate }; 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate struct datadefs { 1657c478bd9Sstevel@tonic-gate datatype_t dd_datatype; /* input data type */ 1667c478bd9Sstevel@tonic-gate size_t dd_input_size; /* input data size */ 1677c478bd9Sstevel@tonic-gate }; 1687c478bd9Sstevel@tonic-gate typedef struct datadefs datadef; 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate typedef void (* adt_token_func_t)(datadef *, void *, int, 1717c478bd9Sstevel@tonic-gate struct adt_event_state *, char *); 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate typedef char *(* adt_msg_func_t)(enum adt_generic); 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate #define ADT_VALID 0xAAAA5555 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate struct adt_internal_state { 1787c478bd9Sstevel@tonic-gate uint32_t as_check; /* == ADT_VALID when created, */ 1797c478bd9Sstevel@tonic-gate /* == zero when freed */ 1807c478bd9Sstevel@tonic-gate uid_t as_euid; 1817c478bd9Sstevel@tonic-gate uid_t as_ruid; 1827c478bd9Sstevel@tonic-gate gid_t as_egid; 1837c478bd9Sstevel@tonic-gate gid_t as_rgid; 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate struct auditinfo_addr as_info; 1867c478bd9Sstevel@tonic-gate /* 1877c478bd9Sstevel@tonic-gate * ai_auid audit id 1887c478bd9Sstevel@tonic-gate * ai_mask.am_success pre-selection mask 1897c478bd9Sstevel@tonic-gate * ai_mask.am_failure 1907c478bd9Sstevel@tonic-gate * ai_termid .at_port terminal id 1917c478bd9Sstevel@tonic-gate * .at_type 1927c478bd9Sstevel@tonic-gate * .ai_termid.at_addr[0] 1937c478bd9Sstevel@tonic-gate * .ai_termid.at_addr[1] 1947c478bd9Sstevel@tonic-gate * .ai_termid.at_addr[2] 1957c478bd9Sstevel@tonic-gate * .ai_termid.at_addr[3] 1967c478bd9Sstevel@tonic-gate * ai_asid session id 1977c478bd9Sstevel@tonic-gate */ 198*91b2cbb3Sgww int as_audit_state; /* audit state */ 1997c478bd9Sstevel@tonic-gate /* 2007c478bd9Sstevel@tonic-gate * data above this line is exported / imported 2017c478bd9Sstevel@tonic-gate * To maintain upward compatibility, the above structures 2027c478bd9Sstevel@tonic-gate * can't change, so for version 2, all changes will need 2037c478bd9Sstevel@tonic-gate * to be added here and the old format (above) maintained. 2047c478bd9Sstevel@tonic-gate */ 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate uint32_t as_have_user_data; 2077c478bd9Sstevel@tonic-gate 20896093503SMarek Pospisil uint32_t as_kernel_audit_policy; 2097c478bd9Sstevel@tonic-gate int as_session_model; 2107c478bd9Sstevel@tonic-gate adt_session_flags_t as_flags; 211c529a23fSgww pid_t as_pid; 212c529a23fSgww m_label_t *as_label; /* if is_system_labeled */ 2130ad2061eSgww adt_translation_t **as_xlate; 2140ad2061eSgww void (*as_preload)(au_event_t, adt_event_data_t *); 2157c478bd9Sstevel@tonic-gate }; 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate /* 2187c478bd9Sstevel@tonic-gate * export data format 2197c478bd9Sstevel@tonic-gate * version number changes when adt_internal_state's export portion 2207c478bd9Sstevel@tonic-gate * changes. 2217c478bd9Sstevel@tonic-gate */ 222c529a23fSgww #define PROTOCOL_VERSION_1 1 223c529a23fSgww #define PROTOCOL_VERSION_2 2 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate /* 2267c478bd9Sstevel@tonic-gate * most recent version is at the top; down level consumers are 2277c478bd9Sstevel@tonic-gate * expected to search down via "prev_offsetX" to a version they 2287c478bd9Sstevel@tonic-gate * understand. "v1" is first, "v0" is used to illustrate correct 2297c478bd9Sstevel@tonic-gate * order for future use. 2307c478bd9Sstevel@tonic-gate */ 2317c478bd9Sstevel@tonic-gate 232c529a23fSgww struct adt_export_v2 { 233c529a23fSgww int32_t ax_euid; 234c529a23fSgww int32_t ax_ruid; 235c529a23fSgww int32_t ax_egid; 236c529a23fSgww int32_t ax_rgid; 237c529a23fSgww int32_t ax_auid; 238c529a23fSgww uint32_t ax_mask_success; 239c529a23fSgww uint32_t ax_mask_failure; 240c529a23fSgww uint32_t ax_port; 241c529a23fSgww uint32_t ax_type; 242c529a23fSgww uint32_t ax_addr[4]; 243c529a23fSgww uint32_t ax_asid; 244*91b2cbb3Sgww int ax_audit_state; 245c529a23fSgww pid_t ax_pid; 24642096647STony Nguyen size32_t ax_label_len; /* 0, unlabeled */ 247c529a23fSgww /* char ax_label[ax_label_len]; if, is_system_labeled */ 248c529a23fSgww }; 2497c478bd9Sstevel@tonic-gate struct adt_export_v1 { 2507c478bd9Sstevel@tonic-gate int32_t ax_euid; 2517c478bd9Sstevel@tonic-gate int32_t ax_ruid; 2527c478bd9Sstevel@tonic-gate int32_t ax_egid; 2537c478bd9Sstevel@tonic-gate int32_t ax_rgid; 2547c478bd9Sstevel@tonic-gate int32_t ax_auid; 2557c478bd9Sstevel@tonic-gate uint32_t ax_mask_success; 2567c478bd9Sstevel@tonic-gate uint32_t ax_mask_failure; 2577c478bd9Sstevel@tonic-gate uint32_t ax_port; 2587c478bd9Sstevel@tonic-gate uint32_t ax_type; 2597c478bd9Sstevel@tonic-gate uint32_t ax_addr[4]; 2607c478bd9Sstevel@tonic-gate uint32_t ax_asid; 261*91b2cbb3Sgww int ax_audit_state; 2627c478bd9Sstevel@tonic-gate uint32_t ax_size_of_tsol_data; /* zero for non-TSOL systems */ 2637c478bd9Sstevel@tonic-gate }; 2647c478bd9Sstevel@tonic-gate struct export_link { 2657c478bd9Sstevel@tonic-gate int32_t ax_version; 2667c478bd9Sstevel@tonic-gate int32_t ax_offset; 2677c478bd9Sstevel@tonic-gate }; 2687c478bd9Sstevel@tonic-gate struct export_header { 2697c478bd9Sstevel@tonic-gate uint32_t ax_check; 2707c478bd9Sstevel@tonic-gate int32_t ax_buffer_length; 2717c478bd9Sstevel@tonic-gate struct export_link ax_link; 2727c478bd9Sstevel@tonic-gate }; 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate struct adt_export_data { 2757c478bd9Sstevel@tonic-gate struct export_header ax_header; 2767c478bd9Sstevel@tonic-gate 277c529a23fSgww struct adt_export_v2 ax_v2; 278c529a23fSgww /* 279c529a23fSgww * end of version 2 data 280c529a23fSgww */ 281c529a23fSgww struct export_link ax_next_v1; 2827c478bd9Sstevel@tonic-gate struct adt_export_v1 ax_v1; 2837c478bd9Sstevel@tonic-gate /* 2847c478bd9Sstevel@tonic-gate * end of version 1 data 2857c478bd9Sstevel@tonic-gate * struct export_link ax_next_A; 2867c478bd9Sstevel@tonic-gate * data for older version 2877c478bd9Sstevel@tonic-gate * struct adt_export_v0 ax_v0; 2887c478bd9Sstevel@tonic-gate */ 2897c478bd9Sstevel@tonic-gate struct export_link ax_last; /* terminator */ 2907c478bd9Sstevel@tonic-gate }; 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* 2937c478bd9Sstevel@tonic-gate * struct entry defines rows in tables defined in adt_xlate.c 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate struct entry { 2977c478bd9Sstevel@tonic-gate char en_token_id; /* token id */ 2987c478bd9Sstevel@tonic-gate int en_count_types; /* # of input fields for this token */ 2997c478bd9Sstevel@tonic-gate datadef *en_type_def; /* field type and size of each input */ 3007c478bd9Sstevel@tonic-gate struct entry *en_next_token; /* linked list pointer */ 3017c478bd9Sstevel@tonic-gate size_t en_offset; /* offset into structure for input */ 3027c478bd9Sstevel@tonic-gate int en_required; /* if 1, always output a token */ 303c529a23fSgww int en_tsol; /* if 1, reserved if for TX */ 3047c478bd9Sstevel@tonic-gate char *en_msg_format; /* pointer to sprintf format string */ 3057c478bd9Sstevel@tonic-gate }; 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate struct translation { 3087c478bd9Sstevel@tonic-gate int tx_offsetsCalculated; /* eponymous */ 3097c478bd9Sstevel@tonic-gate au_event_t tx_external_event; /* event id, external view */ 3107c478bd9Sstevel@tonic-gate au_event_t tx_internal_event; /* event id, internal view */ 3117c478bd9Sstevel@tonic-gate int tx_entries; /* array size of entry array */ 3127c478bd9Sstevel@tonic-gate struct entry *tx_first_entry; /* start of linked list */ 3137c478bd9Sstevel@tonic-gate struct entry *tx_top_entry; /* first array element */ 3147c478bd9Sstevel@tonic-gate }; 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate struct token_jmp { 3177c478bd9Sstevel@tonic-gate long jmp_id; 3187c478bd9Sstevel@tonic-gate adt_token_func_t jmp_to; 3197c478bd9Sstevel@tonic-gate }; 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate struct msg_text { 3227c478bd9Sstevel@tonic-gate int ml_min_index; 3237c478bd9Sstevel@tonic-gate int ml_max_index; 3247c478bd9Sstevel@tonic-gate char **ml_msg_list; 3257c478bd9Sstevel@tonic-gate int ml_offset; 3267c478bd9Sstevel@tonic-gate }; 3277c478bd9Sstevel@tonic-gate 328d67944fbSScott Rotondo extern struct msg_text adt_msg_text[]; 329d67944fbSScott Rotondo 3307c478bd9Sstevel@tonic-gate extern void adt_write_syslog(const char *, int); 3317c478bd9Sstevel@tonic-gate extern void adt_token_open(struct adt_event_state *); 3320ad2061eSgww extern int adt_token_close(struct adt_event_state *); 3337c478bd9Sstevel@tonic-gate extern void adt_generate_token(struct entry *, void *, 3347c478bd9Sstevel@tonic-gate struct adt_event_state *); 3357c478bd9Sstevel@tonic-gate extern void *adt_adjust_address(void *, size_t, size_t); 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3387c478bd9Sstevel@tonic-gate } 3397c478bd9Sstevel@tonic-gate #endif 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate #endif /* _BSM_XLATE_H */ 342