nextcloud / serverinfo

📊 A monitoring app which creates a server info dashboard for admins
GNU Affero General Public License v3.0
94 stars 61 forks source link

Internal server error: OCA\ServerInfo\OperatingSystems\shell_exec() #534

Closed Valdnet closed 4 months ago

Valdnet commented 9 months ago

Expected behaviour

Launching the serverinfo app.

Actual behaviour

An internal server error occurs while running server information.

Logs

[index] Error: Exception: Call to undefined function OCA\ServerInfo\OperatingSystems\shell_exec() in file '/home/xxx/public_html/cloud/apps/serverinfo/lib/OperatingSystems/DefaultOs.php' line 262 at <<closure>>

0. /home/xxx/public_html/cloud/lib/private/AppFramework/App.php line 183
   OC\AppFramework\Http\Dispatcher->dispatch(["OCA\\Settings\ ... "], "index")
1. /home/xxx/public_html/cloud/lib/private/Route/Router.php line 315
   OC\AppFramework\App::main("OCA\\Settings\\ ... r", "index", ["OC\\AppFramewo ... "], ["serverinfo","s ... "])
2. /home/xxx/public_html/cloud/lib/base.php line 1068
   OC\Route\Router->match("/settings/admin/serverinfo")
3. /home/xxx/public_html/cloud/index.php line 36
   OC::handleRequest()

Caused by:

Error: Call to undefined function OCA\ServerInfo\OperatingSystems\shell_exec() at <<closure>>

 0. /home/xxx/public_html/cloud/apps/serverinfo/lib/OperatingSystems/DefaultOs.php line 197
    OCA\ServerInfo\OperatingSystems\DefaultOs->executeCommand("df -TPk")
 1. /home/xxx/public_html/cloud/apps/serverinfo/lib/Os.php line 78
    OCA\ServerInfo\OperatingSystems\DefaultOs->getDiskInfo()
 2. /home/xxx/public_html/cloud/apps/serverinfo/lib/Settings/AdminSettings.php line 79
    OCA\ServerInfo\Os->getDiskInfo()
 3. /home/xxx/public_html/cloud/apps/settings/lib/Controller/CommonSettingsTrait.php line 129
    OCA\ServerInfo\Settings\AdminSettings->getForm()
 4. /home/xxx/public_html/cloud/apps/settings/lib/Controller/AdminSettingsController.php line 83
    OCA\Settings\Controller\AdminSettingsController->formatSettings([[["OCA\\ServerI ... ]])
 5. /home/xxx/public_html/cloud/apps/settings/lib/Controller/CommonSettingsTrait.php line 149
    OCA\Settings\Controller\AdminSettingsController->getSettings("serverinfo")
 6. /home/xxx/public_html/cloud/apps/settings/lib/Controller/AdminSettingsController.php line 68
    OCA\Settings\Controller\AdminSettingsController->getIndexResponse("admin", "serverinfo")
 7. /home/xxx/public_html/cloud/lib/private/AppFramework/Http/Dispatcher.php line 230
    OCA\Settings\Controller\AdminSettingsController->index("serverinfo")
 8. /home/xxx/public_html/cloud/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController(["OCA\\Settings\ ... "], "index")
 9. /home/xxx/public_html/cloud/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch(["OCA\\Settings\ ... "], "index")
10. /home/xxx/public_html/cloud/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main("OCA\\Settings\\ ... r", "index", ["OC\\AppFramewo ... "], ["serverinfo","s ... "])
11. /home/xxx/public_html/cloud/lib/base.php line 1068
    OC\Route\Router->match("/settings/admin/serverinfo")
12. /home/xxx/public_html/cloud/index.php line 36
    OC::handleRequest()

GET /index.php/settings/admin/serverinfo

Nextcloud version: 27.1.3

kesselb commented 9 months ago

Thanks for your report :+1:

It seems that shell_exec is disabled on your end.

I thought this kind of error should be handled properly in executeCommand. What php version are you using?

Valdnet commented 9 months ago

I'm using the PHP version: 7.4 and 8.1.

kesselb commented 8 months ago

Confirmed.

It's not possible to suppress an undefined function error since PHP 8 (https://php.watch/versions/8.0/fatal-error-suppression).

arnaudjaegers commented 7 months ago

Is it possible to detect if shell_exec() exists, and if not, show a proper information that this function should be enabled to use this app, instead of the default 500 error:

CleanShot_2024-01-26_at_14 50 18_Google Chrome_Nextcloud

End users will appreciate it. Thanks.