udev: String substitutions can be done in ENV, too
[systemd_ALT.git] / src / basic / nss-util.h
blob579e2c0bded657c0673f906cc76e5f805f17b402
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
4 #include <grp.h>
5 #include <netdb.h>
6 #include <nss.h>
7 #include <pwd.h>
8 #include <resolv.h>
10 #define NSS_SIGNALS_BLOCK SIGALRM,SIGVTALRM,SIGPIPE,SIGCHLD,SIGTSTP,SIGIO,SIGHUP,SIGUSR1,SIGUSR2,SIGPROF,SIGURG,SIGWINCH
12 #ifndef DEPRECATED_RES_USE_INET6
13 # define DEPRECATED_RES_USE_INET6 0x00002000
14 #endif
16 #define NSS_GETHOSTBYNAME_PROTOTYPES(module) \
17 enum 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_; \
23 enum 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_; \
31 enum 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_; \
37 enum 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_
43 #define NSS_GETHOSTBYADDR_PROTOTYPES(module) \
44 enum 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_; \
51 enum 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_
58 #define NSS_GETHOSTBYNAME_FALLBACKS(module) \
59 enum 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 } \
74 enum 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) { \
79 enum nss_status ret = NSS_STATUS_NOTFOUND; \
81 if (_res.options & DEPRECATED_RES_USE_INET6) \
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( \
92 name, \
93 AF_INET, \
94 host, \
95 buffer, buflen, \
96 errnop, h_errnop, \
97 NULL, \
98 NULL); \
99 return ret; \
102 #define NSS_GETHOSTBYADDR_FALLBACKS(module) \
103 enum 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); \
118 #define NSS_GETPW_PROTOTYPES(module) \
119 enum nss_status _nss_##module##_getpwnam_r( \
120 const char *name, \
121 struct passwd *pwd, \
122 char *buffer, size_t buflen, \
123 int *errnop) _public_; \
124 enum nss_status _nss_##module##_getpwuid_r( \
125 uid_t uid, \
126 struct passwd *pwd, \
127 char *buffer, size_t buflen, \
128 int *errnop) _public_
130 #define NSS_GETSP_PROTOTYPES(module) \
131 enum nss_status _nss_##module##_getspnam_r( \
132 const char *name, \
133 struct spwd *spwd, \
134 char *buffer, size_t buflen, \
135 int *errnop) _public_
137 #define NSS_GETSG_PROTOTYPES(module) \
138 enum nss_status _nss_##module##_getsgnam_r( \
139 const char *name, \
140 struct sgrp *sgrp, \
141 char *buffer, size_t buflen, \
142 int *errnop) _public_
144 #define NSS_GETGR_PROTOTYPES(module) \
145 enum nss_status _nss_##module##_getgrnam_r( \
146 const char *name, \
147 struct group *gr, \
148 char *buffer, size_t buflen, \
149 int *errnop) _public_; \
150 enum nss_status _nss_##module##_getgrgid_r( \
151 gid_t gid, \
152 struct group *gr, \
153 char *buffer, size_t buflen, \
154 int *errnop) _public_
156 #define NSS_PWENT_PROTOTYPES(module) \
157 enum nss_status _nss_##module##_endpwent( \
158 void) _public_; \
159 enum nss_status _nss_##module##_setpwent( \
160 int stayopen) _public_; \
161 enum nss_status _nss_##module##_getpwent_r( \
162 struct passwd *result, \
163 char *buffer, \
164 size_t buflen, \
165 int *errnop) _public_;
167 #define NSS_SPENT_PROTOTYPES(module) \
168 enum nss_status _nss_##module##_endspent( \
169 void) _public_; \
170 enum nss_status _nss_##module##_setspent( \
171 int stayopen) _public_; \
172 enum nss_status _nss_##module##_getspent_r( \
173 struct spwd *spwd, \
174 char *buffer, \
175 size_t buflen, \
176 int *errnop) _public_;
178 #define NSS_GRENT_PROTOTYPES(module) \
179 enum nss_status _nss_##module##_endgrent( \
180 void) _public_; \
181 enum nss_status _nss_##module##_setgrent( \
182 int stayopen) _public_; \
183 enum nss_status _nss_##module##_getgrent_r( \
184 struct group *result, \
185 char *buffer, \
186 size_t buflen, \
187 int *errnop) _public_;
189 #define NSS_SGENT_PROTOTYPES(module) \
190 enum nss_status _nss_##module##_endsgent( \
191 void) _public_; \
192 enum nss_status _nss_##module##_setsgent( \
193 int stayopen) _public_; \
194 enum nss_status _nss_##module##_getsgent_r( \
195 struct sgrp *sgrp, \
196 char *buffer, \
197 size_t buflen, \
198 int *errnop) _public_;
200 #define NSS_INITGROUPS_PROTOTYPE(module) \
201 enum nss_status _nss_##module##_initgroups_dyn( \
202 const char *user, \
203 gid_t group, \
204 long int *start, \
205 long int *size, \
206 gid_t **groupsp, \
207 long int limit, \
208 int *errnop) _public_;
210 typedef enum nss_status (*_nss_gethostbyname4_r_t)(
211 const char *name,
212 struct gaih_addrtuple **pat,
213 char *buffer, size_t buflen,
214 int *errnop, int *h_errnop,
215 int32_t *ttlp);
217 typedef enum nss_status (*_nss_gethostbyname3_r_t)(
218 const char *name,
219 int af,
220 struct hostent *result,
221 char *buffer, size_t buflen,
222 int *errnop, int *h_errnop,
223 int32_t *ttlp,
224 char **canonp);
226 typedef enum nss_status (*_nss_gethostbyname2_r_t)(
227 const char *name,
228 int af,
229 struct hostent *result,
230 char *buffer, size_t buflen,
231 int *errnop, int *h_errnop);
233 typedef enum nss_status (*_nss_gethostbyname_r_t)(
234 const char *name,
235 struct hostent *result,
236 char *buffer, size_t buflen,
237 int *errnop, int *h_errnop);
239 typedef enum nss_status (*_nss_gethostbyaddr2_r_t)(
240 const void* addr, socklen_t len,
241 int af,
242 struct hostent *result,
243 char *buffer, size_t buflen,
244 int *errnop, int *h_errnop,
245 int32_t *ttlp);
246 typedef enum nss_status (*_nss_gethostbyaddr_r_t)(
247 const void* addr, socklen_t len,
248 int af,
249 struct hostent *host,
250 char *buffer, size_t buflen,
251 int *errnop, int *h_errnop);
253 typedef enum nss_status (*_nss_getpwnam_r_t)(
254 const char *name,
255 struct passwd *pwd,
256 char *buffer, size_t buflen,
257 int *errnop);
258 typedef enum nss_status (*_nss_getpwuid_r_t)(
259 uid_t uid,
260 struct passwd *pwd,
261 char *buffer, size_t buflen,
262 int *errnop);
264 typedef enum nss_status (*_nss_getgrnam_r_t)(
265 const char *name,
266 struct group *gr,
267 char *buffer, size_t buflen,
268 int *errnop);
269 typedef enum nss_status (*_nss_getgrgid_r_t)(
270 gid_t gid,
271 struct group *gr,
272 char *buffer, size_t buflen,
273 int *errnop);