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