mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
knownhosts: Read knownhosts file only if found
Avoid trying to open the files if they are not accessible. This was
already treated as a non-error, but with this we save one function call.
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit e5a64a3d6b)
This commit is contained in:
@@ -691,7 +691,7 @@ enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session)
|
|||||||
return SSH_KNOWN_HOSTS_ERROR;
|
return SSH_KNOWN_HOSTS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session->opts.knownhosts != NULL) {
|
if (known_hosts_found) {
|
||||||
rc = ssh_known_hosts_read_entries(host_port,
|
rc = ssh_known_hosts_read_entries(host_port,
|
||||||
session->opts.knownhosts,
|
session->opts.knownhosts,
|
||||||
&entry_list);
|
&entry_list);
|
||||||
@@ -702,7 +702,7 @@ enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session->opts.global_knownhosts != NULL) {
|
if (global_known_hosts_found) {
|
||||||
rc = ssh_known_hosts_read_entries(host_port,
|
rc = ssh_known_hosts_read_entries(host_port,
|
||||||
session->opts.global_knownhosts,
|
session->opts.global_knownhosts,
|
||||||
&entry_list);
|
&entry_list);
|
||||||
|
|||||||
Reference in New Issue
Block a user