From 15061272625ad133c72f89aa6a792841b8479aa8 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 4 Sep 2013 12:49:27 +0000 Subject: [PATCH] 2013-09-04 Miguel de Dios * godmode/agentes/modificar_agente.php, include/functions_agents.php: fixed the delete agent when sometimes have remote config but not the enterprise. MERGED FROM THE BRANCH PANDORA_4 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8740 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 ++++ .../godmode/agentes/modificar_agente.php | 12 +++--- .../godmode/agentes/module_manager_editor.php | 3 +- pandora_console/include/functions_agents.php | 40 ++++++++++--------- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a9fc552b0d..a1726c4d17 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2013-09-04 Miguel de Dios + + * godmode/agentes/modificar_agente.php, + include/functions_agents.php: fixed the delete agent when sometimes + have remote config but not the enterprise. + + MERGED FROM THE BRANCH PANDORA_4 + 2013-09-04 Ramon Novoa * include/functions_events.php, diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 355e5b84d3..db37438c0e 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -85,11 +85,13 @@ if ($agent_to_delete) { ui_print_result_message($result, __('Success deleted agent.'), __('Could not be deleted.')); - // Check if the remote config file still exist - if (isset ($config["remote_config"])) { - enterprise_include_once('include/functions_config_agents.php'); - if (enterprise_hook('config_agents_has_remote_configuration', $id_agente)) { - ui_print_error_message(__('Maybe the files conf or md5 could not be deleted')); + if (enterprise_installed()) { + // Check if the remote config file still exist + if (isset ($config["remote_config"])) { + enterprise_include_once('include/functions_config_agents.php'); + if (enterprise_hook('config_agents_has_remote_configuration', $id_agente)) { + ui_print_error_message(__('Maybe the files conf or md5 could not be deleted')); + } } } } diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index b314da74cd..64580dd958 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -52,7 +52,8 @@ if (is_ajax ()) { } if ($get_module_local_components) { - require_once ($config['homedir'].'/'.ENTERPRISE_DIR.'/include/functions_local_components.php'); + require_once ($config['homedir'] . '/' . ENTERPRISE_DIR . + '/include/functions_local_components.php'); $id_module_group = (int) get_parameter ('id_module_component_group'); $localComponents = local_components_get_local_components( diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index e5f7803569..84c33d08bb 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1668,26 +1668,28 @@ function agents_delete_agent ($id_agents, $disableACL = false) { // db_process_delete_temp ("tagente_datos_inc", "id_agente_modulo", $where_modules); // Delete remote configuration - if (isset ($config["remote_config"])) { - enterprise_include_once('include/functions_config_agents.php'); - if (enterprise_hook('config_agents_has_remote_configuration', $id_agent)) { - $agent_name = agents_get_name($id_agent); - $agent_name = io_safe_output($agent_name); - $agent_md5 = md5 ($agent_name, false); - - // Agent remote configuration editor - $file_name = $config["remote_config"]."/conf/".$agent_md5.".conf"; - - $error = !@unlink ($file_name); - - if (!$error) { - $file_name = $config["remote_config"]."/md5/".$agent_md5.".md5"; + if (enterprise_installed()) { + if (isset ($config["remote_config"])) { + enterprise_include_once('include/functions_config_agents.php'); + if (enterprise_hook('config_agents_has_remote_configuration', $id_agent)) { + $agent_name = agents_get_name($id_agent); + $agent_name = io_safe_output($agent_name); + $agent_md5 = md5 ($agent_name, false); + + // Agent remote configuration editor + $file_name = $config["remote_config"]."/conf/".$agent_md5.".conf"; + $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."); + + 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."); + } } } }