ssh.h
Go to the documentation of this file.
00001 #ifndef HEADER_CURL_SSH_H
00002 #define HEADER_CURL_SSH_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
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 /* HAVE_LIBSSH2_H */
00031 
00032 /****************************************************************************
00033  * SSH unique setup
00034  ***************************************************************************/
00035 typedef enum {
00036   SSH_NO_STATE = -1,  /* Used for "nextState" so say there is none */
00037   SSH_STOP = 0,       /* do nothing state, stops the state machine */
00038 
00039   SSH_INIT,           /* First state in SSH-CONNECT */
00040   SSH_S_STARTUP,      /* Session startup */
00041   SSH_HOSTKEY,        /* verify 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, /* initialize then wait for connection to agent */
00048   SSH_AUTH_AGENT_LIST, /* ask for list then wait for entire list to come */
00049   SSH_AUTH_AGENT,      /* attempt one key at a time */
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,   /* Last state in SSH-CONNECT */
00057 
00058   SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */
00059   SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */
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, /* Last state in SFTP-DO */
00084   SSH_SFTP_CLOSE,    /* Last state in SFTP-DONE */
00085   SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */
00086   SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
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,   /* Last state in SCP-DONE */
00094   SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */
00095   SSH_SESSION_FREE,       /* Last state in SCP/SFTP-DISCONNECT */
00096   SSH_QUIT,
00097   SSH_LAST  /* never used */
00098 } sshstate;
00099 
00100 /* this struct is used in the HandleData struct which is part of the
00101    Curl_easy, which means this is used on a per-easy handle basis.
00102    Everything that is strictly related to a connection is banned from this
00103    struct. */
00104 struct SSHPROTO {
00105   char *path;                  /* the path we operate on */
00106 };
00107 
00108 /* ssh_conn is used for struct connection-oriented data in the connectdata
00109    struct */
00110 struct ssh_conn {
00111   const char *authlist;       /* List of auth. methods, managed by libssh2 */
00112 #ifdef USE_LIBSSH2
00113   const char *passphrase;     /* pass-phrase to use */
00114   char *rsa_pub;              /* path name */
00115   char *rsa;                  /* path name */
00116   bool authed;                /* the connection has been authenticated fine */
00117   sshstate state;             /* always use ssh.c:state() to change state! */
00118   sshstate nextstate;         /* the state to goto after stopping */
00119   CURLcode actualcode;        /* the actual error code */
00120   struct curl_slist *quote_item; /* for the quote option */
00121   char *quote_path1;          /* two generic pointers for the QUOTE stuff */
00122   char *quote_path2;
00123   LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
00124   bool acceptfail;            /* used by the SFTP_QUOTE (continue if
00125                                  quote command fails) */
00126   char *homedir;              /* when doing SFTP we figure out home dir in the
00127                                  connect phase */
00128 
00129   /* Here's a set of struct members used by the SFTP_READDIR state */
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   /* end of READDIR stuff */
00137 
00138   int secondCreateDirs;         /* counter use by the code to see if the
00139                                    second attempt has been made to change
00140                                    to/create a directory */
00141   char *slash_pos;              /* used by the SFTP_CREATE_DIRS state */
00142   LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
00143   LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
00144   LIBSSH2_SFTP *sftp_session;   /* SFTP handle */
00145   LIBSSH2_SFTP_HANDLE *sftp_handle;
00146   int orig_waitfor;             /* default READ/WRITE bits wait for */
00147 
00148 #ifdef HAVE_LIBSSH2_AGENT_API
00149   LIBSSH2_AGENT *ssh_agent;     /* proxy to ssh-agent/pageant */
00150   struct libssh2_agent_publickey *sshagent_identity,
00151                                  *sshagent_prev_identity;
00152 #endif
00153 
00154   /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h
00155      header */
00156 #ifdef HAVE_LIBSSH2_KNOWNHOST_API
00157   LIBSSH2_KNOWNHOSTS *kh;
00158 #endif
00159 #endif /* USE_LIBSSH2 */
00160 };
00161 
00162 #ifdef USE_LIBSSH2
00163 
00164 /* Feature detection based on version numbers to better work with
00165    non-configure platforms */
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 /* USE_LIBSSH2 */
00197 
00198 #endif /* HEADER_CURL_SSH_H */


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06