From a190b7c9d115a1b224807b35a338ea346f70c12b Mon Sep 17 00:00:00 2001 From: ramonn Date: Thu, 19 Nov 2009 00:40:26 +0000 Subject: [PATCH] 2009-11-19 Ramon Novoa * windows/pandora_wmi.cc: Fixed bug #2895307. * modules/pandora_module.cc: Fixed bug #2835450. * bin/pandora_agent.conf: Added xml_buffer configuration token. * ssh/libssh2/libssh2_config.h, ssh/libssh2/packet.c: Renamed usleep to u_sleep to avoid conflicts. * pandora_windows_service.cc: Fixed bug #2899257. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2115 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/win32/ChangeLog | 13 +++++++++++ pandora_agents/win32/bin/pandora_agent.conf | 4 ++++ .../win32/modules/pandora_module.cc | 1 + .../win32/pandora_windows_service.cc | 22 +++++++++++-------- .../win32/ssh/libssh2/libssh2_config.h | 2 +- pandora_agents/win32/ssh/libssh2/packet.c | 2 +- pandora_agents/win32/windows/pandora_wmi.cc | 2 +- 7 files changed, 34 insertions(+), 12 deletions(-) diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog index 57aa12ec6f..3e7aac094b 100644 --- a/pandora_agents/win32/ChangeLog +++ b/pandora_agents/win32/ChangeLog @@ -1,3 +1,16 @@ +2009-11-19 Ramon Novoa + + * windows/pandora_wmi.cc: Fixed bug #2895307. + + * modules/pandora_module.cc: Fixed bug #2835450. + + * bin/pandora_agent.conf: Added xml_buffer configuration token. + + * ssh/libssh2/libssh2_config.h, ssh/libssh2/packet.c: Renamed usleep to + u_sleep to avoid conflicts. + + * pandora_windows_service.cc: Fixed bug #2899257. + 2009-11-17 Sancho Lerena * Installer/Pandora_silent.mpi: Installer in silent mode. Should diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index af31366e3a..ce627651b1 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -56,6 +56,10 @@ server_port 41121 # Set XML encoding (ISO-8859-1 by default). #encoding ISO-8859-1 + +# Enable or disable XML buffer. +xml_buffer 0 + # Module Definition # Check online documentation and module library at http://pandorafms.org diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index ebcfb0318e..0d9b189266 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -407,6 +407,7 @@ Pandora_Module::getXml () { } text = new TiXmlText (data_clean); + text->SetCDATA (true); element->InsertEndChild (*text); data_element->InsertEndChild (*element); delete text; diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 0fac342235..d5c4c3b1ae 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -697,7 +697,7 @@ Pandora_Windows_Service::checkConfig () { int Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) { - int rc = 0; + int rc = 0, xml_buffer; TiXmlDeclaration *decl; TiXmlDocument *doc; TiXmlElement *local_xml, *agent; @@ -712,6 +712,7 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) { conf = this->getConf (); min_free_bytes = 1024 * atoi (conf->getValue ("temporal_min_size").c_str ()); + xml_buffer = atoi (conf->getValue ("xml_buffer").c_str ()); if (mutex == 0) { mutex = CreateMutex (NULL, FALSE, NULL); @@ -781,14 +782,15 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) { if (getPandoraDebug () == false) { rc = this->copyDataFile (tmp_filename); - /* Delete the file if successfully copied or not enough space available */ - if (rc == 0 || (GetDiskFreeSpaceEx (tmp_filepath.c_str (), &free_bytes, NULL, NULL) != 0 - && free_bytes.QuadPart < min_free_bytes)) { - Pandora_File::removeFile (tmp_filepath); - } + /* Delete the file if successfully copied, buffer disabled or not enough space available */ + if (rc == 0 || xml_buffer == 0 || (GetDiskFreeSpaceEx (tmp_filepath.c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart < min_free_bytes)) { + Pandora_File::removeFile (tmp_filepath); + } - /* Send any buffered data files */ - this->sendBufferedXml (conf->getValue ("temporal")); + /* Send any buffered data files */ + if (xml_buffer == 1) { + this->sendBufferedXml (conf->getValue ("temporal")); + } } ReleaseMutex (mutex); @@ -839,7 +841,9 @@ Pandora_Windows_Service::pandora_run () { conf = this->getConf (); /* Check for configuration changes */ - this->checkConfig (); + if (getPandoraDebug == false) { + this->checkConfig (); + } server_addr = conf->getValue ("server_ip"); diff --git a/pandora_agents/win32/ssh/libssh2/libssh2_config.h b/pandora_agents/win32/ssh/libssh2/libssh2_config.h index 7661e99a29..c4a4df30e9 100644 --- a/pandora_agents/win32/ssh/libssh2/libssh2_config.h +++ b/pandora_agents/win32/ssh/libssh2/libssh2_config.h @@ -23,7 +23,7 @@ static inline int writev(int sock, struct iovec *iov, int nvecs) } /* not really usleep, but safe for the way we use it in this lib */ -static inline int usleep(int udelay) +static inline int u_sleep(int udelay) { Sleep(udelay / 1000); return 0; diff --git a/pandora_agents/win32/ssh/libssh2/packet.c b/pandora_agents/win32/ssh/libssh2/packet.c index 859dde9d3a..d0ba708a56 100644 --- a/pandora_agents/win32/ssh/libssh2/packet.c +++ b/pandora_agents/win32/ssh/libssh2/packet.c @@ -673,7 +673,7 @@ static int libssh2_blocking_read(LIBSSH2_SESSION *session, unsigned char *buf, s if (polls++ > LIBSSH2_SOCKET_POLL_MAXLOOPS) { return -1; } - usleep(LIBSSH2_SOCKET_POLL_UDELAY); + u_sleep(LIBSSH2_SOCKET_POLL_UDELAY); #endif /* POLL/SELECT/SLEEP */ continue; } diff --git a/pandora_agents/win32/windows/pandora_wmi.cc b/pandora_agents/win32/windows/pandora_wmi.cc index 8f2b355f0e..fc27f1d81a 100644 --- a/pandora_agents/win32/windows/pandora_wmi.cc +++ b/pandora_agents/win32/windows/pandora_wmi.cc @@ -159,7 +159,7 @@ Pandora_Wmi::getDiskFreeSpace (string disk_id) { L".FreeSpace"); // 1048576 = 1024 * 1024 - return (unsigned long) free_space / 1048576; + return (unsigned long) (free_space / 1048576); } NEXT_THROW (quickfix); } catch (string errstr) { pandoraLog ("getDiskFreeSpace error. %s", errstr.c_str ());