Lines Matching refs:data

109 static CURLcode myssh_connect(struct Curl_easy *data, bool *done);
110 static CURLcode myssh_multi_statemach(struct Curl_easy *data,
112 static CURLcode myssh_do_it(struct Curl_easy *data, bool *done);
114 static CURLcode scp_done(struct Curl_easy *data,
116 static CURLcode scp_doing(struct Curl_easy *data, bool *dophase_done);
117 static CURLcode scp_disconnect(struct Curl_easy *data,
121 static CURLcode sftp_done(struct Curl_easy *data,
123 static CURLcode sftp_doing(struct Curl_easy *data,
125 static CURLcode sftp_disconnect(struct Curl_easy *data,
129 CURLcode sftp_perform(struct Curl_easy *data,
133 static void sftp_quote(struct Curl_easy *data);
134 static void sftp_quote_stat(struct Curl_easy *data);
135 static int myssh_getsock(struct Curl_easy *data,
139 static CURLcode myssh_setup_connection(struct Curl_easy *data,
233 static void mystate(struct Curl_easy *data, sshstate nowstate in mystate() argument
239 struct connectdata *conn = data->conn; in mystate()
308 infof(data, "SSH %p state change from %s to %s (line %d)", in mystate()
327 static int myssh_is_known(struct Curl_easy *data) in myssh_is_known() argument
330 struct connectdata *conn = data->conn; in myssh_is_known()
342 data->set.ssh_keyfunc; in myssh_is_known()
357 if(data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) { in myssh_is_known()
360 const char *pubkey_md5 = data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]; in myssh_is_known()
365 failf(data, in myssh_is_known()
373 infof(data, "SSH MD5 fingerprint: %s", md5buffer); in myssh_is_known()
376 failf(data, in myssh_is_known()
387 if(data->set.str[STRING_SSH_KNOWNHOSTS]) { in myssh_is_known()
499 Curl_set_in_callback(data, TRUE); in myssh_is_known()
500 rc = func(data, knownkeyp, /* from the knownhosts file */ in myssh_is_known()
502 keymatch, data->set.ssh_keyfunc_userp); in myssh_is_known()
503 Curl_set_in_callback(data, FALSE); in myssh_is_known()
551 state(data, SSH_SESSION_DISCONNECT); \
557 state(data, SSH_SFTP_CLOSE); \
566 state(data, SSH_AUTH_PASS_INIT); \
576 state(data, SSH_AUTH_KEY_INIT); \
586 state(data, SSH_AUTH_GSSAPI); \
664 static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) in myssh_statemach_act() argument
667 struct connectdata *conn = data->conn; in myssh_statemach_act()
668 struct SSHPROTO *protop = data->req.p.ssh; in myssh_statemach_act()
692 state(data, SSH_S_STARTUP); in myssh_statemach_act()
700 DEBUGF(infof(data, "ssh_connect -> EAGAIN")); in myssh_statemach_act()
705 failf(data, "Failure establishing ssh session"); in myssh_statemach_act()
710 state(data, SSH_HOSTKEY); in myssh_statemach_act()
715 rc = myssh_is_known(data); in myssh_statemach_act()
721 state(data, SSH_AUTHLIST); in myssh_statemach_act()
734 infof(data, "Authenticated with none"); in myssh_statemach_act()
735 state(data, SSH_AUTH_DONE); in myssh_statemach_act()
746 infof(data, "SSH authentication methods available: %s%s%s%s", in myssh_statemach_act()
756 state(data, SSH_AUTH_PKEY_INIT); in myssh_statemach_act()
757 infof(data, "Authentication using SSH public key file"); in myssh_statemach_act()
760 state(data, SSH_AUTH_GSSAPI); in myssh_statemach_act()
763 state(data, SSH_AUTH_KEY_INIT); in myssh_statemach_act()
766 state(data, SSH_AUTH_PASS_INIT); in myssh_statemach_act()
776 if(!(data->set.ssh_auth_types & CURLSSH_AUTH_PUBLICKEY)) { in myssh_statemach_act()
783 if(data->set.str[STRING_SSH_PRIVATE_KEY]) { in myssh_statemach_act()
784 if(sshc->pubkey && !data->set.ssl.key_passwd) { in myssh_statemach_act()
798 rc = ssh_pki_import_privkey_file(data-> in myssh_statemach_act()
800 data->set.ssl.key_passwd, NULL, in myssh_statemach_act()
803 failf(data, "Could not load private key file %s", in myssh_statemach_act()
804 data->set.str[STRING_SSH_PRIVATE_KEY]); in myssh_statemach_act()
809 state(data, SSH_AUTH_PKEY); in myssh_statemach_act()
815 data->set.ssl.key_passwd); in myssh_statemach_act()
823 infof(data, "Completed public key authentication"); in myssh_statemach_act()
824 state(data, SSH_AUTH_DONE); in myssh_statemach_act()
840 infof(data, "Completed public key authentication"); in myssh_statemach_act()
841 state(data, SSH_AUTH_DONE); in myssh_statemach_act()
845 infof(data, "Failed public key authentication (rc: %d)", rc); in myssh_statemach_act()
851 if(!(data->set.ssh_auth_types & CURLSSH_AUTH_GSSAPI)) { in myssh_statemach_act()
865 infof(data, "Completed gssapi authentication"); in myssh_statemach_act()
866 state(data, SSH_AUTH_DONE); in myssh_statemach_act()
874 if(data->set.ssh_auth_types & CURLSSH_AUTH_KEYBOARD) { in myssh_statemach_act()
875 state(data, SSH_AUTH_KEY); in myssh_statemach_act()
890 infof(data, "completed keyboard interactive authentication"); in myssh_statemach_act()
891 state(data, SSH_AUTH_DONE); in myssh_statemach_act()
899 if(!(data->set.ssh_auth_types & CURLSSH_AUTH_PASSWORD)) { in myssh_statemach_act()
903 state(data, SSH_AUTH_PASS); in myssh_statemach_act()
915 infof(data, "Completed password authentication"); in myssh_statemach_act()
916 state(data, SSH_AUTH_DONE); in myssh_statemach_act()
925 failf(data, "Authentication failure"); in myssh_statemach_act()
933 infof(data, "Authentication complete"); in myssh_statemach_act()
935 Curl_pgrsTime(data, TIMER_APPCONNECT); /* SSH is connected */ in myssh_statemach_act()
941 state(data, SSH_SFTP_INIT); in myssh_statemach_act()
944 infof(data, "SSH CONNECT phase done"); in myssh_statemach_act()
945 state(data, SSH_STOP); in myssh_statemach_act()
953 failf(data, "Failure initializing sftp session: %s", in myssh_statemach_act()
961 failf(data, "Failure initializing sftp session: %s", in myssh_statemach_act()
966 state(data, SSH_SFTP_REALPATH); in myssh_statemach_act()
977 data->state.most_recent_ftp_entrypath = sshc->homedir; in myssh_statemach_act()
983 DEBUGF(infof(data, "SSH CONNECT phase done")); in myssh_statemach_act()
984 state(data, SSH_STOP); in myssh_statemach_act()
988 result = Curl_getworkingpath(data, sshc->homedir, &protop->path); in myssh_statemach_act()
991 state(data, SSH_STOP); in myssh_statemach_act()
995 if(data->set.quote) { in myssh_statemach_act()
996 infof(data, "Sending quote commands"); in myssh_statemach_act()
997 sshc->quote_item = data->set.quote; in myssh_statemach_act()
998 state(data, SSH_SFTP_QUOTE); in myssh_statemach_act()
1001 state(data, SSH_SFTP_GETINFO); in myssh_statemach_act()
1006 if(data->set.postquote) { in myssh_statemach_act()
1007 infof(data, "Sending quote commands"); in myssh_statemach_act()
1008 sshc->quote_item = data->set.postquote; in myssh_statemach_act()
1009 state(data, SSH_SFTP_QUOTE); in myssh_statemach_act()
1012 state(data, SSH_STOP); in myssh_statemach_act()
1018 sftp_quote(data); in myssh_statemach_act()
1028 state(data, SSH_SFTP_QUOTE); in myssh_statemach_act()
1032 state(data, sshc->nextstate); in myssh_statemach_act()
1036 state(data, SSH_SFTP_GETINFO); in myssh_statemach_act()
1042 sftp_quote_stat(data); in myssh_statemach_act()
1051 failf(data, "Attempt to set SFTP stats failed: %s", in myssh_statemach_act()
1053 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1061 state(data, SSH_SFTP_NEXT_QUOTE); in myssh_statemach_act()
1070 failf(data, "symlink command failed: %s", in myssh_statemach_act()
1072 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1077 state(data, SSH_SFTP_NEXT_QUOTE); in myssh_statemach_act()
1082 (mode_t)data->set.new_directory_perms); in myssh_statemach_act()
1085 failf(data, "mkdir command failed: %s", in myssh_statemach_act()
1087 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1092 state(data, SSH_SFTP_NEXT_QUOTE); in myssh_statemach_act()
1101 failf(data, "rename command failed: %s", in myssh_statemach_act()
1103 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1108 state(data, SSH_SFTP_NEXT_QUOTE); in myssh_statemach_act()
1115 failf(data, "rmdir command failed: %s", in myssh_statemach_act()
1117 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1122 state(data, SSH_SFTP_NEXT_QUOTE); in myssh_statemach_act()
1129 failf(data, "rm command failed: %s", in myssh_statemach_act()
1131 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1136 state(data, SSH_SFTP_NEXT_QUOTE); in myssh_statemach_act()
1146 failf(data, "statvfs command failed: %s", in myssh_statemach_act()
1148 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1181 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1186 result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp)); in myssh_statemach_act()
1189 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1194 state(data, SSH_SFTP_NEXT_QUOTE); in myssh_statemach_act()
1199 if(data->set.get_filetime) { in myssh_statemach_act()
1200 state(data, SSH_SFTP_FILETIME); in myssh_statemach_act()
1203 state(data, SSH_SFTP_TRANS_INIT); in myssh_statemach_act()
1213 data->info.filetime = attrs->mtime; in myssh_statemach_act()
1217 state(data, SSH_SFTP_TRANS_INIT); in myssh_statemach_act()
1222 if(data->state.upload) in myssh_statemach_act()
1223 state(data, SSH_SFTP_UPLOAD_INIT); in myssh_statemach_act()
1226 state(data, SSH_SFTP_READDIR_INIT); in myssh_statemach_act()
1228 state(data, SSH_SFTP_DOWNLOAD_INIT); in myssh_statemach_act()
1236 if(data->state.resume_from) { in myssh_statemach_act()
1239 if(data->state.resume_from < 0) { in myssh_statemach_act()
1244 failf(data, "Bad file size (%" FMT_OFF_T ")", size); in myssh_statemach_act()
1248 data->state.resume_from = attrs->size; in myssh_statemach_act()
1253 data->state.resume_from = 0; in myssh_statemach_act()
1258 if(data->set.remote_append) in myssh_statemach_act()
1261 else if(data->state.resume_from > 0) in myssh_statemach_act()
1272 flags, (mode_t)data->set.new_file_perms); in myssh_statemach_act()
1278 (data->set.ftp_create_missing_dirs && in myssh_statemach_act()
1283 state(data, SSH_SFTP_CREATE_DIRS_INIT); in myssh_statemach_act()
1294 if(data->state.resume_from > 0) { in myssh_statemach_act()
1296 if(data->set.seek_func) { in myssh_statemach_act()
1297 Curl_set_in_callback(data, TRUE); in myssh_statemach_act()
1298 seekerr = data->set.seek_func(data->set.seek_client, in myssh_statemach_act()
1299 data->state.resume_from, SEEK_SET); in myssh_statemach_act()
1300 Curl_set_in_callback(data, FALSE); in myssh_statemach_act()
1307 failf(data, "Could not seek stream"); in myssh_statemach_act()
1314 (data->state.resume_from - passed > in myssh_statemach_act()
1316 sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); in myssh_statemach_act()
1319 data->state.fread_func(scratch, 1, in myssh_statemach_act()
1320 readthisamountnow, data->state.in); in myssh_statemach_act()
1326 failf(data, "Failed to read data"); in myssh_statemach_act()
1330 } while(passed < data->state.resume_from); in myssh_statemach_act()
1336 if(data->state.infilesize > 0) { in myssh_statemach_act()
1337 data->state.infilesize -= data->state.resume_from; in myssh_statemach_act()
1338 data->req.size = data->state.infilesize; in myssh_statemach_act()
1339 Curl_pgrsSetUploadSize(data, data->state.infilesize); in myssh_statemach_act()
1342 rc = sftp_seek64(sshc->sftp_file, data->state.resume_from); in myssh_statemach_act()
1348 if(data->state.infilesize > 0) { in myssh_statemach_act()
1349 data->req.size = data->state.infilesize; in myssh_statemach_act()
1350 Curl_pgrsSetUploadSize(data, data->state.infilesize); in myssh_statemach_act()
1353 Curl_xfer_setup1(data, CURL_XFER_SEND, -1, FALSE); in myssh_statemach_act()
1360 sshc->orig_waitfor = data->req.keepon; in myssh_statemach_act()
1365 data->state.select_bits = CURL_CSELECT_OUT; in myssh_statemach_act()
1370 Curl_expire(data, 0, EXPIRE_RUN_NOW); in myssh_statemach_act()
1372 state(data, SSH_STOP); in myssh_statemach_act()
1379 state(data, SSH_SFTP_CREATE_DIRS); in myssh_statemach_act()
1382 state(data, SSH_SFTP_UPLOAD_INIT); in myssh_statemach_act()
1391 infof(data, "Creating directory '%s'", protop->path); in myssh_statemach_act()
1392 state(data, SSH_SFTP_CREATE_DIRS_MKDIR); in myssh_statemach_act()
1395 state(data, SSH_SFTP_UPLOAD_INIT); in myssh_statemach_act()
1401 (mode_t)data->set.new_directory_perms); in myssh_statemach_act()
1419 state(data, SSH_SFTP_CREATE_DIRS); in myssh_statemach_act()
1423 Curl_pgrsSetDownloadSize(data, -1); in myssh_statemach_act()
1424 if(data->req.no_body) { in myssh_statemach_act()
1425 state(data, SSH_STOP); in myssh_statemach_act()
1436 failf(data, "Could not open directory for reading: %s", in myssh_statemach_act()
1441 state(data, SSH_SFTP_READDIR); in myssh_statemach_act()
1455 if(data->set.list_only) { in myssh_statemach_act()
1460 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1464 result = Curl_client_write(data, CLIENTWRITE_BODY, in myssh_statemach_act()
1469 state(data, SSH_STOP); in myssh_statemach_act()
1477 state(data, SSH_STOP); in myssh_statemach_act()
1488 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1493 state(data, SSH_SFTP_READDIR_LINK); in myssh_statemach_act()
1496 state(data, SSH_SFTP_READDIR_BOTTOM); in myssh_statemach_act()
1501 state(data, SSH_SFTP_READDIR_DONE); in myssh_statemach_act()
1505 failf(data, "Could not open remote file for reading: %s", in myssh_statemach_act()
1519 failf(data, "Could not read symlink for reading: %s", in myssh_statemach_act()
1554 state(data, SSH_SFTP_READDIR_BOTTOM); in myssh_statemach_act()
1560 result = Curl_client_write(data, CLIENTWRITE_BODY, in myssh_statemach_act()
1568 state(data, SSH_STOP); in myssh_statemach_act()
1571 state(data, SSH_SFTP_READDIR); in myssh_statemach_act()
1579 Curl_xfer_setup_nop(data); in myssh_statemach_act()
1580 state(data, SSH_STOP); in myssh_statemach_act()
1591 O_RDONLY, (mode_t)data->set.new_file_perms); in myssh_statemach_act()
1593 failf(data, "Could not open remote file for reading: %s", in myssh_statemach_act()
1600 state(data, SSH_SFTP_DOWNLOAD_STAT); in myssh_statemach_act()
1618 data->req.size = -1; in myssh_statemach_act()
1619 data->req.maxdownload = -1; in myssh_statemach_act()
1620 Curl_pgrsSetDownloadSize(data, -1); in myssh_statemach_act()
1629 failf(data, "Bad file size (%" FMT_OFF_T ")", size); in myssh_statemach_act()
1632 if(data->state.use_range) { in myssh_statemach_act()
1639 from_t = curlx_strtoofft(data->state.range, &ptr, 10, &from); in myssh_statemach_act()
1659 failf(data, "Offset (%" FMT_OFF_T ") was beyond file size (%" in myssh_statemach_act()
1679 data->req.size = size; in myssh_statemach_act()
1680 data->req.maxdownload = size; in myssh_statemach_act()
1681 Curl_pgrsSetDownloadSize(data, size); in myssh_statemach_act()
1685 if(data->state.resume_from) { in myssh_statemach_act()
1686 if(data->state.resume_from < 0) { in myssh_statemach_act()
1688 if((curl_off_t)size < -data->state.resume_from) { in myssh_statemach_act()
1689 failf(data, "Offset (%" FMT_OFF_T ") was beyond file size (%" in myssh_statemach_act()
1690 FMT_OFF_T ")", data->state.resume_from, size); in myssh_statemach_act()
1694 data->state.resume_from += size; in myssh_statemach_act()
1697 if((curl_off_t)size < data->state.resume_from) { in myssh_statemach_act()
1698 failf(data, "Offset (%" FMT_OFF_T in myssh_statemach_act()
1700 data->state.resume_from, size); in myssh_statemach_act()
1705 data->req.size = size - data->state.resume_from; in myssh_statemach_act()
1706 data->req.maxdownload = size - data->state.resume_from; in myssh_statemach_act()
1707 Curl_pgrsSetDownloadSize(data, in myssh_statemach_act()
1708 size - data->state.resume_from); in myssh_statemach_act()
1710 rc = sftp_seek64(sshc->sftp_file, data->state.resume_from); in myssh_statemach_act()
1719 if(data->req.size == 0) { in myssh_statemach_act()
1721 Curl_xfer_setup_nop(data); in myssh_statemach_act()
1722 infof(data, "File already completely downloaded"); in myssh_statemach_act()
1723 state(data, SSH_STOP); in myssh_statemach_act()
1726 Curl_xfer_setup1(data, CURL_XFER_RECV, data->req.size, FALSE); in myssh_statemach_act()
1734 data->state.select_bits = CURL_CSELECT_IN; in myssh_statemach_act()
1739 state(data, SSH_SFTP_CLOSE); in myssh_statemach_act()
1744 state(data, SSH_STOP); in myssh_statemach_act()
1755 DEBUGF(infof(data, "SFTP DONE done")); in myssh_statemach_act()
1762 state(data, sshc->nextstate); in myssh_statemach_act()
1766 state(data, SSH_STOP); in myssh_statemach_act()
1787 data->state.most_recent_ftp_entrypath = NULL; in myssh_statemach_act()
1789 state(data, SSH_SESSION_DISCONNECT); in myssh_statemach_act()
1793 result = Curl_getworkingpath(data, sshc->homedir, &protop->path); in myssh_statemach_act()
1796 state(data, SSH_STOP); in myssh_statemach_act()
1803 if(data->state.upload) { in myssh_statemach_act()
1804 if(data->state.infilesize < 0) { in myssh_statemach_act()
1805 failf(data, "SCP requires a known file size for upload"); in myssh_statemach_act()
1813 state(data, SSH_SCP_UPLOAD_INIT); in myssh_statemach_act()
1818 state(data, SSH_SCP_DOWNLOAD_INIT); in myssh_statemach_act()
1823 failf(data, "%s", err_msg); in myssh_statemach_act()
1834 failf(data, "%s", err_msg); in myssh_statemach_act()
1840 data->state.infilesize, in myssh_statemach_act()
1841 (int)data->set.new_file_perms); in myssh_statemach_act()
1844 failf(data, "%s", err_msg); in myssh_statemach_act()
1850 Curl_xfer_setup1(data, CURL_XFER_SEND, -1, FALSE); in myssh_statemach_act()
1857 sshc->orig_waitfor = data->req.keepon; in myssh_statemach_act()
1862 data->state.select_bits = CURL_CSELECT_OUT; in myssh_statemach_act()
1864 state(data, SSH_STOP); in myssh_statemach_act()
1873 failf(data, "%s", err_msg); in myssh_statemach_act()
1877 state(data, SSH_SCP_DOWNLOAD); in myssh_statemach_act()
1886 failf(data, "%s", err_msg); in myssh_statemach_act()
1893 data->req.maxdownload = (curl_off_t) bytecount; in myssh_statemach_act()
1894 Curl_xfer_setup1(data, CURL_XFER_RECV, bytecount, FALSE); in myssh_statemach_act()
1902 data->state.select_bits = CURL_CSELECT_IN; in myssh_statemach_act()
1904 state(data, SSH_STOP); in myssh_statemach_act()
1908 if(data->state.upload) in myssh_statemach_act()
1909 state(data, SSH_SCP_SEND_EOF); in myssh_statemach_act()
1911 state(data, SSH_SCP_CHANNEL_FREE); in myssh_statemach_act()
1924 infof(data, "Failed to close libssh scp channel: %s", in myssh_statemach_act()
1929 state(data, SSH_SCP_CHANNEL_FREE); in myssh_statemach_act()
1937 DEBUGF(infof(data, "SCP DONE phase complete")); in myssh_statemach_act()
1941 state(data, SSH_SESSION_DISCONNECT); in myssh_statemach_act()
1958 Curl_conn_forget_socket(data, FIRSTSOCKET); in myssh_statemach_act()
1962 data->state.most_recent_ftp_entrypath = NULL; in myssh_statemach_act()
1964 state(data, SSH_SESSION_FREE); in myssh_statemach_act()
2012 state(data, SSH_STOP); in myssh_statemach_act()
2019 state(data, SSH_STOP); in myssh_statemach_act()
2038 static int myssh_getsock(struct Curl_easy *data, in myssh_getsock() argument
2043 (void)data; in myssh_getsock()
2055 DEBUGF(infof(data, "ssh_getsock -> %x", bitmap)); in myssh_getsock()
2079 static CURLcode myssh_multi_statemach(struct Curl_easy *data, in myssh_multi_statemach() argument
2082 struct connectdata *conn = data->conn; in myssh_multi_statemach()
2086 CURLcode result = myssh_statemach_act(data, &block); in myssh_multi_statemach()
2094 static CURLcode myssh_block_statemach(struct Curl_easy *data, in myssh_block_statemach() argument
2097 struct connectdata *conn = data->conn; in myssh_block_statemach()
2106 result = myssh_statemach_act(data, &block); in myssh_block_statemach()
2111 if(Curl_pgrsUpdate(data)) in myssh_block_statemach()
2114 result = Curl_speedcheck(data, now); in myssh_block_statemach()
2118 left = Curl_timeleft(data, NULL, FALSE); in myssh_block_statemach()
2120 failf(data, "Operation timed out"); in myssh_block_statemach()
2140 static CURLcode myssh_setup_connection(struct Curl_easy *data, in myssh_setup_connection() argument
2146 data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); in myssh_setup_connection()
2161 static CURLcode myssh_connect(struct Curl_easy *data, bool *done) in myssh_connect() argument
2165 struct connectdata *conn = data->conn; in myssh_connect()
2170 if(!data->req.p.ssh) in myssh_connect()
2171 myssh_setup_connection(data, conn); in myssh_connect()
2190 failf(data, "Failure initialising ssh session"); in myssh_connect()
2203 failf(data, "Could not set remote host"); in myssh_connect()
2209 infof(data, "Could not parse SSH configuration files"); in myssh_connect()
2215 failf(data, "Could not set socket"); in myssh_connect()
2220 infof(data, "User: %s", conn->user); in myssh_connect()
2223 failf(data, "Could not set user"); in myssh_connect()
2228 if(data->set.str[STRING_SSH_KNOWNHOSTS]) { in myssh_connect()
2229 infof(data, "Known hosts: %s", data->set.str[STRING_SSH_KNOWNHOSTS]); in myssh_connect()
2231 data->set.str[STRING_SSH_KNOWNHOSTS]); in myssh_connect()
2233 failf(data, "Could not set known hosts file path"); in myssh_connect()
2242 failf(data, "Could not set remote port"); in myssh_connect()
2247 if(data->set.ssh_compression) { in myssh_connect()
2251 failf(data, "Could not set compression"); in myssh_connect()
2259 if(data->set.str[STRING_SSH_PUBLIC_KEY]) { in myssh_connect()
2260 rc = ssh_pki_import_pubkey_file(data->set.str[STRING_SSH_PUBLIC_KEY], in myssh_connect()
2263 failf(data, "Could not load public key file"); in myssh_connect()
2271 state(data, SSH_INIT); in myssh_connect()
2273 result = myssh_multi_statemach(data, done); in myssh_connect()
2279 static CURLcode scp_doing(struct Curl_easy *data, bool *dophase_done) in scp_doing() argument
2283 result = myssh_multi_statemach(data, dophase_done); in scp_doing()
2286 DEBUGF(infof(data, "DO phase is complete")); in scp_doing()
2301 CURLcode scp_perform(struct Curl_easy *data, in scp_perform() argument
2306 DEBUGF(infof(data, "DO phase starts")); in scp_perform()
2311 state(data, SSH_SCP_TRANS_INIT); in scp_perform()
2313 result = myssh_multi_statemach(data, dophase_done); in scp_perform()
2315 *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); in scp_perform()
2318 DEBUGF(infof(data, "DO phase is complete")); in scp_perform()
2324 static CURLcode myssh_do_it(struct Curl_easy *data, bool *done) in myssh_do_it() argument
2328 struct connectdata *conn = data->conn; in myssh_do_it()
2333 data->req.size = -1; /* make sure this is unknown at this point */ in myssh_do_it()
2339 Curl_pgrsSetUploadCounter(data, 0); in myssh_do_it()
2340 Curl_pgrsSetDownloadCounter(data, 0); in myssh_do_it()
2341 Curl_pgrsSetUploadSize(data, -1); in myssh_do_it()
2342 Curl_pgrsSetDownloadSize(data, -1); in myssh_do_it()
2345 result = scp_perform(data, &connected, done); in myssh_do_it()
2347 result = sftp_perform(data, &connected, done); in myssh_do_it()
2355 static CURLcode scp_disconnect(struct Curl_easy *data, in scp_disconnect() argument
2366 state(data, SSH_SESSION_DISCONNECT); in scp_disconnect()
2368 result = myssh_block_statemach(data, TRUE); in scp_disconnect()
2376 static CURLcode myssh_done(struct Curl_easy *data, CURLcode status) in myssh_done() argument
2379 struct SSHPROTO *protop = data->req.p.ssh; in myssh_done()
2383 result = myssh_block_statemach(data, FALSE); in myssh_done()
2390 if(Curl_pgrsDone(data)) in myssh_done()
2393 data->req.keepon = 0; /* clear all bits */ in myssh_done()
2398 static CURLcode scp_done(struct Curl_easy *data, CURLcode status, in scp_done() argument
2404 state(data, SSH_SCP_DONE); in scp_done()
2406 return myssh_done(data, status); in scp_done()
2410 static ssize_t scp_send(struct Curl_easy *data, int sockindex, in scp_send() argument
2414 struct connectdata *conn = data->conn; in scp_send()
2441 static ssize_t scp_recv(struct Curl_easy *data, int sockindex, in scp_recv() argument
2445 struct connectdata *conn = data->conn; in scp_recv()
2481 CURLcode sftp_perform(struct Curl_easy *data, in sftp_perform() argument
2487 DEBUGF(infof(data, "DO phase starts")); in sftp_perform()
2492 state(data, SSH_SFTP_QUOTE_INIT); in sftp_perform()
2495 result = myssh_multi_statemach(data, dophase_done); in sftp_perform()
2497 *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); in sftp_perform()
2500 DEBUGF(infof(data, "DO phase is complete")); in sftp_perform()
2507 static CURLcode sftp_doing(struct Curl_easy *data, in sftp_doing() argument
2510 CURLcode result = myssh_multi_statemach(data, dophase_done); in sftp_doing()
2512 DEBUGF(infof(data, "DO phase is complete")); in sftp_doing()
2520 static CURLcode sftp_disconnect(struct Curl_easy *data, in sftp_disconnect() argument
2527 DEBUGF(infof(data, "SSH DISCONNECT starts now")); in sftp_disconnect()
2531 state(data, SSH_SFTP_SHUTDOWN); in sftp_disconnect()
2532 result = myssh_block_statemach(data, TRUE); in sftp_disconnect()
2535 DEBUGF(infof(data, "SSH DISCONNECT is done")); in sftp_disconnect()
2541 static CURLcode sftp_done(struct Curl_easy *data, CURLcode status, in sftp_done() argument
2544 struct connectdata *conn = data->conn; in sftp_done()
2551 if(!premature && data->set.postquote && !conn->bits.retry) in sftp_done()
2553 state(data, SSH_SFTP_CLOSE); in sftp_done()
2555 return myssh_done(data, status); in sftp_done()
2559 static ssize_t sftp_send(struct Curl_easy *data, int sockindex, in sftp_send() argument
2564 struct connectdata *conn = data->conn; in sftp_send()
2597 static ssize_t sftp_recv(struct Curl_easy *data, int sockindex, in sftp_recv() argument
2601 struct connectdata *conn = data->conn; in sftp_recv()
2644 static void sftp_quote(struct Curl_easy *data) in sftp_quote() argument
2647 struct connectdata *conn = data->conn; in sftp_quote()
2648 struct SSHPROTO *protop = data->req.p.ssh; in sftp_quote()
2655 char *cmd = sshc->quote_item->data; in sftp_quote()
2674 state(data, SSH_SFTP_CLOSE); in sftp_quote()
2678 Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4); in sftp_quote()
2679 Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp)); in sftp_quote()
2684 result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp)); in sftp_quote()
2687 state(data, SSH_SFTP_CLOSE); in sftp_quote()
2692 state(data, SSH_SFTP_NEXT_QUOTE); in sftp_quote()
2702 failf(data, "Syntax error in SFTP command. Supply parameter(s)"); in sftp_quote()
2703 state(data, SSH_SFTP_CLOSE); in sftp_quote()
2716 failf(data, "Out of memory"); in sftp_quote()
2718 failf(data, "Syntax error: Bad first parameter"); in sftp_quote()
2719 state(data, SSH_SFTP_CLOSE); in sftp_quote()
2743 failf(data, "Out of memory"); in sftp_quote()
2745 failf(data, "Syntax error in chgrp/chmod/chown/atime/mtime: " in sftp_quote()
2748 state(data, SSH_SFTP_CLOSE); in sftp_quote()
2754 state(data, SSH_SFTP_QUOTE_STAT); in sftp_quote()
2765 failf(data, "Out of memory"); in sftp_quote()
2767 failf(data, "Syntax error in ln/symlink: Bad second parameter"); in sftp_quote()
2769 state(data, SSH_SFTP_CLOSE); in sftp_quote()
2774 state(data, SSH_SFTP_QUOTE_SYMLINK); in sftp_quote()
2779 state(data, SSH_SFTP_QUOTE_MKDIR); in sftp_quote()
2789 failf(data, "Out of memory"); in sftp_quote()
2791 failf(data, "Syntax error in rename: Bad second parameter"); in sftp_quote()
2793 state(data, SSH_SFTP_CLOSE); in sftp_quote()
2798 state(data, SSH_SFTP_QUOTE_RENAME); in sftp_quote()
2803 state(data, SSH_SFTP_QUOTE_RMDIR); in sftp_quote()
2807 state(data, SSH_SFTP_QUOTE_UNLINK); in sftp_quote()
2812 state(data, SSH_SFTP_QUOTE_STATVFS); in sftp_quote()
2817 failf(data, "Unknown SFTP command"); in sftp_quote()
2820 state(data, SSH_SFTP_CLOSE); in sftp_quote()
2825 static void sftp_quote_stat(struct Curl_easy *data) in sftp_quote_stat() argument
2827 struct connectdata *conn = data->conn; in sftp_quote_stat()
2829 char *cmd = sshc->quote_item->data; in sftp_quote_stat()
2853 failf(data, "Attempt to get SFTP stats failed: %d", in sftp_quote_stat()
2855 state(data, SSH_SFTP_CLOSE); in sftp_quote_stat()
2868 failf(data, "Syntax error: chgrp gid not a number"); in sftp_quote_stat()
2869 state(data, SSH_SFTP_CLOSE); in sftp_quote_stat()
2883 failf(data, "Syntax error: chmod permissions not a number"); in sftp_quote_stat()
2884 state(data, SSH_SFTP_CLOSE); in sftp_quote_stat()
2898 failf(data, "Syntax error: chown uid not a number"); in sftp_quote_stat()
2899 state(data, SSH_SFTP_CLOSE); in sftp_quote_stat()
2911 failf(data, "incorrect date format for %.*s", 5, cmd); in sftp_quote_stat()
2916 failf(data, "date overflow"); in sftp_quote_stat()
2923 state(data, SSH_SFTP_CLOSE); in sftp_quote_stat()
2937 state(data, SSH_SFTP_QUOTE_SETSTAT); in sftp_quote_stat()