xref: /openbsd-src/lib/librpcsvc/rnusers.x (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1 /*	$OpenBSD: rnusers.x,v 1.12 2004/01/17 12:32:11 deraadt Exp $	*/
2 
3 /*
4  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5  * unrestricted use provided that this legend is included on all tape
6  * media and as a part of the software program in whole or part.  Users
7  * may copy or modify Sun RPC without charge, but are not authorized
8  * to license or distribute it to anyone else except as part of a product or
9  * program developed by the user.
10  *
11  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14  *
15  * Sun RPC is provided with no support and without any obligation on the
16  * part of Sun Microsystems, Inc. to assist in its use, correction,
17  * modification or enhancement.
18  *
19  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21  * OR ANY PART THEREOF.
22  *
23  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24  * or profits or other special, indirect and consequential damages, even if
25  * Sun has been advised of the possibility of such damages.
26  *
27  * Sun Microsystems, Inc.
28  * 2550 Garcia Avenue
29  * Mountain View, California  94043
30  */
31 
32 /*
33  * Find out about remote users
34  */
35 
36 #ifndef RPC_HDR
37 %#ifndef lint
38 %/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/
39 %/*static char sccsid[] = "from: @(#)rnusers.x	2.1 88/08/01 4.0 RPCSRC";*/
40 %static char rcsid[] = "$OpenBSD: rnusers.x,v 1.12 2004/01/17 12:32:11 deraadt Exp $";
41 %#endif /* not lint */
42 #endif
43 
44 
45 #ifdef RPC_HDR
46 %/*
47 % * The following structures are used by version 2 of the rusersd protocol.
48 % * They were not developed with rpcgen, so they do not appear as RPCL.
49 % */
50 %
51 %#define	RUSERSVERS_ORIG 1	/* original version */
52 %#define	RUSERSVERS_IDLE 2
53 %#define	MAXUSERS 100
54 %
55 %/*
56 % * This is the structure used in version 2 of the rusersd RPC service.
57 % * It corresponds to the utmp structure for BSD sytems.
58 % */
59 %
60 %#define RNUSERS_MAXUSERLEN 8
61 %#define RNUSERS_MAXLINELEN 8
62 %#define RNUSERS_MAXHOSTLEN 16
63 %
64 %struct ru_utmp {
65 %	char	*ut_line;		/* tty name */
66 %	char	*ut_name;		/* user id */
67 %	char	*ut_host;		/* host name, if remote */
68 %	int	ut_time;		/* time on */
69 %};
70 %typedef struct ru_utmp rutmp;
71 %
72 %struct utmparr {
73 %	struct ru_utmp **uta_arr;
74 %	int uta_cnt;
75 %};
76 %typedef struct utmparr utmparr;
77 %int	xdr_utmparr(XDR *, struct utmparr *);
78 %
79 %struct utmpidle {
80 %	struct ru_utmp ui_utmp;
81 %	unsigned ui_idle;
82 %};
83 %
84 %struct utmpidlearr {
85 %	struct utmpidle **uia_arr;
86 %	int uia_cnt;
87 %};
88 %typedef struct utmpidlearr utmpidlearr;
89 %int xdr_utmpidlearr(XDR *, struct utmpidlearr *);
90 %
91 %#define RUSERSVERS_1 ((u_long)1)
92 %#define RUSERSVERS_2 ((u_long)2)
93 %#ifndef RUSERSPROG
94 %#define RUSERSPROG ((u_long)100002)
95 %#endif
96 %#ifndef RUSERSPROC_NUM
97 %#define RUSERSPROC_NUM ((u_long)1)
98 %#endif
99 %#ifndef RUSERSPROC_NAMES
100 %#define RUSERSPROC_NAMES ((u_long)2)
101 %#endif
102 %#ifndef RUSERSPROC_ALLNAMES
103 %#define RUSERSPROC_ALLNAMES ((u_long)3)
104 %#endif
105 %
106 #endif	/* RPC_HDR */
107 
108 #ifdef	RPC_XDR
109 %bool_t	xdr_utmp(XDR *, struct ru_utmp *);
110 %bool_t	xdr_utmpptr(XDR *, struct ru_utmp **);
111 %bool_t	xdr_utmparr(XDR *, struct utmparr *);
112 %bool_t	xdr_utmpidle(XDR *, struct utmpidle *);
113 %bool_t	xdr_utmpidleptr(XDR *, struct utmpidle **);
114 %
115 %bool_t
116 %xdr_utmp(XDR *xdrs, struct ru_utmp *objp)
117 %{
118 %	int size;
119 %
120 %	size = RNUSERS_MAXLINELEN;
121 %	if (!xdr_bytes(xdrs, &objp->ut_line, &size, RNUSERS_MAXLINELEN))
122 %		return (FALSE);
123 %	size = RNUSERS_MAXUSERLEN;
124 %	if (!xdr_bytes(xdrs, &objp->ut_name, &size, RNUSERS_MAXUSERLEN))
125 %		return (FALSE);
126 %	size = RNUSERS_MAXHOSTLEN;
127 %	if (!xdr_bytes(xdrs, &objp->ut_host, &size, RNUSERS_MAXHOSTLEN))
128 %		return (FALSE);
129 %	if (!xdr_int(xdrs, &objp->ut_time))
130 %		return (FALSE);
131 %	return (TRUE);
132 %}
133 %
134 %bool_t
135 %xdr_utmpptr(XDR *xdrs, struct ru_utmp **objpp)
136 %{
137 %	if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct ru_utmp),
138 %	    xdr_utmp))
139 %		return (FALSE);
140 %	return (TRUE);
141 %}
142 %
143 %bool_t
144 %xdr_utmparr(XDR *xdrs, struct utmparr *objp)
145 %{
146 %	if (!xdr_array(xdrs, (char **)&objp->uta_arr, (u_int *)&objp->uta_cnt,
147 %	    MAXUSERS, sizeof(struct ru_utmp *), xdr_utmpptr))
148 %		return (FALSE);
149 %	return (TRUE);
150 %}
151 %
152 %bool_t
153 %xdr_utmpidle(XDR *xdrs, struct utmpidle *objp)
154 %{
155 %	if (!xdr_utmp(xdrs, &objp->ui_utmp))
156 %		return (FALSE);
157 %	if (!xdr_u_int(xdrs, &objp->ui_idle))
158 %		return (FALSE);
159 %	return (TRUE);
160 %}
161 %
162 %bool_t
163 %xdr_utmpidleptr(XDR *xdrs, struct utmpidle **objpp)
164 %{
165 %	if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct utmpidle),
166 %	    xdr_utmpidle))
167 %		return (FALSE);
168 %	return (TRUE);
169 %}
170 %
171 %bool_t
172 %xdr_utmpidlearr(XDR *xdrs, struct utmpidlearr *objp)
173 %{
174 %	if (!xdr_array(xdrs, (char **)&objp->uia_arr, (u_int *)&objp->uia_cnt,
175 %	    MAXUSERS, sizeof(struct utmpidle *), xdr_utmpidleptr))
176 %		return (FALSE);
177 %	return (TRUE);
178 %}
179 #endif
180