Lines Matching +full:- +full:- +full:with +full:- +full:libssh
24 * SPDX-License-Identifier: curl
89 /* A recent macro provided by libssh. Or make our own. */
241 struct connectdata *conn = data->conn; in mystate()
242 struct ssh_conn *sshc = &conn->proto.sshc; in mystate()
309 if(sshc->state != nowstate) { in mystate()
311 (void *) sshc, names[sshc->state], names[nowstate], in mystate()
316 sshc->state = nowstate; in mystate()
320 * 1. data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5] is set with an MD5
322 * 2. data->set.ssh_keyfunc callback is set. Then we do trust on first
332 struct connectdata *conn = data->conn; in myssh_is_known()
333 struct ssh_conn *sshc = &conn->proto.sshc; in myssh_is_known()
344 data->set.ssh_keyfunc; in myssh_is_known()
352 rc = ssh_get_server_publickey(sshc->ssh_session, &pubkey); in myssh_is_known()
354 rc = ssh_get_publickey(sshc->ssh_session, &pubkey); in myssh_is_known()
359 if(data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) { in myssh_is_known()
362 const char *pubkey_md5 = data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]; in myssh_is_known()
389 if(data->set.str[STRING_SSH_KNOWNHOSTS]) { in myssh_is_known()
393 vstate = ssh_session_get_known_hosts_entry(sshc->ssh_session, in myssh_is_known()
398 if(knownhostsentry->publickey) { in myssh_is_known()
399 rc = ssh_pki_export_pubkey_base64(knownhostsentry->publickey, in myssh_is_known()
407 switch(ssh_key_type(knownhostsentry->publickey)) { in myssh_is_known()
450 vstate = ssh_is_server_known(sshc->ssh_session); in myssh_is_known()
504 keymatch, data->set.ssh_keyfunc_userp); in myssh_is_known()
510 rc = ssh_session_update_known_hosts(sshc->ssh_session); in myssh_is_known()
512 rc = ssh_write_knownhost(sshc->ssh_session); in myssh_is_known()
554 sshc->actualcode = _r; \
560 sshc->actualcode = \
561 sftp_error_to_CURLE(sftp_get_error(sshc->sftp_session)); \
566 if(sshc->auth_methods & SSH_AUTH_METHOD_PASSWORD) { \
576 if(sshc->auth_methods & SSH_AUTH_METHOD_INTERACTIVE) { \
586 if(sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC) { \
599 struct ssh_conn *sshc = &conn->proto.sshc; in myssh_auth_interactive()
603 switch(sshc->kbd_state) { in myssh_auth_interactive()
605 rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); in myssh_auth_interactive()
612 nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session); in myssh_auth_interactive()
616 rc = ssh_userauth_kbdint_setanswer(sshc->ssh_session, 0, conn->passwd); in myssh_auth_interactive()
622 sshc->kbd_state = 1; in myssh_auth_interactive()
624 rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); in myssh_auth_interactive()
630 nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session); in myssh_auth_interactive()
634 sshc->kbd_state = 2; in myssh_auth_interactive()
641 sshc->kbd_state = 2; in myssh_auth_interactive()
643 rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); in myssh_auth_interactive()
656 sshc->kbd_state = 0; in myssh_auth_interactive()
663 * to will be set to TRUE if the libssh function returns SSH_AGAIN
669 struct connectdata *conn = data->conn; in myssh_statemach_act()
670 struct SSHPROTO *protop = data->req.p.ssh; in myssh_statemach_act()
671 struct ssh_conn *sshc = &conn->proto.sshc; in myssh_statemach_act()
672 curl_socket_t sock = conn->sock[FIRSTSOCKET]; in myssh_statemach_act()
680 switch(sshc->state) { in myssh_statemach_act()
682 sshc->secondCreateDirs = 0; in myssh_statemach_act()
683 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
684 sshc->actualcode = CURLE_OK; in myssh_statemach_act()
690 /* Set libssh to non-blocking, since everything internally is in myssh_statemach_act()
691 non-blocking */ in myssh_statemach_act()
692 ssh_set_blocking(sshc->ssh_session, 0); in myssh_statemach_act()
698 rc = ssh_connect(sshc->ssh_session); in myssh_statemach_act()
702 DEBUGF(infof(data, "ssh_connect -> EAGAIN")); in myssh_statemach_act()
726 sshc->authed = FALSE; in myssh_statemach_act()
728 rc = ssh_userauth_none(sshc->ssh_session, NULL); in myssh_statemach_act()
735 sshc->authed = TRUE; in myssh_statemach_act()
736 infof(data, "Authenticated with none"); in myssh_statemach_act()
745 sshc->auth_methods = in myssh_statemach_act()
746 (unsigned int)ssh_userauth_list(sshc->ssh_session, NULL); in myssh_statemach_act()
747 if(sshc->auth_methods) in myssh_statemach_act()
749 sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY ? in myssh_statemach_act()
751 sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC ? in myssh_statemach_act()
753 sshc->auth_methods & SSH_AUTH_METHOD_INTERACTIVE ? in myssh_statemach_act()
754 "keyboard-interactive, " : "", in myssh_statemach_act()
755 sshc->auth_methods & SSH_AUTH_METHOD_PASSWORD ? in myssh_statemach_act()
757 if(sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY) { in myssh_statemach_act()
761 else if(sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC) { in myssh_statemach_act()
764 else if(sshc->auth_methods & SSH_AUTH_METHOD_INTERACTIVE) { in myssh_statemach_act()
767 else if(sshc->auth_methods & SSH_AUTH_METHOD_PASSWORD) { in myssh_statemach_act()
778 if(!(data->set.ssh_auth_types & CURLSSH_AUTH_PUBLICKEY)) { in myssh_statemach_act()
785 if(data->set.str[STRING_SSH_PRIVATE_KEY]) { in myssh_statemach_act()
786 if(sshc->pubkey && !data->set.ssl.key_passwd) { in myssh_statemach_act()
787 rc = ssh_userauth_try_publickey(sshc->ssh_session, NULL, in myssh_statemach_act()
788 sshc->pubkey); in myssh_statemach_act()
800 rc = ssh_pki_import_privkey_file(data-> in myssh_statemach_act()
802 data->set.ssl.key_passwd, NULL, in myssh_statemach_act()
803 NULL, &sshc->privkey); in myssh_statemach_act()
806 data->set.str[STRING_SSH_PRIVATE_KEY]); in myssh_statemach_act()
816 rc = ssh_userauth_publickey_auto(sshc->ssh_session, NULL, in myssh_statemach_act()
817 data->set.ssl.key_passwd); in myssh_statemach_act()
824 sshc->authed = TRUE; in myssh_statemach_act()
834 rc = ssh_userauth_publickey(sshc->ssh_session, NULL, sshc->privkey); in myssh_statemach_act()
841 sshc->authed = TRUE; in myssh_statemach_act()
853 if(!(data->set.ssh_auth_types & CURLSSH_AUTH_GSSAPI)) { in myssh_statemach_act()
858 rc = ssh_userauth_gssapi(sshc->ssh_session); in myssh_statemach_act()
866 sshc->authed = TRUE; in myssh_statemach_act()
876 if(data->set.ssh_auth_types & CURLSSH_AUTH_KEYBOARD) { in myssh_statemach_act()
885 /* keyboard-interactive authentication */ in myssh_statemach_act()
891 sshc->authed = TRUE; in myssh_statemach_act()
901 if(!(data->set.ssh_auth_types & CURLSSH_AUTH_PASSWORD)) { in myssh_statemach_act()
909 rc = ssh_userauth_password(sshc->ssh_session, NULL, conn->passwd); in myssh_statemach_act()
916 sshc->authed = TRUE; in myssh_statemach_act()
926 if(!sshc->authed) { in myssh_statemach_act()
939 conn->sockfd = sock; in myssh_statemach_act()
940 conn->writesockfd = CURL_SOCKET_BAD; in myssh_statemach_act()
942 if(conn->handler->protocol == CURLPROTO_SFTP) { in myssh_statemach_act()
951 ssh_set_blocking(sshc->ssh_session, 1); in myssh_statemach_act()
953 sshc->sftp_session = sftp_new(sshc->ssh_session); in myssh_statemach_act()
954 if(!sshc->sftp_session) { in myssh_statemach_act()
956 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
961 rc = sftp_init(sshc->sftp_session); in myssh_statemach_act()
964 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
974 sshc->homedir = sftp_canonicalize_path(sshc->sftp_session, "."); in myssh_statemach_act()
975 if(!sshc->homedir) { in myssh_statemach_act()
979 data->state.most_recent_ftp_entrypath = sshc->homedir; in myssh_statemach_act()
990 result = Curl_getworkingpath(data, sshc->homedir, &protop->path); in myssh_statemach_act()
992 sshc->actualcode = result; in myssh_statemach_act()
997 if(data->set.quote) { in myssh_statemach_act()
999 sshc->quote_item = data->set.quote; in myssh_statemach_act()
1008 if(data->set.postquote) { in myssh_statemach_act()
1010 sshc->quote_item = data->set.postquote; in myssh_statemach_act()
1024 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
1025 Curl_safefree(sshc->quote_path2); in myssh_statemach_act()
1027 sshc->quote_item = sshc->quote_item->next; in myssh_statemach_act()
1029 if(sshc->quote_item) { in myssh_statemach_act()
1033 if(sshc->nextstate != SSH_NO_STATE) { in myssh_statemach_act()
1034 state(data, sshc->nextstate); in myssh_statemach_act()
1035 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1048 rc = sftp_setstat(sshc->sftp_session, sshc->quote_path2, in myssh_statemach_act()
1049 sshc->quote_attrs); in myssh_statemach_act()
1050 if(rc && !sshc->acceptfail) { in myssh_statemach_act()
1051 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
1052 Curl_safefree(sshc->quote_path2); in myssh_statemach_act()
1054 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1056 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1057 sshc->actualcode = CURLE_QUOTE_ERROR; in myssh_statemach_act()
1058 /* sshc->actualcode = sftp_error_to_CURLE(err); in myssh_statemach_act()
1067 rc = sftp_symlink(sshc->sftp_session, sshc->quote_path2, in myssh_statemach_act()
1068 sshc->quote_path1); in myssh_statemach_act()
1069 if(rc && !sshc->acceptfail) { in myssh_statemach_act()
1070 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
1071 Curl_safefree(sshc->quote_path2); in myssh_statemach_act()
1073 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1075 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1076 sshc->actualcode = CURLE_QUOTE_ERROR; in myssh_statemach_act()
1083 rc = sftp_mkdir(sshc->sftp_session, sshc->quote_path1, in myssh_statemach_act()
1084 (mode_t)data->set.new_directory_perms); in myssh_statemach_act()
1085 if(rc && !sshc->acceptfail) { in myssh_statemach_act()
1086 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
1088 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1090 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1091 sshc->actualcode = CURLE_QUOTE_ERROR; in myssh_statemach_act()
1098 rc = sftp_rename(sshc->sftp_session, sshc->quote_path1, in myssh_statemach_act()
1099 sshc->quote_path2); in myssh_statemach_act()
1100 if(rc && !sshc->acceptfail) { in myssh_statemach_act()
1101 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
1102 Curl_safefree(sshc->quote_path2); in myssh_statemach_act()
1104 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1106 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1107 sshc->actualcode = CURLE_QUOTE_ERROR; in myssh_statemach_act()
1114 rc = sftp_rmdir(sshc->sftp_session, sshc->quote_path1); in myssh_statemach_act()
1115 if(rc && !sshc->acceptfail) { in myssh_statemach_act()
1116 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
1118 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1120 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1121 sshc->actualcode = CURLE_QUOTE_ERROR; in myssh_statemach_act()
1128 rc = sftp_unlink(sshc->sftp_session, sshc->quote_path1); in myssh_statemach_act()
1129 if(rc && !sshc->acceptfail) { in myssh_statemach_act()
1130 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
1132 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1134 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1135 sshc->actualcode = CURLE_QUOTE_ERROR; in myssh_statemach_act()
1145 statvfs = sftp_statvfs(sshc->sftp_session, sshc->quote_path1); in myssh_statemach_act()
1146 if(!statvfs && !sshc->acceptfail) { in myssh_statemach_act()
1147 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
1149 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1151 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1152 sshc->actualcode = CURLE_QUOTE_ERROR; in myssh_statemach_act()
1173 statvfs->f_bsize, statvfs->f_frsize, in myssh_statemach_act()
1174 statvfs->f_blocks, statvfs->f_bfree, in myssh_statemach_act()
1175 statvfs->f_bavail, statvfs->f_files, in myssh_statemach_act()
1176 statvfs->f_ffree, statvfs->f_favail, in myssh_statemach_act()
1177 statvfs->f_fsid, statvfs->f_flag, in myssh_statemach_act()
1178 statvfs->f_namemax); in myssh_statemach_act()
1184 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1192 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
1193 sshc->actualcode = result; in myssh_statemach_act()
1201 if(data->set.get_filetime) { in myssh_statemach_act()
1213 attrs = sftp_stat(sshc->sftp_session, protop->path); in myssh_statemach_act()
1215 data->info.filetime = attrs->mtime; in myssh_statemach_act()
1224 if(data->state.upload) in myssh_statemach_act()
1227 if(protop->path[strlen(protop->path)-1] == '/') in myssh_statemach_act()
1238 if(data->state.resume_from) { in myssh_statemach_act()
1241 if(data->state.resume_from < 0) { in myssh_statemach_act()
1242 attrs = sftp_stat(sshc->sftp_session, protop->path); in myssh_statemach_act()
1244 curl_off_t size = attrs->size; in myssh_statemach_act()
1250 data->state.resume_from = attrs->size; in myssh_statemach_act()
1255 data->state.resume_from = 0; in myssh_statemach_act()
1260 if(data->set.remote_append) in myssh_statemach_act()
1263 else if(data->state.resume_from > 0) in myssh_statemach_act()
1270 if(sshc->sftp_file) in myssh_statemach_act()
1271 sftp_close(sshc->sftp_file); in myssh_statemach_act()
1272 sshc->sftp_file = in myssh_statemach_act()
1273 sftp_open(sshc->sftp_session, protop->path, in myssh_statemach_act()
1274 flags, (mode_t)data->set.new_file_perms); in myssh_statemach_act()
1275 if(!sshc->sftp_file) { in myssh_statemach_act()
1276 err = sftp_get_error(sshc->sftp_session); in myssh_statemach_act()
1280 (data->set.ftp_create_missing_dirs && in myssh_statemach_act()
1281 (strlen(protop->path) > 1))) { in myssh_statemach_act()
1284 sshc->secondCreateDirs = 1; in myssh_statemach_act()
1296 if(data->state.resume_from > 0) { in myssh_statemach_act()
1298 if(data->set.seek_func) { in myssh_statemach_act()
1300 seekerr = data->set.seek_func(data->set.seek_client, in myssh_statemach_act()
1301 data->state.resume_from, SEEK_SET); in myssh_statemach_act()
1316 (data->state.resume_from - passed > in myssh_statemach_act()
1318 sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); in myssh_statemach_act()
1321 data->state.fread_func(scratch, 1, in myssh_statemach_act()
1322 readthisamountnow, data->state.in); in myssh_statemach_act()
1326 /* this checks for greater-than only to make sure that the in myssh_statemach_act()
1332 } while(passed < data->state.resume_from); in myssh_statemach_act()
1338 if(data->state.infilesize > 0) { in myssh_statemach_act()
1339 data->state.infilesize -= data->state.resume_from; in myssh_statemach_act()
1340 data->req.size = data->state.infilesize; in myssh_statemach_act()
1341 Curl_pgrsSetUploadSize(data, data->state.infilesize); in myssh_statemach_act()
1344 rc = sftp_seek64(sshc->sftp_file, data->state.resume_from); in myssh_statemach_act()
1350 if(data->state.infilesize > 0) { in myssh_statemach_act()
1351 data->req.size = data->state.infilesize; in myssh_statemach_act()
1352 Curl_pgrsSetUploadSize(data, data->state.infilesize); in myssh_statemach_act()
1355 Curl_xfer_setup1(data, CURL_XFER_SEND, -1, FALSE); in myssh_statemach_act()
1358 conn->sockfd = conn->writesockfd; in myssh_statemach_act()
1362 sshc->orig_waitfor = data->req.keepon; in myssh_statemach_act()
1365 out readable as the underlying libssh sftp send function will deal in myssh_statemach_act()
1366 with both accordingly */ in myssh_statemach_act()
1367 data->state.select_bits = CURL_CSELECT_OUT; in myssh_statemach_act()
1374 sshc->sftp_send_state = 0; in myssh_statemach_act()
1381 if(strlen(protop->path) > 1) { in myssh_statemach_act()
1382 sshc->slash_pos = protop->path + 1; /* ignore the leading '/' */ in myssh_statemach_act()
1391 sshc->slash_pos = strchr(sshc->slash_pos, '/'); in myssh_statemach_act()
1392 if(sshc->slash_pos) { in myssh_statemach_act()
1393 *sshc->slash_pos = 0; in myssh_statemach_act()
1395 infof(data, "Creating directory '%s'", protop->path); in myssh_statemach_act()
1403 /* 'mode' - parameter is preliminary - default to 0644 */ in myssh_statemach_act()
1404 rc = sftp_mkdir(sshc->sftp_session, protop->path, in myssh_statemach_act()
1405 (mode_t)data->set.new_directory_perms); in myssh_statemach_act()
1406 *sshc->slash_pos = '/'; in myssh_statemach_act()
1407 ++sshc->slash_pos; in myssh_statemach_act()
1412 * path) - retry on unspecific FAILURE also in myssh_statemach_act()
1414 err = sftp_get_error(sshc->sftp_session); in myssh_statemach_act()
1427 Curl_pgrsSetDownloadSize(data, -1); in myssh_statemach_act()
1428 if(data->req.no_body) { in myssh_statemach_act()
1437 sshc->sftp_dir = sftp_opendir(sshc->sftp_session, in myssh_statemach_act()
1438 protop->path); in myssh_statemach_act()
1439 if(!sshc->sftp_dir) { in myssh_statemach_act()
1441 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1449 Curl_dyn_reset(&sshc->readdir_buf); in myssh_statemach_act()
1450 if(sshc->readdir_attrs) in myssh_statemach_act()
1451 sftp_attributes_free(sshc->readdir_attrs); in myssh_statemach_act()
1453 sshc->readdir_attrs = sftp_readdir(sshc->sftp_session, sshc->sftp_dir); in myssh_statemach_act()
1454 if(sshc->readdir_attrs) { in myssh_statemach_act()
1455 sshc->readdir_filename = sshc->readdir_attrs->name; in myssh_statemach_act()
1456 sshc->readdir_longentry = sshc->readdir_attrs->longname; in myssh_statemach_act()
1457 sshc->readdir_len = strlen(sshc->readdir_filename); in myssh_statemach_act()
1459 if(data->set.list_only) { in myssh_statemach_act()
1462 tmpLine = aprintf("%s\n", sshc->readdir_filename); in myssh_statemach_act()
1465 sshc->actualcode = CURLE_OUT_OF_MEMORY; in myssh_statemach_act()
1469 tmpLine, sshc->readdir_len + 1); in myssh_statemach_act()
1479 if(Curl_dyn_add(&sshc->readdir_buf, sshc->readdir_longentry)) { in myssh_statemach_act()
1480 sshc->actualcode = CURLE_OUT_OF_MEMORY; in myssh_statemach_act()
1485 if((sshc->readdir_attrs->flags & SSH_FILEXFER_ATTR_PERMISSIONS) && in myssh_statemach_act()
1486 ((sshc->readdir_attrs->permissions & SSH_S_IFMT) == in myssh_statemach_act()
1488 sshc->readdir_linkPath = aprintf("%s%s", protop->path, in myssh_statemach_act()
1489 sshc->readdir_filename); in myssh_statemach_act()
1491 if(!sshc->readdir_linkPath) { in myssh_statemach_act()
1493 sshc->actualcode = CURLE_OUT_OF_MEMORY; in myssh_statemach_act()
1504 else if(sftp_dir_eof(sshc->sftp_dir)) { in myssh_statemach_act()
1510 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1517 if(sshc->readdir_link_attrs) in myssh_statemach_act()
1518 sftp_attributes_free(sshc->readdir_link_attrs); in myssh_statemach_act()
1520 sshc->readdir_link_attrs = sftp_lstat(sshc->sftp_session, in myssh_statemach_act()
1521 sshc->readdir_linkPath); in myssh_statemach_act()
1522 if(sshc->readdir_link_attrs == 0) { in myssh_statemach_act()
1524 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1529 if(!sshc->readdir_link_attrs->name) { in myssh_statemach_act()
1530 sshc->readdir_tmp = sftp_readlink(sshc->sftp_session, in myssh_statemach_act()
1531 sshc->readdir_linkPath); in myssh_statemach_act()
1532 if(!sshc->readdir_filename) in myssh_statemach_act()
1533 sshc->readdir_len = 0; in myssh_statemach_act()
1535 sshc->readdir_len = strlen(sshc->readdir_tmp); in myssh_statemach_act()
1536 sshc->readdir_longentry = NULL; in myssh_statemach_act()
1537 sshc->readdir_filename = sshc->readdir_tmp; in myssh_statemach_act()
1540 sshc->readdir_len = strlen(sshc->readdir_link_attrs->name); in myssh_statemach_act()
1541 sshc->readdir_filename = sshc->readdir_link_attrs->name; in myssh_statemach_act()
1542 sshc->readdir_longentry = sshc->readdir_link_attrs->longname; in myssh_statemach_act()
1545 Curl_safefree(sshc->readdir_linkPath); in myssh_statemach_act()
1547 if(Curl_dyn_addf(&sshc->readdir_buf, " -> %s", in myssh_statemach_act()
1548 sshc->readdir_filename)) { in myssh_statemach_act()
1549 sshc->actualcode = CURLE_OUT_OF_MEMORY; in myssh_statemach_act()
1553 sftp_attributes_free(sshc->readdir_link_attrs); in myssh_statemach_act()
1554 sshc->readdir_link_attrs = NULL; in myssh_statemach_act()
1555 sshc->readdir_filename = NULL; in myssh_statemach_act()
1556 sshc->readdir_longentry = NULL; in myssh_statemach_act()
1561 if(Curl_dyn_addn(&sshc->readdir_buf, "\n", 1)) in myssh_statemach_act()
1565 Curl_dyn_ptr(&sshc->readdir_buf), in myssh_statemach_act()
1566 Curl_dyn_len(&sshc->readdir_buf)); in myssh_statemach_act()
1568 ssh_string_free_char(sshc->readdir_tmp); in myssh_statemach_act()
1569 sshc->readdir_tmp = NULL; in myssh_statemach_act()
1579 sftp_closedir(sshc->sftp_dir); in myssh_statemach_act()
1580 sshc->sftp_dir = NULL; in myssh_statemach_act()
1591 if(sshc->sftp_file) in myssh_statemach_act()
1592 sftp_close(sshc->sftp_file); in myssh_statemach_act()
1594 sshc->sftp_file = sftp_open(sshc->sftp_session, protop->path, in myssh_statemach_act()
1595 O_RDONLY, (mode_t)data->set.new_file_perms); in myssh_statemach_act()
1596 if(!sshc->sftp_file) { in myssh_statemach_act()
1598 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1603 sftp_file_set_nonblocking(sshc->sftp_file); in myssh_statemach_act()
1612 attrs = sftp_fstat(sshc->sftp_file); in myssh_statemach_act()
1614 !(attrs->flags & SSH_FILEXFER_ATTR_SIZE) || in myssh_statemach_act()
1615 (attrs->size == 0)) { in myssh_statemach_act()
1619 * OR the server does not return a file size with a stat() in myssh_statemach_act()
1622 data->req.size = -1; in myssh_statemach_act()
1623 data->req.maxdownload = -1; in myssh_statemach_act()
1624 Curl_pgrsSetDownloadSize(data, -1); in myssh_statemach_act()
1628 size = attrs->size; in myssh_statemach_act()
1636 if(data->state.use_range) { in myssh_statemach_act()
1643 from_t = curlx_strtoofft(data->state.range, &ptr, 10, &from); in myssh_statemach_act()
1647 while(*ptr && (ISBLANK(*ptr) || (*ptr == '-'))) in myssh_statemach_act()
1655 to = size - 1; in myssh_statemach_act()
1659 from = size - to; in myssh_statemach_act()
1660 to = size - 1; in myssh_statemach_act()
1672 if((to - from) == CURL_OFF_T_MAX) in myssh_statemach_act()
1674 size = to - from + 1; in myssh_statemach_act()
1677 rc = sftp_seek64(sshc->sftp_file, from); in myssh_statemach_act()
1683 data->req.size = size; in myssh_statemach_act()
1684 data->req.maxdownload = size; in myssh_statemach_act()
1689 if(data->state.resume_from) { in myssh_statemach_act()
1690 if(data->state.resume_from < 0) { in myssh_statemach_act()
1692 if((curl_off_t)size < -data->state.resume_from) { in myssh_statemach_act()
1694 FMT_OFF_T ")", data->state.resume_from, size); in myssh_statemach_act()
1698 data->state.resume_from += size; in myssh_statemach_act()
1701 if((curl_off_t)size < data->state.resume_from) { in myssh_statemach_act()
1704 data->state.resume_from, size); in myssh_statemach_act()
1709 data->req.size = size - data->state.resume_from; in myssh_statemach_act()
1710 data->req.maxdownload = size - data->state.resume_from; in myssh_statemach_act()
1712 size - data->state.resume_from); in myssh_statemach_act()
1714 rc = sftp_seek64(sshc->sftp_file, data->state.resume_from); in myssh_statemach_act()
1723 if(data->req.size == 0) { in myssh_statemach_act()
1730 Curl_xfer_setup1(data, CURL_XFER_RECV, data->req.size, FALSE); in myssh_statemach_act()
1733 conn->writesockfd = conn->sockfd; in myssh_statemach_act()
1736 out writableable as the underlying libssh recv function will deal in myssh_statemach_act()
1737 with both accordingly */ in myssh_statemach_act()
1738 data->state.select_bits = CURL_CSELECT_IN; in myssh_statemach_act()
1744 sshc->actualcode = result; in myssh_statemach_act()
1747 sshc->sftp_recv_state = 0; in myssh_statemach_act()
1753 if(sshc->sftp_file) { in myssh_statemach_act()
1754 sftp_close(sshc->sftp_file); in myssh_statemach_act()
1755 sshc->sftp_file = NULL; in myssh_statemach_act()
1757 Curl_safefree(protop->path); in myssh_statemach_act()
1764 if(sshc->nextstate != SSH_NO_STATE && in myssh_statemach_act()
1765 sshc->nextstate != SSH_SFTP_CLOSE) { in myssh_statemach_act()
1766 state(data, sshc->nextstate); in myssh_statemach_act()
1767 sshc->nextstate = SSH_SFTP_CLOSE; in myssh_statemach_act()
1771 result = sshc->actualcode; in myssh_statemach_act()
1779 ssh_set_blocking(sshc->ssh_session, 0); in myssh_statemach_act()
1781 if(sshc->sftp_aio) { in myssh_statemach_act()
1782 sftp_aio_free(sshc->sftp_aio); in myssh_statemach_act()
1783 sshc->sftp_aio = NULL; in myssh_statemach_act()
1787 if(sshc->sftp_file) { in myssh_statemach_act()
1788 sftp_close(sshc->sftp_file); in myssh_statemach_act()
1789 sshc->sftp_file = NULL; in myssh_statemach_act()
1792 if(sshc->sftp_session) { in myssh_statemach_act()
1793 sftp_free(sshc->sftp_session); in myssh_statemach_act()
1794 sshc->sftp_session = NULL; in myssh_statemach_act()
1797 SSH_STRING_FREE_CHAR(sshc->homedir); in myssh_statemach_act()
1798 data->state.most_recent_ftp_entrypath = NULL; in myssh_statemach_act()
1804 result = Curl_getworkingpath(data, sshc->homedir, &protop->path); in myssh_statemach_act()
1806 sshc->actualcode = result; in myssh_statemach_act()
1812 ssh_set_blocking(sshc->ssh_session, 1); in myssh_statemach_act()
1814 if(data->state.upload) { in myssh_statemach_act()
1815 if(data->state.infilesize < 0) { in myssh_statemach_act()
1817 sshc->actualcode = CURLE_UPLOAD_FAILED; in myssh_statemach_act()
1822 sshc->scp_session = in myssh_statemach_act()
1823 ssh_scp_new(sshc->ssh_session, SSH_SCP_WRITE, protop->path); in myssh_statemach_act()
1827 sshc->scp_session = in myssh_statemach_act()
1828 ssh_scp_new(sshc->ssh_session, SSH_SCP_READ, protop->path); in myssh_statemach_act()
1832 if(!sshc->scp_session) { in myssh_statemach_act()
1833 err_msg = ssh_get_error(sshc->ssh_session); in myssh_statemach_act()
1842 rc = ssh_scp_init(sshc->scp_session); in myssh_statemach_act()
1844 err_msg = ssh_get_error(sshc->ssh_session); in myssh_statemach_act()
1850 rc = ssh_scp_push_file(sshc->scp_session, protop->path, in myssh_statemach_act()
1851 data->state.infilesize, in myssh_statemach_act()
1852 (int)data->set.new_file_perms); in myssh_statemach_act()
1854 err_msg = ssh_get_error(sshc->ssh_session); in myssh_statemach_act()
1861 Curl_xfer_setup1(data, CURL_XFER_SEND, -1, FALSE); in myssh_statemach_act()
1864 conn->sockfd = conn->writesockfd; in myssh_statemach_act()
1868 sshc->orig_waitfor = data->req.keepon; in myssh_statemach_act()
1871 out readable as the underlying libssh scp send function will deal in myssh_statemach_act()
1872 with both accordingly */ in myssh_statemach_act()
1873 data->state.select_bits = CURL_CSELECT_OUT; in myssh_statemach_act()
1881 rc = ssh_scp_init(sshc->scp_session); in myssh_statemach_act()
1883 err_msg = ssh_get_error(sshc->ssh_session); in myssh_statemach_act()
1894 rc = ssh_scp_pull_request(sshc->scp_session); in myssh_statemach_act()
1896 err_msg = ssh_get_error(sshc->ssh_session); in myssh_statemach_act()
1903 bytecount = ssh_scp_request_get_size(sshc->scp_session); in myssh_statemach_act()
1904 data->req.maxdownload = (curl_off_t) bytecount; in myssh_statemach_act()
1908 conn->writesockfd = conn->sockfd; in myssh_statemach_act()
1911 out writableable as the underlying libssh recv function will deal in myssh_statemach_act()
1912 with both accordingly */ in myssh_statemach_act()
1913 data->state.select_bits = CURL_CSELECT_IN; in myssh_statemach_act()
1919 if(data->state.upload) in myssh_statemach_act()
1926 if(sshc->scp_session) { in myssh_statemach_act()
1927 rc = ssh_scp_close(sshc->scp_session); in myssh_statemach_act()
1935 infof(data, "Failed to close libssh scp channel: %s", in myssh_statemach_act()
1936 ssh_get_error(sshc->ssh_session)); in myssh_statemach_act()
1944 if(sshc->scp_session) { in myssh_statemach_act()
1945 ssh_scp_free(sshc->scp_session); in myssh_statemach_act()
1946 sshc->scp_session = NULL; in myssh_statemach_act()
1950 ssh_set_blocking(sshc->ssh_session, 0); in myssh_statemach_act()
1959 if(sshc->scp_session) { in myssh_statemach_act()
1960 ssh_scp_free(sshc->scp_session); in myssh_statemach_act()
1961 sshc->scp_session = NULL; in myssh_statemach_act()
1964 ssh_disconnect(sshc->ssh_session); in myssh_statemach_act()
1966 /* conn->sock[FIRSTSOCKET] is closed by ssh_disconnect behind our back, in myssh_statemach_act()
1967 tell the connection to forget about it. This libssh in myssh_statemach_act()
1972 SSH_STRING_FREE_CHAR(sshc->homedir); in myssh_statemach_act()
1973 data->state.most_recent_ftp_entrypath = NULL; in myssh_statemach_act()
1978 if(sshc->ssh_session) { in myssh_statemach_act()
1979 ssh_free(sshc->ssh_session); in myssh_statemach_act()
1980 sshc->ssh_session = NULL; in myssh_statemach_act()
1983 /* worst-case scenario cleanup */ in myssh_statemach_act()
1985 DEBUGASSERT(sshc->ssh_session == NULL); in myssh_statemach_act()
1986 DEBUGASSERT(sshc->scp_session == NULL); in myssh_statemach_act()
1988 if(sshc->readdir_tmp) { in myssh_statemach_act()
1989 ssh_string_free_char(sshc->readdir_tmp); in myssh_statemach_act()
1990 sshc->readdir_tmp = NULL; in myssh_statemach_act()
1993 if(sshc->quote_attrs) in myssh_statemach_act()
1994 sftp_attributes_free(sshc->quote_attrs); in myssh_statemach_act()
1996 if(sshc->readdir_attrs) in myssh_statemach_act()
1997 sftp_attributes_free(sshc->readdir_attrs); in myssh_statemach_act()
1999 if(sshc->readdir_link_attrs) in myssh_statemach_act()
2000 sftp_attributes_free(sshc->readdir_link_attrs); in myssh_statemach_act()
2002 if(sshc->privkey) in myssh_statemach_act()
2003 ssh_key_free(sshc->privkey); in myssh_statemach_act()
2004 if(sshc->pubkey) in myssh_statemach_act()
2005 ssh_key_free(sshc->pubkey); in myssh_statemach_act()
2007 Curl_safefree(sshc->rsa_pub); in myssh_statemach_act()
2008 Curl_safefree(sshc->rsa); in myssh_statemach_act()
2009 Curl_safefree(sshc->quote_path1); in myssh_statemach_act()
2010 Curl_safefree(sshc->quote_path2); in myssh_statemach_act()
2011 Curl_dyn_free(&sshc->readdir_buf); in myssh_statemach_act()
2012 Curl_safefree(sshc->readdir_linkPath); in myssh_statemach_act()
2013 SSH_STRING_FREE_CHAR(sshc->homedir); in myssh_statemach_act()
2016 result = sshc->actualcode; in myssh_statemach_act()
2021 sshc->state = SSH_SESSION_FREE; /* current */ in myssh_statemach_act()
2022 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
2029 sshc->nextstate = SSH_NO_STATE; in myssh_statemach_act()
2034 } while(!rc && (sshc->state != SSH_STOP)); in myssh_statemach_act()
2055 sock[0] = conn->sock[FIRSTSOCKET]; in myssh_getsock()
2057 if(conn->waitfor & KEEP_RECV) in myssh_getsock()
2060 if(conn->waitfor & KEEP_SEND) in myssh_getsock()
2063 if(!conn->waitfor) in myssh_getsock()
2066 DEBUGF(infof(data, "ssh_getsock -> %x", bitmap)); in myssh_getsock()
2072 struct ssh_conn *sshc = &conn->proto.sshc; in myssh_block2waitfor()
2076 conn->waitfor = sshc->orig_waitfor; in myssh_block2waitfor()
2079 int dir = ssh_get_poll_flags(sshc->ssh_session); in myssh_block2waitfor()
2080 conn->waitfor = 0; in myssh_block2waitfor()
2081 /* translate the libssh define bits into our own bit defines */ in myssh_block2waitfor()
2083 conn->waitfor |= KEEP_RECV; in myssh_block2waitfor()
2085 conn->waitfor |= KEEP_SEND; in myssh_block2waitfor()
2093 struct connectdata *conn = data->conn; in myssh_multi_statemach()
2094 struct ssh_conn *sshc = &conn->proto.sshc; in myssh_multi_statemach()
2099 *done = (sshc->state == SSH_STOP); in myssh_multi_statemach()
2108 struct connectdata *conn = data->conn; in myssh_block_statemach()
2109 struct ssh_conn *sshc = &conn->proto.sshc; in myssh_block_statemach()
2112 while((sshc->state != SSH_STOP) && !result) { in myssh_block_statemach()
2137 curl_socket_t fd_read = conn->sock[FIRSTSOCKET]; in myssh_block_statemach()
2155 struct ssh_conn *sshc = &conn->proto.sshc; in myssh_setup_connection()
2157 data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); in myssh_setup_connection()
2160 Curl_dyn_init(&sshc->readdir_buf, CURL_PATH_MAX * 2); in myssh_setup_connection()
2170 * do protocol-specific actions at connect-time.
2176 struct connectdata *conn = data->conn; in myssh_connect()
2177 curl_socket_t sock = conn->sock[FIRSTSOCKET]; in myssh_connect()
2180 /* initialize per-handle data if not already */ in myssh_connect()
2181 if(!data->req.p.ssh) in myssh_connect()
2188 if(conn->handler->protocol & CURLPROTO_SCP) { in myssh_connect()
2189 conn->recv[FIRSTSOCKET] = scp_recv; in myssh_connect()
2190 conn->send[FIRSTSOCKET] = scp_send; in myssh_connect()
2193 conn->recv[FIRSTSOCKET] = sftp_recv; in myssh_connect()
2194 conn->send[FIRSTSOCKET] = sftp_send; in myssh_connect()
2197 ssh = &conn->proto.sshc; in myssh_connect()
2199 ssh->ssh_session = ssh_new(); in myssh_connect()
2200 if(!ssh->ssh_session) { in myssh_connect()
2205 if(conn->bits.ipv6_ip) { in myssh_connect()
2207 msnprintf(ipv6, sizeof(ipv6), "[%s]", conn->host.name); in myssh_connect()
2208 rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, ipv6); in myssh_connect()
2211 rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name); in myssh_connect()
2218 rc = ssh_options_parse_config(ssh->ssh_session, NULL); in myssh_connect()
2224 rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_FD, &sock); in myssh_connect()
2230 if(conn->user && conn->user[0] != '\0') { in myssh_connect()
2231 infof(data, "User: %s", conn->user); in myssh_connect()
2232 rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_USER, conn->user); in myssh_connect()
2239 if(data->set.str[STRING_SSH_KNOWNHOSTS]) { in myssh_connect()
2240 infof(data, "Known hosts: %s", data->set.str[STRING_SSH_KNOWNHOSTS]); in myssh_connect()
2241 rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_KNOWNHOSTS, in myssh_connect()
2242 data->set.str[STRING_SSH_KNOWNHOSTS]); in myssh_connect()
2249 if(conn->remote_port) { in myssh_connect()
2250 rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_PORT, in myssh_connect()
2251 &conn->remote_port); in myssh_connect()
2258 if(data->set.ssh_compression) { in myssh_connect()
2259 rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_COMPRESSION, in myssh_connect()
2267 ssh->privkey = NULL; in myssh_connect()
2268 ssh->pubkey = NULL; in myssh_connect()
2270 if(data->set.str[STRING_SSH_PUBLIC_KEY]) { in myssh_connect()
2271 rc = ssh_pki_import_pubkey_file(data->set.str[STRING_SSH_PUBLIC_KEY], in myssh_connect()
2272 &ssh->pubkey); in myssh_connect()
2326 *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); in scp_perform()
2339 struct connectdata *conn = data->conn; in myssh_do_it()
2340 struct ssh_conn *sshc = &conn->proto.sshc; in myssh_do_it()
2344 data->req.size = -1; /* make sure this is unknown at this point */ in myssh_do_it()
2346 sshc->actualcode = CURLE_OK; /* reset error code */ in myssh_do_it()
2347 sshc->secondCreateDirs = 0; /* reset the create dir attempt state in myssh_do_it()
2352 Curl_pgrsSetUploadSize(data, -1); in myssh_do_it()
2353 Curl_pgrsSetDownloadSize(data, -1); in myssh_do_it()
2355 if(conn->handler->protocol & CURLPROTO_SCP) in myssh_do_it()
2371 struct ssh_conn *ssh = &conn->proto.sshc; in scp_disconnect()
2374 if(ssh->ssh_session) { in scp_disconnect()
2390 struct SSHPROTO *protop = data->req.p.ssh; in myssh_done()
2393 /* run the state-machine */ in myssh_done()
2400 Curl_safefree(protop->path); in myssh_done()
2404 data->req.keepon = 0; /* clear all bits */ in myssh_done()
2425 struct connectdata *conn = data->conn; in scp_send()
2430 rc = ssh_scp_write(conn->proto.sshc.scp_session, mem, len); in scp_send()
2434 * that libssh at some point will implement non-blocking ssh_scp_write/read. in scp_send()
2446 return -1; in scp_send()
2456 struct connectdata *conn = data->conn; in scp_recv()
2460 /* libssh returns int */ in scp_recv()
2461 nread = ssh_scp_read(conn->proto.sshc.scp_session, mem, len); in scp_recv()
2465 * that libssh at some point will implement non-blocking ssh_scp_write/read. in scp_recv()
2471 nread = -1; in scp_recv()
2505 /* run the state-machine */ in sftp_perform()
2508 *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); in sftp_perform()
2540 if(conn->proto.sshc.ssh_session) { in sftp_disconnect()
2555 struct connectdata *conn = data->conn; in sftp_done()
2556 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_done()
2562 if(!premature && data->set.postquote && !conn->bits.retry) in sftp_done()
2563 sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT; in sftp_done()
2575 struct connectdata *conn = data->conn; in sftp_send()
2580 * https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02 in sftp_send()
2585 switch(conn->proto.sshc.sftp_send_state) { in sftp_send()
2587 sftp_file_set_nonblocking(conn->proto.sshc.sftp_file); in sftp_send()
2588 if(sftp_aio_begin_write(conn->proto.sshc.sftp_file, mem, len, in sftp_send()
2589 &conn->proto.sshc.sftp_aio) == SSH_ERROR) { in sftp_send()
2591 return -1; in sftp_send()
2593 conn->proto.sshc.sftp_send_state = 1; in sftp_send()
2596 nwrite = sftp_aio_wait_write(&conn->proto.sshc.sftp_aio); in sftp_send()
2604 return -1; in sftp_send()
2606 if(conn->proto.sshc.sftp_aio) { in sftp_send()
2607 sftp_aio_free(conn->proto.sshc.sftp_aio); in sftp_send()
2608 conn->proto.sshc.sftp_aio = NULL; in sftp_send()
2610 conn->proto.sshc.sftp_send_state = 0; in sftp_send()
2614 return -1; in sftp_send()
2617 nwrite = sftp_write(conn->proto.sshc.sftp_file, mem, len); in sftp_send()
2621 #if 0 /* not returned by libssh on write */ in sftp_send()
2630 nwrite = -1; in sftp_send()
2645 struct connectdata *conn = data->conn; in sftp_recv()
2650 switch(conn->proto.sshc.sftp_recv_state) { in sftp_recv()
2652 conn->proto.sshc.sftp_file_index = in sftp_recv()
2653 sftp_async_read_begin(conn->proto.sshc.sftp_file, in sftp_recv()
2655 if(conn->proto.sshc.sftp_file_index < 0) { in sftp_recv()
2657 return -1; in sftp_recv()
2662 conn->proto.sshc.sftp_recv_state = 1; in sftp_recv()
2664 nread = sftp_async_read(conn->proto.sshc.sftp_file, in sftp_recv()
2666 (uint32_t)conn->proto.sshc.sftp_file_index); in sftp_recv()
2672 return -1; in sftp_recv()
2676 return -1; in sftp_recv()
2679 conn->proto.sshc.sftp_recv_state = 0; in sftp_recv()
2684 return -1; in sftp_recv()
2691 struct connectdata *conn = data->conn; in sftp_quote()
2692 struct SSHPROTO *protop = data->req.p.ssh; in sftp_quote()
2693 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_quote()
2699 char *cmd = sshc->quote_item->data; in sftp_quote()
2700 sshc->acceptfail = FALSE; in sftp_quote()
2702 /* if a command starts with an asterisk, which a legal SFTP command never in sftp_quote()
2709 sshc->acceptfail = TRUE; in sftp_quote()
2715 protop->path); in sftp_quote()
2717 sshc->actualcode = CURLE_OUT_OF_MEMORY; in sftp_quote()
2719 sshc->nextstate = SSH_NO_STATE; in sftp_quote()
2725 /* this sends an FTP-like "header" to the header callback so that the in sftp_quote()
2732 sshc->nextstate = SSH_NO_STATE; in sftp_quote()
2733 sshc->actualcode = result; in sftp_quote()
2742 * command with a space so we can check for it unconditionally in sftp_quote()
2748 sshc->nextstate = SSH_NO_STATE; in sftp_quote()
2749 sshc->actualcode = CURLE_QUOTE_ERROR; in sftp_quote()
2757 result = Curl_get_pathname(&cp, &sshc->quote_path1, sshc->homedir); in sftp_quote()
2764 sshc->nextstate = SSH_NO_STATE; in sftp_quote()
2765 sshc->actualcode = result; in sftp_quote()
2772 * OpenSSH's sftp program and call the appropriate libssh in sftp_quote()
2782 /* sshc->quote_path1 contains the mode to set */ in sftp_quote()
2784 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in sftp_quote()
2791 Curl_safefree(sshc->quote_path1); in sftp_quote()
2793 sshc->nextstate = SSH_NO_STATE; in sftp_quote()
2794 sshc->actualcode = result; in sftp_quote()
2797 sshc->quote_attrs = NULL; in sftp_quote()
2804 /* sshc->quote_path1 is the source */ in sftp_quote()
2806 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in sftp_quote()
2812 Curl_safefree(sshc->quote_path1); in sftp_quote()
2814 sshc->nextstate = SSH_NO_STATE; in sftp_quote()
2815 sshc->actualcode = result; in sftp_quote()
2830 result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir); in sftp_quote()
2836 Curl_safefree(sshc->quote_path1); in sftp_quote()
2838 sshc->nextstate = SSH_NO_STATE; in sftp_quote()
2839 sshc->actualcode = result; in sftp_quote()
2862 Curl_safefree(sshc->quote_path1); in sftp_quote()
2863 Curl_safefree(sshc->quote_path2); in sftp_quote()
2865 sshc->nextstate = SSH_NO_STATE; in sftp_quote()
2866 sshc->actualcode = CURLE_QUOTE_ERROR; in sftp_quote()
2871 struct connectdata *conn = data->conn; in sftp_quote_stat()
2872 struct ssh_conn *sshc = &conn->proto.sshc; in sftp_quote_stat()
2873 char *cmd = sshc->quote_item->data; in sftp_quote_stat()
2874 sshc->acceptfail = FALSE; in sftp_quote_stat()
2876 /* if a command starts with an asterisk, which a legal SFTP command never in sftp_quote_stat()
2883 sshc->acceptfail = TRUE; in sftp_quote_stat()
2886 /* We read the file attributes, store them in sshc->quote_attrs in sftp_quote_stat()
2891 if(sshc->quote_attrs) in sftp_quote_stat()
2892 sftp_attributes_free(sshc->quote_attrs); in sftp_quote_stat()
2893 sshc->quote_attrs = sftp_stat(sshc->sftp_session, sshc->quote_path2); in sftp_quote_stat()
2894 if(!sshc->quote_attrs) { in sftp_quote_stat()
2895 Curl_safefree(sshc->quote_path1); in sftp_quote_stat()
2896 Curl_safefree(sshc->quote_path2); in sftp_quote_stat()
2898 sftp_get_error(sshc->sftp_session)); in sftp_quote_stat()
2900 sshc->nextstate = SSH_NO_STATE; in sftp_quote_stat()
2901 sshc->actualcode = CURLE_QUOTE_ERROR; in sftp_quote_stat()
2907 sshc->quote_attrs->gid = (uint32_t)strtoul(sshc->quote_path1, NULL, 10); in sftp_quote_stat()
2908 if(sshc->quote_attrs->gid == 0 && !ISDIGIT(sshc->quote_path1[0]) && in sftp_quote_stat()
2909 !sshc->acceptfail) { in sftp_quote_stat()
2910 Curl_safefree(sshc->quote_path1); in sftp_quote_stat()
2911 Curl_safefree(sshc->quote_path2); in sftp_quote_stat()
2914 sshc->nextstate = SSH_NO_STATE; in sftp_quote_stat()
2915 sshc->actualcode = CURLE_QUOTE_ERROR; in sftp_quote_stat()
2918 sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_UIDGID; in sftp_quote_stat()
2922 perms = (mode_t)strtoul(sshc->quote_path1, NULL, 8); in sftp_quote_stat()
2924 if(perms == 0 && !ISDIGIT(sshc->quote_path1[0])) { in sftp_quote_stat()
2925 Curl_safefree(sshc->quote_path1); in sftp_quote_stat()
2926 Curl_safefree(sshc->quote_path2); in sftp_quote_stat()
2929 sshc->nextstate = SSH_NO_STATE; in sftp_quote_stat()
2930 sshc->actualcode = CURLE_QUOTE_ERROR; in sftp_quote_stat()
2933 sshc->quote_attrs->permissions = perms; in sftp_quote_stat()
2934 sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_PERMISSIONS; in sftp_quote_stat()
2937 sshc->quote_attrs->uid = (uint32_t)strtoul(sshc->quote_path1, NULL, 10); in sftp_quote_stat()
2938 if(sshc->quote_attrs->uid == 0 && !ISDIGIT(sshc->quote_path1[0]) && in sftp_quote_stat()
2939 !sshc->acceptfail) { in sftp_quote_stat()
2940 Curl_safefree(sshc->quote_path1); in sftp_quote_stat()
2941 Curl_safefree(sshc->quote_path2); in sftp_quote_stat()
2944 sshc->nextstate = SSH_NO_STATE; in sftp_quote_stat()
2945 sshc->actualcode = CURLE_QUOTE_ERROR; in sftp_quote_stat()
2948 sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_UIDGID; in sftp_quote_stat()
2952 time_t date = Curl_getdate_capped(sshc->quote_path1); in sftp_quote_stat()
2954 if(date == -1) { in sftp_quote_stat()
2965 Curl_safefree(sshc->quote_path1); in sftp_quote_stat()
2966 Curl_safefree(sshc->quote_path2); in sftp_quote_stat()
2968 sshc->nextstate = SSH_NO_STATE; in sftp_quote_stat()
2969 sshc->actualcode = CURLE_QUOTE_ERROR; in sftp_quote_stat()
2973 sshc->quote_attrs->atime = (uint32_t)date; in sftp_quote_stat()
2975 sshc->quote_attrs->mtime = (uint32_t)date; in sftp_quote_stat()
2977 sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME; in sftp_quote_stat()
3001 (void)msnprintf(buffer, buflen, "libssh/%s", ssh_version(0)); in Curl_ssh_version()