summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMark Lumsden <lum@cvs.openbsd.org>2019-05-29 08:30:27 +0000
committerMark Lumsden <lum@cvs.openbsd.org>2019-05-29 08:30:27 +0000
commiteb74bd7b0558a0388295471368cde105bb1f7a45 (patch)
treea3c9e1848ddefcdfbf07cc17fdaa7cb89748027e /usr.bin
parent64cd665550ff87107d8bbb7bfd91cfa69e479fd1 (diff)
Make the standard output messages of both methods of changing a key
pair's comments (using -c and -C) more applicable to both methods. ok and suggestions djm@ dtucker@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/ssh-keygen.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c
index b0b1610d22f..773f2437cc1 100644
--- a/usr.bin/ssh/ssh-keygen.c
+++ b/usr.bin/ssh/ssh-keygen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.329 2019/03/25 16:19:44 dtucker Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.330 2019/05/29 08:30:26 lum Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1467,14 +1467,14 @@ do_change_comment(struct passwd *pw, const char *identity_comment)
exit(1);
}
if (comment)
- printf("Key now has comment '%s'\n", comment);
+ printf("Old comment: %s\n", comment);
else
- printf("Key now has no comment\n");
+ printf("No existing comment\n");
if (identity_comment) {
strlcpy(new_comment, identity_comment, sizeof(new_comment));
} else {
- printf("Enter new comment: ");
+ printf("New comment: ");
fflush(stdout);
if (!fgets(new_comment, sizeof(new_comment), stdin)) {
explicit_bzero(passphrase, strlen(passphrase));
@@ -1483,6 +1483,13 @@ do_change_comment(struct passwd *pw, const char *identity_comment)
}
new_comment[strcspn(new_comment, "\n")] = '\0';
}
+ if (comment != NULL && strcmp(comment, new_comment) == 0) {
+ printf("No change to comment\n");
+ free(passphrase);
+ sshkey_free(private);
+ free(comment);
+ exit(0);
+ }
/* Save the file using the new passphrase. */
if ((r = sshkey_save_private(private, identity_file, passphrase,
@@ -1516,7 +1523,11 @@ do_change_comment(struct passwd *pw, const char *identity_comment)
free(comment);
- printf("The comment in your key file has been changed.\n");
+ if (strlen(new_comment) > 0)
+ printf("Comment '%s' applied\n", new_comment);
+ else
+ printf("Comment removed\n");
+
exit(0);
}