aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-02-09 18:29:52 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-02-09 18:29:52 +0100
commitecd5514a5a1bde7dc4261b0a3d17c222b3e5e58d (patch)
tree7bc16d77547cfb9124bb561031e83d98ab222b89
parenta24478c4683b6edba75dbb55db41adba34389ce6 (diff)
downloadcsync-ecd5514a5a1bde7dc4261b0a3d17c222b3e5e58d.tar.gz
csync-ecd5514a5a1bde7dc4261b0a3d17c222b3e5e58d.tar.xz
csync-ecd5514a5a1bde7dc4261b0a3d17c222b3e5e58d.zip
sftp: Use new ssh_get_publickey_hash() function
-rw-r--r--modules/csync_sftp.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/csync_sftp.c b/modules/csync_sftp.c
index 57359a4..adae541 100644
--- a/modules/csync_sftp.c
+++ b/modules/csync_sftp.c
@@ -156,13 +156,14 @@ static int _sftp_connect(const char *uri) {
char *host = NULL;
unsigned int port = 0;
unsigned char *hash = NULL;
- int hlen;
+ size_t hlen = 0;
int rc = -1;
int state = SSH_SERVER_ERROR;
int timeout = 10;
int method;
char *verbosity;
char errbuf[256] = {0};
+ ssh_key srv_pubkey;
if (_connected) {
return 0;
@@ -269,8 +270,19 @@ static int _sftp_connect(const char *uri) {
goto out;
}
- hlen = ssh_get_pubkey_hash(_ssh_session, &hash);
- if (hlen < 0) {
+ rc = ssh_get_publickey(_ssh_session, &srv_pubkey);
+ if (rc < 0) {
+ fprintf(stderr, "csync_sftp - error connecting to the server: %s\n", ssh_get_error(_ssh_session));
+ ssh_disconnect(_ssh_session);
+ _ssh_session = NULL;
+ ssh_finalize();
+ goto out;
+ }
+
+ rc = ssh_get_publickey_hash(srv_pubkey,
+ SSH_PUBLICKEY_HASH_SHA1,
+ &hash, &hlen);
+ if (rc < 0) {
fprintf(stderr, "csync_sftp - error connecting to the server: %s\n",
ssh_get_error(_ssh_session));
ssh_disconnect(_ssh_session);