Corrections for better 32bit systems support, and some minor fixes

This commit is contained in:
Gerhard Rieger 2023-11-13 20:08:23 +01:00
parent de1ed21026
commit c9ff62744f
15 changed files with 79 additions and 50 deletions

View file

@ -103,7 +103,7 @@ Features:
application to the getaddrinfo() function, when this flag is set while application to the getaddrinfo() function, when this flag is set while
no IP version is preferred by build, environment, option, or address no IP version is preferred by build, environment, option, or address
type, Socat chooses IPv6 because this might activate both versions (but type, Socat chooses IPv6 because this might activate both versions (but
confirm option ipv6-v6only). check option ipv6-v6only).
Added option ai-passive to control this flag explicitely. Added option ai-passive to control this flag explicitely.
New option ai-v4mapped (v4mapped) sets or unsets the AI_V4MAPPED flag New option ai-v4mapped (v4mapped) sets or unsets the AI_V4MAPPED flag
@ -298,6 +298,8 @@ Porting:
_FILE_OFFSET_BITS and _LARGE_FILES. _FILE_OFFSET_BITS and _LARGE_FILES.
Thanks to Fergus Dall for sending a patch. Thanks to Fergus Dall for sending a patch.
Some corrections for better 32bit systems support.
Testing: Testing:
Removed obselete parts from test.sh Removed obselete parts from test.sh

View file

@ -131,7 +131,7 @@ strip: progs
install: progs $(srcdir)/doc/socat.1 install: progs $(srcdir)/doc/socat.1
mkdir -p $(DESTDIR)$(BINDEST) mkdir -p $(DESTDIR)$(BINDEST)
$(INSTALL) -m 755 socat $(DESTDIR)$(BINDEST)/socat1 $(INSTALL) -m 755 socat $(DESTDIR)$(BINDEST)/socat1
ln -s socat1 $(DESTDIR)$(BINDEST)/socat ln -sf socat1 $(DESTDIR)$(BINDEST)/socat
$(INSTALL) -m 755 socat-chain.sh $(DESTDIR)$(BINDEST) $(INSTALL) -m 755 socat-chain.sh $(DESTDIR)$(BINDEST)
$(INSTALL) -m 755 socat-mux.sh $(DESTDIR)$(BINDEST) $(INSTALL) -m 755 socat-mux.sh $(DESTDIR)$(BINDEST)
$(INSTALL) -m 755 socat-broker.sh $(DESTDIR)$(BINDEST) $(INSTALL) -m 755 socat-broker.sh $(DESTDIR)$(BINDEST)
@ -139,7 +139,7 @@ install: progs $(srcdir)/doc/socat.1
$(INSTALL) -m 755 filan $(DESTDIR)$(BINDEST) $(INSTALL) -m 755 filan $(DESTDIR)$(BINDEST)
mkdir -p $(DESTDIR)$(MANDEST)/man1 mkdir -p $(DESTDIR)$(MANDEST)/man1
$(INSTALL) -m 644 $(srcdir)/doc/socat.1 $(DESTDIR)$(MANDEST)/man1/socat1.1 $(INSTALL) -m 644 $(srcdir)/doc/socat.1 $(DESTDIR)$(MANDEST)/man1/socat1.1
ln -s socat1.1 $(DESTDIR)$(MANDEST)/man1/socat.1 ln -sf socat1.1 $(DESTDIR)$(MANDEST)/man1/socat.1
uninstall: uninstall:
rm -f $(DESTDIR)$(BINDEST)/socat rm -f $(DESTDIR)$(BINDEST)/socat

View file

@ -537,7 +537,7 @@ AC_ARG_ENABLE(system, [ --disable-system disable system (shell) support]
[AC_DEFINE(WITH_SYSTEM) AC_MSG_RESULT(yes)]) [AC_DEFINE(WITH_SYSTEM) AC_MSG_RESULT(yes)])
AC_MSG_CHECKING([whether to include shell invocation support]) AC_MSG_CHECKING([whether to include shell invocation support])
AC_ARG_ENABLE(system, [ --disable-shell disable shell invocation support], AC_ARG_ENABLE(shell, [ --disable-shell disable shell invocation support],
[case "$enableval" in [case "$enableval" in
no) AC_MSG_RESULT(no);; no) AC_MSG_RESULT(no);;
*) AC_DEFINE(WITH_SHELL) AC_MSG_RESULT(yes);; *) AC_DEFINE(WITH_SHELL) AC_MSG_RESULT(yes);;

View file

@ -219,13 +219,14 @@ label(option_W)dit(bf(tt(-W))tt(<lockfile>))
creates it and continues, unlinks lockfile on exit. creates it and continues, unlinks lockfile on exit.
label(option_4)dit(bf(tt(-4))) label(option_4)dit(bf(tt(-4)))
Use IP version 4 in case the addresses do not implicitly or explicitly Use IP version 4 in case the addresses do not implicitly or explicitly
specify a version; this is the default. specify a version. Since version 1.8.0 the default is no preference.
label(option_6)dit(bf(tt(-6))) label(option_6)dit(bf(tt(-6)))
Use IP version 6 in case the addresses do not implicitly or explicitly Use IP version 6 in case the addresses do not implicitly or explicitly
specify a version. specify a version.
label(option_statistics)dit(bf(tt(--statistics))) label(option_statistics)dit(bf(tt(--statistics)))
dit(bf(tt(-S)))
Logs transfer statistics (bytes and blocks counters for both directions) Logs transfer statistics (bytes and blocks counters for both directions)
before terminating Socat.nl() before terminating socat().nl()
See also link(signal USR1)(signal_usr1).nl() See also link(signal USR1)(signal_usr1).nl()
This feature is experimental and might change in future versions. This feature is experimental and might change in future versions.
enddit() enddit()
@ -1064,14 +1065,14 @@ label(ADDRESS_ACCEPT_FD)dit(bf(tt(ACCEPT-FD:<fdnum>)))
Expects a listening socket in <fdnum> and accepts one or (with option Expects a listening socket in <fdnum> and accepts one or (with option
link(fork)(OPTION_FORK)) more connections. This address type is useful under link(fork)(OPTION_FORK)) more connections. This address type is useful under
systemd control with "inetd mode".nl() systemd control with "inetd mode".nl()
Example: (link(example)(EXAMPLE_ADDRESS_ACCEPT_FD)) Example: (link(example)(EXAMPLE_ADDRESS_ACCEPT_FD))nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET)link(TCP)(GROUP_TCP),link(CHILD)(GROUP_CHILD),link(RETRY)(GROUP_RETRY) nl() Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET), link(TCP)(GROUP_TCP), link(CHILD)(GROUP_CHILD), link(RETRY)(GROUP_RETRY)nl()
Useful options: Useful options:
link(fork)(OPTION_FORK)), link(fork)(OPTION_FORK),
link(range)(OPTION_RANGE), link(range)(OPTION_RANGE),
link(sourceport)(OPTION_SOURCEPORT), link(sourceport)(OPTION_SOURCEPORT),
link(lowport)(OPTION_LOWPORT), link(lowport)(OPTION_LOWPORT),
link(tcpwrap)(OPTION_TCPWRAPPERS), link(tcpwrap)(OPTION_TCPWRAPPERS)
label(ADDRESS_SOCKS4)dit(bf(tt(SOCKS4:<socks-server>:<host>:<port>))) label(ADDRESS_SOCKS4)dit(bf(tt(SOCKS4:<socks-server>:<host>:<port>)))
Connects via <socks-server> [link(IP address)(TYPE_IP_ADDRESS)] Connects via <socks-server> [link(IP address)(TYPE_IP_ADDRESS)]
to <host> [link(IPv4 address)(TYPE_IPV4_ADDRESS)] to <host> [link(IPv4 address)(TYPE_IPV4_ADDRESS)]
@ -1507,6 +1508,7 @@ label(ADDRESS_UDP6_RECV)dit(bf(tt(UDP6-RECV:<port>)))
Like link(UDP-RECV)(ADDRESS_UDP_RECV), but only supports IPv6 protocol.nl() Like link(UDP-RECV)(ADDRESS_UDP_RECV), but only supports IPv6 protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE)
label(ADDRESS_UDPLITE)
dit(bf(tt(UDPLITE-CONNECT:<host>:<port>))) dit(bf(tt(UDPLITE-CONNECT:<host>:<port>)))
dit(bf(tt(UDPLITE4-CONNECT:<host>:<port>))) dit(bf(tt(UDPLITE4-CONNECT:<host>:<port>)))
dit(bf(tt(UDPLITE6-CONNECT:<host>:<port>))) dit(bf(tt(UDPLITE6-CONNECT:<host>:<port>)))
@ -4120,7 +4122,7 @@ mancommand(\.fi)
htmlcommand(<hr><div class="shell">socat &#x5C; htmlcommand(<hr><div class="shell">socat &#x5C;
TCP-L:7777,reuseaddr,fork &#x5C; TCP-L:7777,reuseaddr,fork &#x5C;
SYSTEM:'filan -i 0 -s >&2',nofork</div>) SYSTEM:'filan -i 0 -s >&amp;2',nofork</div>)
listens for incoming TCP connections on port 7777. For each accepted listens for incoming TCP connections on port 7777. For each accepted
connection, invokes a shell. This shell has its stdin and stdout directly connection, invokes a shell. This shell has its stdin and stdout directly
@ -4212,7 +4214,7 @@ mancommand(\.RE)
mancommand(\.fi) mancommand(\.fi)
htmlcommand(<hr><div class="shell">socat - &#x5C; htmlcommand(<hr><div class="shell">socat - &#x5C;
TCP:<server>:10021,reuseaddr,socktype=6,protocol=33,fork</div>) TCP:&lt;server&gt;:10021,reuseaddr,socktype=6,protocol=33,fork</div>)
is a simple DCCP client. DCCP is now directly provisioned in socat(), is a simple DCCP client. DCCP is now directly provisioned in socat(),
however this example shows how use socat()s TCP procedures, but changes the however this example shows how use socat()s TCP procedures, but changes the

33
test.sh
View file

@ -146,7 +146,8 @@ if type ip >/dev/null 2>&1; then
fi fi
if type ss >/dev/null 2>&1; then if type ss >/dev/null 2>&1; then
if ss -V |grep -q "^ss utility, iproute2-"; then # on Ubuntu-10 ss has differing output format
if ss -V |grep -q "^ss utility, iproute2-[2-6]"; then
SS=$(type -p ss) SS=$(type -p ss)
else else
unset SS unset SS
@ -1050,13 +1051,13 @@ checkconds() {
break; break;
fi fi
done done
[ "$i" ] && { echo "Only on (one of) $unames"; return -1; } [ "$i" ] && { echo "Only on (one of) $unames"; return 255; }
fi fi
if [ "$root" = "root" ]; then if [ "$root" = "root" ]; then
if [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then if [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then
echo "Must be root" echo "Must be root"
return -1; return 255
fi fi
fi fi
@ -1064,7 +1065,7 @@ checkconds() {
for i in $progs; do for i in $progs; do
if ! type >/dev/null 2>&1; then if ! type >/dev/null 2>&1; then
echo "Program $i not available" echo "Program $i not available"
return -1 return 255
fi fi
done done
fi fi
@ -1072,21 +1073,21 @@ checkconds() {
if [ "$feats" ]; then if [ "$feats" ]; then
if ! F=$(testfeats $feats); then if ! F=$(testfeats $feats); then
echo "Feature $F not configured in $SOCAT" echo "Feature $F not configured in $SOCAT"
return -1 return 255
fi fi
fi fi
if [ "$addrs" ]; then if [ "$addrs" ]; then
if ! A=$(testaddrs - $addrs); then if ! A=$(testaddrs - $addrs); then
echo "Address $A not available in $SOCAT" echo "Address $A not available in $SOCAT"
return -1 return 255
fi fi
fi fi
if [ "$opts" ]; then if [ "$opts" ]; then
if ! o=$(testoptions $opts); then if ! o=$(testoptions $opts); then
echo "Option $o not available in $SOCAT" echo "Option $o not available in $SOCAT"
return -1 return 255
fi fi
fi fi
@ -1094,7 +1095,7 @@ checkconds() {
for i in $runs; do for i in $runs; do
if ! runs$i >/dev/null; then if ! runs$i >/dev/null; then
echo "$i not available on host" echo "$i not available on host"
return -1; return 255;
fi fi
done done
fi fi
@ -1102,7 +1103,7 @@ checkconds() {
if [ "$inet" ]; then if [ "$inet" ]; then
if [ -z "$NTERNET" ]; then if [ -z "$NTERNET" ]; then
echo "Use test.sh option --internet" echo "Use test.sh option --internet"
return -1 return 255
fi fi
fi fi
return 0 return 0
@ -10045,6 +10046,7 @@ tsa="$TEST_SOCKADDR" # test server address
if [ "$PORTMETHOD" == PORT ]; then if [ "$PORTMETHOD" == PORT ]; then
newport $proto; tsp="$PORT"; # test server port newport $proto; tsp="$PORT"; # test server port
tsa1="$tsp"; tsa2="$tsa"; tsa="$tsa:$tsp" # tsa2 used for server bind= tsa1="$tsp"; tsa2="$tsa"; tsa="$tsa:$tsp" # tsa2 used for server bind=
TEST_SOCKPORT=$tsp
else else
tsa1="$tsa"; tsa2= # tsa1 used for addr parameter tsa1="$tsa"; tsa2= # tsa1 used for addr parameter
fi fi
@ -10053,6 +10055,7 @@ tca="$TEST_PEERADDR" # test client address
if [ $PORTMETHOD = PORT ]; then if [ $PORTMETHOD = PORT ]; then
newport $proto; tcp="$PORT"; # test client port newport $proto; tcp="$PORT"; # test client port
tca="$tca:$tcp" tca="$tca:$tcp"
TEST_PEERPORT=$tcp
fi fi
#CMD0="$TRACE $SOCAT $opts -u $KEYW-LISTEN:$tsa1 SYSTEM:\"export -p\"" #CMD0="$TRACE $SOCAT $opts -u $KEYW-LISTEN:$tsa1 SYSTEM:\"export -p\""
CMD0="$TRACE $SOCAT $opts -u -lpsocat $KEYW-LISTEN:$tsa1,$REUSEADDR SYSTEM:\"echo SOCAT_SOCKADDR=\\\$SOCAT_SOCKADDR; echo SOCAT_PEERADDR=\\\$SOCAT_PEERADDR; echo SOCAT_SOCKPORT=\\\$SOCAT_SOCKPORT; echo SOCAT_PEERPORT=\\\$SOCAT_PEERPORT; sleep 1\"" CMD0="$TRACE $SOCAT $opts -u -lpsocat $KEYW-LISTEN:$tsa1,$REUSEADDR SYSTEM:\"echo SOCAT_SOCKADDR=\\\$SOCAT_SOCKADDR; echo SOCAT_PEERADDR=\\\$SOCAT_PEERADDR; echo SOCAT_SOCKPORT=\\\$SOCAT_SOCKPORT; echo SOCAT_PEERPORT=\\\$SOCAT_PEERPORT; sleep 1\""
@ -10076,8 +10079,8 @@ if [ $rc1 != 0 ]; then
listCANT="$listCANT $N" listCANT="$listCANT $N"
elif [ "$(grep SOCAT_SOCKADDR "${tf}" |sed -e 's/^[^=]*=//' |sed -e "s/[\"']//g")" = "$TEST_SOCKADDR" -a \ elif [ "$(grep SOCAT_SOCKADDR "${tf}" |sed -e 's/^[^=]*=//' |sed -e "s/[\"']//g")" = "$TEST_SOCKADDR" -a \
"$(grep SOCAT_PEERADDR "${tf}" |sed -e 's/^[^=]*=//' -e "s/[\"']//g")" = "$TEST_PEERADDR" -a \ "$(grep SOCAT_PEERADDR "${tf}" |sed -e 's/^[^=]*=//' -e "s/[\"']//g")" = "$TEST_PEERADDR" -a \
\( "$PORTMETHOD" = ',' -o "$(grep SOCAT_SOCKPORT "${tf}" |sed -e 's/^[^=]*=//' |sed -e 's/"//g')" = "$tsp" \) -a \ \( "$PORTMETHOD" = ',' -o "$(grep SOCAT_SOCKPORT "${tf}" |sed -e 's/^[^=]*=//' |sed -e 's/"//g')" = "$TEST_SOCKPORT" \) -a \
\( "$PORTMETHOD" = ',' -o "$(grep SOCAT_PEERPORT "${tf}" |sed -e 's/^[^=]*=//' |sed -e 's/"//g')" = "$tcp" \) \ \( "$PORTMETHOD" = ',' -o "$(grep SOCAT_PEERPORT "${tf}" |sed -e 's/^[^=]*=//' |sed -e 's/"//g')" = "$TEST_PEERPORT" \) \
]; then ]; then
$PRINTF "$OK\n" $PRINTF "$OK\n"
if [ "$debug" ]; then if [ "$debug" ]; then
@ -18589,6 +18592,7 @@ tsa="$TEST_SOCKADDR" # test server address
if [ "$PORTMETHOD" = PORT ]; then if [ "$PORTMETHOD" = PORT ]; then
newport $proto; tsp="$PORT"; # test server port newport $proto; tsp="$PORT"; # test server port
tsa1="$tsp"; tsa2="$tsa"; tsa="$tsa:$tsp" # tsa2 used for server bind= tsa1="$tsp"; tsa2="$tsa"; tsa="$tsa:$tsp" # tsa2 used for server bind=
TEST_SOCKPORT=$tsp
else else
tsa1="$tsa"; tsa2= # tsa1 used for addr parameter tsa1="$tsa"; tsa2= # tsa1 used for addr parameter
fi fi
@ -18597,6 +18601,7 @@ tca="$TEST_PEERADDR" # test client address
if [ "$PORTMETHOD" = PORT ]; then if [ "$PORTMETHOD" = PORT ]; then
newport $proto; tcp="$PORT"; # test client port newport $proto; tcp="$PORT"; # test client port
tca="$tca:$tcp" tca="$tca:$tcp"
TEST_PEERPORT=$tcp
fi fi
#CMD0="$TRACE $SOCAT $opts -u $KEYW-LISTEN:$tsa1 SYSTEM:\"export -p\"" #CMD0="$TRACE $SOCAT $opts -u $KEYW-LISTEN:$tsa1 SYSTEM:\"export -p\""
CMD0="$TRACE $SOCAT $opts -u -lpsocat $KEYW-LISTEN:$tsa1,$REUSEADDR SYSTEM:\"echo SOCAT_SOCKADDR=\\\$SOCAT_SOCKADDR; echo SOCAT_PEERADDR=\\\$SOCAT_PEERADDR; echo SOCAT_SOCKPORT=\\\$SOCAT_SOCKPORT; echo SOCAT_PEERPORT=\\\$SOCAT_PEERPORT; sleep 1\"" CMD0="$TRACE $SOCAT $opts -u -lpsocat $KEYW-LISTEN:$tsa1,$REUSEADDR SYSTEM:\"echo SOCAT_SOCKADDR=\\\$SOCAT_SOCKADDR; echo SOCAT_PEERADDR=\\\$SOCAT_PEERADDR; echo SOCAT_SOCKPORT=\\\$SOCAT_SOCKPORT; echo SOCAT_PEERPORT=\\\$SOCAT_PEERPORT; sleep 1\""
@ -18620,8 +18625,8 @@ if [ $rc1 != 0 ]; then
listCANT="$listCANT $N" listCANT="$listCANT $N"
elif [ "$(grep SOCAT_SOCKADDR "${tf}" |sed -e 's/^[^=]*=//' |sed -e "s/[\"']//g")" = "$TEST_SOCKADDR" -a \ elif [ "$(grep SOCAT_SOCKADDR "${tf}" |sed -e 's/^[^=]*=//' |sed -e "s/[\"']//g")" = "$TEST_SOCKADDR" -a \
"$(grep SOCAT_PEERADDR "${tf}" |sed -e 's/^[^=]*=//' -e "s/[\"']//g")" = "$TEST_PEERADDR" -a \ "$(grep SOCAT_PEERADDR "${tf}" |sed -e 's/^[^=]*=//' -e "s/[\"']//g")" = "$TEST_PEERADDR" -a \
\( "$PORTMETHOD" = ',' -o "$(grep SOCAT_SOCKPORT "${tf}" |sed -e 's/^[^=]*=//' |sed -e 's/"//g')" = "$tsp" \) -a \ \( "$PORTMETHOD" = ',' -o "$(grep SOCAT_SOCKPORT "${tf}" |sed -e 's/^[^=]*=//' |sed -e 's/"//g')" = "$TEST_SOCKPORT" \) -a \
\( "$PORTMETHOD" = ',' -o "$(grep SOCAT_PEERPORT "${tf}" |sed -e 's/^[^=]*=//' |sed -e 's/"//g')" = "$tcp" \) \ \( "$PORTMETHOD" = ',' -o "$(grep SOCAT_PEERPORT "${tf}" |sed -e 's/^[^=]*=//' |sed -e 's/"//g')" = "$TEST_PEERPORT" \) \
]; then ]; then
$PRINTF "$OK\n" $PRINTF "$OK\n"
if [ "$debug" ]; then if [ "$debug" ]; then
@ -18866,7 +18871,7 @@ N=$((N+1))
# Test the socat-chain.sh script by driving SSL over serial # Test the socat-chain.sh script by driving SSL over serial
NAME=SOCAT_CHAIN_SSL_PTY NAME=SOCAT_CHAIN_SSL_PTY
case "$TESTS" in case "$TESTS" in
*%$N%*|*%functions%*|*%scripts%*|*%socat-chain%*|*%listen%*|*%fork%*|*%ip4%*|*%tcp4%*|*%unix%*|*%socket%*|*%pty%*|*%$NAME%*) *%$N%*|*%functions%*|*%scripts%*|*%socat-chain%*|*%listen%*|*%fork%*|*%ip4%*|*%tcp4%*|*%openssl%*|*%unix%*|*%socket%*|*%pty%*|*%$NAME%*)
TEST="$NAME: test socat-chain.sh with SSL over PTY" TEST="$NAME: test socat-chain.sh with SSL over PTY"
# Run a socat-chain.sh instance with SSL listening behind a PTY; # Run a socat-chain.sh instance with SSL listening behind a PTY;
# open the PTY with socat-chein.sh using SSL; # open the PTY with socat-chein.sh using SSL;

View file

@ -640,7 +640,11 @@ static int xioopen_openssl_listen(
/* this can fork() for us; it only returns on error or on /* this can fork() for us; it only returns on error or on
successful establishment of connection */ successful establishment of connection */
if (ipproto == IPPROTO_TCP || ipproto == IPPROTO_DCCP) { if (ipproto == IPPROTO_TCP
#ifdef IPPROTO_DCCP
|| ipproto == IPPROTO_DCCP
#endif
) {
result = _xioopen_listen(sfd, xioflags, result = _xioopen_listen(sfd, xioflags,
(struct sockaddr *)us, uslen, (struct sockaddr *)us, uslen,
opts, pf, socktype, ipproto, opts, pf, socktype, ipproto,

View file

@ -52,9 +52,9 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
struct opt **optsp, /* in: opts; out: opts for parent/child */ struct opt **optsp, /* in: opts; out: opts for parent/child */
int *duptostderr /* out: redirect stderr to output fd */ int *duptostderr /* out: redirect stderr to output fd */
) { ) {
struct opt *opts; /* common options */ struct opt *opts; /* common options */
struct opt *popts; /* parent options */ struct opt *popts = NULL; /* parent options */
struct opt *copts; /* child options */ struct opt *copts; /* child options */
int numleft; int numleft;
int d, sv[2], rdpip[2], wrpip[2]; int d, sv[2], rdpip[2], wrpip[2];
int rw = (xioflags & XIO_ACCMODE); int rw = (xioflags & XIO_ACCMODE);
@ -613,7 +613,9 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
Info("child process notified parent that it is ready"); Info("child process notified parent that it is ready");
} }
#if HAVE_PTY
applyopts(sfd, ptyfd, popts, PH_LATE); applyopts(sfd, ptyfd, popts, PH_LATE);
#endif /* HAVE_PTY */
if (applyopts_single(sfd, popts, PH_LATE) < 0) if (applyopts_single(sfd, popts, PH_LATE) < 0)
return -1; return -1;

View file

@ -253,7 +253,8 @@ static int xioopen_proxy_connect(
/* parent process */ /* parent process */
Close(sfd->fd); Close(sfd->fd);
Nanosleep(&sfd->intervall, NULL); Nanosleep(&sfd->intervall, NULL);
dropopts(opts, PH_ALL); opts = copyopts(opts0, GROUP_ALL); dropopts(opts, PH_ALL);
opts = copyopts(opts0, GROUP_ALL);
continue; continue;
} else } else
#endif /* WITH_RETRY */ #endif /* WITH_RETRY */

View file

@ -1165,7 +1165,7 @@ int _xioopen_dgram_recvfrom(struct single *sfd, int xioflags,
} }
applyopts(sfd, -1, opts, PH_PASTSOCKET); applyopts(sfd, -1, opts, PH_PASTSOCKET);
//applyopts(sfd, -1, opts, PH_FD); /*! applyopts(sfd, -1, opts, PH_FD); */
applyopts_cloexec(sfd->fd, opts); applyopts_cloexec(sfd->fd, opts);
@ -1389,7 +1389,7 @@ int _xioopen_dgram_recv(struct single *sfd, int xioflags,
} }
applyopts(sfd, -1, opts, PH_PASTSOCKET); applyopts(sfd, -1, opts, PH_PASTSOCKET);
//applyopts(sfd, -1, opts, PH_FD); /*! applyopts(sfd, -1, opts, PH_FD); */
applyopts_cloexec(sfd->fd, opts); applyopts_cloexec(sfd->fd, opts);

View file

@ -6,7 +6,7 @@
#include "xiosysincludes.h" #include "xiosysincludes.h"
#if WITH_UDP && (WITH_IP4 || WITH_IP6) #if _WITH_UDP && (WITH_IP4 || WITH_IP6)
#include "xioopen.h" #include "xioopen.h"
#include "xio-socket.h" #include "xio-socket.h"
@ -18,6 +18,7 @@
#include "xio-udp.h" #include "xio-udp.h"
#if WITH_UDP
const struct addrdesc xioaddr_udp_connect = { "UDP-CONNECT", 1+XIO_RDWR, xioopen_ipapp_connect, GROUP_FD|GROUP_SOCKET|GROUP_SOCK_IP4|GROUP_SOCK_IP6|GROUP_IP_UDP, SOCK_DGRAM, IPPROTO_UDP, PF_UNSPEC HELP(":<host>:<port>") }; const struct addrdesc xioaddr_udp_connect = { "UDP-CONNECT", 1+XIO_RDWR, xioopen_ipapp_connect, GROUP_FD|GROUP_SOCKET|GROUP_SOCK_IP4|GROUP_SOCK_IP6|GROUP_IP_UDP, SOCK_DGRAM, IPPROTO_UDP, PF_UNSPEC HELP(":<host>:<port>") };
#if WITH_LISTEN #if WITH_LISTEN
@ -50,6 +51,8 @@ const struct addrdesc xioaddr_udp6_recvfrom= { "UDP6-RECVFROM", 1+XIO_RDWR, x
const struct addrdesc xioaddr_udp6_recv = { "UDP6-RECV", 1+XIO_RDONLY, xioopen_udp_recv, GROUP_FD|GROUP_SOCKET|GROUP_SOCK_IP6|GROUP_IP_UDP|GROUP_RANGE, PF_INET6, SOCK_DGRAM, IPPROTO_UDP HELP(":<port>") }; const struct addrdesc xioaddr_udp6_recv = { "UDP6-RECV", 1+XIO_RDONLY, xioopen_udp_recv, GROUP_FD|GROUP_SOCKET|GROUP_SOCK_IP6|GROUP_IP_UDP|GROUP_RANGE, PF_INET6, SOCK_DGRAM, IPPROTO_UDP HELP(":<port>") };
#endif /* WITH_IP6 */ #endif /* WITH_IP6 */
#endif /* WITH_UDP */
int _xioopen_ipdgram_listen(struct single *sfd, int _xioopen_ipdgram_listen(struct single *sfd,
int xioflags, union sockaddr_union *us, socklen_t uslen, int xioflags, union sockaddr_union *us, socklen_t uslen,
@ -469,13 +472,17 @@ int xioopen_udp_datagram(
if (sfd->para.socket.ip.dosourceport) { if (sfd->para.socket.ip.dosourceport) {
switch (sfd->peersa.soa.sa_family) { switch (sfd->peersa.soa.sa_family) {
case PF_INET:
default: default:
#if WITH_IP4
case PF_INET:
sfd->para.socket.ip.sourceport = ntohs(sfd->peersa.ip4.sin_port); sfd->para.socket.ip.sourceport = ntohs(sfd->peersa.ip4.sin_port);
break; break;
#endif /* WITH_IP4 */
#if WITH_IP6
case PF_INET6: case PF_INET6:
sfd->para.socket.ip.sourceport = ntohs(sfd->peersa.ip6.sin6_port); sfd->para.socket.ip.sourceport = ntohs(sfd->peersa.ip6.sin6_port);
break; break;
#endif /* WITH_IP6 */
} }
} }
@ -708,4 +715,4 @@ int xioopen_udp_recv(
return result; return result;
} }
#endif /* WITH_UDP && (WITH_IP4 || WITH_IP6) */ #endif /* _WITH_UDP && (WITH_IP4 || WITH_IP6) */

2
xio.h
View file

@ -348,6 +348,7 @@ typedef union bipipe {
enum xiotag tag; enum xiotag tag;
const struct addrdesc *addr; const struct addrdesc *addr;
int flags; int flags;
/* until here, keep consistent with struct single, and with .dual */
} common; /* "bipipe.common" */ } common; /* "bipipe.common" */
struct single stream; struct single stream;
struct { struct {
@ -368,6 +369,7 @@ typedef union bipipe {
bool havelock; /* we are happy owner of the above lock */ bool havelock; /* we are happy owner of the above lock */
int triggerfd; /* close this FD in child process to notify parent */ int triggerfd; /* close this FD in child process to notify parent */
bool cool_write; /* downlevel EPIPE, ECONNRESET to notice */ bool cool_write; /* downlevel EPIPE, ECONNRESET to notice */
/* until here, keep consistent with struct single ! */
struct single *stream[2]; /* input stream, output stream */ struct single *stream[2]; /* input stream, output stream */
} dual; } dual;
} xiofile_t; } xiofile_t;

View file

@ -48,11 +48,15 @@
#endif #endif
#if !WITH_IP4 && !WITH_IP6 #if !WITH_IP4 && !WITH_IP6
# if WITH_TCP || WITH_UDP || WITH_RAWIP # if WITH_TCP || WITH_UDP || WITH_SCTP || WITH_DCCP || WITH_UDPLITE || WITH_RAWIP
# define WITH_IP4 1 # define WITH_IP4 1
# endif # endif
#endif #endif
#if WITH_UDP || WITH_UDPLITE
# define _WITH_UDP 1
#endif
#if WITH_UNIX || WITH_IP4 || WITH_IP6 || WITH_SOCKS4 || WITH_RAWIP || WITH_GENERICSOCKET #if WITH_UNIX || WITH_IP4 || WITH_IP6 || WITH_SOCKS4 || WITH_RAWIP || WITH_GENERICSOCKET
# define _WITH_SOCKET 1 # define _WITH_SOCKET 1
#else #else

View file

@ -735,10 +735,10 @@ int xioopen_single(xiofile_t *xfd, int xioflags) {
return -1; return -1;
#endif /* WITH_NAMESPACES */ #endif /* WITH_NAMESPACES */
#if HAVE_RESOLV_H #if WITH_RESOLVE && HAVE_RESOLV_H
if ((do_res = xio_res_init(sfd, &save_res)) < 0) if ((do_res = xio_res_init(sfd, &save_res)) < 0)
return STAT_NORETRY; return STAT_NORETRY;
#endif /* HAVE_RESOLV_H */ #endif /* WITH_RESOLVE && HAVE_RESOLV_H */
if (xio_chdir(sfd->opts, &orig_dir) < 0) if (xio_chdir(sfd->opts, &orig_dir) < 0)
return STAT_NORETRY; return STAT_NORETRY;

View file

@ -451,7 +451,7 @@ const struct optname optionnames[] = {
#ifdef VDISCARD #ifdef VDISCARD
IF_TERMIOS("discard", &opt_vdiscard) IF_TERMIOS("discard", &opt_vdiscard)
#endif #endif
#if HAVE_RES_NSADDR_LIST #if WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST
IF_IP ("dns", &opt_res_nsaddr) IF_IP ("dns", &opt_res_nsaddr)
#endif #endif
#if HAVE_RESOLV_H #if HAVE_RESOLV_H
@ -566,7 +566,7 @@ const struct optname optionnames[] = {
IF_ANY ("f-setlkw", &opt_f_setlkw_wr) IF_ANY ("f-setlkw", &opt_f_setlkw_wr)
IF_ANY ("f-setlkw-rd", &opt_f_setlkw_rd) IF_ANY ("f-setlkw-rd", &opt_f_setlkw_rd)
IF_ANY ("f-setlkw-wr", &opt_f_setlkw_wr) IF_ANY ("f-setlkw-wr", &opt_f_setlkw_wr)
#if defined(F_SETPIPE_SZ) #if WITH_PIPE && defined(F_SETPIPE_SZ)
IF_ANY ("f-setpipe-sz", &opt_f_setpipe_sz) IF_ANY ("f-setpipe-sz", &opt_f_setpipe_sz)
#endif #endif
IF_EXEC ("fdin", &opt_fdin) IF_EXEC ("fdin", &opt_fdin)
@ -1047,7 +1047,7 @@ const struct optname optionnames[] = {
IF_IP ("multicast-ttl", &opt_ip_multicast_ttl) IF_IP ("multicast-ttl", &opt_ip_multicast_ttl)
IF_IP ("multicastloop", &opt_ip_multicast_loop) IF_IP ("multicastloop", &opt_ip_multicast_loop)
IF_IP ("multicastttl", &opt_ip_multicast_ttl) IF_IP ("multicastttl", &opt_ip_multicast_ttl)
#if HAVE_RES_NSADDR_LIST #if WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST
IF_IP ("nameserver", &opt_res_nsaddr) IF_IP ("nameserver", &opt_res_nsaddr)
#endif #endif
#if defined(O_NDELAY) && (!defined(O_NONBLOCK) || O_NDELAY != O_NONBLOCK) #if defined(O_NDELAY) && (!defined(O_NONBLOCK) || O_NDELAY != O_NONBLOCK)
@ -1115,7 +1115,7 @@ const struct optname optionnames[] = {
IF_OPENSSL("nosni", &opt_openssl_no_sni) IF_OPENSSL("nosni", &opt_openssl_no_sni)
#endif #endif
IF_INTERFACE("notrailers", &opt_iff_notrailers) IF_INTERFACE("notrailers", &opt_iff_notrailers)
#if HAVE_RES_NSADDR_LIST #if WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST
IF_IP ("nsaddr", &opt_res_nsaddr) IF_IP ("nsaddr", &opt_res_nsaddr)
#endif #endif
#ifdef O_NSHARE #ifdef O_NSHARE
@ -1326,7 +1326,7 @@ const struct optname optionnames[] = {
IF_SOCKET ("pf", &opt_protocol_family) IF_SOCKET ("pf", &opt_protocol_family)
IF_EXEC ("pgid", &opt_setpgid) IF_EXEC ("pgid", &opt_setpgid)
IF_EXEC ("pipes", &opt_pipes) IF_EXEC ("pipes", &opt_pipes)
#if defined(F_SETPIPE_SZ) #if WITH_PIPE && defined(F_SETPIPE_SZ)
IF_ANY ("pipesz", &opt_f_setpipe_sz) IF_ANY ("pipesz", &opt_f_setpipe_sz)
#endif #endif
#ifdef IP_PKTINFO #ifdef IP_PKTINFO
@ -1462,7 +1462,7 @@ const struct optname optionnames[] = {
# if HAVE_RES_RETRY # if HAVE_RES_RETRY
IF_RESOLVE("res-maxretry", &opt_res_retry) IF_RESOLVE("res-maxretry", &opt_res_retry)
# endif # endif
# if HAVE_RES_NSADDR_LIST #if WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST
IF_IP ("res-nsaddr", &opt_res_nsaddr) IF_IP ("res-nsaddr", &opt_res_nsaddr)
# endif # endif
# if WITH_RES_PRIMARY # if WITH_RES_PRIMARY

View file

@ -192,11 +192,11 @@ enum e_func {
/* Keep condition consistent with xio.h:groups_t! */ /* Keep condition consistent with xio.h:groups_t! */
#if WITH_POSIXMQ || WITH_SCTP || WITH_DCCP || WITH_UDPLITE #if WITH_POSIXMQ || WITH_SCTP || WITH_DCCP || WITH_UDPLITE
/* The following groups are not expected on systems without uint64_t */ /* The following groups are not expected on systems without uint64_t */
#define GROUP_POSIXMQ 0x0100000000U #define GROUP_POSIXMQ ((groups_t)0x0100000000ULL)
#define GROUP_IP_SCTP 0x0200000000U #define GROUP_IP_SCTP ((groups_t)0x0200000000ULL)
#define GROUP_IP_DCCP 0x0400000000U #define GROUP_IP_DCCP ((groups_t)0x0400000000ULL)
#define GROUP_IP_UDPLITE 0x0800000000U #define GROUP_IP_UDPLITE ((groups_t)0x0800000000ULL)
#define GROUP_ALL 0x0fffffffffU #define GROUP_ALL ((groups_t)0x0fffffffffULL) /* OMG... for 32bit systems */
#else /* !(WITH_POSIXMQ || WITH_SCTP || WITH_DCCP || WITH_UDPLITE) */ #else /* !(WITH_POSIXMQ || WITH_SCTP || WITH_DCCP || WITH_UDPLITE) */
#define GROUP_POSIXMQ 0 #define GROUP_POSIXMQ 0
#define GROUP_IP_SCTP 0 #define GROUP_IP_SCTP 0