From 5eff5b858e717e901e6af6596306a114de9f79f2 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Wed, 3 Oct 2018 06:38:35 +0000 Subject: upstream: Allow ssh_config IdentityAgent directive to accept environment variable names as well as explicit paths. ok dtucker@ OpenBSD-Commit-ID: 2f0996e103876c53d8c9dd51dcce9889d700767b --- misc.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index ae4d29b84..c4ca12560 100644 --- a/misc.c +++ b/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.131 2018/07/27 05:13:02 dtucker Exp $ */ +/* $OpenBSD: misc.c,v 1.132 2018/10/03 06:38:35 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -1948,6 +1948,25 @@ bad: return 0; } +/* + * Verify that a environment variable name (not including initial '$') is + * valid; consisting of one or more alphanumeric or underscore characters only. + * Returns 1 on valid, 0 otherwise. + */ +int +valid_env_name(const char *name) +{ + const char *cp; + + if (name[0] == '\0') + return 0; + for (cp = name; *cp != '\0'; cp++) { + if (!isalnum((u_char)*cp) && *cp != '_') + return 0; + } + return 1; +} + const char * atoi_err(const char *nptr, int *val) { -- cgit v1.2.3 From 2581333d564d8697837729b3d07d45738eaf5a54 Mon Sep 17 00:00:00 2001 From: "naddy@openbsd.org" Date: Fri, 5 Oct 2018 14:26:09 +0000 Subject: upstream: 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@ OpenBSD-Commit-ID: e7f03633133205ab3dfbc67f9df7475fabae660d --- misc.c | 12 ++++++++---- readconf.c | 21 +++++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index c4ca12560..bdc06fdb3 100644 --- a/misc.c +++ b/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.132 2018/10/03 06:38:35 djm Exp $ */ +/* $OpenBSD: misc.c,v 1.133 2018/10/05 14:26:09 naddy Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -332,13 +333,16 @@ pwcopy(struct passwd *pw) int a2port(const char *s) { + struct servent *se; long long port; const char *errstr; port = strtonum(s, 0, 65535, &errstr); - if (errstr != NULL) - return -1; - return (int)port; + if (errstr == NULL) + return (int)port; + if ((se = getservbyname(s, "tcp")) != NULL) + return ntohs(se->s_port); + return -1; } int diff --git a/readconf.c b/readconf.c index d39cfa3c5..433811521 100644 --- a/readconf.c +++ b/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 * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -1158,7 +1158,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) @@ -1168,10 +1181,6 @@ parse_int: *intptr = value; break; - case oConnectionAttempts: - intptr = &options->connection_attempts; - goto parse_int; - case oCiphers: arg = strdelim(&s); if (!arg || *arg == '\0') -- cgit v1.2.3