From f037a3f8119ed33677882aae03a9b6b5ee01a94d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 11 Mar 2015 12:13:38 -0500 Subject: [PATCH] Minor optimizations to redunce unnecessary forking --- testssl.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/testssl.sh b/testssl.sh index 356d3da..5cda096 100755 --- a/testssl.sh +++ b/testssl.sh @@ -270,7 +270,7 @@ wait_kill(){ pid=$1 maxsleep=$2 while true; do - if ! ps ax | grep -v grep | grep -q $pid; then + if ! ps $pid 2>&1 >/dev/null; then return 0 # didn't reach maxsleep yet fi sleep 1 @@ -702,7 +702,7 @@ sockread() { pid=$! while true; do - if ! ps ax | grep -v grep | grep -q $pid; then + if ! ps $pid 2>&1 >/dev/null; then break # didn't reach maxsleep yet kill $pid >&2 2>/dev/null fi @@ -712,7 +712,7 @@ sockread() { done #FIXME: cleanup, we have extra function for this now - if ps ax | grep -v grep | grep -q $pid; then + if ps $pid 2>&1 >/dev/null; then # time's up and dd is still alive --> timeout kill $pid wait $pid 2>/dev/null @@ -858,7 +858,7 @@ testversion() { $OPENSSL s_client -state $1 $STARTTLS -connect $NODEIP:$PORT $sni &>$TMPFILE &1 >/dev/null; then # time's up and dd is still alive --> timeout kill $pid >&2 2>/dev/null wait $pid 2>/dev/null @@ -2188,7 +2188,7 @@ ssl_poodle() { local cbc_ciphers pr_bold " POODLE, SSL"; out " (CVE-2014-3566), experimental " - cbc_ciphers=`$OPENSSL ciphers -v 'ALL:eNULL' | grep CBC | awk '{ print $1 }' | tr '\n' ':'` + cbc_ciphers=`$OPENSSL ciphers -v 'ALL:eNULL' | awk '/CBC/ { print $1 }' | tr '\n' ':'` debugme echo $cbc_ciphers $OPENSSL s_client -ssl3 $STARTTLS -cipher $cbc_ciphers -connect $NODEIP:$PORT $SNI &>$TMPFILE /dev/null >/dev/null if [ $? -eq 0 ]; then # Linux: - IP4=`getent ahostsv4 $NODE 2>/dev/null | grep -v ':' | grep STREAM | awk '{ print $1}' | uniq` + IP4=`getent ahostsv4 $NODE 2>/dev/null | grep -v ':' | awk '/STREAM/ { print $1}' | uniq` #else # IP4=`getent hosts $NODE 2>/dev/null | grep -v ':' | awk '{ print $1}' | uniq` #FIXME: FreeBSD returns only one entry