From 3946124cc72cb652637fce1356db4b9c38acb513 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 19 Oct 2018 11:10:13 +0200 Subject: [PATCH 01/21] Inaugurate the 22 mr with an alter table in talert_commands --- pandora_console/extras/mr/22.sql | 5 +++++ .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 6 +++--- pandora_console/pandoradb.sql | 1 + pandora_console/pandoradb_data.sql | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 pandora_console/extras/mr/22.sql diff --git a/pandora_console/extras/mr/22.sql b/pandora_console/extras/mr/22.sql new file mode 100644 index 0000000000..8cb4ae9cd1 --- /dev/null +++ b/pandora_console/extras/mr/22.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0; + +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 079c9b5d23..29fb368fdb 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1159,8 +1159,8 @@ ALTER TABLE talert_actions ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT " -- Table `talert_commands` -- --------------------------------------------------------------------- UPDATE `talert_commands` SET `fields_descriptions` = '[\"Integria IMS API path\",\"Integria IMS API pass\",\"Integria IMS user\",\"Integria IMS user pass\",\"Ticket title\",\"Ticket group ID\",\"Ticket priority\",\"Email copy\",\"Ticket owner\",\"Ticket description\"]', `fields_values` = '[\"\",\"\",\"\",\"\",\"\",\"\",\"10,Maintenance;0,Informative;1,Low;2,Medium;3,Serious;4,Very Serious\",\"\",\"\",\"\"]' WHERE `id` = 11 AND `name` = 'Integria IMS Ticket'; - UPDATE `talert_commands` SET `description` = 'This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using: _field1_ as destination email address, and _field2_ as subject for message. _field3_ as text of message. _field4_ as content type (text/plain or html/text).', `fields_descriptions` = '[\"Destination address\",\"Subject\",\"Text\",\"Content Type\",\"\",\"\",\"\",\"\",\"\",\"\"]', `fields_values` = '[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id=1; +ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0; UPDATE `talert_actions` SET `field4` = 'text/html', `field4_recovery` = 'text/html' WHERE id = 1; @@ -1180,13 +1180,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 21); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 22); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '728'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '729'); -- --------------------------------------------------------------------- -- Table `tconfig_os` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8d2b64cfee..5a8ce06dc0 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -369,6 +369,7 @@ CREATE TABLE IF NOT EXISTS `talert_commands` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', `command` text, + `id_group` mediumint(8) unsigned NULL default 0, `description` text, `internal` tinyint(1) default 0, `fields_descriptions` TEXT, diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 7439fe087d..83e4d85ec5 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 21), +('MR', 22), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package_enterprise', '728'), +('current_package_enterprise', '729'), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'), ('custom_docs_logo', 'default_docs.png'), ('custom_support_logo', 'default_support.png'), From 8b0b23dc27c1ba091ab92f71864c954aefd4cd32 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 19 Oct 2018 13:14:00 +0200 Subject: [PATCH 02/21] Added group to alert commands update and creation --- .../godmode/alerts/alert_commands.php | 4 +- .../alerts/configure_alert_command.php | 42 ++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 09e868f951..f71b724947 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -273,6 +273,7 @@ if ($create_command) { $name = (string) get_parameter ('name'); $command = (string) get_parameter ('command'); $description = (string) get_parameter ('description'); + $id_group = (string) get_parameter ('id_group', 0); $fields_descriptions = array(); $fields_values = array(); @@ -287,7 +288,8 @@ if ($create_command) { $values['fields_values'] = io_json_mb_encode($fields_values); $values['fields_descriptions'] = io_json_mb_encode($fields_descriptions); $values['description'] = $description; - + $values['id_group'] = $id_group; + $name_check = db_get_value ('name', 'talert_commands', 'name', $name); if (!$name_check) { diff --git a/pandora_console/godmode/alerts/configure_alert_command.php b/pandora_console/godmode/alerts/configure_alert_command.php index 983b8d90ff..55254cdadf 100644 --- a/pandora_console/godmode/alerts/configure_alert_command.php +++ b/pandora_console/godmode/alerts/configure_alert_command.php @@ -54,6 +54,7 @@ if ($update_command) { $name = (string) get_parameter ('name'); $command = (string) get_parameter ('command'); $description = (string) get_parameter ('description'); + $id_group = (string) get_parameter ('id_group', 0); $fields_descriptions = array(); $fields_values = array(); @@ -71,7 +72,8 @@ if ($update_command) { $values['name'] = $name; $values['command'] = $command; $values['description'] = $description; - + $values['id_group'] = $id_group; + //Check it the new name is used in the other command. $id_check = db_get_value ('id', 'talert_commands', 'name', $name); if (($id_check != $id) && (!empty($id_check))) { @@ -100,12 +102,13 @@ $command = ''; $description = ''; $fields_descriptions = ''; $fields_values = ''; +$id_group = 0; if ($id) { $alert = alerts_get_alert_command ($id); $name = $alert['name']; $command = $alert['command']; $description = $alert['description']; - + $id_group = $alert['id_group']; $fields_descriptions = $alert['fields_descriptions']; $fields_values = $alert['fields_values']; } @@ -123,13 +126,7 @@ $table->width = '100%'; $table->class = 'databox filters'; if (defined('METACONSOLE')) { - if ($id) { - $table->head[0] = __('Update Command'); - } - else { - $table->head[0] = __('Create Command'); - } - + $table->head[0] = ($id) ? __('Update Command') : __('Create Command'); $table->head_colspan[0] = 4; $table->headstyle[0] = 'text-align: center'; } @@ -142,18 +139,25 @@ $table->size = array (); $table->size[0] = '20%'; $table->data = array (); -$table->colspan[0][1] = 3; -$table->data[0][0] = __('Name'); -$table->data[0][2] = html_print_input_text ('name', $name, '', 35, 255, true); +$table->colspan['name'][1] = 3; +$table->data['name'][0] = __('Name'); +$table->data['name'][2] = html_print_input_text ('name', $name, '', 35, 255, true); -$table->colspan[1][1] = 3; -$table->data[1][0] = __('Command'); -$table->data[1][0] .= ui_print_help_icon ('alert_macros', true); -$table->data[1][1] = html_print_textarea ('command', 8, 30, $command, '', true); +$table->colspan['command'][1] = 3; +$table->data['command'][0] = __('Command'); +$table->data['command'][0] .= ui_print_help_icon ('alert_macros', true); +$table->data['command'][1] = html_print_textarea ('command', 8, 30, $command, '', true); + +$table->colspan['group'][1] = 3; +$table->data['group'][0] = __('Group'); +$table->data['group'][1] = html_print_select_groups(false, "LM", + true, 'id_group', $id_group, false, + '', 0, true); + +$table->colspan['description'][1] = 3; +$table->data['description'][0] = __('Description'); +$table->data['description'][1] = html_print_textarea ('description', 10, 30, $description, '', true); -$table->colspan[2][1] = 3; -$table->data[2][0] = __('Description'); -$table->data[2][1] = html_print_textarea ('description', 10, 30, $description, '', true); for ($i = 1; $i <= $config['max_macro_fields']; $i++) { From b50b1c9f34bf97d345bacfa66e1576532e0bccd4 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 22 Oct 2018 10:08:25 +0200 Subject: [PATCH 03/21] Added group icon to alerts commands view --- .../godmode/alerts/alert_commands.php | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index f71b724947..033a59436c 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -347,45 +347,49 @@ $table->class = 'databox data'; $table->data = array (); $table->head = array (); -$table->head[0] = __('Name'); -$table->head[1] = __('ID'); -$table->head[2] = __('Description'); -$table->head[3] = __('Delete'); +$table->head['name'] = __('Name'); +$table->head['id'] = __('ID'); +$table->head['group'] = __('Group'); +$table->head['description'] = __('Description'); +$table->head['action'] = __('Delete'); $table->style = array (); -$table->style[0] = 'font-weight: bold'; +$table->style['name'] = 'font-weight: bold'; $table->size = array (); -$table->size[3] = '40px'; +$table->size['action'] = '40px'; $table->align = array (); -$table->align[3] = 'left'; +$table->align['action'] = 'left'; -$commands = db_get_all_rows_in_table ('talert_commands'); -if ($commands === false) - $commands = array (); +$commands = db_get_all_rows_filter( + 'talert_commands', + array('id_group' => array_keys(users_get_groups(false, "LM"))) +); +if ($commands === false) $commands = array (); foreach ($commands as $command) { $data = array (); - - $data[0] = ''; + + $data['name'] = ''; if (! $command['internal']) - $data[0] .= ''. + $data['name'] .= ''. $command['name'].''; else - $data[0] .= $command['name']; - $data[0] .= ''; - $data[1] = $command['id']; - $data[2] = str_replace("\r\n","
", + $data['name'] .= $command['name']; + $data['name'] .= '
'; + $data['id'] = $command['id']; + $data['group'] = ui_print_group_icon ($command["id_group"], true); + $data['description'] = str_replace("\r\n","
", io_safe_output($command['description'])); - $data[3] = ''; + $data['action'] = ''; if (! $command['internal']) { - $data[3] = ''. html_print_image("images/cross.png", true) . ''; } - + array_push ($table->data, $data); } -if (isset($data)) { +if (count($table->data) > 0) { html_print_table ($table); } else { From 1f299cad520d3c20f5794cb8dba636172d8374c4 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 22 Oct 2018 12:01:29 +0200 Subject: [PATCH 04/21] Added copy button to alert commands --- .../godmode/alerts/alert_commands.php | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 033a59436c..3a0178b37c 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -38,6 +38,7 @@ $pure = (int)get_parameter('pure', 0); $update_command = (bool) get_parameter ('update_command'); $create_command = (bool) get_parameter ('create_command'); $delete_command = (bool) get_parameter ('delete_command'); +$copy_command = (bool) get_parameter ('copy_command'); if (is_ajax ()) { $get_alert_command = (bool) get_parameter ('get_alert_command'); @@ -57,37 +58,13 @@ if (is_ajax ()) { if (isset($command['description'])) { $command['description'] = io_safe_input(str_replace("\r\n","
", io_safe_output($command['description']))); } - - // Get the html rows of the fields form - switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - // Descriptions are stored in json - $fields_descriptions = empty($command['fields_descriptions']) ? - '' : json_decode(io_safe_output($command['fields_descriptions']), true); - - // Fields values are stored in json - $fields_values = empty($command['fields_values']) ? - '' : io_safe_output(json_decode($command['fields_values'], true)); - break; - case "oracle": - // Descriptions are stored in json - $description_field = str_replace("\\\"","\"",$command['fields_descriptions']); - $description_field = str_replace("\\","",$description_field); - - $fields_descriptions = empty($command['fields_descriptions']) ? - '' : json_decode(io_safe_output($description_field), true); - - // Fields values are stored in json - $values_fields = str_replace("\\\"","\"",$command['fields_values']); - $values_fields = str_replace("\\","",$values_fields); - - $fields_values = empty($command['fields_values']) ? - '' : io_safe_output(json_decode($values_fields, true)); - - break; - } - + // Descriptions are stored in json + $fields_descriptions = empty($command['fields_descriptions']) ? + '' : json_decode(io_safe_output($command['fields_descriptions']), true); + // Fields values are stored in json + $fields_values = empty($command['fields_values']) ? + '' : io_safe_output(json_decode($command['fields_values'], true)); + $fields_rows = array(); for ($i = 1; $i <= $config['max_macro_fields']; $i++) { @@ -266,9 +243,6 @@ if (defined('METACONSOLE')) else ui_print_page_header (__('Alerts').' » '.__('Alert commands'), "images/gm_alerts.png", false, "alerts_config", true); - - - if ($create_command) { $name = (string) get_parameter ('name'); $command = (string) get_parameter ('command'); @@ -338,8 +312,29 @@ if ($delete_command) { ui_print_result_message ($result, __('Successfully deleted'), __('Could not be deleted')); - - +} + +if ($copy_command) { + $id = (int) get_parameter ('id'); + + // Get the info from the source command + $command_to_copy = db_get_row('talert_commands', 'id', $id); + if ($command_to_copy === false) { + ui_print_error_message(__("Command with id $id does not found.")); + break 2; + } + + // Prepare to insert the copy with same values + unset ($command_to_copy['id']); + $command_to_copy['name'].= __(' (copy)'); + $result = db_process_sql_insert('talert_commands', $command_to_copy); + + // Print the result + ui_print_result_message ($result, + __('Successfully copied'), + __('Could not be copied') + ); + } $table->width = '100%'; @@ -351,7 +346,7 @@ $table->head['name'] = __('Name'); $table->head['id'] = __('ID'); $table->head['group'] = __('Group'); $table->head['description'] = __('Description'); -$table->head['action'] = __('Delete'); +$table->head['action'] = __('Actions'); $table->style = array (); $table->style['name'] = 'font-weight: bold'; $table->size = array (); @@ -381,9 +376,14 @@ foreach ($commands as $command) { io_safe_output($command['description'])); $data['action'] = ''; if (! $command['internal']) { - $data['action'] = ''. + html_print_image("images/copy.png", true) . ''; + $data['action'].= ''. html_print_image("images/cross.png", true) . ''; + $data['action'].= ''; } array_push ($table->data, $data); From f537dbb961cb40ee1da166b47d0ce7cbdc1ab16e Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 22 Oct 2018 16:19:29 +0200 Subject: [PATCH 05/21] Validate the group command on action creation --- .../godmode/alerts/alert_actions.php | 119 +----------------- .../godmode/alerts/configure_alert_action.php | 11 ++ pandora_console/include/functions_alerts.php | 112 +++++++++++++++++ 3 files changed, 126 insertions(+), 116 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 3bad38b982..fd83bb6638 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -57,7 +57,7 @@ else { $sec = 'galertas'; } -if ((!$copy_action) && (!$delete_action) && (!$update_action)) { +if ((!$copy_action) && (!$delete_action)) { // Header if (defined('METACONSOLE')) { alerts_meta_print_header (); @@ -141,121 +141,8 @@ if ($copy_action) { __('Could not be copied')); } -if ($create_action) { - $name = (string) get_parameter ('name'); - $id_alert_command = (int) get_parameter ('id_command'); - - $fields_descriptions = array(); - $fields_values = array(); - $info_fields = ''; - $values = array(); - for($i=1;$i<=$config['max_macro_fields'];$i++) { - $values['field'.$i] = (string) get_parameter ('field'.$i.'_value'); - $info_fields .= ' Field'.$i.': ' . $values['field'.$i]; - $values['field'.$i.'_recovery'] = (string) get_parameter ('field'.$i.'_recovery_value'); - $info_fields .= ' Field'.$i.'Recovery: ' . $values['field'.$i.'_recovery']; - } - - $values['id_group'] = (string) get_parameter ('group'); - $values['action_threshold'] = (int) get_parameter ('action_threshold'); - - $name_check = db_get_value ('name', 'talert_actions', 'name', $name); - - if ($name_check) { - $result = ''; - } - else { - $result = alerts_create_alert_action ($name, $id_alert_command, - $values); - - $info = '{"Name":"'.$name.'", "ID alert Command":"'.$id_alert_command.'", "Field information":"'.$info_fields.'", "Group":"'.$values['id_group'].'", - "Action threshold":"'.$values['action_threshold'].'"}'; - } - - if ($result) { - db_pandora_audit("Command management", "Create alert action #" . $result, false, false, $info); - } - else { - db_pandora_audit("Command management", "Fail try to create alert action", false, false); - } - - ui_print_result_message ($result, - __('Successfully created'), - __('Could not be created')); -} - -if ($update_action) { - $id = (string) get_parameter ('id'); - - $al_action = alerts_get_alert_action ($id); - - if ($al_action !== false) { - if ($al_action['id_group'] == 0) { - if (! check_acl ($config['id_user'], 0, "PM")) { - db_pandora_audit("ACL Violation", - "Trying to access Alert Management"); - require ("general/noaccess.php"); - exit; - } - else { - // Header - if (defined('METACONSOLE')) { - alerts_meta_print_header (); - } - else { - ui_print_page_header (__('Alerts').' » '.__('Alert actions'), "images/gm_alerts.png", false, "alerts_config", true); - } - } - } - } - else { - // Header - if (defined('METACONSOLE')) { - alerts_meta_print_header (); - } - else { - ui_print_page_header (__('Alerts').' » '.__('Alert actions'), "images/gm_alerts.png", false, "alerts_config", true); - } - } - - - $name = (string) get_parameter ('name'); - $id_alert_command = (int) get_parameter ('id_command'); - $group = get_parameter ('group'); - $action_threshold = (int) get_parameter ('action_threshold'); - - $info_fields = ''; - $values = array(); - - for ($i = 1; $i <= $config['max_macro_fields']; $i++) { - $values['field'.$i] = (string) get_parameter ('field'.$i.'_value'); - $info_fields .= ' Field1: ' . $values['field'.$i]; - $values['field'.$i.'_recovery'] = (string) get_parameter ('field'.$i.'_recovery_value'); - $info_fields .= ' Field'.$i.'Recovery: ' . $values['field'.$i.'_recovery']; - } - - $values['name'] = $name; - $values['id_alert_command'] = $id_alert_command; - $values['id_group'] = $group; - $values['action_threshold'] = $action_threshold; - - if (!$name) { - $result = ''; - } - else { - $result = alerts_update_alert_action ($id, $values); - } - - if ($result) { - db_pandora_audit("Command management", "Update alert action #" . $id, false, false, json_encode($values)); - } - else { - db_pandora_audit("Command management", "Fail try to update alert action #" . $id, false, false, json_encode($values)); - } - - ui_print_result_message ($result, - __('Successfully updated'), - __('Could not be updated')); +if ($update_action || $create_action) { + alerts_ui_update_or_create_actions($update_action); } if ($delete_action) { diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index d1fe842469..88b72e4f8b 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -282,6 +282,17 @@ $(document).ready (function () { var max_fields = parseInt(''); + // Change the selected group + $("#group option").each(function(index, value) { + var current_group = $(value).val() + if (data.id_group != 0 && current_group != 0 && current_group != data.id_group) { + $(value).hide(); + } else { + $(value).show(); + } + }); + $("#group").val(0); + for (i = 1; i <= max_fields; i++) { var old_value = ''; var old_recovery_value = ''; diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 17cc0c8bde..752202ba1a 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -2268,5 +2268,117 @@ function alerts_normalize_actions_escalation($escalation) { return $escalation; } +/** + * Check if a command can be added to an action. + * + * @param int Action group id + * @param int Command group id + * + * @return False if command group and alert group are distint of 0 and they are not equal + */ +function alerts_validate_command_to_action($action_group, $command_group) { + // If action group or command group is All, all commands can be applicated. + if ($action_group == 0 || $command_group == 0) return true; + return $action_group == $command_group; +} + +/** + * Print the UI update actions + * + * @param bool Update or create + */ +function alerts_ui_update_or_create_actions($update = true) { + global $config; + $id = (string) get_parameter ('id'); + + // Check ACL of existing aler action + if($update) { + $al_action = alerts_get_alert_action ($id); + if ($al_action !== false) { + if ($al_action['id_group'] == 0) { + if (! check_acl ($config['id_user'], 0, "PM")) { + db_pandora_audit("ACL Violation", + "Trying to access Alert Management"); + require ("general/noaccess.php"); + exit; + } + } + } + } + + $name = (string) get_parameter ('name'); + $id_alert_command = (int) get_parameter ('id_command'); + $group = get_parameter ('group'); + $action_threshold = (int) get_parameter ('action_threshold'); + + // Validate the command + if (!$id_alert_command) { + ui_print_error_message(__('Invalid alert command.')); + return; + } + $comamnd_group = db_get_value('id_group', 'talert_commands', 'id', $id_alert_command); + if(!alerts_validate_command_to_action($group, $comamnd_group)) { + ui_print_error_message(__("Alert and command group does not match")); + return; + } + + // Fill fields info + $info_fields = ''; + $values = array(); + for ($i = 1; $i <= $config['max_macro_fields']; $i++) { + $values['field'.$i] = (string) get_parameter ('field'.$i.'_value'); + $info_fields .= ' Field'.$i.': ' . $values['field'.$i]; + $values['field'.$i.'_recovery'] = (string) get_parameter ('field'.$i.'_recovery_value'); + $info_fields .= ' Field'.$i.'Recovery: ' . $values['field'.$i.'_recovery']; + } + + $values['id_group'] = $group; + $values['action_threshold'] = $action_threshold; + if ($update) { + $values['name'] = $name; + $values['id_alert_command'] = $id_alert_command; + $result = (!$name) ? '' : alerts_update_alert_action ($id, $values); + } else { + $name_check = db_get_value ('name', 'talert_actions', 'name', $name); + if ($name_check) { + $result = ''; + } + else { + $result = alerts_create_alert_action ($name, $id_alert_command, + $values); + $values = array( + "Name" => $name, + "ID alert Command" => $id_alert_command, + "Field information" => $info_fields, + "Group" => $values['id_group'], + "Action threshold" => $values['action_threshold'] + ); + } + } + + if ($result) { + db_pandora_audit( + "Command management", + $update ? "Update alert action #" . $id : "Create alert action #" . $result, + false, + false, + json_encode($values) + ); + } + else { + db_pandora_audit( + "Command management", + $update ? "Fail try to update alert action #" . $id : "Fail try to create alert action", + false, + false, + $update ? json_encode($values) : '' + ); + } + + ui_print_result_message ($result, + $update ? __('Successfully updated') : __('Successfully created'), + $update ? __('Could not be updated') : __('Could not be created') + ); +} ?> From d8a7ebea08b13628305ac4ad5ce279f7e415cd3b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 22 Oct 2018 16:26:58 +0200 Subject: [PATCH 06/21] Only change the group to all grupo if neccesary when command is changed --- pandora_console/godmode/alerts/configure_alert_action.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 88b72e4f8b..49ca26db5b 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -284,14 +284,16 @@ $(document).ready (function () { // Change the selected group $("#group option").each(function(index, value) { - var current_group = $(value).val() + var current_group = $(value).val(); if (data.id_group != 0 && current_group != 0 && current_group != data.id_group) { $(value).hide(); } else { $(value).show(); } }); - $("#group").val(0); + if (data.id_group != 0 && $("#group").val() != data.id_group) { + $("#group").val(0); + } for (i = 1; i <= max_fields; i++) { var old_value = ''; From 7e8fbb4568479c9eef63f26c24ddcbe16dbb7b79 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 22 Oct 2018 16:48:24 +0200 Subject: [PATCH 07/21] Added warning icon to actions that does not match with their commands --- .../godmode/alerts/alert_actions.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index fd83bb6638..84b61661b5 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -236,9 +236,13 @@ $table->align[3] = 'left'; $filter = array(); if (!is_user_admin($config['id_user'])) - $filter['id_group'] = array_keys(users_get_groups(false, "LM")); + $filter['talert_actions.id_group'] = array_keys(users_get_groups(false, "LM")); -$actions = db_get_all_rows_filter ('talert_actions', $filter); +$actions = db_get_all_rows_filter ( + 'talert_actions INNER JOIN talert_commands ON talert_actions.id_alert_command = talert_commands.id', + $filter, + 'talert_actions.* , talert_commands.id_group AS command_group' +); if ($actions === false) $actions = array (); @@ -253,11 +257,19 @@ foreach ($actions as $action) { $iterator++; $data = array (); - + $data[0] = ''. $action['name'].''; $data[1] = ui_print_group_icon ($action["id_group"], true) .' '; - + if (!alerts_validate_command_to_action($action["id_group"], $action["command_group"])) { + $data[1].= html_print_image( + "images/error.png", + true, + // FIXME: Translation. + array("title" => __("The command and the action are not in the same group. Please, contact with an administrator to solve it.") + )); + } + if (check_acl($config['id_user'], $action["id_group"], "LM")) { $data[2] = '' . @@ -266,7 +278,7 @@ foreach ($actions as $action) { onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'. html_print_image("images/cross.png", true) . ''; } - + array_push ($table->data, $data); } if (isset($data)) { From e24794d6ea039de349caad2f50f1f0abf91ae02d Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 22 Oct 2018 16:54:22 +0200 Subject: [PATCH 08/21] Fixed alert command creation error management --- .../godmode/alerts/alert_commands.php | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 3a0178b37c..edd17266d3 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -321,20 +321,18 @@ if ($copy_command) { $command_to_copy = db_get_row('talert_commands', 'id', $id); if ($command_to_copy === false) { ui_print_error_message(__("Command with id $id does not found.")); - break 2; + } else { + // Prepare to insert the copy with same values + unset ($command_to_copy['id']); + $command_to_copy['name'].= __(' (copy)'); + $result = db_process_sql_insert('talert_commands', $command_to_copy); + + // Print the result + ui_print_result_message ($result, + __('Successfully copied'), + __('Could not be copied') + ); } - - // Prepare to insert the copy with same values - unset ($command_to_copy['id']); - $command_to_copy['name'].= __(' (copy)'); - $result = db_process_sql_insert('talert_commands', $command_to_copy); - - // Print the result - ui_print_result_message ($result, - __('Successfully copied'), - __('Could not be copied') - ); - } $table->width = '100%'; From 4308c3f92ea3a2b52e0465d3643fae16d680153e Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 23 Oct 2018 10:53:09 +0200 Subject: [PATCH 09/21] Added acl to alert commands select --- .../godmode/alerts/configure_alert_action.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 49ca26db5b..46b1ce8a4c 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -122,7 +122,6 @@ $table->colspan[0][1] = 2; $table->data[1][0] = __('Group'); -$groups = users_get_groups (); $own_info = get_user_info ($config['id_user']); // Only display group "All" if user is administrator or has "PM" privileges if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) @@ -133,9 +132,17 @@ $table->data[1][1] = html_print_select_groups(false, "LW", $display_all_group, ' $table->colspan[1][1] = 2; $table->data[2][0] = __('Command'); -$table->data[2][1] = html_print_select_from_sql ('SELECT id, name - FROM talert_commands', - 'id_command', $id_command, '', __('None'), 0, true); +$commands_sql = db_get_all_rows_filter( + 'talert_commands', + array('id_group' => array_keys(users_get_groups(false, "LW"))), + array('id', 'name'), + 'AND', + false, + true +); +$table->data[2][1] = html_print_select_from_sql ($commands_sql, 'id_command', $id_command, + '', __('None'), 0, true +); $table->data[2][1] .= ' '; if (check_acl ($config['id_user'], 0, "PM")) { $table->data[2][1] .= html_print_image ('images/add.png', true); From 04ebb6b2c56db3e3c990b6b93faa840f6c621b97 Mon Sep 17 00:00:00 2001 From: danielmaya Date: Mon, 19 Nov 2018 11:28:35 +0100 Subject: [PATCH 10/21] Added delete function in the api --- pandora_console/include/functions_filemanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 31f65447d1..2913cde8e8 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -742,7 +742,7 @@ function filemanager_file_explorer($real_directory, $relative_directory, $data[4] .= ''; $typefile = array_pop(explode(".",$fileinfo['name'])); if (is_writable ($fileinfo['realpath']) && - (! is_dir ($fileinfo['realpath']) || count (scandir ($fileinfo['realpath'])) < 3)) { + (! is_dir ($fileinfo['realpath']) || count (scandir ($fileinfo['realpath'])) < 3) && (!$readOnly)) { $data[4] .= '
'; $data[4] .= ''; $data[4] .= html_print_input_hidden ('filename', $fileinfo['realpath'], true); From 24fe48d5c5253b39c3a152541a69b61dc6d41ba3 Mon Sep 17 00:00:00 2001 From: danielmaya Date: Mon, 19 Nov 2018 12:12:10 +0100 Subject: [PATCH 11/21] Added token metaconsole_deploy_collection in the config --- pandora_console/include/functions_config.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 6afdac590a..39dedbef28 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2023,6 +2023,12 @@ function config_process_config () { config_update_value('ehorus_req_timeout', 5); } + if (is_metaconsole()) { + if (!isset($config["metaconsole_deploy_collection"])) { + config_update_value('metaconsole_deploy_collection', 0); + } + } + /* Finally, check if any value was overwritten in a form */ config_update_config(); } From 3ffab647cbebd90d7ec7d408ba32988105f0b344 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 19 Nov 2018 13:21:25 +0100 Subject: [PATCH 12/21] time used for session cookie set to timezone current time instead of gmt time --- pandora_console/include/functions_config.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 31aca90c7c..120a63b539 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2328,8 +2328,11 @@ function config_prepare_session() { // Reset the expiration time upon page load //session_name() is default name of session PHPSESSID + $date = new DateTime(null, new DateTimeZone('Europe/Madrid')); + $current_time = $date->getTimestamp() + $date->getOffset(); + if (isset($_COOKIE[session_name()])) - setcookie(session_name(), $_COOKIE[session_name()], time() + $sessionCookieExpireTime, "/"); + setcookie(session_name(), $_COOKIE[session_name()], $current_time + $sessionCookieExpireTime, "/"); ini_set("post_max_size", $config["max_file_size"]); ini_set("upload_max_filesize", $config["max_file_size"]); From 9d80e940bf4d7ecd0f911790d7ee763e3a887ad2 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 19 Nov 2018 16:17:20 +0100 Subject: [PATCH 13/21] fixed minor error cfv --- pandora_console/images/agent_mc.menu-2.png | Bin 0 -> 314 bytes .../include/ajax/custom_fields.php | 53 +++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 pandora_console/images/agent_mc.menu-2.png diff --git a/pandora_console/images/agent_mc.menu-2.png b/pandora_console/images/agent_mc.menu-2.png new file mode 100644 index 0000000000000000000000000000000000000000..8c5b304b7f7997ce60e38bea0e31adf74279fcab GIT binary patch literal 314 zcmeAS@N?(olHy`uVBq!ia0vp^;vmey1|%P7U0DF6I14-?iy0WWg+Z8+Vb&Z8prB-l zYeY$Kep*R+Vo@rCV@iHfs)A>3VtQ&&YGO)d;mK4RprYfRE{-7;x03$+|8LLC_uzno zR0YFP4hAC`UT%huZU3J%vZQRjz-z|vi2J`La{;%+#ipms0-v34iZ||PIH6$3@Tg9u zPDw!Dp=>MDq_^A)4jy)3@^kp?$WRqw?O@0}Q{rY5b5BJO_s$0l0=JnzI;s`iV0b*0 zXO6=Ou?Y`9rtF%aaX6FBjaR;{OZ;3*R~NXitZ $server) { + $pwd = $server['auth_token']; + $auth_serialized = json_decode($pwd,true); + + if (is_array($auth_serialized)) { + $pwd = $auth_serialized['auth_token']; + $api_password = $auth_serialized['api_password']; + $console_user = $auth_serialized['console_user']; + $console_password = $auth_serialized['console_password']; + } + + $user = $config['id_user']; + $user_rot13 = str_rot13($config['id_user']); + $hashdata = $user.$pwd; + $hashdata = md5($hashdata); + $url_hash = '&' . + 'loginhash=auto&' . + 'loginhash_data=' . $hashdata . '&' . + 'loginhash_user=' . $user_rot13; + + $hash_array_nodes[$server['id']]['hashurl'] = $url_hash; + $hash_array_nodes[$server['id']]['server_url'] = $server['server_url']; + } + } + //prepare rows for table dinamic $data = array(); foreach ($result as $values) { $image_status = agents_get_image_status($values['status']); + if (can_user_access_node ()) { + //link nodes + $agent_link = '' + ; + + $agent_alias = ui_print_truncate_text($values['alias'], + 'agent_small', false, true, false, '[…]', + 'font-size:7.5pt;' + ); + + $agent = $agent_link . '' . $agent_alias . ''; + } + else { + $agent = $agent_alias; + } + $data[] = array( "ref" => $referencia, "data_custom_field" => $values['name_custom_fields'], "server" => $values['server_name'], - "agent" => $values['alias'], + "agent" => $agent, "IP" => $values['direccion'], "status" => "
" . $image_status . "
", "id_agent" => $values['id_tagente'], From 2c5cd6627b559f32216ed2e85dc4e92ada4f3717 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 19 Nov 2018 16:33:27 +0100 Subject: [PATCH 14/21] time used for session cookie expiration set to gmt time --- pandora_console/include/functions_config.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 120a63b539..31aca90c7c 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2328,11 +2328,8 @@ function config_prepare_session() { // Reset the expiration time upon page load //session_name() is default name of session PHPSESSID - $date = new DateTime(null, new DateTimeZone('Europe/Madrid')); - $current_time = $date->getTimestamp() + $date->getOffset(); - if (isset($_COOKIE[session_name()])) - setcookie(session_name(), $_COOKIE[session_name()], $current_time + $sessionCookieExpireTime, "/"); + setcookie(session_name(), $_COOKIE[session_name()], time() + $sessionCookieExpireTime, "/"); ini_set("post_max_size", $config["max_file_size"]); ini_set("upload_max_filesize", $config["max_file_size"]); From 01ba290a68d689daa2eba03c2040d99a1bfb81be Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 20 Nov 2018 00:01:29 +0100 Subject: [PATCH 15/21] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f3b522f453..5eef9f541d 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.729-181119 +Version: 7.0NG.729-181120 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 744c15faa3..2061e94ba1 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.729-181119" +pandora_version="7.0NG.729-181120" 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 5dcb204f4b..7f39327851 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.729'; -use constant AGENT_BUILD => '181119'; +use constant AGENT_BUILD => '181120'; # 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 1b73e1a002..0d1535b1de 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.729 -%define release 181119 +%define release 181120 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 1bee404d62..1e8f153a2c 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.729 -%define release 181119 +%define release 181120 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 c890a0fee8..9606604f15 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.729" -PI_BUILD="181119" +PI_BUILD="181120" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index e59a1cfd83..19cd2c6a60 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{181119} +{181120} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f763576e59..3f99c929f4 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.729(Build 181119)") +#define PANDORA_VERSION ("7.0NG.729(Build 181120)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index b0a3ce4c02..c8e617ac33 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.729(Build 181119))" + VALUE "ProductVersion", "(7.0NG.729(Build 181120))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 98449ce593..1cf6b8da0a 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.729-181119 +Version: 7.0NG.729-181120 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 c5087fdc30..fd16b309e5 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.729-181119" +pandora_version="7.0NG.729-181120" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 0025d9f13f..3a36e7fe0b 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC181119'; +$build_version = 'PC181120'; $pandora_version = 'v7.0NG.729'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 5ae89c16d8..36d3926c37 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 030012ca0c..d8eded4f2f 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.729 -%define release 181119 +%define release 181120 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index e15299bfd5..9ba292053a 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.729 -%define release 181119 +%define release 181120 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 3d9ded6dc6..1d46177b7e 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.729" -PI_BUILD="181119" +PI_BUILD="181120" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index f36dc37bd5..bb801c88d8 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.729 PS181119"; +my $version = "7.0NG.729 PS181120"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index fc9cbab576..85389d02d3 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.729 PS181119"; +my $version = "7.0NG.729 PS181120"; # save program name for logging my $progname = basename($0); From 2078014406af4fac3a8a8d978516924871d8e7f7 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 20 Nov 2018 09:14:36 +0100 Subject: [PATCH 16/21] fixed minor error --- .../include/ajax/custom_fields.php | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index 82486b959a..91a3ddb115 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -189,22 +189,22 @@ if($build_table_custom_fields){ foreach ($result as $values) { $image_status = agents_get_image_status($values['status']); + //link nodes + $agent_link = '' + ; + + $agent_alias = ui_print_truncate_text($values['alias'], + 'agent_small', false, true, false, '[…]', + 'font-size:7.5pt;' + ); + if (can_user_access_node ()) { - //link nodes - $agent_link = '' - ; - - $agent_alias = ui_print_truncate_text($values['alias'], - 'agent_small', false, true, false, '[…]', - 'font-size:7.5pt;' - ); - $agent = $agent_link . '' . $agent_alias . ''; } else { From 8a00fe5a30d3738f23c818942794365cff300560 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 20 Nov 2018 10:58:58 +0100 Subject: [PATCH 17/21] Fixed query on function agents_get_group_agents --- pandora_console/include/functions_agents.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 6384d94cbe..16bdb974c6 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -922,7 +922,7 @@ function agents_get_group_agents ( } if (isset($search['id_os'])) { - $filter[] = "id_os = ". $search['id_os']; + $filter['id_os'] = $search['id_os']; } if (isset($search['status'])) { From 8735e6e1a3b16cbda5e1681e79a4a794940c59b1 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 20 Nov 2018 11:18:57 +0100 Subject: [PATCH 18/21] Added a translation --- pandora_console/godmode/alerts/alert_actions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 84b61661b5..2c2357541d 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -266,7 +266,7 @@ foreach ($actions as $action) { "images/error.png", true, // FIXME: Translation. - array("title" => __("The command and the action are not in the same group. Please, contact with an administrator to solve it.") + array("title" => __("The action and the command associated with it do not have the same group. Please contact an administrator to fix it.") )); } From a089a9347758908bdf3a235ce8a89cafbd9e4608 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 20 Nov 2018 18:07:43 +0100 Subject: [PATCH 19/21] fixed session bugs --- pandora_console/include/config_process.php | 12 +++++++----- pandora_console/include/functions_config.php | 4 ---- pandora_console/include/load_session.php | 2 +- pandora_console/index.php | 16 ++++++++++------ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 3a36e7fe0b..7ad7bf70b2 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -171,19 +171,21 @@ require_once ($ownDir. 'functions_config.php'); date_default_timezone_set("Europe/Madrid"); +////////////////////////////////////// +//// PLEASE DO NOT CHANGE ORDER ////// +////////////////////////////////////// +require_once ($config["homedir"].'/include/load_session.php'); + +if (empty(session_id())) session_start(); config_process_config(); - config_prepare_session(); -require_once ($config["homedir"].'/include/load_session.php'); -if(session_id() == '') { - $resultado = session_start(); -} // Set a the system timezone default if ((!isset($config["timezone"])) OR ($config["timezone"] == "")) { $config["timezone"] = "Europe/Berlin"; } +//////////////////////////////////////// date_default_timezone_set($config["timezone"]); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 39dedbef28..e773224c16 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2329,11 +2329,7 @@ function config_prepare_session() { else $sessionCookieExpireTime *= 60; - @ini_set('session.gc_maxlifetime', $sessionCookieExpireTime); - @session_set_cookie_params ($sessionCookieExpireTime); - // Reset the expiration time upon page load //session_name() is default name of session PHPSESSID - if (isset($_COOKIE[session_name()])) setcookie(session_name(), $_COOKIE[session_name()], time() + $sessionCookieExpireTime, "/"); diff --git a/pandora_console/include/load_session.php b/pandora_console/include/load_session.php index da09e0ff2a..8144b410b2 100644 --- a/pandora_console/include/load_session.php +++ b/pandora_console/include/load_session.php @@ -77,6 +77,6 @@ function pandora_session_gc ($max_lifetime = 300) { return $retval; } -$result_handler = @session_set_save_handler ('pandora_session_open', 'pandora_session_close', 'pandora_session_read', 'pandora_session_write', 'pandora_session_destroy', 'pandora_session_gc'); +$result_handler = session_set_save_handler ('pandora_session_open', 'pandora_session_close', 'pandora_session_read', 'pandora_session_write', 'pandora_session_destroy', 'pandora_session_gc'); ?> diff --git a/pandora_console/index.php b/pandora_console/index.php index 69bcc7c683..101196ba21 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -105,10 +105,9 @@ if ((! file_exists ("include/config.php")) || (! is_readable ("include/config.ph exit; } -// Real start -if(session_id() == '') { - session_start (); -} +////////////////////////////////////// +//// PLEASE DO NOT CHANGE ORDER ////// +////////////////////////////////////// require_once ("include/config.php"); require_once ("include/functions_config.php"); @@ -126,6 +125,7 @@ if ($config['metaconsole'] == 1 && $config['enterprise_installed'] == 1) { if (file_exists (ENTERPRISE_DIR . "/include/functions_login.php")) { include_once (ENTERPRISE_DIR . "/include/functions_login.php"); } +//////////////////////////////////////// if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) { $query = ''; @@ -564,6 +564,7 @@ if (! isset ($config['id_user'])) { if($home_page == 'Visual console') unset($query_params_redirect["sec2"]); $redirect_url = '?1=1'; foreach ($query_params_redirect as $key => $value) { + if ($key == "login") continue; $redirect_url .= '&'.safe_url_extraclean($key).'='.safe_url_extraclean($value); } header("Location: ".$config['homeurl']."index.php".$redirect_url); @@ -810,8 +811,11 @@ if (isset ($_GET["bye"])) { $iduser = $_SESSION["id_usuario"]; db_logoff ($iduser, $_SERVER['REMOTE_ADDR']); // Unregister Session (compatible with 5.2 and 6.x, old code was deprecated - unset($_SESSION['id_usuario']); - unset($iduser); + $_SESSION = array(); + session_destroy(); + header_remove("Set-Cookie"); + setcookie(session_name(), $_COOKIE[session_name()], time() - 4800, "/"); + if ($config['auth'] == 'saml') { require_once($config['saml_path'] . 'simplesamlphp/lib/_autoload.php'); $as = new SimpleSAML_Auth_Simple('PandoraFMS'); From fd6d830de3e8c2ded48075f8cd28c2b534795cfc Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 21 Nov 2018 00:01:25 +0100 Subject: [PATCH 20/21] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 5eef9f541d..86b23fdb7a 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.729-181120 +Version: 7.0NG.729-181121 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 2061e94ba1..9c23f55258 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.729-181120" +pandora_version="7.0NG.729-181121" 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 7f39327851..7950a9ac3b 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.729'; -use constant AGENT_BUILD => '181120'; +use constant AGENT_BUILD => '181121'; # 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 0d1535b1de..36ab5fd73a 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.729 -%define release 181120 +%define release 181121 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 1e8f153a2c..e40aa2d331 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.729 -%define release 181120 +%define release 181121 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 9606604f15..4472239b6e 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.729" -PI_BUILD="181120" +PI_BUILD="181121" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 19cd2c6a60..474db7ba2c 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{181120} +{181121} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 3f99c929f4..6e4ccb69da 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.729(Build 181120)") +#define PANDORA_VERSION ("7.0NG.729(Build 181121)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index c8e617ac33..839789b48d 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.729(Build 181120))" + VALUE "ProductVersion", "(7.0NG.729(Build 181121))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 1cf6b8da0a..e82acca4ce 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.729-181120 +Version: 7.0NG.729-181121 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 fd16b309e5..bd4a3bd65d 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.729-181120" +pandora_version="7.0NG.729-181121" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 7ad7bf70b2..6a94587686 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC181120'; +$build_version = 'PC181121'; $pandora_version = 'v7.0NG.729'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 36d3926c37..5459cb7d3f 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index d8eded4f2f..290a90f1a5 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.729 -%define release 181120 +%define release 181121 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 9ba292053a..c0b3a82f13 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.729 -%define release 181120 +%define release 181121 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 1d46177b7e..7cbab42c65 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.729" -PI_BUILD="181120" +PI_BUILD="181121" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index bb801c88d8..843b90bbf6 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.729 PS181120"; +my $version = "7.0NG.729 PS181121"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 85389d02d3..a3d53df2fe 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.729 PS181120"; +my $version = "7.0NG.729 PS181121"; # save program name for logging my $progname = basename($0); From 3f6384c6907115aa7484cb91a3ab255b04001127 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 21 Nov 2018 09:36:37 +0100 Subject: [PATCH 21/21] fixed minor error session --- pandora_console/include/config_process.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 7ad7bf70b2..4e731f6b5d 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -176,12 +176,12 @@ date_default_timezone_set("Europe/Madrid"); ////////////////////////////////////// require_once ($config["homedir"].'/include/load_session.php'); -if (empty(session_id())) session_start(); +if (session_id() == '') session_start(); config_process_config(); config_prepare_session(); -// Set a the system timezone default +// Set a the system timezone default if ((!isset($config["timezone"])) OR ($config["timezone"] == "")) { $config["timezone"] = "Europe/Berlin"; }