]>
Commit | Line | Data |
---|---|---|
6d7e8eda | 1 | # Copyright (C) 1996-2023 Free Software Foundation, Inc. |
5f0e6fc7 RM |
2 | # This file is part of the GNU C Library. |
3 | ||
4 | # The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | # modify it under the terms of the GNU Lesser General Public |
6 | # License as published by the Free Software Foundation; either | |
7 | # version 2.1 of the License, or (at your option) any later version. | |
5f0e6fc7 RM |
8 | |
9 | # The GNU C Library is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | # Lesser General Public License for more details. |
5f0e6fc7 | 13 | |
41bdb6e2 | 14 | # You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | # License along with the GNU C Library; if not, see |
5a82c748 | 16 | # <https://www.gnu.org/licenses/>. |
5f0e6fc7 RM |
17 | |
18 | # | |
19 | # Makefile for name service switch. | |
20 | # | |
21 | subdir := nss | |
22 | ||
a5f891ac JM |
23 | include ../Makeconfig |
24 | ||
751850cf | 25 | headers := \ |
42985866 | 26 | aliases.h \ |
b121fdc5 | 27 | grp.h \ |
98b107e3 | 28 | gshadow.h \ |
751850cf | 29 | nss.h \ |
0ac35d18 | 30 | pwd.h \ |
c6b577ca | 31 | shadow.h \ |
751850cf | 32 | # headers |
5f0e6fc7 RM |
33 | |
34 | # This is the trivial part which goes into libc itself. | |
751850cf AS |
35 | routines = \ |
36 | $(addsuffix -lookup,$(databases)) \ | |
37 | compat-lookup \ | |
38 | digits_dots \ | |
39 | getnssent \ | |
40 | getnssent_r \ | |
41 | nss_action \ | |
42 | nss_action_parse \ | |
43 | nss_database \ | |
44 | nss_fgetent_r \ | |
45 | nss_files_data \ | |
46 | nss_files_fopen \ | |
47 | nss_files_functions \ | |
48 | nss_hash \ | |
49 | nss_module \ | |
50 | nss_parse_line_result \ | |
51 | nss_readline \ | |
52 | nsswitch \ | |
53 | rewrite_field \ | |
54 | valid_field \ | |
55 | valid_list_field \ | |
56 | # routines | |
5f0e6fc7 | 57 | |
42985866 AS |
58 | # alias routines: |
59 | routines += \ | |
60 | getaliasent \ | |
61 | getaliasent_r \ | |
62 | getaliasname \ | |
63 | getaliasname_r \ | |
64 | # routines | |
65 | ||
66 | ifeq ($(have-thread-library),yes) | |
67 | CFLAGS-getaliasent_r.c += -fexceptions | |
68 | CFLAGS-getaliasent.c += -fexceptions | |
69 | endif | |
70 | ||
1c402663 AS |
71 | # ethers routines: |
72 | routines += \ | |
73 | ether_hton \ | |
74 | ether_ntoh \ | |
75 | # routines | |
76 | ||
b121fdc5 AS |
77 | # grp routines: |
78 | routines += \ | |
79 | fgetgrent \ | |
80 | fgetgrent_r \ | |
81 | getgrent \ | |
82 | getgrent_r \ | |
83 | getgrgid \ | |
84 | getgrgid_r \ | |
85 | getgrnam \ | |
86 | getgrnam_r \ | |
87 | grp-merge \ | |
88 | initgroups \ | |
89 | putgrent \ | |
90 | # routines | |
91 | ||
92 | ifeq ($(have-thread-library),yes) | |
93 | CFLAGS-fgetgrent.c += -fexceptions | |
94 | CFLAGS-fgetgrent_r.c += -fexceptions $(libio-mtsafe) | |
95 | CFLAGS-getgrent.c += -fexceptions | |
96 | CFLAGS-getgrent_r.c += -fexceptions | |
97 | CFLAGS-getgrgid.c += -fexceptions | |
98 | CFLAGS-getgrgid_r.c += -fexceptions | |
99 | CFLAGS-getgrnam.c += -fexceptions | |
100 | CFLAGS-getgrnam_r.c += -fexceptions | |
101 | CFLAGS-initgroups.c += -fexceptions | |
102 | CFLAGS-putgrent.c += -fexceptions $(libio-mtsafe) | |
103 | endif | |
104 | ||
98b107e3 AS |
105 | # gshadow routines: |
106 | routines += \ | |
107 | fgetsgent \ | |
108 | fgetsgent_r \ | |
109 | getsgent \ | |
110 | getsgent_r \ | |
111 | getsgnam \ | |
112 | getsgnam_r \ | |
113 | putsgent \ | |
114 | sgetsgent \ | |
115 | sgetsgent_r \ | |
116 | # routines | |
117 | ||
118 | ifeq ($(have-thread-library),yes) | |
119 | CFLAGS-getsgent_r.c += -fexceptions | |
120 | CFLAGS-getsgent.c += -fexceptions | |
121 | CFLAGS-fgetsgent.c += -fexceptions | |
122 | CFLAGS-fgetsgent_r.c += -fexceptions $(libio-mtsafe) | |
123 | CFLAGS-putsgent.c += -fexceptions $(libio-mtsafe) | |
124 | CFLAGS-getsgnam.c += -fexceptions | |
125 | CFLAGS-getsgnam_r.c += -fexceptions | |
126 | endif | |
127 | ||
a7e8d0b9 AS |
128 | # hosts routines: |
129 | routines += \ | |
130 | gethstbyad \ | |
131 | gethstbyad_r \ | |
132 | gethstbynm \ | |
133 | gethstbynm2 \ | |
134 | gethstbynm2_r \ | |
135 | gethstbynm_r \ | |
136 | gethstent \ | |
137 | gethstent_r \ | |
138 | # routines | |
139 | ||
140 | ifeq ($(have-thread-library),yes) | |
141 | CFLAGS-gethstbyad.c += -fexceptions | |
142 | CFLAGS-gethstbyad_r.c += -fexceptions | |
143 | CFLAGS-gethstbynm.c += -fexceptions | |
144 | CFLAGS-gethstbynm_r.c += -fexceptions | |
145 | CFLAGS-gethstbynm2.c += -fexceptions | |
146 | CFLAGS-gethstbynm2_r.c += -fexceptions | |
147 | CFLAGS-gethstent.c += -fexceptions | |
148 | CFLAGS-gethstent_r.c += -fexceptions | |
149 | endif | |
150 | ||
0ac35d18 AS |
151 | # pwd routines: |
152 | routines += \ | |
153 | fgetpwent \ | |
154 | fgetpwent_r \ | |
155 | getpw \ | |
156 | getpwent \ | |
157 | getpwent_r \ | |
158 | getpwnam \ | |
159 | getpwnam_r \ | |
160 | getpwuid \ | |
161 | getpwuid_r \ | |
162 | putpwent \ | |
163 | # routines | |
164 | ||
165 | ifeq ($(have-thread-library),yes) | |
166 | CFLAGS-fgetpwent_r.c += $(libio-mtsafe) | |
167 | CFLAGS-getpw.c += -fexceptions | |
168 | CFLAGS-getpwent.c += -fexceptions | |
169 | CFLAGS-getpwent_r.c += -fexceptions | |
170 | endif | |
171 | ||
c6b577ca AS |
172 | # shadow routines |
173 | routines += \ | |
174 | fgetspent \ | |
175 | fgetspent_r \ | |
176 | getspent \ | |
177 | getspent_r \ | |
178 | getspnam \ | |
179 | getspnam_r \ | |
180 | lckpwdf \ | |
181 | putspent \ | |
182 | sgetspent \ | |
183 | sgetspent_r \ | |
184 | # routines | |
185 | ||
186 | ifeq ($(have-thread-library),yes) | |
187 | CFLAGS-getspent_r.c += -fexceptions | |
188 | CFLAGS-getspent.c += -fexceptions | |
189 | CFLAGS-fgetspent.c += -fexceptions | |
190 | CFLAGS-fgetspent_r.c += -fexceptions $(libio-mtsafe) | |
191 | CFLAGS-putspent.c += -fexceptions $(libio-mtsafe) | |
192 | CFLAGS-getspnam.c += -fexceptions | |
193 | CFLAGS-getspnam_r.c += -fexceptions | |
194 | endif | |
195 | ||
6dbe2837 | 196 | # These are the databases that go through nss dispatch. |
a8874ead UD |
197 | # Caution: if you add a database here, you must add its real name |
198 | # in databases.def, too. | |
751850cf AS |
199 | databases = \ |
200 | alias \ | |
201 | ethers \ | |
202 | grp \ | |
203 | hosts \ | |
204 | netgrp \ | |
205 | network \ | |
206 | proto \ | |
207 | pwd \ | |
208 | service \ | |
209 | sgrp \ | |
210 | spwd \ | |
211 | # databases | |
a1309c2b RM |
212 | |
213 | ifneq (,$(filter sunrpc,$(subdirs))) | |
214 | databases += key rpc | |
215 | have-sunrpc := 1 | |
216 | else | |
217 | have-sunrpc := 0 | |
218 | endif | |
219 | CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc) | |
5f0e6fc7 | 220 | |
9ee76b5a UD |
221 | others := getent makedb |
222 | install-bin := getent makedb | |
223 | makedb-modules = xmalloc hash-string | |
7b3ce395 | 224 | others-extras = $(makedb-modules) |
9ee76b5a | 225 | extra-objs += $(makedb-modules:=.o) |
7d6a8338 | 226 | |
676599b3 | 227 | tests-static = tst-field |
7c3018f9 | 228 | tests-internal = tst-field |
e2f68b54 SP |
229 | |
230 | tests := \ | |
231 | bug17079 \ | |
232 | test-digits-dots \ | |
233 | test-netdb \ | |
b121fdc5 | 234 | testgrp \ |
98b107e3 | 235 | tst-fgetsgent_r \ |
a7e8d0b9 | 236 | tst-gethnm \ |
0ac35d18 | 237 | tst-getpw \ |
98b107e3 | 238 | tst-gshadow \ |
e2f68b54 | 239 | tst-nss-getpwent \ |
5f2f0f69 | 240 | tst-nss-hash \ |
e2f68b54 SP |
241 | tst-nss-test1 \ |
242 | tst-nss-test2 \ | |
243 | tst-nss-test4 \ | |
244 | tst-nss-test5 \ | |
245 | tst-nss-test_errno \ | |
b121fdc5 | 246 | tst-putgrent \ |
0ac35d18 | 247 | tst-putpwent \ |
98b107e3 | 248 | tst-putsgent \ |
c6b577ca | 249 | tst-putspent \ |
98b107e3 | 250 | tst-sgetsgent \ |
c6b577ca | 251 | tst-shadow \ |
751850cf | 252 | # tests |
e2f68b54 SP |
253 | |
254 | xtests = bug-erange | |
255 | ||
256 | tests-container := \ | |
b121fdc5 AS |
257 | tst-initgroups1 \ |
258 | tst-initgroups2 \ | |
e2f68b54 SP |
259 | tst-nss-compat1 \ |
260 | tst-nss-db-endgrent \ | |
261 | tst-nss-db-endpwent \ | |
262 | tst-nss-files-hosts-long \ | |
c4376314 | 263 | tst-nss-files-hosts-v4mapped \ |
1c37b802 | 264 | tst-nss-gai-actions \ |
751850cf | 265 | tst-nss-gai-hv2-canonname \ |
e2f68b54 SP |
266 | tst-nss-test3 \ |
267 | tst-reload1 \ | |
268 | tst-reload2 \ | |
751850cf | 269 | # tests-container |
561b0bec | 270 | |
f4a6be25 | 271 | ifeq (yes,$(build-shared)) |
b121fdc5 | 272 | # Tests which need libdl |
f4a6be25 | 273 | tests += tst-nss-files-hosts-erange |
d8425e11 | 274 | tests += tst-nss-files-hosts-multi |
916124ed | 275 | tests += tst-nss-files-hosts-getent |
e95c6f61 | 276 | tests += tst-nss-files-alias-leak |
2bac7daa | 277 | tests += tst-nss-files-alias-truncated |
b121fdc5 AS |
278 | # tst_fgetgrent currently only works with shared libraries |
279 | test-srcs := tst_fgetgrent | |
280 | ifeq ($(run-built-tests),yes) | |
281 | tests-special += $(objpfx)tst_fgetgrent.out | |
282 | $(objpfx)tst_fgetgrent.out: tst_fgetgrent.sh $(objpfx)tst_fgetgrent | |
283 | $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \ | |
284 | $(evaluate-test) | |
285 | endif | |
f4a6be25 FW |
286 | endif |
287 | ||
b0a679f4 CD |
288 | # If we have a thread library then we can test cancellation against |
289 | # some routines like getpwuid_r. | |
290 | ifeq (yes,$(have-thread-library)) | |
291 | tests += tst-cancel-getpwuid_r | |
292 | endif | |
293 | ||
5f0e6fc7 | 294 | # Specify rules for the nss_* modules. We have some services. |
64d1e08e | 295 | services := files db compat |
5f0e6fc7 RM |
296 | |
297 | extra-libs = $(services:%=libnss_%) | |
dbe31b9a RM |
298 | # These libraries will be built in the `others' pass rather than |
299 | # the `lib' pass, because they depend on libc.so being built already. | |
300 | extra-libs-others = $(extra-libs) | |
5f0e6fc7 RM |
301 | |
302 | # The sources are found in the appropriate subdir. | |
6dbe2837 | 303 | subdir-dirs = $(services:%=nss_%) |
9ee76b5a | 304 | vpath %.c $(subdir-dirs) ../locale/programs ../intl |
5f0e6fc7 RM |
305 | |
306 | ||
6212bb67 FW |
307 | routines += \ |
308 | $(addprefix files-, $(filter-out key, $(databases))) \ | |
309 | files-init \ | |
310 | files-initgroups \ | |
311 | # routines | |
5f0e6fc7 | 312 | |
9ed48fee FW |
313 | # Build only an empty shared libnss_files. |
314 | libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes)) | |
315 | ||
316 | # Pretend that libnss_files.so is a linker script, so that the symbolic link | |
317 | # is not installed. | |
318 | install-lib-ldscripts = libnss_files.so | |
319 | $(inst_libdir)/libnss_files.so: | |
320 | ||
2666d441 UD |
321 | libnss_db-dbs := $(addprefix db-,\ |
322 | $(filter-out hosts network key alias,\ | |
9f2da732 UD |
323 | $(databases))) \ |
324 | db-initgroups | |
319b9ad4 | 325 | libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string |
2666d441 UD |
326 | generated += $(filter-out db-alias.c db-netgrp.c, \ |
327 | $(addsuffix .c,$(libnss_db-dbs))) | |
1aadea59 | 328 | |
64d1e08e AS |
329 | libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \ |
330 | nisdomain | |
331 | ||
77fb9117 UD |
332 | install-others += $(inst_vardbdir)/Makefile |
333 | ||
3ff42526 | 334 | # Build static module into libc if requested |
2666d441 | 335 | libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes)) |
64d1e08e | 336 | libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes)) |
3ff42526 | 337 | ifeq ($(build-static-nss),yes) |
676599b3 | 338 | tests-static += tst-nss-static |
6ca96fe2 | 339 | endif |
973fe93a SP |
340 | extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os \ |
341 | nss_test_gai_hv2_canonname.os | |
5f0e6fc7 | 342 | |
ec6b95c3 RG |
343 | ifeq ($(run-built-tests),yes) |
344 | ifneq (no,$(PERL)) | |
345 | tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out | |
346 | endif | |
347 | endif | |
348 | ||
349 | generated += mtrace-tst-nss-gai-hv2-canonname.out \ | |
350 | tst-nss-gai-hv2-canonname.mtrace | |
351 | ||
5f0e6fc7 RM |
352 | include ../Rules |
353 | ||
9ee76b5a UD |
354 | ifeq (yes,$(have-selinux)) |
355 | LDLIBS-makedb := -lselinux | |
356 | endif | |
357 | ||
7b57bfe5 | 358 | libnss-libc = $(common-objpfx)linkobj/libc.so |
fab7ce3f JM |
359 | # Target-specific variable setting to link objects using deprecated |
360 | # RPC interfaces with the version of libc.so that makes them available | |
361 | # for new links: | |
362 | $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc) | |
c3e2f19b | 363 | |
2666d441 UD |
364 | $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c |
365 | @rm -f $@.new | |
366 | (echo '#define EXTERN_PARSER';\ | |
367 | echo '#define GENERIC "../nss_db/db-XXX.c"';\ | |
368 | echo '#include "$<"') > $@.new | |
369 | mv -f $@.new $@ | |
370 | ||
c3e2f19b | 371 | |
9ee76b5a UD |
372 | $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o) |
373 | ||
77fb9117 UD |
374 | $(inst_vardbdir)/Makefile: db-Makefile $(+force) |
375 | $(do-install) | |
376 | ||
ae5c498d DD |
377 | libnss_test1.so-no-z-defs = 1 |
378 | libnss_test2.so-no-z-defs = 1 | |
379 | ||
380 | rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver | |
381 | ||
9cd47470 | 382 | libof-nss_test1 = extramodules |
ae5c498d | 383 | libof-nss_test2 = extramodules |
9bdf92c7 | 384 | libof-nss_test_errno = extramodules |
973fe93a | 385 | libof-nss_test_gai_hv2_canonname = extramodules |
fab7ce3f | 386 | $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps) |
c3e2f19b | 387 | $(build-module) |
ae5c498d DD |
388 | $(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps) |
389 | $(build-module) | |
9bdf92c7 FW |
390 | $(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps) |
391 | $(build-module) | |
973fe93a SP |
392 | $(objpfx)/libnss_test_gai_hv2_canonname.so: \ |
393 | $(objpfx)nss_test_gai_hv2_canonname.os $(link-libc-deps) | |
394 | $(build-module) | |
ae5c498d | 395 | $(objpfx)nss_test2.os : nss_test1.c |
aefc79ab FW |
396 | # Use the nss_files suffix for these objects as well. |
397 | $(objpfx)/libnss_test1.so$(libnss_files.so-version): $(objpfx)/libnss_test1.so | |
c3e2f19b | 398 | $(make-link) |
aefc79ab | 399 | $(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so |
ae5c498d | 400 | $(make-link) |
9bdf92c7 FW |
401 | $(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \ |
402 | $(objpfx)/libnss_test_errno.so | |
403 | $(make-link) | |
973fe93a SP |
404 | $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \ |
405 | $(objpfx)/libnss_test_gai_hv2_canonname.so | |
406 | $(make-link) | |
268bb71e | 407 | $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \ |
aefc79ab | 408 | $(objpfx)/libnss_test1.so$(libnss_files.so-version) \ |
9bdf92c7 | 409 | $(objpfx)/libnss_test2.so$(libnss_files.so-version) \ |
973fe93a SP |
410 | $(objpfx)/libnss_test_errno.so$(libnss_files.so-version) \ |
411 | $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version) | |
b0a679f4 CD |
412 | |
413 | ifeq (yes,$(have-thread-library)) | |
414 | $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library) | |
415 | endif | |
f4a6be25 | 416 | |
e95c6f61 | 417 | $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so |
081bdf94 | 418 | $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so |
57e349b1 | 419 | |
ec6b95c3 RG |
420 | tst-nss-gai-hv2-canonname-ENV = \ |
421 | MALLOC_TRACE=$(objpfx)tst-nss-gai-hv2-canonname.mtrace \ | |
422 | LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so | |
423 | $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out: \ | |
424 | $(objpfx)tst-nss-gai-hv2-canonname.out | |
425 | { test -r $(objpfx)tst-nss-gai-hv2-canonname.mtrace \ | |
426 | || ( echo "tst-nss-gai-hv2-canonname.mtrace does not exist"; exit 77; ) \ | |
427 | && $(common-objpfx)malloc/mtrace \ | |
428 | $(objpfx)tst-nss-gai-hv2-canonname.mtrace; } > $@; \ | |
429 | $(evaluate-test) | |
430 | ||
57e349b1 L |
431 | # Disable DT_RUNPATH on NSS tests so that the glibc internal NSS |
432 | # functions can load testing NSS modules via DT_RPATH. | |
433 | LDFLAGS-tst-nss-test1 = -Wl,--disable-new-dtags | |
434 | LDFLAGS-tst-nss-test2 = -Wl,--disable-new-dtags | |
435 | LDFLAGS-tst-nss-test3 = -Wl,--disable-new-dtags | |
436 | LDFLAGS-tst-nss-test4 = -Wl,--disable-new-dtags | |
437 | LDFLAGS-tst-nss-test5 = -Wl,--disable-new-dtags | |
9bdf92c7 | 438 | LDFLAGS-tst-nss-test_errno = -Wl,--disable-new-dtags |
973fe93a | 439 | LDFLAGS-tst-nss-test_gai_hv2_canonname = -Wl,--disable-new-dtags |