summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/readconf.c
diff options
context:
space:
mode:
authornaddy <naddy@openbsd.org>2018-10-05 14:26:09 +0000
committernaddy <naddy@openbsd.org>2018-10-05 14:26:09 +0000
commitc514dff9ea96685a62107b15c6cdb92065915e80 (patch)
treefa3dd9866221b544b0053cd7066f25c7a0509f08 /usr.bin/ssh/readconf.c
parentGarbage-collect the now unused __statement() macro. (diff)
downloadwireguard-openbsd-c514dff9ea96685a62107b15c6cdb92065915e80.tar.xz
wireguard-openbsd-c514dff9ea96685a62107b15c6cdb92065915e80.zip
Support using service names for port numbers.
* 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. ok dtucker@ deraadt@
Diffstat (limited to 'usr.bin/ssh/readconf.c')
-rw-r--r--usr.bin/ssh/readconf.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c
index 5fe0ccc7d3f..f23dcf0897e 100644
--- a/usr.bin/ssh/readconf.c
+++ b/usr.bin/ssh/readconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.299 2018/10/03 06:38:35 djm Exp $ */
+/* $OpenBSD: readconf.c,v 1.300 2018/10/05 14:26:09 naddy Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1143,7 +1143,20 @@ parse_command:
return 0;
case oPort:
- intptr = &options->port;
+ arg = strdelim(&s);
+ if (!arg || *arg == '\0')
+ fatal("%.200s line %d: Missing argument.",
+ filename, linenum);
+ value = a2port(arg);
+ if (value <= 0)
+ fatal("%.200s line %d: Bad port '%s'.",
+ filename, linenum, arg);
+ if (*activep && options->port == -1)
+ options->port = value;
+ break;
+
+ case oConnectionAttempts:
+ intptr = &options->connection_attempts;
parse_int:
arg = strdelim(&s);
if ((errstr = atoi_err(arg, &value)) != NULL)
@@ -1153,10 +1166,6 @@ parse_int:
*intptr = value;
break;
- case oConnectionAttempts:
- intptr = &options->connection_attempts;
- goto parse_int;
-
case oCiphers:
arg = strdelim(&s);
if (!arg || *arg == '\0')