Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cacti 1.3.6 (develop branch) many duplicate options on user permisson settings #1388

Closed
pautiina opened this issue Feb 22, 2018 · 17 comments
Closed

Comments

@pautiina
Copy link
Contributor

pautiina commented Feb 22, 2018

Hello.
I have plugins Weathermap and after update code from develop branch I have some problem with settings:
image
And plugin tab not showing.
On cacti log:

2018/02/22 10:16:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/user_admin.php: 55 user_edit)(/user_admin.php: 2105 user_realms_edit)(/user_admin.php: 1748 CactiErrorHandler)(/lib/functions.php: 4587 cacti_debug_backtrace)
--
2018/02/22 10:16:01 - ERROR PHP NOTICE: Undefined offset: 2459 in file: /var/www/cacti/user_admin.php on line: 1748
2018/02/22 10:16:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/user_admin.php: 55 user_edit)(/user_admin.php: 2105 user_realms_edit)(/user_admin.php: 1746 CactiErrorHandler)(/lib/functions.php: 4587 cacti_debug_backtrace)
2018/02/22 10:16:01 - ERROR PHP NOTICE: Undefined offset: 2459 in file: /var/www/cacti/user_admin.php on line: 1746
2018/02/22 10:16:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/user_admin.php: 55 user_edit)(/user_admin.php: 2105 user_realms_edit)(/user_admin.php: 1748 CactiErrorHandler)(/lib/functions.php: 4587 cacti_debug_backtrace)
2018/02/22 10:16:01 - ERROR PHP NOTICE: Undefined offset: 2461 in file: /var/www/cacti/user_admin.php on line: 1748
2018/02/22 10:16:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/user_admin.php: 55 user_edit)(/user_admin.php: 2105 user_realms_edit)(/user_admin.php: 1746 CactiErrorHandler)(/lib/functions.php: 4587 cacti_debug_backtrace)
2018/02/22 10:16:01 - ERROR PHP NOTICE: Undefined offset: 2461 in file: /var/www/cacti/user_admin.php on line: 1746
2018/02/22 10:16:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/user_admin.php: 55 user_edit)(/user_admin.php: 2105 user_realms_edit)(/user_admin.php: 1748 CactiErrorHandler)(/lib/functions.php: 4587 cacti_debug_backtrace)
2018/02/22 10:16:01 - ERROR PHP NOTICE: Undefined offset: 2460 in file: /var/www/cacti/user_admin.php on line: 1748
2018/02/22 10:16:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/user_admin.php: 55 user_edit)(/user_admin.php: 2105 user_realms_edit)(/user_admin.php: 1746 CactiErrorHandler)(/lib/functions.php: 4587 cacti_debug_backtrace)
2018/02/22 10:16:01 - ERROR PHP NOTICE: Undefined offset: 2460 in file: /var/www/cacti/user_admin.php on line: 1746


@pautiina pautiina changed the title Cacti 1.3.6 (develop branch) many duplicate options on settings Cacti 1.3.6 (develop branch) many duplicate options on user permisson settings Feb 22, 2018
@netniV
Copy link
Member

netniV commented Feb 22, 2018

That would appear to be a weathermap issue, not a cacti issue. However, I think there may still be a bug were if the realm isn't found, it still tries to display it (based on a quick glance at user_admin.php)

@pautiina
Copy link
Contributor Author

I have two servers Cacti (develop-branch). On one plugin weathermap I constantly update and test from the develop branch. On the second server, I have not touched the plugin weathermap for a very long time.
And the problem is observed on two servers.

@netniV
Copy link
Member

netniV commented Feb 22, 2018

I have other plugins that I am constantly updated and they do not exhibit this issue. It's going to be something between the core code and the way he's creating his realms.

But I have work to do so I can't really look into it too much right now 👎

@pautiina
Copy link
Contributor Author

I also have other plugins and there are no problems with them. The only thing that I sin yet, it's on the plugin THOLD. I updated it today and it turned out that way.

@netniV
Copy link
Member

netniV commented Feb 22, 2018

So updating a plugin is duplicating the realms?

@pautiina
Copy link
Contributor Author

Maybe. I can not repeat the bug. And I do not know why it happened. I now want to remove extra realm and then watch what happens.

@netniV
Copy link
Member

netniV commented Feb 22, 2018

Well, your permissions are based on a realm. So, if you remove the newer realms, it should be OK. eg, keep the first realm matching the plugin and file. Remove the others.

@netniV
Copy link
Member

netniV commented Feb 22, 2018

I think I see a problem. I decided to look. My suggested fix (not tesed):

--- a/lib/plugins.php
+++ b/lib/plugins.php
@@ -672,7 +672,7 @@ function api_plugin_register_realm ($plugin, $file, $display, $admin = true) {
                AND file = ?',
                array($plugin, $file), false);

-       if (!empty($exists)) {
+       if (empty($exists)) {
                db_execute_prepared('INSERT INTO plugin_realms
                        (plugin, file, display)
                        VALUES (?, ?, ?)',

@pautiina
Copy link
Contributor Author

@netniV you patch resolve problem

@netniV
Copy link
Member

netniV commented Feb 22, 2018

Err, I updated the patch as I pasted the wrong one haha. The one I did paste wouldn't ever register a realm ergo no permissions EVER

@pautiina
Copy link
Contributor Author

What do you mean?
I have your patch working. Only I first deleted all realms associated with the Weathermap

@netniV
Copy link
Member

netniV commented Feb 22, 2018

Let me tripple check it.. but Weathermaps IS spamming the register_realm function. See an update on the weathermaps issue.

@netniV
Copy link
Member

netniV commented Feb 22, 2018

Well, it would appear that either works.

2018/02/22 09:46:12 - CMDPHP api_plugin_register_realm('quicktree', 'quicktree.php', 'Plugin -> QuickTree: Access', 1 ) , set = Yes, empty = Yes, false = Yes, sizeof = 1

Smallest change is the removal of the ! but checking $exists === false is equally valid apparently 👍

@netniV
Copy link
Member

netniV commented Feb 22, 2018

160a42c is where this broke as part of #1384

@cigamit
Copy link
Member

cigamit commented Feb 22, 2018

Yea, woops.

cigamit added a commit that referenced this issue Feb 22, 2018
Realm permissions can be duplicated due to develop branch
lib/plugins.php logic issue
@cigamit
Copy link
Member

cigamit commented Feb 22, 2018

Okay, resolved.

@cigamit cigamit closed this as completed Feb 22, 2018
@netniV
Copy link
Member

netniV commented Feb 22, 2018

I'll have to update my sources now to reflect your change lol.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants