minor cleanups for finding openssl binaries

This commit is contained in:
Dirk Wetter 2015-09-04 10:04:56 +02:00
parent 13b4497e8e
commit 422b4d511a

View File

@ -3563,6 +3563,7 @@ get_install_dir() {
test_openssl_suffix() { test_openssl_suffix() {
local naming_ext="$(uname).$(uname -m)" local naming_ext="$(uname).$(uname -m)"
local uname_arch="$(uname -m)" local uname_arch="$(uname -m)"
local myarch_suffix=""
[[ $uname_arch =~ 64 ]] && myarch_suffix=64 || myarch_suffix=32 [[ $uname_arch =~ 64 ]] && myarch_suffix=64 || myarch_suffix=32
if [[ -f "$1/openssl" ]] && [[ -x "$1/openssl" ]]; then if [[ -f "$1/openssl" ]] && [[ -x "$1/openssl" ]]; then
@ -3574,22 +3575,21 @@ test_openssl_suffix() {
elif [[ -f "$1/openssl.$uname_arch" ]] && [[ -x "$1/openssl.$uname_arch" ]]; then elif [[ -f "$1/openssl.$uname_arch" ]] && [[ -x "$1/openssl.$uname_arch" ]]; then
OPENSSL="$1/openssl.$uname_arch" OPENSSL="$1/openssl.$uname_arch"
return 0 return 0
elif [[ -f "$1/openssl$myarch_suffix" ]] && [[ -x "$1/openssl$myarch_suffix" ]]; then
OPENSSL="$1/openssl$myarch_suffix"
return 0
fi fi
return 1 return 1
} }
find_openssl_binary() { find_openssl_binary() {
local myarch_suffix=""
local uname_arch=$(uname -m)
[[ $uname_arch =~ 64 ]] && myarch_suffix=64 || myarch_suffix=32
# 0. check environment variable whether it's executable # 0. check environment variable whether it's executable
if [[ -n "$OPENSSL" ]] && [[ ! -x "$OPENSSL" ]]; then if [[ -n "$OPENSSL" ]] && [[ ! -x "$OPENSSL" ]]; then
pr_litemagentaln "\ncannot find specified (\$OPENSSL=$OPENSSL) binary." pr_litemagentaln "\ncannot find specified (\$OPENSSL=$OPENSSL) binary."
outln " Looking some place else ..." outln " Looking some place else ..."
elif [[ -x "$OPENSSL" ]]; then elif [[ -x "$OPENSSL" ]]; then
: # 1. all ok supplied $OPENSSL is excutable : # 1. all ok supplied $OPENSSL was found and has excutable bit set -- testrun comes below
elif test_openssl_suffix $RUN_DIR; then elif test_openssl_suffix $RUN_DIR; then
: # 2. otherwise try openssl in path of testssl.sh : # 2. otherwise try openssl in path of testssl.sh
elif test_openssl_suffix $RUN_DIR/bin; then elif test_openssl_suffix $RUN_DIR/bin; then
@ -3598,10 +3598,10 @@ find_openssl_binary() {
: # 5. we tried hard and failed, so now we use the system binaries : # 5. we tried hard and failed, so now we use the system binaries
fi fi
# no ERRFILE initialized yet # no ERRFILE initialized yet, thus we use /dev/null for stderr directly
$OPENSSL version -a 2>/dev/null >/dev/null $OPENSSL version -a 2>/dev/null >/dev/null
if [[ $? -ne 0 ]] || [[ ! -x "$OPENSSL" ]]; then if [[ $? -ne 0 ]] || [[ ! -x "$OPENSSL" ]]; then
fatal "cannot exec or find any openssl binary" -1 fatal "\ncannot exec or find any openssl binary" -1
fi fi
# http://www.openssl.org/news/openssl-notes.html # http://www.openssl.org/news/openssl-notes.html
@ -3622,7 +3622,7 @@ find_openssl_binary() {
if $OPENSSL version 2>/dev/null | grep -qi LibreSSL; then if $OPENSSL version 2>/dev/null | grep -qi LibreSSL; then
outln outln
pr_litemagenta "Please note: LibreSSL is not a good choice for testing insecure features!" pr_litemagenta "Please note: LibreSSL is not a good choice for testing INSECURE features!"
fi fi
$OPENSSL s_client -ssl2 2>&1 | grep -aq "unknown option" || \ $OPENSSL s_client -ssl2 2>&1 | grep -aq "unknown option" || \
@ -4816,4 +4816,4 @@ fi
exit $ret exit $ret
# $Id: testssl.sh,v 1.370 2015/09/03 11:26:01 dirkw Exp $ # $Id: testssl.sh,v 1.371 2015/09/04 08:04:55 dirkw Exp $