Bug 2914

Summary: Use getservbyname(3) for port numbers
Product: Portable OpenSSH Reporter: Christian Weisgerber <naddy>
Component: MiscellaneousAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: enhancement    
Priority: P5    
Version: 7.7p1   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch for resolving port specifications with getservbyname none

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