diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0e8b767efb..468f5532ca 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2011-08-17 Miguel de Dios + + * include/functions_agents.php: check if Pandora can delete the conf and md5 + file in function "agents_delete_agent" + + * godmode/agentes/modificar_agente.php: show message of result from the + deleting action. + + Fixes: #3392526 + 2011-08-17 Miguel de Dios * include/functions_visual_map.php, diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 78294d78cb..c7c1c8a525 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -51,13 +51,15 @@ $search = get_parameter ("search", ""); $agent_to_delete = (int)get_parameter('borrar_agente'); +$result = null; + if (!empty($agent_to_delete)) { $id_agente = $agent_to_delete; $agent_name = agents_get_name ($id_agente); $id_grupo = agents_get_agent_group($id_agente); if (check_acl ($config["id_user"], $id_grupo, "AW")==1) { $id_agentes[0] = $id_agente; - agents_delete_agent($id_agentes); + $result = agents_delete_agent($id_agentes); db_pandora_audit("Agent management", "Delete Agent " . $agent_name); } else { @@ -72,6 +74,10 @@ if (!empty($agent_to_delete)) { // Header ui_print_page_header (__('Agent configuration')." » ".__('Agents defined in Pandora'), "", false, "", true); +if (isset($result)) { + ui_print_result_message($result, __('Success deleted agent.'), __('Could not be deleted.')); +} + // Show group selector if (isset($_POST["ag_group"])) { $ag_group = get_parameter_post ("ag_group"); diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 0dcdbcd93e..a03d91ebc1 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1574,10 +1574,18 @@ function agents_delete_agent ($id_agents, $disableACL = false) { if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { // Agent remote configuration editor $file_name = $config["remote_config"]."/conf/".$agent_md5.".conf"; - @unlink ($file_name); + + $error = !@unlink ($file_name); - $file_name = $config["remote_config"]."/md5/".$agent_md5.".md5"; - @unlink ($file_name); + if (!$error) { + $file_name = $config["remote_config"]."/md5/".$agent_md5.".md5"; + $error = !@unlink ($file_name); + } + + if ($error) { + db_pandora_audit( "Agent management", + "Error: Deleted agent '$agent_name', the error is in the delete conf or md5."); + } } } @@ -1590,7 +1598,7 @@ function agents_delete_agent ($id_agents, $disableACL = false) { /* Break the loop on error */ if ($error) - break; + break; } if ($error) {