summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2019-01-26 22:35:02 +0000
committerDamien Miller <djm@cvs.openbsd.org>2019-01-26 22:35:02 +0000
commitf9d5baaa16fc4111d666575c00d389479cfdebc2 (patch)
treefaf08d0570bad8a641afea20a8db5b5058aa64e7 /usr.bin
parent042268021feed772572580e119aac2a69754c487 (diff)
make ssh-keyscan return a non-zero exit status if it finds no keys.
bz#2903
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/ssh-keyscan.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c
index 1e76f3fa470..9e783b604d0 100644
--- a/usr.bin/ssh/ssh-keyscan.c
+++ b/usr.bin/ssh/ssh-keyscan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keyscan.c,v 1.125 2019/01/21 10:38:54 djm Exp $ */
+/* $OpenBSD: ssh-keyscan.c,v 1.126 2019/01/26 22:35:01 djm Exp $ */
/*
* Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
*
@@ -64,6 +64,8 @@ int hash_hosts = 0; /* Hash hostname on output */
int print_sshfp = 0; /* Print SSHFP records instead of known_hosts */
+int found_one = 0; /* Successfully found a key */
+
#define MAXMAXFD 256
/* The number of seconds after which to give up on a TCP connection */
@@ -269,6 +271,8 @@ keyprint_one(const char *host, struct sshkey *key)
char *hostport;
const char *known_host, *hashed;
+ found_one = 1;
+
if (print_sshfp) {
export_dns_rr(host, key, stdout, 0);
return;
@@ -782,5 +786,5 @@ main(int argc, char **argv)
while (ncon > 0)
conloop();
- return (0);
+ return found_one ? 0 : 1;
}