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
520f2cb7bSVasumathi Sundaram - Sun Microsystems  * Common Development and Distribution License (the "License").
620f2cb7bSVasumathi Sundaram - Sun Microsystems  * 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 /*
2220f2cb7bSVasumathi Sundaram - Sun Microsystems  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
25*023efabbSMarcel Telka /*
26*023efabbSMarcel Telka  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
27*023efabbSMarcel Telka  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/errno.h>
317c478bd9Sstevel@tonic-gate #include <sys/tiuser.h>
327c478bd9Sstevel@tonic-gate #include <setjmp.h>
337c478bd9Sstevel@tonic-gate #include <pwd.h>
347c478bd9Sstevel@tonic-gate #include <grp.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <rpc/types.h>
377c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
387c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
397c478bd9Sstevel@tonic-gate #include <rpc/clnt.h>
407c478bd9Sstevel@tonic-gate #include <rpc/rpc_msg.h>
417c478bd9Sstevel@tonic-gate #include <string.h>
427c478bd9Sstevel@tonic-gate #include "snoop.h"
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #include <sys/stat.h>
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate extern char *get_sum_line();
477c478bd9Sstevel@tonic-gate extern void check_retransmit();
487c478bd9Sstevel@tonic-gate extern char *sum_nfsfh();
497c478bd9Sstevel@tonic-gate extern int sum_nfsstat();
507c478bd9Sstevel@tonic-gate extern int detail_nfsstat();
517c478bd9Sstevel@tonic-gate extern void detail_nfsfh();
527c478bd9Sstevel@tonic-gate extern void detail_fattr();
537c478bd9Sstevel@tonic-gate extern void skip_fattr();
547c478bd9Sstevel@tonic-gate extern char *sum_nfsfh3();
557c478bd9Sstevel@tonic-gate extern int sum_nfsstat3();
567c478bd9Sstevel@tonic-gate extern int detail_nfsstat3();
577c478bd9Sstevel@tonic-gate extern void detail_post_op_attr();
587c478bd9Sstevel@tonic-gate extern void detail_nfsfh3();
597c478bd9Sstevel@tonic-gate extern int sum_nfsstat4();
607c478bd9Sstevel@tonic-gate extern int detail_nfsstat4();
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate extern jmp_buf xdr_err;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate static void aclcall2();
657c478bd9Sstevel@tonic-gate static void aclreply2();
667c478bd9Sstevel@tonic-gate static void aclcall3();
677c478bd9Sstevel@tonic-gate static void aclreply3();
687c478bd9Sstevel@tonic-gate static void aclcall4();
697c478bd9Sstevel@tonic-gate static void aclreply4();
707c478bd9Sstevel@tonic-gate static void detail_access2();
717c478bd9Sstevel@tonic-gate static char *sum_access2();
727c478bd9Sstevel@tonic-gate static void detail_mask();
737c478bd9Sstevel@tonic-gate static void detail_secattr();
747c478bd9Sstevel@tonic-gate static void detail_aclent();
757c478bd9Sstevel@tonic-gate static char *detail_uname();
767c478bd9Sstevel@tonic-gate static char *detail_gname();
777c478bd9Sstevel@tonic-gate static char *detail_perm(ushort_t);
782e3b6467Skcpoon static void interpret_nfs_acl2(int, int, int, int, int, char *, int);
792e3b6467Skcpoon static void interpret_nfs_acl3(int, int, int, int, int, char *, int);
802e3b6467Skcpoon static void interpret_nfs_acl4(int, int, int, int, int, char *, int);
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate #define	ACLPROC2_NULL		((unsigned long)(0))
837c478bd9Sstevel@tonic-gate #define	ACLPROC2_GETACL		((unsigned long)(1))
847c478bd9Sstevel@tonic-gate #define	ACLPROC2_SETACL		((unsigned long)(2))
857c478bd9Sstevel@tonic-gate #define	ACLPROC2_GETATTR	((unsigned long)(3))
867c478bd9Sstevel@tonic-gate #define	ACLPROC2_ACCESS		((unsigned long)(4))
877c478bd9Sstevel@tonic-gate #define	ACLPROC2_GETXATTRDIR	((unsigned long)(5))
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #define	ACLPROC3_NULL		((unsigned long)(0))
907c478bd9Sstevel@tonic-gate #define	ACLPROC3_GETACL		((unsigned long)(1))
917c478bd9Sstevel@tonic-gate #define	ACLPROC3_SETACL		((unsigned long)(2))
927c478bd9Sstevel@tonic-gate #define	ACLPROC3_GETXATTRDIR	((unsigned long)(3))
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #define	ACLPROC4_NULL		((unsigned long)(0))
957c478bd9Sstevel@tonic-gate #define	ACLPROC4_GETACL		((unsigned long)(1))
967c478bd9Sstevel@tonic-gate #define	ACLPROC4_SETACL		((unsigned long)(2))
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #define	NA_USER_OBJ	0x1
997c478bd9Sstevel@tonic-gate #define	NA_USER		0x2
1007c478bd9Sstevel@tonic-gate #define	NA_GROUP_OBJ	0x4
1017c478bd9Sstevel@tonic-gate #define	NA_GROUP	0x8
1027c478bd9Sstevel@tonic-gate #define	NA_CLASS_OBJ	0x10
1037c478bd9Sstevel@tonic-gate #define	NA_OTHER_OBJ	0x20
1047c478bd9Sstevel@tonic-gate #define	NA_ACL_DEFAULT	0x1000
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate #define	NA_DEF_USER_OBJ		(NA_USER_OBJ | NA_ACL_DEFAULT)
1077c478bd9Sstevel@tonic-gate #define	NA_DEF_USER		(NA_USER | NA_ACL_DEFAULT)
1087c478bd9Sstevel@tonic-gate #define	NA_DEF_GROUP_OBJ	(NA_GROUP_OBJ | NA_ACL_DEFAULT)
1097c478bd9Sstevel@tonic-gate #define	NA_DEF_GROUP		(NA_GROUP | NA_ACL_DEFAULT)
1107c478bd9Sstevel@tonic-gate #define	NA_DEF_CLASS_OBJ	(NA_CLASS_OBJ | NA_ACL_DEFAULT)
1117c478bd9Sstevel@tonic-gate #define	NA_DEF_OTHER_OBJ	(NA_OTHER_OBJ | NA_ACL_DEFAULT)
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate #define	NA_ACL		0x1
1147c478bd9Sstevel@tonic-gate #define	NA_ACLCNT	0x2
1157c478bd9Sstevel@tonic-gate #define	NA_DFACL	0x4
1167c478bd9Sstevel@tonic-gate #define	NA_DFACLCNT	0x8
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #define	ACCESS2_READ	0x0001
1197c478bd9Sstevel@tonic-gate #define	ACCESS2_LOOKUP	0x0002
1207c478bd9Sstevel@tonic-gate #define	ACCESS2_MODIFY	0x0004
1217c478bd9Sstevel@tonic-gate #define	ACCESS2_EXTEND	0x0008
1227c478bd9Sstevel@tonic-gate #define	ACCESS2_DELETE	0x0010
1237c478bd9Sstevel@tonic-gate #define	ACCESS2_EXECUTE	0x0020
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate static char *procnames_short_v2[] = {
1267c478bd9Sstevel@tonic-gate 	"NULL2",	/*  0 */
1277c478bd9Sstevel@tonic-gate 	"GETACL2",	/*  1 */
1287c478bd9Sstevel@tonic-gate 	"SETACL2",	/*  2 */
1297c478bd9Sstevel@tonic-gate 	"GETATTR2",	/*  3 */
1307c478bd9Sstevel@tonic-gate 	"ACCESS2",	/*  4 */
1317c478bd9Sstevel@tonic-gate 	"GETXATTRDIR2",	/*  5 */
1327c478bd9Sstevel@tonic-gate };
1337c478bd9Sstevel@tonic-gate static char *procnames_short_v3[] = {
1347c478bd9Sstevel@tonic-gate 	"NULL3",	/*  0 */
1357c478bd9Sstevel@tonic-gate 	"GETACL3",	/*  1 */
1367c478bd9Sstevel@tonic-gate 	"SETACL3",	/*  2 */
1377c478bd9Sstevel@tonic-gate 	"GETXATTRDIR3",	/*  3 */
1387c478bd9Sstevel@tonic-gate };
1397c478bd9Sstevel@tonic-gate static char *procnames_short_v4[] = {
1407c478bd9Sstevel@tonic-gate 	"NULL4",	/*  0 */
1417c478bd9Sstevel@tonic-gate 	"GETACL4",	/*  1 */
1427c478bd9Sstevel@tonic-gate 	"SETACL4",	/*  2 */
1437c478bd9Sstevel@tonic-gate };
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate static char *procnames_long_v2[] = {
1467c478bd9Sstevel@tonic-gate 	"Null procedure",			/*  0 */
1477c478bd9Sstevel@tonic-gate 	"Get file access control list",		/*  1 */
1487c478bd9Sstevel@tonic-gate 	"Set file access control list",		/*  2 */
1497c478bd9Sstevel@tonic-gate 	"Get file attributes",			/*  3 */
1507c478bd9Sstevel@tonic-gate 	"Check access permission",		/*  4 */
1517c478bd9Sstevel@tonic-gate 	"Get extended attribute directory",	/*  5 */
1527c478bd9Sstevel@tonic-gate };
1537c478bd9Sstevel@tonic-gate static char *procnames_long_v3[] = {
1547c478bd9Sstevel@tonic-gate 	"Null procedure",			/*  0 */
1557c478bd9Sstevel@tonic-gate 	"Get file access control list",		/*  1 */
1567c478bd9Sstevel@tonic-gate 	"Set file access control list",		/*  2 */
1577c478bd9Sstevel@tonic-gate 	"Get extended attribute directory",	/*  3 */
1587c478bd9Sstevel@tonic-gate };
1597c478bd9Sstevel@tonic-gate static char *procnames_long_v4[] = {
1607c478bd9Sstevel@tonic-gate 	"Null procedure",			/*  0 */
1617c478bd9Sstevel@tonic-gate 	"Get file access control list",		/*  1 */
1627c478bd9Sstevel@tonic-gate 	"Set file access control list",		/*  2 */
1637c478bd9Sstevel@tonic-gate };
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate #define	MAXPROC_V2	5
1667c478bd9Sstevel@tonic-gate #define	MAXPROC_V3	3
1677c478bd9Sstevel@tonic-gate #define	MAXPROC_V4	2
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate /* ARGSUSED */
1707c478bd9Sstevel@tonic-gate void
interpret_nfs_acl(flags,type,xid,vers,proc,data,len)1717c478bd9Sstevel@tonic-gate interpret_nfs_acl(flags, type, xid, vers, proc, data, len)
1727c478bd9Sstevel@tonic-gate 	int flags, type, xid, vers, proc;
1737c478bd9Sstevel@tonic-gate 	char *data;
1747c478bd9Sstevel@tonic-gate 	int len;
1757c478bd9Sstevel@tonic-gate {
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate 	if (vers == 2) {
1787c478bd9Sstevel@tonic-gate 		interpret_nfs_acl2(flags, type, xid, vers, proc, data, len);
1797c478bd9Sstevel@tonic-gate 		return;
1807c478bd9Sstevel@tonic-gate 	}
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate 	if (vers == 3) {
1837c478bd9Sstevel@tonic-gate 		interpret_nfs_acl3(flags, type, xid, vers, proc, data, len);
1847c478bd9Sstevel@tonic-gate 		return;
1857c478bd9Sstevel@tonic-gate 	}
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate 	if (vers == 4) {
1887c478bd9Sstevel@tonic-gate 		interpret_nfs_acl4(flags, type, xid, vers, proc, data, len);
1897c478bd9Sstevel@tonic-gate 		return;
1907c478bd9Sstevel@tonic-gate 	}
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate 
1932e3b6467Skcpoon static void
interpret_nfs_acl2(int flags,int type,int xid,int vers,int proc,char * data,int len)1942e3b6467Skcpoon interpret_nfs_acl2(int flags, int type, int xid, int vers, int proc,
1952e3b6467Skcpoon     char *data, int len)
1967c478bd9Sstevel@tonic-gate {
1977c478bd9Sstevel@tonic-gate 	char *line;
1987c478bd9Sstevel@tonic-gate 	char buff[2048];
1997c478bd9Sstevel@tonic-gate 	int off, sz;
2007c478bd9Sstevel@tonic-gate 	char *fh;
2017c478bd9Sstevel@tonic-gate 	ulong_t mask;
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate 	if (proc < 0 || proc > MAXPROC_V2)
2047c478bd9Sstevel@tonic-gate 		return;
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
2077c478bd9Sstevel@tonic-gate 		line = get_sum_line();
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 		if (type == CALL) {
2107c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NFS_ACL C %s",
21120f2cb7bSVasumathi Sundaram - Sun Microsystems 			    procnames_short_v2[proc]);
2127c478bd9Sstevel@tonic-gate 			line += strlen(line);
2137c478bd9Sstevel@tonic-gate 			switch (proc) {
2147c478bd9Sstevel@tonic-gate 			case ACLPROC2_GETACL:
2157c478bd9Sstevel@tonic-gate 				fh = sum_nfsfh();
2167c478bd9Sstevel@tonic-gate 				mask = getxdr_u_long();
217*023efabbSMarcel Telka 				(void) sprintf(line, "%s mask=0x%lx", fh, mask);
2187c478bd9Sstevel@tonic-gate 				break;
2197c478bd9Sstevel@tonic-gate 			case ACLPROC2_SETACL:
2207c478bd9Sstevel@tonic-gate 				(void) sprintf(line, sum_nfsfh());
2217c478bd9Sstevel@tonic-gate 				break;
2227c478bd9Sstevel@tonic-gate 			case ACLPROC2_GETATTR:
2237c478bd9Sstevel@tonic-gate 				(void) sprintf(line, sum_nfsfh());
2247c478bd9Sstevel@tonic-gate 				break;
2257c478bd9Sstevel@tonic-gate 			case ACLPROC2_ACCESS:
2267c478bd9Sstevel@tonic-gate 				fh = sum_nfsfh();
2277c478bd9Sstevel@tonic-gate 				(void) sprintf(line, "%s (%s)", fh,
22820f2cb7bSVasumathi Sundaram - Sun Microsystems 				    sum_access2());
2297c478bd9Sstevel@tonic-gate 				break;
2307c478bd9Sstevel@tonic-gate 			case ACLPROC2_GETXATTRDIR:
2317c478bd9Sstevel@tonic-gate 				fh = sum_nfsfh();
2327c478bd9Sstevel@tonic-gate 				(void) sprintf(line, "%s create=%s", fh,
2337c478bd9Sstevel@tonic-gate 				    getxdr_bool() ? "true" : "false");
2347c478bd9Sstevel@tonic-gate 				break;
2357c478bd9Sstevel@tonic-gate 			default:
2367c478bd9Sstevel@tonic-gate 				break;
2377c478bd9Sstevel@tonic-gate 			}
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate 			check_retransmit(line, (ulong_t)xid);
2407c478bd9Sstevel@tonic-gate 		} else {
2417c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NFS_ACL R %s ",
24220f2cb7bSVasumathi Sundaram - Sun Microsystems 			    procnames_short_v2[proc]);
2437c478bd9Sstevel@tonic-gate 			line += strlen(line);
2447c478bd9Sstevel@tonic-gate 			switch (proc) {
2457c478bd9Sstevel@tonic-gate 			case ACLPROC2_GETACL:
2467c478bd9Sstevel@tonic-gate 				(void) sum_nfsstat(line);
2477c478bd9Sstevel@tonic-gate 				break;
2487c478bd9Sstevel@tonic-gate 			case ACLPROC2_SETACL:
2497c478bd9Sstevel@tonic-gate 				(void) sum_nfsstat(line);
2507c478bd9Sstevel@tonic-gate 				break;
2517c478bd9Sstevel@tonic-gate 			case ACLPROC2_GETATTR:
2527c478bd9Sstevel@tonic-gate 				(void) sum_nfsstat(line);
2537c478bd9Sstevel@tonic-gate 				break;
2547c478bd9Sstevel@tonic-gate 			case ACLPROC2_ACCESS:
2557c478bd9Sstevel@tonic-gate 				if (sum_nfsstat(line) == 0) {
2567c478bd9Sstevel@tonic-gate 					skip_fattr();
2577c478bd9Sstevel@tonic-gate 					line += strlen(line);
2587c478bd9Sstevel@tonic-gate 					(void) sprintf(line, " (%s)",
25920f2cb7bSVasumathi Sundaram - Sun Microsystems 					    sum_access2());
2607c478bd9Sstevel@tonic-gate 				}
2617c478bd9Sstevel@tonic-gate 				break;
2627c478bd9Sstevel@tonic-gate 			case ACLPROC2_GETXATTRDIR:
2637c478bd9Sstevel@tonic-gate 				if (sum_nfsstat(line) == 0) {
2647c478bd9Sstevel@tonic-gate 					line += strlen(line);
2657c478bd9Sstevel@tonic-gate 					(void) sprintf(line, sum_nfsfh());
2667c478bd9Sstevel@tonic-gate 				}
2677c478bd9Sstevel@tonic-gate 				break;
2687c478bd9Sstevel@tonic-gate 			default:
2697c478bd9Sstevel@tonic-gate 				break;
2707c478bd9Sstevel@tonic-gate 			}
2717c478bd9Sstevel@tonic-gate 		}
2727c478bd9Sstevel@tonic-gate 	}
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL) {
2757c478bd9Sstevel@tonic-gate 		show_header("NFS_ACL:  ", "Sun NFS_ACL", len);
2767c478bd9Sstevel@tonic-gate 		show_space();
2777c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Proc = %d (%s)",
27820f2cb7bSVasumathi Sundaram - Sun Microsystems 		    proc, procnames_long_v2[proc]);
2797c478bd9Sstevel@tonic-gate 		if (type == CALL)
2807c478bd9Sstevel@tonic-gate 			aclcall2(proc);
2817c478bd9Sstevel@tonic-gate 		else
2827c478bd9Sstevel@tonic-gate 			aclreply2(proc);
2837c478bd9Sstevel@tonic-gate 		show_trailer();
2847c478bd9Sstevel@tonic-gate 	}
2857c478bd9Sstevel@tonic-gate }
2867c478bd9Sstevel@tonic-gate 
2872e3b6467Skcpoon static void
interpret_nfs_acl3(int flags,int type,int xid,int vers,int proc,char * data,int len)2882e3b6467Skcpoon interpret_nfs_acl3(int flags, int type, int xid, int vers, int proc,
2892e3b6467Skcpoon     char *data, int len)
2907c478bd9Sstevel@tonic-gate {
2917c478bd9Sstevel@tonic-gate 	char *line;
2927c478bd9Sstevel@tonic-gate 	char buff[2048];
2937c478bd9Sstevel@tonic-gate 	int off, sz;
2947c478bd9Sstevel@tonic-gate 	char *fh;
2957c478bd9Sstevel@tonic-gate 	ulong_t mask;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 	if (proc < 0 || proc > MAXPROC_V3)
2987c478bd9Sstevel@tonic-gate 		return;
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
3017c478bd9Sstevel@tonic-gate 		line = get_sum_line();
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate 		if (type == CALL) {
3047c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NFS_ACL C %s",
30520f2cb7bSVasumathi Sundaram - Sun Microsystems 			    procnames_short_v3[proc]);
3067c478bd9Sstevel@tonic-gate 			line += strlen(line);
3077c478bd9Sstevel@tonic-gate 			switch (proc) {
3087c478bd9Sstevel@tonic-gate 			case ACLPROC3_GETACL:
3097c478bd9Sstevel@tonic-gate 				fh = sum_nfsfh3();
3107c478bd9Sstevel@tonic-gate 				mask = getxdr_u_long();
311*023efabbSMarcel Telka 				(void) sprintf(line, "%s mask=0x%lx", fh, mask);
3127c478bd9Sstevel@tonic-gate 				break;
3137c478bd9Sstevel@tonic-gate 			case ACLPROC3_SETACL:
3147c478bd9Sstevel@tonic-gate 				(void) sprintf(line, sum_nfsfh3());
3157c478bd9Sstevel@tonic-gate 				break;
3167c478bd9Sstevel@tonic-gate 			case ACLPROC3_GETXATTRDIR:
3177c478bd9Sstevel@tonic-gate 				fh = sum_nfsfh3();
3187c478bd9Sstevel@tonic-gate 				(void) sprintf(line, "%s create=%s", fh,
3197c478bd9Sstevel@tonic-gate 				    getxdr_bool() ? "true" : "false");
3207c478bd9Sstevel@tonic-gate 				break;
3217c478bd9Sstevel@tonic-gate 			default:
3227c478bd9Sstevel@tonic-gate 				break;
3237c478bd9Sstevel@tonic-gate 			}
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 			check_retransmit(line, (ulong_t)xid);
3267c478bd9Sstevel@tonic-gate 		} else {
3277c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NFS_ACL R %s ",
32820f2cb7bSVasumathi Sundaram - Sun Microsystems 			    procnames_short_v3[proc]);
3297c478bd9Sstevel@tonic-gate 			line += strlen(line);
3307c478bd9Sstevel@tonic-gate 			switch (proc) {
3317c478bd9Sstevel@tonic-gate 			case ACLPROC3_GETACL:
3327c478bd9Sstevel@tonic-gate 				(void) sum_nfsstat3(line);
3337c478bd9Sstevel@tonic-gate 				break;
3347c478bd9Sstevel@tonic-gate 			case ACLPROC3_SETACL:
3357c478bd9Sstevel@tonic-gate 				(void) sum_nfsstat3(line);
3367c478bd9Sstevel@tonic-gate 				break;
3377c478bd9Sstevel@tonic-gate 			case ACLPROC3_GETXATTRDIR:
3387c478bd9Sstevel@tonic-gate 				if (sum_nfsstat3(line) == 0) {
3397c478bd9Sstevel@tonic-gate 					line += strlen(line);
3407c478bd9Sstevel@tonic-gate 					(void) sprintf(line, sum_nfsfh3());
3417c478bd9Sstevel@tonic-gate 				}
3427c478bd9Sstevel@tonic-gate 				break;
3437c478bd9Sstevel@tonic-gate 			default:
3447c478bd9Sstevel@tonic-gate 				break;
3457c478bd9Sstevel@tonic-gate 			}
3467c478bd9Sstevel@tonic-gate 		}
3477c478bd9Sstevel@tonic-gate 	}
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL) {
3507c478bd9Sstevel@tonic-gate 		show_header("NFS_ACL:  ", "Sun NFS_ACL", len);
3517c478bd9Sstevel@tonic-gate 		show_space();
3527c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Proc = %d (%s)",
35320f2cb7bSVasumathi Sundaram - Sun Microsystems 		    proc, procnames_long_v3[proc]);
3547c478bd9Sstevel@tonic-gate 		if (type == CALL)
3557c478bd9Sstevel@tonic-gate 			aclcall3(proc);
3567c478bd9Sstevel@tonic-gate 		else
3577c478bd9Sstevel@tonic-gate 			aclreply3(proc);
3587c478bd9Sstevel@tonic-gate 		show_trailer();
3597c478bd9Sstevel@tonic-gate 	}
3607c478bd9Sstevel@tonic-gate }
3617c478bd9Sstevel@tonic-gate 
3622e3b6467Skcpoon static void
interpret_nfs_acl4(int flags,int type,int xid,int vers,int proc,char * data,int len)3632e3b6467Skcpoon interpret_nfs_acl4(int flags, int type, int xid, int vers, int proc,
3642e3b6467Skcpoon     char *data, int len)
3657c478bd9Sstevel@tonic-gate {
3667c478bd9Sstevel@tonic-gate 	char *line;
3677c478bd9Sstevel@tonic-gate 	char buff[2048];
3687c478bd9Sstevel@tonic-gate 	int off, sz;
3697c478bd9Sstevel@tonic-gate 	char *fh;
3707c478bd9Sstevel@tonic-gate 	ulong_t mask;
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate 	if (proc < 0 || proc > MAXPROC_V4)
3737c478bd9Sstevel@tonic-gate 		return;
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
3767c478bd9Sstevel@tonic-gate 		line = get_sum_line();
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate 		if (type == CALL) {
3797c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NFS_ACL C %s",
38020f2cb7bSVasumathi Sundaram - Sun Microsystems 			    procnames_short_v4[proc]);
3817c478bd9Sstevel@tonic-gate 			line += strlen(line);
3827c478bd9Sstevel@tonic-gate 			switch (proc) {
3837c478bd9Sstevel@tonic-gate 			case ACLPROC4_GETACL:
3847c478bd9Sstevel@tonic-gate 				fh = sum_nfsfh3();
3857c478bd9Sstevel@tonic-gate 				mask = getxdr_u_long();
386*023efabbSMarcel Telka 				(void) sprintf(line, "%s mask=0x%lx", fh, mask);
3877c478bd9Sstevel@tonic-gate 				break;
3887c478bd9Sstevel@tonic-gate 			case ACLPROC4_SETACL:
3897c478bd9Sstevel@tonic-gate 				(void) sprintf(line, sum_nfsfh3());
3907c478bd9Sstevel@tonic-gate 				break;
3917c478bd9Sstevel@tonic-gate 			default:
3927c478bd9Sstevel@tonic-gate 				break;
3937c478bd9Sstevel@tonic-gate 			}
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate 			check_retransmit(line, (ulong_t)xid);
3967c478bd9Sstevel@tonic-gate 		} else {
3977c478bd9Sstevel@tonic-gate 			(void) sprintf(line, "NFS_ACL R %s ",
39820f2cb7bSVasumathi Sundaram - Sun Microsystems 			    procnames_short_v4[proc]);
3997c478bd9Sstevel@tonic-gate 			line += strlen(line);
4007c478bd9Sstevel@tonic-gate 			switch (proc) {
4017c478bd9Sstevel@tonic-gate 			case ACLPROC4_GETACL:
4027c478bd9Sstevel@tonic-gate 				(void) sum_nfsstat4(line);
4037c478bd9Sstevel@tonic-gate 				break;
4047c478bd9Sstevel@tonic-gate 			case ACLPROC4_SETACL:
4057c478bd9Sstevel@tonic-gate 				(void) sum_nfsstat4(line);
4067c478bd9Sstevel@tonic-gate 				break;
4077c478bd9Sstevel@tonic-gate 			default:
4087c478bd9Sstevel@tonic-gate 				break;
4097c478bd9Sstevel@tonic-gate 			}
4107c478bd9Sstevel@tonic-gate 		}
4117c478bd9Sstevel@tonic-gate 	}
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate 	if (flags & F_DTAIL) {
4147c478bd9Sstevel@tonic-gate 		show_header("NFS_ACL:  ", "Sun NFS_ACL", len);
4157c478bd9Sstevel@tonic-gate 		show_space();
4167c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Proc = %d (%s)",
41720f2cb7bSVasumathi Sundaram - Sun Microsystems 		    proc, procnames_long_v4[proc]);
4187c478bd9Sstevel@tonic-gate 		if (type == CALL)
4197c478bd9Sstevel@tonic-gate 			aclcall4(proc);
4207c478bd9Sstevel@tonic-gate 		else
4217c478bd9Sstevel@tonic-gate 			aclreply4(proc);
4227c478bd9Sstevel@tonic-gate 		show_trailer();
4237c478bd9Sstevel@tonic-gate 	}
4247c478bd9Sstevel@tonic-gate }
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate int
sum_nfsstat4(char * line)4277c478bd9Sstevel@tonic-gate sum_nfsstat4(char *line)
4287c478bd9Sstevel@tonic-gate {
4297c478bd9Sstevel@tonic-gate 	ulong_t status;
4307c478bd9Sstevel@tonic-gate 	char *p, *nfsstat4_to_name(int);
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate 	status = getxdr_long();
4337c478bd9Sstevel@tonic-gate 	p = nfsstat4_to_name(status);
4347c478bd9Sstevel@tonic-gate 	(void) strcpy(line, p);
4357c478bd9Sstevel@tonic-gate 	return (status);
4367c478bd9Sstevel@tonic-gate }
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate int
detail_nfsstat4()4397c478bd9Sstevel@tonic-gate detail_nfsstat4()
4407c478bd9Sstevel@tonic-gate {
4417c478bd9Sstevel@tonic-gate 	ulong_t status;
4427c478bd9Sstevel@tonic-gate 	char buff[64];
4437c478bd9Sstevel@tonic-gate 	int pos;
4447c478bd9Sstevel@tonic-gate 
4457c478bd9Sstevel@tonic-gate 	pos = getxdr_pos();
4467c478bd9Sstevel@tonic-gate 	status = sum_nfsstat4(buff);
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()), "Status = %d (%s)",
44920f2cb7bSVasumathi Sundaram - Sun Microsystems 	    status, buff);
4507c478bd9Sstevel@tonic-gate 
4517c478bd9Sstevel@tonic-gate 	return ((int)status);
4527c478bd9Sstevel@tonic-gate }
4537c478bd9Sstevel@tonic-gate 
4547c478bd9Sstevel@tonic-gate /*
4557c478bd9Sstevel@tonic-gate  * Print out version 2 NFS_ACL call packets
4567c478bd9Sstevel@tonic-gate  */
4577c478bd9Sstevel@tonic-gate static void
aclcall2(proc)4587c478bd9Sstevel@tonic-gate aclcall2(proc)
4597c478bd9Sstevel@tonic-gate 	int proc;
4607c478bd9Sstevel@tonic-gate {
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate 	switch (proc) {
4637c478bd9Sstevel@tonic-gate 	case ACLPROC2_GETACL:
4647c478bd9Sstevel@tonic-gate 		detail_nfsfh();
4657c478bd9Sstevel@tonic-gate 		detail_mask();
4667c478bd9Sstevel@tonic-gate 		break;
4677c478bd9Sstevel@tonic-gate 	case ACLPROC2_SETACL:
4687c478bd9Sstevel@tonic-gate 		detail_nfsfh();
4697c478bd9Sstevel@tonic-gate 		detail_secattr();
4707c478bd9Sstevel@tonic-gate 		break;
4717c478bd9Sstevel@tonic-gate 	case ACLPROC2_GETATTR:
4727c478bd9Sstevel@tonic-gate 		detail_nfsfh();
4737c478bd9Sstevel@tonic-gate 		break;
4747c478bd9Sstevel@tonic-gate 	case ACLPROC2_ACCESS:
4757c478bd9Sstevel@tonic-gate 		detail_nfsfh();
4767c478bd9Sstevel@tonic-gate 		detail_access2();
4777c478bd9Sstevel@tonic-gate 		break;
4787c478bd9Sstevel@tonic-gate 	default:
4797c478bd9Sstevel@tonic-gate 		break;
4807c478bd9Sstevel@tonic-gate 	}
4817c478bd9Sstevel@tonic-gate }
4827c478bd9Sstevel@tonic-gate 
4837c478bd9Sstevel@tonic-gate /*
4847c478bd9Sstevel@tonic-gate  * Print out version 2 NFS_ACL reply packets
4857c478bd9Sstevel@tonic-gate  */
4867c478bd9Sstevel@tonic-gate static void
aclreply2(proc)4877c478bd9Sstevel@tonic-gate aclreply2(proc)
4887c478bd9Sstevel@tonic-gate 	int proc;
4897c478bd9Sstevel@tonic-gate {
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate 	switch (proc) {
4927c478bd9Sstevel@tonic-gate 	case ACLPROC2_GETACL:
4937c478bd9Sstevel@tonic-gate 		if (detail_nfsstat() == 0) {
4947c478bd9Sstevel@tonic-gate 			detail_fattr();
4957c478bd9Sstevel@tonic-gate 			detail_secattr();
4967c478bd9Sstevel@tonic-gate 		}
4977c478bd9Sstevel@tonic-gate 		break;
4987c478bd9Sstevel@tonic-gate 	case ACLPROC2_SETACL:
4997c478bd9Sstevel@tonic-gate 		if (detail_nfsstat() == 0)
5007c478bd9Sstevel@tonic-gate 			detail_fattr();
5017c478bd9Sstevel@tonic-gate 		break;
5027c478bd9Sstevel@tonic-gate 	case ACLPROC2_GETATTR:
5037c478bd9Sstevel@tonic-gate 		if (detail_nfsstat() == 0)
5047c478bd9Sstevel@tonic-gate 			detail_fattr();
5057c478bd9Sstevel@tonic-gate 		break;
5067c478bd9Sstevel@tonic-gate 	case ACLPROC2_ACCESS:
5077c478bd9Sstevel@tonic-gate 		if (detail_nfsstat() == 0) {
5087c478bd9Sstevel@tonic-gate 			detail_fattr();
5097c478bd9Sstevel@tonic-gate 			detail_access2();
5107c478bd9Sstevel@tonic-gate 		}
5117c478bd9Sstevel@tonic-gate 		break;
5127c478bd9Sstevel@tonic-gate 	default:
5137c478bd9Sstevel@tonic-gate 		break;
5147c478bd9Sstevel@tonic-gate 	}
5157c478bd9Sstevel@tonic-gate }
5167c478bd9Sstevel@tonic-gate 
5177c478bd9Sstevel@tonic-gate /*
5187c478bd9Sstevel@tonic-gate  * Print out version 3 NFS_ACL call packets
5197c478bd9Sstevel@tonic-gate  */
5207c478bd9Sstevel@tonic-gate static void
aclcall3(proc)5217c478bd9Sstevel@tonic-gate aclcall3(proc)
5227c478bd9Sstevel@tonic-gate 	int proc;
5237c478bd9Sstevel@tonic-gate {
5247c478bd9Sstevel@tonic-gate 
5257c478bd9Sstevel@tonic-gate 	switch (proc) {
5267c478bd9Sstevel@tonic-gate 	case ACLPROC3_GETACL:
5277c478bd9Sstevel@tonic-gate 		detail_nfsfh3();
5287c478bd9Sstevel@tonic-gate 		detail_mask();
5297c478bd9Sstevel@tonic-gate 		break;
5307c478bd9Sstevel@tonic-gate 	case ACLPROC3_SETACL:
5317c478bd9Sstevel@tonic-gate 		detail_nfsfh3();
5327c478bd9Sstevel@tonic-gate 		detail_secattr();
5337c478bd9Sstevel@tonic-gate 		break;
5347c478bd9Sstevel@tonic-gate 	default:
5357c478bd9Sstevel@tonic-gate 		break;
5367c478bd9Sstevel@tonic-gate 	}
5377c478bd9Sstevel@tonic-gate }
5387c478bd9Sstevel@tonic-gate 
5397c478bd9Sstevel@tonic-gate /*
5407c478bd9Sstevel@tonic-gate  * Print out version 3 NFS_ACL reply packets
5417c478bd9Sstevel@tonic-gate  */
5427c478bd9Sstevel@tonic-gate static void
aclreply3(proc)5437c478bd9Sstevel@tonic-gate aclreply3(proc)
5447c478bd9Sstevel@tonic-gate 	int proc;
5457c478bd9Sstevel@tonic-gate {
5467c478bd9Sstevel@tonic-gate 
5477c478bd9Sstevel@tonic-gate 	switch (proc) {
5487c478bd9Sstevel@tonic-gate 	case ACLPROC3_GETACL:
5497c478bd9Sstevel@tonic-gate 		if (detail_nfsstat3() == 0) {
5507c478bd9Sstevel@tonic-gate 			detail_post_op_attr("");
5517c478bd9Sstevel@tonic-gate 			detail_secattr();
5527c478bd9Sstevel@tonic-gate 		}
5537c478bd9Sstevel@tonic-gate 		break;
5547c478bd9Sstevel@tonic-gate 	case ACLPROC3_SETACL:
5557c478bd9Sstevel@tonic-gate 		if (detail_nfsstat3() == 0)
5567c478bd9Sstevel@tonic-gate 			detail_post_op_attr("");
5577c478bd9Sstevel@tonic-gate 		break;
5587c478bd9Sstevel@tonic-gate 	default:
5597c478bd9Sstevel@tonic-gate 		break;
5607c478bd9Sstevel@tonic-gate 	}
5617c478bd9Sstevel@tonic-gate }
5627c478bd9Sstevel@tonic-gate 
5637c478bd9Sstevel@tonic-gate /*
5647c478bd9Sstevel@tonic-gate  * Print out version 4 NFS_ACL call packets
5657c478bd9Sstevel@tonic-gate  */
5667c478bd9Sstevel@tonic-gate static void
aclcall4(proc)5677c478bd9Sstevel@tonic-gate aclcall4(proc)
5687c478bd9Sstevel@tonic-gate 	int proc;
5697c478bd9Sstevel@tonic-gate {
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate 	switch (proc) {
5727c478bd9Sstevel@tonic-gate 	case ACLPROC4_GETACL:
5737c478bd9Sstevel@tonic-gate 		detail_nfsfh3();
5747c478bd9Sstevel@tonic-gate 		detail_mask();
5757c478bd9Sstevel@tonic-gate 		break;
5767c478bd9Sstevel@tonic-gate 	case ACLPROC4_SETACL:
5777c478bd9Sstevel@tonic-gate 		detail_nfsfh3();
5787c478bd9Sstevel@tonic-gate 		detail_secattr();
5797c478bd9Sstevel@tonic-gate 		break;
5807c478bd9Sstevel@tonic-gate 	default:
5817c478bd9Sstevel@tonic-gate 		break;
5827c478bd9Sstevel@tonic-gate 	}
5837c478bd9Sstevel@tonic-gate }
5847c478bd9Sstevel@tonic-gate 
5857c478bd9Sstevel@tonic-gate /*
5867c478bd9Sstevel@tonic-gate  * Print out version 4 NFS_ACL reply packets
5877c478bd9Sstevel@tonic-gate  */
5887c478bd9Sstevel@tonic-gate static void
aclreply4(proc)5897c478bd9Sstevel@tonic-gate aclreply4(proc)
5907c478bd9Sstevel@tonic-gate 	int proc;
5917c478bd9Sstevel@tonic-gate {
5927c478bd9Sstevel@tonic-gate 
5937c478bd9Sstevel@tonic-gate 	switch (proc) {
5947c478bd9Sstevel@tonic-gate 	case ACLPROC4_GETACL:
5957c478bd9Sstevel@tonic-gate 		if (detail_nfsstat4() == 0) {
5967c478bd9Sstevel@tonic-gate 			detail_post_op_attr("");
5977c478bd9Sstevel@tonic-gate 			detail_secattr();
5987c478bd9Sstevel@tonic-gate 		}
5997c478bd9Sstevel@tonic-gate 		break;
6007c478bd9Sstevel@tonic-gate 	case ACLPROC4_SETACL:
6017c478bd9Sstevel@tonic-gate 		if (detail_nfsstat4() == 0)
6027c478bd9Sstevel@tonic-gate 			detail_post_op_attr("");
6037c478bd9Sstevel@tonic-gate 		break;
6047c478bd9Sstevel@tonic-gate 	default:
6057c478bd9Sstevel@tonic-gate 		break;
6067c478bd9Sstevel@tonic-gate 	}
6077c478bd9Sstevel@tonic-gate }
6087c478bd9Sstevel@tonic-gate 
6097c478bd9Sstevel@tonic-gate static void
detail_access2()6107c478bd9Sstevel@tonic-gate detail_access2()
6117c478bd9Sstevel@tonic-gate {
6127c478bd9Sstevel@tonic-gate 	uint_t bits;
6137c478bd9Sstevel@tonic-gate 
6147c478bd9Sstevel@tonic-gate 	bits = showxdr_u_long("Access bits = 0x%08x");
6157c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
61620f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(bits, ACCESS2_READ, "Read", "(no read)"));
6177c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
61820f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(bits, ACCESS2_LOOKUP, "Lookup", "(no lookup)"));
6197c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
62020f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(bits, ACCESS2_MODIFY, "Modify", "(no modify)"));
6217c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
62220f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(bits, ACCESS2_EXTEND, "Extend", "(no extend)"));
6237c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
62420f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(bits, ACCESS2_DELETE, "Delete", "(no delete)"));
6257c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
62620f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(bits, ACCESS2_EXECUTE, "Execute", "(no execute)"));
6277c478bd9Sstevel@tonic-gate }
6287c478bd9Sstevel@tonic-gate 
6297c478bd9Sstevel@tonic-gate static char *
sum_access2()6307c478bd9Sstevel@tonic-gate sum_access2()
6317c478bd9Sstevel@tonic-gate {
6327c478bd9Sstevel@tonic-gate 	int bits;
6337c478bd9Sstevel@tonic-gate 	static char buff[22];
6347c478bd9Sstevel@tonic-gate 
6357c478bd9Sstevel@tonic-gate 	bits = getxdr_u_long();
6367c478bd9Sstevel@tonic-gate 	buff[0] = '\0';
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate 	if (bits & ACCESS2_READ)
6397c478bd9Sstevel@tonic-gate 		(void) strcat(buff, "read,");
6407c478bd9Sstevel@tonic-gate 	if (bits & ACCESS2_LOOKUP)
6417c478bd9Sstevel@tonic-gate 		(void) strcat(buff, "lookup,");
6427c478bd9Sstevel@tonic-gate 	if (bits & ACCESS2_MODIFY)
6437c478bd9Sstevel@tonic-gate 		(void) strcat(buff, "modify,");
6447c478bd9Sstevel@tonic-gate 	if (bits & ACCESS2_EXTEND)
6457c478bd9Sstevel@tonic-gate 		(void) strcat(buff, "extend,");
6467c478bd9Sstevel@tonic-gate 	if (bits & ACCESS2_DELETE)
6477c478bd9Sstevel@tonic-gate 		(void) strcat(buff, "delete,");
6487c478bd9Sstevel@tonic-gate 	if (bits & ACCESS2_EXECUTE)
6497c478bd9Sstevel@tonic-gate 		(void) strcat(buff, "execute,");
6507c478bd9Sstevel@tonic-gate 	if (buff[0] != '\0')
6517c478bd9Sstevel@tonic-gate 		buff[strlen(buff) - 1] = '\0';
6527c478bd9Sstevel@tonic-gate 
6537c478bd9Sstevel@tonic-gate 	return (buff);
6547c478bd9Sstevel@tonic-gate }
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate static void
detail_mask()6577c478bd9Sstevel@tonic-gate detail_mask()
6587c478bd9Sstevel@tonic-gate {
6597c478bd9Sstevel@tonic-gate 	ulong_t mask;
6607c478bd9Sstevel@tonic-gate 
6617c478bd9Sstevel@tonic-gate 	mask = showxdr_u_long("Mask = 0x%lx");
6627c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
66320f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(mask, NA_ACL, "aclent", "(no aclent)"));
6647c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
66520f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(mask, NA_ACLCNT, "aclcnt", "(no aclcnt)"));
6667c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
66720f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(mask, NA_DFACL, "dfaclent", "(no dfaclent)"));
6687c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "	%s",
66920f2cb7bSVasumathi Sundaram - Sun Microsystems 	    getflag(mask, NA_DFACLCNT, "dfaclcnt", "(no dfaclcnt)"));
6707c478bd9Sstevel@tonic-gate }
6717c478bd9Sstevel@tonic-gate 
6727c478bd9Sstevel@tonic-gate static void
detail_secattr()6737c478bd9Sstevel@tonic-gate detail_secattr()
6747c478bd9Sstevel@tonic-gate {
6757c478bd9Sstevel@tonic-gate 
6767c478bd9Sstevel@tonic-gate 	detail_mask();
6777c478bd9Sstevel@tonic-gate 	showxdr_long("Aclcnt = %d");
6787c478bd9Sstevel@tonic-gate 	detail_aclent();
6797c478bd9Sstevel@tonic-gate 	showxdr_long("Dfaclcnt = %d");
6807c478bd9Sstevel@tonic-gate 	detail_aclent();
6817c478bd9Sstevel@tonic-gate }
6827c478bd9Sstevel@tonic-gate 
6837c478bd9Sstevel@tonic-gate static void
detail_aclent()6847c478bd9Sstevel@tonic-gate detail_aclent()
6857c478bd9Sstevel@tonic-gate {
6867c478bd9Sstevel@tonic-gate 	int count;
6877c478bd9Sstevel@tonic-gate 	int type;
6887c478bd9Sstevel@tonic-gate 	int id;
6897c478bd9Sstevel@tonic-gate 	ushort_t perm;
6907c478bd9Sstevel@tonic-gate 
6917c478bd9Sstevel@tonic-gate 	count = getxdr_long();
6927c478bd9Sstevel@tonic-gate 	while (count-- > 0) {
6937c478bd9Sstevel@tonic-gate 		type = getxdr_long();
6947c478bd9Sstevel@tonic-gate 		id = getxdr_long();
6957c478bd9Sstevel@tonic-gate 		perm = getxdr_u_short();
6967c478bd9Sstevel@tonic-gate 		switch (type) {
6977c478bd9Sstevel@tonic-gate 		case NA_USER:
6987c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tuser:%s:%s",
69920f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_uname(id), detail_perm(perm));
7007c478bd9Sstevel@tonic-gate 			break;
7017c478bd9Sstevel@tonic-gate 		case NA_USER_OBJ:
7027c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tuser::%s",
70320f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_perm(perm));
7047c478bd9Sstevel@tonic-gate 			break;
7057c478bd9Sstevel@tonic-gate 		case NA_GROUP:
7067c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tgroup:%s:%s",
70720f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_gname(id), detail_perm(perm));
7087c478bd9Sstevel@tonic-gate 			break;
7097c478bd9Sstevel@tonic-gate 		case NA_GROUP_OBJ:
7107c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tgroup::%s",
71120f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_perm(perm));
7127c478bd9Sstevel@tonic-gate 			break;
7137c478bd9Sstevel@tonic-gate 		case NA_CLASS_OBJ:
7147c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tmask:%s",
71520f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_perm(perm));
7167c478bd9Sstevel@tonic-gate 			break;
7177c478bd9Sstevel@tonic-gate 		case NA_OTHER_OBJ:
7187c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tother:%s",
71920f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_perm(perm));
7207c478bd9Sstevel@tonic-gate 			break;
7217c478bd9Sstevel@tonic-gate 		case NA_DEF_USER:
7227c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tdefault:user:%s:%s",
72320f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_uname(id), detail_perm(perm));
7247c478bd9Sstevel@tonic-gate 			break;
7257c478bd9Sstevel@tonic-gate 		case NA_DEF_USER_OBJ:
7267c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tdefault:user::%s",
72720f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_perm(perm));
7287c478bd9Sstevel@tonic-gate 			break;
7297c478bd9Sstevel@tonic-gate 		case NA_DEF_GROUP:
7307c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tdefault:group:%s:%s",
73120f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_gname(id), detail_perm(perm));
7327c478bd9Sstevel@tonic-gate 			break;
7337c478bd9Sstevel@tonic-gate 		case NA_DEF_GROUP_OBJ:
7347c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tdefault:group::%s",
73520f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_perm(perm));
7367c478bd9Sstevel@tonic-gate 			break;
7377c478bd9Sstevel@tonic-gate 		case NA_DEF_CLASS_OBJ:
7387c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tdefault:mask:%s",
73920f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_perm(perm));
7407c478bd9Sstevel@tonic-gate 			break;
7417c478bd9Sstevel@tonic-gate 		case NA_DEF_OTHER_OBJ:
7427c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tdefault:other:%s",
74320f2cb7bSVasumathi Sundaram - Sun Microsystems 			    detail_perm(perm));
7447c478bd9Sstevel@tonic-gate 			break;
7457c478bd9Sstevel@tonic-gate 		default:
7467c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "\tunrecognized entry");
7477c478bd9Sstevel@tonic-gate 			break;
7487c478bd9Sstevel@tonic-gate 		}
7497c478bd9Sstevel@tonic-gate 	}
7507c478bd9Sstevel@tonic-gate }
7517c478bd9Sstevel@tonic-gate 
7527c478bd9Sstevel@tonic-gate static char *
detail_uname(uid_t uid)7537c478bd9Sstevel@tonic-gate detail_uname(uid_t uid)
7547c478bd9Sstevel@tonic-gate {
7557c478bd9Sstevel@tonic-gate 	struct passwd *pwd;
7567c478bd9Sstevel@tonic-gate 	static char uidp[10];
7577c478bd9Sstevel@tonic-gate 
7587c478bd9Sstevel@tonic-gate 	pwd = getpwuid(uid);
7597c478bd9Sstevel@tonic-gate 	if (pwd == NULL) {
7607c478bd9Sstevel@tonic-gate 		sprintf(uidp, "%d", uid);
7617c478bd9Sstevel@tonic-gate 		return (uidp);
7627c478bd9Sstevel@tonic-gate 	}
7637c478bd9Sstevel@tonic-gate 	return (pwd->pw_name);
7647c478bd9Sstevel@tonic-gate }
7657c478bd9Sstevel@tonic-gate 
7667c478bd9Sstevel@tonic-gate static char *
detail_gname(gid_t gid)7677c478bd9Sstevel@tonic-gate detail_gname(gid_t gid)
7687c478bd9Sstevel@tonic-gate {
7697c478bd9Sstevel@tonic-gate 	struct group *grp;
7707c478bd9Sstevel@tonic-gate 	static char gidp[10];
7717c478bd9Sstevel@tonic-gate 
7727c478bd9Sstevel@tonic-gate 	grp = getgrgid(gid);
7737c478bd9Sstevel@tonic-gate 	if (grp == NULL) {
7747c478bd9Sstevel@tonic-gate 		sprintf(gidp, "%d", gid);
7757c478bd9Sstevel@tonic-gate 		return (gidp);
7767c478bd9Sstevel@tonic-gate 	}
7777c478bd9Sstevel@tonic-gate 	return (grp->gr_name);
7787c478bd9Sstevel@tonic-gate }
7797c478bd9Sstevel@tonic-gate 
7807c478bd9Sstevel@tonic-gate static char *perms[] = {
7817c478bd9Sstevel@tonic-gate 	"---",
7827c478bd9Sstevel@tonic-gate 	"--x",
7837c478bd9Sstevel@tonic-gate 	"-w-",
7847c478bd9Sstevel@tonic-gate 	"-wx",
7857c478bd9Sstevel@tonic-gate 	"r--",
7867c478bd9Sstevel@tonic-gate 	"r-x",
7877c478bd9Sstevel@tonic-gate 	"rw-",
7887c478bd9Sstevel@tonic-gate 	"rwx"
7897c478bd9Sstevel@tonic-gate };
7907c478bd9Sstevel@tonic-gate static char *
detail_perm(ushort_t perm)7917c478bd9Sstevel@tonic-gate detail_perm(ushort_t perm)
7927c478bd9Sstevel@tonic-gate {
7937c478bd9Sstevel@tonic-gate 
79420f2cb7bSVasumathi Sundaram - Sun Microsystems 	if (perm >= sizeof (perms) / sizeof (perms[0]))
7957c478bd9Sstevel@tonic-gate 		return ("?");
7967c478bd9Sstevel@tonic-gate 	return (perms[perm]);
7977c478bd9Sstevel@tonic-gate }
798