Lines Matching refs:sshc

325   struct ssh_conn *sshc = &conn->proto.sshc;  in state()  local
394 if(sshc->state != nowstate) { in state()
396 (void *)sshc, names[sshc->state], names[nowstate]); in state()
400 sshc->state = nowstate; in state()
458 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_knownhost() local
462 const char *remotekey = libssh2_session_hostkey(sshc->ssh_session, in ssh_knownhost()
485 keycheck = libssh2_knownhost_checkp(sshc->kh, in ssh_knownhost()
495 keycheck = libssh2_knownhost_check(sshc->kh, in ssh_knownhost()
549 result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_knownhost()
557 int addrc = libssh2_knownhost_add(sshc->kh, in ssh_knownhost()
570 libssh2_knownhost_writefile(sshc->kh, in ssh_knownhost()
590 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_check_fingerprint() local
596 const char *fingerprint = libssh2_hostkey_hash(sshc->ssh_session, in ssh_check_fingerprint()
619 sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; in ssh_check_fingerprint()
620 return sshc->actualcode; in ssh_check_fingerprint()
641 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_statemach_act() local
651 switch(sshc->state) { in ssh_statemach_act()
653 sshc->secondCreateDirs = 0; in ssh_statemach_act()
654 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
655 sshc->actualcode = CURLE_OK; in ssh_statemach_act()
659 libssh2_session_set_blocking(sshc->ssh_session, 0); in ssh_statemach_act()
665 rc = libssh2_session_startup(sshc->ssh_session, (int)sock); in ssh_statemach_act()
671 (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); in ssh_statemach_act()
675 sshc->actualcode = CURLE_FAILED_INIT; in ssh_statemach_act()
705 sshc->authlist = libssh2_userauth_list(sshc->ssh_session, in ssh_statemach_act()
709 if(!sshc->authlist) { in ssh_statemach_act()
710 if(libssh2_userauth_authenticated(sshc->ssh_session)) { in ssh_statemach_act()
711 sshc->authed = TRUE; in ssh_statemach_act()
716 err = libssh2_session_last_errno(sshc->ssh_session); in ssh_statemach_act()
721 sshc->actualcode = libssh2_session_error_to_CURLE(err); in ssh_statemach_act()
726 sshc->authlist); in ssh_statemach_act()
736 sshc->authed = FALSE; in ssh_statemach_act()
739 (strstr(sshc->authlist, "publickey") != NULL)) { in ssh_statemach_act()
743 sshc->rsa_pub = sshc->rsa = NULL; in ssh_statemach_act()
750 sshc->rsa = strdup(data->set.str[STRING_SSH_PRIVATE_KEY]); in ssh_statemach_act()
755 sshc->rsa = aprintf("%s/.ssh/id_rsa", home); in ssh_statemach_act()
756 if(!sshc->rsa) in ssh_statemach_act()
758 else if(access(sshc->rsa, R_OK) != 0) { in ssh_statemach_act()
759 Curl_safefree(sshc->rsa); in ssh_statemach_act()
760 sshc->rsa = aprintf("%s/.ssh/id_dsa", home); in ssh_statemach_act()
761 if(!sshc->rsa) in ssh_statemach_act()
763 else if(access(sshc->rsa, R_OK) != 0) { in ssh_statemach_act()
764 Curl_safefree(sshc->rsa); in ssh_statemach_act()
768 if(!out_of_memory && !sshc->rsa) { in ssh_statemach_act()
770 sshc->rsa = strdup("id_rsa"); in ssh_statemach_act()
771 if(sshc->rsa && access(sshc->rsa, R_OK) != 0) { in ssh_statemach_act()
772 Curl_safefree(sshc->rsa); in ssh_statemach_act()
773 sshc->rsa = strdup("id_dsa"); in ssh_statemach_act()
774 if(sshc->rsa && access(sshc->rsa, R_OK) != 0) { in ssh_statemach_act()
775 Curl_safefree(sshc->rsa); in ssh_statemach_act()
778 sshc->rsa = strdup(""); in ssh_statemach_act()
792 sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]); in ssh_statemach_act()
793 if(!sshc->rsa_pub) in ssh_statemach_act()
797 if(out_of_memory || sshc->rsa == NULL) { in ssh_statemach_act()
799 Curl_safefree(sshc->rsa); in ssh_statemach_act()
800 Curl_safefree(sshc->rsa_pub); in ssh_statemach_act()
802 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
806 sshc->passphrase = data->set.ssl.key_passwd; in ssh_statemach_act()
807 if(!sshc->passphrase) in ssh_statemach_act()
808 sshc->passphrase = ""; in ssh_statemach_act()
812 if(sshc->rsa_pub) in ssh_statemach_act()
813 infof(data, "Using SSH public key file '%s'\n", sshc->rsa_pub); in ssh_statemach_act()
814 infof(data, "Using SSH private key file '%s'\n", sshc->rsa); in ssh_statemach_act()
826 rc = libssh2_userauth_publickey_fromfile_ex(sshc->ssh_session, in ssh_statemach_act()
830 sshc->rsa_pub, in ssh_statemach_act()
831 sshc->rsa, sshc->passphrase); in ssh_statemach_act()
836 Curl_safefree(sshc->rsa_pub); in ssh_statemach_act()
837 Curl_safefree(sshc->rsa); in ssh_statemach_act()
840 sshc->authed = TRUE; in ssh_statemach_act()
846 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
856 (strstr(sshc->authlist, "password") != NULL)) { in ssh_statemach_act()
866 rc = libssh2_userauth_password_ex(sshc->ssh_session, conn->user, in ssh_statemach_act()
875 sshc->authed = TRUE; in ssh_statemach_act()
887 (strstr(sshc->authlist, "hostbased") != NULL)) { in ssh_statemach_act()
902 && (strstr(sshc->authlist, "publickey") != NULL)) { in ssh_statemach_act()
907 if(!sshc->ssh_agent) { in ssh_statemach_act()
908 sshc->ssh_agent = libssh2_agent_init(sshc->ssh_session); in ssh_statemach_act()
909 if(!sshc->ssh_agent) { in ssh_statemach_act()
917 rc = libssh2_agent_connect(sshc->ssh_agent); in ssh_statemach_act()
936 rc = libssh2_agent_list_identities(sshc->ssh_agent); in ssh_statemach_act()
947 sshc->sshagent_prev_identity = NULL; in ssh_statemach_act()
957 rc = libssh2_agent_get_identity(sshc->ssh_agent, in ssh_statemach_act()
958 &sshc->sshagent_identity, in ssh_statemach_act()
959 sshc->sshagent_prev_identity); in ssh_statemach_act()
964 rc = libssh2_agent_userauth(sshc->ssh_agent, conn->user, in ssh_statemach_act()
965 sshc->sshagent_identity); in ssh_statemach_act()
970 sshc->sshagent_prev_identity = sshc->sshagent_identity; in ssh_statemach_act()
982 sshc->authed = TRUE; in ssh_statemach_act()
995 && (strstr(sshc->authlist, "keyboard-interactive") != NULL)) { in ssh_statemach_act()
1005 rc = libssh2_userauth_keyboard_interactive_ex(sshc->ssh_session, in ssh_statemach_act()
1014 sshc->authed = TRUE; in ssh_statemach_act()
1021 if(!sshc->authed) { in ssh_statemach_act()
1024 sshc->actualcode = CURLE_LOGIN_DENIED; in ssh_statemach_act()
1050 sshc->sftp_session = libssh2_sftp_init(sshc->ssh_session); in ssh_statemach_act()
1051 if(!sshc->sftp_session) { in ssh_statemach_act()
1053 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
1059 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
1063 sshc->actualcode = CURLE_FAILED_INIT; in ssh_statemach_act()
1076 rc = sftp_libssh2_realpath(sshc->sftp_session, ".", in ssh_statemach_act()
1084 sshc->homedir = strdup(tempHome); in ssh_statemach_act()
1085 if(!sshc->homedir) { in ssh_statemach_act()
1087 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
1090 conn->data->state.most_recent_ftp_entrypath = sshc->homedir; in ssh_statemach_act()
1094 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1101 sshc->actualcode = result; in ssh_statemach_act()
1118 result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path); in ssh_statemach_act()
1120 sshc->actualcode = result; in ssh_statemach_act()
1127 sshc->quote_item = data->set.quote; in ssh_statemach_act()
1138 sshc->quote_item = data->set.postquote; in ssh_statemach_act()
1157 char *cmd = sshc->quote_item->data; in ssh_statemach_act()
1158 sshc->acceptfail = FALSE; in ssh_statemach_act()
1167 sshc->acceptfail = TRUE; in ssh_statemach_act()
1177 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1191 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1192 sshc->actualcode = result; in ssh_statemach_act()
1207 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1208 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1216 result = Curl_get_pathname(&cp, &sshc->quote_path1, sshc->homedir); in ssh_statemach_act()
1223 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1224 sshc->actualcode = result; in ssh_statemach_act()
1241 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in ssh_statemach_act()
1248 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1250 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1251 sshc->actualcode = result; in ssh_statemach_act()
1254 memset(&sshc->quote_attrs, 0, sizeof(LIBSSH2_SFTP_ATTRIBUTES)); in ssh_statemach_act()
1263 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in ssh_statemach_act()
1270 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1272 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1273 sshc->actualcode = result; in ssh_statemach_act()
1288 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in ssh_statemach_act()
1294 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1296 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1297 sshc->actualcode = result; in ssh_statemach_act()
1320 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1321 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1323 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1324 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1331 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1332 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1334 sshc->quote_item = sshc->quote_item->next; in ssh_statemach_act()
1336 if(sshc->quote_item) { in ssh_statemach_act()
1340 if(sshc->nextstate != SSH_NO_STATE) { in ssh_statemach_act()
1341 state(conn, sshc->nextstate); in ssh_statemach_act()
1342 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1352 char *cmd = sshc->quote_item->data; in ssh_statemach_act()
1353 sshc->acceptfail = FALSE; in ssh_statemach_act()
1362 sshc->acceptfail = TRUE; in ssh_statemach_act()
1370 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2, in ssh_statemach_act()
1371 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemach_act()
1373 &sshc->quote_attrs); in ssh_statemach_act()
1377 if(rc != 0 && !sshc->acceptfail) { /* get those attributes */ in ssh_statemach_act()
1378 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1379 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1380 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1384 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1385 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1392 sshc->quote_attrs.gid = strtoul(sshc->quote_path1, NULL, 10); in ssh_statemach_act()
1393 sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_UIDGID; in ssh_statemach_act()
1394 if(sshc->quote_attrs.gid == 0 && !ISDIGIT(sshc->quote_path1[0]) && in ssh_statemach_act()
1395 !sshc->acceptfail) { in ssh_statemach_act()
1396 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1397 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1400 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1401 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1406 sshc->quote_attrs.permissions = strtoul(sshc->quote_path1, NULL, 8); in ssh_statemach_act()
1407 sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_PERMISSIONS; in ssh_statemach_act()
1409 if(sshc->quote_attrs.permissions == 0 && in ssh_statemach_act()
1410 !ISDIGIT(sshc->quote_path1[0])) { in ssh_statemach_act()
1411 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1412 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1415 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1416 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1421 sshc->quote_attrs.uid = strtoul(sshc->quote_path1, NULL, 10); in ssh_statemach_act()
1422 sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_UIDGID; in ssh_statemach_act()
1423 if(sshc->quote_attrs.uid == 0 && !ISDIGIT(sshc->quote_path1[0]) && in ssh_statemach_act()
1424 !sshc->acceptfail) { in ssh_statemach_act()
1425 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1426 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1429 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1430 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1441 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2, in ssh_statemach_act()
1442 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemach_act()
1444 &sshc->quote_attrs); in ssh_statemach_act()
1448 if(rc != 0 && !sshc->acceptfail) { in ssh_statemach_act()
1449 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1450 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1451 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1455 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1456 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1463 rc = libssh2_sftp_symlink_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1464 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemach_act()
1465 sshc->quote_path2, in ssh_statemach_act()
1466 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemach_act()
1471 if(rc != 0 && !sshc->acceptfail) { in ssh_statemach_act()
1472 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1473 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1474 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1478 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1479 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1486 rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1487 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemach_act()
1492 if(rc != 0 && !sshc->acceptfail) { in ssh_statemach_act()
1493 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1494 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1497 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1498 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1505 rc = libssh2_sftp_rename_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1506 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemach_act()
1507 sshc->quote_path2, in ssh_statemach_act()
1508 curlx_uztoui(strlen(sshc->quote_path2)), in ssh_statemach_act()
1516 if(rc != 0 && !sshc->acceptfail) { in ssh_statemach_act()
1517 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1518 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1519 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
1522 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1523 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1530 rc = libssh2_sftp_rmdir_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1531 curlx_uztoui(strlen(sshc->quote_path1))); in ssh_statemach_act()
1535 if(rc != 0 && !sshc->acceptfail) { in ssh_statemach_act()
1536 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1537 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1540 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1541 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1548 rc = libssh2_sftp_unlink_ex(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1549 curlx_uztoui(strlen(sshc->quote_path1))); in ssh_statemach_act()
1553 if(rc != 0 && !sshc->acceptfail) { in ssh_statemach_act()
1554 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1555 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1558 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1559 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1569 rc = libssh2_sftp_statvfs(sshc->sftp_session, sshc->quote_path1, in ssh_statemach_act()
1570 curlx_uztoui(strlen(sshc->quote_path1)), in ssh_statemach_act()
1576 if(rc != 0 && !sshc->acceptfail) { in ssh_statemach_act()
1577 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1578 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
1581 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1582 sshc->actualcode = CURLE_QUOTE_ERROR; in ssh_statemach_act()
1602 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1610 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
1611 sshc->actualcode = result; in ssh_statemach_act()
1633 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path, in ssh_statemach_act()
1671 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path, in ssh_statemach_act()
1701 sshc->sftp_handle = in ssh_statemach_act()
1702 libssh2_sftp_open_ex(sshc->sftp_session, sftp_scp->path, in ssh_statemach_act()
1707 if(!sshc->sftp_handle) { in ssh_statemach_act()
1708 rc = libssh2_session_last_errno(sshc->ssh_session); in ssh_statemach_act()
1716 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1720 if(sshc->secondCreateDirs) { in ssh_statemach_act()
1722 sshc->actualcode = err>= LIBSSH2_FX_OK? in ssh_statemach_act()
1735 sshc->secondCreateDirs = 1; in ssh_statemach_act()
1740 sshc->actualcode = err>= LIBSSH2_FX_OK? in ssh_statemach_act()
1742 if(!sshc->actualcode) { in ssh_statemach_act()
1746 sshc->actualcode = CURLE_SSH; in ssh_statemach_act()
1804 SFTP_SEEK(sshc->sftp_handle, data->state.resume_from); in ssh_statemach_act()
1818 sshc->actualcode = result; in ssh_statemach_act()
1823 sshc->orig_waitfor = data->req.keepon; in ssh_statemach_act()
1842 sshc->slash_pos = sftp_scp->path + 1; /* ignore the leading '/' */ in ssh_statemach_act()
1851 sshc->slash_pos = strchr(sshc->slash_pos, '/'); in ssh_statemach_act()
1852 if(sshc->slash_pos) { in ssh_statemach_act()
1853 *sshc->slash_pos = 0; in ssh_statemach_act()
1864 rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sftp_scp->path, in ssh_statemach_act()
1870 *sshc->slash_pos = '/'; in ssh_statemach_act()
1871 ++sshc->slash_pos; in ssh_statemach_act()
1878 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1884 sshc->actualcode = result?result:CURLE_SSH; in ssh_statemach_act()
1903 sshc->sftp_handle = libssh2_sftp_open_ex(sshc->sftp_session, in ssh_statemach_act()
1908 if(!sshc->sftp_handle) { in ssh_statemach_act()
1909 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
1914 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
1919 sshc->actualcode = result?result:CURLE_SSH; in ssh_statemach_act()
1922 sshc->readdir_filename = malloc(PATH_MAX + 1); in ssh_statemach_act()
1923 if(!sshc->readdir_filename) { in ssh_statemach_act()
1925 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
1928 sshc->readdir_longentry = malloc(PATH_MAX + 1); in ssh_statemach_act()
1929 if(!sshc->readdir_longentry) { in ssh_statemach_act()
1930 Curl_safefree(sshc->readdir_filename); in ssh_statemach_act()
1932 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
1939 rc = libssh2_sftp_readdir_ex(sshc->sftp_handle, in ssh_statemach_act()
1940 sshc->readdir_filename, in ssh_statemach_act()
1942 sshc->readdir_longentry, in ssh_statemach_act()
1944 &sshc->readdir_attrs); in ssh_statemach_act()
1949 sshc->readdir_len = (size_t) rc; in ssh_statemach_act()
1950 sshc->readdir_filename[sshc->readdir_len] = '\0'; in ssh_statemach_act()
1955 tmpLine = aprintf("%s\n", sshc->readdir_filename); in ssh_statemach_act()
1958 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
1962 tmpLine, sshc->readdir_len + 1); in ssh_statemach_act()
1971 data->req.bytecount += sshc->readdir_len + 1; in ssh_statemach_act()
1975 Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_filename, in ssh_statemach_act()
1976 sshc->readdir_len); in ssh_statemach_act()
1980 sshc->readdir_currLen = strlen(sshc->readdir_longentry); in ssh_statemach_act()
1981 sshc->readdir_totalLen = 80 + sshc->readdir_currLen; in ssh_statemach_act()
1982 sshc->readdir_line = calloc(sshc->readdir_totalLen, 1); in ssh_statemach_act()
1983 if(!sshc->readdir_line) { in ssh_statemach_act()
1984 Curl_safefree(sshc->readdir_filename); in ssh_statemach_act()
1985 Curl_safefree(sshc->readdir_longentry); in ssh_statemach_act()
1987 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
1991 memcpy(sshc->readdir_line, sshc->readdir_longentry, in ssh_statemach_act()
1992 sshc->readdir_currLen); in ssh_statemach_act()
1993 if((sshc->readdir_attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) && in ssh_statemach_act()
1994 ((sshc->readdir_attrs.permissions & LIBSSH2_SFTP_S_IFMT) == in ssh_statemach_act()
1996 sshc->readdir_linkPath = malloc(PATH_MAX + 1); in ssh_statemach_act()
1997 if(sshc->readdir_linkPath == NULL) { in ssh_statemach_act()
1998 Curl_safefree(sshc->readdir_filename); in ssh_statemach_act()
1999 Curl_safefree(sshc->readdir_longentry); in ssh_statemach_act()
2001 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
2005 msnprintf(sshc->readdir_linkPath, PATH_MAX, "%s%s", sftp_scp->path, in ssh_statemach_act()
2006 sshc->readdir_filename); in ssh_statemach_act()
2015 Curl_safefree(sshc->readdir_filename); in ssh_statemach_act()
2016 Curl_safefree(sshc->readdir_longentry); in ssh_statemach_act()
2021 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
2023 sshc->actualcode = result?result:CURLE_SSH; in ssh_statemach_act()
2026 libssh2_session_last_errno(sshc->ssh_session)); in ssh_statemach_act()
2027 Curl_safefree(sshc->readdir_filename); in ssh_statemach_act()
2028 Curl_safefree(sshc->readdir_longentry); in ssh_statemach_act()
2036 libssh2_sftp_symlink_ex(sshc->sftp_session, in ssh_statemach_act()
2037 sshc->readdir_linkPath, in ssh_statemach_act()
2038 curlx_uztoui(strlen(sshc->readdir_linkPath)), in ssh_statemach_act()
2039 sshc->readdir_filename, in ssh_statemach_act()
2044 sshc->readdir_len = (size_t) rc; in ssh_statemach_act()
2045 Curl_safefree(sshc->readdir_linkPath); in ssh_statemach_act()
2048 sshc->readdir_totalLen += 4 + sshc->readdir_len; in ssh_statemach_act()
2049 new_readdir_line = Curl_saferealloc(sshc->readdir_line, in ssh_statemach_act()
2050 sshc->readdir_totalLen); in ssh_statemach_act()
2052 sshc->readdir_line = NULL; in ssh_statemach_act()
2053 Curl_safefree(sshc->readdir_filename); in ssh_statemach_act()
2054 Curl_safefree(sshc->readdir_longentry); in ssh_statemach_act()
2056 sshc->actualcode = CURLE_OUT_OF_MEMORY; in ssh_statemach_act()
2059 sshc->readdir_line = new_readdir_line; in ssh_statemach_act()
2061 sshc->readdir_currLen += msnprintf(sshc->readdir_line + in ssh_statemach_act()
2062 sshc->readdir_currLen, in ssh_statemach_act()
2063 sshc->readdir_totalLen - in ssh_statemach_act()
2064 sshc->readdir_currLen, in ssh_statemach_act()
2066 sshc->readdir_filename); in ssh_statemach_act()
2072 sshc->readdir_currLen += msnprintf(sshc->readdir_line + in ssh_statemach_act()
2073 sshc->readdir_currLen, in ssh_statemach_act()
2074 sshc->readdir_totalLen - in ssh_statemach_act()
2075 sshc->readdir_currLen, "\n"); in ssh_statemach_act()
2077 sshc->readdir_line, in ssh_statemach_act()
2078 sshc->readdir_currLen); in ssh_statemach_act()
2084 Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line, in ssh_statemach_act()
2085 sshc->readdir_currLen); in ssh_statemach_act()
2087 data->req.bytecount += sshc->readdir_currLen; in ssh_statemach_act()
2089 Curl_safefree(sshc->readdir_line); in ssh_statemach_act()
2098 if(libssh2_sftp_closedir(sshc->sftp_handle) == in ssh_statemach_act()
2103 sshc->sftp_handle = NULL; in ssh_statemach_act()
2104 Curl_safefree(sshc->readdir_filename); in ssh_statemach_act()
2105 Curl_safefree(sshc->readdir_longentry); in ssh_statemach_act()
2116 sshc->sftp_handle = in ssh_statemach_act()
2117 libssh2_sftp_open_ex(sshc->sftp_session, sftp_scp->path, in ssh_statemach_act()
2121 if(!sshc->sftp_handle) { in ssh_statemach_act()
2122 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
2127 err = sftp_libssh2_last_error(sshc->sftp_session); in ssh_statemach_act()
2132 sshc->actualcode = result?result:CURLE_SSH; in ssh_statemach_act()
2142 rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path, in ssh_statemach_act()
2206 SFTP_SEEK(conn->proto.sshc.sftp_handle, from); in ssh_statemach_act()
2241 SFTP_SEEK(sshc->sftp_handle, data->state.resume_from); in ssh_statemach_act()
2267 sshc->actualcode = result; in ssh_statemach_act()
2275 if(sshc->sftp_handle) { in ssh_statemach_act()
2276 rc = libssh2_sftp_close(sshc->sftp_handle); in ssh_statemach_act()
2282 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2286 sshc->sftp_handle = NULL; in ssh_statemach_act()
2296 if(sshc->nextstate != SSH_NO_STATE && in ssh_statemach_act()
2297 sshc->nextstate != SSH_SFTP_CLOSE) { in ssh_statemach_act()
2298 state(conn, sshc->nextstate); in ssh_statemach_act()
2299 sshc->nextstate = SSH_SFTP_CLOSE; in ssh_statemach_act()
2303 result = sshc->actualcode; in ssh_statemach_act()
2312 if(sshc->sftp_handle) { in ssh_statemach_act()
2313 rc = libssh2_sftp_close(sshc->sftp_handle); in ssh_statemach_act()
2319 (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, in ssh_statemach_act()
2323 sshc->sftp_handle = NULL; in ssh_statemach_act()
2325 if(sshc->sftp_session) { in ssh_statemach_act()
2326 rc = libssh2_sftp_shutdown(sshc->sftp_session); in ssh_statemach_act()
2333 sshc->sftp_session = NULL; in ssh_statemach_act()
2336 Curl_safefree(sshc->homedir); in ssh_statemach_act()
2343 result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path); in ssh_statemach_act()
2345 sshc->actualcode = result; in ssh_statemach_act()
2353 sshc->actualcode = CURLE_UPLOAD_FAILED; in ssh_statemach_act()
2371 sshc->ssh_channel = in ssh_statemach_act()
2372 SCP_SEND(sshc->ssh_session, sftp_scp->path, data->set.new_file_perms, in ssh_statemach_act()
2374 if(!sshc->ssh_channel) { in ssh_statemach_act()
2378 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
2384 ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2388 sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err); in ssh_statemach_act()
2390 if(sshc->actualcode == CURLE_SSH || in ssh_statemach_act()
2391 sshc->actualcode == CURLE_REMOTE_FILE_NOT_FOUND) in ssh_statemach_act()
2392 sshc->actualcode = CURLE_UPLOAD_FAILED; in ssh_statemach_act()
2404 sshc->actualcode = result; in ssh_statemach_act()
2409 sshc->orig_waitfor = data->req.keepon; in ssh_statemach_act()
2437 sshc->ssh_channel = libssh2_scp_recv(sshc->ssh_session, in ssh_statemach_act()
2442 sshc->ssh_channel = libssh2_scp_recv2(sshc->ssh_session, in ssh_statemach_act()
2446 if(!sshc->ssh_channel) { in ssh_statemach_act()
2450 if(libssh2_session_last_errno(sshc->ssh_session) == in ssh_statemach_act()
2457 ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2461 sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err); in ssh_statemach_act()
2480 sshc->actualcode = result; in ssh_statemach_act()
2495 if(sshc->ssh_channel) { in ssh_statemach_act()
2496 rc = libssh2_channel_send_eof(sshc->ssh_channel); in ssh_statemach_act()
2502 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2512 if(sshc->ssh_channel) { in ssh_statemach_act()
2513 rc = libssh2_channel_wait_eof(sshc->ssh_channel); in ssh_statemach_act()
2519 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2528 if(sshc->ssh_channel) { in ssh_statemach_act()
2529 rc = libssh2_channel_wait_closed(sshc->ssh_channel); in ssh_statemach_act()
2535 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2544 if(sshc->ssh_channel) { in ssh_statemach_act()
2545 rc = libssh2_channel_free(sshc->ssh_channel); in ssh_statemach_act()
2551 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2556 sshc->ssh_channel = NULL; in ssh_statemach_act()
2563 result = sshc->actualcode; in ssh_statemach_act()
2570 if(sshc->ssh_channel) { in ssh_statemach_act()
2571 rc = libssh2_channel_free(sshc->ssh_channel); in ssh_statemach_act()
2577 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2582 sshc->ssh_channel = NULL; in ssh_statemach_act()
2585 if(sshc->ssh_session) { in ssh_statemach_act()
2586 rc = libssh2_session_disconnect(sshc->ssh_session, "Shutdown"); in ssh_statemach_act()
2592 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2599 Curl_safefree(sshc->homedir); in ssh_statemach_act()
2607 if(sshc->kh) { in ssh_statemach_act()
2608 libssh2_knownhost_free(sshc->kh); in ssh_statemach_act()
2609 sshc->kh = NULL; in ssh_statemach_act()
2614 if(sshc->ssh_agent) { in ssh_statemach_act()
2615 rc = libssh2_agent_disconnect(sshc->ssh_agent); in ssh_statemach_act()
2621 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2626 libssh2_agent_free(sshc->ssh_agent); in ssh_statemach_act()
2627 sshc->ssh_agent = NULL; in ssh_statemach_act()
2631 sshc->sshagent_identity = NULL; in ssh_statemach_act()
2632 sshc->sshagent_prev_identity = NULL; in ssh_statemach_act()
2636 if(sshc->ssh_session) { in ssh_statemach_act()
2637 rc = libssh2_session_free(sshc->ssh_session); in ssh_statemach_act()
2643 (void)libssh2_session_last_error(sshc->ssh_session, in ssh_statemach_act()
2647 sshc->ssh_session = NULL; in ssh_statemach_act()
2652 DEBUGASSERT(sshc->ssh_session == NULL); in ssh_statemach_act()
2653 DEBUGASSERT(sshc->ssh_channel == NULL); in ssh_statemach_act()
2654 DEBUGASSERT(sshc->sftp_session == NULL); in ssh_statemach_act()
2655 DEBUGASSERT(sshc->sftp_handle == NULL); in ssh_statemach_act()
2657 DEBUGASSERT(sshc->kh == NULL); in ssh_statemach_act()
2660 DEBUGASSERT(sshc->ssh_agent == NULL); in ssh_statemach_act()
2663 Curl_safefree(sshc->rsa_pub); in ssh_statemach_act()
2664 Curl_safefree(sshc->rsa); in ssh_statemach_act()
2666 Curl_safefree(sshc->quote_path1); in ssh_statemach_act()
2667 Curl_safefree(sshc->quote_path2); in ssh_statemach_act()
2669 Curl_safefree(sshc->homedir); in ssh_statemach_act()
2671 Curl_safefree(sshc->readdir_filename); in ssh_statemach_act()
2672 Curl_safefree(sshc->readdir_longentry); in ssh_statemach_act()
2673 Curl_safefree(sshc->readdir_line); in ssh_statemach_act()
2674 Curl_safefree(sshc->readdir_linkPath); in ssh_statemach_act()
2677 result = sshc->actualcode; in ssh_statemach_act()
2679 memset(sshc, 0, sizeof(struct ssh_conn)); in ssh_statemach_act()
2682 sshc->state = SSH_SESSION_FREE; /* current */ in ssh_statemach_act()
2683 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
2691 sshc->nextstate = SSH_NO_STATE; in ssh_statemach_act()
2696 } while(!rc && (sshc->state != SSH_STOP)); in ssh_statemach_act()
2765 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_block2waitfor() local
2768 dir = libssh2_session_block_directions(sshc->ssh_session); in ssh_block2waitfor()
2778 conn->waitfor = sshc->orig_waitfor; in ssh_block2waitfor()
2788 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_multi_statemach() local
2794 *done = (sshc->state == SSH_STOP) ? TRUE : FALSE; in ssh_multi_statemach()
2806 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_block_statemach() local
2810 while((sshc->state != SSH_STOP) && !result) { in ssh_block_statemach()
2836 int dir = libssh2_session_block_directions(sshc->ssh_session); in ssh_block_statemach()
2901 ssh = &conn->proto.sshc; in ssh_connect()
3017 struct ssh_conn *sshc = &conn->proto.sshc; in ssh_do() local
3023 sshc->actualcode = CURLE_OK; /* reset error code */ in ssh_do()
3024 sshc->secondCreateDirs = 0; /* reset the create dir attempt state in ssh_do()
3046 struct ssh_conn *ssh = &conn->proto.sshc; in scp_disconnect()
3109 libssh2_channel_write(conn->proto.sshc.ssh_channel, mem, len); in scp_send()
3133 libssh2_channel_read(conn->proto.sshc.ssh_channel, mem, len); in scp_recv()
3205 if(conn->proto.sshc.ssh_session) { in sftp_disconnect()
3220 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_done() local
3227 sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT; in sftp_done()
3242 nwrite = libssh2_sftp_write(conn->proto.sshc.sftp_handle, mem, len); in sftp_send()
3268 nread = libssh2_sftp_read(conn->proto.sshc.sftp_handle, mem, len); in sftp_recv()