Skip to content

Commit baa462d

Browse files
author
krizsa
committed
small fixes
1 parent 7e1e71f commit baa462d

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

src/init.cc

+9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
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+
18
#include "sftp.h"
29
#include <libssh/callbacks.h>
310

411
#include <errno.h>
512
#include <stdlib.h>
613
#include <pthread.h>
714

15+
// Thread callbacks are based on the libssh pthreads.c file
16+
817
extern "C" {
918
static int ssh_pthread_mutex_init (void **priv)
1019
{

src/sftp.cc

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
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+
18
#include "sftp.h"
29
#include <fcntl.h>
310
#include <node_buffer.h>
@@ -468,20 +475,20 @@ int SFTP::startExec(eio_req *req)
468475
int res;
469476
channel = ssh_channel_new(pthis->m_ssh_session);
470477
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");
472479
return 0;
473480
}
474481

475482
res = ssh_channel_open_session(channel);
476483
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");
478485
ssh_channel_free(channel);
479486
return 0;
480487
}
481488

482489
res = ssh_channel_request_exec(channel, pthis->m_path);
483490
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");
485492
ssh_channel_close(channel);
486493
ssh_channel_free(channel);
487494
return 0;
@@ -497,7 +504,8 @@ int SFTP::startExec(eio_req *req)
497504
}
498505

499506
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));
501509
ssh_channel_close(channel);
502510
ssh_channel_free(channel);
503511
return 0;
@@ -529,6 +537,7 @@ int SFTP::startSetPrvKey(eio_req *req)
529537
pthis->m_path, 0, NULL);
530538
if (!pthis->m_prv_key) {
531539
snprintf(pthis->m_error, SFTP_MAX_ERROR, "Can't set private key.");
540+
fprintf(stderr, pthis->m_path);
532541
}
533542
return 0;
534543
}
@@ -682,11 +691,11 @@ Handle<Value> SFTP::init(const Arguments &args)
682691
return False();
683692

684693
Local<Object> opt = Local<Object>::Cast(args[0]);
685-
// TODO: free these!!!
686694
setOption(pthis->m_ssh_session, opt, "host", SSH_OPTIONS_HOST);
687695
setOption(pthis->m_ssh_session, opt, "port", SSH_OPTIONS_PORT_STR);
688696
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);
690699
//ssh_options_set(pthis->m_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, (void*) new int(SSH_LOG_PACKET));
691700
return True();
692701
}

src/sftp.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
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+
18
#ifndef NODE_SFTP_SFTP_H
29
#define NODE_SFTP_SFTP_H
310

@@ -30,8 +37,7 @@ class SFTP : EventEmitter {
3037
sftp_session m_sftp_session;
3138
sftp_file m_sftp_file;
3239
ssh_string m_pub_key;
33-
ssh_private_key m_prv_key;
34-
long m_timeout;
40+
ssh_private_key m_prv_key;
3541
int m_done;
3642
char* m_error;
3743
ListNode* m_list;

support/libssh

0 commit comments

Comments
 (0)