Home | History | Annotate | Download | only in rpcsvc
      1 /*
      2  * Redistribution and use in source and binary forms, with or without
      3  * modification, are permitted provided that the following conditions are
      4  * met:
      5  *
      6  *     * Redistributions of source code must retain the above copyright
      7  *       notice, this list of conditions and the following disclaimer.
      8  *     * Redistributions in binary form must reproduce the above
      9  *       copyright notice, this list of conditions and the following
     10  *       disclaimer in the documentation and/or other materials
     11  *       provided with the distribution.
     12  *     * Neither the name of Sun Microsystems, Inc. nor the names of its
     13  *       contributors may be used to endorse or promote products derived
     14  *       from this software without specific prior written permission.
     15  *
     16  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     19  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     20  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     21  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     23  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     25  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     26  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     27  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 %/*
     30 % * Find out about remote users
     31 % */
     32 
     33 const RUSERS_MAXUSERLEN = 32;
     34 const RUSERS_MAXLINELEN = 32;
     35 const RUSERS_MAXHOSTLEN = 257;
     36 
     37 struct rusers_utmp {
     38 	string ut_user<RUSERS_MAXUSERLEN>;	/* aka ut_name */
     39 	string ut_line<RUSERS_MAXLINELEN>;	/* device */
     40 	string ut_host<RUSERS_MAXHOSTLEN>;	/* host user logged on from */
     41 	int ut_type;				/* type of entry */
     42 	int ut_time;				/* time entry was made */
     43 	unsigned int ut_idle;			/* minutes idle */
     44 };
     45 
     46 typedef rusers_utmp utmp_array<>;
     47 
     48 #ifdef RPC_HDR
     49 %
     50 %/*
     51 % * Values for ut_type field above.
     52 % */
     53 #endif
     54 const	RUSERS_EMPTY = 0;
     55 const	RUSERS_RUN_LVL = 1;
     56 const	RUSERS_BOOT_TIME = 2;
     57 const	RUSERS_OLD_TIME = 3;
     58 const	RUSERS_NEW_TIME = 4;
     59 const	RUSERS_INIT_PROCESS = 5;
     60 const	RUSERS_LOGIN_PROCESS = 6;
     61 const	RUSERS_USER_PROCESS = 7;
     62 const	RUSERS_DEAD_PROCESS = 8;
     63 const	RUSERS_ACCOUNTING = 9;
     64 
     65 program RUSERSPROG {
     66 
     67 	version RUSERSVERS_3 {
     68 		int
     69 		RUSERSPROC_NUM(void) = 1;
     70 
     71 		utmp_array
     72 		RUSERSPROC_NAMES(void) = 2;
     73 
     74 		utmp_array
     75 		RUSERSPROC_ALLNAMES(void) = 3;
     76 	} = 3;
     77 
     78 } = 100002;
     79 
     80 #ifdef RPC_HDR
     81 %
     82 %
     83 %#ifdef	__cplusplus
     84 %extern "C" {
     85 %#endif
     86 %
     87 %#include <rpc/xdr.h>
     88 %
     89 %/*
     90 % * The following structures are used by version 2 of the rusersd protocol.
     91 % * They were not developed with rpcgen, so they do not appear as RPCL.
     92 % */
     93 %
     94 %#define	RUSERSVERS_IDLE 2
     95 %#define	RUSERSVERS 3		/* current version */
     96 %#define	MAXUSERS 100
     97 %
     98 %/*
     99 % * This is the structure used in version 2 of the rusersd RPC service.
    100 % * It corresponds to the utmp structure for BSD systems.
    101 % */
    102 %struct ru_utmp {
    103 %	char	ut_line[8];		/* tty name */
    104 %	char	ut_name[8];		/* user id */
    105 %	char	ut_host[16];		/* host name, if remote */
    106 %	long int ut_time;		/* time on */
    107 %};
    108 %
    109 %struct utmparr {
    110 %       struct ru_utmp **uta_arr;
    111 %       int uta_cnt;
    112 %};
    113 %typedef struct utmparr utmparr;
    114 %
    115 %extern bool_t xdr_utmparr (XDR *xdrs, struct utmparr *objp) __THROW;
    116 %
    117 %struct utmpidle {
    118 %	struct ru_utmp ui_utmp;
    119 %	unsigned int ui_idle;
    120 %};
    121 %
    122 %struct utmpidlearr {
    123 %	struct utmpidle **uia_arr;
    124 %	int uia_cnt;
    125 %};
    126 %
    127 %extern bool_t xdr_utmpidlearr (XDR *xdrs, struct utmpidlearr *objp) __THROW;
    128 %
    129 %#ifdef	__cplusplus
    130 %}
    131 %#endif
    132 #endif
    133 
    134 
    135 #ifdef	RPC_XDR
    136 %bool_t xdr_utmp (XDR *xdrs, struct ru_utmp *objp);
    137 %
    138 %bool_t
    139 %xdr_utmp(xdrs, objp)
    140 %	XDR *xdrs;
    141 %	struct ru_utmp *objp;
    142 %{
    143 %	/* Since the fields are char foo [xxx], we should not free them. */
    144 %	if (xdrs->x_op != XDR_FREE)
    145 %	{
    146 %		char *ptr;
    147 %		unsigned int size;
    148 %		ptr = objp->ut_line;
    149 %		size = sizeof (objp->ut_line);
    150 %		if (!xdr_bytes (xdrs, &ptr, &size, size)) {
    151 %			return (FALSE);
    152 %		}
    153 %		ptr = objp->ut_name;
    154 %		size = sizeof (objp->ut_name);
    155 %		if (!xdr_bytes (xdrs, &ptr, &size, size)) {
    156 %			return (FALSE);
    157 %		}
    158 %		ptr = objp->ut_host;
    159 %		size = sizeof (objp->ut_host);
    160 %		if (!xdr_bytes (xdrs, &ptr, &size, size)) {
    161 %			return (FALSE);
    162 %		}
    163 %	}
    164 %	if (!xdr_long(xdrs, &objp->ut_time)) {
    165 %		return (FALSE);
    166 %	}
    167 %	return (TRUE);
    168 %}
    169 %
    170 %bool_t xdr_utmpptr(XDR *xdrs, struct ru_utmp **objpp);
    171 %
    172 %bool_t
    173 %xdr_utmpptr(xdrs, objpp)
    174 %	XDR *xdrs;
    175 %	struct ru_utmp **objpp;
    176 %{
    177 %	if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct ru_utmp),
    178 %			   (xdrproc_t) xdr_utmp)) {
    179 %		return (FALSE);
    180 %	}
    181 %	return (TRUE);
    182 %}
    183 %
    184 %bool_t
    185 %xdr_utmparr(xdrs, objp)
    186 %	XDR *xdrs;
    187 %	struct utmparr *objp;
    188 %{
    189 %	if (!xdr_array(xdrs, (char **)&objp->uta_arr, (u_int *)&objp->uta_cnt,
    190 %		       MAXUSERS, sizeof(struct ru_utmp *),
    191 %		       (xdrproc_t) xdr_utmpptr)) {
    192 %		return (FALSE);
    193 %	}
    194 %	return (TRUE);
    195 %}
    196 %
    197 %bool_t xdr_utmpidle(XDR *xdrs, struct utmpidle *objp);
    198 %
    199 %bool_t
    200 %xdr_utmpidle(xdrs, objp)
    201 %	XDR *xdrs;
    202 %	struct utmpidle *objp;
    203 %{
    204 %	if (!xdr_utmp(xdrs, &objp->ui_utmp)) {
    205 %		return (FALSE);
    206 %	}
    207 %	if (!xdr_u_int(xdrs, &objp->ui_idle)) {
    208 %		return (FALSE);
    209 %	}
    210 %	return (TRUE);
    211 %}
    212 %
    213 %bool_t xdr_utmpidleptr(XDR *xdrs, struct utmpidle **objp);
    214 %
    215 %bool_t
    216 %xdr_utmpidleptr(xdrs, objpp)
    217 %	XDR *xdrs;
    218 %	struct utmpidle **objpp;
    219 %{
    220 %	if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct utmpidle),
    221 %			   (xdrproc_t) xdr_utmpidle)) {
    222 %		return (FALSE);
    223 %	}
    224 %	return (TRUE);
    225 %}
    226 %
    227 %bool_t
    228 %xdr_utmpidlearr(xdrs, objp)
    229 %	XDR *xdrs;
    230 %	struct utmpidlearr *objp;
    231 %{
    232 %	if (!xdr_array(xdrs, (char **)&objp->uia_arr, (u_int *)&objp->uia_cnt,
    233 %		       MAXUSERS, sizeof(struct utmpidle *),
    234 %		       (xdrproc_t) xdr_utmpidleptr)) {
    235 %		return (FALSE);
    236 %	}
    237 %	return (TRUE);
    238 %}
    239 #endif
    240