glibc: don't hide symbol `__nss_files_fopen`

I realized that `libredirect` doesn't wrap `__nss_files_fopen` anymore
which subsequently broke the `checkPhase` of `pkgs.openssh`[1] which was
implemented in 85c63a515d.

The reason for that is what `libc_hidden_{def,proto}` are used for, to
quote `libc-symbols.h`[2]:

    The following macros are used for PLT bypassing within libc.so
    (and if needed other libraries similarly).

This basically means that these symbols are altered in a way so that
they cannot be wrapped by `libredirect` even though it re-defines
`__nss_files_fopen` while being loaded at first with `LD_PRELOAD`.

The problem was caused by a change in 2.34[3] where the `files`-module
for NSS isn't loaded from `libnss_files.so.2` anymore, but the relevant
symbols are directly obtained from `libc.so.6` since a lot of glibc's
APIs were merged into `libc.so.6` before.

As this would effectively break `libredirect` whenever it tries to wrap
C APIs that interact with NSS (e.g. to use `getpwnam(3)`), I decided to
undo this change for `__nss_files_fopen`.

[1] https://hydra.nixos.org/build/160688523
[2] https://sourceware.org/git/?p=glibc.git;a=blob;f=include/libc-symbols.h;h=d41ecf4384d07f9108698dba1d4e9e6a7a9b975f;hb=ae37d06c7d127817ba43850f0f898b793d42aea7
[3] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f9c8b11ed7726b858cd7b7cea0d3d7c5233d78cf;hp=6212bb67f4695962748a5981e1b9fea105af74f6
main
Maximilian Bosch 2 years ago
parent 6b98a5e512
commit 748faeb623
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E
  1. 4
      pkgs/development/libraries/glibc/common.nix

@ -140,6 +140,10 @@ stdenv.mkDerivation ({
# nscd needs libgcc, and we don't want it dynamically linked
# because we don't want it to depend on bootstrap-tools libs.
echo "LDFLAGS-nscd += -static-libgcc" >> nscd/Makefile
# Ensure that `__nss_files_fopen` can still be wrapped by `libredirect`.
sed -i -e '/libc_hidden_def (__nss_files_fopen)/d' nss/nss_files_fopen.c
sed -i -e '/libc_hidden_proto (__nss_files_fopen)/d' include/nss_files.h
''
# FIXME: find a solution for infinite recursion in cross builds.
# For now it's hopefully acceptable that IDN from libc doesn't reliably work.

Loading…
Cancel
Save