10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*9759SVasumathi.Sundaram@Sun.COM * Common Development and Distribution License (the "License").
6*9759SVasumathi.Sundaram@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*9759SVasumathi.Sundaram@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate #include <sys/errno.h>
280Sstevel@tonic-gate #include <sys/tiuser.h>
290Sstevel@tonic-gate #include <setjmp.h>
300Sstevel@tonic-gate #include <pwd.h>
310Sstevel@tonic-gate #include <grp.h>
320Sstevel@tonic-gate
330Sstevel@tonic-gate #include <rpc/types.h>
340Sstevel@tonic-gate #include <rpc/xdr.h>
350Sstevel@tonic-gate #include <rpc/auth.h>
360Sstevel@tonic-gate #include <rpc/clnt.h>
370Sstevel@tonic-gate #include <rpc/rpc_msg.h>
380Sstevel@tonic-gate #include <string.h>
390Sstevel@tonic-gate #include "snoop.h"
400Sstevel@tonic-gate
410Sstevel@tonic-gate #include <sys/stat.h>
420Sstevel@tonic-gate
430Sstevel@tonic-gate extern char *get_sum_line();
440Sstevel@tonic-gate extern void check_retransmit();
450Sstevel@tonic-gate extern char *sum_nfsfh();
460Sstevel@tonic-gate extern int sum_nfsstat();
470Sstevel@tonic-gate extern int detail_nfsstat();
480Sstevel@tonic-gate extern void detail_nfsfh();
490Sstevel@tonic-gate extern void detail_fattr();
500Sstevel@tonic-gate extern void skip_fattr();
510Sstevel@tonic-gate extern char *sum_nfsfh3();
520Sstevel@tonic-gate extern int sum_nfsstat3();
530Sstevel@tonic-gate extern int detail_nfsstat3();
540Sstevel@tonic-gate extern void detail_post_op_attr();
550Sstevel@tonic-gate extern void detail_nfsfh3();
560Sstevel@tonic-gate extern int sum_nfsstat4();
570Sstevel@tonic-gate extern int detail_nfsstat4();
580Sstevel@tonic-gate
590Sstevel@tonic-gate extern jmp_buf xdr_err;
600Sstevel@tonic-gate
610Sstevel@tonic-gate static void aclcall2();
620Sstevel@tonic-gate static void aclreply2();
630Sstevel@tonic-gate static void aclcall3();
640Sstevel@tonic-gate static void aclreply3();
650Sstevel@tonic-gate static void aclcall4();
660Sstevel@tonic-gate static void aclreply4();
670Sstevel@tonic-gate static void detail_access2();
680Sstevel@tonic-gate static char *sum_access2();
690Sstevel@tonic-gate static void detail_mask();
700Sstevel@tonic-gate static void detail_secattr();
710Sstevel@tonic-gate static void detail_aclent();
720Sstevel@tonic-gate static char *detail_uname();
730Sstevel@tonic-gate static char *detail_gname();
740Sstevel@tonic-gate static char *detail_perm(ushort_t);
75410Skcpoon static void interpret_nfs_acl2(int, int, int, int, int, char *, int);
76410Skcpoon static void interpret_nfs_acl3(int, int, int, int, int, char *, int);
77410Skcpoon static void interpret_nfs_acl4(int, int, int, int, int, char *, int);
780Sstevel@tonic-gate
790Sstevel@tonic-gate #define ACLPROC2_NULL ((unsigned long)(0))
800Sstevel@tonic-gate #define ACLPROC2_GETACL ((unsigned long)(1))
810Sstevel@tonic-gate #define ACLPROC2_SETACL ((unsigned long)(2))
820Sstevel@tonic-gate #define ACLPROC2_GETATTR ((unsigned long)(3))
830Sstevel@tonic-gate #define ACLPROC2_ACCESS ((unsigned long)(4))
840Sstevel@tonic-gate #define ACLPROC2_GETXATTRDIR ((unsigned long)(5))
850Sstevel@tonic-gate
860Sstevel@tonic-gate #define ACLPROC3_NULL ((unsigned long)(0))
870Sstevel@tonic-gate #define ACLPROC3_GETACL ((unsigned long)(1))
880Sstevel@tonic-gate #define ACLPROC3_SETACL ((unsigned long)(2))
890Sstevel@tonic-gate #define ACLPROC3_GETXATTRDIR ((unsigned long)(3))
900Sstevel@tonic-gate
910Sstevel@tonic-gate #define ACLPROC4_NULL ((unsigned long)(0))
920Sstevel@tonic-gate #define ACLPROC4_GETACL ((unsigned long)(1))
930Sstevel@tonic-gate #define ACLPROC4_SETACL ((unsigned long)(2))
940Sstevel@tonic-gate
950Sstevel@tonic-gate #define NA_USER_OBJ 0x1
960Sstevel@tonic-gate #define NA_USER 0x2
970Sstevel@tonic-gate #define NA_GROUP_OBJ 0x4
980Sstevel@tonic-gate #define NA_GROUP 0x8
990Sstevel@tonic-gate #define NA_CLASS_OBJ 0x10
1000Sstevel@tonic-gate #define NA_OTHER_OBJ 0x20
1010Sstevel@tonic-gate #define NA_ACL_DEFAULT 0x1000
1020Sstevel@tonic-gate
1030Sstevel@tonic-gate #define NA_DEF_USER_OBJ (NA_USER_OBJ | NA_ACL_DEFAULT)
1040Sstevel@tonic-gate #define NA_DEF_USER (NA_USER | NA_ACL_DEFAULT)
1050Sstevel@tonic-gate #define NA_DEF_GROUP_OBJ (NA_GROUP_OBJ | NA_ACL_DEFAULT)
1060Sstevel@tonic-gate #define NA_DEF_GROUP (NA_GROUP | NA_ACL_DEFAULT)
1070Sstevel@tonic-gate #define NA_DEF_CLASS_OBJ (NA_CLASS_OBJ | NA_ACL_DEFAULT)
1080Sstevel@tonic-gate #define NA_DEF_OTHER_OBJ (NA_OTHER_OBJ | NA_ACL_DEFAULT)
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate #define NA_ACL 0x1
1110Sstevel@tonic-gate #define NA_ACLCNT 0x2
1120Sstevel@tonic-gate #define NA_DFACL 0x4
1130Sstevel@tonic-gate #define NA_DFACLCNT 0x8
1140Sstevel@tonic-gate
1150Sstevel@tonic-gate #define ACCESS2_READ 0x0001
1160Sstevel@tonic-gate #define ACCESS2_LOOKUP 0x0002
1170Sstevel@tonic-gate #define ACCESS2_MODIFY 0x0004
1180Sstevel@tonic-gate #define ACCESS2_EXTEND 0x0008
1190Sstevel@tonic-gate #define ACCESS2_DELETE 0x0010
1200Sstevel@tonic-gate #define ACCESS2_EXECUTE 0x0020
1210Sstevel@tonic-gate
1220Sstevel@tonic-gate static char *procnames_short_v2[] = {
1230Sstevel@tonic-gate "NULL2", /* 0 */
1240Sstevel@tonic-gate "GETACL2", /* 1 */
1250Sstevel@tonic-gate "SETACL2", /* 2 */
1260Sstevel@tonic-gate "GETATTR2", /* 3 */
1270Sstevel@tonic-gate "ACCESS2", /* 4 */
1280Sstevel@tonic-gate "GETXATTRDIR2", /* 5 */
1290Sstevel@tonic-gate };
1300Sstevel@tonic-gate static char *procnames_short_v3[] = {
1310Sstevel@tonic-gate "NULL3", /* 0 */
1320Sstevel@tonic-gate "GETACL3", /* 1 */
1330Sstevel@tonic-gate "SETACL3", /* 2 */
1340Sstevel@tonic-gate "GETXATTRDIR3", /* 3 */
1350Sstevel@tonic-gate };
1360Sstevel@tonic-gate static char *procnames_short_v4[] = {
1370Sstevel@tonic-gate "NULL4", /* 0 */
1380Sstevel@tonic-gate "GETACL4", /* 1 */
1390Sstevel@tonic-gate "SETACL4", /* 2 */
1400Sstevel@tonic-gate };
1410Sstevel@tonic-gate
1420Sstevel@tonic-gate static char *procnames_long_v2[] = {
1430Sstevel@tonic-gate "Null procedure", /* 0 */
1440Sstevel@tonic-gate "Get file access control list", /* 1 */
1450Sstevel@tonic-gate "Set file access control list", /* 2 */
1460Sstevel@tonic-gate "Get file attributes", /* 3 */
1470Sstevel@tonic-gate "Check access permission", /* 4 */
1480Sstevel@tonic-gate "Get extended attribute directory", /* 5 */
1490Sstevel@tonic-gate };
1500Sstevel@tonic-gate static char *procnames_long_v3[] = {
1510Sstevel@tonic-gate "Null procedure", /* 0 */
1520Sstevel@tonic-gate "Get file access control list", /* 1 */
1530Sstevel@tonic-gate "Set file access control list", /* 2 */
1540Sstevel@tonic-gate "Get extended attribute directory", /* 3 */
1550Sstevel@tonic-gate };
1560Sstevel@tonic-gate static char *procnames_long_v4[] = {
1570Sstevel@tonic-gate "Null procedure", /* 0 */
1580Sstevel@tonic-gate "Get file access control list", /* 1 */
1590Sstevel@tonic-gate "Set file access control list", /* 2 */
1600Sstevel@tonic-gate };
1610Sstevel@tonic-gate
1620Sstevel@tonic-gate #define MAXPROC_V2 5
1630Sstevel@tonic-gate #define MAXPROC_V3 3
1640Sstevel@tonic-gate #define MAXPROC_V4 2
1650Sstevel@tonic-gate
1660Sstevel@tonic-gate /* ARGSUSED */
1670Sstevel@tonic-gate void
interpret_nfs_acl(flags,type,xid,vers,proc,data,len)1680Sstevel@tonic-gate interpret_nfs_acl(flags, type, xid, vers, proc, data, len)
1690Sstevel@tonic-gate int flags, type, xid, vers, proc;
1700Sstevel@tonic-gate char *data;
1710Sstevel@tonic-gate int len;
1720Sstevel@tonic-gate {
1730Sstevel@tonic-gate
1740Sstevel@tonic-gate if (vers == 2) {
1750Sstevel@tonic-gate interpret_nfs_acl2(flags, type, xid, vers, proc, data, len);
1760Sstevel@tonic-gate return;
1770Sstevel@tonic-gate }
1780Sstevel@tonic-gate
1790Sstevel@tonic-gate if (vers == 3) {
1800Sstevel@tonic-gate interpret_nfs_acl3(flags, type, xid, vers, proc, data, len);
1810Sstevel@tonic-gate return;
1820Sstevel@tonic-gate }
1830Sstevel@tonic-gate
1840Sstevel@tonic-gate if (vers == 4) {
1850Sstevel@tonic-gate interpret_nfs_acl4(flags, type, xid, vers, proc, data, len);
1860Sstevel@tonic-gate return;
1870Sstevel@tonic-gate }
1880Sstevel@tonic-gate }
1890Sstevel@tonic-gate
190410Skcpoon static void
interpret_nfs_acl2(int flags,int type,int xid,int vers,int proc,char * data,int len)191410Skcpoon interpret_nfs_acl2(int flags, int type, int xid, int vers, int proc,
192410Skcpoon char *data, int len)
1930Sstevel@tonic-gate {
1940Sstevel@tonic-gate char *line;
1950Sstevel@tonic-gate char buff[2048];
1960Sstevel@tonic-gate int off, sz;
1970Sstevel@tonic-gate char *fh;
1980Sstevel@tonic-gate ulong_t mask;
1990Sstevel@tonic-gate
2000Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC_V2)
2010Sstevel@tonic-gate return;
2020Sstevel@tonic-gate
2030Sstevel@tonic-gate if (flags & F_SUM) {
2040Sstevel@tonic-gate line = get_sum_line();
2050Sstevel@tonic-gate
2060Sstevel@tonic-gate if (type == CALL) {
2070Sstevel@tonic-gate (void) sprintf(line, "NFS_ACL C %s",
208*9759SVasumathi.Sundaram@Sun.COM procnames_short_v2[proc]);
2090Sstevel@tonic-gate line += strlen(line);
2100Sstevel@tonic-gate switch (proc) {
2110Sstevel@tonic-gate case ACLPROC2_GETACL:
2120Sstevel@tonic-gate fh = sum_nfsfh();
2130Sstevel@tonic-gate mask = getxdr_u_long();
2140Sstevel@tonic-gate (void) sprintf(line, "%s mask=%lu", fh, mask);
2150Sstevel@tonic-gate break;
2160Sstevel@tonic-gate case ACLPROC2_SETACL:
2170Sstevel@tonic-gate (void) sprintf(line, sum_nfsfh());
2180Sstevel@tonic-gate break;
2190Sstevel@tonic-gate case ACLPROC2_GETATTR:
2200Sstevel@tonic-gate (void) sprintf(line, sum_nfsfh());
2210Sstevel@tonic-gate break;
2220Sstevel@tonic-gate case ACLPROC2_ACCESS:
2230Sstevel@tonic-gate fh = sum_nfsfh();
2240Sstevel@tonic-gate (void) sprintf(line, "%s (%s)", fh,
225*9759SVasumathi.Sundaram@Sun.COM sum_access2());
2260Sstevel@tonic-gate break;
2270Sstevel@tonic-gate case ACLPROC2_GETXATTRDIR:
2280Sstevel@tonic-gate fh = sum_nfsfh();
2290Sstevel@tonic-gate (void) sprintf(line, "%s create=%s", fh,
2300Sstevel@tonic-gate getxdr_bool() ? "true" : "false");
2310Sstevel@tonic-gate break;
2320Sstevel@tonic-gate default:
2330Sstevel@tonic-gate break;
2340Sstevel@tonic-gate }
2350Sstevel@tonic-gate
2360Sstevel@tonic-gate check_retransmit(line, (ulong_t)xid);
2370Sstevel@tonic-gate } else {
2380Sstevel@tonic-gate (void) sprintf(line, "NFS_ACL R %s ",
239*9759SVasumathi.Sundaram@Sun.COM procnames_short_v2[proc]);
2400Sstevel@tonic-gate line += strlen(line);
2410Sstevel@tonic-gate switch (proc) {
2420Sstevel@tonic-gate case ACLPROC2_GETACL:
2430Sstevel@tonic-gate (void) sum_nfsstat(line);
2440Sstevel@tonic-gate break;
2450Sstevel@tonic-gate case ACLPROC2_SETACL:
2460Sstevel@tonic-gate (void) sum_nfsstat(line);
2470Sstevel@tonic-gate break;
2480Sstevel@tonic-gate case ACLPROC2_GETATTR:
2490Sstevel@tonic-gate (void) sum_nfsstat(line);
2500Sstevel@tonic-gate break;
2510Sstevel@tonic-gate case ACLPROC2_ACCESS:
2520Sstevel@tonic-gate if (sum_nfsstat(line) == 0) {
2530Sstevel@tonic-gate skip_fattr();
2540Sstevel@tonic-gate line += strlen(line);
2550Sstevel@tonic-gate (void) sprintf(line, " (%s)",
256*9759SVasumathi.Sundaram@Sun.COM sum_access2());
2570Sstevel@tonic-gate }
2580Sstevel@tonic-gate break;
2590Sstevel@tonic-gate case ACLPROC2_GETXATTRDIR:
2600Sstevel@tonic-gate if (sum_nfsstat(line) == 0) {
2610Sstevel@tonic-gate line += strlen(line);
2620Sstevel@tonic-gate (void) sprintf(line, sum_nfsfh());
2630Sstevel@tonic-gate }
2640Sstevel@tonic-gate break;
2650Sstevel@tonic-gate default:
2660Sstevel@tonic-gate break;
2670Sstevel@tonic-gate }
2680Sstevel@tonic-gate }
2690Sstevel@tonic-gate }
2700Sstevel@tonic-gate
2710Sstevel@tonic-gate if (flags & F_DTAIL) {
2720Sstevel@tonic-gate show_header("NFS_ACL: ", "Sun NFS_ACL", len);
2730Sstevel@tonic-gate show_space();
2740Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Proc = %d (%s)",
275*9759SVasumathi.Sundaram@Sun.COM proc, procnames_long_v2[proc]);
2760Sstevel@tonic-gate if (type == CALL)
2770Sstevel@tonic-gate aclcall2(proc);
2780Sstevel@tonic-gate else
2790Sstevel@tonic-gate aclreply2(proc);
2800Sstevel@tonic-gate show_trailer();
2810Sstevel@tonic-gate }
2820Sstevel@tonic-gate }
2830Sstevel@tonic-gate
284410Skcpoon static void
interpret_nfs_acl3(int flags,int type,int xid,int vers,int proc,char * data,int len)285410Skcpoon interpret_nfs_acl3(int flags, int type, int xid, int vers, int proc,
286410Skcpoon char *data, int len)
2870Sstevel@tonic-gate {
2880Sstevel@tonic-gate char *line;
2890Sstevel@tonic-gate char buff[2048];
2900Sstevel@tonic-gate int off, sz;
2910Sstevel@tonic-gate char *fh;
2920Sstevel@tonic-gate ulong_t mask;
2930Sstevel@tonic-gate
2940Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC_V3)
2950Sstevel@tonic-gate return;
2960Sstevel@tonic-gate
2970Sstevel@tonic-gate if (flags & F_SUM) {
2980Sstevel@tonic-gate line = get_sum_line();
2990Sstevel@tonic-gate
3000Sstevel@tonic-gate if (type == CALL) {
3010Sstevel@tonic-gate (void) sprintf(line, "NFS_ACL C %s",
302*9759SVasumathi.Sundaram@Sun.COM procnames_short_v3[proc]);
3030Sstevel@tonic-gate line += strlen(line);
3040Sstevel@tonic-gate switch (proc) {
3050Sstevel@tonic-gate case ACLPROC3_GETACL:
3060Sstevel@tonic-gate fh = sum_nfsfh3();
3070Sstevel@tonic-gate mask = getxdr_u_long();
3080Sstevel@tonic-gate (void) sprintf(line, "%s mask=%lu", fh, mask);
3090Sstevel@tonic-gate break;
3100Sstevel@tonic-gate case ACLPROC3_SETACL:
3110Sstevel@tonic-gate (void) sprintf(line, sum_nfsfh3());
3120Sstevel@tonic-gate break;
3130Sstevel@tonic-gate case ACLPROC3_GETXATTRDIR:
3140Sstevel@tonic-gate fh = sum_nfsfh3();
3150Sstevel@tonic-gate (void) sprintf(line, "%s create=%s", fh,
3160Sstevel@tonic-gate getxdr_bool() ? "true" : "false");
3170Sstevel@tonic-gate break;
3180Sstevel@tonic-gate default:
3190Sstevel@tonic-gate break;
3200Sstevel@tonic-gate }
3210Sstevel@tonic-gate
3220Sstevel@tonic-gate check_retransmit(line, (ulong_t)xid);
3230Sstevel@tonic-gate } else {
3240Sstevel@tonic-gate (void) sprintf(line, "NFS_ACL R %s ",
325*9759SVasumathi.Sundaram@Sun.COM procnames_short_v3[proc]);
3260Sstevel@tonic-gate line += strlen(line);
3270Sstevel@tonic-gate switch (proc) {
3280Sstevel@tonic-gate case ACLPROC3_GETACL:
3290Sstevel@tonic-gate (void) sum_nfsstat3(line);
3300Sstevel@tonic-gate break;
3310Sstevel@tonic-gate case ACLPROC3_SETACL:
3320Sstevel@tonic-gate (void) sum_nfsstat3(line);
3330Sstevel@tonic-gate break;
3340Sstevel@tonic-gate case ACLPROC3_GETXATTRDIR:
3350Sstevel@tonic-gate if (sum_nfsstat3(line) == 0) {
3360Sstevel@tonic-gate line += strlen(line);
3370Sstevel@tonic-gate (void) sprintf(line, sum_nfsfh3());
3380Sstevel@tonic-gate }
3390Sstevel@tonic-gate break;
3400Sstevel@tonic-gate default:
3410Sstevel@tonic-gate break;
3420Sstevel@tonic-gate }
3430Sstevel@tonic-gate }
3440Sstevel@tonic-gate }
3450Sstevel@tonic-gate
3460Sstevel@tonic-gate if (flags & F_DTAIL) {
3470Sstevel@tonic-gate show_header("NFS_ACL: ", "Sun NFS_ACL", len);
3480Sstevel@tonic-gate show_space();
3490Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Proc = %d (%s)",
350*9759SVasumathi.Sundaram@Sun.COM proc, procnames_long_v3[proc]);
3510Sstevel@tonic-gate if (type == CALL)
3520Sstevel@tonic-gate aclcall3(proc);
3530Sstevel@tonic-gate else
3540Sstevel@tonic-gate aclreply3(proc);
3550Sstevel@tonic-gate show_trailer();
3560Sstevel@tonic-gate }
3570Sstevel@tonic-gate }
3580Sstevel@tonic-gate
359410Skcpoon static void
interpret_nfs_acl4(int flags,int type,int xid,int vers,int proc,char * data,int len)360410Skcpoon interpret_nfs_acl4(int flags, int type, int xid, int vers, int proc,
361410Skcpoon char *data, int len)
3620Sstevel@tonic-gate {
3630Sstevel@tonic-gate char *line;
3640Sstevel@tonic-gate char buff[2048];
3650Sstevel@tonic-gate int off, sz;
3660Sstevel@tonic-gate char *fh;
3670Sstevel@tonic-gate ulong_t mask;
3680Sstevel@tonic-gate
3690Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC_V4)
3700Sstevel@tonic-gate return;
3710Sstevel@tonic-gate
3720Sstevel@tonic-gate if (flags & F_SUM) {
3730Sstevel@tonic-gate line = get_sum_line();
3740Sstevel@tonic-gate
3750Sstevel@tonic-gate if (type == CALL) {
3760Sstevel@tonic-gate (void) sprintf(line, "NFS_ACL C %s",
377*9759SVasumathi.Sundaram@Sun.COM procnames_short_v4[proc]);
3780Sstevel@tonic-gate line += strlen(line);
3790Sstevel@tonic-gate switch (proc) {
3800Sstevel@tonic-gate case ACLPROC4_GETACL:
3810Sstevel@tonic-gate fh = sum_nfsfh3();
3820Sstevel@tonic-gate mask = getxdr_u_long();
3830Sstevel@tonic-gate (void) sprintf(line, "%s mask=%lu", fh, mask);
3840Sstevel@tonic-gate break;
3850Sstevel@tonic-gate case ACLPROC4_SETACL:
3860Sstevel@tonic-gate (void) sprintf(line, sum_nfsfh3());
3870Sstevel@tonic-gate break;
3880Sstevel@tonic-gate default:
3890Sstevel@tonic-gate break;
3900Sstevel@tonic-gate }
3910Sstevel@tonic-gate
3920Sstevel@tonic-gate check_retransmit(line, (ulong_t)xid);
3930Sstevel@tonic-gate } else {
3940Sstevel@tonic-gate (void) sprintf(line, "NFS_ACL R %s ",
395*9759SVasumathi.Sundaram@Sun.COM procnames_short_v4[proc]);
3960Sstevel@tonic-gate line += strlen(line);
3970Sstevel@tonic-gate switch (proc) {
3980Sstevel@tonic-gate case ACLPROC4_GETACL:
3990Sstevel@tonic-gate (void) sum_nfsstat4(line);
4000Sstevel@tonic-gate break;
4010Sstevel@tonic-gate case ACLPROC4_SETACL:
4020Sstevel@tonic-gate (void) sum_nfsstat4(line);
4030Sstevel@tonic-gate break;
4040Sstevel@tonic-gate default:
4050Sstevel@tonic-gate break;
4060Sstevel@tonic-gate }
4070Sstevel@tonic-gate }
4080Sstevel@tonic-gate }
4090Sstevel@tonic-gate
4100Sstevel@tonic-gate if (flags & F_DTAIL) {
4110Sstevel@tonic-gate show_header("NFS_ACL: ", "Sun NFS_ACL", len);
4120Sstevel@tonic-gate show_space();
4130Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Proc = %d (%s)",
414*9759SVasumathi.Sundaram@Sun.COM proc, procnames_long_v4[proc]);
4150Sstevel@tonic-gate if (type == CALL)
4160Sstevel@tonic-gate aclcall4(proc);
4170Sstevel@tonic-gate else
4180Sstevel@tonic-gate aclreply4(proc);
4190Sstevel@tonic-gate show_trailer();
4200Sstevel@tonic-gate }
4210Sstevel@tonic-gate }
4220Sstevel@tonic-gate
4230Sstevel@tonic-gate int
sum_nfsstat4(char * line)4240Sstevel@tonic-gate sum_nfsstat4(char *line)
4250Sstevel@tonic-gate {
4260Sstevel@tonic-gate ulong_t status;
4270Sstevel@tonic-gate char *p, *nfsstat4_to_name(int);
4280Sstevel@tonic-gate
4290Sstevel@tonic-gate status = getxdr_long();
4300Sstevel@tonic-gate p = nfsstat4_to_name(status);
4310Sstevel@tonic-gate (void) strcpy(line, p);
4320Sstevel@tonic-gate return (status);
4330Sstevel@tonic-gate }
4340Sstevel@tonic-gate
4350Sstevel@tonic-gate int
detail_nfsstat4()4360Sstevel@tonic-gate detail_nfsstat4()
4370Sstevel@tonic-gate {
4380Sstevel@tonic-gate ulong_t status;
4390Sstevel@tonic-gate char buff[64];
4400Sstevel@tonic-gate int pos;
4410Sstevel@tonic-gate
4420Sstevel@tonic-gate pos = getxdr_pos();
4430Sstevel@tonic-gate status = sum_nfsstat4(buff);
4440Sstevel@tonic-gate
4450Sstevel@tonic-gate (void) sprintf(get_line(pos, getxdr_pos()), "Status = %d (%s)",
446*9759SVasumathi.Sundaram@Sun.COM status, buff);
4470Sstevel@tonic-gate
4480Sstevel@tonic-gate return ((int)status);
4490Sstevel@tonic-gate }
4500Sstevel@tonic-gate
4510Sstevel@tonic-gate /*
4520Sstevel@tonic-gate * Print out version 2 NFS_ACL call packets
4530Sstevel@tonic-gate */
4540Sstevel@tonic-gate static void
aclcall2(proc)4550Sstevel@tonic-gate aclcall2(proc)
4560Sstevel@tonic-gate int proc;
4570Sstevel@tonic-gate {
4580Sstevel@tonic-gate
4590Sstevel@tonic-gate switch (proc) {
4600Sstevel@tonic-gate case ACLPROC2_GETACL:
4610Sstevel@tonic-gate detail_nfsfh();
4620Sstevel@tonic-gate detail_mask();
4630Sstevel@tonic-gate break;
4640Sstevel@tonic-gate case ACLPROC2_SETACL:
4650Sstevel@tonic-gate detail_nfsfh();
4660Sstevel@tonic-gate detail_secattr();
4670Sstevel@tonic-gate break;
4680Sstevel@tonic-gate case ACLPROC2_GETATTR:
4690Sstevel@tonic-gate detail_nfsfh();
4700Sstevel@tonic-gate break;
4710Sstevel@tonic-gate case ACLPROC2_ACCESS:
4720Sstevel@tonic-gate detail_nfsfh();
4730Sstevel@tonic-gate detail_access2();
4740Sstevel@tonic-gate break;
4750Sstevel@tonic-gate default:
4760Sstevel@tonic-gate break;
4770Sstevel@tonic-gate }
4780Sstevel@tonic-gate }
4790Sstevel@tonic-gate
4800Sstevel@tonic-gate /*
4810Sstevel@tonic-gate * Print out version 2 NFS_ACL reply packets
4820Sstevel@tonic-gate */
4830Sstevel@tonic-gate static void
aclreply2(proc)4840Sstevel@tonic-gate aclreply2(proc)
4850Sstevel@tonic-gate int proc;
4860Sstevel@tonic-gate {
4870Sstevel@tonic-gate
4880Sstevel@tonic-gate switch (proc) {
4890Sstevel@tonic-gate case ACLPROC2_GETACL:
4900Sstevel@tonic-gate if (detail_nfsstat() == 0) {
4910Sstevel@tonic-gate detail_fattr();
4920Sstevel@tonic-gate detail_secattr();
4930Sstevel@tonic-gate }
4940Sstevel@tonic-gate break;
4950Sstevel@tonic-gate case ACLPROC2_SETACL:
4960Sstevel@tonic-gate if (detail_nfsstat() == 0)
4970Sstevel@tonic-gate detail_fattr();
4980Sstevel@tonic-gate break;
4990Sstevel@tonic-gate case ACLPROC2_GETATTR:
5000Sstevel@tonic-gate if (detail_nfsstat() == 0)
5010Sstevel@tonic-gate detail_fattr();
5020Sstevel@tonic-gate break;
5030Sstevel@tonic-gate case ACLPROC2_ACCESS:
5040Sstevel@tonic-gate if (detail_nfsstat() == 0) {
5050Sstevel@tonic-gate detail_fattr();
5060Sstevel@tonic-gate detail_access2();
5070Sstevel@tonic-gate }
5080Sstevel@tonic-gate break;
5090Sstevel@tonic-gate default:
5100Sstevel@tonic-gate break;
5110Sstevel@tonic-gate }
5120Sstevel@tonic-gate }
5130Sstevel@tonic-gate
5140Sstevel@tonic-gate /*
5150Sstevel@tonic-gate * Print out version 3 NFS_ACL call packets
5160Sstevel@tonic-gate */
5170Sstevel@tonic-gate static void
aclcall3(proc)5180Sstevel@tonic-gate aclcall3(proc)
5190Sstevel@tonic-gate int proc;
5200Sstevel@tonic-gate {
5210Sstevel@tonic-gate
5220Sstevel@tonic-gate switch (proc) {
5230Sstevel@tonic-gate case ACLPROC3_GETACL:
5240Sstevel@tonic-gate detail_nfsfh3();
5250Sstevel@tonic-gate detail_mask();
5260Sstevel@tonic-gate break;
5270Sstevel@tonic-gate case ACLPROC3_SETACL:
5280Sstevel@tonic-gate detail_nfsfh3();
5290Sstevel@tonic-gate detail_secattr();
5300Sstevel@tonic-gate break;
5310Sstevel@tonic-gate default:
5320Sstevel@tonic-gate break;
5330Sstevel@tonic-gate }
5340Sstevel@tonic-gate }
5350Sstevel@tonic-gate
5360Sstevel@tonic-gate /*
5370Sstevel@tonic-gate * Print out version 3 NFS_ACL reply packets
5380Sstevel@tonic-gate */
5390Sstevel@tonic-gate static void
aclreply3(proc)5400Sstevel@tonic-gate aclreply3(proc)
5410Sstevel@tonic-gate int proc;
5420Sstevel@tonic-gate {
5430Sstevel@tonic-gate
5440Sstevel@tonic-gate switch (proc) {
5450Sstevel@tonic-gate case ACLPROC3_GETACL:
5460Sstevel@tonic-gate if (detail_nfsstat3() == 0) {
5470Sstevel@tonic-gate detail_post_op_attr("");
5480Sstevel@tonic-gate detail_secattr();
5490Sstevel@tonic-gate }
5500Sstevel@tonic-gate break;
5510Sstevel@tonic-gate case ACLPROC3_SETACL:
5520Sstevel@tonic-gate if (detail_nfsstat3() == 0)
5530Sstevel@tonic-gate detail_post_op_attr("");
5540Sstevel@tonic-gate break;
5550Sstevel@tonic-gate default:
5560Sstevel@tonic-gate break;
5570Sstevel@tonic-gate }
5580Sstevel@tonic-gate }
5590Sstevel@tonic-gate
5600Sstevel@tonic-gate /*
5610Sstevel@tonic-gate * Print out version 4 NFS_ACL call packets
5620Sstevel@tonic-gate */
5630Sstevel@tonic-gate static void
aclcall4(proc)5640Sstevel@tonic-gate aclcall4(proc)
5650Sstevel@tonic-gate int proc;
5660Sstevel@tonic-gate {
5670Sstevel@tonic-gate
5680Sstevel@tonic-gate switch (proc) {
5690Sstevel@tonic-gate case ACLPROC4_GETACL:
5700Sstevel@tonic-gate detail_nfsfh3();
5710Sstevel@tonic-gate detail_mask();
5720Sstevel@tonic-gate break;
5730Sstevel@tonic-gate case ACLPROC4_SETACL:
5740Sstevel@tonic-gate detail_nfsfh3();
5750Sstevel@tonic-gate detail_secattr();
5760Sstevel@tonic-gate break;
5770Sstevel@tonic-gate default:
5780Sstevel@tonic-gate break;
5790Sstevel@tonic-gate }
5800Sstevel@tonic-gate }
5810Sstevel@tonic-gate
5820Sstevel@tonic-gate /*
5830Sstevel@tonic-gate * Print out version 4 NFS_ACL reply packets
5840Sstevel@tonic-gate */
5850Sstevel@tonic-gate static void
aclreply4(proc)5860Sstevel@tonic-gate aclreply4(proc)
5870Sstevel@tonic-gate int proc;
5880Sstevel@tonic-gate {
5890Sstevel@tonic-gate
5900Sstevel@tonic-gate switch (proc) {
5910Sstevel@tonic-gate case ACLPROC4_GETACL:
5920Sstevel@tonic-gate if (detail_nfsstat4() == 0) {
5930Sstevel@tonic-gate detail_post_op_attr("");
5940Sstevel@tonic-gate detail_secattr();
5950Sstevel@tonic-gate }
5960Sstevel@tonic-gate break;
5970Sstevel@tonic-gate case ACLPROC4_SETACL:
5980Sstevel@tonic-gate if (detail_nfsstat4() == 0)
5990Sstevel@tonic-gate detail_post_op_attr("");
6000Sstevel@tonic-gate break;
6010Sstevel@tonic-gate default:
6020Sstevel@tonic-gate break;
6030Sstevel@tonic-gate }
6040Sstevel@tonic-gate }
6050Sstevel@tonic-gate
6060Sstevel@tonic-gate static void
detail_access2()6070Sstevel@tonic-gate detail_access2()
6080Sstevel@tonic-gate {
6090Sstevel@tonic-gate uint_t bits;
6100Sstevel@tonic-gate
6110Sstevel@tonic-gate bits = showxdr_u_long("Access bits = 0x%08x");
6120Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
613*9759SVasumathi.Sundaram@Sun.COM getflag(bits, ACCESS2_READ, "Read", "(no read)"));
6140Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
615*9759SVasumathi.Sundaram@Sun.COM getflag(bits, ACCESS2_LOOKUP, "Lookup", "(no lookup)"));
6160Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
617*9759SVasumathi.Sundaram@Sun.COM getflag(bits, ACCESS2_MODIFY, "Modify", "(no modify)"));
6180Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
619*9759SVasumathi.Sundaram@Sun.COM getflag(bits, ACCESS2_EXTEND, "Extend", "(no extend)"));
6200Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
621*9759SVasumathi.Sundaram@Sun.COM getflag(bits, ACCESS2_DELETE, "Delete", "(no delete)"));
6220Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
623*9759SVasumathi.Sundaram@Sun.COM getflag(bits, ACCESS2_EXECUTE, "Execute", "(no execute)"));
6240Sstevel@tonic-gate }
6250Sstevel@tonic-gate
6260Sstevel@tonic-gate static char *
sum_access2()6270Sstevel@tonic-gate sum_access2()
6280Sstevel@tonic-gate {
6290Sstevel@tonic-gate int bits;
6300Sstevel@tonic-gate static char buff[22];
6310Sstevel@tonic-gate
6320Sstevel@tonic-gate bits = getxdr_u_long();
6330Sstevel@tonic-gate buff[0] = '\0';
6340Sstevel@tonic-gate
6350Sstevel@tonic-gate if (bits & ACCESS2_READ)
6360Sstevel@tonic-gate (void) strcat(buff, "read,");
6370Sstevel@tonic-gate if (bits & ACCESS2_LOOKUP)
6380Sstevel@tonic-gate (void) strcat(buff, "lookup,");
6390Sstevel@tonic-gate if (bits & ACCESS2_MODIFY)
6400Sstevel@tonic-gate (void) strcat(buff, "modify,");
6410Sstevel@tonic-gate if (bits & ACCESS2_EXTEND)
6420Sstevel@tonic-gate (void) strcat(buff, "extend,");
6430Sstevel@tonic-gate if (bits & ACCESS2_DELETE)
6440Sstevel@tonic-gate (void) strcat(buff, "delete,");
6450Sstevel@tonic-gate if (bits & ACCESS2_EXECUTE)
6460Sstevel@tonic-gate (void) strcat(buff, "execute,");
6470Sstevel@tonic-gate if (buff[0] != '\0')
6480Sstevel@tonic-gate buff[strlen(buff) - 1] = '\0';
6490Sstevel@tonic-gate
6500Sstevel@tonic-gate return (buff);
6510Sstevel@tonic-gate }
6520Sstevel@tonic-gate
6530Sstevel@tonic-gate static void
detail_mask()6540Sstevel@tonic-gate detail_mask()
6550Sstevel@tonic-gate {
6560Sstevel@tonic-gate ulong_t mask;
6570Sstevel@tonic-gate
6580Sstevel@tonic-gate mask = showxdr_u_long("Mask = 0x%lx");
6590Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
660*9759SVasumathi.Sundaram@Sun.COM getflag(mask, NA_ACL, "aclent", "(no aclent)"));
6610Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
662*9759SVasumathi.Sundaram@Sun.COM getflag(mask, NA_ACLCNT, "aclcnt", "(no aclcnt)"));
6630Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
664*9759SVasumathi.Sundaram@Sun.COM getflag(mask, NA_DFACL, "dfaclent", "(no dfaclent)"));
6650Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s",
666*9759SVasumathi.Sundaram@Sun.COM getflag(mask, NA_DFACLCNT, "dfaclcnt", "(no dfaclcnt)"));
6670Sstevel@tonic-gate }
6680Sstevel@tonic-gate
6690Sstevel@tonic-gate static void
detail_secattr()6700Sstevel@tonic-gate detail_secattr()
6710Sstevel@tonic-gate {
6720Sstevel@tonic-gate
6730Sstevel@tonic-gate detail_mask();
6740Sstevel@tonic-gate showxdr_long("Aclcnt = %d");
6750Sstevel@tonic-gate detail_aclent();
6760Sstevel@tonic-gate showxdr_long("Dfaclcnt = %d");
6770Sstevel@tonic-gate detail_aclent();
6780Sstevel@tonic-gate }
6790Sstevel@tonic-gate
6800Sstevel@tonic-gate static void
detail_aclent()6810Sstevel@tonic-gate detail_aclent()
6820Sstevel@tonic-gate {
6830Sstevel@tonic-gate int count;
6840Sstevel@tonic-gate int type;
6850Sstevel@tonic-gate int id;
6860Sstevel@tonic-gate ushort_t perm;
6870Sstevel@tonic-gate
6880Sstevel@tonic-gate count = getxdr_long();
6890Sstevel@tonic-gate while (count-- > 0) {
6900Sstevel@tonic-gate type = getxdr_long();
6910Sstevel@tonic-gate id = getxdr_long();
6920Sstevel@tonic-gate perm = getxdr_u_short();
6930Sstevel@tonic-gate switch (type) {
6940Sstevel@tonic-gate case NA_USER:
6950Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tuser:%s:%s",
696*9759SVasumathi.Sundaram@Sun.COM detail_uname(id), detail_perm(perm));
6970Sstevel@tonic-gate break;
6980Sstevel@tonic-gate case NA_USER_OBJ:
6990Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tuser::%s",
700*9759SVasumathi.Sundaram@Sun.COM detail_perm(perm));
7010Sstevel@tonic-gate break;
7020Sstevel@tonic-gate case NA_GROUP:
7030Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tgroup:%s:%s",
704*9759SVasumathi.Sundaram@Sun.COM detail_gname(id), detail_perm(perm));
7050Sstevel@tonic-gate break;
7060Sstevel@tonic-gate case NA_GROUP_OBJ:
7070Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tgroup::%s",
708*9759SVasumathi.Sundaram@Sun.COM detail_perm(perm));
7090Sstevel@tonic-gate break;
7100Sstevel@tonic-gate case NA_CLASS_OBJ:
7110Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tmask:%s",
712*9759SVasumathi.Sundaram@Sun.COM detail_perm(perm));
7130Sstevel@tonic-gate break;
7140Sstevel@tonic-gate case NA_OTHER_OBJ:
7150Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tother:%s",
716*9759SVasumathi.Sundaram@Sun.COM detail_perm(perm));
7170Sstevel@tonic-gate break;
7180Sstevel@tonic-gate case NA_DEF_USER:
7190Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tdefault:user:%s:%s",
720*9759SVasumathi.Sundaram@Sun.COM detail_uname(id), detail_perm(perm));
7210Sstevel@tonic-gate break;
7220Sstevel@tonic-gate case NA_DEF_USER_OBJ:
7230Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tdefault:user::%s",
724*9759SVasumathi.Sundaram@Sun.COM detail_perm(perm));
7250Sstevel@tonic-gate break;
7260Sstevel@tonic-gate case NA_DEF_GROUP:
7270Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tdefault:group:%s:%s",
728*9759SVasumathi.Sundaram@Sun.COM detail_gname(id), detail_perm(perm));
7290Sstevel@tonic-gate break;
7300Sstevel@tonic-gate case NA_DEF_GROUP_OBJ:
7310Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tdefault:group::%s",
732*9759SVasumathi.Sundaram@Sun.COM detail_perm(perm));
7330Sstevel@tonic-gate break;
7340Sstevel@tonic-gate case NA_DEF_CLASS_OBJ:
7350Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tdefault:mask:%s",
736*9759SVasumathi.Sundaram@Sun.COM detail_perm(perm));
7370Sstevel@tonic-gate break;
7380Sstevel@tonic-gate case NA_DEF_OTHER_OBJ:
7390Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tdefault:other:%s",
740*9759SVasumathi.Sundaram@Sun.COM detail_perm(perm));
7410Sstevel@tonic-gate break;
7420Sstevel@tonic-gate default:
7430Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "\tunrecognized entry");
7440Sstevel@tonic-gate break;
7450Sstevel@tonic-gate }
7460Sstevel@tonic-gate }
7470Sstevel@tonic-gate }
7480Sstevel@tonic-gate
7490Sstevel@tonic-gate static char *
detail_uname(uid_t uid)7500Sstevel@tonic-gate detail_uname(uid_t uid)
7510Sstevel@tonic-gate {
7520Sstevel@tonic-gate struct passwd *pwd;
7530Sstevel@tonic-gate static char uidp[10];
7540Sstevel@tonic-gate
7550Sstevel@tonic-gate pwd = getpwuid(uid);
7560Sstevel@tonic-gate if (pwd == NULL) {
7570Sstevel@tonic-gate sprintf(uidp, "%d", uid);
7580Sstevel@tonic-gate return (uidp);
7590Sstevel@tonic-gate }
7600Sstevel@tonic-gate return (pwd->pw_name);
7610Sstevel@tonic-gate }
7620Sstevel@tonic-gate
7630Sstevel@tonic-gate static char *
detail_gname(gid_t gid)7640Sstevel@tonic-gate detail_gname(gid_t gid)
7650Sstevel@tonic-gate {
7660Sstevel@tonic-gate struct group *grp;
7670Sstevel@tonic-gate static char gidp[10];
7680Sstevel@tonic-gate
7690Sstevel@tonic-gate grp = getgrgid(gid);
7700Sstevel@tonic-gate if (grp == NULL) {
7710Sstevel@tonic-gate sprintf(gidp, "%d", gid);
7720Sstevel@tonic-gate return (gidp);
7730Sstevel@tonic-gate }
7740Sstevel@tonic-gate return (grp->gr_name);
7750Sstevel@tonic-gate }
7760Sstevel@tonic-gate
7770Sstevel@tonic-gate static char *perms[] = {
7780Sstevel@tonic-gate "---",
7790Sstevel@tonic-gate "--x",
7800Sstevel@tonic-gate "-w-",
7810Sstevel@tonic-gate "-wx",
7820Sstevel@tonic-gate "r--",
7830Sstevel@tonic-gate "r-x",
7840Sstevel@tonic-gate "rw-",
7850Sstevel@tonic-gate "rwx"
7860Sstevel@tonic-gate };
7870Sstevel@tonic-gate static char *
detail_perm(ushort_t perm)7880Sstevel@tonic-gate detail_perm(ushort_t perm)
7890Sstevel@tonic-gate {
7900Sstevel@tonic-gate
791*9759SVasumathi.Sundaram@Sun.COM if (perm >= sizeof (perms) / sizeof (perms[0]))
7920Sstevel@tonic-gate return ("?");
7930Sstevel@tonic-gate return (perms[perm]);
7940Sstevel@tonic-gate }
795