1 /* 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1999-2009 Apple Inc. 5 * Copyright (c) 2016-2017 Robert N. M. Watson 6 * All rights reserved. 7 * 8 * Portions of this software were developed by BAE Systems, the University of 9 * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL 10 * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent 11 * Computing (TC) research program. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. Neither the name of Apple Inc. ("Apple") nor the names of 22 * its contributors may be used to endorse or promote products derived 23 * from this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR 29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 34 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38 #include <sys/cdefs.h> 39 __FBSDID("$FreeBSD$"); 40 41 #include <sys/param.h> 42 #include <sys/vnode.h> 43 #include <sys/ipc.h> 44 #include <sys/lock.h> 45 #include <sys/malloc.h> 46 #include <sys/mutex.h> 47 #include <sys/socket.h> 48 #include <sys/extattr.h> 49 #include <sys/fcntl.h> 50 #include <sys/user.h> 51 #include <sys/systm.h> 52 53 #include <bsm/audit.h> 54 #include <bsm/audit_internal.h> 55 #include <bsm/audit_record.h> 56 #include <bsm/audit_kevents.h> 57 58 #include <security/audit/audit.h> 59 #include <security/audit/audit_private.h> 60 61 #include <netinet/in_systm.h> 62 #include <netinet/in.h> 63 #include <netinet/ip.h> 64 65 MALLOC_DEFINE(M_AUDITBSM, "audit_bsm", "Audit BSM data"); 66 67 static void audit_sys_auditon(struct audit_record *ar, 68 struct au_record *rec); 69 70 /* 71 * Initialize the BSM auditing subsystem. 72 */ 73 void 74 kau_init(void) 75 { 76 77 au_evclassmap_init(); 78 au_evnamemap_init(); 79 } 80 81 /* 82 * This call reserves memory for the audit record. Memory must be guaranteed 83 * before any auditable event can be generated. The au_record structure 84 * maintains a reference to the memory allocated above and also the list of 85 * tokens associated with this record. 86 */ 87 static struct au_record * 88 kau_open(void) 89 { 90 struct au_record *rec; 91 92 rec = malloc(sizeof(*rec), M_AUDITBSM, M_WAITOK); 93 rec->data = NULL; 94 TAILQ_INIT(&rec->token_q); 95 rec->len = 0; 96 rec->used = 1; 97 98 return (rec); 99 } 100 101 /* 102 * Store the token with the record descriptor. 103 */ 104 static void 105 kau_write(struct au_record *rec, struct au_token *tok) 106 { 107 108 KASSERT(tok != NULL, ("kau_write: tok == NULL")); 109 110 TAILQ_INSERT_TAIL(&rec->token_q, tok, tokens); 111 rec->len += tok->len; 112 } 113 114 /* 115 * Close out the audit record by adding the header token, identifying any 116 * missing tokens. Write out the tokens to the record memory. 117 */ 118 static void 119 kau_close(struct au_record *rec, struct timespec *ctime, short event) 120 { 121 u_char *dptr; 122 size_t tot_rec_size; 123 token_t *cur, *hdr, *trail; 124 struct timeval tm; 125 size_t hdrsize; 126 struct auditinfo_addr ak; 127 struct in6_addr *ap; 128 129 audit_get_kinfo(&ak); 130 hdrsize = 0; 131 switch (ak.ai_termid.at_type) { 132 case AU_IPv4: 133 hdrsize = (ak.ai_termid.at_addr[0] == INADDR_ANY) ? 134 AUDIT_HEADER_SIZE : AUDIT_HEADER_EX_SIZE(&ak); 135 break; 136 case AU_IPv6: 137 ap = (struct in6_addr *)&ak.ai_termid.at_addr[0]; 138 hdrsize = (IN6_IS_ADDR_UNSPECIFIED(ap)) ? AUDIT_HEADER_SIZE : 139 AUDIT_HEADER_EX_SIZE(&ak); 140 break; 141 default: 142 panic("kau_close: invalid address family"); 143 } 144 tot_rec_size = rec->len + hdrsize + AUDIT_TRAILER_SIZE; 145 rec->data = malloc(tot_rec_size, M_AUDITBSM, M_WAITOK | M_ZERO); 146 147 tm.tv_usec = ctime->tv_nsec / 1000; 148 tm.tv_sec = ctime->tv_sec; 149 if (hdrsize != AUDIT_HEADER_SIZE) 150 hdr = au_to_header32_ex_tm(tot_rec_size, event, 0, tm, &ak); 151 else 152 hdr = au_to_header32_tm(tot_rec_size, event, 0, tm); 153 TAILQ_INSERT_HEAD(&rec->token_q, hdr, tokens); 154 155 trail = au_to_trailer(tot_rec_size); 156 TAILQ_INSERT_TAIL(&rec->token_q, trail, tokens); 157 158 rec->len = tot_rec_size; 159 dptr = rec->data; 160 TAILQ_FOREACH(cur, &rec->token_q, tokens) { 161 memcpy(dptr, cur->t_data, cur->len); 162 dptr += cur->len; 163 } 164 } 165 166 /* 167 * Free a BSM audit record by releasing all the tokens and clearing the audit 168 * record information. 169 */ 170 void 171 kau_free(struct au_record *rec) 172 { 173 struct au_token *tok; 174 175 /* Free the token list. */ 176 while ((tok = TAILQ_FIRST(&rec->token_q))) { 177 TAILQ_REMOVE(&rec->token_q, tok, tokens); 178 free(tok->t_data, M_AUDITBSM); 179 free(tok, M_AUDITBSM); 180 } 181 182 rec->used = 0; 183 rec->len = 0; 184 free(rec->data, M_AUDITBSM); 185 free(rec, M_AUDITBSM); 186 } 187 188 /* 189 * XXX: May want turn some (or all) of these macros into functions in order 190 * to reduce the generated code size. 191 * 192 * XXXAUDIT: These macros assume that 'kar', 'ar', 'rec', and 'tok' in the 193 * caller are OK with this. 194 */ 195 #define ATFD1_TOKENS(argnum) do { \ 196 if (ARG_IS_VALID(kar, ARG_ATFD1)) { \ 197 tok = au_to_arg32(argnum, "at fd 1", ar->ar_arg_atfd1); \ 198 kau_write(rec, tok); \ 199 } \ 200 } while (0) 201 202 #define ATFD2_TOKENS(argnum) do { \ 203 if (ARG_IS_VALID(kar, ARG_ATFD2)) { \ 204 tok = au_to_arg32(argnum, "at fd 2", ar->ar_arg_atfd2); \ 205 kau_write(rec, tok); \ 206 } \ 207 } while (0) 208 209 #define UPATH1_TOKENS do { \ 210 if (ARG_IS_VALID(kar, ARG_UPATH1)) { \ 211 tok = au_to_path(ar->ar_arg_upath1); \ 212 kau_write(rec, tok); \ 213 } \ 214 } while (0) 215 216 #define UPATH2_TOKENS do { \ 217 if (ARG_IS_VALID(kar, ARG_UPATH2)) { \ 218 tok = au_to_path(ar->ar_arg_upath2); \ 219 kau_write(rec, tok); \ 220 } \ 221 } while (0) 222 223 #define VNODE1_TOKENS do { \ 224 if (ARG_IS_VALID(kar, ARG_ATFD)) { \ 225 tok = au_to_arg32(1, "at fd", ar->ar_arg_atfd); \ 226 kau_write(rec, tok); \ 227 } \ 228 if (ARG_IS_VALID(kar, ARG_VNODE1)) { \ 229 tok = au_to_attr32(&ar->ar_arg_vnode1); \ 230 kau_write(rec, tok); \ 231 } \ 232 } while (0) 233 234 #define UPATH1_VNODE1_TOKENS do { \ 235 UPATH1_TOKENS; \ 236 if (ARG_IS_VALID(kar, ARG_VNODE1)) { \ 237 tok = au_to_attr32(&ar->ar_arg_vnode1); \ 238 kau_write(rec, tok); \ 239 } \ 240 } while (0) 241 242 #define VNODE2_TOKENS do { \ 243 if (ARG_IS_VALID(kar, ARG_VNODE2)) { \ 244 tok = au_to_attr32(&ar->ar_arg_vnode2); \ 245 kau_write(rec, tok); \ 246 } \ 247 } while (0) 248 249 #define FD_VNODE1_TOKENS do { \ 250 if (ARG_IS_VALID(kar, ARG_VNODE1)) { \ 251 if (ARG_IS_VALID(kar, ARG_FD)) { \ 252 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); \ 253 kau_write(rec, tok); \ 254 } \ 255 tok = au_to_attr32(&ar->ar_arg_vnode1); \ 256 kau_write(rec, tok); \ 257 } else { \ 258 if (ARG_IS_VALID(kar, ARG_FD)) { \ 259 tok = au_to_arg32(1, "non-file: fd", \ 260 ar->ar_arg_fd); \ 261 kau_write(rec, tok); \ 262 } \ 263 } \ 264 } while (0) 265 266 #define PROCESS_PID_TOKENS(argn) do { \ 267 if ((ar->ar_arg_pid > 0) /* Reference a single process */ \ 268 && (ARG_IS_VALID(kar, ARG_PROCESS))) { \ 269 tok = au_to_process32_ex(ar->ar_arg_auid, \ 270 ar->ar_arg_euid, ar->ar_arg_egid, \ 271 ar->ar_arg_ruid, ar->ar_arg_rgid, \ 272 ar->ar_arg_pid, ar->ar_arg_asid, \ 273 &ar->ar_arg_termid_addr); \ 274 kau_write(rec, tok); \ 275 } else if (ARG_IS_VALID(kar, ARG_PID)) { \ 276 tok = au_to_arg32(argn, "process", ar->ar_arg_pid); \ 277 kau_write(rec, tok); \ 278 } \ 279 } while (0) 280 281 #define EXTATTR_TOKENS(namespace_argnum) do { \ 282 if (ARG_IS_VALID(kar, ARG_VALUE)) { \ 283 switch (ar->ar_arg_value) { \ 284 case EXTATTR_NAMESPACE_USER: \ 285 tok = au_to_text(EXTATTR_NAMESPACE_USER_STRING);\ 286 break; \ 287 case EXTATTR_NAMESPACE_SYSTEM: \ 288 tok = au_to_text(EXTATTR_NAMESPACE_SYSTEM_STRING);\ 289 break; \ 290 default: \ 291 tok = au_to_arg32((namespace_argnum), \ 292 "attrnamespace", ar->ar_arg_value); \ 293 break; \ 294 } \ 295 kau_write(rec, tok); \ 296 } \ 297 /* attrname is in the text field */ \ 298 if (ARG_IS_VALID(kar, ARG_TEXT)) { \ 299 tok = au_to_text(ar->ar_arg_text); \ 300 kau_write(rec, tok); \ 301 } \ 302 } while (0) 303 304 /* 305 * Not all pointer arguments to system calls are of interest, but in some 306 * cases they reflect delegation of rights, such as mmap(2) followed by 307 * minherit(2) before execve(2), so do the best we can. 308 */ 309 #define ADDR_TOKEN(argnum, argname) do { \ 310 if (ARG_IS_VALID(kar, ARG_ADDR)) { \ 311 if (sizeof(void *) == sizeof(uint32_t)) \ 312 tok = au_to_arg32((argnum), (argname), \ 313 (uint32_t)(uintptr_t)ar->ar_arg_addr); \ 314 else \ 315 tok = au_to_arg64((argnum), (argname), \ 316 (uint64_t)(uintptr_t)ar->ar_arg_addr); \ 317 kau_write(rec, tok); \ 318 } \ 319 } while (0) 320 321 /* 322 * Implement auditing for the auditon() system call. The audit tokens that 323 * are generated depend on the command that was sent into the auditon() 324 * system call. 325 */ 326 static void 327 audit_sys_auditon(struct audit_record *ar, struct au_record *rec) 328 { 329 struct au_token *tok; 330 331 tok = au_to_arg32(3, "length", ar->ar_arg_len); 332 kau_write(rec, tok); 333 switch (ar->ar_arg_cmd) { 334 case A_OLDSETPOLICY: 335 if ((size_t)ar->ar_arg_len == sizeof(int64_t)) { 336 tok = au_to_arg64(2, "policy", 337 ar->ar_arg_auditon.au_policy64); 338 kau_write(rec, tok); 339 break; 340 } 341 /* FALLTHROUGH */ 342 343 case A_SETPOLICY: 344 tok = au_to_arg32(2, "policy", ar->ar_arg_auditon.au_policy); 345 kau_write(rec, tok); 346 break; 347 348 case A_SETKMASK: 349 tok = au_to_arg32(2, "setkmask:as_success", 350 ar->ar_arg_auditon.au_mask.am_success); 351 kau_write(rec, tok); 352 tok = au_to_arg32(2, "setkmask:as_failure", 353 ar->ar_arg_auditon.au_mask.am_failure); 354 kau_write(rec, tok); 355 break; 356 357 case A_OLDSETQCTRL: 358 if ((size_t)ar->ar_arg_len == sizeof(au_qctrl64_t)) { 359 tok = au_to_arg64(2, "setqctrl:aq_hiwater", 360 ar->ar_arg_auditon.au_qctrl64.aq64_hiwater); 361 kau_write(rec, tok); 362 tok = au_to_arg64(2, "setqctrl:aq_lowater", 363 ar->ar_arg_auditon.au_qctrl64.aq64_lowater); 364 kau_write(rec, tok); 365 tok = au_to_arg64(2, "setqctrl:aq_bufsz", 366 ar->ar_arg_auditon.au_qctrl64.aq64_bufsz); 367 kau_write(rec, tok); 368 tok = au_to_arg64(2, "setqctrl:aq_delay", 369 ar->ar_arg_auditon.au_qctrl64.aq64_delay); 370 kau_write(rec, tok); 371 tok = au_to_arg64(2, "setqctrl:aq_minfree", 372 ar->ar_arg_auditon.au_qctrl64.aq64_minfree); 373 kau_write(rec, tok); 374 break; 375 } 376 /* FALLTHROUGH */ 377 378 case A_SETQCTRL: 379 tok = au_to_arg32(2, "setqctrl:aq_hiwater", 380 ar->ar_arg_auditon.au_qctrl.aq_hiwater); 381 kau_write(rec, tok); 382 tok = au_to_arg32(2, "setqctrl:aq_lowater", 383 ar->ar_arg_auditon.au_qctrl.aq_lowater); 384 kau_write(rec, tok); 385 tok = au_to_arg32(2, "setqctrl:aq_bufsz", 386 ar->ar_arg_auditon.au_qctrl.aq_bufsz); 387 kau_write(rec, tok); 388 tok = au_to_arg32(2, "setqctrl:aq_delay", 389 ar->ar_arg_auditon.au_qctrl.aq_delay); 390 kau_write(rec, tok); 391 tok = au_to_arg32(2, "setqctrl:aq_minfree", 392 ar->ar_arg_auditon.au_qctrl.aq_minfree); 393 kau_write(rec, tok); 394 break; 395 396 case A_SETUMASK: 397 tok = au_to_arg32(2, "setumask:as_success", 398 ar->ar_arg_auditon.au_auinfo.ai_mask.am_success); 399 kau_write(rec, tok); 400 tok = au_to_arg32(2, "setumask:as_failure", 401 ar->ar_arg_auditon.au_auinfo.ai_mask.am_failure); 402 kau_write(rec, tok); 403 break; 404 405 case A_SETSMASK: 406 tok = au_to_arg32(2, "setsmask:as_success", 407 ar->ar_arg_auditon.au_auinfo.ai_mask.am_success); 408 kau_write(rec, tok); 409 tok = au_to_arg32(2, "setsmask:as_failure", 410 ar->ar_arg_auditon.au_auinfo.ai_mask.am_failure); 411 kau_write(rec, tok); 412 break; 413 414 case A_OLDSETCOND: 415 if ((size_t)ar->ar_arg_len == sizeof(int64_t)) { 416 tok = au_to_arg64(2, "setcond", 417 ar->ar_arg_auditon.au_cond64); 418 kau_write(rec, tok); 419 break; 420 } 421 /* FALLTHROUGH */ 422 423 case A_SETCOND: 424 tok = au_to_arg32(2, "setcond", ar->ar_arg_auditon.au_cond); 425 kau_write(rec, tok); 426 break; 427 428 case A_SETCLASS: 429 tok = au_to_arg32(2, "setclass:ec_event", 430 ar->ar_arg_auditon.au_evclass.ec_number); 431 kau_write(rec, tok); 432 tok = au_to_arg32(2, "setclass:ec_class", 433 ar->ar_arg_auditon.au_evclass.ec_class); 434 kau_write(rec, tok); 435 break; 436 437 case A_SETPMASK: 438 tok = au_to_arg32(2, "setpmask:as_success", 439 ar->ar_arg_auditon.au_aupinfo.ap_mask.am_success); 440 kau_write(rec, tok); 441 tok = au_to_arg32(2, "setpmask:as_failure", 442 ar->ar_arg_auditon.au_aupinfo.ap_mask.am_failure); 443 kau_write(rec, tok); 444 break; 445 446 case A_SETFSIZE: 447 tok = au_to_arg32(2, "setfsize:filesize", 448 ar->ar_arg_auditon.au_fstat.af_filesz); 449 kau_write(rec, tok); 450 break; 451 452 default: 453 break; 454 } 455 } 456 457 /* 458 * Convert an internal kernel audit record to a BSM record and return a 459 * success/failure indicator. The BSM record is passed as an out parameter to 460 * this function. 461 * 462 * Return conditions: 463 * BSM_SUCCESS: The BSM record is valid 464 * BSM_FAILURE: Failure; the BSM record is NULL. 465 * BSM_NOAUDIT: The event is not auditable for BSM; the BSM record is NULL. 466 */ 467 int 468 kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau) 469 { 470 struct au_token *tok, *subj_tok, *jail_tok; 471 struct au_record *rec; 472 au_tid_t tid; 473 struct audit_record *ar; 474 int ctr; 475 476 KASSERT(kar != NULL, ("kaudit_to_bsm: kar == NULL")); 477 478 *pau = NULL; 479 ar = &kar->k_ar; 480 rec = kau_open(); 481 482 /* 483 * Create the subject token. If this credential was jailed be sure to 484 * generate a zonename token. 485 */ 486 if (ar->ar_jailname[0] != '\0') 487 jail_tok = au_to_zonename(ar->ar_jailname); 488 else 489 jail_tok = NULL; 490 switch (ar->ar_subj_term_addr.at_type) { 491 case AU_IPv4: 492 tid.port = ar->ar_subj_term_addr.at_port; 493 tid.machine = ar->ar_subj_term_addr.at_addr[0]; 494 subj_tok = au_to_subject32(ar->ar_subj_auid, /* audit ID */ 495 ar->ar_subj_cred.cr_uid, /* eff uid */ 496 ar->ar_subj_egid, /* eff group id */ 497 ar->ar_subj_ruid, /* real uid */ 498 ar->ar_subj_rgid, /* real group id */ 499 ar->ar_subj_pid, /* process id */ 500 ar->ar_subj_asid, /* session ID */ 501 &tid); 502 break; 503 case AU_IPv6: 504 subj_tok = au_to_subject32_ex(ar->ar_subj_auid, 505 ar->ar_subj_cred.cr_uid, 506 ar->ar_subj_egid, 507 ar->ar_subj_ruid, 508 ar->ar_subj_rgid, 509 ar->ar_subj_pid, 510 ar->ar_subj_asid, 511 &ar->ar_subj_term_addr); 512 break; 513 default: 514 bzero(&tid, sizeof(tid)); 515 subj_tok = au_to_subject32(ar->ar_subj_auid, 516 ar->ar_subj_cred.cr_uid, 517 ar->ar_subj_egid, 518 ar->ar_subj_ruid, 519 ar->ar_subj_rgid, 520 ar->ar_subj_pid, 521 ar->ar_subj_asid, 522 &tid); 523 } 524 525 /* 526 * The logic inside each case fills in the tokens required for the 527 * event, except for the header, trailer, and return tokens. The 528 * header and trailer tokens are added by the kau_close() function. 529 * The return token is added outside of the switch statement. 530 */ 531 switch(ar->ar_event) { 532 case AUE_ACCEPT: 533 if (ARG_IS_VALID(kar, ARG_FD)) { 534 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 535 kau_write(rec, tok); 536 } 537 if (ARG_IS_VALID(kar, ARG_SADDRINET)) { 538 tok = au_to_sock_inet((struct sockaddr_in *) 539 &ar->ar_arg_sockaddr); 540 kau_write(rec, tok); 541 } 542 if (ARG_IS_VALID(kar, ARG_SADDRUNIX)) { 543 tok = au_to_sock_unix((struct sockaddr_un *) 544 &ar->ar_arg_sockaddr); 545 kau_write(rec, tok); 546 UPATH1_TOKENS; 547 } 548 break; 549 550 case AUE_BIND: 551 case AUE_LISTEN: 552 case AUE_CONNECT: 553 case AUE_RECV: 554 case AUE_RECVFROM: 555 case AUE_RECVMSG: 556 case AUE_SEND: 557 case AUE_SENDMSG: 558 case AUE_SENDTO: 559 /* 560 * Socket-related events. 561 */ 562 if (ARG_IS_VALID(kar, ARG_FD)) { 563 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 564 kau_write(rec, tok); 565 } 566 if (ARG_IS_VALID(kar, ARG_SADDRINET)) { 567 tok = au_to_sock_inet((struct sockaddr_in *) 568 &ar->ar_arg_sockaddr); 569 kau_write(rec, tok); 570 } 571 if (ARG_IS_VALID(kar, ARG_SADDRUNIX)) { 572 tok = au_to_sock_unix((struct sockaddr_un *) 573 &ar->ar_arg_sockaddr); 574 kau_write(rec, tok); 575 UPATH1_TOKENS; 576 } 577 /* XXX Need to handle ARG_SADDRINET6 */ 578 break; 579 580 case AUE_BINDAT: 581 case AUE_CONNECTAT: 582 ATFD1_TOKENS(1); 583 if (ARG_IS_VALID(kar, ARG_FD)) { 584 tok = au_to_arg32(2, "fd", ar->ar_arg_fd); 585 kau_write(rec, tok); 586 } 587 if (ARG_IS_VALID(kar, ARG_SADDRUNIX)) { 588 tok = au_to_sock_unix((struct sockaddr_un *) 589 &ar->ar_arg_sockaddr); 590 kau_write(rec, tok); 591 UPATH1_TOKENS; 592 } 593 break; 594 595 case AUE_SENDFILE: 596 FD_VNODE1_TOKENS; 597 if (ARG_IS_VALID(kar, ARG_SADDRINET)) { 598 tok = au_to_sock_inet((struct sockaddr_in *) 599 &ar->ar_arg_sockaddr); 600 kau_write(rec, tok); 601 } 602 if (ARG_IS_VALID(kar, ARG_SADDRUNIX)) { 603 tok = au_to_sock_unix((struct sockaddr_un *) 604 &ar->ar_arg_sockaddr); 605 kau_write(rec, tok); 606 UPATH1_TOKENS; 607 } 608 /* XXX Need to handle ARG_SADDRINET6 */ 609 break; 610 611 case AUE_SOCKET: 612 case AUE_SOCKETPAIR: 613 if (ARG_IS_VALID(kar, ARG_SOCKINFO)) { 614 tok = au_to_arg32(1, "domain", 615 ar->ar_arg_sockinfo.so_domain); 616 kau_write(rec, tok); 617 tok = au_to_arg32(2, "type", 618 ar->ar_arg_sockinfo.so_type); 619 kau_write(rec, tok); 620 tok = au_to_arg32(3, "protocol", 621 ar->ar_arg_sockinfo.so_protocol); 622 kau_write(rec, tok); 623 } 624 break; 625 626 case AUE_SETSOCKOPT: 627 case AUE_SHUTDOWN: 628 if (ARG_IS_VALID(kar, ARG_FD)) { 629 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 630 kau_write(rec, tok); 631 } 632 break; 633 634 case AUE_ACCT: 635 if (ARG_IS_VALID(kar, ARG_UPATH1)) { 636 UPATH1_VNODE1_TOKENS; 637 } else { 638 tok = au_to_arg32(1, "accounting off", 0); 639 kau_write(rec, tok); 640 } 641 break; 642 643 case AUE_SETAUID: 644 if (ARG_IS_VALID(kar, ARG_AUID)) { 645 tok = au_to_arg32(2, "setauid", ar->ar_arg_auid); 646 kau_write(rec, tok); 647 } 648 break; 649 650 case AUE_SETAUDIT: 651 if (ARG_IS_VALID(kar, ARG_AUID) && 652 ARG_IS_VALID(kar, ARG_ASID) && 653 ARG_IS_VALID(kar, ARG_AMASK) && 654 ARG_IS_VALID(kar, ARG_TERMID)) { 655 tok = au_to_arg32(1, "setaudit:auid", 656 ar->ar_arg_auid); 657 kau_write(rec, tok); 658 tok = au_to_arg32(1, "setaudit:port", 659 ar->ar_arg_termid.port); 660 kau_write(rec, tok); 661 tok = au_to_arg32(1, "setaudit:machine", 662 ar->ar_arg_termid.machine); 663 kau_write(rec, tok); 664 tok = au_to_arg32(1, "setaudit:as_success", 665 ar->ar_arg_amask.am_success); 666 kau_write(rec, tok); 667 tok = au_to_arg32(1, "setaudit:as_failure", 668 ar->ar_arg_amask.am_failure); 669 kau_write(rec, tok); 670 tok = au_to_arg32(1, "setaudit:asid", 671 ar->ar_arg_asid); 672 kau_write(rec, tok); 673 } 674 break; 675 676 case AUE_SETAUDIT_ADDR: 677 if (ARG_IS_VALID(kar, ARG_AUID) && 678 ARG_IS_VALID(kar, ARG_ASID) && 679 ARG_IS_VALID(kar, ARG_AMASK) && 680 ARG_IS_VALID(kar, ARG_TERMID_ADDR)) { 681 tok = au_to_arg32(1, "setaudit_addr:auid", 682 ar->ar_arg_auid); 683 kau_write(rec, tok); 684 tok = au_to_arg32(1, "setaudit_addr:as_success", 685 ar->ar_arg_amask.am_success); 686 kau_write(rec, tok); 687 tok = au_to_arg32(1, "setaudit_addr:as_failure", 688 ar->ar_arg_amask.am_failure); 689 kau_write(rec, tok); 690 tok = au_to_arg32(1, "setaudit_addr:asid", 691 ar->ar_arg_asid); 692 kau_write(rec, tok); 693 tok = au_to_arg32(1, "setaudit_addr:type", 694 ar->ar_arg_termid_addr.at_type); 695 kau_write(rec, tok); 696 tok = au_to_arg32(1, "setaudit_addr:port", 697 ar->ar_arg_termid_addr.at_port); 698 kau_write(rec, tok); 699 if (ar->ar_arg_termid_addr.at_type == AU_IPv6) 700 tok = au_to_in_addr_ex((struct in6_addr *) 701 &ar->ar_arg_termid_addr.at_addr[0]); 702 if (ar->ar_arg_termid_addr.at_type == AU_IPv4) 703 tok = au_to_in_addr((struct in_addr *) 704 &ar->ar_arg_termid_addr.at_addr[0]); 705 kau_write(rec, tok); 706 } 707 break; 708 709 case AUE_AUDITON: 710 /* 711 * For AUDITON commands without own event, audit the cmd. 712 */ 713 if (ARG_IS_VALID(kar, ARG_CMD)) { 714 tok = au_to_arg32(1, "cmd", ar->ar_arg_cmd); 715 kau_write(rec, tok); 716 } 717 /* FALLTHROUGH */ 718 719 case AUE_AUDITON_GETCAR: 720 case AUE_AUDITON_GETCLASS: 721 case AUE_AUDITON_GETCOND: 722 case AUE_AUDITON_GETCWD: 723 case AUE_AUDITON_GETKMASK: 724 case AUE_AUDITON_GETSTAT: 725 case AUE_AUDITON_GPOLICY: 726 case AUE_AUDITON_GQCTRL: 727 case AUE_AUDITON_SETCLASS: 728 case AUE_AUDITON_SETCOND: 729 case AUE_AUDITON_SETKMASK: 730 case AUE_AUDITON_SETSMASK: 731 case AUE_AUDITON_SETSTAT: 732 case AUE_AUDITON_SETUMASK: 733 case AUE_AUDITON_SPOLICY: 734 case AUE_AUDITON_SQCTRL: 735 if (ARG_IS_VALID(kar, ARG_AUDITON)) 736 audit_sys_auditon(ar, rec); 737 break; 738 739 case AUE_AUDITCTL: 740 UPATH1_VNODE1_TOKENS; 741 break; 742 743 case AUE_EXIT: 744 if (ARG_IS_VALID(kar, ARG_EXIT)) { 745 tok = au_to_exit(ar->ar_arg_exitretval, 746 ar->ar_arg_exitstatus); 747 kau_write(rec, tok); 748 } 749 break; 750 751 case AUE_ADJTIME: 752 case AUE_CLOCK_SETTIME: 753 case AUE_AUDIT: 754 case AUE_DUP2: 755 case AUE_GETAUDIT: 756 case AUE_GETAUDIT_ADDR: 757 case AUE_GETAUID: 758 case AUE_GETCWD: 759 case AUE_GETFSSTAT: 760 case AUE_GETRESUID: 761 case AUE_GETRESGID: 762 case AUE_KQUEUE: 763 case AUE_MODLOAD: 764 case AUE_MODUNLOAD: 765 case AUE_MSGSYS: 766 case AUE_NTP_ADJTIME: 767 case AUE_PIPE: 768 case AUE_POSIX_OPENPT: 769 case AUE_PROFILE: 770 case AUE_RTPRIO: 771 case AUE_SEMSYS: 772 case AUE_SETFIB: 773 case AUE_SHMSYS: 774 case AUE_SETPGRP: 775 case AUE_SETRLIMIT: 776 case AUE_SETSID: 777 case AUE_SETTIMEOFDAY: 778 case AUE_SYSARCH: 779 780 /* 781 * Header, subject, and return tokens added at end. 782 */ 783 break; 784 785 case AUE_ACL_DELETE_FD: 786 case AUE_ACL_DELETE_FILE: 787 case AUE_ACL_CHECK_FD: 788 case AUE_ACL_CHECK_FILE: 789 case AUE_ACL_CHECK_LINK: 790 case AUE_ACL_DELETE_LINK: 791 case AUE_ACL_GET_FD: 792 case AUE_ACL_GET_FILE: 793 case AUE_ACL_GET_LINK: 794 case AUE_ACL_SET_FD: 795 case AUE_ACL_SET_FILE: 796 case AUE_ACL_SET_LINK: 797 if (ARG_IS_VALID(kar, ARG_VALUE)) { 798 tok = au_to_arg32(1, "type", ar->ar_arg_value); 799 kau_write(rec, tok); 800 } 801 ATFD1_TOKENS(1); 802 UPATH1_VNODE1_TOKENS; 803 break; 804 805 /* 806 * NB: We may want to verify that the appropriate 807 * audit args are being processed here, but I think 808 * a bit analysis is required. 809 * 810 * Process AUE_JAIL_SET in the next block so we can pickup any path 811 * related tokens that might exist. 812 */ 813 case AUE_JAIL_GET: 814 case AUE_JAIL_ATTACH: 815 case AUE_JAIL_REMOVE: 816 break; 817 818 case AUE_JAIL_SET: 819 case AUE_CHDIR: 820 case AUE_CHROOT: 821 case AUE_FSTATAT: 822 case AUE_FUTIMESAT: 823 case AUE_GETATTRLIST: 824 case AUE_JAIL: 825 case AUE_LUTIMES: 826 case AUE_NFS_GETFH: 827 case AUE_LGETFH: 828 case AUE_LSTAT: 829 case AUE_LPATHCONF: 830 case AUE_PATHCONF: 831 case AUE_READLINK: 832 case AUE_READLINKAT: 833 case AUE_REVOKE: 834 case AUE_RMDIR: 835 case AUE_SEARCHFS: 836 case AUE_SETATTRLIST: 837 case AUE_STAT: 838 case AUE_STATFS: 839 case AUE_SWAPON: 840 case AUE_SWAPOFF: 841 case AUE_TRUNCATE: 842 case AUE_UNDELETE: 843 case AUE_UNLINK: 844 case AUE_UNLINKAT: 845 case AUE_UTIMES: 846 case AUE_REALPATHAT: 847 ATFD1_TOKENS(1); 848 UPATH1_VNODE1_TOKENS; 849 break; 850 851 case AUE_ACCESS: 852 case AUE_EACCESS: 853 case AUE_FACCESSAT: 854 ATFD1_TOKENS(1); 855 UPATH1_VNODE1_TOKENS; 856 if (ARG_IS_VALID(kar, ARG_VALUE)) { 857 tok = au_to_arg32(2, "mode", ar->ar_arg_value); 858 kau_write(rec, tok); 859 } 860 break; 861 862 case AUE_FHSTATFS: 863 case AUE_FHOPEN: 864 case AUE_FHSTAT: 865 /* XXXRW: Need to audit vnode argument. */ 866 break; 867 868 case AUE_CHFLAGS: 869 case AUE_LCHFLAGS: 870 case AUE_CHFLAGSAT: 871 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 872 tok = au_to_arg32(2, "flags", ar->ar_arg_fflags); 873 kau_write(rec, tok); 874 } 875 UPATH1_VNODE1_TOKENS; 876 break; 877 878 case AUE_CHMOD: 879 case AUE_LCHMOD: 880 if (ARG_IS_VALID(kar, ARG_MODE)) { 881 tok = au_to_arg32(2, "new file mode", 882 ar->ar_arg_mode); 883 kau_write(rec, tok); 884 } 885 UPATH1_VNODE1_TOKENS; 886 break; 887 888 case AUE_FCHMODAT: 889 ATFD1_TOKENS(1); 890 if (ARG_IS_VALID(kar, ARG_MODE)) { 891 tok = au_to_arg32(3, "new file mode", 892 ar->ar_arg_mode); 893 kau_write(rec, tok); 894 } 895 UPATH1_VNODE1_TOKENS; 896 break; 897 898 case AUE_CHOWN: 899 case AUE_LCHOWN: 900 if (ARG_IS_VALID(kar, ARG_UID)) { 901 tok = au_to_arg32(2, "new file uid", ar->ar_arg_uid); 902 kau_write(rec, tok); 903 } 904 if (ARG_IS_VALID(kar, ARG_GID)) { 905 tok = au_to_arg32(3, "new file gid", ar->ar_arg_gid); 906 kau_write(rec, tok); 907 } 908 UPATH1_VNODE1_TOKENS; 909 break; 910 911 case AUE_FCHOWNAT: 912 ATFD1_TOKENS(1); 913 if (ARG_IS_VALID(kar, ARG_UID)) { 914 tok = au_to_arg32(3, "new file uid", ar->ar_arg_uid); 915 kau_write(rec, tok); 916 } 917 if (ARG_IS_VALID(kar, ARG_GID)) { 918 tok = au_to_arg32(4, "new file gid", ar->ar_arg_gid); 919 kau_write(rec, tok); 920 } 921 UPATH1_VNODE1_TOKENS; 922 break; 923 924 case AUE_EXCHANGEDATA: 925 UPATH1_VNODE1_TOKENS; 926 UPATH2_TOKENS; 927 break; 928 929 case AUE_CLOSE: 930 if (ARG_IS_VALID(kar, ARG_FD)) { 931 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 932 kau_write(rec, tok); 933 } 934 UPATH1_VNODE1_TOKENS; 935 break; 936 937 case AUE_CLOSEFROM: 938 if (ARG_IS_VALID(kar, ARG_FD)) { 939 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 940 kau_write(rec, tok); 941 } 942 break; 943 944 case AUE_CORE: 945 if (ARG_IS_VALID(kar, ARG_SIGNUM)) { 946 tok = au_to_arg32(1, "signal", ar->ar_arg_signum); 947 kau_write(rec, tok); 948 } 949 UPATH1_VNODE1_TOKENS; 950 break; 951 952 case AUE_EXTATTRCTL: 953 UPATH1_VNODE1_TOKENS; 954 if (ARG_IS_VALID(kar, ARG_CMD)) { 955 tok = au_to_arg32(2, "cmd", ar->ar_arg_cmd); 956 kau_write(rec, tok); 957 } 958 /* extattrctl(2) filename parameter is in upath2/vnode2 */ 959 UPATH2_TOKENS; 960 VNODE2_TOKENS; 961 EXTATTR_TOKENS(4); 962 break; 963 964 case AUE_EXTATTR_GET_FILE: 965 case AUE_EXTATTR_SET_FILE: 966 case AUE_EXTATTR_LIST_FILE: 967 case AUE_EXTATTR_DELETE_FILE: 968 case AUE_EXTATTR_GET_LINK: 969 case AUE_EXTATTR_SET_LINK: 970 case AUE_EXTATTR_LIST_LINK: 971 case AUE_EXTATTR_DELETE_LINK: 972 UPATH1_VNODE1_TOKENS; 973 EXTATTR_TOKENS(2); 974 break; 975 976 case AUE_EXTATTR_GET_FD: 977 case AUE_EXTATTR_SET_FD: 978 case AUE_EXTATTR_LIST_FD: 979 case AUE_EXTATTR_DELETE_FD: 980 if (ARG_IS_VALID(kar, ARG_FD)) { 981 tok = au_to_arg32(2, "fd", ar->ar_arg_fd); 982 kau_write(rec, tok); 983 } 984 EXTATTR_TOKENS(2); 985 break; 986 987 case AUE_FEXECVE: 988 if (ARG_IS_VALID(kar, ARG_FD)) { 989 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 990 kau_write(rec, tok); 991 } 992 /* FALLTHROUGH */ 993 994 case AUE_EXECVE: 995 case AUE_MAC_EXECVE: 996 if (ARG_IS_VALID(kar, ARG_ARGV)) { 997 tok = au_to_exec_args(ar->ar_arg_argv, 998 ar->ar_arg_argc); 999 kau_write(rec, tok); 1000 } 1001 if (ARG_IS_VALID(kar, ARG_ENVV)) { 1002 tok = au_to_exec_env(ar->ar_arg_envv, 1003 ar->ar_arg_envc); 1004 kau_write(rec, tok); 1005 } 1006 UPATH1_VNODE1_TOKENS; 1007 break; 1008 1009 case AUE_FCHMOD: 1010 if (ARG_IS_VALID(kar, ARG_MODE)) { 1011 tok = au_to_arg32(2, "new file mode", 1012 ar->ar_arg_mode); 1013 kau_write(rec, tok); 1014 } 1015 FD_VNODE1_TOKENS; 1016 break; 1017 1018 /* 1019 * XXXRW: Some of these need to handle non-vnode cases as well. 1020 */ 1021 case AUE_FCHDIR: 1022 case AUE_FPATHCONF: 1023 case AUE_FSTAT: 1024 case AUE_FSTATFS: 1025 case AUE_FSYNC: 1026 case AUE_FTRUNCATE: 1027 case AUE_FUTIMES: 1028 case AUE_GETDIRENTRIES: 1029 case AUE_GETDIRENTRIESATTR: 1030 case AUE_LSEEK: 1031 case AUE_POLL: 1032 case AUE_POSIX_FALLOCATE: 1033 case AUE_PREAD: 1034 case AUE_PWRITE: 1035 case AUE_READ: 1036 case AUE_READV: 1037 case AUE_WRITE: 1038 case AUE_WRITEV: 1039 FD_VNODE1_TOKENS; 1040 break; 1041 1042 case AUE_FCHOWN: 1043 if (ARG_IS_VALID(kar, ARG_UID)) { 1044 tok = au_to_arg32(2, "new file uid", ar->ar_arg_uid); 1045 kau_write(rec, tok); 1046 } 1047 if (ARG_IS_VALID(kar, ARG_GID)) { 1048 tok = au_to_arg32(3, "new file gid", ar->ar_arg_gid); 1049 kau_write(rec, tok); 1050 } 1051 FD_VNODE1_TOKENS; 1052 break; 1053 1054 case AUE_FCNTL: 1055 if (ARG_IS_VALID(kar, ARG_CMD)) { 1056 tok = au_to_arg32(2, "cmd", 1057 au_fcntl_cmd_to_bsm(ar->ar_arg_cmd)); 1058 kau_write(rec, tok); 1059 } 1060 FD_VNODE1_TOKENS; 1061 break; 1062 1063 case AUE_FCHFLAGS: 1064 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1065 tok = au_to_arg32(2, "flags", ar->ar_arg_fflags); 1066 kau_write(rec, tok); 1067 } 1068 FD_VNODE1_TOKENS; 1069 break; 1070 1071 case AUE_FLOCK: 1072 if (ARG_IS_VALID(kar, ARG_CMD)) { 1073 tok = au_to_arg32(2, "operation", ar->ar_arg_cmd); 1074 kau_write(rec, tok); 1075 } 1076 FD_VNODE1_TOKENS; 1077 break; 1078 1079 case AUE_RFORK: 1080 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1081 tok = au_to_arg32(1, "flags", ar->ar_arg_fflags); 1082 kau_write(rec, tok); 1083 } 1084 /* FALLTHROUGH */ 1085 1086 case AUE_FORK: 1087 case AUE_VFORK: 1088 if (ARG_IS_VALID(kar, ARG_PID)) { 1089 tok = au_to_arg32(0, "child PID", ar->ar_arg_pid); 1090 kau_write(rec, tok); 1091 } 1092 break; 1093 1094 case AUE_IOCTL: 1095 if (ARG_IS_VALID(kar, ARG_CMD)) { 1096 tok = au_to_arg32(2, "cmd", ar->ar_arg_cmd); 1097 kau_write(rec, tok); 1098 } 1099 if (ARG_IS_VALID(kar, ARG_VNODE1)) 1100 FD_VNODE1_TOKENS; 1101 else { 1102 if (ARG_IS_VALID(kar, ARG_SOCKINFO)) { 1103 tok = kau_to_socket(&ar->ar_arg_sockinfo); 1104 kau_write(rec, tok); 1105 } else { 1106 if (ARG_IS_VALID(kar, ARG_FD)) { 1107 tok = au_to_arg32(1, "fd", 1108 ar->ar_arg_fd); 1109 kau_write(rec, tok); 1110 } 1111 } 1112 } 1113 break; 1114 1115 case AUE_KILL: 1116 case AUE_KILLPG: 1117 if (ARG_IS_VALID(kar, ARG_SIGNUM)) { 1118 tok = au_to_arg32(2, "signal", ar->ar_arg_signum); 1119 kau_write(rec, tok); 1120 } 1121 PROCESS_PID_TOKENS(1); 1122 break; 1123 1124 case AUE_KTRACE: 1125 if (ARG_IS_VALID(kar, ARG_CMD)) { 1126 tok = au_to_arg32(2, "ops", ar->ar_arg_cmd); 1127 kau_write(rec, tok); 1128 } 1129 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1130 tok = au_to_arg32(3, "trpoints", ar->ar_arg_value); 1131 kau_write(rec, tok); 1132 } 1133 PROCESS_PID_TOKENS(4); 1134 UPATH1_VNODE1_TOKENS; 1135 break; 1136 1137 case AUE_LINK: 1138 case AUE_LINKAT: 1139 case AUE_RENAME: 1140 case AUE_RENAMEAT: 1141 ATFD1_TOKENS(1); 1142 UPATH1_VNODE1_TOKENS; 1143 ATFD2_TOKENS(3); 1144 UPATH2_TOKENS; 1145 break; 1146 1147 case AUE_LOADSHFILE: 1148 ADDR_TOKEN(4, "base addr"); 1149 UPATH1_VNODE1_TOKENS; 1150 break; 1151 1152 case AUE_MKDIR: 1153 case AUE_MKDIRAT: 1154 case AUE_MKFIFO: 1155 case AUE_MKFIFOAT: 1156 ATFD1_TOKENS(1); 1157 if (ARG_IS_VALID(kar, ARG_MODE)) { 1158 tok = au_to_arg32(2, "mode", ar->ar_arg_mode); 1159 kau_write(rec, tok); 1160 } 1161 UPATH1_VNODE1_TOKENS; 1162 break; 1163 1164 case AUE_MKNOD: 1165 case AUE_MKNODAT: 1166 ATFD1_TOKENS(1); 1167 if (ARG_IS_VALID(kar, ARG_MODE)) { 1168 tok = au_to_arg32(2, "mode", ar->ar_arg_mode); 1169 kau_write(rec, tok); 1170 } 1171 if (ARG_IS_VALID(kar, ARG_DEV)) { 1172 tok = au_to_arg32(3, "dev", ar->ar_arg_dev); 1173 kau_write(rec, tok); 1174 } 1175 UPATH1_VNODE1_TOKENS; 1176 break; 1177 1178 case AUE_MMAP: 1179 case AUE_MUNMAP: 1180 case AUE_MPROTECT: 1181 case AUE_MLOCK: 1182 case AUE_MUNLOCK: 1183 case AUE_MINHERIT: 1184 ADDR_TOKEN(1, "addr"); 1185 if (ARG_IS_VALID(kar, ARG_LEN)) { 1186 tok = au_to_arg32(2, "len", ar->ar_arg_len); 1187 kau_write(rec, tok); 1188 } 1189 if (ar->ar_event == AUE_MMAP) 1190 FD_VNODE1_TOKENS; 1191 if (ar->ar_event == AUE_MPROTECT) { 1192 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1193 tok = au_to_arg32(3, "protection", 1194 ar->ar_arg_value); 1195 kau_write(rec, tok); 1196 } 1197 } 1198 if (ar->ar_event == AUE_MINHERIT) { 1199 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1200 tok = au_to_arg32(3, "inherit", 1201 ar->ar_arg_value); 1202 kau_write(rec, tok); 1203 } 1204 } 1205 break; 1206 1207 case AUE_MOUNT: 1208 case AUE_NMOUNT: 1209 /* XXX Need to handle NFS mounts */ 1210 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1211 tok = au_to_arg32(3, "flags", ar->ar_arg_fflags); 1212 kau_write(rec, tok); 1213 } 1214 if (ARG_IS_VALID(kar, ARG_TEXT)) { 1215 tok = au_to_text(ar->ar_arg_text); 1216 kau_write(rec, tok); 1217 } 1218 /* FALLTHROUGH */ 1219 1220 case AUE_NFS_SVC: 1221 if (ARG_IS_VALID(kar, ARG_CMD)) { 1222 tok = au_to_arg32(1, "flags", ar->ar_arg_cmd); 1223 kau_write(rec, tok); 1224 } 1225 break; 1226 1227 case AUE_UMOUNT: 1228 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1229 tok = au_to_arg32(2, "flags", ar->ar_arg_value); 1230 kau_write(rec, tok); 1231 } 1232 UPATH1_VNODE1_TOKENS; 1233 if (ARG_IS_VALID(kar, ARG_TEXT)) { 1234 tok = au_to_text(ar->ar_arg_text); 1235 kau_write(rec, tok); 1236 } 1237 break; 1238 1239 case AUE_MSGCTL: 1240 ar->ar_event = audit_msgctl_to_event(ar->ar_arg_svipc_cmd); 1241 /* Fall through */ 1242 1243 case AUE_MSGRCV: 1244 case AUE_MSGSND: 1245 tok = au_to_arg32(1, "msg ID", ar->ar_arg_svipc_id); 1246 kau_write(rec, tok); 1247 if (ar->ar_errno != EINVAL) { 1248 tok = au_to_ipc(AT_IPC_MSG, ar->ar_arg_svipc_id); 1249 kau_write(rec, tok); 1250 } 1251 break; 1252 1253 case AUE_MSGGET: 1254 if (ar->ar_errno == 0) { 1255 if (ARG_IS_VALID(kar, ARG_SVIPC_ID)) { 1256 tok = au_to_ipc(AT_IPC_MSG, 1257 ar->ar_arg_svipc_id); 1258 kau_write(rec, tok); 1259 } 1260 } 1261 break; 1262 1263 case AUE_RESETSHFILE: 1264 ADDR_TOKEN(1, "base addr"); 1265 break; 1266 1267 case AUE_OPEN_RC: 1268 case AUE_OPEN_RTC: 1269 case AUE_OPEN_RWC: 1270 case AUE_OPEN_RWTC: 1271 case AUE_OPEN_WC: 1272 case AUE_OPEN_WTC: 1273 case AUE_CREAT: 1274 if (ARG_IS_VALID(kar, ARG_MODE)) { 1275 tok = au_to_arg32(3, "mode", ar->ar_arg_mode); 1276 kau_write(rec, tok); 1277 } 1278 /* FALLTHROUGH */ 1279 1280 case AUE_OPEN_R: 1281 case AUE_OPEN_RT: 1282 case AUE_OPEN_RW: 1283 case AUE_OPEN_RWT: 1284 case AUE_OPEN_W: 1285 case AUE_OPEN_WT: 1286 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1287 tok = au_to_arg32(2, "flags", ar->ar_arg_fflags); 1288 kau_write(rec, tok); 1289 } 1290 UPATH1_VNODE1_TOKENS; 1291 break; 1292 1293 case AUE_OPENAT_RC: 1294 case AUE_OPENAT_RTC: 1295 case AUE_OPENAT_RWC: 1296 case AUE_OPENAT_RWTC: 1297 case AUE_OPENAT_WC: 1298 case AUE_OPENAT_WTC: 1299 if (ARG_IS_VALID(kar, ARG_MODE)) { 1300 tok = au_to_arg32(3, "mode", ar->ar_arg_mode); 1301 kau_write(rec, tok); 1302 } 1303 /* FALLTHROUGH */ 1304 1305 case AUE_OPENAT_R: 1306 case AUE_OPENAT_RT: 1307 case AUE_OPENAT_RW: 1308 case AUE_OPENAT_RWT: 1309 case AUE_OPENAT_W: 1310 case AUE_OPENAT_WT: 1311 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1312 tok = au_to_arg32(2, "flags", ar->ar_arg_fflags); 1313 kau_write(rec, tok); 1314 } 1315 ATFD1_TOKENS(1); 1316 UPATH1_VNODE1_TOKENS; 1317 break; 1318 1319 case AUE_PDKILL: 1320 if (ARG_IS_VALID(kar, ARG_FD)) { 1321 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 1322 kau_write(rec, tok); 1323 } 1324 if (ARG_IS_VALID(kar, ARG_SIGNUM)) { 1325 tok = au_to_arg32(2, "signal", ar->ar_arg_signum); 1326 kau_write(rec, tok); 1327 } 1328 PROCESS_PID_TOKENS(1); 1329 break; 1330 case AUE_PDFORK: 1331 if (ARG_IS_VALID(kar, ARG_PID)) { 1332 tok = au_to_arg32(0, "child PID", ar->ar_arg_pid); 1333 kau_write(rec, tok); 1334 } 1335 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1336 tok = au_to_arg32(2, "flags", ar->ar_arg_fflags); 1337 kau_write(rec, tok); 1338 } 1339 if (ARG_IS_VALID(kar, ARG_FD)) { 1340 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 1341 kau_write(rec, tok); 1342 } 1343 break; 1344 case AUE_PDGETPID: 1345 if (ARG_IS_VALID(kar, ARG_FD)) { 1346 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 1347 kau_write(rec, tok); 1348 } 1349 break; 1350 1351 case AUE_PROCCTL: 1352 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1353 tok = au_to_arg32(1, "idtype", ar->ar_arg_value); 1354 kau_write(rec, tok); 1355 } 1356 if (ARG_IS_VALID(kar, ARG_CMD)) { 1357 tok = au_to_arg32(2, "com", ar->ar_arg_cmd); 1358 kau_write(rec, tok); 1359 } 1360 PROCESS_PID_TOKENS(3); 1361 break; 1362 1363 case AUE_PTRACE: 1364 if (ARG_IS_VALID(kar, ARG_CMD)) { 1365 tok = au_to_arg32(1, "request", ar->ar_arg_cmd); 1366 kau_write(rec, tok); 1367 } 1368 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1369 tok = au_to_arg32(4, "data", ar->ar_arg_value); 1370 kau_write(rec, tok); 1371 } 1372 PROCESS_PID_TOKENS(2); 1373 break; 1374 1375 case AUE_QUOTACTL: 1376 if (ARG_IS_VALID(kar, ARG_CMD)) { 1377 tok = au_to_arg32(2, "command", ar->ar_arg_cmd); 1378 kau_write(rec, tok); 1379 } 1380 if (ARG_IS_VALID(kar, ARG_UID)) { 1381 tok = au_to_arg32(3, "uid", ar->ar_arg_uid); 1382 kau_write(rec, tok); 1383 } 1384 if (ARG_IS_VALID(kar, ARG_GID)) { 1385 tok = au_to_arg32(3, "gid", ar->ar_arg_gid); 1386 kau_write(rec, tok); 1387 } 1388 UPATH1_VNODE1_TOKENS; 1389 break; 1390 1391 case AUE_REBOOT: 1392 if (ARG_IS_VALID(kar, ARG_CMD)) { 1393 tok = au_to_arg32(1, "howto", ar->ar_arg_cmd); 1394 kau_write(rec, tok); 1395 } 1396 break; 1397 1398 case AUE_SEMCTL: 1399 ar->ar_event = audit_semctl_to_event(ar->ar_arg_svipc_cmd); 1400 /* Fall through */ 1401 1402 case AUE_SEMOP: 1403 if (ARG_IS_VALID(kar, ARG_SVIPC_ID)) { 1404 tok = au_to_arg32(1, "sem ID", ar->ar_arg_svipc_id); 1405 kau_write(rec, tok); 1406 if (ar->ar_errno != EINVAL) { 1407 tok = au_to_ipc(AT_IPC_SEM, 1408 ar->ar_arg_svipc_id); 1409 kau_write(rec, tok); 1410 } 1411 } 1412 break; 1413 1414 case AUE_SEMGET: 1415 if (ar->ar_errno == 0) { 1416 if (ARG_IS_VALID(kar, ARG_SVIPC_ID)) { 1417 tok = au_to_ipc(AT_IPC_SEM, 1418 ar->ar_arg_svipc_id); 1419 kau_write(rec, tok); 1420 } 1421 } 1422 break; 1423 1424 case AUE_SETEGID: 1425 if (ARG_IS_VALID(kar, ARG_EGID)) { 1426 tok = au_to_arg32(1, "egid", ar->ar_arg_egid); 1427 kau_write(rec, tok); 1428 } 1429 break; 1430 1431 case AUE_SETEUID: 1432 if (ARG_IS_VALID(kar, ARG_EUID)) { 1433 tok = au_to_arg32(1, "euid", ar->ar_arg_euid); 1434 kau_write(rec, tok); 1435 } 1436 break; 1437 1438 case AUE_SETREGID: 1439 if (ARG_IS_VALID(kar, ARG_RGID)) { 1440 tok = au_to_arg32(1, "rgid", ar->ar_arg_rgid); 1441 kau_write(rec, tok); 1442 } 1443 if (ARG_IS_VALID(kar, ARG_EGID)) { 1444 tok = au_to_arg32(2, "egid", ar->ar_arg_egid); 1445 kau_write(rec, tok); 1446 } 1447 break; 1448 1449 case AUE_SETREUID: 1450 if (ARG_IS_VALID(kar, ARG_RUID)) { 1451 tok = au_to_arg32(1, "ruid", ar->ar_arg_ruid); 1452 kau_write(rec, tok); 1453 } 1454 if (ARG_IS_VALID(kar, ARG_EUID)) { 1455 tok = au_to_arg32(2, "euid", ar->ar_arg_euid); 1456 kau_write(rec, tok); 1457 } 1458 break; 1459 1460 case AUE_SETRESGID: 1461 if (ARG_IS_VALID(kar, ARG_RGID)) { 1462 tok = au_to_arg32(1, "rgid", ar->ar_arg_rgid); 1463 kau_write(rec, tok); 1464 } 1465 if (ARG_IS_VALID(kar, ARG_EGID)) { 1466 tok = au_to_arg32(2, "egid", ar->ar_arg_egid); 1467 kau_write(rec, tok); 1468 } 1469 if (ARG_IS_VALID(kar, ARG_SGID)) { 1470 tok = au_to_arg32(3, "sgid", ar->ar_arg_sgid); 1471 kau_write(rec, tok); 1472 } 1473 break; 1474 1475 case AUE_SETRESUID: 1476 if (ARG_IS_VALID(kar, ARG_RUID)) { 1477 tok = au_to_arg32(1, "ruid", ar->ar_arg_ruid); 1478 kau_write(rec, tok); 1479 } 1480 if (ARG_IS_VALID(kar, ARG_EUID)) { 1481 tok = au_to_arg32(2, "euid", ar->ar_arg_euid); 1482 kau_write(rec, tok); 1483 } 1484 if (ARG_IS_VALID(kar, ARG_SUID)) { 1485 tok = au_to_arg32(3, "suid", ar->ar_arg_suid); 1486 kau_write(rec, tok); 1487 } 1488 break; 1489 1490 case AUE_SETGID: 1491 if (ARG_IS_VALID(kar, ARG_GID)) { 1492 tok = au_to_arg32(1, "gid", ar->ar_arg_gid); 1493 kau_write(rec, tok); 1494 } 1495 break; 1496 1497 case AUE_SETUID: 1498 if (ARG_IS_VALID(kar, ARG_UID)) { 1499 tok = au_to_arg32(1, "uid", ar->ar_arg_uid); 1500 kau_write(rec, tok); 1501 } 1502 break; 1503 1504 case AUE_SETGROUPS: 1505 if (ARG_IS_VALID(kar, ARG_GROUPSET)) { 1506 for(ctr = 0; ctr < ar->ar_arg_groups.gidset_size; ctr++) 1507 { 1508 tok = au_to_arg32(1, "setgroups", 1509 ar->ar_arg_groups.gidset[ctr]); 1510 kau_write(rec, tok); 1511 } 1512 } 1513 break; 1514 1515 case AUE_SETLOGIN: 1516 if (ARG_IS_VALID(kar, ARG_LOGIN)) { 1517 tok = au_to_text(ar->ar_arg_login); 1518 kau_write(rec, tok); 1519 } 1520 break; 1521 1522 case AUE_SETLOGINCLASS: 1523 break; 1524 1525 case AUE_SETPRIORITY: 1526 if (ARG_IS_VALID(kar, ARG_CMD)) { 1527 tok = au_to_arg32(1, "which", ar->ar_arg_cmd); 1528 kau_write(rec, tok); 1529 } 1530 if (ARG_IS_VALID(kar, ARG_UID)) { 1531 tok = au_to_arg32(2, "who", ar->ar_arg_uid); 1532 kau_write(rec, tok); 1533 } 1534 PROCESS_PID_TOKENS(2); 1535 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1536 tok = au_to_arg32(3, "priority", ar->ar_arg_value); 1537 kau_write(rec, tok); 1538 } 1539 break; 1540 1541 case AUE_SETPRIVEXEC: 1542 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1543 tok = au_to_arg32(1, "flag", ar->ar_arg_value); 1544 kau_write(rec, tok); 1545 } 1546 break; 1547 1548 /* AUE_SHMAT, AUE_SHMCTL, AUE_SHMDT and AUE_SHMGET are SysV IPC */ 1549 case AUE_SHMAT: 1550 if (ARG_IS_VALID(kar, ARG_SVIPC_ID)) { 1551 tok = au_to_arg32(1, "shmid", ar->ar_arg_svipc_id); 1552 kau_write(rec, tok); 1553 /* XXXAUDIT: Does having the ipc token make sense? */ 1554 tok = au_to_ipc(AT_IPC_SHM, ar->ar_arg_svipc_id); 1555 kau_write(rec, tok); 1556 } 1557 if (ARG_IS_VALID(kar, ARG_SVIPC_ADDR)) { 1558 tok = au_to_arg32(2, "shmaddr", 1559 (int)(uintptr_t)ar->ar_arg_svipc_addr); 1560 kau_write(rec, tok); 1561 } 1562 if (ARG_IS_VALID(kar, ARG_SVIPC_PERM)) { 1563 tok = au_to_ipc_perm(&ar->ar_arg_svipc_perm); 1564 kau_write(rec, tok); 1565 } 1566 break; 1567 1568 case AUE_SHMCTL: 1569 if (ARG_IS_VALID(kar, ARG_SVIPC_ID)) { 1570 tok = au_to_arg32(1, "shmid", ar->ar_arg_svipc_id); 1571 kau_write(rec, tok); 1572 /* XXXAUDIT: Does having the ipc token make sense? */ 1573 tok = au_to_ipc(AT_IPC_SHM, ar->ar_arg_svipc_id); 1574 kau_write(rec, tok); 1575 } 1576 switch (ar->ar_arg_svipc_cmd) { 1577 case IPC_STAT: 1578 ar->ar_event = AUE_SHMCTL_STAT; 1579 break; 1580 case IPC_RMID: 1581 ar->ar_event = AUE_SHMCTL_RMID; 1582 break; 1583 case IPC_SET: 1584 ar->ar_event = AUE_SHMCTL_SET; 1585 if (ARG_IS_VALID(kar, ARG_SVIPC_PERM)) { 1586 tok = au_to_ipc_perm(&ar->ar_arg_svipc_perm); 1587 kau_write(rec, tok); 1588 } 1589 break; 1590 default: 1591 break; /* We will audit a bad command */ 1592 } 1593 break; 1594 1595 case AUE_SHMDT: 1596 if (ARG_IS_VALID(kar, ARG_SVIPC_ADDR)) { 1597 tok = au_to_arg32(1, "shmaddr", 1598 (int)(uintptr_t)ar->ar_arg_svipc_addr); 1599 kau_write(rec, tok); 1600 } 1601 break; 1602 1603 case AUE_SHMGET: 1604 /* This is unusual; the return value is in an argument token */ 1605 if (ARG_IS_VALID(kar, ARG_SVIPC_ID)) { 1606 tok = au_to_arg32(0, "shmid", ar->ar_arg_svipc_id); 1607 kau_write(rec, tok); 1608 tok = au_to_ipc(AT_IPC_SHM, ar->ar_arg_svipc_id); 1609 kau_write(rec, tok); 1610 } 1611 if (ARG_IS_VALID(kar, ARG_SVIPC_PERM)) { 1612 tok = au_to_ipc_perm(&ar->ar_arg_svipc_perm); 1613 kau_write(rec, tok); 1614 } 1615 break; 1616 1617 /* shm_rename is a non-Posix extension to the Posix shm implementation */ 1618 case AUE_SHMRENAME: 1619 UPATH1_TOKENS; 1620 UPATH2_TOKENS; 1621 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1622 tok = au_to_arg32(2, "flags", ar->ar_arg_fflags); 1623 kau_write(rec, tok); 1624 } 1625 break; 1626 1627 /* AUE_SHMOPEN, AUE_SHMUNLINK, AUE_SEMOPEN, AUE_SEMCLOSE 1628 * and AUE_SEMUNLINK are Posix IPC */ 1629 case AUE_SHMOPEN: 1630 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1631 tok = au_to_arg32(2, "flags", ar->ar_arg_fflags); 1632 kau_write(rec, tok); 1633 } 1634 if (ARG_IS_VALID(kar, ARG_MODE)) { 1635 tok = au_to_arg32(3, "mode", ar->ar_arg_mode); 1636 kau_write(rec, tok); 1637 } 1638 /* FALLTHROUGH */ 1639 1640 case AUE_SHMUNLINK: 1641 UPATH1_TOKENS; 1642 if (ARG_IS_VALID(kar, ARG_POSIX_IPC_PERM)) { 1643 struct ipc_perm perm; 1644 1645 perm.uid = ar->ar_arg_pipc_perm.pipc_uid; 1646 perm.gid = ar->ar_arg_pipc_perm.pipc_gid; 1647 perm.cuid = ar->ar_arg_pipc_perm.pipc_uid; 1648 perm.cgid = ar->ar_arg_pipc_perm.pipc_gid; 1649 perm.mode = ar->ar_arg_pipc_perm.pipc_mode; 1650 perm.seq = 0; 1651 perm.key = 0; 1652 tok = au_to_ipc_perm(&perm); 1653 kau_write(rec, tok); 1654 } 1655 break; 1656 1657 case AUE_SEMOPEN: 1658 if (ARG_IS_VALID(kar, ARG_FFLAGS)) { 1659 tok = au_to_arg32(2, "flags", ar->ar_arg_fflags); 1660 kau_write(rec, tok); 1661 } 1662 if (ARG_IS_VALID(kar, ARG_MODE)) { 1663 tok = au_to_arg32(3, "mode", ar->ar_arg_mode); 1664 kau_write(rec, tok); 1665 } 1666 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1667 tok = au_to_arg32(4, "value", ar->ar_arg_value); 1668 kau_write(rec, tok); 1669 } 1670 /* FALLTHROUGH */ 1671 1672 case AUE_SEMUNLINK: 1673 if (ARG_IS_VALID(kar, ARG_TEXT)) { 1674 tok = au_to_text(ar->ar_arg_text); 1675 kau_write(rec, tok); 1676 } 1677 if (ARG_IS_VALID(kar, ARG_POSIX_IPC_PERM)) { 1678 struct ipc_perm perm; 1679 1680 perm.uid = ar->ar_arg_pipc_perm.pipc_uid; 1681 perm.gid = ar->ar_arg_pipc_perm.pipc_gid; 1682 perm.cuid = ar->ar_arg_pipc_perm.pipc_uid; 1683 perm.cgid = ar->ar_arg_pipc_perm.pipc_gid; 1684 perm.mode = ar->ar_arg_pipc_perm.pipc_mode; 1685 perm.seq = 0; 1686 perm.key = 0; 1687 tok = au_to_ipc_perm(&perm); 1688 kau_write(rec, tok); 1689 } 1690 break; 1691 1692 case AUE_SEMCLOSE: 1693 if (ARG_IS_VALID(kar, ARG_FD)) { 1694 tok = au_to_arg32(1, "sem", ar->ar_arg_fd); 1695 kau_write(rec, tok); 1696 } 1697 break; 1698 1699 case AUE_SYMLINK: 1700 case AUE_SYMLINKAT: 1701 if (ARG_IS_VALID(kar, ARG_TEXT)) { 1702 tok = au_to_text(ar->ar_arg_text); 1703 kau_write(rec, tok); 1704 } 1705 ATFD1_TOKENS(1); 1706 UPATH1_VNODE1_TOKENS; 1707 break; 1708 1709 case AUE_SYSCTL: 1710 case AUE_SYSCTL_NONADMIN: 1711 if (ARG_IS_VALID(kar, ARG_CTLNAME | ARG_LEN)) { 1712 for (ctr = 0; ctr < ar->ar_arg_len; ctr++) { 1713 tok = au_to_arg32(1, "name", 1714 ar->ar_arg_ctlname[ctr]); 1715 kau_write(rec, tok); 1716 } 1717 } 1718 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1719 tok = au_to_arg32(5, "newval", ar->ar_arg_value); 1720 kau_write(rec, tok); 1721 } 1722 if (ARG_IS_VALID(kar, ARG_TEXT)) { 1723 tok = au_to_text(ar->ar_arg_text); 1724 kau_write(rec, tok); 1725 } 1726 break; 1727 1728 case AUE_UMASK: 1729 if (ARG_IS_VALID(kar, ARG_MASK)) { 1730 tok = au_to_arg32(1, "new mask", ar->ar_arg_mask); 1731 kau_write(rec, tok); 1732 } 1733 tok = au_to_arg32(0, "prev mask", ar->ar_retval); 1734 kau_write(rec, tok); 1735 break; 1736 1737 case AUE_WAIT4: 1738 case AUE_WAIT6: 1739 PROCESS_PID_TOKENS(1); 1740 if (ARG_IS_VALID(kar, ARG_VALUE)) { 1741 tok = au_to_arg32(3, "options", ar->ar_arg_value); 1742 kau_write(rec, tok); 1743 } 1744 break; 1745 1746 case AUE_CAP_RIGHTS_LIMIT: 1747 /* 1748 * XXXRW/XXXJA: Would be nice to audit socket/etc information. 1749 */ 1750 FD_VNODE1_TOKENS; 1751 if (ARG_IS_VALID(kar, ARG_RIGHTS)) { 1752 tok = au_to_rights(&ar->ar_arg_rights); 1753 kau_write(rec, tok); 1754 } 1755 break; 1756 1757 case AUE_CAP_FCNTLS_GET: 1758 case AUE_CAP_IOCTLS_GET: 1759 case AUE_CAP_IOCTLS_LIMIT: 1760 case AUE_CAP_RIGHTS_GET: 1761 if (ARG_IS_VALID(kar, ARG_FD)) { 1762 tok = au_to_arg32(1, "fd", ar->ar_arg_fd); 1763 kau_write(rec, tok); 1764 } 1765 break; 1766 1767 case AUE_CAP_FCNTLS_LIMIT: 1768 FD_VNODE1_TOKENS; 1769 if (ARG_IS_VALID(kar, ARG_FCNTL_RIGHTS)) { 1770 tok = au_to_arg32(2, "fcntlrights", 1771 ar->ar_arg_fcntl_rights); 1772 kau_write(rec, tok); 1773 } 1774 break; 1775 1776 case AUE_CAP_ENTER: 1777 case AUE_CAP_GETMODE: 1778 break; 1779 1780 case AUE_THR_NEW: 1781 case AUE_THR_KILL: 1782 case AUE_THR_EXIT: 1783 break; 1784 1785 case AUE_NULL: 1786 default: 1787 printf("BSM conversion requested for unknown event %d\n", 1788 ar->ar_event); 1789 1790 /* 1791 * Write the subject token so it is properly freed here. 1792 */ 1793 if (jail_tok != NULL) 1794 kau_write(rec, jail_tok); 1795 kau_write(rec, subj_tok); 1796 kau_free(rec); 1797 return (BSM_NOAUDIT); 1798 } 1799 1800 if (jail_tok != NULL) 1801 kau_write(rec, jail_tok); 1802 kau_write(rec, subj_tok); 1803 tok = au_to_return32(au_errno_to_bsm(ar->ar_errno), ar->ar_retval); 1804 kau_write(rec, tok); /* Every record gets a return token */ 1805 1806 kau_close(rec, &ar->ar_endtime, ar->ar_event); 1807 1808 *pau = rec; 1809 return (BSM_SUCCESS); 1810 } 1811 1812 /* 1813 * Verify that a record is a valid BSM record. This verification is simple 1814 * now, but may be expanded on sometime in the future. Return 1 if the 1815 * record is good, 0 otherwise. 1816 */ 1817 int 1818 bsm_rec_verify(void *rec) 1819 { 1820 char c = *(char *)rec; 1821 1822 /* 1823 * Check the token ID of the first token; it has to be a header 1824 * token. 1825 * 1826 * XXXAUDIT There needs to be a token structure to map a token. 1827 * XXXAUDIT 'Shouldn't be simply looking at the first char. 1828 */ 1829 if ((c != AUT_HEADER32) && (c != AUT_HEADER32_EX) && 1830 (c != AUT_HEADER64) && (c != AUT_HEADER64_EX)) 1831 return (0); 1832 return (1); 1833 } 1834