1 /* $OpenBSD: rnusers.x,v 1.14 2010/09/01 14:43:34 millert Exp $ */ 2 3 /* 4 * Copyright (c) 2010, Oracle America, Inc. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above 13 * copyright notice, this list of conditions and the following 14 * disclaimer in the documentation and/or other materials 15 * provided with the distribution. 16 * * Neither the name of the "Oracle America, Inc." nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 /* 35 * Find out about remote users 36 */ 37 38 #ifndef RPC_HDR 39 #endif 40 41 42 #ifdef RPC_HDR 43 %/* 44 % * The following structures are used by version 2 of the rusersd protocol. 45 % * They were not developed with rpcgen, so they do not appear as RPCL. 46 % */ 47 % 48 %#define RUSERSVERS_ORIG 1 /* original version */ 49 %#define RUSERSVERS_IDLE 2 50 %#define MAXUSERS 100 51 % 52 %/* 53 % * This is the structure used in version 2 of the rusersd RPC service. 54 % * It corresponds to the utmp structure for BSD sytems. 55 % */ 56 % 57 %#define RNUSERS_MAXUSERLEN 8 58 %#define RNUSERS_MAXLINELEN 8 59 %#define RNUSERS_MAXHOSTLEN 16 60 % 61 %struct ru_utmp { 62 % char *ut_line; /* tty name */ 63 % char *ut_name; /* user id */ 64 % char *ut_host; /* host name, if remote */ 65 % int ut_time; /* time on */ 66 %}; 67 %typedef struct ru_utmp rutmp; 68 % 69 %struct utmparr { 70 % struct ru_utmp **uta_arr; 71 % int uta_cnt; 72 %}; 73 %typedef struct utmparr utmparr; 74 %int xdr_utmparr(XDR *, struct utmparr *); 75 % 76 %struct utmpidle { 77 % struct ru_utmp ui_utmp; 78 % unsigned ui_idle; 79 %}; 80 % 81 %struct utmpidlearr { 82 % struct utmpidle **uia_arr; 83 % int uia_cnt; 84 %}; 85 %typedef struct utmpidlearr utmpidlearr; 86 %int xdr_utmpidlearr(XDR *, struct utmpidlearr *); 87 % 88 %#define RUSERSVERS_1 ((u_long)1) 89 %#define RUSERSVERS_2 ((u_long)2) 90 %#ifndef RUSERSPROG 91 %#define RUSERSPROG ((u_long)100002) 92 %#endif 93 %#ifndef RUSERSPROC_NUM 94 %#define RUSERSPROC_NUM ((u_long)1) 95 %#endif 96 %#ifndef RUSERSPROC_NAMES 97 %#define RUSERSPROC_NAMES ((u_long)2) 98 %#endif 99 %#ifndef RUSERSPROC_ALLNAMES 100 %#define RUSERSPROC_ALLNAMES ((u_long)3) 101 %#endif 102 % 103 #endif /* RPC_HDR */ 104 105 #ifdef RPC_XDR 106 %bool_t xdr_utmp(XDR *, struct ru_utmp *); 107 %bool_t xdr_utmpptr(XDR *, struct ru_utmp **); 108 %bool_t xdr_utmparr(XDR *, struct utmparr *); 109 %bool_t xdr_utmpidle(XDR *, struct utmpidle *); 110 %bool_t xdr_utmpidleptr(XDR *, struct utmpidle **); 111 % 112 %bool_t 113 %xdr_utmp(XDR *xdrs, struct ru_utmp *objp) 114 %{ 115 % int size; 116 % 117 % size = RNUSERS_MAXLINELEN; 118 % if (!xdr_bytes(xdrs, &objp->ut_line, &size, RNUSERS_MAXLINELEN)) 119 % return (FALSE); 120 % size = RNUSERS_MAXUSERLEN; 121 % if (!xdr_bytes(xdrs, &objp->ut_name, &size, RNUSERS_MAXUSERLEN)) 122 % return (FALSE); 123 % size = RNUSERS_MAXHOSTLEN; 124 % if (!xdr_bytes(xdrs, &objp->ut_host, &size, RNUSERS_MAXHOSTLEN)) 125 % return (FALSE); 126 % if (!xdr_int(xdrs, &objp->ut_time)) 127 % return (FALSE); 128 % return (TRUE); 129 %} 130 % 131 %bool_t 132 %xdr_utmpptr(XDR *xdrs, struct ru_utmp **objpp) 133 %{ 134 % if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct ru_utmp), 135 % xdr_utmp)) 136 % return (FALSE); 137 % return (TRUE); 138 %} 139 % 140 %bool_t 141 %xdr_utmparr(XDR *xdrs, struct utmparr *objp) 142 %{ 143 % if (!xdr_array(xdrs, (char **)&objp->uta_arr, (u_int *)&objp->uta_cnt, 144 % MAXUSERS, sizeof(struct ru_utmp *), xdr_utmpptr)) 145 % return (FALSE); 146 % return (TRUE); 147 %} 148 % 149 %bool_t 150 %xdr_utmpidle(XDR *xdrs, struct utmpidle *objp) 151 %{ 152 % if (!xdr_utmp(xdrs, &objp->ui_utmp)) 153 % return (FALSE); 154 % if (!xdr_u_int(xdrs, &objp->ui_idle)) 155 % return (FALSE); 156 % return (TRUE); 157 %} 158 % 159 %bool_t 160 %xdr_utmpidleptr(XDR *xdrs, struct utmpidle **objpp) 161 %{ 162 % if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct utmpidle), 163 % xdr_utmpidle)) 164 % return (FALSE); 165 % return (TRUE); 166 %} 167 % 168 %bool_t 169 %xdr_utmpidlearr(XDR *xdrs, struct utmpidlearr *objp) 170 %{ 171 % if (!xdr_array(xdrs, (char **)&objp->uia_arr, (u_int *)&objp->uia_cnt, 172 % MAXUSERS, sizeof(struct utmpidle *), xdr_utmpidleptr)) 173 % return (FALSE); 174 % return (TRUE); 175 %} 176 #endif 177