From 96084004b699bd8b5abc1c37b3ef4af2e6a37e26 Mon Sep 17 00:00:00 2001 From: Ryo Nakamura Date: Wed, 7 Feb 2024 13:29:45 +0900 Subject: cleanup error message handling The top-level funtion in a thread should print errors using priv_get_err(), while lower-level functions should set error messages using priv_set_err() except that error mesesages should be printed immediately, e.g., under walk_src_path(). --- src/ssh.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ssh.c') diff --git a/src/ssh.c b/src/ssh.c index 7f003b4..d9a6a2d 100644 --- a/src/ssh.c +++ b/src/ssh.c @@ -186,6 +186,7 @@ static ssh_session ssh_init_session(const char *sshdst, struct mscp_ssh_opts *op } if (!opts->no_hostkey_check && ssh_verify_known_hosts(ssh) != 0) { + priv_set_errv("ssh_veriy_known_hosts failed"); goto disconnect_out; } @@ -203,9 +204,8 @@ sftp_session ssh_init_sftp_session(const char *sshdst, struct mscp_ssh_opts *opt sftp_session sftp; ssh_session ssh = ssh_init_session(sshdst, opts); - if (!ssh) { + if (!ssh) return NULL; - } sftp = sftp_new(ssh); if (!sftp) { @@ -304,7 +304,7 @@ static int ssh_verify_known_hosts(ssh_session session) break; case SSH_KNOWN_HOSTS_ERROR: - priv_set_errv("known hosts error: %s", ssh_get_error(session)); + fprintf(stderr, "known hosts error: %s", ssh_get_error(session)); ssh_clean_pubkey_hash(&hash); return -1; } -- cgit v1.2.3