summaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-12-10 06:50:32 +0000
committerJakub Jelinek <jakub@redhat.com>2004-12-10 06:50:32 +0000
commitf2b016bfc98c9ced9f9572d23580d31442a3519c (patch)
treed9f2e28f30b6d4aca132126bb24de7039805fca8 /elf
parent0e7f328d0849e8e663eb14ade5074b4e451fe276 (diff)
Updated to fedora-glibc-20041210T0634
Diffstat (limited to 'elf')
-rw-r--r--elf/ldd.bash.in26
1 files changed, 23 insertions, 3 deletions
diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
index c91886a1e6..5dbf88cdc8 100644
--- a/elf/ldd.bash.in
+++ b/elf/ldd.bash.in
@@ -106,6 +106,21 @@ add_env="$add_env LD_VERBOSE=$verbose"
if test "$unused" = yes; then
add_env="$add_env LD_DEBUG=\"$LD_DEBUG${LD_DEBUG:+,}unused\""
fi
+
+# The following use of cat is needed to make ldd work in SELinux
+# environments where the executed program might not have permissions
+# to write to the console/tty. But only bash 3.x supports the pipefail
+# option, and we don't bother to handle the case for older bash versions.
+if set -o pipefail 2> /dev/null; then
+ try_trace() {
+ eval $add_env '"$@"' | cat
+ }
+else
+ try_trace() {
+ eval $add_env '"$@"'
+ }
+fi
+
case $# in
0)
echo >&2 'ldd:' $"missing file arguments"
@@ -157,8 +172,13 @@ warning: you do not have execution permission for" "\`$file'" >&2
# If the program exits with exit code 5, it means the process has been
# invoked with __libc_enable_secure. Fall back to running it through
# the dynamic linker.
- ( eval $add_env '"$file"'; ret=$?; [ $ret != 5 ] && exit $ret;
- eval $add_env \${RTLD} '"$file"'; ) || result=1
+ try_trace "$file"
+ rc=$?
+ if [ $rc = 5 ]; then
+ try_trace "$RTLD" "$file"
+ rc=$?
+ fi
+ [ $rc = 0 ] || result=1
;;
1)
# This can be a non-ELF binary or no binary at all.
@@ -168,7 +188,7 @@ warning: you do not have execution permission for" "\`$file'" >&2
}
;;
2)
- eval $add_env \${RTLD} '"$file"' || result=1
+ try_trace "$RTLD" "$file" || result=1
;;
*)
echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($ret)" >&2