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