1
0
mirror of https://github.com/moparisthebest/socat synced 2024-12-21 22:48:48 -05:00

option end-close "did not apply" with some address types

This commit is contained in:
Gerhard Rieger 2009-03-31 23:22:06 +02:00
commit 4a42088332
6 changed files with 44 additions and 9 deletions

View File

@ -8,6 +8,9 @@ corrections:
connections with option connect-timeout fail when the connections connections with option connect-timeout fail when the connections
succeeded. Thanks to Bruno De Fraine for reporting this bug. succeeded. Thanks to Bruno De Fraine for reporting this bug.
option end-close "did not apply" to addresses PTY, SOCKET-CONNECT,
and most UNIX-* and ABSTRACT-*
half close of EXEC and SYSTEM addresses did not work for pipes and half close of EXEC and SYSTEM addresses did not work for pipes and
sometimes socketpair sometimes socketpair

View File

@ -1 +1 @@
"1.7.0.0+execshut+connecttimeout+segvonaccept" "1.7.0.0+execshut+connecttimeout+segvonaccept+endclose"

31
test.sh
View File

@ -7527,6 +7527,37 @@ esac
N=$((N+1)) 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 NAME=UDP6LISTENBIND
# this tests for a bug in (up to) 1.5.0.0: # this tests for a bug in (up to) 1.5.0.0:
# with udp*-listen, the bind option supported only IPv4 # with udp*-listen, the bind option supported only IPv4

View File

@ -1,5 +1,5 @@
/* source: xio-pty.c */ /* 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 */ /* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains the source for creating pty addresses */ /* 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; xfd->stream.howtoend = END_CLOSE;
applyopts(-1, opts, PH_INIT);
if (applyopts_single(&xfd->stream, opts, PH_INIT) < 0) return -1; 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); 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); retropt_timespec(opts, OPT_PTY_INTERVALL, &pollintv);
#endif /* HAVE_POLL */ #endif /* HAVE_POLL */
applyopts2(-1, opts, PH_INIT, PH_EARLY);
if (applyopts_single(&xfd->stream, opts, PH_INIT) < 0) return -1; if (applyopts_single(&xfd->stream, opts, PH_INIT) < 0) return -1;
applyopts2(-1, opts, PH_INIT, PH_EARLY);
applyopts(-1, opts, PH_PREBIGEN); applyopts(-1, opts, PH_PREBIGEN);

View File

@ -237,8 +237,8 @@ int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts,
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/ /*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
xfd->howtoend = END_SHUTDOWN; xfd->howtoend = END_SHUTDOWN;
applyopts(-1, opts, PH_INIT);
if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1;
applyopts(-1, opts, PH_INIT);
applyopts(-1, opts, PH_EARLY); applyopts(-1, opts, PH_EARLY);
themlen = 0; themlen = 0;

View File

@ -1,5 +1,5 @@
/* source: xio-unix.c */ /* 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 */ /* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains the source for opening addresses of UNIX socket type */ /* 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_INIT);
applyopts(-1, opts, PH_EARLY); 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; xfd->opt_unlink_close = true;
} }
applyopts(-1, opts, PH_INIT);
if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1;
applyopts(-1, opts, PH_INIT);
applyopts(-1, opts, PH_EARLY); applyopts(-1, opts, PH_EARLY);
if ((result = 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; xfd->opt_unlink_close = true;
} }
applyopts(-1, opts, PH_INIT);
if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1;
applyopts(-1, opts, PH_INIT);
return return
_xioopen_dgram_sendto(needbind?&us:NULL, uslen, _xioopen_dgram_sendto(needbind?&us:NULL, uslen,
@ -463,8 +464,8 @@ _xioopen_unix_client(xiosingle_t *xfd, int xioflags, unsigned groups,
struct opt *opts0; struct opt *opts0;
int result; int result;
applyopts(-1, opts, PH_INIT);
if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1;
applyopts(-1, opts, PH_INIT);
xfd->howtoend = END_SHUTDOWN; xfd->howtoend = END_SHUTDOWN;
retropt_socket_pf(opts, &pf); retropt_socket_pf(opts, &pf);