diff options
author | djm@openbsd.org <djm@openbsd.org> | 2018-10-03 06:38:35 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2018-10-03 16:39:58 +1000 |
commit | 5eff5b858e717e901e6af6596306a114de9f79f2 (patch) | |
tree | 1e89894968478a2c5b44cabd9747fd90d51725e1 /ssh.c | |
parent | a46ac4d86b25414d78b632e8173578b37e5f8a83 (diff) |
upstream: Allow ssh_config IdentityAgent directive to accept
environment variable names as well as explicit paths. ok dtucker@
OpenBSD-Commit-ID: 2f0996e103876c53d8c9dd51dcce9889d700767b
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -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 @@ -1453,9 +1453,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); } } |