17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*a777da3eSpaulson * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <ctype.h> 297c478bd9Sstevel@tonic-gate #include <dirent.h> 307c478bd9Sstevel@tonic-gate #include <grp.h> 317c478bd9Sstevel@tonic-gate #include <libintl.h> 327c478bd9Sstevel@tonic-gate #include <limits.h> 337c478bd9Sstevel@tonic-gate #include <locale.h> 347c478bd9Sstevel@tonic-gate #include <pwd.h> 357c478bd9Sstevel@tonic-gate #include <stdio.h> 367c478bd9Sstevel@tonic-gate #include <stdlib.h> 377c478bd9Sstevel@tonic-gate #include <string.h> 387c478bd9Sstevel@tonic-gate #include <sys/types.h> 397c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 407c478bd9Sstevel@tonic-gate #include <sys/file.h> 417c478bd9Sstevel@tonic-gate #include <sys/param.h> 427c478bd9Sstevel@tonic-gate #include <sys/uio.h> 437c478bd9Sstevel@tonic-gate #include <sys/stat.h> 447c478bd9Sstevel@tonic-gate #include <sys/acl.h> 457c478bd9Sstevel@tonic-gate #include <sys/socket.h> 467c478bd9Sstevel@tonic-gate #include <sys/errno.h> 477c478bd9Sstevel@tonic-gate #include <sys/ipc.h> 487c478bd9Sstevel@tonic-gate #include <sys/sem.h> 497c478bd9Sstevel@tonic-gate #include <sys/systm.h> 507c478bd9Sstevel@tonic-gate #include <netinet/in.h> 517c478bd9Sstevel@tonic-gate #include <sys/tiuser.h> 527c478bd9Sstevel@tonic-gate #include <rpc/types.h> 537c478bd9Sstevel@tonic-gate #include <rpc/auth.h> 547c478bd9Sstevel@tonic-gate #include <rpc/auth_unix.h> 557c478bd9Sstevel@tonic-gate #include <rpc/svc.h> 567c478bd9Sstevel@tonic-gate #include <rpc/xdr.h> 577c478bd9Sstevel@tonic-gate #include <nfs/nfs.h> 587c478bd9Sstevel@tonic-gate #include <sys/fs/ufs_quota.h> 597c478bd9Sstevel@tonic-gate #include <sys/time.h> 607c478bd9Sstevel@tonic-gate #include <sys/mkdev.h> 617c478bd9Sstevel@tonic-gate #include <unistd.h> 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate #include <bsm/audit.h> 647c478bd9Sstevel@tonic-gate #include <bsm/audit_record.h> 657c478bd9Sstevel@tonic-gate #include <bsm/libbsm.h> 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate #include <tsol/label.h> 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate #include "praudit.h" 707c478bd9Sstevel@tonic-gate #include "toktable.h" 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate #include <netdb.h> 737c478bd9Sstevel@tonic-gate #include <arpa/inet.h> 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate static char *anchor_path(char *); 767c478bd9Sstevel@tonic-gate static char *collapse_path(char *); 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* 807c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 817c478bd9Sstevel@tonic-gate * is_file_token: 827c478bd9Sstevel@tonic-gate * Tests whether the specified token id represents a type 837c478bd9Sstevel@tonic-gate * of file token. 847c478bd9Sstevel@tonic-gate * return codes : 1 - tokenid is a file token type 857c478bd9Sstevel@tonic-gate * : 0 - otherwise 867c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate int 897c478bd9Sstevel@tonic-gate is_file_token(int tokenid) 907c478bd9Sstevel@tonic-gate { 917c478bd9Sstevel@tonic-gate if ((tokenid == AUT_OTHER_FILE32) || (tokenid == AUT_OTHER_FILE64)) 927c478bd9Sstevel@tonic-gate return (1); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate return (0); 957c478bd9Sstevel@tonic-gate } 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 997c478bd9Sstevel@tonic-gate * is_header_token: 1007c478bd9Sstevel@tonic-gate * Tests whether the specified token id represents a type 1017c478bd9Sstevel@tonic-gate * of header token (signifying the start of a record). 1027c478bd9Sstevel@tonic-gate * return codes : 1 - tokenid is a header type 1037c478bd9Sstevel@tonic-gate * : 0 - otherwise 1047c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate int 1077c478bd9Sstevel@tonic-gate is_header_token(int tokenid) 1087c478bd9Sstevel@tonic-gate { 1097c478bd9Sstevel@tonic-gate if ((tokenid == AUT_OHEADER) || (tokenid == AUT_HEADER32) || 1107c478bd9Sstevel@tonic-gate (tokenid == AUT_HEADER32_EX) || (tokenid == AUT_HEADER64) || 1117c478bd9Sstevel@tonic-gate (tokenid == AUT_HEADER64_EX)) 1127c478bd9Sstevel@tonic-gate return (1); 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate return (0); 1157c478bd9Sstevel@tonic-gate } 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 1197c478bd9Sstevel@tonic-gate * is_token: 1207c478bd9Sstevel@tonic-gate * Tests whether the specified token id represents a true 1217c478bd9Sstevel@tonic-gate * token, as opposed to a regular tag. 1227c478bd9Sstevel@tonic-gate * return codes : 1 - tokenid is a true token 1237c478bd9Sstevel@tonic-gate * : 0 - otherwise 1247c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate int 1277c478bd9Sstevel@tonic-gate is_token(int tokenid) 1287c478bd9Sstevel@tonic-gate { 1297c478bd9Sstevel@tonic-gate if ((tokenid > 0) && (tokenid <= MAXTOKEN)) 1307c478bd9Sstevel@tonic-gate return (1); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate return (0); 1337c478bd9Sstevel@tonic-gate } 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 1387c478bd9Sstevel@tonic-gate * exit_token() : Process information label token and display contents 1397c478bd9Sstevel@tonic-gate * return codes : -1 - error 1407c478bd9Sstevel@tonic-gate * : 0 - successful 1417c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the label token id has been retrieved 1427c478bd9Sstevel@tonic-gate * 1437c478bd9Sstevel@tonic-gate * Format of exit token: 1447c478bd9Sstevel@tonic-gate * exit token id adr_char 1457c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate int 1487c478bd9Sstevel@tonic-gate exit_token(pr_context_t *context) 1497c478bd9Sstevel@tonic-gate { 1507c478bd9Sstevel@tonic-gate int returnstat; 1517c478bd9Sstevel@tonic-gate int retval; 1527c478bd9Sstevel@tonic-gate uval_t uval; 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_ERRVAL)) != 0) 1557c478bd9Sstevel@tonic-gate return (returnstat); 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_int32(context, (int32_t *)&retval, 1)) == 0) { 1587c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 1597c478bd9Sstevel@tonic-gate char *emsg = strerror(retval); 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate if (emsg == NULL) 1627c478bd9Sstevel@tonic-gate uval.string_val = gettext("Unknown errno"); 1637c478bd9Sstevel@tonic-gate else 1647c478bd9Sstevel@tonic-gate uval.string_val = gettext(emsg); 1657c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 1667c478bd9Sstevel@tonic-gate } else { 1677c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_INT32; 1687c478bd9Sstevel@tonic-gate uval.int32_val = retval; 1697c478bd9Sstevel@tonic-gate } 1707c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 0); 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate if (returnstat == 0) 1737c478bd9Sstevel@tonic-gate returnstat = close_tag(context, TAG_ERRVAL); 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate return (process_tag(context, TAG_RETVAL, returnstat, 1)); 1767c478bd9Sstevel@tonic-gate } 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* 1797c478bd9Sstevel@tonic-gate * ------------------------------------------------------------------ 1807c478bd9Sstevel@tonic-gate * file_token() : prints out seconds of time and other file name 1817c478bd9Sstevel@tonic-gate * return codes : -1 - error 1827c478bd9Sstevel@tonic-gate * : 0 - successful, valid file token fields 1837c478bd9Sstevel@tonic-gate * At the time of entry, the file token ID has already been retrieved 1847c478bd9Sstevel@tonic-gate * 1857c478bd9Sstevel@tonic-gate * Format of file token: 1867c478bd9Sstevel@tonic-gate * file token id adr_char 1877c478bd9Sstevel@tonic-gate * seconds of time adr_u_int 1887c478bd9Sstevel@tonic-gate * name of other file adr_string 1897c478bd9Sstevel@tonic-gate * ------------------------------------------------------------------ 1907c478bd9Sstevel@tonic-gate */ 1917c478bd9Sstevel@tonic-gate int 1927c478bd9Sstevel@tonic-gate file_token(pr_context_t *context) 1937c478bd9Sstevel@tonic-gate { 1947c478bd9Sstevel@tonic-gate int returnstat; 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate returnstat = pa_utime32(context, 0, 0); /* time from usecs */ 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* other file name */ 1997c478bd9Sstevel@tonic-gate returnstat = pa_file_string(context, returnstat, 1); 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate return (returnstat); 2027c478bd9Sstevel@tonic-gate } 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate int 2057c478bd9Sstevel@tonic-gate file64_token(pr_context_t *context) 2067c478bd9Sstevel@tonic-gate { 2077c478bd9Sstevel@tonic-gate int returnstat; 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate returnstat = pa_utime64(context, 0, 0); /* time from usecs */ 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate /* other file name */ 2127c478bd9Sstevel@tonic-gate returnstat = pa_file_string(context, returnstat, 1); 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate return (returnstat); 2157c478bd9Sstevel@tonic-gate } 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate /* 2187c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 2197c478bd9Sstevel@tonic-gate * header_token() : Process record header token and display contents 2207c478bd9Sstevel@tonic-gate * return codes : -1 - error 2217c478bd9Sstevel@tonic-gate * : 0 - successful 2227c478bd9Sstevel@tonic-gate * : 1 - warning, password entry not found 2237c478bd9Sstevel@tonic-gate * 2247c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the header token id has been retrieved 2257c478bd9Sstevel@tonic-gate * 2267c478bd9Sstevel@tonic-gate * Format of header token: 2277c478bd9Sstevel@tonic-gate * header token id adr_char 2287c478bd9Sstevel@tonic-gate * record byte count adr_u_int 2297c478bd9Sstevel@tonic-gate * event type adr_u_short (printed either ASCII or raw) 2307c478bd9Sstevel@tonic-gate * event class adr_u_int (printed either ASCII or raw) 2317c478bd9Sstevel@tonic-gate * event action adr_u_int 2327c478bd9Sstevel@tonic-gate * if extended: extended host name (IPv4/IPv6) 2337c478bd9Sstevel@tonic-gate * seconds of time adr_u_int (printed either ASCII or raw) 2347c478bd9Sstevel@tonic-gate * nanoseconds of time adr_u_int 2357c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 2367c478bd9Sstevel@tonic-gate */ 2377c478bd9Sstevel@tonic-gate int 2387c478bd9Sstevel@tonic-gate header_token(pr_context_t *context) 2397c478bd9Sstevel@tonic-gate { 2407c478bd9Sstevel@tonic-gate int returnstat; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate returnstat = pa_reclen(context, 0); /* record byte */ 2437c478bd9Sstevel@tonic-gate /* version ID */ 2447c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TOKVERS, returnstat, 0); 2457c478bd9Sstevel@tonic-gate /* event type */ 2467c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_EVTYPE, returnstat, 0); 2477c478bd9Sstevel@tonic-gate /* event modifier */ 2487c478bd9Sstevel@tonic-gate returnstat = pa_event_modifier(context, returnstat, 0); 2497c478bd9Sstevel@tonic-gate /* time from nsec */ 2507c478bd9Sstevel@tonic-gate returnstat = pa_ntime32(context, returnstat, 1); 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate return (returnstat); 2537c478bd9Sstevel@tonic-gate } 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate int 2567c478bd9Sstevel@tonic-gate header64_token(pr_context_t *context) 2577c478bd9Sstevel@tonic-gate { 2587c478bd9Sstevel@tonic-gate int returnstat; 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate returnstat = pa_reclen(context, 0); /* record byte */ 2617c478bd9Sstevel@tonic-gate /* version ID */ 2627c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TOKVERS, returnstat, 0); 2637c478bd9Sstevel@tonic-gate /* event type */ 2647c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_EVTYPE, returnstat, 0); 2657c478bd9Sstevel@tonic-gate /* event modifier */ 2667c478bd9Sstevel@tonic-gate returnstat = pa_event_modifier(context, returnstat, 0); 2677c478bd9Sstevel@tonic-gate /* time from nsec */ 2687c478bd9Sstevel@tonic-gate returnstat = pa_ntime64(context, returnstat, 1); 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate return (returnstat); 2717c478bd9Sstevel@tonic-gate } 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate int 2747c478bd9Sstevel@tonic-gate header32_ex_token(pr_context_t *context) 2757c478bd9Sstevel@tonic-gate { 2767c478bd9Sstevel@tonic-gate int returnstat; 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate returnstat = pa_reclen(context, 0); /* record byte */ 2797c478bd9Sstevel@tonic-gate /* version ID */ 2807c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TOKVERS, returnstat, 0); 2817c478bd9Sstevel@tonic-gate /* event type */ 2827c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_EVTYPE, returnstat, 0); 2837c478bd9Sstevel@tonic-gate /* event modifier */ 2847c478bd9Sstevel@tonic-gate returnstat = pa_event_modifier(context, returnstat, 0); 2857c478bd9Sstevel@tonic-gate /* machine name */ 2867c478bd9Sstevel@tonic-gate returnstat = pa_hostname_ex(context, returnstat, 0); 2877c478bd9Sstevel@tonic-gate /* time from nsec */ 2887c478bd9Sstevel@tonic-gate returnstat = pa_ntime32(context, returnstat, 1); 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate return (returnstat); 2917c478bd9Sstevel@tonic-gate } 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate int 2947c478bd9Sstevel@tonic-gate header64_ex_token(pr_context_t *context) 2957c478bd9Sstevel@tonic-gate { 2967c478bd9Sstevel@tonic-gate int returnstat; 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate returnstat = pa_reclen(context, 0); /* record byte */ 2997c478bd9Sstevel@tonic-gate /* version ID */ 3007c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TOKVERS, returnstat, 0); 3017c478bd9Sstevel@tonic-gate /* event type */ 3027c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_EVTYPE, returnstat, 0); 3037c478bd9Sstevel@tonic-gate /* event modifier */ 3047c478bd9Sstevel@tonic-gate returnstat = pa_event_modifier(context, returnstat, 0); 3057c478bd9Sstevel@tonic-gate /* machine name */ 3067c478bd9Sstevel@tonic-gate returnstat = pa_hostname_ex(context, returnstat, 0); 3077c478bd9Sstevel@tonic-gate /* time from nsec */ 3087c478bd9Sstevel@tonic-gate returnstat = pa_ntime64(context, returnstat, 1); 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate return (returnstat); 3117c478bd9Sstevel@tonic-gate } 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* 3147c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 3157c478bd9Sstevel@tonic-gate * trailer_token() : Process record trailer token and display contents 3167c478bd9Sstevel@tonic-gate * return codes : -1 - error 3177c478bd9Sstevel@tonic-gate * : 0 - successful 3187c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the trailer token id has already been 3197c478bd9Sstevel@tonic-gate * retrieved 3207c478bd9Sstevel@tonic-gate * 3217c478bd9Sstevel@tonic-gate * Format of trailer token: 3227c478bd9Sstevel@tonic-gate * trailer token id adr_char 3237c478bd9Sstevel@tonic-gate * record sequence no adr_u_short (should be AUT_TRAILER_MAGIC) 3247c478bd9Sstevel@tonic-gate * record byte count adr_u_int 3257c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 3267c478bd9Sstevel@tonic-gate */ 3277c478bd9Sstevel@tonic-gate int 3287c478bd9Sstevel@tonic-gate trailer_token(pr_context_t *context) 3297c478bd9Sstevel@tonic-gate { 3307c478bd9Sstevel@tonic-gate short magic_number; 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate if (pr_adr_u_short(context, (ushort_t *)&magic_number, 1) < 0) { 3337c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext( 3347c478bd9Sstevel@tonic-gate "praudit: Cannot retrieve trailer magic number\n")); 3357c478bd9Sstevel@tonic-gate return (-1); 3367c478bd9Sstevel@tonic-gate } else { 3377c478bd9Sstevel@tonic-gate if (magic_number != AUT_TRAILER_MAGIC) { 3387c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext( 3397c478bd9Sstevel@tonic-gate "praudit: Invalid trailer magic number\n")); 3407c478bd9Sstevel@tonic-gate return (-1); 3417c478bd9Sstevel@tonic-gate } else 3427c478bd9Sstevel@tonic-gate /* Do not display trailer in XML mode */ 3437c478bd9Sstevel@tonic-gate if (context->format & PRF_XMLM) { 3447c478bd9Sstevel@tonic-gate uint32_t junk; 3457c478bd9Sstevel@tonic-gate int retstat; 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate retstat = pr_adr_u_int32(context, &junk, 1); 3487c478bd9Sstevel@tonic-gate return (retstat); 3497c478bd9Sstevel@tonic-gate } else { 3507c478bd9Sstevel@tonic-gate return (pa_adr_u_int32(context, 0, 1)); 3517c478bd9Sstevel@tonic-gate } 3527c478bd9Sstevel@tonic-gate } 3537c478bd9Sstevel@tonic-gate } 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate /* 3567c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 3577c478bd9Sstevel@tonic-gate * arbitrary_data_token(): 3587c478bd9Sstevel@tonic-gate * Process arbitrary data token and display contents 3597c478bd9Sstevel@tonic-gate * return codes : -1 - error 3607c478bd9Sstevel@tonic-gate * : 0 - successful 3617c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the arbitrary data token id has already 3627c478bd9Sstevel@tonic-gate * been retrieved 3637c478bd9Sstevel@tonic-gate * 3647c478bd9Sstevel@tonic-gate * Format of arbitrary data token: 3657c478bd9Sstevel@tonic-gate * arbitrary data token id adr char 3667c478bd9Sstevel@tonic-gate * how to print adr_char 3677c478bd9Sstevel@tonic-gate * From audit_record.h, this may be either: 3687c478bd9Sstevel@tonic-gate * AUP_BINARY binary 3697c478bd9Sstevel@tonic-gate * AUP_OCTAL octal 3707c478bd9Sstevel@tonic-gate * AUP_DECIMAL decimal 3717c478bd9Sstevel@tonic-gate * AUP_HEX hexadecimal 3727c478bd9Sstevel@tonic-gate * basic unit adr_char 3737c478bd9Sstevel@tonic-gate * From audit_record.h, this may be either: 3747c478bd9Sstevel@tonic-gate * AUR_BYTE byte 3757c478bd9Sstevel@tonic-gate * AUR_CHAR char 3767c478bd9Sstevel@tonic-gate * AUR_SHORT short 3777c478bd9Sstevel@tonic-gate * AUR_INT32 int32_t 3787c478bd9Sstevel@tonic-gate * AUR_INT64 int64_t 3797c478bd9Sstevel@tonic-gate * unit count adr_char, specifying number of units of 3807c478bd9Sstevel@tonic-gate * data in the "data items" parameter below 3817c478bd9Sstevel@tonic-gate * data items depends on basic unit 3827c478bd9Sstevel@tonic-gate * 3837c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 3847c478bd9Sstevel@tonic-gate */ 3857c478bd9Sstevel@tonic-gate int 3867c478bd9Sstevel@tonic-gate arbitrary_data_token(pr_context_t *context) 3877c478bd9Sstevel@tonic-gate { 3887c478bd9Sstevel@tonic-gate int returnstat; 3897c478bd9Sstevel@tonic-gate int i; 3907c478bd9Sstevel@tonic-gate char c1; 3917c478bd9Sstevel@tonic-gate short c2; 3927c478bd9Sstevel@tonic-gate int32_t c3; 3937c478bd9Sstevel@tonic-gate int64_t c4; 3947c478bd9Sstevel@tonic-gate char how_to_print, basic_unit, unit_count, fwid; 3957c478bd9Sstevel@tonic-gate char *p; 3967c478bd9Sstevel@tonic-gate int index = 0; 3977c478bd9Sstevel@tonic-gate char *pformat = "%*s"; 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate uval_t uval; 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_char(context, &how_to_print, 1)) != 0) 4027c478bd9Sstevel@tonic-gate return (returnstat); 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_char(context, &basic_unit, 1)) != 0) 4057c478bd9Sstevel@tonic-gate return (returnstat); 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_char(context, &unit_count, 1)) != 0) 4087c478bd9Sstevel@tonic-gate return (returnstat); 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 4117c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 4127c478bd9Sstevel@tonic-gate uval.string_val = htp2string(how_to_print); 4137c478bd9Sstevel@tonic-gate } else { 4147c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_INT32; 4157c478bd9Sstevel@tonic-gate uval.int32_val = (int)how_to_print; 4167c478bd9Sstevel@tonic-gate } 4177c478bd9Sstevel@tonic-gate 4187c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_ARBPRINT)) != 0) 4197c478bd9Sstevel@tonic-gate return (returnstat); 4207c478bd9Sstevel@tonic-gate if ((returnstat = pa_print(context, &uval, 0)) < 0) 4217c478bd9Sstevel@tonic-gate return (returnstat); 4227c478bd9Sstevel@tonic-gate if ((returnstat = close_tag(context, TAG_ARBPRINT)) != 0) 4237c478bd9Sstevel@tonic-gate return (returnstat); 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 4267c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 4277c478bd9Sstevel@tonic-gate uval.string_val = bu2string(basic_unit); 4287c478bd9Sstevel@tonic-gate } else { 4297c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_INT32; 4307c478bd9Sstevel@tonic-gate uval.int32_val = (int32_t)basic_unit; 4317c478bd9Sstevel@tonic-gate } 4327c478bd9Sstevel@tonic-gate 4337c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_ARBTYPE)) != 0) 4347c478bd9Sstevel@tonic-gate return (returnstat); 4357c478bd9Sstevel@tonic-gate if ((returnstat = pa_print(context, &uval, 0)) < 0) 4367c478bd9Sstevel@tonic-gate return (returnstat); 4377c478bd9Sstevel@tonic-gate if ((returnstat = close_tag(context, TAG_ARBTYPE)) != 0) 4387c478bd9Sstevel@tonic-gate return (returnstat); 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_INT32; 4417c478bd9Sstevel@tonic-gate uval.int32_val = (int32_t)unit_count; 4427c478bd9Sstevel@tonic-gate 4437c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_ARBCOUNT)) != 0) 4447c478bd9Sstevel@tonic-gate return (returnstat); 4457c478bd9Sstevel@tonic-gate if ((returnstat = pa_print(context, &uval, 1)) < 0) 4467c478bd9Sstevel@tonic-gate return (returnstat); 4477c478bd9Sstevel@tonic-gate if ((returnstat = close_tag(context, TAG_ARBCOUNT)) != 0) 4487c478bd9Sstevel@tonic-gate return (returnstat); 4497c478bd9Sstevel@tonic-gate 4507c478bd9Sstevel@tonic-gate /* Done with attributes; force end of token open */ 4517c478bd9Sstevel@tonic-gate if ((returnstat = finish_open_tag(context)) != 0) 4527c478bd9Sstevel@tonic-gate return (returnstat); 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate /* get the field width in case we need to format output */ 4557c478bd9Sstevel@tonic-gate fwid = findfieldwidth(basic_unit, how_to_print); 4567c478bd9Sstevel@tonic-gate p = (char *)malloc(80); 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate /* now get the data items and print them */ 4597c478bd9Sstevel@tonic-gate for (i = 0; (i < unit_count); i++) { 4607c478bd9Sstevel@tonic-gate switch (basic_unit) { 4617c478bd9Sstevel@tonic-gate /* case AUR_BYTE: */ 4627c478bd9Sstevel@tonic-gate case AUR_CHAR: 4637c478bd9Sstevel@tonic-gate if (pr_adr_char(context, &c1, 1) == 0) 4647c478bd9Sstevel@tonic-gate (void) convert_char_to_string(how_to_print, 4657c478bd9Sstevel@tonic-gate c1, p); 4667c478bd9Sstevel@tonic-gate else { 4677c478bd9Sstevel@tonic-gate free(p); 4687c478bd9Sstevel@tonic-gate return (-1); 4697c478bd9Sstevel@tonic-gate } 4707c478bd9Sstevel@tonic-gate break; 4717c478bd9Sstevel@tonic-gate case AUR_SHORT: 4727c478bd9Sstevel@tonic-gate if (pr_adr_short(context, &c2, 1) == 0) 4737c478bd9Sstevel@tonic-gate (void) convert_short_to_string(how_to_print, 4747c478bd9Sstevel@tonic-gate c2, p); 4757c478bd9Sstevel@tonic-gate else { 4767c478bd9Sstevel@tonic-gate free(p); 4777c478bd9Sstevel@tonic-gate return (-1); 4787c478bd9Sstevel@tonic-gate } 4797c478bd9Sstevel@tonic-gate break; 4807c478bd9Sstevel@tonic-gate case AUR_INT32: 4817c478bd9Sstevel@tonic-gate if (pr_adr_int32(context, &c3, 1) == 0) 4827c478bd9Sstevel@tonic-gate (void) convert_int32_to_string(how_to_print, 4837c478bd9Sstevel@tonic-gate c3, p); 4847c478bd9Sstevel@tonic-gate else { 4857c478bd9Sstevel@tonic-gate free(p); 4867c478bd9Sstevel@tonic-gate return (-1); 4877c478bd9Sstevel@tonic-gate } 4887c478bd9Sstevel@tonic-gate break; 4897c478bd9Sstevel@tonic-gate case AUR_INT64: 4907c478bd9Sstevel@tonic-gate if (pr_adr_int64(context, &c4, 1) == 0) 4917c478bd9Sstevel@tonic-gate (void) convert_int64_to_string(how_to_print, 4927c478bd9Sstevel@tonic-gate c4, p); 4937c478bd9Sstevel@tonic-gate else { 4947c478bd9Sstevel@tonic-gate free(p); 4957c478bd9Sstevel@tonic-gate return (-1); 4967c478bd9Sstevel@tonic-gate } 4977c478bd9Sstevel@tonic-gate break; 4987c478bd9Sstevel@tonic-gate default: 4997c478bd9Sstevel@tonic-gate free(p); 5007c478bd9Sstevel@tonic-gate return (-1); 5017c478bd9Sstevel@tonic-gate /*NOTREACHED*/ 5027c478bd9Sstevel@tonic-gate } 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate /* 5057c478bd9Sstevel@tonic-gate * At this point, we have successfully retrieved a data 5067c478bd9Sstevel@tonic-gate * item and converted it into an ASCII string pointed to 5077c478bd9Sstevel@tonic-gate * by p. If all output is to be printed on one line, 5087c478bd9Sstevel@tonic-gate * simply separate the data items by a space (or by the 5097c478bd9Sstevel@tonic-gate * delimiter if this is the last data item), otherwise, we 5107c478bd9Sstevel@tonic-gate * need to format the output before display. 5117c478bd9Sstevel@tonic-gate */ 5127c478bd9Sstevel@tonic-gate if (context->format & PRF_ONELINE) { 5137c478bd9Sstevel@tonic-gate returnstat = pr_printf(context, "%s", p); 5147c478bd9Sstevel@tonic-gate if ((returnstat >= 0) && (i == (unit_count - 1))) 5157c478bd9Sstevel@tonic-gate returnstat = pr_printf(context, "%s", 5167c478bd9Sstevel@tonic-gate context->SEPARATOR); 5177c478bd9Sstevel@tonic-gate else 5187c478bd9Sstevel@tonic-gate returnstat = pr_putchar(context, ' '); 5197c478bd9Sstevel@tonic-gate } else { /* format output */ 5207c478bd9Sstevel@tonic-gate returnstat = pr_printf(context, pformat, fwid, p); 5217c478bd9Sstevel@tonic-gate index += fwid; 5227c478bd9Sstevel@tonic-gate if ((returnstat >= 0) && 5237c478bd9Sstevel@tonic-gate (((index + fwid) > 75) || 5247c478bd9Sstevel@tonic-gate (i == (unit_count - 1)))) { 5257c478bd9Sstevel@tonic-gate returnstat = pr_putchar(context, '\n'); 5267c478bd9Sstevel@tonic-gate index = 0; 5277c478bd9Sstevel@tonic-gate } 5287c478bd9Sstevel@tonic-gate } /* else if PRF_ONELINE */ 5297c478bd9Sstevel@tonic-gate if (returnstat < 0) { 5307c478bd9Sstevel@tonic-gate free(p); 5317c478bd9Sstevel@tonic-gate return (returnstat); 5327c478bd9Sstevel@tonic-gate } 5337c478bd9Sstevel@tonic-gate } 5347c478bd9Sstevel@tonic-gate free(p); 5357c478bd9Sstevel@tonic-gate 5367c478bd9Sstevel@tonic-gate return (returnstat); 5377c478bd9Sstevel@tonic-gate } 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate /* 5407c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 5417c478bd9Sstevel@tonic-gate * opaque_token() : Process opaque token and display contents 5427c478bd9Sstevel@tonic-gate * return codes : -1 - error 5437c478bd9Sstevel@tonic-gate * : 0 - successful 5447c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the opaque token id has already been 5457c478bd9Sstevel@tonic-gate * retrieved 5467c478bd9Sstevel@tonic-gate * 5477c478bd9Sstevel@tonic-gate * Format of opaque token: 5487c478bd9Sstevel@tonic-gate * opaque token id adr_char 5497c478bd9Sstevel@tonic-gate * size adr_short 5507c478bd9Sstevel@tonic-gate * data adr_char, size times 5517c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 5527c478bd9Sstevel@tonic-gate */ 5537c478bd9Sstevel@tonic-gate int 5547c478bd9Sstevel@tonic-gate opaque_token(pr_context_t *context) 5557c478bd9Sstevel@tonic-gate { 5567c478bd9Sstevel@tonic-gate int returnstat; 5577c478bd9Sstevel@tonic-gate short size; 5587c478bd9Sstevel@tonic-gate char *charp; 5597c478bd9Sstevel@tonic-gate uval_t uval; 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate /* print the size of the token */ 5637c478bd9Sstevel@tonic-gate if (pr_adr_short(context, &size, 1) == 0) { 5647c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_SHORT; 5657c478bd9Sstevel@tonic-gate uval.short_val = size; 5667c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 0); 5677c478bd9Sstevel@tonic-gate } else 5687c478bd9Sstevel@tonic-gate returnstat = -1; 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate /* now print out the data field in hexadecimal */ 5717c478bd9Sstevel@tonic-gate if (returnstat >= 0) { 5727c478bd9Sstevel@tonic-gate /* try to allocate memory for the character string */ 5737c478bd9Sstevel@tonic-gate if ((charp = (char *)malloc(size * sizeof (char))) == NULL) 5747c478bd9Sstevel@tonic-gate returnstat = -1; 5757c478bd9Sstevel@tonic-gate else { 5767c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_char(context, charp, 5777c478bd9Sstevel@tonic-gate size)) == 0) { 5787c478bd9Sstevel@tonic-gate /* print out in hexadecimal format */ 5797c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 5807c478bd9Sstevel@tonic-gate uval.string_val = hexconvert(charp, size, size); 5817c478bd9Sstevel@tonic-gate if (uval.string_val) { 5827c478bd9Sstevel@tonic-gate returnstat = pa_print(context, 5837c478bd9Sstevel@tonic-gate &uval, 1); 5847c478bd9Sstevel@tonic-gate free(uval.string_val); 5857c478bd9Sstevel@tonic-gate } 5867c478bd9Sstevel@tonic-gate } 5877c478bd9Sstevel@tonic-gate free(charp); 5887c478bd9Sstevel@tonic-gate } 5897c478bd9Sstevel@tonic-gate } 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate return (returnstat); 5927c478bd9Sstevel@tonic-gate } 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate /* 5957c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 5967c478bd9Sstevel@tonic-gate * path_token() : Process path token and display contents 5977c478bd9Sstevel@tonic-gate * return codes : -1 - error 5987c478bd9Sstevel@tonic-gate * : 0 - successful 5997c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the path token id has been retrieved 6007c478bd9Sstevel@tonic-gate * 6017c478bd9Sstevel@tonic-gate * Format of path token: 6027c478bd9Sstevel@tonic-gate * token id adr_char 6037c478bd9Sstevel@tonic-gate * path adr_string 6047c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 6057c478bd9Sstevel@tonic-gate */ 6067c478bd9Sstevel@tonic-gate int 6077c478bd9Sstevel@tonic-gate path_token(pr_context_t *context) 6087c478bd9Sstevel@tonic-gate { 6097c478bd9Sstevel@tonic-gate char *path; /* path */ 6107c478bd9Sstevel@tonic-gate char *apath; /* anchored path */ 6117c478bd9Sstevel@tonic-gate char *cpath; /* collapsed path */ 6127c478bd9Sstevel@tonic-gate short length; 6137c478bd9Sstevel@tonic-gate int returnstat; 6147c478bd9Sstevel@tonic-gate uval_t uval; 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gate /* 6177c478bd9Sstevel@tonic-gate * We need to know how much space to allocate for our string, so 6187c478bd9Sstevel@tonic-gate * read the length first, then call pr_adr_char to read those bytes. 6197c478bd9Sstevel@tonic-gate */ 6207c478bd9Sstevel@tonic-gate if (pr_adr_short(context, &length, 1) == 0) { 6217c478bd9Sstevel@tonic-gate if ((path = (char *)malloc(length + 1)) == NULL) { 6227c478bd9Sstevel@tonic-gate returnstat = -1; 6237c478bd9Sstevel@tonic-gate } else if (pr_adr_char(context, path, length) == 0) { 6247c478bd9Sstevel@tonic-gate path[length] = '\0'; 6257c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 6267c478bd9Sstevel@tonic-gate if (*path != '/') { 6277c478bd9Sstevel@tonic-gate apath = anchor_path(path); 6287c478bd9Sstevel@tonic-gate free(path); 6297c478bd9Sstevel@tonic-gate } else 6307c478bd9Sstevel@tonic-gate apath = path; 6317c478bd9Sstevel@tonic-gate cpath = collapse_path(apath); 6327c478bd9Sstevel@tonic-gate uval.string_val = cpath; 6337c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 1); 6347c478bd9Sstevel@tonic-gate free(cpath); 6357c478bd9Sstevel@tonic-gate } else { 6367c478bd9Sstevel@tonic-gate free(path); 6377c478bd9Sstevel@tonic-gate returnstat = -1; 6387c478bd9Sstevel@tonic-gate } 6397c478bd9Sstevel@tonic-gate return (returnstat); 6407c478bd9Sstevel@tonic-gate } else 6417c478bd9Sstevel@tonic-gate return (-1); 6427c478bd9Sstevel@tonic-gate } 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate /* 6457c478bd9Sstevel@tonic-gate * anchor a path name with a slash 6467c478bd9Sstevel@tonic-gate */ 6477c478bd9Sstevel@tonic-gate char * 6487c478bd9Sstevel@tonic-gate anchor_path(char *sp) 6497c478bd9Sstevel@tonic-gate { 6507c478bd9Sstevel@tonic-gate char *dp; /* destination path */ 6517c478bd9Sstevel@tonic-gate char *tp; /* temporary path */ 6527c478bd9Sstevel@tonic-gate size_t len; 6537c478bd9Sstevel@tonic-gate 6547c478bd9Sstevel@tonic-gate len = strlen(sp) + 2; 6557c478bd9Sstevel@tonic-gate if ((dp = tp = (char *)calloc(1, len)) == (char *)0) 6567c478bd9Sstevel@tonic-gate return ((char *)0); 6577c478bd9Sstevel@tonic-gate 6587c478bd9Sstevel@tonic-gate *dp++ = '/'; 6597c478bd9Sstevel@tonic-gate 6607c478bd9Sstevel@tonic-gate (void) strlcpy(dp, sp, len); 6617c478bd9Sstevel@tonic-gate 6627c478bd9Sstevel@tonic-gate return (tp); 6637c478bd9Sstevel@tonic-gate } 6647c478bd9Sstevel@tonic-gate 6657c478bd9Sstevel@tonic-gate /* 6667c478bd9Sstevel@tonic-gate * copy path to collapsed path. 6677c478bd9Sstevel@tonic-gate * collapsed path does not contain: 6687c478bd9Sstevel@tonic-gate * successive slashes 6697c478bd9Sstevel@tonic-gate * instances of dot-slash 6707c478bd9Sstevel@tonic-gate * instances of dot-dot-slash 6717c478bd9Sstevel@tonic-gate * passed path must be anchored with a '/' 6727c478bd9Sstevel@tonic-gate */ 6737c478bd9Sstevel@tonic-gate char * 6747c478bd9Sstevel@tonic-gate collapse_path(char *s) 6757c478bd9Sstevel@tonic-gate { 6767c478bd9Sstevel@tonic-gate int id; /* index of where we are in destination string */ 6777c478bd9Sstevel@tonic-gate int is; /* index of where we are in source string */ 6787c478bd9Sstevel@tonic-gate int slashseen; /* have we seen a slash */ 6797c478bd9Sstevel@tonic-gate int ls; /* length of source string */ 6807c478bd9Sstevel@tonic-gate 6817c478bd9Sstevel@tonic-gate ls = strlen(s) + 1; 6827c478bd9Sstevel@tonic-gate 6837c478bd9Sstevel@tonic-gate slashseen = 0; 6847c478bd9Sstevel@tonic-gate for (is = 0, id = 0; is < ls; is++) { 6857c478bd9Sstevel@tonic-gate /* thats all folks, we've reached the end of input */ 6867c478bd9Sstevel@tonic-gate if (s[is] == '\0') { 6877c478bd9Sstevel@tonic-gate if (id > 1 && s[id-1] == '/') { 6887c478bd9Sstevel@tonic-gate --id; 6897c478bd9Sstevel@tonic-gate } 6907c478bd9Sstevel@tonic-gate s[id++] = '\0'; 6917c478bd9Sstevel@tonic-gate break; 6927c478bd9Sstevel@tonic-gate } 6937c478bd9Sstevel@tonic-gate /* previous character was a / */ 6947c478bd9Sstevel@tonic-gate if (slashseen) { 6957c478bd9Sstevel@tonic-gate if (s[is] == '/') 6967c478bd9Sstevel@tonic-gate continue; /* another slash, ignore it */ 6977c478bd9Sstevel@tonic-gate } else if (s[is] == '/') { 6987c478bd9Sstevel@tonic-gate /* we see a /, just copy it and try again */ 6997c478bd9Sstevel@tonic-gate slashseen = 1; 7007c478bd9Sstevel@tonic-gate s[id++] = '/'; 7017c478bd9Sstevel@tonic-gate continue; 7027c478bd9Sstevel@tonic-gate } 7037c478bd9Sstevel@tonic-gate /* /./ seen */ 7047c478bd9Sstevel@tonic-gate if (s[is] == '.' && s[is+1] == '/') { 7057c478bd9Sstevel@tonic-gate is += 1; 7067c478bd9Sstevel@tonic-gate continue; 7077c478bd9Sstevel@tonic-gate } 7087c478bd9Sstevel@tonic-gate /* XXX/. seen */ 7097c478bd9Sstevel@tonic-gate if (s[is] == '.' && s[is+1] == '\0') { 7107c478bd9Sstevel@tonic-gate if (id > 1) 7117c478bd9Sstevel@tonic-gate id--; 7127c478bd9Sstevel@tonic-gate continue; 7137c478bd9Sstevel@tonic-gate } 7147c478bd9Sstevel@tonic-gate /* XXX/.. seen */ 7157c478bd9Sstevel@tonic-gate if (s[is] == '.' && s[is+1] == '.' && s[is+2] == '\0') { 7167c478bd9Sstevel@tonic-gate is += 1; 7177c478bd9Sstevel@tonic-gate if (id > 0) 7187c478bd9Sstevel@tonic-gate id--; 7197c478bd9Sstevel@tonic-gate while (id > 0 && s[--id] != '/'); 7207c478bd9Sstevel@tonic-gate id++; 7217c478bd9Sstevel@tonic-gate continue; 7227c478bd9Sstevel@tonic-gate } 7237c478bd9Sstevel@tonic-gate /* XXX/../ seen */ 7247c478bd9Sstevel@tonic-gate if (s[is] == '.' && s[is+1] == '.' && s[is+2] == '/') { 7257c478bd9Sstevel@tonic-gate is += 2; 7267c478bd9Sstevel@tonic-gate if (id > 0) 7277c478bd9Sstevel@tonic-gate id--; 7287c478bd9Sstevel@tonic-gate while (id > 0 && s[--id] != '/'); 7297c478bd9Sstevel@tonic-gate id++; 7307c478bd9Sstevel@tonic-gate continue; 7317c478bd9Sstevel@tonic-gate } 7327c478bd9Sstevel@tonic-gate while (is < ls && (s[id++] = s[is++]) != '/'); 7337c478bd9Sstevel@tonic-gate is--; 7347c478bd9Sstevel@tonic-gate } 7357c478bd9Sstevel@tonic-gate return (s); 7367c478bd9Sstevel@tonic-gate } 7377c478bd9Sstevel@tonic-gate 7387c478bd9Sstevel@tonic-gate /* 7397c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 7407c478bd9Sstevel@tonic-gate * cmd_token() : Process cmd token and display contents 7417c478bd9Sstevel@tonic-gate * return codes : -1 - error 7427c478bd9Sstevel@tonic-gate * : 0 - successful 7437c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the cmd token id has been retrieved 7447c478bd9Sstevel@tonic-gate * 7457c478bd9Sstevel@tonic-gate * Format of command token: 7467c478bd9Sstevel@tonic-gate * token id adr_char 7477c478bd9Sstevel@tonic-gate * argc adr_short 7487c478bd9Sstevel@tonic-gate * N*argv[i] adr_string (short, string) 7497c478bd9Sstevel@tonic-gate * env cnt adr_short 7507c478bd9Sstevel@tonic-gate * N*arge[i] adr_string (short, string) 7517c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 7527c478bd9Sstevel@tonic-gate */ 7537c478bd9Sstevel@tonic-gate int 7547c478bd9Sstevel@tonic-gate cmd_token(pr_context_t *context) 7557c478bd9Sstevel@tonic-gate { 7567c478bd9Sstevel@tonic-gate int returnstat; 7577c478bd9Sstevel@tonic-gate short num; 7587c478bd9Sstevel@tonic-gate 7597c478bd9Sstevel@tonic-gate returnstat = pr_adr_short(context, &num, 1); 7607c478bd9Sstevel@tonic-gate if (returnstat < 0) 7617c478bd9Sstevel@tonic-gate return (returnstat); 7627c478bd9Sstevel@tonic-gate 7637c478bd9Sstevel@tonic-gate if (!(context->format & PRF_XMLM)) { 7647c478bd9Sstevel@tonic-gate returnstat = pr_printf(context, "%s%s%d%s", 7657c478bd9Sstevel@tonic-gate (context->format & PRF_ONELINE) ? "" : gettext("argcnt"), 7667c478bd9Sstevel@tonic-gate (context->format & PRF_ONELINE) ? "" : context->SEPARATOR, 7677c478bd9Sstevel@tonic-gate num, context->SEPARATOR); 7687c478bd9Sstevel@tonic-gate if (returnstat < 0) 7697c478bd9Sstevel@tonic-gate return (returnstat); 7707c478bd9Sstevel@tonic-gate } 7717c478bd9Sstevel@tonic-gate 7727c478bd9Sstevel@tonic-gate for (; num > 0; num--) { 7737c478bd9Sstevel@tonic-gate if ((returnstat = process_tag(context, TAG_ARGV, 7747c478bd9Sstevel@tonic-gate returnstat, 0)) < 0) 7757c478bd9Sstevel@tonic-gate return (returnstat); 7767c478bd9Sstevel@tonic-gate } 7777c478bd9Sstevel@tonic-gate 7787c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_short(context, &num, 1)) < 0) 7797c478bd9Sstevel@tonic-gate return (returnstat); 7807c478bd9Sstevel@tonic-gate 7817c478bd9Sstevel@tonic-gate if (!(context->format & PRF_XMLM)) { 7827c478bd9Sstevel@tonic-gate returnstat = pr_printf(context, "%s%s%d%s", 7837c478bd9Sstevel@tonic-gate (context->format & PRF_ONELINE) ? "" : gettext("envcnt"), 7847c478bd9Sstevel@tonic-gate (context->format & PRF_ONELINE) ? "" : context->SEPARATOR, 7857c478bd9Sstevel@tonic-gate num, context->SEPARATOR); 7867c478bd9Sstevel@tonic-gate if (returnstat < 0) 7877c478bd9Sstevel@tonic-gate return (returnstat); 7887c478bd9Sstevel@tonic-gate } 7897c478bd9Sstevel@tonic-gate 7907c478bd9Sstevel@tonic-gate if ((num == 0) && !(context->format & PRF_XMLM)) { 791*a777da3eSpaulson returnstat = do_newline(context, 1); 7927c478bd9Sstevel@tonic-gate if (returnstat < 0) 7937c478bd9Sstevel@tonic-gate return (returnstat); 7947c478bd9Sstevel@tonic-gate } 7957c478bd9Sstevel@tonic-gate 7967c478bd9Sstevel@tonic-gate for (; num > 1; num--) { 7977c478bd9Sstevel@tonic-gate if ((returnstat = process_tag(context, TAG_ARGE, 7987c478bd9Sstevel@tonic-gate returnstat, 0)) < 0) 7997c478bd9Sstevel@tonic-gate return (returnstat); 8007c478bd9Sstevel@tonic-gate } 8017c478bd9Sstevel@tonic-gate if (num) 8027c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_ARGE, returnstat, 1); 8037c478bd9Sstevel@tonic-gate 8047c478bd9Sstevel@tonic-gate return (returnstat); 8057c478bd9Sstevel@tonic-gate 8067c478bd9Sstevel@tonic-gate } 8077c478bd9Sstevel@tonic-gate 8087c478bd9Sstevel@tonic-gate /* 8097c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 8107c478bd9Sstevel@tonic-gate * argument32_token() : Process argument token and display contents 8117c478bd9Sstevel@tonic-gate * return codes : -1 - error 8127c478bd9Sstevel@tonic-gate * : 0 - successful 8137c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the arg token id has been retrieved 8147c478bd9Sstevel@tonic-gate * 8157c478bd9Sstevel@tonic-gate * Format of argument token: 8167c478bd9Sstevel@tonic-gate * current directory token id adr_char 8177c478bd9Sstevel@tonic-gate * argument number adr_char 8187c478bd9Sstevel@tonic-gate * argument value adr_int32 8197c478bd9Sstevel@tonic-gate * argument description adr_string 8207c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 8217c478bd9Sstevel@tonic-gate */ 8227c478bd9Sstevel@tonic-gate int 8237c478bd9Sstevel@tonic-gate argument32_token(pr_context_t *context) 8247c478bd9Sstevel@tonic-gate { 8257c478bd9Sstevel@tonic-gate int returnstat; 8267c478bd9Sstevel@tonic-gate 8277c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_ARGNUM, 0, 0); 8287c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_ARGVAL32, returnstat, 0); 8297c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_ARGDESC, returnstat, 1); 8307c478bd9Sstevel@tonic-gate 8317c478bd9Sstevel@tonic-gate return (returnstat); 8327c478bd9Sstevel@tonic-gate 8337c478bd9Sstevel@tonic-gate } 8347c478bd9Sstevel@tonic-gate 8357c478bd9Sstevel@tonic-gate /* 8367c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 8377c478bd9Sstevel@tonic-gate * argument64_token() : Process argument token and display contents 8387c478bd9Sstevel@tonic-gate * return codes : -1 - error 8397c478bd9Sstevel@tonic-gate * : 0 - successful 8407c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the arg token id has been retrieved 8417c478bd9Sstevel@tonic-gate * 8427c478bd9Sstevel@tonic-gate * Format of 64 bit argument token: 8437c478bd9Sstevel@tonic-gate * current directory token id adr_char 8447c478bd9Sstevel@tonic-gate * argument number adr_char 8457c478bd9Sstevel@tonic-gate * argument value adr_int64 8467c478bd9Sstevel@tonic-gate * argument description adr_string 8477c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 8487c478bd9Sstevel@tonic-gate */ 8497c478bd9Sstevel@tonic-gate int 8507c478bd9Sstevel@tonic-gate argument64_token(pr_context_t *context) 8517c478bd9Sstevel@tonic-gate { 8527c478bd9Sstevel@tonic-gate int returnstat; 8537c478bd9Sstevel@tonic-gate 8547c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_ARGNUM, 0, 0); 8557c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_ARGVAL64, returnstat, 0); 8567c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_ARGDESC, returnstat, 1); 8577c478bd9Sstevel@tonic-gate 8587c478bd9Sstevel@tonic-gate return (returnstat); 8597c478bd9Sstevel@tonic-gate 8607c478bd9Sstevel@tonic-gate } 8617c478bd9Sstevel@tonic-gate 8627c478bd9Sstevel@tonic-gate /* 8637c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 8647c478bd9Sstevel@tonic-gate * process_token() : Process process token and display contents 8657c478bd9Sstevel@tonic-gate * return codes : -1 - error 8667c478bd9Sstevel@tonic-gate * : 0 - successful 8677c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the process token id has been retrieved 8687c478bd9Sstevel@tonic-gate * 8697c478bd9Sstevel@tonic-gate * Format of process token: 8707c478bd9Sstevel@tonic-gate * process token id adr_char 8717c478bd9Sstevel@tonic-gate * auid adr_u_int32 8727c478bd9Sstevel@tonic-gate * euid adr_u_int32 8737c478bd9Sstevel@tonic-gate * egid adr_u_int32 8747c478bd9Sstevel@tonic-gate * ruid adr_u_int32 8757c478bd9Sstevel@tonic-gate * egid adr_u_int32 8767c478bd9Sstevel@tonic-gate * pid adr_u_int32 8777c478bd9Sstevel@tonic-gate * sid adr_u_int32 8787c478bd9Sstevel@tonic-gate * tid adr_u_int32, adr_u_int32 8797c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 8807c478bd9Sstevel@tonic-gate */ 8817c478bd9Sstevel@tonic-gate int 8827c478bd9Sstevel@tonic-gate process32_token(pr_context_t *context) 8837c478bd9Sstevel@tonic-gate { 8847c478bd9Sstevel@tonic-gate int returnstat; 8857c478bd9Sstevel@tonic-gate 8867c478bd9Sstevel@tonic-gate /* auid */ 8877c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_AUID, 0, 0); 8887c478bd9Sstevel@tonic-gate /* uid */ 8897c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 8907c478bd9Sstevel@tonic-gate /* gid */ 8917c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 8927c478bd9Sstevel@tonic-gate /* ruid */ 8937c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RUID, returnstat, 0); 8947c478bd9Sstevel@tonic-gate /* rgid */ 8957c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RGID, returnstat, 0); 8967c478bd9Sstevel@tonic-gate /* pid */ 8977c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_PID, returnstat, 0); 8987c478bd9Sstevel@tonic-gate /* sid */ 8997c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SID, returnstat, 0); 9007c478bd9Sstevel@tonic-gate /* tid */ 9017c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TID32, returnstat, 1); 9027c478bd9Sstevel@tonic-gate 9037c478bd9Sstevel@tonic-gate return (returnstat); 9047c478bd9Sstevel@tonic-gate } 9057c478bd9Sstevel@tonic-gate 9067c478bd9Sstevel@tonic-gate int 9077c478bd9Sstevel@tonic-gate process64_token(pr_context_t *context) 9087c478bd9Sstevel@tonic-gate { 9097c478bd9Sstevel@tonic-gate int returnstat; 9107c478bd9Sstevel@tonic-gate 9117c478bd9Sstevel@tonic-gate /* auid */ 9127c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_AUID, 0, 0); 9137c478bd9Sstevel@tonic-gate /* uid */ 9147c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 9157c478bd9Sstevel@tonic-gate /* gid */ 9167c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 9177c478bd9Sstevel@tonic-gate /* ruid */ 9187c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RUID, returnstat, 0); 9197c478bd9Sstevel@tonic-gate /* rgid */ 9207c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RGID, returnstat, 0); 9217c478bd9Sstevel@tonic-gate /* pid */ 9227c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_PID, returnstat, 0); 9237c478bd9Sstevel@tonic-gate /* sid */ 9247c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SID, returnstat, 0); 9257c478bd9Sstevel@tonic-gate /* tid */ 9267c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TID64, returnstat, 1); 9277c478bd9Sstevel@tonic-gate 9287c478bd9Sstevel@tonic-gate return (returnstat); 9297c478bd9Sstevel@tonic-gate } 9307c478bd9Sstevel@tonic-gate 9317c478bd9Sstevel@tonic-gate /* 9327c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 9337c478bd9Sstevel@tonic-gate * process_ex_token() : Process process token and display contents 9347c478bd9Sstevel@tonic-gate * return codes : -1 - error 9357c478bd9Sstevel@tonic-gate * : 0 - successful 9367c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the process token id has been retrieved 9377c478bd9Sstevel@tonic-gate * 9387c478bd9Sstevel@tonic-gate * Format of extended process token: 9397c478bd9Sstevel@tonic-gate * process token id adr_char 9407c478bd9Sstevel@tonic-gate * auid adr_u_int32 9417c478bd9Sstevel@tonic-gate * euid adr_u_int32 9427c478bd9Sstevel@tonic-gate * egid adr_u_int32 9437c478bd9Sstevel@tonic-gate * ruid adr_u_int32 9447c478bd9Sstevel@tonic-gate * egid adr_u_int32 9457c478bd9Sstevel@tonic-gate * pid adr_u_int32 9467c478bd9Sstevel@tonic-gate * sid adr_u_int32 9477c478bd9Sstevel@tonic-gate * tid adr_u_int32, adr_u_int32, 4*adr_u_int32 9487c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 9497c478bd9Sstevel@tonic-gate */ 9507c478bd9Sstevel@tonic-gate int 9517c478bd9Sstevel@tonic-gate process32_ex_token(pr_context_t *context) 9527c478bd9Sstevel@tonic-gate { 9537c478bd9Sstevel@tonic-gate int returnstat; 9547c478bd9Sstevel@tonic-gate 9557c478bd9Sstevel@tonic-gate /* auid */ 9567c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_AUID, 0, 0); 9577c478bd9Sstevel@tonic-gate /* uid */ 9587c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 9597c478bd9Sstevel@tonic-gate /* gid */ 9607c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 9617c478bd9Sstevel@tonic-gate /* ruid */ 9627c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RUID, returnstat, 0); 9637c478bd9Sstevel@tonic-gate /* rgid */ 9647c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RGID, returnstat, 0); 9657c478bd9Sstevel@tonic-gate /* pid */ 9667c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_PID, returnstat, 0); 9677c478bd9Sstevel@tonic-gate /* sid */ 9687c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SID, returnstat, 0); 9697c478bd9Sstevel@tonic-gate /* tid */ 9707c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TID32_EX, returnstat, 1); 9717c478bd9Sstevel@tonic-gate 9727c478bd9Sstevel@tonic-gate return (returnstat); 9737c478bd9Sstevel@tonic-gate } 9747c478bd9Sstevel@tonic-gate 9757c478bd9Sstevel@tonic-gate int 9767c478bd9Sstevel@tonic-gate process64_ex_token(pr_context_t *context) 9777c478bd9Sstevel@tonic-gate { 9787c478bd9Sstevel@tonic-gate int returnstat; 9797c478bd9Sstevel@tonic-gate 9807c478bd9Sstevel@tonic-gate /* auid */ 9817c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_AUID, 0, 0); 9827c478bd9Sstevel@tonic-gate /* uid */ 9837c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 9847c478bd9Sstevel@tonic-gate /* gid */ 9857c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 9867c478bd9Sstevel@tonic-gate /* ruid */ 9877c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RUID, returnstat, 0); 9887c478bd9Sstevel@tonic-gate /* rgid */ 9897c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RGID, returnstat, 0); 9907c478bd9Sstevel@tonic-gate /* pid */ 9917c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_PID, returnstat, 0); 9927c478bd9Sstevel@tonic-gate /* sid */ 9937c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SID, returnstat, 0); 9947c478bd9Sstevel@tonic-gate /* tid */ 9957c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TID64_EX, returnstat, 1); 9967c478bd9Sstevel@tonic-gate 9977c478bd9Sstevel@tonic-gate return (returnstat); 9987c478bd9Sstevel@tonic-gate } 9997c478bd9Sstevel@tonic-gate 10007c478bd9Sstevel@tonic-gate /* 10017c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 10027c478bd9Sstevel@tonic-gate * return_value32_token(): Process return value and display contents 10037c478bd9Sstevel@tonic-gate * return codes : -1 - error 10047c478bd9Sstevel@tonic-gate * : 0 - successful 10057c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the return value token id has been retrieved 10067c478bd9Sstevel@tonic-gate * 10077c478bd9Sstevel@tonic-gate * Format of return value token: 10087c478bd9Sstevel@tonic-gate * return value token id adr_char 10097c478bd9Sstevel@tonic-gate * error number adr_char 10107c478bd9Sstevel@tonic-gate * return value adr_int32 10117c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 10127c478bd9Sstevel@tonic-gate */ 10137c478bd9Sstevel@tonic-gate int 10147c478bd9Sstevel@tonic-gate return_value32_token(pr_context_t *context) 10157c478bd9Sstevel@tonic-gate { 10167c478bd9Sstevel@tonic-gate int returnstat; 10177c478bd9Sstevel@tonic-gate uchar_t number; 10187c478bd9Sstevel@tonic-gate int32_t value; 10197c478bd9Sstevel@tonic-gate char pb[512]; /* print buffer */ 10207c478bd9Sstevel@tonic-gate uval_t uval; 10217c478bd9Sstevel@tonic-gate bool_t used_ret_val = 0; 10227c478bd9Sstevel@tonic-gate 10237c478bd9Sstevel@tonic-gate /* 10247c478bd9Sstevel@tonic-gate * Every audit record generated contains a return token. 10257c478bd9Sstevel@tonic-gate * 10267c478bd9Sstevel@tonic-gate * The return token is a special token. It indicates the success 10277c478bd9Sstevel@tonic-gate * or failure of the event that contains it. 10287c478bd9Sstevel@tonic-gate * The return32 token contains two pieces of data: 10297c478bd9Sstevel@tonic-gate * 10307c478bd9Sstevel@tonic-gate * char number; 10317c478bd9Sstevel@tonic-gate * int32_t return_value; 10327c478bd9Sstevel@tonic-gate * 10337c478bd9Sstevel@tonic-gate * For audit records generated by the kernel: 10347c478bd9Sstevel@tonic-gate * The kernel always puts a positive value in "number". 10357c478bd9Sstevel@tonic-gate * Upon success "number" is 0. 10367c478bd9Sstevel@tonic-gate * Upon failure "number" is a positive errno value that is less than 10377c478bd9Sstevel@tonic-gate * sys_nerr. 10387c478bd9Sstevel@tonic-gate * 10397c478bd9Sstevel@tonic-gate * For audit records generated at the user level: 10407c478bd9Sstevel@tonic-gate * Upon success "number" is 0. 10417c478bd9Sstevel@tonic-gate * Upon failure "number" is -1. 10427c478bd9Sstevel@tonic-gate * 10437c478bd9Sstevel@tonic-gate * For both kernel and user land the value of "return_value" is 10447c478bd9Sstevel@tonic-gate * arbitrary. For the kernel it contains the return value of 10457c478bd9Sstevel@tonic-gate * the system call. For user land it contains an arbitrary return 10467c478bd9Sstevel@tonic-gate * value if it is less than ADT_FAIL_VALUE; ADT_FAIL_VALUE 10477c478bd9Sstevel@tonic-gate * and above are messages defined in adt_event.h. ADT_FAIL_PAM and 10487c478bd9Sstevel@tonic-gate * above are messages from pam_strerror(). No interpretation is done 10497c478bd9Sstevel@tonic-gate * on "return_value" if it is outside the range of ADT_FAIL_VALUE_* or 10507c478bd9Sstevel@tonic-gate * ADT_FAIL_PAM values. 10517c478bd9Sstevel@tonic-gate */ 10527c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_ERRVAL)) != 0) 10537c478bd9Sstevel@tonic-gate return (returnstat); 10547c478bd9Sstevel@tonic-gate 10557c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_u_char(context, &number, 1)) == 0) { 10567c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 10577c478bd9Sstevel@tonic-gate used_ret_val = 1; 10587c478bd9Sstevel@tonic-gate pa_error(number, pb, sizeof (pb)); 10597c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 10607c478bd9Sstevel@tonic-gate uval.string_val = pb; 10617c478bd9Sstevel@tonic-gate if ((returnstat = pa_print(context, &uval, 0)) != 0) 10627c478bd9Sstevel@tonic-gate return (returnstat); 10637c478bd9Sstevel@tonic-gate if ((returnstat = close_tag(context, TAG_ERRVAL)) != 0) 10647c478bd9Sstevel@tonic-gate return (returnstat); 10657c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_RETVAL)) != 0) 10667c478bd9Sstevel@tonic-gate return (returnstat); 10677c478bd9Sstevel@tonic-gate 10687c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_int32( 10697c478bd9Sstevel@tonic-gate context, &value, 1)) != 0) 10707c478bd9Sstevel@tonic-gate return (returnstat); 10717c478bd9Sstevel@tonic-gate 10727c478bd9Sstevel@tonic-gate pa_retval(value, pb, sizeof (pb)); 10737c478bd9Sstevel@tonic-gate } else { 10747c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_INT32; 10757c478bd9Sstevel@tonic-gate if ((char)number == -1) 10767c478bd9Sstevel@tonic-gate uval.int32_val = -1; 10777c478bd9Sstevel@tonic-gate else 10787c478bd9Sstevel@tonic-gate uval.int32_val = number; 10797c478bd9Sstevel@tonic-gate } 10807c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, used_ret_val); 10817c478bd9Sstevel@tonic-gate } 10827c478bd9Sstevel@tonic-gate if (used_ret_val) { 10837c478bd9Sstevel@tonic-gate if (returnstat == 0) 10847c478bd9Sstevel@tonic-gate returnstat = close_tag(context, TAG_RETVAL); 10857c478bd9Sstevel@tonic-gate return (returnstat); 10867c478bd9Sstevel@tonic-gate } 10877c478bd9Sstevel@tonic-gate if (!returnstat) 10887c478bd9Sstevel@tonic-gate if (returnstat = close_tag(context, TAG_ERRVAL)) 10897c478bd9Sstevel@tonic-gate return (returnstat); 10907c478bd9Sstevel@tonic-gate 10917c478bd9Sstevel@tonic-gate return (process_tag(context, TAG_RETVAL, returnstat, 1)); 10927c478bd9Sstevel@tonic-gate } 10937c478bd9Sstevel@tonic-gate 10947c478bd9Sstevel@tonic-gate /* 10957c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 10967c478bd9Sstevel@tonic-gate * return_value64_token(): Process return value and display contents 10977c478bd9Sstevel@tonic-gate * return codes : -1 - error 10987c478bd9Sstevel@tonic-gate * : 0 - successful 10997c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the return value token id has been retrieved 11007c478bd9Sstevel@tonic-gate * 11017c478bd9Sstevel@tonic-gate * Format of return value token: 11027c478bd9Sstevel@tonic-gate * return value token id adr_char 11037c478bd9Sstevel@tonic-gate * error number adr_char 11047c478bd9Sstevel@tonic-gate * return value adr_int64 11057c478bd9Sstevel@tonic-gate * 11067c478bd9Sstevel@tonic-gate * HOWEVER, the 64 bit return value is a concatenation of two 11077c478bd9Sstevel@tonic-gate * 32 bit return values; the first of which is the same as is 11087c478bd9Sstevel@tonic-gate * carried in the return32 token. The second 32 bits are ignored 11097c478bd9Sstevel@tonic-gate * here so that the displayed return token will have the same 11107c478bd9Sstevel@tonic-gate * number whether the application is 32 or 64 bits. 11117c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 11127c478bd9Sstevel@tonic-gate */ 11137c478bd9Sstevel@tonic-gate int 11147c478bd9Sstevel@tonic-gate return_value64_token(pr_context_t *context) 11157c478bd9Sstevel@tonic-gate { 11167c478bd9Sstevel@tonic-gate int returnstat; 11177c478bd9Sstevel@tonic-gate uchar_t number; 11187c478bd9Sstevel@tonic-gate rval_t rval; 11197c478bd9Sstevel@tonic-gate char pb[512]; /* print buffer */ 11207c478bd9Sstevel@tonic-gate uval_t uval; 11217c478bd9Sstevel@tonic-gate 11227c478bd9Sstevel@tonic-gate /* 11237c478bd9Sstevel@tonic-gate * Every audit record generated contains a return token. 11247c478bd9Sstevel@tonic-gate * 11257c478bd9Sstevel@tonic-gate * The return token is a special token. It indicates the success 11267c478bd9Sstevel@tonic-gate * or failure of the event that contains it. 11277c478bd9Sstevel@tonic-gate * The return64 token contains two pieces of data: 11287c478bd9Sstevel@tonic-gate * 11297c478bd9Sstevel@tonic-gate * char number; 11307c478bd9Sstevel@tonic-gate * int64_t return_value; 11317c478bd9Sstevel@tonic-gate * 11327c478bd9Sstevel@tonic-gate * For audit records generated by the kernel: 11337c478bd9Sstevel@tonic-gate * The kernel always puts a positive value in "number". 11347c478bd9Sstevel@tonic-gate * Upon success "number" is 0. 11357c478bd9Sstevel@tonic-gate * Upon failure "number" is a positive errno value that is less than 11367c478bd9Sstevel@tonic-gate * sys_nerr. 11377c478bd9Sstevel@tonic-gate * 11387c478bd9Sstevel@tonic-gate * For audit records generated at the user level: 11397c478bd9Sstevel@tonic-gate * Upon success "number" is 0. 11407c478bd9Sstevel@tonic-gate * Upon failure "number" is -1. 11417c478bd9Sstevel@tonic-gate * 11427c478bd9Sstevel@tonic-gate * For both kernel and user land the value of "return_value" is 11437c478bd9Sstevel@tonic-gate * arbitrary. For the kernel it contains the return value of 11447c478bd9Sstevel@tonic-gate * the system call. For user land it contains an arbitrary return 11457c478bd9Sstevel@tonic-gate * value if it is less than ADT_FAIL_VALUE; ADT_FAIL_VALUE 11467c478bd9Sstevel@tonic-gate * and above are messages defined in adt_event.h. ADT_FAIL_PAM and 11477c478bd9Sstevel@tonic-gate * above are messages from pam_strerror(). No interpretation is done 11487c478bd9Sstevel@tonic-gate * on "return_value" if it is outside the range of ADT_FAIL_VALUE_* or 11497c478bd9Sstevel@tonic-gate * ADT_FAIL_PAM values. 11507c478bd9Sstevel@tonic-gate * 11517c478bd9Sstevel@tonic-gate * The 64 bit return value consists of two 32bit parts; for 11527c478bd9Sstevel@tonic-gate * system calls, the first part is the value returned by the 11537c478bd9Sstevel@tonic-gate * system call and the second part depends on the system call 11547c478bd9Sstevel@tonic-gate * implementation. In most cases, the second part is either 0 11557c478bd9Sstevel@tonic-gate * or garbage; because of that, it is omitted from the praudit 11567c478bd9Sstevel@tonic-gate * output. 11577c478bd9Sstevel@tonic-gate */ 11587c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_ERRVAL)) != 0) 11597c478bd9Sstevel@tonic-gate return (returnstat); 11607c478bd9Sstevel@tonic-gate 11617c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_u_char(context, &number, 1)) == 0) { 11627c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 11637c478bd9Sstevel@tonic-gate pa_error(number, pb, sizeof (pb)); 11647c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 11657c478bd9Sstevel@tonic-gate uval.string_val = pb; 11667c478bd9Sstevel@tonic-gate if ((returnstat = pa_print(context, &uval, 0)) != 0) 11677c478bd9Sstevel@tonic-gate return (returnstat); 11687c478bd9Sstevel@tonic-gate 11697c478bd9Sstevel@tonic-gate if ((returnstat = close_tag(context, TAG_ERRVAL)) != 0) 11707c478bd9Sstevel@tonic-gate return (returnstat); 11717c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_RETVAL)) != 0) 11727c478bd9Sstevel@tonic-gate return (returnstat); 11737c478bd9Sstevel@tonic-gate 11747c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_int64(context, 11757c478bd9Sstevel@tonic-gate &rval.r_vals, 1)) != 0) 11767c478bd9Sstevel@tonic-gate return (returnstat); 11777c478bd9Sstevel@tonic-gate pa_retval(rval.r_val1, pb, sizeof (pb)); 11787c478bd9Sstevel@tonic-gate } else { 11797c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_INT32; 11807c478bd9Sstevel@tonic-gate if ((char)number == -1) 11817c478bd9Sstevel@tonic-gate uval.int32_val = -1; 11827c478bd9Sstevel@tonic-gate else 11837c478bd9Sstevel@tonic-gate uval.int32_val = number; 11847c478bd9Sstevel@tonic-gate 11857c478bd9Sstevel@tonic-gate if ((returnstat = pa_print(context, &uval, 0)) != 0) 11867c478bd9Sstevel@tonic-gate return (returnstat); 11877c478bd9Sstevel@tonic-gate 11887c478bd9Sstevel@tonic-gate if ((returnstat = close_tag(context, TAG_ERRVAL)) != 0) 11897c478bd9Sstevel@tonic-gate return (returnstat); 11907c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_RETVAL)) != 0) 11917c478bd9Sstevel@tonic-gate return (returnstat); 11927c478bd9Sstevel@tonic-gate 11937c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_int64(context, 11947c478bd9Sstevel@tonic-gate &rval.r_vals, 1)) != 0) 11957c478bd9Sstevel@tonic-gate return (returnstat); 11967c478bd9Sstevel@tonic-gate uval.int32_val = rval.r_val1; 11977c478bd9Sstevel@tonic-gate } 11987c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 1); 11997c478bd9Sstevel@tonic-gate } else { 12007c478bd9Sstevel@tonic-gate return (returnstat); 12017c478bd9Sstevel@tonic-gate } 12027c478bd9Sstevel@tonic-gate 12037c478bd9Sstevel@tonic-gate if (returnstat == 0) 12047c478bd9Sstevel@tonic-gate returnstat = close_tag(context, TAG_RETVAL); 12057c478bd9Sstevel@tonic-gate 12067c478bd9Sstevel@tonic-gate return (returnstat); 12077c478bd9Sstevel@tonic-gate } 12087c478bd9Sstevel@tonic-gate 12097c478bd9Sstevel@tonic-gate /* 12107c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 12117c478bd9Sstevel@tonic-gate * subject32_token() : Process subject token and display contents 12127c478bd9Sstevel@tonic-gate * return codes : -1 - error 12137c478bd9Sstevel@tonic-gate * : 0 - successful 12147c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the subject token id has been retrieved 12157c478bd9Sstevel@tonic-gate * 12167c478bd9Sstevel@tonic-gate * Format of subject token: 12177c478bd9Sstevel@tonic-gate * subject token id adr_char 12187c478bd9Sstevel@tonic-gate * auid adr_u_int32 12197c478bd9Sstevel@tonic-gate * euid adr_u_int32 12207c478bd9Sstevel@tonic-gate * egid adr_u_int32 12217c478bd9Sstevel@tonic-gate * ruid adr_u_int32 12227c478bd9Sstevel@tonic-gate * egid adr_u_int32 12237c478bd9Sstevel@tonic-gate * pid adr_u_int32 12247c478bd9Sstevel@tonic-gate * sid adr_u_int32 12257c478bd9Sstevel@tonic-gate * tid adr_u_int32, adr_u_int32 12267c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 12277c478bd9Sstevel@tonic-gate */ 12287c478bd9Sstevel@tonic-gate int 12297c478bd9Sstevel@tonic-gate subject32_token(pr_context_t *context) 12307c478bd9Sstevel@tonic-gate { 12317c478bd9Sstevel@tonic-gate int returnstat; 12327c478bd9Sstevel@tonic-gate 12337c478bd9Sstevel@tonic-gate /* auid */ 12347c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_AUID, 0, 0); 12357c478bd9Sstevel@tonic-gate /* uid */ 12367c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 12377c478bd9Sstevel@tonic-gate /* gid */ 12387c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 12397c478bd9Sstevel@tonic-gate /* ruid */ 12407c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RUID, returnstat, 0); 12417c478bd9Sstevel@tonic-gate /* rgid */ 12427c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RGID, returnstat, 0); 12437c478bd9Sstevel@tonic-gate /* pid */ 12447c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_PID, returnstat, 0); 12457c478bd9Sstevel@tonic-gate /* sid */ 12467c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SID, returnstat, 0); 12477c478bd9Sstevel@tonic-gate /* tid */ 12487c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TID32, returnstat, 1); 12497c478bd9Sstevel@tonic-gate 12507c478bd9Sstevel@tonic-gate return (returnstat); 12517c478bd9Sstevel@tonic-gate } 12527c478bd9Sstevel@tonic-gate 12537c478bd9Sstevel@tonic-gate int 12547c478bd9Sstevel@tonic-gate subject64_token(pr_context_t *context) 12557c478bd9Sstevel@tonic-gate { 12567c478bd9Sstevel@tonic-gate int returnstat; 12577c478bd9Sstevel@tonic-gate 12587c478bd9Sstevel@tonic-gate /* auid */ 12597c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_AUID, 0, 0); 12607c478bd9Sstevel@tonic-gate /* uid */ 12617c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 12627c478bd9Sstevel@tonic-gate /* gid */ 12637c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 12647c478bd9Sstevel@tonic-gate /* ruid */ 12657c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RUID, returnstat, 0); 12667c478bd9Sstevel@tonic-gate /* rgid */ 12677c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RGID, returnstat, 0); 12687c478bd9Sstevel@tonic-gate /* pid */ 12697c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_PID, returnstat, 0); 12707c478bd9Sstevel@tonic-gate /* sid */ 12717c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SID, returnstat, 0); 12727c478bd9Sstevel@tonic-gate /* tid */ 12737c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TID64, returnstat, 1); 12747c478bd9Sstevel@tonic-gate 12757c478bd9Sstevel@tonic-gate return (returnstat); 12767c478bd9Sstevel@tonic-gate } 12777c478bd9Sstevel@tonic-gate 12787c478bd9Sstevel@tonic-gate /* 12797c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 12807c478bd9Sstevel@tonic-gate * subject_ex_token(): Process subject token and display contents 12817c478bd9Sstevel@tonic-gate * return codes : -1 - error 12827c478bd9Sstevel@tonic-gate * : 0 - successful 12837c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the subject token id has been retrieved 12847c478bd9Sstevel@tonic-gate * 12857c478bd9Sstevel@tonic-gate * Format of extended subject token: 12867c478bd9Sstevel@tonic-gate * subject token id adr_char 12877c478bd9Sstevel@tonic-gate * auid adr_u_int32 12887c478bd9Sstevel@tonic-gate * euid adr_u_int32 12897c478bd9Sstevel@tonic-gate * egid adr_u_int32 12907c478bd9Sstevel@tonic-gate * ruid adr_u_int32 12917c478bd9Sstevel@tonic-gate * egid adr_u_int32 12927c478bd9Sstevel@tonic-gate * pid adr_u_int32 12937c478bd9Sstevel@tonic-gate * sid adr_u_int32 12947c478bd9Sstevel@tonic-gate * tid adr_u_int32, adr_u_int32 12957c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 12967c478bd9Sstevel@tonic-gate */ 12977c478bd9Sstevel@tonic-gate int 12987c478bd9Sstevel@tonic-gate subject32_ex_token(pr_context_t *context) 12997c478bd9Sstevel@tonic-gate { 13007c478bd9Sstevel@tonic-gate int returnstat; 13017c478bd9Sstevel@tonic-gate 13027c478bd9Sstevel@tonic-gate /* auid */ 13037c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_AUID, 0, 0); 13047c478bd9Sstevel@tonic-gate /* uid */ 13057c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 13067c478bd9Sstevel@tonic-gate /* gid */ 13077c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 13087c478bd9Sstevel@tonic-gate /* ruid */ 13097c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RUID, returnstat, 0); 13107c478bd9Sstevel@tonic-gate /* rgid */ 13117c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RGID, returnstat, 0); 13127c478bd9Sstevel@tonic-gate /* pid */ 13137c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_PID, returnstat, 0); 13147c478bd9Sstevel@tonic-gate /* sid */ 13157c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SID, returnstat, 0); 13167c478bd9Sstevel@tonic-gate /* tid */ 13177c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TID32_EX, returnstat, 1); 13187c478bd9Sstevel@tonic-gate 13197c478bd9Sstevel@tonic-gate return (returnstat); 13207c478bd9Sstevel@tonic-gate } 13217c478bd9Sstevel@tonic-gate 13227c478bd9Sstevel@tonic-gate int 13237c478bd9Sstevel@tonic-gate subject64_ex_token(pr_context_t *context) 13247c478bd9Sstevel@tonic-gate { 13257c478bd9Sstevel@tonic-gate int returnstat; 13267c478bd9Sstevel@tonic-gate 13277c478bd9Sstevel@tonic-gate /* auid */ 13287c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_AUID, 0, 0); 13297c478bd9Sstevel@tonic-gate /* uid */ 13307c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 13317c478bd9Sstevel@tonic-gate /* gid */ 13327c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 13337c478bd9Sstevel@tonic-gate /* ruid */ 13347c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RUID, returnstat, 0); 13357c478bd9Sstevel@tonic-gate /* rgid */ 13367c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_RGID, returnstat, 0); 13377c478bd9Sstevel@tonic-gate /* pid */ 13387c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_PID, returnstat, 0); 13397c478bd9Sstevel@tonic-gate /* sid */ 13407c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SID, returnstat, 0); 13417c478bd9Sstevel@tonic-gate /* tid */ 13427c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_TID64_EX, returnstat, 1); 13437c478bd9Sstevel@tonic-gate 13447c478bd9Sstevel@tonic-gate return (returnstat); 13457c478bd9Sstevel@tonic-gate } 13467c478bd9Sstevel@tonic-gate 13477c478bd9Sstevel@tonic-gate /* 13487c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 13497c478bd9Sstevel@tonic-gate * s5_IPC_token() : Process System V IPC token and display contents 13507c478bd9Sstevel@tonic-gate * return codes : -1 - error 13517c478bd9Sstevel@tonic-gate * : 0 - successful 13527c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the System V IPC id has been retrieved 13537c478bd9Sstevel@tonic-gate * 13547c478bd9Sstevel@tonic-gate * Format of System V IPC token: 13557c478bd9Sstevel@tonic-gate * System V IPC token id adr_char 13567c478bd9Sstevel@tonic-gate * object id adr_int32 13577c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 13587c478bd9Sstevel@tonic-gate */ 13597c478bd9Sstevel@tonic-gate int 13607c478bd9Sstevel@tonic-gate s5_IPC_token(pr_context_t *context) 13617c478bd9Sstevel@tonic-gate { 13627c478bd9Sstevel@tonic-gate int returnstat; 13637c478bd9Sstevel@tonic-gate uchar_t ipctype; 13647c478bd9Sstevel@tonic-gate uval_t uval; 13657c478bd9Sstevel@tonic-gate 13667c478bd9Sstevel@tonic-gate /* 13677c478bd9Sstevel@tonic-gate * TRANSLATION_NOTE 13687c478bd9Sstevel@tonic-gate * These names refer to the type of System V IPC object: 13697c478bd9Sstevel@tonic-gate * message queue, semaphore, shared memory. 13707c478bd9Sstevel@tonic-gate */ 13717c478bd9Sstevel@tonic-gate 13727c478bd9Sstevel@tonic-gate if (pr_adr_u_char(context, &ipctype, 1) == 0) { 13737c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_IPCTYPE)) != 0) 13747c478bd9Sstevel@tonic-gate return (returnstat); 13757c478bd9Sstevel@tonic-gate 13767c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 13777c478bd9Sstevel@tonic-gate /* print in ASCII form */ 13787c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 13797c478bd9Sstevel@tonic-gate switch (ipctype) { 13807c478bd9Sstevel@tonic-gate case AT_IPC_MSG: 13817c478bd9Sstevel@tonic-gate uval.string_val = gettext("msg"); 13827c478bd9Sstevel@tonic-gate break; 13837c478bd9Sstevel@tonic-gate case AT_IPC_SEM: 13847c478bd9Sstevel@tonic-gate uval.string_val = gettext("sem"); 13857c478bd9Sstevel@tonic-gate break; 13867c478bd9Sstevel@tonic-gate case AT_IPC_SHM: 13877c478bd9Sstevel@tonic-gate uval.string_val = gettext("shm"); 13887c478bd9Sstevel@tonic-gate break; 13897c478bd9Sstevel@tonic-gate } 13907c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 0); 13917c478bd9Sstevel@tonic-gate } 13927c478bd9Sstevel@tonic-gate /* print in integer form */ 13937c478bd9Sstevel@tonic-gate if ((context->format & PRF_RAWM) || (returnstat == 1)) { 13947c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_BYTE; 13957c478bd9Sstevel@tonic-gate uval.char_val = ipctype; 13967c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 0); 13977c478bd9Sstevel@tonic-gate } 13987c478bd9Sstevel@tonic-gate if ((returnstat = close_tag(context, TAG_IPCTYPE)) != 0) 13997c478bd9Sstevel@tonic-gate return (returnstat); 14007c478bd9Sstevel@tonic-gate 14017c478bd9Sstevel@tonic-gate /* next get and print ipc id */ 14027c478bd9Sstevel@tonic-gate return (process_tag(context, TAG_IPCID, returnstat, 1)); 14037c478bd9Sstevel@tonic-gate } else { 14047c478bd9Sstevel@tonic-gate /* cannot retrieve ipc type */ 14057c478bd9Sstevel@tonic-gate return (-1); 14067c478bd9Sstevel@tonic-gate } 14077c478bd9Sstevel@tonic-gate } 14087c478bd9Sstevel@tonic-gate 14097c478bd9Sstevel@tonic-gate /* 14107c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 14117c478bd9Sstevel@tonic-gate * text_token() : Process text token and display contents 14127c478bd9Sstevel@tonic-gate * return codes : -1 - error 14137c478bd9Sstevel@tonic-gate * : 0 - successful 14147c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the text token id has been retrieved 14157c478bd9Sstevel@tonic-gate * 14167c478bd9Sstevel@tonic-gate * Format of text token: 14177c478bd9Sstevel@tonic-gate * text token id adr_char 14187c478bd9Sstevel@tonic-gate * text adr_string 14197c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 14207c478bd9Sstevel@tonic-gate */ 14217c478bd9Sstevel@tonic-gate int 14227c478bd9Sstevel@tonic-gate text_token(pr_context_t *context) 14237c478bd9Sstevel@tonic-gate { 14247c478bd9Sstevel@tonic-gate return (pa_adr_string(context, 0, 1)); 14257c478bd9Sstevel@tonic-gate } 14267c478bd9Sstevel@tonic-gate 14277c478bd9Sstevel@tonic-gate /* 14287c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 14297c478bd9Sstevel@tonic-gate * tid_token() : Process a generic terminal id token / AUT_TID 14307c478bd9Sstevel@tonic-gate * return codes : -1 - error 14317c478bd9Sstevel@tonic-gate * : 0 - successful 14327c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the token id has been retrieved 14337c478bd9Sstevel@tonic-gate * 14347c478bd9Sstevel@tonic-gate * Format of tid token: 14357c478bd9Sstevel@tonic-gate * ip token id adr_char 14367c478bd9Sstevel@tonic-gate * terminal type adr_char 14377c478bd9Sstevel@tonic-gate * terminal type = AU_IPADR: 14387c478bd9Sstevel@tonic-gate * remote port: adr_short 14397c478bd9Sstevel@tonic-gate * local port: adr_short 14407c478bd9Sstevel@tonic-gate * IP type: adt_int32 -- AU_IPv4 or AU_IPv6 14417c478bd9Sstevel@tonic-gate * address: adr_int32 if IPv4, else 4 * adr_int32 14427c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 14437c478bd9Sstevel@tonic-gate */ 14447c478bd9Sstevel@tonic-gate int 14457c478bd9Sstevel@tonic-gate tid_token(pr_context_t *context) 14467c478bd9Sstevel@tonic-gate { 14477c478bd9Sstevel@tonic-gate int returnstat; 14487c478bd9Sstevel@tonic-gate uchar_t type; 14497c478bd9Sstevel@tonic-gate uval_t uval; 14507c478bd9Sstevel@tonic-gate 14517c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_u_char(context, &type, 1)) != 0) 14527c478bd9Sstevel@tonic-gate return (returnstat); 14537c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 14547c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_TID_TYPE)) != 0) 14557c478bd9Sstevel@tonic-gate return (returnstat); 14567c478bd9Sstevel@tonic-gate 14577c478bd9Sstevel@tonic-gate switch (type) { 14587c478bd9Sstevel@tonic-gate default: 14597c478bd9Sstevel@tonic-gate return (-1); /* other than IP type is not implemented */ 14607c478bd9Sstevel@tonic-gate case AU_IPADR: 14617c478bd9Sstevel@tonic-gate uval.string_val = "ip"; 14627c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 0); 14637c478bd9Sstevel@tonic-gate returnstat = close_tag(context, TAG_TID_TYPE); 14647c478bd9Sstevel@tonic-gate returnstat = open_tag(context, TAG_IP); 14657c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IP_REMOTE, returnstat, 0); 14667c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IP_LOCAL, returnstat, 0); 14677c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IP_ADR, returnstat, 1); 14687c478bd9Sstevel@tonic-gate returnstat = close_tag(context, TAG_IP); 14697c478bd9Sstevel@tonic-gate break; 14707c478bd9Sstevel@tonic-gate } 14717c478bd9Sstevel@tonic-gate return (returnstat); 14727c478bd9Sstevel@tonic-gate } 14737c478bd9Sstevel@tonic-gate 14747c478bd9Sstevel@tonic-gate /* 14757c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 14767c478bd9Sstevel@tonic-gate * ip_addr_token() : Process ip token and display contents 14777c478bd9Sstevel@tonic-gate * return codes : -1 - error 14787c478bd9Sstevel@tonic-gate * : 0 - successful 14797c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the ip token id has been retrieved 14807c478bd9Sstevel@tonic-gate * 14817c478bd9Sstevel@tonic-gate * Format of ip address token: 14827c478bd9Sstevel@tonic-gate * ip token id adr_char 14837c478bd9Sstevel@tonic-gate * address adr_int32 (printed in hex) 14847c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 14857c478bd9Sstevel@tonic-gate */ 14867c478bd9Sstevel@tonic-gate 14877c478bd9Sstevel@tonic-gate int 14887c478bd9Sstevel@tonic-gate ip_addr_token(pr_context_t *context) 14897c478bd9Sstevel@tonic-gate { 14907c478bd9Sstevel@tonic-gate return (pa_hostname(context, 0, 1)); 14917c478bd9Sstevel@tonic-gate } 14927c478bd9Sstevel@tonic-gate 14937c478bd9Sstevel@tonic-gate int 14947c478bd9Sstevel@tonic-gate ip_addr_ex_token(pr_context_t *context) 14957c478bd9Sstevel@tonic-gate { 14967c478bd9Sstevel@tonic-gate int returnstat; 14977c478bd9Sstevel@tonic-gate uint32_t ip_addr[16]; 14987c478bd9Sstevel@tonic-gate uint32_t ip_type; 14997c478bd9Sstevel@tonic-gate struct in_addr ia; 15007c478bd9Sstevel@tonic-gate char *ipstring; 15017c478bd9Sstevel@tonic-gate char buf[256]; 15027c478bd9Sstevel@tonic-gate uval_t uval; 15037c478bd9Sstevel@tonic-gate 15047c478bd9Sstevel@tonic-gate /* get address type */ 15057c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_u_int32(context, &ip_type, 1)) != 0) 15067c478bd9Sstevel@tonic-gate return (returnstat); 15077c478bd9Sstevel@tonic-gate 15087c478bd9Sstevel@tonic-gate /* legal address types are either AU_IPv4 or AU_IPv6 only */ 15097c478bd9Sstevel@tonic-gate if ((ip_type != AU_IPv4) && (ip_type != AU_IPv6)) 15107c478bd9Sstevel@tonic-gate return (-1); 15117c478bd9Sstevel@tonic-gate 15127c478bd9Sstevel@tonic-gate /* get address (4/16) */ 15137c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_char(context, (char *)ip_addr, ip_type)) != 0) 15147c478bd9Sstevel@tonic-gate return (returnstat); 15157c478bd9Sstevel@tonic-gate 15167c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 15177c478bd9Sstevel@tonic-gate if (ip_type == AU_IPv4) { 15187c478bd9Sstevel@tonic-gate uval.string_val = buf; 15197c478bd9Sstevel@tonic-gate 15207c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 15217c478bd9Sstevel@tonic-gate get_Hname(ip_addr[0], buf, sizeof (buf)); 15227c478bd9Sstevel@tonic-gate return (pa_print(context, &uval, 1)); 15237c478bd9Sstevel@tonic-gate } 15247c478bd9Sstevel@tonic-gate 15257c478bd9Sstevel@tonic-gate ia.s_addr = ip_addr[0]; 15267c478bd9Sstevel@tonic-gate if ((ipstring = inet_ntoa(ia)) == NULL) 15277c478bd9Sstevel@tonic-gate return (-1); 15287c478bd9Sstevel@tonic-gate 15297c478bd9Sstevel@tonic-gate (void) snprintf(buf, sizeof (buf), "%s", ipstring); 15307c478bd9Sstevel@tonic-gate 15317c478bd9Sstevel@tonic-gate } else { 15327c478bd9Sstevel@tonic-gate uval.string_val = buf; 15337c478bd9Sstevel@tonic-gate 15347c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 15357c478bd9Sstevel@tonic-gate get_Hname_ex(ip_addr, buf, sizeof (buf)); 15367c478bd9Sstevel@tonic-gate return (pa_print(context, &uval, 1)); 15377c478bd9Sstevel@tonic-gate } 15387c478bd9Sstevel@tonic-gate 15397c478bd9Sstevel@tonic-gate (void) inet_ntop(AF_INET6, (void *) ip_addr, buf, 15407c478bd9Sstevel@tonic-gate sizeof (buf)); 15417c478bd9Sstevel@tonic-gate 15427c478bd9Sstevel@tonic-gate } 15437c478bd9Sstevel@tonic-gate 15447c478bd9Sstevel@tonic-gate return (pa_print(context, &uval, 1)); 15457c478bd9Sstevel@tonic-gate } 15467c478bd9Sstevel@tonic-gate 15477c478bd9Sstevel@tonic-gate /* 15487c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 15497c478bd9Sstevel@tonic-gate * ip_token() : Process ip header token and display contents 15507c478bd9Sstevel@tonic-gate * return codes : -1 - error 15517c478bd9Sstevel@tonic-gate * : 0 - successful 15527c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the ip token id has been retrieved 15537c478bd9Sstevel@tonic-gate * 15547c478bd9Sstevel@tonic-gate * Format of ip header token: 15557c478bd9Sstevel@tonic-gate * ip header token id adr_char 15567c478bd9Sstevel@tonic-gate * version adr_char (printed in hex) 15577c478bd9Sstevel@tonic-gate * type of service adr_char (printed in hex) 15587c478bd9Sstevel@tonic-gate * length adr_short 15597c478bd9Sstevel@tonic-gate * id adr_u_short 15607c478bd9Sstevel@tonic-gate * offset adr_u_short 15617c478bd9Sstevel@tonic-gate * ttl adr_char (printed in hex) 15627c478bd9Sstevel@tonic-gate * protocol adr_char (printed in hex) 15637c478bd9Sstevel@tonic-gate * checksum adr_u_short 15647c478bd9Sstevel@tonic-gate * source address adr_int32 (printed in hex) 15657c478bd9Sstevel@tonic-gate * destination address adr_int32 (printed in hex) 15667c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 15677c478bd9Sstevel@tonic-gate */ 15687c478bd9Sstevel@tonic-gate int 15697c478bd9Sstevel@tonic-gate ip_token(pr_context_t *context) 15707c478bd9Sstevel@tonic-gate { 15717c478bd9Sstevel@tonic-gate int returnstat; 15727c478bd9Sstevel@tonic-gate 15737c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPVERS, 0, 0); 15747c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPSERV, returnstat, 0); 15757c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPLEN, returnstat, 0); 15767c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPID, returnstat, 0); 15777c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPOFFS, returnstat, 0); 15787c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPTTL, returnstat, 0); 15797c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPPROTO, returnstat, 0); 15807c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPCKSUM, returnstat, 0); 15817c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPSRC, returnstat, 0); 15827c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_IPDEST, returnstat, 1); 15837c478bd9Sstevel@tonic-gate 15847c478bd9Sstevel@tonic-gate return (returnstat); 15857c478bd9Sstevel@tonic-gate } 15867c478bd9Sstevel@tonic-gate 15877c478bd9Sstevel@tonic-gate /* 15887c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 15897c478bd9Sstevel@tonic-gate * iport_token() : Process ip port address token and display contents 15907c478bd9Sstevel@tonic-gate * return codes : -1 - error 15917c478bd9Sstevel@tonic-gate * : 0 - successful 15927c478bd9Sstevel@tonic-gate * NOTE: At time of call, the ip port address token id has been retrieved 15937c478bd9Sstevel@tonic-gate * 15947c478bd9Sstevel@tonic-gate * Format of ip port token: 15957c478bd9Sstevel@tonic-gate * ip port address token id adr_char 15967c478bd9Sstevel@tonic-gate * port address adr_short (in hex) 15977c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 15987c478bd9Sstevel@tonic-gate */ 15997c478bd9Sstevel@tonic-gate int 16007c478bd9Sstevel@tonic-gate iport_token(pr_context_t *context) 16017c478bd9Sstevel@tonic-gate { 16027c478bd9Sstevel@tonic-gate return (pa_adr_shorthex(context, 0, 1)); 16037c478bd9Sstevel@tonic-gate } 16047c478bd9Sstevel@tonic-gate 16057c478bd9Sstevel@tonic-gate /* 16067c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 16077c478bd9Sstevel@tonic-gate * socket_token() : Process socket token and display contents 16087c478bd9Sstevel@tonic-gate * return codes : -1 - error 16097c478bd9Sstevel@tonic-gate * : 0 - successful 16107c478bd9Sstevel@tonic-gate * NOTE: At time of call, the socket token id has been retrieved 16117c478bd9Sstevel@tonic-gate * 16127c478bd9Sstevel@tonic-gate * Format of socket token: 16137c478bd9Sstevel@tonic-gate * ip socket token id adr_char 16147c478bd9Sstevel@tonic-gate * socket type adr_short (in hex) 16157c478bd9Sstevel@tonic-gate * foreign port adr_short (in hex) 16167c478bd9Sstevel@tonic-gate * foreign internet address adr_hostname/adr_int32 (in ascii/hex) 16177c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 16187c478bd9Sstevel@tonic-gate * 16197c478bd9Sstevel@tonic-gate * Note: local port and local internet address have been removed for 5.x 16207c478bd9Sstevel@tonic-gate */ 16217c478bd9Sstevel@tonic-gate int 16227c478bd9Sstevel@tonic-gate socket_token(pr_context_t *context) 16237c478bd9Sstevel@tonic-gate { 16247c478bd9Sstevel@tonic-gate int returnstat; 16257c478bd9Sstevel@tonic-gate 16267c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SOCKTYPE, 0, 0); 16277c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SOCKPORT, returnstat, 0); 16287c478bd9Sstevel@tonic-gate if (returnstat != 0) 16297c478bd9Sstevel@tonic-gate return (returnstat); 16307c478bd9Sstevel@tonic-gate 16317c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_SOCKADDR)) != 0) 16327c478bd9Sstevel@tonic-gate return (returnstat); 16337c478bd9Sstevel@tonic-gate 16347c478bd9Sstevel@tonic-gate if ((returnstat = pa_hostname(context, returnstat, 1)) != 0) 16357c478bd9Sstevel@tonic-gate return (returnstat); 16367c478bd9Sstevel@tonic-gate 16377c478bd9Sstevel@tonic-gate return (close_tag(context, TAG_SOCKADDR)); 16387c478bd9Sstevel@tonic-gate } 16397c478bd9Sstevel@tonic-gate 16407c478bd9Sstevel@tonic-gate /* 16417c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 16427c478bd9Sstevel@tonic-gate * socket_ex_token() : Process socket token and display contents 16437c478bd9Sstevel@tonic-gate * return codes : -1 - error 16447c478bd9Sstevel@tonic-gate * : 0 - successful 16457c478bd9Sstevel@tonic-gate * NOTE: At time of call, the extended socket token id has been retrieved 16467c478bd9Sstevel@tonic-gate * 16477c478bd9Sstevel@tonic-gate * Format of extended socket token: 16487c478bd9Sstevel@tonic-gate * token id adr_char 16497c478bd9Sstevel@tonic-gate * socket domain adr_short (in hex) 16507c478bd9Sstevel@tonic-gate * socket type adr_short (in hex) 16517c478bd9Sstevel@tonic-gate * IP address type adr_short (in hex) [not displayed] 16527c478bd9Sstevel@tonic-gate * local port adr_short (in hex) 16537c478bd9Sstevel@tonic-gate * local internet address adr_hostname/adr_int32 (in ascii/hex) 16547c478bd9Sstevel@tonic-gate * foreign port adr_short (in hex) 16557c478bd9Sstevel@tonic-gate * foreign internet address adr_hostname/adr_int32 (in ascii/hex) 16567c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 16577c478bd9Sstevel@tonic-gate * 16587c478bd9Sstevel@tonic-gate * Note: local port and local internet address have been removed for 5.x 16597c478bd9Sstevel@tonic-gate */ 16607c478bd9Sstevel@tonic-gate int 16617c478bd9Sstevel@tonic-gate socket_ex_token(pr_context_t *context) 16627c478bd9Sstevel@tonic-gate { 16637c478bd9Sstevel@tonic-gate int returnstat; 16647c478bd9Sstevel@tonic-gate 16657c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SOCKEXDOM, 0, 0); 16667c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SOCKEXTYPE, returnstat, 0); 16677c478bd9Sstevel@tonic-gate returnstat = pa_hostname_so(context, returnstat, 1); 16687c478bd9Sstevel@tonic-gate 16697c478bd9Sstevel@tonic-gate return (returnstat); 16707c478bd9Sstevel@tonic-gate } 16717c478bd9Sstevel@tonic-gate 16727c478bd9Sstevel@tonic-gate /* 16737c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 16747c478bd9Sstevel@tonic-gate * sequence_token() : Process sequence token and display contents 16757c478bd9Sstevel@tonic-gate * return codes : -1 - error 16767c478bd9Sstevel@tonic-gate * : 0 - successful 16777c478bd9Sstevel@tonic-gate * NOTE: At time of call, the socket token id has been retrieved 16787c478bd9Sstevel@tonic-gate * 16797c478bd9Sstevel@tonic-gate * Format of sequence token: 16807c478bd9Sstevel@tonic-gate * sequence token id adr_char 16817c478bd9Sstevel@tonic-gate * sequence number adr_u_int32 (in hex) 16827c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 16837c478bd9Sstevel@tonic-gate */ 16847c478bd9Sstevel@tonic-gate int 16857c478bd9Sstevel@tonic-gate sequence_token(pr_context_t *context) 16867c478bd9Sstevel@tonic-gate { 16877c478bd9Sstevel@tonic-gate return (process_tag(context, TAG_SEQNUM, 0, 1)); 16887c478bd9Sstevel@tonic-gate } 16897c478bd9Sstevel@tonic-gate 16907c478bd9Sstevel@tonic-gate /* 16917c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 16927c478bd9Sstevel@tonic-gate * acl_token() : Process access control list term 16937c478bd9Sstevel@tonic-gate * return codes : -1 - error 16947c478bd9Sstevel@tonic-gate * : 0 - successful 16957c478bd9Sstevel@tonic-gate * 16967c478bd9Sstevel@tonic-gate * Format of acl token: 16977c478bd9Sstevel@tonic-gate * token id adr_char 16987c478bd9Sstevel@tonic-gate * term type adr_u_int32 16997c478bd9Sstevel@tonic-gate * term value adr_u_int32 (depends on type) 17007c478bd9Sstevel@tonic-gate * file mode adr_u_int (in octal) 17017c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 17027c478bd9Sstevel@tonic-gate */ 17037c478bd9Sstevel@tonic-gate int 17047c478bd9Sstevel@tonic-gate acl_token(pr_context_t *context) 17057c478bd9Sstevel@tonic-gate { 17067c478bd9Sstevel@tonic-gate int returnstat; 17077c478bd9Sstevel@tonic-gate 17087c478bd9Sstevel@tonic-gate returnstat = pa_pw_uid_gr_gid(context, 0, 0); 17097c478bd9Sstevel@tonic-gate 17107c478bd9Sstevel@tonic-gate return (process_tag(context, TAG_MODE, returnstat, 1)); 17117c478bd9Sstevel@tonic-gate } 17127c478bd9Sstevel@tonic-gate 17137c478bd9Sstevel@tonic-gate /* 17147c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 17157c478bd9Sstevel@tonic-gate * attribute_token() : Process attribute token and display contents 17167c478bd9Sstevel@tonic-gate * return codes : -1 - error 17177c478bd9Sstevel@tonic-gate * : 0 - successful 17187c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the attribute token id has been retrieved 17197c478bd9Sstevel@tonic-gate * 17207c478bd9Sstevel@tonic-gate * Format of attribute token: 17217c478bd9Sstevel@tonic-gate * attribute token id adr_char 17227c478bd9Sstevel@tonic-gate * mode adr_u_int (printed in octal) 17237c478bd9Sstevel@tonic-gate * uid adr_u_int 17247c478bd9Sstevel@tonic-gate * gid adr_u_int 17257c478bd9Sstevel@tonic-gate * file system id adr_int 17267c478bd9Sstevel@tonic-gate * 17277c478bd9Sstevel@tonic-gate * node id adr_int (attribute_token 17287c478bd9Sstevel@tonic-gate * pre SunOS 5.7) 17297c478bd9Sstevel@tonic-gate * device adr_u_int 17307c478bd9Sstevel@tonic-gate * or 17317c478bd9Sstevel@tonic-gate * node id adr_int64 (attribute32_token) 17327c478bd9Sstevel@tonic-gate * device adr_u_int 17337c478bd9Sstevel@tonic-gate * or 17347c478bd9Sstevel@tonic-gate * node id adr_int64 (attribute64_token) 17357c478bd9Sstevel@tonic-gate * device adr_u_int64 17367c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 17377c478bd9Sstevel@tonic-gate */ 17387c478bd9Sstevel@tonic-gate int 17397c478bd9Sstevel@tonic-gate attribute_token(pr_context_t *context) 17407c478bd9Sstevel@tonic-gate { 17417c478bd9Sstevel@tonic-gate int returnstat; 17427c478bd9Sstevel@tonic-gate 17437c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_MODE, 0, 0); 17447c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 17457c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 17467c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_FSID, returnstat, 0); 17477c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_NODEID32, returnstat, 0); 17487c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_DEVICE32, returnstat, 1); 17497c478bd9Sstevel@tonic-gate 17507c478bd9Sstevel@tonic-gate return (returnstat); 17517c478bd9Sstevel@tonic-gate } 17527c478bd9Sstevel@tonic-gate 17537c478bd9Sstevel@tonic-gate int 17547c478bd9Sstevel@tonic-gate attribute32_token(pr_context_t *context) 17557c478bd9Sstevel@tonic-gate { 17567c478bd9Sstevel@tonic-gate int returnstat; 17577c478bd9Sstevel@tonic-gate 17587c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_MODE, 0, 0); 17597c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 17607c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 17617c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_FSID, returnstat, 0); 17627c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_NODEID64, returnstat, 0); 17637c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_DEVICE32, returnstat, 1); 17647c478bd9Sstevel@tonic-gate 17657c478bd9Sstevel@tonic-gate return (returnstat); 17667c478bd9Sstevel@tonic-gate } 17677c478bd9Sstevel@tonic-gate 17687c478bd9Sstevel@tonic-gate int 17697c478bd9Sstevel@tonic-gate attribute64_token(pr_context_t *context) 17707c478bd9Sstevel@tonic-gate { 17717c478bd9Sstevel@tonic-gate int returnstat; 17727c478bd9Sstevel@tonic-gate 17737c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_MODE, 0, 0); 17747c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, returnstat, 0); 17757c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 17767c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_FSID, returnstat, 0); 17777c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_NODEID64, returnstat, 0); 17787c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_DEVICE64, returnstat, 1); 17797c478bd9Sstevel@tonic-gate 17807c478bd9Sstevel@tonic-gate return (returnstat); 17817c478bd9Sstevel@tonic-gate } 17827c478bd9Sstevel@tonic-gate 17837c478bd9Sstevel@tonic-gate /* 17847c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 17857c478bd9Sstevel@tonic-gate * group_token() : Process group token and display contents 17867c478bd9Sstevel@tonic-gate * return codes : -1 - error 17877c478bd9Sstevel@tonic-gate * : 0 - successful 17887c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the group token id has been retrieved 17897c478bd9Sstevel@tonic-gate * 17907c478bd9Sstevel@tonic-gate * Format of group token: 17917c478bd9Sstevel@tonic-gate * group token id adr_char 17927c478bd9Sstevel@tonic-gate * group list adr_long, 16 times 17937c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 17947c478bd9Sstevel@tonic-gate */ 17957c478bd9Sstevel@tonic-gate int 17967c478bd9Sstevel@tonic-gate group_token(pr_context_t *context) 17977c478bd9Sstevel@tonic-gate { 17987c478bd9Sstevel@tonic-gate int returnstat = 0; 17997c478bd9Sstevel@tonic-gate int i; 18007c478bd9Sstevel@tonic-gate 18017c478bd9Sstevel@tonic-gate for (i = 0; i < NGROUPS_MAX - 1; i++) { 18027c478bd9Sstevel@tonic-gate if ((returnstat = process_tag(context, TAG_GROUPID, 18037c478bd9Sstevel@tonic-gate returnstat, 0)) < 0) 18047c478bd9Sstevel@tonic-gate return (returnstat); 18057c478bd9Sstevel@tonic-gate } 18067c478bd9Sstevel@tonic-gate 18077c478bd9Sstevel@tonic-gate return (process_tag(context, TAG_GROUPID, returnstat, 1)); 18087c478bd9Sstevel@tonic-gate } 18097c478bd9Sstevel@tonic-gate 18107c478bd9Sstevel@tonic-gate /* 18117c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 18127c478bd9Sstevel@tonic-gate * newgroup_token() : Process group token and display contents 18137c478bd9Sstevel@tonic-gate * return codes : -1 - error 18147c478bd9Sstevel@tonic-gate * : 0 - successful 18157c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the group token id has been retrieved 18167c478bd9Sstevel@tonic-gate * 18177c478bd9Sstevel@tonic-gate * Format of new group token: 18187c478bd9Sstevel@tonic-gate * group token id adr_char 18197c478bd9Sstevel@tonic-gate * group number adr_short 18207c478bd9Sstevel@tonic-gate * group list adr_int32, group number times 18217c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 18227c478bd9Sstevel@tonic-gate */ 18237c478bd9Sstevel@tonic-gate int 18247c478bd9Sstevel@tonic-gate newgroup_token(pr_context_t *context) 18257c478bd9Sstevel@tonic-gate { 18267c478bd9Sstevel@tonic-gate int returnstat; 18277c478bd9Sstevel@tonic-gate int i, num; 18287c478bd9Sstevel@tonic-gate short n_groups; 18297c478bd9Sstevel@tonic-gate 18307c478bd9Sstevel@tonic-gate returnstat = pr_adr_short(context, &n_groups, 1); 18317c478bd9Sstevel@tonic-gate if (returnstat != 0) 18327c478bd9Sstevel@tonic-gate return (returnstat); 18337c478bd9Sstevel@tonic-gate 18347c478bd9Sstevel@tonic-gate num = (int)n_groups; 18357c478bd9Sstevel@tonic-gate if (num == 0) { 18367c478bd9Sstevel@tonic-gate if (!(context->format & PRF_XMLM)) { 1837*a777da3eSpaulson returnstat = do_newline(context, 1); 18387c478bd9Sstevel@tonic-gate } 18397c478bd9Sstevel@tonic-gate return (returnstat); 18407c478bd9Sstevel@tonic-gate } 18417c478bd9Sstevel@tonic-gate for (i = 0; i < num - 1; i++) { 18427c478bd9Sstevel@tonic-gate if ((returnstat = process_tag(context, TAG_GROUPID, 18437c478bd9Sstevel@tonic-gate returnstat, 0)) < 0) 18447c478bd9Sstevel@tonic-gate return (returnstat); 18457c478bd9Sstevel@tonic-gate } 18467c478bd9Sstevel@tonic-gate 18477c478bd9Sstevel@tonic-gate return (process_tag(context, TAG_GROUPID, returnstat, 1)); 18487c478bd9Sstevel@tonic-gate } 18497c478bd9Sstevel@tonic-gate 18507c478bd9Sstevel@tonic-gate static int 18517c478bd9Sstevel@tonic-gate string_token_common(pr_context_t *context, int tag) 18527c478bd9Sstevel@tonic-gate { 18537c478bd9Sstevel@tonic-gate int returnstat; 18547c478bd9Sstevel@tonic-gate int num; 18557c478bd9Sstevel@tonic-gate 18567c478bd9Sstevel@tonic-gate returnstat = pr_adr_int32(context, (int32_t *)&num, 1); 18577c478bd9Sstevel@tonic-gate if (returnstat != 0) 18587c478bd9Sstevel@tonic-gate return (returnstat); 18597c478bd9Sstevel@tonic-gate 18607c478bd9Sstevel@tonic-gate if (!(context->format & PRF_XMLM)) { 18617c478bd9Sstevel@tonic-gate returnstat = pr_printf(context, "%d%s", num, 18627c478bd9Sstevel@tonic-gate context->SEPARATOR); 18637c478bd9Sstevel@tonic-gate if (returnstat != 0) 18647c478bd9Sstevel@tonic-gate return (returnstat); 18657c478bd9Sstevel@tonic-gate } 18667c478bd9Sstevel@tonic-gate 18677c478bd9Sstevel@tonic-gate if (num == 0) 18687c478bd9Sstevel@tonic-gate return (0); 18697c478bd9Sstevel@tonic-gate 18707c478bd9Sstevel@tonic-gate for (; num > 1; num--) { 18717c478bd9Sstevel@tonic-gate if ((returnstat = (process_tag(context, tag, 18727c478bd9Sstevel@tonic-gate returnstat, 0))) < 0) 18737c478bd9Sstevel@tonic-gate return (returnstat); 18747c478bd9Sstevel@tonic-gate } 18757c478bd9Sstevel@tonic-gate 18767c478bd9Sstevel@tonic-gate return (process_tag(context, tag, returnstat, 1)); 18777c478bd9Sstevel@tonic-gate } 18787c478bd9Sstevel@tonic-gate 18797c478bd9Sstevel@tonic-gate int 18807c478bd9Sstevel@tonic-gate path_attr_token(pr_context_t *context) 18817c478bd9Sstevel@tonic-gate { 18827c478bd9Sstevel@tonic-gate return (string_token_common(context, TAG_XAT)); 18837c478bd9Sstevel@tonic-gate } 18847c478bd9Sstevel@tonic-gate 18857c478bd9Sstevel@tonic-gate int 18867c478bd9Sstevel@tonic-gate exec_args_token(pr_context_t *context) 18877c478bd9Sstevel@tonic-gate { 18887c478bd9Sstevel@tonic-gate return (string_token_common(context, TAG_ARG)); 18897c478bd9Sstevel@tonic-gate } 18907c478bd9Sstevel@tonic-gate 18917c478bd9Sstevel@tonic-gate int 18927c478bd9Sstevel@tonic-gate exec_env_token(pr_context_t *context) 18937c478bd9Sstevel@tonic-gate { 18947c478bd9Sstevel@tonic-gate return (string_token_common(context, TAG_ENV)); 18957c478bd9Sstevel@tonic-gate } 18967c478bd9Sstevel@tonic-gate 18977c478bd9Sstevel@tonic-gate /* 18987c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 18997c478bd9Sstevel@tonic-gate * s5_IPC_perm_token() : Process System V IPC permission token and display 19007c478bd9Sstevel@tonic-gate * contents 19017c478bd9Sstevel@tonic-gate * return codes : -1 - error 19027c478bd9Sstevel@tonic-gate * : 0 - successful 19037c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the System V IPC permission token id 19047c478bd9Sstevel@tonic-gate * has been retrieved 19057c478bd9Sstevel@tonic-gate * 19067c478bd9Sstevel@tonic-gate * Format of System V IPC permission token: 19077c478bd9Sstevel@tonic-gate * System V IPC permission token id adr_char 19087c478bd9Sstevel@tonic-gate * uid adr_u_int32 19097c478bd9Sstevel@tonic-gate * gid adr_u_int32 19107c478bd9Sstevel@tonic-gate * cuid adr_u_int32 19117c478bd9Sstevel@tonic-gate * cgid adr_u_int32 19127c478bd9Sstevel@tonic-gate * mode adr_u_int32 19137c478bd9Sstevel@tonic-gate * seq adr_u_int32 19147c478bd9Sstevel@tonic-gate * key adr_int32 19157c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19167c478bd9Sstevel@tonic-gate */ 19177c478bd9Sstevel@tonic-gate int 19187c478bd9Sstevel@tonic-gate s5_IPC_perm_token(pr_context_t *context) 19197c478bd9Sstevel@tonic-gate { 19207c478bd9Sstevel@tonic-gate int returnstat; 19217c478bd9Sstevel@tonic-gate 19227c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_UID, 0, 0); 19237c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_GID, returnstat, 0); 19247c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_CUID, returnstat, 0); 19257c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_CGID, returnstat, 0); 19267c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_MODE, returnstat, 0); 19277c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SEQ, returnstat, 0); 19287c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_KEY, returnstat, 1); 19297c478bd9Sstevel@tonic-gate 19307c478bd9Sstevel@tonic-gate return (returnstat); 19317c478bd9Sstevel@tonic-gate } 19327c478bd9Sstevel@tonic-gate 19337c478bd9Sstevel@tonic-gate /* 19347c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19357c478bd9Sstevel@tonic-gate * host_token() : Process host token and display contents 19367c478bd9Sstevel@tonic-gate * return codes : -1 - error 19377c478bd9Sstevel@tonic-gate * : 0 - successful 19387c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the host token id has been retrieved 19397c478bd9Sstevel@tonic-gate * 19407c478bd9Sstevel@tonic-gate * Format of host token: 19417c478bd9Sstevel@tonic-gate * host token id adr_char 19427c478bd9Sstevel@tonic-gate * hostid adr_u_int32 19437c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19447c478bd9Sstevel@tonic-gate */ 19457c478bd9Sstevel@tonic-gate int 19467c478bd9Sstevel@tonic-gate host_token(pr_context_t *context) 19477c478bd9Sstevel@tonic-gate { 19487c478bd9Sstevel@tonic-gate return (pa_hostname(context, 0, 1)); 19497c478bd9Sstevel@tonic-gate } 19507c478bd9Sstevel@tonic-gate 19517c478bd9Sstevel@tonic-gate /* 19527c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19537c478bd9Sstevel@tonic-gate * liaison_token() : Process liaison token and display contents 19547c478bd9Sstevel@tonic-gate * return codes : -1 - error 19557c478bd9Sstevel@tonic-gate * : 0 - successful 19567c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the liaison token id has been retrieved 19577c478bd9Sstevel@tonic-gate * 19587c478bd9Sstevel@tonic-gate * Format of liaison token: 19597c478bd9Sstevel@tonic-gate * liaison token id adr_char 19607c478bd9Sstevel@tonic-gate * liaison adr_u_int32 19617c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19627c478bd9Sstevel@tonic-gate */ 19637c478bd9Sstevel@tonic-gate int 19647c478bd9Sstevel@tonic-gate liaison_token(pr_context_t *context) 19657c478bd9Sstevel@tonic-gate { 19667c478bd9Sstevel@tonic-gate return (pa_liaison(context, 0, 1)); 19677c478bd9Sstevel@tonic-gate } 19687c478bd9Sstevel@tonic-gate 19697c478bd9Sstevel@tonic-gate /* 19707c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19717c478bd9Sstevel@tonic-gate * useofauth_token(): Process useofauth token and display contents 19727c478bd9Sstevel@tonic-gate * return codes : -1 - error 19737c478bd9Sstevel@tonic-gate * : 0 - successful 19747c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the uauth token id has been retrieved 19757c478bd9Sstevel@tonic-gate * 19767c478bd9Sstevel@tonic-gate * Format of useofauth token: 19777c478bd9Sstevel@tonic-gate * uauth token id adr_char 19787c478bd9Sstevel@tonic-gate * uauth adr_string 19797c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19807c478bd9Sstevel@tonic-gate */ 19817c478bd9Sstevel@tonic-gate int 19827c478bd9Sstevel@tonic-gate useofauth_token(pr_context_t *context) 19837c478bd9Sstevel@tonic-gate { 19847c478bd9Sstevel@tonic-gate return (pa_adr_string(context, 0, 1)); 19857c478bd9Sstevel@tonic-gate } 19867c478bd9Sstevel@tonic-gate 19877c478bd9Sstevel@tonic-gate /* 19887c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19897c478bd9Sstevel@tonic-gate * zonename_token(): Process zonename token and display contents 19907c478bd9Sstevel@tonic-gate * return codes : -1 - error 19917c478bd9Sstevel@tonic-gate * : 0 - successful 19927c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the zonename token id has been retrieved 19937c478bd9Sstevel@tonic-gate * 19947c478bd9Sstevel@tonic-gate * Format of zonename token: 19957c478bd9Sstevel@tonic-gate * zonename token id adr_char 19967c478bd9Sstevel@tonic-gate * zone name adr_string 19977c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 19987c478bd9Sstevel@tonic-gate */ 19997c478bd9Sstevel@tonic-gate int 20007c478bd9Sstevel@tonic-gate zonename_token(pr_context_t *context) 20017c478bd9Sstevel@tonic-gate { 20027c478bd9Sstevel@tonic-gate return (process_tag(context, TAG_ZONENAME, 0, 1)); 20037c478bd9Sstevel@tonic-gate } 20047c478bd9Sstevel@tonic-gate 20057c478bd9Sstevel@tonic-gate /* 20067c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 2007103b2b15Sgww * fmri_token(): Process fmri token and display contents 2008103b2b15Sgww * return codes : -1 - error 2009103b2b15Sgww * : 0 - successful 2010103b2b15Sgww * NOTE: At the time of call, the fmri token id has been retrieved 2011103b2b15Sgww * 2012103b2b15Sgww * Format of fmri token: 2013103b2b15Sgww * fmri token id adr_char 2014103b2b15Sgww * service instance name adr_string 2015103b2b15Sgww * ----------------------------------------------------------------------- 2016103b2b15Sgww */ 2017103b2b15Sgww int 2018103b2b15Sgww fmri_token(pr_context_t *context) 2019103b2b15Sgww { 2020103b2b15Sgww return (pa_adr_string(context, 0, 1)); 2021103b2b15Sgww } 2022103b2b15Sgww 2023103b2b15Sgww /* 2024103b2b15Sgww * ----------------------------------------------------------------------- 20257c478bd9Sstevel@tonic-gate * xatom_token() : Process Xatom token and display contents in hex. 20267c478bd9Sstevel@tonic-gate * return codes : -1 - error 20277c478bd9Sstevel@tonic-gate * : 0 - successful 20287c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the xatom token id has been retrieved 20297c478bd9Sstevel@tonic-gate * 20307c478bd9Sstevel@tonic-gate * Format of xatom token: 20317c478bd9Sstevel@tonic-gate * token id adr_char 20327c478bd9Sstevel@tonic-gate * length adr_short 20337c478bd9Sstevel@tonic-gate * atom adr_char length times 20347c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 20357c478bd9Sstevel@tonic-gate */ 20367c478bd9Sstevel@tonic-gate int 20377c478bd9Sstevel@tonic-gate xatom_token(pr_context_t *context) 20387c478bd9Sstevel@tonic-gate { 20397c478bd9Sstevel@tonic-gate return (pa_adr_string(context, 0, 1)); 20407c478bd9Sstevel@tonic-gate } 20417c478bd9Sstevel@tonic-gate 20427c478bd9Sstevel@tonic-gate int 20437c478bd9Sstevel@tonic-gate xcolormap_token(pr_context_t *context) 20447c478bd9Sstevel@tonic-gate { 20457c478bd9Sstevel@tonic-gate return (pa_xgeneric(context)); 20467c478bd9Sstevel@tonic-gate } 20477c478bd9Sstevel@tonic-gate 20487c478bd9Sstevel@tonic-gate int 20497c478bd9Sstevel@tonic-gate xcursor_token(pr_context_t *context) 20507c478bd9Sstevel@tonic-gate { 20517c478bd9Sstevel@tonic-gate return (pa_xgeneric(context)); 20527c478bd9Sstevel@tonic-gate } 20537c478bd9Sstevel@tonic-gate 20547c478bd9Sstevel@tonic-gate int 20557c478bd9Sstevel@tonic-gate xfont_token(pr_context_t *context) 20567c478bd9Sstevel@tonic-gate { 20577c478bd9Sstevel@tonic-gate return (pa_xgeneric(context)); 20587c478bd9Sstevel@tonic-gate } 20597c478bd9Sstevel@tonic-gate 20607c478bd9Sstevel@tonic-gate int 20617c478bd9Sstevel@tonic-gate xgc_token(pr_context_t *context) 20627c478bd9Sstevel@tonic-gate { 20637c478bd9Sstevel@tonic-gate return (pa_xgeneric(context)); 20647c478bd9Sstevel@tonic-gate } 20657c478bd9Sstevel@tonic-gate 20667c478bd9Sstevel@tonic-gate int 20677c478bd9Sstevel@tonic-gate xpixmap_token(pr_context_t *context) 20687c478bd9Sstevel@tonic-gate { 20697c478bd9Sstevel@tonic-gate return (pa_xgeneric(context)); 20707c478bd9Sstevel@tonic-gate } 20717c478bd9Sstevel@tonic-gate 20727c478bd9Sstevel@tonic-gate int 20737c478bd9Sstevel@tonic-gate xwindow_token(pr_context_t *context) 20747c478bd9Sstevel@tonic-gate { 20757c478bd9Sstevel@tonic-gate return (pa_xgeneric(context)); 20767c478bd9Sstevel@tonic-gate } 20777c478bd9Sstevel@tonic-gate 20787c478bd9Sstevel@tonic-gate /* 20797c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 20807c478bd9Sstevel@tonic-gate * xproperty_token(): Process Xproperty token and display contents 20817c478bd9Sstevel@tonic-gate * 20827c478bd9Sstevel@tonic-gate * return codes : -1 - error 20837c478bd9Sstevel@tonic-gate * : 0 - successful 20847c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the xproperty token id has been retrieved 20857c478bd9Sstevel@tonic-gate * 20867c478bd9Sstevel@tonic-gate * Format of xproperty token: 20877c478bd9Sstevel@tonic-gate * token id adr_char 20887c478bd9Sstevel@tonic-gate * XID adr_u_int32 20897c478bd9Sstevel@tonic-gate * creator UID adr_u_int32 20907c478bd9Sstevel@tonic-gate * text adr_text 20917c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 20927c478bd9Sstevel@tonic-gate */ 20937c478bd9Sstevel@tonic-gate int 20947c478bd9Sstevel@tonic-gate xproperty_token(pr_context_t *context) 20957c478bd9Sstevel@tonic-gate { 20967c478bd9Sstevel@tonic-gate int returnstat; 20977c478bd9Sstevel@tonic-gate 20987c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_XID, 0, 0); 20997c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_XCUID, returnstat, 0); 21007c478bd9Sstevel@tonic-gate 21017c478bd9Sstevel@tonic-gate /* Done with attributes; force end of token open */ 21027c478bd9Sstevel@tonic-gate if (returnstat == 0) 21037c478bd9Sstevel@tonic-gate returnstat = finish_open_tag(context); 21047c478bd9Sstevel@tonic-gate 21057c478bd9Sstevel@tonic-gate returnstat = pa_adr_string(context, returnstat, 1); 21067c478bd9Sstevel@tonic-gate 21077c478bd9Sstevel@tonic-gate return (returnstat); 21087c478bd9Sstevel@tonic-gate } 21097c478bd9Sstevel@tonic-gate 21107c478bd9Sstevel@tonic-gate /* 21117c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 21127c478bd9Sstevel@tonic-gate * xselect_token(): Process Xselect token and display contents in hex 21137c478bd9Sstevel@tonic-gate * 21147c478bd9Sstevel@tonic-gate * return codes : -1 - error 21157c478bd9Sstevel@tonic-gate * : 0 - successful 21167c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the xselect token id has been retrieved 21177c478bd9Sstevel@tonic-gate * 21187c478bd9Sstevel@tonic-gate * Format of xselect token 21197c478bd9Sstevel@tonic-gate * text token id adr_char 21207c478bd9Sstevel@tonic-gate * property text adr_string 21217c478bd9Sstevel@tonic-gate * property type adr_string 21227c478bd9Sstevel@tonic-gate * property data adr_string 21237c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 21247c478bd9Sstevel@tonic-gate */ 21257c478bd9Sstevel@tonic-gate int 21267c478bd9Sstevel@tonic-gate xselect_token(pr_context_t *context) 21277c478bd9Sstevel@tonic-gate { 21287c478bd9Sstevel@tonic-gate int returnstat; 21297c478bd9Sstevel@tonic-gate 21307c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_XSELTEXT, 0, 0); 21317c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_XSELTYPE, returnstat, 0); 21327c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_XSELDATA, returnstat, 1); 21337c478bd9Sstevel@tonic-gate 21347c478bd9Sstevel@tonic-gate return (returnstat); 21357c478bd9Sstevel@tonic-gate } 21367c478bd9Sstevel@tonic-gate 21377c478bd9Sstevel@tonic-gate /* 21387c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 21397c478bd9Sstevel@tonic-gate * xclient_token(): Process Xclient token and display contents in hex. 21407c478bd9Sstevel@tonic-gate * 21417c478bd9Sstevel@tonic-gate * return codes : -1 - error 21427c478bd9Sstevel@tonic-gate * : 0 - successful 21437c478bd9Sstevel@tonic-gate * 21447c478bd9Sstevel@tonic-gate * Format of xclient token: 21457c478bd9Sstevel@tonic-gate * token id adr_char 21467c478bd9Sstevel@tonic-gate * client adr_int32 21477c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 21487c478bd9Sstevel@tonic-gate */ 21497c478bd9Sstevel@tonic-gate int 21507c478bd9Sstevel@tonic-gate xclient_token(pr_context_t *context) 21517c478bd9Sstevel@tonic-gate { 21527c478bd9Sstevel@tonic-gate return (pa_adr_int32(context, 0, 1)); 21537c478bd9Sstevel@tonic-gate } 21547c478bd9Sstevel@tonic-gate 21557c478bd9Sstevel@tonic-gate /* 21567c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 2157a13cf099Sgww * label_token() : Process label token and display contents 21587c478bd9Sstevel@tonic-gate * return codes : -1 - error 21597c478bd9Sstevel@tonic-gate * : 0 - successful 2160a13cf099Sgww * NOTE: At the time of call, the label token id has been retrieved 21617c478bd9Sstevel@tonic-gate * 2162a13cf099Sgww * Format of label token: 2163a13cf099Sgww * label token id adr_char 2164a13cf099Sgww * label ID adr_char 2165a13cf099Sgww * label compartment length adr_char 2166a13cf099Sgww * label classification adr_short 2167a13cf099Sgww * label compartment words <compartment length> * 4 adr_char 21687c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 21697c478bd9Sstevel@tonic-gate */ 21707c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 21717c478bd9Sstevel@tonic-gate int 2172a13cf099Sgww label_token(pr_context_t *context) 21737c478bd9Sstevel@tonic-gate { 2174a13cf099Sgww static m_label_t *label = NULL; 2175a13cf099Sgww static size_t l_size; 2176a13cf099Sgww int len; 21777c478bd9Sstevel@tonic-gate int returnstat; 21787c478bd9Sstevel@tonic-gate uval_t uval; 21797c478bd9Sstevel@tonic-gate 2180a13cf099Sgww if (label == NULL) { 2181a13cf099Sgww if ((label = m_label_alloc(MAC_LABEL)) == NULL) { 2182a13cf099Sgww return (-1); 2183a13cf099Sgww } 2184a13cf099Sgww l_size = blabel_size() - 4; 2185a13cf099Sgww } 2186a13cf099Sgww if ((returnstat = pr_adr_char(context, (char *)label, 4)) == 0) { 2187a13cf099Sgww len = (int)(((char *)label)[1] * 4); 2188a13cf099Sgww if ((len > l_size) || 2189a13cf099Sgww (pr_adr_char(context, &((char *)label)[4], len) != 0)) { 2190a13cf099Sgww return (-1); 2191a13cf099Sgww } 21927c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 21937c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 219445916cd2Sjpk /* print in ASCII form */ 2195a13cf099Sgww if (label_to_str(label, &uval.string_val, M_LABEL, 219645916cd2Sjpk DEF_NAMES) == 0) { 21977c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 1); 21987c478bd9Sstevel@tonic-gate } else /* cannot convert to string */ 21997c478bd9Sstevel@tonic-gate returnstat = 1; 22007c478bd9Sstevel@tonic-gate } 22017c478bd9Sstevel@tonic-gate /* print in hexadecimal form */ 22027c478bd9Sstevel@tonic-gate if ((context->format & PRF_RAWM) || (returnstat == 1)) { 2203a13cf099Sgww uval.string_val = hexconvert((char *)label, len, len); 22047c478bd9Sstevel@tonic-gate if (uval.string_val) { 22057c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 1); 2206a13cf099Sgww } 2207a13cf099Sgww } 22087c478bd9Sstevel@tonic-gate free(uval.string_val); 22097c478bd9Sstevel@tonic-gate } 22107c478bd9Sstevel@tonic-gate return (returnstat); 22117c478bd9Sstevel@tonic-gate } 22127c478bd9Sstevel@tonic-gate 22137c478bd9Sstevel@tonic-gate /* 22147c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 22157c478bd9Sstevel@tonic-gate * useofpriv_token() : Process priv token and display contents 22167c478bd9Sstevel@tonic-gate * return codes : -1 - error 22177c478bd9Sstevel@tonic-gate * : 0 - successful 22187c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the useofpriv token id has been retrieved 22197c478bd9Sstevel@tonic-gate * 22207c478bd9Sstevel@tonic-gate * Format of useofpriv token: 22217c478bd9Sstevel@tonic-gate * useofpriv token id adr_char 22227c478bd9Sstevel@tonic-gate * success/failure flag adr_char 22237c478bd9Sstevel@tonic-gate * priv adr_int32 (Trusted Solaris) 22247c478bd9Sstevel@tonic-gate * priv_set '\0' separated privileges. 22257c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 22267c478bd9Sstevel@tonic-gate */ 22277c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 22287c478bd9Sstevel@tonic-gate int 22297c478bd9Sstevel@tonic-gate useofpriv_token(pr_context_t *context) 22307c478bd9Sstevel@tonic-gate { 22317c478bd9Sstevel@tonic-gate int returnstat; 22327c478bd9Sstevel@tonic-gate char sf; 22337c478bd9Sstevel@tonic-gate uval_t uval; 22347c478bd9Sstevel@tonic-gate 22357c478bd9Sstevel@tonic-gate if ((returnstat = pr_adr_char(context, &sf, 1)) != 0) { 22367c478bd9Sstevel@tonic-gate return (returnstat); 22377c478bd9Sstevel@tonic-gate } 22387c478bd9Sstevel@tonic-gate if (!(context->format & PRF_RAWM)) { 22397c478bd9Sstevel@tonic-gate /* print in ASCII form */ 22407c478bd9Sstevel@tonic-gate 22417c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_RESULT)) != 0) 22427c478bd9Sstevel@tonic-gate return (returnstat); 22437c478bd9Sstevel@tonic-gate 22447c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_STRING; 22457c478bd9Sstevel@tonic-gate if (sf) { 22467c478bd9Sstevel@tonic-gate uval.string_val = gettext("successful use of priv"); 22477c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 0); 22487c478bd9Sstevel@tonic-gate } else { 22497c478bd9Sstevel@tonic-gate uval.string_val = gettext("failed use of priv"); 22507c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 0); 22517c478bd9Sstevel@tonic-gate } 22527c478bd9Sstevel@tonic-gate if (returnstat == 0) 22537c478bd9Sstevel@tonic-gate returnstat = close_tag(context, TAG_RESULT); 22547c478bd9Sstevel@tonic-gate 22557c478bd9Sstevel@tonic-gate /* Done with attributes; force end of token open */ 22567c478bd9Sstevel@tonic-gate if (returnstat == 0) 22577c478bd9Sstevel@tonic-gate returnstat = finish_open_tag(context); 22587c478bd9Sstevel@tonic-gate } else { 22597c478bd9Sstevel@tonic-gate /* print in hexadecimal form */ 22607c478bd9Sstevel@tonic-gate if ((returnstat = open_tag(context, TAG_RESULT)) != 0) 22617c478bd9Sstevel@tonic-gate return (returnstat); 22627c478bd9Sstevel@tonic-gate uval.uvaltype = PRA_SHORT; 22637c478bd9Sstevel@tonic-gate uval.short_val = sf; 22647c478bd9Sstevel@tonic-gate returnstat = pa_print(context, &uval, 0); 22657c478bd9Sstevel@tonic-gate if (returnstat == 0) 22667c478bd9Sstevel@tonic-gate returnstat = close_tag(context, TAG_RESULT); 22677c478bd9Sstevel@tonic-gate 22687c478bd9Sstevel@tonic-gate /* Done with attributes; force end of token open */ 22697c478bd9Sstevel@tonic-gate if (returnstat == 0) 22707c478bd9Sstevel@tonic-gate returnstat = finish_open_tag(context); 22717c478bd9Sstevel@tonic-gate } 22727c478bd9Sstevel@tonic-gate return (pa_adr_string(context, 0, 1)); 22737c478bd9Sstevel@tonic-gate } 22747c478bd9Sstevel@tonic-gate 22757c478bd9Sstevel@tonic-gate /* 22767c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 22777c478bd9Sstevel@tonic-gate * privilege_token() : Process privilege token and display contents 22787c478bd9Sstevel@tonic-gate * return codes : -1 - error 22797c478bd9Sstevel@tonic-gate * : 0 - successful 22807c478bd9Sstevel@tonic-gate * NOTE: At the time of call, the privilege token id has been retrieved 22817c478bd9Sstevel@tonic-gate * 22827c478bd9Sstevel@tonic-gate * Format of privilege token: 22837c478bd9Sstevel@tonic-gate * privilege token id adr_char 22847c478bd9Sstevel@tonic-gate * privilege type adr_string 22857c478bd9Sstevel@tonic-gate * privilege adr_string 22867c478bd9Sstevel@tonic-gate * ----------------------------------------------------------------------- 22877c478bd9Sstevel@tonic-gate */ 22887c478bd9Sstevel@tonic-gate int 22897c478bd9Sstevel@tonic-gate privilege_token(pr_context_t *context) 22907c478bd9Sstevel@tonic-gate { 22917c478bd9Sstevel@tonic-gate int returnstat; 22927c478bd9Sstevel@tonic-gate 22937c478bd9Sstevel@tonic-gate /* privilege type: */ 22947c478bd9Sstevel@tonic-gate returnstat = process_tag(context, TAG_SETTYPE, 0, 0); 22957c478bd9Sstevel@tonic-gate 22967c478bd9Sstevel@tonic-gate /* Done with attributes; force end of token open */ 22977c478bd9Sstevel@tonic-gate if (returnstat == 0) 22987c478bd9Sstevel@tonic-gate returnstat = finish_open_tag(context); 22997c478bd9Sstevel@tonic-gate 23007c478bd9Sstevel@tonic-gate /* privilege: */ 23017c478bd9Sstevel@tonic-gate return (pa_adr_string(context, returnstat, 1)); 23027c478bd9Sstevel@tonic-gate } 2303