Added Strict ACL mode to networmaps.

This commit is contained in:
Vanessa Gil 2015-01-23 08:59:42 +01:00
parent a69a3999cb
commit c0dec93d28
9 changed files with 318 additions and 98 deletions

View File

@ -2369,9 +2369,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta =
}
// Add tags condition to filter
$user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict);
$tags_condition = " AND (".tags_get_acl_tags_event_condition($acltags, false, $user_strict).")";
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
//This will give the distinct id_agente, give the id_grupo that goes
//with it and then the number of times it occured. GROUP BY statement
@ -2465,9 +2463,7 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200) {
$filter = str_replace ( "\\" , "", $filter);
// Add tags condition to filter
$user_strict = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$acltags = tags_get_user_module_and_tags ($config['id_user'], $access = 'ER', $user_strict);
$tags_condition = " AND (".tags_get_acl_tags_event_condition($acltags, false, $user_strict).")";
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
$filter .= $tags_condition;
$data = array ();

View File

@ -537,12 +537,22 @@ function groups_get_groups_tree_recursive($groups, $trash = 0, $trash2 = 0) {
*
* @return int Status of the agents.
*/
function groups_get_status ($id_group = 0) {
function groups_get_status ($id_group = 0, $strict_user = false) {
global $config;
require_once ($config['homedir'].'/include/functions_reporting.php');
$data = reporting_get_group_stats($id_group);
if ($strict_user) {
$acltags = tags_get_user_module_and_tags ($config['id_user'], 'AR', $strict_user);
$group_status = group_get_data ($config['id_user'], $strict_user, $acltags, false, 'group');
$data['monitor_alerts_fired'] = $groups_status['_monitors_alerts_fired_'];
$data['agent_critical'] = $groups_status['_agents_critical_'];
$data['agent_warning'] = $groups_status['_agents_warning_'];
$data['agent_unknown'] = $groups_status['_agents_unknown_'];
} else {
$data = reporting_get_group_stats($id_group);
}
if ($data['monitor_alerts_fired'] > 0) {
return AGENT_STATUS_ALERT_FIRED;
@ -1394,7 +1404,6 @@ function groups_monitor_ok ($group_array, $strict_user = false, $id_group_strict
if ($strict_user) {
$tags_clause = "AND tagente_modulo.id_agente_modulo NOT IN (SELECT id_agente_modulo FROM ttag_module)";
$count = db_get_sql ("SELECT COUNT(*) FROM tagente_modulo, tagente_estado
WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo
AND tagente_estado.estado = 0
@ -1796,8 +1805,6 @@ function groups_get_tree(&$groups, $parent = false) {
return $return;
}
function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
global $config;
@ -1831,7 +1838,6 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group') {
global $config;
if ($id_user == false) {
$id_user = $config['id_user'];
}

View File

@ -113,7 +113,7 @@ function networkmap_generate_hash($pandora_name, $group = 0,
$graph = networkmap_generate_dot($pandora_name, $group,
$simple, $font_size, $layout, $nooverlap, $zoom, $ranksep,
$center, $regen, $pure, $id_networkmap, $show_snmp_modules,
$cut_names, $relative, $text_filter);
$cut_names, $relative, $text_filter, false, null, false, $strict_user);
$return = array();
if (!empty($graph)) {
@ -234,7 +234,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
$relative = false, $text_filter = '', $l2_network = false, $ip_mask = null,
$dont_show_subgroups = false) {
$dont_show_subgroups = false, $strict_user = false) {
global $config;
@ -281,12 +281,35 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
//Order by id_parent ascendant for to avoid the bugs
//because the first agents to process in the next
//foreach loop are without parent (id_parent = 0)
// Get agents data
if ($strict_user) {
if ($dont_show_subgroups)
$filter['id_group'] = $group;
else {
if (!empty($childrens)) {
foreach ($childrens as $children) {
$filter_id_groups[$children] = $children;
}
}
$filter_id_groups[$group] = $group;
$filter['id_group'] = implode(',', $filter_id_groups);
}
$filter['group_by'] = 'tagente.id_agente';
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_parent, tagente.id_agente,
tagente.normal_count, tagente.warning_count, tagente.critical_count,
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
} else {
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'), 'AR',
array('field' => 'id_parent', 'order' => 'ASC'));
}
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'), 'AR',
array('field' => 'id_parent', 'order' => 'ASC'));
}
else if ($group == -666) {
$agents = false;
@ -295,22 +318,29 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$agents = networkmap_get_new_nodes_from_ip_mask($ip_mask,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'));
unknown_count, total_count, notinit_count'), $strict_user);
}
else {
//Order by id_parent ascendant for to avoid the bugs
//because the first agents to process in the next
//foreach loop are without parent (id_parent = 0)
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'), 'AR',
array('field' => 'id_parent', 'order' => 'ASC'));
if ($strict_user) {
$filter['group_by'] = 'tagente.id_agente';
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_parent, tagente.id_agente,
tagente.normal_count, tagente.warning_count, tagente.critical_count,
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
} else {
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'), 'AR',
array('field' => 'id_parent', 'order' => 'ASC'));
}
}
if ($agents === false)
//return false;
$agents = array();
@ -343,10 +373,14 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$filter = array();
$filter['disabled'] = 0;
// Get agent modules data
$modules = agents_get_modules($agent['id_agente'], '*',
$filter, true, true);
if ($strict_user) {
$modules = tags_get_agent_modules ($agent['id_agente'], $acltags, false, $filter, false);
} else {
$modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true);
}
if ($modules === false)
$modules = array();
@ -611,10 +645,13 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0,
$depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0,
$text_filter = '') {
$text_filter = '', $strict_user = false) {
global $config;
if ($strict_user) {
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
}
$parents = array();
$orphans = array();
@ -654,7 +691,11 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
$filter['id_grupo'] = $id_groups;
}
else {
$groups = db_get_all_rows_in_table ('tgrupo');
if ($strict_user) {
$groups = users_get_groups ($config['id_user'],"AR", false, true);
} else {
$groups = db_get_all_rows_in_table ('tgrupo');
}
if ($groups === false) {
$groups = array();
}
@ -676,7 +717,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
// Add node
$nodes_groups[$group2['id_grupo']] = $group2;
}
$node_count = 0;
$groups_hiden = array();
@ -702,12 +743,19 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
}
if ($depth != 'group') {
if ($strict_user) {
$filter['group_by'] = 'tagente.nombre';
$fields = array ('tagente.id_grupo, tagente.nombre, tagente.id_os, tagente.id_agente,
tagente.normal_count, tagente.warning_count, tagente.critical_count,
tagente.unknown_count, tagente.total_count, tagente.notinit_count');
$agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
} else {
// Get agents data
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'));
}
if ($agents === false)
$agents = array();
@ -741,7 +789,13 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
}
// Get agent modules data
$modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false);
if ($strict_user) {
$filter['disabled'] = 0;
$modules = tags_get_agent_modules ($agent['id_agente'], $acltags, false, $filter, false);
} else {
$modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false);
}
// Parse modules
foreach ($modules as $key => $module) {
$node_count ++;
@ -784,7 +838,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
// Create void statistics array
$stats = array();
// Create nodes
foreach ($nodes as $node_id => $node) {
if ($center > 0 && ! networkmap_is_descendant ($node_id, $center, $parents)) {
@ -795,7 +849,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
}
switch ($node['type']) {
case 'group':
$graph .= networkmap_create_group_node ($node , $simple, $font_size) .
$graph .= networkmap_create_group_node ($node , $simple, $font_size, $metaconsole = false, null, $strict_user) .
"\n\t\t";
$stats['groups'][] = $node['id_grupo'];
break;
@ -878,12 +932,12 @@ function networkmap_create_transparent_edge($head, $tail) {
}
// Returns a group node definition
function networkmap_create_group_node ($group, $simple = 0, $font_size = 10, $metaconsole = false, $id_server = null) {
function networkmap_create_group_node ($group, $simple = 0, $font_size = 10, $metaconsole = false, $id_server = null, $strict_user = false) {
global $config;
global $hack_networkmap_mobile;
$status = groups_get_status ($group['id_grupo']);
$status = groups_get_status ($group['id_grupo'], $strict_user);
// Set node status
switch ($status) {
case 0:
@ -963,11 +1017,21 @@ function networkmap_create_group_node ($group, $simple = 0, $font_size = 10, $me
}
// Returns a node definition
function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cut_names = true, $relative = false, $metaconsole = false, $id_server = null) {
function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cut_names = true, $relative = false, $metaconsole = false, $id_server = null, $strict_user = false) {
global $config;
global $hack_networkmap_mobile;
$status = agents_get_status_from_counts($agent);
if ($strict_user) {
$strict_data['normal_count'] = groups_agent_ok ($agent['id_grupo'], $strict_user, $agent['id_grupo']);
$strict_data['warning_count'] = groups_agent_warning ($agent['id_grupo'], $strict_user, $agent['id_grupo']);
$strict_data['critical_count'] = groups_agent_critical ($agent['id_grupo'], $strict_user, $agent['id_grupo']);
$strict_data['unknown_count'] = groups_agent_unknown ($agent['id_grupo'], $strict_user, $agent['id_grupo']);
$strict_data['notinit_count'] = groups_agent_not_init ($agent['id_grupo'], $strict_user, $agent['id_grupo']);
$strict_data['total_count'] = groups_agent_total ($agent['id_grupo'], $strict_user, $agent['id_grupo']);
$status = agents_get_status_from_counts($strict_data);
} else {
$status = agents_get_status_from_counts($agent);
}
if (defined('METACONSOLE')) {
$server_data = db_get_row('tmetaconsole_setup', 'id',
@ -1062,7 +1126,7 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
$url_tooltip = 'ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'];
}
$node = "\n" . $agent['id_node'] . ' [ color="' . $status_color . '", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>' . $img_node . '</TD></TR>
$node = "\n" . $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>' . $img_node . '</TD></TR>
<TR><TD>'.io_safe_output($name).'</TD></TR></TABLE>>,
shape="doublecircle", URL="'.$url.'",
tooltip="' . $url_tooltip . '"];' . "\n";
@ -1500,7 +1564,7 @@ function networkmap_get_networkmap ($id_networkmap, $filter = false, $fields = f
*
* @return Networkmap with the given id. False if not available or readable.
*/
function networkmap_get_networkmaps ($id_user = '', $type = '', $optgrouped = true) {
function networkmap_get_networkmaps ($id_user = '', $type = '', $optgrouped = true, $strict_user = false) {
global $config;
if ($id_user == '') {
@ -1527,11 +1591,17 @@ function networkmap_get_networkmaps ($id_user = '', $type = '', $optgrouped = tr
$networkmaps = array();
foreach ($networkmaps_raw as $key => $networkmapitem) {
if ($optgrouped) {
if ((($networkmapitem['type'] == 'policies') || ($networkmapitem['type'] == 'radial_dynamic')) && ($strict_user)) {
continue;
}
$networkmaps[$networkmapitem['id_networkmap']] =
array('name' => $networkmapitem['name'],
'optgroup' => $networkmapitem['type']);
}
else {
if ((($networkmapitem['type'] == 'policies') || ($networkmapitem['type'] == 'radial_dynamic')) && ($strict_user)) {
continue;
}
$networkmaps[$networkmapitem['id_networkmap']] =
$networkmapitem['name'];
}
@ -1600,7 +1670,7 @@ function networkmap_update_networkmap ($id_networkmap, $values) {
*
* @return Array Networkmap diferent types.
*/
function networkmap_get_types () {
function networkmap_get_types ($strict_user = false) {
$networkmap_types = array();
$is_enterprise = enterprise_include_once('include/functions_policies.php');
@ -1608,9 +1678,11 @@ function networkmap_get_types () {
$networkmap_types['topology'] = __('Create a new topology map');
$networkmap_types['groups'] = __('Create a new group map');
$networkmap_types['dinamic'] = __('Create a new dynamic map');
$networkmap_types['radial_dynamic'] = __('Create a new radial dynamic map');
if (!$strict_user) {
$networkmap_types['radial_dynamic'] = __('Create a new radial dynamic map');
}
if ($is_enterprise !== ENTERPRISE_NOT_HOOK) {
if (($is_enterprise !== ENTERPRISE_NOT_HOOK) && (!$strict_user)) {
$enterprise_types = enterprise_hook('policies_get_networkmap_types');
$networkmap_types = array_merge($networkmap_types, $enterprise_types);
@ -1624,7 +1696,7 @@ function networkmap_get_types () {
*
* @return Array Networkmap diferent types.
*/
function networkmap_get_filter_types () {
function networkmap_get_filter_types ($strict_user = false) {
$networkmap_types = array();
$is_enterprise = enterprise_include_once('include/functions_policies.php');
@ -1632,9 +1704,11 @@ function networkmap_get_filter_types () {
$networkmap_types['topology'] = __('Topology');
$networkmap_types['groups'] = __('Group');
$networkmap_types['dinamic'] = __('Dynamic');
$networkmap_types['radial_dynamic'] = __('Radial dynamic');
if (!$strict_user) {
$networkmap_types['radial_dynamic'] = __('Radial dynamic');
}
if ($is_enterprise !== ENTERPRISE_NOT_HOOK) {
if (($is_enterprise !== ENTERPRISE_NOT_HOOK) && (!$strict_user)) {
$enterprise_types = enterprise_hook('policies_get_networkmap_filter_types');
$networkmap_types = array_merge($networkmap_types, $enterprise_types);
@ -1659,28 +1733,48 @@ function networkmap_cidr_match($ip, $cidr_mask) {
return ($ip & $mask) == $subnet;
}
function networkmap_get_new_nodes_from_ip_mask($ip_mask, $fields = array()) {
function networkmap_get_new_nodes_from_ip_mask($ip_mask, $fields = array(), $strict_user = false) {
$list_ip_masks = explode(",", $ip_mask);
$list_address = db_get_all_rows_in_table('taddress');
if (empty($address))
$address = array();
if ($strict_user) {
$filter['group_by'] = 'tagente.id_agente';
$fields = array ('tagente.id_agente');
$acltags = tags_get_user_module_and_tags ($config['id_user'],'AR', $strict_user);
$user_agents = tags_get_all_user_agents (false, $config['id_user'], $acltags, $filter, $fields, false, $strict_user, true);
foreach ($all_user_agents as $agent) {
$user_agents[$agent['id_agente']] = $agent['id_agente'];
}
}
$agents = array();
foreach ($list_address as $address) {
foreach ($list_ip_masks as $ip_mask) {
if (networkmap_cidr_match($address['ip'], $ip_mask)) {
$id_agent = db_get_value_filter('id_agent', 'taddress_agent', array('id_a' => $address['id_a']));
if (empty($fields)) {
$agents[] = db_get_value_filter('id_agent',
'taddress_agent', array('id_a' => $address['id_a']));
if ($strict_user) {
if (array_key_exists($id_agent, $user_agents)) {
$agents[] = db_get_value_filter('id_agent', 'taddress_agent', array('id_a' => $address['id_a']));
}
} else {
$agents[] = db_get_value_filter('id_agent', 'taddress_agent', array('id_a' => $address['id_a']));
}
}
else {
$id_agent = db_get_value_filter('id_agent',
'taddress_agent', array('id_a' => $address['id_a']));
$agents[] = db_get_row('tagente', 'id_agente',
$id_agent, $fields);
if ($strict_user) {
if (array_key_exists($id_agent, $user_agents)) {
$agents[] = db_get_row('tagente', 'id_agente', $id_agent, $fields);
}
} else {
$agents[] = db_get_row('tagente', 'id_agente', $id_agent, $fields);
}
}
}
}

View File

@ -433,7 +433,7 @@ function tags_insert_module_tag ($id_agent_module, $tags) {
$values = array();
if ($tags == false) {
if($tags == false) {
$tags = array();
}
@ -590,17 +590,6 @@ function tags_get_module_tags ($id, $policy = false) {
return $return;
}
function tags_get_module_policy_tags($id_tag, $id_module) {
if (empty($id_tag))
return false;
$id_module_policy = db_get_value_filter('id_policy_module',
'ttag_module',
array('id_tag' => $id_tag, 'id_agente_modulo' => $id_module));
return $id_module_policy;
}
/**
* Select all tags of a policy module.
*
@ -1798,14 +1787,15 @@ function tags_get_monitors_alerts ($id_tag, $groups_and_tags = array()) {
*
* @return mixed Returns count of agents with this tag or false if they aren't.
*/
function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true) {
function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_and_tags = array(), $filter = false, $fields = false, $meta = true, $strict_user = true, $return_all_fields = false) {
global $config;
// Avoid mysql error
if (empty($id_tag))
return;
if (empty($id_tag)) {
$tag_filter = '';
} else {
$tag_filter = " AND ttag_module.id_tag = " . $id_tag;
}
if (empty($id_user)) {
$id_user = $config['id_user'];
}
@ -1815,17 +1805,60 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags =
$fields[0] = "id_agente";
$fields[1] = "nombre";
}
$select_fields = implode(',',$fields);
$select_fields = implode(',',$fields);
$groups_clause = "";
if ($strict_user) {
if (!empty($groups_and_tags)) {
$groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo");
$groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo");
}
} else {
$groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")";
}
if (!empty($filter['id_group'])) {
$groups_clause .= " AND tagente.id_grupo IN (".$filter['id_group'].")";
}
$status_sql = '';
if (isset($filter['status'])) {
switch ($filter['status']) {
case AGENT_STATUS_NORMAL:
$status_sql =
" AND (normal_count = total_count)";
break;
case AGENT_STATUS_WARNING:
$status_sql =
"AND (critical_count = 0 AND warning_count > 0)";
break;
case AGENT_STATUS_CRITICAL:
$status_sql =
"AND (critical_count > 0)";
break;
case AGENT_STATUS_UNKNOWN:
$status_sql =
"AND (critical_count = 0 AND warning_count = 0
AND unknown_count > 0)";
break;
case AGENT_STATUS_NOT_NORMAL:
$status_sql = " AND (normal_count <> total_count)";
break;
case AGENT_STATUS_NOT_INIT:
$status_sql = "AND (notinit_count = total_count)";
break;
}
}
if (!empty($filter['group_by'])) {
$group_by = " GROUP BY ".$filter['group_by'];
}
$id_agent_search = '';
if (!empty($filter['id_agent'])) {
$id_agent_search = " AND tagente.id_agente = ".$filter['id_agent'];
}
$search_sql = "";
$void_agents = "";
if ($filter) {
@ -1840,23 +1873,29 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags =
}
}
}
$user_agents_sql = "SELECT ".$select_fields ."
FROM tagente, tagente_modulo, ttag_module
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo
AND ttag_module.id_tag = " . $id_tag .
". $tag_filter .
$groups_clause . $search_sql . $void_agents .
$status_sql .
$group_by .
" ORDER BY tagente.nombre ASC";
//return db_get_sql ($user_agents);
$user_agents = db_get_all_rows_sql($user_agents_sql);
$user_agents = db_get_all_rows_sql($user_agents_sql);
if ($user_agents == false) {
$user_agents = array();
}
if ($return_all_fields) {
return $user_agents;
}
if (!$meta){
$user_agents_aux = array();
if ($user_agents === false) {
$user_agents = array();
}
foreach ($user_agents as $ua) {
$user_agents_aux[$ua['id_agente']] = $ua['nombre'];
}
@ -1864,4 +1903,73 @@ function tags_get_all_user_agents ($id_tag, $id_user = false, $groups_and_tags =
}
return $user_agents;
}
function tags_get_agent_modules ($id_agent, $groups_and_tags = array(), $fields = false, $filter = false, $return_all_fields = false) {
global $config;
// Avoid mysql error
if (empty($id_agent))
return;
if (!is_array ($fields)) {
$fields = array ();
$fields[0] = "id_agente_modulo";
$fields[1] = "nombre";
}
$select_fields = implode(',',$fields);
if ($filter) {
$filter_sql = '';
if (isset($filter['disabled'])) {
$filter_sql .= " AND disabled = ".$filter['disabled'];
}
if (isset($filter['nombre'])) {
$filter_sql .= ' AND nombre LIKE "' .$filter['nombre'].'"';
}
}
$tag_filter = "";
if (!empty($groups_and_tags)) {
$agent_group = db_get_value('id_grupo', 'tagente', 'id_agente', $id_agent);
if (isset($groups_and_tags[$agent_group]) && ($groups_and_tags[$agent_group] != '')) {
//~ $tag_filter = " AND ttag_module.id_tag IN (".$groups_and_tags[$agent_group].")";
$tag_filter = " AND id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (".$groups_and_tags[$agent_group]."))";
}
}
$agent_modules_sql = "SELECT ".$select_fields ."
FROM tagente_modulo
WHERE id_agente=". $id_agent .
$tag_filter .
$filter_sql ."
ORDER BY nombre";
$agent_modules = db_get_all_rows_sql($agent_modules_sql);
if ($agent_modules == false) {
$agent_modules = array();
}
if ($return_all_fields) {
$result = array();
foreach ($agent_modules as $am) {
$am['status'] = modules_get_agentmodule_status($am['id_agente_modulo']);
$am['isinit'] = modules_get_agentmodule_is_init($am['id_agente_modulo']);
if ($am['isinit']) {
}
$result[$am['id_agente_modulo']] = $am;
}
return $result;
}
$result = array();
foreach ($agent_modules as $am) {
$result[$am['id_agente_modulo']] = $am['nombre'];
}
return $result;
}
?>

View File

@ -28,6 +28,8 @@ if (! check_acl ($config['id_user'], 0, "AR")) {
require_once ('include/functions_networkmap.php');
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
if ($activeTab == "radial_dynamic") {
include_once("include/functions_graph.php");
@ -39,7 +41,7 @@ if ($activeTab == "radial_dynamic") {
if (!empty($module_group))
$filter['module_group'] = $module_group;
echo graph_monitor_wheel(600, 650, $filter);
echo graph_monitor_wheel(600, 650, $filter, $strict_user);
echo "</div>";
return;
@ -56,7 +58,7 @@ if (!isset($text_filter)) {
$graph = networkmap_generate_hash(__('Pandora FMS'), $group, $simple,
$font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen,
$pure, $id_networkmap, $show_snmp_modules, true, true,
$text_filter);
$text_filter, $strict_user);
networkmap_print_jsdata($graph);

View File

@ -28,6 +28,8 @@ if (! check_acl ($config['id_user'], 0, "AR")) {
require_once ('include/functions_networkmap.php');
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
// Set filter
$filter = networkmap_get_filter ($layout);
@ -36,7 +38,7 @@ $filter = networkmap_get_filter ($layout);
$graph = networkmap_generate_dot_groups (__('Pandora FMS'), $group,
$simple, $font_size, $layout, $nooverlap, $zoom, $ranksep, $center,
$regen, $pure, $modwithalerts, $module_group, $hidepolicymodules,
$depth, $id_networkmap, $dont_show_subgroups, $text_filter);
$depth, $id_networkmap, $dont_show_subgroups, $text_filter, $strict_user);
if ($graph === false) {
ui_print_error_message (__('Map could not be generated'));

View File

@ -28,6 +28,8 @@ if (! check_acl ($config['id_user'], 0, "AR")) {
require_once ('include/functions_networkmap.php');
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$name = '';
$pure = (int) get_parameter ('pure', 0);
$activeTab = get_parameter ('tab', 'topology');
@ -143,7 +145,7 @@ if ($save_networkmap || $update_networkmap) {
}
}
$networkmaps = networkmap_get_networkmaps();
$networkmaps = networkmap_get_networkmaps('','', true, $strict_user);
$nomaps = false;
if ($networkmaps === false) {
@ -197,7 +199,7 @@ else {
'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;pure=1&amp;tab='.$activeTab.'">' .
html_print_image("images/full_screen.png", true, array ('title' => __('Full screen'))) .'</a>');
}
if ($config['enterprise_installed']) {
if (($config['enterprise_installed']) && (!$strict_user)) {
$buttons['policies'] = array('active' => $activeTab == 'policies',
'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;tab=policies&amp;pure='.$pure.'">' .
html_print_image("images/policies_mc.png", true, array ("title" => __('Policies view'))) .'</a>');
@ -215,9 +217,11 @@ $buttons['dinamic'] = array('active' => $activeTab == 'dinamic',
'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;tab=dinamic&amp;pure='.$pure.'">' .
html_print_image("images/dynamic_network_icon.png", true, array ("title" => __('Dynamic view'))) .'</a>');
$buttons['radial_dinamic'] = array('active' => $activeTab == 'radial_dynamic',
'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;tab=radial_dynamic&amp;pure='.$pure.'">' .
html_print_image("images/radial_dynamic_network_icon.png", true, array ("title" => __('Radial dynamic view'))) .'</a>');
if (!$strict_user) {
$buttons['radial_dinamic'] = array('active' => $activeTab == 'radial_dynamic',
'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;tab=radial_dynamic&amp;pure='.$pure.'">' .
html_print_image("images/radial_dynamic_network_icon.png", true, array ("title" => __('Radial dynamic view'))) .'</a>');
}
$combolist = '<form name="query_sel" method="post" action="index.php?sec=network&sec2=operation/agentes/networkmap">';
@ -295,7 +299,7 @@ if (!empty($name)) {
ui_print_page_header (__('Network map') . " - " . $title,
"images/op_network.png", false, "network_map", false, $buttons);
if (tags_has_user_acl_tags()) {
if ((tags_has_user_acl_tags()) && (!$strict_user)) {
ui_print_tags_warning();
}

View File

@ -28,6 +28,8 @@ if (! check_acl ($config['id_user'], 0, "AR")) {
require_once ('include/functions_networkmap.php');
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
// Set filter
$filter = networkmap_get_filter ($layout);
@ -39,7 +41,7 @@ if (!isset($text_filter)) {
$graph = networkmap_generate_dot(__('Pandora FMS'), $group, $simple,
$font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen,
$pure, $id_networkmap, $show_snmp_modules, true, true,
$text_filter, $l2_network, null, $dont_show_subgroups);
$text_filter, $l2_network, null, $dont_show_subgroups, $strict_user);
if ($graph === false) {
ui_print_error_message (__('Map could not be generated'));

View File

@ -73,6 +73,8 @@ if (is_ajax()) {
return;
}
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
ui_print_page_header(__('Network map'), "images/op_network.png", false, "network_map", false);
// Delete networkmap action
@ -118,7 +120,7 @@ $type_search = get_parameter('type_filter', '0');
</td>
<td class='datos'>
<?php
$networkmap_filter_types = networkmap_get_filter_types();
$networkmap_filter_types = networkmap_get_filter_types($strict_user);
html_print_select($networkmap_filter_types, 'type_filter',
$type_search, '', __('All'), 0, false);
?>
@ -200,7 +202,11 @@ else {
// If enterprise not loaded then skip this code
if ($network_map['type'] == 'policies' and (!defined('PANDORA_ENTERPRISE')))
continue;
if (($network_map['type'] == 'radial_dynamic' || $network_map['type'] == 'policies') && ($strict_user)) {
continue;
}
$data = array();
$data[0] = '<b><a href="index.php?sec=network&sec2=operation/agentes/networkmap&tab=view&id_networkmap=' . $network_map['id_networkmap'] . '">' . $network_map['name'] . '</a></b>';
$data[1] = $network_map['type'];
@ -234,7 +240,7 @@ if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0,
'create' => __('Create'),
'delete' => __('Delete')
);
$networkmap_types = networkmap_get_types();
$networkmap_types = networkmap_get_types($strict_user);
$delete_options = array(
'selected' => __('Delete selected')
);