• Home
  • Raw
  • Download

Lines Matching refs:sshc

308   struct ssh_conn *sshc = &conn->proto.sshc;  in state()  local
377 if(sshc->state != nowstate) { in state()
379 (void *)sshc, names[sshc->state], names[nowstate]); in state()
383 sshc->state = nowstate; in state()
478 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_knownhost() local
480 const char *remotekey = libssh2_session_hostkey(sshc->ssh_session, in ssh_knownhost()
535 keycheck = libssh2_knownhost_checkp(sshc->kh, in ssh_knownhost()
545 keycheck = libssh2_knownhost_check(sshc->kh, in ssh_knownhost()
598 result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_knownhost()
603 libssh2_knownhost_del(sshc->kh, host); in ssh_knownhost()
612 int addrc = libssh2_knownhost_add(sshc->kh, in ssh_knownhost()
626 libssh2_knownhost_writefile(sshc->kh, in ssh_knownhost()
647 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_check_fingerprint() local
665 fingerprint = libssh2_hostkey_hash(sshc->ssh_session, in ssh_check_fingerprint()
672 hostkey = libssh2_session_hostkey(sshc->ssh_session, &len, NULL); in ssh_check_fingerprint()
684 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
685 return sshc->actualcode; in ssh_check_fingerprint()
693 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
694 return sshc->actualcode; in ssh_check_fingerprint()
700 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
701 return sshc->actualcode; in ssh_check_fingerprint()
727 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
728 return sshc->actualcode; in ssh_check_fingerprint()
740 fingerprint = libssh2_hostkey_hash(sshc->ssh_session, in ssh_check_fingerprint()
767 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
768 return sshc->actualcode; in ssh_check_fingerprint()
779 const char *remotekey = libssh2_session_hostkey(sshc->ssh_session, in ssh_check_fingerprint()
789 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
790 return sshc->actualcode; in ssh_check_fingerprint()
795 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
796 return sshc->actualcode; in ssh_check_fingerprint()
845 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_force_knownhost_key_type() local
852 if(sshc->kh && !data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) { in ssh_force_knownhost_key_type()
854 while(!libssh2_knownhost_get(sshc->kh, &store, store)) { in ssh_force_knownhost_key_type()
939 rc = libssh2_session_method_pref(sshc->ssh_session, in ssh_force_knownhost_key_type()
944 libssh2_session_last_error(sshc->ssh_session, &errmsg, &errlen, 0); in ssh_force_knownhost_key_type()
972 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_statemach_act() local
982 switch(sshc->state) { in ssh_statemach_act()
984 sshc->secondCreateDirs = 0; in ssh_statemach_act()
985 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
986 sshc->actualcode = CURLE_OK; in ssh_statemach_act()
990 libssh2_session_set_blocking(sshc->ssh_session, 0); in ssh_statemach_act()
995 sshc->actualcode = result; in ssh_statemach_act()
1003 rc = session_startup(sshc->ssh_session, sock); in ssh_statemach_act()
1009 (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); in ssh_statemach_act()
1013 sshc->actualcode = CURLE_FAILED_INIT; in ssh_statemach_act()
1043 sshc->authlist = libssh2_userauth_list(sshc->ssh_session, in ssh_statemach_act()
1047 if(!sshc->authlist) { in ssh_statemach_act()
1048 if(libssh2_userauth_authenticated(sshc->ssh_session)) { in ssh_statemach_act()
1049 sshc->authed = TRUE; in ssh_statemach_act()
1054 ssherr = libssh2_session_last_errno(sshc->ssh_session); in ssh_statemach_act()
1059 sshc->actualcode = libssh2_session_error_to_CURLE(ssherr); in ssh_statemach_act()
1064 sshc->authlist); in ssh_statemach_act()
1074 sshc->authed = FALSE; in ssh_statemach_act()
1077 (strstr(sshc->authlist, "publickey") != NULL)) { in ssh_statemach_act()
1080 sshc->rsa_pub = sshc->rsa = NULL; in ssh_statemach_act()
1083 sshc->rsa = strdup(data->set.str[STRING_SSH_PRIVATE_KEY]); in ssh_statemach_act()
1092 sshc->rsa = aprintf("%s/.ssh/id_rsa", home); in ssh_statemach_act()
1093 if(!sshc->rsa) in ssh_statemach_act()
1095 else if(access(sshc->rsa, R_OK) != 0) { in ssh_statemach_act()
1096 Curl_safefree(sshc->rsa); in ssh_statemach_act()
1097 sshc->rsa = aprintf("%s/.ssh/id_dsa", home); in ssh_statemach_act()
1098 if(!sshc->rsa) in ssh_statemach_act()
1100 else if(access(sshc->rsa, R_OK) != 0) { in ssh_statemach_act()
1101 Curl_safefree(sshc->rsa); in ssh_statemach_act()
1106 if(!out_of_memory && !sshc->rsa) { in ssh_statemach_act()
1108 sshc->rsa = strdup("id_rsa"); in ssh_statemach_act()
1109 if(sshc->rsa && access(sshc->rsa, R_OK) != 0) { in ssh_statemach_act()
1110 Curl_safefree(sshc->rsa); in ssh_statemach_act()
1111 sshc->rsa = strdup("id_dsa"); in ssh_statemach_act()
1112 if(sshc->rsa && access(sshc->rsa, R_OK) != 0) { in ssh_statemach_act()
1113 Curl_safefree(sshc->rsa); in ssh_statemach_act()
1116 sshc->rsa = strdup(""); in ssh_statemach_act()
1130 sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]); in ssh_statemach_act()
1131 if(!sshc->rsa_pub) in ssh_statemach_act()
1135 if(out_of_memory || !sshc->rsa) { in ssh_statemach_act()
1136 Curl_safefree(sshc->rsa); in ssh_statemach_act()
1137 Curl_safefree(sshc->rsa_pub); in ssh_statemach_act()
1139 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
1143 sshc->passphrase = data->set.ssl.key_passwd; in ssh_statemach_act()
1144 if(!sshc->passphrase) in ssh_statemach_act()
1145 sshc->passphrase = ""; in ssh_statemach_act()
1147 if(sshc->rsa_pub) in ssh_statemach_act()
1148 infof(data, "Using SSH public key file '%s'", sshc->rsa_pub); in ssh_statemach_act()
1149 infof(data, "Using SSH private key file '%s'", sshc->rsa); in ssh_statemach_act()
1161 rc = libssh2_userauth_publickey_fromfile_ex(sshc->ssh_session, in ssh_statemach_act()
1165 sshc->rsa_pub, in ssh_statemach_act()
1166 sshc->rsa, sshc->passphrase); in ssh_statemach_act()
1171 Curl_safefree(sshc->rsa_pub); in ssh_statemach_act()
1172 Curl_safefree(sshc->rsa); in ssh_statemach_act()
1175 sshc->authed = TRUE; in ssh_statemach_act()
1188 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
1199 (strstr(sshc->authlist, "password") != NULL)) { in ssh_statemach_act()
1209 rc = libssh2_userauth_password_ex(sshc->ssh_session, conn->user, in ssh_statemach_act()
1218 sshc->authed = TRUE; in ssh_statemach_act()
1230 (strstr(sshc->authlist, "hostbased") != NULL)) { in ssh_statemach_act()
1245 && (strstr(sshc->authlist, "publickey") != NULL)) { in ssh_statemach_act()
1250 if(!sshc->ssh_agent) { in ssh_statemach_act()
1251 sshc->ssh_agent = libssh2_agent_init(sshc->ssh_session); in ssh_statemach_act()
1252 if(!sshc->ssh_agent) { in ssh_statemach_act()
1260 rc = libssh2_agent_connect(sshc->ssh_agent); in ssh_statemach_act()
1279 rc = libssh2_agent_list_identities(sshc->ssh_agent); in ssh_statemach_act()
1290 sshc->sshagent_prev_identity = NULL; in ssh_statemach_act()
1300 rc = libssh2_agent_get_identity(sshc->ssh_agent, in ssh_statemach_act()
1301 &sshc->sshagent_identity, in ssh_statemach_act()
1302 sshc->sshagent_prev_identity); in ssh_statemach_act()
1307 rc = libssh2_agent_userauth(sshc->ssh_agent, conn->user, in ssh_statemach_act()
1308 sshc->sshagent_identity); in ssh_statemach_act()
1313 sshc->sshagent_prev_identity = sshc->sshagent_identity; in ssh_statemach_act()
1325 sshc->authed = TRUE; in ssh_statemach_act()
1338 && (strstr(sshc->authlist, "keyboard-interactive") != NULL)) { in ssh_statemach_act()
1348 rc = libssh2_userauth_keyboard_interactive_ex(sshc->ssh_session, in ssh_statemach_act()
1357 sshc->authed = TRUE; in ssh_statemach_act()
1364 if(!sshc->authed) { in ssh_statemach_act()
1367 sshc->actualcode = CURLE_LOGIN_DENIED; in ssh_statemach_act()
1393 sshc->sftp_session = libssh2_sftp_init(sshc->ssh_session); in ssh_statemach_act()
1394 if(!sshc->sftp_session) { in ssh_statemach_act()
1396 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
1402 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
1406 sshc->actualcode = CURLE_FAILED_INIT; in ssh_statemach_act()
1419 rc = sftp_libssh2_realpath(sshc->sftp_session, ".", in ssh_statemach_act()
1427 sshc->homedir = strdup(tempHome); in ssh_statemach_act()
1428 if(!sshc->homedir) { in ssh_statemach_act()
1430 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
1433 data->state.most_recent_ftp_entrypath = sshc->homedir; in ssh_statemach_act()
1437 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1444 sshc->actualcode = result; in ssh_statemach_act()
1461 result = Curl_getworkingpath(data, sshc->homedir, &sshp->path); in ssh_statemach_act()
1463 sshc->actualcode = result; in ssh_statemach_act()
1470 sshc->quote_item = data->set.quote; in ssh_statemach_act()
1481 sshc->quote_item = data->set.postquote; in ssh_statemach_act()
1500 char *cmd = sshc->quote_item->data; in ssh_statemach_act()
1501 sshc->acceptfail = FALSE; in ssh_statemach_act()
1510 sshc->acceptfail = TRUE; in ssh_statemach_act()
1520 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1533 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1534 sshc->actualcode = result; in ssh_statemach_act()
1550 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1551 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1559 result = Curl_get_pathname(&cp, &sshc->quote_path1, sshc->homedir); in ssh_statemach_act()
1566 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1567 sshc->actualcode = result; in ssh_statemach_act()
1586 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in ssh_statemach_act()
1592 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1594 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1595 sshc->actualcode = result; in ssh_statemach_act()
1607 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in ssh_statemach_act()
1614 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1616 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1617 sshc->actualcode = result; in ssh_statemach_act()
1632 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in ssh_statemach_act()
1638 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1640 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1641 sshc->actualcode = result; in ssh_statemach_act()
1664 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1665 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1667 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1668 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1675 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1676 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1678 sshc->quote_item = sshc->quote_item->next; in ssh_statemach_act()
1680 if(sshc->quote_item) { in ssh_statemach_act()
1684 if(sshc->nextstate != SSH_NO_STATE) { in ssh_statemach_act()
1685 state(data, sshc->nextstate); in ssh_statemach_act()
1686 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1696 char *cmd = sshc->quote_item->data; in ssh_statemach_act()
1697 sshc->acceptfail = FALSE; in ssh_statemach_act()
1706 sshc->acceptfail = TRUE; in ssh_statemach_act()
1714 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2, in ssh_statemach_act()
1715 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemach_act()
1721 if(rc && !sshc->acceptfail) { /* get those attributes */ in ssh_statemach_act()
1722 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1723 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1724 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1728 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1729 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1736 sshp->quote_attrs.gid = strtoul(sshc->quote_path1, NULL, 10); in ssh_statemach_act()
1738 if(sshp->quote_attrs.gid == 0 && !ISDIGIT(sshc->quote_path1[0]) && in ssh_statemach_act()
1739 !sshc->acceptfail) { in ssh_statemach_act()
1740 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1741 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1744 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1745 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1750 sshp->quote_attrs.permissions = strtoul(sshc->quote_path1, NULL, 8); in ssh_statemach_act()
1754 !ISDIGIT(sshc->quote_path1[0])) { in ssh_statemach_act()
1755 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1756 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1759 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1760 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1765 sshp->quote_attrs.uid = strtoul(sshc->quote_path1, NULL, 10); in ssh_statemach_act()
1767 if(sshp->quote_attrs.uid == 0 && !ISDIGIT(sshc->quote_path1[0]) && in ssh_statemach_act()
1768 !sshc->acceptfail) { in ssh_statemach_act()
1769 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1770 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1773 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1774 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1780 time_t date = Curl_getdate_capped(sshc->quote_path1); in ssh_statemach_act()
1795 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1796 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1798 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1799 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1816 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2, in ssh_statemach_act()
1817 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemach_act()
1823 if(rc && !sshc->acceptfail) { in ssh_statemach_act()
1824 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1825 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1826 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1830 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1831 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1838 rc = libssh2_sftp_symlink_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1839 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemach_act()
1840 sshc->quote_path2, in ssh_statemach_act()
1841 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemach_act()
1846 if(rc && !sshc->acceptfail) { in ssh_statemach_act()
1847 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1848 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1849 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1853 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1854 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1861 rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1862 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemach_act()
1867 if(rc && !sshc->acceptfail) { in ssh_statemach_act()
1868 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1869 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1873 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1874 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1881 rc = libssh2_sftp_rename_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1882 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemach_act()
1883 sshc->quote_path2, in ssh_statemach_act()
1884 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemach_act()
1892 if(rc && !sshc->acceptfail) { in ssh_statemach_act()
1893 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1894 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1895 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1899 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1900 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1907 rc = libssh2_sftp_rmdir_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1908 curlx_uztoui(strlen(sshc->quote_path1))); in ssh_statemach_act()
1912 if(rc && !sshc->acceptfail) { in ssh_statemach_act()
1913 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1914 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1918 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1919 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1926 rc = libssh2_sftp_unlink_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1927 curlx_uztoui(strlen(sshc->quote_path1))); in ssh_statemach_act()
1931 if(rc && !sshc->acceptfail) { in ssh_statemach_act()
1932 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1933 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1936 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1937 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1947 rc = libssh2_sftp_statvfs(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1948 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemach_act()
1954 if(rc && !sshc->acceptfail) { in ssh_statemach_act()
1955 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
1956 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1960 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1961 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1981 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1989 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1990 sshc->actualcode = result; in ssh_statemach_act()
2012 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path, in ssh_statemach_act()
2050 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path, in ssh_statemach_act()
2080 sshc->sftp_handle = in ssh_statemach_act()
2081 libssh2_sftp_open_ex(sshc->sftp_session, sshp->path, in ssh_statemach_act()
2086 if(!sshc->sftp_handle) { in ssh_statemach_act()
2087 rc = libssh2_session_last_errno(sshc->ssh_session); in ssh_statemach_act()
2095 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
2099 if(sshc->secondCreateDirs) { in ssh_statemach_act()
2101 sshc->actualcode = sftperr != LIBSSH2_FX_OK ? in ssh_statemach_act()
2114 sshc->secondCreateDirs = 1; in ssh_statemach_act()
2119 sshc->actualcode = sftperr != LIBSSH2_FX_OK ? in ssh_statemach_act()
2121 if(!sshc->actualcode) { in ssh_statemach_act()
2125 sshc->actualcode = CURLE_SSH; in ssh_statemach_act()
2184 SFTP_SEEK(sshc->sftp_handle, data->state.resume_from); in ssh_statemach_act()
2198 sshc->actualcode = result; in ssh_statemach_act()
2203 sshc->orig_waitfor = data->req.keepon; in ssh_statemach_act()
2222 sshc->slash_pos = sshp->path + 1; /* ignore the leading '/' */ in ssh_statemach_act()
2231 sshc->slash_pos = strchr(sshc->slash_pos, '/'); in ssh_statemach_act()
2232 if(sshc->slash_pos) { in ssh_statemach_act()
2233 *sshc->slash_pos = 0; in ssh_statemach_act()
2244 rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshp->path, in ssh_statemach_act()
2250 *sshc->slash_pos = '/'; in ssh_statemach_act()
2251 ++sshc->slash_pos; in ssh_statemach_act()
2258 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
2264 sshc->actualcode = result?result:CURLE_SSH; in ssh_statemach_act()
2283 sshc->sftp_handle = libssh2_sftp_open_ex(sshc->sftp_session, in ssh_statemach_act()
2288 if(!sshc->sftp_handle) { in ssh_statemach_act()
2289 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
2294 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
2299 sshc->actualcode = result?result:CURLE_SSH; in ssh_statemach_act()
2305 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
2312 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
2320 rc = libssh2_sftp_readdir_ex(sshc->sftp_handle, in ssh_statemach_act()
2372 sshc->actualcode = result; in ssh_statemach_act()
2384 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
2386 sshc->actualcode = result?result:CURLE_SSH; in ssh_statemach_act()
2389 libssh2_session_last_errno(sshc->ssh_session)); in ssh_statemach_act()
2399 libssh2_sftp_symlink_ex(sshc->sftp_session, in ssh_statemach_act()
2416 sshc->actualcode = result; in ssh_statemach_act()
2448 if(libssh2_sftp_closedir(sshc->sftp_handle) == in ssh_statemach_act()
2453 sshc->sftp_handle = NULL; in ssh_statemach_act()
2466 sshc->sftp_handle = in ssh_statemach_act()
2467 libssh2_sftp_open_ex(sshc->sftp_session, sshp->path, in ssh_statemach_act()
2471 if(!sshc->sftp_handle) { in ssh_statemach_act()
2472 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
2477 sftperr = libssh2_sftp_last_error(sshc->sftp_session); in ssh_statemach_act()
2482 sshc->actualcode = result?result:CURLE_SSH; in ssh_statemach_act()
2492 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path, in ssh_statemach_act()
2557 SFTP_SEEK(sshc->sftp_handle, from); in ssh_statemach_act()
2591 SFTP_SEEK(sshc->sftp_handle, data->state.resume_from); in ssh_statemach_act()
2617 sshc->actualcode = result; in ssh_statemach_act()
2625 if(sshc->sftp_handle) { in ssh_statemach_act()
2626 rc = libssh2_sftp_close(sshc->sftp_handle); in ssh_statemach_act()
2632 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2636 sshc->sftp_handle = NULL; in ssh_statemach_act()
2646 if(sshc->nextstate != SSH_NO_STATE && in ssh_statemach_act()
2647 sshc->nextstate != SSH_SFTP_CLOSE) { in ssh_statemach_act()
2648 state(data, sshc->nextstate); in ssh_statemach_act()
2649 sshc->nextstate = SSH_SFTP_CLOSE; in ssh_statemach_act()
2653 result = sshc->actualcode; in ssh_statemach_act()
2662 if(sshc->sftp_handle) { in ssh_statemach_act()
2663 rc = libssh2_sftp_close(sshc->sftp_handle); in ssh_statemach_act()
2669 (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, in ssh_statemach_act()
2673 sshc->sftp_handle = NULL; in ssh_statemach_act()
2675 if(sshc->sftp_session) { in ssh_statemach_act()
2676 rc = libssh2_sftp_shutdown(sshc->sftp_session); in ssh_statemach_act()
2683 sshc->sftp_session = NULL; in ssh_statemach_act()
2686 Curl_safefree(sshc->homedir); in ssh_statemach_act()
2693 result = Curl_getworkingpath(data, sshc->homedir, &sshp->path); in ssh_statemach_act()
2695 sshc->actualcode = result; in ssh_statemach_act()
2703 sshc->actualcode = CURLE_UPLOAD_FAILED; in ssh_statemach_act()
2721 sshc->ssh_channel = in ssh_statemach_act()
2722 SCP_SEND(sshc->ssh_session, sshp->path, data->set.new_file_perms, in ssh_statemach_act()
2724 if(!sshc->ssh_channel) { in ssh_statemach_act()
2728 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
2734 ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2738 sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err); in ssh_statemach_act()
2740 if(sshc->actualcode == CURLE_SSH || in ssh_statemach_act()
2741 sshc->actualcode == CURLE_REMOTE_FILE_NOT_FOUND) in ssh_statemach_act()
2742 sshc->actualcode = CURLE_UPLOAD_FAILED; in ssh_statemach_act()
2756 sshc->actualcode = result; in ssh_statemach_act()
2761 sshc->orig_waitfor = data->req.keepon; in ssh_statemach_act()
2789 sshc->ssh_channel = libssh2_scp_recv(sshc->ssh_session, in ssh_statemach_act()
2794 sshc->ssh_channel = libssh2_scp_recv2(sshc->ssh_session, in ssh_statemach_act()
2798 if(!sshc->ssh_channel) { in ssh_statemach_act()
2802 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
2809 ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2813 sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err); in ssh_statemach_act()
2832 sshc->actualcode = result; in ssh_statemach_act()
2847 if(sshc->ssh_channel) { in ssh_statemach_act()
2848 rc = libssh2_channel_send_eof(sshc->ssh_channel); in ssh_statemach_act()
2854 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2864 if(sshc->ssh_channel) { in ssh_statemach_act()
2865 rc = libssh2_channel_wait_eof(sshc->ssh_channel); in ssh_statemach_act()
2871 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2880 if(sshc->ssh_channel) { in ssh_statemach_act()
2881 rc = libssh2_channel_wait_closed(sshc->ssh_channel); in ssh_statemach_act()
2887 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2896 if(sshc->ssh_channel) { in ssh_statemach_act()
2897 rc = libssh2_channel_free(sshc->ssh_channel); in ssh_statemach_act()
2903 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2908 sshc->ssh_channel = NULL; in ssh_statemach_act()
2915 result = sshc->actualcode; in ssh_statemach_act()
2922 if(sshc->ssh_channel) { in ssh_statemach_act()
2923 rc = libssh2_channel_free(sshc->ssh_channel); in ssh_statemach_act()
2929 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2934 sshc->ssh_channel = NULL; in ssh_statemach_act()
2937 if(sshc->ssh_session) { in ssh_statemach_act()
2938 rc = libssh2_session_disconnect(sshc->ssh_session, "Shutdown"); in ssh_statemach_act()
2944 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2951 Curl_safefree(sshc->homedir); in ssh_statemach_act()
2959 if(sshc->kh) { in ssh_statemach_act()
2960 libssh2_knownhost_free(sshc->kh); in ssh_statemach_act()
2961 sshc->kh = NULL; in ssh_statemach_act()
2966 if(sshc->ssh_agent) { in ssh_statemach_act()
2967 rc = libssh2_agent_disconnect(sshc->ssh_agent); in ssh_statemach_act()
2973 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2978 libssh2_agent_free(sshc->ssh_agent); in ssh_statemach_act()
2979 sshc->ssh_agent = NULL; in ssh_statemach_act()
2983 sshc->sshagent_identity = NULL; in ssh_statemach_act()
2984 sshc->sshagent_prev_identity = NULL; in ssh_statemach_act()
2988 if(sshc->ssh_session) { in ssh_statemach_act()
2989 rc = libssh2_session_free(sshc->ssh_session); in ssh_statemach_act()
2995 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2999 sshc->ssh_session = NULL; in ssh_statemach_act()
3004 DEBUGASSERT(sshc->ssh_session == NULL); in ssh_statemach_act()
3005 DEBUGASSERT(sshc->ssh_channel == NULL); in ssh_statemach_act()
3006 DEBUGASSERT(sshc->sftp_session == NULL); in ssh_statemach_act()
3007 DEBUGASSERT(sshc->sftp_handle == NULL); in ssh_statemach_act()
3009 DEBUGASSERT(sshc->kh == NULL); in ssh_statemach_act()
3012 DEBUGASSERT(sshc->ssh_agent == NULL); in ssh_statemach_act()
3015 Curl_safefree(sshc->rsa_pub); in ssh_statemach_act()
3016 Curl_safefree(sshc->rsa); in ssh_statemach_act()
3017 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
3018 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
3019 Curl_safefree(sshc->homedir); in ssh_statemach_act()
3022 result = sshc->actualcode; in ssh_statemach_act()
3024 memset(sshc, 0, sizeof(struct ssh_conn)); in ssh_statemach_act()
3027 sshc->state = SSH_SESSION_FREE; /* current */ in ssh_statemach_act()
3028 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
3036 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
3041 } while(!rc && (sshc->state != SSH_STOP)); in ssh_statemach_act()
3082 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_block2waitfor() local
3085 dir = libssh2_session_block_directions(sshc->ssh_session); in ssh_block2waitfor()
3095 conn->waitfor = sshc->orig_waitfor; in ssh_block2waitfor()
3102 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_multi_statemach() local
3108 *done = (sshc->state == SSH_STOP) ? TRUE : FALSE; in ssh_multi_statemach()
3121 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_block_statemach() local
3125 while((sshc->state != SSH_STOP) && !result) { in ssh_block_statemach()
3156 int dir = libssh2_session_block_directions(sshc->ssh_session); in ssh_block_statemach()
3201 struct ssh_conn *ssh = &conn->proto.sshc; in ssh_tls_recv()
3225 struct ssh_conn *ssh = &conn->proto.sshc; in ssh_tls_send()
3251 struct ssh_conn *sshc; in ssh_connect() local
3266 sshc = &conn->proto.sshc; in ssh_connect()
3280 sshc->ssh_session = libssh2_session_init_ex(my_libssh2_malloc, in ssh_connect()
3284 if(!sshc->ssh_session) { in ssh_connect()
3293 libssh2_session_set_read_timeout(sshc->ssh_session, in ssh_connect()
3333 libssh2_session_callback_set(sshc->ssh_session, in ssh_connect()
3335 libssh2_session_callback_set(sshc->ssh_session, in ssh_connect()
3340 sshc->tls_recv = conn->recv[FIRSTSOCKET]; in ssh_connect()
3341 sshc->tls_send = conn->send[FIRSTSOCKET]; in ssh_connect()
3356 if(libssh2_session_flag(sshc->ssh_session, LIBSSH2_FLAG_COMPRESS, 1) < 0) in ssh_connect()
3364 sshc->kh = libssh2_knownhost_init(sshc->ssh_session); in ssh_connect()
3365 if(!sshc->kh) { in ssh_connect()
3366 libssh2_session_free(sshc->ssh_session); in ssh_connect()
3367 sshc->ssh_session = NULL; in ssh_connect()
3372 rc = libssh2_knownhost_readfile(sshc->kh, in ssh_connect()
3382 libssh2_trace(sshc->ssh_session, ~0); in ssh_connect()
3451 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_do() local
3457 sshc->actualcode = CURLE_OK; /* reset error code */ in ssh_do()
3458 sshc->secondCreateDirs = 0; /* reset the create dir attempt state in ssh_do()
3482 struct ssh_conn *sshc = &conn->proto.sshc; in scp_disconnect() local
3485 if(sshc->ssh_session) { in scp_disconnect()
3538 struct ssh_conn *sshc = &conn->proto.sshc; in scp_send() local
3542 nwrite = (ssize_t) libssh2_channel_write(sshc->ssh_channel, mem, len); in scp_send()
3563 struct ssh_conn *sshc = &conn->proto.sshc; in scp_recv() local
3567 nread = (ssize_t) libssh2_channel_read(sshc->ssh_channel, mem, len); in scp_recv()
3636 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_disconnect() local
3641 if(sshc->ssh_session) { in sftp_disconnect()
3657 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_done() local
3664 sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT; in sftp_done()
3676 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_send() local
3679 nwrite = libssh2_sftp_write(sshc->sftp_handle, mem, len); in sftp_send()
3704 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_recv() local
3707 nread = libssh2_sftp_read(sshc->sftp_handle, mem, len); in sftp_recv()
3820 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_attach() local
3821 if(sshc->ssh_session) { in ssh_attach()
3823 void **abstract = libssh2_session_abstract(sshc->ssh_session); in ssh_attach()