diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index 88f78e31ac..50e901f0ce 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -585,7 +585,7 @@ sub write_broker_conf($){ # Change the agent name if ($line =~ m/^\s*#*\s*agent_name\s+/) { - $line = "agent_name $broker_agent\n"; + $line = "agent_name $broker_agent\n#broker active\n"; } # Change the logfile elsif ($line =~ m/^\s*logfile\s+(.*)/) { diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index e7c241251a..c8ee8180a7 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.775-240123 +Version: 7.0NG.775-240126 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 00e1bec872..fa783cc923 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.775-240123" +pandora_version="7.0NG.775-240126" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 40317705f1..112e0419da 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1039,7 +1039,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.775'; -use constant AGENT_BUILD => '240123'; +use constant AGENT_BUILD => '240126'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -1860,7 +1860,7 @@ sub write_broker_conf($){ # Change the agent name if ($line =~ m/^\s*#*\s*agent_name\s+/) { - $line = "agent_name $broker_agent\n"; + $line = "agent_name $broker_agent\n#broker active\n"; } # Change the logfile elsif ($line =~ m/^\s*logfile\s+(.*)/) { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 8ed67cacd8..5c05e6110e 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240123 +%define release 240126 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec index e073b7a1b6..78383784e9 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240123 +%define release 240126 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec index ca44c46126..b21d106a96 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240123 +%define release 240126 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec index 857491d509..7a15966693 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240123 +%define release 240126 Summary: Pandora FMS Linux agent, binary version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 1491df0b07..337a0ec5f3 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240123 +%define release 240126 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 0232a6bf8c..2f6e9c4d3d 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240123" +PI_BUILD="240126" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/Makefile.am b/pandora_agents/win32/Makefile.am index 4641081570..94e77312c4 100644 --- a/pandora_agents/win32/Makefile.am +++ b/pandora_agents/win32/Makefile.am @@ -1,9 +1,9 @@ bin_PROGRAMS = PandoraAgent if DEBUG -PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp +PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_exec_powershell.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp PandoraAgent_CXXFLAGS=-g -O0 else -PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_logchannel.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc +PandoraAgent_SOURCES = misc/cron.cc misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_exec_powershell.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_logchannel.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc PandoraAgent_CXXFLAGS=-O2 endif diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 74ffb7b496..95fa0dd4a3 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{240123} +{240126} ViewReadme {Yes} diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index 2df46ad9d5..69a801e96b 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -236,6 +236,8 @@ Module_Kind Pandora_Module::parseModuleKindFromString (string kind) { if (kind == module_exec_str) { return MODULE_EXEC; + } else if (kind == module_exec_powershell_str) { + return MODULE_EXEC_POWERSHELL; } else if (kind == module_proc_str) { return MODULE_PROC; } else if (kind == module_service_str) { diff --git a/pandora_agents/win32/modules/pandora_module.h b/pandora_agents/win32/modules/pandora_module.h index 111fc79c79..bb19b266b2 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -94,7 +94,8 @@ namespace Pandora_Modules { MODULE_REGEXP, /**< The module searches a file for matches of a regular expression */ MODULE_PLUGIN, /**< Plugin */ MODULE_PING, /**< Ping module */ - MODULE_SNMPGET /**< SNMP get module */ + MODULE_SNMPGET, /**< SNMP get module */ + MODULE_EXEC_POWERSHELL /**< The module run a custom powershell command */ } Module_Kind; /** @@ -109,24 +110,25 @@ namespace Pandora_Modules { regex_t regexp; } Condition; - const string module_exec_str = "module_exec"; - const string module_proc_str = "module_proc"; - const string module_service_str = "module_service"; - const string module_freedisk_str = "module_freedisk"; - const string module_freedisk_percent_str = "module_freedisk_percent"; - const string module_freememory_str = "module_freememory"; - const string module_freememory_percent_str = "module_freememory_percent"; - const string module_cpuusage_str = "module_cpuusage"; - const string module_inventory_str = "module_inventory"; - const string module_logevent_str = "module_logevent"; - const string module_logchannel_str = "module_logchannel"; - const string module_wmiquery_str = "module_wmiquery"; - const string module_perfcounter_str = "module_perfcounter"; - const string module_tcpcheck_str = "module_tcpcheck"; - const string module_regexp_str = "module_regexp"; - const string module_plugin_str = "module_plugin"; - const string module_ping_str = "module_ping"; - const string module_snmpget_str = "module_snmpget"; + const string module_exec_str = "module_exec"; + const string module_proc_str = "module_proc"; + const string module_service_str = "module_service"; + const string module_freedisk_str = "module_freedisk"; + const string module_freedisk_percent_str = "module_freedisk_percent"; + const string module_freememory_str = "module_freememory"; + const string module_freememory_percent_str = "module_freememory_percent"; + const string module_cpuusage_str = "module_cpuusage"; + const string module_inventory_str = "module_inventory"; + const string module_logevent_str = "module_logevent"; + const string module_logchannel_str = "module_logchannel"; + const string module_wmiquery_str = "module_wmiquery"; + const string module_perfcounter_str = "module_perfcounter"; + const string module_tcpcheck_str = "module_tcpcheck"; + const string module_regexp_str = "module_regexp"; + const string module_plugin_str = "module_plugin"; + const string module_ping_str = "module_ping"; + const string module_snmpget_str = "module_snmpget"; + const string module_exec_powershell_str = "module_exec_powershell"; /** * Pandora module super-class exception. diff --git a/pandora_agents/win32/modules/pandora_module_exec_powershell.cc b/pandora_agents/win32/modules/pandora_module_exec_powershell.cc new file mode 100644 index 0000000000..99d37b7822 --- /dev/null +++ b/pandora_agents/win32/modules/pandora_module_exec_powershell.cc @@ -0,0 +1,91 @@ +/* Pandora exec module. These modules exec a powershell command. + + Copyright (c) 2006-2023 Pandora FMS. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "pandora_module_exec_powershell.h" +#include "../pandora_strutils.h" + +#include +#include +#include +#include +#include +#include + +#define EXEC_OK 0 +#define EXEC_ERR -1 +#define BUFSIZE 4096 + +using namespace Pandora; +using namespace Pandora_Strutils; +using namespace Pandora_Modules; + +/** + * Creates a Pandora_Module_Exec_Powershell object. + * + * @param name Module name + * @param exec Command to be executed. + */ +Pandora_Module_Exec_Powershell::Pandora_Module_Exec_Powershell(string name, string exec) + : Pandora_Module (name) { + + string escaped_exec; + + for (char c : exec) { + if (c == '"' || c == '\\') { + escaped_exec += '\\'; + } + escaped_exec += c; + } + + this->module_exec = "powershell -C \"" + escaped_exec + "\""; + + this->setKind (module_exec_powershell_str); +} + +void Pandora_Module_Exec_Powershell::run() { + string output_result; + + this->has_output = false; + + FILE* pipe = popen(this->module_exec.c_str(), "r"); + if (!pipe) { + pandoraLog ("Error while executing command.", GetLastError ()); + return; + } + + char buffer[BUFSIZE]; + while (fgets(buffer, BUFSIZE, pipe) != NULL) { + output_result += buffer; + } + + int result = pclose(pipe); + + if (result == EXEC_ERR) { + pandoraLog ("Error while closing command process.", GetLastError ()); + return; + } + + if (result != EXEC_OK) { + pandoraLog ("Error invalid powershell command.", GetLastError ()); + return; + } + + this->has_output = true; + this->setOutput (output_result); +} \ No newline at end of file diff --git a/pandora_agents/win32/modules/pandora_module_exec_powershell.h b/pandora_agents/win32/modules/pandora_module_exec_powershell.h new file mode 100644 index 0000000000..d3c9785c29 --- /dev/null +++ b/pandora_agents/win32/modules/pandora_module_exec_powershell.h @@ -0,0 +1,43 @@ +/* Pandora exec module. These modules exec a powershell command + + Copyright (c) 2006-2023 Pandora FMS. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef __PANDORA_MODULE_EXEC_POWERWSHELL_H__ +#define __PANDORA_MODULE_EXEC_POWERWSHELL_H__ + +#include "pandora_module.h" + +namespace Pandora_Modules { + /** + * Module to execute a powershell command. + * + * Any custom order that want to be executed can be put in + * the util directory into the Pandora agent path. + */ + class Pandora_Module_Exec_Powershell : public Pandora_Module { + + private: + string module_exec; + + public: + Pandora_Module_Exec_Powershell (string name, string exec); + void run (); + }; +} + +#endif diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index de149293ff..dd71dc2dd8 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -22,6 +22,7 @@ #include "pandora_module_factory.h" #include "pandora_module.h" #include "pandora_module_exec.h" +#include "pandora_module_exec_powershell.h" #include "pandora_module_proc.h" #include "pandora_module_service.h" #include "pandora_module_freedisk.h" @@ -129,6 +130,7 @@ using namespace Pandora_Strutils; #define TOKEN_ALERT_TEMPLATE ("module_alert_template") #define TOKEN_USER_SESSION ("module_user_session ") #define TOKEN_WAIT_TIMEOUT ("module_wait_timeout ") +#define TOKEN_EXEC_POWERSHELL ("module_exec_powershell ") string parseLine (string line, string token) { @@ -158,7 +160,7 @@ Pandora_Module * Pandora_Module_Factory::getModuleFromDefinition (string definition) { list tokens; list::iterator iter; - string module_name, module_type, module_exec; + string module_name, module_type, module_exec, module_exec_powershell; string module_min, module_max, module_description; string module_interval, module_absoluteinterval; string module_proc, module_service; @@ -268,6 +270,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_user_session = ""; macro = ""; module_wait_timeout = ""; + module_exec_powershell = ""; stringtok (tokens, definition, "\n"); @@ -302,6 +305,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_exec == "") { module_exec = parseLine (line, TOKEN_EXEC); } + if (module_exec_powershell == "") { + module_exec_powershell = parseLine (line, TOKEN_EXEC_POWERSHELL); + } if (module_wait_timeout == "") { module_wait_timeout = parseLine (line, TOKEN_WAIT_TIMEOUT); } @@ -626,6 +632,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { } } + if (module_exec_powershell != "") { + pos_macro = module_exec_powershell.find(macro_name); + if (pos_macro != string::npos){ + module_exec_powershell.replace(pos_macro, macro_name.size(), macro_value); + } + } + if (module_proc != "") { pos_macro = module_proc.find(macro_name); if (pos_macro != string::npos){ @@ -1155,6 +1168,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module->setWaitTimeout (atoi (module_wait_timeout.c_str ())); } + } else if (module_exec_powershell != "") { + module = new Pandora_Module_Exec_Powershell (module_name, module_exec_powershell); + } else if (module_proc != "") { module = new Pandora_Module_Proc (module_name, module_proc); diff --git a/pandora_agents/win32/modules/pandora_module_list.cc b/pandora_agents/win32/modules/pandora_module_list.cc index be5cc32d45..b0612902a3 100644 --- a/pandora_agents/win32/modules/pandora_module_list.cc +++ b/pandora_agents/win32/modules/pandora_module_list.cc @@ -21,6 +21,7 @@ #include "pandora_module_factory.h" #include "pandora_module_list.h" #include "pandora_module_exec.h" +#include "pandora_module_exec_powershell.h" #include "pandora_module_proc.h" #include "pandora_module_service.h" #include "pandora_module_freedisk.h" @@ -235,6 +236,7 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition) Pandora_Module_Plugin *module_plugin; Pandora_Module_Ping *module_ping; Pandora_Module_SNMPGet *module_snmpget; + Pandora_Module_Exec_Powershell *module_exec_powershell; module = Pandora_Module_Factory::getModuleFromDefinition (definition); @@ -244,6 +246,11 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition) module_exec = (Pandora_Module_Exec *) module; modules->push_back (module_exec); + break; + case MODULE_EXEC_POWERSHELL: + module_exec_powershell = (Pandora_Module_Exec_Powershell *) module; + modules->push_back (module_exec_powershell); + break; case MODULE_PROC: module_proc = (Pandora_Module_Proc *) module; diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 8e094eedae..f3961807fe 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.775 Build 240123") +#define PANDORA_VERSION ("7.0NG.775 Build 240126") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index b7d17d6756..1bb160a879 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.775(Build 240123))" + VALUE "ProductVersion", "(7.0NG.775(Build 240126))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 4d832ca478..466722a50b 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.775-240123 +Version: 7.0NG.775-240126 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 95ee569569..a47efa89c2 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.775-240123" +pandora_version="7.0NG.775-240126" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index acaaadd12c..38bb7c2d8b 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -280,18 +280,17 @@ function dbmgr_extension_main() if (is_array($result) === false) { echo 'Output: '.$result; - - db_pandora_audit( - AUDIT_LOG_SYSTEM, - 'DB Interface Extension. SQL', - false, - false, - $sql - ); - return; } + db_pandora_audit( + AUDIT_LOG_SYSTEM, + 'DB Interface Extension. SQL', + false, + false, + $sql + ); + echo "
"; $table = new stdClass(); $table->width = '100%'; diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 6f09d889f7..98e8886733 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -223,7 +223,7 @@ function mainInsertData() '', empty($agent_id) ); - $table->data[1][2] = html_print_input_text('data', ($save === true) ? date(DATE_FORMAT) : $data, __('Data'), 10, 60, true); + $table->data[1][2] = html_print_input_text('date', ($save === true) ? date(DATE_FORMAT) : $data, __('Data'), 10, 60, true); $table->data[1][2] .= ' '; $table->data[1][2] .= html_print_input_text('time', ($save === true) ? date(TIME_FORMAT) : $time, '', 10, 7, true); @@ -283,8 +283,14 @@ function mainInsertData() secondText: '', currentText: '', closeText: ''}); - - $("#text-date").datepicker({dateFormat: ""}); + + $('#text-date').datepicker ({ + dateFormat: '', + changeMonth: true, + changeYear: true, + showAnim: 'slideDown', + firstDay: "", + }); $.datepicker.setDefaults($.datepicker.regional[ ""]); }); diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index 7ab19fe840..db168d5c22 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -1,5 +1,45 @@ START TRANSACTION; +CREATE TABLE IF NOT EXISTS `tmerge_error` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `step` int(10) default 0, + `msg` LONGTEXT default "", + `action` text default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tmerge_error` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + +CREATE TABLE IF NOT EXISTS `tmerge_steps` ( + `id` int(10) NOT NULL auto_increment, + `id_node` int(10) default 0, + `phase` int(10) default 0, + `total` int(10) default 0, + `step` int(10) default 0, + `debug` varchar(1024) default "", + `action` varchar(100) default "", + `affected` varchar(100) default "", + `query` mediumtext default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tmerge_steps` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + +CREATE TABLE IF NOT EXISTS `tmerge_queries` ( + `steps` int(10) NOT NULL auto_increment, + `action` varchar(100) default "", + `affected` varchar(100) default "", + `utimestamp` int(20) unsigned NOT NULL default 0, + `query` LONGTEXT NOT NULL default "", + PRIMARY KEY (`steps`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tmerge_queries` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; + -- Update version for plugin oracle UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.oracle'; @@ -16,4 +56,5 @@ ADD COLUMN `id_agent_data` int not null default 0 AFTER `script_type`; ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ; ALTER TABLE `tmensajes` ADD COLUMN `icon_notification` VARCHAR(250) NULL DEFAULT NULL AFTER `url`; + COMMIT; \ No newline at end of file diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 759e319dbd..ed583c7ed4 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -100,7 +100,7 @@ if ($initial && users_is_admin()) { ); } -if (check_acl($config['id_user'], 0, 'AW')) { +if (check_acl($config['id_user'], 0, 'AW') && empty($sec2)) { $welcome = !$initial; try { $welcome_window = new WelcomeWindow($welcome); diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 4e62337547..80a480dd12 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -500,21 +500,40 @@ $tableAgent->data['primary_group'][0] .= ui_print_group_icon( ); $tableAgent->data['primary_group'][0] .= ''; -$tableAgent->data['caption_interval'][0] = __('Interval'); -// $tableAgent->rowstyle['interval'] = 'width: 260px'; -$tableAgent->rowclass['interval'] = 'w540px'; -$tableAgent->data['interval'][0] = html_print_extended_select_for_time( - 'intervalo', - $intervalo, - '', - '', - '0', - 10, - true, - false, - true, - 'w33p' -); +$broker = false; +if (enterprise_installed()) { + // CHECK BROKER FOR SHOW INTERVAL. + enterprise_include('include/functions_config_agents.php'); + // Read configuration file. + $files = config_agents_get_agent_config_filenames($id_agente); + $file_name = $files['conf']; + $agent_config = file_get_contents($file_name); + $encoding = 'UTF-8'; + $agent_config_utf8 = mb_convert_encoding($agent_config, 'UTF-8', $encoding); + if ($agent_config_utf8 !== false) { + $agent_config = $agent_config_utf8; + } + + $broker = str_contains($agent_config, '#broker active'); +} + +if ($broker === false) { + $tableAgent->data['caption_interval'][0] = __('Interval'); + // $tableAgent->rowstyle['interval'] = 'width: 260px'; + $tableAgent->rowclass['interval'] = 'w540px'; + $tableAgent->data['interval'][0] = html_print_extended_select_for_time( + 'intervalo', + $intervalo, + '', + '', + '0', + 10, + true, + false, + true, + 'w33p' + ); +} if ($intervalo < SECONDS_5MINUTES) { $tableAgent->data['interval'][0] .= clippy_context_help('interval_agent_min'); diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 7809742221..499bbded5e 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -308,13 +308,18 @@ $table->head[0] = __('Actions'); $table->style[0] = 'font-weight: bold; text-align: left;'; if (count($actions) == 1 && isset($actions[0])) { - $table->head[1] = __('Every time that the alert is fired'); - $table->data[0][0] = $actions[0]['name']; - $table->data[0][1] = html_print_image( - 'images/tick.png', - true, - ['class' => 'invert_filter'] - ); + if (!empty($actions[0]['name'])) { + $table->head[1] = __('Every time that the alert is fired'); + $table->data[0][0] = $actions[0]['name']; + $table->data[0][1] = html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); + } else { + $table->colspan[0] = 2; + $table->data[0] = __('No action defined.'); + } } else { foreach ($actions as $kaction => $action) { $table->data[$kaction][0] = $action['name']; diff --git a/pandora_console/godmode/events/event_responses.editor.php b/pandora_console/godmode/events/event_responses.editor.php index ae31e10ad1..52d5a48ad1 100644 --- a/pandora_console/godmode/events/event_responses.editor.php +++ b/pandora_console/godmode/events/event_responses.editor.php @@ -285,20 +285,25 @@ if (enterprise_installed()) { $data = []; $data[0] = html_print_label_input_block( '', - '