]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: Fix UpdateHostkeys/HashKnownHosts/CheckHostIP bug
authordjm@openbsd.org <djm@openbsd.org>
Wed, 7 Oct 2020 02:25:43 +0000 (02:25 +0000)
committerDamien Miller <djm@mindrot.org>
Wed, 7 Oct 2020 02:34:11 +0000 (13:34 +1100)
When all of UpdateHostkeys, HashKnownHosts and ChechHostIP
were enabled and new host keys were learned, known_hosts IP
entries were not being recorded for new host keys.

reported by matthieu@ ok markus@

OpenBSD-Commit-ID: a654a8290bd1c930aac509e8158cf85e42e49cb7

hostfile.c

index 00462555f8ba7441b40e0d676c78f3f8e9f505cf..650ad66f7f9f8260d384bb22bafe93a7e814408e 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostfile.c,v 1.83 2020/10/04 09:45:01 djm Exp $ */
+/* $OpenBSD: hostfile.c,v 1.84 2020/10/07 02:25:43 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -451,6 +451,9 @@ write_host_entry(FILE *f, const char *host, const char *ip,
        else
                error("%s: sshkey_write failed: %s", __func__, ssh_err(r));
        fputc('\n', f);
+       /* If hashing is enabled, the IP address needs to go on its own line */
+       if (success && store_hash && ip != NULL)
+               success = write_host_entry(f, ip, NULL, key, 1);
        return success;
 }