]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/nss-util.h
tree-wide: remove Emacs lines from all files
[thirdparty/systemd.git] / src / basic / nss-util.h
CommitLineData
c9fdc26e
LP
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
71d35b6b 22#include <grp.h>
c9fdc26e 23#include <netdb.h>
71d35b6b 24#include <nss.h>
c01ff965 25#include <pwd.h>
71d35b6b 26#include <resolv.h>
c01ff965 27
0c5eb056
LP
28#define NSS_SIGNALS_BLOCK SIGALRM,SIGVTALRM,SIGPIPE,SIGCHLD,SIGTSTP,SIGIO,SIGHUP,SIGUSR1,SIGUSR2,SIGPROF,SIGURG,SIGWINCH
29
c9fdc26e
LP
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) { \
ea30eb86
LP
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( \
c9fdc26e 106 name, \
ea30eb86 107 AF_INET, \
c9fdc26e
LP
108 host, \
109 buffer, buflen, \
110 errnop, h_errnop, \
111 NULL, \
112 NULL); \
ea30eb86 113 return ret; \
c01ff965
LP
114} \
115struct __useless_struct_to_allow_trailing_semicolon__
c9fdc26e
LP
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); \
c01ff965
LP
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_; \
140enum nss_status _nss_mymachines_getpwuid_r( \
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_