summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-09-14 09:45:03 +1000
committerDamien Miller <djm@mindrot.org>2013-09-14 09:45:03 +1000
commit660854859cad31d234edb9353fb7ca2780df8128 (patch)
treeb445d042762c31c679390f97fffd1bb194140bb0
parent045bda5cb8acf0eb9d71c275ee1247e3154fc9e5 (diff)
- mikeb@cvs.openbsd.org 2013/08/28 12:34:27
[ssh-keygen.c] improve batch processing a bit by making use of the quite flag a bit more often and exit with a non zero code if asked to find a hostname in a known_hosts file and it wasn't there; originally from reyk@, ok djm
-rw-r--r--ChangeLog6
-rw-r--r--ssh-keygen.c25
2 files changed, 21 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a8d6c274..67ea2804 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,12 @@
Stir PRNG after post-accept fork. The child gets a different PRNG state
anyway via rexec and explicit privsep reseeds, but it's good to be sure.
ok markus@
+ - mikeb@cvs.openbsd.org 2013/08/28 12:34:27
+ [ssh-keygen.c]
+ improve batch processing a bit by making use of the quite flag a bit
+ more often and exit with a non zero code if asked to find a hostname
+ in a known_hosts file and it wasn't there;
+ originally from reyk@, ok djm
20130828
- (djm) [openbsd-compat/bsd-snprintf.c] teach our local snprintf code the
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 6ee8145a..9c19f00d 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.232 2013/08/13 18:33:08 djm Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.233 2013/08/28 12:34:27 mikeb Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1001,6 +1001,7 @@ do_known_hosts(struct passwd *pw, const char *name)
char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN];
int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0;
int ca;
+ int found_key = 0;
if (!have_identity) {
cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid);
@@ -1103,11 +1104,13 @@ do_known_hosts(struct passwd *pw, const char *name)
}
c = (strcmp(cp2, cp) == 0);
if (find_host && c) {
- printf("# Host %s found: "
- "line %d type %s%s\n", name,
- num, key_type(pub),
- ca ? " (CA key)" : "");
+ if (!quiet)
+ printf("# Host %s found: "
+ "line %d type %s%s\n", name,
+ num, key_type(pub),
+ ca ? " (CA key)" : "");
printhost(out, cp, pub, ca, 0);
+ found_key = 1;
}
if (delete_host) {
if (!c && !ca)
@@ -1124,12 +1127,14 @@ do_known_hosts(struct passwd *pw, const char *name)
c = (match_hostname(name, cp,
strlen(cp)) == 1);
if (find_host && c) {
- printf("# Host %s found: "
- "line %d type %s%s\n", name,
- num, key_type(pub),
- ca ? " (CA key)" : "");
+ if (!quiet)
+ printf("# Host %s found: "
+ "line %d type %s%s\n", name,
+ num, key_type(pub),
+ ca ? " (CA key)" : "");
printhost(out, name, pub,
ca, hash_hosts && !ca);
+ found_key = 1;
}
if (delete_host) {
if (!c && !ca)
@@ -1205,7 +1210,7 @@ do_known_hosts(struct passwd *pw, const char *name)
}
}
- exit(0);
+ exit (find_host && !found_key);
}
/*