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