Skip to content

Commit c514f3c

Browse files
djmdjmdaztucker
authored andcommitted
upstream: avoid spurious "Unable to load host key" message when
sshd can load a private key but no public counterpart; with & ok markus@ OpenBSD-Commit-ID: 0713cbdf9aa1ff8ac7b1f78b09ac911af510f81b
1 parent 7fafaeb commit c514f3c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

authfile.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: authfile.c,v 1.140 2020/04/17 07:15:11 djm Exp $ */
1+
/* $OpenBSD: authfile.c,v 1.141 2020/06/18 23:33:38 djm Exp $ */
22
/*
33
* Copyright (c) 2000, 2013 Markus Friedl. All rights reserved.
44
*
@@ -263,7 +263,7 @@ int
263263
sshkey_load_public(const char *filename, struct sshkey **keyp, char **commentp)
264264
{
265265
char *pubfile = NULL;
266-
int r;
266+
int r, oerrno;
267267

268268
if (keyp != NULL)
269269
*keyp = NULL;
@@ -283,8 +283,14 @@ sshkey_load_public(const char *filename, struct sshkey **keyp, char **commentp)
283283
if ((r = sshkey_load_pubkey_from_private(filename, keyp)) == 0)
284284
goto out;
285285

286+
/* Pretend we couldn't find the key */
287+
r = SSH_ERR_SYSTEM_ERROR;
288+
errno = ENOENT;
289+
286290
out:
291+
oerrno = errno;
287292
free(pubfile);
293+
errno = oerrno;
288294
return r;
289295
}
290296

0 commit comments

Comments
 (0)