diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7d3ce1a54f..68ed553e88 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2013-08-01 Miguel de Dios + + * enterprise/godmode/agentes/agent_disk_conf_editor.php, + enterprise/godmode/agentes/collection_manager.php, + enterprise/godmode/policies/policy_agents.php, + enterprise/include/functions_collection.php, + enterprise/include/functions_policies.php, + enterprise/include/functions_config_agents.php, + enterprise/operation/agentes/collection_view.php: fixed and unified + the code to access the remote config. + + MERGED FROM BRANCH PANDORA_4 + 2013-08-01 Sergio Martin * include/functions_filemanager.php diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 5ea1446d55..c638a882a9 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -14,6 +14,7 @@ // GNU General Public License for more details. if (is_ajax ()) { + global $config; $search_parents_2 = (bool) get_parameter ('search_parents_2'); @@ -78,7 +79,7 @@ if (is_ajax ()) { if ($out === false) { $out = $oid_snmp; } - else{ + else { $out = array_intersect($out,$oid_snmp); } @@ -117,11 +118,7 @@ echo '
 
'; if (!$new_agent) { // Agent remote configuration editor - $agent_md5 = md5 ($nombre_agente, false); - $filename['md5'] = $config["remote_config"] . "/md5/" . - $agent_md5 . ".md5"; - $filename['conf'] = $config["remote_config"] . "/conf/" . - $agent_md5 . ".conf"; + $filename = config_agents_get_agent_config_filenames($id_agente); } $disk_conf = (bool) get_parameter ('disk_conf'); @@ -155,6 +152,7 @@ $table->data[0][0] = __('Agent name') . $table->data[0][1] = html_print_input_text ('agente', $nombre_agente, '', 50, 100,true); if ($id_agente) { + $table->data[0][1] .= " ".__("ID")."  $id_agente  "; $table->data[0][1] .= '  '; $table->data[0][1] .= html_print_image ("images/zoom.png", true, array ("border" => 0, "title" => __('Agent detail'))); @@ -164,6 +162,10 @@ if ($id_agente) { // Remote configuration available if (!$new_agent) { if (file_exists ($filename['md5'])) { + $agent_name = agents_get_name($id_agente); + $agent_name = io_safe_output($agent_name); + $agent_md5 = md5 ($agent_name, false); + $table->data[0][1] .= '  '; $table->data[0][1] .= html_print_image ("images/application_edit.png", true, array ("border" => 0, "title" => __('This agent can be remotely configured'))); $table->data[0][1] .= ''.ui_print_help_tip (__('You can remotely edit this agent configuration'), true); @@ -282,7 +284,8 @@ else $listIcons = gis_get_array_list_icons(); $arraySelectIcon = array(); -foreach ($listIcons as $index => $value) $arraySelectIcon[$index] = $index; +foreach ($listIcons as $index => $value) + $arraySelectIcon[$index] = $index; $path = 'images/gis_map/icons/'; //TODO set better method the path $table->data[4][0] = __('Agent icon') . ui_print_help_tip(__('Agent icon for GIS Maps.'), true); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 4fb89f2c87..df1b4915ab 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -488,7 +488,7 @@ if ($delete_conf_file) { $correct = false; // Delete remote configuration if (isset ($config["remote_config"])) { - $agent_md5 = md5 (agents_get_name ($id_agente,'none'), FALSE); + $agent_md5 = md5(io_safe_output(agents_get_name ($id_agente,'none')), FALSE); if (file_exists ($config["remote_config"] . "/md5/" . $agent_md5 . ".md5")) { // Agent remote configuration editor diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 3fb9534e9f..c58f32b5dd 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -87,10 +87,7 @@ if ($agent_to_delete) { // Check if the remote config file still exist if (isset ($config["remote_config"])) { - $agent_md5 = md5 (agents_get_name($id_agente, ""), FALSE); - - if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5") || - file_exists ($config["remote_config"]."/conf/".$agent_md5.".conf")) { + if (config_agents_has_remote_configuration($id_agente)) { ui_print_error_message(__('Maybe the files conf or md5 could not be deleted')); } } @@ -160,6 +157,7 @@ echo '
"; echo ""; + $selected = 'border: 1px solid black;'; $selectNameUp = ''; $selectNameDown = ''; @@ -281,6 +279,7 @@ if ($ag_group > 0) { } } else { + // Admin user get ANY group, even if they doesnt exist if (check_acl ($config['id_user'], 0, "PM")) { $sql = sprintf ('SELECT COUNT(*) FROM tagente WHERE 1=1 %s', $search_sql); @@ -397,8 +396,8 @@ if ($agents !== false) { '' . html_print_image("images/sort_up.png", true, array("style" => $selectGroupUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectGroupDown)) . ''; echo ""; - echo "".__('Description').""; - echo "".__('Actions').""; + echo "" . __('Description') . ""; + echo "" . __('Actions') . ""; $color=1; $rowPair = true; @@ -478,8 +477,7 @@ if ($agents !== false) { echo ""; // Has remote configuration ? - $agent_md5 = md5 ($agent["nombre"], false); - if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { + if (config_agents_has_remote_configuration($agent["id_agente"])) { echo ""; echo html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config'))); echo ""; @@ -530,7 +528,7 @@ if ($agents !== false) { echo "
"; } else { - echo "
".__('There are no defined agents')."
"; + echo "
" . __('There are no defined agents') . "
"; echo " 
"; } @@ -548,23 +546,23 @@ echo "
"; ?> diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 174f4b5889..52021cba55 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -52,7 +52,7 @@ if (is_ajax ()) { $id_module_group = (int) get_parameter ('id_module_component_group'); $localComponents = local_components_get_local_components( - array('id_network_component_group' => $id_module_group), + array('id_network_component_group' => $id_module_group), array('id', 'name')); echo json_encode($localComponents); @@ -324,6 +324,7 @@ if($is_function_policies !== ENTERPRISE_NOT_HOOK) { db_pandora_audit("Agent management", "Unlink module " . $id_agent_module); } + } global $__code_from; $__code_from = 'modules'; @@ -334,9 +335,7 @@ switch ($moduletype) { case MODULE_DATA: $moduletype = MODULE_DATA; // Has remote configuration ? - $agent_md5 = md5 (agents_get_name($id_agente), false); - $remote_conf = file_exists ($config["remote_config"] ."/md5/" . - $agent_md5 . ".md5"); + $remote_conf = config_agents_has_remote_configuration($id_agente); /* Categories is an array containing the allowed module types (generic_data, generic_string, etc) from ttipo_modulo (field categoria) */ @@ -391,6 +390,7 @@ switch ($moduletype) { 1) forgot to use the database converter
2) used a bad version of the database converter (see Bugreport #2124706 for the solution)
3) found a new bug - please report a way to duplicate this error'); + return; } break; diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 1dc27b3e44..90a0ba3554 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1669,9 +1669,11 @@ function agents_delete_agent ($id_agents, $disableACL = false) { // Delete remote configuration if (isset ($config["remote_config"])) { - $agent_md5 = md5 ($agent_name, FALSE); - - if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { + if (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"; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index d844e6ff59..d2df6272eb 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -88,6 +88,7 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent if ($id_new_module === false) { return false; } + } // If the module is synthetic we duplicate the operations too @@ -128,8 +129,9 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent $id_agente = modules_get_agentmodule_agent($id_agent_module); - $agent_md5 = md5 (agents_get_name($id_agente), false); - $remote_conf = file_exists ($config["remote_config"] . "/md5/" . $agent_md5 . ".md5"); + $file = config_agents_get_agent_config_filenames($id_agente); + $agent_md5 = $file['md5']; + $remote_conf = $file['conf']; if ($remote_conf) { $result = enterprise_hook('config_agents_copy_agent_module_to_agent', @@ -309,6 +311,7 @@ function modules_update_agent_module ($id, $values, $onlyNoDeletePending = false } $result = @db_process_sql_update ('tagente_modulo', $values, $where); + if (($result === false) || ($result_disable === ERR_GENERIC)) { return ERR_DB; } diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 8848ecb51e..1aec641b95 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -22,6 +22,7 @@ require_once ("include/functions_reporting.php"); require_once($config['homedir'] . "/include/functions_agents.php"); require_once($config['homedir'] . '/include/functions_users.php'); require_once($config['homedir'] . '/include/functions_modules.php'); +enterprise_include_once('include/functions_config_agents.php'); check_login (); @@ -109,6 +110,7 @@ if (is_ajax ()) { } ob_end_clean(); + // Take some parameters (GET) $group_id = (int) get_parameter ("group_id", 0); $search = trim(get_parameter ("search", "")); @@ -131,13 +133,13 @@ if (check_acl ($config['id_user'], 0, "AW")) { $setuptab['godmode'] = true; $setuptab['active'] = false; - + $onheader = array('setup' => $setuptab); } ui_print_page_header ( __("Agent detail"), "images/agent_mc.png", false, "agent_status", false, $onheader); -if(tags_has_user_acl_tags()) { +if (tags_has_user_acl_tags()) { ui_print_tags_warning(); } @@ -434,7 +436,7 @@ foreach ($agents as $agent) { $status_img = agents_tree_view_status_img ($agent["critical_count"], $agent["warning_count"], $agent["unknown_count"], $agent["total_count"], $agent["notinit_count"]); - + $data = array (); $data[0] = ''; @@ -464,6 +466,7 @@ foreach ($agents as $agent) { $data[5] = reporting_tiny_stats($agent, true); + $data[6] = $status_img; $data[7] = $alert_img; @@ -487,12 +490,12 @@ foreach ($agents as $agent) { if (check_acl ($config["id_user"], $group_id, "AW")) { // Has remote configuration ? $data[9]=""; - $agent_name = db_get_value("nombre", "tagente", "id_agente", $agent["id_agente"]); - $agent_md5 = md5 ($agent_name, false); - if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { + + if (config_agents_has_remote_configuration($agent["id_agente"])) { $data[9] = "". html_print_image("images/application_edit.png", true, array("align" => 'middle', "title" => __('Edit remote config'))).""; } + } array_push ($table->data, $data);