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