Lines Matching refs:sshc
312 struct ssh_conn *sshc = &conn->proto.sshc; in state() local
381 if(sshc->state != nowstate) { in state()
383 (void *)sshc, names[sshc->state], names[nowstate]); in state()
387 sshc->state = nowstate; in state()
482 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_knownhost() local
484 const char *remotekey = libssh2_session_hostkey(sshc->ssh_session, in ssh_knownhost()
539 keycheck = libssh2_knownhost_checkp(sshc->kh, in ssh_knownhost()
549 keycheck = libssh2_knownhost_check(sshc->kh, in ssh_knownhost()
601 result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_knownhost()
606 libssh2_knownhost_del(sshc->kh, host); in ssh_knownhost()
614 int addrc = libssh2_knownhost_add(sshc->kh, in ssh_knownhost()
628 libssh2_knownhost_writefile(sshc->kh, in ssh_knownhost()
649 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_check_fingerprint() local
667 fingerprint = libssh2_hostkey_hash(sshc->ssh_session, in ssh_check_fingerprint()
674 hostkey = libssh2_session_hostkey(sshc->ssh_session, &len, NULL); in ssh_check_fingerprint()
686 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
687 return sshc->actualcode; in ssh_check_fingerprint()
695 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
696 return sshc->actualcode; in ssh_check_fingerprint()
702 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
703 return sshc->actualcode; in ssh_check_fingerprint()
729 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
730 return sshc->actualcode; in ssh_check_fingerprint()
742 fingerprint = libssh2_hostkey_hash(sshc->ssh_session, in ssh_check_fingerprint()
769 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
770 return sshc->actualcode; in ssh_check_fingerprint()
781 const char *remotekey = libssh2_session_hostkey(sshc->ssh_session, in ssh_check_fingerprint()
791 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
792 return sshc->actualcode; in ssh_check_fingerprint()
797 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
798 return sshc->actualcode; in ssh_check_fingerprint()
847 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_force_knownhost_key_type() local
854 if(sshc->kh && !data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) { in ssh_force_knownhost_key_type()
856 while(!libssh2_knownhost_get(sshc->kh, &store, store)) { in ssh_force_knownhost_key_type()
941 rc = libssh2_session_method_pref(sshc->ssh_session, in ssh_force_knownhost_key_type()
946 libssh2_session_last_error(sshc->ssh_session, &errmsg, &errlen, 0); in ssh_force_knownhost_key_type()
963 struct ssh_conn *sshc, in sftp_quote() argument
975 char *cmd = sshc->quote_item->data; in sftp_quote()
976 sshc->acceptfail = FALSE; in sftp_quote()
985 sshc->acceptfail = TRUE; in sftp_quote()
1020 result = Curl_get_pathname(&cp, &sshc->quote_path1, sshc->homedir); in sftp_quote()
1041 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in sftp_quote()
1045 Curl_safefree(sshc->quote_path1); in sftp_quote()
1057 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in sftp_quote()
1061 Curl_safefree(sshc->quote_path1); in sftp_quote()
1076 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in sftp_quote()
1080 Curl_safefree(sshc->quote_path1); in sftp_quote()
1103 Curl_safefree(sshc->quote_path1); in sftp_quote()
1104 Curl_safefree(sshc->quote_path2); in sftp_quote()
1110 struct ssh_conn *sshc, in sftp_upload_init() argument
1126 int rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path, in sftp_upload_init()
1157 sshc->sftp_handle = in sftp_upload_init()
1158 libssh2_sftp_open_ex(sshc->sftp_session, sshp->path, in sftp_upload_init()
1163 if(!sshc->sftp_handle) { in sftp_upload_init()
1165 int rc = libssh2_session_last_errno(sshc->ssh_session); in sftp_upload_init()
1175 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in sftp_upload_init()
1179 if(sshc->secondCreateDirs) { in sftp_upload_init()
1181 sshc->actualcode = sftperr != LIBSSH2_FX_OK ? in sftp_upload_init()
1193 sshc->secondCreateDirs = 1; in sftp_upload_init()
1198 sshc->actualcode = sftperr != LIBSSH2_FX_OK ? in sftp_upload_init()
1200 if(!sshc->actualcode) { in sftp_upload_init()
1204 sshc->actualcode = CURLE_SSH; in sftp_upload_init()
1211 return sshc->actualcode; in sftp_upload_init()
1265 SFTP_SEEK(sshc->sftp_handle, data->state.resume_from); in sftp_upload_init()
1279 sshc->orig_waitfor = data->req.keepon; in sftp_upload_init()
1297 struct ssh_conn *sshc) in sftp_pkey_init() argument
1303 sshc->authed = FALSE; in sftp_pkey_init()
1306 (strstr(sshc->authlist, "publickey") != NULL)) { in sftp_pkey_init()
1309 sshc->rsa_pub = sshc->rsa = NULL; in sftp_pkey_init()
1312 sshc->rsa = strdup(data->set.str[STRING_SSH_PRIVATE_KEY]); in sftp_pkey_init()
1322 sshc->rsa = aprintf("%s/.ssh/id_rsa", home); in sftp_pkey_init()
1323 if(!sshc->rsa) in sftp_pkey_init()
1325 else if(stat(sshc->rsa, &sbuf)) { in sftp_pkey_init()
1326 Curl_safefree(sshc->rsa); in sftp_pkey_init()
1327 sshc->rsa = aprintf("%s/.ssh/id_dsa", home); in sftp_pkey_init()
1328 if(!sshc->rsa) in sftp_pkey_init()
1330 else if(stat(sshc->rsa, &sbuf)) { in sftp_pkey_init()
1331 Curl_safefree(sshc->rsa); in sftp_pkey_init()
1336 if(!out_of_memory && !sshc->rsa) { in sftp_pkey_init()
1338 sshc->rsa = strdup("id_rsa"); in sftp_pkey_init()
1339 if(sshc->rsa && stat(sshc->rsa, &sbuf)) { in sftp_pkey_init()
1340 Curl_safefree(sshc->rsa); in sftp_pkey_init()
1341 sshc->rsa = strdup("id_dsa"); in sftp_pkey_init()
1342 if(sshc->rsa && stat(sshc->rsa, &sbuf)) { in sftp_pkey_init()
1343 Curl_safefree(sshc->rsa); in sftp_pkey_init()
1346 sshc->rsa = strdup(""); in sftp_pkey_init()
1360 sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]); in sftp_pkey_init()
1361 if(!sshc->rsa_pub) in sftp_pkey_init()
1365 if(out_of_memory || !sshc->rsa) { in sftp_pkey_init()
1366 Curl_safefree(sshc->rsa); in sftp_pkey_init()
1367 Curl_safefree(sshc->rsa_pub); in sftp_pkey_init()
1369 sshc->actualcode = CURLE_OUT_OF_MEMORY; in sftp_pkey_init()
1373 sshc->passphrase = data->set.ssl.key_passwd; in sftp_pkey_init()
1374 if(!sshc->passphrase) in sftp_pkey_init()
1375 sshc->passphrase = ""; in sftp_pkey_init()
1377 if(sshc->rsa_pub) in sftp_pkey_init()
1378 infof(data, "Using SSH public key file '%s'", sshc->rsa_pub); in sftp_pkey_init()
1379 infof(data, "Using SSH private key file '%s'", sshc->rsa); in sftp_pkey_init()
1391 struct ssh_conn *sshc, in sftp_quote_stat() argument
1395 char *cmd = sshc->quote_item->data; in sftp_quote_stat()
1396 sshc->acceptfail = FALSE; in sftp_quote_stat()
1405 sshc->acceptfail = TRUE; in sftp_quote_stat()
1413 int rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2, in sftp_quote_stat()
1414 curlx_uztoui(strlen(sshc->quote_path2)), in sftp_quote_stat()
1421 if(rc && !sshc->acceptfail) { /* get those attributes */ in sftp_quote_stat()
1422 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in sftp_quote_stat()
1431 sshp->quote_attrs.gid = strtoul(sshc->quote_path1, NULL, 10); in sftp_quote_stat()
1433 if(sshp->quote_attrs.gid == 0 && !ISDIGIT(sshc->quote_path1[0]) && in sftp_quote_stat()
1434 !sshc->acceptfail) { in sftp_quote_stat()
1440 sshp->quote_attrs.permissions = strtoul(sshc->quote_path1, NULL, 8); in sftp_quote_stat()
1444 !ISDIGIT(sshc->quote_path1[0])) { in sftp_quote_stat()
1450 sshp->quote_attrs.uid = strtoul(sshc->quote_path1, NULL, 10); in sftp_quote_stat()
1452 if(sshp->quote_attrs.uid == 0 && !ISDIGIT(sshc->quote_path1[0]) && in sftp_quote_stat()
1453 !sshc->acceptfail) { in sftp_quote_stat()
1460 time_t date = Curl_getdate_capped(sshc->quote_path1); in sftp_quote_stat()
1488 Curl_safefree(sshc->quote_path1); in sftp_quote_stat()
1489 Curl_safefree(sshc->quote_path2); in sftp_quote_stat()
1495 struct ssh_conn *sshc, in sftp_download_stat() argument
1500 int rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path, in sftp_download_stat()
1566 SFTP_SEEK(sshc->sftp_handle, from); in sftp_download_stat()
1599 SFTP_SEEK(sshc->sftp_handle, data->state.resume_from); in sftp_download_stat()
1625 struct ssh_conn *sshc, in sftp_readdir() argument
1630 int rc = libssh2_sftp_readdir_ex(sshc->sftp_handle, in sftp_readdir()
1675 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in sftp_readdir()
1677 sshc->actualcode = result ? result : CURLE_SSH; in sftp_readdir()
1680 libssh2_session_last_errno(sshc->ssh_session)); in sftp_readdir()
1697 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_statemachine() local
1703 switch(sshc->state) { in ssh_statemachine()
1705 sshc->secondCreateDirs = 0; in ssh_statemachine()
1706 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
1707 sshc->actualcode = CURLE_OK; in ssh_statemachine()
1711 libssh2_session_set_blocking(sshc->ssh_session, 0); in ssh_statemachine()
1716 sshc->actualcode = result; in ssh_statemachine()
1724 rc = session_startup(sshc->ssh_session, conn->sock[FIRSTSOCKET]); in ssh_statemachine()
1730 (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); in ssh_statemachine()
1734 sshc->actualcode = CURLE_FAILED_INIT; in ssh_statemachine()
1764 sshc->authlist = libssh2_userauth_list(sshc->ssh_session, in ssh_statemachine()
1768 if(!sshc->authlist) { in ssh_statemachine()
1769 if(libssh2_userauth_authenticated(sshc->ssh_session)) { in ssh_statemachine()
1770 sshc->authed = TRUE; in ssh_statemachine()
1775 rc = libssh2_session_last_errno(sshc->ssh_session); in ssh_statemachine()
1780 sshc->actualcode = libssh2_session_error_to_CURLE(rc); in ssh_statemachine()
1785 sshc->authlist); in ssh_statemachine()
1791 result = sftp_pkey_init(data, sshc); in ssh_statemachine()
1797 rc = libssh2_userauth_publickey_fromfile_ex(sshc->ssh_session, in ssh_statemachine()
1801 sshc->rsa_pub, in ssh_statemachine()
1802 sshc->rsa, sshc->passphrase); in ssh_statemachine()
1807 Curl_safefree(sshc->rsa_pub); in ssh_statemachine()
1808 Curl_safefree(sshc->rsa); in ssh_statemachine()
1811 sshc->authed = TRUE; in ssh_statemachine()
1824 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
1835 (strstr(sshc->authlist, "password") != NULL)) { in ssh_statemachine()
1845 rc = libssh2_userauth_password_ex(sshc->ssh_session, conn->user, in ssh_statemachine()
1854 sshc->authed = TRUE; in ssh_statemachine()
1866 (strstr(sshc->authlist, "hostbased") != NULL)) { in ssh_statemachine()
1881 && (strstr(sshc->authlist, "publickey") != NULL)) { in ssh_statemachine()
1886 if(!sshc->ssh_agent) { in ssh_statemachine()
1887 sshc->ssh_agent = libssh2_agent_init(sshc->ssh_session); in ssh_statemachine()
1888 if(!sshc->ssh_agent) { in ssh_statemachine()
1896 rc = libssh2_agent_connect(sshc->ssh_agent); in ssh_statemachine()
1915 rc = libssh2_agent_list_identities(sshc->ssh_agent); in ssh_statemachine()
1926 sshc->sshagent_prev_identity = NULL; in ssh_statemachine()
1936 rc = libssh2_agent_get_identity(sshc->ssh_agent, in ssh_statemachine()
1937 &sshc->sshagent_identity, in ssh_statemachine()
1938 sshc->sshagent_prev_identity); in ssh_statemachine()
1943 rc = libssh2_agent_userauth(sshc->ssh_agent, conn->user, in ssh_statemachine()
1944 sshc->sshagent_identity); in ssh_statemachine()
1949 sshc->sshagent_prev_identity = sshc->sshagent_identity; in ssh_statemachine()
1961 sshc->authed = TRUE; in ssh_statemachine()
1974 && (strstr(sshc->authlist, "keyboard-interactive") != NULL)) { in ssh_statemachine()
1984 rc = libssh2_userauth_keyboard_interactive_ex(sshc->ssh_session, in ssh_statemachine()
1993 sshc->authed = TRUE; in ssh_statemachine()
2000 if(!sshc->authed) { in ssh_statemachine()
2003 sshc->actualcode = CURLE_LOGIN_DENIED; in ssh_statemachine()
2029 sshc->sftp_session = libssh2_sftp_init(sshc->ssh_session); in ssh_statemachine()
2030 if(!sshc->sftp_session) { in ssh_statemachine()
2032 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemachine()
2038 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2042 sshc->actualcode = CURLE_FAILED_INIT; in ssh_statemachine()
2052 rc = sftp_libssh2_realpath(sshc->sftp_session, ".", in ssh_statemachine()
2060 sshc->homedir = strdup(sshp->readdir_filename); in ssh_statemachine()
2061 if(!sshc->homedir) { in ssh_statemachine()
2063 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemachine()
2066 data->state.most_recent_ftp_entrypath = sshc->homedir; in ssh_statemachine()
2070 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2077 sshc->actualcode = result; in ssh_statemachine()
2094 result = Curl_getworkingpath(data, sshc->homedir, &sshp->path); in ssh_statemachine()
2096 sshc->actualcode = result; in ssh_statemachine()
2103 sshc->quote_item = data->set.quote; in ssh_statemachine()
2114 sshc->quote_item = data->set.postquote; in ssh_statemachine()
2124 result = sftp_quote(data, sshc, sshp); in ssh_statemachine()
2127 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2128 sshc->actualcode = result; in ssh_statemachine()
2133 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2134 Curl_safefree(sshc->quote_path2); in ssh_statemachine()
2136 sshc->quote_item = sshc->quote_item->next; in ssh_statemachine()
2138 if(sshc->quote_item) { in ssh_statemachine()
2142 if(sshc->nextstate != SSH_NO_STATE) { in ssh_statemachine()
2143 state(data, sshc->nextstate); in ssh_statemachine()
2144 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2153 result = sftp_quote_stat(data, sshc, sshp, block); in ssh_statemachine()
2156 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2157 sshc->actualcode = result; in ssh_statemachine()
2162 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2, in ssh_statemachine()
2163 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemachine()
2169 if(rc && !sshc->acceptfail) { in ssh_statemachine()
2170 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2171 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2172 Curl_safefree(sshc->quote_path2); in ssh_statemachine()
2176 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2177 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemachine()
2184 rc = libssh2_sftp_symlink_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemachine()
2185 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemachine()
2186 sshc->quote_path2, in ssh_statemachine()
2187 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemachine()
2192 if(rc && !sshc->acceptfail) { in ssh_statemachine()
2193 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2194 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2195 Curl_safefree(sshc->quote_path2); in ssh_statemachine()
2199 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2200 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemachine()
2207 rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemachine()
2208 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemachine()
2213 if(rc && !sshc->acceptfail) { in ssh_statemachine()
2214 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2215 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2219 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2220 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemachine()
2227 rc = libssh2_sftp_rename_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemachine()
2228 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemachine()
2229 sshc->quote_path2, in ssh_statemachine()
2230 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemachine()
2238 if(rc && !sshc->acceptfail) { in ssh_statemachine()
2239 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2240 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2241 Curl_safefree(sshc->quote_path2); in ssh_statemachine()
2245 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2246 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemachine()
2253 rc = libssh2_sftp_rmdir_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemachine()
2254 curlx_uztoui(strlen(sshc->quote_path1))); in ssh_statemachine()
2258 if(rc && !sshc->acceptfail) { in ssh_statemachine()
2259 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2260 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2264 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2265 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemachine()
2272 rc = libssh2_sftp_unlink_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemachine()
2273 curlx_uztoui(strlen(sshc->quote_path1))); in ssh_statemachine()
2277 if(rc && !sshc->acceptfail) { in ssh_statemachine()
2278 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2279 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2282 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2283 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemachine()
2293 rc = libssh2_sftp_statvfs(sshc->sftp_session, sshc->quote_path1, in ssh_statemachine()
2294 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemachine()
2300 if(rc && !sshc->acceptfail) { in ssh_statemachine()
2301 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2302 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2306 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2307 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemachine()
2337 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2345 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2346 sshc->actualcode = result; in ssh_statemachine()
2368 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path, in ssh_statemachine()
2394 result = sftp_upload_init(data, sshc, sshp, block); in ssh_statemachine()
2397 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2398 sshc->actualcode = result; in ssh_statemachine()
2404 sshc->slash_pos = sshp->path + 1; /* ignore the leading '/' */ in ssh_statemachine()
2413 sshc->slash_pos = strchr(sshc->slash_pos, '/'); in ssh_statemachine()
2414 if(sshc->slash_pos) { in ssh_statemachine()
2415 *sshc->slash_pos = 0; in ssh_statemachine()
2426 rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshp->path, in ssh_statemachine()
2432 *sshc->slash_pos = '/'; in ssh_statemachine()
2433 ++sshc->slash_pos; in ssh_statemachine()
2440 unsigned long sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2446 sshc->actualcode = result ? result : CURLE_SSH; in ssh_statemachine()
2465 sshc->sftp_handle = in ssh_statemachine()
2466 libssh2_sftp_open_ex(sshc->sftp_session, sshp->path, in ssh_statemachine()
2469 if(!sshc->sftp_handle) { in ssh_statemachine()
2471 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemachine()
2476 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2481 sshc->actualcode = result ? result : CURLE_SSH; in ssh_statemachine()
2489 result = sftp_readdir(data, sshc, sshp, block); in ssh_statemachine()
2491 sshc->actualcode = result; in ssh_statemachine()
2498 libssh2_sftp_symlink_ex(sshc->sftp_session, in ssh_statemachine()
2514 sshc->actualcode = result; in ssh_statemachine()
2539 if(libssh2_sftp_closedir(sshc->sftp_handle) == in ssh_statemachine()
2544 sshc->sftp_handle = NULL; in ssh_statemachine()
2555 sshc->sftp_handle = in ssh_statemachine()
2556 libssh2_sftp_open_ex(sshc->sftp_session, sshp->path, in ssh_statemachine()
2560 if(!sshc->sftp_handle) { in ssh_statemachine()
2562 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemachine()
2567 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemachine()
2572 sshc->actualcode = result ? result : CURLE_SSH; in ssh_statemachine()
2579 result = sftp_download_stat(data, sshc, sshp, block); in ssh_statemachine()
2582 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2583 sshc->actualcode = result; in ssh_statemachine()
2588 if(sshc->sftp_handle) { in ssh_statemachine()
2589 rc = libssh2_sftp_close(sshc->sftp_handle); in ssh_statemachine()
2595 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2599 sshc->sftp_handle = NULL; in ssh_statemachine()
2609 if(sshc->nextstate != SSH_NO_STATE && in ssh_statemachine()
2610 sshc->nextstate != SSH_SFTP_CLOSE) { in ssh_statemachine()
2611 state(data, sshc->nextstate); in ssh_statemachine()
2612 sshc->nextstate = SSH_SFTP_CLOSE; in ssh_statemachine()
2616 result = sshc->actualcode; in ssh_statemachine()
2625 if(sshc->sftp_handle) { in ssh_statemachine()
2626 rc = libssh2_sftp_close(sshc->sftp_handle); in ssh_statemachine()
2632 (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, in ssh_statemachine()
2636 sshc->sftp_handle = NULL; in ssh_statemachine()
2638 if(sshc->sftp_session) { in ssh_statemachine()
2639 rc = libssh2_sftp_shutdown(sshc->sftp_session); in ssh_statemachine()
2646 sshc->sftp_session = NULL; in ssh_statemachine()
2649 Curl_safefree(sshc->homedir); in ssh_statemachine()
2656 result = Curl_getworkingpath(data, sshc->homedir, &sshp->path); in ssh_statemachine()
2658 sshc->actualcode = result; in ssh_statemachine()
2666 sshc->actualcode = CURLE_UPLOAD_FAILED; in ssh_statemachine()
2684 sshc->ssh_channel = in ssh_statemachine()
2685 SCP_SEND(sshc->ssh_session, sshp->path, data->set.new_file_perms, in ssh_statemachine()
2687 if(!sshc->ssh_channel) { in ssh_statemachine()
2691 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemachine()
2697 ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2701 sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err); in ssh_statemachine()
2703 if(sshc->actualcode == CURLE_SSH || in ssh_statemachine()
2704 sshc->actualcode == CURLE_REMOTE_FILE_NOT_FOUND) in ssh_statemachine()
2705 sshc->actualcode = CURLE_UPLOAD_FAILED; in ssh_statemachine()
2719 sshc->actualcode = result; in ssh_statemachine()
2724 sshc->orig_waitfor = data->req.keepon; in ssh_statemachine()
2752 sshc->ssh_channel = libssh2_scp_recv(sshc->ssh_session, in ssh_statemachine()
2757 sshc->ssh_channel = libssh2_scp_recv2(sshc->ssh_session, in ssh_statemachine()
2761 if(!sshc->ssh_channel) { in ssh_statemachine()
2765 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemachine()
2772 ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2776 sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err); in ssh_statemachine()
2795 sshc->actualcode = result; in ssh_statemachine()
2810 if(sshc->ssh_channel) { in ssh_statemachine()
2811 rc = libssh2_channel_send_eof(sshc->ssh_channel); in ssh_statemachine()
2817 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2827 if(sshc->ssh_channel) { in ssh_statemachine()
2828 rc = libssh2_channel_wait_eof(sshc->ssh_channel); in ssh_statemachine()
2834 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2843 if(sshc->ssh_channel) { in ssh_statemachine()
2844 rc = libssh2_channel_wait_closed(sshc->ssh_channel); in ssh_statemachine()
2850 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2859 if(sshc->ssh_channel) { in ssh_statemachine()
2860 rc = libssh2_channel_free(sshc->ssh_channel); in ssh_statemachine()
2866 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2871 sshc->ssh_channel = NULL; in ssh_statemachine()
2878 result = sshc->actualcode; in ssh_statemachine()
2885 if(sshc->ssh_channel) { in ssh_statemachine()
2886 rc = libssh2_channel_free(sshc->ssh_channel); in ssh_statemachine()
2892 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2897 sshc->ssh_channel = NULL; in ssh_statemachine()
2900 if(sshc->ssh_session) { in ssh_statemachine()
2901 rc = libssh2_session_disconnect(sshc->ssh_session, "Shutdown"); in ssh_statemachine()
2907 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2914 Curl_safefree(sshc->homedir); in ssh_statemachine()
2922 if(sshc->kh) { in ssh_statemachine()
2923 libssh2_knownhost_free(sshc->kh); in ssh_statemachine()
2924 sshc->kh = NULL; in ssh_statemachine()
2929 if(sshc->ssh_agent) { in ssh_statemachine()
2930 rc = libssh2_agent_disconnect(sshc->ssh_agent); in ssh_statemachine()
2936 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2941 libssh2_agent_free(sshc->ssh_agent); in ssh_statemachine()
2942 sshc->ssh_agent = NULL; in ssh_statemachine()
2946 sshc->sshagent_identity = NULL; in ssh_statemachine()
2947 sshc->sshagent_prev_identity = NULL; in ssh_statemachine()
2951 if(sshc->ssh_session) { in ssh_statemachine()
2952 rc = libssh2_session_free(sshc->ssh_session); in ssh_statemachine()
2958 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemachine()
2962 sshc->ssh_session = NULL; in ssh_statemachine()
2967 DEBUGASSERT(sshc->ssh_session == NULL); in ssh_statemachine()
2968 DEBUGASSERT(sshc->ssh_channel == NULL); in ssh_statemachine()
2969 DEBUGASSERT(sshc->sftp_session == NULL); in ssh_statemachine()
2970 DEBUGASSERT(sshc->sftp_handle == NULL); in ssh_statemachine()
2972 DEBUGASSERT(sshc->kh == NULL); in ssh_statemachine()
2975 DEBUGASSERT(sshc->ssh_agent == NULL); in ssh_statemachine()
2978 Curl_safefree(sshc->rsa_pub); in ssh_statemachine()
2979 Curl_safefree(sshc->rsa); in ssh_statemachine()
2980 Curl_safefree(sshc->quote_path1); in ssh_statemachine()
2981 Curl_safefree(sshc->quote_path2); in ssh_statemachine()
2982 Curl_safefree(sshc->homedir); in ssh_statemachine()
2985 result = sshc->actualcode; in ssh_statemachine()
2987 memset(sshc, 0, sizeof(struct ssh_conn)); in ssh_statemachine()
2990 sshc->state = SSH_SESSION_FREE; /* current */ in ssh_statemachine()
2991 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
2998 sshc->nextstate = SSH_NO_STATE; in ssh_statemachine()
3003 } while(!rc && (sshc->state != SSH_STOP)); in ssh_statemachine()
3044 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_block2waitfor() local
3047 dir = libssh2_session_block_directions(sshc->ssh_session); in ssh_block2waitfor()
3057 conn->waitfor = sshc->orig_waitfor; in ssh_block2waitfor()
3064 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_multi_statemach() local
3070 *done = (sshc->state == SSH_STOP); in ssh_multi_statemach()
3083 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_block_statemach() local
3087 while((sshc->state != SSH_STOP) && !result) { in ssh_block_statemach()
3118 int dir = libssh2_session_block_directions(sshc->ssh_session); in ssh_block_statemach()
3163 struct ssh_conn *ssh = &conn->proto.sshc; in ssh_tls_recv()
3188 struct ssh_conn *ssh = &conn->proto.sshc; in ssh_tls_send()
3215 struct ssh_conn *sshc; in ssh_connect() local
3230 sshc = &conn->proto.sshc; in ssh_connect()
3244 sshc->ssh_session = libssh2_session_init_ex(my_libssh2_malloc, in ssh_connect()
3248 if(!sshc->ssh_session) { in ssh_connect()
3256 libssh2_session_set_read_timeout(sshc->ssh_session, in ssh_connect()
3277 libssh2_session_callback_set2(sshc->ssh_session, in ssh_connect()
3280 libssh2_session_callback_set2(sshc->ssh_session, in ssh_connect()
3304 libssh2_session_callback_set(sshc->ssh_session, in ssh_connect()
3306 libssh2_session_callback_set(sshc->ssh_session, in ssh_connect()
3312 sshc->tls_recv = conn->recv[FIRSTSOCKET]; in ssh_connect()
3313 sshc->tls_send = conn->send[FIRSTSOCKET]; in ssh_connect()
3328 if(libssh2_session_flag(sshc->ssh_session, LIBSSH2_FLAG_COMPRESS, 1) < 0) in ssh_connect()
3336 sshc->kh = libssh2_knownhost_init(sshc->ssh_session); in ssh_connect()
3337 if(!sshc->kh) { in ssh_connect()
3338 libssh2_session_free(sshc->ssh_session); in ssh_connect()
3339 sshc->ssh_session = NULL; in ssh_connect()
3344 rc = libssh2_knownhost_readfile(sshc->kh, in ssh_connect()
3354 libssh2_trace(sshc->ssh_session, ~0); in ssh_connect()
3423 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_do() local
3429 sshc->actualcode = CURLE_OK; /* reset error code */ in ssh_do()
3430 sshc->secondCreateDirs = 0; /* reset the create dir attempt state in ssh_do()
3454 struct ssh_conn *sshc = &conn->proto.sshc; in scp_disconnect() local
3457 if(sshc->ssh_session) { in scp_disconnect()
3508 struct ssh_conn *sshc = &conn->proto.sshc; in scp_send() local
3513 nwrite = (ssize_t) libssh2_channel_write(sshc->ssh_channel, mem, len); in scp_send()
3534 struct ssh_conn *sshc = &conn->proto.sshc; in scp_recv() local
3538 nread = (ssize_t) libssh2_channel_read(sshc->ssh_channel, mem, len); in scp_recv()
3607 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_disconnect() local
3612 if(sshc->ssh_session) { in sftp_disconnect()
3628 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_done() local
3635 sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT; in sftp_done()
3647 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_send() local
3651 nwrite = libssh2_sftp_write(sshc->sftp_handle, mem, len); in sftp_send()
3676 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_recv() local
3679 nread = libssh2_sftp_read(sshc->sftp_handle, mem, len); in sftp_recv()
3792 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_attach() local
3793 if(sshc->ssh_session) { in ssh_attach()
3795 void **abstract = libssh2_session_abstract(sshc->ssh_session); in ssh_attach()