1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 15:48:49 -05:00

libssh: added SFTP support

The SFTP back-end supports asynchronous reading only, limited
to 32-bit file length. Writing is synchronous with no other
limitations.

This also brings keyboard-interactive authentication.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
This commit is contained in:
Nikos Mavrogiannopoulos 2017-10-31 18:30:36 +01:00 committed by Daniel Stenberg
parent c75c9d4fbc
commit a2f3966800
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 1548 additions and 19 deletions

View File

@ -4091,6 +4091,7 @@ if test "x$USE_LIBSSH2" = "x1"; then
fi fi
if test "x$USE_LIBSSH" = "x1"; then if test "x$USE_LIBSSH" = "x1"; then
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP" SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
fi fi
if test "x$CURL_DISABLE_RTSP" != "x1"; then if test "x$CURL_DISABLE_RTSP" != "x1"; then
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTSP" SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTSP"

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,7 @@
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#elif defined(HAVE_LIBSSH_LIBSSH_H) #elif defined(HAVE_LIBSSH_LIBSSH_H)
#include <libssh/libssh.h> #include <libssh/libssh.h>
#include <libssh/sftp.h>
#endif /* HAVE_LIBSSH2_H */ #endif /* HAVE_LIBSSH2_H */
/**************************************************************************** /****************************************************************************
@ -130,8 +131,6 @@ struct ssh_conn {
quote command fails) */ quote command fails) */
char *homedir; /* when doing SFTP we figure out home dir in the char *homedir; /* when doing SFTP we figure out home dir in the
connect phase */ connect phase */
char *readdir_filename;
char *readdir_longentry;
int readdir_len, readdir_totalLen, readdir_currLen; int readdir_len, readdir_totalLen, readdir_currLen;
char *readdir_line; char *readdir_line;
char *readdir_linkPath; char *readdir_linkPath;
@ -146,12 +145,29 @@ struct ssh_conn {
#if defined(USE_LIBSSH) #if defined(USE_LIBSSH)
/* our variables */ /* our variables */
unsigned kbd_state; /* 0 or 1 */
ssh_key privkey; ssh_key privkey;
ssh_key pubkey; ssh_key pubkey;
int auth_methods; int auth_methods;
ssh_session ssh_session; ssh_session ssh_session;
ssh_scp scp_session; ssh_scp scp_session;
sftp_session sftp_session;
sftp_file sftp_file;
sftp_dir sftp_dir;
unsigned sftp_recv_state; /* 0 or 1 */
int sftp_file_index; /* for async read */
sftp_attributes readdir_attrs; /* used by the SFTP readdir actions */
sftp_attributes readdir_link_attrs; /* used by the SFTP readdir actions */
sftp_attributes quote_attrs; /* used by the SFTP_QUOTE state */
const char *readdir_filename; /* points within readdir_attrs */
const char *readdir_longentry;
char *readdir_tmp;
#elif defined(USE_LIBSSH2) #elif defined(USE_LIBSSH2)
char *readdir_filename;
char *readdir_longentry;
LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */ LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
/* Here's a set of struct members used by the SFTP_READDIR state */ /* Here's a set of struct members used by the SFTP_READDIR state */
@ -180,6 +196,7 @@ struct ssh_conn {
#define CURL_LIBSSH_VERSION ssh_version(0) #define CURL_LIBSSH_VERSION ssh_version(0)
extern const struct Curl_handler Curl_handler_scp; extern const struct Curl_handler Curl_handler_scp;
extern const struct Curl_handler Curl_handler_sftp;
#elif defined(USE_LIBSSH2) #elif defined(USE_LIBSSH2)

View File

@ -200,7 +200,7 @@ static const struct Curl_handler * const protocols[] = {
&Curl_handler_scp, &Curl_handler_scp,
#endif #endif
#if defined(USE_LIBSSH2) #if defined(USE_LIBSSH2) || defined(USE_LIBSSH)
&Curl_handler_sftp, &Curl_handler_sftp,
#endif #endif

View File

@ -272,8 +272,6 @@ static const char * const protocols[] = {
#endif #endif
#if defined(USE_LIBSSH) || defined(USE_LIBSSH2) #if defined(USE_LIBSSH) || defined(USE_LIBSSH2)
"scp", "scp",
#endif
#ifdef USE_LIBSSH2
"sftp", "sftp",
#endif #endif
#if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \ #if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \