version 1.343, 2018/11/16 03:26:01 |
version 1.344, 2018/11/19 04:12:32 |
|
|
} |
} |
|
|
static void |
static void |
array_append(const char *file, const int line, const char *directive, |
array_append2(const char *file, const int line, const char *directive, |
char ***array, u_int *lp, const char *s) |
char ***array, int **iarray, u_int *lp, const char *s, int i) |
{ |
{ |
|
|
if (*lp >= INT_MAX) |
if (*lp >= INT_MAX) |
fatal("%s line %d: Too many %s entries", file, line, directive); |
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 = xrecallocarray(*array, *lp, *lp + 1, sizeof(**array)); |
(*array)[*lp] = xstrdup(s); |
(*array)[*lp] = xstrdup(s); |
(*lp)++; |
(*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 |
void |
servconf_add_hostkey(const char *file, const int line, |
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); |
char *apath = derelativise_path(path); |
|
|
array_append(file, line, "HostKey", |
array_append2(file, line, "HostKey", |
&options->host_key_files, &options->num_host_key_files, apath); |
&options->host_key_files, &options->host_key_file_userprovided, |
|
&options->num_host_key_files, apath, userprovided); |
free(apath); |
free(apath); |
} |
} |
|
|
|
|
if (options->num_host_key_files == 0) { |
if (options->num_host_key_files == 0) { |
/* fill default hostkeys */ |
/* fill default hostkeys */ |
servconf_add_hostkey("[default]", 0, options, |
servconf_add_hostkey("[default]", 0, options, |
_PATH_HOST_RSA_KEY_FILE); |
_PATH_HOST_RSA_KEY_FILE, 0); |
servconf_add_hostkey("[default]", 0, options, |
servconf_add_hostkey("[default]", 0, options, |
_PATH_HOST_ECDSA_KEY_FILE); |
_PATH_HOST_ECDSA_KEY_FILE, 0); |
servconf_add_hostkey("[default]", 0, options, |
servconf_add_hostkey("[default]", 0, options, |
_PATH_HOST_ED25519_KEY_FILE); |
_PATH_HOST_ED25519_KEY_FILE, 0); |
#ifdef WITH_XMSS |
#ifdef WITH_XMSS |
servconf_add_hostkey("[default]", 0, options, |
servconf_add_hostkey("[default]", 0, options, |
_PATH_HOST_XMSS_KEY_FILE); |
_PATH_HOST_XMSS_KEY_FILE, 0); |
#endif /* WITH_XMSS */ |
#endif /* WITH_XMSS */ |
} |
} |
/* No certificates by default */ |
/* No certificates by default */ |
|
|
if (!arg || *arg == '\0') |
if (!arg || *arg == '\0') |
fatal("%s line %d: missing file name.", |
fatal("%s line %d: missing file name.", |
filename, linenum); |
filename, linenum); |
if (*activep) |
if (*activep) { |
servconf_add_hostkey(filename, linenum, options, arg); |
servconf_add_hostkey(filename, linenum, |
|
options, arg, 1); |
|
} |
break; |
break; |
|
|
case sHostKeyAgent: |
case sHostKeyAgent: |