Home | History | Annotate | Download | only in snoop
      1  0  stevel /*
      2  0  stevel  * CDDL HEADER START
      3  0  stevel  *
      4  0  stevel  * The contents of this file are subject to the terms of the
      5  0  stevel  * Common Development and Distribution License, Version 1.0 only
      6  0  stevel  * (the "License").  You may not use this file except in compliance
      7  0  stevel  * with the License.
      8  0  stevel  *
      9  0  stevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  0  stevel  * or http://www.opensolaris.org/os/licensing.
     11  0  stevel  * See the License for the specific language governing permissions
     12  0  stevel  * and limitations under the License.
     13  0  stevel  *
     14  0  stevel  * When distributing Covered Code, include this CDDL HEADER in each
     15  0  stevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  0  stevel  * If applicable, add the following below this CDDL HEADER, with the
     17  0  stevel  * fields enclosed by brackets "[]" replaced with your own identifying
     18  0  stevel  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  0  stevel  *
     20  0  stevel  * CDDL HEADER END
     21  0  stevel  */
     22  0  stevel /*
     23  0  stevel  * Copyright (c) 1991, 1999 by Sun Microsystems, Inc.
     24  0  stevel  * All rights reserved.
     25  0  stevel  */
     26  0  stevel 
     27  0  stevel #ident	"%Z%%M%	%I%	%E% SMI"	/* SunOS	*/
     28  0  stevel 
     29  0  stevel #include <sys/types.h>
     30  0  stevel #include <sys/errno.h>
     31  0  stevel #include <setjmp.h>
     32  0  stevel #include <string.h>
     33  0  stevel 
     34  0  stevel #include <netinet/in.h>
     35  0  stevel #include <rpc/types.h>
     36  0  stevel #include <rpc/rpc.h>
     37  0  stevel #include <rpc/xdr.h>
     38  0  stevel #include <rpc/auth.h>
     39  0  stevel #include <rpc/clnt.h>
     40  0  stevel #include <rpc/rpc_msg.h>
     41  0  stevel #include <rpcsvc/rquota.h>
     42  0  stevel #include "snoop.h"
     43  0  stevel 
     44  0  stevel extern char *dlc_header;
     45  0  stevel extern jmp_buf xdr_err;
     46  0  stevel 
     47  0  stevel static char *procnames_short[] = {
     48  0  stevel 	"Null",		/*  0 */
     49  0  stevel 	"GETQUOTA",	/*  1 */
     50  0  stevel 	"GETACTIVE",	/*  2 */
     51  0  stevel };
     52  0  stevel 
     53  0  stevel static char *procnames_long[] = {
     54  0  stevel 	"Null procedure",	/*  0 */
     55  0  stevel 	"Get quotas",		/*  1 */
     56  0  stevel 	"Get active quotas",	/*  2 */
     57  0  stevel };
     58  0  stevel 
     59  0  stevel #define	MAXPROC	2
     60  0  stevel 
     61  0  stevel static void show_quota(void);
     62  0  stevel 
     63  0  stevel void
     64  0  stevel interpret_rquota(flags, type, xid, vers, proc, data, len)
     65  0  stevel 	int flags, type, xid, vers, proc;
     66  0  stevel 	char *data;
     67  0  stevel 	int len;
     68  0  stevel {
     69  0  stevel 	char *line;
     70  0  stevel 	char buff[RQ_PATHLEN + 1];
     71  0  stevel 	int status;
     72  0  stevel 	int uid;
     73  0  stevel 
     74  0  stevel 	if (proc < 0 || proc > MAXPROC)
     75  0  stevel 		return;
     76  0  stevel 
     77  0  stevel 	if (flags & F_SUM) {
     78  0  stevel 		if (setjmp(xdr_err)) {
     79  0  stevel 			return;
     80  0  stevel 		}
     81  0  stevel 
     82  0  stevel 		line = get_sum_line();
     83  0  stevel 
     84  0  stevel 		if (type == CALL) {
     85  0  stevel 			(void) getxdr_string(buff, RQ_PATHLEN);
     86  0  stevel 			uid = getxdr_long();
     87  0  stevel 			(void) sprintf(line,
     88  0  stevel 				"RQUOTA C %s Uid=%d Path=%s",
     89  0  stevel 				procnames_short[proc],
     90  0  stevel 				uid, buff);
     91  0  stevel 
     92  0  stevel 			check_retransmit(line, xid);
     93  0  stevel 		} else {
     94  0  stevel 			(void) sprintf(line, "RQUOTA R %s ",
     95  0  stevel 				procnames_short[proc]);
     96  0  stevel 			line += strlen(line);
     97  0  stevel 			status = getxdr_u_long();
     98  0  stevel 			if (status == Q_OK)
     99  0  stevel 				(void) sprintf(line, "OK");
    100  0  stevel 			else if (status == Q_NOQUOTA)
    101  0  stevel 				(void) sprintf(line, "No quota");
    102  0  stevel 			else if (status == Q_EPERM)
    103  0  stevel 				(void) sprintf(line, "No permission");
    104  0  stevel 		}
    105  0  stevel 	}
    106  0  stevel 
    107  0  stevel 	if (flags & F_DTAIL) {
    108  0  stevel 		show_header("RQUOTA:  ", "Remote Quota Check", len);
    109  0  stevel 		show_space();
    110  0  stevel 		if (setjmp(xdr_err)) {
    111  0  stevel 			return;
    112  0  stevel 		}
    113  0  stevel 		(void) sprintf(get_line(0, 0),
    114  0  stevel 			"Proc = %d (%s)",
    115  0  stevel 			proc, procnames_long[proc]);
    116  0  stevel 
    117  0  stevel 		if (type == CALL) {
    118  0  stevel 			switch (proc) {
    119  0  stevel 			case  RQUOTAPROC_GETQUOTA:
    120  0  stevel 			case RQUOTAPROC_GETACTIVEQUOTA:
    121  0  stevel 				(void) showxdr_string(RQ_PATHLEN,
    122  0  stevel 					"Path = %s");
    123  0  stevel 				(void) showxdr_long("User id = %d");
    124  0  stevel 				break;
    125  0  stevel 			}
    126  0  stevel 		} else {
    127  0  stevel 			status = getxdr_u_long();
    128  0  stevel 			(void) sprintf(get_line(0, 0),
    129  0  stevel 				"Status = %lu (%s)",
    130  0  stevel 				status,
    131  0  stevel 				status == Q_OK ? "OK" :
    132  0  stevel 				status == Q_NOQUOTA ? "No quota" :
    133  0  stevel 				status == Q_EPERM ? "No permission":"");
    134  0  stevel 
    135  0  stevel 			if (status == Q_OK)
    136  0  stevel 				show_quota();
    137  0  stevel 		}
    138  0  stevel 
    139  0  stevel 		show_trailer();
    140  0  stevel 	}
    141  0  stevel }
    142  0  stevel 
    143  0  stevel static void
    144  0  stevel show_quota()
    145  0  stevel {
    146  0  stevel 	int active;
    147  0  stevel 
    148  0  stevel 	(void) showxdr_u_long("Block size = %lu");
    149  0  stevel 	active = getxdr_u_long();
    150  0  stevel 	(void) sprintf(get_line(0, 0),
    151  0  stevel 		"         Quota checking = %lu (%s)",
    152  0  stevel 		active,
    153  0  stevel 		active ? "on" : "off");
    154  0  stevel 	(void) showxdr_u_long("      Blocks hard limit = %lu");
    155  0  stevel 	(void) showxdr_u_long("      Blocks soft limit = %lu");
    156  0  stevel 	(void) showxdr_u_long("    Current block count = %lu");
    157  0  stevel 	(void) show_space();
    158  0  stevel 	(void) showxdr_u_long("        File hard limit = %lu");
    159  0  stevel 	(void) showxdr_u_long("        File soft limit = %lu");
    160  0  stevel 	(void) showxdr_u_long("     Current file count = %lu");
    161  0  stevel 	(void) show_space();
    162  0  stevel 	(void) showxdr_u_long("Excessive blocks limit  = %lu sec");
    163  0  stevel 	(void) showxdr_u_long("Excessive files  limit  = %lu sec");
    164  0  stevel }
    165