summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/servconf.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2018-11-19 04:12:33 +0000
committerDamien Miller <djm@cvs.openbsd.org>2018-11-19 04:12:33 +0000
commitebda086837a48331ae1018e347a1bf12fdcb3035 (patch)
tree00e1178398b382410ae08bac269fa0c6d597f7bf /usr.bin/ssh/servconf.c
parent38b169160a5a9a7c60665aa58c57c1f344de1c67 (diff)
silence (to log level debug2) failure messages when loading the default
hostkeys. Hostkeys explicitly specified in the configuration or on the command-line are still reported as errors, and failure to load at least one host key remains a fatal error. Based on patch from Dag-Erling Smørgrav via https://github.com/openssh/openssh-portable/pull/103 ok markus@
Diffstat (limited to 'usr.bin/ssh/servconf.c')
-rw-r--r--usr.bin/ssh/servconf.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c
index b088c7896cf..0dd5e237239 100644
--- a/usr.bin/ssh/servconf.c
+++ b/usr.bin/ssh/servconf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: servconf.c,v 1.343 2018/11/16 03:26:01 djm Exp $ */
+/* $OpenBSD: servconf.c,v 1.344 2018/11/19 04:12:32 djm Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -207,26 +207,40 @@ assemble_algorithms(ServerOptions *o)
}
static void
-array_append(const char *file, const int line, const char *directive,
- char ***array, u_int *lp, const char *s)
+array_append2(const char *file, const int line, const char *directive,
+ char ***array, int **iarray, u_int *lp, const char *s, int i)
{
if (*lp >= INT_MAX)
fatal("%s line %d: Too many %s entries", file, line, directive);
+ if (iarray != NULL) {
+ *iarray = xrecallocarray(*iarray, *lp, *lp + 1,
+ sizeof(**iarray));
+ (*iarray)[*lp] = i;
+ }
+
*array = xrecallocarray(*array, *lp, *lp + 1, sizeof(**array));
(*array)[*lp] = xstrdup(s);
(*lp)++;
}
+static void
+array_append(const char *file, const int line, const char *directive,
+ char ***array, u_int *lp, const char *s)
+{
+ array_append2(file, line, directive, array, NULL, lp, s, 0);
+}
+
void
servconf_add_hostkey(const char *file, const int line,
- ServerOptions *options, const char *path)
+ ServerOptions *options, const char *path, int userprovided)
{
char *apath = derelativise_path(path);
- array_append(file, line, "HostKey",
- &options->host_key_files, &options->num_host_key_files, apath);
+ array_append2(file, line, "HostKey",
+ &options->host_key_files, &options->host_key_file_userprovided,
+ &options->num_host_key_files, apath, userprovided);
free(apath);
}
@@ -249,14 +263,14 @@ fill_default_server_options(ServerOptions *options)
if (options->num_host_key_files == 0) {
/* fill default hostkeys */
servconf_add_hostkey("[default]", 0, options,
- _PATH_HOST_RSA_KEY_FILE);
+ _PATH_HOST_RSA_KEY_FILE, 0);
servconf_add_hostkey("[default]", 0, options,
- _PATH_HOST_ECDSA_KEY_FILE);
+ _PATH_HOST_ECDSA_KEY_FILE, 0);
servconf_add_hostkey("[default]", 0, options,
- _PATH_HOST_ED25519_KEY_FILE);
+ _PATH_HOST_ED25519_KEY_FILE, 0);
#ifdef WITH_XMSS
servconf_add_hostkey("[default]", 0, options,
- _PATH_HOST_XMSS_KEY_FILE);
+ _PATH_HOST_XMSS_KEY_FILE, 0);
#endif /* WITH_XMSS */
}
/* No certificates by default */
@@ -1292,8 +1306,10 @@ process_server_config_line(ServerOptions *options, char *line,
if (!arg || *arg == '\0')
fatal("%s line %d: missing file name.",
filename, linenum);
- if (*activep)
- servconf_add_hostkey(filename, linenum, options, arg);
+ if (*activep) {
+ servconf_add_hostkey(filename, linenum,
+ options, arg, 1);
+ }
break;
case sHostKeyAgent: