1
+ /* *
2
+ * @package node-ssh
3
+ * @copyright Copyright(c) 2011 Ajax.org B.V. <info AT ajax.org>
4
+ * @author Gabor Krizsanits <gabor AT ajax DOT org>
5
+ * @license http://github.com/ajaxorg/node-ssh/blob/master/LICENSE MIT License
6
+ */
7
+
1
8
#include " sftp.h"
2
9
#include < fcntl.h>
3
10
#include < node_buffer.h>
@@ -468,20 +475,20 @@ int SFTP::startExec(eio_req *req)
468
475
int res;
469
476
channel = ssh_channel_new (pthis->m_ssh_session );
470
477
if (!channel) {
471
- snprintf (pthis->m_error , SFTP_MAX_ERROR, " Can't create shh channel." );
478
+ snprintf (pthis->m_error , SFTP_MAX_ERROR, " Can't create shh channel.\n " );
472
479
return 0 ;
473
480
}
474
481
475
482
res = ssh_channel_open_session (channel);
476
483
if (res != SSH_OK) {
477
- snprintf (pthis->m_error , SFTP_MAX_ERROR, " Can't open shh channel." );
484
+ snprintf (pthis->m_error , SFTP_MAX_ERROR, " Can't open shh channel.\n " );
478
485
ssh_channel_free (channel);
479
486
return 0 ;
480
487
}
481
488
482
489
res = ssh_channel_request_exec (channel, pthis->m_path );
483
490
if (res != SSH_OK) {
484
- snprintf (pthis->m_error , SFTP_MAX_ERROR, " SSH exec failed." );
491
+ snprintf (pthis->m_error , SFTP_MAX_ERROR, " SSH exec failed.\n " );
485
492
ssh_channel_close (channel);
486
493
ssh_channel_free (channel);
487
494
return 0 ;
@@ -497,7 +504,8 @@ int SFTP::startExec(eio_req *req)
497
504
}
498
505
499
506
if (nbytes < 0 ) {
500
- snprintf (pthis->m_error , SFTP_MAX_ERROR, " SSH exec read error." );
507
+ snprintf (pthis->m_error , SFTP_MAX_ERROR, " SSH exec read error.%s\n " ,
508
+ ssh_get_error (pthis->m_ssh_session ));
501
509
ssh_channel_close (channel);
502
510
ssh_channel_free (channel);
503
511
return 0 ;
@@ -529,6 +537,7 @@ int SFTP::startSetPrvKey(eio_req *req)
529
537
pthis->m_path , 0 , NULL );
530
538
if (!pthis->m_prv_key ) {
531
539
snprintf (pthis->m_error , SFTP_MAX_ERROR, " Can't set private key." );
540
+ fprintf (stderr, pthis->m_path );
532
541
}
533
542
return 0 ;
534
543
}
@@ -682,11 +691,11 @@ Handle<Value> SFTP::init(const Arguments &args)
682
691
return False ();
683
692
684
693
Local<Object> opt = Local<Object>::Cast (args[0 ]);
685
- // TODO: free these!!!
686
694
setOption (pthis->m_ssh_session , opt, " host" , SSH_OPTIONS_HOST);
687
695
setOption (pthis->m_ssh_session , opt, " port" , SSH_OPTIONS_PORT_STR);
688
696
setOption (pthis->m_ssh_session , opt, " user" , SSH_OPTIONS_USER);
689
- ssh_options_set (pthis->m_ssh_session , SSH_OPTIONS_TIMEOUT, (void *) new long (10 ));
697
+ long timeout = 10 ;
698
+ ssh_options_set (pthis->m_ssh_session , SSH_OPTIONS_TIMEOUT, (void *) &timeout);
690
699
// ssh_options_set(pthis->m_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, (void*) new int(SSH_LOG_PACKET));
691
700
return True ();
692
701
}
0 commit comments