Lines Matching refs:sshc
337 struct ssh_conn *sshc = &conn->proto.sshc;
401 if(sshc->state != nowstate) {
403 (void *)sshc, names[sshc->state], names[nowstate]);
407 sshc->state = nowstate;
529 struct ssh_conn *sshc = &conn->proto.sshc;
533 const char *remotekey = libssh2_session_hostkey(sshc->ssh_session,
556 keycheck = libssh2_knownhost_checkp(sshc->kh,
566 keycheck = libssh2_knownhost_check(sshc->kh,
618 result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION;
626 int addrc = libssh2_knownhost_add(sshc->kh,
639 libssh2_knownhost_writefile(sshc->kh,
659 struct ssh_conn *sshc = &conn->proto.sshc;
665 const char *fingerprint = libssh2_hostkey_hash(sshc->ssh_session,
688 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION;
689 return sshc->actualcode;
713 struct ssh_conn *sshc = &conn->proto.sshc;
723 switch(sshc->state) {
725 sshc->secondCreateDirs = 0;
726 sshc->nextstate = SSH_NO_STATE;
727 sshc->actualcode = CURLE_OK;
731 libssh2_session_set_blocking(sshc->ssh_session, 0);
737 rc = libssh2_session_startup(sshc->ssh_session, (int)sock);
744 sshc->actualcode = CURLE_FAILED_INIT;
774 sshc->authlist = libssh2_userauth_list(sshc->ssh_session,
778 if(!sshc->authlist) {
779 if(libssh2_userauth_authenticated(sshc->ssh_session)) {
780 sshc->authed = TRUE;
785 else if((err = libssh2_session_last_errno(sshc->ssh_session)) ==
792 sshc->actualcode = libssh2_session_error_to_CURLE(err);
797 sshc->authlist);
807 sshc->authed = FALSE;
810 (strstr(sshc->authlist, "publickey") != NULL)) {
814 sshc->rsa_pub = sshc->rsa = NULL;
821 sshc->rsa = strdup(data->set.str[STRING_SSH_PRIVATE_KEY]);
826 sshc->rsa = aprintf("%s/.ssh/id_rsa", home);
827 if(!sshc->rsa)
829 else if(access(sshc->rsa, R_OK) != 0) {
830 Curl_safefree(sshc->rsa);
831 sshc->rsa = aprintf("%s/.ssh/id_dsa", home);
832 if(!sshc->rsa)
834 else if(access(sshc->rsa, R_OK) != 0) {
835 Curl_safefree(sshc->rsa);
839 if(!out_of_memory && !sshc->rsa) {
841 sshc->rsa = strdup("id_rsa");
842 if(sshc->rsa && access(sshc->rsa, R_OK) != 0) {
843 Curl_safefree(sshc->rsa);
844 sshc->rsa = strdup("id_dsa");
845 if(sshc->rsa && access(sshc->rsa, R_OK) != 0) {
846 Curl_safefree(sshc->rsa);
849 sshc->rsa = strdup("");
858 * This is done by simply passing sshc->rsa_pub = NULL.
863 sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]);
864 if(!sshc->rsa_pub)
868 if(out_of_memory || sshc->rsa == NULL) {
870 Curl_safefree(sshc->rsa);
871 Curl_safefree(sshc->rsa_pub);
873 sshc->actualcode = CURLE_OUT_OF_MEMORY;
877 sshc->passphrase = data->set.str[STRING_KEY_PASSWD];
878 if(!sshc->passphrase)
879 sshc->passphrase = "";
883 if(sshc->rsa_pub)
884 infof(data, "Using SSH public key file '%s'\n", sshc->rsa_pub);
885 infof(data, "Using SSH private key file '%s'\n", sshc->rsa);
897 rc = libssh2_userauth_publickey_fromfile_ex(sshc->ssh_session,
901 sshc->rsa_pub,
902 sshc->rsa, sshc->passphrase);
907 Curl_safefree(sshc->rsa_pub);
908 Curl_safefree(sshc->rsa);
911 sshc->authed = TRUE;
917 (void)libssh2_session_last_error(sshc->ssh_session,
926 (strstr(sshc->authlist, "password") != NULL)) {
935 rc = libssh2_userauth_password_ex(sshc->ssh_session, conn->user,
944 sshc->authed = TRUE;
956 (strstr(sshc->authlist, "hostbased") != NULL)) {
971 && (strstr(sshc->authlist, "publickey") != NULL)) {
976 if(!sshc->ssh_agent) {
977 sshc->ssh_agent = libssh2_agent_init(sshc->ssh_session);
978 if(!sshc->ssh_agent) {
986 rc = libssh2_agent_connect(sshc->ssh_agent);
1004 rc = libssh2_agent_list_identities(sshc->ssh_agent);
1014 sshc->sshagent_prev_identity = NULL;
1024 rc = libssh2_agent_get_identity(sshc->ssh_agent,
1025 &sshc->sshagent_identity,
1026 sshc->sshagent_prev_identity);
1031 rc = libssh2_agent_userauth(sshc->ssh_agent, conn->user,
1032 sshc->sshagent_identity);
1037 sshc->sshagent_prev_identity = sshc->sshagent_identity;
1049 sshc->authed = TRUE;
1062 && (strstr(sshc->authlist, "keyboard-interactive") != NULL)) {
1072 rc = libssh2_userauth_keyboard_interactive_ex(sshc->ssh_session,
1081 sshc->authed = TRUE;
1088 if(!sshc->authed) {
1091 sshc->actualcode = CURLE_LOGIN_DENIED;
1117 sshc->sftp_session = libssh2_sftp_init(sshc->ssh_session);
1118 if(!sshc->sftp_session) {
1119 if(libssh2_session_last_errno(sshc->ssh_session) ==
1127 (void)libssh2_session_last_error(sshc->ssh_session,
1131 sshc->actualcode = CURLE_FAILED_INIT;
1145 rc = sftp_libssh2_realpath(sshc->sftp_session, ".",
1153 sshc->homedir = strdup(tempHome);
1154 if(!sshc->homedir) {
1156 sshc->actualcode = CURLE_OUT_OF_MEMORY;
1159 conn->data->state.most_recent_ftp_entrypath = sshc->homedir;
1163 err = sftp_libssh2_last_error(sshc->sftp_session);
1170 sshc->actualcode = result;
1187 result = ssh_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
1189 sshc->actualcode = result;
1196 sshc->quote_item = data->set.quote;
1207 sshc->quote_item = data->set.postquote;
1223 char *cmd = sshc->quote_item->data;
1224 sshc->acceptfail = FALSE;
1233 sshc->acceptfail = TRUE;
1243 sshc->nextstate = SSH_NO_STATE;
1257 sshc->nextstate = SSH_NO_STATE;
1258 sshc->actualcode = result;
1273 sshc->nextstate = SSH_NO_STATE;
1274 sshc->actualcode = CURLE_QUOTE_ERROR;
1282 result = get_pathname(&cp, &sshc->quote_path1);
1289 sshc->nextstate = SSH_NO_STATE;
1290 sshc->actualcode = result;
1305 /* sshc->quote_path1 contains the mode to set */
1307 result = get_pathname(&cp, &sshc->quote_path2);
1314 Curl_safefree(sshc->quote_path1);
1316 sshc->nextstate = SSH_NO_STATE;
1317 sshc->actualcode = result;
1320 memset(&sshc->quote_attrs, 0, sizeof(LIBSSH2_SFTP_ATTRIBUTES));
1327 /* sshc->quote_path1 is the source */
1329 result = get_pathname(&cp, &sshc->quote_path2);
1336 Curl_safefree(sshc->quote_path1);
1338 sshc->nextstate = SSH_NO_STATE;
1339 sshc->actualcode = result;
1354 result = get_pathname(&cp, &sshc->quote_path2);
1360 Curl_safefree(sshc->quote_path1);
1362 sshc->nextstate = SSH_NO_STATE;
1363 sshc->actualcode = result;
1386 Curl_safefree(sshc->quote_path1);
1387 Curl_safefree(sshc->quote_path2);
1389 sshc->nextstate = SSH_NO_STATE;
1390 sshc->actualcode = CURLE_QUOTE_ERROR;
1394 if(!sshc->quote_item) {
1400 Curl_safefree(sshc->quote_path1);
1401 Curl_safefree(sshc->quote_path2);
1403 sshc->quote_item = sshc->quote_item->next;
1405 if(sshc->quote_item) {
1409 if(sshc->nextstate != SSH_NO_STATE) {
1410 state(conn, sshc->nextstate);
1411 sshc->nextstate = SSH_NO_STATE;
1421 char *cmd = sshc->quote_item->data;
1422 sshc->acceptfail = FALSE;
1431 sshc->acceptfail = TRUE;
1439 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2,
1440 curlx_uztoui(strlen(sshc->quote_path2)),
1442 &sshc->quote_attrs);
1446 else if(rc != 0 && !sshc->acceptfail) { /* get those attributes */
1447 err = sftp_libssh2_last_error(sshc->sftp_session);
1448 Curl_safefree(sshc->quote_path1);
1449 Curl_safefree(sshc->quote_path2);
1453 sshc->nextstate = SSH_NO_STATE;
1454 sshc->actualcode = CURLE_QUOTE_ERROR;
1461 sshc->quote_attrs.gid = strtoul(sshc->quote_path1, NULL, 10);
1462 sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_UIDGID;
1463 if(sshc->quote_attrs.gid == 0 && !ISDIGIT(sshc->quote_path1[0]) &&
1464 !sshc->acceptfail) {
1465 Curl_safefree(sshc->quote_path1);
1466 Curl_safefree(sshc->quote_path2);
1469 sshc->nextstate = SSH_NO_STATE;
1470 sshc->actualcode = CURLE_QUOTE_ERROR;
1475 sshc->quote_attrs.permissions = strtoul(sshc->quote_path1, NULL, 8);
1476 sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_PERMISSIONS;
1478 if(sshc->quote_attrs.permissions == 0 &&
1479 !ISDIGIT(sshc->quote_path1[0])) {
1480 Curl_safefree(sshc->quote_path1);
1481 Curl_safefree(sshc->quote_path2);
1484 sshc->nextstate = SSH_NO_STATE;
1485 sshc->actualcode = CURLE_QUOTE_ERROR;
1490 sshc->quote_attrs.uid = strtoul(sshc->quote_path1, NULL, 10);
1491 sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_UIDGID;
1492 if(sshc->quote_attrs.uid == 0 && !ISDIGIT(sshc->quote_path1[0]) &&
1493 !sshc->acceptfail) {
1494 Curl_safefree(sshc->quote_path1);
1495 Curl_safefree(sshc->quote_path2);
1498 sshc->nextstate = SSH_NO_STATE;
1499 sshc->actualcode = CURLE_QUOTE_ERROR;
1510 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2,
1511 curlx_uztoui(strlen(sshc->quote_path2)),
1513 &sshc->quote_attrs);
1517 else if(rc != 0 && !sshc->acceptfail) {
1518 err = sftp_libssh2_last_error(sshc->sftp_session);
1519 Curl_safefree(sshc->quote_path1);
1520 Curl_safefree(sshc->quote_path2);
1524 sshc->nextstate = SSH_NO_STATE;
1525 sshc->actualcode = CURLE_QUOTE_ERROR;
1532 rc = libssh2_sftp_symlink_ex(sshc->sftp_session, sshc->quote_path1,
1533 curlx_uztoui(strlen(sshc->quote_path1)),
1534 sshc->quote_path2,
1535 curlx_uztoui(strlen(sshc->quote_path2)),
1540 else if(rc != 0 && !sshc->acceptfail) {
1541 err = sftp_libssh2_last_error(sshc->sftp_session);
1542 Curl_safefree(sshc->quote_path1);
1543 Curl_safefree(sshc->quote_path2);
1547 sshc->nextstate = SSH_NO_STATE;
1548 sshc->actualcode = CURLE_QUOTE_ERROR;
1555 rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshc->quote_path1,
1556 curlx_uztoui(strlen(sshc->quote_path1)),
1561 else if(rc != 0 && !sshc->acceptfail) {
1562 err = sftp_libssh2_last_error(sshc->sftp_session);
1563 Curl_safefree(sshc->quote_path1);
1566 sshc->nextstate = SSH_NO_STATE;
1567 sshc->actualcode = CURLE_QUOTE_ERROR;
1574 rc = libssh2_sftp_rename_ex(sshc->sftp_session, sshc->quote_path1,
1575 curlx_uztoui(strlen(sshc->quote_path1)),
1576 sshc->quote_path2,
1577 curlx_uztoui(strlen(sshc->quote_path2)),
1585 else if(rc != 0 && !sshc->acceptfail) {
1586 err = sftp_libssh2_last_error(sshc->sftp_session);
1587 Curl_safefree(sshc->quote_path1);
1588 Curl_safefree(sshc->quote_path2);
1591 sshc->nextstate = SSH_NO_STATE;
1592 sshc->actualcode = CURLE_QUOTE_ERROR;
1599 rc = libssh2_sftp_rmdir_ex(sshc->sftp_session, sshc->quote_path1,
1600 curlx_uztoui(strlen(sshc->quote_path1)));
1604 else if(rc != 0 && !sshc->acceptfail) {
1605 err = sftp_libssh2_last_error(sshc->sftp_session);
1606 Curl_safefree(sshc->quote_path1);
1609 sshc->nextstate = SSH_NO_STATE;
1610 sshc->actualcode = CURLE_QUOTE_ERROR;
1617 rc = libssh2_sftp_unlink_ex(sshc->sftp_session, sshc->quote_path1,
1618 curlx_uztoui(strlen(sshc->quote_path1)));
1622 else if(rc != 0 && !sshc->acceptfail) {
1623 err = sftp_libssh2_last_error(sshc->sftp_session);
1624 Curl_safefree(sshc->quote_path1);
1627 sshc->nextstate = SSH_NO_STATE;
1628 sshc->actualcode = CURLE_QUOTE_ERROR;
1638 rc = libssh2_sftp_statvfs(sshc->sftp_session, sshc->quote_path1,
1639 curlx_uztoui(strlen(sshc->quote_path1)),
1645 else if(rc != 0 && !sshc->acceptfail) {
1646 err = sftp_libssh2_last_error(sshc->sftp_session);
1647 Curl_safefree(sshc->quote_path1);
1650 sshc->nextstate = SSH_NO_STATE;
1651 sshc->actualcode = CURLE_QUOTE_ERROR;
1671 sshc->nextstate = SSH_NO_STATE;
1679 sshc->nextstate = SSH_NO_STATE;
1680 sshc->actualcode = result;
1702 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
1740 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
1770 sshc->sftp_handle =
1771 libssh2_sftp_open_ex(sshc->sftp_session, sftp_scp->path,
1776 if(!sshc->sftp_handle) {
1777 rc = libssh2_session_last_errno(sshc->ssh_session);
1785 err = sftp_libssh2_last_error(sshc->sftp_session);
1789 if(sshc->secondCreateDirs) {
1791 sshc->actualcode = err>= LIBSSH2_FX_OK?
1803 sshc->secondCreateDirs = 1;
1808 sshc->actualcode = err>= LIBSSH2_FX_OK?
1810 if(!sshc->actualcode) {
1814 sshc->actualcode = CURLE_SSH;
1869 SFTP_SEEK(sshc->sftp_handle, data->state.resume_from);
1883 sshc->actualcode = result;
1888 sshc->orig_waitfor = data->req.keepon;
1907 sshc->slash_pos = sftp_scp->path + 1; /* ignore the leading '/' */
1916 sshc->slash_pos = strchr(sshc->slash_pos, '/');
1917 if(sshc->slash_pos) {
1918 *sshc->slash_pos = 0;
1931 rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sftp_scp->path,
1937 *sshc->slash_pos = '/';
1938 ++sshc->slash_pos;
1945 err = sftp_libssh2_last_error(sshc->sftp_session);
1951 sshc
1969 sshc->sftp_handle = libssh2_sftp_open_ex(sshc->sftp_session,
1974 if(!sshc->sftp_handle) {
1975 if(libssh2_session_last_errno(sshc->ssh_session) ==
1981 err = sftp_libssh2_last_error(sshc->sftp_session);
1986 sshc->actualcode = result?result:CURLE_SSH;
1990 if((sshc->readdir_filename = malloc(PATH_MAX+1)) == NULL) {
1992 sshc->actualcode = CURLE_OUT_OF_MEMORY;
1995 if((sshc->readdir_longentry = malloc(PATH_MAX+1)) == NULL) {
1996 Curl_safefree(sshc->readdir_filename);
1998 sshc->actualcode = CURLE_OUT_OF_MEMORY;
2005 sshc->readdir_len = libssh2_sftp_readdir_ex(sshc->sftp_handle,
2006 sshc->readdir_filename,
2008 sshc->readdir_longentry,
2010 &sshc->readdir_attrs);
2011 if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) {
2015 if(sshc->readdir_len > 0) {
2016 sshc->readdir_filename[sshc->readdir_len] = '\0';
2021 tmpLine = aprintf("%s\n", sshc->readdir_filename);
2024 sshc->actualcode = CURLE_OUT_OF_MEMORY;
2028 tmpLine, sshc->readdir_len+1);
2037 data->req.bytecount += sshc->readdir_len+1;
2041 Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_filename,
2042 sshc->readdir_len, conn);
2046 sshc->readdir_currLen = (int)strlen(sshc->readdir_longentry);
2047 sshc->readdir_totalLen = 80 + sshc->readdir_currLen;
2048 sshc->readdir_line = calloc(sshc->readdir_totalLen, 1);
2049 if(!sshc->readdir_line) {
2050 Curl_safefree(sshc->readdir_filename);
2051 Curl_safefree(sshc->readdir_longentry);
2053 sshc->actualcode = CURLE_OUT_OF_MEMORY;
2057 memcpy(sshc->readdir_line, sshc->readdir_longentry,
2058 sshc->readdir_currLen);
2059 if((sshc->readdir_attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) &&
2060 ((sshc->readdir_attrs.permissions & LIBSSH2_SFTP_S_IFMT) ==
2062 sshc->readdir_linkPath = malloc(PATH_MAX + 1);
2063 if(sshc->readdir_linkPath == NULL) {
2064 Curl_safefree(sshc->readdir_filename);
2065 Curl_safefree(sshc->readdir_longentry);
2067 sshc->actualcode = CURLE_OUT_OF_MEMORY;
2071 snprintf(sshc->readdir_linkPath, PATH_MAX, "%s%s", sftp_scp->path,
2072 sshc->readdir_filename);
2080 else if(sshc->readdir_len == 0) {
2081 Curl_safefree(sshc->readdir_filename);
2082 Curl_safefree(sshc->readdir_longentry);
2086 else if(sshc->readdir_len <= 0) {
2087 err = sftp_libssh2_last_error(sshc->sftp_session);
2089 sshc->actualcode = result?result:CURLE_SSH;
2092 libssh2_session_last_errno(sshc->ssh_session));
2093 Curl_safefree(sshc->readdir_filename);
2094 Curl_safefree(sshc->readdir_longentry);
2101 sshc->readdir_len =
2102 libssh2_sftp_symlink_ex(sshc->sftp_session,
2103 sshc->readdir_linkPath,
2104 curlx_uztoui(strlen(sshc->readdir_linkPath)),
2105 sshc->readdir_filename,
2107 if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) {
2111 Curl_safefree(sshc->readdir_linkPath);
2114 sshc->readdir_totalLen += 4 + sshc->readdir_len;
2115 new_readdir_line = realloc(sshc->readdir_line, sshc->readdir_totalLen);
2117 Curl_safefree(sshc->readdir_line);
2118 Curl_safefree(sshc->readdir_filename);
2119 Curl_safefree(sshc->readdir_longentry);
2121 sshc->actualcode = CURLE_OUT_OF_MEMORY;
2124 sshc->readdir_line = new_readdir_line;
2126 sshc->readdir_currLen += snprintf(sshc->readdir_line +
2127 sshc->readdir_currLen,
2128 sshc->readdir_totalLen -
2129 sshc->readdir_currLen,
2131 sshc->readdir_filename);
2137 sshc->readdir_currLen += snprintf(sshc->readdir_line +
2138 sshc->readdir_currLen,
2139 sshc->readdir_totalLen -
2140 sshc->readdir_currLen, "\n");
2142 sshc->readdir_line,
2143 sshc->readdir_currLen);
2149 Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line,
2150 sshc->readdir_currLen, conn);
2152 data->req.bytecount += sshc->readdir_currLen;
2154 Curl_safefree(sshc->readdir_line);
2163 if(libssh2_sftp_closedir(sshc->sftp_handle) ==
2168 sshc->sftp_handle = NULL;
2169 Curl_safefree(sshc->readdir_filename);
2170 Curl_safefree(sshc->readdir_longentry);
2181 sshc->sftp_handle =
2182 libssh2_sftp_open_ex(sshc->sftp_session, sftp_scp->path,
2186 if(!sshc->sftp_handle) {
2187 if(libssh2_session_last_errno(sshc->ssh_session) ==
2193 err = sftp_libssh2_last_error(sshc->sftp_session);
2198 sshc->actualcode = result?result:CURLE_SSH;
2209 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
2266 SFTP_SEEK(conn->proto.sshc.sftp_handle, from);
2301 SFTP_SEEK(sshc->sftp_handle, data->state.resume_from);
2329 sshc->actualcode = result;
2337 if(sshc->sftp_handle) {
2338 rc = libssh2_sftp_close(sshc->sftp_handle);
2345 sshc->sftp_handle = NULL;
2355 if(sshc->nextstate != SSH_NO_STATE &&
2356 sshc->nextstate != SSH_SFTP_CLOSE) {
2357 state(conn, sshc->nextstate);
2358 sshc->nextstate = SSH_SFTP_CLOSE;
2362 result = sshc->actualcode;
2371 if(sshc->sftp_handle) {
2372 rc = libssh2_sftp_close(sshc->sftp_handle);
2379 sshc->sftp_handle = NULL;
2381 if(sshc->sftp_session) {
2382 rc = libssh2_sftp_shutdown(sshc->sftp_session);
2389 sshc->sftp_session = NULL;
2392 Curl_safefree(sshc->homedir);
2399 result = ssh_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
2401 sshc->actualcode = result;
2409 sshc->actualcode = CURLE_UPLOAD_FAILED;
2427 sshc->ssh_channel =
2428 SCP_SEND(sshc->ssh_session, sftp_scp->path, data->set.new_file_perms,
2430 if(!sshc->ssh_channel) {
2431 if(libssh2_session_last_errno(sshc->ssh_session) ==
2440 ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session,
2444 sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err);
2458 sshc->actualcode = result;
2463 sshc->orig_waitfor = data->req.keepon;
2491 sshc->ssh_channel = libssh2_scp_recv(sshc->ssh_session,
2496 sshc->ssh_channel = libssh2_scp_recv2(sshc->ssh_session,
2500 if(!sshc->ssh_channel) {
2501 if(libssh2_session_last_errno(sshc->ssh_session) ==
2510 ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session,
2514 sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err);
2534 sshc->actualcode = result;
2549 if(sshc->ssh_channel) {
2550 rc = libssh2_channel_send_eof(sshc->ssh_channel);
2562 if(sshc->ssh_channel) {
2563 rc = libssh2_channel_wait_eof(sshc->ssh_channel);
2575 if(sshc->ssh_channel) {
2576 rc = libssh2_channel_wait_closed(sshc->ssh_channel);
2588 if(sshc->ssh_channel) {
2589 rc = libssh2_channel_free(sshc->ssh_channel);
2596 sshc->ssh_channel = NULL;
2603 result = sshc->actualcode;
2610 if(sshc->ssh_channel) {
2611 rc = libssh2_channel_free(sshc->ssh_channel);
2618 sshc->ssh_channel = NULL;
2621 if(sshc->ssh_session) {
2622 rc = libssh2_session_disconnect(sshc->ssh_session, "Shutdown");
2631 Curl_safefree(sshc->homedir);
2639 if(sshc->kh) {
2640 libssh2_knownhost_free(sshc->kh);
2641 sshc->kh = NULL;
2646 if(sshc->ssh_agent) {
2647 rc = libssh2_agent_disconnect(sshc->ssh_agent);
2654 libssh2_agent_free (sshc->ssh_agent);
2655 sshc->ssh_agent = NULL;
2659 sshc->sshagent_identity = NULL;
2660 sshc->sshagent_prev_identity = NULL;
2664 if(sshc->ssh_session) {
2665 rc = libssh2_session_free(sshc->ssh_session);
2672 sshc->ssh_session = NULL;
2677 DEBUGASSERT(sshc->ssh_session == NULL);
2678 DEBUGASSERT(sshc->ssh_channel == NULL);
2679 DEBUGASSERT(sshc->sftp_session == NULL);
2680 DEBUGASSERT(sshc->sftp_handle == NULL);
2682 DEBUGASSERT(sshc->kh == NULL);
2685 DEBUGASSERT(sshc->ssh_agent == NULL);
2688 Curl_safefree(sshc->rsa_pub);
2689 Curl_safefree(sshc->rsa);
2691 Curl_safefree(sshc->quote_path1);
2692 Curl_safefree(sshc->quote_path2);
2694 Curl_safefree(sshc->homedir);
2696 Curl_safefree(sshc->readdir_filename);
2697 Curl_safefree(sshc->readdir_longentry);
2698 Curl_safefree(sshc->readdir_line);
2699 Curl_safefree(sshc->readdir_linkPath);
2702 result = sshc->actualcode;
2704 memset(sshc, 0, sizeof(struct ssh_conn));
2707 sshc->state = SSH_SESSION_FREE; /* current */
2708 sshc->nextstate = SSH_NO_STATE;
2716 sshc->nextstate = SSH_NO_STATE;
2721 } while(!rc && (sshc->state != SSH_STOP));
2790 struct ssh_conn *sshc = &conn->proto.sshc;
2792 if(block && (dir = libssh2_session_block_directions(sshc->ssh_session))) {
2800 conn->waitfor = sshc->orig_waitfor;
2810 struct ssh_conn *sshc = &conn->proto.sshc;
2816 *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
2825 struct ssh_conn *sshc = &conn->proto.sshc;
2829 while((sshc->state != SSH_STOP) && !result) {
2854 int dir = libssh2_session_block_directions(sshc->ssh_session);
2919 ssh = &conn->proto.sshc;
3028 struct ssh_conn *sshc = &conn->proto.sshc;
3034 sshc->actualcode = CURLE_OK; /* reset error code */
3035 sshc->secondCreateDirs =0; /* reset the create dir attempt state
3057 struct ssh_conn *ssh = &conn->proto.sshc;
3121 libssh2_channel_write(conn->proto.sshc.ssh_channel, mem, len);
3149 libssh2_channel_read(conn->proto.sshc.ssh_channel, mem, len);
3221 if(conn->proto.sshc.ssh_session) {
3236 struct ssh_conn *sshc = &conn->proto.sshc;
3243 sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT;
3261 nwrite = libssh2_sftp_write(conn->proto.sshc.sftp_handle, mem, len);
3287 nread = libssh2_sftp_read(conn->proto.sshc.sftp_handle, mem, len);