merged 1.6.0.1

This commit is contained in:
Gerhard Rieger 2008-10-17 22:49:55 +02:00
commit 326cac28d6
156 changed files with 939 additions and 5201 deletions

53
CHANGES
View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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: <hugo@localhost>" "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: <hugo@localhost>\"" "\"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

12
FAQ
View file

@ -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.

View file

@ -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

17
README
View file

@ -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(<!)ARG1+htmlcommand(>)))
> whenhtml(htmlcommand(<!--)ARG1+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

View file

@ -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()

View file

@ -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 */

View file

@ -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

View file

@ -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

View file

@ -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 ' ':

View file

@ -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 */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -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(<timeout>))
down. Then, socat() waits <timeout> [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(<timeout>))
Total inactivity timeout: when socat is already in the transfer loop and
@ -1716,14 +1716,14 @@ dit(bf(tt(ip-add-membership=<multicast-address:interface-address:interface-index
The indices of active network interfaces can be shown using the utility
procan().
label(OPTION_IP_MULTICAST_IF)
dif(bf(tt(ip-multicast-if=<hostname>)))
dit(bf(tt(ip-multicast-if=<hostname>)))
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=<bool>)))
dit(bf(tt(ip-multicast-loop=<bool>)))
Specifies if outgoing multicast traffic should loop back to the interface.
label(OPTION_IP_MULTICAST_TTL)
dif(bf(tt(ip-multicast-ttl=<byte>)))
dit(bf(tt(ip-multicast-ttl=<byte>)))
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=<seconds>)))
Sets the idle time before sending the first keepalive to <seconds>
[link(int)(TYPE_INT)].
label(OPTION_KEEPINTVL)dit(bf(tt(keepintvl=<seconds>)))
Sets the intervall between two keepalives to <seconds>
Sets the interval between two keepalives to <seconds>
[link(int)(TYPE_INT)].
label(OPTION_LINGER2)dit(bf(tt(linger2=<seconds>)))
Sets the time to keep the socket in FIN-WAIT-2 state to <seconds>
@ -2145,7 +2145,7 @@ label(OPTION_ISIG)dit(bf(tt(isig=<bool>)))
label(OPTION_ISPEED)dit(bf(tt(ispeed=<unsigned-int>)))
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=<bool>)))
label(OPTION_ISTRIP)dit(bf(tt(istrip=<bool>)))
label(OPTION_IUCLC)dit(bf(tt(iuclc=<bool>)))
label(OPTION_IXANY)dit(bf(tt(ixany=<bool>)))
label(OPTION_IXOFF)dit(bf(tt(ixoff=<bool>)))
@ -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=<seconds>)))
label(OPTION_PTY_INTERVAL)dit(bf(tt(pty-interval=<seconds>)))
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=<num>)))
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=<timespec>)))
label(OPTION_INTERVAL)dit(bf(tt(interval=<timespec>)))
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(<dt><code><strong>(echo PASSWORD; sleep 5; echo ls; sleep 1) |</strong><br>
htmlcommand(<dt><code><strong>(sleep 5; echo PASSWORD; sleep 5; echo ls; sleep 1) |</strong><br>
<strong>socat - EXEC:'ssh -l user server',pty,setsid,ctty</strong></code><dd>)
link(EXEC)(ADDRESS_EXEC)'utes an ssh session to server. Uses a link(pty)(OPTION_PTY) for communication between socat() and

View file

@ -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=<double>
Option: interval=<double>
Type: TIMESPEC
Option group: RETRY

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

2
ftp.sh
View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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 */

View file

@ -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

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

84
procan-cdefs.c Normal file
View file

@ -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;
}

View file

@ -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 */

View file

@ -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) */

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,6 +1,6 @@
%define majorver 1.6
%define minorver 0.0
%define minorver 0.1
Summary: socat - multipurpose relay
Name: socat

View file

@ -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

View file

@ -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

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

448
test.sh
View file

@ -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 ' <defunct>$')" ;;
FreeBSD) l="$(echo "$1" |grep ' <defunct>$')" ;;
HP-UX) l="$(echo "$1" |grep ' <defunct>$')" ;;
Linux) l="$(echo "$1" |grep ' <defunct>$')" ;;
SunOS) l="$(echo "$1" |grep ' <defunct>$')" ;;
*) l="$(echo "$1" |grep ' <defunct>$')" ;;
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" <<EOF
sleep 1; echo; sleep 1; touch "$tda"; echo
EOF
chmod a+x "$tsh"
CMD1="$SOCAT $opts -U UNIX-LISTEN:$ts,fork EXEC:$tsh,pty"
CMD="$SOCAT $opts /dev/null UNIX-CONNECT:$ts"
printf "test $F_n $TEST... " $N
$CMD1 2>"${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

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */
}
}

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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';

View file

@ -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 */

View file

@ -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));

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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;

View file

@ -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 */

View file

@ -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);

View file

@ -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 */

View file

@ -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 */

Some files were not shown because too many files have changed in this diff Show more