diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index 707e1ae301..770de9a32d 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,9 @@ +2008-12-24 Ramon Novoa + + * win32/pandora_windows_service.h, + win32/bin/pandora_agent.conf, + win32/pandora_windows_service.cc: Added local transfer mode. + 2008-12-24 Ramon Novoa * win32/pandora_windows_service.cc: Do not send XML if server address diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 978b5f3ecc..009b8f7385 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -28,7 +28,7 @@ temporal "$AgentTemp$" interval 300 -# tranfer_modes: Possible values are tentacle (default), ftp and ssh. +# tranfer_modes: Possible values are local, tentacle (default), ftp and ssh. transfer_mode tentacle server_port 41121 diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 81dea37209..96eaf70974 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -372,19 +372,24 @@ Pandora_Windows_Service::copyDataFile (string filename) mode = conf->getValue ("transfer_mode"); host = conf->getValue ("server_ip"); remote_path = conf->getValue ("server_path"); - if (remote_path[remote_path.length () - 1] != '/') { + // Fix remote path + if (mode != "local" && remote_path[remote_path.length () - 1] != '/') { remote_path += "/"; + } else if (mode == "local" && remote_path[remote_path.length () - 1] != '\\') { + remote_path += "\\"; } try { if (mode == "ftp") { copyFtpDataFile (host, remote_path, filename, conf->getValue ("server_pwd")); - } else if (mode == "tentacle") { + } else if (mode == "tentacle" || mode == "") { copyTentacleDataFile (host, filename, conf->getValue ("server_port"), conf->getValue ("server_ssl"), conf->getValue ("server_pwd"), conf->getValue ("server_opts")); - } else if (mode == "ssh" || mode == "") { + } else if (mode == "ssh") { copyScpDataFile (host, remote_path, filename); + } else if (mode == "local") { + copyLocalDataFile (remote_path, filename); } else { pandoraLog ("Invalid transfer mode: %s." "Please recheck transfer_mode option " @@ -518,6 +523,23 @@ Pandora_Windows_Service::recvDataFile (string filename) { } } +void +Pandora_Windows_Service::copyLocalDataFile (string remote_path, + string filename) +{ + string local_path, local_file, remote_file; + local_path = conf->getValue ("temporal"); + if (local_path[local_path.length () - 1] != '\\') { + local_path += "\\"; + } + + local_file = local_path + filename; + remote_file = remote_path + filename; + if (!CopyFile (local_file.c_str (), remote_file.c_str (), TRUE)) { + throw Pandora_Exception (); + } +} + void Pandora_Windows_Service::checkConfig () { int i, conf_size; diff --git a/pandora_agents/win32/pandora_windows_service.h b/pandora_agents/win32/pandora_windows_service.h index 062492c560..0e45aa1284 100644 --- a/pandora_agents/win32/pandora_windows_service.h +++ b/pandora_agents/win32/pandora_windows_service.h @@ -61,6 +61,8 @@ namespace Pandora { string remote_path, string filename, string password); + void copyLocalDataFile (string remote_path, + string filename); void recvDataFile (string filename); void recvTentacleDataFile (string host, string filename);