summaryrefslogtreecommitdiff
path: root/ssh-keygen.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r--ssh-keygen.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 2c0543c96..3c2bd964a 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.271 2015/04/27 01:52:30 djm Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.272 2015/05/21 12:01:19 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1078,6 +1078,12 @@ static int
1078known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx) 1078known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
1079{ 1079{
1080 struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx; 1080 struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx;
1081 enum sshkey_fp_rep rep;
1082 int fptype;
1083 char *fp;
1084
1085 fptype = print_bubblebabble ? SSH_DIGEST_SHA1 : fingerprint_hash;
1086 rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_DEFAULT;
1081 1087
1082 if (l->status == HKF_STATUS_MATCHED) { 1088 if (l->status == HKF_STATUS_MATCHED) {
1083 if (delete_host) { 1089 if (delete_host) {
@@ -1106,7 +1112,12 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
1106 } 1112 }
1107 if (hash_hosts) 1113 if (hash_hosts)
1108 known_hosts_hash(l, ctx); 1114 known_hosts_hash(l, ctx);
1109 else 1115 else if (print_fingerprint) {
1116 fp = sshkey_fingerprint(l->key, fptype, rep);
1117 printf("%s %s %s %s\n", ctx->host,
1118 sshkey_type(l->key), fp, l->comment);
1119 free(fp);
1120 } else
1110 fprintf(ctx->out, "%s\n", l->line); 1121 fprintf(ctx->out, "%s\n", l->line);
1111 return 0; 1122 return 0;
1112 } 1123 }
@@ -1127,6 +1138,7 @@ do_known_hosts(struct passwd *pw, const char *name)
1127 char *cp, tmp[PATH_MAX], old[PATH_MAX]; 1138 char *cp, tmp[PATH_MAX], old[PATH_MAX];
1128 int r, fd, oerrno, inplace = 0; 1139 int r, fd, oerrno, inplace = 0;
1129 struct known_hosts_ctx ctx; 1140 struct known_hosts_ctx ctx;
1141 u_int foreach_options;
1130 1142
1131 if (!have_identity) { 1143 if (!have_identity) {
1132 cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid); 1144 cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid);
@@ -1163,9 +1175,11 @@ do_known_hosts(struct passwd *pw, const char *name)
1163 } 1175 }
1164 1176
1165 /* XXX support identity_file == "-" for stdin */ 1177 /* XXX support identity_file == "-" for stdin */
1178 foreach_options = find_host ? HKF_WANT_MATCH : 0;
1179 foreach_options |= print_fingerprint ? HKF_WANT_PARSE_KEY : 0;
1166 if ((r = hostkeys_foreach(identity_file, 1180 if ((r = hostkeys_foreach(identity_file,
1167 hash_hosts ? known_hosts_hash : known_hosts_find_delete, &ctx, 1181 hash_hosts ? known_hosts_hash : known_hosts_find_delete, &ctx,
1168 name, NULL, find_host ? HKF_WANT_MATCH : 0)) != 0) 1182 name, NULL, foreach_options)) != 0)
1169 fatal("%s: hostkeys_foreach failed: %s", __func__, ssh_err(r)); 1183 fatal("%s: hostkeys_foreach failed: %s", __func__, ssh_err(r));
1170 1184
1171 if (inplace) 1185 if (inplace)