• Home
  • Raw
  • Download

Lines Matching +full:wolfssh +full:-

21  * SPDX-License-Identifier: curl
143 struct connectdata *conn = data->conn; in state()
144 struct ssh_conn *sshc = &conn->proto.sshc; in state()
213 if(sshc->state != nowstate) { in state()
214 infof(data, "wolfssh %p state change from %s to %s", in state()
215 (void *)sshc, names[sshc->state], names[nowstate]); in state()
219 sshc->state = nowstate; in state()
254 struct connectdata *conn = data->conn; in wsftp_send()
255 struct ssh_conn *sshc = &conn->proto.sshc; in wsftp_send()
261 offset[0] = (word32)sshc->offset & 0xFFFFFFFF; in wsftp_send()
262 offset[1] = (word32)(sshc->offset >> 32) & 0xFFFFFFFF; in wsftp_send()
264 rc = wolfSSH_SFTP_SendWritePacket(sshc->ssh_session, sshc->handle, in wsftp_send()
265 sshc->handleSz, in wsftp_send()
270 rc = wolfSSH_get_error(sshc->ssh_session); in wsftp_send()
272 conn->waitfor = KEEP_RECV; in wsftp_send()
274 return -1; in wsftp_send()
277 conn->waitfor = KEEP_SEND; in wsftp_send()
279 return -1; in wsftp_send()
283 return -1; in wsftp_send()
287 len, sshc->offset); in wsftp_send()
288 sshc->offset += len; in wsftp_send()
300 struct connectdata *conn = data->conn; in wsftp_recv()
301 struct ssh_conn *sshc = &conn->proto.sshc; in wsftp_recv()
305 offset[0] = (word32)sshc->offset & 0xFFFFFFFF; in wsftp_recv()
306 offset[1] = (word32)(sshc->offset >> 32) & 0xFFFFFFFF; in wsftp_recv()
308 rc = wolfSSH_SFTP_SendReadPacket(sshc->ssh_session, sshc->handle, in wsftp_recv()
309 sshc->handleSz, in wsftp_recv()
313 rc = wolfSSH_get_error(sshc->ssh_session); in wsftp_recv()
315 conn->waitfor = KEEP_RECV; in wsftp_recv()
317 return -1; in wsftp_recv()
320 conn->waitfor = KEEP_SEND; in wsftp_recv()
322 return -1; in wsftp_recv()
329 return -1; in wsftp_recv()
331 sshc->offset += len; in wsftp_recv()
345 data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); in wssh_setup_connection()
357 DEBUGF(infof(data, "wolfssh callback: type %s", in userauth()
361 authdata->sf.password.password = (byte *)data->conn->passwd; in userauth()
362 authdata->sf.password.passwordSz = (word32) strlen(data->conn->passwd); in userauth()
370 struct connectdata *conn = data->conn; in wssh_connect()
372 curl_socket_t sock = conn->sock[FIRSTSOCKET]; in wssh_connect()
375 /* initialize per-handle data if not already */ in wssh_connect()
376 if(!data->req.p.ssh) in wssh_connect()
383 if(conn->handler->protocol & CURLPROTO_SCP) { in wssh_connect()
384 conn->recv[FIRSTSOCKET] = wscp_recv; in wssh_connect()
385 conn->send[FIRSTSOCKET] = wscp_send; in wssh_connect()
388 conn->recv[FIRSTSOCKET] = wsftp_recv; in wssh_connect()
389 conn->send[FIRSTSOCKET] = wsftp_send; in wssh_connect()
391 sshc = &conn->proto.sshc; in wssh_connect()
392 sshc->ctx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_CLIENT, NULL); in wssh_connect()
393 if(!sshc->ctx) { in wssh_connect()
394 failf(data, "No wolfSSH context"); in wssh_connect()
398 sshc->ssh_session = wolfSSH_new(sshc->ctx); in wssh_connect()
399 if(!sshc->ssh_session) { in wssh_connect()
400 failf(data, "No wolfSSH session"); in wssh_connect()
404 rc = wolfSSH_SetUsername(sshc->ssh_session, conn->user); in wssh_connect()
406 failf(data, "wolfSSH failed to set username"); in wssh_connect()
411 wolfSSH_SetUserAuth(sshc->ctx, userauth); in wssh_connect()
412 wolfSSH_SetUserAuthCtx(sshc->ssh_session, data); in wssh_connect()
414 rc = wolfSSH_set_fd(sshc->ssh_session, (int)sock); in wssh_connect()
416 failf(data, "wolfSSH failed to set socket"); in wssh_connect()
425 if(conn->handler->protocol & CURLPROTO_SCP) in wssh_connect()
432 wolfSSH_free(sshc->ssh_session); in wssh_connect()
433 wolfSSH_CTX_free(sshc->ctx); in wssh_connect()
440 * to will be set to TRUE if the wolfssh function returns EAGAIN meaning it
447 struct connectdata *conn = data->conn; in wssh_statemach_act()
448 struct ssh_conn *sshc = &conn->proto.sshc; in wssh_statemach_act()
449 struct SSHPROTO *sftp_scp = data->req.p.ssh; in wssh_statemach_act()
455 switch(sshc->state) { in wssh_statemach_act()
461 rc = wolfSSH_connect(sshc->ssh_session); in wssh_statemach_act()
463 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
466 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
471 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
478 infof(data, "wolfssh connected"); in wssh_statemach_act()
485 rc = wolfSSH_SFTP_connect(sshc->ssh_session); in wssh_statemach_act()
487 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
490 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
495 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
499 infof(data, "wolfssh SFTP connected"); in wssh_statemach_act()
503 failf(data, "wolfssh SFTP connect error %d", rc); in wssh_statemach_act()
508 name = wolfSSH_SFTP_RealPath(sshc->ssh_session, (char *)"."); in wssh_statemach_act()
509 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
512 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
517 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
521 sshc->homedir = Curl_memdup0(name->fName, name->fSz); in wssh_statemach_act()
522 if(!sshc->homedir) in wssh_statemach_act()
523 sshc->actualcode = CURLE_OUT_OF_MEMORY; in wssh_statemach_act()
528 failf(data, "wolfssh SFTP realpath %d", rc); in wssh_statemach_act()
532 result = Curl_getworkingpath(data, sshc->homedir, &sftp_scp->path); in wssh_statemach_act()
534 sshc->actualcode = result; in wssh_statemach_act()
539 if(data->set.quote) { in wssh_statemach_act()
541 sshc->quote_item = data->set.quote; in wssh_statemach_act()
549 if(data->set.get_filetime) { in wssh_statemach_act()
557 if(data->state.upload) in wssh_statemach_act()
560 if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/') in wssh_statemach_act()
569 if(data->state.resume_from) { in wssh_statemach_act()
571 if(data->state.resume_from < 0) { in wssh_statemach_act()
572 rc = wolfSSH_SFTP_STAT(sshc->ssh_session, sftp_scp->path, in wssh_statemach_act()
578 data->state.resume_from = 0; in wssh_statemach_act()
586 data->state.resume_from = size; in wssh_statemach_act()
591 if(data->set.remote_append) in wssh_statemach_act()
594 else if(data->state.resume_from > 0) in wssh_statemach_act()
602 createattrs.per = (word32)data->set.new_file_perms; in wssh_statemach_act()
603 sshc->handleSz = sizeof(sshc->handle); in wssh_statemach_act()
604 rc = wolfSSH_SFTP_Open(sshc->ssh_session, sftp_scp->path, in wssh_statemach_act()
606 sshc->handle, &sshc->handleSz); in wssh_statemach_act()
608 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
611 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
616 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
620 infof(data, "wolfssh SFTP open succeeded"); in wssh_statemach_act()
623 failf(data, "wolfssh SFTP upload open failed: %d", rc); in wssh_statemach_act()
630 if(data->state.resume_from > 0) { in wssh_statemach_act()
633 if(data->set.seek_func) { in wssh_statemach_act()
635 seekerr = data->set.seek_func(data->set.seek_client, in wssh_statemach_act()
636 data->state.resume_from, SEEK_SET); in wssh_statemach_act()
651 (data->state.resume_from - passed > in wssh_statemach_act()
653 sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); in wssh_statemach_act()
657 actuallyread = data->state.fread_func(scratch, 1, in wssh_statemach_act()
659 data->state.in); in wssh_statemach_act()
664 /* this checks for greater-than only to make sure that the in wssh_statemach_act()
669 } while(passed < data->state.resume_from); in wssh_statemach_act()
673 if(data->state.infilesize > 0) { in wssh_statemach_act()
674 data->state.infilesize -= data->state.resume_from; in wssh_statemach_act()
675 data->req.size = data->state.infilesize; in wssh_statemach_act()
676 Curl_pgrsSetUploadSize(data, data->state.infilesize); in wssh_statemach_act()
679 sshc->offset += data->state.resume_from; in wssh_statemach_act()
681 if(data->state.infilesize > 0) { in wssh_statemach_act()
682 data->req.size = data->state.infilesize; in wssh_statemach_act()
683 Curl_pgrsSetUploadSize(data, data->state.infilesize); in wssh_statemach_act()
686 Curl_xfer_setup1(data, CURL_XFER_SEND, -1, FALSE); in wssh_statemach_act()
689 conn->sockfd = conn->writesockfd; in wssh_statemach_act()
693 sshc->actualcode = result; in wssh_statemach_act()
698 sshc->orig_waitfor = data->req.keepon; in wssh_statemach_act()
703 data->state.select_bits = CURL_CSELECT_OUT; in wssh_statemach_act()
715 sshc->handleSz = sizeof(sshc->handle); in wssh_statemach_act()
716 rc = wolfSSH_SFTP_Open(sshc->ssh_session, sftp_scp->path, in wssh_statemach_act()
718 sshc->handle, &sshc->handleSz); in wssh_statemach_act()
720 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
723 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
728 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
732 infof(data, "wolfssh SFTP open succeeded"); in wssh_statemach_act()
737 failf(data, "wolfssh SFTP open failed: %d", rc); in wssh_statemach_act()
744 rc = wolfSSH_SFTP_STAT(sshc->ssh_session, sftp_scp->path, &attrs); in wssh_statemach_act()
746 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
749 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
754 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
758 infof(data, "wolfssh STAT succeeded"); in wssh_statemach_act()
761 failf(data, "wolfssh SFTP open failed: %d", rc); in wssh_statemach_act()
762 data->req.size = -1; in wssh_statemach_act()
763 data->req.maxdownload = -1; in wssh_statemach_act()
764 Curl_pgrsSetDownloadSize(data, -1); in wssh_statemach_act()
770 data->req.size = size; in wssh_statemach_act()
771 data->req.maxdownload = size; in wssh_statemach_act()
776 /* We cannot seek with wolfSSH so resuming and range requests are not in wssh_statemach_act()
778 if(data->state.use_range || data->state.resume_from) { in wssh_statemach_act()
779 infof(data, "wolfSSH cannot do range/seek on SFTP"); in wssh_statemach_act()
784 if(data->req.size == 0) { in wssh_statemach_act()
791 Curl_xfer_setup1(data, CURL_XFER_RECV, data->req.size, FALSE); in wssh_statemach_act()
794 conn->writesockfd = conn->sockfd; in wssh_statemach_act()
799 data->state.select_bits = CURL_CSELECT_IN; in wssh_statemach_act()
805 sshc->actualcode = result; in wssh_statemach_act()
813 if(sshc->handleSz) in wssh_statemach_act()
814 rc = wolfSSH_SFTP_Close(sshc->ssh_session, sshc->handle, in wssh_statemach_act()
815 sshc->handleSz); in wssh_statemach_act()
820 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
825 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
833 failf(data, "wolfssh SFTP CLOSE failed: %d", rc); in wssh_statemach_act()
837 Curl_pgrsSetDownloadSize(data, -1); in wssh_statemach_act()
838 if(data->req.no_body) { in wssh_statemach_act()
846 name = wolfSSH_SFTP_LS(sshc->ssh_session, sftp_scp->path); in wssh_statemach_act()
848 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
854 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
859 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
867 data->set.list_only ? in wssh_statemach_act()
868 name->fName : name->lName); in wssh_statemach_act()
871 sshc->actualcode = CURLE_OUT_OF_MEMORY; in wssh_statemach_act()
878 sshc->actualcode = result; in wssh_statemach_act()
881 name = name->next; in wssh_statemach_act()
887 failf(data, "wolfssh SFTP ls failed: %d", rc); in wssh_statemach_act()
891 Curl_safefree(sshc->homedir); in wssh_statemach_act()
892 wolfSSH_free(sshc->ssh_session); in wssh_statemach_act()
893 wolfSSH_CTX_free(sshc->ctx); in wssh_statemach_act()
899 } while(!rc && (sshc->state != SSH_STOP)); in wssh_statemach_act()
906 struct connectdata *conn = data->conn; in wssh_multi_statemach()
907 struct ssh_conn *sshc = &conn->proto.sshc; in wssh_multi_statemach()
913 *done = (sshc->state == SSH_STOP); in wssh_multi_statemach()
949 /* run the state-machine */ in wsftp_perform()
952 *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); in wsftp_perform()
968 struct connectdata *conn = data->conn; in wssh_do()
969 struct ssh_conn *sshc = &conn->proto.sshc; in wssh_do()
972 data->req.size = -1; /* make sure this is unknown at this point */ in wssh_do()
973 sshc->actualcode = CURLE_OK; /* reset error code */ in wssh_do()
974 sshc->secondCreateDirs = 0; /* reset the create dir attempt state in wssh_do()
979 Curl_pgrsSetUploadSize(data, -1); in wssh_do()
980 Curl_pgrsSetDownloadSize(data, -1); in wssh_do()
982 if(conn->handler->protocol & CURLPROTO_SCP) in wssh_do()
993 struct connectdata *conn = data->conn; in wssh_block_statemach()
994 struct ssh_conn *sshc = &conn->proto.sshc; in wssh_block_statemach()
997 while((sshc->state != SSH_STOP) && !result) { in wssh_block_statemach()
1022 int dir = conn->waitfor; in wssh_block_statemach()
1023 curl_socket_t sock = conn->sock[FIRSTSOCKET]; in wssh_block_statemach()
1045 struct SSHPROTO *sftp_scp = data->req.p.ssh; in wssh_done()
1048 /* run the state-machine */ in wssh_done()
1055 Curl_safefree(sftp_scp->path); in wssh_done()
1059 data->req.keepon = 0; /* clear all bits */ in wssh_done()
1126 if(conn->proto.sshc.ssh_session) { in wsftp_disconnect()
1141 int dir = conn->waitfor; in wssh_getsock()
1143 sock[0] = conn->sock[FIRSTSOCKET]; in wssh_getsock()
1155 (void)msnprintf(buffer, buflen, "wolfssh/%s", LIBWOLFSSH_VERSION_STRING); in Curl_ssh_version()