00001 #ifndef HEADER_CURL_SSH_H
00002 #define HEADER_CURL_SSH_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "curl_setup.h"
00026
00027 #ifdef HAVE_LIBSSH2_H
00028 #include <libssh2.h>
00029 #include <libssh2_sftp.h>
00030 #endif
00031
00032
00033
00034
00035 typedef enum {
00036 SSH_NO_STATE = -1,
00037 SSH_STOP = 0,
00038
00039 SSH_INIT,
00040 SSH_S_STARTUP,
00041 SSH_HOSTKEY,
00042 SSH_AUTHLIST,
00043 SSH_AUTH_PKEY_INIT,
00044 SSH_AUTH_PKEY,
00045 SSH_AUTH_PASS_INIT,
00046 SSH_AUTH_PASS,
00047 SSH_AUTH_AGENT_INIT,
00048 SSH_AUTH_AGENT_LIST,
00049 SSH_AUTH_AGENT,
00050 SSH_AUTH_HOST_INIT,
00051 SSH_AUTH_HOST,
00052 SSH_AUTH_KEY_INIT,
00053 SSH_AUTH_KEY,
00054 SSH_AUTH_DONE,
00055 SSH_SFTP_INIT,
00056 SSH_SFTP_REALPATH,
00057
00058 SSH_SFTP_QUOTE_INIT,
00059 SSH_SFTP_POSTQUOTE_INIT,
00060 SSH_SFTP_QUOTE,
00061 SSH_SFTP_NEXT_QUOTE,
00062 SSH_SFTP_QUOTE_STAT,
00063 SSH_SFTP_QUOTE_SETSTAT,
00064 SSH_SFTP_QUOTE_SYMLINK,
00065 SSH_SFTP_QUOTE_MKDIR,
00066 SSH_SFTP_QUOTE_RENAME,
00067 SSH_SFTP_QUOTE_RMDIR,
00068 SSH_SFTP_QUOTE_UNLINK,
00069 SSH_SFTP_QUOTE_STATVFS,
00070 SSH_SFTP_GETINFO,
00071 SSH_SFTP_FILETIME,
00072 SSH_SFTP_TRANS_INIT,
00073 SSH_SFTP_UPLOAD_INIT,
00074 SSH_SFTP_CREATE_DIRS_INIT,
00075 SSH_SFTP_CREATE_DIRS,
00076 SSH_SFTP_CREATE_DIRS_MKDIR,
00077 SSH_SFTP_READDIR_INIT,
00078 SSH_SFTP_READDIR,
00079 SSH_SFTP_READDIR_LINK,
00080 SSH_SFTP_READDIR_BOTTOM,
00081 SSH_SFTP_READDIR_DONE,
00082 SSH_SFTP_DOWNLOAD_INIT,
00083 SSH_SFTP_DOWNLOAD_STAT,
00084 SSH_SFTP_CLOSE,
00085 SSH_SFTP_SHUTDOWN,
00086 SSH_SCP_TRANS_INIT,
00087 SSH_SCP_UPLOAD_INIT,
00088 SSH_SCP_DOWNLOAD_INIT,
00089 SSH_SCP_DONE,
00090 SSH_SCP_SEND_EOF,
00091 SSH_SCP_WAIT_EOF,
00092 SSH_SCP_WAIT_CLOSE,
00093 SSH_SCP_CHANNEL_FREE,
00094 SSH_SESSION_DISCONNECT,
00095 SSH_SESSION_FREE,
00096 SSH_QUIT,
00097 SSH_LAST
00098 } sshstate;
00099
00100
00101
00102
00103
00104 struct SSHPROTO {
00105 char *path;
00106 };
00107
00108
00109
00110 struct ssh_conn {
00111 const char *authlist;
00112 #ifdef USE_LIBSSH2
00113 const char *passphrase;
00114 char *rsa_pub;
00115 char *rsa;
00116 bool authed;
00117 sshstate state;
00118 sshstate nextstate;
00119 CURLcode actualcode;
00120 struct curl_slist *quote_item;
00121 char *quote_path1;
00122 char *quote_path2;
00123 LIBSSH2_SFTP_ATTRIBUTES quote_attrs;
00124 bool acceptfail;
00125
00126 char *homedir;
00127
00128
00129
00130 LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
00131 char *readdir_filename;
00132 char *readdir_longentry;
00133 int readdir_len, readdir_totalLen, readdir_currLen;
00134 char *readdir_line;
00135 char *readdir_linkPath;
00136
00137
00138 int secondCreateDirs;
00139
00140
00141 char *slash_pos;
00142 LIBSSH2_SESSION *ssh_session;
00143 LIBSSH2_CHANNEL *ssh_channel;
00144 LIBSSH2_SFTP *sftp_session;
00145 LIBSSH2_SFTP_HANDLE *sftp_handle;
00146 int orig_waitfor;
00147
00148 #ifdef HAVE_LIBSSH2_AGENT_API
00149 LIBSSH2_AGENT *ssh_agent;
00150 struct libssh2_agent_publickey *sshagent_identity,
00151 *sshagent_prev_identity;
00152 #endif
00153
00154
00155
00156 #ifdef HAVE_LIBSSH2_KNOWNHOST_API
00157 LIBSSH2_KNOWNHOSTS *kh;
00158 #endif
00159 #endif
00160 };
00161
00162 #ifdef USE_LIBSSH2
00163
00164
00165
00166
00167 #if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000)
00168 # error "SCP/SFTP protocols require libssh2 0.16 or later"
00169 #endif
00170
00171 #if LIBSSH2_VERSION_NUM >= 0x010000
00172 #define HAVE_LIBSSH2_SFTP_SEEK64 1
00173 #endif
00174
00175 #if LIBSSH2_VERSION_NUM >= 0x010100
00176 #define HAVE_LIBSSH2_VERSION 1
00177 #endif
00178
00179 #if LIBSSH2_VERSION_NUM >= 0x010205
00180 #define HAVE_LIBSSH2_INIT 1
00181 #define HAVE_LIBSSH2_EXIT 1
00182 #endif
00183
00184 #if LIBSSH2_VERSION_NUM >= 0x010206
00185 #define HAVE_LIBSSH2_KNOWNHOST_CHECKP 1
00186 #define HAVE_LIBSSH2_SCP_SEND64 1
00187 #endif
00188
00189 #if LIBSSH2_VERSION_NUM >= 0x010208
00190 #define HAVE_LIBSSH2_SESSION_HANDSHAKE 1
00191 #endif
00192
00193 extern const struct Curl_handler Curl_handler_scp;
00194 extern const struct Curl_handler Curl_handler_sftp;
00195
00196 #endif
00197
00198 #endif