diff --git a/CHANGES b/CHANGES index 06127d0..6a436e1 100644 --- a/CHANGES +++ b/CHANGES @@ -27,6 +27,59 @@ new features: new form of FD address with output/input fd numbers +####################### V 1.6.0.1: + +new features: + new make target "gitclean" + + docu source doc/socat.yo released + +corrections: + exec:...,pty did not kill child process under some circumstances; fixed + by correcting typo in xio-progcall.c (thanks to Ralph Forsythe for + reporting this problem) + + service name resolution failed due to byte order mistake + (thanks to James Sainsbury for reporting this problem) + + socat would hang when invoked with many file descriptors already opened + fix: replaced FOPEN_MAX with FD_SETSIZE + thanks to Daniel Lucq for reporting this problem. + + fixed bugs where sub processes would become zombies because the master + process did not catch SIGCHLD. this affected addresses UDP-LISTEN, + UDP-CONNECT, TCP-CONNECT, OPENSSL, PROXY, UNIX-CONNECT, UNIX-CLIENT, + ABSTRACT-CONNECT, ABSTRACT-CLIENT, SOCKSA, SOCKS4A + (thanks to Fernanda G Weiden for reporting this problem) + + fixed a bug where sub processes would become zombies because the master + process caught SIGCHLD but did not wait(). this affected addresses + UDP-RECVFROM, IP-RECVFROM, UNIX-RECVFROM, ABSTRACT-RECVFROM + (thanks to Evan Borgstrom for reporting this problem) + + corrected option handling with STDIO; usecase: cool-write + + configure --disable-pty also disabled option waitlock + + fixed small bugs on systems with struct ip_mreq without struct ip_mreqn + (thanks to Roland Illig for sending a patch) + + corrected name of option intervall to interval (old form still valid + for us German speaking guys) + + corrected some print statements and variable names + + make uninstall did not uninstall procan + + fixed lots of weaknesses in test.sh + + corrected some bugs and typos in doc/socat.yo, EXAMPLES, C comments + +further changes: + procan -c prints C defines important for socat + + added test OPENSSLEOF for OpenSSL half close + ####################### V 1.6.0.0: new features: diff --git a/Config/Makefile.AIX-5-1 b/Config/Makefile.AIX-5-1 index 906b044..98b404d 100644 --- a/Config/Makefile.AIX-5-1 +++ b/Config/Makefile.AIX-5-1 @@ -1,4 +1,4 @@ -# $Id: Makefile.AIX-5-1,v 1.16 2006/07/13 21:29:05 gerhard Exp $ +# source: Makefile.AIX-5-1 # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/Config/Makefile.FreeBSD-6-1 b/Config/Makefile.FreeBSD-6-1 index e54007e..0d8faae 100644 --- a/Config/Makefile.FreeBSD-6-1 +++ b/Config/Makefile.FreeBSD-6-1 @@ -1,4 +1,4 @@ -# $Id: Makefile.FreeBSD-6-1,v 1.2 2007/03/06 21:44:34 gerhard Exp $ +# source: Makefile.FreeBSD-6-1 # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/Config/Makefile.HP-UX-B-11-11 b/Config/Makefile.HP-UX-B-11-11 index 31605b3..4afa954 100644 --- a/Config/Makefile.HP-UX-B-11-11 +++ b/Config/Makefile.HP-UX-B-11-11 @@ -1,4 +1,4 @@ -# $Id: Makefile.HP-UX-B-11-11,v 1.7 2007/03/06 21:44:34 gerhard Exp $ +# source: Makefile.HP-UX-B-11-11 # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/Config/Makefile.Linux-2-6-16 b/Config/Makefile.Linux-2-6-16 index bdb3e60..8c8b961 100644 --- a/Config/Makefile.Linux-2-6-16 +++ b/Config/Makefile.Linux-2-6-16 @@ -1,4 +1,4 @@ -# $Id: Makefile.Linux-2-6-16,v 1.1 2007/03/06 21:51:57 gerhard Exp $ +# source: Makefile.Linux-2-6-16 # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/Config/Makefile.NetBSD-2-0-2 b/Config/Makefile.NetBSD-2-0-2 index 52a888a..05fa303 100644 --- a/Config/Makefile.NetBSD-2-0-2 +++ b/Config/Makefile.NetBSD-2-0-2 @@ -1,4 +1,4 @@ -# $Id: Makefile.NetBSD-2-0-2,v 1.1 2006/07/13 21:40:28 gerhard Exp $ +# source: Makefile.NetBSD-2-0-2 # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/Config/Makefile.OpenBSD-3-8 b/Config/Makefile.OpenBSD-3-8 index 5863bec..a3f29f8 100644 --- a/Config/Makefile.OpenBSD-3-8 +++ b/Config/Makefile.OpenBSD-3-8 @@ -1,4 +1,4 @@ -# $Id: Makefile.OpenBSD-3-8,v 1.1 2006/07/13 21:40:31 gerhard Exp $ +# source: Makefile.OpenBSD-3-8 # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/Config/Makefile.SunOS-5-8 b/Config/Makefile.SunOS-5-8 index 82cf882..9de9548 100644 --- a/Config/Makefile.SunOS-5-8 +++ b/Config/Makefile.SunOS-5-8 @@ -1,4 +1,4 @@ -# $Id: Makefile.SunOS-5-8,v 1.24 2007/03/06 21:44:34 gerhard Exp $ +# source: Makefile.SunOS-5-8 # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/Config/Makefile.Tru64-5-1B b/Config/Makefile.Tru64-5-1B index 67dac46..ca26440 100644 --- a/Config/Makefile.Tru64-5-1B +++ b/Config/Makefile.Tru64-5-1B @@ -1,4 +1,4 @@ -# $Id: Makefile.Tru64-5-1B,v 1.6 2006/07/13 21:30:05 gerhard Exp $ +# source: Makefile.Tru64-5-1B # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/Config/config.AIX-5-1.h b/Config/config.AIX-5-1.h index 33cf69b..4d79b57 100644 --- a/Config/config.AIX-5-1.h +++ b/Config/config.AIX-5-1.h @@ -1,5 +1,5 @@ /* config.h. Generated by configure. */ -/* $Id: config.AIX-5-1.h,v 1.14 2006/07/13 21:33:50 gerhard Exp $ */ +/* source: Config/config.AIX-5-1.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/Config/config.FreeBSD-6-1.h b/Config/config.FreeBSD-6-1.h index 881807c..af45423 100644 --- a/Config/config.FreeBSD-6-1.h +++ b/Config/config.FreeBSD-6-1.h @@ -1,5 +1,5 @@ /* config.h. Generated by configure. */ -/* $Id: config.FreeBSD-6-1.h,v 1.2 2007/03/06 21:44:34 gerhard Exp $ */ +/* source: Config/config.FreeBSD-6-1.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/Config/config.HP-UX-B-11-11.h b/Config/config.HP-UX-B-11-11.h index a83b248..903138d 100644 --- a/Config/config.HP-UX-B-11-11.h +++ b/Config/config.HP-UX-B-11-11.h @@ -1,5 +1,5 @@ /* config.h. Generated by configure. */ -/* $Id: config.HP-UX-B-11-11.h,v 1.7 2007/03/06 21:44:34 gerhard Exp $ */ +/* source: Config/config.HP-UX-B-11-11.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/Config/config.Linux-2-6-16.h b/Config/config.Linux-2-6-16.h index 15b8717..bbcc32e 100644 --- a/Config/config.Linux-2-6-16.h +++ b/Config/config.Linux-2-6-16.h @@ -1,5 +1,5 @@ /* config.h. Generated by configure. */ -/* $Id: config.Linux-2-6-16.h,v 1.1 2007/03/06 21:51:57 gerhard Exp $ */ +/* source: Config/config.Linux-2-6-16.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/Config/config.NetBSD-2-0-2.h b/Config/config.NetBSD-2-0-2.h index 8b82877..fdbcb55 100644 --- a/Config/config.NetBSD-2-0-2.h +++ b/Config/config.NetBSD-2-0-2.h @@ -1,5 +1,5 @@ /* config.h. Generated by configure. */ -/* $Id: config.NetBSD-2-0-2.h,v 1.1 2006/07/13 21:44:07 gerhard Exp $ */ +/* source: Config/config.NetBSD-2-0-2.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/Config/config.OpenBSD-3-8.h b/Config/config.OpenBSD-3-8.h index 14b32a8..00dfa23 100644 --- a/Config/config.OpenBSD-3-8.h +++ b/Config/config.OpenBSD-3-8.h @@ -1,5 +1,5 @@ /* config.h. Generated by configure. */ -/* $Id: config.OpenBSD-3-8.h,v 1.1 2006/07/13 21:44:11 gerhard Exp $ */ +/* source: Config/config.OpenBSD-3-8.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/Config/config.SunOS-5-8.h b/Config/config.SunOS-5-8.h index ce9790b..63dc9af 100644 --- a/Config/config.SunOS-5-8.h +++ b/Config/config.SunOS-5-8.h @@ -1,5 +1,5 @@ /* config.h. Generated by configure. */ -/* $Id: config.SunOS-5-8.h,v 1.18 2007/03/06 21:44:34 gerhard Exp $ */ +/* source: Config/config.SunOS-5-8.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/Config/config.Tru64-5-1B.h b/Config/config.Tru64-5-1B.h index 9d0a516..45ae042 100644 --- a/Config/config.Tru64-5-1B.h +++ b/Config/config.Tru64-5-1B.h @@ -1,5 +1,5 @@ /* config.h. Generated by configure. */ -/* $Id: config.Tru64-5-1B.h,v 1.5 2006/07/13 21:35:43 gerhard Exp $ */ +/* source: Config/config.Tru64-5-1B.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/EXAMPLES b/EXAMPLES index 838522d..00fc20e 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -43,7 +43,7 @@ $ socat -,raw,echo=0 tcp:172.16.181.130:2023 // wait for a connection on port 8000; do not wait for request, but immediately // start a shell that sends reply headers and an empty line; then echo all // incoming data back to client -$ socat TCP-LISTEN:8000,crlf SYSTEM:"echo HTTP/1.0 200; echo Content-Type: text/plain; echo; cat" +$ socat TCP-LISTEN:8000,crlf SYSTEM:"echo HTTP/1.0 200; echo Content-Type\: text/plain; echo; cat" /////////////////////////////////////////////////////////////////////////////// // for communicating with an attached modem, I had reasonable results with @@ -210,7 +210,7 @@ $ gdb ./filan // note: some OS's do not need "-e" for echo to print control characters // note: chat might send bytes one by one // with AIX, a similar program is available under the name "pppdial" -$ socat -d -d system:'/usr/sbin/chat "220 " "HELO loopback" "250 " "MAIL FROM: " "250 " "RCPT TO: root" "250 " "DATA" "354 " "test1'$(echo -e "\r.")'" "250 " "QUIT"',pty,echo=0,cr tcp:localhost:25,crlf,nodelay +$ socat -d -d tcp:localhost:25,crlf,nodelay exec:'/usr/sbin/chat -v -s "\"220 \"" "\"HELO loopback\"" "\"250 \"" "\"MAIL FROM: \"" "\"250 \"" "\"RCPT TO: root\"" "\"250 \"" "\"DATA\"" "\"354 \"" "\"test1'$(echo -e "\r.")'\"" "\"250 \"" "\"QUIT\"" "\"221 \""',pty,echo=0,cr ////////////////////////////////////////////////////////////////////////////// // IP6 @@ -235,10 +235,10 @@ $ socat -,icanon=0,echo=0 tcp:target:5555; reset // access local display from ssh server, when ssh port forwarding is disabled // socat must be installed on ssh server host // might have to use xauth... -// this example is one-shot, because ',' cannot be passed to remote socat -xterm1$ socat -d -d exec:"ssh target ~/bin/socat -d -d unix-l:/tmp/.X11-unix/X1 -" unix:/tmp/.X11-unix/X0 +// this example is one-shot because ssh can handle only one channel +xterm1$ socat -d -d exec:"ssh www.dest-unreach.org rm -f /tmp/.X11-unix/X9; ~/bin/socat -d -d unix-l\:/tmp/.X11-unix/X9\,fork -" unix:/tmp/.X11-unix/X0 xterm2$ ssh target -target$ DISPLAY=:1 myxapplication +target$ DISPLAY=:9 myxapplication // touch with perms: // no race condition for perms (applied with creat() call) @@ -262,7 +262,7 @@ socat -,echo=0,icanon=0 exec:'ssh server',pty,setsid,ctty // 2) from XWindows (DISPLAY !); again 10 seconds (sleep 10; echo "ls"; sleep 1) |socat - exec:'ssh server',pty,setsid // 3) from script -(echo PASSWORD; echo ls; sleep 1) |./socat - exec:'ssh server',pty,setsid,ctty +(sleep 5; echo PASSWORD; echo ls; sleep 1) |./socat - exec:'ssh server',pty,setsid,ctty // download with proxy CONNECT @@ -317,10 +317,10 @@ $ xclock -display localhost:30 // and for improved security: # socat -d -d TCP-L:80,bind=fw-addr3,su=nobody,fork TCP:dmz-www3:80 -// pass an arbitrary IP protocol through your firewall (answers won't work) +// proxy an arbitrary IP protocol over your firewall (answers won't work) # socat -d -d IP:0.0.0.0:150,bind=fwnonsec IP:sec-host:150,bind=fwsec -// pass an unsupported IP protocol through your firewall, point to point +// proxy an unsupported IP protocol over your firewall, point to point // end points see firewall interfaces as IP peers! # socat -d -d IP:nonsec-host:150,bind=fwnonsec IP:sec-host:150,bind=fwsec // note that, for IPsec, you might face problems that are known with NAT diff --git a/FAQ b/FAQ index 32d8f32..6ae8a52 100644 --- a/FAQ +++ b/FAQ @@ -75,3 +75,15 @@ A: Probably, in a second attempt you set the correct LD_LIBARY_PATH for socat, but it had not been set during the ./configure run, or you did not "make clean" before running configure. Try it again: make distclean; ./configure; make + + +Q: A socat process, run in background from an interactive shell, is always +stopped with all its child processes after about 5 minutes. killall -9 socat is +required to clean the system and allow socat to be started again. + +A: The terminal (window) might have the TOSTOP flag set and one of the socat +processes wants to write to the terminal. Clear this flag in your shell: + stty -tostop +and start socat again. +Thanks to Philippe Teuwen for reporting this situation. + diff --git a/Makefile.in b/Makefile.in index 6667eed..684c5bf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ -# $Id: Makefile.in,v 1.114 2007/03/06 21:52:34 gerhard Exp $ -# Copyright Gerhard Rieger 2001-2007 +# source: Makefile.in +# Copyright Gerhard Rieger 2001-2008 # Published under the GNU General Public License V.2, see file COPYING # note: @...@ forms are filled in by configure script @@ -51,7 +51,7 @@ XIOSRCS = xioinitialize.c xiohelp.c xioparam.c xiodiag.c xioopen.c xioopts.c \ xio-ascii.c xiolockfile.c xio-tcpwrap.c xio-ext2.c xio-tun.c \ xio-nop.c xio-test.c XIOOBJS = $(XIOSRCS:.c=.o) -UTLSRCS = error.c dalan.c procan.c hostan.c fdname.c sysutils.c utils.c nestlex.c @FILAN@ @SYCLS@ @SSLCLS@ +UTLSRCS = error.c dalan.c procan.c procan-cdefs.c hostan.c fdname.c sysutils.c utils.c nestlex.c @FILAN@ @SYCLS@ @SSLCLS@ UTLOBJS = $(UTLSRCS:.c=.o) CFILES = $(XIOSRCS) $(UTLSRCS) socat.c procan_main.c filan_main.c OFILES = $(CFILES:.c=.o) @@ -68,7 +68,7 @@ HFILES = sycls.h sslcls.h error.h dalan.h procan.h filan.h hostan.h sysincludes. xio-ascii.h xiolockfile.h xio-tcpwrap.h xio-ext2.h xio-tun.h \ xiosigchld.h xiostatic.h xio-nop.h xio-test.h -DOCFILES = README README.FIPS CHANGES FILES EXAMPLES PORTING SECURITY DEVELOPMENT doc/socat.1 doc/socat.html FAQ BUGREPORTS COPYING COPYING.OpenSSL doc/dest-unreach.css doc/socat-openssltunnel.html doc/socat-multicast.html doc/socat-tun.html +DOCFILES = README README.FIPS CHANGES FILES EXAMPLES PORTING SECURITY DEVELOPMENT doc/socat.yo doc/socat.1 doc/socat.html FAQ BUGREPORTS COPYING COPYING.OpenSSL doc/dest-unreach.css doc/socat-openssltunnel.html doc/socat-multicast.html doc/socat-tun.html SHFILES = daemon.sh mail.sh ftp.sh readline.sh TESTFILES = test.sh socks4echo.sh proxyecho.sh gatherinfo.sh readline-test.sh \ proxy.sh socks4a-echo.sh testcert.conf @@ -82,7 +82,23 @@ TESTFILES = test.sh socks4echo.sh proxyecho.sh gatherinfo.sh readline-test.sh \ # Config/Makefile.Tru64-5-1B Config/config.Tru64-5-1B.h -all: progs +all: progs doc + +scmclean: gitclean + +gitclean: distclean docclean + rm -f Makefile.bak configure + +doc: doc/socat.1 doc/socat.html + +docclean: + rm -f doc/socat.1 doc/socat.html + +doc/socat.1: doc/socat.yo + yodl2man -o $@ $+ + +doc/socat.html: doc/socat.yo + yodl2html -o $@ $+ progs: $(PROGS) @@ -92,7 +108,7 @@ depend: $(CFILES) $(HFILES) socat: socat.o libxio.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ socat.o libxio.a $(CLIBS) -PROCAN_OBJS=procan_main.o procan.o hostan.o error.o sycls.o sysutils.o utils.o +PROCAN_OBJS=procan_main.o procan.o procan-cdefs.o hostan.o error.o sycls.o sysutils.o utils.o procan: $(PROCAN_OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(PROCAN_OBJS) $(CLIBS) @@ -119,7 +135,7 @@ install: progs doc/socat.1 uninstall: rm -f $(DESTDIR)$(BINDEST)/socat - rm -f $(DESTDIR)$(BINDEST)/procat + rm -f $(DESTDIR)$(BINDEST)/procan rm -f $(DESTDIR)$(BINDEST)/filan rm -f $(DESTDIR)$(MANDEST)/man1/socat.1 diff --git a/README b/README index a30bf66..6baad77 100644 --- a/README +++ b/README @@ -76,7 +76,7 @@ install Get the tarball and extract it: gtar xzf socat.tar.gz - cd socat-1.6.0.0 + cd socat-1.6.0.1 ./configure make su @@ -225,6 +225,18 @@ doc/socat-multicast.html is a short tutorial for multicast and broadcast communications. doc/socat-tun shows how to build a virtual network between two hosts. +socat.1 and socat.html can be generated from socat.yo (which is released with +socat 1.6.0.1 and later) using the yodl document language package. Maintenance +of yodl had been discontinued by its author +(http://www.xs4all.nl/~jantien/yodl/) (there seems to be a revival at +http://yodl.sourceforge.net/ though). For socat, the old version 1.31 is used; +an rpm is still distributed with recent OpenSuSE versions (confirmed for +OpenSuSE 10.1 in suse/i586/yodl-1.31.18-1142.i586.rpm). It appears to install +smoothly also under RedHat Linux. After yodl 1.31 installation, the following +correction must be performed in /usr/share/yodl/shared.yo in two places: +< whenhtml(htmlcommand())) +> whenhtml(htmlcommand())) + license ------- @@ -270,3 +282,6 @@ For socat source distribution, bug fixes, and latest news see www.socat.org is an alternate site providing the same contents. +public git repository: + git://repo.or.cz/socat.git + http://repo.or.cz/r/socat.git diff --git a/compat.h b/compat.h index c03ebec..64e5fe6 100644 --- a/compat.h +++ b/compat.h @@ -1,13 +1,13 @@ -/* $Id: compat.h,v 1.32 2006/06/19 20:28:52 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: compat.h */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __compat_h_included #define __compat_h_included 1 /*****************************************************************************/ -/* I dont like this system dependent part, but it would be quit a challenge for - configure */ +/* I dont like this system dependent part, but it would be quite a challenge + for configure */ /* define if the following does not work: socket() diff --git a/config.h.in b/config.h.in index 37a23d6..02630e7 100644 --- a/config.h.in +++ b/config.h.in @@ -1,4 +1,4 @@ -/* $Id: config.h.in,v 1.63 2007/03/06 21:00:16 gerhard Exp $ */ +/* source: config.h.in */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/configure.in b/configure.in index 4a32b71..e723554 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ -nl $Id: configure.in,v 1.108 2007/03/06 21:00:28 gerhard Exp $ -dnl Copyright Gerhard Rieger 2001-2007 +nl source: configure.in +dnl Copyright Gerhard Rieger 2001-2008 dnl Published under the GNU General Public License V.2, see file COPYING dnl Process this file with autoconf to produce a configure script. @@ -1177,7 +1177,7 @@ AC_MSG_RESULT($ac_cv_have_z_modifier) dnl find the number of bits we must shift a value to match the given mask dnl (e.g., mask 0x00f0 requires shifting with 4) -## NOTE: some platforms only need on '\' to escape '"' in string constant +## NOTE: some platforms only need one '\' to escape '"' in string constant define(AC_SHIFT_OFFSET,[ AC_CACHE_CHECK(shift offset of $1, $2, [LIBS1="$LIBS"; LIBS="" # avoid libwrap allow_severity undefined diff --git a/daemon.sh b/daemon.sh index fd7aa14..2a9167a 100755 --- a/daemon.sh +++ b/daemon.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $Id: daemon.sh,v 1.4 2001/10/29 09:52:47 gerhard Exp $ +# source: daemon.sh # Copyright Gerhard Rieger 2001 # Published under the GNU General Public License V.2, see file COPYING diff --git a/dalan.c b/dalan.c index 2313ee2..bc475cd 100644 --- a/dalan.c +++ b/dalan.c @@ -1,5 +1,5 @@ -/* $Id: dalan.c,v 1.8 2004/06/20 21:49:11 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2004 */ +/* source: dalan.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* idea of a low level data description language. currently only a most @@ -79,7 +79,7 @@ int dalan(const char *line, char *data, size_t *p, size_t n) { size_t p1 = *p; char c; - fputs(line, stderr); fputc('\n', stderr); + /*fputs(line, stderr); fputc('\n', stderr);*/ while (c = *line++) { switch (c) { case ' ': diff --git a/dalan.h b/dalan.h index 5d8c44e..7fd6e5f 100644 --- a/dalan.h +++ b/dalan.h @@ -1,4 +1,4 @@ -/* $Id: dalan.h,v 1.3 2001/06/30 14:02:39 gerhard Exp $ */ +/* source: dalan.h */ /* Copyright Gerhard Rieger 2001 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/doc/socat.1 b/doc/socat.1 deleted file mode 100644 index 86443bf..0000000 --- a/doc/socat.1 +++ /dev/null @@ -1,2574 +0,0 @@ -.TH "socat" "1" "July 2006" "socat" "" -.PP -.PP -.SH "NAME" -socat \- Multipurpose relay (SOcket CAT) -.PP -.SH "SYNOPSIS" -\f(CWsocat [options] \fP -.br -\f(CWsocat [options] \fP -.br -\f(CWsocat [options] \&.\&.\fP -.br -\f(CWsocat [options] \&.\&. -- \&.\&.\fP -.br -\f(CWsocat -V\fP -.br -\f(CWsocat -h[h[h]] | -?[?[?]]\fP -.br -\f(CWfilan\fP -.br -\f(CWprocan\fP -.PP -.SH "DESCRIPTION" -.PP -\fBSocat\fP is a command line based utility that establishes two bidirectional byte -streams and transfers data between them\&. Because the streams can be constructed -from a large set of different types of data sinks and sources -(see address types), and because lots of -address options may be applied to the streams, socat can -be used for many different purposes\&. -It might be one of the tools that one `has already needed\'\&. -.PP -\fBFilan\fP is a utility that prints information about its active file -descriptors to stdout\&. It has been written for debugging \fBsocat\fP, but might be -useful for other purposes too\&. Use the -h option to find more infos\&. -.PP -\fBProcan\fP is a utility that prints information about process parameters to -stdout\&. It has been written to better understand -some UNIX process properties and for debugging \fBsocat\fP, but might be -useful for other purposes too\&. -.PP -The life cycle of a \fBsocat\fP instance typically consists of four phases\&. -.PP -In the \fIinit\fP phase, the command line options are parsed and logging is -initialized\&. -.PP -During the \fIopen\fP phase, \fBsocat\fP opens the first address and afterwards the -second address\&. These steps are usually blocking; thus, especially for complex address types like socks, -connection requests or authentication dialogs must be completed before the next -step is started\&. -.PP -In the \fItransfer\fP phase, \fBsocat\fP watches both streams\' read and write file -descriptors via \f(CWselect()\fP, and, when data is available on one side \fIand\fP -can be written to the other side, socat reads it, performs newline -character conversions if required, and writes the data to the write file -descriptor of the other stream, then continues waiting for more data in both -directions\&. -.PP -When one of the streams effectively reaches EOF, the \fIclosing\fP phase -begins\&. \fBSocat\fP transfers the EOF condition to the other stream, -i\&.e\&. tries to shutdown only its write stream, giving it a chance to -terminate gracefully\&. For a defined time \fBsocat\fP continues to transfer data in -the other direction, but then closes all remaining channels and terminates\&. -.PP -.SH "OPTIONS" -.PP -\fBSocat\fP provides some command line options that modify the behaviour of the -program\&. They have nothing to do with so called -address options that are used as parts of address specifications\&. -.PP -.IP "\fB\f(CW-V\fP\fP" -Print version and available feature information to stdout, and exit\&. -.IP "\fB\f(CW-h | -?\fP\fP" -Print a help text to stdout describing command line options and available address -types, and exit\&. -.IP "\fB\f(CW-hh | -??\fP\fP" -Like -h, plus a list of the short names of all available address options\&. Some options are -platform dependend, so this output is helpful for checking the particular -implementation\&. -.IP "\fB\f(CW-hhh | -???\fP\fP" -Like -hh, plus a list of all available address option names\&. -.IP "\fB\f(CW-d\fP\fP" -Without this option, only fatal and error messages are generated; applying -this option also prints warning messages\&. See DIAGNOSTICS -for more information\&. -.IP "\fB\f(CW-d -d\fP\fP" -Prints fatal, error, warning, and notice messages\&. -.IP "\fB\f(CW-d -d -d\fP\fP" -Prints fatal, error, warning, notice, and info messages\&. -.IP "\fB\f(CW-d -d -d -d\fP\fP" -Prints fatal, error, warning, notice, info, and debug -messages\&. -.IP "\fB\f(CW-D\fP\fP" -Logs information about file descriptors before starting the transfer phase\&. -.IP "\fB\f(CW-ly[]\fP\fP" -Writes messages to syslog instead of stderr; severity as defined with -d -option\&. With optional , the syslog type can -be selected, default is "daemon"\&. -.IP "\fB\f(CW-lf\fP\fP\f(CW \fP" -Writes messages to [filename] instead of -stderr\&. -.IP "\fB\f(CW-ls\fP\fP" -Writes messages to stderr (this is the default)\&. -.IP "\fB\f(CW-lp\fP\fP\f(CW\fP" -Overrides the program name printed in error messages\&. -.IP "\fB\f(CW-lu\fP\fP" -Extends the timestamp of error messages to microsecond resolution\&. Does not -work when logging to syslog\&. -.IP "\fB\f(CW-lm[]\fP\fP" -Mixed log mode\&. During startup messages are printed to stderr; when \fBsocat\fP -starts the transfer phase loop or daemon mode (i\&.e\&. after opening all -streams and before starting data transfer, or, with listening sockets with -fork option, before the first accept call), it switches logging to syslog\&. -With optional , the syslog type can be -selected, default is "daemon"\&. -.IP "\fB\f(CW-lh\fP\fP" -Adds hostname to log messages\&. Uses the value from environment variable -HOSTNAME or the value retrieved with \f(CWuname()\fP if HOSTNAME is not set\&. -.IP "\fB\f(CW-v\fP\fP" -Writes the transferred data not only to their target streams, but also to -stderr\&. The output format is text with some conversions for readability, and -prefixed with "> " or "< " indicating flow directions\&. -.IP "\fB\f(CW-x\fP\fP" -Writes the transferred data not only to their target streams, but also to -stderr\&. The output format is hexadecimal, prefixed with "> " or "< " -indicating flow directions\&. Can be combined with \f(CW-v\fP\&. -.IP "\fB\f(CW-b\fP\fP\f(CW\fP" -Sets the data transfer block [size_t]\&. -At most bytes are transferred per step\&. Default is 8192 bytes\&. -.IP "\fB\f(CW-s\fP\fP" -By default, \fBsocat\fP terminates when an error occurred to prevent the process -from running when some option could not be applied\&. With this -option, \fBsocat\fP is sloppy with errors and tries to continue\&. Even with this -option, socat will exit on fatals, and will abort connection attempts when -security checks failed\&. -.IP "\fB\f(CW-t\fP\fP\f(CW\fP" -When one channel has reached EOF, the write part of the other channel is shut -down\&. Then, \fBsocat\fP waits [timeval] seconds -before terminating\&. Default is 0\&.5 seconds\&. This timeout only applies to -addresses where write and read part can be closed independently\&. When during -the timeout intervall the read part gives EOF, socat terminates without -awaiting the timeout\&. -.IP "\fB\f(CW-T\fP\fP\f(CW\fP" -Total inactivity timeout: when socat is already in the transfer loop and -nothing has happened for [timeval] seconds -(no data arrived, no interrupt occurred\&.\&.\&.) then it terminates\&. -Useful with protocols like UDP that cannot transfer EOF\&. -.IP "\fB\f(CW-u\fP\fP" -Uses unidirectional mode\&. The first address is only used for reading, and the -second address is only used for writing\&. -.IP "\fB\f(CW-U\fP\fP" -Uses unidirectional mode in reverse direction\&. The first address is only -used for writing, and the second address is only used for reading\&. -.IP "\fB\f(CW-g\fP\fP" -During address option parsing, don\'t check if the option is considered -useful in the given address environment\&. Use it if you want to force, e\&.g\&., -appliance of a socket option to a serial device\&. -.IP "\fB\f(CW-L\fP\fP\f(CW\fP" -If lockfile exists, exits with error\&. If lockfile does not exist, creates it -and continues, unlinks lockfile on exit\&. -.IP "\fB\f(CW-W\fP\fP\f(CW\fP" -If lockfile exists, waits until it disappears\&. When lockfile does not exist, -creates it and continues, unlinks lockfile on exit\&. -.IP "\fB\f(CW-4\fP\fP" -Use IP version 4 in case that the addresses do not implicitly or explicitly -specify a version; this is the default\&. -.IP "\fB\f(CW-6\fP\fP" -Use IP version 6 in case that the addresses do not implicitly or explicitly -specify a version\&. -.PP -.SH "ADDRESS SPECIFICATIONS" -.PP -With the address command line arguments, the user gives \fBsocat\fP instructions and -the necessary information for establishing the byte streams\&. -.PP -An address specification usually consists of an address type -keyword, zero or more required address parameters separated by \':\' from the keyword and -from each -other, and zero or more address options separated by \',\'\&. -.PP -The keyword specifies the address type (e\&.g\&., TCP4, OPEN, EXEC)\&. For some -keywords there exist synonyms (\'-\' for STDIO, TCP for TCP4)\&. Keywords are case -insensitive\&. -For a few special address types, the keyword may be omitted: -Address specifications starting with a number are assumed to be FD (raw file -descriptor) addresses; -if a \'/\' is found before the first \':\' or \',\', GOPEN (generic file open) is -assumed\&. -.PP -The required number and type of address parameters depend on the address -type\&. E\&.g\&., TCP4 requires a server specification (name or address), and a port -specification (number or service name)\&. -.PP -Zero or more address options may be given with each address\&. They influence the -address in some ways\&. -Options consist of an option keyword or an option keyword and a value, -separated by \'=\'\&. Option keywords are case insensitive\&. -For filtering the options that are useful with an address -type, each option is member of one option group\&. For -each address type there is a set of option groups allowed\&. Only options -belonging to one of these address groups may be used (except with option -g)\&. -.PP -Address specifications following the above schema are also called \fIsingle\fP -address specifications\&. -Two single addresses can be combined with "!!" to form a \fIdual\fP type -address for one channel\&. Here, the first address is used by \fBsocat\fP for reading -data, and the -second address for writing data\&. There is no way to specify an option only once -for being applied to both single addresses\&. -.PP -Usually, addresses are opened in read/write -mode\&. When an address is part of a dual address specification, or when -option -u or -U is used, an address might be -used only for reading or for writing\&. Considering this is important with some -address types\&. -.PP -With socat version 1\&.5\&.0 and higher, the lexical analysis tries to handle -quotes and parenthesis meaningfully and allows escaping of special characters\&. -If one of the characters ( { [ \' is found, the corresponding closing -character - ) } ] \' - is looked for; they may also be nested\&. Within these -constructs, socats special characters and strings : , !! are not handled -specially\&. All those characters and strings can be escaped with \e or within "" -.PP -.SH "ADDRESS TYPES" -.PP -This section describes the available address types with their keywords, -parameters, and semantics\&. -.PP -.IP "\fB\f(CWCREATE:\fP\fP" -Opens with \f(CWcreat()\fP and uses the file -descriptor for writing\&. -This address type requires write-only context, because a file opened with -\f(CWcreat\fP cannot be read from\&. - must be a valid existing or not existing path\&. -If is a named pipe, \f(CWcreat()\fP might block; -if refers to a socket, this is an error\&. -.br -Option groups: FD,REG,NAMED -.br -Useful options: -mode, -user, -group, -unlink-early, -unlink-late, -append -.br -See also: OPEN, GOPEN -.IP "\fB\f(CWEXEC:\fP\fP" -Forks a sub process that establishes communication with its parent process -and invokes the specified program with \f(CWexecvp()\fP\&. - is a simple command -with arguments separated by single spaces\&. If the program name -contains a \'/\', the part after the last \'/\' is taken as ARGV[0]\&. If the -program name is a relative -path, the \f(CWexecvp()\fP semantics for finding the program via -\f(CW$PATH\fP -apply\&. After successful program start, \fBsocat\fP writes data to stdin of the -process and reads from its stdout using a UNIX domain socket generated by -\f(CWsocketpair()\fP per default\&. -.br -Option groups: FD,SOCKET,EXEC,FORK,TERMIOS -.br -Useful options: -path, -fdin, -fdout, -chroot, -su, -su-d, -nofork, -pty, -stderr, -ctty, -setsid, -pipes, -login, -sigint, -sigquit -.br -See also: SYSTEM -.IP "\fB\f(CWFD:\fP\fP" -Uses the file descriptor \&. It must already exist as -valid UN*X file descriptor\&. -.br -Option groups: FD (TERMIOS,REG,SOCKET) -.br -See also: -STDIO, -STDIN, -STDOUT, -STDERR -.IP "\fB\f(CWGOPEN:\fP\fP" -(Generic open) This address type tries to handle any file system entry -except directories usefully\&. may be a -relative or absolute path\&. If it already exists, its type is checked\&. -In case of a UNIX domain socket, \fBsocat\fP connects; if connecting fails, -\fBsocat\fP assumes a datagram socket and uses \f(CWsendto()\fP calls\&. -If the entry is not a socket, \fBsocat\fP opens it applying the \f(CWO_APPEND\fP -flag\&. -If it does not exist, it is opened with flag -\f(CWO_CREAT\fP as a regular file\&. -.br -Option groups: FD,REG,SOCKET,NAMED,OPEN -.br -See also: -OPEN, -CREATE, -UNIX-CONNECT -.IP -.IP "\fB\f(CWIP-SENDTO::\fP\fP" -Opens a raw IP socket\&. Depending on host specification or option pf, IP procotol version -4 or 6 is used\&. It uses to send packets -to [IP address] and receives packets from -host, ignores packets from other hosts\&. -Protocol 255 uses the raw socket with the IP header being part of the -data\&. -.br -Option groups: FD,SOCKET,IP4,IP6 -.br -Useful options: -pf, -ttl, -broadcast -.br -See also: -IP4-SENDTO, -IP6-SENDTO, -IP-RECVFROM, -IP-RECV, -UDP-SENDTO -UNIX-SENDTO -.IP "\fB\f(CWIP4-SENDTO::\fP\fP" -Like IP-SENDTO, but always uses IPv4\&. -.br -Option groups: FD,SOCKET,IP4 -.br -.IP "\fB\f(CWIP6-SENDTO::\fP\fP" -Like IP-SENDTO, but always uses IPv6\&. -.br -Option groups: FD,SOCKET,IP6 -.br -.IP -.IP "\fB\f(CWIP-RECVFROM:\fP\fP" -Opens a raw IP socket of \&. Depending on option pf, IP procotol version -4 or 6 is used\&. It receives one packet from an unspecified peer and may send one or more answer packets to that peer\&. -This mode is particularly useful with fork option where each arriving packet - from arbitrary peers - is handled by its own sub process\&. -This allows a behaviour similar to typical UDP based servers like ntpd or named\&. -This address works well with IP-SENDTO address peers (see above)\&. -Protocol 255 uses the raw socket with the IP header being part of the -data\&. -.br -Option groups: FD,SOCKET,IP4,IP6,CHILD,RANGE -.br -Useful options: -pf, -fork, -range, -ttl, -broadcast -.br -See also: -IP4-RECVFROM, -IP6-RECVFROM, -IP-SENDTO, -IP-RECV, -UDP-RECVFROM, -UNIX-RECVFROM -.IP "\fB\f(CWIP4-RECVFROM:\fP\fP" -Like IP-RECVFROM, but always uses IPv4\&. -.br -Option groups: FD,SOCKET,IP4,CHILD,RANGE -.br -.IP "\fB\f(CWIP6-RECVFROM:\fP\fP" -Like IP-RECVFROM, but always uses IPv6\&. -.br -Option groups: FD,SOCKET,IP6,CHILD,RANGE -.br -.IP -.IP "\fB\f(CWIP-RECV:\fP\fP" -Opens a raw IP socket of \&. Depending on option pf, IP procotol version -4 or 6 is used\&. It receives packets from multiple unspecified peers and merges the data\&. -No replies are possible\&. -It can be, e\&.g\&., addressed by socat IP-SENDTO address peers\&. -Protocol 255 uses the raw socket with the IP header being part of the -data\&. -.br -Option groups: FD,SOCKET,IP4,IP6,RANGE -.br -Useful options: -pf, -range -.br -See also: -IP4-RECV, -IP6-RECV, -IP-SENDTO, -IP-RECVFROM, -UDP-RECV, -UNIX-RECV -.IP "\fB\f(CWIP4-RECV:\fP\fP" -Like IP-RECV, but always uses IPv4\&. -.br -Option groups: FD,SOCKET,IP4,RANGE -.br -.IP "\fB\f(CWIP6-RECV:\fP\fP" -Like IP-RECV, but always uses IPv6\&. -.br -Option groups: FD,SOCKET,IP6,RANGE -.br -.IP -.IP "\fB\f(CWOPEN:\fP\fP" -Opens using the \f(CWopen()\fP system call\&. -This operation fails on UNIX domain sockets\&. -.br -Note: This address type is rarly useful in bidirectional mode\&. -.br -Option groups: FD,REG,NAMED,OPEN -.br -Useful options: -creat, -excl, -noatime, -nofollow, -append, -rdonly, -wronly, -lock, -readbytes, -ignoreeof -.br -See also: -CREATE, -GOPEN, -UNIX-CONNECT -.IP "\fB\f(CWOPENSSL::\fP\fP" -Tries to establish a SSL connection to [TCP -service] on - [IP address] using TCP/IP version 4 or 6 -depending on address specification, name resolution, or option -pf\&. -.br -NOTE: The server certificate is only checked for validity against -cafile or capath, -but not for match with the server\'s name or its IP address! -.br -Option groups: FD,SOCKET,IP4,IP6,TCP,OPENSSL,RETRY -.br -Useful options: -cipher, -method, -verify, -cafile, -capath, -certificate, -bind, -pf, -connect-timeout, -sourceport, -retry -.br -See also: -OPENSSL-LISTEN, -TCP -.IP "\fB\f(CWOPENSSL-LISTEN:\fP\fP" -Listens on tcp [TCP service]\&. -The IP version is 4 or the one specified with -pf\&. When a -connection is accepted, this address behaves as SSL server\&. -.br -Note: You probably want to use the certificate option with this address\&. -.br -NOTE: Without verify option, the client certificate is -not checked\&. Even with verify option, the client -certificate is only checked for validity against cafile -or capath, but not for match with the client\'s name or -its IP address! -.br -Option groups: FD,SOCKET,IP4,IP6,TCP,LISTEN,OPENSSL,CHILD,RANGE,RETRY -.br -Useful options: -pf, -cipher, -method, -verify, -cafile, -capath, -certificate, -fork, -bind, -range, -tcpwrap, -su, -reuseaddr, -retry -.br -See also: -OPENSSL, -TCP -.IP "\fB\f(CWPIPE:\fP\fP" -If already exists, it is opened\&. -If is does not exist, a named pipe is created and opened\&. Beginning with -socat version 1\&.4\&.3, the named pipe is removed when the address is closed -(but see option unlink-close -.br -Note: When a pipe is used for both reading and writing, it works -as echo service\&. -.br -Note: When a pipe is used for both reading and writing, and socat tries -to write more bytes than the pipe can buffer (Linux 2\&.4: 2048 bytes), socat -might block\&. Consider using socat option, e\&.g\&., \f(CW-b 2048\fP -.br -Option groups: FD,NAMED,OPEN -.br -Useful options: -rdonly, -nonblock, -group, -user, -mode, -unlink-early -.br -See also: unnamed pipe -.IP "\fB\f(CWPIPE\fP\fP" -Creates an unnamed pipe and uses it for reading and writing\&. It works as an -echo, because everything written -to it appeares immediately as read data\&. -.br -Note: When socat tries to write more bytes than the pipe can queue (Linux -2\&.4: 2048 bytes), socat might block\&. Consider, e\&.g\&., using -option \f(CW-b 2048\fP -.br -Option groups: FD -.br -See also: named pipe -.IP "\fB\f(CWPROXY:::\fP\fP" -Connects to an HTTP proxy server on port 8080 using TCP/IP version 4 or 6 -depending on address specification, name resolution, or option -pf, and sends a CONNECT -request for hostname:port\&. If the proxy grants access and succeeds to -connect to the target, data transfer between socat and the target can -start\&. Note that the traffic need not be HTTP but can be an arbitrary -protocol\&. -.br -Option groups: FD,SOCKET,IP4,IP6,TCP,HTTP,RETRY -.br -Useful options: -proxyport, -ignorecr, -proxyauth, -resolve, -crnl, -bind, -connect-timeout, -mss, -sourceport, -retry -.br -See also: SOCKS, TCP -.IP "\fB\f(CWPTY\fP\fP" -.IP "\fB\f(CWPTY:\fP\fP" -Generates a pseudo terminal (pty) and uses its master side\&. Another process -may open the pty\'s slave side using it like a serial line or terminal\&. If -both the ptmx and the openpty mechanisms are available, ptmx is used -(POSIX)\&. In the second form, the link option is -already integrated as a parameter\&. -.br -Option groups: FD,NAMED,PTY,TERMIOS -.br -Useful options: -link, -openpty, -wait-slave, -mode, -user, -group -.br -See also: -UNIX-LISTEN, -PIPE, -EXEC, SYSTEM -.IP "\fB\f(CWREADLINE\fP\fP" -Uses GNU readline and history on stdio to allow editing and reusing input -lines\&. This requires the GNU readline and -history libraries\&. Note that stdio should be a (pseudo) terminal device, -otherwise readline does not seem to work\&. -.br -Option groups: FD,READLINE,TERMIOS -.br -Useful options: -history, -noecho -.br -See also: -STDIO -.IP "\fB\f(CWSOCKS4:::\fP\fP" -Connects via [IP address] -to [IPv4 address] -on [TCP service], -using socks version 4 protocol over IP version 4 or 6 depending on address specification, name resolution, or option -pf\&. -.br -Option groups: FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY -.br -Useful options: -socksuser, -socksport, -sourceport, -pf, -retry -.br -See also: -SOCKS4A, -PROXY, -TCP -.IP "\fB\f(CWSOCKS4A:::\fP\fP" -like SOCKS4, but uses socks protocol version 4a, thus -leaving host name resolution to the socks server\&. -.br -Option groups: FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY -.br -.IP "\fB\f(CWSTDERR\fP\fP" -Uses file descriptor 2\&. -.br -Option groups: FD (TERMIOS,REG,SOCKET) -.br -See also: FD -.IP "\fB\f(CWSTDIN\fP\fP" -Uses file descriptor 0\&. -.br -Option groups: FD (TERMIOS,REG,SOCKET) -.br -Useful options: -readbytes -.br -See also: FD -.IP "\fB\f(CWSTDIO\fP\fP" -Uses file descriptor 0 for reading, and 1 for writing\&. -.br -Option groups: FD (TERMIOS,REG,SOCKET) -.br -Useful options: -readbytes -.br -See also: FD -.IP "\fB\f(CWSTDOUT\fP\fP" -Uses file descriptor 1\&. -.br -Option groups: FD (TERMIOS,REG,SOCKET) -.br -See also: FD -.IP "\fB\f(CWSYSTEM:\fP\fP" -Forks a sub process that establishes communication with its parent process -and invokes the specified program with \f(CWsystem()\fP\&. Please note that - [string] must -not contain \',\' or "!!", and that shell meta characters may have to be -protected\&. -After successful program start, \fBsocat\fP writes data to stdin of the -process and reads from its stdout\&. -.br -Option groups: FD,SOCKET,EXEC,FORK,TERMIOS -.br -Useful options: -path, -fdin, -fdout, -chroot, -su, -su-d, -nofork, -pty, -stderr, -ctty, -setsid, -pipes, -sigint, -sigquit -.br -See also: EXEC -.IP "\fB\f(CWTCP::\fP\fP" -Connects to [TCP service] on - [IP address] using TCP/IP version 4 or 6 -depending on address specification, name resolution, or option -pf\&. -.br -Option groups: FD,SOCKET,IP4,IP6,TCP,RETRY -.br -Useful options: -crnl, -bind, -pf, -connect-timeout, -tos, -mtudiscover, -mss, -nodelay, -nonblock, -sourceport, -retry, -readbytes -.br -See also: -TCP4, -TCP6, -TCP-LISTEN, -UDP, -UNIX-CONNECT -.IP "\fB\f(CWTCP4::\fP\fP" -Like TCP, but only supports IPv4 protocol\&. -.br -Option groups: FD,SOCKET,IP4,TCP,RETRY -.br -.IP "\fB\f(CWTCP6::\fP\fP" -Like TCP, but only supports IPv6 protocol\&. -.br -Option groups: FD,SOCKET,IP6,TCP,RETRY -.br -.IP "\fB\f(CWTCP-LISTEN:\fP\fP" -Listens on [TCP service] and accepts a -TCP/IP connection\&. The IP version is 4 or the one specified with -pf\&. -Note that opening -this address usually blocks until a client connects\&. -.br -Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6,TCP,RETRY -.br -Useful options: -crnl, -fork, -bind, -range, -tcpwrap, -pf, -backlog, -mss, -su, -reuseaddr, -retry, -retry -.br -See also: -TCP4-LISTEN, -TCP6-LISTEN, -UDP-LISTEN, -UNIX-LISTEN, -OPENSSL-LISTEN -.IP "\fB\f(CWTCP4-LISTEN:\fP\fP" -Like TCP-LISTEN, but only supports IPv4 -protocol\&. -.br -Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,TCP,RETRY -.br -.IP "\fB\f(CWTCP6-LISTEN:\fP\fP" -Like TCP-LISTEN, but only supports IPv6 -protocol\&. -.br -Additional useful option: -ipv6only -.br -Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6,TCP,RETRY -.br -.IP -.IP "\fB\f(CWUDP::\fP\fP" -Connects to [UDP service] on - [IP address] using UDP/IP version 4 or 6 -depending on address specification, name resolution, or option -pf\&. -.br -Please note that, -due to UDP protocol properties, no real connection is established; data has -to be sent for `connecting\' to the server, and no end-of-file condition can -be transported\&. -.br -Option groups: FD,SOCKET,IP4,IP6 -.br -Useful options: -ttl, -tos, -bind, -sourceport, -pf -.br -See also: -UDP4, -UDP6, -UDP-LISTEN, -TCP, -IP -.IP "\fB\f(CWUDP4::\fP\fP" -Like UDP, but only supports IPv4 protocol\&. -.br -Option groups: FD,SOCKET,IP4 -.br -.IP "\fB\f(CWUDP6::\fP\fP" -Like UDP, but only supports IPv6 protocol\&. -.br -Option groups: FD,SOCKET,IP6 -.br -.IP -.IP "\fB\f(CWUDP-LISTEN:\fP\fP" -Waits for a UDP/IP packet arriving on -[UDP service] and `connects\' back to sender\&. -The accepted IP version is 4 or the one specified with option -pf\&. -Please note that, -due to UDP protocol properties, no real connection is established; data has to arrive from the peer first, and no end-of-file condition can be -transported\&. Note that opening -this address usually blocks until a client connects\&. -.br -Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6 -.br -Useful options: -fork, -bind, -range, -pf -.br -See also: -UDP, -UDP4-LISTEN, -UDP6-LISTEN, -TCP-LISTEN -.IP "\fB\f(CWUDP4-LISTEN:\fP\fP" -Like UDP-LISTEN, but only support IPv4 -protocol\&. -.br -Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4 -.br -.IP "\fB\f(CWUDP6-LISTEN:\fP\fP" -Like UDP-LISTEN, but only support IPv6 -protocol\&. -.br -Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6 -.br -.IP -.IP "\fB\f(CWUDP-SENDTO::\fP\fP" -Communicates with the specified peer socket, defined by [UDP service] on - [IP address], using UDP/IP version 4 or 6 -depending on address specification, name resolution, or option -pf\&. It sends packets to and receives packets from that peer socket only\&. -This is effectively a datagram client\&. -It works well with socat UDP-RECVFROM and UDP-RECV address peers\&. -.br -Option groups: FD,SOCKET,IP4,IP6 -.br -Useful options: -ttl, -tos, -bind, -sourceport, -pf -.br -See also: -UDP4-SENDTO, -UDP6-SENDTO, -UDP-RECVFROM, -UDP-RECV, -UDP-CONNECT, -UDP-LISTEN, -IP-SENDTO -.IP "\fB\f(CWUDP4-SENDTO::\fP\fP" -Like UDP-SENDTO, but only supports IPv4 protocol\&. -.br -Option groups: FD,SOCKET,IP4 -.IP "\fB\f(CWUDP6-SENDTO::\fP\fP" -Like UDP-SENDTO, but only supports IPv6 protocol\&. -.br -Option groups: FD,SOCKET,IP6 -.IP -.IP "\fB\f(CWUDP-RECVFROM:\fP\fP" -Creates a UDP socket on [UDP service] using UDP/IP version 4 or 6 -depending on option pf\&. -It receives one packet from an unspecified peer and may send one or more -answer packets to that peer\&. This mode is particularly useful with fork option -where each arriving packet - from arbitrary peers - is handled by its own sub -process\&. This allows a behaviour similar to typical UDP based servers like ntpd -or named\&. This address works well with socat SENDTO address peers\&. -.br -Option groups: FD,SOCKET,IP4,IP6,CHILD,RANGE -.br -Useful options: -fork, -ttl, -tos, -bind, -sourceport, -pf -.br -See also: -UDP4-RECVFROM, -UDP6-RECVFROM, -UDP-SENDTO, -UDP-RECV, -UDP-CONNECT, -UDP-LISTEN, -IP-RECVFROM, -UNIX-RECVFROM -.IP "\fB\f(CWUDP4-RECVFROM:\fP\fP" -Like UDP-RECVFROM, but only supports IPv4 protocol\&. -.br -Option groups: FD,SOCKET,IP4,CHILD,RANGE -.IP "\fB\f(CWUDP6-RECVFROM:\fP\fP" -Like UDP-RECVFROM, but only supports IPv6 protocol\&. -.br -Option groups: FD,SOCKET,IP6,CHILD,RANGE -.IP -.IP "\fB\f(CWUDP-RECV:\fP\fP" -Creates a UDP socket on [UDP service] using UDP/IP version 4 or 6 -depending on option pf\&. -It receives packets from multiple unspecified peers and merges the data\&. -No replies are possible\&. It can be, e\&.g\&., addressed by socat UDP-SENDTO address peers\&. -This address works well with socat SENDTO address peers; it behaves similar to a syslog server\&. -.br -Option groups: FD,SOCKET,IP4,IP6,RANGE -.br -Useful options: -fork, -pf, -bind, -sourceport, -ttl, -tos -.br -See also: -UDP4-RECV, -UDP6-RECV, -UDP-SENDTO, -UDP-RECVFROM, -UDP-CONNECT, -UDP-LISTEN, -IP-RECV, -UNIX-RECV -.IP "\fB\f(CWUDP4-RECV:\fP\fP" -Like UDP-RECV, but only supports IPv4 protocol\&. -.br -Option groups: FD,SOCKET,IP4,RANGE -.IP "\fB\f(CWUDP6-RECV:\fP\fP" -Like UDP-RECV, but only supports IPv6 protocol\&. -.br -Option groups: FD,SOCKET,IP6,RANGE -.IP -.IP "\fB\f(CWUNIX-CONNECT:\fP\fP" -Connects to assuming it is a UNIX domain -socket\&. -If does not exist, this is an error; -if is not a UNIX domain socket, this is an error; -if is a UNIX domain socket, but no process is listening, this is -an error\&. -.br -Option groups: FD,SOCKET,NAMED,RETRY -.br -) -Useful options: -bind -.br -See also: -UNIX-LISTEN, -UNIX-SENDTO, -TCP -.IP -.IP "\fB\f(CWUNIX-LISTEN:\fP\fP" -Listens on using a UNIX domain stream -socket and accepts a connection\&. -If exists and is not a socket, this is an error\&. -If exists and is a UNIX domain socket, binding to the address -fails (use option unlink-early!)\&. -Note that opening this address usually blocks until a client connects\&. -Beginning with socat version 1\&.4\&.3, the file system entry is removed when -this address is closed (but see option unlink-close)\&. -.br -Option groups: FD,SOCKET,NAMED,LISTEN,CHILD,RETRY -.br -Useful options: -fork, -umask, -mode, -user, -group, -unlink-early -.br -See also: -UNIX-CONNECT, -UNIX-RECVFROM, -UNIX-RECV, -TCP-LISTEN -.IP -.IP "\fB\f(CWUNIX-SENDTO:\fP\fP" -Communicates with the specified peer socket, defined by [] assuming it is a UNIX domain datagram socket\&. -It sends packets to and receives packets from that peer socket only\&. -It works well with socat UNIX-RECVFROM and UNIX-RECV address peers\&. -.br -Option groups: FD,SOCKET,NAMED -.br -Useful options: -bind -.br -See also: -UNIX-RECVFROM, -UNIX-RECV, -UNIX-CONNECT, -UDP-SENDTO, -IP-SENDTO -.IP -.IP "\fB\f(CWUNIX-RECVFROM:\fP\fP" -Creates a UNIX domain datagram socket []\&. -Receives one packet and may send one or more answer packets to that peer\&. -This mode is particularly useful with fork option where each arriving packet - from arbitrary peers - is handled by its own sub process\&. -This address works well with socat UNIX-SENDTO address peers\&. -.br -Option groups: FD,SOCKET,NAMED,CHILD -.br -Useful options: -fork -.br -See also: -UNIX-SENDTO, -UNIX-RECV, -UNIX-LISTEN, -UDP-RECVFROM, -IP-RECVFROM -.IP -.IP "\fB\f(CWUNIX-RECV:\fP\fP" -Creates a UNIX domain datagram socket []\&. -Receives packets from multiple unspecified peers and merges the data\&. -No replies are possible\&. It can be, e\&.g\&., addressed by socat UNIX-SENDTO address peers\&. -It behaves similar to a syslog server\&. -Option groups: FD,SOCKET,NAMED -.br -See also: -UNIX-SENDTO, -UNIX-RECVFROM, -UNIX-LISTEN, -UDP-RECV, -IP-RECV -.IP -.IP "\fB\f(CWUNIX:\fP\fP" -Communicates with the specified peer socket, defined by -[] assuming it is a UNIX domain socket\&. -It first tries to connect and, if that fails, assumes it is a datagram -socket, thus supporting both types\&. -.br -Option groups: FD,SOCKET,NAMED -.br -Useful options: -bind -.br -See also: -UNIX-CONNECT, -UNIX-SENDTO, -GOPEN -.PP -.SH "ADDRESS OPTIONS" -.PP -Address options can be applied to address specifications to influence the -process of opening the addresses and the -properties of the resulting data channels\&. -.PP -For technical reasons not every option can be -applied to every address type; e\&.g\&., applying a socket option to a regular file -will fail\&. To catch most useless combinations as early as in the open phase, -the concept of \fIoption groups\fP was introduced\&. Each option belongs to one -or more option groups\&. Options can be used only with address types that support -at least one of their option groups (but see option -g)\&. -.PP -Address options have data types that their values must conform to\&. -Every address option consists of just a keyword or a keyword followed by -"=value", where value must conform to the options type\&. -Some address options manipulate parameters of system calls; -e\&.g\&., option sync sets the \f(CWO_SYNC\fP flag with the \f(CWopen()\fP call\&. -Other options cause a system or library call; e\&.g\&., with option `ttl=value\' -the \f(CWsetsockopt(fd, SOL_IP, IP_TTL, value, sizeof(int))\fP call is applied\&. -Other -options set internal \fBsocat\fP variables that are used during data transfer; -e\&.g\&., `crnl\' causes explicit character conversions\&. -A few options have more complex implementations; e\&.g\&., su-d -(substuser-delayed) inquires some user and group infos, stores them, and -applies them later after a possible \f(CWchroot()\fP call\&. -.PP -If multiple options are given to an address, their sequence in the address specification has (almost) no -effect on the sequence of their execution/application\&. Instead, \fBsocat\fP has -built in an \fIoption phase\fP model that tries to bring the options in a useful -order\&. Some options exist in different forms (e\&.g\&., -unlink, unlink-early, unlink-late) to control the time of their execution\&. -.PP -If the same option is specified more than once within one address -specification, with equal or different values, the effect depends on the kind of option\&. Options -resulting in function calls like \f(CWsetsockopt()\fP cause multiple -invocations\&. With options that set parameters for a required call like -\f(CWopen()\fP -or set internal flags, the value of the last option occurrence is effective\&. -.PP -The existence or semantics of many options are system dependent\&. \fBSocat\fP -usually does NOT try to emulate missing libc or kernel features, it just -provides an -interface to the underlying system\&. So, if an operating system lacks a feature, -the related option is simply not available on this platform\&. -.PP -The following paragraphs introduce just the more common address options\&. For -a more comprehensive reference and to find information about canonical option -names, alias names, option phases, and platforms see file \fBxio\&.help\fP\&. -.br -.br -.PP -.br -.PP -\fI\fBFD option group\fP\fP -.PP -This option group contains options that are applied to a UN*X -style file descriptor, no matter how it was generated\&. -Because all current \fBsocat\fP address types are file descriptor based, these -options may be applied to any address\&. -.br -Note: Some of these options are also member of another option group, that -provides an other, non-fd based mechanism\&. -For these options, it depends on the actual address type and its option groups -which mechanism is used\&. The second, non-fd based mechanism is prioritized\&. -.IP "\fB\f(CWcloexec=\fP\fP" -Sets the \f(CWFD_CLOEXEC\fP flag with the \f(CWfcntl()\fP system call to value -\&. If set, -the file descriptor is closed on \f(CWexec()\fP family function calls\&. \fBSocat\fP -internally handles -this flag for the fds it controls, so in most cases there will be no need to -apply this option\&. -.IP "\fB\f(CWsetlk\fP\fP" -Tries to set a discretionary lock to the whole file using the \f(CWfcntl(fd, -F_SETLK, \&.\&.\&.)\fP system call\&. If the file is already locked, this call results -in an error\&. -.IP "\fB\f(CWsetlkw\fP\fP" -Tries to set a discretionary waiting lock to the whole file using the -\f(CWfcntl(fd, F_SETLKW, \&.\&.\&.)\fP system call\&. If the file is already locked, -this call blocks\&. -.IP "\fB\f(CWflock-ex\fP\fP" -Tries to set a blocking exclusive advisory lock to the file using the -\f(CWflock(fd, LOCK_EX)\fP system call\&. \fBSocat\fP hangs in this call if the file -is locked by another process\&. -.IP "\fB\f(CWflock-ex-nb\fP\fP" -Tries to set a nonblocking exclusive advisory lock to the file using the -\f(CWflock(fd, LOCK_EX)\fP system call\&. If the file is already locked, -this option results in an error\&. -.IP "\fB\f(CWflock-sh\fP\fP" -Tries to set a blocking shared advisory lock to the file using the -\f(CWflock(fd, LOCK_SH)\fP system call\&. \fBSocat\fP hangs in this call if the file -is locked by another process\&. -.IP "\fB\f(CWflock-sh-nb\fP\fP" -Tries to set a nonblocking shared advisory lock to the file using the -\f(CWflock(fd, LOCK_SH|LOCK_NB)\fP system call\&. If the file is already locked, -this option results in an error\&. -.IP "\fB\f(CWlock\fP\fP" -Sets a blocking lock on the file\&. Uses the setlk or flock mechanism -depending on availability on the particular platform\&. If both are available, -the POSIX variant (setlkw) is selected\&. -.IP "\fB\f(CWuser=\fP\fP" -Sets the (owner) of the stream\&. -If the address is member of the NAMED option group, -\fBsocat\fP uses the \f(CWchown()\fP system call after opening the -file or binding to the UNIX domain socket (race condition!)\&. -Without filesystem entry, \fBsocat\fP sets the user of the stream -using the \f(CWfchown()\fP system call\&. -These calls might require root privilege\&. -.IP "\fB\f(CWuser-late=\fP\fP" -Sets the owner of the fd to with the \f(CWfchown()\fP -system call after opening -or connecting the channel\&. -This is useful only on file system entries\&. -.IP "\fB\f(CWgroup=\fP\fP" -Sets the of the stream\&. -If the address is member of the NAMED option group, -\fBsocat\fP uses the \f(CWchown()\fP system call after opening the -file or binding to the UNIX domain socket (race condition!)\&. -Without filesystem entry, \fBsocat\fP sets the group of the stream -with the \f(CWfchown()\fP system call\&. -These calls might require group membership or root privilege\&. -.IP "\fB\f(CWgroup-late=\fP\fP" -Sets the group of the fd to with the -\f(CWfchown()\fP system call after opening -or connecting the channel\&. -This is useful only on file system entries\&. -.IP "\fB\f(CWmode=\fP\fP" -Sets the [mode_t] (permissions) of the stream\&. -If the address is member of the NAMED option group and -uses the \f(CWopen()\fP or \f(CWcreat()\fP call, the mode is applied with these\&. -If the address is member of the NAMED option group without using these -system calls, \fBsocat\fP uses the \f(CWchmod()\fP system call after opening the -filesystem entry or binding to the UNIX domain socket (race condition!)\&. -Otherwise, \fBsocat\fP sets the mode of the stream -using \f(CWfchmod()\fP\&. -These calls might require ownership or root privilege\&. -.IP "\fB\f(CWperm-late=\fP\fP" -Sets the permissions of the fd to value -[mode_t] using the \f(CWfchmod()\fP system call after -opening or connecting the channel\&. -This is useful only on file system entries\&. -.IP "\fB\f(CWappend=\fP\fP" -Always writes data to the actual end of file\&. -If the address is member of the OPEN option group, -\fBsocat\fP uses the \f(CWO_APPEND\fP flag with the \f(CWopen()\fP system call\&. -Otherwise, \fBsocat\fP applies the \f(CWfcntl(fd, F_SETFL, O_APPEND)\fP call\&. -.IP "\fB\f(CWnonblock=\fP\fP" -Tries to open or use file in nonblocking mode\&. Its only effects are that the -\f(CWconnect()\fP call of TCP addresses does not block, and that opening a -named pipe for reading does not block\&. -If the address is member of the OPEN option group, -\fBsocat\fP uses the \f(CWO_NONBLOCK\fP flag with the \f(CWopen()\fP system call\&. -Otherwise, \fBsocat\fP applies the \f(CWfcntl(fd, F_SETFL, O_NONBLOCK)\fP call\&. -.IP "\fB\f(CWbinary\fP\fP" -Opens the file in binary mode to avoid implicit line terminator -conversions (Cygwin)\&. -.IP "\fB\f(CWtext\fP\fP" -Opens the file in text mode to force implicit line terminator conversions -(Cygwin)\&. -.IP "\fB\f(CWnoinherit\fP\fP" -Does not keep this file open in a spawned process (Cygwin)\&. -.IP "\fB\f(CWcool-write\fP\fP" -Takes it easy when write fails with EPIPE or ECONNRESET and logs the message -with \fInotice\fP level instead of \fIerror\fP\&. -This prevents the log file from being filled with useless error messages -when socat is used as a high volume server or proxy where clients often -abort the connection\&. -.br -This option is experimental\&. -.PP -.br -.PP -\fI\fBNAMED option group\fP\fP -.PP -These options work on file system entries\&. -.br -See also options user, group, and -mode\&. -.PP -.IP "\fB\f(CWuser-early=\fP\fP" -Changes the (owner) of the file system entry before -accessing it, using the -\f(CWchown()\fP system call\&. This call might require root privilege\&. -.IP "\fB\f(CWgroup-early=\fP\fP" -Changes the of the file system entry before -accessing it, using the -\f(CWchown()\fP system call\&. This call might require group membership or root -privilege\&. -.IP "\fB\f(CWperm-early=\fP\fP" -Changes the [mode_t] of the file system entry -before accessing it, using the -\f(CWchmod()\fP system call\&. This call might require ownership or root -privilege\&. -.IP "\fB\f(CWumask=\fP\fP" -Sets the umask of the process to [mode_t] before -accessing the file system entry (useful -with UNIX domain sockets!)\&. This call might affect all further operations -of the \fBsocat\fP process! -.IP "\fB\f(CWunlink-early\fP\fP" -Unlinks (removes) the file before opening it and even before applying -user-early etc\&. -.IP "\fB\f(CWunlink\fP\fP" -Unlinks (removes) the file before accessing it, but after user-early etc\&. -.IP "\fB\f(CWunlink-late\fP\fP" -Unlinks (removes) the file after opening it to make it inaccessible for -other processes after a short race condition\&. -.IP "\fB\f(CWunlink-close\fP\fP" -Removes the addresses file system entry when closing the address\&. -For named pipes, -listening unix domain sockets, -and the symbolic links of pty addresses, -the default is 1; for created files, -opened files, -generic opened files, and -client unix domain sockets the default is 0\&. -.PP -.br -.PP -\fI\fBOPEN option group\fP\fP -.PP -The OPEN group options allow to set flags with the \f(CWopen()\fP system call\&. -E\&.g\&., option `creat\' sets the \f(CWO_CREAT\fP flag\&. -.br -See also options append and -nonblock\&. -.IP "\fB\f(CWcreat=\fP\fP" -Creates the file if it does not exist\&. -.IP "\fB\f(CWdsync=\fP\fP" -Blocks \f(CWwrite()\fP calls until metainfo is physically written to media\&. -.IP "\fB\f(CWexcl=\fP\fP" -With option creat, if file exists this is an error\&. -.IP "\fB\f(CWlargefile=\fP\fP" -On 32 bit systems, allows a file larger than 2^31 bytes\&. -.IP "\fB\f(CWnoatime\fP\fP" -Sets the O_NOATIME options, so reads do not change the access timestamp\&. -.IP "\fB\f(CWnoctty=\fP\fP" -Does not make this file the controlling terminal\&. -.IP "\fB\f(CWnofollow=\fP\fP" -Does not follow symbolic links\&. -.IP "\fB\f(CWnshare=\fP\fP" -Does not allow to share this file with other processes\&. -.IP "\fB\f(CWrshare=\fP\fP" -Does not allow other processes to open this file for writing\&. -.IP "\fB\f(CWrsync=\fP\fP" -Blocks \f(CWwrite()\fP until metainfo is physically written to media\&. -.IP "\fB\f(CWsync=\fP\fP" -Blocks \f(CWwrite()\fP until data is physically written to media\&. -.IP "\fB\f(CWrdonly=\fP\fP" -Opens the file for reading only\&. -.IP "\fB\f(CWwronly=\fP\fP" -Opens the file for writing only\&. -.IP "\fB\f(CWtrunc\fP\fP" -Truncates the file to size 0 during opening it\&. -.PP -.br -.PP -\fI\fBREG and BLK option group\fP\fP -.PP -These options are usually applied to a UN*X file descriptor, but their -semantics make sense only on a file supporting random access\&. -.IP "\fB\f(CWseek=\fP\fP" -Applies the \f(CWlseek(fd, , SEEK_SET)\fP (or \f(CWlseek64\fP) system -call, thus positioning the file pointer absolutely to -[off_t or off64_t]\&. -.IP "\fB\f(CWseek-cur=\fP\fP" -Applies the \f(CWlseek(fd, , SEEK_CUR)\fP (or \f(CWlseek64\fP) system -call, thus positioning the file pointer [off_t or -off64_t] bytes relatively to its current position (which -is usually 0)\&. -.IP "\fB\f(CWseek-end=\fP\fP" -Applies the \f(CWlseek(fd, , SEEK_END)\fP (or \f(CWlseek64\fP) system -call, thus positioning the file pointer [off_t or -off64_t] bytes relatively to the files current end\&. -.IP "\fB\f(CWftruncate=\fP\fP" -Applies the \f(CWftruncate(fd, )\fP -(or \f(CWftruncate64\fP if available) system call, thus -truncating the file at the position [off_t or -off64_t]\&. -.IP -.IP "\fB\f(CWsecrm=\fP\fP" -.IP "\fB\f(CWunrm=\fP\fP" -.IP "\fB\f(CWcompr=\fP\fP" -.IP "\fB\f(CWext2-sync=\fP\fP" -.IP "\fB\f(CWimmutable=\fP\fP" -.IP "\fB\f(CWext2-append=\fP\fP" -.IP "\fB\f(CWnodump=\fP\fP" -.IP "\fB\f(CWext2-noatime=\fP\fP" -.IP "\fB\f(CWjournal-data=\fP\fP" -.IP "\fB\f(CWnotail=\fP\fP" -.IP "\fB\f(CWdirsync=\fP\fP" -These options change non standard file attributes on operating systems and -file systems that support these features, like Linux with ext2fs, -ext3fs, or reiserfs\&. See man 1 chattr for information on these options\&. -Please note that there might be a race condition between creating the file -and applying these options\&. -.PP -.br -.PP -\fI\fBPROCESS option group\fP\fP -.PP -Options of this group change the process properties instead of just affecting -one data channel\&. -For EXEC and SYSTEM addresses and for LISTEN and CONNECT type addresses with -option FORK, -these options apply to the child processes instead of the main socat process\&. -.IP "\fB\f(CWchroot=\fP\fP" -Performs a \f(CWchroot()\fP operation to -after processing the address\&. This call might require root privilege\&. -.IP "\fB\f(CWchroot-early=\fP\fP" -Performs a \f(CWchroot()\fP operation to -before opening the address\&. This call might require root privilege\&. -.IP "\fB\f(CWsetgid=\fP\fP" -Changes the primary of the process after -processing the address\&. This call might require root privilege\&. -.IP "\fB\f(CWsetgid-early=\fP\fP" -Changes the primary of the process before opening -the address\&. This call might require root privilege\&. -.IP "\fB\f(CWsetuid=\fP\fP" -Changes the (owner) of the process after processing -the address\&. This call might require root privilege\&. -.IP "\fB\f(CWsetuid-early=\fP\fP" -Changes the (owner) of the process before opening -the address\&. This call might require root privilege\&. -.IP "\fB\f(CWsu=\fP\fP" -Changes the (owner) and groups of the process after -processing the address\&. This call might require root privilege\&. -.IP "\fB\f(CWsu-d=\fP\fP" -Short name for \fB\f(CWsubstuser-delayed\fP\fP\&. -Changes the -(owner) and groups of the process after processing the address\&. -The user and his groups are retrieved \fIbefore\fP a possible -\f(CWchroot()\fP\&. This call might require root privilege\&. -.IP "\fB\f(CWsetpgid=\fP\fP" -Makes the process a member of the specified process group -\&. If no value -is given, or if the value is 0 or 1, the process becomes leader of a new -process group\&. -.IP "\fB\f(CWsetsid\fP\fP" -Makes the process the leader of a new session\&. -.PP -.br -.PP -\fI\fBREADLINE option group\fP\fP -.PP -These options apply to the readline address type\&. -.IP "\fB\f(CWhistory=\fP\fP" -Reads and writes history from/to \&. -.IP "\fB\f(CWnoprompt\fP\fP" -Since version 1\&.4\&.0, socat per default tries to determine a prompt - -that is then passed to the readline call - by remembering the last -incomplete line of the output\&. With this option, socat does not pass a -prompt to readline, so it begins line editing in the first column -of the terminal\&. -.IP "\fB\f(CWnoecho=\fP\fP" -Specifies a regular pattern for a prompt that prevents the following input -line from being displayed on the screen and from being added to the history\&. -The prompt is defined as the text that was output to the readline address -after the lastest newline character and before an input character was -typed\&. The pattern is a regular expression, e\&.g\&. -"^[Pp]assword:\&.*$" or "([Uu]ser:|[Pp]assword:)"\&. See regex(7) for details\&. -.IP "\fB\f(CWprompt=\fP\fP" -Passes the string as prompt to the readline function\&. readline prints this -prompt when stepping through the history\&. If this string matches a constant -prompt issued by an interactive program on the other socat address, -consistent look and feel can be archieved\&. -.PP -.br -.PP -\fI\fBAPPLICATION option group\fP\fP -.PP -This group contains options that work at data level\&. -Note that these options only apply to the "raw" data transferred by socat, -but not to protocol data used by addresses like -PROXY\&. -.IP "\fB\f(CWcr\fP\fP" -Converts the default line termination character NL (\'\en\', 0x0a) to/from CR -(\'\er\', 0x0d) when writing/reading on this channel\&. -.IP "\fB\f(CWcrnl\fP\fP" -Converts the default line termination character NL (\'\en\', 0x0a) to/from CRNL -("\er\en", 0x0d0a) when writing/reading on this channel\&. -Note: socat simply strips all CR characters\&. -.IP "\fB\f(CWignoreeof\fP\fP" -When EOF occurs on this channel, \fBsocat\fP ignores it and tries to read more -data (like "tail -f")\&. -.IP "\fB\f(CWreadbytes=\fP\fP" -\fBsocat\fP reads only so many bytes from this address (the address provides -only so many bytes for transfer and pretends to be at EOF afterwards)\&. -Must be greater than 0\&. -.IP "\fB\f(CWlockfile=\fP\fP" -If lockfile exists, exits with error\&. If lockfile does not exist, creates it -and continues, unlinks lockfile on exit\&. -.IP "\fB\f(CWwaitlock=\fP\fP" -If lockfile exists, waits until it disappears\&. When lockfile does not exist, -creates it and continues, unlinks lockfile on exit\&. -.PP -.br -.PP -\fI\fBSOCKET option group\fP\fP -.PP -These options are intended for all kinds of sockets, e\&.g\&. IP or UNIX domain\&. Most are applied with a \f(CWsetsockopt()\fP call\&. -.IP "\fB\f(CWbind=\fP\fP" -Binds the socket to the given socket address using the \f(CWbind()\fP system -call\&. The form of is socket domain dependent: -IP4 and IP6 allow the form [hostname|hostaddress][:(service|port)], -UNIX domain sockets require \&. -.IP "\fB\f(CWconnect-timeout=\fP\fP" -Abort the connection attempt after [timeval] -with error status\&. -.IP "\fB\f(CWinterface=\fP\fP" -Binds the socket to the given \&. -This option might require root privilege\&. -.IP "\fB\f(CWbroadcast\fP\fP" -For datagram sockets, allows sending to broadcast addresses and receiving -packets addressed to broadcast addresses\&. -.IP "\fB\f(CWbsdcompat\fP\fP" -Emulates some (old?) bugs of the BSD socket implementation\&. -.IP "\fB\f(CWdebug\fP\fP" -Enables socket debugging\&. -.IP "\fB\f(CWdontroute\fP\fP" -Only communicates with directly connected peers, does not use routers\&. -.IP "\fB\f(CWkeepalive\fP\fP" -Enables sending keepalives on the socket\&. -.IP "\fB\f(CWlinger=\fP\fP" -Blocks \f(CWshutdown()\fP or \f(CWclose()\fP until data transfers have finished -or the given timeout [int] expired\&. -.IP "\fB\f(CWoobinline\fP\fP" -Places out-of-band data in the input data stream\&. -.IP "\fB\f(CWpriority=\fP\fP" -Sets the protocol defined [] for outgoing -packets\&. -.IP "\fB\f(CWrcvbuf=\fP\fP" -Sets the size of the receive buffer after the \f(CWsocket()\fP call to - [int]\&. With TCP -sockets, this value corresponds to the socket\'s maximal window size\&. -.IP "\fB\f(CWrcvbuf-late=\fP\fP" -Sets the size of the receive buffer when the socket is already -connected to [int]\&. -With TCP sockets, this value corresponds to the socket\'s -maximal window size\&. -.IP "\fB\f(CWrcvlowat=\fP\fP" -Specifies the minimum number of received bytes [int] until -the socket layer will pass the buffered data to \fBsocat\fP\&. -.IP "\fB\f(CWrcvtimeo=\fP\fP" -Sets the receive timeout [timeval]\&. -.IP "\fB\f(CWreuseaddr\fP\fP" -Allows other sockets to bind to an address even if parts of it (e\&.g\&. the -local port) are already in use by \fBsocat\fP\&. -.IP "\fB\f(CWsndbuf=\fP\fP" -Sets the size of the send buffer after the \f(CWsocket()\fP call to - [int]\&. -.IP "\fB\f(CWsndbuf-late=\fP\fP" -Sets the size of the send buffer when the socket is connected to - [int]\&. -.IP "\fB\f(CWsndlowat=\fP\fP" -Specifies the minimum number of bytes in the send buffer until the socket -layer will send the data to [int]\&. -.IP "\fB\f(CWsndtimeo=\fP\fP" -Sets the send timeout to seconds [timeval]\&. -.IP "\fB\f(CWtype=\fP\fP" -Sets the type of the socket, usually as argument to the \f(CWsocket()\fP or -\f(CWsocketpair()\fP call, to [int]\&. -Under Linux, 1 means stream oriented socket, 2 means datagram socket, and 3 -means raw socket\&. -.IP "\fB\f(CWpf=\fP\fP" -Forces the use of the specified IP version\&. can be -something like "ip4" or "ip6"\&. -.PP -.br -.PP -\fI\fBIP4 and IP6 option groups\fP\fP -.PP -These options can be used with IPv4 and IPv6 based sockets\&. -.IP "\fB\f(CWtos=\fP\fP" -Sets the TOS (type of service) field of outgoing packets to -[byte] (see RFC 791)\&. -.IP "\fB\f(CWttl=\fP\fP" -Sets the TTL (time to live) field of outgoing packets to -[byte]\&. -.IP "\fB\f(CWipoptions=\fP\fP" -Sets IP options like source routing\&. Must be given in binary form, -recommended format is a leading "x" followed by an even number of hex -digits\&. This option may be used multiple times, data are appended\&. -E\&.g\&., to connect to host 10\&.0\&.0\&.1 via some gateway using a loose source -route, use the gateway as address parameter and set a loose source route -using the option \f(CWipoptions=x8307040a000001\fP\&. -.br -IP options are defined in RFC 791\&. -.br -.IP "\fB\f(CWmtudiscover=<0|1|2>\fP\fP" -Takes 0, 1, 2 to never, want, or always use path MTU discover on this -socket\&. -.IP "\fB\f(CWres-debug\fP\fP" -.IP "\fB\f(CWres-aaonly\fP\fP" -.IP "\fB\f(CWres-usevc\fP\fP" -.IP "\fB\f(CWres-primary\fP\fP" -.IP "\fB\f(CWres-igntc\fP\fP" -.IP "\fB\f(CWres-recurse\fP\fP" -.IP "\fB\f(CWres-defnames\fP\fP" -.IP "\fB\f(CWres-stayopen\fP\fP" -.IP "\fB\f(CWres-dnsrch\fP\fP" -These options set the corresponding resolver (name resolution) option flags\&. -Append "=0" to clear a default option\&. See man resolver(5) for more -information on these options\&. Note: these options are valid only for the -address they are applied to\&. -.IP -.PP -.br -.PP -\fI\fBIP6 option group\fP\fP -.PP -These options can only be used on IPv6 based sockets\&. See IP -options for options that can be applied to both IPv4 and IPv6 -sockets\&. -.IP "\fB\f(CWipv6only=\fP\fP" -Sets the IPV6_V6ONLY socket option\&. If 0, the TCP stack will also accept -connections using IPv4 protocol on the same port\&. The default is system -dependent\&. -.PP -.br -.PP -\fI\fBTCP option group\fP\fP -.PP -These options may be applied to TCP sockets\&. They work by invoking \f(CWsetsockopt()\fP with the appropriate parameters\&. -.IP "\fB\f(CWcork\fP\fP" -Doesn\'t send packets smaller than MSS (maximal segment size)\&. -.IP "\fB\f(CWdefer-accept\fP\fP" -While listening, accepts connections only when data from the peer arrived\&. -.IP "\fB\f(CWkeepcnt=\fP\fP" -Sets the number of keepalives before shutting down the socket to - [int]\&. -.IP "\fB\f(CWkeepidle=\fP\fP" -Sets the idle time before sending the first keepalive to -[int]\&. -.IP "\fB\f(CWkeepintvl=\fP\fP" -Sets the intervall between two keepalives to -[int]\&. -.IP "\fB\f(CWlinger2=\fP\fP" -Sets the time to keep the socket in FIN-WAIT-2 state to -[int]\&. -.IP "\fB\f(CWmss=\fP\fP" -Sets the MSS (maximum segment size) after the \f(CWsocket()\fP call to -[int]\&. This -value is then proposed to the peer with the SYN or SYN/ACK packet\&. -.IP "\fB\f(CWmss-late=\fP\fP" -Sets the MSS of the socket after connection has been established to -[int]\&. -.IP "\fB\f(CWnodelay\fP\fP" -Turns off the Nagle algorithm for measuring the RTT (round trip time)\&. -.IP "\fB\f(CWrfc1323\fP\fP" -Enables RFC1323 TCP options: TCP window scale, round-trip time measurement -(RTTM), and protect against wrapped sequence numbers (PAWS) (AIX)\&. -.IP "\fB\f(CWstdurg\fP\fP" -Enables RFC1122 compliant urgent pointer handling (AIX)\&. -.IP "\fB\f(CWsyncnt=\fP\fP" -Sets the maximal number of SYN retransmits during connect to -[int]\&. -.IP "\fB\f(CWmd5sig\fP\fP" -Enables generation of MD5 digests on the packets (FreeBSD)\&. -.IP "\fB\f(CWnoopt\fP\fP" -Disables use of TCP options (FreeBSD, MacOSX)\&. -.IP "\fB\f(CWnopush\fP\fP" -sets the TCP_NOPUSH socket option (FreeBSD, MacOSX)\&. -.IP "\fB\f(CWsack-disable\fP\fP" -Disables use the selective acknowledge feature (OpenBSD)\&. -.IP "\fB\f(CWsignature-enable\fP\fP" -Enables generation of MD5 digests on the packets (OpenBSD)\&. -.IP "\fB\f(CWabort-threshold=\fP\fP" -Sets the time to wait for an answer of the peer on an established connection -(HP-UX)\&. -.IP "\fB\f(CWconn-abort-threshold=\fP\fP" -Sets the time to wait for an answer of the server during the initial connect -(HP-UX)\&. -.IP "\fB\f(CWkeepinit\fP\fP" -Sets the time to wait for an answer of the server during connect() before -giving up\&. Value in half seconds, default is 150 (75s) (Tru64)\&. -.IP "\fB\f(CWpaws\fP\fP" -Enables the "protect against wrapped sequence numbers" feature (Tru64)\&. -.IP "\fB\f(CWsackena\fP\fP" -Enables selective acknowledge (Tru64)\&. -.IP "\fB\f(CWtsoptena\fP\fP" -Enables the time stamp option that allows RTT recalculation on existing -connections (Tru64)\&. -.PP -.br -.PP -\fI\fBUDP and TCP option groups\fP\fP -.PP -Here we find options that are related to the network port mechanism and that -thus can be used with UDP and TCP, client and server addresses\&. -.IP "\fB\f(CWsourceport=\fP\fP" -For outgoing (client) TCP and UDP connections, it sets the source - using an extra \f(CWbind()\fP call\&. -With TCP or UDP listen addresses, socat immediately shuts down the -connection if the client does not use this sourceport\&. -.IP "\fB\f(CWlowport\fP\fP" -Outgoing (client) TCP and UDP connections with this option use -an unused random source port between 640 and 1023 incl\&. On UNIX class operating -systems, this requires root privilege, and thus indicates that the -client process is authorized by local root\&. -TCP and UDP listen addresses with this option immediately shut down the -connection if the client does not use a sourceport <= 1023\&. -This mechanism can provide limited authorization under some circumstances\&. -.PP -.br -.PP -\fI\fBSOCKS option group\fP\fP -.PP -When using SOCKS type addresses, some socks specific options can be set\&. -.IP "\fB\f(CWsocksport=\fP\fP" -Overrides the default "socks" service or port 1080 for the socks server -port with \&. -.IP "\fB\f(CWsocksuser=\fP\fP" -Sends the [string] in the username field to the -socks server\&. Default is the actual user name ($LOGNAME or $USER)\&. -.PP -.br -.PP -\fI\fBHTTP option group\fP\fP -.PP -Options that can be provided with HTTP type addresses\&. The only HTTP address -currently implemented is proxy-connect\&. -.PP -.IP "\fB\f(CWproxyport=\fP\fP" -Overrides the default HTTP proxy port 8080 with -\&. -.IP "\fB\f(CWignorecr\fP\fP" -The HTTP protocol requires the use of CR+NL as line terminator\&. When a proxy -server violates this standard, socat might not understand its answer\&. -This option directs socat to interprete NL as line terminator and -to ignore CR in the answer\&. Nevertheless, socat sends CR+NL to the proxy\&. -.IP "\fB\f(CWproxyauth=:\fP\fP" -Provide "basic" authentication to the proxy server\&. The argument to the -option is used with a "Proxy-Authorization: Base" header in base64 encoded -form\&. -.br -Note: username and password are visible for every user on the local machine -in the process list; username and password are transferred to the proxy -server unencrypted (base64 encoded) and might be sniffed\&. -.IP "\fB\f(CWresolve\fP\fP" -Per default, socat sends to the proxy a CONNECT request containing the -target hostname\&. With this option, socat resolves the hostname locally and -sends the IP address\&. -.PP -.br -.PP -\fI\fBRANGE option group\fP\fP -.PP -These options check if a connecting client is granted access\&. They can be -applied to listening and receiving network sockets\&. tcp-wrappers options fall -into this group\&. -.IP "\fB\f(CWrange=\fP\fP" -After accepting a connection, tests if the peer is within \fIrange\fP\&. For -IPv4 addresses, address-range takes the form ww\&.xx\&.yy\&.zz/bits, e\&.g\&. -10\&.0\&.0\&.0/8; for IPv6, it is [ip6-address/bits], e\&.g\&. [::1/128]\&. -If the client address does not match, \fBsocat\fP issues a warning and keeps -listening/receiving\&. -.IP "\fB\f(CWtcpwrap[=]\fP\fP" -Uses Wietse Venema\'s libwrap (tcpd) library to determine -if the client is allowed to connect\&. The configuration files are -/etc/hosts\&.allow and /etc/hosts\&.deny per default, see "man 5 hosts_access" -for more information\&. The optional (type string) -is passed to the wrapper functions as daemon process name\&. -If omitted, the basename of socats invocation (argv[0]) is passed\&. -If both tcpwrap and range options are applied to an address, both -conditions must be fulfilled to allow the connection\&. -.IP "\fB\f(CWallow-table=\fP\fP" -Takes the specified file instead of /etc/hosts\&.allow\&. -.IP "\fB\f(CWdeny-table=\fP\fP" -Takes the specified file instead of /etc/hosts\&.deny\&. -.IP "\fB\f(CWtcpwrap-etc=\fP\fP" -Looks for hosts\&.allow and hosts\&.deny in the specified directory\&. Is -overridden by options hosts-allow -and hosts-deny\&. -.PP -.br -.PP -\fI\fBLISTEN option group\fP\fP -.PP -Options specific to listening sockets\&. -.IP "\fB\f(CWbacklog=\fP\fP" -Sets the backlog value passed with the \f(CWlisten()\fP system call to -[int]\&. Default is 5\&. -.br -.PP -\fI\fBCHILD option group\fP\fP -.PP -Options for addresses with multiple connections via child processes\&. -.IP "\fB\f(CWfork\fP\fP" -After establishing a connection, handles its channel in a child process and -keeps the parent process attempting to produce more connections, either by -listening or by connecting in a loop\&. -.br -SSL-CONNECT and SSL-LISTEN differ in when they actually fork off the child: -SSL-LISTEN forks \fIbefore\fP the SSL handshake, while SSL-CONNECT forks -\fIafterwards\fP\&. -RETRY and FOREVER options are not inherited by the child process\&. -.br -.PP -.br -.PP -\fI\fBEXEC option group\fP\fP -.PP -Options for addresses that invoke a program\&. -.IP "\fB\f(CWpath=\fP\fP" -Overrides the PATH environment variable for searching the program with -\&. This -\f(CW$PATH\fP value is effective in the child process too\&. -.IP "\fB\f(CWlogin\fP\fP" -Prefixes \f(CWargv[0]\fP for the \f(CWexecvp()\fP call with \'-\', thus making a -shell behave as login shell\&. -.PP -.br -.PP -\fI\fBFORK option group\fP\fP -.PP -EXEC or SYSTEM addresses invoke a program using a child process and transfer data between \fBsocat\fP and the program\&. The interprocess communication mechanism can be influenced with the following options\&. Per -default, a \f(CWsocketpair()\fP is created and assigned to stdin and stdout of -the child process, while stderr is inherited from the \fBsocat\fP process, and the -child process uses file descriptors 0 and 1 for communicating with the main -socat process\&. -.IP "\fB\f(CWnofork\fP\fP" -Does not fork a subprocess for executing the program, instead calls execvp() -or system() directly from the actual socat instance\&. This avoids the -overhead of another process between the program and its peer, -but introduces a lot of restrictions: -.IP o -this option can only be applied to the second \fBsocat\fP address\&. -.IP o -it cannot be applied to a part of a dual address\&. -.IP o -the first socat address cannot be OPENSSL or READLINE -.IP o -socat options -b, -t, -D, -l, -v, -x become useless -.IP o -for both addresses, options ignoreeof, cr, and crnl become useless -.IP o -for the second address (the one with option nofork), options -append, cloexec, flock, user, group, mode, nonblock, -perm-late, setlk, and setpgid cannot be applied\&. Some of these could be -used on the first address though\&. -.IP "\fB\f(CWpipes\fP\fP" -Creates a pair of unnamed pipes for interprocess communication instead of a -socket pair\&. -.IP "\fB\f(CWopenpty\fP\fP" -Establishes communication with the sub process using a pseudo terminal -created with \f(CWopenpty()\fP instead of the default (socketpair or ptmx)\&. -.IP "\fB\f(CWptmx\fP\fP" -Establishes communication with the sub process using a pseudo terminal -created by opening \fB/dev/ptmx\fP or \fB/dev/ptc\fP instead of the default -(socketpair)\&. -.IP "\fB\f(CWpty\fP\fP" -Establishes communication with the sub process using a pseudo terminal -instead of a socket pair\&. Creates the pty with an available mechanism\&. If -openpty and ptmx are both available, it uses ptmx because this is POSIX -compliant\&. -.IP "\fB\f(CWctty\fP\fP" -Makes the pty the controlling tty of the sub process\&. -.IP "\fB\f(CWstderr\fP\fP" -Directs stderr of the sub process to its output channel by making stderr a -\f(CWdup()\fP of stdout\&. -.IP "\fB\f(CWfdin=\fP\fP" -Assigns the sub processes input channel to its file descriptor - -instead of stdin (0)\&. The program started from the subprocess has to use -this fd for reading data from \fBsocat\fP\&. -.IP "\fB\f(CWfdout=\fP\fP" -Assigns the sub processes output channel to its file descriptor - -instead of stdout (1)\&. The program started from the subprocess has to use -this fd for writing data to \fBsocat\fP\&. -.IP "\fB\f(CWsighup\fP\fP, \fB\f(CWsigint\fP\fP, \fB\f(CWsigquit\fP\fP" -Has \fBsocat\fP pass an eventual signal of this type to the sub process\&. -If no address has this option, socat terminates on these signals\&. -.PP -.br -.PP -\fI\fBTERMIOS option group\fP\fP -.PP -For addresses that work on a tty (e\&.g\&., stdio, file:/dev/tty, exec:\&.\&.\&.,pty), the terminal parameters defined in the UN*X termios mechanism are made available as address option parameters\&. -Please note that changes of the parameters of your interactive terminal -remain effective after \fBsocat\fP\'s termination, so you might have to enter "reset" -or "stty sane" in your shell afterwards\&. -For EXEC and SYSTEM addresses with option PTY, -these options apply to the pty by the child processes\&. -.PP -.IP "\fB\f(CWb0\fP\fP" -Disconnects the terminal\&. -.IP "\fB\f(CWb19200\fP\fP" -Sets the serial line speed to 19200 baud\&. Some other rates are possible; use -something like \f(CWsocat -hh |grep \' b[1-9]\'\fP to find all speeds supported by -your implementation\&. -.br -Note: On some operating systems, these options may not be -available\&. Use ispeed or ospeed -instead\&. -.IP "\fB\f(CWecho=\fP\fP" -Enables or disables local echo\&. -.IP "\fB\f(CWicanon=\fP\fP" -Sets or clears canonical mode, enabling line buffering and some special -characters\&. -.IP "\fB\f(CWraw\fP\fP" -Sets raw mode, thus passing input and output almost unprocessed\&. -.IP "\fB\f(CWignbrk=\fP\fP" -Ignores or interpretes the BREAK character (e\&.g\&., ^C) -.IP "\fB\f(CWbrkint=\fP\fP" -.IP "\fB\f(CWbs0\fP\fP" -.IP "\fB\f(CWbs1\fP\fP" -.IP "\fB\f(CWbsdly=<0|1>\fP\fP" -.IP "\fB\f(CWclocal=\fP\fP" -.IP -\.LP -\.nf -\fBcr0 -cr1 -cr2 -cr3\fP -\.fi -\.IP -Sets the carriage return delay to 0, 1, 2, or 3, respectively\&. -0 means no delay, the other values are terminal dependent\&. -.IP -.IP "\fB\f(CWcrdly=<0|1|2|3>\fP\fP" -.IP "\fB\f(CWcread=\fP\fP" -.IP "\fB\f(CWcrtscts=\fP\fP" -.IP -\.LP -\.nf -\fBcs5 -cs6 -cs7 -cs8\fP -\.fi -\.IP -Sets the character size to 5, 6, 7, or 8 bits, respectively\&. -.IP -.IP "\fB\f(CWcsize=<0|1|2|3>\fP\fP" -.IP "\fB\f(CWcstopb=\fP\fP" -Sets two stop bits, rather than one\&. -.IP "\fB\f(CWdsusp=\fP\fP" -Sets the value for the VDSUSP character that suspends the current foreground -process and reactivates the shell (all except Linux)\&. -.IP "\fB\f(CWechoctl=\fP\fP" -Echos control characters in hat notation (e\&.g\&. ^A) -.IP "\fB\f(CWechoe=\fP\fP" -.IP "\fB\f(CWechok=\fP\fP" -.IP "\fB\f(CWechoke=\fP\fP" -.IP "\fB\f(CWechonl=\fP\fP" -.IP "\fB\f(CWechoprt=\fP\fP" -.IP "\fB\f(CWeof=\fP\fP" -.IP "\fB\f(CWeol=\fP\fP" -.IP "\fB\f(CWeol2=\fP\fP" -.IP "\fB\f(CWerase=\fP\fP" -.IP "\fB\f(CWdiscard=\fP\fP" -.IP "\fB\f(CWff0\fP\fP" -.IP "\fB\f(CWff1\fP\fP" -.IP "\fB\f(CWffdly=\fP\fP" -.IP "\fB\f(CWflusho=\fP\fP" -.IP "\fB\f(CWhupcl=\fP\fP" -.IP "\fB\f(CWicrnl=\fP\fP" -.IP "\fB\f(CWiexten=\fP\fP" -.IP "\fB\f(CWigncr=\fP\fP" -.IP "\fB\f(CWignpar=\fP\fP" -.IP "\fB\f(CWimaxbel=\fP\fP" -.IP "\fB\f(CWinlcr=\fP\fP" -.IP "\fB\f(CWinpck=\fP\fP" -.IP "\fB\f(CWintr=\fP\fP" -.IP "\fB\f(CWisig=\fP\fP" -.IP "\fB\f(CWispeed=\fP\fP" -Set the baud rate for incoming data on this line\&. -.br -See also: ospeed, b19200 -dif(\fB\f(CWistrip=\fP\fP) -.IP "\fB\f(CWiuclc=\fP\fP" -.IP "\fB\f(CWixany=\fP\fP" -.IP "\fB\f(CWixoff=\fP\fP" -.IP "\fB\f(CWixon=\fP\fP" -.IP "\fB\f(CWkill=\fP\fP" -.IP "\fB\f(CWlnext=\fP\fP" -.IP "\fB\f(CWmin=\fP\fP" -.IP "\fB\f(CWnl0\fP\fP" -Sets the newline delay to 0\&. -.IP "\fB\f(CWnl1\fP\fP" -.IP "\fB\f(CWnldly=\fP\fP" -.IP "\fB\f(CWnoflsh=\fP\fP" -.IP "\fB\f(CWocrnl=\fP\fP" -.IP "\fB\f(CWofdel=\fP\fP" -.IP "\fB\f(CWofill=\fP\fP" -.IP "\fB\f(CWolcuc=\fP\fP" -.IP "\fB\f(CWonlcr=\fP\fP" -.IP "\fB\f(CWonlret=\fP\fP" -.IP "\fB\f(CWonocr=\fP\fP" -.IP "\fB\f(CWopost=\fP\fP" -Enables or disables output processing; e\&.g\&., converts NL to CR-NL\&. -.IP "\fB\f(CWospeed=\fP\fP" -Set the baud rate for outgoing data on this line\&. -.br -See also: ispeed, b19200 -.IP "\fB\f(CWparenb=\fP\fP" -Enable parity generation on output and parity checking for input\&. -.IP "\fB\f(CWparmrk=\fP\fP" -.IP "\fB\f(CWparodd=\fP\fP" -.IP "\fB\f(CWpendin=\fP\fP" -.IP "\fB\f(CWquit=\fP\fP" -.IP "\fB\f(CWreprint=\fP\fP" -.IP "\fB\f(CWsane\fP\fP" -Brings the terminal to something like a useful default state\&. -.IP "\fB\f(CWstart=\fP\fP" -.IP "\fB\f(CWstop=\fP\fP" -.IP "\fB\f(CWsusp=\fP\fP" -.IP "\fB\f(CWswtc=\fP\fP" -.IP "\fB\f(CWtab0\fP\fP" -.IP "\fB\f(CWtab1\fP\fP" -.IP "\fB\f(CWtab2\fP\fP" -.IP "\fB\f(CWtab3\fP\fP" -.IP "\fB\f(CWtabdly=\fP\fP" -.IP "\fB\f(CWtime=\fP\fP" -.IP "\fB\f(CWtostop=\fP\fP" -.IP "\fB\f(CWvt0\fP\fP" -.IP "\fB\f(CWvt1\fP\fP" -.IP "\fB\f(CWvtdly=\fP\fP" -.IP "\fB\f(CWwerase=\fP\fP" -.IP "\fB\f(CWxcase=\fP\fP" -.IP "\fB\f(CWxtabs\fP\fP" -.PP -.br -.PP -\fI\fBPTY option group\fP\fP -.PP -These options are intended for use with the pty address -type\&. -.PP -.IP "\fB\f(CWlink=\fP\fP" -Generates a symbolic link that points to the actual pseudo terminal -(pty)\&. This might help -to solve the problem that ptys are generated with more or less -unpredictable names, making it difficult to directly access the socat -generated pty automatically\&. With this option, the user can specify a "fix" -point in the file hierarchy that helps him to access the actual pty\&. -Beginning with \fBsocat\fP version 1\&.4\&.3, the symbolic link is removed when -the address is closed (but see option unlink-close)\&. -.IP "\fB\f(CWwait-slave\fP\fP" -Blocks the open phase until a process opens the slave side of the pty\&. -Usually, socat continues after generating the pty with opening the next -address or with entering the transfer loop\&. With the wait-slave option, -socat waits until some process opens the slave side of the pty before -continuing\&. -This option only works if the operating system provides the \f(CWpoll()\fP -system call\&. And it depends on an undocumented behaviour of pty\'s, so it -does not work on all operating systems\&. It has successfully been tested on -Linux, FreeBSD, NetBSD, and on Tru64 with openpty\&. -.IP "\fB\f(CWpty-intervall=\fP\fP" -When the wait-slave option is set, socat -periodically checks the HUP condition using \f(CWpoll()\fP to find if the pty\'s -slave side has been opened\&. The default polling intervall is 1s\&. Use the -pty-intervall option [timeval] to change this value\&. -.PP -.br -.PP -\fI\fBOPENSSL option group\fP\fP -.PP -These options apply to the openssl and -openssl-listen address types\&. -.PP -.IP "\fB\f(CWcipher=\fP\fP" -Selects the list of ciphers that may be used for the connection\&. -See the man page of \f(CWciphers\fP, section \fBCIPHER LIST FORMAT\fP, for -detailed information about syntax, values, and default of \&. -.br -Several cipher strings may be given, separated by \':\'\&. -Some simple cipher strings: -.IP "3DES" -Uses a cipher suite with triple DES\&. -.IP "MD5" -Uses a cipher suite with MD5\&. -.IP "aNULL" -Uses a cipher suite without authentication\&. -.IP "NULL" -Does not use encryption\&. -.IP "HIGH" -Uses a cipher suite with "high" encryption\&. -Note that the peer must support the selected property, or the negotiation -will fail\&. -.IP "\fB\f(CWmethod=\fP\fP" -Sets the protocol version to be used\&. Valid strings (not case sensitive) -are: -.IP "\f(CWSSLv2\fP" -Select SSL protocol version 2\&. -.IP "\f(CWSSLv3\fP" -Select SSL protocol version 3\&. -.IP "\f(CWSSLv23\fP" -Select SSL protocol version 2 or 3\&. This is the default when -this option is not provided\&. -.IP "\f(CWTLSv1\fP" -Select TLS protocol version 1\&. -.IP "\fB\f(CWverify=\fP\fP" -Controls check of the peer\'s certificate\&. Default is 1 (true) for client and -0 (false) for server addresses\&. Disabling verify might open your socket for -everyone! -.IP "\fB\f(CWcert=\fP\fP" -Specifies the file with the certificate and private key for authentication\&. -The certificate must be in OpenSSL format (*\&.pem)\&. -With openssl-listen, use of this option is strongly -recommended\&. Except with cipher aNULL, "no shared ciphers" error will -occur when no certificate is given\&. -.IP "\fB\f(CWkey=\fP\fP" -Specifies the file with the private key\&. The private key may be in this -file or in the file given with the cert option\&. The party that has -to proof that it is the owner of a certificate needs the private key\&. -.IP "\fB\f(CWdhparams=\fP\fP" -Specifies the file with the Diffie Hellman parameters\&. These parameters may -also be in the file given with the cert -option in which case the dhparams option is not needed\&. -.IP "\fB\f(CWcafile=\fP\fP" -Specifies the file with the trusted (root) authority certificates\&. The file -must be in PEM format and should contain one or more certificates\&. The party -that checks the authentication of its peer trusts only certificates that are -in this file\&. -.IP "\fB\f(CWcapath=\fP\fP" -Specifies the directory with the trusted (root) certificates\&. The directory -must contain certificates in PEM format and their hashes (see OpenSSL -documentation) -.IP "\fB\f(CWegd=\fP\fP" -On some systems, openssl requires an explicit source of random data\&. Specify -the socket name where an entropy gathering daemon like egd provides random -data, e\&.g\&. /dev/egd-pool\&. -.IP "\fB\f(CWpseudo\fP\fP" -On systems where openssl cannot find an entropy source and where no entropy -gathering daemon can be utilized, this option activates a mechanism for -providing pseudo entropy\&. This is archieved by taking the current time in -microseconds for feeding the libc pseudo random number generator with an -initial value\&. openssl is then feeded with output from random() calls\&. -.br -NOTE:This mechanism is not sufficient for generation of secure keys! -.IP "\fB\f(CWfips\fP\fP" -Enables FIPS mode if compiled in\&. For info about the FIPS encryption -implementation standard see http://oss-institute\&.org/fips-faq\&.html\&. -This mode might require that the involved certificates are generated with a -FIPS enabled version of openssl\&. Setting or clearing this option on one -socat address affects all OpenSSL addresses of this process\&. -.PP -.br -.PP -\fI\fBRETRY option group\fP\fP -.PP -Options that control retry of some system calls, especially connection -attempts\&. -.PP -.IP "\fB\f(CWretry=\fP\fP" -Number of retries before the connection or listen attempt is aborted\&. -Default is 0, which means just one attempt\&. -.IP "\fB\f(CWintervall=\fP\fP" -Time between consecutive attempts (seconds, -[timespec])\&. Default is 1 second\&. -.IP "\fB\f(CWforever\fP\fP" -Performs an unlimited number of retry attempts\&. -.PP -.br -.PP -.SH "DATA VALUES" -.PP -This section explains the different data types that address parameters and -address options can take\&. -.PP -.IP "address-range" -Is currently only implemented for IPv4 and IPv6\&. See address-option -`range\' -.IP "bool" -"0" or "1"; if value is omitted, "1" is taken\&. -.IP "byte" -An unsigned int number, read with \f(CWstrtoul()\fP, lower or equal to -\f(CWUCHAR_MAX\fP\&. -.IP "command-line" -A string specifying a program name and its arguments, separated by single -spaces\&. -.IP "data" -A raw data specification following \fIdalan\fP syntax\&. The only documented -form is a string starting with \'x\' followed by an even number of hex digits\&. -.IP "directory" -A string with usual UN*X directory name semantics\&. -.IP "facility" -The name of a syslog facility in lower case characters\&. -.IP "fdnum" -An unsigned int type, read with \f(CWstrtoul()\fP, specifying a UN*X file -descriptor\&. -.IP "filename" -A string with usual UN*X filename semantics\&. -.IP "group" -If the first character is a decimal digit, the value is read with -\f(CWstrtoul()\fP as unsigned integer specifying a group id\&. Otherwise, it -must be an existing group name\&. -.IP "int" -A number following the rules of the \f(CWstrtol()\fP function with base -"0", i\&.e\&. decimal number, octal number with leading "0", or hexadecimal -number with leading "0x"\&. The value must fit into a C int\&. -.IP "interface" -A string specifying the device name of a network interface, e\&.g\&. "eth0"\&. -.IP "IP address" -An IPv4 address in numbers-and-dots notation, an IPv6 address in hex -notation enclosed in brackets, or a hostname that resolves to an IPv4 or an -IPv6 address\&. -.br -Examples: 127\&.0\&.0\&.1, [::1], www\&.dest-unreach\&.org, dns1 -.IP "IPv4 address" -An IPv4 address in numbers-and-dots notation or a hostname that resolves to -an IPv4 address\&. -.br -Examples: 127\&.0\&.0\&.1, www\&.dest-unreach\&.org, dns2 -.IP "IPv6 address" -An iPv6 address in hexnumbers-and-colons notation enclosed in brackets, or a -hostname that resolves to an IPv6 address\&. -.br -Examples: [::1], [1234:5678:9abc:def0:1234:5678:9abc:def0], -ip6name\&.domain\&.org -.IP "long" -A number read with \f(CWstrtol()\fP\&. The value must fit into a C long\&. -.IP "long long" -A number read with \f(CWstrtoll()\fP\&. The value must fit into a C long long\&. -.IP "off_t" -An implementation dependend signed number, usually 32 bits, read with strtol -or strtoll\&. -.IP "off64_t" -An implementation dependend signed number, usually 64 bits, read with strtol -or strtoll\&. -.IP "mode_t" -An unsigned integer, read with \f(CWstrtoul()\fP, specifying mode (permission) -bits\&. -.IP "pid_t" -A number, read with \f(CWstrtol()\fP, specifying a process id\&. -.IP "port" -A uint16_t (16 bit unsigned number) specifying a TCP or UDP port, read -with \f(CWstrtoul()\fP\&. -.IP "protocol" -An unsigned 8 bit number, read with \f(CWstrtoul()\fP\&. -.IP "size_t" -An unsigned number with size_t limitations, read with \f(CWstrtoul\fP\&. -.IP "sockname" -A socket address\&. See address-option `bind\' -.IP "string" -A sequence of characters, not containing \'\e0\' and, depending on -the position within the command line, \':\', \',\', or "!!"\&. Note -that you might have to escape shell meta characters in the command line\&. -.IP "TCP service" -A service name, not starting with a digit, that is resolved by -\f(CWgetservbyname()\fP, or an unsigned int 16 bit number read with -\f(CWstrtoul()\fP\&. -.IP "timeval" -A double float specifying seconds; the number is mapped into a -struct timeval, consisting of seconds and microseconds\&. -.IP "timespec" -A double float specifying seconds; the number is mapped into a -struct timespec, consisting of seconds and nanoseconds\&. -.IP "UDP service" -A service name, not starting with a digit, that is resolved by -\f(CWgetservbyname()\fP, or an unsigned int 16 bit number read with -\f(CWstrtoul()\fP\&. -.IP "unsigned int" -A number read with \f(CWstrtoul()\fP\&. The value must fit into a C unsigned -int\&. -.IP "user" -If the first character is a decimal digit, the value is read with -\f(CWstrtoul()\fP as unsigned integer specifying a user id\&. Otherwise, it must -be an existing user name\&. -.PP -.SH "EXAMPLES" -.PP -.IP -.IP "\fB\f(CWsocat - TCP4:www\&.domain\&.org:80\fP\fP" -.IP -Transfers data between STDIO (-) and a -TCP4 connection to port 80 of host -www\&.domain\&.org\&. This example results in an interactive connection similar to -telnet or netcat\&. The stdin terminal parameters are not changed, so you may -close the relay with ^D or abort it with ^C\&. -.IP -\.LP -\.nf -\fBsocat -d -d READLINE,history=$HOME/.http_history \\ -TCP4:www.domain.org:www,crnl\fP -\.fi -.IP -.IP -This is similar to the previous example, but you can edit the current line in a -bash like manner (READLINE) and use the -history file \&.http_history; \fBsocat\fP -prints messages about progress (-d -d)\&. The port is specified by service name -(www), and correct network line termination characters (crnl) instead of NL -are used\&. -.IP -.IP "\fB\f(CWsocat TCP4-LISTEN:www TCP4:www\&.domain\&.org:www\fP\fP" -.IP -Installs a simple TCP port forwarder\&. With -TCP4-LISTEN it listens on local port "www" until a -connection comes in, accepts it, then connects to the remote host -(TCP4) and starts data transfer\&. It will not accept a -second connection\&. -.IP -\.LP -\.nf -\fBsocat -d -d -lmlocal2 \\ -TCP4-LISTEN:80,bind=myaddr1,su=nobody,fork,range=10.0.0.0/8,reuseaddr \\ -TCP4:www.domain.org:80,bind=myaddr2\fP -\.fi -.IP -.IP -TCP port forwarder, each side bound to another local IP address -(bind)\&. This example handles an almost -arbitrary number of parallel or consecutive connections by -fork\'ing a new -process after each \f(CWaccept()\fP\&. It provides a little security by -su\'ing to user -nobody after forking; it only permits connections from the private 10 network (range); -due to reuseaddr, it allows immediate restart after master process\'s -termination, even if some child sockets are not completely shut down\&. -With -lmlocal2, socat logs to stderr until successfully -reaching the accept loop\&. Further logging is directed to syslog with facility -local2\&. -.IP -\.LP -\.nf -\fBsocat TCP4-LISTEN:5555,fork,tcpwrap=script \\ -EXEC:/bin/myscript,chroot=/home/sandbox,su-d=sandbox,pty,stderr\fP -\.fi -.IP -.IP -A simple server that accepts connections -(TCP4-LISTEN) and fork\'s a new -child process for each connection; every child acts as single relay\&. -The client must match the rules for daemon process name "script" in -/etc/hosts\&.allow and /etc/hosts\&.deny, otherwise it is refused access (see "man -5 hosts_access")\&. -For EXEC\'uting the program, the child process -chroot\'s -to \fB/home/sandbox\fP, su\'s to user sandbox, and then starts -the program \fB/home/sandbox/bin/myscript\fP\&. \fBSocat\fP and -myscript communicate via a pseudo tty (pty); myscript\'s -stderr is redirected to stdout, -so its error messages are transferred via \fBsocat\fP to the connected client\&. -.IP -\.LP -\.nf -\fBsocat EXEC:"mail.sh target@domain.com",fdin=3,fdout=4 \\ -TCP4:mail.relay.org:25,crnl,bind=alias1.server.org,mss=512\fP -\.fi -.IP -.IP -\fBmail\&.sh\fP is a shell script, distributed with \fBsocat\fP, that implements a -simple -SMTP client\&. It is programmed to "speak" SMTP on its FDs 3 (in) and 4 (out)\&. -The fdin and fdout options tell \fBsocat\fP -to use these FDs for communication with -the program\&. Because mail\&.sh inherits stdin and stdout while \fBsocat\fP does not -use them, the script can read a -mail body from stdin\&. \fBSocat\fP makes alias1 your local source address -(bind), cares for correct network line termination -(crnl) and sends -at most 512 data bytes per packet (mss)\&. -.IP -.IP "\fB\f(CWsocat - /dev/ttyS0,raw,echo=0,crnl\fP\fP" -.IP -Opens an interactive connection via the serial line, e\&.g\&. for talking with a -modem\&. raw and echo set ttyS0\'s terminal -parameters to practicable values, crnl -converts to correct newline characters\&. Consider using -READLINE instead of `-\'\&. -.IP -\.LP -\.nf -\fBsocat UNIX-LISTEN:/tmp/.X11-unix/X1,fork \\ -SOCKS4:host.victim.org:127.0.0.1:6000,socksuser=nobody,sourceport=20\fP -\.fi -.IP -.IP -With UNIX-LISTEN, \fBsocat\fP opens a listening -UNIX domain socket \fB/tmp/\&.X11-unix/X1\fP\&. This path corresponds -to local XWindow display :1 on your machine, so XWindow client connections to -DISPLAY=:1 are accepted\&. \fBSocat\fP then speaks with -the SOCKS4 server host\&.victim\&.org that might permit -sourceport 20 based connections due to an FTP related -weakness in its static IP filters\&. \fBSocat\fP -pretends to be invoked by socksuser nobody, and -requests to be connected to -loopback port 6000 (only weak sockd configurations will allow this)\&. So we get -a connection to the victims XWindow server and, if it does not require MIT -cookies or Kerberos authentication, we can start work\&. Please note that there -can only be one connection at a time, because TCP can establish only one -session with a given set of addresses and ports\&. -.IP -.IP "\fB\f(CWsocat -u /tmp/readdata,seek-end=0,ignoreeof -\fP\fP" -.IP -This is an example for unidirectional data transfer -(-u)\&. \fBSocat\fP transfers data -from file /tmp/readdata (implicit address GOPEN), starting -at its current end (seek-end=0 lets \fBsocat\fP start -reading at current end of file; use seek=0 or no -seek option to first read the existing data) in a "tail -f" like mode -(ignoreeof)\&. The "file" -might also be a listening UNIX domain socket (do not use a seek option then)\&. -.IP -\.LP -\.nf -\fB(sleep 5; echo PASSWORD; sleep 5; echo ls; sleep 1) | -socat - EXEC:'ssh -l user server',pty,setsid,ctty\fP -\.fi -.IP -.IP -EXEC\'utes an ssh session to server\&. Uses a pty for communication between \fBsocat\fP and -ssh, makes it ssh\'s controlling tty (ctty), -and makes this pty the owner of -a new process group (setsid), so ssh accepts the password from \fBsocat\fP\&. -.IP -\.LP -\.nf -\fBsocat -u TCP4-LISTEN:3334,reuseaddr,fork \\ -OPEN:/tmp/in.log,creat,append\fP -\.fi -.IP -.IP -Implements a simple network based message collector\&. -For each client connecting to port 3334, a new child process is generated (option fork)\&. -All data sent by the clients are append\'ed to the file /tmp/in\&.log\&. -If the file does not exist, socat creat\'s it\&. -Option reuseaddr allows immediate restart of the server -process\&. -.IP -.IP -.IP "\fB\f(CWsocat READLINE,noecho=\'[Pp]assword:\' EXEC:\'ftp ftp\&.server\&.com\',pty,setsid,ctty\fP\fP" -.IP -Wraps a command line history (READLINE) around the EXEC\'uted ftp client utility\&. -This allows editing and reuse of FTP commands for relatively comfortable -browsing through the ftp directory hierarchy\&. The password is echoed! -pty is required to have ftp issue a prompt\&. -Nevertheless, there may occur some confusion with the password and FTP -prompts\&. -.IP -.IP "\fB\f(CWsocat PTY,link=$HOME/dev/vmodem0,raw,echo=0,waitslave exec:\'"ssh modemserver\&.us\&.org socat - /dev/ttyS0,nonblock,raw,echo=0"\'\fP\fP" -.IP -Generates a pseudo terminal -device (PTY) on the client that can be reached under the -symbolic link \fB$HOME/dev/vmodem0\fP\&. -An application that expects a serial line or modem -can be configured to use \fB$HOME/dev/vmodem0\fP; its traffic will be directed -to a modemserver via ssh where another socat instance links it with -\fB/dev/ttyS0\fP\&. -.IP -\.LP -\.nf -\fBsocat TCP4-LISTEN:2022,reuseaddr,fork \\ -PROXY:proxy:www.domain.org:22,proxyport=3128,proxyauth=user:pass\fP -\.fi -.IP -.IP -starts a forwarder that accepts connections on port 2022, and directs them -through the proxy daemon listening on port 3128 -(proxyport) on host proxy, using the -CONNECT method, where they are authenticated as "user" with "pass" (proxyauth)\&. The proxy -should establish connections to host www\&.domain\&.org on port 22 then\&. -.IP -.IP "\fB\f(CWecho |socat -u - file:/tmp/bigfile,create,largefile,seek=100000000000\fP\fP" -.IP -creates a 100GB sparse file; this requires a file system type that -supports this (ext2, ext3, reiserfs, jfs; not minix, vfat)\&. The operation of -writing 1 byte might take long (reiserfs: some minutes; ext2: "no" time), and -the resulting file can consume some disk space with just its inodes (reiserfs: -2MB; ext2: 16KB)\&. -.IP -.IP "\fB\f(CWsocat tcp-l:7777,reuseaddr,fork system:\'filan -i 0 -s >&2\',nofork\fP\fP" -.IP -listens for incoming TCP connections on port 7777\&. For each accepted -connection, invokes a shell\&. This shell has its stdin and stdout directly -connected to the TCP socket (nofork)\&. The shell starts filan and lets it print the socket addresses to -stderr (your terminal window)\&. -.IP -.IP "\fB\f(CWecho -e "\e0\e14\e0\e0\ec" |socat -u - file:/usr/bin/squid\&.exe,seek=0x00074420\fP\fP" -.IP -functions as primitive binary editor: it writes the 4 bytes 000 014 000 000 to -the executable /usr/bin/squid at offset 0x00074420 (this is a real world patch -to make the squid executable from Cygwin run under Windows, actual per May 2004)\&. -.IP -.IP "\fB\f(CWsocat - tcp:www\&.blackhat\&.org:31337,readbytes=1000\fP\fP" -.IP -connect to an unknown service and prevent being flooded\&. -.IP -.PP -.SH "DIAGNOSTICS" -.PP -\fBSocat\fP uses a logging mechanism that allows to filter messages by severity\&. The -severities provided are more or less compatible to the appropriate syslog -priority\&. With one or up to four occurrences of the -d command line option, the -lowest priority of messages that are issued can be selected\&. Each message -contains a single uppercase character specifying the messages severity (one of -F, E, W, N, I, or D) -.PP -.IP "FATAL:" -Conditions that require unconditional and immediate program termination\&. -.IP "ERROR:" -Conditions that prevent proper program processing\&. Usually the -program is terminated (see option -s)\&. -.IP "WARNING:" -Something did not function correctly or is in a state where -correct further processing cannot be guaranteed, but might be possible\&. -.IP "NOTICE:" -Interesting actions of the program, e\&.g\&. for supervising \fBsocat\fP in some kind of server mode\&. -.IP "INFO:" -Description of what the program does, and maybe why it -happens\&. Allows to monitor the lifecycles of file descriptors\&. -.IP "DEBUG:" -Description of how the program works, all system or library calls and their results\&. -.PP -Log messages can be written to stderr, to a file, or to syslog\&. -.PP -On exit, \fBsocat\fP gives status 0 if it terminated due to EOF or inactivity -timeout, with a positive value on error, and with a negative value on fatal -error\&. -.PP -.SH "FILES" -.PP -/usr/bin/socat -.br -/usr/bin/filan -.br -/usr/bin/procan -.PP -.SH "ENVIRONMENT VARIABLES" -.PP -.IP "\fBSOCAT_DEFAULT_LISTEN_IP\fP" -(Values 4 or 6) Sets the IP version to be used -for listen, recv, and recvfrom addresses if no pf -(protocol-family) option is given\&. Is overridden by socat options --4 or -6\&. -.IP -.IP "\fBSOCAT_PREFERRED_RESOLVE_IP\fP" -(Values 0, 4, or 6) Sets the IP version to -be used when resolving target host names when version is not specified by -address type, option pf (protocol-family), or -address format\&. If name resolution does not return a matching entry, the first -result (with differing IP version) is taken\&. With value 0, socat always selects -the first record and its IP version\&. -.IP -.IP "\fBSOCAT_FORK_WAIT\fP" -Specifies the time (seconds) to sleep the parent and -child processes after successful fork()\&. Useful for debugging\&. -.IP -.IP "\fBHOSTNAME\fP" -Is used to determine the hostname for logging (see --lh)\&. -.IP -.IP "\fBLOGNAME\fP" -Is used as name for the socks client user name if no -socksuser is given\&. -.br -With options su and -su-d, LOGNAME is set to the given user name\&. -.IP -.IP "\fBUSER\fP" -Is used as name for the socks client user name if no -socksuser is given and LOGNAME is empty\&. -.br -With options su and -su-d, USER is set to the given user name\&. -.IP -.IP "\fBSHELL\fP" -With options su and -su-d, SHELL is set to the login shell of the -given user\&. -.IP -.IP "\fBPATH\fP" -Can be set with option path for exec and -system addresses\&. -.IP -.IP "\fBHOME\fP" -With options su and -su-d, HOME is set to the home directory of the -given user\&. -.IP -.PP -.SH "CREDITS" -.PP -The work of the following groups and organizations was invaluable for this -project: -.PP -The \fIFSF\fP (GNU, http://www\&.fsf\&.org/ project -with their free and portable development software and -lots of other useful tools and libraries\&. -.PP -The \fILinux developers community\fP (http://www\&.linux\&.org/) for providing a free, open source operating -system\&. -.PP -\fISourceforge\fP (http://www\&.sourceforge\&.net/) for providing a compile -farm with Solaris, FreeBSD, and MacOS X machines, making these ports possible\&. -.PP -The \fIOpen Group\fP (http://www\&.unix-systems\&.org/) for making their -standard specifications available on the Internet for free\&. -.PP -.SH "VERSION" -.PP -This man page describes version 1\&.5\&.0 of \fBsocat\fP\&. -.PP -.SH "BUGS" -.PP -Addresses cannot be nested, so a single socat process cannot, e\&.g\&., drive ssl -over socks\&. -.PP -Address option ftruncate without value uses default 1 instead of 0\&. -.PP -Verbose modes (-x and/or -v) display line termination characters inconsistently -when address options cr or crnl are used: They show the data \fIafter\fP -conversion in either direction\&. -.PP -The data transfer blocksize setting (-b) is ignored with address readline\&. -.PP -Send bug reports to -.PP -.SH "SEE ALSO" -.PP -nc(1), netcat6(1), sock(1), rinetd(8), cage(1), socks\&.conf(5), openssl(1), -stunnel(8), pty(1), rlwrap(1), setsid(1) -.PP -\fBSocat\fP home page http://www\&.dest-unreach\&.org/socat/ -.PP -.SH "AUTHOR" -.PP -Gerhard Rieger diff --git a/doc/socat.html b/doc/socat.html deleted file mode 100644 index b18097e..0000000 --- a/doc/socat.html +++ /dev/null @@ -1,2364 +0,0 @@ - - - - - - - - - - - - - - - - -socat - - - - - -
- -

socat

-

socat

-

July 2006

- - - -

- -

CONTENTS

- -NAME
-SYNOPSIS
-DESCRIPTION
-OPTIONS
-ADDRESS SPECIFICATIONS
-ADDRESS TYPES
-ADDRESS OPTIONS
-DATA VALUES
-EXAMPLES
-DIAGNOSTICS
-FILES
-ENVIRONMENT VARIABLES
-CREDITS
-VERSION
-BUGS
-SEE ALSO
-

-

NAME

- socat - Multipurpose relay (SOcket CAT) -

-

SYNOPSIS

- -socat [options] <right-address>
-socat [options] <left-address> <right-address>
-socat [options] <left-address> <right-address> ..
-socat [options] <left-addresses> .. -- <right-address> ..
-socat -V
-socat -h[h[h]] | -?[?[?]]
-filan
-procan -

-

DESCRIPTION

- -

Socat is a command line based utility that establishes two bidirectional byte -streams and transfers data between them. Because the streams can be constructed -from a large set of different types of data sinks and sources -(see address types), and because lots of -address options may be applied to the streams, socat can -be used for many different purposes. -It might be one of the tools that one `has already needed'. -

Filan is a utility that prints information about its active file -descriptors to stdout. It has been written for debugging socat, but might be -useful for other purposes too. Use the -h option to find more infos. -

Procan is a utility that prints information about process parameters to -stdout. It has been written to better understand -some UNIX process properties and for debugging socat, but might be -useful for other purposes too. -

The life cycle of a socat instance typically consists of four phases. -

In the init phase, the command line options are parsed and logging is -initialized. -

During the open phase, socat opens the first address and afterwards the -second address. These steps are usually blocking; thus, especially for complex address types like socks, -connection requests or authentication dialogs must be completed before the next -step is started. -

In the transfer phase, socat watches both streams' read and write file -descriptors via select(), and, when data is available on one side and -can be written to the other side, socat reads it, performs newline -character conversions if required, and writes the data to the write file -descriptor of the other stream, then continues waiting for more data in both -directions. -

When one of the streams effectively reaches EOF, the closing phase -begins. Socat transfers the EOF condition to the other stream, -i.e. tries to shutdown only its write stream, giving it a chance to -terminate gracefully. For a defined time socat continues to transfer data in -the other direction, but then closes all remaining channels and terminates. -

-

OPTIONS

- -

Socat provides some command line options that modify the behaviour of the -program. They have nothing to do with so called -address options that are used as parts of address specifications. -

-

-V
- Print version and available feature information to stdout, and exit. -

-h | -?
- Print a help text to stdout describing command line options and available address - types, and exit. -

-hh | -??
- Like -h, plus a list of the short names of all available address options. Some options are - platform dependend, so this output is helpful for checking the particular - implementation. -

-hhh | -???
- Like -hh, plus a list of all available address option names. -

-d
- Without this option, only fatal and error messages are generated; applying - this option also prints warning messages. See DIAGNOSTICS - for more information. -

-d -d
Prints fatal, error, warning, and notice messages. -

-d -d -d
Prints fatal, error, warning, notice, and info messages. -

-d -d -d -d
Prints fatal, error, warning, notice, info, and debug - messages. -

-D
- Logs information about file descriptors before starting the transfer phase. -

-ly[<facility>]
- Writes messages to syslog instead of stderr; severity as defined with -d - option. With optional <facility>, the syslog type can - be selected, default is "daemon". -

-lf <logfile>
- Writes messages to <logfile> [filename] instead of - stderr. -

-ls
- Writes messages to stderr (this is the default). -

-lp<progname>
- Overrides the program name printed in error messages. -

-lu
- Extends the timestamp of error messages to microsecond resolution. Does not - work when logging to syslog. -

-lm[<facility>]
- Mixed log mode. During startup messages are printed to stderr; when socat - starts the transfer phase loop or daemon mode (i.e. after opening all - streams and before starting data transfer, or, with listening sockets with - fork option, before the first accept call), it switches logging to syslog. - With optional <facility>, the syslog type can be - selected, default is "daemon". -

-lh
- Adds hostname to log messages. Uses the value from environment variable - HOSTNAME or the value retrieved with uname() if HOSTNAME is not set. -

-v
- Writes the transferred data not only to their target streams, but also to - stderr. The output format is text with some conversions for readability, and - prefixed with "> " or "< " indicating flow directions. -

-x
- Writes the transferred data not only to their target streams, but also to - stderr. The output format is hexadecimal, prefixed with "> " or "< " - indicating flow directions. Can be combined with -v. -

-b<size>
- Sets the data transfer block <size> [size_t]. - At most <size> bytes are transferred per step. Default is 8192 bytes. -

-s
- By default, socat terminates when an error occurred to prevent the process - from running when some option could not be applied. With this - option, socat is sloppy with errors and tries to continue. Even with this - option, socat will exit on fatals, and will abort connection attempts when - security checks failed. -

-t<timeout>
- When one channel has reached EOF, the write part of the other channel is shut - down. Then, socat waits <timeout> [timeval] seconds - before terminating. Default is 0.5 seconds. This timeout only applies to - addresses where write and read part can be closed independently. When during - the timeout intervall the read part gives EOF, socat terminates without - awaiting the timeout. -

-T<timeout>
- Total inactivity timeout: when socat is already in the transfer loop and - nothing has happened for <timeout> [timeval] seconds - (no data arrived, no interrupt occurred...) then it terminates. - Useful with protocols like UDP that cannot transfer EOF. -

-u
- Uses unidirectional mode. The first address is only used for reading, and the - second address is only used for writing. -

-U
- Uses unidirectional mode in reverse direction. The first address is only - used for writing, and the second address is only used for reading. -

-g
- During address option parsing, don't check if the option is considered - useful in the given address environment. Use it if you want to force, e.g., - appliance of a socket option to a serial device. -

-L<lockfile>
- If lockfile exists, exits with error. If lockfile does not exist, creates it - and continues, unlinks lockfile on exit. -

-W<lockfile>
- If lockfile exists, waits until it disappears. When lockfile does not exist, - creates it and continues, unlinks lockfile on exit. -

-4
- Use IP version 4 in case that the addresses do not implicitly or explicitly - specify a version; this is the default. -

-6
- Use IP version 6 in case that the addresses do not implicitly or explicitly - specify a version. -
-

-

ADDRESS SPECIFICATIONS

- -

With the address command line arguments, the user gives socat instructions and -the necessary information for establishing the byte streams. -

An address specification usually consists of an address type -keyword, zero or more required address parameters separated by ':' from the keyword and -from each -other, and zero or more address options separated by ','. -

The keyword specifies the address type (e.g., TCP4, OPEN, EXEC). For some -keywords there exist synonyms ('-' for STDIO, TCP for TCP4). Keywords are case -insensitive. -For a few special address types, the keyword may be omitted: -Address specifications starting with a number are assumed to be FD (raw file -descriptor) addresses; -if a '/' is found before the first ':' or ',', GOPEN (generic file open) is -assumed. -

The required number and type of address parameters depend on the address -type. E.g., TCP4 requires a server specification (name or address), and a port -specification (number or service name). -

Zero or more address options may be given with each address. They influence the -address in some ways. -Options consist of an option keyword or an option keyword and a value, -separated by '='. Option keywords are case insensitive. -For filtering the options that are useful with an address -type, each option is member of one option group. For -each address type there is a set of option groups allowed. Only options -belonging to one of these address groups may be used (except with option -g). -

-Address specifications following the above schema are also called single -address specifications. -Two single addresses can be combined with "!!" to form a dual type -address for one channel. Here, the first address is used by socat for reading -data, and the -second address for writing data. There is no way to specify an option only once -for being applied to both single addresses. -

Usually, addresses are opened in read/write -mode. When an address is part of a dual address specification, or when -option -u or -U is used, an address might be -used only for reading or for writing. Considering this is important with some -address types. -

With socat version 1.5.0 and higher, the lexical analysis tries to handle -quotes and parenthesis meaningfully and allows escaping of special characters. -If one of the characters ( { [ ' is found, the corresponding closing -character - ) } ] ' - is looked for; they may also be nested. Within these -constructs, socats special characters and strings : , !! are not handled -specially. All those characters and strings can be escaped with \ or within "" -

-

ADDRESS TYPES

- -

This section describes the available address types with their keywords, -parameters, and semantics. -

-

CREATE:<filename>
- Opens <filename> with creat() and uses the file - descriptor for writing. - This address type requires write-only context, because a file opened with - creat cannot be read from. - <filename> must be a valid existing or not existing path. - If <filename> is a named pipe, creat() might block; - if <filename> refers to a socket, this is an error.
- Option groups: FD,REG,NAMED
- Useful options: - mode, - user, - group, - unlink-early, - unlink-late, - append
- See also: OPEN, GOPEN -

EXEC:<command-line>
- Forks a sub process that establishes communication with its parent process - and invokes the specified program with execvp(). - <command-line> is a simple command - with arguments separated by single spaces. If the program name - contains a '/', the part after the last '/' is taken as ARGV[0]. If the - program name is a relative - path, the execvp() semantics for finding the program via - $PATH - apply. After successful program start, socat writes data to stdin of the - process and reads from its stdout using a UNIX domain socket generated by - socketpair() per default.
- Option groups: FD,SOCKET,EXEC,FORK,TERMIOS
- Useful options: - path, - fdin, - fdout, - chroot, - su, - su-d, - nofork, - pty, - stderr, - ctty, - setsid, - pipes, - login, - sigint, - sigquit
- See also: SYSTEM -

FD:<fdnum>
- Uses the file descriptor <fdnum>. It must already exist as - valid UN*X file descriptor.
- Option groups: FD (TERMIOS,REG,SOCKET)
- See also: - STDIO, - STDIN, - STDOUT, - STDERR -

GOPEN:<filename>
- (Generic open) This address type tries to handle any file system entry - except directories usefully. <filename> may be a - relative or absolute path. If it already exists, its type is checked. - In case of a UNIX domain socket, socat connects; if connecting fails, - socat assumes a datagram socket and uses sendto() calls. - If the entry is not a socket, socat opens it applying the O_APPEND - flag. - If it does not exist, it is opened with flag - O_CREAT as a regular file.
- Option groups: FD,REG,SOCKET,NAMED,OPEN
- See also: - OPEN, - CREATE, - UNIX-CONNECT -

IP-SENDTO:<host>:<protocol>
- Opens a raw IP socket. Depending on host specification or option pf, IP procotol version - 4 or 6 is used. It uses <protocol> to send packets - to <host> [IP address] and receives packets from - host, ignores packets from other hosts. - Protocol 255 uses the raw socket with the IP header being part of the - data.
- Option groups: FD,SOCKET,IP4,IP6
- Useful options: - pf, - ttl, - broadcast
- See also: - IP4-SENDTO, - IP6-SENDTO, - IP-RECVFROM, - IP-RECV, - UDP-SENDTO - UNIX-SENDTO -

IP4-SENDTO:<host>:<protocol>
- Like IP-SENDTO, but always uses IPv4.
- Option groups: FD,SOCKET,IP4
-

IP6-SENDTO:<host>:<protocol>
- Like IP-SENDTO, but always uses IPv6.
- Option groups: FD,SOCKET,IP6
-

IP-RECVFROM:<protocol>
- Opens a raw IP socket of <protocol>. Depending on option pf, IP procotol version - 4 or 6 is used. It receives one packet from an unspecified peer and may send one or more answer packets to that peer. - This mode is particularly useful with fork option where each arriving packet - from arbitrary peers - is handled by its own sub process. - This allows a behaviour similar to typical UDP based servers like ntpd or named. - This address works well with IP-SENDTO address peers (see above). - Protocol 255 uses the raw socket with the IP header being part of the - data.
- Option groups: FD,SOCKET,IP4,IP6,CHILD,RANGE
- Useful options: - pf, - fork, - range, - ttl, - broadcast
- See also: - IP4-RECVFROM, - IP6-RECVFROM, - IP-SENDTO, - IP-RECV, - UDP-RECVFROM, - UNIX-RECVFROM -

IP4-RECVFROM:<protocol>
- Like IP-RECVFROM, but always uses IPv4.
- Option groups: FD,SOCKET,IP4,CHILD,RANGE
-

IP6-RECVFROM:<protocol>
- Like IP-RECVFROM, but always uses IPv6.
- Option groups: FD,SOCKET,IP6,CHILD,RANGE
-

IP-RECV:<protocol>
- Opens a raw IP socket of <protocol>. Depending on option pf, IP procotol version - 4 or 6 is used. It receives packets from multiple unspecified peers and merges the data. - No replies are possible. - It can be, e.g., addressed by socat IP-SENDTO address peers. - Protocol 255 uses the raw socket with the IP header being part of the - data.
- Option groups: FD,SOCKET,IP4,IP6,RANGE
- Useful options: - pf, - range
- See also: - IP4-RECV, - IP6-RECV, - IP-SENDTO, - IP-RECVFROM, - UDP-RECV, - UNIX-RECV -

IP4-RECV:<protocol>
- Like IP-RECV, but always uses IPv4.
- Option groups: FD,SOCKET,IP4,RANGE
-

IP6-RECV:<protocol>
- Like IP-RECV, but always uses IPv6.
- Option groups: FD,SOCKET,IP6,RANGE
-

OPEN:<filename>
- Opens <filename> using the open() system call. - This operation fails on UNIX domain sockets.
- Note: This address type is rarly useful in bidirectional mode.
- Option groups: FD,REG,NAMED,OPEN
- Useful options: - creat, - excl, - noatime, - nofollow, - append, - rdonly, - wronly, - lock, - readbytes, - ignoreeof
- See also: - CREATE, - GOPEN, - UNIX-CONNECT -

OPENSSL:<host>:<port>
- Tries to establish a SSL connection to <port> [TCP - service] on - <host> [IP address] using TCP/IP version 4 or 6 - depending on address specification, name resolution, or option - pf.
- NOTE: The server certificate is only checked for validity against - cafile or capath, - but not for match with the server's name or its IP address!
- Option groups: FD,SOCKET,IP4,IP6,TCP,OPENSSL,RETRY
- Useful options: - cipher, - method, - verify, - cafile, - capath, - certificate, - bind, - pf, - connect-timeout, - sourceport, - retry
- See also: - OPENSSL-LISTEN, - TCP -

OPENSSL-LISTEN:<port>
- Listens on tcp <port> [TCP service]. - The IP version is 4 or the one specified with - pf. When a - connection is accepted, this address behaves as SSL server.
- Note: You probably want to use the certificate option with this address.
- NOTE: Without verify option, the client certificate is - not checked. Even with verify option, the client - certificate is only checked for validity against cafile - or capath, but not for match with the client's name or - its IP address!
- Option groups: FD,SOCKET,IP4,IP6,TCP,LISTEN,OPENSSL,CHILD,RANGE,RETRY
- Useful options: - pf, - cipher, - method, - verify, - cafile, - capath, - certificate, - fork, - bind, - range, - tcpwrap, - su, - reuseaddr, - retry
- See also: - OPENSSL, - TCP -

PIPE:<filename>
- If <filename> already exists, it is opened. - If is does not exist, a named pipe is created and opened. Beginning with - socat version 1.4.3, the named pipe is removed when the address is closed - (but see option unlink-close
- Note: When a pipe is used for both reading and writing, it works - as echo service.
- Note: When a pipe is used for both reading and writing, and socat tries - to write more bytes than the pipe can buffer (Linux 2.4: 2048 bytes), socat - might block. Consider using socat option, e.g., -b 2048
- Option groups: FD,NAMED,OPEN
- Useful options: - rdonly, - nonblock, - group, - user, - mode, - unlink-early
- See also: unnamed pipe -

PIPE
- Creates an unnamed pipe and uses it for reading and writing. It works as an - echo, because everything written - to it appeares immediately as read data.
- Note: When socat tries to write more bytes than the pipe can queue (Linux - 2.4: 2048 bytes), socat might block. Consider, e.g., using - option -b 2048
- Option groups: FD
- See also: named pipe -

PROXY:<proxy>:<hostname>:<port>
- Connects to an HTTP proxy server on port 8080 using TCP/IP version 4 or 6 - depending on address specification, name resolution, or option - pf, and sends a CONNECT - request for hostname:port. If the proxy grants access and succeeds to - connect to the target, data transfer between socat and the target can - start. Note that the traffic need not be HTTP but can be an arbitrary - protocol.
- Option groups: FD,SOCKET,IP4,IP6,TCP,HTTP,RETRY
- Useful options: - proxyport, - ignorecr, - proxyauth, - resolve, - crnl, - bind, - connect-timeout, - mss, - sourceport, - retry
- See also: SOCKS, TCP -

PTY
-

PTY:<symlink>
- Generates a pseudo terminal (pty) and uses its master side. Another process - may open the pty's slave side using it like a serial line or terminal. If - both the ptmx and the openpty mechanisms are available, ptmx is used - (POSIX). In the second form, the link option is - already integrated as a parameter.
- Option groups: FD,NAMED,PTY,TERMIOS
- Useful options: - link, - openpty, - wait-slave, - mode, - user, - group
- See also: - UNIX-LISTEN, - PIPE, - EXEC, SYSTEM -

READLINE
- Uses GNU readline and history on stdio to allow editing and reusing input - lines. This requires the GNU readline and - history libraries. Note that stdio should be a (pseudo) terminal device, - otherwise readline does not seem to work.
- Option groups: FD,READLINE,TERMIOS
- Useful options: - history, - noecho
- See also: - STDIO -

SOCKS4:<socks-server>:<host>:<port>
- Connects via <socks-server> [IP address] - to <host> [IPv4 address] - on <port> [TCP service], - using socks version 4 protocol over IP version 4 or 6 depending on address specification, name resolution, or option - pf.
- Option groups: FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY
- Useful options: - socksuser, - socksport, - sourceport, - pf, - retry
- See also: - SOCKS4A, - PROXY, - TCP -

SOCKS4A:<socks-server>:<host>:<port>
- like SOCKS4, but uses socks protocol version 4a, thus - leaving host name resolution to the socks server.
- Option groups: FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY
-

STDERR
- Uses file descriptor 2.
- Option groups: FD (TERMIOS,REG,SOCKET)
- See also: FD -

STDIN
- Uses file descriptor 0.
- Option groups: FD (TERMIOS,REG,SOCKET)
- Useful options: - readbytes
- See also: FD -

STDIO
- Uses file descriptor 0 for reading, and 1 for writing.
- Option groups: FD (TERMIOS,REG,SOCKET)
- Useful options: - readbytes
- See also: FD -

STDOUT
- Uses file descriptor 1.
- Option groups: FD (TERMIOS,REG,SOCKET)
- See also: FD -

SYSTEM:<shell-command>
- Forks a sub process that establishes communication with its parent process - and invokes the specified program with system(). Please note that - <shell-command> [string] must - not contain ',' or "!!", and that shell meta characters may have to be - protected. - After successful program start, socat writes data to stdin of the - process and reads from its stdout.
- Option groups: FD,SOCKET,EXEC,FORK,TERMIOS
- Useful options: - path, - fdin, - fdout, - chroot, - su, - su-d, - nofork, - pty, - stderr, - ctty, - setsid, - pipes, - sigint, - sigquit
- See also: EXEC -

TCP:<host>:<port>
- Connects to <port> [TCP service] on - <host> [IP address] using TCP/IP version 4 or 6 - depending on address specification, name resolution, or option - pf.
- Option groups: FD,SOCKET,IP4,IP6,TCP,RETRY
- Useful options: - crnl, - bind, - pf, - connect-timeout, - tos, - mtudiscover, - mss, - nodelay, - nonblock, - sourceport, - retry, - readbytes
- See also: - TCP4, - TCP6, - TCP-LISTEN, - UDP, - UNIX-CONNECT -

TCP4:<host>:<port>
- Like TCP, but only supports IPv4 protocol.
- Option groups: FD,SOCKET,IP4,TCP,RETRY
-

TCP6:<host>:<port>
- Like TCP, but only supports IPv6 protocol.
- Option groups: FD,SOCKET,IP6,TCP,RETRY
-

TCP-LISTEN:<port>
- Listens on <port> [TCP service] and accepts a - TCP/IP connection. The IP version is 4 or the one specified with - pf. - Note that opening - this address usually blocks until a client connects.
- Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6,TCP,RETRY
- Useful options: - crnl, - fork, - bind, - range, - tcpwrap, - pf, - backlog, - mss, - su, - reuseaddr, - retry, - retry
- See also: - TCP4-LISTEN, - TCP6-LISTEN, - UDP-LISTEN, - UNIX-LISTEN, - OPENSSL-LISTEN -

TCP4-LISTEN:<port>
- Like TCP-LISTEN, but only supports IPv4 - protocol.
- Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,TCP,RETRY
-

TCP6-LISTEN:<port>
- Like TCP-LISTEN, but only supports IPv6 - protocol.
- Additional useful option: - ipv6only
- Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6,TCP,RETRY
-

UDP:<host>:<port>
- Connects to <port> [UDP service] on - <host> [IP address] using UDP/IP version 4 or 6 - depending on address specification, name resolution, or option - pf.
- Please note that, - due to UDP protocol properties, no real connection is established; data has - to be sent for `connecting' to the server, and no end-of-file condition can - be transported.
- Option groups: FD,SOCKET,IP4,IP6
- Useful options: - ttl, - tos, - bind, - sourceport, - pf
- See also: - UDP4, - UDP6, - UDP-LISTEN, - TCP, - IP -

UDP4:<host>:<port>
- Like UDP, but only supports IPv4 protocol.
- Option groups: FD,SOCKET,IP4
-

UDP6:<host>:<port>
- Like UDP, but only supports IPv6 protocol.
- Option groups: FD,SOCKET,IP6
-

UDP-LISTEN:<port>
- Waits for a UDP/IP packet arriving on <port> - [UDP service] and `connects' back to sender. - The accepted IP version is 4 or the one specified with option - pf. - Please note that, - due to UDP protocol properties, no real connection is established; data has to arrive from the peer first, and no end-of-file condition can be - transported. Note that opening - this address usually blocks until a client connects.
- Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6
- Useful options: - fork, - bind, - range, - pf
- See also: - UDP, - UDP4-LISTEN, - UDP6-LISTEN, - TCP-LISTEN -

UDP4-LISTEN:<port>
- Like UDP-LISTEN, but only support IPv4 - protocol.
- Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4
-

UDP6-LISTEN:<port>
- Like UDP-LISTEN, but only support IPv6 - protocol.
- Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6
-

UDP-SENDTO:<host>:<port>
- Communicates with the specified peer socket, defined by <port> [UDP service] on - <host> [IP address], using UDP/IP version 4 or 6 - depending on address specification, name resolution, or option - pf. It sends packets to and receives packets from that peer socket only. - This is effectively a datagram client. - It works well with socat UDP-RECVFROM and UDP-RECV address peers.
- Option groups: FD,SOCKET,IP4,IP6
- Useful options: - ttl, - tos, - bind, - sourceport, - pf
- See also: - UDP4-SENDTO, - UDP6-SENDTO, - UDP-RECVFROM, - UDP-RECV, - UDP-CONNECT, - UDP-LISTEN, - IP-SENDTO -

UDP4-SENDTO:<host>:<port>
- Like UDP-SENDTO, but only supports IPv4 protocol.
- Option groups: FD,SOCKET,IP4 -

UDP6-SENDTO:<host>:<port>
- Like UDP-SENDTO, but only supports IPv6 protocol.
- Option groups: FD,SOCKET,IP6 -

UDP-RECVFROM:<port>
- Creates a UDP socket on <port> [UDP service] using UDP/IP version 4 or 6 - depending on option pf. - It receives one packet from an unspecified peer and may send one or more - answer packets to that peer. This mode is particularly useful with fork option - where each arriving packet - from arbitrary peers - is handled by its own sub - process. This allows a behaviour similar to typical UDP based servers like ntpd - or named. This address works well with socat SENDTO address peers.
- Option groups: FD,SOCKET,IP4,IP6,CHILD,RANGE
- Useful options: - fork, - ttl, - tos, - bind, - sourceport, - pf
- See also: - UDP4-RECVFROM, - UDP6-RECVFROM, - UDP-SENDTO, - UDP-RECV, - UDP-CONNECT, - UDP-LISTEN, - IP-RECVFROM, - UNIX-RECVFROM -

UDP4-RECVFROM:<port>
- Like UDP-RECVFROM, but only supports IPv4 protocol.
- Option groups: FD,SOCKET,IP4,CHILD,RANGE -

UDP6-RECVFROM:<port>
- Like UDP-RECVFROM, but only supports IPv6 protocol.
- Option groups: FD,SOCKET,IP6,CHILD,RANGE -

UDP-RECV:<port>
- Creates a UDP socket on <port> [UDP service] using UDP/IP version 4 or 6 - depending on option pf. - It receives packets from multiple unspecified peers and merges the data. - No replies are possible. It can be, e.g., addressed by socat UDP-SENDTO address peers. - This address works well with socat SENDTO address peers; it behaves similar to a syslog server.
- Option groups: FD,SOCKET,IP4,IP6,RANGE
- Useful options: - fork, - pf, - bind, - sourceport, - ttl, - tos
- See also: - UDP4-RECV, - UDP6-RECV, - UDP-SENDTO, - UDP-RECVFROM, - UDP-CONNECT, - UDP-LISTEN, - IP-RECV, - UNIX-RECV -

UDP4-RECV:<port>
- Like UDP-RECV, but only supports IPv4 protocol.
- Option groups: FD,SOCKET,IP4,RANGE -

UDP6-RECV:<port>
- Like UDP-RECV, but only supports IPv6 protocol.
- Option groups: FD,SOCKET,IP6,RANGE -

UNIX-CONNECT:<filename>
- Connects to <filename> assuming it is a UNIX domain - socket. - If <filename> does not exist, this is an error; - if <filename> is not a UNIX domain socket, this is an error; - if <filename> is a UNIX domain socket, but no process is listening, this is - an error.
- Option groups: FD,SOCKET,NAMED,RETRY
) - Useful options: - bind
- See also: - UNIX-LISTEN, - UNIX-SENDTO, - TCP -

UNIX-LISTEN:<filename>
- Listens on <filename> using a UNIX domain stream - socket and accepts a connection. - If <filename> exists and is not a socket, this is an error. - If <filename> exists and is a UNIX domain socket, binding to the address - fails (use option unlink-early!). - Note that opening this address usually blocks until a client connects. - Beginning with socat version 1.4.3, the file system entry is removed when - this address is closed (but see option unlink-close).
- Option groups: FD,SOCKET,NAMED,LISTEN,CHILD,RETRY
- Useful options: - fork, - umask, - mode, - user, - group, - unlink-early
- See also: - UNIX-CONNECT, - UNIX-RECVFROM, - UNIX-RECV, - TCP-LISTEN -

UNIX-SENDTO:<filename>
- Communicates with the specified peer socket, defined by [<filename>] assuming it is a UNIX domain datagram socket. - It sends packets to and receives packets from that peer socket only. - It works well with socat UNIX-RECVFROM and UNIX-RECV address peers.
- Option groups: FD,SOCKET,NAMED
- Useful options: - bind
- See also: - UNIX-RECVFROM, - UNIX-RECV, - UNIX-CONNECT, - UDP-SENDTO, - IP-SENDTO -

UNIX-RECVFROM:<filename>
- Creates a UNIX domain datagram socket [<filename>]. - Receives one packet and may send one or more answer packets to that peer. - This mode is particularly useful with fork option where each arriving packet - from arbitrary peers - is handled by its own sub process. - This address works well with socat UNIX-SENDTO address peers.
- Option groups: FD,SOCKET,NAMED,CHILD
- Useful options: - fork
- See also: - UNIX-SENDTO, - UNIX-RECV, - UNIX-LISTEN, - UDP-RECVFROM, - IP-RECVFROM -

UNIX-RECV:<filename>
- Creates a UNIX domain datagram socket [<filename>]. - Receives packets from multiple unspecified peers and merges the data. - No replies are possible. It can be, e.g., addressed by socat UNIX-SENDTO address peers. - It behaves similar to a syslog server. - Option groups: FD,SOCKET,NAMED
- See also: - UNIX-SENDTO, - UNIX-RECVFROM, - UNIX-LISTEN, - UDP-RECV, - IP-RECV -

UNIX:<filename>
- Communicates with the specified peer socket, defined by - [<filename>] assuming it is a UNIX domain socket. - It first tries to connect and, if that fails, assumes it is a datagram - socket, thus supporting both types.
- Option groups: FD,SOCKET,NAMED
- Useful options: - bind
- See also: - UNIX-CONNECT, - UNIX-SENDTO, - GOPEN -
-

-

ADDRESS OPTIONS

- -

Address options can be applied to address specifications to influence the -process of opening the addresses and the -properties of the resulting data channels. -

For technical reasons not every option can be -applied to every address type; e.g., applying a socket option to a regular file -will fail. To catch most useless combinations as early as in the open phase, -the concept of option groups was introduced. Each option belongs to one -or more option groups. Options can be used only with address types that support -at least one of their option groups (but see option -g). -

Address options have data types that their values must conform to. -Every address option consists of just a keyword or a keyword followed by -"=value", where value must conform to the options type. - -Some address options manipulate parameters of system calls; -e.g., option sync sets the O_SYNC flag with the open() call. -Other options cause a system or library call; e.g., with option `ttl=value' -the setsockopt(fd, SOL_IP, IP_TTL, value, sizeof(int)) call is applied. -Other -options set internal socat variables that are used during data transfer; -e.g., `crnl' causes explicit character conversions. -A few options have more complex implementations; e.g., su-d -(substuser-delayed) inquires some user and group infos, stores them, and -applies them later after a possible chroot() call. -

If multiple options are given to an address, their sequence in the address specification has (almost) no -effect on the sequence of their execution/application. Instead, socat has -built in an option phase model that tries to bring the options in a useful -order. Some options exist in different forms (e.g., -unlink, unlink-early, unlink-late) to control the time of their execution. -

If the same option is specified more than once within one address -specification, with equal or different values, the effect depends on the kind of option. Options -resulting in function calls like setsockopt() cause multiple -invocations. With options that set parameters for a required call like -open() -or set internal flags, the value of the last option occurrence is effective. -

The existence or semantics of many options are system dependent. Socat -usually does NOT try to emulate missing libc or kernel features, it just -provides an -interface to the underlying system. So, if an operating system lacks a feature, -the related option is simply not available on this platform. -

The following paragraphs introduce just the more common address options. For -a more comprehensive reference and to find information about canonical option -names, alias names, option phases, and platforms see file xio.help. -

-


-

FD option group -

This option group contains options that are applied to a UN*X -style file descriptor, no matter how it was generated. -Because all current socat address types are file descriptor based, these -options may be applied to any address.
-Note: Some of these options are also member of another option group, that -provides an other, non-fd based mechanism. -For these options, it depends on the actual address type and its option groups -which mechanism is used. The second, non-fd based mechanism is prioritized. -

-

cloexec=<bool>
- Sets the FD_CLOEXEC flag with the fcntl() system call to value - <bool>. If set, - the file descriptor is closed on exec() family function calls. Socat - internally handles - this flag for the fds it controls, so in most cases there will be no need to - apply this option. -

setlk
- Tries to set a discretionary lock to the whole file using the fcntl(fd, - F_SETLK, ...) system call. If the file is already locked, this call results - in an error. -

setlkw
- Tries to set a discretionary waiting lock to the whole file using the - fcntl(fd, F_SETLKW, ...) system call. If the file is already locked, - this call blocks. -

flock-ex
- Tries to set a blocking exclusive advisory lock to the file using the - flock(fd, LOCK_EX) system call. Socat hangs in this call if the file - is locked by another process. -

flock-ex-nb
- Tries to set a nonblocking exclusive advisory lock to the file using the - flock(fd, LOCK_EX) system call. If the file is already locked, - this option results in an error. -

flock-sh
- Tries to set a blocking shared advisory lock to the file using the - flock(fd, LOCK_SH) system call. Socat hangs in this call if the file - is locked by another process. -

flock-sh-nb
- Tries to set a nonblocking shared advisory lock to the file using the - flock(fd, LOCK_SH|LOCK_NB) system call. If the file is already locked, - this option results in an error. -

lock
- Sets a blocking lock on the file. Uses the setlk or flock mechanism - depending on availability on the particular platform. If both are available, - the POSIX variant (setlkw) is selected. -

user=<user>
- Sets the <user> (owner) of the stream. - If the address is member of the NAMED option group, - socat uses the chown() system call after opening the - file or binding to the UNIX domain socket (race condition!). - Without filesystem entry, socat sets the user of the stream - using the fchown() system call. - These calls might require root privilege. -

user-late=<user>
- Sets the owner of the fd to <user> with the fchown() - system call after opening - or connecting the channel. - This is useful only on file system entries. -

group=<group>
- Sets the <group> of the stream. - If the address is member of the NAMED option group, - socat uses the chown() system call after opening the - file or binding to the UNIX domain socket (race condition!). - Without filesystem entry, socat sets the group of the stream - with the fchown() system call. - These calls might require group membership or root privilege. -

group-late=<group>
- Sets the group of the fd to <group> with the - fchown() system call after opening - or connecting the channel. - This is useful only on file system entries. -

mode=<mode>
- Sets the <mode> [mode_t] (permissions) of the stream. - If the address is member of the NAMED option group and - uses the open() or creat() call, the mode is applied with these. - If the address is member of the NAMED option group without using these - system calls, socat uses the chmod() system call after opening the - filesystem entry or binding to the UNIX domain socket (race condition!). - Otherwise, socat sets the mode of the stream - using fchmod(). - These calls might require ownership or root privilege. -

perm-late=<mode>
- Sets the permissions of the fd to value <mode> - [mode_t] using the fchmod() system call after - opening or connecting the channel. - This is useful only on file system entries. -

append=<bool>
- Always writes data to the actual end of file. - If the address is member of the OPEN option group, - socat uses the O_APPEND flag with the open() system call. - Otherwise, socat applies the fcntl(fd, F_SETFL, O_APPEND) call. -

nonblock=<bool>
- Tries to open or use file in nonblocking mode. Its only effects are that the - connect() call of TCP addresses does not block, and that opening a - named pipe for reading does not block. - If the address is member of the OPEN option group, - socat uses the O_NONBLOCK flag with the open() system call. - Otherwise, socat applies the fcntl(fd, F_SETFL, O_NONBLOCK) call. - - -

binary
- Opens the file in binary mode to avoid implicit line terminator - conversions (Cygwin). -

text
- Opens the file in text mode to force implicit line terminator conversions - (Cygwin). -

noinherit
- Does not keep this file open in a spawned process (Cygwin). -

cool-write
- Takes it easy when write fails with EPIPE or ECONNRESET and logs the message - with notice level instead of error. - This prevents the log file from being filled with useless error messages - when socat is used as a high volume server or proxy where clients often - abort the connection.
- This option is experimental. -
-


-

NAMED option group -

These options work on file system entries.
-See also options user, group, and -mode. -

-

user-early=<user>
- Changes the <user> (owner) of the file system entry before - accessing it, using the - chown() system call. This call might require root privilege. -

group-early=<group>
- Changes the <group> of the file system entry before - accessing it, using the - chown() system call. This call might require group membership or root - privilege. -

perm-early=<mode>
- Changes the <mode> [mode_t] of the file system entry - before accessing it, using the - chmod() system call. This call might require ownership or root - privilege. -

umask=<mode>
- Sets the umask of the process to <mode> [mode_t] before - accessing the file system entry (useful - with UNIX domain sockets!). This call might affect all further operations - of the socat process! -

unlink-early
- Unlinks (removes) the file before opening it and even before applying - user-early etc. -

unlink
- Unlinks (removes) the file before accessing it, but after user-early etc. -

unlink-late
- Unlinks (removes) the file after opening it to make it inaccessible for - other processes after a short race condition. -

unlink-close
- Removes the addresses file system entry when closing the address. - For named pipes, - listening unix domain sockets, - and the symbolic links of pty addresses, - the default is 1; for created files, - opened files, - generic opened files, and - client unix domain sockets the default is 0. -
-


-

OPEN option group -

The OPEN group options allow to set flags with the open() system call. -E.g., option `creat' sets the O_CREAT flag.
-See also options append and -nonblock. -

-

creat=<bool>
- Creates the file if it does not exist. -

dsync=<bool>
- Blocks write() calls until metainfo is physically written to media. -

excl=<bool>
- With option creat, if file exists this is an error. -

largefile=<bool>
- On 32 bit systems, allows a file larger than 2^31 bytes. -

noatime
- Sets the O_NOATIME options, so reads do not change the access timestamp. -

noctty=<bool>
- Does not make this file the controlling terminal. -

nofollow=<bool>
- Does not follow symbolic links. -

nshare=<bool>
- Does not allow to share this file with other processes. -

rshare=<bool>
- Does not allow other processes to open this file for writing. -

rsync=<bool>
- Blocks write() until metainfo is physically written to media. -

sync=<bool>
- Blocks write() until data is physically written to media. - - - - -

rdonly=<bool>
- Opens the file for reading only. - -

wronly=<bool>
- Opens the file for writing only. -

trunc
- Truncates the file to size 0 during opening it. -
-


-

REG and BLK option group -

These options are usually applied to a UN*X file descriptor, but their -semantics make sense only on a file supporting random access. -

-

seek=<offset>
- Applies the lseek(fd, <offset>, SEEK_SET) (or lseek64) system - call, thus positioning the file pointer absolutely to <offset> - [off_t or off64_t]. -

seek-cur=<offset>
- Applies the lseek(fd, <offset>, SEEK_CUR) (or lseek64) system - call, thus positioning the file pointer <offset> [off_t or - off64_t] bytes relatively to its current position (which - is usually 0). -

seek-end=<offset>
- Applies the lseek(fd, <offset>, SEEK_END) (or lseek64) system - call, thus positioning the file pointer <offset> [off_t or - off64_t] bytes relatively to the files current end. -

ftruncate=<offset>
- Applies the ftruncate(fd, <offset>) - (or ftruncate64 if available) system call, thus - truncating the file at the position <offset> [off_t or - off64_t]. -

secrm=<bool>
-

unrm=<bool>
-

compr=<bool>
-

ext2-sync=<bool>
-

immutable=<bool>
-

ext2-append=<bool>
-

nodump=<bool>
-

ext2-noatime=<bool>
-

journal-data=<bool>
-

notail=<bool>
-

dirsync=<bool>
- These options change non standard file attributes on operating systems and - file systems that support these features, like Linux with ext2fs, - ext3fs, or reiserfs. See man 1 chattr for information on these options. - Please note that there might be a race condition between creating the file - and applying these options. -
-


-

PROCESS option group -

Options of this group change the process properties instead of just affecting -one data channel. -For EXEC and SYSTEM addresses and for LISTEN and CONNECT type addresses with -option FORK, -these options apply to the child processes instead of the main socat process. -

-

chroot=<directory>
- Performs a chroot() operation to <directory> - after processing the address. This call might require root privilege. -

chroot-early=<directory>
- Performs a chroot() operation to <directory> - before opening the address. This call might require root privilege. -

setgid=<group>
- Changes the primary <group> of the process after - processing the address. This call might require root privilege. -

setgid-early=<group>
- Changes the primary <group> of the process before opening - the address. This call might require root privilege. -

setuid=<user>
- Changes the <user> (owner) of the process after processing - the address. This call might require root privilege. -

setuid-early=<user>
- Changes the <user> (owner) of the process before opening - the address. This call might require root privilege. -

su=<user>
- Changes the <user> (owner) and groups of the process after - processing the address. This call might require root privilege. -

su-d=<user>
- Short name for substuser-delayed. - Changes the <user> - (owner) and groups of the process after processing the address. - The user and his groups are retrieved before a possible - chroot(). This call might require root privilege. -

setpgid=<pid_t>
- Makes the process a member of the specified process group - <pid_t>. If no value - is given, or if the value is 0 or 1, the process becomes leader of a new - process group. -

setsid
- Makes the process the leader of a new session. -
-


-

READLINE option group -

These options apply to the readline address type. -

-

history=<filename>
- Reads and writes history from/to <filename>. -

noprompt
- Since version 1.4.0, socat per default tries to determine a prompt - - that is then passed to the readline call - by remembering the last - incomplete line of the output. With this option, socat does not pass a - prompt to readline, so it begins line editing in the first column - of the terminal. -

noecho=<pattern>
- Specifies a regular pattern for a prompt that prevents the following input - line from being displayed on the screen and from being added to the history. - The prompt is defined as the text that was output to the readline address - after the lastest newline character and before an input character was - typed. The pattern is a regular expression, e.g. - "^[Pp]assword:.*$" or "([Uu]ser:|[Pp]assword:)". See regex(7) for details. -

prompt=<string>
- Passes the string as prompt to the readline function. readline prints this - prompt when stepping through the history. If this string matches a constant - prompt issued by an interactive program on the other socat address, - consistent look and feel can be archieved. -
-


-

APPLICATION option group -

This group contains options that work at data level. -Note that these options only apply to the "raw" data transferred by socat, -but not to protocol data used by addresses like -PROXY. -

-

cr
- Converts the default line termination character NL ('\n', 0x0a) to/from CR - ('\r', 0x0d) when writing/reading on this channel. -

crnl
- Converts the default line termination character NL ('\n', 0x0a) to/from CRNL - ("\r\n", 0x0d0a) when writing/reading on this channel. - Note: socat simply strips all CR characters. -

ignoreeof
- When EOF occurs on this channel, socat ignores it and tries to read more - data (like "tail -f"). -

readbytes=<bytes>
- socat reads only so many bytes from this address (the address provides - only so many bytes for transfer and pretends to be at EOF afterwards). - Must be greater than 0. -

lockfile=<filename>
- If lockfile exists, exits with error. If lockfile does not exist, creates it - and continues, unlinks lockfile on exit. -

waitlock=<filename>
- If lockfile exists, waits until it disappears. When lockfile does not exist, - creates it and continues, unlinks lockfile on exit. -
-


-

SOCKET option group -

These options are intended for all kinds of sockets, e.g. IP or UNIX domain. Most are applied with a setsockopt() call. -

-

bind=<sockname>
- Binds the socket to the given socket address using the bind() system - call. The form of <sockname> is socket domain dependent: - IP4 and IP6 allow the form [hostname|hostaddress][:(service|port)], - UNIX domain sockets require <filename>. -

connect-timeout=<seconds>
- Abort the connection attempt after <seconds> [timeval] - with error status. -

interface=<interface>
- Binds the socket to the given <interface>. - This option might require root privilege. -

broadcast
- For datagram sockets, allows sending to broadcast addresses and receiving - packets addressed to broadcast addresses. -

bsdcompat
- Emulates some (old?) bugs of the BSD socket implementation. -

debug
- Enables socket debugging. -

dontroute
- Only communicates with directly connected peers, does not use routers. -

keepalive
- Enables sending keepalives on the socket. -

linger=<seconds>
- Blocks shutdown() or close() until data transfers have finished - or the given timeout [int] expired. - -

oobinline
- Places out-of-band data in the input data stream. -

priority=<priority>
- Sets the protocol defined <priority> [<int>] for outgoing - packets. -

rcvbuf=<bytes>
- Sets the size of the receive buffer after the socket() call to - <bytes> [int]. With TCP - sockets, this value corresponds to the socket's maximal window size. -

rcvbuf-late=<bytes>
- Sets the size of the receive buffer when the socket is already - connected to <bytes> [int]. - With TCP sockets, this value corresponds to the socket's - maximal window size. -

rcvlowat=<bytes>
- Specifies the minimum number of received bytes [int] until - the socket layer will pass the buffered data to socat. -

rcvtimeo=<seconds>
- Sets the receive timeout [timeval]. -

reuseaddr
- Allows other sockets to bind to an address even if parts of it (e.g. the - local port) are already in use by socat. -

sndbuf=<bytes>
- Sets the size of the send buffer after the socket() call to - <bytes> [int]. -

sndbuf-late=<bytes>
- Sets the size of the send buffer when the socket is connected to - <bytes> [int]. -

sndlowat=<bytes>
- Specifies the minimum number of bytes in the send buffer until the socket - layer will send the data to <bytes> [int]. -

sndtimeo=<seconds>
- Sets the send timeout to seconds [timeval]. -

type=<type>
- Sets the type of the socket, usually as argument to the socket() or - socketpair() call, to <type> [int]. - Under Linux, 1 means stream oriented socket, 2 means datagram socket, and 3 - means raw socket. - - - - - - - - - - - - - - - - - - - - - -

pf=<string>
- Forces the use of the specified IP version. <string> can be - something like "ip4" or "ip6". -
-


-

-IP4 and IP6 option groups -

These options can be used with IPv4 and IPv6 based sockets. -

-

tos=<tos>
- Sets the TOS (type of service) field of outgoing packets to <tos> - [byte] (see RFC 791). -

ttl=<ttl>
- Sets the TTL (time to live) field of outgoing packets to <ttl> - [byte]. -

ipoptions=<data>
- Sets IP options like source routing. Must be given in binary form, - recommended format is a leading "x" followed by an even number of hex - digits. This option may be used multiple times, data are appended. - E.g., to connect to host 10.0.0.1 via some gateway using a loose source - route, use the gateway as address parameter and set a loose source route - using the option ipoptions=x8307040a000001.
- IP options are defined in RFC 791.
- -

mtudiscover=<0|1|2>
- Takes 0, 1, 2 to never, want, or always use path MTU discover on this - socket. - - - - - - - - - - - -

res-debug
-

res-aaonly
-

res-usevc
-

res-primary
-

res-igntc
-

res-recurse
-

res-defnames
-

res-stayopen
-

res-dnsrch
- These options set the corresponding resolver (name resolution) option flags. - Append "=0" to clear a default option. See man resolver(5) for more - information on these options. Note: these options are valid only for the - address they are applied to. -

-


-

IP6 option group -

These options can only be used on IPv6 based sockets. See IP -options for options that can be applied to both IPv4 and IPv6 -sockets. -

-

ipv6only=<bool>
- Sets the IPV6_V6ONLY socket option. If 0, the TCP stack will also accept - connections using IPv4 protocol on the same port. The default is system - dependent. -
-


-

TCP option group -

These options may be applied to TCP sockets. They work by invoking setsockopt() with the appropriate parameters. -

-

cork
- Doesn't send packets smaller than MSS (maximal segment size). -

defer-accept
- While listening, accepts connections only when data from the peer arrived. -

keepcnt=<count>
- Sets the number of keepalives before shutting down the socket to - <count> [int]. -

keepidle=<seconds>
- Sets the idle time before sending the first keepalive to <seconds> - [int]. -

keepintvl=<seconds>
- Sets the intervall between two keepalives to <seconds> - [int]. -

linger2=<seconds>
- Sets the time to keep the socket in FIN-WAIT-2 state to <seconds> - [int]. -

mss=<bytes>
- Sets the MSS (maximum segment size) after the socket() call to <bytes> - [int]. This - value is then proposed to the peer with the SYN or SYN/ACK packet. -

mss-late=<bytes>
- Sets the MSS of the socket after connection has been established to <bytes> - [int]. -

nodelay
- Turns off the Nagle algorithm for measuring the RTT (round trip time). -

rfc1323
- Enables RFC1323 TCP options: TCP window scale, round-trip time measurement - (RTTM), and protect against wrapped sequence numbers (PAWS) (AIX). -

stdurg
- Enables RFC1122 compliant urgent pointer handling (AIX). -

syncnt=<count>
- Sets the maximal number of SYN retransmits during connect to <count> - [int]. - - -

md5sig
- Enables generation of MD5 digests on the packets (FreeBSD). -

noopt
- Disables use of TCP options (FreeBSD, MacOSX). -

nopush
- sets the TCP_NOPUSH socket option (FreeBSD, MacOSX). -

sack-disable
- Disables use the selective acknowledge feature (OpenBSD). -

signature-enable
- Enables generation of MD5 digests on the packets (OpenBSD). -

abort-threshold=<milliseconds>
- Sets the time to wait for an answer of the peer on an established connection - (HP-UX). -

conn-abort-threshold=<milliseconds>
- Sets the time to wait for an answer of the server during the initial connect - (HP-UX). -

keepinit
- Sets the time to wait for an answer of the server during connect() before - giving up. Value in half seconds, default is 150 (75s) (Tru64). -

paws
- Enables the "protect against wrapped sequence numbers" feature (Tru64). -

sackena
- Enables selective acknowledge (Tru64). -

tsoptena
- Enables the time stamp option that allows RTT recalculation on existing - connections (Tru64). -
-


-

UDP and TCP option groups -

Here we find options that are related to the network port mechanism and that -thus can be used with UDP and TCP, client and server addresses. -

-

sourceport=<port>
- For outgoing (client) TCP and UDP connections, it sets the source - <port> using an extra bind() call. - With TCP or UDP listen addresses, socat immediately shuts down the - connection if the client does not use this sourceport. -

lowport
- Outgoing (client) TCP and UDP connections with this option use - an unused random source port between 640 and 1023 incl. On UNIX class operating - systems, this requires root privilege, and thus indicates that the - client process is authorized by local root. - TCP and UDP listen addresses with this option immediately shut down the - connection if the client does not use a sourceport <= 1023. - This mechanism can provide limited authorization under some circumstances. -
-


-

SOCKS option group -

When using SOCKS type addresses, some socks specific options can be set. -

-

socksport=<tcp service>
- Overrides the default "socks" service or port 1080 for the socks server - port with <TCP service>. -

socksuser=<user>
- Sends the <user> [string] in the username field to the - socks server. Default is the actual user name ($LOGNAME or $USER). -
-


-

HTTP option group -

Options that can be provided with HTTP type addresses. The only HTTP address -currently implemented is proxy-connect. -

-

proxyport=<TCP service>
- Overrides the default HTTP proxy port 8080 with - <TCP service>. -

ignorecr
- The HTTP protocol requires the use of CR+NL as line terminator. When a proxy - server violates this standard, socat might not understand its answer. - This option directs socat to interprete NL as line terminator and - to ignore CR in the answer. Nevertheless, socat sends CR+NL to the proxy. -

proxyauth=<username>:<password>
- Provide "basic" authentication to the proxy server. The argument to the - option is used with a "Proxy-Authorization: Base" header in base64 encoded - form.
- Note: username and password are visible for every user on the local machine - in the process list; username and password are transferred to the proxy - server unencrypted (base64 encoded) and might be sniffed. -

resolve
- Per default, socat sends to the proxy a CONNECT request containing the - target hostname. With this option, socat resolves the hostname locally and - sends the IP address. -
-


-

RANGE option group -

These options check if a connecting client is granted access. They can be -applied to listening and receiving network sockets. tcp-wrappers options fall -into this group. -

-

range=<address-range>
- After accepting a connection, tests if the peer is within range. For - IPv4 addresses, address-range takes the form ww.xx.yy.zz/bits, e.g. - 10.0.0.0/8; for IPv6, it is [ip6-address/bits], e.g. [::1/128]. - If the client address does not match, socat issues a warning and keeps - listening/receiving. -

tcpwrap[=<name>]
- Uses Wietse Venema's libwrap (tcpd) library to determine - if the client is allowed to connect. The configuration files are - /etc/hosts.allow and /etc/hosts.deny per default, see "man 5 hosts_access" - for more information. The optional <name> (type string) - is passed to the wrapper functions as daemon process name. - If omitted, the basename of socats invocation (argv[0]) is passed. - If both tcpwrap and range options are applied to an address, both - conditions must be fulfilled to allow the connection. -

allow-table=<filename>
- Takes the specified file instead of /etc/hosts.allow. -

deny-table=<filename>
- Takes the specified file instead of /etc/hosts.deny. -

tcpwrap-etc=<directoryname>
- Looks for hosts.allow and hosts.deny in the specified directory. Is - overridden by options hosts-allow - and hosts-deny. -
-


-

LISTEN option group -

Options specific to listening sockets. -

-

backlog=<count>
- Sets the backlog value passed with the listen() system call to <count> - [int]. Default is 5. -
-

-

CHILD option group -

Options for addresses with multiple connections via child processes. -

-

fork
- After establishing a connection, handles its channel in a child process and - keeps the parent process attempting to produce more connections, either by - listening or by connecting in a loop.
- SSL-CONNECT and SSL-LISTEN differ in when they actually fork off the child: -SSL-LISTEN forks before the SSL handshake, while SSL-CONNECT forks -afterwards. - RETRY and FOREVER options are not inherited by the child process.
-
-


-

EXEC option group -

Options for addresses that invoke a program. -

-

path=<string>
- Overrides the PATH environment variable for searching the program with - <string>. This - $PATH value is effective in the child process too. -

login
- Prefixes argv[0] for the execvp() call with '-', thus making a - shell behave as login shell. -
-


-

FORK option group -

EXEC or SYSTEM addresses invoke a program using a child process and transfer data between socat and the program. The interprocess communication mechanism can be influenced with the following options. Per -default, a socketpair() is created and assigned to stdin and stdout of -the child process, while stderr is inherited from the socat process, and the -child process uses file descriptors 0 and 1 for communicating with the main -socat process. -

-

nofork
- Does not fork a subprocess for executing the program, instead calls execvp() - or system() directly from the actual socat instance. This avoids the - overhead of another process between the program and its peer, - but introduces a lot of restrictions: -
-
  • this option can only be applied to the second socat address. -
  • it cannot be applied to a part of a dual address. -
  • the first socat address cannot be OPENSSL or READLINE -
  • socat options -b, -t, -D, -l, -v, -x become useless -
  • for both addresses, options ignoreeof, cr, and crnl become useless -
  • for the second address (the one with option nofork), options - append, cloexec, flock, user, group, mode, nonblock, - perm-late, setlk, and setpgid cannot be applied. Some of these could be - used on the first address though. -
  • -

    pipes
    - Creates a pair of unnamed pipes for interprocess communication instead of a - socket pair. -

    openpty
    - Establishes communication with the sub process using a pseudo terminal - created with openpty() instead of the default (socketpair or ptmx). -

    ptmx
    - Establishes communication with the sub process using a pseudo terminal - created by opening /dev/ptmx or /dev/ptc instead of the default - (socketpair). -

    pty
    - Establishes communication with the sub process using a pseudo terminal - instead of a socket pair. Creates the pty with an available mechanism. If - openpty and ptmx are both available, it uses ptmx because this is POSIX - compliant. -

    ctty
    - Makes the pty the controlling tty of the sub process. -

    stderr
    - Directs stderr of the sub process to its output channel by making stderr a - dup() of stdout. -

    fdin=<fdnum>
    - Assigns the sub processes input channel to its file descriptor - <fdnum> - instead of stdin (0). The program started from the subprocess has to use - this fd for reading data from socat. -

    fdout=<fdnum>
    - Assigns the sub processes output channel to its file descriptor - <fdnum> - instead of stdout (1). The program started from the subprocess has to use - this fd for writing data to socat. -

    sighup, sigint, sigquit
    - Has socat pass an eventual signal of this type to the sub process. - If no address has this option, socat terminates on these signals. -
    -


    -

    TERMIOS option group -

    For addresses that work on a tty (e.g., stdio, file:/dev/tty, exec:...,pty), the terminal parameters defined in the UN*X termios mechanism are made available as address option parameters. -Please note that changes of the parameters of your interactive terminal -remain effective after socat's termination, so you might have to enter "reset" -or "stty sane" in your shell afterwards. -For EXEC and SYSTEM addresses with option PTY, -these options apply to the pty by the child processes. -

    -

    b0
    - Disconnects the terminal. -

    b19200
    - Sets the serial line speed to 19200 baud. Some other rates are possible; use -something like socat -hh |grep ' b[1-9]' to find all speeds supported by -your implementation.
    -Note: On some operating systems, these options may not be -available. Use ispeed or ospeed -instead. -

    echo=<bool>
    - Enables or disables local echo. -

    icanon=<bool>
    - Sets or clears canonical mode, enabling line buffering and some special - characters. -

    raw
    - Sets raw mode, thus passing input and output almost unprocessed. -

    ignbrk=<bool>
    - Ignores or interpretes the BREAK character (e.g., ^C) -

    brkint=<bool>
    -

    bs0
    -

    bs1
    -

    bsdly=<0|1>
    -

    clocal=<bool>
    -

    - - - - - -

    cr0
    -cr1
    -cr2
    -cr3
    - Sets the carriage return delay to 0, 1, 2, or 3, respectively. - 0 means no delay, the other values are terminal dependent. -

    crdly=<0|1|2|3>
    -

    cread=<bool>
    -

    crtscts=<bool>
    -

    - - - - - -

    cs5
    -cs6
    -cs7
    -cs8
    - Sets the character size to 5, 6, 7, or 8 bits, respectively. -

    csize=<0|1|2|3>
    -

    cstopb=<bool>
    - Sets two stop bits, rather than one. -

    dsusp=<byte>
    - Sets the value for the VDSUSP character that suspends the current foreground - process and reactivates the shell (all except Linux). -

    echoctl=<bool>
    - Echos control characters in hat notation (e.g. ^A) -

    echoe=<bool>
    -

    echok=<bool>
    -

    echoke=<bool>
    -

    echonl=<bool>
    -

    echoprt=<bool>
    -

    eof=<byte>
    -

    eol=<byte>
    -

    eol2=<byte>
    -

    erase=<byte>
    -

    discard=<byte>
    -

    ff0
    -

    ff1
    -

    ffdly=<bool>
    -

    flusho=<bool>
    -

    hupcl=<bool>
    -

    icrnl=<bool>
    -

    iexten=<bool>
    -

    igncr=<bool>
    -

    ignpar=<bool>
    -

    imaxbel=<bool>
    -

    inlcr=<bool>
    -

    inpck=<bool>
    -

    intr=<byte>
    -

    isig=<bool>
    -

    ispeed=<unsigned-int>
    - Set the baud rate for incoming data on this line.
    - See also: ospeed, b19200 -dif(istrip=<bool>) -

    iuclc=<bool>
    -

    ixany=<bool>
    -

    ixoff=<bool>
    -

    ixon=<bool>
    -

    kill=<byte>
    -

    lnext=<byte>
    -

    min=<byte>
    -

    nl0
    - Sets the newline delay to 0. -

    nl1
    -

    nldly=<bool>
    -

    noflsh=<bool>
    -

    ocrnl=<bool>
    -

    ofdel=<bool>
    -

    ofill=<bool>
    -

    olcuc=<bool>
    -

    onlcr=<bool>
    -

    onlret=<bool>
    -

    onocr=<bool>
    -

    opost=<bool>
    - Enables or disables output processing; e.g., converts NL to CR-NL. -

    ospeed=<unsigned-int>
    - Set the baud rate for outgoing data on this line.
    - See also: ispeed, b19200 -

    parenb=<bool>
    - Enable parity generation on output and parity checking for input. -

    parmrk=<bool>
    -

    parodd=<bool>
    -

    pendin=<bool>
    -

    quit=<byte>
    -

    reprint=<byte>
    -

    sane
    - Brings the terminal to something like a useful default state. -

    start=<byte>
    -

    stop=<byte>
    -

    susp=<byte>
    -

    swtc=<byte>
    -

    tab0
    -

    tab1
    -

    tab2
    -

    tab3
    -

    tabdly=<unsigned-int>
    -

    time=<byte>
    -

    tostop=<bool>
    -

    vt0
    -

    vt1
    -

    vtdly=<bool>
    -

    werase=<byte>
    -

    xcase=<bool>
    -

    xtabs
    -
    -


    -

    PTY option group -

    These options are intended for use with the pty address -type. -

    -

    link=<filename>
    - Generates a symbolic link that points to the actual pseudo terminal - (pty). This might help - to solve the problem that ptys are generated with more or less - unpredictable names, making it difficult to directly access the socat - generated pty automatically. With this option, the user can specify a "fix" - point in the file hierarchy that helps him to access the actual pty. - Beginning with socat version 1.4.3, the symbolic link is removed when - the address is closed (but see option unlink-close). -

    wait-slave
    - Blocks the open phase until a process opens the slave side of the pty. - Usually, socat continues after generating the pty with opening the next - address or with entering the transfer loop. With the wait-slave option, - socat waits until some process opens the slave side of the pty before - continuing. - This option only works if the operating system provides the poll() - system call. And it depends on an undocumented behaviour of pty's, so it - does not work on all operating systems. It has successfully been tested on - Linux, FreeBSD, NetBSD, and on Tru64 with openpty. -

    pty-intervall=<seconds>
    - When the wait-slave option is set, socat - periodically checks the HUP condition using poll() to find if the pty's - slave side has been opened. The default polling intervall is 1s. Use the - pty-intervall option [timeval] to change this value. -
    -


    -

    OPENSSL option group -

    These options apply to the openssl and -openssl-listen address types. -

    -

    cipher=<cipherlist>
    - Selects the list of ciphers that may be used for the connection. - See the man page of ciphers, section CIPHER LIST FORMAT, for - detailed information about syntax, values, and default of <cipherlist>.
    - Several cipher strings may be given, separated by ':'. - Some simple cipher strings: -
    -

    3DES
    Uses a cipher suite with triple DES. -

    MD5
    Uses a cipher suite with MD5. -

    aNULL
    Uses a cipher suite without authentication. -

    NULL
    Does not use encryption. -

    HIGH
    Uses a cipher suite with "high" encryption. -
    - Note that the peer must support the selected property, or the negotiation - will fail. -

    method=<ssl-method>
    - Sets the protocol version to be used. Valid strings (not case sensitive) - are: -
    -

    SSLv2
    Select SSL protocol version 2. -

    SSLv3
    Select SSL protocol version 3. -

    SSLv23
    Select SSL protocol version 2 or 3. This is the default when - this option is not provided. -

    TLSv1
    Select TLS protocol version 1. -
    -

    verify=<bool>
    - Controls check of the peer's certificate. Default is 1 (true) for client and - 0 (false) for server addresses. Disabling verify might open your socket for - everyone! -

    cert=<filename>
    - Specifies the file with the certificate and private key for authentication. - The certificate must be in OpenSSL format (*.pem). - With openssl-listen, use of this option is strongly - recommended. Except with cipher aNULL, "no shared ciphers" error will - occur when no certificate is given. -

    key=<filename>
    - Specifies the file with the private key. The private key may be in this - file or in the file given with the cert option. The party that has - to proof that it is the owner of a certificate needs the private key. -

    dhparams=<filename>
    - Specifies the file with the Diffie Hellman parameters. These parameters may - also be in the file given with the cert - option in which case the dhparams option is not needed. -

    cafile=<filename>
    - Specifies the file with the trusted (root) authority certificates. The file - must be in PEM format and should contain one or more certificates. The party - that checks the authentication of its peer trusts only certificates that are - in this file. -

    capath=<dirname>
    - Specifies the directory with the trusted (root) certificates. The directory - must contain certificates in PEM format and their hashes (see OpenSSL - documentation) -

    egd=<filename>
    - On some systems, openssl requires an explicit source of random data. Specify - the socket name where an entropy gathering daemon like egd provides random - data, e.g. /dev/egd-pool. -

    pseudo
    - On systems where openssl cannot find an entropy source and where no entropy - gathering daemon can be utilized, this option activates a mechanism for - providing pseudo entropy. This is archieved by taking the current time in - microseconds for feeding the libc pseudo random number generator with an - initial value. openssl is then feeded with output from random() calls.
    - NOTE:This mechanism is not sufficient for generation of secure keys! -

    fips
    - Enables FIPS mode if compiled in. For info about the FIPS encryption - implementation standard see http://oss-institute.org/fips-faq.html. - This mode might require that the involved certificates are generated with a - FIPS enabled version of openssl. Setting or clearing this option on one - socat address affects all OpenSSL addresses of this process. -
    -


    -

    RETRY option group -

    Options that control retry of some system calls, especially connection -attempts. -

    -

    retry=<num>
    - Number of retries before the connection or listen attempt is aborted. - Default is 0, which means just one attempt. -

    intervall=<timespec>
    - Time between consecutive attempts (seconds, - [timespec]). Default is 1 second. -

    forever
    - Performs an unlimited number of retry attempts. -
    -


    -

    -

    DATA VALUES

    - -

    This section explains the different data types that address parameters and -address options can take. -

    -

    address-range
    - Is currently only implemented for IPv4 and IPv6. See address-option - `range' -

    bool
    - "0" or "1"; if value is omitted, "1" is taken. -

    byte
    - An unsigned int number, read with strtoul(), lower or equal to - UCHAR_MAX. -

    command-line
    - A string specifying a program name and its arguments, separated by single - spaces. -

    data
    - A raw data specification following dalan syntax. The only documented - form is a string starting with 'x' followed by an even number of hex digits. -

    directory
    - A string with usual UN*X directory name semantics. -

    facility
    - The name of a syslog facility in lower case characters. -

    fdnum
    - An unsigned int type, read with strtoul(), specifying a UN*X file - descriptor. -

    filename
    - A string with usual UN*X filename semantics. -

    group
    - If the first character is a decimal digit, the value is read with - strtoul() as unsigned integer specifying a group id. Otherwise, it - must be an existing group name. -

    int
    - A number following the rules of the strtol() function with base - "0", i.e. decimal number, octal number with leading "0", or hexadecimal - number with leading "0x". The value must fit into a C int. -

    interface
    - A string specifying the device name of a network interface, e.g. "eth0". -

    IP address
    - An IPv4 address in numbers-and-dots notation, an IPv6 address in hex - notation enclosed in brackets, or a hostname that resolves to an IPv4 or an - IPv6 address.
    - Examples: 127.0.0.1, [::1], www.dest-unreach.org, dns1 -

    IPv4 address
    - An IPv4 address in numbers-and-dots notation or a hostname that resolves to - an IPv4 address.
    - Examples: 127.0.0.1, www.dest-unreach.org, dns2 -

    IPv6 address
    - An iPv6 address in hexnumbers-and-colons notation enclosed in brackets, or a - hostname that resolves to an IPv6 address.
    - Examples: [::1], [1234:5678:9abc:def0:1234:5678:9abc:def0], - ip6name.domain.org -

    long
    - A number read with strtol(). The value must fit into a C long. -

    long long
    - A number read with strtoll(). The value must fit into a C long long. -

    off_t
    - An implementation dependend signed number, usually 32 bits, read with strtol - or strtoll. -

    off64_t
    - An implementation dependend signed number, usually 64 bits, read with strtol - or strtoll. -

    mode_t
    - An unsigned integer, read with strtoul(), specifying mode (permission) - bits. -

    pid_t
    - A number, read with strtol(), specifying a process id. -

    port
    - A uint16_t (16 bit unsigned number) specifying a TCP or UDP port, read - with strtoul(). -

    protocol
    - An unsigned 8 bit number, read with strtoul(). -

    size_t
    - An unsigned number with size_t limitations, read with strtoul. -

    sockname
    - A socket address. See address-option `bind' -

    string
    - A sequence of characters, not containing '\0' and, depending on - the position within the command line, ':', ',', or "!!". Note - that you might have to escape shell meta characters in the command line. -

    TCP service
    - A service name, not starting with a digit, that is resolved by - getservbyname(), or an unsigned int 16 bit number read with - strtoul(). -

    timeval
    - A double float specifying seconds; the number is mapped into a - struct timeval, consisting of seconds and microseconds. -

    timespec
    - A double float specifying seconds; the number is mapped into a - struct timespec, consisting of seconds and nanoseconds. -

    UDP service
    - A service name, not starting with a digit, that is resolved by - getservbyname(), or an unsigned int 16 bit number read with - strtoul(). -

    unsigned int
    - A number read with strtoul(). The value must fit into a C unsigned - int. -

    user
    - If the first character is a decimal digit, the value is read with - strtoul() as unsigned integer specifying a user id. Otherwise, it must - be an existing user name. -
    -

    -

    EXAMPLES

    - -

    -

    socat - TCP4:www.domain.org:80
    -

    Transfers data between STDIO (-) and a -TCP4 connection to port 80 of host -www.domain.org. This example results in an interactive connection similar to -telnet or netcat. The stdin terminal parameters are not changed, so you may -close the relay with ^D or abort it with ^C. -

    - - - -

    socat -d -d READLINE,history=$HOME/.http_history \
    -TCP4:www.domain.org:www,crnl
    -

    This is similar to the previous example, but you can edit the current line in a -bash like manner (READLINE) and use the -history file .http_history; socat -prints messages about progress (-d -d). The port is specified by service name -(www), and correct network line termination characters (crnl) instead of NL -are used. -

    socat TCP4-LISTEN:www TCP4:www.domain.org:www
    -

    Installs a simple TCP port forwarder. With -TCP4-LISTEN it listens on local port "www" until a -connection comes in, accepts it, then connects to the remote host -(TCP4) and starts data transfer. It will not accept a -second connection. -

    - - - -

    socat -d -d -lmlocal2 \
    -TCP4-LISTEN:80,bind=myaddr1,su=nobody,fork,range=10.0.0.0/8,reuseaddr \
    -TCP4:www.domain.org:80,bind=myaddr2
    -

    TCP port forwarder, each side bound to another local IP address -(bind). This example handles an almost -arbitrary number of parallel or consecutive connections by -fork'ing a new -process after each accept(). It provides a little security by -su'ing to user -nobody after forking; it only permits connections from the private 10 network (range); -due to reuseaddr, it allows immediate restart after master process's -termination, even if some child sockets are not completely shut down. -With -lmlocal2, socat logs to stderr until successfully -reaching the accept loop. Further logging is directed to syslog with facility -local2. -

    - - - -

    socat TCP4-LISTEN:5555,fork,tcpwrap=script \
    -EXEC:/bin/myscript,chroot=/home/sandbox,su-d=sandbox,pty,stderr
    -

    A simple server that accepts connections -(TCP4-LISTEN) and fork's a new -child process for each connection; every child acts as single relay. -The client must match the rules for daemon process name "script" in -/etc/hosts.allow and /etc/hosts.deny, otherwise it is refused access (see "man -5 hosts_access"). -For EXEC'uting the program, the child process -chroot's -to /home/sandbox, su's to user sandbox, and then starts -the program /home/sandbox/bin/myscript. Socat and -myscript communicate via a pseudo tty (pty); myscript's -stderr is redirected to stdout, -so its error messages are transferred via socat to the connected client. -

    - - - -

    socat EXEC:"mail.sh target@domain.com",fdin=3,fdout=4 \
    -TCP4:mail.relay.org:25,crnl,bind=alias1.server.org,mss=512
    -

    mail.sh is a shell script, distributed with socat, that implements a -simple -SMTP client. It is programmed to "speak" SMTP on its FDs 3 (in) and 4 (out). -The fdin and fdout options tell socat -to use these FDs for communication with -the program. Because mail.sh inherits stdin and stdout while socat does not -use them, the script can read a -mail body from stdin. Socat makes alias1 your local source address -(bind), cares for correct network line termination -(crnl) and sends -at most 512 data bytes per packet (mss). -

    socat - /dev/ttyS0,raw,echo=0,crnl
    -

    Opens an interactive connection via the serial line, e.g. for talking with a -modem. raw and echo set ttyS0's terminal -parameters to practicable values, crnl -converts to correct newline characters. Consider using -READLINE instead of `-'. -

    - - - -

    socat UNIX-LISTEN:/tmp/.X11-unix/X1,fork \
    -SOCKS4:host.victim.org:127.0.0.1:6000,socksuser=nobody,sourceport=20
    -

    With UNIX-LISTEN, socat opens a listening -UNIX domain socket /tmp/.X11-unix/X1. This path corresponds -to local XWindow display :1 on your machine, so XWindow client connections to -DISPLAY=:1 are accepted. Socat then speaks with -the SOCKS4 server host.victim.org that might permit -sourceport 20 based connections due to an FTP related -weakness in its static IP filters. Socat -pretends to be invoked by socksuser nobody, and -requests to be connected to -loopback port 6000 (only weak sockd configurations will allow this). So we get -a connection to the victims XWindow server and, if it does not require MIT -cookies or Kerberos authentication, we can start work. Please note that there -can only be one connection at a time, because TCP can establish only one -session with a given set of addresses and ports. -

    socat -u /tmp/readdata,seek-end=0,ignoreeof -
    -

    This is an example for unidirectional data transfer -(-u). Socat transfers data -from file /tmp/readdata (implicit address GOPEN), starting -at its current end (seek-end=0 lets socat start -reading at current end of file; use seek=0 or no -seek option to first read the existing data) in a "tail -f" like mode -(ignoreeof). The "file" -might also be a listening UNIX domain socket (do not use a seek option then). -

    - - - -

    (echo PASSWORD; sleep 5; echo ls; sleep 1) |
    -socat - EXEC:'ssh -l user server',pty,setsid,ctty
    -

    EXEC'utes an ssh session to server. Uses a pty for communication between socat and -ssh, makes it ssh's controlling tty (ctty), -and makes this pty the owner of -a new process group (setsid), so ssh accepts the password from socat. -

    - - - -

    socat -u TCP4-LISTEN:3334,reuseaddr,fork \
    -OPEN:/tmp/in.log,creat,append
    -

    Implements a simple network based message collector. -For each client connecting to port 3334, a new child process is generated (option fork). -All data sent by the clients are append'ed to the file /tmp/in.log. -If the file does not exist, socat creat's it. -Option reuseaddr allows immediate restart of the server -process. -

    - -

    socat READLINE,noecho='[Pp]assword:' EXEC:'ftp ftp.server.com',pty,setsid,ctty
    -

    Wraps a command line history (READLINE) around the EXEC'uted ftp client utility. -This allows editing and reuse of FTP commands for relatively comfortable -browsing through the ftp directory hierarchy. The password is echoed! - pty is required to have ftp issue a prompt. -Nevertheless, there may occur some confusion with the password and FTP -prompts. -

    socat PTY,link=$HOME/dev/vmodem0,raw,echo=0,waitslave exec:'"ssh modemserver.us.org socat - /dev/ttyS0,nonblock,raw,echo=0"'
    -

    Generates a pseudo terminal -device (PTY) on the client that can be reached under the -symbolic link $HOME/dev/vmodem0. -An application that expects a serial line or modem -can be configured to use $HOME/dev/vmodem0; its traffic will be directed -to a modemserver via ssh where another socat instance links it with -/dev/ttyS0. -

    - - - -

    socat TCP4-LISTEN:2022,reuseaddr,fork \
    -PROXY:proxy:www.domain.org:22,proxyport=3128,proxyauth=user:pass
    -

    starts a forwarder that accepts connections on port 2022, and directs them -through the proxy daemon listening on port 3128 -(proxyport) on host proxy, using the -CONNECT method, where they are authenticated as "user" with "pass" (proxyauth). The proxy -should establish connections to host www.domain.org on port 22 then. -

    echo |socat -u - file:/tmp/bigfile,create,largefile,seek=100000000000
    -

    creates a 100GB sparse file; this requires a file system type that -supports this (ext2, ext3, reiserfs, jfs; not minix, vfat). The operation of -writing 1 byte might take long (reiserfs: some minutes; ext2: "no" time), and -the resulting file can consume some disk space with just its inodes (reiserfs: -2MB; ext2: 16KB). -

    socat tcp-l:7777,reuseaddr,fork system:'filan -i 0 -s >&2',nofork
    -

    listens for incoming TCP connections on port 7777. For each accepted -connection, invokes a shell. This shell has its stdin and stdout directly -connected to the TCP socket (nofork). The shell starts filan and lets it print the socket addresses to -stderr (your terminal window). -

    echo -e "\0\14\0\0\c" |socat -u - file:/usr/bin/squid.exe,seek=0x00074420
    -

    functions as primitive binary editor: it writes the 4 bytes 000 014 000 000 to -the executable /usr/bin/squid at offset 0x00074420 (this is a real world patch -to make the squid executable from Cygwin run under Windows, actual per May 2004). -

    socat - tcp:www.blackhat.org:31337,readbytes=1000
    -

    connect to an unknown service and prevent being flooded. -

    -

    -

    DIAGNOSTICS

    - -

    Socat uses a logging mechanism that allows to filter messages by severity. The -severities provided are more or less compatible to the appropriate syslog -priority. With one or up to four occurrences of the -d command line option, the -lowest priority of messages that are issued can be selected. Each message -contains a single uppercase character specifying the messages severity (one of -F, E, W, N, I, or D) -

    -

    FATAL:
    Conditions that require unconditional and immediate program termination. -

    ERROR:
    Conditions that prevent proper program processing. Usually the -program is terminated (see option -s). -

    WARNING:
    Something did not function correctly or is in a state where -correct further processing cannot be guaranteed, but might be possible. -

    NOTICE:
    Interesting actions of the program, e.g. for supervising socat in some kind of server mode. -

    INFO:
    Description of what the program does, and maybe why it -happens. Allows to monitor the lifecycles of file descriptors. -

    DEBUG:
    Description of how the program works, all system or library calls and their results. -
    -

    Log messages can be written to stderr, to a file, or to syslog. -

    On exit, socat gives status 0 if it terminated due to EOF or inactivity -timeout, with a positive value on error, and with a negative value on fatal -error. -

    -

    FILES

    - -

    /usr/bin/socat
    -/usr/bin/filan
    -/usr/bin/procan -

    -

    ENVIRONMENT VARIABLES

    - -

    -

    SOCAT_DEFAULT_LISTEN_IP
    (Values 4 or 6) Sets the IP version to be used -for listen, recv, and recvfrom addresses if no pf -(protocol-family) option is given. Is overridden by socat options --4 or -6. -

    SOCAT_PREFERRED_RESOLVE_IP
    (Values 0, 4, or 6) Sets the IP version to -be used when resolving target host names when version is not specified by -address type, option pf (protocol-family), or -address format. If name resolution does not return a matching entry, the first -result (with differing IP version) is taken. With value 0, socat always selects -the first record and its IP version. -

    SOCAT_FORK_WAIT
    Specifies the time (seconds) to sleep the parent and -child processes after successful fork(). Useful for debugging. -

    HOSTNAME
    Is used to determine the hostname for logging (see --lh). -

    LOGNAME
    Is used as name for the socks client user name if no -socksuser is given.
    -With options su and -su-d, LOGNAME is set to the given user name. -

    USER
    Is used as name for the socks client user name if no -socksuser is given and LOGNAME is empty.
    -With options su and -su-d, USER is set to the given user name. -

    SHELL
    -With options su and -su-d, SHELL is set to the login shell of the -given user. -

    PATH
    -Can be set with option path for exec and -system addresses. -

    HOME
    -With options su and -su-d, HOME is set to the home directory of the -given user. -

    -

    -

    CREDITS

    - -

    The work of the following groups and organizations was invaluable for this -project: -

    The FSF (GNU, http://www.fsf.org/ project -with their free and portable development software and -lots of other useful tools and libraries. -

    The Linux developers community (http://www.linux.org/) for providing a free, open source operating -system. -

    Sourceforge (http://www.sourceforge.net/) for providing a compile -farm with Solaris, FreeBSD, and MacOS X machines, making these ports possible. -

    The Open Group (http://www.unix-systems.org/) for making their -standard specifications available on the Internet for free. -

    -

    VERSION

    - -

    This man page describes version 1.5.0 of socat. -

    -

    BUGS

    - -

    Addresses cannot be nested, so a single socat process cannot, e.g., drive ssl -over socks. -

    Address option ftruncate without value uses default 1 instead of 0. -

    Verbose modes (-x and/or -v) display line termination characters inconsistently -when address options cr or crnl are used: They show the data after -conversion in either direction. -

    The data transfer blocksize setting (-b) is ignored with address readline. -

    Send bug reports to <socat@dest-unreach.org> -

    -

    SEE ALSO

    - -

    -nc(1), netcat6(1), sock(1), rinetd(8), cage(1), socks.conf(5), openssl(1), -stunnel(8), pty(1), rlwrap(1), setsid(1) -

    Socat home page http://www.dest-unreach.org/socat/ -

    -

    AUTHOR

    - -

    Gerhard Rieger <rieger@dest-unreach.org> - - diff --git a/doc/socat.yo b/doc/socat.yo index 49bacab..4befd5b 100644 --- a/doc/socat.yo +++ b/doc/socat.yo @@ -1,4 +1,4 @@ -COMMENT($Id: socat.yo,v 1.99 2007/03/06 20:56:24 gerhard Exp $) +COMMENT(source: socat.yo) mailto(socat@dest-unreach.org) def(unix)(0)(UN*X) @@ -10,7 +10,7 @@ def(Filan)(0)(bf(Filan)) def(procan)(0)(bf(procan)) def(Procan)(0)(bf(Procan)) -manpage(socat)(1)(March 2007)(socat)() +manpage(socat)(1)(Feb 2008)(socat)() whenhtml( label(CONTENTS) @@ -163,7 +163,7 @@ label(option_t)dit(bf(tt(-t))tt()) down. Then, socat() waits [link(timeval)(TYPE_TIMEVAL)] seconds before terminating. Default is 0.5 seconds. This timeout only applies to addresses where write and read part can be closed independently. When during - the timeout intervall the read part gives EOF, socat terminates without + the timeout interval the read part gives EOF, socat terminates without awaiting the timeout. label(option_T)dit(bf(tt(-T))tt()) Total inactivity timeout: when socat is already in the transfer loop and @@ -1716,14 +1716,14 @@ dit(bf(tt(ip-add-membership=))) +dit(bf(tt(ip-multicast-if=))) Specifies hostname or address of the network interface to be used for multicast traffic. label(OPTION_IP_MULTICAST_LOOP) -dif(bf(tt(ip-multicast-loop=))) +dit(bf(tt(ip-multicast-loop=))) Specifies if outgoing multicast traffic should loop back to the interface. label(OPTION_IP_MULTICAST_TTL) -dif(bf(tt(ip-multicast-ttl=))) +dit(bf(tt(ip-multicast-ttl=))) Sets the TTL used for outgoing multicast traffic. Default is 1. label(OPTION_RES_DEBUG)dit(bf(tt(res-debug))) label(OPTION_RES_AAONLY)dit(bf(tt(res-aaonly))) @@ -1774,7 +1774,7 @@ label(OPTION_KEEPIDLE)dit(bf(tt(keepidle=))) Sets the idle time before sending the first keepalive to [link(int)(TYPE_INT)]. label(OPTION_KEEPINTVL)dit(bf(tt(keepintvl=))) - Sets the intervall between two keepalives to + Sets the interval between two keepalives to [link(int)(TYPE_INT)]. label(OPTION_LINGER2)dit(bf(tt(linger2=))) Sets the time to keep the socket in FIN-WAIT-2 state to @@ -2145,7 +2145,7 @@ label(OPTION_ISIG)dit(bf(tt(isig=))) label(OPTION_ISPEED)dit(bf(tt(ispeed=))) Set the baud rate for incoming data on this line.nl() See also: link(ospeed)(OPTION_OSPEED), link(b19200)(OPTION_B19200) -label(OPTION_ISTRIP)dif(bf(tt(istrip=))) +label(OPTION_ISTRIP)dit(bf(tt(istrip=))) label(OPTION_IUCLC)dit(bf(tt(iuclc=))) label(OPTION_IXANY)dit(bf(tt(ixany=))) label(OPTION_IXOFF)dit(bf(tt(ixoff=))) @@ -2227,11 +2227,11 @@ label(OPTION_PTY_WAIT_SLAVE)dit(bf(tt(wait-slave))) system call. And it depends on an undocumented behaviour of pty's, so it does not work on all operating systems. It has successfully been tested on Linux, FreeBSD, NetBSD, and on Tru64 with openpty. -label(OPTION_PTY_INTERVALL)dit(bf(tt(pty-intervall=))) +label(OPTION_PTY_INTERVAL)dit(bf(tt(pty-interval=))) When the link(wait-slave)(OPTION_PTY_WAIT_SLAVE) option is set, socat periodically checks the HUP condition using tt(poll()) to find if the pty's - slave side has been opened. The default polling intervall is 1s. Use the - pty-intervall option [link(timeval)(TYPE_TIMEVAL)] to change this value. + slave side has been opened. The default polling interval is 1s. Use the + pty-interval option [link(timeval)(TYPE_TIMEVAL)] to change this value. enddit() @@ -2326,7 +2326,7 @@ startdit() label(OPTION_RETRY)dit(bf(tt(retry=))) Number of retries before the connection or listen attempt is aborted. Default is 0, which means just one attempt. -label(OPTION_INTERVALL)dit(bf(tt(intervall=))) +label(OPTION_INTERVAL)dit(bf(tt(interval=))) Time between consecutive attempts (seconds, [link(timespec)(TYPE_TIMESPEC)]). Default is 1 second. label(OPTION_FOREVER)dit(bf(tt(forever))) @@ -2690,7 +2690,7 @@ mancommand(\fB(sleep 5; echo PASSWORD; sleep 5; echo ls; sleep 1) | socat - EXEC:'ssh -l user server',pty,setsid,ctty\fP) mancommand(\.fi) -htmlcommand(

    (echo PASSWORD; sleep 5; echo ls; sleep 1) |
    +htmlcommand(
    (sleep 5; echo PASSWORD; sleep 5; echo ls; sleep 1) |
    socat - EXEC:'ssh -l user server',pty,setsid,ctty
    ) link(EXEC)(ADDRESS_EXEC)'utes an ssh session to server. Uses a link(pty)(OPTION_PTY) for communication between socat() and diff --git a/doc/xio.help b/doc/xio.help index 937a93d..c1ac403 100644 --- a/doc/xio.help +++ b/doc/xio.help @@ -1,4 +1,4 @@ -# $Id: xio.help,v 1.115 2007/03/06 20:57:34 gerhard Exp $ +# source: xio.help # Copyright Gerhard Rieger 2001-2007 Operating systems: @@ -1789,7 +1789,7 @@ Platforms: all Linux, FreeBSD, NetBSD, and on Tru64 with openpty. -Option: pty-intervall +Option: pty-interval Type: TIMESPEC Option group: PTY @@ -1799,7 +1799,7 @@ Platforms: all When the wait-slave option is set, socat periodically checks the HUP condition using poll() to find if the pty's slave side has been opened. The default - polling intervall is 1s. Use the pty-intervall option to change this value. + polling interval is 1s. Use the pty-interval option to change this value. =============================================================================== @@ -3008,7 +3008,7 @@ Option group: IP_TCP Phase: PASTSOCKET Platforms: Linux -Sets the TCP_KEEPINTVL value of the socket with setsockopt(). Intervall between +Sets the TCP_KEEPINTVL value of the socket with setsockopt(). Interval between keepalives (in seconds?) @@ -4703,7 +4703,7 @@ Number of retries before the connection or listen attempt is aborted. Default is 0, which means just one attempt. -Option: intervall= +Option: interval= Type: TIMESPEC Option group: RETRY diff --git a/error.c b/error.c index 0728515..54e2dd5 100644 --- a/error.c +++ b/error.c @@ -1,4 +1,4 @@ -/* $Id: error.c,v 1.29 2007/02/08 18:22:23 gerhard Exp $ */ +/* source: error.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/error.h b/error.h index 72eb85b..537987f 100644 --- a/error.h +++ b/error.h @@ -1,4 +1,4 @@ -/* $Id: error.h,v 1.14 2007/03/06 21:19:18 gerhard Exp $ */ +/* source: error.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/fdname.c b/fdname.c index f48e736..8ede9fe 100644 --- a/fdname.c +++ b/fdname.c @@ -1,4 +1,4 @@ -/* $Id: fdname.c,v 1.9 2007/02/08 18:27:00 gerhard Exp $ */ +/* source: fdname.c */ /* Copyright Gerhard Rieger 2003-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/filan.c b/filan.c index b486389..e0477d1 100644 --- a/filan.c +++ b/filan.c @@ -1,4 +1,4 @@ -/* $Id: filan.c,v 1.45 2007/02/08 19:42:34 gerhard Exp $ */ +/* source: filan.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/filan.h b/filan.h index 604ab03..8ed3484 100644 --- a/filan.h +++ b/filan.h @@ -1,4 +1,4 @@ -/* $Id: filan.h,v 1.8 2007/03/06 21:19:18 gerhard Exp $ */ +/* source: filan.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/filan_main.c b/filan_main.c index 1231263..3a52f2b 100644 --- a/filan_main.c +++ b/filan_main.c @@ -1,4 +1,4 @@ -/* $Id: filan_main.c,v 1.19 2006/07/12 21:59:15 gerhard Exp $ */ +/* source: filan_main.c */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/ftp.sh b/ftp.sh index 8489137..4cbb956 100755 --- a/ftp.sh +++ b/ftp.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $Id: ftp.sh,v 1.11 2006/12/28 07:27:01 gerhard Exp $ +# source: ftp.sh # Copyright Gerhard Rieger 2001-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/gatherinfo.sh b/gatherinfo.sh index 18083bd..d5f540e 100755 --- a/gatherinfo.sh +++ b/gatherinfo.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $Id: gatherinfo.sh,v 1.12 2007/03/06 21:01:07 gerhard Exp $ +# source: gatherinfo.sh # Copyright Gerhard Rieger 2001, 2002 # Published under the GNU General Public License V.2, see file COPYING diff --git a/hostan.c b/hostan.c index 75501e0..8862bf5 100644 --- a/hostan.c +++ b/hostan.c @@ -1,5 +1,5 @@ -/* $Id: hostan.c,v 1.2 2007/03/06 21:02:01 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2006-2007 */ +/* source: hostan.c */ +/* Copyright Gerhard Rieger 2006-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* the subroutine hostan makes a "HOST ANalysis". It gathers information @@ -21,6 +21,7 @@ static int iffan(FILE *outfile); int hostan(FILE *outfile) { #if WITH_SOCKET + fprintf(outfile, "\nIP INTERFACES\n"); iffan(outfile); #endif return 0; diff --git a/hostan.h b/hostan.h index ab9b8e0..88844b4 100644 --- a/hostan.h +++ b/hostan.h @@ -1,4 +1,4 @@ -/* $Id: hostan.h,v 1.1 2006/12/31 17:49:25 gerhard Exp $ */ +/* source: hostan.h */ /* Copyright Gerhard Rieger 2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/mail.sh b/mail.sh index 669ac75..115b1eb 100755 --- a/mail.sh +++ b/mail.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $Id: mail.sh,v 1.11 2005/09/10 16:48:38 gerhard Exp $ +# source: mail.sh # Copyright Gerhard Rieger 2001-2005 # Published under the GNU General Public License V.2, see file COPYING diff --git a/mytypes.h b/mytypes.h index f96eaa2..f625314 100644 --- a/mytypes.h +++ b/mytypes.h @@ -1,4 +1,4 @@ -/* $Id: mytypes.h,v 1.4 2006/05/06 14:15:47 gerhard Exp $ */ +/* source: mytypes.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/nestlex.c b/nestlex.c index 4cadd82..5230f9b 100644 --- a/nestlex.c +++ b/nestlex.c @@ -1,4 +1,4 @@ -/* $Id: nestlex.c,v 1.4 2006/06/23 17:04:36 gerhard Exp $ */ +/* source: nestlex.c */ /* Copyright Gerhard Rieger 2006-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/nestlex.h b/nestlex.h index 206ffde..9d08d5e 100644 --- a/nestlex.h +++ b/nestlex.h @@ -1,4 +1,4 @@ -/* $Id: nestlex.h,v 1.3 2006/06/23 17:04:39 gerhard Exp $ */ +/* source: nestlex.h */ /* Copyright Gerhard Rieger 2006-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/procan-cdefs.c b/procan-cdefs.c new file mode 100644 index 0000000..14333de --- /dev/null +++ b/procan-cdefs.c @@ -0,0 +1,84 @@ +/* source: procan-cdefs.c */ +/* Copyright Gerhard Rieger 2008 */ +/* Published under the GNU General Public License V.2, see file COPYING */ + +/* a function that prints compile time parameters */ +/* the set of parameters is only a small subset of the available defines and + will be extended on demand */ + + +#include "xiosysincludes.h" +#include "mytypes.h" +#include "compat.h" +#include "error.h" + +#include "procan.h" + +int procan_cdefs(FILE *outfile) { + /* basic C/system constants */ +#ifdef FD_SETSIZE + fprintf(outfile, "#define FD_SETSIZE %u\n", FD_SETSIZE); +#endif +#ifdef NFDBITS + fprintf(outfile, "#define NFDBITS %u\n", NFDBITS); +#endif +#ifdef O_RDONLY + fprintf(outfile, "#define O_RDONLY %u\n", O_RDONLY); +#endif +#ifdef O_WRONLY + fprintf(outfile, "#define O_WRONLY %u\n", O_WRONLY); +#endif +#ifdef O_RDWR + fprintf(outfile, "#define O_RDWR %u\n", O_RDWR); +#endif +#ifdef SHUT_RD + fprintf(outfile, "#define SHUT_RD %u\n", SHUT_RD); +#endif +#ifdef SHUT_WR + fprintf(outfile, "#define SHUT_WR %u\n", SHUT_WR); +#endif +#ifdef SHUT_RDWR + fprintf(outfile, "#define SHUT_RDWR %u\n", SHUT_RDWR); +#endif + + /* termios constants */ +#ifdef CRDLY + fprintf(outfile, "#define CRDLY 0%011o\n", CRDLY); +#endif +#ifdef CR0 + fprintf(outfile, "#define CR0 0%011o\n", CR0); +#endif +#ifdef CR1 + fprintf(outfile, "#define CR1 0%011o\n", CR1); +#endif +#ifdef CR2 + fprintf(outfile, "#define CR2 0%011o\n", CR2); +#endif +#ifdef CR3 + fprintf(outfile, "#define CR3 0%011o\n", CR3); +#endif +#ifdef TABDLY + fprintf(outfile, "#define TABDLY 0%011o\n", TABDLY); +#endif +#ifdef TAB0 + fprintf(outfile, "#define TAB0 0%011o\n", TAB0); +#endif +#ifdef TAB1 + fprintf(outfile, "#define TAB1 0%011o\n", TAB1); +#endif +#ifdef TAB2 + fprintf(outfile, "#define TAB2 0%011o\n", TAB2); +#endif +#ifdef TAB3 + fprintf(outfile, "#define TAB3 0%011o\n", TAB3); +#endif +#ifdef CSIZE + fprintf(outfile, "#define CSIZE 0%011o\n", CSIZE); +#endif + + /* stdio constants */ +#ifdef FOPEN_MAX + fprintf(outfile, "#define FOPEN_MAX %u\n", FOPEN_MAX); +#endif + return 0; +} diff --git a/procan.c b/procan.c index 376b890..5c12aaf 100644 --- a/procan.c +++ b/procan.c @@ -1,4 +1,4 @@ -/* $Id: procan.c,v 1.17 2006/12/28 07:25:01 gerhard Exp $ */ +/* source: procan.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/procan.h b/procan.h index 0825c54..4fd8e06 100644 --- a/procan.h +++ b/procan.h @@ -1,10 +1,11 @@ -/* $Id: procan.h,v 1.2 2001/06/30 14:02:39 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001 */ +/* source: procan.h */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __procan_h_included #define __procan_h_included 1 extern int procan(FILE *outfile); +extern int procan_cdefs(FILE *outfile); #endif /* !defined(__procan_h_included) */ diff --git a/procan_main.c b/procan_main.c index b368ac1..b482306 100644 --- a/procan_main.c +++ b/procan_main.c @@ -1,5 +1,5 @@ -/* $Id: procan_main.c,v 1.13 2007/03/06 21:19:18 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: procan_main.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ const char copyright[] = "procan by Gerhard Rieger - send bug reports to socat@dest-unreach.org"; @@ -32,6 +32,7 @@ int main(int argc, const char *argv[]) { #if WITH_HELP case '?': case 'h': procan_usage(stdout); exit(0); #endif /* WITH_HELP */ + case 'c': procan_cdefs(stdout); exit(0); #if LATER case 'V': procan_version(stdout); exit(0); case 'l': diag_set(arg1[0][2], &arg1[0][3]); break; @@ -79,6 +80,7 @@ static void procan_usage(FILE *fd) { #if WITH_HELP fputs(" -?|-h print a help text describing command line options\n", fd); #endif + fputs(" -c print values of compile time C defines\n", fd); #if LATER fputs(" -d increase verbosity (use up to 4 times; 2 are recommended)\n", fd); #endif diff --git a/proxy.sh b/proxy.sh index e4da38c..09b1b06 100755 --- a/proxy.sh +++ b/proxy.sh @@ -1,5 +1,5 @@ #! /bin/bash -# $Id: proxy.sh,v 1.3 2004/07/11 07:55:57 gerhard Exp $ +# source: proxy.sh # Copyright Gerhard Rieger 2003-2004 # Published under the GNU General Public License V.2, see file COPYING diff --git a/proxyecho.sh b/proxyecho.sh index 545fe68..26b4f6f 100755 --- a/proxyecho.sh +++ b/proxyecho.sh @@ -1,5 +1,5 @@ #! /bin/bash -# $Id: proxyecho.sh,v 1.5 2004/06/06 17:33:22 gerhard Exp $ +# source: proxyecho.sh # Copyright Gerhard Rieger 2003 # Published under the GNU General Public License V.2, see file COPYING diff --git a/readline-test.sh b/readline-test.sh index 83c24a2..569bff6 100755 --- a/readline-test.sh +++ b/readline-test.sh @@ -1,5 +1,5 @@ #! /bin/bash -# $Id: readline-test.sh,v 1.1 2003/12/23 21:28:12 gerhard Exp $ +# source: readline-test.sh # Copyright Gerhard Rieger 2003 # Published under the GNU General Public License V.2, see file COPYING diff --git a/readline.sh b/readline.sh index 26cd1df..fda7ea6 100755 --- a/readline.sh +++ b/readline.sh @@ -1,5 +1,5 @@ #! /bin/bash -# $Id: readline.sh,v 1.3 2004/08/25 15:52:59 gerhard Exp $ +# source: readline.sh # Copyright Gerhard Rieger 2003-2004 # Published under the GNU General Public License V.2, see file COPYING diff --git a/socat.c b/socat.c index 5b93804..f77feb8 100644 --- a/socat.c +++ b/socat.c @@ -1,5 +1,5 @@ -/* $Id: socat.c,v 1.111 2007/03/06 21:03:28 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: socat.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this is the main source, including command line option parsing, general diff --git a/socat.spec b/socat.spec index db6beac..b3a6561 100644 --- a/socat.spec +++ b/socat.spec @@ -1,6 +1,6 @@ %define majorver 1.6 -%define minorver 0.0 +%define minorver 0.1 Summary: socat - multipurpose relay Name: socat diff --git a/socks4a-echo.sh b/socks4a-echo.sh index 2ab8142..5369c83 100755 --- a/socks4a-echo.sh +++ b/socks4a-echo.sh @@ -1,5 +1,5 @@ #! /bin/bash -# $Id: socks4a-echo.sh,v 1.2 2004/08/25 16:01:30 gerhard Exp $ +# source: socks4a-echo.sh #set -vx # Copyright Gerhard Rieger 2004 diff --git a/socks4echo.sh b/socks4echo.sh index 343d32f..348367a 100755 --- a/socks4echo.sh +++ b/socks4echo.sh @@ -1,5 +1,5 @@ #! /bin/bash -# $Id: socks4echo.sh,v 1.4 2006/03/21 18:48:53 gerhard Exp $ +# source: socks4echo.sh # Copyright Gerhard Rieger 2004-2006 # Published under the GNU General Public License V.2, see file COPYING diff --git a/sslcls.c b/sslcls.c index c0fdd0b..076cc95 100644 --- a/sslcls.c +++ b/sslcls.c @@ -1,4 +1,4 @@ -/* $Id: sslcls.c,v 1.8 2007/02/26 21:30:58 gerhard Exp $ */ +/* source: sslcls.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/sslcls.h b/sslcls.h index bb61d86..8d2d193 100644 --- a/sslcls.h +++ b/sslcls.h @@ -1,4 +1,4 @@ -/* $Id: sslcls.h,v 1.9 2007/02/26 21:30:58 gerhard Exp $ */ +/* source: sslcls.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/sycls.c b/sycls.c index 64d185a..3102419 100644 --- a/sycls.c +++ b/sycls.c @@ -1,4 +1,4 @@ -/* $Id: sycls.c,v 1.75 2007/03/06 21:04:12 gerhard Exp $ */ +/* source: sycls.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/sycls.h b/sycls.h index 565c483..c518bc9 100644 --- a/sycls.h +++ b/sycls.h @@ -1,4 +1,4 @@ -/* $Id: sycls.h,v 1.50 2007/03/06 21:04:26 gerhard Exp $ */ +/* source: sycls.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/sysincludes.h b/sysincludes.h index 6294cd6..35e5257 100644 --- a/sysincludes.h +++ b/sysincludes.h @@ -1,4 +1,4 @@ -/* $Id: sysincludes.h,v 1.23 2007/03/06 21:04:58 gerhard Exp $ */ +/* source: sysincludes.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/sysutils.c b/sysutils.c index 344c75e..050a94a 100644 --- a/sysutils.c +++ b/sysutils.c @@ -1,4 +1,4 @@ -/* $Id: sysutils.c,v 1.44 2007/03/06 21:05:11 gerhard Exp $ */ +/* source: sysutils.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/sysutils.h b/sysutils.h index 28e33d4..68a5459 100644 --- a/sysutils.h +++ b/sysutils.h @@ -1,4 +1,4 @@ -/* $Id: sysutils.h,v 1.23 2007/03/06 21:05:37 gerhard Exp $ */ +/* source: sysutils.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/test.sh b/test.sh index 80d0aa1..93c485c 100755 --- a/test.sh +++ b/test.sh @@ -1,6 +1,6 @@ #! /bin/bash -# $Id: test.sh,v 1.134 2007/03/06 21:06:20 gerhard Exp $ -# Copyright Gerhard Rieger 2001-2007 +# source: test.sh +# Copyright Gerhard Rieger 2001-2008 # Published under the GNU General Public License V.2, see file COPYING # perform lots of tests on socat @@ -380,11 +380,11 @@ filloptionvalues() { esac # PTY case "$OPTS" in - *,pty-intervall,*) OPTS=$(echo "$OPTS" |sed "s/,pty-intervall,/,pty-intervall=$INTERFACE,/g");; + *,pty-interval,*) OPTS=$(echo "$OPTS" |sed "s/,pty-interval,/,pty-interval=$INTERFACE,/g");; esac # RETRY case "$OPTS" in - *,intervall,*) OPTS=$(echo "$OPTS" |sed "s/,intervall,/,intervall=1,/g");; + *,interval,*) OPTS=$(echo "$OPTS" |sed "s/,interval,/,interval=1,/g");; esac # READLINE case "$OPTS" in @@ -1444,15 +1444,13 @@ testecho () { #$ECHO "testing $title (test $num)... \c" $PRINTF "test $F_n %s... " $num "$title" #echo "$da" |$cmd >"$tf" 2>"$te" -#set -vx - (echo "$da"; rsleep $T) |$SOCAT $opts "$arg1" "$arg2" >"$tf" 2>"$te" & + (echo "$da"; rsleep $T) |($SOCAT $opts "$arg1" "$arg2" >"$tf" 2>"$te"; echo $? >"$td/test$N.rc") & export rc1=$! #sleep 5 && kill $rc1 2>/dev/null & # rc2=$! wait $rc1 # kill $rc2 2>/dev/null -#set +vx - if [ "$?" != 0 ]; then + if [ "$(cat "$td/test$N.rc")" != 0 ]; then $PRINTF "$FAILED: $SOCAT:\n" echo "$SOCAT $opts $arg1 $arg2" cat "$te" @@ -1522,7 +1520,7 @@ testod () { local te="$td/test$N.stderr" local tdiff="$td/test$N.diff" local dain="$(date)" - local daout="$(echo "$dain" |od -c)" + local daout="$(echo "$dain" |$OD_C)" $PRINTF "test $F_n %s... " $num "$title" (echo "$dain"; rsleep $T) |$SOCAT $opts "$arg1" "$arg2" >"$tf" 2>"$te" if [ "$?" != 0 ]; then @@ -1575,6 +1573,61 @@ testoptions () { return 0 } +# check if a process with given pid exists; print its ps line +# if yes: prints line to stdout, returns 0 +# if not: prints ev.message to stderr, returns 1 +ifprocess () { + local l + case "$UNAME" in + AIX) l="$(ps -fade |grep "^........ $(printf %6u $1)")" ;; + FreeBSD) l="$(ps -faje |grep "^........ $(printf %5u $1)")" ;; + HP-UX) l="$(ps -fade |grep "^........ $(printf %5u $1)")" ;; + Linux) l="$(ps -fade |grep "^........ $(printf %5u $1)")" ;; + SunOS) l="$(ps -fade |grep "^........ $(printf %5u $1)")" ;; + *) l="$(ps -fade |grep "^[^ ][^ ]*[ ][ ]*$(printf %5u $1) ")" ;; + esac + if [ -z "$l" ]; then + return 1; + fi + echo "$l" + return 0 +} + +# check if the given pid exists and has child processes +# if yes: prints child process lines to stdout, returns 0 +# if not: prints ev.message to stderr, returns 1 +childprocess () { + local l + case "$UNAME" in + AIX) l="$(ps -fade |grep "^........ ...... $(printf %6u $1)")" ;; + FreeBSD) l="$(ps -faje |grep "^........ ..... $(printf %5u $1)")" ;; + HP-UX) l="$(ps -fade |grep "^........ ..... $(printf %5u $1)")" ;; + Linux) l="$(ps -fade |grep "^........ ..... $(printf %5u $1)")" ;; + SunOS) l="$(ps -fade |grep "^........ ..... $(printf %5u $1)")" ;; + *) l="$(ps -fade |grep "^[^ ][^ ]*[ ][ ]*[0-9][0-9]**[ ][ ]*$(printf %5u $1) ")" ;; esac + if [ -z "$l" ]; then + return 1; + fi + echo "$l" + return 0 +} + +# check if the given process line refers to a defunct (zombie) process +# yes: returns 0 +# no: returns 1 +isdefunct () { + local l + case "$UNAME" in + AIX) l="$(echo "$1" |grep ' $')" ;; + FreeBSD) l="$(echo "$1" |grep ' $')" ;; + HP-UX) l="$(echo "$1" |grep ' $')" ;; + Linux) l="$(echo "$1" |grep ' $')" ;; + SunOS) l="$(echo "$1" |grep ' $')" ;; + *) l="$(echo "$1" |grep ' $')" ;; + esac + [ -n "$l" ]; +} + unset HAVENOT_IP4 # check if an IP4 loopback interface exists runsip4 () { @@ -2052,7 +2105,11 @@ esac N=$((N+1)) +# test: send EOF to exec'ed sub process, let it finished its operation, and +# check if the sub process returns its data before terminating. NAME=EXECSOCKETFLUSH +# idea: have socat exec'ing od; send data and EOF, and check if the od'ed data +# arrives. case "$TESTS" in *%functions%*|*%exec%*|*%$NAME%*) TEST="$NAME: call to od via exec with socketpair" @@ -2341,13 +2398,15 @@ CMD1="$SOCAT $opts TCP4-LISTEN:$tsl,reuseaddr PIPE" CMD2="$SOCAT $opts stdout%stdin TCP4:$ts" printf "test $F_n $TEST... " $N $CMD1 >"$tf" 2>"${te}1" & +pid1=$! waittcp4port $tsl 1 echo "$da" |$CMD2 >>"$tf" 2>>"${te}2" if [ $? -ne 0 ]; then $PRINTF "$FAILED: $SOCAT:\n" echo "$CMD1 &" + cat "${te}1" echo "$CMD2" - cat "$te" + cat "${te}2" numFAIL=$((numFAIL+1)) elif ! echo "$da" |diff - "$tf" >"$tdiff"; then $PRINTF "$FAILED\n" @@ -2357,7 +2416,9 @@ else $PRINTF "$OK\n" if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi numOK=$((numOK+1)) -fi ;; +fi +kill $pid1 2>/dev/null +wait ;; esac PORT=$((PORT+1)) N=$((N+1)) @@ -3642,6 +3703,52 @@ esac PORT=$((PORT+1)) N=$((N+1)) +# does our OpenSSL implementation support halfclose? +NAME=OPENSSLEOF +case "$TESTS" in +*%functions%*|*%openssl%*|*%tcp%*|*%tcp4%*|*%ip4%*|*%$NAME%*) +TEST="$NAME: openssl half close" +# have an SSL server that executes "$OD_C" and see if EOF on the SSL client +# brings the result of od to the client +if ! testaddrs openssl >/dev/null; then + $PRINTF "test $F_n $TEST... ${YELLOW}OPENSSL not available${NORMAL}\n" $N + 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 +gentestcert testsrv +tf="$td/test$N.stdout" +te="$td/test$N.stderr" +tdiff="$td/test$N.diff" +da=$(date) +CMD2="$SOCAT $opts OPENSSL-LISTEN:$PORT,pf=ip4,reuseaddr,$SOCAT_EGD,cert=testsrv.crt,key=testsrv.key,verify=0 exec:'$OD_C'" +CMD="$SOCAT $opts - openssl:$LOCALHOST:$PORT,verify=0,$SOCAT_EGD" +printf "test $F_n $TEST... " $N +eval "$CMD2 2>\"${te}1\" &" +pid=$! # background process id +waittcp4port $PORT +echo "$da" |$CMD >$tf 2>"${te}2" +if ! echo "$da" |$OD_C |diff - "$tf" >"$tdiff"; then + $PRINTF "$FAILED: $SOCAT:\n" + echo "$CMD2 &" + echo "$CMD" + cat "${te}1" + cat "${te}2" + cat "$tdiff" + numFAIL=$((numFAIL+1)) +else + $PRINTF "$OK\n" + if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi + numOK=$((numOK+1)) +fi +kill $pid 2>/dev/null +wait +fi +esac +PORT=$((PORT+1)) +N=$((N+1)) + NAME=OPENSSL_SERVERAUTH case "$TESTS" in @@ -4482,7 +4589,7 @@ da=$(date) # this is the server in the protected network that we want to reach CMD1="$SOCAT -lpserver $opts tcp4-l:$PORT,reuseaddr,bind=$LOCALHOST echo" # this is the double client in the protected network -CMD2="$SOCAT -lp2client $opts tcp4:$LOCALHOST:$((PORT+1)),retry=10,intervall=1 tcp4:$LOCALHOST:$PORT" +CMD2="$SOCAT -lp2client $opts tcp4:$LOCALHOST:$((PORT+1)),retry=10,interval=1 tcp4:$LOCALHOST:$PORT" # this is the double server in the outside network CMD3="$SOCAT -lp2server $opts tcp4-l:$((PORT+2)),reuseaddr,bind=$LOCALHOST tcp4-l:$((PORT+1)),reuseaddr,bind=$LOCALHOST" # this is the outside client that wants to use the protected server @@ -4544,7 +4651,7 @@ CMD2="$SOCAT $opts -lpproxy tcp4-l:$((PORT+1)),reuseaddr,bind=$LOCALHOST,fork ex #CMD3="$SOCAT $opts -lpwrapper tcp4-l:$((PORT+2)),reuseaddr,bind=$LOCALHOST,fork proxy:$LOCALHOST:$LOCALHOST:$((PORT+3)),pf=ip4,proxyport=$((PORT+1)),resolve" CMD3="$SOCAT $opts -lpwrapper tcp4-l:$((PORT+2)),reuseaddr,bind=$LOCALHOST,fork proxy:$LOCALHOST:$((PORT+3)),resolve\\|tcp4:$LOCALHOST:$((PORT+1))" # this is our double client in the protected network using SSL -#CMD4="$SOCAT $opts -lp2client ssl:$LOCALHOST:$((PORT+2)),pf=ip4,retry=10,intervall=1,cert=testcli.pem,cafile=testsrv.crt,$SOCAT_EGD tcp4:$LOCALHOST:$PORT" +#CMD4="$SOCAT $opts -lp2client ssl:$LOCALHOST:$((PORT+2)),pf=ip4,retry=10,interval=1,cert=testcli.pem,cafile=testsrv.crt,$SOCAT_EGD tcp4:$LOCALHOST:$PORT" #CMD4="$SOCAT $opts -lp2client ssl:$LOCALHOST:$((PORT+2)),pf=ip4,cert=testcli.pem,cafile=testsrv.crt,$SOCAT_EGD tcp4:$LOCALHOST:$PORT" CMD4="$SOCAT $opts -lp2client ssl,cert=testcli.pem,cafile=testsrv.crt,$SOCAT_EGD\|tcp4:$LOCALHOST:$((PORT+2)) tcp4:$LOCALHOST:$PORT" # this is the double server in the outside network @@ -5299,7 +5406,7 @@ NAME=UNIEXECEOF case "$TESTS" in *%functions%*|*%$NAME%*) TEST="$NAME: give exec'd write-only process a chance to flush (-u)" -testod "$N" "$TEST" "" exec:'od -c' "$opts -u" +testod "$N" "$TEST" "" exec:"$OD_C" "$opts -u" esac N=$((N+1)) @@ -5308,7 +5415,7 @@ NAME=REVEXECEOF case "$TESTS" in *%functions%*|*%$NAME%*) TEST="$NAME: give exec'd write-only process a chance to flush (-U)" -testod "$N" "$TEST" exec:'od -c' "-" "$opts -U" +testod "$N" "$TEST" exec:"$OD_C" "-" "$opts -U" esac N=$((N+1)) @@ -6050,7 +6157,10 @@ NAME=RAWIP6RECVFROM case "$TESTS" in *%functions%*|*%ip%*|*%ip6%*|*%rawip%*|*%rawip6%*|*%dgram%*|*%root%*|*%$NAME%*) TEST="$NAME: raw IPv6 datagram by self addressing" -if [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then +if ! feat=$(testaddrs ip6 rawip) || ! runsip6 >/dev/null; then + $PRINTF "test $F_n $TEST... ${YELLOW}$feat not available${NORMAL}\n" $N + numCANT=$((numCANT+1)) +elif [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then $PRINTF "test $F_n $TEST... ${YELLOW}must be root${NORMAL}\n" $N numCANT=$((numCANT+1)) else @@ -6278,7 +6388,7 @@ NAME=RAWIP6RECV case "$TESTS" in *%functions%*|*%ip6%*|*%dgram%*|*%rawip%*|*%rawip6%*|*%recv%*|*%root%*|*%$NAME%*) TEST="$NAME: raw IPv6 receive" -if ! feat=$(testaddrs ip6 rawip) || ! runsip4 >/dev/null; then +if ! feat=$(testaddrs ip6 rawip) || ! runsip6 >/dev/null; then $PRINTF "test $F_n $TEST... ${YELLOW}$feat not available${NORMAL}\n" $N numCANT=$((numCANT+1)) elif [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then @@ -6985,14 +7095,14 @@ N=$((N+1)) NAME=COOLWRITE case "$TESTS" in -*%functions%*|*%timeout%*|*%ignoreeof%*|*%$NAME%*) +*%functions%*|*%timeout%*|*%ignoreeof%*|*%coolwrite%*|*%$NAME%*) TEST="$NAME: option cool-write" if ! testoptions cool-write >/dev/null; then $PRINTF "test $F_n $TEST... ${YELLOW}option cool-write not available${NORMAL}\n" $N numCANT=$((numCANT+1)) else #set -vx -ti="$td/test$N.file" +ti="$td/test$N.pipe" tf="$td/test$N.stdout" te="$td/test$N.stderr" tdiff="$td/test$N.diff" @@ -7022,6 +7132,53 @@ esac N=$((N+1)) +# test if option coolwrite can be applied to bidirectional address stdio +# this failed up to socat 1.6.0.0 +NAME=COOLSTDIO +case "$TESTS" in +*%functions%*|*%timeout%*|*%ignoreeof%*|*%coolwrite%*|*%$NAME%*) +TEST="$NAME: option cool-write on bidirectional stdio" +# this test starts a socat reader that terminates after receiving one+ +# bytes (option readbytes); and a test process that sends two bytes via +# named pipe to the receiving process and, a second later, sends another +# byte. The last write will fail with "broken pipe"; if option coolwrite +# has been applied successfully, socat will terminate with 0 (OK), +# otherwise with error. +if ! testoptions cool-write >/dev/null; then + $PRINTF "test $F_n $TEST... ${YELLOW}option cool-write not available${NORMAL}\n" $N + numCANT=$((numCANT+1)) +else +#set -vx +ti="$td/test$N.pipe" +tf="$td/test$N.stdout" +te="$td/test$N.stderr" +tdiff="$td/test$N.diff" +da="$(date) $RANDOM" +# a reader that will terminate after 1 byte +CMD1="$SOCAT $opts -u pipe:\"$ti\",readbytes=1 /dev/null" +CMD="$SOCAT $opts -,cool-write pipe >\"$ti\"" +printf "test $F_n $TEST... " $N +$CMD1 2>"${te}1" & +bg=$! # background process id +sleep 1 +(echo .; sleep 1; echo) |eval "$CMD" 2>"$te" +rc=$? +kill $bg 2>/dev/null; wait +if [ $rc -ne 0 ]; then + $PRINTF "$FAILED: $SOCAT:\n" + echo "$CMD &" + cat "$te" + numFAIL=$((numFAIL+1)) +else + $PRINTF "$OK\n" + if [ -n "$debug" ]; then cat "$te"; fi + numOK=$((numOK+1)) +fi +fi # testoptions +esac +N=$((N+1)) + + # purpose of the shut-none option is to keep a shared socket # open. with shared we mean that two or more processes use it. usually, when a # process closes a socket, it performs a shutdown procedure with half close. @@ -7740,6 +7897,7 @@ touch "$ts" # make a file with same name, so non-abstract fails eval "$SRV 2>${te}s &" pids=$! #waitfile "$ts" +sleep 1 echo "$da1" |eval "$CMD" >"${tf}1" 2>"${te}1" if [ $? -ne 0 ]; then kill "$pids" 2>/dev/null @@ -7790,6 +7948,7 @@ printf "test $F_n $TEST... " $N touch "$ts1" # make a file with same name, so non-abstract fails $CMD1 2>"${te}1" & pid1="$!" +sleep 1 echo "$da" |$CMD2 >>"$tf" 2>>"${te}2" rc2=$? kill "$pid1" 2>/dev/null; wait @@ -7836,6 +7995,7 @@ touch "$ts1" # make a file with same name, so non-abstract fails $CMD1 >"$tf" 2>"${te}1" & pid1="$!" #waitfile $ts1 1 +sleep 1 echo "$da" |$CMD2 2>>"${te}2" rc2="$?" i=0; while [ ! -s "$tf" -a "$i" -lt 10 ]; do usleep 100000; i=$((i+1)); done @@ -7865,7 +8025,7 @@ N=$((N+1)) NAME=OPENSSLREAD # socat determined availability of data using select(). With openssl, the # following situation might occur: -# a SSL data block with more than 8192 bytes (socat defaults blocksize) +# a SSL data block with more than 8192 bytes (socats default blocksize) # arrives; socat calls SSL_read, and the SSL routine reads the complete block. # socat then reads 8192 bytes from the SSL layer, the rest remains buffered. # If the TCP connection stays idle for some time, the data in the SSL layer @@ -7894,7 +8054,9 @@ printf "test $F_n $TEST... " $N # $CMD1 2>"${te}1" >"$tf" & pid=$! # background process id +waittcp4port $PORT (echo "$da"; sleep 2) |$CMD2 2>"${te}2" +kill "$pid" 2>/dev/null; wait if ! echo "$da" |diff - "$tf" >"$tdiff"; then $PRINTF "$FAILED: $SOCAT:\n" echo "$CMD1" @@ -7909,6 +8071,7 @@ else numOK=$((numOK+1)) fi fi +wait ;; esac N=$((N+1)) @@ -7926,8 +8089,7 @@ TEST="$NAME: trigger EOF after that many bytes, even when socket idle" # we try to transfer data in the other direction then; if transfer succeeds, # the process did not terminate and the bug is still there. if false; then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not avail -able${NORMAL}\n" $N + $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N numCANT=$((numCANT+1)) else tr="$td/test$N.ref" @@ -7952,6 +8114,248 @@ fi esac N=$((N+1)) + +# test: there was a bug with exec:...,pty that did not kill the exec'd sub +# process under some circumstances. +NAME=EXECPTYKILL +case "$TESTS" in +*%functions%*|*%bugs%*|*%exec%*|*%$NAME%*) +TEST="$NAME: exec:...,pty explicitely kills sub process" +# we want to check if the exec'd sub process is kill in time +# for this we have a shell script that generates a file after two seconds; +# it should be killed after one second, so if the file was generated the test +# has failed +tf="$td/test$N.stdout" +te="$td/test$N.stderr" +ts="$td/test$N.sock" +tda="$td/test$N.data" +tsh="$td/test$N.sh" +tdiff="$td/test$N.diff" +cat >"$tsh" <"${te}2" & +pid1=$! +sleep 1 +waitfile $ts 1 +$CMD 2>>"${te}1" >>"$tf" +usleep 2500000 +kill "$pid1" 2>/dev/null +wait +if [ $? -ne 0 ]; then + $PRINTF "$FAILED: $SOCAT:\n" + echo "$CMD1 &" + echo "$CMD2" + cat "${te}1" "${te}2" + numFAIL=$((numFAIL+1)) +elif [ -f "$tda" ]; then + $PRINTF "$FAILED\n" + cat "${te}1" "${te}2" + numFAIL=$((numFAIL+1)) +else + $PRINTF "$OK\n" + if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi + numOK=$((numOK+1)) +fi ;; +esac +PORT=$((PORT+1)) +N=$((N+1)) + + +# test if service name resolution works; this was buggy in 1.5 and 1.6.0.0 +NAME=TCP4SERVICE +case "$TESTS" in +*%functions%*|*%ip4%*|*%ipapp%*|*%tcp%*|*%$NAME%*) +TEST="$NAME: echo via connection to TCP V4 socket" +# select a tcp entry from /etc/services, have a server listen on the port +# number and connect using the service name; with the bug, connection will to a +# wrong port +tf="$td/test$N.stdout" +te="$td/test$N.stderr" +tdiff="$td/test$N.diff" +# find a service entry we do not need root for (>=1024; here >=1100 for ease) +SERVENT="$(grep '^[a-z][a-z]*[^!-~][^!-~]*[1-9][1-9][0-9][0-9]/tcp' /etc/services |head -n 1)" +SERVICE="$(echo $SERVENT |cut -d' ' -f1)" +PORT="$(echo $SERVENT |sed 's/.* \([1-9][0-9]*\).*/\1/')" +tsl="$PORT" +ts="127.0.0.1:$SERVICE" +da=$(date) +CMD1="$SOCAT $opts TCP4-LISTEN:$tsl,reuseaddr PIPE" +CMD2="$SOCAT $opts stdout%stdin TCP4:$ts" +printf "test $F_n $TEST... " $N +$CMD1 >"$tf" 2>"${te}1" & +pid1=$! +waittcp4port $tsl 1 +echo "$da" |$CMD2 >>"$tf" 2>>"${te}2" +if [ $? -ne 0 ]; then + $PRINTF "$FAILED: $SOCAT:\n" + echo "$CMD1 &" + cat "${te}1" + echo "$CMD2" + cat "${te}2" + numFAIL=$((numFAIL+1)) +elif ! echo "$da" |diff - "$tf" >"$tdiff"; then + $PRINTF "$FAILED\n" + cat "$tdiff" + numFAIL=$((numFAIL+1)) +else + $PRINTF "$OK\n" + if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi + numOK=$((numOK+1)) +fi +kill $pid1 2>/dev/null +wait ;; +esac +#PORT=$((PORT+1)) +N=$((N+1)) + + +# test: up to socat 1.6.0.0, the highest file descriptor supported in socats +# transfer engine was FOPEN_MAX-1; this usually worked fine but would fail when +# socat was invoked with many file descriptors already opened. socat would +# just hang in the select() call. Thanks to Daniel Lucq for reporting this +# problem. +# FOPEN_MAX on different OS's: +# OS FOPEN_ ulimit ulimit FD_ +# MAX -H -n -S -n SETSIZE +# Linux 2.6: 16 1024 1024 1024 +# HP-UX 11.11: 60 2048 2048 2048 +# FreeBSD: 20 11095 11095 1024 +# Cygwin: 20 unlimit 256 64 +# AIX: 32767 65534 65534 +# SunOS 8: 20 1024 +NAME=EXCEED_FOPEN_MAX +case "$TESTS" in +*%functions%*|*%maxfds%*|*%$NAME%*) +TEST="$NAME: more than FOPEN_MAX FDs in use" +# this test opens a number of FDs before socat is invoked. socat will have to +# allocate higher FD numbers and thus hang if it cannot handle them. +REDIR= +#set -vx +FOPEN_MAX=$($PROCAN -c 2>/dev/null |grep '^#define[ ][ ]*FOPEN_MAX' |awk '{print($3);}') +if [ -z "$FOPEN_MAX" ]; then + $PRINTF "test $F_n $TEST... ${YELLOW}could not determine FOPEN_MAX${NORMAL}\n" "$N" + numCANT=$((numCANT+1)) +else +OPEN_FILES=$FOPEN_MAX # more than the highest FOPEN_MAX +i=3; while [ "$i" -lt "$OPEN_FILES" ]; do + REDIR="$REDIR $i>&2" + i=$((i+1)) +done +#echo "$REDIR" +#testecho "$N" "$TEST" "" "pipe" "$opts -T 3" "" 1 +#set -vx +eval testecho "\"$N\"" "\"$TEST\"" "\"\"" "pipe" "\"$opts -T 1\"" 1 $REDIR +#set +vx +fi # could determine FOPEN_MAX +esac +N=$((N+1)) + + +# there was a bug with udp-listen and fork: terminating sub processes became +# zombies because the master process did not catch SIGCHLD +NAME=UDP4LISTEN_SIGCHLD +case "$TESTS" in +*%functions%*|*%ip4%*|*%ipapp%*|*%udp%*|*%zombie%*|*%$NAME%*) +TEST="$NAME: test if UDP4-LISTEN child becomes zombie" +# idea: run a udp-listen process with fork and -T. Connect once, so a sub +# process is forked off. Make some transfer and wait until the -T timeout is +# over. Now check for the child process: if it is zombie the test failed. +# Correct is that child process terminated +tf="$td/test$N.stdout" +te="$td/test$N.stderr" +tdiff="$td/test$N.diff" +tsl=$PORT +ts="$LOCALHOST:$tsl" +da=$(date) +CMD1="$SOCAT $opts -T 0.5 UDP4-LISTEN:$tsl,reuseaddr,fork PIPE" +CMD2="$SOCAT $opts - UDP4:$ts" +printf "test $F_n $TEST... " $N +$CMD1 >"$tf" 2>"${te}1" & +pid1=$! +waitudp4port $tsl 1 +echo "$da" |$CMD2 >>"$tf" 2>>"${te}2" +rc2=$? +sleep 1 +#read -p ">" +l="$(childprocess $pid1)" +kill $pid1 2>/dev/null; wait +if [ $rc2 -ne 0 ]; then + $PRINTF "$NO_RESULT\n" # already handled in test UDP4STREAM + numCANT=$((numCANT+1)) +elif ! echo "$da" |diff - "$tf" >"$tdiff"; then + $PRINTF "$NO_RESULT\n" # already handled in test UDP4STREAM + numCANT=$((numCANT+1)) +elif $(isdefunct "$l"); then + $PRINTF "$FAILED: $SOCAT:\n" + echo "$CMD1 &" + echo "$CMD2" + cat "${te}1" "${te}2" + numFAIL=$((numFAIL+1)) +else + $PRINTF "$OK\n" + if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi + numOK=$((numOK+1)) +fi ;; +esac +PORT=$((PORT+1)) +N=$((N+1)) + + +# there was a bug with udp-recvfrom and fork: terminating sub processes became +# zombies because the master process caught SIGCHLD but did not wait() +NAME=UDP4RECVFROM_SIGCHLD +case "$TESTS" in +*%functions%*|*%ip4%*|*%udp%*|*%dgram%*|*%zombie%*|*%$NAME%*) +TEST="$NAME: test if UDP4-RECVFROM child becomes zombie" +# idea: run a udp-recvfrom process with fork and -T. Sent it one packet, so a +# sub process is forked off. Make some transfer and wait until the -T timeout +# is over. Now check for the child process: if it is zombie the test failed. +# Correct is that child process terminated +tf="$td/test$N.stdout" +te="$td/test$N.stderr" +tdiff="$td/test$N.diff" +tsl=$PORT +ts="$LOCALHOST:$tsl" +da=$(date) +CMD1="$SOCAT $opts -T 0.5 UDP4-RECVFROM:$tsl,reuseaddr,fork PIPE" +CMD2="$SOCAT $opts - UDP4-SENDTO:$ts" +printf "test $F_n $TEST... " $N +$CMD1 >"$tf" 2>"${te}1" & +pid1=$! +waitudp4port $tsl 1 +echo "$da" |$CMD2 >>"$tf" 2>>"${te}2" +rc2=$? +sleep 1 +#read -p ">" +l="$(childprocess $pid1)" +kill $pid1 2>/dev/null; wait +if [ $rc2 -ne 0 ]; then + $PRINTF "$NO_RESULT\n" # already handled in test UDP4DGRAM + numCANT=$((numCANT+1)) +elif ! echo "$da" |diff - "$tf" >"$tdiff"; then + $PRINTF "$NO_RESULT\n" # already handled in test UDP4DGRAMM + numCANT=$((numCANT+1)) +elif $(isdefunct "$l"); then + $PRINTF "$FAILED: $SOCAT:\n" + echo "$CMD1 &" + echo "$CMD2" + cat "${te}1" "${te}2" + numFAIL=$((numFAIL+1)) +else + $PRINTF "$OK\n" + if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi + numOK=$((numOK+1)) +fi ;; +esac +PORT=$((PORT+1)) +N=$((N+1)) + + echo "summary: $((N-1)) tests; $numOK ok, $numFAIL failed, $numCANT could not be performed" if [ "$numFAIL" -gt 0 ]; then diff --git a/utils.c b/utils.c index e2d6824..eeca60c 100644 --- a/utils.c +++ b/utils.c @@ -1,4 +1,4 @@ -/* $Id: utils.c,v 1.17 2007/02/08 18:36:16 gerhard Exp $ */ +/* source: utils.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/utils.h b/utils.h index c974a41..4488358 100644 --- a/utils.h +++ b/utils.h @@ -1,4 +1,4 @@ -/* $Id: utils.h,v 1.7 2007/02/08 18:36:16 gerhard Exp $ */ +/* source: utils.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ascii.c b/xio-ascii.c index 4ebe0d2..88909dc 100644 --- a/xio-ascii.c +++ b/xio-ascii.c @@ -1,4 +1,4 @@ -/* $Id: xio-ascii.c,v 1.5 2006/07/23 07:30:46 gerhard Exp $ */ +/* source: xio-ascii.c */ /* Copyright Gerhard Rieger 2002-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ascii.h b/xio-ascii.h index bc4735d..875623d 100644 --- a/xio-ascii.h +++ b/xio-ascii.h @@ -1,4 +1,4 @@ -/* $Id: xio-ascii.h,v 1.4 2006/07/23 07:30:49 gerhard Exp $ */ +/* source: xio-ascii.h */ /* Copyright Gerhard Rieger 2002-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-creat.c b/xio-creat.c index 2f26cc9..a5eafc0 100644 --- a/xio-creat.c +++ b/xio-creat.c @@ -1,4 +1,4 @@ -/* $Id: xio-creat.c,v 1.16.2.1 2006/07/24 19:17:32 gerhard Exp $ */ +/* source: xio-creat.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-creat.h b/xio-creat.h index 94b4c34..5a285a3 100644 --- a/xio-creat.h +++ b/xio-creat.h @@ -1,4 +1,4 @@ -/* $Id: xio-creat.h,v 1.4.2.1 2006/07/24 19:17:34 gerhard Exp $ */ +/* source: xio-creat.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-exec.c b/xio-exec.c index 6f0300f..2fb3d83 100644 --- a/xio-exec.c +++ b/xio-exec.c @@ -1,4 +1,4 @@ -/* $Id: xio-exec.c,v 1.19.2.1 2006/07/24 19:17:35 gerhard Exp $ */ +/* source: xio-exec.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-exec.h b/xio-exec.h index 3a70212..d70a140 100644 --- a/xio-exec.h +++ b/xio-exec.h @@ -1,4 +1,4 @@ -/* $Id: xio-exec.h,v 1.6.2.1 2006/07/24 19:17:37 gerhard Exp $ */ +/* source: xio-exec.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ext2.c b/xio-ext2.c index 6082190..46229b3 100644 --- a/xio-ext2.c +++ b/xio-ext2.c @@ -1,4 +1,4 @@ -/* $Id: xio-ext2.c,v 1.1 2006/05/07 17:06:53 gerhard Exp $ */ +/* source: xio-ext2.c */ /* Copyright Gerhard Rieger 2005-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ext2.h b/xio-ext2.h index a7571c4..02d18a4 100644 --- a/xio-ext2.h +++ b/xio-ext2.h @@ -1,4 +1,4 @@ -/* $Id: xio-ext2.h,v 1.2 2006/05/31 19:28:24 gerhard Exp $ */ +/* source: xio-ext2.h */ /* Copyright Gerhard Rieger 2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-fd.c b/xio-fd.c index 5915583..af12446 100644 --- a/xio-fd.c +++ b/xio-fd.c @@ -1,4 +1,4 @@ -/* $Id: xio-fd.c,v 1.26 2006/12/28 07:35:50 gerhard Exp $ */ +/* source: xio-fd.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-fd.h b/xio-fd.h index 38b22d0..b08bd5e 100644 --- a/xio-fd.h +++ b/xio-fd.h @@ -1,4 +1,4 @@ -/* $Id: xio-fd.h,v 1.12 2006/12/28 07:35:50 gerhard Exp $ */ +/* source: xio-fd.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-fdnum.c b/xio-fdnum.c index 25bf91f..1b8143e 100644 --- a/xio-fdnum.c +++ b/xio-fdnum.c @@ -1,4 +1,4 @@ -/* $Id: xio-fdnum.c,v 1.13.2.1 2006/07/24 19:17:38 gerhard Exp $ */ +/* source: xio-fdnum.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-fdnum.h b/xio-fdnum.h index 88c4e95..a172dd6 100644 --- a/xio-fdnum.h +++ b/xio-fdnum.h @@ -1,4 +1,4 @@ -/* $Id: xio-fdnum.h,v 1.6.2.1 2006/07/24 19:17:40 gerhard Exp $ */ +/* source: xio-fdnum.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-file.c b/xio-file.c index 303a1fa..626b856 100644 --- a/xio-file.c +++ b/xio-file.c @@ -1,4 +1,4 @@ -/* $Id: xio-file.c,v 1.21 2007/03/06 21:07:25 gerhard Exp $ */ +/* source: xio-file.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-file.h b/xio-file.h index eba1ae4..b372771 100644 --- a/xio-file.h +++ b/xio-file.h @@ -1,4 +1,4 @@ -/* $Id: xio-file.h,v 1.8.2.1 2006/07/24 19:17:44 gerhard Exp $ */ +/* source: xio-file.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-gopen.c b/xio-gopen.c index 8d3fa66..6557019 100644 --- a/xio-gopen.c +++ b/xio-gopen.c @@ -1,4 +1,4 @@ -/* $Id: xio-gopen.c,v 1.32 2007/02/08 18:36:44 gerhard Exp $ */ +/* source: xio-gopen.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-gopen.h b/xio-gopen.h index 2b51ef7..543ea26 100644 --- a/xio-gopen.h +++ b/xio-gopen.h @@ -1,4 +1,4 @@ -/* $Id: xio-gopen.h,v 1.4.2.1 2006/07/24 19:17:49 gerhard Exp $ */ +/* source: xio-gopen.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ip.c b/xio-ip.c index cb065dc..df5a5b6 100644 --- a/xio-ip.c +++ b/xio-ip.c @@ -1,5 +1,5 @@ -/* $Id: xio-ip.c,v 1.31 2007/03/06 21:08:02 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-ip.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for IP related functions */ @@ -113,7 +113,7 @@ int xiogetaddrinfo(const char *node, const char *service, int family, int socktype, int protocol, union sockaddr_union *sau, socklen_t *socklen, unsigned long res_opts0, unsigned long res_opts1) { - int port = -1; + int port = -1; /* port number in network byte order */ char *numnode = NULL; size_t nodelen; unsigned long save_res_opts = 0; @@ -144,7 +144,7 @@ int xiogetaddrinfo(const char *node, const char *service, with NIS), so we handle this specially */ if (service && isdigit(service[0]&0xff)) { char *extra; - port = strtoul(service, &extra, 0); + port = htons(strtoul(service, &extra, 0)); if (*extra != '\0') { Warn2("xiogetaddrinfo(, \"%s\", ...): extra trailing data \"%s\"", service, extra); @@ -230,6 +230,7 @@ int xiogetaddrinfo(const char *node, const char *service, #endif return STAT_RETRYLATER; } + service = NULL; /* do not resolve later again */ record = res; if (family == PF_UNSPEC && xioopts.preferred_ip == '0') { @@ -396,15 +397,15 @@ int xiogetaddrinfo(const char *node, const char *service, #if WITH_TCP || WITH_UDP if (service) { - port = parseport(service, family); + port = parseport(service, protocol); } if (port >= 0) { switch (family) { #if WITH_IP4 - case PF_INET: sau->ip4.sin_port = htons(port); break; + case PF_INET: sau->ip4.sin_port = port; break; #endif /* WITH_IP4 */ #if WITH_IP6 - case PF_INET6: sau->ip6.sin6_port = htons(port); break; + case PF_INET6: sau->ip6.sin6_port = port; break; #endif /* WITH_IP6 */ } } diff --git a/xio-ip.h b/xio-ip.h index 2cf8277..4d68012 100644 --- a/xio-ip.h +++ b/xio-ip.h @@ -1,4 +1,4 @@ -/* $Id: xio-ip.h,v 1.11 2007/03/06 21:19:18 gerhard Exp $ */ +/* source: xio-ip.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ip4.c b/xio-ip4.c index 29e121a..6e8ff23 100644 --- a/xio-ip4.c +++ b/xio-ip4.c @@ -1,4 +1,4 @@ -/* $Id: xio-ip4.c,v 1.13 2007/03/06 21:08:38 gerhard Exp $ */ +/* source: xio-ip4.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ip4.h b/xio-ip4.h index 5af6e23..9357dcc 100644 --- a/xio-ip4.h +++ b/xio-ip4.h @@ -1,4 +1,4 @@ -/* $Id: xio-ip4.h,v 1.9 2007/03/06 21:19:18 gerhard Exp $ */ +/* source: xio-ip4.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ip6.c b/xio-ip6.c index 78a233f..0bf8577 100644 --- a/xio-ip6.c +++ b/xio-ip6.c @@ -1,4 +1,4 @@ -/* $Id: xio-ip6.c,v 1.31 2007/03/06 21:19:18 gerhard Exp $ */ +/* source: xio-ip6.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ip6.h b/xio-ip6.h index 2c5b809..431d4d1 100644 --- a/xio-ip6.h +++ b/xio-ip6.h @@ -1,4 +1,4 @@ -/* $Id: xio-ip6.h,v 1.13 2007/03/06 21:19:18 gerhard Exp $ */ +/* source: xio-ip6.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-ipapp.c b/xio-ipapp.c index d6a5c62..75d8d09 100644 --- a/xio-ipapp.c +++ b/xio-ipapp.c @@ -1,5 +1,5 @@ -/* $Id: xio-ipapp.c,v 1.34 2007/02/08 18:27:00 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-ipapp.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for TCP and UDP related options */ @@ -55,6 +55,10 @@ int xioopen_ipapp_connect(int argc, const char *argv[], struct opt *opts, return STAT_NORETRY; } + if (dofork) { + xiosetchilddied(); /* set SIGCHLD handler */ + } + if (xioopts.logopt == 'm') { Info("starting connect loop, switching to syslog"); diag_set('y', xioopts.syslogfac); xioopts.logopt = 'y'; diff --git a/xio-ipapp.h b/xio-ipapp.h index 9d44407..ce5ece1 100644 --- a/xio-ipapp.h +++ b/xio-ipapp.h @@ -1,4 +1,4 @@ -/* $Id: xio-ipapp.h,v 1.13 2006/05/19 05:54:39 gerhard Exp $ */ +/* source: xio-ipapp.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-listen.c b/xio-listen.c index abcb152..ec4e95c 100644 --- a/xio-listen.c +++ b/xio-listen.c @@ -1,5 +1,5 @@ -/* $Id: xio-listen.c,v 1.44 2007/02/08 18:27:00 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-listen.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for listen socket options */ @@ -115,6 +115,10 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl if (applyopts_single(xfd, opts, PH_INIT) < 0) return -1; + if (dofork) { + xiosetchilddied(); /* set SIGCHLD handler */ + } + if ((xfd->fd1 = Socket(pf, socktype, proto)) < 0) { Msg4(level, "socket(%d, %d, %d): %s", pf, socktype, proto, strerror(errno)); diff --git a/xio-listen.h b/xio-listen.h index 7c2adf2..24303c1 100644 --- a/xio-listen.h +++ b/xio-listen.h @@ -1,4 +1,4 @@ -/* $Id: xio-listen.h,v 1.10 2006/07/13 06:44:53 gerhard Exp $ */ +/* source: xio-listen.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-named.c b/xio-named.c index ead5333..892cc96 100644 --- a/xio-named.c +++ b/xio-named.c @@ -1,5 +1,5 @@ -/* $Id: xio-named.c,v 1.28 2007/03/06 21:09:01 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-named.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for filesystem entry functions */ @@ -22,7 +22,7 @@ const struct optdesc opt_unlink_early= { "unlink-early",NULL, OPT_UNLINK_EARLY,G const struct optdesc opt_unlink_late = { "unlink-late", NULL, OPT_UNLINK_LATE, GROUP_NAMED, PH_PASTOPEN, TYPE_BOOL, OFUNC_SPEC }; const struct optdesc opt_unlink_close = { "unlink-close", NULL, OPT_UNLINK_CLOSE, GROUP_NAMED, PH_LATE, TYPE_BOOL, OFUNC_SPEC }; const struct optdesc opt_umask = { "umask", NULL, OPT_UMASK, GROUP_NAMED, PH_EARLY, TYPE_MODET, OFUNC_SPEC }; -#endif /* _WITH_NAMED */ +#endif /* WITH_NAMED */ /* applies to fd all options belonging to phase */ int applyopts_named(const char *filename, struct opt *opts, unsigned int phase) { @@ -213,4 +213,4 @@ int _xioopen_open(const char *path, int rw, struct opt *opts) { return fd; } -#endif /* WITH_NAMED */ +#endif /* _WITH_NAMED */ diff --git a/xio-named.h b/xio-named.h index e3db995..87dda76 100644 --- a/xio-named.h +++ b/xio-named.h @@ -1,4 +1,4 @@ -/* $Id: xio-named.h,v 1.8 2006/03/18 20:04:31 gerhard Exp $ */ +/* source: xio-named.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-openssl.c b/xio-openssl.c index c396675..2034c49 100644 --- a/xio-openssl.c +++ b/xio-openssl.c @@ -1,5 +1,5 @@ -/* $Id: xio-openssl.c,v 1.33 2007/02/26 21:31:40 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2002-2007 */ +/* source: xio-openssl.c */ +/* Copyright Gerhard Rieger 2002-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the implementation of the openssl addresses */ @@ -377,6 +377,10 @@ static int default: return STAT_NORETRY; } + if (dofork) { + xiosetchilddied(); /* set SIGCHLD handler */ + } + #if WITH_RETRY if (dofork) { pid_t pid; diff --git a/xio-openssl.h b/xio-openssl.h index 4d1d2f7..5545ec6 100644 --- a/xio-openssl.h +++ b/xio-openssl.h @@ -1,4 +1,4 @@ -/* $Id: xio-openssl.h,v 1.8 2007/02/26 21:31:40 gerhard Exp $ */ +/* source: xio-openssl.h */ /* Copyright Gerhard Rieger 2002-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-pipe.c b/xio-pipe.c index ea42657..50c4fb6 100644 --- a/xio-pipe.c +++ b/xio-pipe.c @@ -1,5 +1,5 @@ -/* $Id: xio-pipe.c,v 1.24 2007/01/25 21:36:11 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-pipe.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses of pipe type */ @@ -79,7 +79,7 @@ static int xioopen_fifo0(int argc, const char *argv[], struct opt *opts, int xio } -/* open a named pipe/fifo */ +/* open a named or unnamed pipe/fifo */ static int xioopen_fifo1(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *fd, unsigned groups, int dummy1, int dummy2, int dummy3) { const char *pipename = argv[1]; int rw = (xioflags & XIO_ACCMODE); diff --git a/xio-pipe.h b/xio-pipe.h index fc7efad..41d0eba 100644 --- a/xio-pipe.h +++ b/xio-pipe.h @@ -1,4 +1,4 @@ -/* $Id: xio-pipe.h,v 1.4.2.1 2006/07/24 19:18:02 gerhard Exp $ */ +/* source: xio-pipe.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-process.c b/xio-process.c index 1b7960e..246c47a 100644 --- a/xio-process.c +++ b/xio-process.c @@ -1,4 +1,4 @@ -/* $Id: xio-process.c,v 1.9 2003/05/21 05:16:38 gerhard Exp $ */ +/* source: xio-process.c */ /* Copyright Gerhard Rieger 2001-2003 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-process.h b/xio-process.h index 928b6f9..4a80928 100644 --- a/xio-process.h +++ b/xio-process.h @@ -1,4 +1,4 @@ -/* $Id: xio-process.h,v 1.7 2002/10/01 19:37:51 gerhard Exp $ */ +/* source: xio-process.h */ /* Copyright Gerhard Rieger 2001, 2002 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-progcall.c b/xio-progcall.c index 1633253..27b62a5 100644 --- a/xio-progcall.c +++ b/xio-progcall.c @@ -1,5 +1,5 @@ -/* $Id: xio-progcall.c,v 1.54 2007/03/06 21:11:55 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-progcall.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains common code dealing with program calls (exec, system) */ @@ -941,6 +941,8 @@ int _xioopen_foxec_end(int xioflags, /* XIO_RDONLY etc. */ return STAT_RETRYLATER; } applyopts_cloexec(ptyfd, popts);/*!*/ + + /* exec:...,pty did not kill child process under some circumstances */ if (fd->howtoshut == XIOSHUT_UNSPEC) { fd->howtoshut = XIOSHUTRD_SIGTERM|XIOSHUTWR_SIGHUP; } @@ -1077,11 +1079,8 @@ int _xioopen_foxec_end(int xioflags, /* XIO_RDONLY etc. */ /*0 if ((optpr = copyopts(*copts, GROUP_PROCESS)) == NULL) return STAT_RETRYLATER;*/ retropt_bool(*copts, OPT_STDERR, &withstderr); -#if 0 - if (Signal(SIGCHLD, childdied) == SIG_ERR) { - Warn2("signal(SIGCHLD, %p): %s", childdied, strerror(errno)); - } -#endif + + xiosetchilddied(); /* set SIGCHLD handler */ if (withfork) { const char *forkwaitstring; diff --git a/xio-progcall.h b/xio-progcall.h index 3254a1c..2910d31 100644 --- a/xio-progcall.h +++ b/xio-progcall.h @@ -1,4 +1,4 @@ -/* $Id: xio-progcall.h,v 1.13 2006/02/08 19:37:15 gerhard Exp $ */ +/* source: xio-progcall.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-proxy.c b/xio-proxy.c index 5af454c..f262e52 100644 --- a/xio-proxy.c +++ b/xio-proxy.c @@ -1,5 +1,5 @@ -/* $Id: xio-proxy.c,v 1.28 2006/12/28 14:02:54 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2002-2007 */ +/* source: xio-proxy.c */ +/* Copyright Gerhard Rieger 2002-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses of HTTP proxy CONNECT @@ -255,6 +255,10 @@ static int xioopen_proxy_connect3(int argc, const char *argv[], struct opt *opts return result; } + if (dofork) { + xiosetchilddied(); /* set SIGCHLD handler */ + } + #if WITH_RETRY if (dofork) { pid_t pid; diff --git a/xio-proxy.h b/xio-proxy.h index cc9e852..a6744fa 100644 --- a/xio-proxy.h +++ b/xio-proxy.h @@ -1,4 +1,4 @@ -/* $Id: xio-proxy.h,v 1.6.2.1 2006/07/24 19:18:10 gerhard Exp $ */ +/* source: xio-proxy.h */ /* Copyright Gerhard Rieger 2002-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-pty.c b/xio-pty.c index 7c44964..0fae9b3 100644 --- a/xio-pty.c +++ b/xio-pty.c @@ -1,5 +1,5 @@ -/* $Id: xio-pty.c,v 1.20 2007/01/25 21:36:11 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2002-2007 */ +/* source: xio-pty.c */ +/* Copyright Gerhard Rieger 2002-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for creating pty addresses */ @@ -34,7 +34,7 @@ const union xioaddr_desc* xioaddrs_pty[] = { const struct optdesc opt_symbolic_link = { "symbolic-link", "link", OPT_SYMBOLIC_LINK, GROUP_PTY, PH_LATE, TYPE_FILENAME, OFUNC_SPEC, 0, 0 }; #if HAVE_POLL const struct optdesc opt_pty_wait_slave = { "pty-wait-slave", "wait-slave", OPT_PTY_WAIT_SLAVE, GROUP_PTY, PH_EARLY, TYPE_BOOL, OFUNC_SPEC, 0, 0 }; -const struct optdesc opt_pty_intervall = { "pty-intervall", NULL, OPT_PTY_INTERVALL, GROUP_PTY, PH_EARLY, TYPE_TIMESPEC, OFUNC_SPEC, 0, 0 }; +const struct optdesc opt_pty_intervall = { "pty-interval", NULL, OPT_PTY_INTERVALL, GROUP_PTY, PH_EARLY, TYPE_TIMESPEC, OFUNC_SPEC, 0, 0 }; #endif /* HAVE_POLL */ static int xioopen_pty0(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, unsigned groups, int dummy1, int dummy2, int dummy3) { diff --git a/xio-pty.h b/xio-pty.h index 0c93eff..1f87506 100644 --- a/xio-pty.h +++ b/xio-pty.h @@ -1,4 +1,4 @@ -/* $Id: xio-pty.h,v 1.2.2.1 2006/07/24 19:18:15 gerhard Exp $ */ +/* source: xio-pty.h */ /* Copyright Gerhard Rieger 2002-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-rawip.c b/xio-rawip.c index bf1d3f5..c28c152 100644 --- a/xio-rawip.c +++ b/xio-rawip.c @@ -1,5 +1,5 @@ -/* $Id: xio-rawip.c,v 1.32 2007/02/05 19:56:34 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-rawip.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses of raw IP type */ @@ -29,7 +29,7 @@ int xioopen_rawip_datagram(int argc, const char *argv[], struct opt *opts, static int xioopen_rawip_recvfrom(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, unsigned groups, - int pf, int dummy2, int dummy3); + int pf, int socktype, int dummy3); static int xioopen_rawip_recv(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, unsigned groups, @@ -262,11 +262,12 @@ int xioopen_rawip_recvfrom(int argc, const char *argv[], struct opt *opts, static int xioopen_rawip_recv(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, unsigned groups, - int pf, int socktype, int ipproto) { + int pf, int socktype, int dummy3) { const char *protname = argv[1]; char *garbage; union sockaddr_union us; socklen_t uslen = sizeof(us); + int ipproto; int result; if (argc != 2) { @@ -276,11 +277,11 @@ int xioopen_rawip_recv(int argc, const char *argv[], struct opt *opts, } if ((ipproto = strtoul(protname, &garbage, 0)) >= 256) { - Error2("xioopen_rawip_recvfrom(\"%s\",,): protocol number exceeds 255 (%u)", + Error2("xioopen_rawip_recv(\"%s\",,): protocol number exceeds 255 (%u)", protname, ipproto); return STAT_NORETRY; } else if (*garbage) { - Warn1("xioopen_rawip_recvfrom(\"%s\",,): trailing garbage in protocol specification", + Warn1("xioopen_rawip_recv(\"%s\",,): trailing garbage in protocol specification", protname); /*return STAT_NORETRY;*/ } diff --git a/xio-rawip.h b/xio-rawip.h index 4de5688..5b50211 100644 --- a/xio-rawip.h +++ b/xio-rawip.h @@ -1,4 +1,4 @@ -/* $Id: xio-rawip.h,v 1.13 2007/02/05 19:56:34 gerhard Exp $ */ +/* source: xio-rawip.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-readline.c b/xio-readline.c index 8c27ad1..c8c7dd8 100644 --- a/xio-readline.c +++ b/xio-readline.c @@ -1,4 +1,4 @@ -/* $Id: xio-readline.c,v 1.17 2007/01/25 21:36:11 gerhard Exp $ */ +/* source: xio-readline.c */ /* Copyright Gerhard Rieger 2002-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-readline.h b/xio-readline.h index 16e006d..54aa78b 100644 --- a/xio-readline.h +++ b/xio-readline.h @@ -1,4 +1,4 @@ -/* $Id: xio-readline.h,v 1.4.2.1 2006/07/24 19:18:24 gerhard Exp $ */ +/* source: xio-readline.h */ /* Copyright Gerhard Rieger 2002-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-socket.c b/xio-socket.c index c2e46cb..ae632c6 100644 --- a/xio-socket.c +++ b/xio-socket.c @@ -1,5 +1,5 @@ -/* $Id: xio-socket.c,v 1.45 2007/03/06 21:12:09 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-socket.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for socket related functions */ @@ -402,6 +402,10 @@ int xioopen_connect(struct single *xfd, struct sockaddr *us, size_t uslen, return result; } + if (dofork) { + xiosetchilddied(); /* set SIGCHLD handler */ + } + #if WITH_RETRY if (dofork) { pid_t pid; @@ -509,9 +513,37 @@ int _xioopen_dgram_sendto(/* them is already in xfd->peersa */ static pid_t xio_waitingfor; static bool xio_hashappened; void xiosigaction_hasread(int signum, siginfo_t *siginfo, void *ucontext) { + pid_t pid; + int _errno; + int status = 0; + bool wassig = false; Debug5("xiosigaction_hasread(%d, {%d,%d,%d,"F_pid"}, )", signum, siginfo->si_signo, siginfo->si_errno, siginfo->si_code, siginfo->si_pid); + _errno = errno; + do { + pid = Waitpid(-1, &status, WNOHANG); + if (pid == 0) { + Msg(wassig?E_INFO:E_WARN, + "waitpid(-1, {}, WNOHANG): no child has exited"); + Info("childdied() finished"); + errno = _errno; + return; + } else if (pid < 0 && errno == ECHILD) { + Msg1(wassig?E_INFO:E_WARN, + "waitpid(-1, {}, WNOHANG): %s", strerror(errno)); + Info("childdied() finished"); + errno = _errno; + return; + } + wassig = true; + if (pid < 0) { + Warn2("waitpid(-1, {%d}, WNOHANG): %s", status, strerror(errno)); + Info("childdied() finished"); + errno = _errno; + return; + } + } while (1); if (xio_waitingfor == siginfo->si_pid) { xio_hashappened = true; } diff --git a/xio-socket.h b/xio-socket.h index 422a906..d218357 100644 --- a/xio-socket.h +++ b/xio-socket.h @@ -1,4 +1,4 @@ -/* $Id: xio-socket.h,v 1.16 2006/12/30 23:04:21 gerhard Exp $ */ +/* source: xio-socket.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-socks.c b/xio-socks.c index 4bdfde2..3e8a403 100644 --- a/xio-socks.c +++ b/xio-socks.c @@ -1,5 +1,5 @@ -/* $Id: xio-socks.c,v 1.33 2006/12/28 14:06:37 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-socks.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses of socks4 type */ @@ -206,6 +206,10 @@ static int xioopen_socks4_connect(int argc, const char *argv[], struct opt *opts return result; } + if (dofork) { + xiosetchilddied(); /* set SIGCHLD handler */ + } + #if WITH_RETRY if (dofork) { pid_t pid; diff --git a/xio-socks.h b/xio-socks.h index fa312a2..0d52491 100644 --- a/xio-socks.h +++ b/xio-socks.h @@ -1,4 +1,4 @@ -/* $Id: xio-socks.h,v 1.6.2.1 2006/07/24 19:18:30 gerhard Exp $ */ +/* source: xio-socks.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-stdio.c b/xio-stdio.c index ae172f6..2528aea 100644 --- a/xio-stdio.c +++ b/xio-stdio.c @@ -1,5 +1,5 @@ -/* $Id: xio-stdio.c,v 1.18 2006/12/28 14:07:01 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-stdio.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses stdio type */ @@ -34,8 +34,7 @@ const union xioaddr_desc *xioaddrs_stdout[] = { const union xioaddr_desc *xioaddrs_stderr[] = { (union xioaddr_desc *)&xioaddr_stderr0, NULL }; -/* process a bidirectional "stdio" or "-" argument with options. - generate a dual address. */ +/* process a bidirectional "stdio" or "-" argument with options. */ int xioopen_stdio_bi(xiofile_t *sock) { struct opt *opts1, *opts2, *optspr; unsigned int groups1 = xioaddr_stdio0.groups, groups2 = xioaddr_stdio0.groups; @@ -68,8 +67,8 @@ int xioopen_stdio_bi(xiofile_t *sock) { } } #endif /* WITH_TERMIOS */ - - if (applyopts_single(&sock->stream, sock->stream.opts, PH_INIT) < 0) return -1; + if (applyopts_single(&sock->stream, sock->stream.opts, PH_INIT) < 0) + return -1; applyopts(-1, sock->stream.opts, PH_INIT); /* options here are one-time and one-direction, no second use */ diff --git a/xio-stdio.h b/xio-stdio.h index e70f160..3a1fc98 100644 --- a/xio-stdio.h +++ b/xio-stdio.h @@ -1,4 +1,4 @@ -/* $Id: xio-stdio.h,v 1.5.2.1 2006/07/24 19:18:35 gerhard Exp $ */ +/* source: xio-stdio.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-system.c b/xio-system.c index ced0396..6bff074 100644 --- a/xio-system.c +++ b/xio-system.c @@ -1,5 +1,5 @@ -/* $Id: xio-system.c,v 1.13.2.1 2006/07/24 19:18:36 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-system.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses of system type */ @@ -58,6 +58,7 @@ static int xioopen_system(int argc, const char *argv[], struct opt *opts, result = System(string); if (result != 0) { Warn2("system(\"%s\") returned with status %d", string, result); + Warn1("system(): %s", strerror(errno)); } Exit(0); /* this child process */ } diff --git a/xio-system.h b/xio-system.h index 6668d55..9a20a8f 100644 --- a/xio-system.h +++ b/xio-system.h @@ -1,4 +1,4 @@ -/* $Id: xio-system.h,v 1.4.2.1 2006/07/24 19:18:38 gerhard Exp $ */ +/* source: xio-system.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-tcp.c b/xio-tcp.c index bed01af..2069f33 100644 --- a/xio-tcp.c +++ b/xio-tcp.c @@ -1,4 +1,4 @@ -/* $Id: xio-tcp.c,v 1.24.2.1 2006/07/24 19:18:39 gerhard Exp $ */ +/* source: xio-tcp.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-tcp.h b/xio-tcp.h index 927fbaf..755d1c8 100644 --- a/xio-tcp.h +++ b/xio-tcp.h @@ -1,4 +1,4 @@ -/* $Id: xio-tcp.h,v 1.12.2.1 2006/07/24 19:18:42 gerhard Exp $ */ +/* source: xio-tcp.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-tcpwrap.c b/xio-tcpwrap.c index cb05757..a81800f 100644 --- a/xio-tcpwrap.c +++ b/xio-tcpwrap.c @@ -1,4 +1,4 @@ -/* $Id: xio-tcpwrap.c,v 1.4 2007/02/05 19:48:00 gerhard Exp $ */ +/* source: xio-tcpwrap.c */ /* Copyright Gerhard Rieger 2006-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-tcpwrap.h b/xio-tcpwrap.h index aaffc98..1a715b9 100644 --- a/xio-tcpwrap.h +++ b/xio-tcpwrap.h @@ -1,4 +1,4 @@ -/* $Id: xio-tcpwrap.h,v 1.1 2006/05/12 21:00:00 gerhard Exp $ */ +/* source: xio-tcpwrap.h */ /* Copyright Gerhard Rieger 2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-termios.c b/xio-termios.c index ff07001..04e46f3 100644 --- a/xio-termios.c +++ b/xio-termios.c @@ -1,4 +1,4 @@ -/* $Id: xio-termios.c,v 1.18 2006/07/13 06:49:37 gerhard Exp $ */ +/* source: xio-termios.c */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-termios.h b/xio-termios.h index 8023346..00e7118 100644 --- a/xio-termios.h +++ b/xio-termios.h @@ -1,4 +1,4 @@ -/* $Id: xio-termios.h,v 1.11 2006/05/31 19:23:43 gerhard Exp $ */ +/* source: xio-termios.h */ /* Copyright Gerhard Rieger 2001-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-tun.c b/xio-tun.c index 1091443..2f989ca 100644 --- a/xio-tun.c +++ b/xio-tun.c @@ -1,4 +1,4 @@ -/* $Id: xio-tun.c,v 1.2 2007/03/06 21:13:35 gerhard Exp $ */ +/* source: xio-tun.c */ /* Copyright Gerhard Rieger 2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-tun.h b/xio-tun.h index 2c25e6a..cb74dc1 100644 --- a/xio-tun.h +++ b/xio-tun.h @@ -1,4 +1,4 @@ -/* $Id: xio-tun.h,v 1.2 2007/03/06 21:19:18 gerhard Exp $ */ +/* source: xio-tun.h */ /* Copyright Gerhard Rieger 2006-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-udp.c b/xio-udp.c index 4a744bf..9e964af 100644 --- a/xio-udp.c +++ b/xio-udp.c @@ -1,5 +1,5 @@ -/* $Id: xio-udp.c,v 1.36 2007/02/08 18:27:00 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio-udp.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for handling UDP addresses */ @@ -183,6 +183,10 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts, } retropt_bool(opts, OPT_LOWPORT, &fd->stream.para.socket.ip.lowport); + if (dofork) { + xiosetchilddied(); /* set SIGCHLD handler */ + } + while (true) { /* we loop with fork or prohibited packets */ /* now wait for some packet on this datagram socket, get its sender address, connect there, and return */ diff --git a/xio-udp.h b/xio-udp.h index 860636c..d58870b 100644 --- a/xio-udp.h +++ b/xio-udp.h @@ -1,4 +1,4 @@ -/* $Id: xio-udp.h,v 1.12 2007/02/05 19:57:09 gerhard Exp $ */ +/* source: xio-udp.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-unix.c b/xio-unix.c index 508918b..b21839f 100644 --- a/xio-unix.c +++ b/xio-unix.c @@ -1,4 +1,4 @@ -/* $Id: xio-unix.c,v 1.34 2007/03/06 21:25:12 gerhard Exp $ */ +/* source: xio-unix.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio-unix.h b/xio-unix.h index 99fe1d7..10e80c4 100644 --- a/xio-unix.h +++ b/xio-unix.h @@ -1,4 +1,4 @@ -/* $Id: xio-unix.h,v 1.6 2007/02/08 18:30:08 gerhard Exp $ */ +/* source: xio-unix.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xio.h b/xio.h index 5bf5ad6..1237318 100644 --- a/xio.h +++ b/xio.h @@ -1,5 +1,5 @@ -/* $Id: xio.h,v 1.66 2007/03/06 21:25:51 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xio.h */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __xio_h_included @@ -591,6 +591,8 @@ extern int xioopenhelp(FILE *of, int level); extern xiofile_t *xioallocfd(void); extern void xiofreefd(xiofile_t *xfd); +extern int xiosetsigchild(xiofile_t *xfd, int (*callback)(struct single *)); +extern int xiosetchilddied(void); extern int xio_opt_signal(pid_t pid, int signum); extern void *xioengine(void *thread_arg); diff --git a/xioclose.c b/xioclose.c index 17b802a..aaff0b8 100644 --- a/xioclose.c +++ b/xioclose.c @@ -1,5 +1,5 @@ -/* $Id: xioclose.c,v 1.26 2007/01/25 21:36:11 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xioclose.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this is the source of the extended close function */ @@ -12,7 +12,7 @@ #include "xio-termios.h" -/* close the xio fd; must be valid and "simple" */ +/* close the xio fd; must be valid and "simple" (not dual) */ int xioclose1(struct single *pipe) { if (pipe->tag == XIO_TAG_INVALID) { diff --git a/xioconfig.h b/xioconfig.h index 114e972..82fca6a 100644 --- a/xioconfig.h +++ b/xioconfig.h @@ -1,4 +1,4 @@ -/* $Id: xioconfig.h,v 1.27 2007/03/06 21:26:23 gerhard Exp $ */ +/* source: xioconfig.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiodiag.c b/xiodiag.c index 5f60133..2753cc1 100644 --- a/xiodiag.c +++ b/xiodiag.c @@ -1,4 +1,4 @@ -/* $Id: xiodiag.c,v 1.3 2003/05/21 05:16:38 gerhard Exp $ */ +/* source: xiodiag.c */ /* Copyright Gerhard Rieger 2001, 2003 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiodiag.h b/xiodiag.h index 802798b..694730e 100644 --- a/xiodiag.h +++ b/xiodiag.h @@ -1,4 +1,4 @@ -/* $Id: xiodiag.h,v 1.2 2001/11/04 17:13:22 gerhard Exp $ */ +/* source: xiodiag.h */ /* Copyright Gerhard Rieger 2001 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xioexit.c b/xioexit.c index fe99a42..fd19589 100644 --- a/xioexit.c +++ b/xioexit.c @@ -1,4 +1,4 @@ -/* $Id: xioexit.c,v 1.10 2005/03/13 12:19:11 gerhard Exp $ */ +/* source: xioexit.c */ /* Copyright Gerhard Rieger 2001-2005 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiohelp.c b/xiohelp.c index 5540e53..1e7fb20 100644 --- a/xiohelp.c +++ b/xiohelp.c @@ -1,5 +1,5 @@ -/* $Id: xiohelp.c,v 1.19 2007/02/05 21:07:07 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xiohelp.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for the help function */ @@ -25,7 +25,7 @@ static const char *optiontypenames[] = { "OFF_T", "OFF64_T", #if HAVE_STRUCT_IP_MREQN "STRUCT-IP_MREQN", -#elif HAVE_STRUCT_IP_MREQN +#elif HAVE_STRUCT_IP_MREQ "STRUCT-IP_MREQ", #endif "IP4NAME", diff --git a/xiohelp.h b/xiohelp.h index 7953ac8..8348fb9 100644 --- a/xiohelp.h +++ b/xiohelp.h @@ -1,4 +1,4 @@ -/* $Id: xiohelp.h,v 1.2 2001/11/04 17:19:21 gerhard Exp $ */ +/* source: xiohelp.h */ /* Copyright Gerhard Rieger 2001 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xioinitialize.c b/xioinitialize.c index e9b6fcd..69df965 100644 --- a/xioinitialize.c +++ b/xioinitialize.c @@ -1,5 +1,5 @@ -/* $Id: xioinitialize.c,v 1.17 2006/12/28 14:21:41 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xioinitialize.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for the initialize function */ @@ -160,8 +160,8 @@ void xiodroplocks(void) { /* consider an invokation like this: socat -u exec:'some program that accepts data' tcp-l:...,fork we do not want the program to be killed by the first tcp-l sub process, it's - better if it survives all sub processes. Thus, it must not be killed if the - sub process delivers EOF. Also, a socket that is reused in sub processes + better if it survives all sub processes. Thus, it must not be killed when + the sub process delivers EOF. Also, a socket that is reused in sub processes should not be shut down (affects the connection), but closed (affects only sub processes copy of file descriptor) */ static int xio_nokill(xiofile_t *sock) { diff --git a/xiolayer.c b/xiolayer.c index 4183db1..e8ce025 100644 --- a/xiolayer.c +++ b/xiolayer.c @@ -1,5 +1,5 @@ -/* $Id: xiolayer.c,v 1.7 2005/08/18 19:56:05 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xiolayer.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for common options */ diff --git a/xiolayer.h b/xiolayer.h index 743cbc7..926dede 100644 --- a/xiolayer.h +++ b/xiolayer.h @@ -1,4 +1,4 @@ -/* $Id: xiolayer.h,v 1.5 2005/08/18 19:56:05 gerhard Exp $ */ +/* source: xiolayer.h */ /* Copyright Gerhard Rieger 2001-2005 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiolockfile.c b/xiolockfile.c index c297394..0ad5269 100644 --- a/xiolockfile.c +++ b/xiolockfile.c @@ -1,4 +1,4 @@ -/* $Id: xiolockfile.c,v 1.2 2006/02/08 19:51:24 gerhard Exp $ */ +/* source: xiolockfile.c */ /* Copyright Gerhard Rieger 2005-2006 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiolockfile.h b/xiolockfile.h index ff22288..1cf99c0 100644 --- a/xiolockfile.h +++ b/xiolockfile.h @@ -1,4 +1,4 @@ -/* $Id: xiolockfile.h,v 1.1 2005/08/18 19:42:05 gerhard Exp $ */ +/* source: xiolockfile.h */ /* Copyright Gerhard Rieger 2005 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiomodes.h b/xiomodes.h index f2e625b..36716da 100644 --- a/xiomodes.h +++ b/xiomodes.h @@ -1,4 +1,4 @@ -/* $Id: xiomodes.h,v 1.13 2007/03/06 21:22:29 gerhard Exp $ */ +/* source: xiomodes.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xioopen.c b/xioopen.c index 6180510..837b84d 100644 --- a/xioopen.c +++ b/xioopen.c @@ -1,4 +1,4 @@ -/* $Id: xioopen.c,v 1.119 2007/03/06 21:20:28 gerhard Exp $ */ +/* source: xioopen.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xioopen.h b/xioopen.h index 9c53ccf..5c93d12 100644 --- a/xioopen.h +++ b/xioopen.h @@ -1,4 +1,4 @@ -/* $Id: xioopen.h,v 1.22.2.1 2006/07/24 19:26:29 gerhard Exp $ */ +/* source: xioopen.h */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xioopts.c b/xioopts.c index f494a02..530af72 100644 --- a/xioopts.c +++ b/xioopts.c @@ -1,5 +1,5 @@ -/* $Id: xioopts.c,v 1.99 2007/03/06 21:22:04 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xioopts.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for address options handling */ @@ -586,6 +586,7 @@ const struct optname optionnames[] = { #ifdef SO_BINDTODEVICE IF_SOCKET ("interface", &opt_so_bindtodevice) #endif + IF_RETRY ("interval", &opt_intervall) IF_RETRY ("intervall", &opt_intervall) IF_TERMIOS("intr", &opt_vintr) #ifdef IP_ADD_MEMBERSHIP @@ -1067,6 +1068,7 @@ const struct optname optionnames[] = { IF_EXEC ("pty", &opt_pty) #endif #if HAVE_PTY && HAVE_POLL + IF_PTY ("pty-interval", &opt_pty_intervall) IF_PTY ("pty-intervall", &opt_pty_intervall) IF_PTY ("pty-wait-slave", &opt_pty_wait_slave) #endif /* HAVE_PTY && HAVE_POLL */ @@ -1542,7 +1544,9 @@ const struct optname optionnames[] = { #endif #if HAVE_PTY && HAVE_POLL IF_PTY ("wait-slave", &opt_pty_wait_slave) +#endif /* HAVE_PTY && HAVE_POLL */ IF_ANY ("waitlock", &opt_waitlock) +#if HAVE_PTY && HAVE_POLL IF_PTY ("waitslave", &opt_pty_wait_slave) #endif /* HAVE_PTY && HAVE_POLL */ #ifdef VWERASE diff --git a/xioopts.h b/xioopts.h index b2f1da2..695e3bf 100644 --- a/xioopts.h +++ b/xioopts.h @@ -1,5 +1,5 @@ -/* $Id: xioopts.h,v 1.70 2007/03/06 21:19:46 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xioopts.h */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __xioopts_h_included @@ -49,7 +49,9 @@ enum e_types { TYPE_LONGLONG, /* long long */ TYPE_OFF32, /* off_t */ TYPE_OFF64, /* off64_t */ +#if HAVE_STRUCT_IP_MREQ || HAVE_STRUCT_IP_MREQN TYPE_IP_MREQN, /* for struct ip_mreq or struct ip_mreqn */ +#endif TYPE_IP4NAME, /* IPv4 hostname or address */ TYPE_2BYTE = TYPE_USHORT diff --git a/xioparam.c b/xioparam.c index 83f4301..792f278 100644 --- a/xioparam.c +++ b/xioparam.c @@ -1,4 +1,4 @@ -/* $Id: xioparam.c,v 1.10 2006/06/19 20:30:24 gerhard Exp $ */ +/* source: xioparam.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xioread.c b/xioread.c index 8347977..33faae9 100644 --- a/xioread.c +++ b/xioread.c @@ -1,5 +1,5 @@ -/* $Id: xioread.c,v 1.38 2007/03/06 21:20:07 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xioread.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this is the source of the extended read function */ @@ -172,7 +172,7 @@ ssize_t xioread(xiofile_t *file, void *buff, size_t bufsiz) { } if (pipe->peersa.soa.sa_family != PF_UNSPEC) { - /* a peer address is defined, so we need to check if it matches */ + /* a peer address is registered, so we need to check if it matches */ #if 0 /* with UNIX sockets we find inconsistent lengths */ if (fromlen != pipe->salen) { Info("recvfrom(): wrong peer address length, ignoring packet"); diff --git a/xioshutdown.c b/xioshutdown.c index a90606f..aa68637 100644 --- a/xioshutdown.c +++ b/xioshutdown.c @@ -1,4 +1,4 @@ -/* $Id: xioshutdown.c,v 1.21 2007/01/25 21:36:11 gerhard Exp $ */ +/* source: xioshutdown.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiosigchld.c b/xiosigchld.c index f23e617..3414d55 100644 --- a/xiosigchld.c +++ b/xiosigchld.c @@ -1,5 +1,5 @@ -/* $Id: xiosigchld.c,v 1.21 2006/12/28 14:38:38 gerhard Exp $ */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* source: xiosigchld.c */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this is the source of the extended child signal handler */ @@ -292,3 +292,26 @@ void xiosigaction_child(int signum, siginfo_t *siginfo, void *ucontext) { } } + +int xiosetchilddied(void) { +#if HAVE_SIGACTION + struct sigaction act; + memset(&act, 0, sizeof(struct sigaction)); + act.sa_flags = SA_NOCLDSTOP|SA_RESTART|SA_SIGINFO +#ifdef SA_NOMASK + |SA_NOMASK +#endif + ; + act.sa_sigaction = childdied; + if (Sigaction(SIGCHLD, &act, NULL) < 0) { + /*! man does not say that errno is defined */ + Warn2("sigaction(SIGCHLD, %p, NULL): %s", childdied, strerror(errno)); + } +#else /* HAVE_SIGACTION */ + if (Signal(SIGCHLD, childdied) == SIG_ERR) { + Warn2("signal(SIGCHLD, %p): %s", childdied, strerror(errno)); + } +#endif /* !HAVE_SIGACTION */ + return 0; +} + diff --git a/xiosignal.c b/xiosignal.c index 405ff98..f41d24d 100644 --- a/xiosignal.c +++ b/xiosignal.c @@ -1,4 +1,4 @@ -/* $Id: xiosignal.c,v 1.2 2003/12/23 21:22:38 gerhard Exp $ */ +/* source: xiosignal.c */ /* Copyright Gerhard Rieger 2001-2003 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiosysincludes.h b/xiosysincludes.h index e30ef13..73b4ce2 100644 --- a/xiosysincludes.h +++ b/xiosysincludes.h @@ -1,4 +1,4 @@ -/* $Id: xiosysincludes.h,v 1.4 2001/12/27 16:52:34 gerhard Exp $ */ +/* source: xiosysincludes.h */ /* Copyright Gerhard Rieger 2001 */ /* Published under the GNU General Public License V.2, see file COPYING */ diff --git a/xiowrite.c b/xiowrite.c index 179e855..662b584 100644 --- a/xiowrite.c +++ b/xiowrite.c @@ -1,4 +1,4 @@ -/* $Id: xiowrite.c,v 1.29 2007/02/08 18:27:00 gerhard Exp $ */ +/* source: xiowrite.c */ /* Copyright Gerhard Rieger 2001-2007 */ /* Published under the GNU General Public License V.2, see file COPYING */