Comment 3 for bug 590925

Revision history for this message
Soren Hansen (soren) wrote : Re: [Bug 590925] Re: broken version of netcat installed by default

On Mon, Jun 07, 2010 at 08:52:50PM -0000, Grondr wrote:
> I believe I was quite clear:
>
> (a) "nc -l -p 1234" spits out a usage message.

I think this is the first time you shared any of the commands you
attempted to run.

You are asking people (volunteers, mostly) to help you with your
problems. Please don't make their lives more difficult by making them
guess what you've done when you could just tell them.

> The traditional version actually listens on port 1234. Having finally
> found nc's manpage, I see that the OpenBSD version uses completely
> incompatible arguments,

Ok, I'll take your flame bait.

-c and -e are missing. Noone should be using them anyway, but yes, they
are missing.

-b is missing. The openbsd version seems to allow broadcast by default,
so we could just make it accept the option and ignore it.

-g and -G are missing, so you don't get to specify source routing.

Both have -h. It does the same.

Both have -i. It does the same.

Both have -k. They seem to do the same.

Both have -l. They do the same.

Both have -n. They do the same.

-o is missing in the openbsd version. I think it's a silly option, but
yes, it's missing.

-p is different between the two. The OpenBSD version uses it to set a
source port for remote connections, while the traditional nc uses it to
specify the local port on which it will listen when in listen mode.

Both have -r. They do the same.

Both have -q. They do the same, but have different defaults (see
#544935).

Both have -s. They do the same.

Both have -T. They do the same.

Both have -t. They do the same.

Both have -u. They do the same.

Both have -v. They do the same.

Both have -w. They do the same.

Both have -z. They do the same.

In addition, the openbsd version has all these cool new things:

-4 and -6 to specify ipv4 or ipv6, respectively.

-D to enable a debug socket (don't really know what this is).

-d detaches from stdin.

-P to specify username for proxy auth.

-S to enable TCP MD5 signatures.

-C to do LF/CRLF translation.

-U to talk to UNIX domain sockets.

-X to specify proxy protocol.

-x to specify proxy address.

So no, they're not identical, but they're also hardly "completely
incompatible". This is the sort of stuff I'm talking about when I say
"constructive tone". Let's focus on the specific issues and try to work
on them rather than tossing around (incorrect) absolutes, shall we?

> hence breaking scripts that expect the decades-old version and giving
> no real clue what happened, because: (b) nc's usage message does not
> say it's from OpenBSD and has no version number, hence making
> debugging the change in behavior needlessly frustrating.

True. The "nc -h" output says it loud and clear, though:
OpenBSD netcat (Debian patchlevel 1.89-3ubuntu2)

Would you like to file a feature request about making it output this as
part of its usage message? If so, could you file a similar bug against
the traditional netcat as it has the same behaviour?

> (Not to mention that it has -only- a short-form usage message and
> fails to take --version or --help or any of the other canonical ways
> of getting more info, so it fakes people out into believing that it's
> basically the same set of options when in fact they're totally
> different.)

Yeah. Neither of the netcats follow this GNU convention:

soren@leonard:~$ nc.traditional --version
nc.traditional: invalid option -- '-'
nc -h for help
soren@leonard:~$ nc.traditional --help
nc.traditional: invalid option -- '-'
nc -h for help
soren@leonard:~$ nc.openbsd --help
nc.openbsd: invalid option -- '-'
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-P proxy_username] [-p source_port]
   [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol]
   [-x proxy_address[:port]] [hostname] [port[s]]
soren@leonard:~$ nc.openbsd --version
nc.openbsd: invalid option -- '-'
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-P proxy_username] [-p source_port]
   [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol]
   [-x proxy_address[:port]] [hostname] [port[s]]
soren@leonard:~$ nc.openbsd -h 2>&1| head -n 1
OpenBSD netcat (Debian patchlevel 1.89-3ubuntu2)
soren@leonard:~$ nc.traditional -h 2>&1 | head -n 1
[v1.10-38]

It's quite annoying. Certainly worthy of a bug report on its own.

> This is true in both 32- and 64-bit Lucid on any machine I've tried.

Yeah, we woulnd't make such things behave differently depending on word
size. That would be silly.

> I note, btw, that using update-alternatives did -not- replace the
> OpenBSD manpage with the traditional one, even though it replaced the
> links in /etc/alternatives, so I now have the manpage for the OpenBSD
> version installed even though nc & netcat on my machines are actually
> the traditional version. This also seems buggy to me, since it's a
> really easy way to totally confuse people by showing them the manpage
> for the wrong program. I suppose I should file a bug report about that,
> too.

You need to do update-alternatives for nc.1.gz as well.
update-alternatives is a reasonably low-level tool. This would need to
be handled higher up in the food chain if it has to be done
automatically for both.

--
Soren Hansen
Ubuntu Developer
http://www.ubuntu.com/