rusers.x 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. const RUSERS_MAXUSERLEN = 32;
  33. const RUSERS_MAXLINELEN = 32;
  34. const RUSERS_MAXHOSTLEN = 257;
  35. struct rusers_utmp {
  36. string ut_user<RUSERS_MAXUSERLEN>; /* aka ut_name */
  37. string ut_line<RUSERS_MAXLINELEN>; /* device */
  38. string ut_host<RUSERS_MAXHOSTLEN>; /* host user logged on from */
  39. int ut_type; /* type of entry */
  40. int ut_time; /* time entry was made */
  41. unsigned int ut_idle; /* minutes idle */
  42. };
  43. typedef rusers_utmp utmp_array<>;
  44. #ifdef RPC_HDR
  45. %
  46. %/*
  47. % * Values for ut_type field above.
  48. % */
  49. #endif
  50. const RUSERS_EMPTY = 0;
  51. const RUSERS_RUN_LVL = 1;
  52. const RUSERS_BOOT_TIME = 2;
  53. const RUSERS_OLD_TIME = 3;
  54. const RUSERS_NEW_TIME = 4;
  55. const RUSERS_INIT_PROCESS = 5;
  56. const RUSERS_LOGIN_PROCESS = 6;
  57. const RUSERS_USER_PROCESS = 7;
  58. const RUSERS_DEAD_PROCESS = 8;
  59. const RUSERS_ACCOUNTING = 9;
  60. program RUSERSPROG {
  61. version RUSERSVERS_3 {
  62. int
  63. RUSERSPROC_NUM(void) = 1;
  64. utmp_array
  65. RUSERSPROC_NAMES(void) = 2;
  66. utmp_array
  67. RUSERSPROC_ALLNAMES(void) = 3;
  68. } = 3;
  69. } = 100002;
  70. #ifdef RPC_HDR
  71. %
  72. %
  73. %#ifdef __cplusplus
  74. %extern "C" {
  75. %#endif
  76. %
  77. %#include <rpc/xdr.h>
  78. %
  79. %/*
  80. % * The following structures are used by version 2 of the rusersd protocol.
  81. % * They were not developed with rpcgen, so they do not appear as RPCL.
  82. % */
  83. %
  84. %#define RUSERSVERS_IDLE 2
  85. %#define RUSERSVERS 3 /* current version */
  86. %#define MAXUSERS 100
  87. %
  88. %/*
  89. % * This is the structure used in version 2 of the rusersd RPC service.
  90. % * It corresponds to the utmp structure for BSD systems.
  91. % */
  92. %struct ru_utmp {
  93. % char ut_line[8]; /* tty name */
  94. % char ut_name[8]; /* user id */
  95. % char ut_host[16]; /* host name, if remote */
  96. % long int ut_time; /* time on */
  97. %};
  98. %
  99. %struct utmparr {
  100. % struct ru_utmp **uta_arr;
  101. % int uta_cnt;
  102. %};
  103. %typedef struct utmparr utmparr;
  104. %
  105. %extern bool_t xdr_utmparr (XDR *xdrs, struct utmparr *objp) __THROW;
  106. %
  107. %struct utmpidle {
  108. % struct ru_utmp ui_utmp;
  109. % unsigned int ui_idle;
  110. %};
  111. %
  112. %struct utmpidlearr {
  113. % struct utmpidle **uia_arr;
  114. % int uia_cnt;
  115. %};
  116. %
  117. %extern bool_t xdr_utmpidlearr (XDR *xdrs, struct utmpidlearr *objp) __THROW;
  118. %
  119. %#ifdef __cplusplus
  120. %}
  121. %#endif
  122. #endif
  123. #ifdef RPC_XDR
  124. %bool_t xdr_utmp (XDR *xdrs, struct ru_utmp *objp);
  125. %
  126. %bool_t
  127. %xdr_utmp(xdrs, objp)
  128. % XDR *xdrs;
  129. % struct ru_utmp *objp;
  130. %{
  131. % /* Since the fields are char foo [xxx], we should not free them. */
  132. % if (xdrs->x_op != XDR_FREE)
  133. % {
  134. % char *ptr;
  135. % unsigned int size;
  136. % ptr = objp->ut_line;
  137. % size = sizeof (objp->ut_line);
  138. % if (!xdr_bytes (xdrs, &ptr, &size, size)) {
  139. % return (FALSE);
  140. % }
  141. % ptr = objp->ut_name;
  142. % size = sizeof (objp->ut_name);
  143. % if (!xdr_bytes (xdrs, &ptr, &size, size)) {
  144. % return (FALSE);
  145. % }
  146. % ptr = objp->ut_host;
  147. % size = sizeof (objp->ut_host);
  148. % if (!xdr_bytes (xdrs, &ptr, &size, size)) {
  149. % return (FALSE);
  150. % }
  151. % }
  152. % if (!xdr_long(xdrs, &objp->ut_time)) {
  153. % return (FALSE);
  154. % }
  155. % return (TRUE);
  156. %}
  157. %
  158. %bool_t xdr_utmpptr(XDR *xdrs, struct ru_utmp **objpp);
  159. %
  160. %bool_t
  161. %xdr_utmpptr(xdrs, objpp)
  162. % XDR *xdrs;
  163. % struct ru_utmp **objpp;
  164. %{
  165. % if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct ru_utmp),
  166. % (xdrproc_t) xdr_utmp)) {
  167. % return (FALSE);
  168. % }
  169. % return (TRUE);
  170. %}
  171. %
  172. %bool_t
  173. %xdr_utmparr(xdrs, objp)
  174. % XDR *xdrs;
  175. % struct utmparr *objp;
  176. %{
  177. % if (!xdr_array(xdrs, (char **)&objp->uta_arr, (u_int *)&objp->uta_cnt,
  178. % MAXUSERS, sizeof(struct ru_utmp *),
  179. % (xdrproc_t) xdr_utmpptr)) {
  180. % return (FALSE);
  181. % }
  182. % return (TRUE);
  183. %}
  184. %
  185. %bool_t xdr_utmpidle(XDR *xdrs, struct utmpidle *objp);
  186. %
  187. %bool_t
  188. %xdr_utmpidle(xdrs, objp)
  189. % XDR *xdrs;
  190. % struct utmpidle *objp;
  191. %{
  192. % if (!xdr_utmp(xdrs, &objp->ui_utmp)) {
  193. % return (FALSE);
  194. % }
  195. % if (!xdr_u_int(xdrs, &objp->ui_idle)) {
  196. % return (FALSE);
  197. % }
  198. % return (TRUE);
  199. %}
  200. %
  201. %bool_t xdr_utmpidleptr(XDR *xdrs, struct utmpidle **objp);
  202. %
  203. %bool_t
  204. %xdr_utmpidleptr(xdrs, objpp)
  205. % XDR *xdrs;
  206. % struct utmpidle **objpp;
  207. %{
  208. % if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct utmpidle),
  209. % (xdrproc_t) xdr_utmpidle)) {
  210. % return (FALSE);
  211. % }
  212. % return (TRUE);
  213. %}
  214. %
  215. %bool_t
  216. %xdr_utmpidlearr(xdrs, objp)
  217. % XDR *xdrs;
  218. % struct utmpidlearr *objp;
  219. %{
  220. % if (!xdr_array(xdrs, (char **)&objp->uia_arr, (u_int *)&objp->uia_cnt,
  221. % MAXUSERS, sizeof(struct utmpidle *),
  222. % (xdrproc_t) xdr_utmpidleptr)) {
  223. % return (FALSE);
  224. % }
  225. % return (TRUE);
  226. %}
  227. #endif