glibc: revert `/bin/bash` usage

Rather than `$BASH`, `glibc` now hardcodes `/bin/bash` as
interpreter[1] in several scripts (including `ldd`).

This is a problem because relevant programs such as `ldd(1)` won't work
properly without this since we set `BASH` to `/bin/sh` to avoid
dependencies to the bootstrap tools for `bash` as runtime-dependency (since
NixOS doesn't have `/bin/bash`).

Considering that this was only done as an "improvement" to their
build-system and not because they wanted to use some bashisms here (the
variable was always called `BASH` and we still used `/bin/sh` anyways),
I'd consider this to be relatively safe.

[1] 5188a9d0265cc6f7235a8af1d31ab02e4a24853d
main
Maximilian Bosch 3 years ago
parent f363b7c5df
commit 1b8aa881ea
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E
  1. 131
      pkgs/development/libraries/glibc/0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch
  2. 2
      pkgs/development/libraries/glibc/common.nix

@ -0,0 +1,131 @@
From f81744bae4442345ff6f40d80fdb8adaba8b330f Mon Sep 17 00:00:00 2001
From: Maximilian Bosch <maximilian@mbosch.me>
Date: Fri, 27 Aug 2021 17:19:27 +0200
Subject: [PATCH] Revert "Remove all usage of @BASH@ or ${BASH} in installed
files, and hardcode /bin/bash instead"
We need the ability to override to use `/bin/sh` here to avoid having
some bootstrap tools in a final build product.
This reverts commit 5188a9d0265cc6f7235a8af1d31ab02e4a24853d.
---
debug/Makefile | 5 +++--
debug/xtrace.sh | 2 +-
elf/Makefile | 4 +++-
elf/ldd.bash.in | 2 +-
elf/sotruss.sh | 2 +-
malloc/Makefile | 5 +++--
malloc/memusage.sh | 2 +-
timezone/Makefile | 3 ++-
8 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/debug/Makefile b/debug/Makefile
index 6893111cbf..3f66666c6c 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -216,7 +216,8 @@ $(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o
$(objpfx)xtrace: xtrace.sh
rm -f $@.new
- sed -e 's|@VERSION@|$(version)|' -e 's|@SLIBDIR@|$(sLIBdir)|' \
- -e 's|@BINDIR@|$(bindir)|' -e 's|@PKGVERSION@|$(PKGVERSION)|' \
+ sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
+ -e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \
+ -e 's|@PKGVERSION@|$(PKGVERSION)|' \
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
&& rm -f $@ && mv $@.new $@ && chmod +x $@
diff --git a/debug/xtrace.sh b/debug/xtrace.sh
index 9697fbe0b4..279fe59ac6 100755
--- a/debug/xtrace.sh
+++ b/debug/xtrace.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#! @BASH@
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Ulrich Drepper <drepper@gnu.org>, 1999.
diff --git a/elf/Makefile b/elf/Makefile
index d05f410592..9264409fdd 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -144,7 +144,8 @@ $(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
$(common-objpfx)libc_nonshared.a
$(objpfx)sotruss: sotruss.sh $(common-objpfx)config.make
- sed -e 's%@VERSION@%$(version)%g' \
+ sed -e 's%@BASH@%$(BASH)%g' \
+ -e 's%@VERSION@%$(version)%g' \
-e 's%@TEXTDOMAINDIR@%$(localedir)%g' \
-e 's%@PREFIX@%$(prefix)%g' \
-e 's|@PKGVERSION@|$(PKGVERSION)|g' \
@@ -659,6 +660,7 @@ ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
-e 's%@VERSION@%$(version)%g' \
-e 's|@PKGVERSION@|$(PKGVERSION)|g' \
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
+ -e 's%@BASH@%$(BASH)%g' \
-e 's%@TEXTDOMAINDIR@%$(localedir)%g'
ifeq ($(ldd-rewrite-script),no)
diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
index ba736464ac..57442bc3f2 100644
--- a/elf/ldd.bash.in
+++ b/elf/ldd.bash.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#! @BASH@
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
diff --git a/elf/sotruss.sh b/elf/sotruss.sh
index 003cf4d825..fd4da80244 100755
--- a/elf/sotruss.sh
+++ b/elf/sotruss.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#! @BASH@
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
diff --git a/malloc/Makefile b/malloc/Makefile
index 9b70831d38..90ecadff6c 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -271,8 +271,9 @@ $(objpfx)mtrace: mtrace.pl
$(objpfx)memusage: memusage.sh
rm -f $@.new
- sed -e 's|@VERSION@|$(version)|' -e 's|@SLIBDIR@|$(sLIBdir)|' \
- -e 's|@BINDIR@|$(bindir)|' -e 's|@PKGVERSION@|$(PKGVERSION)|' \
+ sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
+ -e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \
+ -e 's|@PKGVERSION@|$(PKGVERSION)|' \
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
&& rm -f $@ && mv $@.new $@ && chmod +x $@
diff --git a/malloc/memusage.sh b/malloc/memusage.sh
index 0645f09911..c1cd4e23b7 100755
--- a/malloc/memusage.sh
+++ b/malloc/memusage.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#! @BASH@
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Ulrich Drepper <drepper@gnu.org>, 1999.
diff --git a/timezone/Makefile b/timezone/Makefile
index c624a189b3..395abfeebd 100644
--- a/timezone/Makefile
+++ b/timezone/Makefile
@@ -123,7 +123,8 @@ $(testdata)/XT%: testdata/XT%
cp $< $@
$(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
- sed -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
+ sed -e 's|/bin/bash|$(BASH)|' \
+ -e 's|TZDIR=[^}]*|TZDIR=$(zonedir)|' \
-e '/TZVERSION=/s|see_Makefile|"$(version)"|' \
-e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
-e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
--
2.31.1

@ -125,6 +125,8 @@ stdenv.mkDerivation ({
/* https://github.com/NixOS/nixpkgs/pull/137601 */
./nix-nss-open-files.patch
./0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch
]
++ lib.optional stdenv.hostPlatform.isMusl ./fix-rpc-types-musl-conflicts.patch
++ lib.optional stdenv.buildPlatform.isDarwin ./darwin-cross-build.patch;

Loading…
Cancel
Save