[openssh-commits] [openssh] 07/08: upstream commit

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Sep 16 17:52:21 AEST 2015


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 2681cdb6e0de7c1af549dac37a9531af202b4434
Author: tim at openbsd.org <tim at openbsd.org>
Date:   Sun Sep 13 13:48:19 2015 +0000

    upstream commit
    
    When adding keys to the agent, don't ignore the comment
     of keys for which the user is prompted for a passphrase.
    
    Tweak and OK djm@
    
    Upstream-ID: dc737c620a5a8d282cc4f66e3b9b624e9abefbec
---
 ssh-add.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/ssh-add.c b/ssh-add.c
index d6271d7..c2be36d 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-add.c,v 1.123 2015/07/03 03:43:18 djm Exp $ */
+/* $OpenBSD: ssh-add.c,v 1.124 2015/09/13 13:48:19 tim Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -93,7 +93,7 @@ static int lifetime = 0;
 /* User has to confirm key use */
 static int confirm = 0;
 
-/* we keep a cache of one passphrases */
+/* we keep a cache of one passphrase */
 static char *pass = NULL;
 static void
 clear_pass(void)
@@ -234,19 +234,17 @@ add_file(int agent_fd, const char *filename, int key_only)
 			goto fail_load;
 		}
 	}
-	if (comment == NULL)
-		comment = xstrdup(filename);
 	if (private == NULL) {
 		/* clear passphrase since it did not work */
 		clear_pass();
-		snprintf(msg, sizeof msg, "Enter passphrase for %.200s%s: ",
-		    comment, confirm ? " (will confirm each use)" : "");
+		snprintf(msg, sizeof msg, "Enter passphrase for %s%s: ",
+		    filename, confirm ? " (will confirm each use)" : "");
 		for (;;) {
 			pass = read_passphrase(msg, RP_ALLOW_STDIN);
 			if (strcmp(pass, "") == 0)
 				goto fail_load;
 			if ((r = sshkey_parse_private_fileblob(keyblob, pass,
-			    filename, &private, NULL)) == 0)
+			    filename, &private, &comment)) == 0)
 				break;
 			else if (r != SSH_ERR_KEY_WRONG_PASSPHRASE) {
 				fprintf(stderr,
@@ -254,16 +252,17 @@ add_file(int agent_fd, const char *filename, int key_only)
 				    filename, ssh_err(r));
  fail_load:
 				clear_pass();
-				free(comment);
 				sshbuf_free(keyblob);
 				return -1;
 			}
 			clear_pass();
 			snprintf(msg, sizeof msg,
-			    "Bad passphrase, try again for %.200s%s: ", comment,
+			    "Bad passphrase, try again for %s%s: ", filename,
 			    confirm ? " (will confirm each use)" : "");
 		}
 	}
+	if (comment == NULL || *comment == '\0')
+		comment = xstrdup(filename);
 	sshbuf_free(keyblob);
 
 	if ((r = ssh_add_identity_constrained(agent_fd, private, comment,

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list