1 /*- 2 * Copyright (c) 2006 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $P4: //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#5 $ 27 */ 28 29 /* 30 * Generate a series of BSM token samples in the requested directory. 31 */ 32 33 #include <sys/types.h> 34 #include <sys/socket.h> 35 #include <sys/stat.h> 36 37 #include <netinet/in.h> 38 #include <netinet/in_systm.h> 39 #include <netinet/ip.h> 40 41 #include <arpa/inet.h> 42 43 #include <bsm/audit_kevents.h> 44 #include <bsm/libbsm.h> 45 46 #include <err.h> 47 #include <errno.h> 48 #include <fcntl.h> 49 #include <limits.h> 50 #include <stdio.h> 51 #include <stdlib.h> 52 #include <string.h> 53 #include <sysexits.h> 54 #include <unistd.h> 55 56 static int do_records, do_tokens; 57 58 static void 59 usage(void) 60 { 61 62 fprintf(stderr, "generate [-rt] path\n"); 63 exit(EX_USAGE); 64 } 65 66 static int 67 open_file(const char *directory, const char *name) 68 { 69 char pathname[PATH_MAX]; 70 int fd; 71 72 snprintf(pathname, PATH_MAX, "%s/%s", directory, name); 73 (void)unlink(pathname); 74 fd = open(pathname, O_WRONLY | O_CREAT | O_EXCL, 0600); 75 if (fd < 0) 76 err(EX_CANTCREAT, "open: %s", name); 77 return (fd); 78 } 79 80 static void 81 write_file(int fd, void *buffer, size_t buflen, const char *filename) 82 { 83 ssize_t len; 84 85 len = write(fd, buffer, buflen); 86 if (len < 0) 87 err(EX_OSERR, "write_file: %s", filename); 88 if (len < buflen) 89 err(EX_OSERR, "write_file: short write: %s", filename); 90 } 91 92 /* 93 * Write a single token to a file. 94 */ 95 static void 96 write_token(const char *directory, const char *filename, token_t *tok) 97 { 98 u_char buffer[MAX_AUDIT_RECORD_SIZE]; 99 size_t buflen; 100 int fd; 101 102 buflen = MAX_AUDIT_RECORD_SIZE; 103 if (au_close_token(tok, buffer, &buflen) < 0) 104 err(EX_UNAVAILABLE, "au_close_token"); 105 fd = open_file(directory, filename); 106 write_file(fd, buffer, buflen, filename); 107 close(fd); 108 } 109 110 /* 111 * Write a token to a file, wrapped in audit record header and trailer. 112 */ 113 static void 114 write_record(const char *directory, const char *filename, token_t *tok, 115 short event) 116 { 117 u_char buffer[MAX_AUDIT_RECORD_SIZE]; 118 size_t buflen; 119 int au, fd; 120 121 au = au_open(); 122 if (au < 0) 123 err(EX_UNAVAILABLE, "au_open"); 124 if (au_write(au, tok) < 0) 125 err(EX_UNAVAILABLE, "au_write"); 126 buflen = MAX_AUDIT_RECORD_SIZE; 127 if (au_close_buffer(au, event, buffer, &buflen) < 0) 128 err(EX_UNAVAILABLE, "au_close_buffer"); 129 fd = open_file(directory, filename); 130 write_file(fd, buffer, buflen, filename); 131 close(fd); 132 } 133 134 static struct timeval file_token_timeval = { 0x12345, 0x67890} ; 135 136 static void 137 generate_file_token(const char *directory, const char *token_filename) 138 { 139 token_t *file_token; 140 141 file_token = au_to_file("test", file_token_timeval); 142 if (file_token == NULL) 143 err(EX_UNAVAILABLE, "au_to_file"); 144 write_token(directory, token_filename, file_token); 145 } 146 147 static void 148 generate_file_record(const char *directory, const char *record_filename) 149 { 150 token_t *file_token; 151 152 file_token = au_to_file("test", file_token_timeval); 153 if (file_token == NULL) 154 err(EX_UNAVAILABLE, "au_to_file"); 155 write_record(directory, record_filename, file_token, AUE_NULL); 156 } 157 158 /* 159 * AUT_OHEADER 160 */ 161 162 static int trailer_token_len = 0x12345678; 163 164 static void 165 generate_trailer_token(const char *directory, const char *token_filename) 166 { 167 token_t *trailer_token; 168 169 trailer_token = au_to_trailer(trailer_token_len); 170 if (trailer_token == NULL) 171 err(EX_UNAVAILABLE, "au_to_trailer"); 172 write_token(directory, token_filename, trailer_token); 173 } 174 175 static int header32_token_len = 0x12345678; 176 static au_event_t header32_e_type = AUE_OPEN; 177 static au_emod_t header32_e_mod = 0x4567; 178 static struct timeval header32_tm = { 0x12345, 0x67890 }; 179 180 static void 181 generate_header32_token(const char *directory, const char *token_filename) 182 { 183 token_t *header32_token; 184 185 header32_token = au_to_header32_tm(header32_token_len, 186 header32_e_type, header32_e_mod, header32_tm); 187 if (header32_token == NULL) 188 err(EX_UNAVAILABLE, "au_to_header32"); 189 write_token(directory, token_filename, header32_token); 190 } 191 192 /* 193 * AUT_HEADER32_EX 194 */ 195 196 static char data_token_unit_print = AUP_STRING; 197 static char data_token_unit_type = AUR_CHAR; 198 static char *data_token_data = "SomeData"; 199 static char data_token_unit_count = sizeof("SomeData") + 1; 200 201 static void 202 generate_data_token(const char *directory, const char *token_filename) 203 { 204 token_t *data_token; 205 206 data_token = au_to_data(data_token_unit_print, data_token_unit_type, 207 data_token_unit_count, data_token_data); 208 if (data_token == NULL) 209 err(EX_UNAVAILABLE, "au_to_data"); 210 write_token(directory, token_filename, data_token); 211 } 212 213 static void 214 generate_data_record(const char *directory, const char *record_filename) 215 { 216 token_t *data_token; 217 218 data_token = au_to_data(data_token_unit_print, data_token_unit_type, 219 data_token_unit_count, data_token_data); 220 if (data_token == NULL) 221 err(EX_UNAVAILABLE, "au_to_data"); 222 write_record(directory, record_filename, data_token, AUE_NULL); 223 } 224 225 static char ipc_type = AT_IPC_MSG; 226 static int ipc_id = 0x12345678; 227 228 static void 229 generate_ipc_token(const char *directory, const char *token_filename) 230 { 231 token_t *ipc_token; 232 233 ipc_token = au_to_ipc(ipc_type, ipc_id); 234 if (ipc_token == NULL) 235 err(EX_UNAVAILABLE, "au_to_ipc"); 236 write_token(directory, token_filename, ipc_token); 237 } 238 239 static void 240 generate_ipc_record(const char *directory, const char *record_filename) 241 { 242 token_t *ipc_token; 243 244 ipc_token = au_to_ipc(ipc_type, ipc_id); 245 if (ipc_token == NULL) 246 err(EX_UNAVAILABLE, "au_to_ipc"); 247 write_record(directory, record_filename, ipc_token, AUE_NULL); 248 } 249 250 static char *path_token_path = "/test/this/is/a/test"; 251 252 static void 253 generate_path_token(const char *directory, const char *token_filename) 254 { 255 token_t *path_token; 256 257 path_token = au_to_path(path_token_path); 258 if (path_token == NULL) 259 err(EX_UNAVAILABLE, "au_to_path"); 260 write_token(directory, token_filename, path_token); 261 } 262 263 static void 264 generate_path_record(const char *directory, const char *record_filename) 265 { 266 token_t *path_token; 267 268 path_token = au_to_path(path_token_path); 269 if (path_token == NULL) 270 err(EX_UNAVAILABLE, "au_to_path"); 271 write_record(directory, record_filename, path_token, AUE_NULL); 272 } 273 274 static au_id_t subject32_auid = 0x12345678; 275 static uid_t subject32_euid = 0x01234567; 276 static gid_t subject32_egid = 0x23456789; 277 static uid_t subject32_ruid = 0x98765432; 278 static gid_t subject32_rgid = 0x09876543; 279 static pid_t subject32_pid = 0x13243546; 280 static au_asid_t subject32_sid = 0x97867564; 281 static au_tid_t subject32_tid = { 0x16593746 }; 282 static au_tid_addr_t subject32_tid_addr = { 0x16593746 }; 283 284 static void 285 generate_subject32_token(const char *directory, const char *token_filename) 286 { 287 token_t *subject32_token; 288 289 subject32_tid.machine = inet_addr("127.0.0.1"); 290 291 subject32_token = au_to_subject32(subject32_auid, subject32_euid, 292 subject32_egid, subject32_ruid, subject32_rgid, subject32_pid, 293 subject32_sid, &subject32_tid); 294 if (subject32_token == NULL) 295 err(EX_UNAVAILABLE, "au_to_subject32"); 296 write_token(directory, token_filename, subject32_token); 297 } 298 299 static void 300 generate_subject32_record(const char *directory, const char *record_filename) 301 { 302 token_t *subject32_token; 303 304 subject32_tid.machine = inet_addr("127.0.0.1"); 305 306 subject32_token = au_to_subject32(subject32_auid, subject32_euid, 307 subject32_egid, subject32_ruid, subject32_rgid, subject32_pid, 308 subject32_sid, &subject32_tid); 309 if (subject32_token == NULL) 310 err(EX_UNAVAILABLE, "au_to_subject32"); 311 write_record(directory, record_filename, subject32_token, AUE_NULL); 312 } 313 314 static void 315 generate_subject32ex_token(const char *directory, const char *token_filename, 316 u_int32_t type) 317 { 318 token_t *subject32ex_token; 319 char *buf; 320 321 buf = (char *)malloc(strlen(token_filename) + 6); 322 if (type == AU_IPv6) { 323 inet_pton(AF_INET6, "fe80::1", subject32_tid_addr.at_addr); 324 subject32_tid_addr.at_type = AU_IPv6; 325 sprintf(buf, "%s%s", token_filename, "-IPv6"); 326 } else { 327 subject32_tid_addr.at_addr[0] = inet_addr("127.0.0.1"); 328 subject32_tid_addr.at_type = AU_IPv4; 329 sprintf(buf, "%s%s", token_filename, "-IPv4"); 330 } 331 332 subject32ex_token = au_to_subject32_ex(subject32_auid, subject32_euid, 333 subject32_egid, subject32_ruid, subject32_rgid, subject32_pid, 334 subject32_sid, &subject32_tid_addr); 335 if (subject32ex_token == NULL) 336 err(EX_UNAVAILABLE, "au_to_subject32_ex"); 337 write_token(directory, buf, subject32ex_token); 338 } 339 340 static void 341 generate_subject32ex_record(const char *directory, const char *record_filename, 342 u_int32_t type) 343 { 344 token_t *subject32ex_token; 345 char *buf; 346 347 buf = (char *)malloc(strlen(record_filename) + 6); 348 if (type == AU_IPv6) { 349 inet_pton(AF_INET6, "fe80::1", subject32_tid_addr.at_addr); 350 subject32_tid_addr.at_type = AU_IPv6; 351 sprintf(buf, "%s%s", record_filename, "-IPv6"); 352 } else { 353 subject32_tid_addr.at_addr[0] = inet_addr("127.0.0.1"); 354 subject32_tid_addr.at_type = AU_IPv4; 355 sprintf(buf, "%s%s", record_filename, "-IPv4"); 356 } 357 358 subject32ex_token = au_to_subject32_ex(subject32_auid, subject32_euid, 359 subject32_egid, subject32_ruid, subject32_rgid, subject32_pid, 360 subject32_sid, &subject32_tid_addr); 361 if (subject32ex_token == NULL) 362 err(EX_UNAVAILABLE, "au_to_subject32_ex"); 363 write_record(directory, record_filename, subject32ex_token, AUE_NULL); 364 } 365 366 static au_id_t process32_auid = 0x12345678; 367 static uid_t process32_euid = 0x01234567; 368 static gid_t process32_egid = 0x23456789; 369 static uid_t process32_ruid = 0x98765432; 370 static gid_t process32_rgid = 0x09876543; 371 static pid_t process32_pid = 0x13243546; 372 static au_asid_t process32_sid = 0x97867564; 373 static au_tid_t process32_tid = { 0x16593746 }; 374 static au_tid_addr_t process32_tid_addr = { 0x16593746 }; 375 376 static void 377 generate_process32_token(const char *directory, const char *token_filename) 378 { 379 token_t *process32_token; 380 381 process32_tid.machine = inet_addr("127.0.0.1"); 382 383 process32_token = au_to_process32(process32_auid, process32_euid, 384 process32_egid, process32_ruid, process32_rgid, process32_pid, 385 process32_sid, &process32_tid); 386 if (process32_token == NULL) 387 err(EX_UNAVAILABLE, "au_to_process32"); 388 write_token(directory, token_filename, process32_token); 389 } 390 391 static void 392 generate_process32_record(const char *directory, const char *record_filename) 393 { 394 token_t *process32_token; 395 396 process32_tid.machine = inet_addr("127.0.0.1"); 397 398 process32_token = au_to_process32(process32_auid, process32_euid, 399 process32_egid, process32_ruid, process32_rgid, process32_pid, 400 process32_sid, &process32_tid); 401 if (process32_token == NULL) 402 err(EX_UNAVAILABLE, "au_ti_process32"); 403 write_record(directory, record_filename, process32_token, AUE_NULL); 404 } 405 406 static void 407 generate_process32ex_token(const char *directory, const char *token_filename) 408 { 409 token_t *process32ex_token; 410 411 process32_tid_addr.at_addr[0] = inet_addr("127.0.0.1"); 412 process32_tid_addr.at_type = AU_IPv4; 413 414 process32ex_token = au_to_process32_ex(process32_auid, process32_euid, 415 process32_egid, process32_ruid, process32_rgid, process32_pid, 416 process32_sid, &process32_tid_addr); 417 if (process32ex_token == NULL) 418 err(EX_UNAVAILABLE, "au_to_process32_ex"); 419 write_token(directory, token_filename, process32ex_token); 420 } 421 422 static void 423 generate_process32ex_record(const char *directory, const char *record_filename) 424 { 425 token_t *process32ex_token; 426 427 process32_tid_addr.at_addr[0] = inet_addr("127.0.0.1"); 428 process32_tid_addr.at_type = AU_IPv4; 429 430 process32ex_token = au_to_process32_ex(process32_auid, process32_euid, 431 process32_egid, process32_ruid, process32_rgid, process32_pid, 432 process32_sid, &process32_tid_addr); 433 if (process32ex_token == NULL) 434 err(EX_UNAVAILABLE, "au_to_process32_ex"); 435 write_record(directory, record_filename, process32ex_token, AUE_NULL); 436 } 437 438 static char return32_status = 0xd7; 439 static uint32_t return32_ret = 0x12345678; 440 441 static void 442 generate_return32_token(const char *directory, const char *token_filename) 443 { 444 token_t *return32_token; 445 446 return32_token = au_to_return32(return32_status, return32_ret); 447 if (return32_token == NULL) 448 err(EX_UNAVAILABLE, "au_to_return32"); 449 write_token(directory, token_filename, return32_token); 450 } 451 452 static void 453 generate_return32_record(const char *directory, const char *record_filename) 454 { 455 token_t *return32_token; 456 457 return32_token = au_to_return32(return32_status, return32_ret); 458 if (return32_token == NULL) 459 err(EX_UNAVAILABLE, "au_to_return32"); 460 write_record(directory, record_filename, return32_token, AUE_NULL); 461 } 462 463 static char *text_token_text = "This is a test."; 464 465 static void 466 generate_text_token(const char *directory, const char *token_filename) 467 { 468 token_t *text_token; 469 470 text_token = au_to_text(text_token_text); 471 if (text_token == NULL) 472 err(EX_UNAVAILABLE, "au_to_text"); 473 write_token(directory, token_filename, text_token); 474 } 475 476 static void 477 generate_text_record(const char *directory, const char *record_filename) 478 { 479 token_t *text_token; 480 481 text_token = au_to_text(text_token_text); 482 if (text_token == NULL) 483 err(EX_UNAVAILABLE, "au_to_text"); 484 write_record(directory, record_filename, text_token, AUE_NULL); 485 } 486 487 static char opaque_token_data[] = {0xaa, 0xbb, 0xcc, 0xdd}; 488 static int opaque_token_bytes = sizeof(opaque_token_data); 489 490 static void 491 generate_opaque_token(const char *directory, const char *token_filename) 492 { 493 token_t *opaque_token; 494 495 opaque_token = au_to_opaque(opaque_token_data, opaque_token_bytes); 496 if (opaque_token == NULL) 497 err(EX_UNAVAILABLE, "au_to_opaque"); 498 write_token(directory, token_filename, opaque_token); 499 } 500 501 static void 502 generate_opaque_record(const char *directory, const char *record_filename) 503 { 504 token_t *opaque_token; 505 506 opaque_token = au_to_opaque(opaque_token_data, opaque_token_bytes); 507 if (opaque_token == NULL) 508 err(EX_UNAVAILABLE, "au_to_opaque"); 509 write_record(directory, record_filename, opaque_token, AUE_NULL); 510 } 511 512 static struct in_addr in_addr_token_addr; 513 514 static void 515 generate_in_addr_token(const char *directory, const char *token_filename) 516 { 517 token_t *in_addr_token; 518 519 in_addr_token_addr.s_addr = inet_addr("192.168.100.15"); 520 521 in_addr_token = au_to_in_addr(&in_addr_token_addr); 522 if (in_addr_token == NULL) 523 err(EX_UNAVAILABLE, "au_to_in_addr"); 524 write_token(directory, token_filename, in_addr_token); 525 } 526 527 static void 528 generate_in_addr_record(const char *directory, const char *record_filename) 529 { 530 token_t *in_addr_token; 531 532 in_addr_token_addr.s_addr = inet_addr("192.168.100.15"); 533 534 in_addr_token = au_to_in_addr(&in_addr_token_addr); 535 if (in_addr_token == NULL) 536 err(EX_UNAVAILABLE, "au_to_in_addr"); 537 write_record(directory, record_filename, in_addr_token, AUE_NULL); 538 } 539 540 static struct ip ip_token_ip; 541 static u_char ip_token_ip_v = 4; 542 static uint16_t ip_token_ip_id = 0x5478; 543 static u_char ip_token_ip_ttl = 64; 544 static u_char ip_token_ip_p = IPPROTO_ICMP; 545 static struct in_addr ip_token_ip_src; 546 static struct in_addr ip_token_ip_dst; 547 548 static void 549 generate_ip_token(const char *directory, const char *token_filename) 550 { 551 token_t *ip_token; 552 553 ip_token_ip_src.s_addr = inet_addr("192.168.100.155"); 554 ip_token_ip_dst.s_addr = inet_addr("192.168.110.48"); 555 556 memset(&ip_token_ip, 0, sizeof(ip_token_ip)); 557 ip_token_ip.ip_v = ip_token_ip_v; 558 ip_token_ip.ip_len = htons(sizeof(ip_token_ip)); 559 ip_token_ip.ip_id = htons(ip_token_ip_id); 560 ip_token_ip.ip_ttl = ip_token_ip_ttl; 561 ip_token_ip.ip_p = ip_token_ip_p; 562 ip_token_ip.ip_src = ip_token_ip_src; 563 ip_token_ip.ip_dst = ip_token_ip_dst; 564 565 ip_token = au_to_ip(&ip_token_ip); 566 if (ip_token == NULL) 567 err(EX_UNAVAILABLE, "au_to_ip"); 568 write_token(directory, token_filename, ip_token); 569 } 570 571 static void 572 generate_ip_record(const char *directory, const char *record_filename) 573 { 574 token_t *ip_token; 575 576 ip_token_ip_src.s_addr = inet_addr("192.168.100.155"); 577 ip_token_ip_dst.s_addr = inet_addr("192.168.110.48"); 578 579 memset(&ip_token_ip, 0, sizeof(ip_token_ip)); 580 ip_token_ip.ip_v = ip_token_ip_v; 581 ip_token_ip.ip_len = htons(sizeof(ip_token_ip)); 582 ip_token_ip.ip_id = htons(ip_token_ip_id); 583 ip_token_ip.ip_ttl = ip_token_ip_ttl; 584 ip_token_ip.ip_p = ip_token_ip_p; 585 ip_token_ip.ip_src = ip_token_ip_src; 586 ip_token_ip.ip_dst = ip_token_ip_dst; 587 588 ip_token = au_to_ip(&ip_token_ip); 589 if (ip_token == NULL) 590 err(EX_UNAVAILABLE, "au_to_ip"); 591 write_record(directory, record_filename, ip_token, AUE_NULL); 592 } 593 594 static u_int16_t iport_token_iport; 595 596 static void 597 generate_iport_token(const char *directory, const char *token_filename) 598 { 599 token_t *iport_token; 600 601 iport_token_iport = htons(80); 602 603 iport_token = au_to_iport(iport_token_iport); 604 if (iport_token == NULL) 605 err(EX_UNAVAILABLE, "au_to_iport"); 606 write_token(directory, token_filename, iport_token); 607 } 608 609 static void 610 generate_iport_record(const char *directory, const char *record_filename) 611 { 612 token_t *iport_token; 613 614 iport_token_iport = htons(80); 615 616 iport_token = au_to_iport(iport_token_iport); 617 if (iport_token == NULL) 618 err(EX_UNAVAILABLE, "au_to_iport"); 619 write_record(directory, record_filename, iport_token, AUE_NULL); 620 } 621 622 static char arg32_token_n = 3; 623 static char *arg32_token_text = "test_arg32_token"; 624 static uint32_t arg32_token_v = 0xabcdef00; 625 626 static void 627 generate_arg32_token(const char *directory, const char *token_filename) 628 { 629 token_t *arg32_token; 630 631 arg32_token = au_to_arg32(arg32_token_n, arg32_token_text, 632 arg32_token_v); 633 if (arg32_token == NULL) 634 err(EX_UNAVAILABLE, "au_to_arg32"); 635 write_token(directory, token_filename, arg32_token); 636 } 637 638 static void 639 generate_arg32_record(const char *directory, const char *record_filename) 640 { 641 token_t *arg32_token; 642 643 arg32_token = au_to_arg32(arg32_token_n, arg32_token_text, 644 arg32_token_v); 645 if (arg32_token == NULL) 646 err(EX_UNAVAILABLE, "au_to_arg32"); 647 write_record(directory, record_filename, arg32_token, AUE_NULL); 648 } 649 650 static long seq_audit_count = 0x12345678; 651 652 static void 653 generate_seq_token(const char *directory, const char *token_filename) 654 { 655 token_t *seq_token; 656 657 seq_token = au_to_seq(seq_audit_count); 658 if (seq_token == NULL) 659 err(EX_UNAVAILABLE, "au_to_seq"); 660 write_token(directory, token_filename, seq_token); 661 } 662 663 static void 664 generate_seq_record(const char *directory, const char *record_filename) 665 { 666 token_t *seq_token; 667 668 seq_token = au_to_seq(seq_audit_count); 669 if (seq_token == NULL) 670 err(EX_UNAVAILABLE, "au_to_seq"); 671 write_record(directory, record_filename, seq_token, AUE_NULL); 672 } 673 674 /* 675 * AUT_ACL 676 */ 677 678 static void 679 generate_attr_token(const char *directory, const char *token_filename) 680 { 681 token_t *attr_token; 682 683 } 684 685 static void 686 generate_attr_record(const char *directory, const char *record_filename) 687 { 688 token_t *attr_token; 689 690 } 691 692 static void 693 generate_ipc_perm_token(const char *directory, const char *token_filename) 694 { 695 token_t *ipc_perm_token; 696 697 } 698 699 static void 700 generate_ipc_perm_record(const char *directory, const char *record_filename) 701 { 702 token_t *ipc_perm_token; 703 704 } 705 706 /* 707 * AUT_LABEL 708 */ 709 710 static void 711 generate_groups_token(const char *directory, const char *token_filename) 712 { 713 token_t *groups_token; 714 715 } 716 717 static void 718 generate_groups_record(const char *directory, const char *record_filename) 719 { 720 token_t *groups_token; 721 722 } 723 724 /* 725 * AUT_ILABEL 726 */ 727 728 /* 729 * AUT_SLABEL 730 */ 731 732 /* 733 * AUT_CLEAR 734 */ 735 736 /* 737 * AUT_PRIV 738 */ 739 740 /* 741 * AUT_UPRIV 742 */ 743 744 /* 745 * AUT_LIAISON 746 */ 747 748 /* 749 * AUT_NEWGROUPS 750 */ 751 752 /* 753 * AUT_EXEC_ARGS 754 */ 755 756 /* 757 * AUT_EXEC_ENV 758 */ 759 760 static void 761 generate_attr32_token(const char *directory, const char *token_filename) 762 { 763 token_t *attr32_token; 764 765 } 766 767 static void 768 generate_attr32_record(const char *directory, const char *record_filename) 769 { 770 token_t *attr32_token; 771 772 } 773 774 int 775 main(int argc, char *argv[]) 776 { 777 const char *directory; 778 int ch; 779 780 while ((ch = getopt(argc, argv, "rt")) != -1) { 781 switch (ch) { 782 case 'r': 783 do_records++; 784 break; 785 786 case 't': 787 do_tokens++; 788 break; 789 790 default: 791 usage(); 792 } 793 } 794 795 argc -= optind; 796 argv += optind; 797 798 if (argc != 1) 799 usage(); 800 801 directory = argv[0]; 802 803 if (mkdir(directory, 0755) < 0 && errno != EEXIST) 804 err(EX_OSERR, "mkdir: %s", directory); 805 806 if (do_tokens) { 807 generate_file_token(directory, "file_token"); 808 generate_trailer_token(directory, "trailer_token"); 809 generate_header32_token(directory, "header32_token"); 810 generate_data_token(directory, "data_token"); 811 generate_ipc_token(directory, "ipc_token"); 812 generate_path_token(directory, "path_token"); 813 generate_subject32_token(directory, "subject32_token"); 814 generate_subject32ex_token(directory, "subject32ex_token", AU_IPv4); 815 generate_subject32ex_token(directory, "subject32ex_token", AU_IPv6); 816 generate_process32_token(directory, "process32_token"); 817 generate_process32ex_token(directory, "process32ex_token"); 818 generate_return32_token(directory, "return32_token"); 819 generate_text_token(directory, "text_token"); 820 generate_opaque_token(directory, "opaque_token"); 821 generate_in_addr_token(directory, "in_addr_token"); 822 generate_ip_token(directory, "ip_token"); 823 generate_iport_token(directory, "iport_token"); 824 generate_arg32_token(directory, "arg32_token"); 825 generate_seq_token(directory, "seq_token"); 826 generate_attr_token(directory, "attr_token"); 827 generate_ipc_perm_token(directory, "ipc_perm_token"); 828 generate_groups_token(directory, "groups_token"); 829 generate_attr32_token(directory, "attr32_token"); 830 } 831 832 if (do_records) { 833 generate_file_record(directory, "file_record"); 834 generate_data_record(directory, "data_record"); 835 generate_ipc_record(directory, "ipc_record"); 836 generate_path_record(directory, "path_record"); 837 generate_subject32_record(directory, "subject32_record"); 838 generate_subject32ex_record(directory, "subject32ex_record", 839 AU_IPv4); 840 generate_subject32ex_record(directory, "subject32ex_record", 841 AU_IPv6); 842 generate_process32_record(directory, "process32_record"); 843 generate_process32ex_record(directory, "process32ex_record"); 844 generate_return32_record(directory, "return32_record"); 845 generate_text_record(directory, "text_record"); 846 generate_opaque_record(directory, "opaque_record"); 847 generate_in_addr_record(directory, "in_addr_record"); 848 generate_ip_record(directory, "ip_record"); 849 generate_iport_record(directory, "iport_record"); 850 generate_arg32_record(directory, "arg32_record"); 851 generate_seq_record(directory, "seq_record"); 852 generate_attr_record(directory, "attr_record"); 853 generate_ipc_perm_record(directory, "ipc_perm_record"); 854 generate_groups_record(directory, "groups_record"); 855 generate_attr32_record(directory, "attr32_record"); 856 } 857 858 return (0); 859 } 860