Cacti / plugin_wmi

Cacti WMI Plugin
GNU General Public License v2.0
5 stars 12 forks source link

PHP and SQL backtrace when deleting stored WMI queries or credentials #3

Closed Elix-g closed 5 years ago

Elix-g commented 5 years ago

Dears,

I've installed the latest version of the WMI plugin in Cacti 1.2.4 and today again after upgrading to 1.2.5. Two issues: It's not possible to delete saved WMI queries and it's not possible to delete stored credentials. In both cases, the confirmation popup appears but upon confirmation button, nothing happens. I can find some according entries in clog.

Attempt to delete a query:

2019/07/18 17:20:36 - CMDPHP PHP ERROR Backtrace: (/plugins/wmi/wmi_queries.php[97]:actions_queries(), /plugins/wmi/wmi_queries.php[147]:each(), CactiErrorHandler()) 2019/07/18 17:20:36 - ERROR PHP DEPRECATED in Plugin 'wmi': The each() function is deprecated. This message will be suppressed on further calls in file: /xxxxxxxxxx/plugins/wmi/wmi_queries.php on line: 147

Attempt to delete credentials:

2019/07/18 17:24:55 - CMDPHP PHP ERROR Backtrace: (/plugins/wmi/wmi_accounts.php[76]:actions_accounts(), /plugins/wmi/wmi_accounts.php[122]:each(), CactiErrorHandler()) 2019/07/18 17:24:55 - ERROR PHP DEPRECATED in Plugin 'wmi': The each() function is deprecated. This message will be suppressed on further calls in file: /data/apache2_wwwroot/plugins/wmi/wmi_accounts.php on line: 122 2019/07/18 17:24:47 - CMDPHP SQL Backtrace: (/plugins/wmi/wmi_accounts.php[90]:show_accounts(), /plugins/wmi/wmi_accounts.php[379]:db_fetch_cell_prepared(), /lib/database.php[378]:db_execute_prepared()) 2019/07/18 17:24:47 - CMDPHP ERROR: A DB Cell Failed!, Error: Unknown column 'wmi_account' in 'field list'

Appreciate any help on this!

BR, Elix

Elix-g commented 5 years ago

Hi,

how about this (untested)?

replace whole line 147 in wmi_queries.php with: foreach($_POST as $var => $val) {

replace whole line 122 in wmi_accounts.php with: foreach($_POST as $var => $val) {

Just the DB error should remain.

netniV commented 5 years ago

There are a couple of depreciated bits with PHP 7.2, plus we need to also check on MySQL reserved words too as there have been a number of changes to both PHP/MySQL/MariaDB that have caused bugs where things worked previously.

What you have identified is normally one of those elements 👍

Elix-g commented 5 years ago

Hi,

deleting a stored query seems to work. Nonetheless, some error message in clog:

2019/07/22` 12:00:01 - CMDPHP PHP ERROR Backtrace: (/plugins/wmi/wmi_queries.php[97]:actions_queries(), /plugins/wmi/wmi_queries.php[150]:each(), CactiErrorHandler()) 2019/07/22 12:00:01 - ERROR PHP DEPRECATED in Plugin 'wmi': The each() function is deprecated. This message will be suppressed on further calls in file: /data/apache2_wwwroot/plugins/wmi/wmi_queries.php on line: 150

Deleting stored credentials still doesn't work. Errors in clog:

2019/07/22 12:02:46 - CMDPHP PHP ERROR Backtrace: (/plugins/wmi/wmi_accounts.php[76]:actions_accounts(), /plugins/wmi/wmi_accounts.php[122]:each(), CactiErrorHandler()) 2019/07/22 12:02:46 - ERROR PHP DEPRECATED in Plugin 'wmi': The each() function is deprecated. This message will be suppressed on further calls in file: /xxxxxxxxxxxxx/plugins/wmi/wmi_accounts.php on line: 122

netniV commented 5 years ago

Download the latest version as this should now be resolved in 0db7d13

Elix-g commented 5 years ago

Confirmed, errors are gone and clog is clean. But though, deleting Authentications still doesn't work. It doesn't throw any error message anymore, but the Continue button has no function.

cigamit commented 5 years ago

Yea, totally missed the each errors. I'm doing my development on a dated version of PHP, so did not see them. I'm not sure I know what you mean about Continue button. Could this be the authentication tab?

cigamit commented 5 years ago

Yea, it was the accounts tab. That is now fixed too, as should $ signs in the password or any other special character for that matter now.

Elix-g commented 5 years ago

I'm sorry, I was unprecise. Indeed I meant the Continue button in the confirmation dialogue that appears when deleting an Authentication. Deletion now works properly, thanks a lot! Just another detail: After an Authentication has been deleted, I'm forwarded to a site where something is missing ;-) Please see the following picture:

delete_wmi_account

URL that is being called is https://xxxxxxxxxxxx/plugins/wmi/wmi_accounts.php?header=false.

Setting the header attribute to true and everything looks normal.

netniV commented 5 years ago

Yea, it needs the header=false taking off.

Elix-g commented 5 years ago

Perfect, works like a charm now. Many thanks again for your swift reaction!

BR, Elix