Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 184 lines (164 sloc) 6.641 kb
c036f6a @yangtse Adjust some libssh2 preprocessor symbol definition checks
yangtse authored
1 #ifndef HEADER_CURL_SSH_H
2 #define HEADER_CURL_SSH_H
2147284 @bagder James Housley brought support for SCP transfers
authored
3 /***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
7d94af4 @bagder SSH: set non-blocking earlier
authored
10 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
2147284 @bagder James Housley brought support for SCP transfers
authored
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at http://curl.haxx.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ***************************************************************************/
24
83a6b34 @bagder split out more protocol-specific structs from urldata.h into their own
authored
25 #include "setup.h"
26
27 #ifdef HAVE_LIBSSH2_H
28 #include <libssh2.h>
29 #include <libssh2_sftp.h>
30 #endif /* HAVE_LIBSSH2_H */
31
32 /****************************************************************************
33 * SSH unique setup
34 ***************************************************************************/
35 typedef enum {
36 SSH_NO_STATE = -1, /* Used for "nextState" so say there is none */
37 SSH_STOP = 0, /* do nothing state, stops the state machine */
38
7d94af4 @bagder SSH: set non-blocking earlier
authored
39 SSH_INIT, /* First state in SSH-CONNECT */
40 SSH_S_STARTUP, /* Session startup */
83a6b34 @bagder split out more protocol-specific structs from urldata.h into their own
authored
41 SSH_HOSTKEY, /* verify hostkey */
42 SSH_AUTHLIST,
43 SSH_AUTH_PKEY_INIT,
44 SSH_AUTH_PKEY,
45 SSH_AUTH_PASS_INIT,
46 SSH_AUTH_PASS,
e351972 SSH: added agent based authentication
Armel Asselin authored
47 SSH_AUTH_AGENT_INIT,/* initialize then wait for connection to agent */
48 SSH_AUTH_AGENT_LIST,/* ask for list then wait for entire list to come */
49 SSH_AUTH_AGENT, /* attempt one key at a time */
83a6b34 @bagder split out more protocol-specific structs from urldata.h into their own
authored
50 SSH_AUTH_HOST_INIT,
51 SSH_AUTH_HOST,
52 SSH_AUTH_KEY_INIT,
53 SSH_AUTH_KEY,
54 SSH_AUTH_DONE,
55 SSH_SFTP_INIT,
56 SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
57
58 SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */
59 SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */
60 SSH_SFTP_QUOTE,
61 SSH_SFTP_NEXT_QUOTE,
62 SSH_SFTP_QUOTE_STAT,
63 SSH_SFTP_QUOTE_SETSTAT,
64 SSH_SFTP_QUOTE_SYMLINK,
65 SSH_SFTP_QUOTE_MKDIR,
66 SSH_SFTP_QUOTE_RENAME,
67 SSH_SFTP_QUOTE_RMDIR,
68 SSH_SFTP_QUOTE_UNLINK,
69 SSH_SFTP_TRANS_INIT,
70 SSH_SFTP_UPLOAD_INIT,
71 SSH_SFTP_CREATE_DIRS_INIT,
72 SSH_SFTP_CREATE_DIRS,
73 SSH_SFTP_CREATE_DIRS_MKDIR,
74 SSH_SFTP_READDIR_INIT,
75 SSH_SFTP_READDIR,
76 SSH_SFTP_READDIR_LINK,
77 SSH_SFTP_READDIR_BOTTOM,
78 SSH_SFTP_READDIR_DONE,
79 SSH_SFTP_DOWNLOAD_INIT,
80 SSH_SFTP_DOWNLOAD_STAT, /* Last state in SFTP-DO */
81 SSH_SFTP_CLOSE, /* Last state in SFTP-DONE */
82 SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */
83 SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
84 SSH_SCP_UPLOAD_INIT,
85 SSH_SCP_DOWNLOAD_INIT,
86 SSH_SCP_DONE,
87 SSH_SCP_SEND_EOF,
88 SSH_SCP_WAIT_EOF,
89 SSH_SCP_WAIT_CLOSE,
90 SSH_SCP_CHANNEL_FREE, /* Last state in SCP-DONE */
91 SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */
92 SSH_SESSION_FREE, /* Last state in SCP/SFTP-DISCONNECT */
93 SSH_QUIT,
94 SSH_LAST /* never used */
95 } sshstate;
96
97 /* this struct is used in the HandleData struct which is part of the
98 SessionHandle, which means this is used on a per-easy handle basis.
99 Everything that is strictly related to a connection is banned from this
100 struct. */
101 struct SSHPROTO {
102 char *path; /* the path we operate on */
103 };
104
105 /* ssh_conn is used for struct connection-oriented data in the connectdata
106 struct */
107 struct ssh_conn {
108 const char *authlist; /* List of auth. methods, managed by libssh2 */
109 #ifdef USE_LIBSSH2
110 const char *passphrase; /* pass-phrase to use */
111 char *rsa_pub; /* path name */
112 char *rsa; /* path name */
113 bool authed; /* the connection has been authenticated fine */
114 sshstate state; /* always use ssh.c:state() to change state! */
115 sshstate nextstate; /* the state to goto after stopping */
116 CURLcode actualcode; /* the actual error code */
117 struct curl_slist *quote_item; /* for the quote option */
118 char *quote_path1; /* two generic pointers for the QUOTE stuff */
119 char *quote_path2;
120 LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
0604b2f @jonasschnelli rectify comment
jonasschnelli authored
121 bool acceptfail; /* used by the SFTP_QUOTE (continue if
122 quote command fails) */
83a6b34 @bagder split out more protocol-specific structs from urldata.h into their own
authored
123 char *homedir; /* when doing SFTP we figure out home dir in the
124 connect phase */
125
126 /* Here's a set of struct members used by the SFTP_READDIR state */
127 LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
128 char *readdir_filename;
129 char *readdir_longentry;
130 int readdir_len, readdir_totalLen, readdir_currLen;
131 char *readdir_line;
132 char *readdir_linkPath;
133 /* end of READDIR stuff */
134
135 int secondCreateDirs; /* counter use by the code to see if the
136 second attempt has been made to change
137 to/create a directory */
138 char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
139 LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
140 LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
141 LIBSSH2_SFTP *sftp_session; /* SFTP handle */
142 LIBSSH2_SFTP_HANDLE *sftp_handle;
143 int orig_waitfor; /* default READ/WRITE bits wait for */
144
e351972 SSH: added agent based authentication
Armel Asselin authored
145 #ifdef HAVE_LIBSSH2_AGENT_API
146 LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */
147 struct libssh2_agent_publickey *sshagent_identity,
148 *sshagent_prev_identity;
149 #endif
150
83a6b34 @bagder split out more protocol-specific structs from urldata.h into their own
authored
151 /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h
152 header */
153 #ifdef HAVE_LIBSSH2_KNOWNHOST_API
154 LIBSSH2_KNOWNHOSTS *kh;
155 #endif
156 #endif /* USE_LIBSSH2 */
157 };
158
2147284 @bagder James Housley brought support for SCP transfers
authored
159 #ifdef USE_LIBSSH2
c036f6a @yangtse Adjust some libssh2 preprocessor symbol definition checks
yangtse authored
160
161 #if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000)
162 # error "SCP/SFTP protocols require libssh2 0.16 or later"
163 #endif
164
ddb0b8d @yangtse Fix libssh2 preprocessor symbol definition check
yangtse authored
165 #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010000)
eab8c0d @bagder libssh2_sftp_seek2 was just renamed to libssh2_sftp_seek64 ...
authored
166 # define HAVE_LIBSSH2_SFTP_SEEK64 1
167 #else
e9895ea Remove trailing #undef value. Typo?
Gisle Vanem authored
168 # undef HAVE_LIBSSH2_SFTP_SEEK64
eab8c0d @bagder libssh2_sftp_seek2 was just renamed to libssh2_sftp_seek64 ...
authored
169 #endif
170
f8cf037 @bagder SCP: send large files properly with new enough libssh2
authored
171 #if defined(LIBSSH2_VERSION_NUM) && (LIBSSH2_VERSION_NUM >= 0x010206)
172 # define HAVE_LIBSSH2_SCP_SEND64 1
173 #else
992ceae @yangtse build: fix libssh2_scp_send64() availability
yangtse authored
174 # undef HAVE_LIBSSH2_SCP_SEND64
f8cf037 @bagder SCP: send large files properly with new enough libssh2
authored
175 #endif
176
eab8c0d @bagder libssh2_sftp_seek2 was just renamed to libssh2_sftp_seek64 ...
authored
177
07b6e73 Added per-protocol callback static tables, replacing callback ptr sto…
Patrick Monnerat authored
178 extern const struct Curl_handler Curl_handler_scp;
179 extern const struct Curl_handler Curl_handler_sftp;
2147284 @bagder James Housley brought support for SCP transfers
authored
180
181 #endif /* USE_LIBSSH2 */
a634f64 @bagder James Housley did lots of work and introduced SFTP downloads.
authored
182
c036f6a @yangtse Adjust some libssh2 preprocessor symbol definition checks
yangtse authored
183 #endif /* HEADER_CURL_SSH_H */
Something went wrong with that request. Please try again.