summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-10-03 06:38:35 +0000
committerDamien Miller <djm@mindrot.org>2018-10-03 16:39:58 +1000
commit5eff5b858e717e901e6af6596306a114de9f79f2 (patch)
tree1e89894968478a2c5b44cabd9747fd90d51725e1 /ssh.c
parenta46ac4d86b25414d78b632e8173578b37e5f8a83 (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.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/ssh.c b/ssh.c
index 849fae355..0777c31e4 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.493 2018/09/21 03:11:36 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.494 2018/10/03 06:38:35 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1453,9 +1453,27 @@ main(int ac, char **av)
1453 "r", options.user, 1453 "r", options.user,
1454 "u", pw->pw_name, 1454 "u", pw->pw_name,
1455 (char *)NULL); 1455 (char *)NULL);
1456 setenv(SSH_AUTHSOCKET_ENV_NAME, cp, 1);
1457 free(cp);
1458 free(p); 1456 free(p);
1457 /*
1458 * If identity_agent represents an environment variable
1459 * then recheck that it is valid (since processing with
1460 * percent_expand() may have changed it) and substitute
1461 * its value.
1462 */
1463 if (cp[0] == '$') {
1464 if (!valid_env_name(cp + 1)) {
1465 fatal("Invalid IdentityAgent "
1466 "environment variable name %s", cp);
1467 }
1468 if ((p = getenv(cp + 1)) == NULL)
1469 unsetenv(SSH_AUTHSOCKET_ENV_NAME);
1470 else
1471 setenv(SSH_AUTHSOCKET_ENV_NAME, p, 1);
1472 } else {
1473 /* identity_agent specifies a path directly */
1474 setenv(SSH_AUTHSOCKET_ENV_NAME, cp, 1);
1475 }
1476 free(cp);
1459 } 1477 }
1460 } 1478 }
1461 1479