diff --git a/CHANGES b/CHANGES index 3f49045..80ab410 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,9 @@ new features: introduced option names substuser-early and su-e, currently equivalent to option substuser (thanks to Mike Perry for providing the patch) +corrections: + fixed some typos and improved some comments + ####################### V 1.7.0.1: corrections: diff --git a/EXAMPLES b/EXAMPLES index eca34f3..e5160bc 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -230,7 +230,7 @@ $ socat -d -d tcp:localhost:25,crlf,nodelay exec:'/usr/sbin/chat -v -s "\"220 \" ////////////////////////////////////////////////////////////////////////////// // IP6 -# socat readline TCP6:::1:21 # if your inetd/ftp is listening on ip6 +# socat readline TCP6:[::1]:21 # if your inetd/ftp is listening on ip6 /////////////////////////////////////////////////////////////////////////////// diff --git a/README b/README index f92849d..e0ebc54 100644 --- a/README +++ b/README @@ -50,7 +50,7 @@ following operating systems: Debian lenny/sid on x86, kernel 2.6.24 FreeBSD 6.1 on x86 -NetBSD4.0 on x86 +NetBSD 4.0 on x86 OpenBSD 4.3 on x86 OpenSolaris 10 on x86 with gcc Mac OS X 10.5.5 on iMac G5, with libreadline diff --git a/VERSION b/VERSION index 447515f..726d12a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -"1.7.0.1+shutnull" +"1.7.0.1+shutnull+suearly+typos" diff --git a/doc/socat-multicast.html b/doc/socat-multicast.html index 829eba3..4f7305e 100644 --- a/doc/socat-multicast.html +++ b/doc/socat-multicast.html @@ -41,8 +41,8 @@ requirements. All the following examples work bidirectionally except when otherwise noticed. For "clients" we just use STDIO, and for "servers" we use EXEC:hostname which ingores its input but shows us which host the reply comes from. Replace these -addresses with what is appropriate for you (e.g. shell script -invokations). Port 6666 can be replaced with any other port (but for ports < +socat addresses with what is appropriate for your needs (e.g. shell script +invocations). Port 6666 can be replaced with any other port (but for ports < 1024 root privilege might be required).

@@ -85,7 +85,7 @@ direction the first data is passed. A packet from the network is accepted by the IP stack for our socket if:

@@ -226,9 +226,10 @@ Set a multicast/broadcast route with the following command:

route add -net 224.0.0.0/3 gw 192.168.10.2 +

ALL-SYSTEMS multicast address

-224.0.0.1 is the all-systems multicast address: all +224.0.0.1 is the all-systems multicast address: all datagram sockets appear to be automatically member of this group on all interfaces. This membership cannot be dropped on Linux.

@@ -237,10 +238,14 @@ interfaces. This membership cannot be dropped on Linux.

(In)Security

When you use the above examples you should understand that all datagram -sockets without exception accept packets that are directly addressed to them; +sockets without exception accept all packets that are directly addressed to +them; the multi- and broadcast receiving features are just extensions to the normal -functionality. socat has no way to find out if an incoming packet is addressed -to a unicast, multicast, or broadcast address.

+functionality. socat currently has no means to handle incoming packets +differently when it is addressed to a unicast, multicast, or broadcast +address. However, for EXEC'd scripts socat can provide this info in environment +variables. +

Authentication or encryption are not available.

@@ -296,13 +301,13 @@ Please note that the new features could not be successfully tested on IPv6; these sections thus apply to IPv4 only.

-

This document was last modified in March 2007.

+

This document was last modified in July 2008.

More info about socat datagrams

Links regarding this tutorial

-address udp4-datagram
-address udp4-recvfrom
+address UDP4-DATAGRAM
+address UDP4-RECVFROM
option range
option broadcast
option ip-add-membership
@@ -310,11 +315,11 @@ these sections thus apply to IPv4 only. option bind

Other datagram addresses

-address udp4-recv: pure datagram receiver
-address udp4-sendto: communicate +address UDP4-RECV: pure datagram receiver
+address UDP4-SENDTO: communicate with one peer address
-address udp4-listen: pseudo stream server
-address udp4-connect: pseudo stream client
+address UDP4-LISTEN: pseudo stream server
+address UDP4-CONNECT: pseudo stream client

Related socat option groups

IP options
@@ -331,7 +336,7 @@ with one peer address
broadcasting on Wikipedia

-Copyright: Gerhard Rieger 2007
+Copyright: Gerhard Rieger 2007-2008
License: GNU Free Documentation License (FDL)

diff --git a/doc/socat-tun.html b/doc/socat-tun.html index 0df6bca..4d1d680 100644 --- a/doc/socat-tun.html +++ b/doc/socat-tun.html @@ -16,7 +16,7 @@ these devices are called TUN or TAP.

socat provides an address type that creates a TUN device on Linux; the other -socat address can be any type; it transfer the "wire" data as desired. +socat address can be any type; it transfers the "wire" data as desired.

This document shows how a simple virtual network can be created between @@ -31,7 +31,7 @@ following commands with the requirements of your situation:

- +
hostaddressmask
physical "server" address1.2.3.4n/a
physical "client" address223.2.3.4n/a
physical "client" addressn/an/a
TUN on "server"192.168.255.1255.255.255.0
TUN on "client"192.168.255.2255.255.255.0
diff --git a/doc/socat.yo b/doc/socat.yo index e943317..1c072cf 100644 --- a/doc/socat.yo +++ b/doc/socat.yo @@ -340,21 +340,21 @@ label(ADDRESS_IP_SENDTO)dit(bf(tt(IP-SENDTO::))) Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6) nl() Useful options: link(pf)(OPTION_PROTOCOL_FAMILY), - link(ttl)(OPTION_TTL) + link(ttl)(OPTION_TTL) nl() See also: link(IP4-SENDTO)(ADDRESS_IP4_SENDTO), link(IP6-SENDTO)(ADDRESS_IP6_SENDTO), link(IP-RECVFROM)(ADDRESS_IP_RECVFROM), link(IP-RECV)(ADDRESS_IP_RECV), - link(UDP-SENDTO)(ADDRESS_UDP_SENDTO) + link(UDP-SENDTO)(ADDRESS_UDP_SENDTO), link(UNIX-SENDTO)(ADDRESS_UNIX_SENDTO) label(ADDRESS_INTERFACE)dit(bf(tt(INTERFACE:))) - Communicate with a network connected on an interface using raw packets + Communicates with a network connected on an interface using raw packets including link level data. link()(TYPE_INTERFACE) is the name of the network interface. Currently only available on Linux. Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET) nl() Useful options: - link(pf)(OPTION_PROTOCOL_FAMILY) + link(pf)(OPTION_PROTOCOL_FAMILY), link(type)(OPTION_SO_TYPE)nl() See also: link(ip-recv)(ADDRESS_IP_RECV) label(ADDRESS_IP4_SENDTO)dit(bf(tt(IP4-SENDTO::))) @@ -368,7 +368,7 @@ label(ADDRESS_IP_DATAGRAM)dit(bf(tt(IP-DATAGRAM:
:))) Sends outgoing data to the specified address which may in particular be a broadcast or multicast address. Packets arriving on the local socket are checked if their source addresses match - eventual link(RANGE)(OPTION_RANGE) or link(TCPWRAP)(OPTION_TCPWRAPPERS) + link(RANGE)(OPTION_RANGE) or link(TCPWRAP)(OPTION_TCPWRAPPERS) options. This address type can for example be used for implementing symmetric or asymmetric broadcast or multicast communications.nl() Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET), @@ -395,19 +395,21 @@ label(ADDRESS_IP_DATAGRAM)dit(bf(tt(IP-DATAGRAM:
:))) label(ADDRESS_IP4_DATAGRAM)dit(bf(tt(IP4-DATAGRAM::))) Like link(IP-DATAGRAM)(ADDRESS_IP_DATAGRAM), but always uses IPv4. (link(example)(EXAMPLE_ADDRESS_IP4_BROADCAST_CLIENT))nl() - Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET), - link(IP4)(GROUP_IP4), link(RANGE)(GROUP_RANGE) nl() + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(RANGE)(GROUP_RANGE) nl() label(ADDRESS_IP6_DATAGRAM)dit(bf(tt(IP6-DATAGRAM::))) Like link(IP-DATAGRAM)(ADDRESS_IP_DATAGRAM), but always uses IPv6. Please note that IPv6 does not know broadcasts.nl() - Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET), - link(IP6)(GROUP_IP6), link(RANGE)(GROUP_RANGE) nl() + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) nl() label(ADDRESS_IP_RECVFROM)dit(bf(tt(IP-RECVFROM:))) Opens a raw IP socket of link()(TYPE_PROTOCOL). Depending on option link(pf)(OPTION_PROTOCOL_FAMILY), 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 allows a behaviour similar to typical UDP based servers like ntpd or + named.nl() + Please note that the reply packets might be fetched as incoming traffic when + sender and receiver IP address are identical because there is no port number + to distinguish the sockets.nl() 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.nl() @@ -675,7 +677,7 @@ label(ADDRESS_SCTP6_LISTEN)dit(bf(tt(SCTP6-LISTEN:))) Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(LISTEN)(GROUP_LISTEN),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE),link(IP6)(GROUP_IP6),link(SCTP)(GROUP_SCTP),link(RETRY)(GROUP_RETRY) nl() label(ADDRESS_SOCKET_CONNECT)dit(bf(tt(SOCKET-CONNECT:::))) Creates a stream socket using the first and second given socket parameters - and tt(SOCK_STREAM) (see man socket(2)) and connects to the remote-address. + and tt(SOCK_STREAM) (see man socket\(2)) and connects to the remote-address. The two socket parameters have to be specified by link(int)(TYPE_INT) numbers. Consult your OS documentation and include files to find the appropriate values. The remote-address must be the link(data)(TYPE_DATA) @@ -699,7 +701,7 @@ label(ADDRESS_SOCKET_CONNECT)dit(bf(tt(SOCKET-CONNECT::::::))) Creates a datagram socket using the first three given socket parameters (see - man socket(2)) and sends outgoing data to the remote-address. The three + man socket\(2)) and sends outgoing data to the remote-address. The three socket parameters have to be specified by link(int)(TYPE_INT) numbers. Consult your OS documentation and include files to find the appropriate values. The remote-address must be the link(data)(TYPE_DATA) @@ -724,7 +726,7 @@ label(ADDRESS_SOCKET_DATAGRAM)dit(bf(tt(SOCKET-DATAGRAM:::::))) Creates a stream socket using the first and second given socket parameters - and tt(SOCK_STREAM) (see man socket(2)) and waits for incoming connections + and tt(SOCK_STREAM) (see man socket\(2)) and waits for incoming connections on local-address. The two socket parameters have to be specified by link(int)(TYPE_INT) numbers. Consult your OS documentation and include files to find the appropriate values. The local-address must be the @@ -746,8 +748,8 @@ label(ADDRESS_SOCKET_LISTEN)dit(bf(tt(SOCKET-LISTEN::::::))) - Creates a socket using the three given socket parameters (see man socket(2)) +label(ADDRESS_SOCKET_RECV)dit(bf(tt(SOCKET-RECV::::))) + Creates a socket using the three given socket parameters (see man socket\(2)) and binds it to . Receives arriving data. The three parameters have to be specified by link(int)(TYPE_INT) numbers. Consult your OS documentation and include files to find the appropriate values. The @@ -767,8 +769,8 @@ label(ADDRESS_SOCKET_RECV)dit(bf(tt(SOCKET_RECV:::::::))) - Creates a socket using the three given socket parameters (see man socket(2)) +label(ADDRESS_SOCKET_RECVFROM)dit(bf(tt(SOCKET-RECVFROM::::))) + Creates a socket using the three given socket parameters (see man socket\(2)) and binds it to . Receives arriving data and sends replies back to the sender. The first three parameters have to be specified as link(int)(TYPE_INT) numbers. Consult your OS documentation and include files @@ -790,9 +792,9 @@ label(ADDRESS_SOCKET_RECVFROM)dit(bf(tt(SOCKET_RECVFROM::::::))) +label(ADDRESS_SOCKET_SENDTO)dit(bf(tt(SOCKET-SENDTO::::))) Creates a socket using the three given socket parameters (see man - socket(2)). Sends outgoing data to the given address and receives replies. + socket\(2)). Sends outgoing data to the given address and receives replies. The three parameters have to be specified as link(int)(TYPE_INT) numbers. Consult your OS documentation and include files to find the appropriate values. The remote-address must be the link(data)(TYPE_DATA) @@ -996,7 +998,7 @@ label(ADDRESS_UDP_DATAGRAM)dit(bf(tt(UDP-DATAGRAM:
:))) Sends outgoing data to the specified address which may in particular be a broadcast or multicast address. Packets arriving on the local socket are checked for the correct remote port and if their source addresses match - eventual link(RANGE)(OPTION_RANGE) or link(TCPWRAP)(OPTION_TCPWRAPPERS) + link(RANGE)(OPTION_RANGE) or link(TCPWRAP)(OPTION_TCPWRAPPERS) options. This address type can for example be used for implementing symmetric or asymmetric broadcast or multicast communications.nl() Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) nl() @@ -1026,13 +1028,11 @@ label(ADDRESS_UDP4_DATAGRAM)dit(bf(tt(UDP4-DATAGRAM:
:))) Like link(UDP-DATAGRAM)(ADDRESS_UDP_DATAGRAM), but only supports IPv4 protocol (link(example1)(EXAMPLE_ADDRESS_UDP4_BROADCAST_CLIENT), link(example2)(EXAMPLE_ADDRESS_UDP4_MULTICAST)).nl() - Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET), - link(IP4)(GROUP_IP4), link(RANGE)(GROUP_RANGE) + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4), link(RANGE)(GROUP_RANGE) label(ADDRESS_UDP6_DATAGRAM)dit(bf(tt(UDP6-DATAGRAM:
:))) Like link(UDP-DATAGRAM)(ADDRESS_UDP_DATAGRAM), but only supports IPv6 protocol.nl() - Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET), - link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) label(ADDRESS_UDP_LISTEN)dit(bf(tt(UDP-LISTEN:))) Waits for a UDP/IP packet arriving on [link(UDP service)(TYPE_UDP_SERVICE)] and `connects' back to sender. @@ -1104,7 +1104,7 @@ label(ADDRESS_UDP_RECVFROM)dit(bf(tt(UDP-RECVFROM:))) 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.nl() + or named. This address works well with socat UDP-SENDTO address peers.nl() Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE) nl() Useful options: link(fork)(OPTION_FORK), @@ -1165,9 +1165,7 @@ label(ADDRESS_UNIX_CONNECT)dit(bf(tt(UNIX-CONNECT:))) if is not a unixdomain() socket, this is an error; if is a unixdomain() socket, but no process is listening, this is an error.nl() - Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET), - link(NAMED)(GROUP_NAMED),link(RETRY)(GROUP_RETRY), - link(UNIX)(GROUP_SOCK_UNIX) nl()) + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(NAMED)(GROUP_NAMED),link(RETRY)(GROUP_RETRY),link(UNIX)(GROUP_SOCK_UNIX) nl()) Useful options: link(bind)(OPTION_BIND)nl() See also: @@ -1184,10 +1182,7 @@ label(ADDRESS_UNIX_LISTEN)dit(bf(tt(UNIX-LISTEN:))) 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 link(unlink-close)(OPTION_UNLINK_CLOSE)) (link(example)(EXAMPLE_ADDRESS_UNIX_LISTEN)).nl() - Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET), - link(NAMED)(GROUP_NAMED),link(LISTEN)(GROUP_LISTEN), - link(CHILD)(GROUP_CHILD),link(RETRY)(GROUP_RETRY), - link(UNIX)(GROUP_SOCK_UNIX) nl() + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(NAMED)(GROUP_NAMED),link(LISTEN)(GROUP_LISTEN),link(CHILD)(GROUP_CHILD),link(RETRY)(GROUP_RETRY),link(UNIX)(GROUP_SOCK_UNIX) nl() Useful options: link(fork)(OPTION_FORK), link(umask)(OPTION_UMASK), @@ -1204,9 +1199,12 @@ label(ADDRESS_UNIX_LISTEN)dit(bf(tt(UNIX-LISTEN:))) label(ADDRESS_UNIX_SENDTO)dit(bf(tt(UNIX-SENDTO:))) Communicates with the specified peer socket, defined by [link()(TYPE_FILENAME)] assuming it is a unixdomain() 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.nl() - Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET), - link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX)nl() + Please note that it might be neccessary to link(bind)(OPTION_BIND) the + local socket to an address (e.g. tt(/tmp/sock1), which must not exist + before). + This address type works well with socat UNIX-RECVFROM and UNIX-RECV address + peers.nl() + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX)nl() Useful options: link(bind)(OPTION_BIND)nl() See also: @@ -1221,9 +1219,7 @@ label(ADDRESS_UNIX_RECVFROM)dit(bf(tt(UNIX-RECVFROM:))) 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.nl() - Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET), - link(NAMED)(GROUP_NAMED),link(CHILD)(GROUP_CHILD), - link(UNIX)(GROUP_SOCK_UNIX) nl() + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(NAMED)(GROUP_NAMED),link(CHILD)(GROUP_CHILD),link(UNIX)(GROUP_SOCK_UNIX) nl() Useful options: link(fork)(OPTION_FORK)nl() See also: @@ -1238,8 +1234,7 @@ label(ADDRESS_UNIX_RECV)dit(bf(tt(UNIX-RECV:))) 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: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET), - link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX) nl() + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX) nl() See also: link(UNIX-SENDTO)(ADDRESS_UNIX_SENDTO), link(UNIX-RECVFROM)(ADDRESS_UNIX_RECVFROM), @@ -1252,8 +1247,7 @@ label(ADDRESS_UNIX_CLIENT)dit(bf(tt(UNIX-CLIENT:))) [link()(TYPE_FILENAME)] assuming it is a unixdomain() socket. It first tries to connect and, if that fails, assumes it is a datagram socket, thus supporting both types.nl() - Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET), - link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX) nl() + Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX) nl() Useful options: link(bind)(OPTION_BIND)nl() See also: @@ -1629,21 +1623,24 @@ startdit() label(OPTION_SEEK)dit(bf(tt(seek=))) Applies the code(lseek(fd, , SEEK_SET)) (or code(lseek64)) system call, thus positioning the file pointer absolutely to - [link(off_t)(TYPE_OFF) or link(off64_t)(TYPE_OFF64)]. + [link(off_t)(TYPE_OFF) or link(off64_t)(TYPE_OFF64)]. Please note that a + missing value defaults to 1, not 0. label(OPTION_SEEK_CUR)dit(bf(tt(seek-cur=))) Applies the code(lseek(fd, , SEEK_CUR)) (or code(lseek64)) system call, thus positioning the file pointer [link(off_t)(TYPE_OFF) or link(off64_t)(TYPE_OFF64)] bytes relatively to its current position (which - is usually 0). + is usually 0). Please note that a missing value defaults to 1, not 0. label(OPTION_SEEK_END)dit(bf(tt(seek-end=))) Applies the code(lseek(fd, , SEEK_END)) (or code(lseek64)) system call, thus positioning the file pointer [link(off_t)(TYPE_OFF) or - link(off64_t)(TYPE_OFF64)] bytes relatively to the files current end. + link(off64_t)(TYPE_OFF64)] bytes relatively to the files current end. Please + note that a missing value defaults to 1, not 0. label(OPTION_FTRUNCATE)dit(bf(tt(ftruncate=))) Applies the code(ftruncate(fd, )) (or code(ftruncate64) if available) system call, thus truncating the file at the position [link(off_t)(TYPE_OFF) or - link(off64_t)(TYPE_OFF64)]. + link(off64_t)(TYPE_OFF64)]. Please note that a missing value defaults to 1, + not 0. label(OPTION_EXT2_SECRM_FL)dit(bf(tt(secrm=))) label(OPTION_EXT2_UNRM)dit(bf(tt(unrm=))) @@ -1733,7 +1730,7 @@ label(OPTION_NOECHO)dit(bf(tt(noecho=))) 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. + "^[Pp]assword:.*$" or "([Uu]ser:|[Pp]assword:)". See regex\(7) for details. (link(example)(EXAMPLE_OPTION_NOECHO)) label(OPTION_PROMPT)dit(bf(tt(prompt=))) Passes the string as prompt to the readline function. readline prints this @@ -1789,11 +1786,11 @@ label(OPTION_BIND)dit(bf(tt(bind=))) Binds the socket to the given socket address using the code(bind()) system call. The form of is socket domain dependent: IP4 and IP6 allow the form [hostname|hostaddress][:(service|port)] (link(example)(EXAMPLE_OPTION_BIND_TCP4)), - unixdomain() sockets require link()(TYPE_FILENAME). + unixdomain() sockets require link()(TYPE_FILENAME). label(OPTION_CONNECT_TIMEOUT)dit(bf(tt(connect-timeout=))) Abort the connection attempt after [link(timeval)(TYPE_TIMEVAL)] with error status. -label(OPTION_INTERFACE)dit(bf(tt(interface=))) +label(OPTION_SO_BINDTODEV)dit(bf(tt(so-bindtodev=))) Binds the socket to the given link()(TYPE_INTERFACE). This option might require root privilege. label(OPTION_SO_BROADCAST)dit(bf(tt(broadcast))) @@ -1914,7 +1911,7 @@ label(OPTION_SETSOCKOPT_INT)dit(bf(tt(setsockopt-int=::) set. For the actual numbers you might have to look up the appropriate include files of your system. The 4th tt(setsockopt()) parameter, tt(value) [link(int)(TYPE_INT)], is passed to the function per pointer, and for the - length parameter sizeof(int) is taken implicitely. + length parameter sizeof\(int) is taken implicitely. label(OPTION_SETSOCKOPT_BIN)dit(bf(tt(setsockopt-bin=::))) Like tt(setsockopt-int), but must be provided in link(dalan)(TYPE_DATA) format and specifies an arbitrary sequence of bytes; @@ -2036,7 +2033,7 @@ label(OPTION_RES_DEFNAMES)dit(bf(tt(res-defnames))) label(OPTION_RES_STAYOPEN)dit(bf(tt(res-stayopen))) label(OPTION_RES_DNSRCH)dit(bf(tt(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 + 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. @@ -2143,7 +2140,7 @@ label(OPTION_TCP_CONN_ABORT_THRESHOLD)dit(bf(tt(conn-abort-threshold=))) instead of stdout (1). The program started from the subprocess has to use this fd for writing data to socat() (link(example)(EXAMPLE_OPTION_FDOUT)). label(OPTION_SIGHUP)label(OPTION_SIGINT)label(OPTION_SIGQUIT)dit(bf(tt(sighup)), bf(tt(sigint)), bf(tt(sigquit))) - Has socat() pass an eventual signal of this type to the sub process. + Has socat() pass signals of this type to the sub process. If no address has this option, socat terminates on these signals. enddit() @@ -2650,7 +2647,7 @@ label(OPTION_OPENSSL_PSEUDO)dit(bf(tt(pseudo))) 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.nl() + initial value. openssl is then feeded with output from random\() calls.nl() NOTE:This mechanism is not sufficient for generation of secure keys! label(OPTION_OPENSSL_FIPS)dit(bf(tt(fips))) Enables FIPS mode if compiled in. For info about the FIPS encryption @@ -3192,8 +3189,8 @@ dit(bf(tt(socat -U TCP:target:9999,end-close TCP-L:8888,reuseaddr,fork))) merges data arriving from different TCP streams on port 8888 to just one stream to target:9999. The link(end-close)(OPTION_END_CLOSE) option prevents the child processes forked off by the second address from terminating the shared -connection to 9999 (close(2) just unlinks the inode which stays active as long -as the parent process lives; shutdown(2) would actively terminate the +connection to 9999 (close\(2) just unlinks the inode which stays active as long +as the parent process lives; shutdown\(2) would actively terminate the connection). @@ -3216,7 +3213,7 @@ tt(SO_BROADCAST). label(EXAMPLE_ADDRESS_IP4_BROADCAST_CLIENT) dit(bf(tt(socat - IP4-DATAGRAM:255.255.255.255:44,broadcast,range=10.0.0.0/8))) -sends a broadcast to the local network(s) using protocol 44. Accepts replies +sends a broadcast to the local network\(s) using protocol 44. Accepts replies from the private address range only. @@ -3266,7 +3263,7 @@ servers), and the original client request. label(EXAMPLE_ANCILLARY) dit(bf(tt(socat -d -d UDP4-RECVFROM:9999,so-broadcast,so-timestamp,ip-pktinfo,ip-recverr,ip-recvopts,ip-recvtos,ip-recvttl!!- SYSTEM:'export; sleep 1' |grep SOCAT))) -waits for incoming UDP packets on port 9999 and prints the environment +waits for an incoming UDP packets on port 9999 and prints the environment variables provided by socat. On BSD based systems you have to replace link(tt(ip-pktinfo))(OPTION_IP_PKTINFO) with link(tt(ip-recvdstaddr))(OPTION_IP_RECVDSTADDR),link(tt(ip-recvif))(OPTION_IP_RECVIF). Especially interesting is SOCAT_IP_DSTADDR: it contains the target address of the packet which may be a @@ -3344,7 +3341,7 @@ result (with differing IP version) is taken. With value 0, socat always selects the first record and its IP version. dit(bf(SOCAT_FORK_WAIT) (input)) Specifies the time (seconds) to sleep the -parent and child processes after successful fork(). Useful for debugging. +parent and child processes after successful fork\(). Useful for debugging. dit(bf(SOCAT_VERSION) (output)) Socat sets this variable to its version string, e.g. tt("1.7.0.0") for released versions or e.g. tt("1.6.0.1+envvar") for @@ -3493,8 +3490,8 @@ label(SEEALSO) manpageseealso() COMMENT(procan\(1), filan\(1), ) -nc(1), netcat6(1), sock(1), rinetd(8), cage(1), socks.conf(5), openssl(1), -stunnel(8), pty(1), rlwrap(1), setsid(1) +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 lurl(http://www.dest-unreach.org/socat/) diff --git a/mail.sh b/mail.sh index 115b1eb..1ea265e 100755 --- a/mail.sh +++ b/mail.sh @@ -8,7 +8,9 @@ # This is an example for a shell script that can be fed to socat with exec. # Its clue is that it does not use stdin/stdout for communication with socat, # so you may feed the mail message via stdin to the script. The message should -# contain appropriate mail headers. +# contain appropriate mail headers without continuation lines. +# socat establishes the connection to the SMTP server; the script performs the +# SMTP dialog and afterwards transfers the message body to the server. # Lines with only a dot are not permitted - use two dots as escape. # This script supports multiline answers from server, but not much more yet. diff --git a/proxyecho.sh b/proxyecho.sh index 26b4f6f..4644b89 100755 --- a/proxyecho.sh +++ b/proxyecho.sh @@ -1,6 +1,6 @@ #! /bin/bash # source: proxyecho.sh -# Copyright Gerhard Rieger 2003 +# Copyright Gerhard Rieger 2003-2009 # Published under the GNU General Public License V.2, see file COPYING # perform primitive simulation of a proxy server with echo function via stdio. @@ -56,4 +56,4 @@ echo "HTTP/1.0${SPACES}200 OK" echo # perform echo function -$CAT +exec $CAT diff --git a/sysincludes.h b/sysincludes.h index 90bda79..f92c018 100644 --- a/sysincludes.h +++ b/sysincludes.h @@ -1,5 +1,5 @@ /* source: sysincludes.h */ -/* Copyright Gerhard Rieger 2001-2008 */ +/* Copyright Gerhard Rieger 2001-2009 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __sysincludes_h_included @@ -36,7 +36,7 @@ #if HAVE_GRP_H #include /* getgrnam() */ #endif -#if HAVE_PTY_H && _WITH_TERMIOS +#if HAVE_PTY_H && (_WITH_TERMIOS || HAVE_OPENPTY) #include #endif #if HAVE_SYS_PARAM_H diff --git a/test.sh b/test.sh index d8b7404..6233520 100755 --- a/test.sh +++ b/test.sh @@ -2054,7 +2054,7 @@ waitfile () { # generate a test certificate and key gentestcert () { local name="$1" - if [ -f $name.key -a -f $name.crt -a -f $name.pem ]; then return; fi + if [ -s $name.key -a -s $name.crt -a -s $name.pem ]; then return; fi openssl genrsa $OPENSSL_RAND -out $name.key 768 >/dev/null 2>&1 openssl req -new -config testcert.conf -key $name.key -x509 -out $name.crt -days 3653 >/dev/null 2>&1 cat $name.key $name.crt >$name.pem @@ -2063,7 +2063,7 @@ gentestcert () { # generate a test DSA key and certificate gentestdsacert () { local name="$1" - if [ -f $name.key -a -f $name.crt -a -f $name.pem ]; then return; fi + if [ -s $name.key -a -s $name.crt -a -s $name.pem ]; then return; fi openssl dsaparam -out $name-dsa.pem 512 >/dev/null 2>&1 openssl dhparam -dsaparam -out $name-dh.pem 512 >/dev/null 2>&1 openssl req -newkey dsa:$name-dsa.pem -keyout $name.key -nodes -x509 -config testcert.conf -out $name.crt -days 3653 >/dev/null 2>&1 @@ -4564,7 +4564,7 @@ case "$TESTS" in TEST="$NAME: readline with password and sigint" if ! eval $NUMCOND; then :; elif ! feat=$(testaddrs readline pty); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${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 SAVETERM="$TERM"; TERM= # 'cause konsole might print controls even in raw @@ -4708,7 +4708,7 @@ case "$TESTS" in TEST="$NAME: gender changer via SSL through HTTP proxy, oneshot" if ! eval $NUMCOND; then :; elif ! feat=$(testaddrs openssl proxy); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat |tr 'a-z' 'A-Z') not available${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 gentestcert testsrv @@ -4793,7 +4793,7 @@ case "$TESTS" in TEST="$NAME: gender changer via SSL through HTTP proxy, daemons" if ! eval $NUMCOND; then :; elif ! feat=$(testaddrs openssl proxy); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${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 gentestcert testsrv @@ -5661,10 +5661,10 @@ case "$TESTS" in TEST="$NAME: test if master pty ($PTYTYPE) waits for slave connection" if ! eval $NUMCOND; then :; else if ! feat=$(testaddrs pty); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N + $PRINTF "test $F_n $TEST... ${YELLOW}$(echo "$feat"| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N numCANT=$((numCANT+1)) elif ! feat=$(testoptions "$PTYTYPE" pty-wait-slave); then - $PRINTF "test $F_n $TEST... ${YELLOW}option $(echo $feat| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N + $PRINTF "test $F_n $TEST... ${YELLOW}option $(echo "$feat"| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N numCANT=$((numCANT+1)) else testptywaitslave "$N" "$TEST" "$PTYTYPE" "$opts" @@ -5680,10 +5680,10 @@ case "$TESTS" in TEST="$NAME: test if master pty ($PTYTYPE) waits for slave connection" if ! eval $NUMCOND; then :; elif ! feat=$(testaddrs pty); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N + $PRINTF "test $F_n $TEST... ${YELLOW}$(echo "$feat"| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N numCANT=$((numCANT+1)) elif ! feat=$(testoptions "$PTYTYPE" pty-wait-slave); then - $PRINTF "test $F_n $TEST... ${YELLOW}option $(echo $feat| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N + $PRINTF "test $F_n $TEST... ${YELLOW}option $(echo "$feat"| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N numCANT=$((numCANT+1)) else testptywaitslave "$N" "$TEST" "$PTYTYPE" "$opts" @@ -5698,10 +5698,10 @@ case "$TESTS" in TEST="$NAME: test the connect-timeout option" if ! eval $NUMCOND; then :; elif ! feat=$(testaddrs tcp); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N + $PRINTF "test $F_n $TEST... ${YELLOW}$(echo "$feat"| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N numCANT=$((numCANT+1)) elif ! feat=$(testoptions connect-timeout); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${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 # we need a hanging connection attempt, guess an address for this @@ -5840,7 +5840,7 @@ N=$((N+1)) signum () { if [ ! "$BASH_VERSION" -o -o posix ]; then # we expect: - for i in $(POSIXLY_CORRECT=1 kill -l); do echo $i; done |grep -n -i "^$1$" |cut -d: -f1 + for i in $(POSIXLY_CORRECT=1 kill -l); do echo "$i"; done |grep -n -i "^$1$" |cut -d: -f1 else # expect: # " 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL" @@ -5860,7 +5860,7 @@ case "$TESTS" in TEST="$NAME: exit status when dying on SIG$signam" if ! eval $NUMCOND; then :; elif ! feat=$(testaddrs pty); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat |tr a-z A-Z) not available${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 SIG="$(signum $signam)" @@ -5904,7 +5904,7 @@ case "$TESTS" in TEST="$NAME: restrict reading from file with bytes option" if ! eval $NUMCOND; then :; elif false; then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${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" @@ -7954,7 +7954,8 @@ waitip4proto $ts1p 1 usleep $MICROS echo "$da" |$CMD2 2>>"${te}2" rc2="$?" -usleep $MICROS +#usleep $MICROS +sleep 1 kill "$pid1" 2>/dev/null; wait; if [ "$rc2" -ne 0 ]; then $PRINTF "$FAILED: $SOCAT:\n" @@ -8405,7 +8406,7 @@ TEST="$NAME: socat handles data buffered by openssl" # transferred, the test has failed. if ! eval $NUMCOND; then :; elif ! feat=$(testaddrs openssl) >/dev/null; then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${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 tf="$td/test$N.out" @@ -8457,7 +8458,7 @@ TEST="$NAME: trigger EOF after that many bytes, even when socket idle" # the process did not terminate and the bug is still there. if ! eval $NUMCOND; then :; elif false; then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${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" @@ -9044,8 +9045,8 @@ while read PF KEYW ADDR IPPORT SCM_ENABLE SCM_RECV SCM_TYPE SCM_NAME ROOT SCM_VA do if [ -z "$PF" ] || [[ "$PF" == \#* ]]; then continue; fi # -pf="$(echo $PF |tr A-Z a-z)" -proto="$(echo $KEYW |tr A-Z a-z)" +pf="$(echo "$PF" |tr A-Z a-z)" +proto="$(echo "$KEYW" |tr A-Z a-z)" NAME=${KEYW}SCM_$SCM_TYPE case "$TESTS" in *%functions%*|*%$pf%*|*%dgram%*|*%udp%*|*%$proto%*|*%recv%*|*%ancillary%*|*%$ROOT%*|*%$NAME%*) @@ -9165,7 +9166,7 @@ IP6 IP6 [::1] PROTO ipv6-tclass=0xaa ipv6-recvtclass IPV6_TCLASS while read KEYW FEAT TEST_SOCKADDR TEST_PEERADDR TEST_SOCKPORT TEST_PEERPORT; do if [ -z "$KEYW" ] || [[ "$KEYW" == \#* ]]; then continue; fi # -test_proto="$(echo $KEYW |tr A-Z a-z)" +test_proto="$(echo "$KEYW" |tr A-Z a-z)" NAME=${KEYW}LISTENENV case "$TESTS" in *%functions%*|*%ip4%*|*%ipapp%*|*%tcp%*|*%$test_proto%*|*%envvar%*|*%$NAME%*) @@ -9176,12 +9177,12 @@ TEST="$NAME: $KEYW-LISTEN fills environment variables with socket addresses" # describing the peer and local sockets. if ! eval $NUMCOND; then :; elif ! feat=$(testaddrs $FEAT); then - $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat |tr a-z A-Z) not available${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 tf="$td/test$N.stdout" te="$td/test$N.stderr" -TEST_SOCKADDR="$(echo $TEST_SOCKADDR |sed "s/\$N/$N/g")" # actual vars +TEST_SOCKADDR="$(echo "$TEST_SOCKADDR" |sed "s/\$N/$N/g")" # actual vars tsa="$TEST_SOCKADDR" # test server address tsp="$TEST_SOCKPORT" # test server port if [ "$tsp" != ',' ]; then @@ -9189,7 +9190,7 @@ if [ "$tsp" != ',' ]; then else tsa1="$tsa"; tsa2= # tsa1 used for addr parameter fi -TEST_PEERADDR="$(echo $TEST_PEERADDR |sed "s/\$N/$N/g")" # actual vars +TEST_PEERADDR="$(echo "$TEST_PEERADDR" |sed "s/\$N/$N/g")" # actual vars tca="$TEST_PEERADDR" # test client address tcp="$TEST_PEERPORT" # test client port if [ "$tcp" != ',' ]; then @@ -9235,11 +9236,11 @@ else cat "${te}1" numFAIL=$((numFAIL+1)) fi -set +xv fi # NUMCOND, feats ;; esac N=$((N+1)) +set +xv # done <<<" TCP4 TCP $LOCALHOST $SECONDADDR $PORT $((PORT+1)) @@ -9258,8 +9259,8 @@ while read PF KEYW ADDR IPPORT SCM_ENABLE SCM_RECV SCM_ENVNAME ROOT SCM_VALUE do if [ -z "$PF" ] || [[ "$PF" == \#* ]]; then continue; fi # -pf="$(echo $PF |tr A-Z a-z)" -proto="$(echo $KEYW |tr A-Z a-z)" +pf="$(echo "$PF" |tr A-Z a-z)" +proto="$(echo "$KEYW" |tr A-Z a-z)" NAME=${KEYW}ENV_$SCM_ENVNAME case "$TESTS" in *%functions%*|*%$pf%*|*%dgram%*|*%udp%*|*%$proto%*|*%recv%*|*%ancillary%*|*%envvar%*|*%$ROOT%*|*%$NAME%*) @@ -9970,7 +9971,7 @@ printf "test $F_n $TEST... " $N $CMD1 >"$tf" 2>"${te}1" & pid1=$! waitsctp4port $tsl 1 -# SCTP does not seem to support half close, so we let it 1s to finish +# SCTP does not seem to support half close, so we give it 1s to finish (echo "$da"; sleep 1) |$CMD2 >>"$tf" 2>>"${te}2" if [ $? -ne 0 ]; then $PRINTF "$FAILED: $SOCAT:\n" @@ -10026,8 +10027,9 @@ waitsctp6port $tsl 1 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: diff:\n" @@ -10077,12 +10079,12 @@ case "$TESTS" in TEST="$NAME: give a one line description of test" # describe how the test is performed, and what's the success criteria if ! eval $NUMCOND; then :; else -tf="$td/test$N.stout" +tf="$td/test$N.stdout" te="$td/test$N.stderr" tdiff="$td/test$N.diff" da="test$N $(date) $RANDOM" CMD0="$SOCAT $opts server-address PIPE" -CMD1="$SOCAT - client-address" +CMD1="$SOCAT $opts - client-address" printf "test $F_n $TEST... " $N $CMD0 >/dev/null 2>"${te}0" & pid0=$! diff --git a/xioopts.c b/xioopts.c index 602f4a2..3a455b7 100644 --- a/xioopts.c +++ b/xioopts.c @@ -927,6 +927,7 @@ const struct optname optionnames[] = { IF_OPEN ("nshare", &opt_o_nshare) #endif IF_SOCKET ("null-eof", &opt_null_eof) + IF_ANY ("o-append", &opt_append) #ifdef O_ASYNC IF_ANY ("o-async", &opt_async) #endif