diff options
author | dartraiden <wowemuh@gmail.com> | 2020-12-12 21:52:50 +0300 |
---|---|---|
committer | dartraiden <wowemuh@gmail.com> | 2020-12-12 21:52:50 +0300 |
commit | 3b96a0dcef3c7e1de852025cfea5a9e56486021c (patch) | |
tree | e0f3d4006a618993b1c70f507cc32c707db5e73b /libs/libcurl/src/vssh | |
parent | 346d20620a22103175778d0ae96299af9f93c7ea (diff) |
libcurl: update to 7.74.0
Diffstat (limited to 'libs/libcurl/src/vssh')
-rw-r--r-- | libs/libcurl/src/vssh/libssh.c | 33 | ||||
-rw-r--r-- | libs/libcurl/src/vssh/libssh2.c | 90 | ||||
-rw-r--r-- | libs/libcurl/src/vssh/ssh.h | 8 | ||||
-rw-r--r-- | libs/libcurl/src/vssh/wolfssh.c | 10 |
4 files changed, 66 insertions, 75 deletions
diff --git a/libs/libcurl/src/vssh/libssh.c b/libs/libcurl/src/vssh/libssh.c index acdb4e7534..e79d8e823c 100644 --- a/libs/libcurl/src/vssh/libssh.c +++ b/libs/libcurl/src/vssh/libssh.c @@ -12,7 +12,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -664,7 +664,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) { CURLcode result = CURLE_OK; struct Curl_easy *data = conn->data; - struct SSHPROTO *protop = data->req.protop; + struct SSHPROTO *protop = data->req.p.ssh; struct ssh_conn *sshc = &conn->proto.sshc; curl_socket_t sock = conn->sock[FIRSTSOCKET]; int rc = SSH_NO_ERROR, err; @@ -1432,11 +1432,8 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) data->req.bytecount += sshc->readdir_len + 1; /* output debug output if that is requested */ - if(data->set.verbose) { - Curl_debug(data, CURLINFO_DATA_OUT, - (char *)sshc->readdir_filename, - sshc->readdir_len); - } + Curl_debug(data, CURLINFO_DATA_OUT, (char *)sshc->readdir_filename, + sshc->readdir_len); } else { sshc->readdir_currLen = strlen(sshc->readdir_longentry); @@ -1548,12 +1545,9 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) sshc->readdir_currLen); if(!result) { - /* output debug output if that is requested */ - if(data->set.verbose) { - Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line, - sshc->readdir_currLen); - } + Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line, + sshc->readdir_currLen); data->req.bytecount += sshc->readdir_currLen; } Curl_safefree(sshc->readdir_line); @@ -2131,7 +2125,7 @@ static CURLcode myssh_setup_connection(struct connectdata *conn) { struct SSHPROTO *ssh; - conn->data->req.protop = ssh = calloc(1, sizeof(struct SSHPROTO)); + conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); if(!ssh) return CURLE_OUT_OF_MEMORY; @@ -2154,7 +2148,7 @@ static CURLcode myssh_connect(struct connectdata *conn, bool *done) int rc; /* initialize per-handle data if not already */ - if(!data->req.protop) + if(!data->req.p.ssh) myssh_setup_connection(conn); /* We default to persistent connections. We set this already in this connect @@ -2355,7 +2349,7 @@ static CURLcode scp_disconnect(struct connectdata *conn, static CURLcode myssh_done(struct connectdata *conn, CURLcode status) { CURLcode result = CURLE_OK; - struct SSHPROTO *protop = conn->data->req.protop; + struct SSHPROTO *protop = conn->data->req.p.ssh; if(!status) { /* run the state-machine */ @@ -2608,7 +2602,7 @@ static void sftp_quote(struct connectdata *conn) { const char *cp; struct Curl_easy *data = conn->data; - struct SSHPROTO *protop = data->req.protop; + struct SSHPROTO *protop = data->req.p.ssh; struct ssh_conn *sshc = &conn->proto.sshc; CURLcode result; @@ -2638,10 +2632,9 @@ static void sftp_quote(struct connectdata *conn) sshc->nextstate = SSH_NO_STATE; return; } - if(data->set.verbose) { - Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4); - Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp)); - } + Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4); + Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp)); + /* this sends an FTP-like "header" to the header callback so that the current directory can be read very similar to how it is read when using ordinary FTP. */ diff --git a/libs/libcurl/src/vssh/libssh2.c b/libs/libcurl/src/vssh/libssh2.c index d983cc9a9c..a69bcda995 100644 --- a/libs/libcurl/src/vssh/libssh2.c +++ b/libs/libcurl/src/vssh/libssh2.c @@ -9,7 +9,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -798,7 +798,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) { CURLcode result = CURLE_OK; struct Curl_easy *data = conn->data; - struct SSHPROTO *sftp_scp = data->req.protop; + struct SSHPROTO *sftp_scp = data->req.p.ssh; struct ssh_conn *sshc = &conn->proto.sshc; curl_socket_t sock = conn->sock[FIRSTSOCKET]; int rc = LIBSSH2_ERROR_NONE; @@ -1265,7 +1265,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) a time-out or similar */ result = CURLE_SSH; sshc->actualcode = result; - DEBUGF(infof(data, "error = %d makes libcurl = %d\n", + DEBUGF(infof(data, "error = %lu makes libcurl = %d\n", sftperr, (int)result)); state(conn, SSH_STOP); break; @@ -1343,10 +1343,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) sshc->nextstate = SSH_NO_STATE; break; } - if(data->set.verbose) { - Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4); - Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp)); - } + Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4); + Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp)); + /* this sends an FTP-like "header" to the header callback so that the current directory can be read very similar to how it is read when using ordinary FTP. */ @@ -1946,7 +1945,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) sshc->actualcode = CURLE_SSH; sftperr = LIBSSH2_FX_OK; } - failf(data, "Upload failed: %s (%d/%d)", + failf(data, "Upload failed: %s (%lu/%d)", sftperr != LIBSSH2_FX_OK ? sftp_libssh2_strerror(sftperr):"ssh error", sftperr, rc); @@ -2167,11 +2166,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) data->req.bytecount += readdir_len + 1; /* output debug output if that is requested */ - if(data->set.verbose) { - Curl_debug(data, CURLINFO_DATA_IN, sshc->readdir_filename, - readdir_len); - Curl_debug(data, CURLINFO_DATA_IN, (char *)"\n", 1); - } + Curl_debug(data, CURLINFO_DATA_IN, sshc->readdir_filename, + readdir_len); + Curl_debug(data, CURLINFO_DATA_IN, (char *)"\n", 1); } else { result = Curl_dyn_add(&sshc->readdir, sshc->readdir_longentry); @@ -2252,13 +2249,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) Curl_dyn_len(&sshc->readdir)); if(!result) { - /* output debug output if that is requested */ - if(data->set.verbose) { - Curl_debug(data, CURLINFO_DATA_IN, - Curl_dyn_ptr(&sshc->readdir), - Curl_dyn_len(&sshc->readdir)); - } + Curl_debug(data, CURLINFO_DATA_IN, + Curl_dyn_ptr(&sshc->readdir), + Curl_dyn_len(&sshc->readdir)); data->req.bytecount += Curl_dyn_len(&sshc->readdir); } if(result) { @@ -2887,7 +2881,6 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) static int ssh_perform_getsock(const struct connectdata *conn, curl_socket_t *sock) { -#ifdef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION int bitmap = GETSOCK_BLANK; sock[0] = conn->sock[FIRSTSOCKET]; @@ -2899,11 +2892,6 @@ static int ssh_perform_getsock(const struct connectdata *conn, bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET); return bitmap; -#else - /* if we don't know the direction we can use the generic *_getsock() - function even for the protocol_connect and doing states */ - return Curl_single_getsock(conn, sock); -#endif } /* Generic function called by the multi interface to figure out what socket(s) @@ -2911,20 +2899,11 @@ static int ssh_perform_getsock(const struct connectdata *conn, static int ssh_getsock(struct connectdata *conn, curl_socket_t *sock) { -#ifndef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION - (void)conn; - (void)sock; - /* if we don't know any direction we can just play along as we used to and - not provide any sensible info */ - return GETSOCK_BLANK; -#else /* if we know the direction we can use the generic *_getsock() function even for the protocol_connect and doing states */ return ssh_perform_getsock(conn, sock); -#endif } -#ifdef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION /* * When one of the libssh2 functions has returned LIBSSH2_ERROR_EAGAIN this * function is used to figure out in what direction and stores this info so @@ -2949,10 +2928,6 @@ static void ssh_block2waitfor(struct connectdata *conn, bool block) the original set */ conn->waitfor = sshc->orig_waitfor; } -#else - /* no libssh2 directional support so we simply don't know */ -#define ssh_block2waitfor(x,y) Curl_nop_stmt -#endif /* called repeatedly until done from multi.c */ static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done) @@ -3001,7 +2976,6 @@ static CURLcode ssh_block_statemach(struct connectdata *conn, return CURLE_OPERATION_TIMEDOUT; } -#ifdef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION if(block) { int dir = libssh2_session_block_directions(sshc->ssh_session); curl_socket_t sock = conn->sock[FIRSTSOCKET]; @@ -3015,8 +2989,6 @@ static CURLcode ssh_block_statemach(struct connectdata *conn, (void)Curl_socket_check(fd_read, CURL_SOCKET_BAD, fd_write, left>1000?1000:left); } -#endif - } return result; @@ -3029,7 +3001,7 @@ static CURLcode ssh_setup_connection(struct connectdata *conn) { struct SSHPROTO *ssh; - conn->data->req.protop = ssh = calloc(1, sizeof(struct SSHPROTO)); + conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); if(!ssh) return CURLE_OUT_OF_MEMORY; @@ -3039,21 +3011,27 @@ static CURLcode ssh_setup_connection(struct connectdata *conn) static Curl_recv scp_recv, sftp_recv; static Curl_send scp_send, sftp_send; +#ifndef CURL_DISABLE_PROXY static ssize_t ssh_tls_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags, void **abstract) { struct connectdata *conn = (struct connectdata *)*abstract; ssize_t nread; CURLcode result; + Curl_recv *backup = conn->recv[0]; + struct ssh_conn *ssh = &conn->proto.sshc; (void)flags; + /* swap in the TLS reader function for this call only, and then swap back + the SSH one again */ + conn->recv[0] = ssh->tls_recv; result = Curl_read(conn, sock, buffer, length, &nread); + conn->recv[0] = backup; if(result == CURLE_AGAIN) return -EAGAIN; /* magic return code for libssh2 */ else if(result) return -1; /* generic error */ - if(conn->data->set.verbose) - Curl_debug(conn->data, CURLINFO_DATA_IN, (char *)buffer, (size_t)nread); + Curl_debug(conn->data, CURLINFO_DATA_IN, (char *)buffer, (size_t)nread); return nread; } @@ -3063,17 +3041,23 @@ static ssize_t ssh_tls_send(libssh2_socket_t sock, const void *buffer, struct connectdata *conn = (struct connectdata *)*abstract; ssize_t nwrite; CURLcode result; + Curl_send *backup = conn->send[0]; + struct ssh_conn *ssh = &conn->proto.sshc; (void)flags; + /* swap in the TLS writer function for this call only, and then swap back + the SSH one again */ + conn->send[0] = ssh->tls_send; result = Curl_write(conn, sock, buffer, length, &nwrite); + conn->send[0] = backup; if(result == CURLE_AGAIN) return -EAGAIN; /* magic return code for libssh2 */ else if(result) return -1; /* error */ - if(conn->data->set.verbose) - Curl_debug(conn->data, CURLINFO_DATA_OUT, (char *)buffer, (size_t)nwrite); + Curl_debug(conn->data, CURLINFO_DATA_OUT, (char *)buffer, (size_t)nwrite); return nwrite; } +#endif /* * Curl_ssh_connect() gets called from Curl_protocol_connect() to allow us to @@ -3089,7 +3073,7 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done) struct Curl_easy *data = conn->data; /* initialize per-handle data if not already */ - if(!data->req.protop) + if(!data->req.p.ssh) ssh_setup_connection(conn); /* We default to persistent connections. We set this already in this connect @@ -3116,6 +3100,7 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done) return CURLE_FAILED_INIT; } +#ifndef CURL_DISABLE_PROXY if(conn->http_proxy.proxytype == CURLPROXY_HTTPS) { /* * This crazy union dance is here to avoid assigning a void pointer a @@ -3153,8 +3138,15 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done) LIBSSH2_CALLBACK_RECV, sshrecv.recvp); libssh2_session_callback_set(ssh->ssh_session, LIBSSH2_CALLBACK_SEND, sshsend.sendp); + + /* Store the underlying TLS recv/send function pointers to be used when + reading from the proxy */ + ssh->tls_recv = conn->recv[FIRSTSOCKET]; + ssh->tls_send = conn->send[FIRSTSOCKET]; } - else if(conn->handler->protocol & CURLPROTO_SCP) { + +#endif /* CURL_DISABLE_PROXY */ + if(conn->handler->protocol & CURLPROTO_SCP) { conn->recv[FIRSTSOCKET] = scp_recv; conn->send[FIRSTSOCKET] = scp_send; } @@ -3307,7 +3299,7 @@ static CURLcode scp_disconnect(struct connectdata *conn, bool dead_connection) static CURLcode ssh_done(struct connectdata *conn, CURLcode status) { CURLcode result = CURLE_OK; - struct SSHPROTO *sftp_scp = conn->data->req.protop; + struct SSHPROTO *sftp_scp = conn->data->req.p.ssh; if(!status) { /* run the state-machine */ diff --git a/libs/libcurl/src/vssh/ssh.h b/libs/libcurl/src/vssh/ssh.h index 9e49993e96..377337031d 100644 --- a/libs/libcurl/src/vssh/ssh.h +++ b/libs/libcurl/src/vssh/ssh.h @@ -11,7 +11,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -182,6 +182,12 @@ struct ssh_conn { LIBSSH2_SFTP *sftp_session; /* SFTP handle */ LIBSSH2_SFTP_HANDLE *sftp_handle; +#ifndef CURL_DISABLE_PROXY + /* for HTTPS proxy storage */ + Curl_recv *tls_recv; + Curl_send *tls_send; +#endif + #ifdef HAVE_LIBSSH2_AGENT_API LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */ struct libssh2_agent_publickey *sshagent_identity, diff --git a/libs/libcurl/src/vssh/wolfssh.c b/libs/libcurl/src/vssh/wolfssh.c index dcbbab6c3d..b0dfb20478 100644 --- a/libs/libcurl/src/vssh/wolfssh.c +++ b/libs/libcurl/src/vssh/wolfssh.c @@ -9,7 +9,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -322,7 +322,7 @@ static CURLcode wssh_setup_connection(struct connectdata *conn) { struct SSHPROTO *ssh; - conn->data->req.protop = ssh = calloc(1, sizeof(struct SSHPROTO)); + conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); if(!ssh) return CURLE_OUT_OF_MEMORY; @@ -356,7 +356,7 @@ static CURLcode wssh_connect(struct connectdata *conn, bool *done) int rc; /* initialize per-handle data if not already */ - if(!data->req.protop) + if(!data->req.p.ssh) wssh_setup_connection(conn); /* We default to persistent connections. We set this already in this connect @@ -429,7 +429,7 @@ static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block) CURLcode result = CURLE_OK; struct ssh_conn *sshc = &conn->proto.sshc; struct Curl_easy *data = conn->data; - struct SSHPROTO *sftp_scp = data->req.protop; + struct SSHPROTO *sftp_scp = data->req.p.ssh; WS_SFTPNAME *name; int rc = 0; *block = FALSE; /* we're not blocking by default */ @@ -1027,7 +1027,7 @@ static CURLcode wssh_block_statemach(struct connectdata *conn, static CURLcode wssh_done(struct connectdata *conn, CURLcode status) { CURLcode result = CURLE_OK; - struct SSHPROTO *sftp_scp = conn->data->req.protop; + struct SSHPROTO *sftp_scp = conn->data->req.p.ssh; if(!status) { /* run the state-machine */ |