diff options
author | jcs@openbsd.org <jcs@openbsd.org> | 2015-11-15 22:26:49 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-11-16 11:31:39 +1100 |
commit | f361df474c49a097bfcf16d1b7b5c36fcd844b4b (patch) | |
tree | 493beb15e73f9b57f42244e8c927bdf75480188f /sshconnect1.c | |
parent | d87063d9baf5479b6e813d47dfb694a97df6f6f5 (diff) |
upstream commit
Add an AddKeysToAgent client option which can be set to
'yes', 'no', 'ask', or 'confirm', and defaults to 'no'. When enabled, a
private key that is used during authentication will be added to ssh-agent if
it is running (with confirmation enabled if set to 'confirm').
Initial version from Joachim Schipper many years ago.
ok markus@
Upstream-ID: a680db2248e8064ec55f8be72d539458c987d5f4
Diffstat (limited to 'sshconnect1.c')
-rw-r--r-- | sshconnect1.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sshconnect1.c b/sshconnect1.c index 016abbce5..bfc523bde 100644 --- a/sshconnect1.c +++ b/sshconnect1.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshconnect1.c,v 1.77 2015/01/14 20:05:27 djm Exp $ */ | 1 | /* $OpenBSD: sshconnect1.c,v 1.78 2015/11/15 22:26:49 jcs 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 |
@@ -221,7 +221,7 @@ try_rsa_authentication(int idx) | |||
221 | { | 221 | { |
222 | BIGNUM *challenge; | 222 | BIGNUM *challenge; |
223 | Key *public, *private; | 223 | Key *public, *private; |
224 | char buf[300], *passphrase, *comment, *authfile; | 224 | char buf[300], *passphrase = NULL, *comment, *authfile; |
225 | int i, perm_ok = 1, type, quit; | 225 | int i, perm_ok = 1, type, quit; |
226 | 226 | ||
227 | public = options.identity_keys[idx]; | 227 | public = options.identity_keys[idx]; |
@@ -283,13 +283,20 @@ try_rsa_authentication(int idx) | |||
283 | debug2("no passphrase given, try next key"); | 283 | debug2("no passphrase given, try next key"); |
284 | quit = 1; | 284 | quit = 1; |
285 | } | 285 | } |
286 | explicit_bzero(passphrase, strlen(passphrase)); | ||
287 | free(passphrase); | ||
288 | if (private != NULL || quit) | 286 | if (private != NULL || quit) |
289 | break; | 287 | break; |
290 | debug2("bad passphrase given, try again..."); | 288 | debug2("bad passphrase given, try again..."); |
291 | } | 289 | } |
292 | } | 290 | } |
291 | |||
292 | if (private != NULL) | ||
293 | maybe_add_key_to_agent(authfile, private, comment, passphrase); | ||
294 | |||
295 | if (passphrase != NULL) { | ||
296 | explicit_bzero(passphrase, strlen(passphrase)); | ||
297 | free(passphrase); | ||
298 | } | ||
299 | |||
293 | /* We no longer need the comment. */ | 300 | /* We no longer need the comment. */ |
294 | free(comment); | 301 | free(comment); |
295 | 302 | ||