diff options
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r-- | usr.bin/ssh/ssh.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index d96fba9b401..3b5ea99148f 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh.c,v 1.493 2018/09/21 03:11:36 djm Exp $ */ +/* $OpenBSD: ssh.c,v 1.494 2018/10/03 06:38:35 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -1421,9 +1421,27 @@ main(int ac, char **av) "r", options.user, "u", pw->pw_name, (char *)NULL); - setenv(SSH_AUTHSOCKET_ENV_NAME, cp, 1); - free(cp); free(p); + /* + * If identity_agent represents an environment variable + * then recheck that it is valid (since processing with + * percent_expand() may have changed it) and substitute + * its value. + */ + if (cp[0] == '$') { + if (!valid_env_name(cp + 1)) { + fatal("Invalid IdentityAgent " + "environment variable name %s", cp); + } + if ((p = getenv(cp + 1)) == NULL) + unsetenv(SSH_AUTHSOCKET_ENV_NAME); + else + setenv(SSH_AUTHSOCKET_ENV_NAME, p, 1); + } else { + /* identity_agent specifies a path directly */ + setenv(SSH_AUTHSOCKET_ENV_NAME, cp, 1); + } + free(cp); } } |