mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 15:48:49 -05:00
Added support for libssh SSH SCP back-end
libssh is an alternative library to libssh2. https://www.libssh.org/ That patch set also introduces support for ECDSA ed25519 keys, as well as gssapi authentication. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
This commit is contained in:
parent
3973ee6a65
commit
c92d2e14cf
87
configure.ac
87
configure.ac
@ -2716,8 +2716,15 @@ dnl Default to compiler & linker defaults for LIBSSH2 files & libraries.
|
|||||||
OPT_LIBSSH2=off
|
OPT_LIBSSH2=off
|
||||||
AC_ARG_WITH(libssh2,dnl
|
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=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([--without-libssh2], [disable LIBSSH2]),
|
AC_HELP_STRING([--with-libssh2], [enable LIBSSH2]),
|
||||||
OPT_LIBSSH2=$withval)
|
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]),
|
||||||
|
OPT_LIBSSH=$withval, OPT_LIBSSH=no)
|
||||||
|
|
||||||
if test X"$OPT_LIBSSH2" != Xno; then
|
if test X"$OPT_LIBSSH2" != Xno; then
|
||||||
dnl backup the pre-libssh2 variables
|
dnl backup the pre-libssh2 variables
|
||||||
@ -2792,6 +2799,79 @@ if test X"$OPT_LIBSSH2" != Xno; then
|
|||||||
CPPFLAGS=$CLEANCPPFLAGS
|
CPPFLAGS=$CLEANCPPFLAGS
|
||||||
LIBS=$CLEANLIBS
|
LIBS=$CLEANLIBS
|
||||||
fi
|
fi
|
||||||
|
elif test X"$OPT_LIBSSH" != Xno; then
|
||||||
|
dnl backup the pre-libssh variables
|
||||||
|
CLEANLDFLAGS="$LDFLAGS"
|
||||||
|
CLEANCPPFLAGS="$CPPFLAGS"
|
||||||
|
CLEANLIBS="$LIBS"
|
||||||
|
|
||||||
|
case "$OPT_LIBSSH" in
|
||||||
|
yes)
|
||||||
|
dnl --with-libssh (without path) used
|
||||||
|
CURL_CHECK_PKGCONFIG(libssh)
|
||||||
|
|
||||||
|
if test "$PKGCONFIG" != "no" ; then
|
||||||
|
LIB_SSH=`$PKGCONFIG --libs-only-l libssh`
|
||||||
|
LD_SSH=`$PKGCONFIG --libs-only-L libssh`
|
||||||
|
CPP_SSH=`$PKGCONFIG --cflags-only-I libssh`
|
||||||
|
version=`$PKGCONFIG --modversion libssh`
|
||||||
|
DIR_SSH=`echo $LD_SSH | $SED -e 's/-L//'`
|
||||||
|
fi
|
||||||
|
|
||||||
|
;;
|
||||||
|
off)
|
||||||
|
dnl no --with-libssh option given, just check default places
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
dnl use the given --with-libssh spot
|
||||||
|
PREFIX_SSH=$OPT_LIBSSH
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
dnl if given with a prefix, we set -L and -I based on that
|
||||||
|
if test -n "$PREFIX_SSH"; then
|
||||||
|
LIB_SSH="-lssh"
|
||||||
|
LD_SSH=-L${PREFIX_SSH}/lib$libsuff
|
||||||
|
CPP_SSH=-I${PREFIX_SSH}/include
|
||||||
|
DIR_SSH=${PREFIX_SSH;}/lib$libsuff
|
||||||
|
fi
|
||||||
|
|
||||||
|
LDFLAGS="$LDFLAGS $LD_SSH"
|
||||||
|
CPPFLAGS="$CPPFLAGS $CPP_SSH"
|
||||||
|
LIBS="$LIB_SSH $LIBS"
|
||||||
|
|
||||||
|
AC_CHECK_LIB(ssh, ssh_new)
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS(libssh/libssh.h,
|
||||||
|
curl_ssh_msg="enabled (libSSH)"
|
||||||
|
LIBSSH_ENABLED=1
|
||||||
|
AC_DEFINE(USE_LIBSSH, 1, [if libSSH is in use])
|
||||||
|
AC_SUBST(USE_LIBSSH, [1])
|
||||||
|
)
|
||||||
|
|
||||||
|
if test X"$OPT_LIBSSH" != Xoff &&
|
||||||
|
test "$LIBSSH_ENABLED" != "1"; then
|
||||||
|
AC_MSG_ERROR([libSSH libs and/or directories were not found where specified!])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$LIBSSH_ENABLED" = "1"; then
|
||||||
|
if test -n "$DIR_SSH"; then
|
||||||
|
dnl when the libssh shared libs were found in a path that the run-time
|
||||||
|
dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
|
||||||
|
dnl to prevent further configure tests to fail due to this
|
||||||
|
|
||||||
|
if test "x$cross_compiling" != "xyes"; then
|
||||||
|
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DIR_SSH"
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
AC_MSG_NOTICE([Added $DIR_SSH to LD_LIBRARY_PATH])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
dnl no libssh, revert back to clean variables
|
||||||
|
LDFLAGS=$CLEANLDFLAGS
|
||||||
|
CPPFLAGS=$CLEANCPPFLAGS
|
||||||
|
LIBS=$CLEANLIBS
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl **********************************************************************
|
dnl **********************************************************************
|
||||||
@ -4009,6 +4089,9 @@ if test "x$USE_LIBSSH2" = "x1"; then
|
|||||||
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
|
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
|
||||||
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
|
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP"
|
||||||
fi
|
fi
|
||||||
|
if test "x$USE_LIBSSH" = "x1"; then
|
||||||
|
SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP"
|
||||||
|
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"
|
||||||
fi
|
fi
|
||||||
|
@ -715,6 +715,7 @@ typedef enum {
|
|||||||
#define CURLSSH_AUTH_HOST (1<<2) /* host key files */
|
#define CURLSSH_AUTH_HOST (1<<2) /* host key files */
|
||||||
#define CURLSSH_AUTH_KEYBOARD (1<<3) /* keyboard interactive */
|
#define CURLSSH_AUTH_KEYBOARD (1<<3) /* keyboard interactive */
|
||||||
#define CURLSSH_AUTH_AGENT (1<<4) /* agent (ssh-agent, pageant...) */
|
#define CURLSSH_AUTH_AGENT (1<<4) /* agent (ssh-agent, pageant...) */
|
||||||
|
#define CURLSSH_AUTH_GSSAPI (1<<5) /* gssapi (kerberos, ...) */
|
||||||
#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY
|
#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY
|
||||||
|
|
||||||
#define CURLGSSAPI_DELEGATION_NONE 0 /* no delegation (default) */
|
#define CURLGSSAPI_DELEGATION_NONE 0 /* no delegation (default) */
|
||||||
@ -727,7 +728,9 @@ enum curl_khtype {
|
|||||||
CURLKHTYPE_UNKNOWN,
|
CURLKHTYPE_UNKNOWN,
|
||||||
CURLKHTYPE_RSA1,
|
CURLKHTYPE_RSA1,
|
||||||
CURLKHTYPE_RSA,
|
CURLKHTYPE_RSA,
|
||||||
CURLKHTYPE_DSS
|
CURLKHTYPE_DSS,
|
||||||
|
CURLKHTYPE_ECDSA,
|
||||||
|
CURLKHTYPE_ED25519
|
||||||
};
|
};
|
||||||
|
|
||||||
struct curl_khkey {
|
struct curl_khkey {
|
||||||
|
@ -46,7 +46,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
|
|||||||
http_digest.c md4.c md5.c http_negotiate.c inet_pton.c strtoofft.c \
|
http_digest.c md4.c md5.c http_negotiate.c inet_pton.c strtoofft.c \
|
||||||
strerror.c amigaos.c hostasyn.c hostip4.c hostip6.c hostsyn.c \
|
strerror.c amigaos.c hostasyn.c hostip4.c hostip6.c hostsyn.c \
|
||||||
inet_ntop.c parsedate.c select.c tftp.c splay.c strdup.c socks.c \
|
inet_ntop.c parsedate.c select.c tftp.c splay.c strdup.c socks.c \
|
||||||
ssh.c curl_addrinfo.c socks_gssapi.c socks_sspi.c \
|
ssh.c ssh-libssh.c curl_addrinfo.c socks_gssapi.c socks_sspi.c \
|
||||||
curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c \
|
curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c \
|
||||||
pingpong.c rtsp.c curl_threads.c warnless.c hmac.c curl_rtmp.c \
|
pingpong.c rtsp.c curl_threads.c warnless.c hmac.c curl_rtmp.c \
|
||||||
openldap.c curl_gethostname.c gopher.c idn_win32.c \
|
openldap.c curl_gethostname.c gopher.c idn_win32.c \
|
||||||
@ -54,7 +54,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
|
|||||||
http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c rand.c \
|
http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c rand.c \
|
||||||
curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c \
|
curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c \
|
||||||
x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c \
|
x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c \
|
||||||
mime.c sha256.c setopt.c
|
mime.c sha256.c setopt.c curl_path.c
|
||||||
|
|
||||||
LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
|
LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
|
||||||
formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \
|
formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \
|
||||||
@ -73,7 +73,8 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
|
|||||||
curl_sasl.h curl_multibyte.h hostcheck.h conncache.h \
|
curl_sasl.h curl_multibyte.h hostcheck.h conncache.h \
|
||||||
curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \
|
curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \
|
||||||
x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \
|
x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \
|
||||||
curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h
|
curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h \
|
||||||
|
curl_path.h
|
||||||
|
|
||||||
LIB_RCFILES = libcurl.rc
|
LIB_RCFILES = libcurl.rc
|
||||||
|
|
||||||
|
179
lib/curl_path.c
Normal file
179
lib/curl_path.c
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2017, 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.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "curl_setup.h"
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include "curl_memory.h"
|
||||||
|
#include "curl_path.h"
|
||||||
|
#include "escape.h"
|
||||||
|
#include "memdebug.h"
|
||||||
|
|
||||||
|
/* figure out the path to work with in this particular request */
|
||||||
|
CURLcode Curl_getworkingpath(struct connectdata *conn,
|
||||||
|
char *homedir, /* when SFTP is used */
|
||||||
|
char **path) /* returns the allocated
|
||||||
|
real path to work with */
|
||||||
|
{
|
||||||
|
struct Curl_easy *data = conn->data;
|
||||||
|
char *real_path = NULL;
|
||||||
|
char *working_path;
|
||||||
|
size_t working_path_len;
|
||||||
|
CURLcode result =
|
||||||
|
Curl_urldecode(data, data->state.path, 0, &working_path,
|
||||||
|
&working_path_len, FALSE);
|
||||||
|
if(result)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
/* Check for /~/, indicating relative to the user's home directory */
|
||||||
|
if(conn->handler->protocol & CURLPROTO_SCP) {
|
||||||
|
real_path = malloc(working_path_len + 1);
|
||||||
|
if(real_path == NULL) {
|
||||||
|
free(working_path);
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))
|
||||||
|
/* It is referenced to the home directory, so strip the leading '/~/' */
|
||||||
|
memcpy(real_path, working_path + 3, 4 + working_path_len-3);
|
||||||
|
else
|
||||||
|
memcpy(real_path, working_path, 1 + working_path_len);
|
||||||
|
}
|
||||||
|
else if(conn->handler->protocol & CURLPROTO_SFTP) {
|
||||||
|
if((working_path_len > 1) && (working_path[1] == '~')) {
|
||||||
|
size_t homelen = strlen(homedir);
|
||||||
|
real_path = malloc(homelen + working_path_len + 1);
|
||||||
|
if(real_path == NULL) {
|
||||||
|
free(working_path);
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
/* It is referenced to the home directory, so strip the
|
||||||
|
leading '/' */
|
||||||
|
memcpy(real_path, homedir, homelen);
|
||||||
|
real_path[homelen] = '/';
|
||||||
|
real_path[homelen + 1] = '\0';
|
||||||
|
if(working_path_len > 3) {
|
||||||
|
memcpy(real_path + homelen + 1, working_path + 3,
|
||||||
|
1 + working_path_len -3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
real_path = malloc(working_path_len + 1);
|
||||||
|
if(real_path == NULL) {
|
||||||
|
free(working_path);
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
memcpy(real_path, working_path, 1 + working_path_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(working_path);
|
||||||
|
|
||||||
|
/* store the pointer for the caller to receive */
|
||||||
|
*path = real_path;
|
||||||
|
|
||||||
|
return CURLE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The get_pathname() function is being borrowed from OpenSSH sftp.c
|
||||||
|
version 4.6p1. */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
CURLcode Curl_get_pathname(const char **cpp, char **path)
|
||||||
|
{
|
||||||
|
const char *cp = *cpp, *end;
|
||||||
|
char quot;
|
||||||
|
unsigned int i, j;
|
||||||
|
static const char WHITESPACE[] = " \t\r\n";
|
||||||
|
|
||||||
|
cp += strspn(cp, WHITESPACE);
|
||||||
|
if(!*cp) {
|
||||||
|
*cpp = cp;
|
||||||
|
*path = NULL;
|
||||||
|
return CURLE_QUOTE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*path = malloc(strlen(cp) + 1);
|
||||||
|
if(*path == NULL)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
/* Check for quoted filenames */
|
||||||
|
if(*cp == '\"' || *cp == '\'') {
|
||||||
|
quot = *cp++;
|
||||||
|
|
||||||
|
/* Search for terminating quote, unescape some chars */
|
||||||
|
for(i = j = 0; i <= strlen(cp); i++) {
|
||||||
|
if(cp[i] == quot) { /* Found quote */
|
||||||
|
i++;
|
||||||
|
(*path)[j] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(cp[i] == '\0') { /* End of string */
|
||||||
|
/*error("Unterminated quote");*/
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if(cp[i] == '\\') { /* Escaped characters */
|
||||||
|
i++;
|
||||||
|
if(cp[i] != '\'' && cp[i] != '\"' &&
|
||||||
|
cp[i] != '\\') {
|
||||||
|
/*error("Bad escaped character '\\%c'",
|
||||||
|
cp[i]);*/
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(*path)[j++] = cp[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(j == 0) {
|
||||||
|
/*error("Empty quotes");*/
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
*cpp = cp + i + strspn(cp + i, WHITESPACE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Read to end of filename */
|
||||||
|
end = strpbrk(cp, WHITESPACE);
|
||||||
|
if(end == NULL)
|
||||||
|
end = strchr(cp, '\0');
|
||||||
|
*cpp = end + strspn(end, WHITESPACE);
|
||||||
|
|
||||||
|
memcpy(*path, cp, end - cp);
|
||||||
|
(*path)[end - cp] = '\0';
|
||||||
|
}
|
||||||
|
return CURLE_OK;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
Curl_safefree(*path);
|
||||||
|
return CURLE_QUOTE_ERROR;
|
||||||
|
}
|
45
lib/curl_path.h
Normal file
45
lib/curl_path.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2017, 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.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "curl_setup.h"
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include "urldata.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# undef PATH_MAX
|
||||||
|
# define PATH_MAX MAX_PATH
|
||||||
|
# ifndef R_OK
|
||||||
|
# define R_OK 4
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
#define PATH_MAX 1024 /* just an extra precaution since there are systems that
|
||||||
|
have their definition hidden well */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CURLcode Curl_getworkingpath(struct connectdata *conn,
|
||||||
|
char *homedir,
|
||||||
|
char **path);
|
||||||
|
|
||||||
|
CURLcode
|
||||||
|
Curl_get_pathname(const char **cpp, char **path);
|
11
lib/easy.c
11
lib/easy.c
@ -253,6 +253,13 @@ static CURLcode global_init(long flags, bool memoryfuncs)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_LIBSSH)
|
||||||
|
if(ssh_init()) {
|
||||||
|
DEBUGF(fprintf(stderr, "Error: libssh_init failed\n"));
|
||||||
|
return CURLE_FAILED_INIT;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if(flags & CURL_GLOBAL_ACK_EINTR)
|
if(flags & CURL_GLOBAL_ACK_EINTR)
|
||||||
Curl_ack_eintr = 1;
|
Curl_ack_eintr = 1;
|
||||||
|
|
||||||
@ -330,6 +337,10 @@ void curl_global_cleanup(void)
|
|||||||
(void)libssh2_exit();
|
(void)libssh2_exit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_LIBSSH)
|
||||||
|
(void)ssh_finalize();
|
||||||
|
#endif
|
||||||
|
|
||||||
init_flags = 0;
|
init_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2110,7 +2110,7 @@ static CURLcode setopt(struct Curl_easy *data, CURLoption option,
|
|||||||
data->set.proxy_ssl.primary.sessionid = data->set.ssl.primary.sessionid;
|
data->set.proxy_ssl.primary.sessionid = data->set.ssl.primary.sessionid;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef USE_LIBSSH2
|
#if defined(USE_LIBSSH2) || defined(USE_LIBSSH)
|
||||||
/* we only include SSH options if explicitly built to support SSH */
|
/* we only include SSH options if explicitly built to support SSH */
|
||||||
case CURLOPT_SSH_AUTH_TYPES:
|
case CURLOPT_SSH_AUTH_TYPES:
|
||||||
data->set.ssh_auth_types = va_arg(param, long);
|
data->set.ssh_auth_types = va_arg(param, long);
|
||||||
@ -2161,7 +2161,6 @@ static CURLcode setopt(struct Curl_easy *data, CURLoption option,
|
|||||||
data->set.ssh_keyfunc_userp = va_arg(param, void *);
|
data->set.ssh_keyfunc_userp = va_arg(param, void *);
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_LIBSSH2_KNOWNHOST_API */
|
#endif /* HAVE_LIBSSH2_KNOWNHOST_API */
|
||||||
|
|
||||||
#endif /* USE_LIBSSH2 */
|
#endif /* USE_LIBSSH2 */
|
||||||
|
|
||||||
case CURLOPT_HTTP_TRANSFER_DECODING:
|
case CURLOPT_HTTP_TRANSFER_DECODING:
|
||||||
|
1234
lib/ssh-libssh.c
Normal file
1234
lib/ssh-libssh.c
Normal file
File diff suppressed because it is too large
Load Diff
183
lib/ssh.c
183
lib/ssh.c
@ -87,21 +87,9 @@
|
|||||||
/* The last 3 #include files should be in this order */
|
/* The last 3 #include files should be in this order */
|
||||||
#include "curl_printf.h"
|
#include "curl_printf.h"
|
||||||
#include "curl_memory.h"
|
#include "curl_memory.h"
|
||||||
|
#include "curl_path.h"
|
||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
# undef PATH_MAX
|
|
||||||
# define PATH_MAX MAX_PATH
|
|
||||||
# ifndef R_OK
|
|
||||||
# define R_OK 4
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
|
||||||
#define PATH_MAX 1024 /* just an extra precaution since there are systems that
|
|
||||||
have their definition hidden well */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LIBSSH2_VERSION_NUM >= 0x010206
|
#if LIBSSH2_VERSION_NUM >= 0x010206
|
||||||
/* libssh2_sftp_statvfs and friends were added in 1.2.6 */
|
/* libssh2_sftp_statvfs and friends were added in 1.2.6 */
|
||||||
#define HAS_STATVFS_SUPPORT 1
|
#define HAS_STATVFS_SUPPORT 1
|
||||||
@ -120,16 +108,10 @@ static LIBSSH2_ALLOC_FUNC(my_libssh2_malloc);
|
|||||||
static LIBSSH2_REALLOC_FUNC(my_libssh2_realloc);
|
static LIBSSH2_REALLOC_FUNC(my_libssh2_realloc);
|
||||||
static LIBSSH2_FREE_FUNC(my_libssh2_free);
|
static LIBSSH2_FREE_FUNC(my_libssh2_free);
|
||||||
|
|
||||||
static CURLcode get_pathname(const char **cpp, char **path);
|
|
||||||
|
|
||||||
static CURLcode ssh_connect(struct connectdata *conn, bool *done);
|
static CURLcode ssh_connect(struct connectdata *conn, bool *done);
|
||||||
static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done);
|
static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done);
|
||||||
static CURLcode ssh_do(struct connectdata *conn, bool *done);
|
static CURLcode ssh_do(struct connectdata *conn, bool *done);
|
||||||
|
|
||||||
static CURLcode ssh_getworkingpath(struct connectdata *conn,
|
|
||||||
char *homedir, /* when SFTP is used */
|
|
||||||
char **path);
|
|
||||||
|
|
||||||
static CURLcode scp_done(struct connectdata *conn,
|
static CURLcode scp_done(struct connectdata *conn,
|
||||||
CURLcode, bool premature);
|
CURLcode, bool premature);
|
||||||
static CURLcode scp_doing(struct connectdata *conn,
|
static CURLcode scp_doing(struct connectdata *conn,
|
||||||
@ -410,70 +392,6 @@ static void state(struct connectdata *conn, sshstate nowstate)
|
|||||||
sshc->state = nowstate;
|
sshc->state = nowstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* figure out the path to work with in this particular request */
|
|
||||||
static CURLcode ssh_getworkingpath(struct connectdata *conn,
|
|
||||||
char *homedir, /* when SFTP is used */
|
|
||||||
char **path) /* returns the allocated
|
|
||||||
real path to work with */
|
|
||||||
{
|
|
||||||
struct Curl_easy *data = conn->data;
|
|
||||||
char *real_path = NULL;
|
|
||||||
char *working_path;
|
|
||||||
size_t working_path_len;
|
|
||||||
CURLcode result =
|
|
||||||
Curl_urldecode(data, data->state.path, 0, &working_path,
|
|
||||||
&working_path_len, FALSE);
|
|
||||||
if(result)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
/* Check for /~/, indicating relative to the user's home directory */
|
|
||||||
if(conn->handler->protocol & CURLPROTO_SCP) {
|
|
||||||
real_path = malloc(working_path_len + 1);
|
|
||||||
if(real_path == NULL) {
|
|
||||||
free(working_path);
|
|
||||||
return CURLE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))
|
|
||||||
/* It is referenced to the home directory, so strip the leading '/~/' */
|
|
||||||
memcpy(real_path, working_path + 3, 4 + working_path_len-3);
|
|
||||||
else
|
|
||||||
memcpy(real_path, working_path, 1 + working_path_len);
|
|
||||||
}
|
|
||||||
else if(conn->handler->protocol & CURLPROTO_SFTP) {
|
|
||||||
if((working_path_len > 1) && (working_path[1] == '~')) {
|
|
||||||
size_t homelen = strlen(homedir);
|
|
||||||
real_path = malloc(homelen + working_path_len + 1);
|
|
||||||
if(real_path == NULL) {
|
|
||||||
free(working_path);
|
|
||||||
return CURLE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
/* It is referenced to the home directory, so strip the
|
|
||||||
leading '/' */
|
|
||||||
memcpy(real_path, homedir, homelen);
|
|
||||||
real_path[homelen] = '/';
|
|
||||||
real_path[homelen + 1] = '\0';
|
|
||||||
if(working_path_len > 3) {
|
|
||||||
memcpy(real_path + homelen + 1, working_path + 3,
|
|
||||||
1 + working_path_len -3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
real_path = malloc(working_path_len + 1);
|
|
||||||
if(real_path == NULL) {
|
|
||||||
free(working_path);
|
|
||||||
return CURLE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
memcpy(real_path, working_path, 1 + working_path_len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(working_path);
|
|
||||||
|
|
||||||
/* store the pointer for the caller to receive */
|
|
||||||
*path = real_path;
|
|
||||||
|
|
||||||
return CURLE_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
|
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
|
||||||
static int sshkeycallback(struct Curl_easy *easy,
|
static int sshkeycallback(struct Curl_easy *easy,
|
||||||
@ -1184,7 +1102,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
|
|
||||||
case SSH_SFTP_QUOTE_INIT:
|
case SSH_SFTP_QUOTE_INIT:
|
||||||
|
|
||||||
result = ssh_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
|
result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
|
||||||
if(result) {
|
if(result) {
|
||||||
sshc->actualcode = result;
|
sshc->actualcode = result;
|
||||||
state(conn, SSH_STOP);
|
state(conn, SSH_STOP);
|
||||||
@ -1279,7 +1197,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
* also, every command takes at least one argument so we get that
|
* also, every command takes at least one argument so we get that
|
||||||
* first argument right now
|
* first argument right now
|
||||||
*/
|
*/
|
||||||
result = get_pathname(&cp, &sshc->quote_path1);
|
result = Curl_get_pathname(&cp, &sshc->quote_path1);
|
||||||
if(result) {
|
if(result) {
|
||||||
if(result == CURLE_OUT_OF_MEMORY)
|
if(result == CURLE_OUT_OF_MEMORY)
|
||||||
failf(data, "Out of memory");
|
failf(data, "Out of memory");
|
||||||
@ -1304,7 +1222,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
|
|
||||||
/* sshc->quote_path1 contains the mode to set */
|
/* sshc->quote_path1 contains the mode to set */
|
||||||
/* get the destination */
|
/* get the destination */
|
||||||
result = get_pathname(&cp, &sshc->quote_path2);
|
result = Curl_get_pathname(&cp, &sshc->quote_path2);
|
||||||
if(result) {
|
if(result) {
|
||||||
if(result == CURLE_OUT_OF_MEMORY)
|
if(result == CURLE_OUT_OF_MEMORY)
|
||||||
failf(data, "Out of memory");
|
failf(data, "Out of memory");
|
||||||
@ -1326,7 +1244,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
/* symbolic linking */
|
/* symbolic linking */
|
||||||
/* sshc->quote_path1 is the source */
|
/* sshc->quote_path1 is the source */
|
||||||
/* get the destination */
|
/* get the destination */
|
||||||
result = get_pathname(&cp, &sshc->quote_path2);
|
result = Curl_get_pathname(&cp, &sshc->quote_path2);
|
||||||
if(result) {
|
if(result) {
|
||||||
if(result == CURLE_OUT_OF_MEMORY)
|
if(result == CURLE_OUT_OF_MEMORY)
|
||||||
failf(data, "Out of memory");
|
failf(data, "Out of memory");
|
||||||
@ -1351,7 +1269,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
/* rename file */
|
/* rename file */
|
||||||
/* first param is the source path */
|
/* first param is the source path */
|
||||||
/* second param is the dest. path */
|
/* second param is the dest. path */
|
||||||
result = get_pathname(&cp, &sshc->quote_path2);
|
result = Curl_get_pathname(&cp, &sshc->quote_path2);
|
||||||
if(result) {
|
if(result) {
|
||||||
if(result == CURLE_OUT_OF_MEMORY)
|
if(result == CURLE_OUT_OF_MEMORY)
|
||||||
failf(data, "Out of memory");
|
failf(data, "Out of memory");
|
||||||
@ -2399,7 +2317,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SSH_SCP_TRANS_INIT:
|
case SSH_SCP_TRANS_INIT:
|
||||||
result = ssh_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
|
result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
|
||||||
if(result) {
|
if(result) {
|
||||||
sshc->actualcode = result;
|
sshc->actualcode = result;
|
||||||
state(conn, SSH_STOP);
|
state(conn, SSH_STOP);
|
||||||
@ -3307,93 +3225,6 @@ static ssize_t sftp_recv(struct connectdata *conn, int sockindex,
|
|||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The get_pathname() function is being borrowed from OpenSSH sftp.c
|
|
||||||
version 4.6p1. */
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
static CURLcode
|
|
||||||
get_pathname(const char **cpp, char **path)
|
|
||||||
{
|
|
||||||
const char *cp = *cpp, *end;
|
|
||||||
char quot;
|
|
||||||
unsigned int i, j;
|
|
||||||
static const char WHITESPACE[] = " \t\r\n";
|
|
||||||
|
|
||||||
cp += strspn(cp, WHITESPACE);
|
|
||||||
if(!*cp) {
|
|
||||||
*cpp = cp;
|
|
||||||
*path = NULL;
|
|
||||||
return CURLE_QUOTE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
*path = malloc(strlen(cp) + 1);
|
|
||||||
if(*path == NULL)
|
|
||||||
return CURLE_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
/* Check for quoted filenames */
|
|
||||||
if(*cp == '\"' || *cp == '\'') {
|
|
||||||
quot = *cp++;
|
|
||||||
|
|
||||||
/* Search for terminating quote, unescape some chars */
|
|
||||||
for(i = j = 0; i <= strlen(cp); i++) {
|
|
||||||
if(cp[i] == quot) { /* Found quote */
|
|
||||||
i++;
|
|
||||||
(*path)[j] = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(cp[i] == '\0') { /* End of string */
|
|
||||||
/*error("Unterminated quote");*/
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if(cp[i] == '\\') { /* Escaped characters */
|
|
||||||
i++;
|
|
||||||
if(cp[i] != '\'' && cp[i] != '\"' &&
|
|
||||||
cp[i] != '\\') {
|
|
||||||
/*error("Bad escaped character '\\%c'",
|
|
||||||
cp[i]);*/
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(*path)[j++] = cp[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(j == 0) {
|
|
||||||
/*error("Empty quotes");*/
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
*cpp = cp + i + strspn(cp + i, WHITESPACE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* Read to end of filename */
|
|
||||||
end = strpbrk(cp, WHITESPACE);
|
|
||||||
if(end == NULL)
|
|
||||||
end = strchr(cp, '\0');
|
|
||||||
*cpp = end + strspn(end, WHITESPACE);
|
|
||||||
|
|
||||||
memcpy(*path, cp, end - cp);
|
|
||||||
(*path)[end - cp] = '\0';
|
|
||||||
}
|
|
||||||
return CURLE_OK;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
Curl_safefree(*path);
|
|
||||||
return CURLE_QUOTE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const char *sftp_libssh2_strerror(int err)
|
static const char *sftp_libssh2_strerror(int err)
|
||||||
{
|
{
|
||||||
switch(err) {
|
switch(err) {
|
||||||
|
48
lib/ssh.h
48
lib/ssh.h
@ -24,9 +24,11 @@
|
|||||||
|
|
||||||
#include "curl_setup.h"
|
#include "curl_setup.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBSSH2_H
|
#if defined(HAVE_LIBSSH2_H)
|
||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#include <libssh2_sftp.h>
|
#include <libssh2_sftp.h>
|
||||||
|
#elif defined(HAVE_LIBSSH_LIBSSH_H)
|
||||||
|
#include <libssh/libssh.h>
|
||||||
#endif /* HAVE_LIBSSH2_H */
|
#endif /* HAVE_LIBSSH2_H */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -51,6 +53,7 @@ typedef enum {
|
|||||||
SSH_AUTH_HOST,
|
SSH_AUTH_HOST,
|
||||||
SSH_AUTH_KEY_INIT,
|
SSH_AUTH_KEY_INIT,
|
||||||
SSH_AUTH_KEY,
|
SSH_AUTH_KEY,
|
||||||
|
SSH_AUTH_GSSAPI,
|
||||||
SSH_AUTH_DONE,
|
SSH_AUTH_DONE,
|
||||||
SSH_SFTP_INIT,
|
SSH_SFTP_INIT,
|
||||||
SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
|
SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
|
||||||
@ -86,6 +89,7 @@ typedef enum {
|
|||||||
SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
|
SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
|
||||||
SSH_SCP_UPLOAD_INIT,
|
SSH_SCP_UPLOAD_INIT,
|
||||||
SSH_SCP_DOWNLOAD_INIT,
|
SSH_SCP_DOWNLOAD_INIT,
|
||||||
|
SSH_SCP_DOWNLOAD,
|
||||||
SSH_SCP_DONE,
|
SSH_SCP_DONE,
|
||||||
SSH_SCP_SEND_EOF,
|
SSH_SCP_SEND_EOF,
|
||||||
SSH_SCP_WAIT_EOF,
|
SSH_SCP_WAIT_EOF,
|
||||||
@ -109,7 +113,8 @@ struct SSHPROTO {
|
|||||||
struct */
|
struct */
|
||||||
struct ssh_conn {
|
struct ssh_conn {
|
||||||
const char *authlist; /* List of auth. methods, managed by libssh2 */
|
const char *authlist; /* List of auth. methods, managed by libssh2 */
|
||||||
#ifdef USE_LIBSSH2
|
|
||||||
|
/* common */
|
||||||
const char *passphrase; /* pass-phrase to use */
|
const char *passphrase; /* pass-phrase to use */
|
||||||
char *rsa_pub; /* path name */
|
char *rsa_pub; /* path name */
|
||||||
char *rsa; /* path name */
|
char *rsa; /* path name */
|
||||||
@ -120,14 +125,11 @@ struct ssh_conn {
|
|||||||
struct curl_slist *quote_item; /* for the quote option */
|
struct curl_slist *quote_item; /* for the quote option */
|
||||||
char *quote_path1; /* two generic pointers for the QUOTE stuff */
|
char *quote_path1; /* two generic pointers for the QUOTE stuff */
|
||||||
char *quote_path2;
|
char *quote_path2;
|
||||||
LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
|
|
||||||
bool acceptfail; /* used by the SFTP_QUOTE (continue if
|
bool acceptfail; /* used by the SFTP_QUOTE (continue if
|
||||||
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 */
|
||||||
|
|
||||||
/* Here's a set of struct members used by the SFTP_READDIR state */
|
|
||||||
LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
|
|
||||||
char *readdir_filename;
|
char *readdir_filename;
|
||||||
char *readdir_longentry;
|
char *readdir_longentry;
|
||||||
int readdir_len, readdir_totalLen, readdir_currLen;
|
int readdir_len, readdir_totalLen, readdir_currLen;
|
||||||
@ -139,11 +141,25 @@ struct ssh_conn {
|
|||||||
second attempt has been made to change
|
second attempt has been made to change
|
||||||
to/create a directory */
|
to/create a directory */
|
||||||
char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
|
char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
|
||||||
|
|
||||||
|
int orig_waitfor; /* default READ/WRITE bits wait for */
|
||||||
|
|
||||||
|
#if defined(USE_LIBSSH)
|
||||||
|
/* our variables */
|
||||||
|
ssh_key privkey;
|
||||||
|
ssh_key pubkey;
|
||||||
|
int auth_methods;
|
||||||
|
ssh_session ssh_session;
|
||||||
|
ssh_scp scp_session;
|
||||||
|
#elif defined(USE_LIBSSH2)
|
||||||
|
LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
|
||||||
|
|
||||||
|
/* Here's a set of struct members used by the SFTP_READDIR state */
|
||||||
|
LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
|
||||||
LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
|
LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
|
||||||
LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
|
LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
|
||||||
LIBSSH2_SFTP *sftp_session; /* SFTP handle */
|
LIBSSH2_SFTP *sftp_session; /* SFTP handle */
|
||||||
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
||||||
int orig_waitfor; /* default READ/WRITE bits wait for */
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBSSH2_AGENT_API
|
#ifdef HAVE_LIBSSH2_AGENT_API
|
||||||
LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */
|
LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */
|
||||||
@ -156,10 +172,16 @@ struct ssh_conn {
|
|||||||
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
|
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
|
||||||
LIBSSH2_KNOWNHOSTS *kh;
|
LIBSSH2_KNOWNHOSTS *kh;
|
||||||
#endif
|
#endif
|
||||||
#endif /* USE_LIBSSH2 */
|
#endif /* USE_LIBSSH */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_LIBSSH2
|
#if defined(USE_LIBSSH)
|
||||||
|
|
||||||
|
#define CURL_LIBSSH_VERSION ssh_version(0)
|
||||||
|
|
||||||
|
extern const struct Curl_handler Curl_handler_scp;
|
||||||
|
|
||||||
|
#elif defined(USE_LIBSSH2)
|
||||||
|
|
||||||
/* Feature detection based on version numbers to better work with
|
/* Feature detection based on version numbers to better work with
|
||||||
non-configure platforms */
|
non-configure platforms */
|
||||||
@ -190,6 +212,14 @@ struct ssh_conn {
|
|||||||
#define HAVE_LIBSSH2_SESSION_HANDSHAKE 1
|
#define HAVE_LIBSSH2_SESSION_HANDSHAKE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBSSH2_VERSION
|
||||||
|
/* get it run-time if possible */
|
||||||
|
#define CURL_LIBSSH2_VERSION libssh2_version(0)
|
||||||
|
#else
|
||||||
|
/* use build-time if run-time not possible */
|
||||||
|
#define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
|
||||||
|
#endif
|
||||||
|
|
||||||
extern const struct Curl_handler Curl_handler_scp;
|
extern const struct Curl_handler Curl_handler_scp;
|
||||||
extern const struct Curl_handler Curl_handler_sftp;
|
extern const struct Curl_handler Curl_handler_sftp;
|
||||||
|
|
||||||
|
@ -196,8 +196,11 @@ static const struct Curl_handler * const protocols[] = {
|
|||||||
&Curl_handler_tftp,
|
&Curl_handler_tftp,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_LIBSSH2
|
#if defined(USE_LIBSSH2) || defined(USE_LIBSSH)
|
||||||
&Curl_handler_scp,
|
&Curl_handler_scp,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_LIBSSH2)
|
||||||
&Curl_handler_sftp,
|
&Curl_handler_sftp,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1410,7 +1410,7 @@ enum dupstring {
|
|||||||
STRING_RTSP_SESSION_ID, /* Session ID to use */
|
STRING_RTSP_SESSION_ID, /* Session ID to use */
|
||||||
STRING_RTSP_STREAM_URI, /* Stream URI for this request */
|
STRING_RTSP_STREAM_URI, /* Stream URI for this request */
|
||||||
STRING_RTSP_TRANSPORT, /* Transport for this session */
|
STRING_RTSP_TRANSPORT, /* Transport for this session */
|
||||||
#ifdef USE_LIBSSH2
|
#if defined(USE_LIBSSH2) || defined(USE_LIBSSH)
|
||||||
STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
|
STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
|
||||||
STRING_SSH_PUBLIC_KEY, /* path to the public key file for auth */
|
STRING_SSH_PUBLIC_KEY, /* path to the public key file for auth */
|
||||||
STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */
|
STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "urldata.h"
|
#include "urldata.h"
|
||||||
#include "vtls/vtls.h"
|
#include "vtls/vtls.h"
|
||||||
#include "http2.h"
|
#include "http2.h"
|
||||||
|
#include "ssh.h"
|
||||||
#include "curl_printf.h"
|
#include "curl_printf.h"
|
||||||
|
|
||||||
#ifdef USE_ARES
|
#ifdef USE_ARES
|
||||||
@ -176,6 +177,11 @@ char *curl_version(void)
|
|||||||
left -= len;
|
left -= len;
|
||||||
ptr += len;
|
ptr += len;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_LIBSSH
|
||||||
|
len = snprintf(ptr, left, " libssh/%s", CURL_LIBSSH_VERSION);
|
||||||
|
left -= len;
|
||||||
|
ptr += len;
|
||||||
|
#endif
|
||||||
#ifdef USE_NGHTTP2
|
#ifdef USE_NGHTTP2
|
||||||
len = Curl_http2_ver(ptr, left);
|
len = Curl_http2_ver(ptr, left);
|
||||||
left -= len;
|
left -= len;
|
||||||
@ -264,7 +270,7 @@ static const char * const protocols[] = {
|
|||||||
#ifndef CURL_DISABLE_RTSP
|
#ifndef CURL_DISABLE_RTSP
|
||||||
"rtsp",
|
"rtsp",
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_LIBSSH2
|
#if defined(USE_LIBSSH) || defined(USE_LIBSSH2)
|
||||||
"scp",
|
"scp",
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_LIBSSH2
|
#ifdef USE_LIBSSH2
|
||||||
@ -379,7 +385,7 @@ static curl_version_info_data version_info = {
|
|||||||
curl_version_info_data *curl_version_info(CURLversion stamp)
|
curl_version_info_data *curl_version_info(CURLversion stamp)
|
||||||
{
|
{
|
||||||
static bool initialized;
|
static bool initialized;
|
||||||
#ifdef USE_LIBSSH2
|
#if defined(USE_LIBSSH) || defined(USE_LIBSSH2)
|
||||||
static char ssh_buffer[80];
|
static char ssh_buffer[80];
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SSL
|
#ifdef USE_SSL
|
||||||
@ -431,9 +437,12 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
|
|||||||
#endif /* _LIBICONV_VERSION */
|
#endif /* _LIBICONV_VERSION */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_LIBSSH2
|
#if defined(USE_LIBSSH2)
|
||||||
snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
|
snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
|
||||||
version_info.libssh_version = ssh_buffer;
|
version_info.libssh_version = ssh_buffer;
|
||||||
|
#elif defined(USE_LIBSSH)
|
||||||
|
snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh/%s", CURL_LIBSSH_VERSION);
|
||||||
|
version_info.libssh_version = ssh_buffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_BROTLI
|
#ifdef HAVE_BROTLI
|
||||||
|
Loading…
Reference in New Issue
Block a user