verify-elf: fix passing of LD_PRELOAD in verify_unresolved

In verify_unresolved(), do not preload requested objects to $elf_ldd
directly because the latter is not an ELF interpreter but a shell
script.  Instead, pass the list of objects that have to be preloaded
to $elf_ldd script which in turn assigns it to LD_PRELOAD variable
in the ELF interpreter invocation.
This commit is contained in:
Дмитрий Левин 2017-01-14 13:21:50 +00:00
parent e8c780c2b0
commit a95f23ef1a
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,6 @@
#! /bin/sh
# Copyright (C) 1996-2004, 2005 Free Software Foundation, Inc.
# Copyright (C) 2006 Dmitry V. Levin <ldv@altlinux.org>
# Copyright (C) 2006-2017 Dmitry V. Levin <ldv@altlinux.org>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -82,7 +82,12 @@ verify_out="$("$rtld" --verify "$file")"
[ "$?" = 0 -o "$?" = 2 ] ||
Fatal "$file: trace failed"
LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now LD_DEBUG=$debug LD_LIBRARY_VERSION=$verify_out \
LD_TRACE_LOADED_OBJECTS=1 \
LD_WARN=$warn \
LD_BIND_NOW=$bind_now \
LD_DEBUG=$debug \
LD_LIBRARY_VERSION=$verify_out \
LD_PRELOAD="$RPM_LD_PRELOAD" \
"$rtld" --library-path "$rpath" "$file" ||
Fatal "$file: trace failed"

View File

@ -2,7 +2,7 @@
#
# verify-elf - verify ELF objects.
#
# Copyright (C) 2002-2011 Dmitry V. Levin <ldv@altlinux.org>
# Copyright (C) 2002-2017 Dmitry V. Levin <ldv@altlinux.org>
# Copyright (C) 2009 Alexey Tourbin <at@altlinux.org>
# Copyright (C) 2016 Ivan Zakharyaschev <imz@altlinux.org>
#
@ -181,7 +181,7 @@ verify_unresolved()
tr -s '[:space:]' : |
sed -e 's/^:\+//; s/:\+$//')"
if ! ldd_info="$(LD_PRELOAD="$preload" "$elf_ldd" --undefined -- "$f" "$rpath" 2>&1)"; then
if ! ldd_info="$(RPM_LD_PRELOAD="$preload" "$elf_ldd" --undefined -- "$f" "$rpath" 2>&1)"; then
printf >&2 '%s\n' "$ldd_info"
error_relaxed UNRESOLVED "$f" 'ldd failed'
return