NagVis / nagvis

Visualization addon for your open source monitoring core
http://nagvis.org/
GNU General Public License v2.0
113 stars 73 forks source link

Trying to access array offset on value of type bool in CoreAuthorisationModPDO.php #294

Open rootwheel opened 2 years ago

rootwheel commented 2 years ago

Hello! I faced an issue then adding user to auth.db with LDAP and Nagios credentials. A user is added successfully, but he has no role (role is empty). The related section in nagvis.ini.php is present

logonmodule="LogonEnv"
logonenvvar="REMOTE_USER"
logonenvcreateuser="1"
logonenvcreaterole="Users (read-only)"

Debian 11 PHP 7.4 Full error message:

Error: (0) Trying to access array offset on value of type bool
URL: /nagvis/frontend/nagvis-js/index.php
File: /usr/share/nagvis/share/server/core/classes/CoreAuthorisationModPDO.php
Line: 263
#0 /usr/share/nagvis/share/server/core/classes/CoreAuthorisationModPDO.php(263): nagvisExceptionErrorHandler()
#1 /usr/share/nagvis/share/server/core/classes/CoreAuthorisationModPDO.php(233): CoreAuthorisationModPDO->getUserId()
#2 /usr/share/nagvis/share/server/core/classes/CoreAuthorisationHandler.php(235): CoreAuthorisationModPDO->parsePermissions()
#3 /usr/share/nagvis/share/server/core/classes/CoreLogonModule.php(36): CoreAuthorisationHandler->parsePermissions()
#4 /usr/share/nagvis/share/server/core/classes/CoreLogonModule.php(46): CoreLogonModule->createUser()
#5 /usr/share/nagvis/share/server/core/classes/CoreLogonEnv.php(46): CoreLogonModule->verifyUserExists()
#6 /usr/share/nagvis/share/server/core/functions/index.php(56): CoreLogonEnv->check()
#7 /usr/share/nagvis/share/frontend/nagvis-js/index.php(53): require('/usr/share/nagv...')
#8 {main}

Thank you!

ErwinE commented 2 years ago

We have the same issue.

Error: (0) Trying to access array offset on value of type bool
URL: /nagvis/frontend/nagvis-js/index.php
File: /usr/local/nagvis/share/server/core/classes/CoreAuthorisationModPDO.php
Line: 263
#0 /usr/local/nagvis/share/server/core/classes/CoreAuthorisationModPDO.php(263): nagvisExceptionErrorHandler()
#1 /usr/local/nagvis/share/server/core/classes/CoreAuthorisationModPDO.php(233): CoreAuthorisationModPDO->getUserId()
#2 /usr/local/nagvis/share/server/core/classes/CoreAuthorisationHandler.php(235): CoreAuthorisationModPDO->parsePermissions()
#3 /usr/local/nagvis/share/server/core/classes/CoreLogonModule.php(36): CoreAuthorisationHandler->parsePermissions()
#4 /usr/local/nagvis/share/server/core/classes/CoreLogonModule.php(46): CoreLogonModule->createUser()
#5 /usr/local/nagvis/share/server/core/classes/CoreLogonEnv.php(46): CoreLogonModule->verifyUserExists()
#6 /usr/local/nagvis/share/server/core/functions/index.php(56): CoreLogonEnv->check()
#7 /usr/local/nagvis/share/frontend/nagvis-js/index.php(53): require('...')
#8 {main}

CentOS 8 / CentOS Stream PHP 8.0.13 NagVis 1.9.27

ErwinE commented 2 years ago

I solved the issue with somme googleing. I have no experience with PHP, so I don´t know how and why it´s working with that.

I just changed the code in line 263 in the file /usr/share/nagvis/share/server/core/classes/CoreAuthorisationModPDO.php from:

return intval($ret['userId'];

to

return intval($ret['userId']??='default value');

LarsMichelsen commented 2 years ago

Not using the PDO, can not support you with this issue. Have had a quick look, but did not spot an obvious issue. Would need some debugging.