• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:without +full:- +full:libssh2

18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
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()
215 (void *)sshc, names[sshc->state], names[nowstate]); in state()
219 sshc->state = nowstate; in state()
252 struct connectdata *conn = data->conn; in wsftp_send()
253 struct ssh_conn *sshc = &conn->proto.sshc; in wsftp_send()
258 offset[0] = (word32)sshc->offset&0xFFFFFFFF; in wsftp_send()
259 offset[1] = (word32)(sshc->offset>>32)&0xFFFFFFFF; in wsftp_send()
261 rc = wolfSSH_SFTP_SendWritePacket(sshc->ssh_session, sshc->handle, in wsftp_send()
262 sshc->handleSz, in wsftp_send()
267 rc = wolfSSH_get_error(sshc->ssh_session); in wsftp_send()
269 conn->waitfor = KEEP_RECV; in wsftp_send()
271 return -1; in wsftp_send()
274 conn->waitfor = KEEP_SEND; in wsftp_send()
276 return -1; in wsftp_send()
280 return -1; in wsftp_send()
284 len, sshc->offset); in wsftp_send()
285 sshc->offset += len; in wsftp_send()
297 struct connectdata *conn = data->conn; in wsftp_recv()
298 struct ssh_conn *sshc = &conn->proto.sshc; in wsftp_recv()
302 offset[0] = (word32)sshc->offset&0xFFFFFFFF; in wsftp_recv()
303 offset[1] = (word32)(sshc->offset>>32)&0xFFFFFFFF; in wsftp_recv()
305 rc = wolfSSH_SFTP_SendReadPacket(sshc->ssh_session, sshc->handle, in wsftp_recv()
306 sshc->handleSz, in wsftp_recv()
310 rc = wolfSSH_get_error(sshc->ssh_session); in wsftp_recv()
312 conn->waitfor = KEEP_RECV; in wsftp_recv()
314 return -1; in wsftp_recv()
317 conn->waitfor = KEEP_SEND; in wsftp_recv()
319 return -1; in wsftp_recv()
326 return -1; in wsftp_recv()
328 sshc->offset += len; in wsftp_recv()
342 data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO)); in wssh_setup_connection()
358 authdata->sf.password.password = (byte *)data->conn->passwd; in userauth()
359 authdata->sf.password.passwordSz = (word32) strlen(data->conn->passwd); in userauth()
367 struct connectdata *conn = data->conn; in wssh_connect()
369 curl_socket_t sock = conn->sock[FIRSTSOCKET]; in wssh_connect()
372 /* initialize per-handle data if not already */ in wssh_connect()
373 if(!data->req.p.ssh) in wssh_connect()
380 if(conn->handler->protocol & CURLPROTO_SCP) { in wssh_connect()
381 conn->recv[FIRSTSOCKET] = wscp_recv; in wssh_connect()
382 conn->send[FIRSTSOCKET] = wscp_send; in wssh_connect()
385 conn->recv[FIRSTSOCKET] = wsftp_recv; in wssh_connect()
386 conn->send[FIRSTSOCKET] = wsftp_send; in wssh_connect()
388 sshc = &conn->proto.sshc; in wssh_connect()
389 sshc->ctx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_CLIENT, NULL); in wssh_connect()
390 if(!sshc->ctx) { in wssh_connect()
395 sshc->ssh_session = wolfSSH_new(sshc->ctx); in wssh_connect()
396 if(!sshc->ssh_session) { in wssh_connect()
401 rc = wolfSSH_SetUsername(sshc->ssh_session, conn->user); in wssh_connect()
408 wolfSSH_SetUserAuth(sshc->ctx, userauth); in wssh_connect()
409 wolfSSH_SetUserAuthCtx(sshc->ssh_session, data); in wssh_connect()
411 rc = wolfSSH_set_fd(sshc->ssh_session, (int)sock); in wssh_connect()
422 if(conn->handler->protocol & CURLPROTO_SCP) in wssh_connect()
429 wolfSSH_free(sshc->ssh_session); in wssh_connect()
430 wolfSSH_CTX_free(sshc->ctx); in wssh_connect()
435 * wssh_statemach_act() runs the SSH state machine as far as it can without
436 * blocking and without reaching the end. The data the pointer 'block' points
444 struct connectdata *conn = data->conn; in wssh_statemach_act()
445 struct ssh_conn *sshc = &conn->proto.sshc; in wssh_statemach_act()
446 struct SSHPROTO *sftp_scp = data->req.p.ssh; in wssh_statemach_act()
452 switch(sshc->state) { in wssh_statemach_act()
458 rc = wolfSSH_connect(sshc->ssh_session); in wssh_statemach_act()
460 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
463 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
468 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
482 rc = wolfSSH_SFTP_connect(sshc->ssh_session); in wssh_statemach_act()
484 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
487 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
492 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
505 name = wolfSSH_SFTP_RealPath(sshc->ssh_session, (char *)"."); in wssh_statemach_act()
506 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
509 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
514 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
518 sshc->homedir = Curl_memdup0(name->fName, name->fSz); in wssh_statemach_act()
519 if(!sshc->homedir) in wssh_statemach_act()
520 sshc->actualcode = CURLE_OUT_OF_MEMORY; in wssh_statemach_act()
529 result = Curl_getworkingpath(data, sshc->homedir, &sftp_scp->path); in wssh_statemach_act()
531 sshc->actualcode = result; in wssh_statemach_act()
536 if(data->set.quote) { in wssh_statemach_act()
538 sshc->quote_item = data->set.quote; in wssh_statemach_act()
546 if(data->set.get_filetime) { in wssh_statemach_act()
554 if(data->state.upload) in wssh_statemach_act()
557 if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/') in wssh_statemach_act()
566 if(data->state.resume_from) { in wssh_statemach_act()
568 if(data->state.resume_from < 0) { in wssh_statemach_act()
569 rc = wolfSSH_SFTP_STAT(sshc->ssh_session, sftp_scp->path, in wssh_statemach_act()
575 data->state.resume_from = 0; in wssh_statemach_act()
583 data->state.resume_from = size; in wssh_statemach_act()
588 if(data->set.remote_append) in wssh_statemach_act()
591 else if(data->state.resume_from > 0) in wssh_statemach_act()
599 createattrs.per = (word32)data->set.new_file_perms; in wssh_statemach_act()
600 sshc->handleSz = sizeof(sshc->handle); in wssh_statemach_act()
601 rc = wolfSSH_SFTP_Open(sshc->ssh_session, sftp_scp->path, in wssh_statemach_act()
603 sshc->handle, &sshc->handleSz); in wssh_statemach_act()
605 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
608 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
613 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
627 if(data->state.resume_from > 0) { in wssh_statemach_act()
630 if(data->set.seek_func) { in wssh_statemach_act()
632 seekerr = data->set.seek_func(data->set.seek_client, in wssh_statemach_act()
633 data->state.resume_from, SEEK_SET); in wssh_statemach_act()
648 (data->state.resume_from - passed > in wssh_statemach_act()
650 sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); in wssh_statemach_act()
654 actuallyread = data->state.fread_func(scratch, 1, in wssh_statemach_act()
656 data->state.in); in wssh_statemach_act()
661 /* this checks for greater-than only to make sure that the in wssh_statemach_act()
666 } while(passed < data->state.resume_from); in wssh_statemach_act()
670 if(data->state.infilesize > 0) { in wssh_statemach_act()
671 data->state.infilesize -= data->state.resume_from; in wssh_statemach_act()
672 data->req.size = data->state.infilesize; in wssh_statemach_act()
673 Curl_pgrsSetUploadSize(data, data->state.infilesize); in wssh_statemach_act()
676 sshc->offset += data->state.resume_from; in wssh_statemach_act()
678 if(data->state.infilesize > 0) { in wssh_statemach_act()
679 data->req.size = data->state.infilesize; in wssh_statemach_act()
680 Curl_pgrsSetUploadSize(data, data->state.infilesize); in wssh_statemach_act()
683 Curl_xfer_setup(data, -1, -1, FALSE, FIRSTSOCKET); in wssh_statemach_act()
686 conn->sockfd = conn->writesockfd; in wssh_statemach_act()
690 sshc->actualcode = result; in wssh_statemach_act()
695 sshc->orig_waitfor = data->req.keepon; in wssh_statemach_act()
698 out readable as the underlying libssh2 sftp send function will deal in wssh_statemach_act()
700 data->state.select_bits = CURL_CSELECT_OUT; in wssh_statemach_act()
712 sshc->handleSz = sizeof(sshc->handle); in wssh_statemach_act()
713 rc = wolfSSH_SFTP_Open(sshc->ssh_session, sftp_scp->path, in wssh_statemach_act()
715 sshc->handle, &sshc->handleSz); in wssh_statemach_act()
717 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
720 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
725 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
741 rc = wolfSSH_SFTP_STAT(sshc->ssh_session, sftp_scp->path, &attrs); in wssh_statemach_act()
743 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
746 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
751 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
759 data->req.size = -1; in wssh_statemach_act()
760 data->req.maxdownload = -1; in wssh_statemach_act()
761 Curl_pgrsSetDownloadSize(data, -1); in wssh_statemach_act()
767 data->req.size = size; in wssh_statemach_act()
768 data->req.maxdownload = size; in wssh_statemach_act()
775 if(data->state.use_range || data->state.resume_from) { in wssh_statemach_act()
781 if(data->req.size == 0) { in wssh_statemach_act()
783 Curl_xfer_setup(data, -1, -1, FALSE, -1); in wssh_statemach_act()
788 Curl_xfer_setup(data, FIRSTSOCKET, data->req.size, FALSE, -1); in wssh_statemach_act()
791 conn->writesockfd = conn->sockfd; in wssh_statemach_act()
794 out writableable as the underlying libssh2 recv function will deal in wssh_statemach_act()
796 data->state.select_bits = CURL_CSELECT_IN; in wssh_statemach_act()
802 sshc->actualcode = result; in wssh_statemach_act()
810 if(sshc->handleSz) in wssh_statemach_act()
811 rc = wolfSSH_SFTP_Close(sshc->ssh_session, sshc->handle, in wssh_statemach_act()
812 sshc->handleSz); in wssh_statemach_act()
817 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
822 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
834 Curl_pgrsSetDownloadSize(data, -1); in wssh_statemach_act()
835 if(data->req.no_body) { in wssh_statemach_act()
843 name = wolfSSH_SFTP_LS(sshc->ssh_session, sftp_scp->path); in wssh_statemach_act()
845 rc = wolfSSH_get_error(sshc->ssh_session); in wssh_statemach_act()
851 conn->waitfor = KEEP_RECV; in wssh_statemach_act()
856 conn->waitfor = KEEP_SEND; in wssh_statemach_act()
864 data->set.list_only ? in wssh_statemach_act()
865 name->fName : name->lName); in wssh_statemach_act()
868 sshc->actualcode = CURLE_OUT_OF_MEMORY; in wssh_statemach_act()
875 sshc->actualcode = result; in wssh_statemach_act()
878 name = name->next; in wssh_statemach_act()
888 Curl_safefree(sshc->homedir); in wssh_statemach_act()
889 wolfSSH_free(sshc->ssh_session); in wssh_statemach_act()
890 wolfSSH_CTX_free(sshc->ctx); in wssh_statemach_act()
896 } while(!rc && (sshc->state != SSH_STOP)); in wssh_statemach_act()
903 struct connectdata *conn = data->conn; in wssh_multi_statemach()
904 struct ssh_conn *sshc = &conn->proto.sshc; in wssh_multi_statemach()
910 *done = (sshc->state == SSH_STOP) ? TRUE : FALSE; in wssh_multi_statemach()
946 /* run the state-machine */ in wsftp_perform()
949 *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); in wsftp_perform()
965 struct connectdata *conn = data->conn; in wssh_do()
966 struct ssh_conn *sshc = &conn->proto.sshc; in wssh_do()
969 data->req.size = -1; /* make sure this is unknown at this point */ in wssh_do()
970 sshc->actualcode = CURLE_OK; /* reset error code */ in wssh_do()
971 sshc->secondCreateDirs = 0; /* reset the create dir attempt state in wssh_do()
976 Curl_pgrsSetUploadSize(data, -1); in wssh_do()
977 Curl_pgrsSetDownloadSize(data, -1); in wssh_do()
979 if(conn->handler->protocol & CURLPROTO_SCP) in wssh_do()
990 struct connectdata *conn = data->conn; in wssh_block_statemach()
991 struct ssh_conn *sshc = &conn->proto.sshc; in wssh_block_statemach()
994 while((sshc->state != SSH_STOP) && !result) { in wssh_block_statemach()
1019 int dir = conn->waitfor; in wssh_block_statemach()
1020 curl_socket_t sock = conn->sock[FIRSTSOCKET]; in wssh_block_statemach()
1042 struct SSHPROTO *sftp_scp = data->req.p.ssh; in wssh_done()
1045 /* run the state-machine */ in wssh_done()
1052 Curl_safefree(sftp_scp->path); in wssh_done()
1056 data->req.keepon = 0; /* clear all bits */ in wssh_done()
1123 if(conn->proto.sshc.ssh_session) { in wsftp_disconnect()
1138 int dir = conn->waitfor; in wssh_getsock()
1140 sock[0] = conn->sock[FIRSTSOCKET]; in wssh_getsock()