> On Tue, May 31, 2016 at 10:17 PM, Theo de Raadt <[email protected]>
> wrote:
> >> This diff allows users to use the name of a service in /etc/services
> >> instead of a port number when using netcat. Hopefully, this will make
> >> using netcat easier for some users.
> >
> > I don't see how it makes it easier. There are a number of netcat
> > versions out there, mostly trying to be somewhat compatible. On a
> > whim, this introduces an incompatibility --> scripts become less
> > portable.
>
> Well, we would rather that people use nc than openssl s_client or
> telnet ...and both those do service name lookup...
I have changed my mind. Original hobbit netcat used getservbyname.
Everyone please move the drinks near your keyboards a bit further
away....
case 'p': /* local source port */
o_lport = getportpoop (optarg, 0);
...
/* getportpoop :
Same general idea as gethostpoop -- look up a port in /etc/services, fill
in global port_poop, but return the actual port *number*. Pass ONE of:
pstring to resolve stuff like "23" or "exec";
pnum to reverse-resolve something that's already a number.
If o_nflag is on, fill in what we can but skip the getservby??? stuff.
Might as well have consistent behavior here, and it *is* faster. */
USHORT getportpoop (pstring, pnum)
char * pstring;
unsigned int pnum;
{
struct servent * servent;
...
servent = getservbyport (y, whichp);
if (servent) {
It is strange that none of the other derivatives did so. I guess this
shows they are really clones of the Eric Jackson / OpenBSD variant.