GNU netcat in make tests
Darren Tucker
dtucker at zip.com.au
Sat Jul 26 00:59:01 EST 2014
On Fri, Jul 25, 2014 at 4:33 AM, Corinna Vinschen <vinschen at redhat.com>
wrote:
>
> [...] or the ncat tool from http://nmap.org/ as used on
> Fedora, both of which provide -U for AF_UNIX sockets.
>
ncat has a different problem: it doesn't handle FD closures properly. Grab
yourself a decent-sized (a MB or two) data file and try this (this is on
Fedora 20):
$ ncat -l 127.0.0.1 1234 <testdata &
$ ncat 127.0.0.1 1234 >testcopy
This will transfer the full file then hang indefinitely waiting for stdin
to close:
^C
$ ls -l testdata testcopy
-rw-r--r-- 1 dtucker dtucker 5485744 Jul 26 00:45 testcopy
-rwxr-xr-x 1 dtucker dtucker 5485744 Jul 26 00:43 testdata
If you try to work around this by redirecting stdin to /dev/null it'll exit
after one pass through the copy loop even though the TCP stream it's
writing hasn't been completely written:
$ ncat -l 127.0.0.1 1234 <testdata &
$ ncat 127.0.0.1 1234 >testcopy </dev/null
$ ls -l testdata testcopy
-rw-r--r-- 1 dtucker dtucker 16384 Jul 26 00:48 testcopy
-rwxr-xr-x 1 dtucker dtucker 5485744 Jul 26 00:43 testdata
A had a look around and it seems their abstraction layer doesn't allow them
to do this. They have --send-only and --recv-only which seem like hacks
around the problem, but no other nc implementation either needs or
understands them.
Damien suggested shipping OpenBSD's nc in contrib and I made fun of him for
it, but he may have been right (as usual :-)
--
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
More information about the openssh-unix-dev
mailing list