[ZBX-25845] Permission issue: Some users cannot see all hosts or items, even with proper permissions Created: 2025 Jan 08 Updated: 2025 Feb 03 Resolved: 2025 Jan 13 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 7.2.1 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Critical |
Reporter: | Simon D. | Assignee: | Vladimirs Maksimovs |
Resolution: | Workaround proposed | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | 9h | ||
Original Estimate: | Not Specified | ||
Environment: |
Database: PostgreSQL/MySQL |
Attachments: |
![]() |
||||
Issue Links: |
|
||||
Team: | |||||
Sprint: | S25-W2/3 |
Description |
Comments |
Comment by Alexander Vladishev [ 2025 Jan 08 ] |
Starting from version 7.0, intermediate tables were introduced to improve the performance of permissions calculations.
select hg.hostid, max(r.permission) as permission from hosts_groups hg, rights r, users_groups ug, users u where hg.groupid = r.id and r.groupid = ug.usrgrpid and ug.userid = u.userid and u.username = '<username>' group by hg.hostid having min(r.permission)>0 select hhg.hostid, p.permission from users u, user_ugset uug, permission p, host_hgset hhg where u.userid = uug.userid and uug.ugsetid = p.ugsetid and p.hgsetid = hhg.hgsetid and u.username = '<username>' order by u.userid, hhg.hostid UPD: Apologies for the incorrect information. The intermediate tables are updated both on the server side and on the API/frontend side. The first question is retracted. |
Comment by Alexander Vladishev [ 2025 Jan 08 ] |
It seems I have reproduced this issue on latest 7.0.8:
The templates "Acronis Cyber Protect Cloud by HTTP", "Acronis Cyber Protect Cloud MSP by HTTP", and "Nextcloud by HTTP" do not appear, although they belong to the "Templates/Applications" group. The proposed SQL statements also return a different number of records. |
Comment by Alexander Vladishev [ 2025 Jan 09 ] |
After some additional investigation, it turned out that the issue with the templates is caused by missing entries in the host_hgset table in the default dataset. We will definitely fix this. There are no such entries for six templates: "Acronis Cyber Protect Cloud by HTTP", "Acronis Cyber Protect Cloud MSP by HTTP", "Nextcloud by HTTP", "FortiGate by HTTP", "FortiGate by SNMP", and "HPE iLO by HTTP". Your issue is not related to these templates. Therefore, we are waiting for the output of the SQL queries from you. Thank you! |
Comment by Simon D. [ 2025 Jan 09 ] |
Thank you for your comments.
select max(r.permission), hg.hostid from hosts_groups hg, rights r, users_groups ug, users u where hg.groupid = r.id and r.groupid = ug.usrgrpid and ug.userid = u.userid and u.username = '<username>' group by hg.hostid having min(r.permission)>0
Gives: max|hostid| ---+------+ 2| 10294| 2| 11253| 2| 11189| 2| 10902| 2| 10734| 2| 10476| 2| 10477| 2| 10898| 2| 10706| 2| 10436| 2| 10893| 2| 10754| 2| 10838| 2| 10259| 2| 11252| 2| 10334| 2| 11251| 2| 11194| 2| 10260| 2| 11195| 2| 10310| 2| 10844| 2| 10884| 2| 10903| 2| 10735| 2| 10378| 2| 10370| 2| 10376| 2| 11254| 2| 10758| 2| 10295| 2| 10755| 2| 10674| 2| 11192| 2| 11190| 2| 10757| 2| 10435| 2| 10883| 2| 11250| 2| 10258| 2| 10279| 2| 10311| 2| 11245| 2| 10894| 2| 10312| 2| 10144| 2| 10471| 2| 10809| 2| 10579| 2| 10896| And
select u.userid, hhg.hostid, p.permission from users u, user_ugset uug, permission p, host_hgset hhg where u.userid = uug.userid and uug.ugsetid = p.ugsetid and p.hgsetid = hhg.hgsetid and u.username = '<username>' order by u.userid, hhg.hostid
Gives : userid|hostid|permission| ------+------+----------+ 25| 10376| 2| 25| 10674| 2| 25| 10757| 2| 25| 10758| 2| 25| 10838| 2| 25| 10844| 2| 25| 10884| 2| 25| 10893| 2| 25| 10894| 2| 25| 10896| 2| 25| 10898| 2| 25| 10902| 2| 25| 10903| 2| 25| 11189| 2| 25| 11190| 2| 25| 11192| 2| 25| 11194| 2| 25| 11195| 2| 25| 11245| 2| 25| 11250| 2| 25| 11251| 2| 25| 11252| 2| 25| 11253| 2| 25| 11254| 2| |
Comment by Alexander Vladishev [ 2025 Jan 09 ] |
--- config.txt 2025-01-09 09:49:27.209694395 +0000 +++ cache.txt 2025-01-09 09:49:20.085699642 +0000 @@ -1,37 +1,11 @@ userid|hostid|permission| ------+------+----------+ - 25| 10144| 2| - 25| 10258| 2| - 25| 10259| 2| - 25| 10260| 2| - 25| 10279| 2| - 25| 10294| 2| - 25| 10295| 2| - 25| 10310| 2| - 25| 10311| 2| - 25| 10312| 2| - 25| 10334| 2| - 25| 10370| 2| 25| 10376| 2| - 25| 10378| 2| - 25| 10435| 2| - 25| 10436| 2| - 25| 10471| 2| - 25| 10476| 2| - 25| 10477| 2| - 25| 10579| 2| 25| 10674| 2| - 25| 10706| 2| - 25| 10734| 2| - 25| 10735| 2| - 25| 10754| 2| - 25| 10755| 2| 25| 10757| 2| 25| 10758| 2| - 25| 10809| 2| 25| 10838| 2| 25| 10844| 2| - 25| 10883| 2| 25| 10884| 2| 25| 10893| 2| 25| 10894| 2| As expected, the intermediate tables are missing some entries.
|
Comment by Simon D. [ 2025 Jan 09 ] |
We did not manipulate data values on databases. But, we had to adjust format of some primary keys and foreign keys because updates did not adjust them correctly (since version 7). particularly on primary keys (should be bigint/int8, but we had in4, numeric...), and we had to recreate missing indexes. The first version of our zabbix vas version 5, and 3 years ago, we migrated from mysql to pgsql with no issues until version 7.
The SQL query gives only 155 of our 231 hosts configured. |
Comment by Vladimirs Maksimovs [ 2025 Jan 09 ] |
Hello, dedisoft! Thank you for active help with investigation of this issue. |
Comment by Simon D. [ 2025 Jan 09 ] |
No, hosts were always configured with at least one host group. |
Comment by Vladimirs Maksimovs [ 2025 Jan 09 ] |
Sorry for primitive questions. |
Comment by Simon D. [ 2025 Jan 09 ] |
No worries, thank you for your help. Most of our hosts were already configured before 7.0 update, so around 220 - 230 hosts. All are configured by the UI. |
Comment by Vladimirs Maksimovs [ 2025 Jan 09 ] |
Have you noticed this permission issue right after upgrade to 7.0, or after some time? Do you have the zabbix server log at the moment of upgrade to 7.0? Could you provide your database schema, please? Just to compare how much it matches the original one. |
Comment by Alexander Vladishev [ 2025 Jan 09 ] |
This command can be used to dump the database schema: pg_dump -U <user_name> <db_name> --schema-only | gzip -c > schema.dump.gz |
Comment by Simon D. [ 2025 Jan 09 ] |
Comment by Simon D. [ 2025 Jan 10 ] |
Hi, How can we generate missing host_hgset entries ? Thanks |
Comment by Vladimirs Maksimovs [ 2025 Jan 10 ] |
Here are the steps to generate missing host_hgset records: 1. Do the following actions in database: select h.hostid, h.host from hosts h where h.flags = 0 and h.hostid not in (select hostid from host_hgset); 1.2. On database level: insert into host_hgset table entry for each host collected in step 1 by setting the any of existing hgsetid. INSERT INTO host_hgset (hostid,hgsetid) VALUES ('<missing hostid>','<any of existing hgsetid>'); 2. Do the following actions in UI or API: After the following steps host_hgset records will be generated correctly. |
Comment by Simon D. [ 2025 Jan 13 ] |
Thank you very much. It solved our problem. |
Comment by Vladimirs Maksimovs [ 2025 Jan 13 ] |
Hello dedisoft! Thank you again for active help in issue detection! Due to lack of all necessary information we wasn't able to reproduce the issue. The instructions of how to repair the permissions is given in the comment above. The described above issue related with the templates will be fixed in scope of The current ticket is considering to be closed. |