From 33c7902247bccc97e1dc1a291ca41ab93e7ba589 Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 16 Oct 2018 15:32:11 +0200 Subject: [PATCH] Check requirements on missing binaries As #1146 noted some installations miss hexdump. Better practice is to check before what's needed albeit the error message when a binary is missing does give the user a hint. --- testssl.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/testssl.sh b/testssl.sh index f1907bb..3eb1822 100755 --- a/testssl.sh +++ b/testssl.sh @@ -17392,6 +17392,16 @@ create_cmd_line_string() { printf '%s\n' "${allargs[*]}" } +check_base_requirements() { + local binary='' + + for binary in 'hexdump' 'dd' 'grep' 'awk' 'tr' 'sed' 'date' 'cat' 'ps' 'kill' 'head' 'tail' 'dirname'; do + if ! type -p "${binary}" &> /dev/null; then + fatal "You need to install ${binary} for this program to work" $ERR_RESOURCE + fi + done +} + parse_cmd_line() { local outfile_arg="" local cipher_mapping @@ -18031,6 +18041,7 @@ lets_roll() { lets_roll init initialize_globals + check_base_requirements # needs to come after $do_html is defined parse_cmd_line "$@" # html_header() needs to be called early! Otherwise if html_out() is called before html_header() and the # command line contains --htmlfile or --html, it'll make problems with html output, see #692.