1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-05-24 05:32:41 +00:00

Small fixes with tests, logs, comments, and doc

This commit is contained in:
Gerhard 2025-02-17 20:39:06 +01:00
parent 9269897bab
commit 436d764029
6 changed files with 36 additions and 31 deletions

View file

@ -159,6 +159,8 @@ Testing:
Newer Linux distributions now deprecate usleep; replaced it in test.sh
UDPLITE4STREAM was trice, changed one of them to UDPLITE6STREAM.
Documentation:
Removed obsolete CHANGES.ISO-8859-1 file.
@ -1035,11 +1037,11 @@ Corrections:
Under certain conditions OpenSSL stream connections, in particular bulk
data transfer in unidirectional mode, failed during transfer or near
its with Connection reset by peer on receiver side.
its end with Connection reset by peer on receiver side.
This happened with Socat versions 1.7.3.3 to 1.7.4.0. Reasons were
lazy SSL shutdown handling on the sender side in combination with
SSL_MODE_AUTO_RETRY turned off.
Fix: After SSH_shutdown but before socket shutdown call SSL_read()
Fix: After SSL_shutdown() but before socket shutdown call SSL_read()
Test: OPENSSL_STREAM_TO_SERVER
Fixes Red Hat issue 1870279.

View file

@ -774,8 +774,8 @@ label(ADDRESS_SOCKETPAIR)dit(bf(tt(SOCKETPAIR)))
See also: link(unnamed pipe)(ADDRESS_UNNAMED_PIPE)
label(ADDRESS_POSIXMQ_READ)dit(bf(tt(POSIXMQ-READ:/<mqueue>)))
Opens the specified POSIX message queue and reads messages (packets). It
keeps the boundaries.nl()
Opens or creates the specified POSIX message queue and reads messages
(packets). It keeps the packet boundaries.nl()
This is a read-only address, see options link(-u)(option_u) and
link(-U)(option_U) and link(dual addresses)(ADDRESS_DUAL).nl()
Socat() provides this address type only on Linux because POSIX MQ is based
@ -791,7 +791,8 @@ label(ADDRESS_POSIXMQ_READ)dit(bf(tt(POSIXMQ-READ:/<mqueue>)))
label(ADDRESS_POSIXMQ_RECEIVE)dit(bf(tt(POSIXMQ-RECEIVE:/<mqueue>)))
dit(bf(tt(POSIXMQ-RECV:/<mqueue>)))
Opens the specified POSIX message queue and reads one message (packet).nl()
Opens or creates the specified POSIX message queue and reads one message
(packet).nl()
This is a read-only address. See link(POSIXMQ-READ)(ADDRESS_POSIXMQ_READ)
for more info.nl()
Example: link(POSIX MQ recv with fork)(EXAMPLE_POSIXMQ_RECV_FORK)nl()
@ -806,12 +807,14 @@ dit(bf(tt(POSIXMQ-RECV:/<mqueue>)))
link(umask)(OPTION_UMASK)
label(ADDRESS_POSIXMQ_SEND)dit(bf(tt(POSIXMQ-SEND:/<mqueue>)))
Opens the specified POSIX message queue and writes messages (packets).nl()
Opens or creates the specified POSIX message queue and writes messages
(packets).nl()
This is a write-only address. See link(POSIXMQ-READ)(ADDRESS_POSIXMQ_READ)
for more info.nl()
(link(Example)(EXAMPLE_POSIXMQ_SEND))nl()
Useful options:
link(posixmq-priority)(OPTION_POSIXMQ_PRIORITY),
link(posixmq-flush)(OPTION_POSIXMQ_FLUSH),
link(fork)(OPTION_FORK),
link(max-children)(OPTION_MAX_CHILDREN),
link(unlink-early)(OPTION_UNLINK_EARLY),
@ -822,8 +825,8 @@ label(ADDRESS_POSIXMQ_SEND)dit(bf(tt(POSIXMQ-SEND:/<mqueue>)))
label(ADDRESS_POSIXMQ_BIDIRECTIONAL)dit(bf(tt(POSIXMQ-BIDIRECTIONAL:/mqueue)))
dit(bf(tt(POSIXMQ:/mqueue)))
Opens the specified POSIX message queue in read and/or write mode depending
on context, then reads and/or writes messages (packets).
Opens or creates the specified POSIX message queue in read and/or write mode
depending on context, then reads and/or writes messages (packets).
In bidirectional mode this is just another echo service.nl()
See link(POSIXMQ-READ)(ADDRESS_POSIXMQ_READ) and
link(POSIXMQ-SEND)(ADDRESS_POSIXMQ_SEND) for more info.
@ -2180,8 +2183,8 @@ label(OPTION_SETSID)dit(bf(tt(setsid)))
Makes the process the leader of a new session (link(example)(EXAMPLE_OPTION_SETSID)).
label(OPTION_NETNS)dit(bf(tt(netns=<net-namespace-name>)))
Before opening the address it tries to switch to the named network namespace.
After opening the address it switches back to the previous namespace.
(link(Example with TCP forwarder)(EXAMPLE_OPTION_NETNS),
After opening the address it switches back to the previous namespace
(link(example with TCP forwarder)(EXAMPLE_OPTION_NETNS),
link(example with virtual network connection)(EXAMPLE_TUN_NETNS)).nl()
Only on Linux; requires root; use option tt(--experimental).nl()
enddit()
@ -2547,7 +2550,8 @@ dit(bf(tt(ipv6-join-source-group=<multicast-address:interface-index:source-addre
IPv4 variant. The option takes the IP address of the multicast group,
info about the desired network interface and the source IP address of the
multicast traffic. The indices of active network interfaces can be shown
using the utility procan().
using the utility procan().nl()
This feature is experimental.
label(OPTION_IP_MULTICAST_IF)
dit(bf(tt(ip-multicast-if=<hostname>)))
Specifies hostname or address of the network interface to be used for
@ -3520,11 +3524,11 @@ label(OPTION_POSIXMQ_FLUSH)dit(bf(tt(posixmq-flush (mq-flush))))
label(OPTION_POSIXMQ_MAXMSG)dit(bf(tt(posixmq-maxmsg (mq-maxmsg))))
Sets the maxmsg parameter of the POSIX message queue when creating it.
Note: You need root or CAP_SYS_RESOURCE to exceed the default value
(<tt>/proc/sys/fs/mqueue/msg_default</tt>).
(code(/proc/sys/fs/mqueue/msg_default)).
label(OPTION_POSIXMQ_MSGSIZE)dit(bf(tt(posixmq-msgsize (mq-msgsize))))
Sets the msgsize parameter of the POSIX message queue when creating it.
Note: You need root or CAP_SYS_RESOURCE to exceed the default value
(<tt>/proc/sys/fs/mqueue/msgsize_default</tt>).
(code(/proc/sys/fs/mqueue/msgsize_default)).
enddit()

View file

@ -2,7 +2,7 @@
# Copyright Gerhard Rieger and contributors (see file CHANGES)
# Published under the GNU General Public License V.2, see file COPYING
# Shell script to build a many-to-one, one-to-all communication
# Shell script to establish many-to-one, one-to-all communications.
# It starts two Socat instances that communicate via IPv4 broadcast,
# the first of which forks a child process for each connected client.

29
test.sh
View file

@ -296,7 +296,7 @@ FOPEN_MAX=$($PROCAN -c 2>/dev/null |grep '^#define[ ][ ]*FOPEN_MAX' |awk '{print
[ "$DEFS" ] && echo "FOPEN_MAX=\"$FOPEN_MAX\"" >&2
PF_INET6="$($PROCAN -c |grep "^#define[[:space:]]*PF_INET6[[:space:]]" |cut -d' ' -f3)"
[ "$DEFS" ] && echo "PF_INET6=\"$PF_INET6\"" >&2
TIOCEXCL="$($PROCAN -c |grep "^#define[[:space:]]*TIOCEXCL[[:space:]]" |cut -d' ' -f3)"
TIOCEXCL="$($PROCAN -c |grep "^#define[[:space:]]*TIOCEXCL[[:space:]]" |{ read _ _ v; echo "$v"; })"
[ "$DEFS" ] && echo "TIOCEXCL=\"$TIOCEXCL\"" >&2
SOL_SOCKET="$($PROCAN -c |grep "^#define[[:space:]]*SOL_SOCKET[[:space:]]" |cut -d' ' -f3)"
[ "$DEFS" ] && echo "SOL_SOCKET=\"$SOL_SOCKET\"" >&2
@ -715,7 +715,6 @@ numCANT=0
listOK=
listFAIL=
listCANT=
namesFAIL=
ok () {
numOK=$((numOK+1))
@ -762,7 +761,7 @@ testecho () {
#echo "$da" |$cmd >"$tf" 2>"$te"
{ sleep $T; echo "$da"; sleep $T; } | { $TRACE $SOCAT $opts "$arg1" "$arg2" >"$tf" 2>"$te"; echo $? >"$td/test$N.rc"; } &
pid1=$!
#sleep 5 && kill $rc1 2>/dev/null &
#sleep 5 && kill $pid1 2>/dev/null &
# rc2=$!
wait $pid1
# kill $rc2 2>/dev/null
@ -17969,7 +17968,7 @@ N=$((N+1))
NAME=UDPLITE4STREAM
case "$TESTS" in
*%$N%*|*%functions%*|*%ip4%*|*%ipapp%*|*%udplite%*|*%$NAME%*)
TEST="$NAME: echo via connection to UDP-Lite V4 socket"
TEST="$NAME: echo via connection to UDP-Lite IPv4 socket"
if ! eval $NUMCOND; then :;
elif ! cond=$(checkconds \
"" \
@ -18029,7 +18028,7 @@ N=$((N+1))
NAME=UDPLITE4STREAM
case "$TESTS" in
*%$N%*|*%functions%*|*%ip4%*|*%ipapp%*|*%udplite%*|*%$NAME%*)
TEST="$NAME: echo via connection to UDP-Lite V4 socket"
TEST="$NAME: echo via connection to UDP-Lite IPv4 socket"
if ! eval $NUMCOND; then :;
elif ! cond=$(checkconds \
"" \
@ -18086,19 +18085,19 @@ esac
N=$((N+1))
NAME=UDPLITE4STREAM
NAME=UDPLITE6STREAM
case "$TESTS" in
*%$N%*|*%functions%*|*%ip4%*|*%ipapp%*|*%udplite%*|*%$NAME%*)
TEST="$NAME: echo via connection to UDP-Lite V4 socket"
*%$N%*|*%functions%*|*%ip6%*|*%ipapp%*|*%udplite%*|*%$NAME%*)
TEST="$NAME: echo via connection to UDP-Lite IPv6 socket"
if ! eval $NUMCOND; then :;
elif ! cond=$(checkconds \
"" \
"" \
"" \
"IP4 UDPLITE LISTEN STDIO PIPE" \
"UDPLITE4-LISTEN PIPE STDIO UDPLITE4" \
"IP6 UDPLITE LISTEN STDIO PIPE" \
"UDPLITE6-LISTEN PIPE STDIO UDPLITE6" \
"so-reuseaddr" \
"udplite4" ); then
"udplite6" ); then
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
cant
else
@ -18106,14 +18105,14 @@ else
te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
tsl=$PORT
ts="$LOCALHOST:$tsl"
ts="$LOCALHOST6:$tsl"
da="test$N $(date) $RANDOM"
CMD1="$TRACE $SOCAT $opts UDPLITE4-LISTEN:$tsl,$REUSEADDR PIPE"
CMD2="$TRACE $SOCAT $opts - UDPLITE4:$ts"
CMD1="$TRACE $SOCAT $opts UDPLITE6-LISTEN:$tsl,$REUSEADDR PIPE"
CMD2="$TRACE $SOCAT $opts - UDPLITE6:$ts"
printf "test $F_n $TEST... " $N
$CMD1 >"$tf" 2>"${te}1" &
pid1=$!
waitudplite4port $tsl 1
waitudplite6port $tsl 1
echo "$da" |$CMD2 >>"$tf" 2>>"${te}2"
rc2=$?
kill $pid1 2>/dev/null; wait

View file

@ -81,7 +81,7 @@ static int xioopen_shell(
Setenv("SHELL", shellpath, 1);
Info1("executing shell command \"%s\"", string);
Debug3("execl(\"%s\", \"%s\", \"-c\", \"%s\", NULL",
Debug3("execl(\"%s\", \"%s\", \"-c\", \"%s\", NULL)",
shellpath, shellname, string);
result = execl(shellpath, shellname, "-c", string, (char *)NULL);
if (result != 0) {

View file

@ -731,7 +731,7 @@ int xioopen_single(xiofile_t *xfd, int xioflags) {
if (applyopts_single(sfd, sfd->opts, PH_OFFSET) < 0)
return -1;
#if WITH_NAMESPACES
#if WITH_NAMESPACES /* netns */
if ((save_netfd = xio_apply_namespace(sfd->opts)) < 0)
return -1;
#endif /* WITH_NAMESPACES */