rusers.x 5.7 KB

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