Bug 2914 - Use getservbyname(3) for port numbers
Summary: Use getservbyname(3) for port numbers
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: 7.7p1
Hardware: All All
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-05 06:01 AEST by Christian Weisgerber
Modified: 2021-04-23 15:10 AEST (History)
0 users

See Also:


Attachments
Patch for resolving port specifications with getservbyname (1.83 KB, application/octet-stream)
2018-10-05 06:01 AEST, Christian Weisgerber
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Weisgerber 2018-10-05 06:01:45 AEST
Created attachment 3186 [details]
Patch for resolving port specifications with getservbyname

Is there a reason ssh doesn't consult services(5) for port numbers?

This has irked me forever.  I'd rather write ssh -L icb:localhost:icb
instead of ssh -L 7326, wait, 7236, uhm, grep icb /etc/services...

I don't think there is any syntactic ambiguity since Unix sockets
already must contain a '/'.

The patch below adds this:
* Try to resolve a port specification with getservbyname(3) if a
  numeric conversion fails.
* Make the "Port" option in ssh_config handle its argument as a
  port rather than a plain integer.

All other command line switches and configuration file options
already use a2port().

This passes the existing regression tests.
Comment 1 Christian Weisgerber 2018-10-06 00:26:51 AEST
Committed.
Comment 2 Damien Miller 2021-04-23 15:10:03 AEST
closing resolved bugs as of 8.6p1 release