Blame SOURCES/0014-curl-7.61.1-libssh-socket.patch

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