diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2000-05-01 18:41:07 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2000-05-01 18:41:07 +0000 |
commit | 756fb52ccabcff6737e97484a6d22b480f8f92d4 (patch) | |
tree | cbb8cdc274a06cd93e695b90b63afbc38e4b4043 /usr.bin/ssh | |
parent | 606c6463cf1051e348d6bfd50cdb7f398b092cc6 (diff) |
check whether file exists before asking for passphrase
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/sshconnect2.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/ssh/sshconnect2.c b/usr.bin/ssh/sshconnect2.c index 31ef3084c87..a4342e2df08 100644 --- a/usr.bin/ssh/sshconnect2.c +++ b/usr.bin/ssh/sshconnect2.c @@ -28,7 +28,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect2.c,v 1.4 2000/04/27 17:54:01 markus Exp $"); +RCSID("$OpenBSD: sshconnect2.c,v 1.5 2000/05/01 18:41:06 markus Exp $"); #include <openssl/bn.h> #include <openssl/rsa.h> @@ -310,7 +310,12 @@ ssh2_try_pubkey(char *filename, Key *k; unsigned char *blob, *signature; int bloblen, slen; + struct stat st; + if (stat(filename, &st) != 0) { + debug("key does not exist: %s", filename); + return 0; + } debug("try pubkey: %s", filename); k = key_new(KEY_DSA); @@ -318,9 +323,9 @@ ssh2_try_pubkey(char *filename, int success = 0; char *passphrase; char prompt[300]; - snprintf(prompt, sizeof prompt, + snprintf(prompt, sizeof prompt, "Enter passphrase for DSA key '%.100s': ", - filename); + filename); passphrase = read_passphrase(prompt, 0); success = load_private_key(filename, passphrase, k, NULL); memset(passphrase, 0, strlen(passphrase)); |