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