]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c9fdc26e LP |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2014 Lennart Poettering | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
71d35b6b | 23 | #include <grp.h> |
c9fdc26e | 24 | #include <netdb.h> |
71d35b6b | 25 | #include <nss.h> |
c01ff965 | 26 | #include <pwd.h> |
71d35b6b | 27 | #include <resolv.h> |
c01ff965 | 28 | |
0c5eb056 LP |
29 | #define NSS_SIGNALS_BLOCK SIGALRM,SIGVTALRM,SIGPIPE,SIGCHLD,SIGTSTP,SIGIO,SIGHUP,SIGUSR1,SIGUSR2,SIGPROF,SIGURG,SIGWINCH |
30 | ||
6154d33d ZJS |
31 | #ifndef DEPRECATED_RES_USE_INET6 |
32 | # define DEPRECATED_RES_USE_INET6 0x00002000 | |
33 | #endif | |
34 | ||
c9fdc26e LP |
35 | #define NSS_GETHOSTBYNAME_PROTOTYPES(module) \ |
36 | enum nss_status _nss_##module##_gethostbyname4_r( \ | |
37 | const char *name, \ | |
38 | struct gaih_addrtuple **pat, \ | |
39 | char *buffer, size_t buflen, \ | |
40 | int *errnop, int *h_errnop, \ | |
41 | int32_t *ttlp) _public_; \ | |
42 | enum nss_status _nss_##module##_gethostbyname3_r( \ | |
43 | const char *name, \ | |
44 | int af, \ | |
45 | struct hostent *host, \ | |
46 | char *buffer, size_t buflen, \ | |
47 | int *errnop, int *h_errnop, \ | |
48 | int32_t *ttlp, \ | |
49 | char **canonp) _public_; \ | |
50 | enum nss_status _nss_##module##_gethostbyname2_r( \ | |
51 | const char *name, \ | |
52 | int af, \ | |
53 | struct hostent *host, \ | |
54 | char *buffer, size_t buflen, \ | |
55 | int *errnop, int *h_errnop) _public_; \ | |
56 | enum nss_status _nss_##module##_gethostbyname_r( \ | |
57 | const char *name, \ | |
58 | struct hostent *host, \ | |
59 | char *buffer, size_t buflen, \ | |
60 | int *errnop, int *h_errnop) _public_ | |
61 | ||
62 | #define NSS_GETHOSTBYADDR_PROTOTYPES(module) \ | |
63 | enum nss_status _nss_##module##_gethostbyaddr2_r( \ | |
64 | const void* addr, socklen_t len, \ | |
65 | int af, \ | |
66 | struct hostent *host, \ | |
67 | char *buffer, size_t buflen, \ | |
68 | int *errnop, int *h_errnop, \ | |
69 | int32_t *ttlp) _public_; \ | |
70 | enum nss_status _nss_##module##_gethostbyaddr_r( \ | |
71 | const void* addr, socklen_t len, \ | |
72 | int af, \ | |
73 | struct hostent *host, \ | |
74 | char *buffer, size_t buflen, \ | |
75 | int *errnop, int *h_errnop) _public_ | |
76 | ||
77 | #define NSS_GETHOSTBYNAME_FALLBACKS(module) \ | |
78 | enum nss_status _nss_##module##_gethostbyname2_r( \ | |
79 | const char *name, \ | |
80 | int af, \ | |
81 | struct hostent *host, \ | |
82 | char *buffer, size_t buflen, \ | |
83 | int *errnop, int *h_errnop) { \ | |
84 | return _nss_##module##_gethostbyname3_r( \ | |
85 | name, \ | |
86 | af, \ | |
87 | host, \ | |
88 | buffer, buflen, \ | |
89 | errnop, h_errnop, \ | |
90 | NULL, \ | |
91 | NULL); \ | |
92 | } \ | |
93 | enum nss_status _nss_##module##_gethostbyname_r( \ | |
94 | const char *name, \ | |
95 | struct hostent *host, \ | |
96 | char *buffer, size_t buflen, \ | |
97 | int *errnop, int *h_errnop) { \ | |
ea30eb86 LP |
98 | enum nss_status ret = NSS_STATUS_NOTFOUND; \ |
99 | \ | |
6154d33d | 100 | if (_res.options & DEPRECATED_RES_USE_INET6) \ |
ea30eb86 LP |
101 | ret = _nss_##module##_gethostbyname3_r( \ |
102 | name, \ | |
103 | AF_INET6, \ | |
104 | host, \ | |
105 | buffer, buflen, \ | |
106 | errnop, h_errnop, \ | |
107 | NULL, \ | |
108 | NULL); \ | |
109 | if (ret == NSS_STATUS_NOTFOUND) \ | |
110 | ret = _nss_##module##_gethostbyname3_r( \ | |
c9fdc26e | 111 | name, \ |
ea30eb86 | 112 | AF_INET, \ |
c9fdc26e LP |
113 | host, \ |
114 | buffer, buflen, \ | |
115 | errnop, h_errnop, \ | |
116 | NULL, \ | |
117 | NULL); \ | |
ea30eb86 | 118 | return ret; \ |
c01ff965 LP |
119 | } \ |
120 | struct __useless_struct_to_allow_trailing_semicolon__ | |
c9fdc26e LP |
121 | |
122 | #define NSS_GETHOSTBYADDR_FALLBACKS(module) \ | |
123 | enum nss_status _nss_##module##_gethostbyaddr_r( \ | |
124 | const void* addr, socklen_t len, \ | |
125 | int af, \ | |
126 | struct hostent *host, \ | |
127 | char *buffer, size_t buflen, \ | |
128 | int *errnop, int *h_errnop) { \ | |
129 | return _nss_##module##_gethostbyaddr2_r( \ | |
130 | addr, len, \ | |
131 | af, \ | |
132 | host, \ | |
133 | buffer, buflen, \ | |
134 | errnop, h_errnop, \ | |
135 | NULL); \ | |
c01ff965 LP |
136 | } \ |
137 | struct __useless_struct_to_allow_trailing_semicolon__ | |
138 | ||
139 | #define NSS_GETPW_PROTOTYPES(module) \ | |
140 | enum nss_status _nss_##module##_getpwnam_r( \ | |
141 | const char *name, \ | |
142 | struct passwd *pwd, \ | |
143 | char *buffer, size_t buflen, \ | |
144 | int *errnop) _public_; \ | |
c0f81393 | 145 | enum nss_status _nss_##module##_getpwuid_r( \ |
c01ff965 LP |
146 | uid_t uid, \ |
147 | struct passwd *pwd, \ | |
148 | char *buffer, size_t buflen, \ | |
149 | int *errnop) _public_ | |
150 | ||
151 | #define NSS_GETGR_PROTOTYPES(module) \ | |
152 | enum nss_status _nss_##module##_getgrnam_r( \ | |
153 | const char *name, \ | |
154 | struct group *gr, \ | |
155 | char *buffer, size_t buflen, \ | |
156 | int *errnop) _public_; \ | |
157 | enum nss_status _nss_##module##_getgrgid_r( \ | |
158 | gid_t gid, \ | |
159 | struct group *gr, \ | |
160 | char *buffer, size_t buflen, \ | |
161 | int *errnop) _public_ | |
cf2d43e7 ZJS |
162 | |
163 | typedef enum nss_status (*_nss_gethostbyname4_r_t)( | |
164 | const char *name, | |
165 | struct gaih_addrtuple **pat, | |
166 | char *buffer, size_t buflen, | |
167 | int *errnop, int *h_errnop, | |
168 | int32_t *ttlp); | |
169 | ||
170 | typedef enum nss_status (*_nss_gethostbyname3_r_t)( | |
171 | const char *name, | |
172 | int af, | |
173 | struct hostent *result, | |
174 | char *buffer, size_t buflen, | |
175 | int *errnop, int *h_errnop, | |
176 | int32_t *ttlp, | |
177 | char **canonp); | |
178 | ||
2abb5b3b ZJS |
179 | typedef enum nss_status (*_nss_gethostbyname2_r_t)( |
180 | const char *name, | |
181 | int af, | |
182 | struct hostent *result, | |
183 | char *buffer, size_t buflen, | |
184 | int *errnop, int *h_errnop); | |
185 | ||
186 | typedef enum nss_status (*_nss_gethostbyname_r_t)( | |
187 | const char *name, | |
188 | struct hostent *result, | |
189 | char *buffer, size_t buflen, | |
190 | int *errnop, int *h_errnop); | |
191 | ||
cf2d43e7 ZJS |
192 | typedef enum nss_status (*_nss_gethostbyaddr2_r_t)( |
193 | const void* addr, socklen_t len, | |
194 | int af, | |
195 | struct hostent *result, | |
196 | char *buffer, size_t buflen, | |
197 | int *errnop, int *h_errnop, | |
198 | int32_t *ttlp); | |
2abb5b3b ZJS |
199 | typedef enum nss_status (*_nss_gethostbyaddr_r_t)( |
200 | const void* addr, socklen_t len, | |
201 | int af, | |
202 | struct hostent *host, | |
203 | char *buffer, size_t buflen, | |
204 | int *errnop, int *h_errnop); |