audit_record.h revision 155191
1155191Srwatson/* 2155191Srwatson * Copyright (c) 2005 Apple Computer, Inc. 3155191Srwatson * All rights reserved. 4155191Srwatson * 5155191Srwatson * @APPLE_BSD_LICENSE_HEADER_START@ 6155191Srwatson * 7155191Srwatson * Redistribution and use in source and binary forms, with or without 8155191Srwatson * modification, are permitted provided that the following conditions 9155191Srwatson * are met: 10155191Srwatson * 11155191Srwatson * 1. Redistributions of source code must retain the above copyright 12155191Srwatson * notice, this list of conditions and the following disclaimer. 13155191Srwatson * 2. Redistributions in binary form must reproduce the above copyright 14155191Srwatson * notice, this list of conditions and the following disclaimer in the 15155191Srwatson * documentation and/or other materials provided with the distribution. 16155191Srwatson * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 17155191Srwatson * its contributors may be used to endorse or promote products derived 18155191Srwatson * from this software without specific prior written permission. 19155191Srwatson * 20155191Srwatson * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 21155191Srwatson * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22155191Srwatson * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23155191Srwatson * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 24155191Srwatson * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25155191Srwatson * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26155191Srwatson * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27155191Srwatson * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28155191Srwatson * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29155191Srwatson * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30155191Srwatson * 31155191Srwatson * @APPLE_BSD_LICENSE_HEADER_END@ 32155191Srwatson * 33155191Srwatson * $P4: //depot/projects/trustedbsd/audit3/sys/bsm/audit_record.h#8 $ 34155191Srwatson * $FreeBSD: head/sys/bsm/audit_record.h 155191 2006-02-01 19:54:22Z rwatson $ 35155191Srwatson */ 36155191Srwatson 37155191Srwatson#ifndef _BSM_AUDIT_RECORD_H_ 38155191Srwatson#define _BSM_AUDIT_RECORD_H_ 39155191Srwatson 40155191Srwatson/* Various token id types */ 41155191Srwatson 42155191Srwatson/* 43155191Srwatson * Values inside the comments are not documented in the BSM pages and 44155191Srwatson * have been picked up from the header files 45155191Srwatson */ 46155191Srwatson 47155191Srwatson/* 48155191Srwatson * Values marked as XXX do not have a value defined in the BSM header files 49155191Srwatson */ 50155191Srwatson 51155191Srwatson#define AUT_INVALID 0x00 52155191Srwatson#define AUT_OTHER_FILE32 0x11 53155191Srwatson#define AUT_OHEADER 0x12 54155191Srwatson#define AUT_TRAILER 0x13 55155191Srwatson#define AUT_HEADER32 0x14 56155191Srwatson#define AUT_HEADER32_EX 0x15 57155191Srwatson#define AUT_DATA 0x21 58155191Srwatson#define AUT_IPC 0x22 59155191Srwatson#define AUT_PATH 0x23 60155191Srwatson#define AUT_SUBJECT32 0x24 61155191Srwatson#define AUT_SERVER32 0x25 62155191Srwatson#define AUT_PROCESS32 0x26 63155191Srwatson#define AUT_RETURN32 0x27 64155191Srwatson#define AUT_TEXT 0x28 65155191Srwatson#define AUT_OPAQUE 0x29 66155191Srwatson#define AUT_IN_ADDR 0x2a 67155191Srwatson#define AUT_IP 0x2b 68155191Srwatson#define AUT_IPORT 0x2c 69155191Srwatson#define AUT_ARG32 0x2d 70155191Srwatson#define AUT_SOCKET 0x2e 71155191Srwatson#define AUT_SEQ 0x2f 72155191Srwatson#define AUT_ACL 0x30 73155191Srwatson#define AUT_ATTR 0x31 74155191Srwatson#define AUT_IPC_PERM 0x32 75155191Srwatson#define AUT_LABEL 0x33 76155191Srwatson#define AUT_GROUPS 0x34 77155191Srwatson#define AUT_ILABEL 0x35 78155191Srwatson#define AUT_SLABEL 0x36 79155191Srwatson#define AUT_CLEAR 0x37 80155191Srwatson#define AUT_PRIV 0x38 81155191Srwatson#define AUT_UPRIV 0x39 82155191Srwatson#define AUT_LIAISON 0x3a 83155191Srwatson#define AUT_NEWGROUPS 0x3b 84155191Srwatson#define AUT_EXEC_ARGS 0x3c 85155191Srwatson#define AUT_EXEC_ENV 0x3d 86155191Srwatson#define AUT_ATTR32 0x3e 87155191Srwatson/* #define AUT_???? 0x3f */ 88155191Srwatson#define AUT_XATOM 0x40 89155191Srwatson#define AUT_XOBJ 0x41 90155191Srwatson#define AUT_XPROTO 0x42 91155191Srwatson#define AUT_XSELECT 0x43 92155191Srwatson/* XXXRW: Additional X11 tokens not defined? */ 93155191Srwatson#define AUT_CMD 0x51 94155191Srwatson#define AUT_EXIT 0x52 95155191Srwatson/* XXXRW: OpenBSM AUT_HOST 0x70? */ 96155191Srwatson#define AUT_ARG64 0x71 97155191Srwatson#define AUT_RETURN64 0x72 98155191Srwatson#define AUT_ATTR64 0x73 99155191Srwatson#define AUT_HEADER64 0x74 100155191Srwatson#define AUT_SUBJECT64 0x75 101155191Srwatson#define AUT_SERVER64 0x76 102155191Srwatson#define AUT_PROCESS64 0x77 103155191Srwatson#define AUT_OTHER_FILE64 0x78 104155191Srwatson#define AUT_HEADER64_EX 0x79 105155191Srwatson#define AUT_SUBJECT32_EX 0x7a 106155191Srwatson#define AUT_PROCESS32_EX 0x7b 107155191Srwatson#define AUT_SUBJECT64_EX 0x7c 108155191Srwatson#define AUT_PROCESS64_EX 0x7d 109155191Srwatson#define AUT_IN_ADDR_EX 0x7e 110155191Srwatson#define AUT_SOCKET_EX 0x7f 111155191Srwatson 112155191Srwatson/* 113155191Srwatson * Pre-64-bit BSM, 32-bit tokens weren't explicitly named as '32'. We have 114155191Srwatson * compatibility defines. 115155191Srwatson */ 116155191Srwatson#define AUT_HEADER AUT_HEADER32 117155191Srwatson#define AUT_ARG AUT_ARG32 118155191Srwatson#define AUT_RETURN AUT_RETURN32 119155191Srwatson#define AUT_SUBJECT AUT_SUBJECT32 120155191Srwatson#define AUT_SERVER AUT_SERVER32 121155191Srwatson#define AUT_PROCESS AUT_PROCESS32 122155191Srwatson#define AUT_OTHER_FILE AUT_OTHER_FILE32 123155191Srwatson 124155191Srwatson/* 125155191Srwatson * Darwin's bsm distribution uses the following non-BSM token name defines. 126155191Srwatson * We provide them for a single OpenBSM release for compatibility reasons. 127155191Srwatson */ 128155191Srwatson#define AU_FILE_TOKEN AUT_OTHER_FILE32 129155191Srwatson#define AU_TRAILER_TOKEN AUT_TRAILER 130155191Srwatson#define AU_HEADER_32_TOKEN AUT_HEADER32 131155191Srwatson#define AU_DATA_TOKEN AUT_DATA 132155191Srwatson#define AU_ARB_TOKEN AUT_DATA 133155191Srwatson#define AU_IPC_TOKEN AUT_IPC 134155191Srwatson#define AU_PATH_TOKEN AUT_PATH 135155191Srwatson#define AU_SUBJECT_32_TOKEN AUT_SUBJECT32 136155191Srwatson#define AU_PROCESS_32_TOKEN AUT_PROCESS32 137155191Srwatson#define AU_RETURN_32_TOKEN AUT_RETURN32 138155191Srwatson#define AU_TEXT_TOKEN AUT_TEXT 139155191Srwatson#define AU_OPAQUE_TOKEN AUT_OPAQUE 140155191Srwatson#define AU_IN_ADDR_TOKEN AUT_IN_ADDR 141155191Srwatson#define AU_IP_TOKEN AUT_IP 142155191Srwatson#define AU_IPORT_TOKEN AUT_IPORT 143155191Srwatson#define AU_ARG32_TOKEN AUT_ARG32 144155191Srwatson#define AU_SOCK_TOKEN AUT_SOCKET 145155191Srwatson#define AU_SEQ_TOKEN AUT_SEQ 146155191Srwatson#define AU_ATTR_TOKEN AUT_ATTR 147155191Srwatson#define AU_IPCPERM_TOKEN AUT_IPC_PERM 148155191Srwatson#define AU_NEWGROUPS_TOKEN AUT_NEWGROUPS 149155191Srwatson#define AU_EXEC_ARG_TOKEN AUT_EXEC_ARGS 150155191Srwatson#define AU_EXEC_ENV_TOKEN AUT_EXEC_ENV 151155191Srwatson#define AU_ATTR32_TOKEN AUT_ATTR32 152155191Srwatson#define AU_CMD_TOKEN AUT_CMD 153155191Srwatson#define AU_EXIT_TOKEN AUT_EXIT 154155191Srwatson#define AU_ARG64_TOKEN AUT_ARG64 155155191Srwatson#define AU_RETURN_64_TOKEN AUT_RETURN64 156155191Srwatson#define AU_ATTR64_TOKEN AUT_ATTR64 157155191Srwatson#define AU_HEADER_64_TOKEN AUT_HEADER64 158155191Srwatson#define AU_SUBJECT_64_TOKEN AUT_SUBJECT64 159155191Srwatson#define AU_PROCESS_64_TOKEN AUT_PROCESS64 160155191Srwatson#define AU_HEADER_64_EX_TOKEN AUT_HEADER64_EX 161155191Srwatson#define AU_SUBJECT_32_EX_TOKEN AUT_SUBJECT32_EX 162155191Srwatson#define AU_PROCESS_32_EX_TOKEN AUT_PROCESS32_EX 163155191Srwatson#define AU_SUBJECT_64_EX_TOKEN AUT_SUBJECT64_EX 164155191Srwatson#define AU_PROCESS_64_EX_TOKEN AUT_PROCESS64_EX 165155191Srwatson#define AU_IN_ADDR_EX_TOKEN AUT_IN_ADDR_EX 166155191Srwatson#define AU_SOCK_32_EX_TOKEN AUT_SOCKET_EX 167155191Srwatson 168155191Srwatson/* 169155191Srwatson * The values for the following token ids are not defined by BSM. 170155191Srwatson * 171155191Srwatson * XXXRW: Not sure how to handle these in OpenBSM yet, but I'll give them 172155191Srwatson * names more consistent with Sun's BSM. These originally came from Apple's 173155191Srwatson * BSM. 174155191Srwatson */ 175155191Srwatson#define AUT_SOCKINET32 0x80 /* XXX */ 176155191Srwatson#define AUT_SOCKINET128 0x81 /* XXX */ 177155191Srwatson#define AUT_SOCKUNIX 0x82 /* XXX */ 178155191Srwatson#define AU_SOCK_INET_32_TOKEN AUT_SOCKINET32 179155191Srwatson#define AU_SOCK_INET_128_TOKEN AUT_SOCKINET128 180155191Srwatson#define AU_SOCK_UNIX_TOKEN AUT_SOCKUNIX 181155191Srwatson 182155191Srwatson/* print values for the arbitrary token */ 183155191Srwatson#define AUP_BINARY 0 184155191Srwatson#define AUP_OCTAL 1 185155191Srwatson#define AUP_DECIMAL 2 186155191Srwatson#define AUP_HEX 3 187155191Srwatson#define AUP_STRING 4 188155191Srwatson 189155191Srwatson/* data-types for the arbitrary token */ 190155191Srwatson#define AUR_BYTE 0 191155191Srwatson#define AUR_SHORT 1 192155191Srwatson#define AUR_LONG 2 193155191Srwatson 194155191Srwatson/* ... and their sizes */ 195155191Srwatson#define AUR_BYTE_SIZE sizeof(u_char) 196155191Srwatson#define AUR_SHORT_SIZE sizeof(uint16_t) 197155191Srwatson#define AUR_LONG_SIZE sizeof(uint32_t) 198155191Srwatson 199155191Srwatson/* Modifiers for the header token */ 200155191Srwatson#define PAD_NOTATTR 0x4000 /* nonattributable event */ 201155191Srwatson#define PAD_FAILURE 0x8000 /* fail audit event */ 202155191Srwatson 203155191Srwatson 204155191Srwatson#define BSM_MAX_GROUPS 16 205155191Srwatson#define HEADER_VERSION 1 206155191Srwatson 207155191Srwatson/* 208155191Srwatson * BSM define is AUT_TRAILER_MAGIC; Apple BSM define is TRAILER_PAD_MAGIC; we 209155191Srwatson * split the difference, will remove the Apple define for the next release. 210155191Srwatson */ 211155191Srwatson#define AUT_TRAILER_MAGIC 0xb105 212155191Srwatson#define TRAILER_PAD_MAGIC AUT_TRAILER_MAGIC 213155191Srwatson 214155191Srwatson/* BSM library calls */ 215155191Srwatson 216155191Srwatson__BEGIN_DECLS 217155191Srwatson 218155191Srwatsonstruct in_addr; 219155191Srwatsonstruct in6_addr; 220155191Srwatsonstruct ip; 221155191Srwatsonstruct ipc_perm; 222155191Srwatsonstruct kevent; 223155191Srwatsonstruct sockaddr_in; 224155191Srwatsonstruct sockaddr_in6; 225155191Srwatsonstruct sockaddr_un; 226155191Srwatson#if defined(_KERNEL) || defined(KERNEL) 227155191Srwatsonstruct vnode_au_info; 228155191Srwatson#endif 229155191Srwatson 230155191Srwatsonint au_open(void); 231155191Srwatsonint au_write(int d, token_t *m); 232155191Srwatsonint au_close(int d, int keep, short event); 233155191Srwatsonint au_close_buffer(int d, short event, u_char *buffer, size_t *buflen); 234155191Srwatson 235155191Srwatson#if defined(KERNEL) || defined(_KERNEL) 236155191Srwatsontoken_t *au_to_file(char *file, struct timeval tm); 237155191Srwatson#else 238155191Srwatsontoken_t *au_to_file(char *file); 239155191Srwatson#endif 240155191Srwatson 241155191Srwatson#if defined(KERNEL) || defined(_KERNEL) 242155191Srwatsontoken_t *au_to_header(int rec_size, au_event_t e_type, au_emod_t e_mod, 243155191Srwatson struct timeval tm); 244155191Srwatsontoken_t *au_to_header32(int rec_size, au_event_t e_type, au_emod_t e_mod, 245155191Srwatson struct timeval tm); 246155191Srwatson#else 247155191Srwatsontoken_t *au_to_header(int rec_size, au_event_t e_type, au_emod_t e_mod); 248155191Srwatsontoken_t *au_to_header32(int rec_size, au_event_t e_type, au_emod_t e_mod); 249155191Srwatson#endif 250155191Srwatson 251155191Srwatsontoken_t *au_to_header64(int rec_size, au_event_t e_type, au_emod_t e_mod); 252155191Srwatsontoken_t *au_to_me(void); 253155191Srwatsontoken_t *au_to_arg(char n, char *text, uint32_t v); 254155191Srwatsontoken_t *au_to_arg32(char n, char *text, uint32_t v); 255155191Srwatsontoken_t *au_to_arg64(char n, char *text, uint64_t v); 256155191Srwatson 257155191Srwatson#if defined(_KERNEL) || defined(KERNEL) 258155191Srwatsontoken_t *au_to_attr(struct vnode_au_info *vni); 259155191Srwatsontoken_t *au_to_attr32(struct vnode_au_info *vni); 260155191Srwatsontoken_t *au_to_attr64(struct vnode_au_info *vni); 261155191Srwatson#endif 262155191Srwatson 263155191Srwatsontoken_t *au_to_data(char unit_print, char unit_type, char unit_count, 264155191Srwatson char *p); 265155191Srwatsontoken_t *au_to_exit(int retval, int err); 266155191Srwatsontoken_t *au_to_groups(int *groups); 267155191Srwatsontoken_t *au_to_newgroups(uint16_t n, gid_t *groups); 268155191Srwatsontoken_t *au_to_in_addr(struct in_addr *internet_addr); 269155191Srwatsontoken_t *au_to_in_addr_ex(struct in6_addr *internet_addr); 270155191Srwatsontoken_t *au_to_ip(struct ip *ip); 271155191Srwatsontoken_t *au_to_ipc(char type, int id); 272155191Srwatsontoken_t *au_to_ipc_perm(struct ipc_perm *perm); 273155191Srwatsontoken_t *au_to_iport(uint16_t iport); 274155191Srwatsontoken_t *au_to_opaque(char *data, uint16_t bytes); 275155191Srwatsontoken_t *au_to_path(char *path); 276155191Srwatsontoken_t *au_to_process(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 277155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); 278155191Srwatsontoken_t *au_to_process32(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 279155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); 280155191Srwatsontoken_t *au_to_process64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 281155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); 282155191Srwatsontoken_t *au_to_process_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 283155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); 284155191Srwatsontoken_t *au_to_process32_ex(au_id_t auid, uid_t euid, gid_t egid, 285155191Srwatson uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, 286155191Srwatson au_tid_addr_t *tid); 287155191Srwatsontoken_t *au_to_process64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 288155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); 289155191Srwatsontoken_t *au_to_return(char status, uint32_t ret); 290155191Srwatsontoken_t *au_to_return32(char status, uint32_t ret); 291155191Srwatsontoken_t *au_to_return64(char status, uint64_t ret); 292155191Srwatsontoken_t *au_to_seq(long audit_count); 293155191Srwatson 294155191Srwatson#if defined(_KERNEL) || defined(KERNEL) 295155191Srwatsontoken_t *au_to_socket(struct socket *so); 296155191Srwatsontoken_t *au_to_socket_ex_32(uint16_t lp, uint16_t rp, struct sockaddr *la, 297155191Srwatson struct sockaddr *ta); 298155191Srwatsontoken_t *au_to_socket_ex_128(uint16_t lp, uint16_t rp, struct sockaddr *la, 299155191Srwatson struct sockaddr *ta); 300155191Srwatson#endif 301155191Srwatson 302155191Srwatsontoken_t *au_to_sock_inet(struct sockaddr_in *so); 303155191Srwatsontoken_t *au_to_sock_inet32(struct sockaddr_in *so); 304155191Srwatsontoken_t *au_to_sock_inet128(struct sockaddr_in6 *so); 305155191Srwatsontoken_t *au_to_sock_unix(struct sockaddr_un *so); 306155191Srwatsontoken_t *au_to_subject(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 307155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); 308155191Srwatsontoken_t *au_to_subject32(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 309155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); 310155191Srwatsontoken_t *au_to_subject64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 311155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); 312155191Srwatsontoken_t *au_to_subject_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 313155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); 314155191Srwatsontoken_t *au_to_subject32_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 315155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); 316155191Srwatsontoken_t *au_to_subject64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, 317155191Srwatson gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); 318155191Srwatsontoken_t *au_to_exec_args(const char **); 319155191Srwatsontoken_t *au_to_exec_env(const char **); 320155191Srwatsontoken_t *au_to_text(char *text); 321155191Srwatsontoken_t *au_to_kevent(struct kevent *kev); 322155191Srwatsontoken_t *au_to_trailer(int rec_size); 323155191Srwatson 324155191Srwatson__END_DECLS 325155191Srwatson 326155191Srwatson#endif /* ! _BSM_AUDIT_RECORD_H_ */ 327