152267f74SRobert Watson /*- 206edd2f1SRobert Watson * Copyright (c) 2004-2009 Apple Inc. 3ca0716f5SRobert Watson * All rights reserved. 4ca0716f5SRobert Watson * 5ca0716f5SRobert Watson * Redistribution and use in source and binary forms, with or without 6ca0716f5SRobert Watson * modification, are permitted provided that the following conditions 7ca0716f5SRobert Watson * are met: 8ca0716f5SRobert Watson * 1. Redistributions of source code must retain the above copyright 9ca0716f5SRobert Watson * notice, this list of conditions and the following disclaimer. 10ca0716f5SRobert Watson * 2. Redistributions in binary form must reproduce the above copyright 11ca0716f5SRobert Watson * notice, this list of conditions and the following disclaimer in the 12ca0716f5SRobert Watson * documentation and/or other materials provided with the distribution. 1352267f74SRobert Watson * 3. Neither the name of Apple Inc. ("Apple") nor the names of 14ca0716f5SRobert Watson * its contributors may be used to endorse or promote products derived 15ca0716f5SRobert Watson * from this software without specific prior written permission. 16ca0716f5SRobert Watson * 17ca0716f5SRobert Watson * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND 18ca0716f5SRobert Watson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19ca0716f5SRobert Watson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20ca0716f5SRobert Watson * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR 21ca0716f5SRobert Watson * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22ca0716f5SRobert Watson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23ca0716f5SRobert Watson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24ca0716f5SRobert Watson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25ca0716f5SRobert Watson * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26ca0716f5SRobert Watson * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ca0716f5SRobert Watson * POSSIBILITY OF SUCH DAMAGE. 28ca0716f5SRobert Watson */ 29ca0716f5SRobert Watson 30ca0716f5SRobert Watson #ifndef _LIBBSM_H_ 31ca0716f5SRobert Watson #define _LIBBSM_H_ 32ca0716f5SRobert Watson 33ca0716f5SRobert Watson /* 34ca0716f5SRobert Watson * NB: definitions, etc., marked with "OpenSSH compatibility" were introduced 35ca0716f5SRobert Watson * solely to allow OpenSSH to compile; Darwin/Apple code should not use them. 36ca0716f5SRobert Watson */ 37ca0716f5SRobert Watson 38ca0716f5SRobert Watson #include <sys/types.h> 39ca0716f5SRobert Watson #include <sys/cdefs.h> 40ca0716f5SRobert Watson 41d9af45c4SRobert Watson #include <inttypes.h> /* Required for audit.h. */ 423b97a967SRobert Watson #include <time.h> /* Required for clock_t on Linux. */ 43f4e380b0SRobert Watson 44ca0716f5SRobert Watson #include <bsm/audit.h> 45ca0716f5SRobert Watson #include <bsm/audit_record.h> 46ca0716f5SRobert Watson 47ca0716f5SRobert Watson #include <stdio.h> 48ca0716f5SRobert Watson 49ca0716f5SRobert Watson #ifdef __APPLE__ 50ca0716f5SRobert Watson #include <mach/mach.h> /* audit_token_t */ 51ca0716f5SRobert Watson #endif 52ca0716f5SRobert Watson 53bb97b418SRobert Watson /* 54bb97b418SRobert Watson * Size parsed token vectors for execve(2) arguments and environmental 55bb97b418SRobert Watson * variables. Note: changing these sizes affects the ABI of the token 56bb97b418SRobert Watson * structure, and as the token structure is often placed in the caller stack, 57bb97b418SRobert Watson * this is undesirable. 58bb97b418SRobert Watson */ 59bb97b418SRobert Watson #define AUDIT_MAX_ARGS 128 60bb97b418SRobert Watson #define AUDIT_MAX_ENV 128 61bb97b418SRobert Watson 62bb97b418SRobert Watson /* 63bb97b418SRobert Watson * Arguments to au_preselect(3). 64bb97b418SRobert Watson */ 65bb97b418SRobert Watson #define AU_PRS_USECACHE 0 66bb97b418SRobert Watson #define AU_PRS_REREAD 1 67bb97b418SRobert Watson 68ca0716f5SRobert Watson #define AU_PRS_SUCCESS 1 69ca0716f5SRobert Watson #define AU_PRS_FAILURE 2 70ca0716f5SRobert Watson #define AU_PRS_BOTH (AU_PRS_SUCCESS|AU_PRS_FAILURE) 71ca0716f5SRobert Watson 72ca0716f5SRobert Watson #define AUDIT_EVENT_FILE "/etc/security/audit_event" 73ca0716f5SRobert Watson #define AUDIT_CLASS_FILE "/etc/security/audit_class" 74ca0716f5SRobert Watson #define AUDIT_CONTROL_FILE "/etc/security/audit_control" 75ca0716f5SRobert Watson #define AUDIT_USER_FILE "/etc/security/audit_user" 76ca0716f5SRobert Watson 77ca0716f5SRobert Watson #define DIR_CONTROL_ENTRY "dir" 78aa772005SRobert Watson #define DIST_CONTROL_ENTRY "dist" 794bd0c025SRobert Watson #define FILESZ_CONTROL_ENTRY "filesz" 80ca0716f5SRobert Watson #define FLAGS_CONTROL_ENTRY "flags" 81aa772005SRobert Watson #define HOST_CONTROL_ENTRY "host" 82aa772005SRobert Watson #define MINFREE_CONTROL_ENTRY "minfree" 83ca0716f5SRobert Watson #define NA_CONTROL_ENTRY "naflags" 84bb97b418SRobert Watson #define POLICY_CONTROL_ENTRY "policy" 8506edd2f1SRobert Watson #define EXPIRE_AFTER_CONTROL_ENTRY "expire-after" 86*5e386598SRobert Watson #define QSZ_CONTROL_ENTRY "qsize" 87ca0716f5SRobert Watson 88ca0716f5SRobert Watson #define AU_CLASS_NAME_MAX 8 89ca0716f5SRobert Watson #define AU_CLASS_DESC_MAX 72 90ca0716f5SRobert Watson #define AU_EVENT_NAME_MAX 30 91ca0716f5SRobert Watson #define AU_EVENT_DESC_MAX 50 92ca0716f5SRobert Watson #define AU_USER_NAME_MAX 50 93ca0716f5SRobert Watson #define AU_LINE_MAX 256 94ca0716f5SRobert Watson #define MAX_AUDITSTRING_LEN 256 95ca0716f5SRobert Watson #define BSM_TEXTBUFSZ MAX_AUDITSTRING_LEN /* OpenSSH compatibility */ 96ca0716f5SRobert Watson 97*5e386598SRobert Watson #define USE_DEFAULT_QSZ -1 /* Use system default queue size */ 98*5e386598SRobert Watson 99ca0716f5SRobert Watson /* 10022ccb20dSRobert Watson * Arguments to au_close(3). 101ca0716f5SRobert Watson */ 10222ccb20dSRobert Watson #define AU_TO_NO_WRITE 0 /* Abandon audit record. */ 10322ccb20dSRobert Watson #define AU_TO_WRITE 1 /* Commit audit record. */ 104ca0716f5SRobert Watson 105aa772005SRobert Watson /* 106aa772005SRobert Watson * Output format flags for au_print_flags_tok(). 107aa772005SRobert Watson */ 108aa772005SRobert Watson #define AU_OFLAG_NONE 0x0000 /* Default form. */ 109aa772005SRobert Watson #define AU_OFLAG_RAW 0x0001 /* Raw, numeric form. */ 110aa772005SRobert Watson #define AU_OFLAG_SHORT 0x0002 /* Short form. */ 111aa772005SRobert Watson #define AU_OFLAG_XML 0x0004 /* XML form. */ 112aa772005SRobert Watson #define AU_OFLAG_NORESOLVE 0x0008 /* No user/group name resolution. */ 113aa772005SRobert Watson 114ca0716f5SRobert Watson __BEGIN_DECLS 115ca0716f5SRobert Watson struct au_event_ent { 116ca0716f5SRobert Watson au_event_t ae_number; 117ca0716f5SRobert Watson char *ae_name; 118ca0716f5SRobert Watson char *ae_desc; 119ca0716f5SRobert Watson au_class_t ae_class; 120ca0716f5SRobert Watson }; 121ca0716f5SRobert Watson typedef struct au_event_ent au_event_ent_t; 122ca0716f5SRobert Watson 123ca0716f5SRobert Watson struct au_class_ent { 124ca0716f5SRobert Watson char *ac_name; 125ca0716f5SRobert Watson au_class_t ac_class; 126ca0716f5SRobert Watson char *ac_desc; 127ca0716f5SRobert Watson }; 128ca0716f5SRobert Watson typedef struct au_class_ent au_class_ent_t; 129ca0716f5SRobert Watson 130ca0716f5SRobert Watson struct au_user_ent { 131ca0716f5SRobert Watson char *au_name; 132ca0716f5SRobert Watson au_mask_t au_always; 133ca0716f5SRobert Watson au_mask_t au_never; 134ca0716f5SRobert Watson }; 135ca0716f5SRobert Watson typedef struct au_user_ent au_user_ent_t; 136ca0716f5SRobert Watson __END_DECLS 137ca0716f5SRobert Watson 138ca0716f5SRobert Watson #define ADD_TO_MASK(m, c, sel) do { \ 139ca0716f5SRobert Watson if (sel & AU_PRS_SUCCESS) \ 140ca0716f5SRobert Watson (m)->am_success |= c; \ 141ca0716f5SRobert Watson if (sel & AU_PRS_FAILURE) \ 142ca0716f5SRobert Watson (m)->am_failure |= c; \ 143ca0716f5SRobert Watson } while (0) 144ca0716f5SRobert Watson 145ca0716f5SRobert Watson #define SUB_FROM_MASK(m, c, sel) do { \ 146ca0716f5SRobert Watson if (sel & AU_PRS_SUCCESS) \ 147ca0716f5SRobert Watson (m)->am_success &= ((m)->am_success ^ c); \ 148ca0716f5SRobert Watson if (sel & AU_PRS_FAILURE) \ 149ca0716f5SRobert Watson (m)->am_failure &= ((m)->am_failure ^ c); \ 150ca0716f5SRobert Watson } while (0) 151ca0716f5SRobert Watson 152ca0716f5SRobert Watson #define ADDMASK(m, v) do { \ 153ca0716f5SRobert Watson (m)->am_success |= (v)->am_success; \ 154ca0716f5SRobert Watson (m)->am_failure |= (v)->am_failure; \ 155ca0716f5SRobert Watson } while(0) 156ca0716f5SRobert Watson 157ca0716f5SRobert Watson #define SUBMASK(m, v) do { \ 158ca0716f5SRobert Watson (m)->am_success &= ((m)->am_success ^ (v)->am_success); \ 159ca0716f5SRobert Watson (m)->am_failure &= ((m)->am_failure ^ (v)->am_failure); \ 160ca0716f5SRobert Watson } while(0) 161ca0716f5SRobert Watson 162ca0716f5SRobert Watson __BEGIN_DECLS 163ca0716f5SRobert Watson 164ca0716f5SRobert Watson typedef struct au_tid32 { 165ca0716f5SRobert Watson u_int32_t port; 166ca0716f5SRobert Watson u_int32_t addr; 167ca0716f5SRobert Watson } au_tid32_t; 168ca0716f5SRobert Watson 169ca0716f5SRobert Watson typedef struct au_tid64 { 170ca0716f5SRobert Watson u_int64_t port; 171ca0716f5SRobert Watson u_int32_t addr; 172ca0716f5SRobert Watson } au_tid64_t; 173ca0716f5SRobert Watson 174ca0716f5SRobert Watson typedef struct au_tidaddr32 { 175ca0716f5SRobert Watson u_int32_t port; 176ca0716f5SRobert Watson u_int32_t type; 177ca0716f5SRobert Watson u_int32_t addr[4]; 178ca0716f5SRobert Watson } au_tidaddr32_t; 179ca0716f5SRobert Watson 180bc168a6cSRobert Watson typedef struct au_tidaddr64 { 181bc168a6cSRobert Watson u_int64_t port; 182bc168a6cSRobert Watson u_int32_t type; 183bc168a6cSRobert Watson u_int32_t addr[4]; 184bc168a6cSRobert Watson } au_tidaddr64_t; 185bc168a6cSRobert Watson 186ca0716f5SRobert Watson /* 187ca0716f5SRobert Watson * argument # 1 byte 188ca0716f5SRobert Watson * argument value 4 bytes/8 bytes (32-bit/64-bit value) 189ca0716f5SRobert Watson * text length 2 bytes 190ca0716f5SRobert Watson * text N bytes + 1 terminating NULL byte 191ca0716f5SRobert Watson */ 192ca0716f5SRobert Watson typedef struct { 193ca0716f5SRobert Watson u_char no; 194ca0716f5SRobert Watson u_int32_t val; 195ca0716f5SRobert Watson u_int16_t len; 196ca0716f5SRobert Watson char *text; 197ca0716f5SRobert Watson } au_arg32_t; 198ca0716f5SRobert Watson 199ca0716f5SRobert Watson typedef struct { 200ca0716f5SRobert Watson u_char no; 201ca0716f5SRobert Watson u_int64_t val; 202ca0716f5SRobert Watson u_int16_t len; 203ca0716f5SRobert Watson char *text; 204ca0716f5SRobert Watson } au_arg64_t; 205ca0716f5SRobert Watson 206ca0716f5SRobert Watson /* 207ca0716f5SRobert Watson * how to print 1 byte 208ca0716f5SRobert Watson * basic unit 1 byte 209ca0716f5SRobert Watson * unit count 1 byte 210ca0716f5SRobert Watson * data items (depends on basic unit) 211ca0716f5SRobert Watson */ 212ca0716f5SRobert Watson typedef struct { 213ca0716f5SRobert Watson u_char howtopr; 214ca0716f5SRobert Watson u_char bu; 215ca0716f5SRobert Watson u_char uc; 216ca0716f5SRobert Watson u_char *data; 217ca0716f5SRobert Watson } au_arb_t; 218ca0716f5SRobert Watson 219ca0716f5SRobert Watson /* 220ca0716f5SRobert Watson * file access mode 4 bytes 221ca0716f5SRobert Watson * owner user ID 4 bytes 222ca0716f5SRobert Watson * owner group ID 4 bytes 223ca0716f5SRobert Watson * file system ID 4 bytes 224ca0716f5SRobert Watson * node ID 8 bytes 225ca0716f5SRobert Watson * device 4 bytes/8 bytes (32-bit/64-bit) 226ca0716f5SRobert Watson */ 227ca0716f5SRobert Watson typedef struct { 228ca0716f5SRobert Watson u_int32_t mode; 229ca0716f5SRobert Watson u_int32_t uid; 230ca0716f5SRobert Watson u_int32_t gid; 231ca0716f5SRobert Watson u_int32_t fsid; 232ca0716f5SRobert Watson u_int64_t nid; 233ca0716f5SRobert Watson u_int32_t dev; 234ca0716f5SRobert Watson } au_attr32_t; 235ca0716f5SRobert Watson 236ca0716f5SRobert Watson typedef struct { 237ca0716f5SRobert Watson u_int32_t mode; 238ca0716f5SRobert Watson u_int32_t uid; 239ca0716f5SRobert Watson u_int32_t gid; 240ca0716f5SRobert Watson u_int32_t fsid; 241ca0716f5SRobert Watson u_int64_t nid; 242ca0716f5SRobert Watson u_int64_t dev; 243ca0716f5SRobert Watson } au_attr64_t; 244ca0716f5SRobert Watson 245ca0716f5SRobert Watson /* 246ca0716f5SRobert Watson * count 4 bytes 247ca0716f5SRobert Watson * text count null-terminated string(s) 248ca0716f5SRobert Watson */ 249ca0716f5SRobert Watson typedef struct { 250ca0716f5SRobert Watson u_int32_t count; 25122ccb20dSRobert Watson char *text[AUDIT_MAX_ARGS]; 252ca0716f5SRobert Watson } au_execarg_t; 253ca0716f5SRobert Watson 254ca0716f5SRobert Watson /* 255ca0716f5SRobert Watson * count 4 bytes 256ca0716f5SRobert Watson * text count null-terminated string(s) 257ca0716f5SRobert Watson */ 258ca0716f5SRobert Watson typedef struct { 259ca0716f5SRobert Watson u_int32_t count; 26022ccb20dSRobert Watson char *text[AUDIT_MAX_ENV]; 261ca0716f5SRobert Watson } au_execenv_t; 262ca0716f5SRobert Watson 263ca0716f5SRobert Watson /* 264ca0716f5SRobert Watson * status 4 bytes 265ca0716f5SRobert Watson * return value 4 bytes 266ca0716f5SRobert Watson */ 267ca0716f5SRobert Watson typedef struct { 268ca0716f5SRobert Watson u_int32_t status; 269ca0716f5SRobert Watson u_int32_t ret; 270ca0716f5SRobert Watson } au_exit_t; 271ca0716f5SRobert Watson 272ca0716f5SRobert Watson /* 273ca0716f5SRobert Watson * seconds of time 4 bytes 274ca0716f5SRobert Watson * milliseconds of time 4 bytes 275ca0716f5SRobert Watson * file name length 2 bytes 276ca0716f5SRobert Watson * file pathname N bytes + 1 terminating NULL byte 277ca0716f5SRobert Watson */ 278ca0716f5SRobert Watson typedef struct { 279ca0716f5SRobert Watson u_int32_t s; 280ca0716f5SRobert Watson u_int32_t ms; 281ca0716f5SRobert Watson u_int16_t len; 282ca0716f5SRobert Watson char *name; 283ca0716f5SRobert Watson } au_file_t; 284ca0716f5SRobert Watson 285ca0716f5SRobert Watson 286ca0716f5SRobert Watson /* 287ca0716f5SRobert Watson * number groups 2 bytes 288ca0716f5SRobert Watson * group list N * 4 bytes 289ca0716f5SRobert Watson */ 290ca0716f5SRobert Watson typedef struct { 291ca0716f5SRobert Watson u_int16_t no; 29222ccb20dSRobert Watson u_int32_t list[AUDIT_MAX_GROUPS]; 293ca0716f5SRobert Watson } au_groups_t; 294ca0716f5SRobert Watson 295ca0716f5SRobert Watson /* 296ca0716f5SRobert Watson * record byte count 4 bytes 297ca0716f5SRobert Watson * version # 1 byte [2] 298ca0716f5SRobert Watson * event type 2 bytes 299ca0716f5SRobert Watson * event modifier 2 bytes 300ca0716f5SRobert Watson * seconds of time 4 bytes/8 bytes (32-bit/64-bit value) 301ca0716f5SRobert Watson * milliseconds of time 4 bytes/8 bytes (32-bit/64-bit value) 302ca0716f5SRobert Watson */ 303ca0716f5SRobert Watson typedef struct { 304ca0716f5SRobert Watson u_int32_t size; 305ca0716f5SRobert Watson u_char version; 306ca0716f5SRobert Watson u_int16_t e_type; 307ca0716f5SRobert Watson u_int16_t e_mod; 308ca0716f5SRobert Watson u_int32_t s; 309ca0716f5SRobert Watson u_int32_t ms; 310ca0716f5SRobert Watson } au_header32_t; 311ca0716f5SRobert Watson 312ca0716f5SRobert Watson /* 313ca0716f5SRobert Watson * record byte count 4 bytes 314ca0716f5SRobert Watson * version # 1 byte [2] 315ca0716f5SRobert Watson * event type 2 bytes 316ca0716f5SRobert Watson * event modifier 2 bytes 317ca0716f5SRobert Watson * address type/length 1 byte (XXX: actually, 4 bytes) 318ca0716f5SRobert Watson * machine address 4 bytes/16 bytes (IPv4/IPv6 address) 319ca0716f5SRobert Watson * seconds of time 4 bytes/8 bytes (32/64-bits) 320ca0716f5SRobert Watson * nanoseconds of time 4 bytes/8 bytes (32/64-bits) 321ca0716f5SRobert Watson */ 322ca0716f5SRobert Watson typedef struct { 323ca0716f5SRobert Watson u_int32_t size; 324ca0716f5SRobert Watson u_char version; 325ca0716f5SRobert Watson u_int16_t e_type; 326ca0716f5SRobert Watson u_int16_t e_mod; 327ca0716f5SRobert Watson u_int32_t ad_type; 328ca0716f5SRobert Watson u_int32_t addr[4]; 329ca0716f5SRobert Watson u_int32_t s; 330ca0716f5SRobert Watson u_int32_t ms; 331ca0716f5SRobert Watson } au_header32_ex_t; 332ca0716f5SRobert Watson 333ca0716f5SRobert Watson typedef struct { 334ca0716f5SRobert Watson u_int32_t size; 335ca0716f5SRobert Watson u_char version; 336ca0716f5SRobert Watson u_int16_t e_type; 337ca0716f5SRobert Watson u_int16_t e_mod; 338ca0716f5SRobert Watson u_int64_t s; 339ca0716f5SRobert Watson u_int64_t ms; 340ca0716f5SRobert Watson } au_header64_t; 341ca0716f5SRobert Watson 342ca0716f5SRobert Watson typedef struct { 343ca0716f5SRobert Watson u_int32_t size; 344ca0716f5SRobert Watson u_char version; 345ca0716f5SRobert Watson u_int16_t e_type; 346ca0716f5SRobert Watson u_int16_t e_mod; 347ca0716f5SRobert Watson u_int32_t ad_type; 348ca0716f5SRobert Watson u_int32_t addr[4]; 349ca0716f5SRobert Watson u_int64_t s; 350ca0716f5SRobert Watson u_int64_t ms; 351ca0716f5SRobert Watson } au_header64_ex_t; 352ca0716f5SRobert Watson 353ca0716f5SRobert Watson /* 354ca0716f5SRobert Watson * internet address 4 bytes 355ca0716f5SRobert Watson */ 356ca0716f5SRobert Watson typedef struct { 357ca0716f5SRobert Watson u_int32_t addr; 358ca0716f5SRobert Watson } au_inaddr_t; 359ca0716f5SRobert Watson 360ca0716f5SRobert Watson /* 361ca0716f5SRobert Watson * type 4 bytes 362ca0716f5SRobert Watson * internet address 16 bytes 363ca0716f5SRobert Watson */ 364ca0716f5SRobert Watson typedef struct { 365ca0716f5SRobert Watson u_int32_t type; 366ca0716f5SRobert Watson u_int32_t addr[4]; 367ca0716f5SRobert Watson } au_inaddr_ex_t; 368ca0716f5SRobert Watson 369ca0716f5SRobert Watson /* 370ca0716f5SRobert Watson * version and ihl 1 byte 371ca0716f5SRobert Watson * type of service 1 byte 372ca0716f5SRobert Watson * length 2 bytes 373ca0716f5SRobert Watson * id 2 bytes 374ca0716f5SRobert Watson * offset 2 bytes 375ca0716f5SRobert Watson * ttl 1 byte 376ca0716f5SRobert Watson * protocol 1 byte 377ca0716f5SRobert Watson * checksum 2 bytes 378ca0716f5SRobert Watson * source address 4 bytes 379ca0716f5SRobert Watson * destination address 4 bytes 380ca0716f5SRobert Watson */ 381ca0716f5SRobert Watson typedef struct { 382ca0716f5SRobert Watson u_char version; 383ca0716f5SRobert Watson u_char tos; 384ca0716f5SRobert Watson u_int16_t len; 385ca0716f5SRobert Watson u_int16_t id; 386ca0716f5SRobert Watson u_int16_t offset; 387ca0716f5SRobert Watson u_char ttl; 388ca0716f5SRobert Watson u_char prot; 389ca0716f5SRobert Watson u_int16_t chksm; 390ca0716f5SRobert Watson u_int32_t src; 391ca0716f5SRobert Watson u_int32_t dest; 392ca0716f5SRobert Watson } au_ip_t; 393ca0716f5SRobert Watson 394ca0716f5SRobert Watson /* 395ca0716f5SRobert Watson * object ID type 1 byte 396ca0716f5SRobert Watson * object ID 4 bytes 397ca0716f5SRobert Watson */ 398ca0716f5SRobert Watson typedef struct { 399ca0716f5SRobert Watson u_char type; 400ca0716f5SRobert Watson u_int32_t id; 401ca0716f5SRobert Watson } au_ipc_t; 402ca0716f5SRobert Watson 403ca0716f5SRobert Watson /* 404ca0716f5SRobert Watson * owner user ID 4 bytes 405ca0716f5SRobert Watson * owner group ID 4 bytes 406ca0716f5SRobert Watson * creator user ID 4 bytes 407ca0716f5SRobert Watson * creator group ID 4 bytes 408ca0716f5SRobert Watson * access mode 4 bytes 409ca0716f5SRobert Watson * slot sequence # 4 bytes 410ca0716f5SRobert Watson * key 4 bytes 411ca0716f5SRobert Watson */ 412ca0716f5SRobert Watson typedef struct { 413ca0716f5SRobert Watson u_int32_t uid; 414ca0716f5SRobert Watson u_int32_t gid; 415ca0716f5SRobert Watson u_int32_t puid; 416ca0716f5SRobert Watson u_int32_t pgid; 417ca0716f5SRobert Watson u_int32_t mode; 418ca0716f5SRobert Watson u_int32_t seq; 419ca0716f5SRobert Watson u_int32_t key; 420ca0716f5SRobert Watson } au_ipcperm_t; 421ca0716f5SRobert Watson 422ca0716f5SRobert Watson /* 423ca0716f5SRobert Watson * port IP address 2 bytes 424ca0716f5SRobert Watson */ 425ca0716f5SRobert Watson typedef struct { 426ca0716f5SRobert Watson u_int16_t port; 427ca0716f5SRobert Watson } au_iport_t; 428ca0716f5SRobert Watson 429ca0716f5SRobert Watson /* 430ca0716f5SRobert Watson * length 2 bytes 431ca0716f5SRobert Watson * data length bytes 432ca0716f5SRobert Watson */ 433ca0716f5SRobert Watson typedef struct { 434ca0716f5SRobert Watson u_int16_t size; 435ca0716f5SRobert Watson char *data; 436ca0716f5SRobert Watson } au_opaque_t; 437ca0716f5SRobert Watson 438ca0716f5SRobert Watson /* 439ca0716f5SRobert Watson * path length 2 bytes 440ca0716f5SRobert Watson * path N bytes + 1 terminating NULL byte 441ca0716f5SRobert Watson */ 442ca0716f5SRobert Watson typedef struct { 443ca0716f5SRobert Watson u_int16_t len; 444ca0716f5SRobert Watson char *path; 445ca0716f5SRobert Watson } au_path_t; 446ca0716f5SRobert Watson 447ca0716f5SRobert Watson /* 448ca0716f5SRobert Watson * audit ID 4 bytes 449ca0716f5SRobert Watson * effective user ID 4 bytes 450ca0716f5SRobert Watson * effective group ID 4 bytes 451ca0716f5SRobert Watson * real user ID 4 bytes 452ca0716f5SRobert Watson * real group ID 4 bytes 453ca0716f5SRobert Watson * process ID 4 bytes 454ca0716f5SRobert Watson * session ID 4 bytes 455ca0716f5SRobert Watson * terminal ID 456ca0716f5SRobert Watson * port ID 4 bytes/8 bytes (32-bit/64-bit value) 457ca0716f5SRobert Watson * machine address 4 bytes 458ca0716f5SRobert Watson */ 459ca0716f5SRobert Watson typedef struct { 460ca0716f5SRobert Watson u_int32_t auid; 461ca0716f5SRobert Watson u_int32_t euid; 462ca0716f5SRobert Watson u_int32_t egid; 463ca0716f5SRobert Watson u_int32_t ruid; 464ca0716f5SRobert Watson u_int32_t rgid; 465ca0716f5SRobert Watson u_int32_t pid; 466ca0716f5SRobert Watson u_int32_t sid; 467ca0716f5SRobert Watson au_tid32_t tid; 468ca0716f5SRobert Watson } au_proc32_t; 469ca0716f5SRobert Watson 470ca0716f5SRobert Watson typedef struct { 471ca0716f5SRobert Watson u_int32_t auid; 472ca0716f5SRobert Watson u_int32_t euid; 473ca0716f5SRobert Watson u_int32_t egid; 474ca0716f5SRobert Watson u_int32_t ruid; 475ca0716f5SRobert Watson u_int32_t rgid; 476ca0716f5SRobert Watson u_int32_t pid; 477ca0716f5SRobert Watson u_int32_t sid; 478ca0716f5SRobert Watson au_tid64_t tid; 479ca0716f5SRobert Watson } au_proc64_t; 480ca0716f5SRobert Watson 481ca0716f5SRobert Watson /* 482ca0716f5SRobert Watson * audit ID 4 bytes 483ca0716f5SRobert Watson * effective user ID 4 bytes 484ca0716f5SRobert Watson * effective group ID 4 bytes 485ca0716f5SRobert Watson * real user ID 4 bytes 486ca0716f5SRobert Watson * real group ID 4 bytes 487ca0716f5SRobert Watson * process ID 4 bytes 488ca0716f5SRobert Watson * session ID 4 bytes 489ca0716f5SRobert Watson * terminal ID 490ca0716f5SRobert Watson * port ID 4 bytes/8 bytes (32-bit/64-bit value) 491ca0716f5SRobert Watson * type 4 bytes 492ca0716f5SRobert Watson * machine address 16 bytes 493ca0716f5SRobert Watson */ 494ca0716f5SRobert Watson typedef struct { 495ca0716f5SRobert Watson u_int32_t auid; 496ca0716f5SRobert Watson u_int32_t euid; 497ca0716f5SRobert Watson u_int32_t egid; 498ca0716f5SRobert Watson u_int32_t ruid; 499ca0716f5SRobert Watson u_int32_t rgid; 500ca0716f5SRobert Watson u_int32_t pid; 501ca0716f5SRobert Watson u_int32_t sid; 502ca0716f5SRobert Watson au_tidaddr32_t tid; 503ca0716f5SRobert Watson } au_proc32ex_t; 504ca0716f5SRobert Watson 505bc168a6cSRobert Watson typedef struct { 506bc168a6cSRobert Watson u_int32_t auid; 507bc168a6cSRobert Watson u_int32_t euid; 508bc168a6cSRobert Watson u_int32_t egid; 509bc168a6cSRobert Watson u_int32_t ruid; 510bc168a6cSRobert Watson u_int32_t rgid; 511bc168a6cSRobert Watson u_int32_t pid; 512bc168a6cSRobert Watson u_int32_t sid; 513bc168a6cSRobert Watson au_tidaddr64_t tid; 514bc168a6cSRobert Watson } au_proc64ex_t; 515bc168a6cSRobert Watson 516ca0716f5SRobert Watson /* 517ca0716f5SRobert Watson * error status 1 byte 518ca0716f5SRobert Watson * return value 4 bytes/8 bytes (32-bit/64-bit value) 519ca0716f5SRobert Watson */ 520ca0716f5SRobert Watson typedef struct { 521ca0716f5SRobert Watson u_char status; 522ca0716f5SRobert Watson u_int32_t ret; 523ca0716f5SRobert Watson } au_ret32_t; 524ca0716f5SRobert Watson 525ca0716f5SRobert Watson typedef struct { 526ca0716f5SRobert Watson u_char err; 527ca0716f5SRobert Watson u_int64_t val; 528ca0716f5SRobert Watson } au_ret64_t; 529ca0716f5SRobert Watson 530ca0716f5SRobert Watson /* 531ca0716f5SRobert Watson * sequence number 4 bytes 532ca0716f5SRobert Watson */ 533ca0716f5SRobert Watson typedef struct { 534ca0716f5SRobert Watson u_int32_t seqno; 535ca0716f5SRobert Watson } au_seq_t; 536ca0716f5SRobert Watson 537ca0716f5SRobert Watson /* 538ca0716f5SRobert Watson * socket type 2 bytes 539ca0716f5SRobert Watson * local port 2 bytes 540ca0716f5SRobert Watson * local Internet address 4 bytes 541ca0716f5SRobert Watson * remote port 2 bytes 542ca0716f5SRobert Watson * remote Internet address 4 bytes 543ca0716f5SRobert Watson */ 544ca0716f5SRobert Watson typedef struct { 545ca0716f5SRobert Watson u_int16_t type; 546ca0716f5SRobert Watson u_int16_t l_port; 547ca0716f5SRobert Watson u_int32_t l_addr; 548ca0716f5SRobert Watson u_int16_t r_port; 549ca0716f5SRobert Watson u_int32_t r_addr; 550ca0716f5SRobert Watson } au_socket_t; 551ca0716f5SRobert Watson 552ca0716f5SRobert Watson /* 553ca0716f5SRobert Watson * socket type 2 bytes 554ca0716f5SRobert Watson * local port 2 bytes 555ca0716f5SRobert Watson * address type/length 4 bytes 556ca0716f5SRobert Watson * local Internet address 4 bytes/16 bytes (IPv4/IPv6 address) 557ca0716f5SRobert Watson * remote port 4 bytes 558ca0716f5SRobert Watson * address type/length 4 bytes 559ca0716f5SRobert Watson * remote Internet address 4 bytes/16 bytes (IPv4/IPv6 address) 560ca0716f5SRobert Watson */ 561ca0716f5SRobert Watson typedef struct { 5627a0a89d2SRobert Watson u_int16_t domain; 563ca0716f5SRobert Watson u_int16_t type; 5647a0a89d2SRobert Watson u_int16_t atype; 565ca0716f5SRobert Watson u_int16_t l_port; 5667a0a89d2SRobert Watson u_int32_t l_addr[4]; 567ca0716f5SRobert Watson u_int32_t r_port; 5687a0a89d2SRobert Watson u_int32_t r_addr[4]; 569ca0716f5SRobert Watson } au_socket_ex32_t; 570ca0716f5SRobert Watson 571ca0716f5SRobert Watson /* 572ca0716f5SRobert Watson * socket family 2 bytes 573ca0716f5SRobert Watson * local port 2 bytes 574ca0716f5SRobert Watson * socket address 4 bytes/16 bytes (IPv4/IPv6 address) 575ca0716f5SRobert Watson */ 576ca0716f5SRobert Watson typedef struct { 577ca0716f5SRobert Watson u_int16_t family; 578ca0716f5SRobert Watson u_int16_t port; 579c0020399SRobert Watson u_int32_t addr[4]; 580c0020399SRobert Watson } au_socketinet_ex32_t; 581c0020399SRobert Watson 582c0020399SRobert Watson typedef struct { 583c0020399SRobert Watson u_int16_t family; 584c0020399SRobert Watson u_int16_t port; 585ca0716f5SRobert Watson u_int32_t addr; 586ca0716f5SRobert Watson } au_socketinet32_t; 587ca0716f5SRobert Watson 588ca0716f5SRobert Watson /* 589ca0716f5SRobert Watson * socket family 2 bytes 590ca0716f5SRobert Watson * path 104 bytes 591ca0716f5SRobert Watson */ 592ca0716f5SRobert Watson typedef struct { 593ca0716f5SRobert Watson u_int16_t family; 594ca0716f5SRobert Watson char path[104]; 595ca0716f5SRobert Watson } au_socketunix_t; 596ca0716f5SRobert Watson 597ca0716f5SRobert Watson /* 598ca0716f5SRobert Watson * audit ID 4 bytes 599ca0716f5SRobert Watson * effective user ID 4 bytes 600ca0716f5SRobert Watson * effective group ID 4 bytes 601ca0716f5SRobert Watson * real user ID 4 bytes 602ca0716f5SRobert Watson * real group ID 4 bytes 603ca0716f5SRobert Watson * process ID 4 bytes 604ca0716f5SRobert Watson * session ID 4 bytes 605ca0716f5SRobert Watson * terminal ID 606ca0716f5SRobert Watson * port ID 4 bytes/8 bytes (32-bit/64-bit value) 607ca0716f5SRobert Watson * machine address 4 bytes 608ca0716f5SRobert Watson */ 609ca0716f5SRobert Watson typedef struct { 610ca0716f5SRobert Watson u_int32_t auid; 611ca0716f5SRobert Watson u_int32_t euid; 612ca0716f5SRobert Watson u_int32_t egid; 613ca0716f5SRobert Watson u_int32_t ruid; 614ca0716f5SRobert Watson u_int32_t rgid; 615ca0716f5SRobert Watson u_int32_t pid; 616ca0716f5SRobert Watson u_int32_t sid; 617ca0716f5SRobert Watson au_tid32_t tid; 618ca0716f5SRobert Watson } au_subject32_t; 619ca0716f5SRobert Watson 620ca0716f5SRobert Watson typedef struct { 621ca0716f5SRobert Watson u_int32_t auid; 622ca0716f5SRobert Watson u_int32_t euid; 623ca0716f5SRobert Watson u_int32_t egid; 624ca0716f5SRobert Watson u_int32_t ruid; 625ca0716f5SRobert Watson u_int32_t rgid; 626ca0716f5SRobert Watson u_int32_t pid; 627ca0716f5SRobert Watson u_int32_t sid; 628ca0716f5SRobert Watson au_tid64_t tid; 629ca0716f5SRobert Watson } au_subject64_t; 630ca0716f5SRobert Watson 631ca0716f5SRobert Watson /* 632ca0716f5SRobert Watson * audit ID 4 bytes 633ca0716f5SRobert Watson * effective user ID 4 bytes 634ca0716f5SRobert Watson * effective group ID 4 bytes 635ca0716f5SRobert Watson * real user ID 4 bytes 636ca0716f5SRobert Watson * real group ID 4 bytes 637ca0716f5SRobert Watson * process ID 4 bytes 638ca0716f5SRobert Watson * session ID 4 bytes 639ca0716f5SRobert Watson * terminal ID 640ca0716f5SRobert Watson * port ID 4 bytes/8 bytes (32-bit/64-bit value) 641ca0716f5SRobert Watson * type 4 bytes 642ca0716f5SRobert Watson * machine address 16 bytes 643ca0716f5SRobert Watson */ 644ca0716f5SRobert Watson typedef struct { 645ca0716f5SRobert Watson u_int32_t auid; 646ca0716f5SRobert Watson u_int32_t euid; 647ca0716f5SRobert Watson u_int32_t egid; 648ca0716f5SRobert Watson u_int32_t ruid; 649ca0716f5SRobert Watson u_int32_t rgid; 650ca0716f5SRobert Watson u_int32_t pid; 651ca0716f5SRobert Watson u_int32_t sid; 652ca0716f5SRobert Watson au_tidaddr32_t tid; 653ca0716f5SRobert Watson } au_subject32ex_t; 654ca0716f5SRobert Watson 655bc168a6cSRobert Watson typedef struct { 656bc168a6cSRobert Watson u_int32_t auid; 657bc168a6cSRobert Watson u_int32_t euid; 658bc168a6cSRobert Watson u_int32_t egid; 659bc168a6cSRobert Watson u_int32_t ruid; 660bc168a6cSRobert Watson u_int32_t rgid; 661bc168a6cSRobert Watson u_int32_t pid; 662bc168a6cSRobert Watson u_int32_t sid; 663bc168a6cSRobert Watson au_tidaddr64_t tid; 664bc168a6cSRobert Watson } au_subject64ex_t; 665bc168a6cSRobert Watson 666ca0716f5SRobert Watson /* 667ca0716f5SRobert Watson * text length 2 bytes 668ca0716f5SRobert Watson * text N bytes + 1 terminating NULL byte 669ca0716f5SRobert Watson */ 670ca0716f5SRobert Watson typedef struct { 671ca0716f5SRobert Watson u_int16_t len; 672ca0716f5SRobert Watson char *text; 673ca0716f5SRobert Watson } au_text_t; 674ca0716f5SRobert Watson 675bc168a6cSRobert Watson /* 676aa772005SRobert Watson * upriv status 1 byte 677aa772005SRobert Watson * privstr len 2 bytes 678aa772005SRobert Watson * privstr N bytes + 1 (\0 byte) 679aa772005SRobert Watson */ 680aa772005SRobert Watson typedef struct { 681aa772005SRobert Watson u_int8_t sorf; 682aa772005SRobert Watson u_int16_t privstrlen; 683aa772005SRobert Watson char *priv; 684aa772005SRobert Watson } au_priv_t; 685aa772005SRobert Watson 686aa772005SRobert Watson /* 687aa772005SRobert Watson * privset 688aa772005SRobert Watson * privtstrlen 2 bytes 689aa772005SRobert Watson * privtstr N Bytes + 1 690aa772005SRobert Watson * privstrlen 2 bytes 691aa772005SRobert Watson * privstr N Bytes + 1 692aa772005SRobert Watson */ 693aa772005SRobert Watson typedef struct { 694aa772005SRobert Watson u_int16_t privtstrlen; 695aa772005SRobert Watson char *privtstr; 696aa772005SRobert Watson u_int16_t privstrlen; 697aa772005SRobert Watson char *privstr; 698aa772005SRobert Watson } au_privset_t; 699aa772005SRobert Watson 700aa772005SRobert Watson /* 701bc168a6cSRobert Watson * zonename length 2 bytes 702bc168a6cSRobert Watson * zonename text N bytes + 1 NULL terminator 703bc168a6cSRobert Watson */ 704bc168a6cSRobert Watson typedef struct { 705bc168a6cSRobert Watson u_int16_t len; 706bc168a6cSRobert Watson char *zonename; 707bc168a6cSRobert Watson } au_zonename_t; 708bc168a6cSRobert Watson 709ca0716f5SRobert Watson typedef struct { 710ca0716f5SRobert Watson u_int32_t ident; 711ca0716f5SRobert Watson u_int16_t filter; 712ca0716f5SRobert Watson u_int16_t flags; 713ca0716f5SRobert Watson u_int32_t fflags; 714ca0716f5SRobert Watson u_int32_t data; 715ca0716f5SRobert Watson } au_kevent_t; 716ca0716f5SRobert Watson 717ca0716f5SRobert Watson typedef struct { 718ca0716f5SRobert Watson u_int16_t length; 719ca0716f5SRobert Watson char *data; 720ca0716f5SRobert Watson } au_invalid_t; 721ca0716f5SRobert Watson 722ca0716f5SRobert Watson /* 723ca0716f5SRobert Watson * trailer magic number 2 bytes 724ca0716f5SRobert Watson * record byte count 4 bytes 725ca0716f5SRobert Watson */ 726ca0716f5SRobert Watson typedef struct { 727ca0716f5SRobert Watson u_int16_t magic; 728ca0716f5SRobert Watson u_int32_t count; 729ca0716f5SRobert Watson } au_trailer_t; 730ca0716f5SRobert Watson 731ca0716f5SRobert Watson struct tokenstr { 732ca0716f5SRobert Watson u_char id; 733ca0716f5SRobert Watson u_char *data; 734ca0716f5SRobert Watson size_t len; 735ca0716f5SRobert Watson union { 736ca0716f5SRobert Watson au_arg32_t arg32; 737ca0716f5SRobert Watson au_arg64_t arg64; 738ca0716f5SRobert Watson au_arb_t arb; 739ca0716f5SRobert Watson au_attr32_t attr32; 740ca0716f5SRobert Watson au_attr64_t attr64; 741ca0716f5SRobert Watson au_execarg_t execarg; 742ca0716f5SRobert Watson au_execenv_t execenv; 743ca0716f5SRobert Watson au_exit_t exit; 744ca0716f5SRobert Watson au_file_t file; 745ca0716f5SRobert Watson au_groups_t grps; 746ca0716f5SRobert Watson au_header32_t hdr32; 747ca0716f5SRobert Watson au_header32_ex_t hdr32_ex; 748ca0716f5SRobert Watson au_header64_t hdr64; 749ca0716f5SRobert Watson au_header64_ex_t hdr64_ex; 750ca0716f5SRobert Watson au_inaddr_t inaddr; 751ca0716f5SRobert Watson au_inaddr_ex_t inaddr_ex; 752ca0716f5SRobert Watson au_ip_t ip; 753ca0716f5SRobert Watson au_ipc_t ipc; 754ca0716f5SRobert Watson au_ipcperm_t ipcperm; 755ca0716f5SRobert Watson au_iport_t iport; 756ca0716f5SRobert Watson au_opaque_t opaque; 757ca0716f5SRobert Watson au_path_t path; 758ca0716f5SRobert Watson au_proc32_t proc32; 759ca0716f5SRobert Watson au_proc32ex_t proc32_ex; 760bc168a6cSRobert Watson au_proc64_t proc64; 761bc168a6cSRobert Watson au_proc64ex_t proc64_ex; 762ca0716f5SRobert Watson au_ret32_t ret32; 763ca0716f5SRobert Watson au_ret64_t ret64; 764ca0716f5SRobert Watson au_seq_t seq; 765ca0716f5SRobert Watson au_socket_t socket; 766ca0716f5SRobert Watson au_socket_ex32_t socket_ex32; 767c0020399SRobert Watson au_socketinet_ex32_t sockinet_ex32; 768ca0716f5SRobert Watson au_socketunix_t sockunix; 769ca0716f5SRobert Watson au_subject32_t subj32; 770ca0716f5SRobert Watson au_subject32ex_t subj32_ex; 771bc168a6cSRobert Watson au_subject64_t subj64; 772bc168a6cSRobert Watson au_subject64ex_t subj64_ex; 773ca0716f5SRobert Watson au_text_t text; 774ca0716f5SRobert Watson au_kevent_t kevent; 775ca0716f5SRobert Watson au_invalid_t invalid; 776ca0716f5SRobert Watson au_trailer_t trail; 777bc168a6cSRobert Watson au_zonename_t zonename; 778aa772005SRobert Watson au_priv_t priv; 779aa772005SRobert Watson au_privset_t privset; 780ca0716f5SRobert Watson } tt; /* The token is one of the above types */ 781ca0716f5SRobert Watson }; 782ca0716f5SRobert Watson 783ca0716f5SRobert Watson typedef struct tokenstr tokenstr_t; 784ca0716f5SRobert Watson 785506764c6SRobert Watson int audit_submit(short au_event, au_id_t auid, 786506764c6SRobert Watson char status, int reterr, const char *fmt, ...); 787506764c6SRobert Watson 788ca0716f5SRobert Watson /* 789ca0716f5SRobert Watson * Functions relating to querying audit class information. 790ca0716f5SRobert Watson */ 791ca0716f5SRobert Watson void setauclass(void); 792ca0716f5SRobert Watson void endauclass(void); 793ca0716f5SRobert Watson struct au_class_ent *getauclassent(void); 794ca0716f5SRobert Watson struct au_class_ent *getauclassent_r(au_class_ent_t *class_int); 795ca0716f5SRobert Watson struct au_class_ent *getauclassnam(const char *name); 796ca0716f5SRobert Watson struct au_class_ent *getauclassnam_r(au_class_ent_t *class_int, 797ca0716f5SRobert Watson const char *name); 798ca0716f5SRobert Watson struct au_class_ent *getauclassnum(au_class_t class_number); 799ca0716f5SRobert Watson struct au_class_ent *getauclassnum_r(au_class_ent_t *class_int, 800ca0716f5SRobert Watson au_class_t class_number); 801ca0716f5SRobert Watson 802ca0716f5SRobert Watson /* 803ca0716f5SRobert Watson * Functions relating to querying audit control information. 804ca0716f5SRobert Watson */ 805ca0716f5SRobert Watson void setac(void); 806ca0716f5SRobert Watson void endac(void); 807ca0716f5SRobert Watson int getacdir(char *name, int len); 808aa772005SRobert Watson int getacdist(void); 809aa772005SRobert Watson int getacexpire(int *andflg, time_t *age, size_t *size); 8104bd0c025SRobert Watson int getacfilesz(size_t *size_val); 811*5e386598SRobert Watson int getacqsize(int *size_val); 812ca0716f5SRobert Watson int getacflg(char *auditstr, int len); 813aa772005SRobert Watson int getachost(char *auditstr, size_t len); 814aa772005SRobert Watson int getacmin(int *min_val); 815ca0716f5SRobert Watson int getacna(char *auditstr, int len); 816bb97b418SRobert Watson int getacpol(char *auditstr, size_t len); 817ca0716f5SRobert Watson int getauditflagsbin(char *auditstr, au_mask_t *masks); 818ca0716f5SRobert Watson int getauditflagschar(char *auditstr, au_mask_t *masks, 819ca0716f5SRobert Watson int verbose); 820ca0716f5SRobert Watson int au_preselect(au_event_t event, au_mask_t *mask_p, 821ca0716f5SRobert Watson int sorf, int flag); 822c0020399SRobert Watson ssize_t au_poltostr(int policy, size_t maxsize, char *buf); 823c0020399SRobert Watson int au_strtopol(const char *polstr, int *policy); 824ca0716f5SRobert Watson 825ca0716f5SRobert Watson /* 826ca0716f5SRobert Watson * Functions relating to querying audit event information. 827ca0716f5SRobert Watson */ 828ca0716f5SRobert Watson void setauevent(void); 829ca0716f5SRobert Watson void endauevent(void); 830ca0716f5SRobert Watson struct au_event_ent *getauevent(void); 831ca0716f5SRobert Watson struct au_event_ent *getauevent_r(struct au_event_ent *e); 832ca0716f5SRobert Watson struct au_event_ent *getauevnam(const char *name); 833ca0716f5SRobert Watson struct au_event_ent *getauevnam_r(struct au_event_ent *e, 834ca0716f5SRobert Watson const char *name); 835ca0716f5SRobert Watson struct au_event_ent *getauevnum(au_event_t event_number); 836ca0716f5SRobert Watson struct au_event_ent *getauevnum_r(struct au_event_ent *e, 837ca0716f5SRobert Watson au_event_t event_number); 838ca0716f5SRobert Watson au_event_t *getauevnonam(const char *event_name); 839ca0716f5SRobert Watson au_event_t *getauevnonam_r(au_event_t *ev, 840ca0716f5SRobert Watson const char *event_name); 841ca0716f5SRobert Watson 842ca0716f5SRobert Watson /* 843ca0716f5SRobert Watson * Functions relating to querying audit user information. 844ca0716f5SRobert Watson */ 845ca0716f5SRobert Watson void setauuser(void); 846ca0716f5SRobert Watson void endauuser(void); 847ca0716f5SRobert Watson struct au_user_ent *getauuserent(void); 848ca0716f5SRobert Watson struct au_user_ent *getauuserent_r(struct au_user_ent *u); 849ca0716f5SRobert Watson struct au_user_ent *getauusernam(const char *name); 850ca0716f5SRobert Watson struct au_user_ent *getauusernam_r(struct au_user_ent *u, 851ca0716f5SRobert Watson const char *name); 852ca0716f5SRobert Watson int au_user_mask(char *username, au_mask_t *mask_p); 853ca0716f5SRobert Watson int getfauditflags(au_mask_t *usremask, 854ca0716f5SRobert Watson au_mask_t *usrdmask, au_mask_t *lastmask); 855ca0716f5SRobert Watson 856ca0716f5SRobert Watson /* 857ca0716f5SRobert Watson * Functions for reading and printing records and tokens from audit trails. 858ca0716f5SRobert Watson */ 859ca0716f5SRobert Watson int au_read_rec(FILE *fp, u_char **buf); 860ca0716f5SRobert Watson int au_fetch_tok(tokenstr_t *tok, u_char *buf, int len); 861ca0716f5SRobert Watson //XXX The following interface has different prototype from BSM 862ca0716f5SRobert Watson void au_print_tok(FILE *outfp, tokenstr_t *tok, 863ca0716f5SRobert Watson char *del, char raw, char sfrm); 864aa772005SRobert Watson void au_print_flags_tok(FILE *outfp, tokenstr_t *tok, 865aa772005SRobert Watson char *del, int oflags); 866bc168a6cSRobert Watson void au_print_tok_xml(FILE *outfp, tokenstr_t *tok, 867bc168a6cSRobert Watson char *del, char raw, char sfrm); 868bc168a6cSRobert Watson 869bc168a6cSRobert Watson /* 870bc168a6cSRobert Watson * Functions relating to XML output. 871bc168a6cSRobert Watson */ 872bc168a6cSRobert Watson void au_print_xml_header(FILE *outfp); 873bc168a6cSRobert Watson void au_print_xml_footer(FILE *outfp); 874ca0716f5SRobert Watson 8757a0a89d2SRobert Watson const char *au_strerror(u_char bsm_error); 876c74c7b73SRobert Watson __END_DECLS 8777a0a89d2SRobert Watson 8787a0a89d2SRobert Watson /* 87922ccb20dSRobert Watson * The remaining APIs are associated with Apple's BSM implementation, in 88022ccb20dSRobert Watson * particular as relates to Mach IPC auditing and triggers passed via Mach 88122ccb20dSRobert Watson * IPC. 88222ccb20dSRobert Watson */ 883ca0716f5SRobert Watson #ifdef __APPLE__ 884ca0716f5SRobert Watson #include <sys/appleapiopts.h> 885ca0716f5SRobert Watson 886ca0716f5SRobert Watson /************************************************************************** 887ca0716f5SRobert Watson ************************************************************************** 888ca0716f5SRobert Watson ** The following definitions, functions, etc., are NOT officially 889ca0716f5SRobert Watson ** supported: they may be changed or removed in the future. Do not use 890ca0716f5SRobert Watson ** them unless you are prepared to cope with that eventuality. 891ca0716f5SRobert Watson ************************************************************************** 892ca0716f5SRobert Watson **************************************************************************/ 893ca0716f5SRobert Watson 894ca0716f5SRobert Watson #ifdef __APPLE_API_PRIVATE 895ca0716f5SRobert Watson #define __BSM_INTERNAL_NOTIFY_KEY "com.apple.audit.change" 896ca0716f5SRobert Watson #endif /* __APPLE_API_PRIVATE */ 897ca0716f5SRobert Watson 898ca0716f5SRobert Watson /* 899ca0716f5SRobert Watson * au_get_state() return values 900ca0716f5SRobert Watson * XXX use AUC_* values directly instead (<bsm/audit.h>); AUDIT_OFF and 901ca0716f5SRobert Watson * AUDIT_ON are deprecated and WILL be removed. 902ca0716f5SRobert Watson */ 903ca0716f5SRobert Watson #ifdef __APPLE_API_PRIVATE 904ca0716f5SRobert Watson #define AUDIT_OFF AUC_NOAUDIT 905ca0716f5SRobert Watson #define AUDIT_ON AUC_AUDITING 906ca0716f5SRobert Watson #endif /* __APPLE_API_PRIVATE */ 907ca0716f5SRobert Watson #endif /* !__APPLE__ */ 908ca0716f5SRobert Watson 909ca0716f5SRobert Watson /* 910ca0716f5SRobert Watson * Error return codes for audit_set_terminal_id(), audit_write() and its 911ca0716f5SRobert Watson * brethren. We have 255 (not including kAUNoErr) to play with. 912ca0716f5SRobert Watson * 913ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 914ca0716f5SRobert Watson */ 915ca0716f5SRobert Watson enum { 916ca0716f5SRobert Watson kAUNoErr = 0, 917ca0716f5SRobert Watson kAUBadParamErr = -66049, 918ca0716f5SRobert Watson kAUStatErr, 919ca0716f5SRobert Watson kAUSysctlErr, 920ca0716f5SRobert Watson kAUOpenErr, 921ca0716f5SRobert Watson kAUMakeSubjectTokErr, 922ca0716f5SRobert Watson kAUWriteSubjectTokErr, 923ca0716f5SRobert Watson kAUWriteCallerTokErr, 924ca0716f5SRobert Watson kAUMakeReturnTokErr, 925ca0716f5SRobert Watson kAUWriteReturnTokErr, 926ca0716f5SRobert Watson kAUCloseErr, 927ca0716f5SRobert Watson kAUMakeTextTokErr, 928ca0716f5SRobert Watson kAULastErr 929ca0716f5SRobert Watson }; 930ca0716f5SRobert Watson 931ca0716f5SRobert Watson #ifdef __APPLE__ 932ca0716f5SRobert Watson /* 933ca0716f5SRobert Watson * Error return codes for au_get_state() and/or its private support 934ca0716f5SRobert Watson * functions. These codes are designed to be compatible with the 935ca0716f5SRobert Watson * NOTIFY_STATUS_* codes defined in <notify.h> but non-overlapping. 936ca0716f5SRobert Watson * Any changes to notify(3) may cause these values to change in future. 937ca0716f5SRobert Watson * 938ca0716f5SRobert Watson * AU_UNIMPL should never happen unless you've changed your system software 939ca0716f5SRobert Watson * without rebooting. Shame on you. 940ca0716f5SRobert Watson */ 941ca0716f5SRobert Watson #ifdef __APPLE_API_PRIVATE 942ca0716f5SRobert Watson #define AU_UNIMPL NOTIFY_STATUS_FAILED + 1 /* audit unimplemented */ 943ca0716f5SRobert Watson #endif /* __APPLE_API_PRIVATE */ 944ca0716f5SRobert Watson #endif /* !__APPLE__ */ 945ca0716f5SRobert Watson 946ca0716f5SRobert Watson __BEGIN_DECLS 947ca0716f5SRobert Watson /* 948ca0716f5SRobert Watson * XXX This prototype should be in audit_record.h 949ca0716f5SRobert Watson * 950ca0716f5SRobert Watson * au_free_token() 951ca0716f5SRobert Watson * 952ca0716f5SRobert Watson * @summary - au_free_token() deallocates a token_t created by any of 953ca0716f5SRobert Watson * the au_to_*() BSM API functions. 954ca0716f5SRobert Watson * 955ca0716f5SRobert Watson * The BSM API generally manages deallocation of token_t objects. However, 956ca0716f5SRobert Watson * if au_write() is passed a bad audit descriptor, the token_t * parameter 957ca0716f5SRobert Watson * will be left untouched. In that case, the caller can deallocate the 958ca0716f5SRobert Watson * token_t using au_free_token() if desired. This is, in fact, what 959ca0716f5SRobert Watson * audit_write() does, in keeping with the existing memory management model 960ca0716f5SRobert Watson * of the BSM API. 961ca0716f5SRobert Watson * 962ca0716f5SRobert Watson * @param tok - A token_t * generated by one of the au_to_*() BSM API 963ca0716f5SRobert Watson * calls. For convenience, tok may be NULL, in which case 964ca0716f5SRobert Watson * au_free_token() returns immediately. 965ca0716f5SRobert Watson * 966ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 967ca0716f5SRobert Watson */ 968ca0716f5SRobert Watson void au_free_token(token_t *tok); 969ca0716f5SRobert Watson 970ca0716f5SRobert Watson /* 971ca0716f5SRobert Watson * Lightweight check to determine if auditing is enabled. If a client 972ca0716f5SRobert Watson * wants to use this to govern whether an entire series of audit calls 973ca0716f5SRobert Watson * should be made--as in the common case of a caller building a set of 974ca0716f5SRobert Watson * tokens, then writing them--it should cache the audit status in a local 975ca0716f5SRobert Watson * variable. This call always returns the current state of auditing. 976ca0716f5SRobert Watson * 977ca0716f5SRobert Watson * @return - AUC_AUDITING or AUC_NOAUDIT if no error occurred. 978ca0716f5SRobert Watson * Otherwise the function can return any of the errno values defined for 979ca0716f5SRobert Watson * setaudit(2), or AU_UNIMPL if audit does not appear to be supported by 980ca0716f5SRobert Watson * the system. 981ca0716f5SRobert Watson * 982ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 983ca0716f5SRobert Watson */ 984ca0716f5SRobert Watson int au_get_state(void); 9857a0a89d2SRobert Watson 9867a0a89d2SRobert Watson /* 9877a0a89d2SRobert Watson * Initialize the audit notification. If it has not already been initialized 9887a0a89d2SRobert Watson * it will automatically on the first call of au_get_state(). 9897a0a89d2SRobert Watson */ 9907a0a89d2SRobert Watson uint32_t au_notify_initialize(void); 9917a0a89d2SRobert Watson 9927a0a89d2SRobert Watson /* 9937a0a89d2SRobert Watson * Cancel audit notification and free the resources associated with it. 9947a0a89d2SRobert Watson * Responsible code that no longer needs to use au_get_state() should call 9957a0a89d2SRobert Watson * this. 9967a0a89d2SRobert Watson */ 9977a0a89d2SRobert Watson int au_notify_terminate(void); 998ca0716f5SRobert Watson __END_DECLS 999ca0716f5SRobert Watson 1000ca0716f5SRobert Watson /* OpenSSH compatibility */ 1001f4e380b0SRobert Watson int cannot_audit(int); 1002ca0716f5SRobert Watson 1003ca0716f5SRobert Watson __BEGIN_DECLS 1004ca0716f5SRobert Watson /* 1005ca0716f5SRobert Watson * audit_set_terminal_id() 1006ca0716f5SRobert Watson * 1007ca0716f5SRobert Watson * @summary - audit_set_terminal_id() fills in an au_tid_t struct, which is 1008ca0716f5SRobert Watson * used in audit session initialization by processes like /usr/bin/login. 1009ca0716f5SRobert Watson * 1010ca0716f5SRobert Watson * @param tid - A pointer to an au_tid_t struct. 1011ca0716f5SRobert Watson * 1012ca0716f5SRobert Watson * @return - kAUNoErr on success; kAUBadParamErr if tid is NULL, kAUStatErr 1013ca0716f5SRobert Watson * or kAUSysctlErr if one of the underlying system calls fails (a message 1014ca0716f5SRobert Watson * is sent to the system log in those cases). 1015ca0716f5SRobert Watson * 1016ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 1017ca0716f5SRobert Watson */ 1018ca0716f5SRobert Watson int audit_set_terminal_id(au_tid_t *tid); 1019ca0716f5SRobert Watson 1020ca0716f5SRobert Watson /* 1021ca0716f5SRobert Watson * BEGIN au_write() WRAPPERS 1022ca0716f5SRobert Watson * 1023ca0716f5SRobert Watson * The following calls all wrap the existing BSM API. They use the 1024ca0716f5SRobert Watson * provided subject information, if any, to construct the subject token 1025ca0716f5SRobert Watson * required for every log message. They use the provided return/error 1026ca0716f5SRobert Watson * value(s), if any, to construct the success/failure indication required 1027ca0716f5SRobert Watson * for every log message. They only permit one "miscellaneous" token, 1028ca0716f5SRobert Watson * which should contain the event-specific logging information mandated by 1029ca0716f5SRobert Watson * CAPP. 1030ca0716f5SRobert Watson * 1031ca0716f5SRobert Watson * All these calls assume the caller has previously determined that 1032ca0716f5SRobert Watson * auditing is enabled by calling au_get_state(). 1033ca0716f5SRobert Watson */ 1034ca0716f5SRobert Watson 1035ca0716f5SRobert Watson /* 1036ca0716f5SRobert Watson * audit_write() 1037ca0716f5SRobert Watson * 1038ca0716f5SRobert Watson * @summary - audit_write() is the basis for the other audit_write_*() 1039ca0716f5SRobert Watson * calls. Performs a basic write of an audit record (subject, additional 1040ca0716f5SRobert Watson * info, success/failure). Note that this call only permits logging one 1041ca0716f5SRobert Watson * caller-specified token; clients needing to log more flexibly must use 1042ca0716f5SRobert Watson * the existing BSM API (au_open(), et al.) directly. 1043ca0716f5SRobert Watson * 1044ca0716f5SRobert Watson * Note on memory management: audit_write() guarantees that the token_t *s 1045ca0716f5SRobert Watson * passed to it will be deallocated whether or not the underlying write to 1046ca0716f5SRobert Watson * the audit log succeeded. This addresses an inconsistency in the 1047ca0716f5SRobert Watson * underlying BSM API in which token_t *s are usually but not always 1048ca0716f5SRobert Watson * deallocated. 1049ca0716f5SRobert Watson * 1050ca0716f5SRobert Watson * @param event_code - The code for the event being logged. This should 1051ca0716f5SRobert Watson * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h. 1052ca0716f5SRobert Watson * 1053ca0716f5SRobert Watson * @param subject - A token_t * generated by au_to_subject(), 1054ca0716f5SRobert Watson * au_to_subject32(), au_to_subject64(), or au_to_me(). If no subject is 1055ca0716f5SRobert Watson * required, subject should be NULL. 1056ca0716f5SRobert Watson * 1057ca0716f5SRobert Watson * @param misctok - A token_t * generated by one of the au_to_*() BSM API 1058ca0716f5SRobert Watson * calls. This should correspond to the additional information required by 1059ca0716f5SRobert Watson * CAPP for the event being audited. If no additional information is 1060ca0716f5SRobert Watson * required, misctok should be NULL. 1061ca0716f5SRobert Watson * 1062ca0716f5SRobert Watson * @param retval - The return value to be logged for this event. This 1063ca0716f5SRobert Watson * should be 0 (zero) for success, otherwise the value is event-specific. 1064ca0716f5SRobert Watson * 1065ca0716f5SRobert Watson * @param errcode - Any error code associated with the return value (e.g., 1066ca0716f5SRobert Watson * errno or h_errno). If there was no error, errcode should be 0 (zero). 1067ca0716f5SRobert Watson * 1068ca0716f5SRobert Watson * @return - The status of the call: 0 (zero) on success, else one of the 1069ca0716f5SRobert Watson * kAU*Err values defined above. 1070ca0716f5SRobert Watson * 1071ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 1072ca0716f5SRobert Watson */ 1073ca0716f5SRobert Watson int audit_write(short event_code, token_t *subject, token_t *misctok, 1074ca0716f5SRobert Watson char retval, int errcode); 1075ca0716f5SRobert Watson 1076ca0716f5SRobert Watson /* 1077ca0716f5SRobert Watson * audit_write_success() 1078ca0716f5SRobert Watson * 1079ca0716f5SRobert Watson * @summary - audit_write_success() records an auditable event that did not 1080ca0716f5SRobert Watson * encounter an error. The interface is designed to require as little 1081ca0716f5SRobert Watson * direct use of the au_to_*() API as possible. It builds a subject token 1082ca0716f5SRobert Watson * from the information passed in and uses that to invoke audit_write(). 1083ca0716f5SRobert Watson * A subject, as defined by CAPP, is a process acting on the user's behalf. 1084ca0716f5SRobert Watson * 1085ca0716f5SRobert Watson * If the subject information is the same as the current process, use 1086ca0716f5SRobert Watson * au_write_success_self(). 1087ca0716f5SRobert Watson * 1088ca0716f5SRobert Watson * @param event_code - The code for the event being logged. This should 1089ca0716f5SRobert Watson * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h. 1090ca0716f5SRobert Watson * 1091ca0716f5SRobert Watson * @param misctok - A token_t * generated by one of the au_to_*() BSM API 1092ca0716f5SRobert Watson * calls. This should correspond to the additional information required by 1093ca0716f5SRobert Watson * CAPP for the event being audited. If no additional information is 1094ca0716f5SRobert Watson * required, misctok should be NULL. 1095ca0716f5SRobert Watson * 1096ca0716f5SRobert Watson * @param auid - The subject's audit ID. 1097ca0716f5SRobert Watson * 1098ca0716f5SRobert Watson * @param euid - The subject's effective user ID. 1099ca0716f5SRobert Watson * 1100ca0716f5SRobert Watson * @param egid - The subject's effective group ID. 1101ca0716f5SRobert Watson * 1102ca0716f5SRobert Watson * @param ruid - The subject's real user ID. 1103ca0716f5SRobert Watson * 1104ca0716f5SRobert Watson * @param rgid - The subject's real group ID. 1105ca0716f5SRobert Watson * 1106ca0716f5SRobert Watson * @param pid - The subject's process ID. 1107ca0716f5SRobert Watson * 1108ca0716f5SRobert Watson * @param sid - The subject's session ID. 1109ca0716f5SRobert Watson * 1110ca0716f5SRobert Watson * @param tid - The subject's terminal ID. 1111ca0716f5SRobert Watson * 1112ca0716f5SRobert Watson * @return - The status of the call: 0 (zero) on success, else one of the 1113ca0716f5SRobert Watson * kAU*Err values defined above. 1114ca0716f5SRobert Watson * 1115ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 1116ca0716f5SRobert Watson */ 1117ca0716f5SRobert Watson int audit_write_success(short event_code, token_t *misctok, au_id_t auid, 1118ca0716f5SRobert Watson uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, pid_t pid, 1119ca0716f5SRobert Watson au_asid_t sid, au_tid_t *tid); 1120ca0716f5SRobert Watson 1121ca0716f5SRobert Watson /* 1122ca0716f5SRobert Watson * audit_write_success_self() 1123ca0716f5SRobert Watson * 1124ca0716f5SRobert Watson * @summary - Similar to audit_write_success(), but used when the subject 1125ca0716f5SRobert Watson * (process) is owned and operated by the auditable user him/herself. 1126ca0716f5SRobert Watson * 1127ca0716f5SRobert Watson * @param event_code - The code for the event being logged. This should 1128ca0716f5SRobert Watson * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h. 1129ca0716f5SRobert Watson * 1130ca0716f5SRobert Watson * @param misctok - A token_t * generated by one of the au_to_*() BSM API 1131ca0716f5SRobert Watson * calls. This should correspond to the additional information required by 1132ca0716f5SRobert Watson * CAPP for the event being audited. If no additional information is 1133ca0716f5SRobert Watson * required, misctok should be NULL. 1134ca0716f5SRobert Watson * 1135ca0716f5SRobert Watson * @return - The status of the call: 0 (zero) on success, else one of the 1136ca0716f5SRobert Watson * kAU*Err values defined above. 1137ca0716f5SRobert Watson * 1138ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 1139ca0716f5SRobert Watson */ 1140ca0716f5SRobert Watson int audit_write_success_self(short event_code, token_t *misctok); 1141ca0716f5SRobert Watson 1142ca0716f5SRobert Watson /* 1143ca0716f5SRobert Watson * audit_write_failure() 1144ca0716f5SRobert Watson * 1145ca0716f5SRobert Watson * @summary - audit_write_failure() records an auditable event that 1146ca0716f5SRobert Watson * encountered an error. The interface is designed to require as little 1147ca0716f5SRobert Watson * direct use of the au_to_*() API as possible. It builds a subject token 1148ca0716f5SRobert Watson * from the information passed in and uses that to invoke audit_write(). 1149ca0716f5SRobert Watson * A subject, as defined by CAPP, is a process acting on the user's behalf. 1150ca0716f5SRobert Watson * 1151ca0716f5SRobert Watson * If the subject information is the same as the current process, use 1152ca0716f5SRobert Watson * au_write_failure_self(). 1153ca0716f5SRobert Watson * 1154ca0716f5SRobert Watson * @param event_code - The code for the event being logged. This should 1155ca0716f5SRobert Watson * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h. 1156ca0716f5SRobert Watson * 1157ca0716f5SRobert Watson * @param errmsg - A text message providing additional information about 1158ca0716f5SRobert Watson * the event being audited. 1159ca0716f5SRobert Watson * 1160ca0716f5SRobert Watson * @param errret - A numerical value providing additional information about 1161ca0716f5SRobert Watson * the error. This is intended to store the value of errno or h_errno if 1162ca0716f5SRobert Watson * it's relevant. This can be 0 (zero) if no additional information is 1163ca0716f5SRobert Watson * available. 1164ca0716f5SRobert Watson * 1165ca0716f5SRobert Watson * @param auid - The subject's audit ID. 1166ca0716f5SRobert Watson * 1167ca0716f5SRobert Watson * @param euid - The subject's effective user ID. 1168ca0716f5SRobert Watson * 1169ca0716f5SRobert Watson * @param egid - The subject's effective group ID. 1170ca0716f5SRobert Watson * 1171ca0716f5SRobert Watson * @param ruid - The subject's real user ID. 1172ca0716f5SRobert Watson * 1173ca0716f5SRobert Watson * @param rgid - The subject's real group ID. 1174ca0716f5SRobert Watson * 1175ca0716f5SRobert Watson * @param pid - The subject's process ID. 1176ca0716f5SRobert Watson * 1177ca0716f5SRobert Watson * @param sid - The subject's session ID. 1178ca0716f5SRobert Watson * 1179ca0716f5SRobert Watson * @param tid - The subject's terminal ID. 1180ca0716f5SRobert Watson * 1181ca0716f5SRobert Watson * @return - The status of the call: 0 (zero) on success, else one of the 1182ca0716f5SRobert Watson * kAU*Err values defined above. 1183ca0716f5SRobert Watson * 1184ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 1185ca0716f5SRobert Watson */ 1186ca0716f5SRobert Watson int audit_write_failure(short event_code, char *errmsg, int errret, 1187ca0716f5SRobert Watson au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid, 1188ca0716f5SRobert Watson pid_t pid, au_asid_t sid, au_tid_t *tid); 1189ca0716f5SRobert Watson 1190ca0716f5SRobert Watson /* 1191ca0716f5SRobert Watson * audit_write_failure_self() 1192ca0716f5SRobert Watson * 1193ca0716f5SRobert Watson * @summary - Similar to audit_write_failure(), but used when the subject 1194ca0716f5SRobert Watson * (process) is owned and operated by the auditable user him/herself. 1195ca0716f5SRobert Watson * 1196ca0716f5SRobert Watson * @param event_code - The code for the event being logged. This should 1197ca0716f5SRobert Watson * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h. 1198ca0716f5SRobert Watson * 1199ca0716f5SRobert Watson * @param errmsg - A text message providing additional information about 1200ca0716f5SRobert Watson * the event being audited. 1201ca0716f5SRobert Watson * 1202ca0716f5SRobert Watson * @param errret - A numerical value providing additional information about 1203ca0716f5SRobert Watson * the error. This is intended to store the value of errno or h_errno if 1204ca0716f5SRobert Watson * it's relevant. This can be 0 (zero) if no additional information is 1205ca0716f5SRobert Watson * available. 1206ca0716f5SRobert Watson * 1207ca0716f5SRobert Watson * @return - The status of the call: 0 (zero) on success, else one of the 1208ca0716f5SRobert Watson * kAU*Err values defined above. 1209ca0716f5SRobert Watson * 1210ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 1211ca0716f5SRobert Watson */ 1212ca0716f5SRobert Watson int audit_write_failure_self(short event_code, char *errmsg, int errret); 1213ca0716f5SRobert Watson 1214ca0716f5SRobert Watson /* 1215ca0716f5SRobert Watson * audit_write_failure_na() 1216ca0716f5SRobert Watson * 1217ca0716f5SRobert Watson * @summary - audit_write_failure_na() records errors during login. Such 1218ca0716f5SRobert Watson * errors are implicitly non-attributable (i.e., not ascribable to any user). 1219ca0716f5SRobert Watson * 1220ca0716f5SRobert Watson * @param event_code - The code for the event being logged. This should 1221ca0716f5SRobert Watson * be one of the AUE_ values in /usr/include/bsm/audit_uevents.h. 1222ca0716f5SRobert Watson * 1223ca0716f5SRobert Watson * @param errmsg - A text message providing additional information about 1224ca0716f5SRobert Watson * the event being audited. 1225ca0716f5SRobert Watson * 1226ca0716f5SRobert Watson * @param errret - A numerical value providing additional information about 1227ca0716f5SRobert Watson * the error. This is intended to store the value of errno or h_errno if 1228ca0716f5SRobert Watson * it's relevant. This can be 0 (zero) if no additional information is 1229ca0716f5SRobert Watson * available. 1230ca0716f5SRobert Watson * 1231ca0716f5SRobert Watson * @param euid - The subject's effective user ID. 1232ca0716f5SRobert Watson * 1233ca0716f5SRobert Watson * @param egid - The subject's effective group ID. 1234ca0716f5SRobert Watson * 1235ca0716f5SRobert Watson * @param pid - The subject's process ID. 1236ca0716f5SRobert Watson * 1237ca0716f5SRobert Watson * @param tid - The subject's terminal ID. 1238ca0716f5SRobert Watson * 1239ca0716f5SRobert Watson * @return - The status of the call: 0 (zero) on success, else one of the 1240ca0716f5SRobert Watson * kAU*Err values defined above. 1241ca0716f5SRobert Watson * 1242ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 1243ca0716f5SRobert Watson */ 1244ca0716f5SRobert Watson int audit_write_failure_na(short event_code, char *errmsg, int errret, 1245ca0716f5SRobert Watson uid_t euid, gid_t egid, pid_t pid, au_tid_t *tid); 1246ca0716f5SRobert Watson 1247ca0716f5SRobert Watson /* END au_write() WRAPPERS */ 1248ca0716f5SRobert Watson 1249ca0716f5SRobert Watson #ifdef __APPLE__ 1250ca0716f5SRobert Watson /* 1251ca0716f5SRobert Watson * audit_token_to_au32() 1252ca0716f5SRobert Watson * 1253ca0716f5SRobert Watson * @summary - Extract information from an audit_token_t, used to identify 1254ca0716f5SRobert Watson * Mach tasks and senders of Mach messages as subjects to the audit system. 1255ca0716f5SRobert Watson * audit_tokent_to_au32() is the only method that should be used to parse 1256ca0716f5SRobert Watson * an audit_token_t, since its internal representation may change over 1257ca0716f5SRobert Watson * time. A pointer parameter may be NULL if that information is not 1258ca0716f5SRobert Watson * needed. 1259ca0716f5SRobert Watson * 1260ca0716f5SRobert Watson * @param atoken - the audit token containing the desired information 1261ca0716f5SRobert Watson * 1262ca0716f5SRobert Watson * @param auidp - Pointer to a uid_t; on return will be set to the task or 1263ca0716f5SRobert Watson * sender's audit user ID 1264ca0716f5SRobert Watson * 1265ca0716f5SRobert Watson * @param euidp - Pointer to a uid_t; on return will be set to the task or 1266ca0716f5SRobert Watson * sender's effective user ID 1267ca0716f5SRobert Watson * 1268ca0716f5SRobert Watson * @param egidp - Pointer to a gid_t; on return will be set to the task or 1269ca0716f5SRobert Watson * sender's effective group ID 1270ca0716f5SRobert Watson * 1271ca0716f5SRobert Watson * @param ruidp - Pointer to a uid_t; on return will be set to the task or 1272ca0716f5SRobert Watson * sender's real user ID 1273ca0716f5SRobert Watson * 1274ca0716f5SRobert Watson * @param rgidp - Pointer to a gid_t; on return will be set to the task or 1275ca0716f5SRobert Watson * sender's real group ID 1276ca0716f5SRobert Watson * 1277ca0716f5SRobert Watson * @param pidp - Pointer to a pid_t; on return will be set to the task or 1278ca0716f5SRobert Watson * sender's process ID 1279ca0716f5SRobert Watson * 1280ca0716f5SRobert Watson * @param asidp - Pointer to an au_asid_t; on return will be set to the 1281ca0716f5SRobert Watson * task or sender's audit session ID 1282ca0716f5SRobert Watson * 1283ca0716f5SRobert Watson * @param tidp - Pointer to an au_tid_t; on return will be set to the task 1284ca0716f5SRobert Watson * or sender's terminal ID 1285ca0716f5SRobert Watson * 1286ca0716f5SRobert Watson * XXXRW: In Apple's bsm-8, these are marked __APPLE_API_PRIVATE. 1287ca0716f5SRobert Watson */ 1288ca0716f5SRobert Watson void audit_token_to_au32( 1289ca0716f5SRobert Watson audit_token_t atoken, 1290ca0716f5SRobert Watson uid_t *auidp, 1291ca0716f5SRobert Watson uid_t *euidp, 1292ca0716f5SRobert Watson gid_t *egidp, 1293ca0716f5SRobert Watson uid_t *ruidp, 1294ca0716f5SRobert Watson gid_t *rgidp, 1295ca0716f5SRobert Watson pid_t *pidp, 1296ca0716f5SRobert Watson au_asid_t *asidp, 1297ca0716f5SRobert Watson au_tid_t *tidp); 1298ca0716f5SRobert Watson #endif /* !__APPLE__ */ 1299ca0716f5SRobert Watson 1300c0020399SRobert Watson /* 1301c0020399SRobert Watson * Wrapper functions to auditon(2). 1302c0020399SRobert Watson */ 1303c0020399SRobert Watson int audit_get_car(char *path, size_t sz); 1304c0020399SRobert Watson int audit_get_class(au_evclass_map_t *evc_map, size_t sz); 1305c0020399SRobert Watson int audit_set_class(au_evclass_map_t *evc_map, size_t sz); 1306*5e386598SRobert Watson int audit_get_event(au_evname_map_t *evn_map, size_t sz); 1307*5e386598SRobert Watson int audit_set_event(au_evname_map_t *evn_map, size_t sz); 1308c0020399SRobert Watson int audit_get_cond(int *cond); 1309c0020399SRobert Watson int audit_set_cond(int *cond); 1310c0020399SRobert Watson int audit_get_cwd(char *path, size_t sz); 1311c0020399SRobert Watson int audit_get_fsize(au_fstat_t *fstat, size_t sz); 1312c0020399SRobert Watson int audit_set_fsize(au_fstat_t *fstat, size_t sz); 1313c0020399SRobert Watson int audit_get_kmask(au_mask_t *kmask, size_t sz); 1314c0020399SRobert Watson int audit_set_kmask(au_mask_t *kmask, size_t sz); 1315c0020399SRobert Watson int audit_get_kaudit(auditinfo_addr_t *aia, size_t sz); 1316c0020399SRobert Watson int audit_set_kaudit(auditinfo_addr_t *aia, size_t sz); 1317c0020399SRobert Watson int audit_set_pmask(auditpinfo_t *api, size_t sz); 1318c0020399SRobert Watson int audit_get_pinfo(auditpinfo_t *api, size_t sz); 1319c0020399SRobert Watson int audit_get_pinfo_addr(auditpinfo_addr_t *apia, size_t sz); 1320c0020399SRobert Watson int audit_get_policy(int *policy); 1321c0020399SRobert Watson int audit_set_policy(int *policy); 1322c0020399SRobert Watson int audit_get_qctrl(au_qctrl_t *qctrl, size_t sz); 1323c0020399SRobert Watson int audit_set_qctrl(au_qctrl_t *qctrl, size_t sz); 1324c0020399SRobert Watson int audit_get_sinfo_addr(auditinfo_addr_t *aia, size_t sz); 1325c0020399SRobert Watson int audit_get_stat(au_stat_t *stats, size_t sz); 1326c0020399SRobert Watson int audit_set_stat(au_stat_t *stats, size_t sz); 1327c0020399SRobert Watson int audit_send_trigger(int *trigger); 1328c0020399SRobert Watson 1329ca0716f5SRobert Watson __END_DECLS 1330ca0716f5SRobert Watson 1331ca0716f5SRobert Watson #endif /* !_LIBBSM_H_ */ 1332