[PATCH] Use correct exit status in ldd (bug 24150)

Carlos O'Donell codonell@redhat.com
Mon Feb 3 15:57:00 GMT 2020


On 2/3/20 6:25 AM, Andreas Schwab wrote:
> The message "not a dynamic executable" is not an error, so don't exit with
> a nonzero status.

I don't consider that a strong enough reason to make this change given the
potential for breaking scripts that use ldd.

Existing scripts can use ldd to test if a file is a valid dynamic executable,
and may be relying on that behaviour.

Florian only just had eu-elfclassify added to elfutils to help classify binaries
so we could avoid needlessly using ldd for such purposes, but this is relatively
new.

In summary:
- I'd like to see a strong reason to change this.
- User scripts should use eu-elfclassify, but may continue to use ldd.

> ---
>  elf/ldd.bash.in | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
> index 467cbf44e9..a879ddd640 100644
> --- a/elf/ldd.bash.in
> +++ b/elf/ldd.bash.in
> @@ -166,10 +166,7 @@ warning: you do not have execution permission for" "\`$file'" >&2
>      case $ret in
>      1)
>        # This can be a non-ELF binary or no binary at all.
> -      nonelf "$file" || {
> -	echo $"	not a dynamic executable" >&2
> -	result=1
> -      }
> +      nonelf "$file" || echo $"	not a dynamic executable"

If all rtld in ${RTLDLIST} are non-executable this will cause the script to return
success when it should not.

>        ;;
>      0|2)
>        try_trace "$RTLD" "$file" || result=1
> 


-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list