mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
UNIX-CONNECT did not support half-close
This commit is contained in:
parent
2e385902c0
commit
e0d548df71
3 changed files with 43 additions and 16 deletions
3
CHANGES
3
CHANGES
|
@ -11,6 +11,9 @@ corrections:
|
||||||
UDP-LISTEN would alway set SO_REUSEADDR even without fork option and
|
UDP-LISTEN would alway set SO_REUSEADDR even without fork option and
|
||||||
when user set it to 0. Thanks to Michal Svoboda for reporting this bug.
|
when user set it to 0. Thanks to Michal Svoboda for reporting this bug.
|
||||||
|
|
||||||
|
UNIX-CONNECT did not support half-close. Thanks to Greg Hughes who
|
||||||
|
pointed me to that bug
|
||||||
|
|
||||||
####################### V 1.7.1.3:
|
####################### V 1.7.1.3:
|
||||||
|
|
||||||
security:
|
security:
|
||||||
|
|
54
test.sh
54
test.sh
|
@ -3772,32 +3772,39 @@ esac
|
||||||
PORT=$((PORT+1))
|
PORT=$((PORT+1))
|
||||||
N=$((N+1))
|
N=$((N+1))
|
||||||
|
|
||||||
# does our OpenSSL implementation support halfclose?
|
|
||||||
NAME=OPENSSLEOF
|
while read NAMEKEYW TESTTMPL PEERTMPL WAITTMPL; do
|
||||||
|
if [ -z "$NAMEKEYW" ] || [[ "$NAMEKEYW" == \#* ]]; then continue; fi
|
||||||
|
|
||||||
|
export ts="$td/test$N.socket"
|
||||||
|
WAITTMPL="$(echo "$WAITTMPL" |sed -e 's/\040/ /g')"
|
||||||
|
TESTADDR=$(eval echo $TESTTMPL)
|
||||||
|
PEERADDR=$(eval echo $PEERTMPL)
|
||||||
|
WAITCMD=$(eval echo $WAITTMPL)
|
||||||
|
TESTKEYW=${TESTADDR%%:*}
|
||||||
|
|
||||||
|
# does our address implementation support halfclose?
|
||||||
|
NAME=${NAMEKEYW}_HALFCLOSE
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%openssl%*|*%tcp%*|*%tcp4%*|*%ip4%*|*%$NAME%*)
|
*%functions%*|*%socket%*|*%halfclose%*|*%$NAME%*)
|
||||||
TEST="$NAME: openssl half close"
|
TEST="$NAME: $TESTKEYW half close"
|
||||||
# have an SSL server that executes "$OD_C" and see if EOF on the SSL client
|
# have a "peer" socat "peer" that executes "$OD_C" and see if EOF on the
|
||||||
# brings the result of od to the client
|
# connecting socat brings the result of od
|
||||||
if ! eval $NUMCOND; then :;
|
if ! eval $NUMCOND; then :;
|
||||||
elif ! testaddrs openssl >/dev/null; then
|
#elif ! testaddrs unix >/dev/null; then
|
||||||
$PRINTF "test $F_n $TEST... ${YELLOW}OPENSSL not available${NORMAL}\n" $N
|
# $PRINTF "test $F_n $TEST... ${YELLOW}UNIX not available${NORMAL}\n" $N
|
||||||
numCANT=$((numCANT+1))
|
# numCANT=$((numCANT+1))
|
||||||
elif ! testaddrs listen tcp ip4 >/dev/null || ! runsip4 >/dev/null; then
|
|
||||||
$PRINTF "test $F_n $TEST... ${YELLOW}TCP/IPv4 not available${NORMAL}\n" $N
|
|
||||||
numCANT=$((numCANT+1))
|
|
||||||
else
|
else
|
||||||
gentestcert testsrv
|
|
||||||
tf="$td/test$N.stdout"
|
tf="$td/test$N.stdout"
|
||||||
te="$td/test$N.stderr"
|
te="$td/test$N.stderr"
|
||||||
tdiff="$td/test$N.diff"
|
tdiff="$td/test$N.diff"
|
||||||
da="test$N $(date) $RANDOM"
|
da="test$N $(date) $RANDOM"
|
||||||
CMD2="$SOCAT $opts OPENSSL-LISTEN:$PORT,pf=ip4,reuseaddr,$SOCAT_EGD,cert=testsrv.crt,key=testsrv.key,verify=0 exec:'$OD_C'"
|
CMD2="$SOCAT $opts \"$PEERADDR\" EXEC:'$OD_C'"
|
||||||
CMD="$SOCAT -T1 $OPTS - openssl:$LOCALHOST:$PORT,verify=0,$SOCAT_EGD"
|
CMD="$SOCAT -T1 $opts - $TESTADDR"
|
||||||
printf "test $F_n $TEST... " $N
|
printf "test $F_n $TEST... " $N
|
||||||
eval "$CMD2 2>\"${te}1\" &"
|
eval "$CMD2 2>\"${te}1\" &"
|
||||||
pid=$! # background process id
|
pid=$! # background process id
|
||||||
waittcp4port $PORT
|
$WAITCMD
|
||||||
echo "$da" |$CMD >$tf 2>"${te}2"
|
echo "$da" |$CMD >$tf 2>"${te}2"
|
||||||
if ! echo "$da" |$OD_C |diff - "$tf" >"$tdiff"; then
|
if ! echo "$da" |$OD_C |diff - "$tf" >"$tdiff"; then
|
||||||
$PRINTF "$FAILED: $SOCAT:\n"
|
$PRINTF "$FAILED: $SOCAT:\n"
|
||||||
|
@ -3819,6 +3826,21 @@ esac
|
||||||
PORT=$((PORT+1))
|
PORT=$((PORT+1))
|
||||||
N=$((N+1))
|
N=$((N+1))
|
||||||
|
|
||||||
|
done <<<"
|
||||||
|
UNIXCONNECT UNIX-CONNECT:\$ts UNIX-LISTEN:\$ts waitfile\040\$ts
|
||||||
|
UNIXCLIENT UNIX-CLIENT:\$ts UNIX-LISTEN:\$ts waitfile\040\$ts
|
||||||
|
GOPEN_UNIXSTREAM GOPEN:\$ts UNIX-LISTEN:\$ts waitfile\040\$ts
|
||||||
|
UNIXLISTEN UNIX-LISTEN:\$ts UNIX-CONNECT:\$ts,retry=3 sleep\040\1
|
||||||
|
TCP4CONNECT TCP4-CONNECT:\$LOCALHOST:\$PORT TCP4-LISTEN:\$PORT waittcp4port\040\$PORT
|
||||||
|
TCP4LISTEN TCP4-LISTEN:\$PORT TCP4-CONNECT:\$LOCALHOST:\$PORT,retry=3
|
||||||
|
TCP6CONNECT TCP6-CONNECT:\$LOCALHOST6:\$PORT TCP6-LISTEN:\$PORT waittcp6port\040\$PORT
|
||||||
|
TCP6LISTEN TCP6-LISTEN:\$PORT TCP6-CONNECT:\$LOCALHOST6:\$PORT,retry=3
|
||||||
|
OPENSSL4CLIENT OPENSSL:\$LOCALHOST:\$PORT,verify=0 OPENSSL-LISTEN:\$PORT,$SOCAT_EGD,cert=testsrv.crt,key=testsrv.key,verify=0 waittcp4port\040\$PORT
|
||||||
|
OPENSSL4SERVER OPENSSL-LISTEN:\$PORT,$SOCAT_EGD,cert=testsrv.crt,key=testsrv.key,verify=0 OPENSSL:\$LOCALHOST:\$PORT,verify=0,retry=3
|
||||||
|
OPENSSL6CLIENT OPENSSL:\$LOCALHOST6:\$PORT,pf=ip6,verify=0 OPENSSL-LISTEN:\$PORT,pf=ip6,$SOCAT_EGD,cert=testsrv.crt,key=testsrv.key,verify=0 waittcp6port\040\$PORT
|
||||||
|
OPENSSL6SERVER OPENSSL-LISTEN:\$PORT,pf=ip6,$SOCAT_EGD,cert=testsrv.crt,key=testsrv.key,verify=0 OPENSSL:\$LOCALHOST:\$PORT,pf=ip6,verify=0,retry=3
|
||||||
|
"
|
||||||
|
|
||||||
|
|
||||||
NAME=OPENSSL_SERVERAUTH
|
NAME=OPENSSL_SERVERAUTH
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
|
|
|
@ -216,6 +216,8 @@ static int xioopen_unix_connect(int argc, const char *argv[], struct opt *opts,
|
||||||
return STAT_NORETRY;
|
return STAT_NORETRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xfd->howtoend = END_SHUTDOWN;
|
||||||
|
|
||||||
name = argv[1];
|
name = argv[1];
|
||||||
retropt_socket_pf(opts, &pf);
|
retropt_socket_pf(opts, &pf);
|
||||||
retropt_bool(opts, OPT_UNIX_TIGHTSOCKLEN, &tight);
|
retropt_bool(opts, OPT_UNIX_TIGHTSOCKLEN, &tight);
|
||||||
|
|
Loading…
Reference in a new issue