From 7b61382c76835cf9f65a0929d87c3727a3a623e5 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Thu, 12 Mar 2009 06:31:42 +0100 Subject: [PATCH] end-close "did not apply" to some addresses --- CHANGES | 4 ++++ VERSION | 2 +- test.sh | 33 ++++++++++++++++++++++++++++++++- xio-pty.c | 6 +++--- xio-socket.c | 4 ++-- xio-unix.c | 9 +++++---- 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 4fe6ee3..fe69fbf 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +corrections: + option end-close "did not apply" to addresses PTY, SOCKET-CONNECT, + and most UNIX-* and ABSTRACT-* + ####################### V 1.7.0.0: new features: diff --git a/VERSION b/VERSION index bd51149..3cad7f2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -"1.7.0.0" +"1.7.0.0+endclose" diff --git a/test.sh b/test.sh index 3ff4cfb..f6e1421 100755 --- a/test.sh +++ b/test.sh @@ -1,6 +1,6 @@ #! /bin/bash # source: test.sh -# Copyright Gerhard Rieger 2001-2008 +# Copyright Gerhard Rieger 2001-2009 # Published under the GNU General Public License V.2, see file COPYING # perform lots of tests on socat @@ -7483,6 +7483,37 @@ esac N=$((N+1)) +# up to 1.7.0.0 option end-close led to an error with some address types due to +# bad internal handling. here we check it for address PTY +NAME=PTYENDCLOSE +case "$TESTS" in +*%functions%*|*%bugs%*|*%pty%*|*%$NAME%*) +TEST="$NAME: PTY handles option end-close" +# with the bug, socat exits with error. we invoke socat in a no-op mode and +# check its return status. +if ! eval $NUMCOND; then :; + else +tf="$td/test$N.stout" +te="$td/test$N.stderr" +CMD="$SOCAT $opts /dev/null pty,end-close" +printf "test $F_n $TEST... " $N +$CMD 2>"${te}" +rc=$? +if [ "$rc" = 0 ]; then + $PRINTF "$OK\n" + numOK=$((numOK+1)) +else + $PRINTF "$FAILED\n" + echo "$CMD" + cat "${te}" + numFAIL=$((numFAIL+1)) +fi +fi # NUMCOND + ;; +esac +N=$((N+1)) + + NAME=UDP6LISTENBIND # this tests for a bug in (up to) 1.5.0.0: # with udp*-listen, the bind option supported only IPv4 diff --git a/xio-pty.c b/xio-pty.c index 290f676..1f7d7d3 100644 --- a/xio-pty.c +++ b/xio-pty.c @@ -1,5 +1,5 @@ /* source: xio-pty.c */ -/* Copyright Gerhard Rieger 2002-2008 */ +/* Copyright Gerhard Rieger 2002-2009 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for creating pty addresses */ @@ -49,8 +49,8 @@ static int xioopen_pty(int argc, const char *argv[], struct opt *opts, int xiofl xfd->stream.howtoend = END_CLOSE; - applyopts(-1, opts, PH_INIT); if (applyopts_single(&xfd->stream, opts, PH_INIT) < 0) return -1; + applyopts(-1, opts, PH_INIT); retropt_bool(opts, OPT_UNLINK_CLOSE, &opt_unlink_close); @@ -82,8 +82,8 @@ static int xioopen_pty(int argc, const char *argv[], struct opt *opts, int xiofl retropt_timespec(opts, OPT_PTY_INTERVALL, &pollintv); #endif /* HAVE_POLL */ - applyopts2(-1, opts, PH_INIT, PH_EARLY); if (applyopts_single(&xfd->stream, opts, PH_INIT) < 0) return -1; + applyopts2(-1, opts, PH_INIT, PH_EARLY); applyopts(-1, opts, PH_PREBIGEN); diff --git a/xio-socket.c b/xio-socket.c index a28710f..9e780ef 100644 --- a/xio-socket.c +++ b/xio-socket.c @@ -1,5 +1,5 @@ /* source: xio-socket.c */ -/* Copyright Gerhard Rieger 2001-2008 */ +/* Copyright Gerhard Rieger 2001-2009 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for socket related functions, and the @@ -237,8 +237,8 @@ int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts, /*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/ xfd->howtoend = END_SHUTDOWN; - applyopts(-1, opts, PH_INIT); if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; + applyopts(-1, opts, PH_INIT); applyopts(-1, opts, PH_EARLY); themlen = 0; diff --git a/xio-unix.c b/xio-unix.c index e3c7d78..e45a3fa 100644 --- a/xio-unix.c +++ b/xio-unix.c @@ -1,5 +1,5 @@ /* source: xio-unix.c */ -/* Copyright Gerhard Rieger 2001-2008 */ +/* Copyright Gerhard Rieger 2001-2009 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses of UNIX socket type */ @@ -155,6 +155,7 @@ static int xioopen_unix_listen(int argc, const char *argv[], struct opt *opts, i } } + if (applyopts_single(xfd, opts, PH_INIT) < 0) return STAT_NORETRY; applyopts(-1, opts, PH_INIT); applyopts(-1, opts, PH_EARLY); @@ -227,8 +228,8 @@ static int xioopen_unix_connect(int argc, const char *argv[], struct opt *opts, xfd->opt_unlink_close = true; } - applyopts(-1, opts, PH_INIT); if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; + applyopts(-1, opts, PH_INIT); applyopts(-1, opts, PH_EARLY); if ((result = @@ -290,8 +291,8 @@ static int xioopen_unix_sendto(int argc, const char *argv[], struct opt *opts, i xfd->opt_unlink_close = true; } - applyopts(-1, opts, PH_INIT); if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; + applyopts(-1, opts, PH_INIT); return _xioopen_dgram_sendto(needbind?&us:NULL, uslen, @@ -463,8 +464,8 @@ _xioopen_unix_client(xiosingle_t *xfd, int xioflags, unsigned groups, struct opt *opts0; int result; - applyopts(-1, opts, PH_INIT); if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; + applyopts(-1, opts, PH_INIT); xfd->howtoend = END_SHUTDOWN; retropt_socket_pf(opts, &pf);