]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/nss-util.h
Merge pull request #8575 from keszybz/non-absolute-paths
[thirdparty/systemd.git] / src / basic / nss-util.h
CommitLineData
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
c9fdc26e
LP
8***/
9
71d35b6b 10#include <grp.h>
c9fdc26e 11#include <netdb.h>
71d35b6b 12#include <nss.h>
c01ff965 13#include <pwd.h>
71d35b6b 14#include <resolv.h>
c01ff965 15
0c5eb056
LP
16#define NSS_SIGNALS_BLOCK SIGALRM,SIGVTALRM,SIGPIPE,SIGCHLD,SIGTSTP,SIGIO,SIGHUP,SIGUSR1,SIGUSR2,SIGPROF,SIGURG,SIGWINCH
17
6154d33d
ZJS
18#ifndef DEPRECATED_RES_USE_INET6
19# define DEPRECATED_RES_USE_INET6 0x00002000
20#endif
21
c9fdc26e
LP
22#define NSS_GETHOSTBYNAME_PROTOTYPES(module) \
23enum nss_status _nss_##module##_gethostbyname4_r( \
24 const char *name, \
25 struct gaih_addrtuple **pat, \
26 char *buffer, size_t buflen, \
27 int *errnop, int *h_errnop, \
28 int32_t *ttlp) _public_; \
29enum nss_status _nss_##module##_gethostbyname3_r( \
30 const char *name, \
31 int af, \
32 struct hostent *host, \
33 char *buffer, size_t buflen, \
34 int *errnop, int *h_errnop, \
35 int32_t *ttlp, \
36 char **canonp) _public_; \
37enum nss_status _nss_##module##_gethostbyname2_r( \
38 const char *name, \
39 int af, \
40 struct hostent *host, \
41 char *buffer, size_t buflen, \
42 int *errnop, int *h_errnop) _public_; \
43enum nss_status _nss_##module##_gethostbyname_r( \
44 const char *name, \
45 struct hostent *host, \
46 char *buffer, size_t buflen, \
47 int *errnop, int *h_errnop) _public_
48
49#define NSS_GETHOSTBYADDR_PROTOTYPES(module) \
50enum nss_status _nss_##module##_gethostbyaddr2_r( \
51 const void* addr, socklen_t len, \
52 int af, \
53 struct hostent *host, \
54 char *buffer, size_t buflen, \
55 int *errnop, int *h_errnop, \
56 int32_t *ttlp) _public_; \
57enum nss_status _nss_##module##_gethostbyaddr_r( \
58 const void* addr, socklen_t len, \
59 int af, \
60 struct hostent *host, \
61 char *buffer, size_t buflen, \
62 int *errnop, int *h_errnop) _public_
63
64#define NSS_GETHOSTBYNAME_FALLBACKS(module) \
65enum nss_status _nss_##module##_gethostbyname2_r( \
66 const char *name, \
67 int af, \
68 struct hostent *host, \
69 char *buffer, size_t buflen, \
70 int *errnop, int *h_errnop) { \
71 return _nss_##module##_gethostbyname3_r( \
72 name, \
73 af, \
74 host, \
75 buffer, buflen, \
76 errnop, h_errnop, \
77 NULL, \
78 NULL); \
79} \
80enum nss_status _nss_##module##_gethostbyname_r( \
81 const char *name, \
82 struct hostent *host, \
83 char *buffer, size_t buflen, \
84 int *errnop, int *h_errnop) { \
ea30eb86
LP
85 enum nss_status ret = NSS_STATUS_NOTFOUND; \
86 \
6154d33d 87 if (_res.options & DEPRECATED_RES_USE_INET6) \
ea30eb86
LP
88 ret = _nss_##module##_gethostbyname3_r( \
89 name, \
90 AF_INET6, \
91 host, \
92 buffer, buflen, \
93 errnop, h_errnop, \
94 NULL, \
95 NULL); \
96 if (ret == NSS_STATUS_NOTFOUND) \
97 ret = _nss_##module##_gethostbyname3_r( \
c9fdc26e 98 name, \
ea30eb86 99 AF_INET, \
c9fdc26e
LP
100 host, \
101 buffer, buflen, \
102 errnop, h_errnop, \
103 NULL, \
104 NULL); \
ea30eb86 105 return ret; \
f6a8265b 106}
c9fdc26e
LP
107
108#define NSS_GETHOSTBYADDR_FALLBACKS(module) \
109enum nss_status _nss_##module##_gethostbyaddr_r( \
110 const void* addr, socklen_t len, \
111 int af, \
112 struct hostent *host, \
113 char *buffer, size_t buflen, \
114 int *errnop, int *h_errnop) { \
115 return _nss_##module##_gethostbyaddr2_r( \
116 addr, len, \
117 af, \
118 host, \
119 buffer, buflen, \
120 errnop, h_errnop, \
121 NULL); \
f6a8265b 122}
c01ff965
LP
123
124#define NSS_GETPW_PROTOTYPES(module) \
125enum nss_status _nss_##module##_getpwnam_r( \
126 const char *name, \
127 struct passwd *pwd, \
128 char *buffer, size_t buflen, \
129 int *errnop) _public_; \
c0f81393 130enum nss_status _nss_##module##_getpwuid_r( \
c01ff965
LP
131 uid_t uid, \
132 struct passwd *pwd, \
133 char *buffer, size_t buflen, \
134 int *errnop) _public_
135
136#define NSS_GETGR_PROTOTYPES(module) \
137enum nss_status _nss_##module##_getgrnam_r( \
138 const char *name, \
139 struct group *gr, \
140 char *buffer, size_t buflen, \
141 int *errnop) _public_; \
142enum nss_status _nss_##module##_getgrgid_r( \
143 gid_t gid, \
144 struct group *gr, \
145 char *buffer, size_t buflen, \
146 int *errnop) _public_
cf2d43e7
ZJS
147
148typedef enum nss_status (*_nss_gethostbyname4_r_t)(
149 const char *name,
150 struct gaih_addrtuple **pat,
151 char *buffer, size_t buflen,
152 int *errnop, int *h_errnop,
153 int32_t *ttlp);
154
155typedef enum nss_status (*_nss_gethostbyname3_r_t)(
156 const char *name,
157 int af,
158 struct hostent *result,
159 char *buffer, size_t buflen,
160 int *errnop, int *h_errnop,
161 int32_t *ttlp,
162 char **canonp);
163
2abb5b3b
ZJS
164typedef enum nss_status (*_nss_gethostbyname2_r_t)(
165 const char *name,
166 int af,
167 struct hostent *result,
168 char *buffer, size_t buflen,
169 int *errnop, int *h_errnop);
170
171typedef enum nss_status (*_nss_gethostbyname_r_t)(
172 const char *name,
173 struct hostent *result,
174 char *buffer, size_t buflen,
175 int *errnop, int *h_errnop);
176
cf2d43e7
ZJS
177typedef enum nss_status (*_nss_gethostbyaddr2_r_t)(
178 const void* addr, socklen_t len,
179 int af,
180 struct hostent *result,
181 char *buffer, size_t buflen,
182 int *errnop, int *h_errnop,
183 int32_t *ttlp);
2abb5b3b
ZJS
184typedef enum nss_status (*_nss_gethostbyaddr_r_t)(
185 const void* addr, socklen_t len,
186 int af,
187 struct hostent *host,
188 char *buffer, size_t buflen,
189 int *errnop, int *h_errnop);