From a4d99f3f70a5e237931b2abe4a2426edf78feee4 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 8 Feb 2023 19:40:19 +0100 Subject: [PATCH] Upstream test for ldconfig -p (#2167811) Related: #2167811 --- glibc-upstream-2.34-389.patch | 120 ++++++++++++++++++++++++++++++++++ glibc.spec | 6 +- 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 glibc-upstream-2.34-389.patch diff --git a/glibc-upstream-2.34-389.patch b/glibc-upstream-2.34-389.patch new file mode 100644 index 0000000..83170ad --- /dev/null +++ b/glibc-upstream-2.34-389.patch @@ -0,0 +1,120 @@ +commit 2d7550e6cfff541380d3a1f2ac33e76aaf1273de +Author: Florian Weimer +Date: Wed Feb 8 18:11:04 2023 +0100 + + elf: Smoke-test ldconfig -p against system /etc/ld.so.cache + + The test is sufficient to detect the ldconfig bug fixed in + commit 9fe6f6363886aae6b2b210cae3ed1f5921299083 ("elf: Fix 64 time_t + support for installed statically binaries"). + + Reviewed-by: Carlos O'Donell + (cherry picked from commit 9fd63e35371b9939e9153907c6a753e6960b68ad) + +diff --git a/elf/Makefile b/elf/Makefile +index 3a8590e0d3cc33ab..0daa8a85ec1a1bc5 100644 +--- a/elf/Makefile ++++ b/elf/Makefile +@@ -553,6 +553,7 @@ ifeq ($(run-built-tests),yes) + tests-special += \ + $(objpfx)noload-mem.out \ + $(objpfx)tst-ldconfig-X.out \ ++ $(objpfx)tst-ldconfig-p.out \ + $(objpfx)tst-leaks1-mem.out \ + $(objpfx)tst-rtld-help.out \ + # tests-special +@@ -2259,6 +2260,11 @@ $(objpfx)tst-ldconfig-X.out : tst-ldconfig-X.sh $(objpfx)ldconfig + '$(run-program-env)' > $@; \ + $(evaluate-test) + ++$(objpfx)tst-ldconfig-p.out : tst-ldconfig-p.sh $(objpfx)ldconfig ++ $(SHELL) $< '$(common-objpfx)' '$(test-wrapper-env)' \ ++ '$(run-program-env)' > $@; \ ++ $(evaluate-test) ++ + # Test static linking of all the libraries we can possibly link + # together. Note that in some configurations this may be less than the + # complete list of libraries we build but we try to maxmimize this list. +diff --git a/elf/tst-ldconfig-p.sh b/elf/tst-ldconfig-p.sh +new file mode 100644 +index 0000000000000000..ec937bf4ec04e8c0 +--- /dev/null ++++ b/elf/tst-ldconfig-p.sh +@@ -0,0 +1,77 @@ ++#!/bin/sh ++# Test that ldconfig -p prints something useful. ++# Copyright (C) 2023 Free Software Foundation, Inc. ++# This file is part of the GNU C Library. ++ ++# The GNU C Library is free software; you can redistribute it and/or ++# modify it under the terms of the GNU Lesser General Public ++# License as published by the Free Software Foundation; either ++# version 2.1 of the License, or (at your option) any later version. ++ ++# The GNU C Library is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# Lesser General Public License for more details. ++ ++# You should have received a copy of the GNU Lesser General Public ++# License along with the GNU C Library; if not, see ++# . ++ ++# Check that the newly built ldconfig -p can dump the system ++# /etc/ld.so.cache file. This should always work even if the ABIs are ++# not compatible, except in a cross-endian build (that presumably ++# involves emulation when running ldconfig). ++ ++common_objpfx=$1 ++test_wrapper_env=$2 ++run_program_env=$3 ++ ++if ! test -r /etc/ld.so.cache; then ++ echo "warning: /etc/ld.so.cache does not exist, test skipped" ++ exit 77 ++fi ++ ++testout="${common_objpfx}elf/tst-ldconfig-p.out" ++# Truncate file. ++: > "$testout" ++ ++${test_wrapper_env} \ ++${run_program_env} \ ++${common_objpfx}elf/ldconfig -p \ ++ $testroot/lib >>"$testout" 2>>"$testout" ++status=$? ++echo "info: ldconfig exit status: $status" >>"$testout" ++ ++errors=0 ++case $status in ++ (0) ++ if head -n 1 "$testout" | \ ++ grep -q "libs found in cache \`/etc/ld.so.cache'\$" ; then ++ echo "info: initial string found" >>"$testout" ++ else ++ echo "error: initial string not found" >>"$testout" ++ errors=1 ++ fi ++ if grep -q "^ libc\.so\..* => " "$testout"; then ++ echo "info: libc.so.* string found" >>"$testout" ++ else ++ echo "error: libc.so.* string not found" >>"$testout" ++ errors=1 ++ fi ++ ;; ++ (1) ++ if head -n 1 "$testout" | \ ++ grep -q ": Cache file has wrong endianness\.$" ; then ++ echo "info: cache file has wrong endianess" >> "$testout" ++ else ++ echo "error: unexpected ldconfig error message" >> "$testout" ++ errors=1 ++ fi ++ ;; ++ (*) ++ echo "error: unexpected exit status" >> "$testout" ++ errors=1 ++ ;; ++esac ++ ++exit $errors diff --git a/glibc.spec b/glibc.spec index 537f656..ddb8035 100644 --- a/glibc.spec +++ b/glibc.spec @@ -155,7 +155,7 @@ end \ Summary: The GNU libc libraries Name: glibc Version: %{glibcversion} -Release: 59%{?dist} +Release: 60%{?dist} # In general, GPLv2+ is used by programs, LGPLv2+ is used for # libraries. @@ -699,6 +699,7 @@ Patch467: glibc-upstream-2.34-385.patch Patch468: glibc-upstream-2.34-386.patch # glibc-upstream-2.34-387.patch is a NEWS-only update. Skipped downstream. Patch469: glibc-upstream-2.34-388.patch +Patch470: glibc-upstream-2.34-389.patch ############################################################################## # Continued list of core "glibc" package information: @@ -2858,6 +2859,9 @@ fi %endif %changelog +* Wed Feb 8 2023 Florian Weimer - 2.34-60 +- Upstream test for ldconfig -p (#2167811) + * Wed Feb 8 2023 Florian Weimer - 2.34-59 - Fix ldconfig -p on i686 (#2167811)