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