diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index b105a8c654..c5437d2225 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -1141,7 +1141,7 @@ sub guess_os_version { # Linux if ($os eq 'linux') { - $os_version = `lsb_release -sd 2>$DevNull`; + $os_version = `cat /etc/*ease|grep PRETTY| cut -f 2 -d= | tr -d '"' 2>$DevNull`; # AIX } elsif ($os eq 'aix') { $os_version = "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/); diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index e81a2dd077..735369d2e7 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.760-220328 +Version: 7.0NG.760-220330 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 d7fb7a340c..b2cb2ea88b 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.760-220328" +pandora_version="7.0NG.760-220330" 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 e60ee431d1..19f6a16d7b 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.760'; -use constant AGENT_BUILD => '220328'; +use constant AGENT_BUILD => '220330'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -2736,7 +2736,7 @@ sub guess_os_version ($) { # Linux if ($os eq 'linux') { - $os_version = `lsb_release -sd 2>$DevNull`; + $os_version = `cat /etc/*ease|grep PRETTY| cut -f 2 -d= | tr -d '"' 2>$DevNull`; # AIX } elsif ($os eq 'aix') { $os_version = "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/); diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 03257eafbc..bd18df8bce 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.760 -%define release 220328 +%define release 220330 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 90ea38e90a..78979d3707 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.760 -%define release 220328 +%define release 220330 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 14fb1d1b35..b1b855189b 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.760" -PI_BUILD="220328" +PI_BUILD="220330" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 7f01f316d2..225f8c74a0 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220328} +{220330} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 8acc633dbe..995f60c249 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.760 Build 220328") +#define PANDORA_VERSION ("7.0NG.760 Build 220330") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 56bc41ab03..cf91832174 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.760(Build 220328))" + VALUE "ProductVersion", "(7.0NG.760(Build 220330))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 0d701e3883..b91cb91ee5 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.760-220328 +Version: 7.0NG.760-220330 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 72783aa7f8..09fdcd3c0a 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.760-220328" +pandora_version="7.0NG.760-220330" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/files_repo.php b/pandora_console/extensions/files_repo.php index 34e5fe52d2..c319954748 100644 --- a/pandora_console/extensions/files_repo.php +++ b/pandora_console/extensions/files_repo.php @@ -145,7 +145,7 @@ function pandora_files_repo_godmode() // Check for an anoying error that causes the $_POST and $_FILES arrays. // were empty if the file is larger than the post_max_size. if (intval($server_content_length) > 0 && empty($_POST)) { - ui_print_error_message(__('The file exceeds the maximum size')); + ui_print_error_message(__('Problem uploading. Please check this PHP runtime variable values:
post_max_size (currently '.ini_get('post_max_size').')')); } // GET and POST parameters. diff --git a/pandora_console/extensions/files_repo/files_repo_list.php b/pandora_console/extensions/files_repo/files_repo_list.php index cc1584dc17..783e155dc4 100644 --- a/pandora_console/extensions/files_repo/files_repo_list.php +++ b/pandora_console/extensions/files_repo/files_repo_list.php @@ -77,7 +77,7 @@ if (!empty($files)) { $file_name = explode('/', $file['location']); $file_decoded = $file_name[(count($file_name) - 1)]; $file_path = base64_encode($file_decoded); - $hash = md5($file_path.$config['dbpass']); + $hash = md5($file_path.$config['server_unique_identifier']); $url = ui_get_full_url( 'include/get_file.php?file='.urlencode($file_path).'&hash='.$hash ); diff --git a/pandora_console/extras/mr/53.sql b/pandora_console/extras/mr/53.sql index 86553a4e34..6dbda9a59f 100644 --- a/pandora_console/extras/mr/53.sql +++ b/pandora_console/extras/mr/53.sql @@ -1,6 +1,10 @@ START TRANSACTION; ALTER TABLE `tipam_vlan` ADD COLUMN `custom_id` bigint(20) unsigned DEFAULT NULL; +ALTER TABLE `tuser_task_scheduled`ADD COLUMN `enabled` TINYINT UNSIGNED NOT NULL DEFAULT 1; + +ALTER TABLE tagente MODIFY alias varchar(600) NOT NULL DEFAULT ''; +ALTER TABLE tagente MODIFY nombre varchar(600) NOT NULL DEFAULT ''; UPDATE `tuser_task` SET `parameters` = 'a:3:{i:0;a:2:{s:11:"description";s:11:"Description";s:4:"type";s:4:"text";}i:1;a:3:{s:11:"description";s:20:"Save to disk in path";s:4:"type";s:6:"string";s:13:"default_value";s:21:"_%_ATTACHMENT_PATH_%_";}i:2;a:3:{s:11:"description";s:14:"Active backups";s:4:"type";s:6:"number";s:13:"default_value";i:3;}}' WHERE `function_name` = 'cron_task_do_backup'; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_759.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_759.mysql.sql index 535182d147..fcedcf16ae 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_759.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_759.mysql.sql @@ -1664,7 +1664,8 @@ UPDATE tagente SET tagente.alias = tagente.nombre; ALTER TABLE `tagente` MODIFY COLUMN `remote` tinyint(1) NOT NULL DEFAULT '0', MODIFY COLUMN `cascade_protection_module` int(10) unsigned NOT NULL DEFAULT '0', MODIFY COLUMN `update_secondary_groups` tinyint(1) NOT NULL DEFAULT '0', - MODIFY COLUMN `alias` varchar(600) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', + MODIFY COLUMN `alias` varchar(600) NOT NULL DEFAULT '', + MODIFY COLUMN `nombre` varchar(600) NOT NULL DEFAULT '', MODIFY COLUMN `alias_as_name` tinyint(2) NOT NULL DEFAULT '0'; -- --------------------------------------------------------------------- diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index f4a10a3fbb..ba690e8ce6 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -133,6 +133,11 @@ class DiscoveryTaskList extends HTML return $this->deleteConsoleTask(); } + $toggle_console_task = (int) get_parameter('toggle_console_task', -1); + if ($toggle_console_task === 1 || $toggle_console_task === 0) { + return $this->toggleConsoleTask($toggle_console_task); + } + $delete = (bool) get_parameter('delete', false); if ($delete === true) { return $this->deleteTask(); @@ -321,6 +326,49 @@ class DiscoveryTaskList extends HTML } + /** + * Toggle enable/disable status of selected Console Task. + * + * @param integer $enable If 1 enable the console task. + * + * @return void + */ + public function toggleConsoleTask(int $enable) + { + global $config; + + if ((bool) check_acl($config['id_user'], 0, 'RM') === false) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return; + } + + $id_console_task = (int) get_parameter('id_console_task'); + + if ($id_console_task > 0) { + $result = db_process_sql_update( + 'tuser_task_scheduled', + ['enabled' => $enable], + ['id' => $id_console_task] + ); + + if ((int) $result === 1) { + return [ + 'result' => 0, + 'msg' => ((bool) $enable === true) ? __('Task successfully enabled') : __('Task succesfully disabled'), + 'id' => false, + ]; + } + + // Trick to avoid double execution. + header('Location: '.$this->url); + } + } + + /** * Delete a Console task. * diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index e8a0d5831a..8daf7bb786 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -26,6 +26,8 @@ * ============================================================================ */ +use PandoraFMS\Enterprise\Metaconsole\Node; + // Begin. global $config; @@ -86,6 +88,7 @@ $get_event_filters = get_parameter('get_event_filters', 0); $get_comments = (bool) get_parameter('get_comments', false); $get_events_fired = (bool) get_parameter('get_events_fired'); $get_id_source_event = get_parameter('get_id_source_event'); +$node_id = (int) get_parameter('node_id', 0); if ($get_comments === true) { $event = get_parameter('event', false); $filter = get_parameter('filter', false); @@ -195,7 +198,23 @@ if ($delete_event) { return; } - $r = events_delete($id_evento, $filter); + if ($node_id > 0) { + try { + $node = new Node($node_id); + $node->connect(); + $r = events_delete($id_evento, $filter, false, true); + } catch (\Exception $e) { + // Unexistent agent. + $node->disconnect(); + $success = false; + echo 'owner_error'; + } finally { + $node->disconnect(); + } + } else { + $r = events_delete($id_evento, $filter); + } + if ($r === false) { echo 'Failed'; } else { @@ -1261,18 +1280,42 @@ if ($change_status) { $event_ids = get_parameter('event_ids'); $new_status = get_parameter('new_status'); - $return = events_change_status( - explode(',', $event_ids), - $new_status, - $meta, - $history - ); + if ($node_id > 0) { + try { + $node = new Node($node_id); + $node->connect(); + $return = events_change_status( + explode(',', $event_ids), + $new_status, + $meta, + $history + ); + } catch (\Exception $e) { + // Unexistent agent. + $node->disconnect(); + $success = false; + echo 'owner_error'; + } finally { + $node->disconnect(); + } + } else { + $return = events_change_status( + explode(',', $event_ids), + $new_status, + $meta, + $history + ); + } if ($return !== false) { + $event_st = events_display_status($new_status); + echo json_encode( [ - 'status' => 'status_ok', - 'user' => db_get_value( + 'status_title' => $event_st['title'], + 'status_img' => html_print_image($event_st['img'], true, false, true), + 'status' => 'status_ok', + 'user' => db_get_value( 'fullname', 'tusuario', 'id_user', @@ -1306,7 +1349,22 @@ if ($change_owner) { $new_owner = ''; } - $return = events_change_owner($event_id, $new_owner, true, $meta, $history); + if ($node_id > 0) { + try { + $node = new Node($node_id); + $node->connect(); + $return = events_change_owner($event_id, $new_owner, true, $meta, $history); + } catch (\Exception $e) { + // Unexistent agent. + $node->disconnect(); + $success = false; + echo 'owner_error'; + } finally { + $node->disconnect(); + } + } else { + $return = events_change_owner($event_id, $new_owner, true, $meta, $history); + } if ($return) { echo 'owner_ok'; @@ -1322,7 +1380,7 @@ if ($change_owner) { if ($get_extended_event) { global $config; - $event = get_parameter('event', false); + $event = io_safe_output(get_parameter('event', false)); $filter = get_parameter('filter', false); if ($event === false) { @@ -1411,6 +1469,9 @@ if ($get_extended_event) { // Print group_rep in a hidden field to recover it from javascript. html_print_input_hidden('group_rep', (int) $group_rep); + if ($node_id > 0) { + html_print_input_hidden('node_id', (int) $node_id); + } if ($event === false) { return; @@ -1578,14 +1639,16 @@ if ($get_extended_event) { $comments = ''; - $notifications = '
upload_max_filesize (currently '.ini_get('upload_max_filesize').')'); break; case UPLOAD_ERR_FORM_SIZE: diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php index bbbac884b5..a311b7ec4a 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -1,23 +1,32 @@ '; - $data[0] .= html_print_image( - 'images/target.png', - true, - [ - 'title' => __('Force run'), - 'class' => 'invert_filter', - ] - ); - $data[0] .= ''; + if ((bool) $task['enabled'] === true) { + $data[0] = html_print_anchor( + [ + 'href' => sprintf( + '%sforce_run=1&id_console_task=%s', + $url, + $task['id'] + ), + 'content' => html_print_image( + 'images/target.png', + true, + [ + 'title' => __('Force run'), + 'class' => 'invert_filter', + ] + ), + ], + true + ); + } else { + $data[0] = ''; + } $data[1] = $task['id_usuario']; $data[2] = db_get_value( @@ -501,18 +521,25 @@ function cron_list_table() break; case 'cron_task_generate_report': - if ($write_perms || $manage_pandora) { - $data[0] = ''; - $data[0] .= html_print_image( - 'images/target.png', - true, + if ((bool) $task['enabled'] === true && ($write_perms === true || $manage_pandora === true)) { + $data[0] = html_print_anchor( [ - 'title' => __('Force run'), - 'class' => 'invert_filter', - ] + 'href' => sprintf( + '%sforce_run=1&id_user_task=%s', + $url, + $task['id'] + ), + 'content' => html_print_image( + 'images/target.png', + true, + [ + 'title' => __('Force run'), + 'class' => 'invert_filter', + ] + ), + ], + true ); - $data[0] .= ''; } else { $data[0] = ''; } @@ -549,18 +576,25 @@ function cron_list_table() break; case 'cron_task_generate_report_by_template': - if ($write_perms || $manage_pandora) { - $data[0] = ''; - $data[0] .= html_print_image( - 'images/target.png', - true, + if ((bool) $task['enabled'] === true && ($write_perms === true || $manage_pandora === true)) { + $data[0] = html_print_anchor( [ - 'title' => __('Force run'), - 'class' => 'invert_filter', - ] + 'href' => sprintf( + '%sforce_run=1&id_user_task=%s', + $url, + $task['id'] + ), + 'content' => html_print_image( + 'images/target.png', + true, + [ + 'title' => __('Force run'), + 'class' => 'invert_filter', + ] + ), + ], + true ); - $data[0] .= ''; } else { $data[0] = ''; } @@ -634,18 +668,25 @@ function cron_list_table() break; case 'cron_task_execute_custom_script': - if ($manage_pandora) { - $data[0] = ''; - $data[0] .= html_print_image( - 'images/target.png', - true, + if ((bool) $task['enabled'] === true) { + $data[0] = html_print_anchor( [ - 'title' => __('Force run'), - 'class' => 'invert_filter', - ] + 'href' => sprintf( + '%sforce_run=1&id_user_task=%s', + $url, + $task['id'] + ), + 'content' => html_print_image( + 'images/target.png', + true, + [ + 'title' => __('Force run'), + 'class' => 'invert_filter', + ] + ), + ], + true ); - $data[0] .= ''; } else { $data[0] = ''; } @@ -663,18 +704,25 @@ function cron_list_table() break; case 'cron_task_save_report_to_disk': - if ($write_perms || $manage_pandora) { - $data[0] = ''; - $data[0] .= html_print_image( - 'images/target.png', - true, + if ((bool) $task['enabled'] === true) { + $data[0] = html_print_anchor( [ - 'title' => __('Force run'), - 'class' => 'invert_filter', - ] + 'href' => sprintf( + '%sforce_run=1&id_user_task=%s', + $url, + $task['id'] + ), + 'content' => html_print_image( + 'images/target.png', + true, + [ + 'title' => __('Force run'), + 'class' => 'invert_filter', + ] + ), + ], + true ); - $data[0] .= ''; } else { $data[0] = ''; } @@ -702,18 +750,25 @@ function cron_list_table() break; case 'cron_task_save_xml_report_to_disk': - if ($write_perms || $manage_pandora) { - $data[0] = ''; - $data[0] .= html_print_image( - 'images/target.png', - true, + if ((bool) $task['enabled'] === true && ($write_perms === true || $manage_pandora === true)) { + $data[0] = html_print_anchor( [ - 'title' => __('Force run'), - 'class' => 'invert_filter', - ] + 'href' => sprintf( + '%sforce_run=1&id_user_task=%s', + $url, + $task['id'] + ), + 'content' => html_print_image( + 'images/target.png', + true, + [ + 'title' => __('Force run'), + 'class' => 'invert_filter', + ] + ), + ], + true ); - $data[0] .= ''; } else { $data[0] = ''; } @@ -734,22 +789,28 @@ function cron_list_table() $data[2] .= '&id='.$args[0]."'>".$report['name'].''; $data[2] .= '