known_hosts: Avoid using deprecated functions (even from deprecated functions)

Fixes: T165

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 83fa060cec)
This commit is contained in:
Jakub Jelen
2019-09-13 13:14:35 +02:00
committed by Anderson Toshiyuki Sasaki
parent 93113ccfb9
commit d2af62624d

View File

@@ -405,8 +405,12 @@ int ssh_is_server_known(ssh_session session)
if ((ret == SSH_SERVER_NOT_KNOWN) && if ((ret == SSH_SERVER_NOT_KNOWN) &&
(session->opts.StrictHostKeyChecking == 0)) { (session->opts.StrictHostKeyChecking == 0)) {
ssh_write_knownhost(session); int rv = ssh_session_update_known_hosts(session);
ret = SSH_SERVER_KNOWN_OK; if (rv != SSH_OK) {
ret = SSH_SERVER_ERROR;
} else {
ret = SSH_SERVER_KNOWN_OK;
}
} }
SAFE_FREE(host); SAFE_FREE(host);
@@ -492,9 +496,10 @@ char * ssh_dump_knownhost(ssh_session session) {
* @deprecated Please use ssh_session_update_known_hosts() * @deprecated Please use ssh_session_update_known_hosts()
* @brief This function is deprecated * @brief This function is deprecated
*/ */
int ssh_write_knownhost(ssh_session session) { int ssh_write_knownhost(ssh_session session)
{
FILE *file; FILE *file;
char *buffer; char *buffer = NULL;
char *dir; char *dir;
int rc; int rc;
@@ -542,8 +547,8 @@ int ssh_write_knownhost(ssh_session session) {
} }
} }
buffer = ssh_dump_knownhost(session); rc = ssh_session_export_known_hosts_entry(session, &buffer);
if (buffer == NULL) { if (rc != SSH_OK) {
fclose(file); fclose(file);
return SSH_ERROR; return SSH_ERROR;
} }