-
Notifications
You must be signed in to change notification settings - Fork 61
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
PHP error Invalid argument supplied for foreach() #168
Comments
serverinfo/lib/OperatingSystems/DefaultOs.php Line 117 in e499dd0
|
It exits and it will be readable by the php process:
sudo -u apache ls /sys/class/net/*
But selinux will forbids it, because of the system call "df". And the call don't catch an empty array as
|
OK. But the |
Having same issue here. @kesselb :
|
Having the same issue in Debian 9.12 (stretch) - PHP 7.2.28 - NC 18.0.2 My output of
I fixed it temporary by adding |
Why not? |
In my case |
In my opinion a software should be created as open minded as possible, so it can handle different situations on its own. The user should not be pushed into fiddling with too many configurations. Best example is from @acs-ferreira since he is not using |
Feel free to submit a patch with your suggested solution. |
I my case it will result in this: |
You need to add the following paths to your open_basedir to work:
A resulting open_basedir directive could look like
|
In my case I have the line: |
@tuxmaster5000 For whatever reason, allowing /sys/class/net isn't recursive to the network interfaces. I had to adapt my open_basedirl to give it my network adapters:
This made the error go away. Can you confirm ? |
As @deajan already mentioned, in some cases allowing You need to check the content of Examples of full paths:
|
I think the problem is much deeper, because all files under /sys/class/net are symlinks.
And add /sys/devices/ to open_basedir is an security nightmare I think. For testing In have added the path, then no error will shown, but php call access all devices. :( |
…esult Signed-off-by: Adrian Sausenthaler <github@sausenthaler.de>
For me it was on line 152 (NC 22.1.1)
My "Patch" fixes the error, thus the system tab loads again. public function getNetworkInterfaces(): array {
$interfaces = glob('/sys/class/net/*');
$result = [];
if(is_bool($interfaces)){ // add this
return $result;
}
. . . |
Hello {
"reqId": "YVw@g5CkrUk0I3kQpeGrmgAAAA8",
"level": 3,
"time": "2021-10-05T12:01:08+00:00",
"remoteAddr": "xx.xx.xx.xx",
"user": "admin",
"app": "PHP",
"method": "GET",
"url": "/index.php/settings/admin/serverinfo",
"message": {
"Exception": "Error",
"Message": "Invalid argument supplied for foreach() at /<<path_to_nc>>/apps/serverinfo/lib/OperatingSystems/DefaultOs.php#149",
"Code": 0,
"Trace": [{
"file": "/<<path_to_nc>>/apps/serverinfo/lib/OperatingSystems/DefaultOs.php",
"line": 149,
"function": "onError",
"class": "OC\\Log\\ErrorHandler",
"type": "::"
}, {
"file": "/<<path_to_nc>>/apps/serverinfo/lib/Os.php",
"line": 124,
"function": "getNetworkInterfaces",
"class": "OCA\\ServerInfo\\OperatingSystems\\DefaultOs",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/serverinfo/lib/Settings/AdminSettings.php",
"line": 111,
"function": "getNetworkInterfaces",
"class": "OCA\\ServerInfo\\Os",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/CommonSettingsTrait.php",
"line": 138,
"function": "getForm",
"class": "OCA\\ServerInfo\\Settings\\AdminSettings",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/AdminSettingsController.php",
"line": 83,
"function": "formatSettings",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/CommonSettingsTrait.php",
"line": 149,
"function": "getSettings",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/AdminSettingsController.php",
"line": 68,
"function": "getIndexResponse",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/Http/Dispatcher.php",
"line": 218,
"function": "index",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/Http/Dispatcher.php",
"line": 127,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/App.php",
"line": 157,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/Route/Router.php",
"line": 302,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
}, {
"file": "/<<path_to_nc>>/lib/base.php",
"line": 993,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
}, {
"file": "/<<path_to_nc>>/index.php",
"line": 37,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "/<<path_to_nc>>/lib/private/Log/ErrorHandler.php",
"Line": 92,
"CustomMessage": "--"
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0",
"version": "21.0.5.1"
}{
"reqId": "YVw@g5CkrUk0I3kQpeGrmgAAAA8",
"level": 3,
"time": "2021-10-05T12:01:08+00:00",
"remoteAddr": "xx.xx.xx.xx",
"user": "admin",
"app": "PHP",
"method": "GET",
"url": "/index.php/settings/admin/serverinfo",
"message": {
"Exception": "Error",
"Message": "opcache_get_status() has been disabled for security reasons at /<<path_to_nc>>/apps/serverinfo/lib/PhpStatistics.php#68",
"Code": 0,
"Trace": [{
"function": "onError",
"class": "OC\\Log\\ErrorHandler",
"type": "::"
}, {
"file": "/<<path_to_nc>>/apps/serverinfo/lib/PhpStatistics.php",
"line": 68,
"function": "opcache_get_status"
}, {
"file": "/<<path_to_nc>>/apps/serverinfo/lib/PhpStatistics.php",
"line": 50,
"function": "getOPcacheStatus",
"class": "OCA\\ServerInfo\\PhpStatistics",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/serverinfo/lib/Settings/AdminSettings.php",
"line": 115,
"function": "getPhpStatistics",
"class": "OCA\\ServerInfo\\PhpStatistics",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/CommonSettingsTrait.php",
"line": 138,
"function": "getForm",
"class": "OCA\\ServerInfo\\Settings\\AdminSettings",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/AdminSettingsController.php",
"line": 83,
"function": "formatSettings",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/CommonSettingsTrait.php",
"line": 149,
"function": "getSettings",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/AdminSettingsController.php",
"line": 68,
"function": "getIndexResponse",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/Http/Dispatcher.php",
"line": 218,
"function": "index",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/Http/Dispatcher.php",
"line": 127,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/App.php",
"line": 157,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/Route/Router.php",
"line": 302,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
}, {
"file": "/<<path_to_nc>>/lib/base.php",
"line": 993,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
}, {
"file": "/<<path_to_nc>>/index.php",
"line": 37,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "/<<path_to_nc>>/lib/private/Log/ErrorHandler.php",
"Line": 92,
"CustomMessage": "--"
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0",
"version": "21.0.5.1"
}{
"reqId": "YVw@g5CkrUk0I3kQpeGrmgAAAA8",
"level": 3,
"time": "2021-10-05T12:01:08+00:00",
"remoteAddr": "xx.xx.xx.xx",
"user": "admin",
"app": "index",
"method": "GET",
"url": "/index.php/settings/admin/serverinfo",
"message": {
"Exception": "Exception",
"Message": "Return value of OCA\\ServerInfo\\PhpStatistics::getOPcacheStatus() must be of the type array, null returned",
"Code": 0,
"Trace": [{
"file": "/<<path_to_nc>>/lib/private/AppFramework/App.php",
"line": 157,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/Route/Router.php",
"line": 302,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
}, {
"file": "/<<path_to_nc>>/lib/base.php",
"line": 993,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
}, {
"file": "/<<path_to_nc>>/index.php",
"line": 37,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "/<<path_to_nc>>/lib/private/AppFramework/Http/Dispatcher.php",
"Line": 159,
"Previous": {
"Exception": "TypeError",
"Message": "Return value of OCA\\ServerInfo\\PhpStatistics::getOPcacheStatus() must be of the type array, null returned",
"Code": 0,
"Trace": [{
"file": "/<<path_to_nc>>/apps/serverinfo/lib/PhpStatistics.php",
"line": 50,
"function": "getOPcacheStatus",
"class": "OCA\\ServerInfo\\PhpStatistics",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/serverinfo/lib/Settings/AdminSettings.php",
"line": 115,
"function": "getPhpStatistics",
"class": "OCA\\ServerInfo\\PhpStatistics",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/CommonSettingsTrait.php",
"line": 138,
"function": "getForm",
"class": "OCA\\ServerInfo\\Settings\\AdminSettings",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/AdminSettingsController.php",
"line": 83,
"function": "formatSettings",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/CommonSettingsTrait.php",
"line": 149,
"function": "getSettings",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/apps/settings/lib/Controller/AdminSettingsController.php",
"line": 68,
"function": "getIndexResponse",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/Http/Dispatcher.php",
"line": 218,
"function": "index",
"class": "OCA\\Settings\\Controller\\AdminSettingsController",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/Http/Dispatcher.php",
"line": 127,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/AppFramework/App.php",
"line": 157,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
}, {
"file": "/<<path_to_nc>>/lib/private/Route/Router.php",
"line": 302,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
}, {
"file": "/<<path_to_nc>>/lib/base.php",
"line": 993,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
}, {
"file": "/<<path_to_nc>>/index.php",
"line": 37,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "/<<path_to_nc>>/apps/serverinfo/lib/PhpStatistics.php",
"Line": 75
},
"CustomMessage": "--"
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0",
"version": "21.0.5.1"
} |
Maybe create a pull request with this fix? |
This patch works but imho the code should be simplified using the new php function net_get_interfaces() |
net-get-interfaces is a good idea. Could you run Thanks |
On my server CentOS8 PHP 8.0 it will work.
|
Looks good on my FreeBSD test vm too 🎉
|
Looks good on my Ubuntu test vm too 🎉
|
Steps to reproduce
Expected behaviour
That no error will get logged.
Actual behaviour
On every call this error will be logged:
"message":"Invalid argument supplied for foreach() at /var/www/html/owncloud/apps/serverinfo/lib/OperatingSystems/DefaultOs.php#120"
Server configuration
Operating system: CentOS 7.7
Web server: Apache
Database: MariaDB
PHP version: 7.2
Nextcloud version: 17.0.2
Updated from an older Nextcloud/ownCloud or fresh install:
Updated from older
Where did you install Nextcloud from:
From the nextcloud web site
Signing status:
Signing status
``` No errors have been found. ```List of activated apps:
App list
Nextcloud configuration:
Config report
Are you using external storage, if yes which one: local/smb/sftp/...
no
Are you using encryption: yes/no
no
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
no
The text was updated successfully, but these errors were encountered: