From 756fb52ccabcff6737e97484a6d22b480f8f92d4 Mon Sep 17 00:00:00 2001 From: Markus Friedl Date: Mon, 1 May 2000 18:41:07 +0000 Subject: check whether file exists before asking for passphrase --- usr.bin/ssh/sshconnect2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'usr.bin') 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 #include @@ -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)); -- cgit v1.2.3