]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nss: Fix tst-nss-files-alias-truncated for default --as-needed linking
authorFlorian Weimer <fweimer@redhat.com>
Thu, 14 Mar 2019 14:02:52 +0000 (15:02 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 14 Mar 2019 14:38:00 +0000 (15:38 +0100)
Linking to the NSS module directly does not work if the linker defaults
to --as-needed because it will remove the apparently unused DSO
reference and not generate a DT_NEEDED entry.  Use an explicit dlopen
call, like in the other chroot tests involving NSS modules.

ChangeLog
nss/Makefile
nss/tst-nss-files-alias-truncated.c

index f0281e5d10ac9951ac22582caf306240070e770f..72a149513701d082dc6fb68ce05ca73c9e37bc6e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-03-14  Florian Weimer  <fweimer@redhat.com>
+
+       * nss/tst-nss-files-alias-truncated.c (do_test): Load
+       libnss_files.
+       * nss/Makefile (tst-nss-files-alias-truncated): Link with -ldl,
+       but not with libnss_files.
+       (tst-nss-files-alias-truncated.out): Depend on libnss_files.
+
 2019-03-14  Zack Weinberg  <zackw@panix.com>
 
        * scripts/check-obsolete-constructs.py (HeaderChecker.check):
index a8caa8af380cdac98933e92ca7a9c99023c8eb14..95081bddc5ba899c32fe8ffe5006a2a7670bc373 100644 (file)
@@ -178,4 +178,5 @@ $(objpfx)tst-nss-files-hosts-multi: $(libdl)
 $(objpfx)tst-nss-files-hosts-getent: $(libdl)
 $(objpfx)tst-nss-files-alias-leak: $(libdl)
 $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so
-$(objpfx)tst-nss-files-alias-truncated: $(objpfx)/libnss_files.so
+$(objpfx)tst-nss-files-alias-truncated: $(libdl)
+$(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so
index 2d6aba3c0e339c6763089c7272d25a3311b976db..029ae6a2a7e62e056789400f90cd36a4583496fd 100644 (file)
    <http://www.gnu.org/licenses/>.  */
 
 #include <aliases.h>
+#include <gnu/lib-names.h>
 #include <nss.h>
 #include <stddef.h>
 #include <support/check.h>
 #include <support/namespace.h>
 #include <support/test-driver.h>
+#include <support/xdlfcn.h>
 #include <support/xunistd.h>
 
 static void
@@ -42,8 +44,9 @@ in_chroot (void *closure)
 static int
 do_test (void)
 {
-  /* nss_files has already been loaded via DT_NEEDED, outside the
-     chroot.  */
+  /* Make sure we don't try to load the module in the chroot.  */
+  xdlopen (LIBNSS_FILES_SO, RTLD_NOW);
+
   __nss_configure_lookup ("aliases", "files");
 
   support_become_root ();