diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index b44dc853ae..8531120360 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -618,7 +618,7 @@ if (enterprise_installed()) { $plugins = $agent_plugin->getPlugins(); // Check if some plugin was enabled/disabled in conf. foreach ($plugins as $key => $row) { - if (preg_match('/(pandora_hardening).*/', $row['raw']) === 1) { + if (preg_match('/pandora_hardening/', $row['raw']) === 1) { if ($row['disabled'] === 1) { $security_hardening = 0; } else { @@ -626,19 +626,42 @@ if (enterprise_installed()) { } } - if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) { - if ($row['disabled'] === 1) { - $enable_log_collector = 0; - } else { - $enable_log_collector = 1; + if ($id_os === '1' || $id_os === '8') { + if (preg_match('/(module_plugin grep_log_module ).*/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $enable_log_collector = 0; + } else { + $enable_log_collector = 1; + } + } + + if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $enable_inventory = 0; + } else { + $enable_inventory = 1; + } + } + } else { + if (preg_match('/PROGRAMFILES%.Pandora_Agent.util.software_installed.vbs/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $enable_inventory = 0; + } else { + $enable_inventory = 1; + } } } + } - if (preg_match('/(module_plugin inventory).*/', $row['raw']) === 1) { - if ($row['disabled'] === 1) { - $enable_inventory = 0; - } else { - $enable_inventory = 1; + if ($id_os === '9') { + $modules = $agent_plugin->getModules(); + foreach ($modules as $key => $row) { + if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) { + if ($row['disabled'] === 1) { + $enable_log_collector = 0; + } else { + $enable_log_collector = 1; + } } } } diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index dfba48afc5..144c7996c8 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1259,7 +1259,7 @@ if ($update_agent) { foreach ($plugins as $key => $row) { // Only check plugins when agent package is bigger than 774. if ($options_package === '1') { - if (preg_match('/(pandora_hardening).*/', $row['raw']) === 1) { + if (preg_match('/pandora_hardening/', $row['raw']) === 1) { if ($security_hardening === 1) { if ($row['disabled'] === 1) { $agent->enablePlugins($row['raw']); @@ -1296,6 +1296,34 @@ if ($update_agent) { } } } + + // Inventory switch enable when basic options are enabled. + if (preg_match('/PROGRAMFILES%.Pandora_Agent.util.software_installed.vbs/', $row['raw']) === 1) { + if ($enable_inventory === 1) { + if ($row['disabled'] === 1) { + $agent->enablePlugins($row['raw']); + } + } else { + if ($row['disabled'] !== 1) { + $agent->disablePlugins($row['raw']); + } + } + } + } + + $modules = $agent->getModules(); + foreach ($modules as $key => $row) { + if (preg_match('/PandoraAgent_log/', $row['raw']) === 1) { + if ($enable_log_collector === 1) { + if ($row['disabled'] === 1) { + $agent->enableModule($row['module_name'], $row); + } + } else { + if ($row['disabled'] !== 1) { + $agent->disableModule($row['module_name'], $row); + } + } + } } } }