[openssh-commits] [openssh] 77/87: upstream: when updating known_hosts files for UpdateHostKeys,
git+noreply at mindrot.org
git+noreply at mindrot.org
Fri Oct 30 20:21:54 AEDT 2026
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 6321396a87a325fb3b932c55428b8ecde1c8d82f
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Fri Oct 30 09:00:39 2026 +0000
upstream: when updating known_hosts files for UpdateHostKeys,
bail out if the unable to write to the first known_hosts file in the list.
Avoids a situation where a host key could be fully removed from all
known_hosts files.
Anthropic ANT-2026-YH3JNW7S
OpenBSD-Commit-ID: 88594d6e53dd23d6fad98c36df1e220bcfdf2bee
---
clientloop.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/clientloop.c b/clientloop.c
index 6e6526aee..74a4751a1 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.c,v 1.428 2026/10/30 08:39:48 djm Exp $ */
+/* $OpenBSD: clientloop.c,v 1.429 2026/10/30 09:00:39 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo at cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -2343,7 +2343,10 @@ update_known_hosts(struct hostkeys_update_ctx *ctx)
for (i = 0; i < options.num_user_hostfiles; i++) {
/*
* NB. keys are only added to hostfiles[0], for the rest we
- * just delete the hostname entries.
+ * just delete the hostname entries. If the keys could not be
+ * written to hostfiles[0] then leave the remaining files
+ * untouched, otherwise the host's existing entries there
+ * would be deleted without being recorded anywhere.
*/
if (stat(options.user_hostfiles[i], &sb) != 0) {
if (errno == ENOENT) {
@@ -2354,6 +2357,8 @@ update_known_hosts(struct hostkeys_update_ctx *ctx)
"inaccessible: %s",
options.user_hostfiles[i], strerror(errno));
}
+ if (i == 0)
+ break;
continue;
}
if ((r = hostfile_replace_entries(options.user_hostfiles[i],
@@ -2363,6 +2368,8 @@ update_known_hosts(struct hostkeys_update_ctx *ctx)
options.fingerprint_hash)) != 0) {
error_fr(r, "hostfile_replace_entries failed for %s",
options.user_hostfiles[i]);
+ if (i == 0)
+ break;
}
}
}
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list