diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index e9d22f629b..015f306205 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.731-190226 +Version: 7.0NG.731-190227 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 64c13e926e..4e132515b9 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.731-190226" +pandora_version="7.0NG.731-190227" 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 bb7d98e310..97b13365d3 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.731'; -use constant AGENT_BUILD => '190226'; +use constant AGENT_BUILD => '190227'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index d4e33903d4..ce3173b9f3 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190226 +%define release 190227 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 87436366bb..f5be518e22 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190226 +%define release 190227 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 3ff9b6a963..e27ad14333 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190226" +PI_BUILD="190227" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index abdf2e0ce4..3d62982f64 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190226} +{190227} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 01f027089d..8ce589ce8a 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.731(Build 190226)") +#define PANDORA_VERSION ("7.0NG.731(Build 190227)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index cb30f2163d..f54a5ebd36 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.731(Build 190226))" + VALUE "ProductVersion", "(7.0NG.731(Build 190227))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index fe87752dff..8ece3fcc84 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.731-190226 +Version: 7.0NG.731-190227 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 60d17de09e..ea4a0bd5a1 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.731-190226" +pandora_version="7.0NG.731-190227" package_pear=0 package_pandora=1 diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index ff370a5c48..b04643e1c3 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -112,6 +112,7 @@ $edit_file = get_parameter('edit_file', false); $update_file = get_parameter('update_file', false); $plugin_command = get_parameter('plugin_command', ''); $tab = get_parameter('tab', ''); +$deploy_plugin = get_parameter('deploy_plugin', 0); if ($view != '') { $form_id = $view; @@ -192,9 +193,8 @@ if ($filemanager) { // If is win compatible and the compatibility must be unix if ($is_win_compatible !== false && $compatibility == 'unix') { $contentFile = str_replace("\r\n", "\n", $contentFile); - } - // If is unix compatible and the compatibility must be win - else if ($is_win_compatible === false && $compatibility == 'windows') { + } else if ($is_win_compatible === false && $compatibility == 'windows') { + // If is unix compatible and the compatibility must be win $contentFile = str_replace("\n", "\r\n", $contentFile); } @@ -268,12 +268,16 @@ if ($filemanager) { // ===================================================================== $sec = 'gservers'; -if (($create != '') or ($view != '')) { +if (($create != '') || ($view != '')) { enterprise_hook('open_meta_frame'); if (defined('METACONSOLE')) { components_meta_print_header(); $sec = 'advanced'; + $management_allowed = is_management_allowed(); + if (!$management_allowed) { + ui_print_warning_message(__('To manage plugin you must activate centralized management')); + } } else { if ($create != '') { ui_print_page_header( @@ -292,6 +296,16 @@ if (($create != '') or ($view != '')) { true ); } + + $management_allowed = !is_central_policies_on_node(); + if (!$management_allowed) { + ui_print_warning_message( + __( + 'This console is not manager of this environment, + please manage this feature from centralized manager console (Metaconsole).' + ) + ); + } } @@ -564,9 +578,53 @@ if (($create != '') or ($view != '')) { if (defined('METACONSOLE')) { components_meta_print_header(); $sec = 'advanced'; + $management_allowed = is_management_allowed(); + if (!$management_allowed) { + ui_print_warning_message(__('To manage plugin you must activate centralized management')); + } + + if (!$config['metaconsole_deploy_plugin_server'] && $management_allowed) { + $deploy_plugin_server = true; + + echo '
'; + ?> + + '; @@ -576,9 +634,8 @@ if (($create != '') or ($view != '')) { } - // Update plugin + // Update plugin. if (isset($_GET['update_plugin'])) { - // if modified any parameter $plugin_id = get_parameter('update_plugin', 0); $plugin_name = get_parameter('form_name', ''); $plugin_description = get_parameter('form_description', ''); @@ -709,12 +766,15 @@ if (($create != '') or ($view != '')) { $result = db_process_sql_delete('tplugin', ['id' => $plugin_id]); - if (! $result) { - ui_print_error_message(__('Problem deleting plugin')); - } else { - ui_print_success_message(__('Plugin deleted successfully')); + if (!is_metaconsole()) { + if (!$result) { + ui_print_error_message(__('Problem deleting plugin')); + } else { + ui_print_success_message(__('Plugin deleted successfully')); + } } + if ($plugin_id != 0) { // Delete all the modules with this plugin $plugin_modules = db_get_all_rows_filter( @@ -737,6 +797,153 @@ if (($create != '') or ($view != '')) { policies_change_delete_pending_module($policies_id['id']); } } + + if (is_metaconsole()) { + enterprise_include_once('include/functions_plugins.php'); + $result = plugins_delete_plugin($plugin_id); + if (!$result) { + ui_print_error_message(__('Problem deleting plugin')); + } else { + ui_print_success_message(__('Plugin deleted successfully')); + } + } + } + } + + if ($deploy_plugin) { + if (is_metaconsole()) { + enterprise_include_once('include/functions_plugins.php'); + $result = plugins_deploy_plugin($deploy_plugin); + if (!$result) { + ui_print_error_message(__('Problem deploying plugin')); + } else { + ui_print_success_message(__('Plugin deployed successfully')); + } + } + } + + if ($deploy_plugin_server) { + $setup = db_get_all_rows_in_table('tmetaconsole_setup'); + // recorremos todos los nodos. + foreach ($setup as $key => $value) { + // Obtenemos los plugins de la meta. + $all_plugin_meta = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false); + // Conectamos con el nodo. + if (metaconsole_connect($value) == NOERR) { + $values = []; + // Obtenemos los plugin del nodo. + $node_plugin_server = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false); + foreach ($node_plugin_server as $key2 => $plugin) { + // Comprobamos si el id esta meta y nodo al mismo tiempo. + $key_exists = array_search($plugin['id'], array_column($all_plugin_meta, 'id')); + if ($key_exists !== false) { + // Si el plugin tiene el mismo id pero diferentes datos. + if ($all_plugin_meta[$key_exists] != $plugin) { + $old_id = $plugin['id']; + $new_id = ($plugin['id'] + (1000 * $value['id'])); + + // El plugin del nodo pasa a tener otro id y otro nombre. + $plugin['id'] = $new_id; + $plugin['name'] = $plugin['name'].'_'.$value['server_name']; + $result_update = db_process_sql_update( + 'tplugin', + [ + 'id' => $new_id, + 'name' => $plugin['name'], + ], + ['id' => $old_id] + ); + + if ($result_update) { + db_process_sql_update( + 'tagente_modulo', + ['id_plugin' => $new_id], + ['id_plugin' => $old_id] + ); + + db_process_sql_update( + 'tnetwork_component', + ['id_plugin' => $new_id], + ['id_plugin' => $old_id] + ); + + db_process_sql_update( + 'tpolicy_modules', + ['id_plugin' => $new_id], + ['id_plugin' => $old_id] + ); + } + + // New plugins to insert in the metaconsole. + $values[$plugin['id']] = $plugin; + } + } else { + // Exists in the node, but does not exist in the metaconsole. + $values[$plugin['id']] = $plugin; + } + } + + // Restore to metaconsole. + metaconsole_restore_db(); + + // Insert in metaconsole. + if (!empty($values)) { + foreach ($values as $key2 => $val) { + // Insert into metaconsole. + $result_insert = db_process_sql_insert('tplugin', $val); + } + } + } + } + + $all_plugin_meta = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false); + + foreach ($setup as $key => $value) { + if (metaconsole_connect($value) == NOERR) { + $all_plugin_node = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false); + + $array_diff = array_diff(array_column($all_plugin_meta, 'id'), array_column($all_plugin_node, 'id')); + foreach ($array_diff as $key2 => $pluginid) { + $other = []; + $plugin_meta = $all_plugin_meta[$key2]; + + unset($plugin_meta['id']); + $other['name'] = urlencode($plugin_meta['name']); + $other['description'] = urlencode($plugin_meta['description']); + $other['max_timeout'] = $plugin_meta['max_timeout']; + $other['max_retries'] = $plugin_meta['max_retries']; + $other['execute'] = urlencode($plugin_meta['execute']); + $other['net_dst_opt'] = $plugin_meta['net_dst_opt']; + $other['net_port_opt'] = $plugin_meta['net_port_opt']; + $other['user_opt'] = $plugin_meta['user_opt']; + $other['pass_opt'] = $plugin_meta['pass_opt']; + $other['plugin_type'] = $plugin_meta['plugin_type']; + $other['macros'] = urlencode($plugin_meta['macros']); + $other['parameters'] = urlencode($plugin_meta['parameters']); + $other = implode('%7C', $other); + + $auth_token = json_decode($value['auth_token']); + $url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7C&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password"; + $file_path = realpath($plugin_meta['execute']); + $post = ''; + if (file_exists($file_path)) { + $post = ['file' => curl_file_create($file_path)]; + } + + $curlObj = curl_init(); + curl_setopt($curlObj, CURLOPT_URL, $url); + curl_setopt($curlObj, CURLOPT_POST, 1); + curl_setopt($curlObj, CURLOPT_POSTFIELDS, $post); + curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, false); + + $api_result = curl_exec($curlObj); + curl_close($curlObj); + } + } + + // restore to metaconsole + metaconsole_restore_db(); } } @@ -753,7 +960,10 @@ if (($create != '') or ($view != '')) { echo ''; - echo " |