diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ssh-keygen.c | 25 |
2 files changed, 21 insertions, 10 deletions
@@ -5,6 +5,12 @@ | |||
5 | Stir PRNG after post-accept fork. The child gets a different PRNG state | 5 | Stir PRNG after post-accept fork. The child gets a different PRNG state |
6 | anyway via rexec and explicit privsep reseeds, but it's good to be sure. | 6 | anyway via rexec and explicit privsep reseeds, but it's good to be sure. |
7 | ok markus@ | 7 | ok markus@ |
8 | - mikeb@cvs.openbsd.org 2013/08/28 12:34:27 | ||
9 | [ssh-keygen.c] | ||
10 | improve batch processing a bit by making use of the quite flag a bit | ||
11 | more often and exit with a non zero code if asked to find a hostname | ||
12 | in a known_hosts file and it wasn't there; | ||
13 | originally from reyk@, ok djm | ||
8 | 14 | ||
9 | 20130828 | 15 | 20130828 |
10 | - (djm) [openbsd-compat/bsd-snprintf.c] teach our local snprintf code the | 16 | - (djm) [openbsd-compat/bsd-snprintf.c] teach our local snprintf code the |
diff --git a/ssh-keygen.c b/ssh-keygen.c index 6ee8145af..9c19f00d0 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keygen.c,v 1.232 2013/08/13 18:33:08 djm Exp $ */ | 1 | /* $OpenBSD: ssh-keygen.c,v 1.233 2013/08/28 12:34:27 mikeb 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 |
@@ -1001,6 +1001,7 @@ do_known_hosts(struct passwd *pw, const char *name) | |||
1001 | char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN]; | 1001 | char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN]; |
1002 | int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0; | 1002 | int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0; |
1003 | int ca; | 1003 | int ca; |
1004 | int found_key = 0; | ||
1004 | 1005 | ||
1005 | if (!have_identity) { | 1006 | if (!have_identity) { |
1006 | cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid); | 1007 | cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid); |
@@ -1103,11 +1104,13 @@ do_known_hosts(struct passwd *pw, const char *name) | |||
1103 | } | 1104 | } |
1104 | c = (strcmp(cp2, cp) == 0); | 1105 | c = (strcmp(cp2, cp) == 0); |
1105 | if (find_host && c) { | 1106 | if (find_host && c) { |
1106 | printf("# Host %s found: " | 1107 | if (!quiet) |
1107 | "line %d type %s%s\n", name, | 1108 | printf("# Host %s found: " |
1108 | num, key_type(pub), | 1109 | "line %d type %s%s\n", name, |
1109 | ca ? " (CA key)" : ""); | 1110 | num, key_type(pub), |
1111 | ca ? " (CA key)" : ""); | ||
1110 | printhost(out, cp, pub, ca, 0); | 1112 | printhost(out, cp, pub, ca, 0); |
1113 | found_key = 1; | ||
1111 | } | 1114 | } |
1112 | if (delete_host) { | 1115 | if (delete_host) { |
1113 | if (!c && !ca) | 1116 | if (!c && !ca) |
@@ -1124,12 +1127,14 @@ do_known_hosts(struct passwd *pw, const char *name) | |||
1124 | c = (match_hostname(name, cp, | 1127 | c = (match_hostname(name, cp, |
1125 | strlen(cp)) == 1); | 1128 | strlen(cp)) == 1); |
1126 | if (find_host && c) { | 1129 | if (find_host && c) { |
1127 | printf("# Host %s found: " | 1130 | if (!quiet) |
1128 | "line %d type %s%s\n", name, | 1131 | printf("# Host %s found: " |
1129 | num, key_type(pub), | 1132 | "line %d type %s%s\n", name, |
1130 | ca ? " (CA key)" : ""); | 1133 | num, key_type(pub), |
1134 | ca ? " (CA key)" : ""); | ||
1131 | printhost(out, name, pub, | 1135 | printhost(out, name, pub, |
1132 | ca, hash_hosts && !ca); | 1136 | ca, hash_hosts && !ca); |
1137 | found_key = 1; | ||
1133 | } | 1138 | } |
1134 | if (delete_host) { | 1139 | if (delete_host) { |
1135 | if (!c && !ca) | 1140 | if (!c && !ca) |
@@ -1205,7 +1210,7 @@ do_known_hosts(struct passwd *pw, const char *name) | |||
1205 | } | 1210 | } |
1206 | } | 1211 | } |
1207 | 1212 | ||
1208 | exit(0); | 1213 | exit (find_host && !found_key); |
1209 | } | 1214 | } |
1210 | 1215 | ||
1211 | /* | 1216 | /* |