summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-01-26 22:35:01 +0000
committerDamien Miller <djm@mindrot.org>2019-01-27 09:42:19 +1100
commitc2c18a39683db382a15b438632afab3f551d50ce (patch)
tree19d3fcface81337f2793de0949283bbcf78bd1db
parent05b9a466700b44d49492edc2aa415fc2e8913dfe (diff)
upstream: make ssh-keyscan return a non-zero exit status if it
finds no keys. bz#2903 OpenBSD-Commit-ID: 89f1081fb81d950ebb48e6e73d21807b2723d488
-rw-r--r--ssh-keyscan.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 144daa6df..2ed041559 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keyscan.c,v 1.125 2019/01/21 10:38:54 djm Exp $ */ 1/* $OpenBSD: ssh-keyscan.c,v 1.126 2019/01/26 22:35:01 djm Exp $ */
2/* 2/*
3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4 * 4 *
@@ -70,6 +70,8 @@ int hash_hosts = 0; /* Hash hostname on output */
70 70
71int print_sshfp = 0; /* Print SSHFP records instead of known_hosts */ 71int print_sshfp = 0; /* Print SSHFP records instead of known_hosts */
72 72
73int found_one = 0; /* Successfully found a key */
74
73#define MAXMAXFD 256 75#define MAXMAXFD 256
74 76
75/* The number of seconds after which to give up on a TCP connection */ 77/* The number of seconds after which to give up on a TCP connection */
@@ -287,6 +289,8 @@ keyprint_one(const char *host, struct sshkey *key)
287 char *hostport; 289 char *hostport;
288 const char *known_host, *hashed; 290 const char *known_host, *hashed;
289 291
292 found_one = 1;
293
290 if (print_sshfp) { 294 if (print_sshfp) {
291 export_dns_rr(host, key, stdout, 0); 295 export_dns_rr(host, key, stdout, 0);
292 return; 296 return;
@@ -802,5 +806,5 @@ main(int argc, char **argv)
802 while (ncon > 0) 806 while (ncon > 0)
803 conloop(); 807 conloop();
804 808
805 return (0); 809 return found_one ? 0 : 1;
806} 810}