diff --git a/CHANGES b/CHANGES index de9ddb6..c0c0b98 100644 --- a/CHANGES +++ b/CHANGES @@ -61,6 +61,11 @@ porting: functions and dependend option openssl-method can still be used when configuring socat with --enable-openssl-method + Shell scripts in socat distribution are now headed with: + #! /usr/bin/env bash + to make them better portable to systems without /bin/bash + Thanks to Maya Rashish for sending a patch + testing: test.sh: Show a warning when phase-1 (insecure phase) of a security test fails diff --git a/FAQ b/FAQ index 51cd3c1..51d8c1b 100644 --- a/FAQ +++ b/FAQ @@ -24,8 +24,7 @@ Q: I succeeded to configure and make socat, but ./test.sh says something like: ./test.sh: No such file or directory -A: You need a bash shell, and its location must be correctly specified in the -first line of test.sh, e.g. /usr/local/bin/bash instead of /bin/bash. +A: You need a bash shell in your executable path (locations in $PATH) Q: configure disables readline / openssl / libwrap support because it does not diff --git a/proxy.sh b/proxy.sh index 230e298..6c24126 100755 --- a/proxy.sh +++ b/proxy.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash # source: proxy.sh # Copyright Gerhard Rieger and contributors (see file CHANGES) # Published under the GNU General Public License V.2, see file COPYING diff --git a/proxyecho.sh b/proxyecho.sh index 05acab4..db7efd5 100755 --- a/proxyecho.sh +++ b/proxyecho.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash # source: proxyecho.sh # Copyright Gerhard Rieger and contributors (see file CHANGES) # Published under the GNU General Public License V.2, see file COPYING diff --git a/readline-test.sh b/readline-test.sh index 7547794..26f392f 100755 --- a/readline-test.sh +++ b/readline-test.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash # source: readline-test.sh # Copyright Gerhard Rieger and contributors (see file CHANGES) # Published under the GNU General Public License V.2, see file COPYING diff --git a/readline.sh b/readline.sh index d377716..b6f8438 100755 --- a/readline.sh +++ b/readline.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash # source: readline.sh # Copyright Gerhard Rieger and contributors (see file CHANGES) # Published under the GNU General Public License V.2, see file COPYING diff --git a/socks4a-echo.sh b/socks4a-echo.sh index 499d1c6..7360366 100755 --- a/socks4a-echo.sh +++ b/socks4a-echo.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash # source: socks4a-echo.sh #set -vx diff --git a/socks4echo.sh b/socks4echo.sh index 129b02e..103719a 100755 --- a/socks4echo.sh +++ b/socks4echo.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash # source: socks4echo.sh # Copyright Gerhard Rieger and contributors (see file CHANGES) diff --git a/test.sh b/test.sh index e9a77d3..d304912 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash # source: test.sh # Copyright Gerhard Rieger and contributors (see file CHANGES) # Published under the GNU General Public License V.2, see file COPYING @@ -750,7 +750,7 @@ for addr in proxy; do done echo $OPTS # prepare dummy server - $SOCAT tcp-l:$PORT,reuseaddr,crlf exec:"/bin/bash proxyecho.sh" || echo "cannot start proxyecho.sh" >&2 & + $SOCAT tcp-l:$PORT,reuseaddr,crlf exec:"/usr/bin/env bash proxyecho.sh" || echo "cannot start proxyecho.sh" >&2 & pid=$! sleep 1 for o in $(filloptionvalues $OPTS|tr ',' ' '); do @@ -1951,7 +1951,7 @@ waitip4proto () { while [ $timeout -gt 0 ]; do case "$UNAME" in Linux) if [ "$SS" ]; then - l=$($SS -n -w -l |grep '^raw .* .*[0-9*]:'$proto' [ ]*0\.0\.0\.0:\*') + l=$($SS -n -w -l |grep '^\(raw\|UNCONN\) .* .*[0-9*]:'$proto' [ ]*0\.0\.0\.0:\*') else l=$(netstat -n -w -l |grep '^raw .* .*[0-9*]:'$proto' [ ]*0\.0\.0\.0:\*') fi ;; @@ -1997,7 +1997,7 @@ waitip6proto () { case "$UNAME" in Linux) if [ "$SS" ]; then - l=$($SS -n -w -l |grep '^raw .* .*[0-9*]:'$proto' [ ]*0\.0\.0\.0:\*') + l=$($SS -n -w -l |grep '^\(raw\|UNCONN\) .* \*:'$proto' [ ]*\*:\*') else l=$(netstat -n -w -l |grep '^raw[6 ] .* .*:[0-9*]*:'$proto' [ ]*:::\*') fi ;; @@ -4648,7 +4648,7 @@ te="$td/test$N.stderr" tdiff="$td/test$N.diff" da="test$N $(date) $RANDOM"; da="$da$($ECHO '\r')" #CMD2="$TRACE $SOCAT tcp4-l:$PORT,crlf SYSTEM:\"read; read; $ECHO \\\"HTTP/1.0 200 OK\n\\\"; cat\"" -CMD2="$TRACE $SOCAT $opts tcp4-l:$PORT,reuseaddr,crlf exec:\"/bin/bash proxyecho.sh\"" +CMD2="$TRACE $SOCAT $opts tcp4-l:$PORT,reuseaddr,crlf exec:\"/usr/bin/env bash proxyecho.sh\"" CMD="$TRACE $SOCAT $opts - proxy:$LOCALHOST:127.0.0.1:1000,pf=ip4,proxyport=$PORT" printf "test $F_n $TEST... " $N eval "$CMD2 2>\"${te}2\" &" @@ -4694,7 +4694,7 @@ te="$td/test$N.stderr" tdiff="$td/test$N.diff" da="test$N $(date) $RANDOM"; da="$da$($ECHO '\r')" #CMD2="$TRACE $SOCAT $opts tcp6-l:$PORT,crlf SYSTEM:\"read; read; $ECHO \\\"HTTP/1.0 200 OK\n\\\"; cat\"" -CMD2="$TRACE $SOCAT $opts tcp6-l:$PORT,reuseaddr,crlf exec:\"/bin/bash proxyecho.sh\"" +CMD2="$TRACE $SOCAT $opts tcp6-l:$PORT,reuseaddr,crlf exec:\"/usr/bin/env bash proxyecho.sh\"" CMD="$TRACE $SOCAT $opts - proxy:$LOCALHOST6:127.0.0.1:1000,proxyport=$PORT" printf "test $F_n $TEST... " $N eval "$CMD2 2>\"${te}2\" &" @@ -4928,7 +4928,7 @@ te="$td/test$N.stderr" tdiff="$td/test$N.diff" da="test$N $(date) $RANDOM"; da="$da$($ECHO '\r')" #CMD2="$TRACE $SOCAT $opts tcp-l:$PORT,crlf SYSTEM:\"read; read; $ECHO \\\"HTTP/1.0 200 OK\n\\\"; cat\"" -CMD2="$TRACE $SOCAT $opts tcp4-l:$PORT,reuseaddr,crlf exec:\"/bin/bash proxyecho.sh -w 2\"" +CMD2="$TRACE $SOCAT $opts tcp4-l:$PORT,reuseaddr,crlf exec:\"/usr/bin/env bash proxyecho.sh -w 2\"" CMD="$TRACE $SOCAT $opts - proxy:$LOCALHOST:127.0.0.1:1000,pf=ip4,proxyport=$PORT" printf "test $F_n $TEST... " $N eval "$CMD2 2>\"${te}1\" &" @@ -6436,10 +6436,10 @@ tp="$td/test$N.pid" $PRINTF "test $F_n $TEST... " $N (sleep 1; kill -"$SIG" "$(cat "$tpp")") & # a simple "system:echo $PPID..." does not work on NetBSD, OpenBSD -#$TRACE $SOCAT $opts echo SYSTEM:'exec /bin/bash -c "echo \$PPID '">$tpp"'; echo \$$ '">$tp; read x\"",nofork 2>"$te"; stat=$? +#$TRACE $SOCAT $opts echo SYSTEM:'exec /usr/bin/env bash -c "echo \$PPID '">$tpp"'; echo \$$ '">$tp; read x\"",nofork 2>"$te"; stat=$? tsh="$td/test$N.sh" cat <"$tsh" -#! /bin/bash +#! /usr/bin/env bash echo \$PPID >"$tpp" echo \$\$ >"$tp" read x