i noticed that after adding an 'Zabbix admin' user and allowing him read-write access to any single host group, he will gets read-write access to _all_ hosts and groups. i really wonder why this is not fixed in any patches here cos this makes user management completely useless. here is the patch (not the best but works).
File: include/perm.inc.php
find definition of function 'get_accessible_hosts_by_user' and edit it like this:
Before:
After:
File: include/perm.inc.php
find definition of function 'get_accessible_hosts_by_user' and edit it like this:
Before:
Code:
...
while($host_data = DBfetch($db_hosts))
{
$host_data += DBfetch(DBselect('select * from hosts where hostid='.$host_data['hostid']));
if(is_null($host_data['nodeid'])) $host_data['nodeid'] = id2nodeid($host_data['hostid']);
/* if no rights defined used node rights */
if( (is_null($host_data['permission']) || is_null($host_data['userid'])) )
{
if( isset($processed[$host_data['hostid']]) )
continue;
if(!isset($nodes))
{
$nodes = get_accessible_nodes_by_user($user_data,PERM_DENY,PERM_MODE_GE,PERM_RES_DATA_ARRAY);
}
if( !isset($nodes[$host_data['nodeid']]) || $user_type==USER_TYPE_ZABBIX_USER )
$host_data['permission'] = PERM_DENY;
else
$host_data['permission'] = $nodes[$host_data['nodeid']]['permission'];
}
$processed[$host_data['hostid']] = true;
if(eval('return ('.$host_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
continue;
$result[$host_data['hostid']] = eval('return '.$resdata.';');
}
...
Code:
...
while($host_data = DBfetch($db_hosts))
{
[B]if(!is_null($host_data['userid'])) {[/B]
$host_data += DBfetch(DBselect('select * from hosts where hostid='.$host_data['hostid']));
if(is_null($host_data['nodeid'])) $host_data['nodeid'] = id2nodeid($host_data['hostid']);
/* if no rights defined used node rights */
if( (is_null($host_data['permission']) || is_null($host_data['userid'])) )
{
if( isset($processed[$host_data['hostid']]) )
continue;
if(!isset($nodes))
{
$nodes = get_accessible_nodes_by_user($user_data,PERM_DENY,PERM_MODE_GE,PERM_RES_DATA_ARRAY);
}
if( !isset($nodes[$host_data['nodeid']]) || $user_type==USER_TYPE_ZABBIX_USER )
$host_data['permission'] = PERM_DENY;
else
$host_data['permission'] = $nodes[$host_data['nodeid']]['permission'];
}
$processed[$host_data['hostid']] = true;
if(eval('return ('.$host_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
continue;
$result[$host_data['hostid']] = eval('return '.$resdata.';');
[B]}[/B]
}
...
there is a little correction in patch for charts.php
Comment