]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/nss-util.h
Merge pull request #18990 from yuwata/network-dhcpv6-use-domains
[thirdparty/systemd.git] / src / basic / nss-util.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
c9fdc26e
LP
2#pragma once
3
71d35b6b 4#include <grp.h>
c9fdc26e 5#include <netdb.h>
71d35b6b 6#include <nss.h>
c01ff965 7#include <pwd.h>
71d35b6b 8#include <resolv.h>
c01ff965 9
0c5eb056
LP
10#define NSS_SIGNALS_BLOCK SIGALRM,SIGVTALRM,SIGPIPE,SIGCHLD,SIGTSTP,SIGIO,SIGHUP,SIGUSR1,SIGUSR2,SIGPROF,SIGURG,SIGWINCH
11
6154d33d
ZJS
12#ifndef DEPRECATED_RES_USE_INET6
13# define DEPRECATED_RES_USE_INET6 0x00002000
14#endif
15
c9fdc26e
LP
16#define NSS_GETHOSTBYNAME_PROTOTYPES(module) \
17enum nss_status _nss_##module##_gethostbyname4_r( \
18 const char *name, \
19 struct gaih_addrtuple **pat, \
20 char *buffer, size_t buflen, \
21 int *errnop, int *h_errnop, \
22 int32_t *ttlp) _public_; \
23enum nss_status _nss_##module##_gethostbyname3_r( \
24 const char *name, \
25 int af, \
26 struct hostent *host, \
27 char *buffer, size_t buflen, \
28 int *errnop, int *h_errnop, \
29 int32_t *ttlp, \
30 char **canonp) _public_; \
31enum nss_status _nss_##module##_gethostbyname2_r( \
32 const char *name, \
33 int af, \
34 struct hostent *host, \
35 char *buffer, size_t buflen, \
36 int *errnop, int *h_errnop) _public_; \
37enum nss_status _nss_##module##_gethostbyname_r( \
38 const char *name, \
39 struct hostent *host, \
40 char *buffer, size_t buflen, \
41 int *errnop, int *h_errnop) _public_
42
43#define NSS_GETHOSTBYADDR_PROTOTYPES(module) \
44enum nss_status _nss_##module##_gethostbyaddr2_r( \
45 const void* addr, socklen_t len, \
46 int af, \
47 struct hostent *host, \
48 char *buffer, size_t buflen, \
49 int *errnop, int *h_errnop, \
50 int32_t *ttlp) _public_; \
51enum nss_status _nss_##module##_gethostbyaddr_r( \
52 const void* addr, socklen_t len, \
53 int af, \
54 struct hostent *host, \
55 char *buffer, size_t buflen, \
56 int *errnop, int *h_errnop) _public_
57
58#define NSS_GETHOSTBYNAME_FALLBACKS(module) \
59enum nss_status _nss_##module##_gethostbyname2_r( \
60 const char *name, \
61 int af, \
62 struct hostent *host, \
63 char *buffer, size_t buflen, \
64 int *errnop, int *h_errnop) { \
65 return _nss_##module##_gethostbyname3_r( \
66 name, \
67 af, \
68 host, \
69 buffer, buflen, \
70 errnop, h_errnop, \
71 NULL, \
72 NULL); \
73} \
74enum nss_status _nss_##module##_gethostbyname_r( \
75 const char *name, \
76 struct hostent *host, \
77 char *buffer, size_t buflen, \
78 int *errnop, int *h_errnop) { \
ea30eb86
LP
79 enum nss_status ret = NSS_STATUS_NOTFOUND; \
80 \
6154d33d 81 if (_res.options & DEPRECATED_RES_USE_INET6) \
ea30eb86
LP
82 ret = _nss_##module##_gethostbyname3_r( \
83 name, \
84 AF_INET6, \
85 host, \
86 buffer, buflen, \
87 errnop, h_errnop, \
88 NULL, \
89 NULL); \
90 if (ret == NSS_STATUS_NOTFOUND) \
91 ret = _nss_##module##_gethostbyname3_r( \
c9fdc26e 92 name, \
ea30eb86 93 AF_INET, \
c9fdc26e
LP
94 host, \
95 buffer, buflen, \
96 errnop, h_errnop, \
97 NULL, \
98 NULL); \
ea30eb86 99 return ret; \
f6a8265b 100}
c9fdc26e
LP
101
102#define NSS_GETHOSTBYADDR_FALLBACKS(module) \
103enum nss_status _nss_##module##_gethostbyaddr_r( \
104 const void* addr, socklen_t len, \
105 int af, \
106 struct hostent *host, \
107 char *buffer, size_t buflen, \
108 int *errnop, int *h_errnop) { \
109 return _nss_##module##_gethostbyaddr2_r( \
110 addr, len, \
111 af, \
112 host, \
113 buffer, buflen, \
114 errnop, h_errnop, \
115 NULL); \
f6a8265b 116}
c01ff965
LP
117
118#define NSS_GETPW_PROTOTYPES(module) \
119enum nss_status _nss_##module##_getpwnam_r( \
120 const char *name, \
121 struct passwd *pwd, \
122 char *buffer, size_t buflen, \
123 int *errnop) _public_; \
c0f81393 124enum nss_status _nss_##module##_getpwuid_r( \
c01ff965
LP
125 uid_t uid, \
126 struct passwd *pwd, \
127 char *buffer, size_t buflen, \
128 int *errnop) _public_
129
130#define NSS_GETGR_PROTOTYPES(module) \
131enum nss_status _nss_##module##_getgrnam_r( \
132 const char *name, \
133 struct group *gr, \
134 char *buffer, size_t buflen, \
135 int *errnop) _public_; \
136enum nss_status _nss_##module##_getgrgid_r( \
137 gid_t gid, \
138 struct group *gr, \
139 char *buffer, size_t buflen, \
140 int *errnop) _public_
cf2d43e7 141
2ee4b118
LP
142#define NSS_PWENT_PROTOTYPES(module) \
143enum nss_status _nss_##module##_endpwent( \
144 void) _public_; \
145enum nss_status _nss_##module##_setpwent( \
146 int stayopen) _public_; \
147enum nss_status _nss_##module##_getpwent_r( \
148 struct passwd *result, \
149 char *buffer, \
150 size_t buflen, \
151 int *errnop) _public_;
152
153#define NSS_GRENT_PROTOTYPES(module) \
154enum nss_status _nss_##module##_endgrent( \
155 void) _public_; \
156enum nss_status _nss_##module##_setgrent( \
157 int stayopen) _public_; \
158enum nss_status _nss_##module##_getgrent_r( \
159 struct group *result, \
160 char *buffer, \
161 size_t buflen, \
162 int *errnop) _public_;
163
164#define NSS_INITGROUPS_PROTOTYPE(module) \
165enum nss_status _nss_##module##_initgroups_dyn( \
166 const char *user, \
167 gid_t group, \
168 long int *start, \
169 long int *size, \
170 gid_t **groupsp, \
171 long int limit, \
172 int *errnop) _public_;
173
cf2d43e7
ZJS
174typedef enum nss_status (*_nss_gethostbyname4_r_t)(
175 const char *name,
176 struct gaih_addrtuple **pat,
177 char *buffer, size_t buflen,
178 int *errnop, int *h_errnop,
179 int32_t *ttlp);
180
181typedef enum nss_status (*_nss_gethostbyname3_r_t)(
182 const char *name,
183 int af,
184 struct hostent *result,
185 char *buffer, size_t buflen,
186 int *errnop, int *h_errnop,
187 int32_t *ttlp,
188 char **canonp);
189
2abb5b3b
ZJS
190typedef enum nss_status (*_nss_gethostbyname2_r_t)(
191 const char *name,
192 int af,
193 struct hostent *result,
194 char *buffer, size_t buflen,
195 int *errnop, int *h_errnop);
196
197typedef enum nss_status (*_nss_gethostbyname_r_t)(
198 const char *name,
199 struct hostent *result,
200 char *buffer, size_t buflen,
201 int *errnop, int *h_errnop);
202
cf2d43e7
ZJS
203typedef enum nss_status (*_nss_gethostbyaddr2_r_t)(
204 const void* addr, socklen_t len,
205 int af,
206 struct hostent *result,
207 char *buffer, size_t buflen,
208 int *errnop, int *h_errnop,
209 int32_t *ttlp);
2abb5b3b
ZJS
210typedef enum nss_status (*_nss_gethostbyaddr_r_t)(
211 const void* addr, socklen_t len,
212 int af,
213 struct hostent *host,
214 char *buffer, size_t buflen,
215 int *errnop, int *h_errnop);
f0d12668
ZJS
216
217typedef enum nss_status (*_nss_getpwnam_r_t)(
218 const char *name,
219 struct passwd *pwd,
220 char *buffer, size_t buflen,
221 int *errnop);
222typedef enum nss_status (*_nss_getpwuid_r_t)(
223 uid_t uid,
224 struct passwd *pwd,
225 char *buffer, size_t buflen,
226 int *errnop);
227
228typedef enum nss_status (*_nss_getgrnam_r_t)(
229 const char *name,
230 struct group *gr,
231 char *buffer, size_t buflen,
232 int *errnop);
233typedef enum nss_status (*_nss_getgrgid_r_t)(
234 gid_t gid,
235 struct group *gr,
236 char *buffer, size_t buflen,
237 int *errnop);