Skip to content

Commit cd7a887

Browse files
committed
Fix port problem for Opossum
This fixes #2847 . It was falsely assumed that the http head command blocks when port 80 is not available but actucally the exec for the socket is the culprit. This PR changes that so that the exec is put in the background. Another change is that $node is still used but the port is stripped of which lead to the problem raised in #2847. We use $node instead of $NODE has we can recycle the `http_head[er]_printf()` later. `http_header_printf()`was renamed to `http_head_printf()` as there's also an `http_head()` and an `http_get()`
1 parent a719c46 commit cd7a887

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

testssl.sh

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,50 +1922,50 @@ http_head() {
19221922
# arg2: extra http header
19231923
#
19241924
# return codes:
1925-
# 0: all fine
1926-
# 1: server dind't respond within HEADER_MAXSLEEP
1927-
# 3: server dind't respond within HEADER_MAXSLEEP and PROXY was defined
1925+
# 0: all fine (response header is returned as string)
1926+
# 1: server didn't respond within HEADER_MAXSLEEP
1927+
# 3: server didn't respond within HEADER_MAXSLEEP and PROXY was defined
19281928
#
1929-
http_header_printf() {
1929+
http_head_printf() {
19301930
local request_header="$2"
19311931
local useragent="$UA_STD"
1932-
local tmpfile=$TEMPDIR/$NODE.$NODEIP.http_header_printf.log
1933-
local errfile=$TEMPDIR/$NODE.$NODEIP.http_header_printf-err.log
1932+
local tmpfile=$TEMPDIR/$NODE.$NODEIP.http_head_printf.log
1933+
local errfile=$TEMPDIR/$NODE.$NODEIP.http_head_printf-err.log
19341934
local -i ret=0
19351935
local proto="" foo="" node="" query=""
19361936

19371937
[[ $DEBUG -eq 0 ]] && errfile=/dev/null
19381938

19391939
IFS=/ read -r proto foo node query <<< "$1"
1940-
exec 33<>/dev/tcp/$node/80
1941-
printf -- "%b" "HEAD ${proto}//${node}/${query} HTTP/1.1\r\nUser-Agent: ${useragent}\r\nHost: ${node}\r\n${request_header}\r\nAccept: */*\r\n\r\n\r\n" >&33 2>$errfile &
1940+
node=${node%:*}
1941+
# $node works here good as it connects via IPv6 first, then IPv4
1942+
bash -c "exec 33<>/dev/tcp/$node/80" >/dev/null &
19421943
wait_kill $! $HEADER_MAXSLEEP
19431944
if [[ $? -ne 0 ]]; then
1944-
# not killed
1945+
# not killed --> socket open. Now we connect to the virtual host "$node"
1946+
printf -- "%b" "HEAD ${proto}//${node}/${query} HTTP/1.1\r\nUser-Agent: ${useragent}\r\nHost: ${node}\r\n${request_header}\r\nAccept: */*\r\n\r\n\r\n" >&33 2>$errfile
1947+
ret=0
1948+
if [[ $DEBUG -eq 0 ]] ; then
1949+
cat <&33
1950+
else
1951+
cat <&33 >$tmpfile
1952+
cat $tmpfile
1953+
fi
1954+
else
19451955
if [[ -n "$PROXY" ]]; then
19461956
ret=3
1957+
else
1958+
ret=1
19471959
fi
1948-
ret=1
1949-
else
1950-
ret=0
1951-
fi
1952-
if [[ $DEBUG -eq 0 ]] ; then
1953-
cat <&33
1954-
else
1955-
cat <&33 >$tmpfile
1956-
cat $tmpfile
19571960
fi
1958-
exec 33<&-
1961+
exec 33<&-
19591962
exec 33>&-
19601963
return $ret
19611964
}
19621965

19631966

19641967
ldap_get() {
19651968
local ldif
1966-
local -i success
1967-
local crl="$1"
1968-
local tmpfile="$2"
19691969
local jsonID="$3"
19701970

19711971
if type -p curl &>/dev/null; then
@@ -17703,7 +17703,7 @@ run_opossum() {
1770317703
case $service in
1770417704
HTTP)
1770517705
uri=${URI/https:\/\//}
17706-
response=$(http_header_printf http://${uri} 'Upgrade: TLS/1.0\r\n\r\nClose\r\n')
17706+
response=$(http_head_printf http://${uri} 'Upgrade: TLS/1.0\r\n\r\nClose\r\n')
1770717707
# In any case we use $response but we handle the return codes
1770817708
case $? in
1770917709
0) ret=0 ;;

0 commit comments

Comments
 (0)