|
|
f036d1 |
From 095d4cf3b1c388b2871e3783f8c41b1e01200a25 Mon Sep 17 00:00:00 2001
|
|
|
f036d1 |
From: =?UTF-8?q?Felix=20H=C3=A4dicke?= <felixhaedicke@web.de>
|
|
|
f036d1 |
Date: Wed, 23 Jan 2019 23:47:55 +0100
|
|
|
f036d1 |
Subject: [PATCH] libssh: do not let libssh create socket
|
|
|
f036d1 |
|
|
|
f036d1 |
By default, libssh creates a new socket, instead of using the socket
|
|
|
f036d1 |
created by curl for SSH connections.
|
|
|
f036d1 |
|
|
|
f036d1 |
Pass the socket created by curl to libssh using ssh_options_set() with
|
|
|
f036d1 |
SSH_OPTIONS_FD directly after ssh_new(). So libssh uses our socket
|
|
|
f036d1 |
instead of creating a new one.
|
|
|
f036d1 |
|
|
|
f036d1 |
This approach is very similar to what is done in the libssh2 code, where
|
|
|
f036d1 |
the socket created by curl is passed to libssh2 when
|
|
|
f036d1 |
libssh2_session_startup() is called.
|
|
|
f036d1 |
|
|
|
f036d1 |
Fixes #3491
|
|
|
f036d1 |
Closes #3495
|
|
|
f036d1 |
|
|
|
f036d1 |
Upstream-commit: 15c94b310bf9e0c92d71fca5a88eb67a1e2548a6
|
|
|
f036d1 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
f036d1 |
---
|
|
|
f036d1 |
lib/ssh-libssh.c | 6 +++++-
|
|
|
f036d1 |
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
f036d1 |
|
|
|
f036d1 |
diff --git a/lib/ssh-libssh.c b/lib/ssh-libssh.c
|
|
|
f036d1 |
index 7d59089..4110be2 100644
|
|
|
f036d1 |
--- a/lib/ssh-libssh.c
|
|
|
f036d1 |
+++ b/lib/ssh-libssh.c
|
|
|
f036d1 |
@@ -549,6 +549,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
|
|
|
f036d1 |
struct Curl_easy *data = conn->data;
|
|
|
f036d1 |
struct SSHPROTO *protop = data->req.protop;
|
|
|
f036d1 |
struct ssh_conn *sshc = &conn->proto.sshc;
|
|
|
f036d1 |
+ curl_socket_t sock = conn->sock[FIRSTSOCKET];
|
|
|
f036d1 |
int rc = SSH_NO_ERROR, err;
|
|
|
f036d1 |
char *new_readdir_line;
|
|
|
f036d1 |
int seekerr = CURL_SEEKFUNC_OK;
|
|
|
f036d1 |
@@ -792,7 +793,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
|
|
|
f036d1 |
|
|
|
f036d1 |
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSH is connected */
|
|
|
f036d1 |
|
|
|
f036d1 |
- conn->sockfd = ssh_get_fd(sshc->ssh_session);
|
|
|
f036d1 |
+ conn->sockfd = sock;
|
|
|
f036d1 |
conn->writesockfd = CURL_SOCKET_BAD;
|
|
|
f036d1 |
|
|
|
f036d1 |
if(conn->handler->protocol == CURLPROTO_SFTP) {
|
|
|
f036d1 |
@@ -2048,6 +2049,7 @@ static CURLcode myssh_connect(struct connectdata *conn, bool *done)
|
|
|
f036d1 |
{
|
|
|
f036d1 |
struct ssh_conn *ssh;
|
|
|
f036d1 |
CURLcode result;
|
|
|
f036d1 |
+ curl_socket_t sock = conn->sock[FIRSTSOCKET];
|
|
|
f036d1 |
struct Curl_easy *data = conn->data;
|
|
|
f036d1 |
int rc;
|
|
|
f036d1 |
|
|
|
f036d1 |
@@ -2076,6 +2078,8 @@ static CURLcode myssh_connect(struct connectdata *conn, bool *done)
|
|
|
f036d1 |
return CURLE_FAILED_INIT;
|
|
|
f036d1 |
}
|
|
|
f036d1 |
|
|
|
f036d1 |
+ ssh_options_set(ssh->ssh_session, SSH_OPTIONS_FD, &sock);
|
|
|
f036d1 |
+
|
|
|
f036d1 |
if(conn->user) {
|
|
|
f036d1 |
infof(data, "User: %s\n", conn->user);
|
|
|
f036d1 |
ssh_options_set(ssh->ssh_session, SSH_OPTIONS_USER, conn->user);
|
|
|
f036d1 |
--
|
|
|
f036d1 |
2.17.2
|
|
|
f036d1 |
|