]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: avoid spurious "Unable to load host key" message when
authordjm@openbsd.org <djm@openbsd.org>
Thu, 18 Jun 2020 23:33:38 +0000 (23:33 +0000)
committerDarren Tucker <dtucker@dtucker.net>
Fri, 19 Jun 2020 05:51:04 +0000 (15:51 +1000)
sshd can load a private key but no public counterpart; with & ok markus@

OpenBSD-Commit-ID: 0713cbdf9aa1ff8ac7b1f78b09ac911af510f81b

authfile.c

index 35ccf576c2b5f0c9fa9b975f2bb3624fb69f1282..946f50ca8114700982ae7621fbd08f2d6fde4c2c 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: authfile.c,v 1.140 2020/04/17 07:15:11 djm Exp $ */
+/* $OpenBSD: authfile.c,v 1.141 2020/06/18 23:33:38 djm Exp $ */
 /*
  * Copyright (c) 2000, 2013 Markus Friedl.  All rights reserved.
  *
@@ -263,7 +263,7 @@ int
 sshkey_load_public(const char *filename, struct sshkey **keyp, char **commentp)
 {
        char *pubfile = NULL;
-       int r;
+       int r, oerrno;
 
        if (keyp != NULL)
                *keyp = NULL;
@@ -283,8 +283,14 @@ sshkey_load_public(const char *filename, struct sshkey **keyp, char **commentp)
        if ((r = sshkey_load_pubkey_from_private(filename, keyp)) == 0)
                goto out;
 
+       /* Pretend we couldn't find the key */
+       r = SSH_ERR_SYSTEM_ERROR;
+       errno = ENOENT;
+
  out:
+       oerrno = errno;
        free(pubfile);
+       errno = oerrno;
        return r;
 }