mirror of
https://github.com/moparisthebest/curl
synced 2025-01-13 23:18:01 -05:00
wolfSSH: new SSH backend
Adds support for SFTP (not SCP) using WolfSSH. Closes #4231
This commit is contained in:
parent
ad0aa27a9d
commit
6773c7ca65
40
configure.ac
40
configure.ac
@ -2795,17 +2795,23 @@ dnl **********************************************************************
|
||||
dnl Default to compiler & linker defaults for LIBSSH2 files & libraries.
|
||||
OPT_LIBSSH2=off
|
||||
AC_ARG_WITH(libssh2,dnl
|
||||
AC_HELP_STRING([--with-libssh2=PATH],[Where to look for libssh2, PATH points to the LIBSSH2 installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
|
||||
AC_HELP_STRING([--with-libssh2], [enable LIBSSH2]),
|
||||
AC_HELP_STRING([--with-libssh2=PATH],[Where to look for libssh2, PATH points to the libssh2 installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
|
||||
AC_HELP_STRING([--with-libssh2], [enable libssh2]),
|
||||
OPT_LIBSSH2=$withval, OPT_LIBSSH2=no)
|
||||
|
||||
|
||||
OPT_LIBSSH=off
|
||||
AC_ARG_WITH(libssh,dnl
|
||||
AC_HELP_STRING([--with-libssh=PATH],[Where to look for libssh, PATH points to the LIBSSH installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
|
||||
AC_HELP_STRING([--with-libssh], [enable LIBSSH]),
|
||||
AC_HELP_STRING([--with-libssh=PATH],[Where to look for libssh, PATH points to the libssh installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
|
||||
AC_HELP_STRING([--with-libssh], [enable libssh]),
|
||||
OPT_LIBSSH=$withval, OPT_LIBSSH=no)
|
||||
|
||||
OPT_WOLFSSH=off
|
||||
AC_ARG_WITH(wolfssh,dnl
|
||||
AC_HELP_STRING([--with-wolfssh=PATH],[Where to look for wolfssh, PATH points to the wolfSSH installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
|
||||
AC_HELP_STRING([--with-wolfssh], [enable wolfssh]),
|
||||
OPT_WOLFSSH=$withval, OPT_WOLFSSH=no)
|
||||
|
||||
if test X"$OPT_LIBSSH2" != Xno; then
|
||||
dnl backup the pre-libssh2 variables
|
||||
CLEANLDFLAGS="$LDFLAGS"
|
||||
@ -2952,6 +2958,28 @@ elif test X"$OPT_LIBSSH" != Xno; then
|
||||
CPPFLAGS=$CLEANCPPFLAGS
|
||||
LIBS=$CLEANLIBS
|
||||
fi
|
||||
elif test X"$OPT_WOLFSSH" != Xno; then
|
||||
dnl backup the pre-wolfssh variables
|
||||
CLEANLDFLAGS="$LDFLAGS"
|
||||
CLEANCPPFLAGS="$CPPFLAGS"
|
||||
CLEANLIBS="$LIBS"
|
||||
|
||||
|
||||
if test "$OPT_WOLFSSH" != yes; then
|
||||
WOLFCONFIG="$OPT_WOLFSSH/bin/wolfssh-config"
|
||||
LDFLAGS="$LDFLAGS `$WOLFCONFIG --libs`"
|
||||
CPPFLAGS="$CPPFLAGS `$WOLFCONFIG --cflags`"
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(wolfssh, wolfSSH_Init)
|
||||
|
||||
AC_CHECK_HEADERS(wolfssh/ssh.h,
|
||||
curl_ssh_msg="enabled (wolfSSH)"
|
||||
WOLFSSH_ENABLED=1
|
||||
AC_DEFINE(USE_WOLFSSH, 1, [if wolfSSH is in use])
|
||||
AC_SUBST(USE_WOLFSSH, [1])
|
||||
)
|
||||
|
||||
fi
|
||||
|
||||
dnl **********************************************************************
|
||||
@ -4761,6 +4789,10 @@ if test "x$USE_LIBSSH" = "x1"; then
|
||||
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
|
||||
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
|
||||
fi
|
||||
if test "x$USE_WOLFSSH" = "x1"; then
|
||||
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
|
||||
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
|
||||
fi
|
||||
if test "x$CURL_DISABLE_RTSP" != "x1"; then
|
||||
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTSP"
|
||||
fi
|
||||
|
@ -42,7 +42,7 @@ LIB_VQUIC_CFILES = vquic/ngtcp2.c vquic/quiche.c
|
||||
|
||||
LIB_VQUIC_HFILES = vquic/ngtcp2.h vquic/quiche.h
|
||||
|
||||
LIB_VSSH_CFILES = vssh/libssh2.c vssh/libssh.c
|
||||
LIB_VSSH_CFILES = vssh/libssh2.c vssh/libssh.c vssh/wolfssh.c
|
||||
|
||||
LIB_VSSH_HFILES = vssh/ssh.h
|
||||
|
||||
|
13
lib/easy.c
13
lib/easy.c
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -193,6 +193,13 @@ static CURLcode global_init(long flags, bool memoryfuncs)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_WOLFSSH
|
||||
if(WS_SUCCESS != wolfSSH_Init()) {
|
||||
DEBUGF(fprintf(stderr, "Error: wolfSSH_Init failed\n"));
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(flags & CURL_GLOBAL_ACK_EINTR)
|
||||
Curl_ack_eintr = 1;
|
||||
|
||||
@ -272,6 +279,10 @@ void curl_global_cleanup(void)
|
||||
|
||||
Curl_ssh_cleanup();
|
||||
|
||||
#ifdef USE_WOLFSSH
|
||||
(void)wolfSSH_Cleanup();
|
||||
#endif
|
||||
|
||||
init_flags = 0;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -187,7 +187,7 @@ static const struct Curl_handler * const protocols[] = {
|
||||
&Curl_handler_tftp,
|
||||
#endif
|
||||
|
||||
#if defined(USE_SSH)
|
||||
#if defined(USE_SSH) && !defined(USE_WOLFSSH)
|
||||
&Curl_handler_scp,
|
||||
#endif
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -265,8 +265,10 @@ static const char * const protocols[] = {
|
||||
#ifndef CURL_DISABLE_RTSP
|
||||
"rtsp",
|
||||
#endif
|
||||
#if defined(USE_SSH)
|
||||
#if defined(USE_SSH) && !defined(USE_WOLFSSH)
|
||||
"scp",
|
||||
#endif
|
||||
#ifdef USE_SSH
|
||||
"sftp",
|
||||
#endif
|
||||
#if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
|
||||
|
@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -30,7 +30,10 @@
|
||||
#elif defined(HAVE_LIBSSH_LIBSSH_H)
|
||||
#include <libssh/libssh.h>
|
||||
#include <libssh/sftp.h>
|
||||
#endif /* HAVE_LIBSSH2_H */
|
||||
#elif defined(USE_WOLFSSH)
|
||||
#include <wolfssh/ssh.h>
|
||||
#include <wolfssh/wolfsftp.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* SSH unique setup
|
||||
@ -188,6 +191,12 @@ struct ssh_conn {
|
||||
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
|
||||
LIBSSH2_KNOWNHOSTS *kh;
|
||||
#endif
|
||||
#elif defined(USE_WOLFSSH)
|
||||
WOLFSSH *ssh_session;
|
||||
WOLFSSH_CTX *ctx;
|
||||
word32 handleSz;
|
||||
byte handle[WOLFSSH_MAX_HANDLE];
|
||||
curl_off_t offset;
|
||||
#endif /* USE_LIBSSH */
|
||||
};
|
||||
|
||||
@ -195,9 +204,6 @@ struct ssh_conn {
|
||||
|
||||
#define CURL_LIBSSH_VERSION ssh_version(0)
|
||||
|
||||
extern const struct Curl_handler Curl_handler_scp;
|
||||
extern const struct Curl_handler Curl_handler_sftp;
|
||||
|
||||
#elif defined(USE_LIBSSH2)
|
||||
|
||||
/* Feature detection based on version numbers to better work with
|
||||
@ -237,11 +243,13 @@ extern const struct Curl_handler Curl_handler_sftp;
|
||||
#define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
|
||||
#endif
|
||||
|
||||
extern const struct Curl_handler Curl_handler_scp;
|
||||
extern const struct Curl_handler Curl_handler_sftp;
|
||||
#endif /* USE_LIBSSH2 */
|
||||
|
||||
#ifdef USE_SSH
|
||||
|
||||
extern const struct Curl_handler Curl_handler_scp;
|
||||
extern const struct Curl_handler Curl_handler_sftp;
|
||||
|
||||
/* generic SSH backend functions */
|
||||
CURLcode Curl_ssh_init(void);
|
||||
void Curl_ssh_cleanup(void);
|
||||
|
1150
lib/vssh/wolfssh.c
Normal file
1150
lib/vssh/wolfssh.c
Normal file
File diff suppressed because it is too large
Load Diff
27
lib/vssh/wolfssh.h
Normal file
27
lib/vssh/wolfssh.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef HEADER_CURL_WOLFSSH_H
|
||||
#define HEADER_CURL_WOLFSSH_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2019 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
extern const struct Curl_handler Curl_handler_sftp;
|
||||
|
||||
#endif /* HEADER_CURL_WOLFSSH_H */
|
Loading…
Reference in New Issue
Block a user