generate.c (159248) | generate.c (159985) |
---|---|
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 unchanged lines hidden (view full) --- 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 * | 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 unchanged lines hidden (view full) --- 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#3 $ | 26 * $P4: //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#4 $ |
27 */ 28 29/* 30 * Generate a series of BSM token samples in the requested directory. 31 */ 32 33#include <sys/types.h> | 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> |
|
34#include <sys/stat.h> 35 36#include <netinet/in.h> 37#include <netinet/in_systm.h> 38#include <netinet/ip.h> 39 40#include <arpa/inet.h> 41 --- 220 unchanged lines hidden (view full) --- 262static au_id_t subject32_auid = 0x12345678; 263static uid_t subject32_euid = 0x01234567; 264static gid_t subject32_egid = 0x23456789; 265static uid_t subject32_ruid = 0x98765432; 266static gid_t subject32_rgid = 0x09876543; 267static pid_t subject32_pid = 0x13243546; 268static au_asid_t subject32_sid = 0x97867564; 269static au_tid_t subject32_tid = { 0x16593746 }; | 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 --- 220 unchanged lines hidden (view full) --- 263static au_id_t subject32_auid = 0x12345678; 264static uid_t subject32_euid = 0x01234567; 265static gid_t subject32_egid = 0x23456789; 266static uid_t subject32_ruid = 0x98765432; 267static gid_t subject32_rgid = 0x09876543; 268static pid_t subject32_pid = 0x13243546; 269static au_asid_t subject32_sid = 0x97867564; 270static au_tid_t subject32_tid = { 0x16593746 }; |
271static au_tid_addr_t subject32_tid_addr = { 0x16593746 }; |
|
270 271static void 272generate_subject32_token(const char *directory, const char *token_filename) 273{ 274 token_t *subject32_token; 275 276 subject32_tid.machine = inet_addr("127.0.0.1"); 277 --- 15 unchanged lines hidden (view full) --- 293 subject32_token = au_to_subject32(subject32_auid, subject32_euid, 294 subject32_egid, subject32_ruid, subject32_rgid, subject32_pid, 295 subject32_sid, &subject32_tid); 296 if (subject32_token == NULL) 297 err(EX_UNAVAILABLE, "au_to_subject32"); 298 write_record(directory, record_filename, subject32_token, AUE_NULL); 299} 300 | 272 273static void 274generate_subject32_token(const char *directory, const char *token_filename) 275{ 276 token_t *subject32_token; 277 278 subject32_tid.machine = inet_addr("127.0.0.1"); 279 --- 15 unchanged lines hidden (view full) --- 295 subject32_token = au_to_subject32(subject32_auid, subject32_euid, 296 subject32_egid, subject32_ruid, subject32_rgid, subject32_pid, 297 subject32_sid, &subject32_tid); 298 if (subject32_token == NULL) 299 err(EX_UNAVAILABLE, "au_to_subject32"); 300 write_record(directory, record_filename, subject32_token, AUE_NULL); 301} 302 |
303static void 304generate_subject32ex_token(const char *directory, const char *token_filename, 305 u_int32_t type) 306{ 307 token_t *subject32ex_token; 308 char *buf; 309 310 buf = (char *)malloc(strlen(token_filename) + 6); 311 if (type == AU_IPv6) { 312 inet_pton(AF_INET6, "fe80::1", subject32_tid_addr.at_addr); 313 subject32_tid_addr.at_type = AU_IPv6; 314 sprintf(buf, "%s%s", token_filename, "-IPv6"); 315 } else { 316 subject32_tid_addr.at_addr[0] = inet_addr("127.0.0.1"); 317 subject32_tid_addr.at_type = AU_IPv4; 318 sprintf(buf, "%s%s", token_filename, "-IPv4"); 319 } 320 321 subject32ex_token = au_to_subject32_ex(subject32_auid, subject32_euid, 322 subject32_egid, subject32_ruid, subject32_rgid, subject32_pid, 323 subject32_sid, &subject32_tid_addr); 324 if (subject32ex_token == NULL) 325 err(EX_UNAVAILABLE, "au_to_subject32_ex"); 326 write_token(directory, buf, subject32ex_token); 327} 328 |
|
301static au_id_t process32_auid = 0x12345678; 302static uid_t process32_euid = 0x01234567; 303static gid_t process32_egid = 0x23456789; 304static uid_t process32_ruid = 0x98765432; 305static gid_t process32_rgid = 0x09876543; 306static pid_t process32_pid = 0x13243546; 307static au_asid_t process32_sid = 0x97867564; 308static au_tid_t process32_tid = { 0x16593746 }; | 329static au_id_t process32_auid = 0x12345678; 330static uid_t process32_euid = 0x01234567; 331static gid_t process32_egid = 0x23456789; 332static uid_t process32_ruid = 0x98765432; 333static gid_t process32_rgid = 0x09876543; 334static pid_t process32_pid = 0x13243546; 335static au_asid_t process32_sid = 0x97867564; 336static au_tid_t process32_tid = { 0x16593746 }; |
337static au_tid_addr_t process32_tid_addr = { 0x16593746 }; |
|
309 310static void 311generate_process32_token(const char *directory, const char *token_filename) 312{ 313 token_t *process32_token; 314 315 process32_tid.machine = inet_addr("127.0.0.1"); 316 --- 15 unchanged lines hidden (view full) --- 332 process32_token = au_to_process32(process32_auid, process32_euid, 333 process32_egid, process32_ruid, process32_rgid, process32_pid, 334 process32_sid, &process32_tid); 335 if (process32_token == NULL) 336 err(EX_UNAVAILABLE, "au_ti_process32"); 337 write_record(directory, record_filename, process32_token, AUE_NULL); 338} 339 | 338 339static void 340generate_process32_token(const char *directory, const char *token_filename) 341{ 342 token_t *process32_token; 343 344 process32_tid.machine = inet_addr("127.0.0.1"); 345 --- 15 unchanged lines hidden (view full) --- 361 process32_token = au_to_process32(process32_auid, process32_euid, 362 process32_egid, process32_ruid, process32_rgid, process32_pid, 363 process32_sid, &process32_tid); 364 if (process32_token == NULL) 365 err(EX_UNAVAILABLE, "au_ti_process32"); 366 write_record(directory, record_filename, process32_token, AUE_NULL); 367} 368 |
369static void 370generate_process32ex_token(const char *directory, const char *token_filename) 371{ 372 token_t *process32ex_token; 373 374 process32_tid_addr.at_addr[0] = inet_addr("127.0.0.1"); 375 process32_tid_addr.at_type = AU_IPv4; 376 377 process32ex_token = au_to_process32_ex(process32_auid, process32_euid, 378 process32_egid, process32_ruid, process32_rgid, process32_pid, 379 process32_sid, &process32_tid_addr); 380 if (process32ex_token == NULL) 381 err(EX_UNAVAILABLE, "au_to_process32_ex"); 382 write_token(directory, token_filename, process32ex_token); 383} 384 |
|
340static char return32_status = 0xd7; 341static uint32_t return32_ret = 0x12345678; 342 343static void 344generate_return32_token(const char *directory, const char *token_filename) 345{ 346 token_t *return32_token; 347 --- 360 unchanged lines hidden (view full) --- 708 if (do_tokens) { 709 generate_file_token(directory, "file_token"); 710 generate_trailer_token(directory, "trailer_token"); 711 generate_header32_token(directory, "header32_token"); 712 generate_data_token(directory, "data_token"); 713 generate_ipc_token(directory, "ipc_token"); 714 generate_path_token(directory, "path_token"); 715 generate_subject32_token(directory, "subject32_token"); | 385static char return32_status = 0xd7; 386static uint32_t return32_ret = 0x12345678; 387 388static void 389generate_return32_token(const char *directory, const char *token_filename) 390{ 391 token_t *return32_token; 392 --- 360 unchanged lines hidden (view full) --- 753 if (do_tokens) { 754 generate_file_token(directory, "file_token"); 755 generate_trailer_token(directory, "trailer_token"); 756 generate_header32_token(directory, "header32_token"); 757 generate_data_token(directory, "data_token"); 758 generate_ipc_token(directory, "ipc_token"); 759 generate_path_token(directory, "path_token"); 760 generate_subject32_token(directory, "subject32_token"); |
761 generate_subject32ex_token(directory, "subject32ex_token", AU_IPv4); 762 generate_subject32ex_token(directory, "subject32ex_token", AU_IPv6); |
|
716 generate_process32_token(directory, "process32_token"); | 763 generate_process32_token(directory, "process32_token"); |
764 generate_process32ex_token(directory, "process32ex_token"); |
|
717 generate_return32_token(directory, "return32_token"); 718 generate_text_token(directory, "text_token"); 719 generate_opaque_token(directory, "opaque_token"); 720 generate_in_addr_token(directory, "in_addr_token"); 721 generate_ip_token(directory, "ip_token"); 722 generate_iport_token(directory, "iport_token"); 723 generate_arg32_token(directory, "arg32_token"); 724 generate_seq_token(directory, "seq_token"); --- 6 unchanged lines hidden (view full) --- 731 if (do_records) { 732 generate_file_token(directory, "file_token"); 733 generate_trailer_token(directory, "trailer_token"); 734 generate_header32_token(directory, "header32_token"); 735 generate_data_token(directory, "data_record"); 736 generate_ipc_token(directory, "ipc_record"); 737 generate_path_token(directory, "path_record"); 738 generate_subject32_token(directory, "subject32_record"); | 765 generate_return32_token(directory, "return32_token"); 766 generate_text_token(directory, "text_token"); 767 generate_opaque_token(directory, "opaque_token"); 768 generate_in_addr_token(directory, "in_addr_token"); 769 generate_ip_token(directory, "ip_token"); 770 generate_iport_token(directory, "iport_token"); 771 generate_arg32_token(directory, "arg32_token"); 772 generate_seq_token(directory, "seq_token"); --- 6 unchanged lines hidden (view full) --- 779 if (do_records) { 780 generate_file_token(directory, "file_token"); 781 generate_trailer_token(directory, "trailer_token"); 782 generate_header32_token(directory, "header32_token"); 783 generate_data_token(directory, "data_record"); 784 generate_ipc_token(directory, "ipc_record"); 785 generate_path_token(directory, "path_record"); 786 generate_subject32_token(directory, "subject32_record"); |
787 generate_subject32ex_token(directory, "subject32ex_record", AU_IPv4); 788 generate_subject32ex_token(directory, "subject32ex_record", AU_IPv6); |
|
739 generate_process32_token(directory, "process32_record"); | 789 generate_process32_token(directory, "process32_record"); |
790 generate_process32ex_token(directory, "process32ex_token"); |
|
740 generate_return32_token(directory, "return32_record"); 741 generate_text_token(directory, "text_record"); 742 generate_opaque_token(directory, "opaque_record"); 743 generate_in_addr_token(directory, "in_addr_record"); 744 generate_ip_token(directory, "ip_record"); 745 generate_iport_token(directory, "iport_record"); 746 generate_arg32_token(directory, "arg32_record"); 747 generate_seq_token(directory, "seq_record"); 748 generate_attr_token(directory, "attr_record"); 749 generate_ipc_perm_token(directory, "ipc_perm_record"); 750 generate_groups_token(directory, "groups_record"); 751 generate_attr32_token(directory, "attr32_record"); 752 } 753 754 return (0); 755} | 791 generate_return32_token(directory, "return32_record"); 792 generate_text_token(directory, "text_record"); 793 generate_opaque_token(directory, "opaque_record"); 794 generate_in_addr_token(directory, "in_addr_record"); 795 generate_ip_token(directory, "ip_record"); 796 generate_iport_token(directory, "iport_record"); 797 generate_arg32_token(directory, "arg32_record"); 798 generate_seq_token(directory, "seq_record"); 799 generate_attr_token(directory, "attr_record"); 800 generate_ipc_perm_token(directory, "ipc_perm_record"); 801 generate_groups_token(directory, "groups_record"); 802 generate_attr32_token(directory, "attr32_record"); 803 } 804 805 return (0); 806} |