nss.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /* Copyright (C) 1996-2021 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /* Define interface to NSS. This is meant for the interface functions
  15. and for implementors of new services. */
  16. #ifndef _NSS_H
  17. #define _NSS_H 1
  18. #include <features.h>
  19. #include <stddef.h>
  20. #include <stdint.h>
  21. #include <sys/types.h>
  22. __BEGIN_DECLS
  23. /* Possible results of lookup using a nss_* function. */
  24. enum nss_status
  25. {
  26. NSS_STATUS_TRYAGAIN = -2,
  27. NSS_STATUS_UNAVAIL,
  28. NSS_STATUS_NOTFOUND,
  29. NSS_STATUS_SUCCESS,
  30. NSS_STATUS_RETURN
  31. };
  32. /* Data structure used for the 'gethostbyname4_r' function. */
  33. struct gaih_addrtuple
  34. {
  35. struct gaih_addrtuple *next;
  36. char *name;
  37. int family;
  38. uint32_t addr[4];
  39. uint32_t scopeid;
  40. };
  41. /* Overwrite service selection for database DBNAME using specification
  42. in STRING.
  43. This function should only be used by system programs which have to
  44. work around non-existing services (e.e., while booting).
  45. Attention: Using this function repeatedly will slowly eat up the
  46. whole memory since previous selection data cannot be freed. */
  47. extern int __nss_configure_lookup (const char *__dbname,
  48. const char *__string) __THROW;
  49. /* NSS-related types. */
  50. struct __netgrent;
  51. struct aliasent;
  52. struct ether_addr;
  53. struct etherent;
  54. struct group;
  55. struct hostent;
  56. struct netent;
  57. struct passwd;
  58. struct protoent;
  59. struct rpcent;
  60. struct servent;
  61. struct sgrp;
  62. struct spwd;
  63. struct traced_file;
  64. /* Types of functions exported from NSS service modules. */
  65. typedef enum nss_status nss_endaliasent (void);
  66. typedef enum nss_status nss_endetherent (void);
  67. typedef enum nss_status nss_endgrent (void);
  68. typedef enum nss_status nss_endhostent (void);
  69. typedef enum nss_status nss_endnetent (void);
  70. typedef enum nss_status nss_endnetgrent (struct __netgrent *);
  71. typedef enum nss_status nss_endprotoent (void);
  72. typedef enum nss_status nss_endpwent (void);
  73. typedef enum nss_status nss_endrpcent (void);
  74. typedef enum nss_status nss_endservent (void);
  75. typedef enum nss_status nss_endsgent (void);
  76. typedef enum nss_status nss_endspent (void);
  77. typedef enum nss_status nss_getaliasbyname_r (const char *, struct aliasent *,
  78. char *, size_t, int *);
  79. typedef enum nss_status nss_getaliasent_r (struct aliasent *,
  80. char *, size_t, int *);
  81. typedef enum nss_status nss_getcanonname_r (const char *, char *, size_t,
  82. char **, int *, int *);
  83. typedef enum nss_status nss_getetherent_r (struct etherent *,
  84. char *, size_t, int *);
  85. typedef enum nss_status nss_getgrent_r (struct group *, char *, size_t, int *);
  86. typedef enum nss_status nss_getgrgid_r (__gid_t, struct group *,
  87. char *, size_t, int *);
  88. typedef enum nss_status nss_getgrnam_r (const char *, struct group *,
  89. char *, size_t, int *);
  90. typedef enum nss_status nss_gethostbyaddr2_r (const void *, __socklen_t, int,
  91. struct hostent *, char *, size_t,
  92. int *, int *, int32_t *);
  93. typedef enum nss_status nss_gethostbyaddr_r (const void *, __socklen_t, int,
  94. struct hostent *, char *, size_t,
  95. int *, int *);
  96. typedef enum nss_status nss_gethostbyname2_r (const char *, int,
  97. struct hostent *, char *, size_t,
  98. int *, int *);
  99. typedef enum nss_status nss_gethostbyname3_r (const char *, int,
  100. struct hostent *, char *, size_t,
  101. int *, int *, int32_t *,
  102. char **);
  103. typedef enum nss_status nss_gethostbyname4_r (const char *,
  104. struct gaih_addrtuple **,
  105. char *, size_t,
  106. int *, int *, int32_t *);
  107. typedef enum nss_status nss_gethostbyname_r (const char *, struct hostent *,
  108. char *, size_t, int *, int *);
  109. typedef enum nss_status nss_gethostent_r (struct hostent *, char *, size_t,
  110. int *, int *);
  111. typedef enum nss_status nss_gethostton_r (const char *, struct etherent *,
  112. char *, size_t, int *);
  113. typedef enum nss_status nss_getnetbyaddr_r (uint32_t, int, struct netent *,
  114. char *, size_t, int *, int *);
  115. typedef enum nss_status nss_getnetbyname_r (const char *, struct netent *,
  116. char *, size_t, int *, int *);
  117. typedef enum nss_status nss_getnetent_r (struct netent *,
  118. char *, size_t, int *, int *);
  119. typedef enum nss_status nss_getnetgrent_r (struct __netgrent *,
  120. char *, size_t, int *);
  121. typedef enum nss_status nss_getntohost_r (const struct ether_addr *,
  122. struct etherent *, char *, size_t,
  123. int *);
  124. typedef enum nss_status nss_getprotobyname_r (const char *, struct protoent *,
  125. char *, size_t, int *);
  126. typedef enum nss_status nss_getprotobynumber_r (int, struct protoent *,
  127. char *, size_t, int *);
  128. typedef enum nss_status nss_getprotoent_r (struct protoent *,
  129. char *, size_t, int *);
  130. typedef enum nss_status nss_getpublickey (const char *, char *, int *);
  131. typedef enum nss_status nss_getpwent_r (struct passwd *,
  132. char *, size_t, int *);
  133. typedef enum nss_status nss_getpwnam_r (const char *, struct passwd *,
  134. char *, size_t, int *);
  135. typedef enum nss_status nss_getpwuid_r (__uid_t, struct passwd *,
  136. char *, size_t, int *);
  137. typedef enum nss_status nss_getrpcbyname_r (const char *, struct rpcent *,
  138. char *, size_t, int *);
  139. typedef enum nss_status nss_getrpcbynumber_r (int, struct rpcent *,
  140. char *, size_t, int *);
  141. typedef enum nss_status nss_getrpcent_r (struct rpcent *,
  142. char *, size_t, int *);
  143. typedef enum nss_status nss_getsecretkey (const char *, char *, char *, int *);
  144. typedef enum nss_status nss_getservbyname_r (const char *, const char *,
  145. struct servent *, char *, size_t,
  146. int *);
  147. typedef enum nss_status nss_getservbyport_r (int, const char *,
  148. struct servent *, char *, size_t,
  149. int *);
  150. typedef enum nss_status nss_getservent_r (struct servent *, char *, size_t,
  151. int *);
  152. typedef enum nss_status nss_getsgent_r (struct sgrp *, char *, size_t, int *);
  153. typedef enum nss_status nss_getsgnam_r (const char *, struct sgrp *,
  154. char *, size_t, int *);
  155. typedef enum nss_status nss_getspent_r (struct spwd *, char *, size_t, int *);
  156. typedef enum nss_status nss_getspnam_r (const char *, struct spwd *,
  157. char *, size_t, int *);
  158. typedef void nss_init (void (*) (size_t, struct traced_file *));
  159. typedef enum nss_status nss_initgroups_dyn (const char *, __gid_t, long int *,
  160. long int *, __gid_t **, long int,
  161. int *);
  162. typedef enum nss_status nss_netname2user (char [], __uid_t *, __gid_t *,
  163. int *, __gid_t *, int *);
  164. typedef enum nss_status nss_setaliasent (void);
  165. typedef enum nss_status nss_setetherent (int);
  166. typedef enum nss_status nss_setgrent (int);
  167. typedef enum nss_status nss_sethostent (int);
  168. typedef enum nss_status nss_setnetent (int);
  169. typedef enum nss_status nss_setnetgrent (const char *, struct __netgrent *);
  170. typedef enum nss_status nss_setprotoent (int);
  171. typedef enum nss_status nss_setpwent (int);
  172. typedef enum nss_status nss_setrpcent (int);
  173. typedef enum nss_status nss_setservent (int);
  174. typedef enum nss_status nss_setsgent (int);
  175. typedef enum nss_status nss_setspent (int);
  176. /* Declare all NSS functions for MODULE. */
  177. #define NSS_DECLARE_MODULE_FUNCTIONS(module) \
  178. extern nss_endaliasent _nss_##module##_endaliasent; \
  179. extern nss_endetherent _nss_##module##_endetherent; \
  180. extern nss_endgrent _nss_##module##_endgrent; \
  181. extern nss_endhostent _nss_##module##_endhostent; \
  182. extern nss_endnetent _nss_##module##_endnetent; \
  183. extern nss_endnetgrent _nss_##module##__endnetgrent; \
  184. extern nss_endprotoent _nss_##module##_endprotoent; \
  185. extern nss_endpwent _nss_##module##_endpwent; \
  186. extern nss_endrpcent _nss_##module##_endrpcent; \
  187. extern nss_endservent _nss_##module##_endservent; \
  188. extern nss_endsgent _nss_##module##_endsgent; \
  189. extern nss_endspent _nss_##module##_endspent; \
  190. extern nss_getaliasbyname_r _nss_##module##_getaliasbyname_r; \
  191. extern nss_getaliasent_r _nss_##module##_getaliasent_r; \
  192. extern nss_getcanonname_r _nss_##module##_getcanonname_r; \
  193. extern nss_getetherent_r _nss_##module##_getetherent_r; \
  194. extern nss_getgrent_r _nss_##module##_getgrent_r; \
  195. extern nss_getgrgid_r _nss_##module##_getgrgid_r; \
  196. extern nss_getgrnam_r _nss_##module##_getgrnam_r; \
  197. extern nss_gethostbyaddr2_r _nss_##module##_gethostbyaddr2_r; \
  198. extern nss_gethostbyaddr_r _nss_##module##_gethostbyaddr_r; \
  199. extern nss_gethostbyname2_r _nss_##module##_gethostbyname2_r; \
  200. extern nss_gethostbyname3_r _nss_##module##_gethostbyname3_r; \
  201. extern nss_gethostbyname4_r _nss_##module##_gethostbyname4_r; \
  202. extern nss_gethostbyname_r _nss_##module##_gethostbyname_r; \
  203. extern nss_gethostent_r _nss_##module##_gethostent_r; \
  204. extern nss_gethostton_r _nss_##module##_gethostton_r; \
  205. extern nss_getnetbyaddr_r _nss_##module##_getnetbyaddr_r; \
  206. extern nss_getnetbyname_r _nss_##module##_getnetbyname_r; \
  207. extern nss_getnetent_r _nss_##module##_getnetent_r; \
  208. extern nss_getnetgrent_r _nss_##module##_getnetgrent_r; \
  209. extern nss_getntohost_r _nss_##module##_getntohost_r; \
  210. extern nss_getprotobyname_r _nss_##module##_getprotobyname_r; \
  211. extern nss_getprotobynumber_r _nss_##module##_getprotobynumber_r; \
  212. extern nss_getprotoent_r _nss_##module##_getprotoent_r; \
  213. extern nss_getpublickey _nss_##module##_getpublickey; \
  214. extern nss_getpwent_r _nss_##module##_getpwent_r; \
  215. extern nss_getpwnam_r _nss_##module##_getpwnam_r; \
  216. extern nss_getpwuid_r _nss_##module##_getpwuid_r; \
  217. extern nss_getrpcbyname_r _nss_##module##_getrpcbyname_r; \
  218. extern nss_getrpcbynumber_r _nss_##module##_getrpcbynumber_r; \
  219. extern nss_getrpcent_r _nss_##module##_getrpcent_r; \
  220. extern nss_getsecretkey _nss_##module##_getsecretkey; \
  221. extern nss_getservbyname_r _nss_##module##_getservbyname_r; \
  222. extern nss_getservbyport_r _nss_##module##_getservbyport_r; \
  223. extern nss_getservent_r _nss_##module##_getservent_r; \
  224. extern nss_getsgent_r _nss_##module##_getsgent_r; \
  225. extern nss_getsgnam_r _nss_##module##_getsgnam_r; \
  226. extern nss_getspent_r _nss_##module##_getspent_r; \
  227. extern nss_getspnam_r _nss_##module##_getspnam_r; \
  228. extern nss_init _nss_##module##_init; \
  229. extern nss_initgroups_dyn _nss_##module##_initgroups_dyn; \
  230. extern nss_netname2user _nss_##module##_netname2user; \
  231. extern nss_setaliasent _nss_##module##_setaliasent; \
  232. extern nss_setetherent _nss_##module##_setetherent; \
  233. extern nss_setgrent _nss_##module##_setgrent; \
  234. extern nss_sethostent _nss_##module##_sethostent; \
  235. extern nss_setnetent _nss_##module##_setnetent; \
  236. extern nss_setnetgrent _nss_##module##_setnetgrent; \
  237. extern nss_setprotoent _nss_##module##_setprotoent; \
  238. extern nss_setpwent _nss_##module##_setpwent; \
  239. extern nss_setrpcent _nss_##module##_setrpcent; \
  240. extern nss_setservent _nss_##module##_setservent; \
  241. extern nss_setsgent _nss_##module##_setsgent; \
  242. extern nss_setspent _nss_##module##_setspent; \
  243. __END_DECLS
  244. #endif /* nss.h */