From 2147284cad624325f5b0034c2f394db62086d9e6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 2 Nov 2006 21:56:40 +0000 Subject: James Housley brought support for SCP transfers --- lib/ssh.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/ssh.h (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h new file mode 100644 index 000000000..56f658a80 --- /dev/null +++ b/lib/ssh.h @@ -0,0 +1,40 @@ +#ifndef __SFTP_H +#define __SFTP_H + +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2006, Daniel Stenberg, , 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 http://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. + * + * $Id$ + ***************************************************************************/ + +#ifdef USE_LIBSSH2 + +CURLcode Curl_scp_connect(struct connectdata *conn, bool *done); +CURLcode Curl_scp_do(struct connectdata *conn, bool *done); +CURLcode Curl_scp_done(struct connectdata *conn, CURLcode); + +int Curl_scp_send(struct connectdata *conn, int sockindex, + void *mem, size_t len); +int Curl_scp_recv(struct connectdata *conn, int sockindex, + char *mem, size_t len); + +#endif + +#endif /* USE_LIBSSH2 */ -- cgit v1.2.1 From a634f644005cbe2b3dea2b84328d605ec3474054 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 24 Nov 2006 22:14:39 +0000 Subject: James Housley did lots of work and introduced SFTP downloads. --- lib/ssh.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 56f658a80..b491a7684 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -1,5 +1,5 @@ -#ifndef __SFTP_H -#define __SFTP_H +#ifndef __SSH_H +#define __SSH_H /*************************************************************************** * _ _ ____ _ @@ -26,15 +26,24 @@ #ifdef USE_LIBSSH2 -CURLcode Curl_scp_connect(struct connectdata *conn, bool *done); +CURLcode Curl_ssh_connect(struct connectdata *conn, bool *done); + CURLcode Curl_scp_do(struct connectdata *conn, bool *done); CURLcode Curl_scp_done(struct connectdata *conn, CURLcode); -int Curl_scp_send(struct connectdata *conn, int sockindex, - void *mem, size_t len); -int Curl_scp_recv(struct connectdata *conn, int sockindex, - char *mem, size_t len); +ssize_t Curl_scp_send(struct connectdata *conn, int sockindex, + void *mem, size_t len); +ssize_t Curl_scp_recv(struct connectdata *conn, int sockindex, + char *mem, size_t len); + +CURLcode Curl_sftp_do(struct connectdata *conn, bool *done); +CURLcode Curl_sftp_done(struct connectdata *conn, CURLcode); -#endif +ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, + void *mem, size_t len); +ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, + char *mem, size_t len); #endif /* USE_LIBSSH2 */ + +#endif /* __SSH_H */ -- cgit v1.2.1 From 385e612fa5b7663fc2bc815677b8c27bec2f0fe4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 16 Jan 2007 22:22:10 +0000 Subject: - Armel Asselin improved libcurl to behave a lot better when an easy handle doing an FTP transfer is removed from a multi handle before completion. The fix also fixed the "alive counter" to be correct on "premature removal" for all protocols. --- lib/ssh.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index b491a7684..d9144903b 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -29,7 +29,7 @@ CURLcode Curl_ssh_connect(struct connectdata *conn, bool *done); CURLcode Curl_scp_do(struct connectdata *conn, bool *done); -CURLcode Curl_scp_done(struct connectdata *conn, CURLcode); +CURLcode Curl_scp_done(struct connectdata *conn, CURLcode, bool premature); ssize_t Curl_scp_send(struct connectdata *conn, int sockindex, void *mem, size_t len); @@ -37,7 +37,7 @@ ssize_t Curl_scp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); CURLcode Curl_sftp_do(struct connectdata *conn, bool *done); -CURLcode Curl_sftp_done(struct connectdata *conn, CURLcode); +CURLcode Curl_sftp_done(struct connectdata *conn, CURLcode, bool premature); ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, void *mem, size_t len); -- cgit v1.2.1 From 99e0597c7b74a8be4c85819554b7a1eb447f5ed5 Mon Sep 17 00:00:00 2001 From: James Housley Date: Tue, 12 Jun 2007 12:31:10 +0000 Subject: Convert Curl_ssh_connect() to run in a state machine for LIBSSH2_APINO >= 200706012030. More to come... --- lib/ssh.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index d9144903b..d83e013f2 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -27,6 +27,7 @@ #ifdef USE_LIBSSH2 CURLcode Curl_ssh_connect(struct connectdata *conn, bool *done); +CURLcode Curl_ssh_multi_statemach(struct connectdata *conn, bool *done); CURLcode Curl_scp_do(struct connectdata *conn, bool *done); CURLcode Curl_scp_done(struct connectdata *conn, CURLcode, bool premature); -- cgit v1.2.1 From 8026d94c07cae4185b3e88872fb68ecd071a2c00 Mon Sep 17 00:00:00 2001 From: James Housley Date: Tue, 10 Jul 2007 22:26:32 +0000 Subject: * Finish moving sftp:// into a state machine so it won't block in multi mode * Move scp:// into a state machine so it won't block in multi mode * When available use the full directory entry from the sftp:// server --- lib/ssh.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index d83e013f2..8e5c4718c 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -45,6 +45,13 @@ ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); +#if (LIBSSH2_APINO >= 200706012030) +CURLcode Curl_sftp_doing(struct connectdata *conn, + bool *dophase_done); +CURLcode Curl_scp_doing(struct connectdata *conn, + bool *dophase_done); +#endif (LIBSSH2_APINO >= 200706012030) + #endif /* USE_LIBSSH2 */ #endif /* __SSH_H */ -- cgit v1.2.1 From c39690486c29e83f036e771aa386d6ab2468d14c Mon Sep 17 00:00:00 2001 From: Gunter Knauf Date: Wed, 11 Jul 2007 08:55:28 +0000 Subject: fixed endif comment. --- lib/ssh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 8e5c4718c..dd2dad17a 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -50,7 +50,7 @@ CURLcode Curl_sftp_doing(struct connectdata *conn, bool *dophase_done); CURLcode Curl_scp_doing(struct connectdata *conn, bool *dophase_done); -#endif (LIBSSH2_APINO >= 200706012030) +#endif /* (LIBSSH2_APINO >= 200706012030) */ #endif /* USE_LIBSSH2 */ -- cgit v1.2.1 From fee4f8c86dc91ab1861118aa2cc149d87cc4ee85 Mon Sep 17 00:00:00 2001 From: Gunter Knauf Date: Sat, 14 Jul 2007 15:59:01 +0000 Subject: for now unless we do better fixed LIBSSH2_APINO compares to use long constants. --- lib/ssh.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index dd2dad17a..4de876890 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -45,12 +45,12 @@ ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); -#if (LIBSSH2_APINO >= 200706012030) +#if (LIBSSH2_APINO >= 200706012030L) CURLcode Curl_sftp_doing(struct connectdata *conn, bool *dophase_done); CURLcode Curl_scp_doing(struct connectdata *conn, bool *dophase_done); -#endif /* (LIBSSH2_APINO >= 200706012030) */ +#endif /* (LIBSSH2_APINO >= 200706012030L) */ #endif /* USE_LIBSSH2 */ -- cgit v1.2.1 From 72f5d6ba46709bb2b58b5493ffa12135ea66ee00 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 3 Aug 2007 08:14:51 +0000 Subject: The SSH code now only works with libssh2 0.16 or later. Thus we must not release the next curl until there is a libssh2 0.16 released. --- lib/ssh.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 4de876890..71b48db04 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -36,7 +36,6 @@ ssize_t Curl_scp_send(struct connectdata *conn, int sockindex, void *mem, size_t len); ssize_t Curl_scp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); - CURLcode Curl_sftp_do(struct connectdata *conn, bool *done); CURLcode Curl_sftp_done(struct connectdata *conn, CURLcode, bool premature); @@ -44,13 +43,10 @@ ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, void *mem, size_t len); ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); - -#if (LIBSSH2_APINO >= 200706012030L) CURLcode Curl_sftp_doing(struct connectdata *conn, bool *dophase_done); CURLcode Curl_scp_doing(struct connectdata *conn, bool *dophase_done); -#endif /* (LIBSSH2_APINO >= 200706012030L) */ #endif /* USE_LIBSSH2 */ -- cgit v1.2.1 From 07b6e7363d910ad4828376d568a2f19fd8d64661 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Fri, 12 Oct 2007 13:36:37 +0000 Subject: Added per-protocol callback static tables, replacing callback ptr storage in the connectdata structure by a single handler table ptr. --- lib/ssh.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 71b48db04..8ac2a41ee 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -25,28 +25,18 @@ ***************************************************************************/ #ifdef USE_LIBSSH2 - -CURLcode Curl_ssh_connect(struct connectdata *conn, bool *done); -CURLcode Curl_ssh_multi_statemach(struct connectdata *conn, bool *done); - -CURLcode Curl_scp_do(struct connectdata *conn, bool *done); -CURLcode Curl_scp_done(struct connectdata *conn, CURLcode, bool premature); +extern const struct Curl_handler Curl_handler_scp; +extern const struct Curl_handler Curl_handler_sftp; ssize_t Curl_scp_send(struct connectdata *conn, int sockindex, void *mem, size_t len); ssize_t Curl_scp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); -CURLcode Curl_sftp_do(struct connectdata *conn, bool *done); -CURLcode Curl_sftp_done(struct connectdata *conn, CURLcode, bool premature); ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, void *mem, size_t len); ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); -CURLcode Curl_sftp_doing(struct connectdata *conn, - bool *dophase_done); -CURLcode Curl_scp_doing(struct connectdata *conn, - bool *dophase_done); #endif /* USE_LIBSSH2 */ -- cgit v1.2.1 From e2b82b4325e2726a802b6202f2d011fb4988e41d Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 9 May 2008 11:27:54 +0000 Subject: - Make Curl_write and it's callees accept a const pointer, in preparation of tetetest's patch for curl_easy_send() --- lib/ssh.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 8ac2a41ee..e87b21ba3 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -29,12 +29,12 @@ extern const struct Curl_handler Curl_handler_scp; extern const struct Curl_handler Curl_handler_sftp; ssize_t Curl_scp_send(struct connectdata *conn, int sockindex, - void *mem, size_t len); + const void *mem, size_t len); ssize_t Curl_scp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, - void *mem, size_t len); + const void *mem, size_t len); ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); -- cgit v1.2.1 From 422fd933f508225d3d95128ba97ae3e38dff53dc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 20 Jun 2008 10:43:32 +0000 Subject: - Hans-Jurgen May pointed out that trying SCP or SFTP over a SOCKS proxy crashed libcurl. This is now addressed by making sure we use "plain send" internally when doing the socks handshake instead of the Curl_write() function which is designed to use the "target" protocol. That's then SCP or SFTP in this case. I also took the opportunity and cleaned up some ssh- related #ifdefs in the code for readability. --- lib/ssh.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index e87b21ba3..9bbeaeda8 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -37,6 +37,17 @@ ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, const void *mem, size_t len); ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); +bool Curl_ssh_enabled(struct connectdata *conn, + int prot); + +#define Curl_ssh_enabled(conn,prot) (conn->protocol & prot) + +#else /* USE_LIBSSH2 */ +#define Curl_ssh_enabled(x,y) 0 +#define Curl_scp_send(a,b,c,d) 0 +#define Curl_sftp_send(a,b,c,d) 0 +#define Curl_scp_recv(a,b,c,d) 0 +#define Curl_sftp_recv(a,b,c,d) 0 #endif /* USE_LIBSSH2 */ -- cgit v1.2.1 From 2e1a9da5e2ab29b4e7024395a09ab254f6b8d913 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 20 Jun 2008 10:45:26 +0000 Subject: remove leftover proto that isn't used, I made it a macro instead --- lib/ssh.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 9bbeaeda8..72c4f0b41 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -37,8 +37,6 @@ ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, const void *mem, size_t len); ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, char *mem, size_t len); -bool Curl_ssh_enabled(struct connectdata *conn, - int prot); #define Curl_ssh_enabled(conn,prot) (conn->protocol & prot) -- cgit v1.2.1 From c036f6ae2da0395a633dc1d11b68879fd6795e19 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 29 Nov 2008 16:39:56 +0000 Subject: Adjust some libssh2 preprocessor symbol definition checks --- lib/ssh.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 72c4f0b41..48612245f 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -1,6 +1,5 @@ -#ifndef __SSH_H -#define __SSH_H - +#ifndef HEADER_CURL_SSH_H +#define HEADER_CURL_SSH_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -25,6 +24,17 @@ ***************************************************************************/ #ifdef USE_LIBSSH2 + +#if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000) +# error "SCP/SFTP protocols require libssh2 0.16 or later" +#endif + +#if (LIBSSH2_VERSION_NUM >= 0x001300) +# ifndef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS +# define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS 1 +# endif +#endif + extern const struct Curl_handler Curl_handler_scp; extern const struct Curl_handler Curl_handler_sftp; @@ -49,4 +59,4 @@ ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, #endif /* USE_LIBSSH2 */ -#endif /* __SSH_H */ +#endif /* HEADER_CURL_SSH_H */ -- cgit v1.2.1 From 39d0b57ebff9b9a710c9a56eb0f99675de8fbc73 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 29 Nov 2008 17:45:16 +0000 Subject: Further adjust a libssh2 preprocessor function-symbol definition check --- lib/ssh.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 48612245f..a8a9f5267 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -30,9 +30,9 @@ #endif #if (LIBSSH2_VERSION_NUM >= 0x001300) -# ifndef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS -# define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS 1 -# endif +# define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS 1 +#else +# undef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS #endif extern const struct Curl_handler Curl_handler_scp; -- cgit v1.2.1 From d5bfec70af0d53eed164c9fdec142ebe8fe5c81d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 22 Dec 2008 13:07:13 +0000 Subject: - Anthony Bryan provided a set of patches that cleaned up manual language, corrected spellings and more. --- lib/ssh.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index a8a9f5267..c271a06af 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -30,9 +30,15 @@ #endif #if (LIBSSH2_VERSION_NUM >= 0x001300) +/* libssh2 0.19 was the planned release version for a while before it was + decided to instead become 1.0. Thus >= 0x001300 should still work fine + for snapshots done during the 0.19 days as well as things released once + it was bumped to 1.0 */ # define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS 1 +# define HAVE_LIBSSH2_SFTP_SEEK2 1 #else # undef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS +# undef HAVE_LIBSSH2_SFTP_SEEK2 1 #endif extern const struct Curl_handler Curl_handler_scp; -- cgit v1.2.1 From eab8c0d7548194af0118dcf1a940ade8f0c9a295 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 22 Dec 2008 13:21:23 +0000 Subject: libssh2_sftp_seek2 was just renamed to libssh2_sftp_seek64 ... --- lib/ssh.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index c271a06af..ec711fbe9 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -35,12 +35,19 @@ for snapshots done during the 0.19 days as well as things released once it was bumped to 1.0 */ # define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS 1 -# define HAVE_LIBSSH2_SFTP_SEEK2 1 #else # undef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS -# undef HAVE_LIBSSH2_SFTP_SEEK2 1 #endif +#if (LIBSSH2_VERSION_NUM >= 0x010000) +/* libssh2_sftp_seek64() has only ever been provided by libssh2 1.0 or + later */ +# define HAVE_LIBSSH2_SFTP_SEEK64 1 +#else +# undef HAVE_LIBSSH2_SFTP_SEEK64 1 +#endif + + extern const struct Curl_handler Curl_handler_scp; extern const struct Curl_handler Curl_handler_sftp; -- cgit v1.2.1 From e9895ea2e7751180feeb898494073b7bb7686d41 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Mon, 22 Dec 2008 18:46:12 +0000 Subject: Remove trailing #undef value. Typo? --- lib/ssh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index ec711fbe9..00fe7173e 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -44,7 +44,7 @@ later */ # define HAVE_LIBSSH2_SFTP_SEEK64 1 #else -# undef HAVE_LIBSSH2_SFTP_SEEK64 1 +# undef HAVE_LIBSSH2_SFTP_SEEK64 #endif -- cgit v1.2.1 From ddb0b8d8b8b7be2c31d6d77cee9065eff4cb1833 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 9 May 2009 15:32:59 +0000 Subject: Fix libssh2 preprocessor symbol definition check --- lib/ssh.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 00fe7173e..38f91a151 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -29,7 +29,7 @@ # error "SCP/SFTP protocols require libssh2 0.16 or later" #endif -#if (LIBSSH2_VERSION_NUM >= 0x001300) +#if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x001300) /* libssh2 0.19 was the planned release version for a while before it was decided to instead become 1.0. Thus >= 0x001300 should still work fine for snapshots done during the 0.19 days as well as things released once @@ -39,7 +39,7 @@ # undef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS #endif -#if (LIBSSH2_VERSION_NUM >= 0x010000) +#if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010000) /* libssh2_sftp_seek64() has only ever been provided by libssh2 1.0 or later */ # define HAVE_LIBSSH2_SFTP_SEEK64 1 @@ -64,6 +64,7 @@ ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, #define Curl_ssh_enabled(conn,prot) (conn->protocol & prot) #else /* USE_LIBSSH2 */ + #define Curl_ssh_enabled(x,y) 0 #define Curl_scp_send(a,b,c,d) 0 #define Curl_sftp_send(a,b,c,d) 0 -- cgit v1.2.1 From 1bb68cbcfa625c06baf7ca1eb4cbcc85ce3a0e13 Mon Sep 17 00:00:00 2001 From: Gunter Knauf Date: Tue, 19 May 2009 23:21:25 +0000 Subject: changed ssh.c to use HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION define provided by libssh2.h; removed related define block from ssh.h. --- lib/ssh.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 38f91a151..a20e19905 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -29,16 +29,6 @@ # error "SCP/SFTP protocols require libssh2 0.16 or later" #endif -#if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x001300) -/* libssh2 0.19 was the planned release version for a while before it was - decided to instead become 1.0. Thus >= 0x001300 should still work fine - for snapshots done during the 0.19 days as well as things released once - it was bumped to 1.0 */ -# define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS 1 -#else -# undef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTIONS -#endif - #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010000) /* libssh2_sftp_seek64() has only ever been provided by libssh2 1.0 or later */ -- cgit v1.2.1 From 83a6b348037048c389fbe859d7e3ea3e290a7644 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 12 Dec 2009 22:17:51 +0000 Subject: split out more protocol-specific structs from urldata.h into their own protocol-specific header files --- lib/ssh.h | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index a20e19905..3feb7b074 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -23,6 +23,128 @@ * $Id$ ***************************************************************************/ +#include "setup.h" + +#ifdef HAVE_LIBSSH2_H +#include +#include +#endif /* HAVE_LIBSSH2_H */ + +/**************************************************************************** + * SSH unique setup + ***************************************************************************/ +typedef enum { + SSH_NO_STATE = -1, /* Used for "nextState" so say there is none */ + SSH_STOP = 0, /* do nothing state, stops the state machine */ + + SSH_S_STARTUP, /* Session startup, First state in SSH-CONNECT */ + SSH_HOSTKEY, /* verify hostkey */ + SSH_AUTHLIST, + SSH_AUTH_PKEY_INIT, + SSH_AUTH_PKEY, + SSH_AUTH_PASS_INIT, + SSH_AUTH_PASS, + SSH_AUTH_HOST_INIT, + SSH_AUTH_HOST, + SSH_AUTH_KEY_INIT, + SSH_AUTH_KEY, + SSH_AUTH_DONE, + SSH_SFTP_INIT, + SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */ + + SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */ + SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */ + SSH_SFTP_QUOTE, + SSH_SFTP_NEXT_QUOTE, + SSH_SFTP_QUOTE_STAT, + SSH_SFTP_QUOTE_SETSTAT, + SSH_SFTP_QUOTE_SYMLINK, + SSH_SFTP_QUOTE_MKDIR, + SSH_SFTP_QUOTE_RENAME, + SSH_SFTP_QUOTE_RMDIR, + SSH_SFTP_QUOTE_UNLINK, + SSH_SFTP_TRANS_INIT, + SSH_SFTP_UPLOAD_INIT, + SSH_SFTP_CREATE_DIRS_INIT, + SSH_SFTP_CREATE_DIRS, + SSH_SFTP_CREATE_DIRS_MKDIR, + SSH_SFTP_READDIR_INIT, + SSH_SFTP_READDIR, + SSH_SFTP_READDIR_LINK, + SSH_SFTP_READDIR_BOTTOM, + SSH_SFTP_READDIR_DONE, + SSH_SFTP_DOWNLOAD_INIT, + SSH_SFTP_DOWNLOAD_STAT, /* Last state in SFTP-DO */ + SSH_SFTP_CLOSE, /* Last state in SFTP-DONE */ + SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */ + SSH_SCP_TRANS_INIT, /* First state in SCP-DO */ + SSH_SCP_UPLOAD_INIT, + SSH_SCP_DOWNLOAD_INIT, + SSH_SCP_DONE, + SSH_SCP_SEND_EOF, + SSH_SCP_WAIT_EOF, + SSH_SCP_WAIT_CLOSE, + SSH_SCP_CHANNEL_FREE, /* Last state in SCP-DONE */ + SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */ + SSH_SESSION_FREE, /* Last state in SCP/SFTP-DISCONNECT */ + SSH_QUIT, + SSH_LAST /* never used */ +} sshstate; + +/* this struct is used in the HandleData struct which is part of the + SessionHandle, which means this is used on a per-easy handle basis. + Everything that is strictly related to a connection is banned from this + struct. */ +struct SSHPROTO { + char *path; /* the path we operate on */ +}; + +/* ssh_conn is used for struct connection-oriented data in the connectdata + struct */ +struct ssh_conn { + const char *authlist; /* List of auth. methods, managed by libssh2 */ +#ifdef USE_LIBSSH2 + const char *passphrase; /* pass-phrase to use */ + char *rsa_pub; /* path name */ + char *rsa; /* path name */ + bool authed; /* the connection has been authenticated fine */ + sshstate state; /* always use ssh.c:state() to change state! */ + sshstate nextstate; /* the state to goto after stopping */ + CURLcode actualcode; /* the actual error code */ + struct curl_slist *quote_item; /* for the quote option */ + char *quote_path1; /* two generic pointers for the QUOTE stuff */ + char *quote_path2; + LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */ + char *homedir; /* when doing SFTP we figure out home dir in the + 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_longentry; + int readdir_len, readdir_totalLen, readdir_currLen; + char *readdir_line; + char *readdir_linkPath; + /* end of READDIR stuff */ + + int secondCreateDirs; /* counter use by the code to see if the + second attempt has been made to change + to/create a directory */ + char *slash_pos; /* used by the SFTP_CREATE_DIRS state */ + LIBSSH2_SESSION *ssh_session; /* Secure Shell session */ + LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */ + LIBSSH2_SFTP *sftp_session; /* SFTP handle */ + LIBSSH2_SFTP_HANDLE *sftp_handle; + int orig_waitfor; /* default READ/WRITE bits wait for */ + + /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h + header */ +#ifdef HAVE_LIBSSH2_KNOWNHOST_API + LIBSSH2_KNOWNHOSTS *kh; +#endif +#endif /* USE_LIBSSH2 */ +}; + #ifdef USE_LIBSSH2 #if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000) -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- lib/ssh.h | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 3feb7b074..4e268c253 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -20,7 +20,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From d64bd82bdcb169d0647a80f00068cedd761f8163 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 7 May 2010 15:05:34 +0200 Subject: sendrecv: split the I/O handling into private handler Howard Chu brought the bulk work of this patch that properly moves out the sending and recving of data to the parts of the code that are properly responsible for the various ways of doing so. Daniel Stenberg assisted with polishing a few bits and fixed some minor flaws in the original patch. Another upside of this patch is that we now abuse CURLcodes less with the "magic" -1 return codes and instead use CURLE_AGAIN more consistently. --- lib/ssh.h | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 4e268c253..b92b5c03b 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -162,26 +162,6 @@ struct ssh_conn { extern const struct Curl_handler Curl_handler_scp; extern const struct Curl_handler Curl_handler_sftp; -ssize_t Curl_scp_send(struct connectdata *conn, int sockindex, - const void *mem, size_t len); -ssize_t Curl_scp_recv(struct connectdata *conn, int sockindex, - char *mem, size_t len); - -ssize_t Curl_sftp_send(struct connectdata *conn, int sockindex, - const void *mem, size_t len); -ssize_t Curl_sftp_recv(struct connectdata *conn, int sockindex, - char *mem, size_t len); - -#define Curl_ssh_enabled(conn,prot) (conn->protocol & prot) - -#else /* USE_LIBSSH2 */ - -#define Curl_ssh_enabled(x,y) 0 -#define Curl_scp_send(a,b,c,d) 0 -#define Curl_sftp_send(a,b,c,d) 0 -#define Curl_scp_recv(a,b,c,d) 0 -#define Curl_sftp_recv(a,b,c,d) 0 - #endif /* USE_LIBSSH2 */ #endif /* HEADER_CURL_SSH_H */ -- cgit v1.2.1 From f8cf037ecf67d4dc490e0e54fb2c691211e859ba Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 4 Aug 2010 17:23:38 +0200 Subject: SCP: send large files properly with new enough libssh2 libssh2 1.2.6 and later handle >32bit file sizes properly even on 32bit architectures and we make sure to use that ability. Reported by: Mikael Johansson Bug: http://curl.haxx.se/mail/lib-2010-08/0052.html --- lib/ssh.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index b92b5c03b..d0882e956 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -158,6 +158,12 @@ struct ssh_conn { # undef HAVE_LIBSSH2_SFTP_SEEK64 #endif +#if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010206) +# define HAVE_LIBSSH2_SCP_SEND64 1 +#else +# undef HAVE_LIBSSH2_SFTP_SEEK64 +#endif + extern const struct Curl_handler Curl_handler_scp; extern const struct Curl_handler Curl_handler_sftp; -- cgit v1.2.1 From 992ceae386cc9452d5961c20e1ce23e57260fed2 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 5 Aug 2010 16:27:39 +0200 Subject: build: fix libssh2_scp_send64() availability --- lib/ssh.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index d0882e956..406220cc4 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -151,8 +151,6 @@ struct ssh_conn { #endif #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010000) -/* libssh2_sftp_seek64() has only ever been provided by libssh2 1.0 or - later */ # define HAVE_LIBSSH2_SFTP_SEEK64 1 #else # undef HAVE_LIBSSH2_SFTP_SEEK64 @@ -161,7 +159,7 @@ struct ssh_conn { #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010206) # define HAVE_LIBSSH2_SCP_SEND64 1 #else -# undef HAVE_LIBSSH2_SFTP_SEEK64 +# undef HAVE_LIBSSH2_SCP_SEND64 #endif -- cgit v1.2.1 From 7d94af497d27543337e18012518e2a27a46c35a1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 1 May 2011 23:01:31 +0200 Subject: SSH: set non-blocking earlier Introduce an INIT state for the SSH state machine and set libssh2 non-blocking in that so that it is set properly before libssh2_session_startup() is called. Bug: http://curl.haxx.se/mail/archive-2011-05/0001.html --- lib/ssh.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 406220cc4..6257b96fc 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -36,7 +36,8 @@ typedef enum { SSH_NO_STATE = -1, /* Used for "nextState" so say there is none */ SSH_STOP = 0, /* do nothing state, stops the state machine */ - SSH_S_STARTUP, /* Session startup, First state in SSH-CONNECT */ + SSH_INIT, /* First state in SSH-CONNECT */ + SSH_S_STARTUP, /* Session startup */ SSH_HOSTKEY, /* verify hostkey */ SSH_AUTHLIST, SSH_AUTH_PKEY_INIT, -- cgit v1.2.1 From f64812ca63d5dbcd8b255cc1102fcc321997eceb Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 18 Nov 2011 15:55:09 +0100 Subject: SFTP: support '*' prefix for quote operations prefixing a command with '*' means it is allowed to fail without aborting the chain actions --- lib/ssh.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 6257b96fc..7ab5255c1 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -115,6 +115,7 @@ struct ssh_conn { char *quote_path1; /* two generic pointers for the QUOTE stuff */ char *quote_path2; LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */ + bool acceptfail; /* accept file in SFTP_QUOTE state */ char *homedir; /* when doing SFTP we figure out home dir in the connect phase */ -- cgit v1.2.1 From 0604b2fb90cb91c047f0946ed5e235639f2100af Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 25 Nov 2011 15:02:43 +0100 Subject: rectify comment --- lib/ssh.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index 7ab5255c1..dce035b5e 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -115,7 +115,8 @@ struct ssh_conn { char *quote_path1; /* two generic pointers for the QUOTE stuff */ char *quote_path2; LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */ - bool acceptfail; /* accept file in SFTP_QUOTE state */ + bool acceptfail; /* used by the SFTP_QUOTE (continue if + quote command fails) */ char *homedir; /* when doing SFTP we figure out home dir in the connect phase */ -- cgit v1.2.1 From e351972bc89aa4ccfc83054a01d29ee7337e0b4a Mon Sep 17 00:00:00 2001 From: Armel Asselin Date: Fri, 9 Mar 2012 17:24:42 +0100 Subject: SSH: added agent based authentication CURLSSH_AUTH_AGENT is a new auth type for SSH --- lib/ssh.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/ssh.h') diff --git a/lib/ssh.h b/lib/ssh.h index dce035b5e..bf43fdf3a 100644 --- a/lib/ssh.h +++ b/lib/ssh.h @@ -44,6 +44,9 @@ typedef enum { SSH_AUTH_PKEY, SSH_AUTH_PASS_INIT, SSH_AUTH_PASS, + SSH_AUTH_AGENT_INIT,/* initialize then wait for connection to agent */ + SSH_AUTH_AGENT_LIST,/* ask for list then wait for entire list to come */ + SSH_AUTH_AGENT, /* attempt one key at a time */ SSH_AUTH_HOST_INIT, SSH_AUTH_HOST, SSH_AUTH_KEY_INIT, @@ -139,6 +142,12 @@ struct ssh_conn { LIBSSH2_SFTP_HANDLE *sftp_handle; int orig_waitfor; /* default READ/WRITE bits wait for */ +#ifdef HAVE_LIBSSH2_AGENT_API + LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */ + struct libssh2_agent_publickey *sshagent_identity, + *sshagent_prev_identity; +#endif + /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h header */ #ifdef HAVE_LIBSSH2_KNOWNHOST_API -- cgit v1.2.1