diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f3b522f453..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-181119 +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 744c15faa3..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-181119" +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 5dcb204f4b..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 => '181119'; +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 1b73e1a002..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 181119 +%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 1bee404d62..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 181119 +%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 c890a0fee8..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="181119" +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 e59a1cfd83..474db7ba2c 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{181119} +{181121} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f763576e59..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 181119)") +#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 b0a3ce4c02..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 181119))" + 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 98449ce593..e82acca4ce 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-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 c5087fdc30..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-181119" +pandora_version="7.0NG.729-181121" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/22.sql b/pandora_console/extras/mr/22.sql index 39c18cad6c..6ddb2bf5ac 100644 --- a/pandora_console/extras/mr/22.sql +++ b/pandora_console/extras/mr/22.sql @@ -1,5 +1,7 @@ START TRANSACTION; +ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0; + ALTER TABLE `tusuario` DROP COLUMN `flash_chart`; ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0'; 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 a2d81b64d9..e27569a0cf 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; diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index a80ba40a23..2c2357541d 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,135 +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); - } - - - /* Show errors */ - if (!isset($messageAction)) { - $messageAction = __('Could not be created'); - } - - if ($name == "") { - $messageAction = __('No name specified'); - } - - if ($id_alert_command == "") { - $messageAction = __('No command specified'); - } - - $messageAction = ui_print_result_message ($result, - __('Successfully created'), - $messageAction); -} - -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) { @@ -363,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 (); @@ -380,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 action and the command associated with it do not have the same group. Please contact an administrator to fix it.") + )); + } + if (check_acl($config['id_user'], $action["id_group"], "LM")) { $data[2] = '' . @@ -393,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)) { diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 9ca4ea501a..3f890e1190 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,13 +243,11 @@ 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'); $description = (string) get_parameter ('description'); + $id_group = (string) get_parameter ('id_group', 0); $fields_descriptions = array(); $fields_values = array(); @@ -287,7 +262,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) { @@ -349,8 +325,27 @@ 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.")); + } 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') + ); + } } $table->width = '100%'; @@ -358,45 +353,54 @@ $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'] = __('Actions'); $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/copy.png", true) . ''; + $data['action'].= ''. html_print_image("images/cross.png", true) . ''; + $data['action'].= ''; } - + array_push ($table->data, $data); } -if (isset($data)) { +if (count($table->data) > 0) { html_print_table ($table); } else { diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index d1fe842469..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); @@ -282,6 +289,19 @@ $(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(); + } + }); + if (data.id_group != 0 && $("#group").val() != data.id_group) { + $("#group").val(0); + } + for (i = 1; i <= max_fields; i++) { var old_value = ''; var old_recovery_value = ''; 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++) { 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 0000000000..8c5b304b7f Binary files /dev/null and b/pandora_console/images/agent_mc.menu-2.png differ diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index dfe7cf8c57..91a3ddb115 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -155,16 +155,67 @@ if($build_table_custom_fields){ $count = db_get_sql($query_count); + //for link nodes. + $array_nodes = metaconsole_get_connections(); + if(isset($array_nodes) && is_array($array_nodes)){ + $hash_array_nodes = array(); + foreach ($array_nodes as $key => $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']); + //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 ()) { + $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'], diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 0025d9f13f..ee7ab047b5 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 = 'PC181121'; $pandora_version = 'v7.0NG.729'; // Do not overwrite default timezone set if defined. @@ -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 (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 +// 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_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'])) { diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 17cc0c8bde..dbe18fe4d7 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -2268,5 +2268,121 @@ 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 some values + if (!$id_alert_command) { + ui_print_error_message(__('No command specified')); + return; + } + if (!$name) { + ui_print_error_message(__('No name specified')); + 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') + ); +} ?> diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 6afdac590a..e773224c16 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(); } @@ -2323,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/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); 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'); diff --git a/pandora_console/install.php b/pandora_console/install.php index 5ae89c16d8..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 030012ca0c..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 181119 +%define release 181121 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index e15299bfd5..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 181119 +%define release 181121 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 3d9ded6dc6..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="181119" +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 f36dc37bd5..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 PS181119"; +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 fc9cbab576..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 PS181119"; +my $version = "7.0NG.729 PS181121"; # save program name for logging my $progname = basename($0);