From d8e69922547f52a85cce3c054116b3266c1f9fd1 Mon Sep 17 00:00:00 2001 From: darode Date: Wed, 7 Jul 2010 15:14:18 +0000 Subject: [PATCH] 2010-07-07 Dario Rodriguez * win32/pandora_windows_service.h: Added constant for default port for ftp and ssh * win32/pandora_windows_service.cc: Added support for change ssh and ftp port git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2971 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- .../win32/pandora_windows_service.cc | 27 +++++++++++++++---- .../win32/pandora_windows_service.h | 3 +++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index ef16e42400..81ae6f95d7 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -305,8 +305,9 @@ Pandora_Windows_Service::copyScpDataFile (string host, { int rc = 0; SSH::Pandora_Ssh_Client ssh_client; - string tmp_dir, filepath; + string tmp_dir, filepath,port_str; string pubkey_file, privkey_file; + int port; tmp_dir = conf->getValue ("temporal"); if (tmp_dir[tmp_dir.length () - 1] != '\\') { @@ -321,7 +322,14 @@ Pandora_Windows_Service::copyScpDataFile (string host, privkey_file = Pandora::getPandoraInstallDir (); privkey_file += "key\\id_dsa"; - rc = ssh_client.connectWithPublicKey (host.c_str (), 22, "pandora", + port_str = conf->getValue ("server_port"); + if (port_str.length () == 0) { + port = SSH_DEFAULT_PORT; + } else { + port = strtoint(port_str); + } + + rc = ssh_client.connectWithPublicKey (host.c_str (), port, "pandora", pubkey_file, privkey_file, ""); if (rc == AUTHENTICATION_FAILED) { pandoraLog ("Pandora Agent: Authentication Failed " @@ -359,7 +367,8 @@ Pandora_Windows_Service::copyFtpDataFile (string host, { int rc = 0; FTP::Pandora_Ftp_Client ftp_client; - string filepath; + string filepath, port_str; + int port; filepath = conf->getValue ("temporal"); if (filepath[filepath.length () - 1] != '\\') { @@ -367,8 +376,15 @@ Pandora_Windows_Service::copyFtpDataFile (string host, } filepath += filename; + port_str = conf->getValue ("server_port"); + if (port_str.length () == 0) { + port = FTP_DEFAULT_PORT; + } else { + port = strtoint(port_str); + } + ftp_client.connect (host, - 22, + port, "pandora", password); @@ -549,7 +565,7 @@ Pandora_Windows_Service::recvDataFile (string filename) { if (mode == "tentacle") { recvTentacleDataFile (host, filename); } else { - pandoraLog ("Transfer mode %s does not support file retrieval."); + pandoraLog ("Transfer mode %s does not support file retrieval.", mode.c_str () ); throw Pandora_Exception (); } } @@ -879,6 +895,7 @@ Pandora_Windows_Service::pandora_run () { } } + this->elapsed_transfer_time += this->interval; if (this->elapsed_transfer_time >= this->transfer_interval) { diff --git a/pandora_agents/win32/pandora_windows_service.h b/pandora_agents/win32/pandora_windows_service.h index 10b9571006..bc161e9a0b 100644 --- a/pandora_agents/win32/pandora_windows_service.h +++ b/pandora_agents/win32/pandora_windows_service.h @@ -27,6 +27,9 @@ #include "modules/pandora_module_list.h" #include "ssh/pandora_ssh_client.h" +#define FTP_DEFAULT_PORT 21 +#define SSH_DEFAULT_PORT 22 + using namespace std; using namespace Pandora_Modules;