/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <setjmp.h>
#include <pwd.h>
#include <grp.h>
#include <string.h>
#include "snoop.h"
extern char *get_sum_line();
extern void check_retransmit();
extern char *sum_nfsfh();
extern int sum_nfsstat();
extern int detail_nfsstat();
extern void detail_nfsfh();
extern void detail_fattr();
extern void skip_fattr();
extern char *sum_nfsfh3();
extern int sum_nfsstat3();
extern int detail_nfsstat3();
extern void detail_post_op_attr();
extern void detail_nfsfh3();
extern int sum_nfsstat4();
extern int detail_nfsstat4();
static void aclcall2();
static void aclreply2();
static void aclcall3();
static void aclreply3();
static void aclcall4();
static void aclreply4();
static void detail_access2();
static char *sum_access2();
static void detail_mask();
static void detail_secattr();
static void detail_aclent();
static char *detail_uname();
static char *detail_gname();
static char *detail_perm(ushort_t);
static void interpret_nfs_acl2(int, int, int, int, int, char *, int);
static void interpret_nfs_acl3(int, int, int, int, int, char *, int);
static void interpret_nfs_acl4(int, int, int, int, int, char *, int);
#define ACLPROC2_NULL ((unsigned long)(0))
#define ACLPROC3_NULL ((unsigned long)(0))
#define ACLPROC4_NULL ((unsigned long)(0))
static char *procnames_short_v2[] = {
"NULL2", /* 0 */
"GETACL2", /* 1 */
"SETACL2", /* 2 */
"GETATTR2", /* 3 */
"ACCESS2", /* 4 */
"GETXATTRDIR2", /* 5 */
};
static char *procnames_short_v3[] = {
"NULL3", /* 0 */
"GETACL3", /* 1 */
"SETACL3", /* 2 */
"GETXATTRDIR3", /* 3 */
};
static char *procnames_short_v4[] = {
"NULL4", /* 0 */
"GETACL4", /* 1 */
"SETACL4", /* 2 */
};
static char *procnames_long_v2[] = {
"Null procedure", /* 0 */
"Get file access control list", /* 1 */
"Set file access control list", /* 2 */
"Get file attributes", /* 3 */
"Check access permission", /* 4 */
"Get extended attribute directory", /* 5 */
};
static char *procnames_long_v3[] = {
"Null procedure", /* 0 */
"Get file access control list", /* 1 */
"Set file access control list", /* 2 */
"Get extended attribute directory", /* 3 */
};
static char *procnames_long_v4[] = {
"Null procedure", /* 0 */
"Get file access control list", /* 1 */
"Set file access control list", /* 2 */
};
/* ARGSUSED */
void
char *data;
int len;
{
if (vers == 2) {
return;
}
if (vers == 3) {
return;
}
if (vers == 4) {
return;
}
}
static void
{
char *line;
char *fh;
return;
line = get_sum_line();
switch (proc) {
case ACLPROC2_GETACL:
mask = getxdr_u_long();
break;
case ACLPROC2_SETACL:
break;
case ACLPROC2_GETATTR:
break;
case ACLPROC2_ACCESS:
sum_access2());
break;
case ACLPROC2_GETXATTRDIR:
break;
default:
break;
}
} else {
switch (proc) {
case ACLPROC2_GETACL:
(void) sum_nfsstat(line);
break;
case ACLPROC2_SETACL:
(void) sum_nfsstat(line);
break;
case ACLPROC2_GETATTR:
(void) sum_nfsstat(line);
break;
case ACLPROC2_ACCESS:
if (sum_nfsstat(line) == 0) {
skip_fattr();
sum_access2());
}
break;
case ACLPROC2_GETXATTRDIR:
if (sum_nfsstat(line) == 0) {
}
break;
default:
break;
}
}
}
show_space();
else
show_trailer();
}
}
static void
{
char *line;
char *fh;
return;
line = get_sum_line();
switch (proc) {
case ACLPROC3_GETACL:
fh = sum_nfsfh3();
mask = getxdr_u_long();
break;
case ACLPROC3_SETACL:
break;
case ACLPROC3_GETXATTRDIR:
fh = sum_nfsfh3();
break;
default:
break;
}
} else {
switch (proc) {
case ACLPROC3_GETACL:
(void) sum_nfsstat3(line);
break;
case ACLPROC3_SETACL:
(void) sum_nfsstat3(line);
break;
case ACLPROC3_GETXATTRDIR:
if (sum_nfsstat3(line) == 0) {
}
break;
default:
break;
}
}
}
show_space();
else
show_trailer();
}
}
static void
{
char *line;
char *fh;
return;
line = get_sum_line();
switch (proc) {
case ACLPROC4_GETACL:
fh = sum_nfsfh3();
mask = getxdr_u_long();
break;
case ACLPROC4_SETACL:
break;
default:
break;
}
} else {
switch (proc) {
case ACLPROC4_GETACL:
(void) sum_nfsstat4(line);
break;
case ACLPROC4_SETACL:
(void) sum_nfsstat4(line);
break;
default:
break;
}
}
}
show_space();
else
show_trailer();
}
}
int
{
char *p, *nfsstat4_to_name(int);
status = getxdr_long();
p = nfsstat4_to_name(status);
return (status);
}
int
{
int pos;
pos = getxdr_pos();
return ((int)status);
}
/*
* Print out version 2 NFS_ACL call packets
*/
static void
int proc;
{
switch (proc) {
case ACLPROC2_GETACL:
detail_nfsfh();
detail_mask();
break;
case ACLPROC2_SETACL:
detail_nfsfh();
break;
case ACLPROC2_GETATTR:
detail_nfsfh();
break;
case ACLPROC2_ACCESS:
detail_nfsfh();
break;
default:
break;
}
}
/*
* Print out version 2 NFS_ACL reply packets
*/
static void
int proc;
{
switch (proc) {
case ACLPROC2_GETACL:
if (detail_nfsstat() == 0) {
detail_fattr();
}
break;
case ACLPROC2_SETACL:
if (detail_nfsstat() == 0)
detail_fattr();
break;
case ACLPROC2_GETATTR:
if (detail_nfsstat() == 0)
detail_fattr();
break;
case ACLPROC2_ACCESS:
if (detail_nfsstat() == 0) {
detail_fattr();
}
break;
default:
break;
}
}
/*
* Print out version 3 NFS_ACL call packets
*/
static void
int proc;
{
switch (proc) {
case ACLPROC3_GETACL:
detail_mask();
break;
case ACLPROC3_SETACL:
break;
default:
break;
}
}
/*
* Print out version 3 NFS_ACL reply packets
*/
static void
int proc;
{
switch (proc) {
case ACLPROC3_GETACL:
if (detail_nfsstat3() == 0) {
detail_post_op_attr("");
}
break;
case ACLPROC3_SETACL:
if (detail_nfsstat3() == 0)
detail_post_op_attr("");
break;
default:
break;
}
}
/*
* Print out version 4 NFS_ACL call packets
*/
static void
int proc;
{
switch (proc) {
case ACLPROC4_GETACL:
detail_mask();
break;
case ACLPROC4_SETACL:
break;
default:
break;
}
}
/*
* Print out version 4 NFS_ACL reply packets
*/
static void
int proc;
{
switch (proc) {
case ACLPROC4_GETACL:
if (detail_nfsstat4() == 0) {
detail_post_op_attr("");
}
break;
case ACLPROC4_SETACL:
if (detail_nfsstat4() == 0)
detail_post_op_attr("");
break;
default:
break;
}
}
static void
{
}
static char *
{
int bits;
bits = getxdr_u_long();
buff[0] = '\0';
if (bits & ACCESS2_READ)
if (bits & ACCESS2_LOOKUP)
if (bits & ACCESS2_MODIFY)
if (bits & ACCESS2_EXTEND)
if (bits & ACCESS2_DELETE)
if (bits & ACCESS2_EXECUTE)
if (buff[0] != '\0')
return (buff);
}
static void
{
}
static void
{
detail_mask();
showxdr_long("Aclcnt = %d");
showxdr_long("Dfaclcnt = %d");
}
static void
{
int count;
int type;
int id;
count = getxdr_long();
while (count-- > 0) {
type = getxdr_long();
id = getxdr_long();
perm = getxdr_u_short();
switch (type) {
case NA_USER:
break;
case NA_USER_OBJ:
detail_perm(perm));
break;
case NA_GROUP:
break;
case NA_GROUP_OBJ:
detail_perm(perm));
break;
case NA_CLASS_OBJ:
detail_perm(perm));
break;
case NA_OTHER_OBJ:
detail_perm(perm));
break;
case NA_DEF_USER:
break;
case NA_DEF_USER_OBJ:
detail_perm(perm));
break;
case NA_DEF_GROUP:
break;
case NA_DEF_GROUP_OBJ:
detail_perm(perm));
break;
case NA_DEF_CLASS_OBJ:
detail_perm(perm));
break;
case NA_DEF_OTHER_OBJ:
detail_perm(perm));
break;
default:
break;
}
}
}
static char *
{
return (uidp);
}
}
static char *
{
return (gidp);
}
}
static char *perms[] = {
"---",
"--x",
"-w-",
"-wx",
"r--",
"r-x",
"rw-",
"rwx"
};
static char *
{
return ("?");
}