mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 06:08:46 -04:00
Check for open_basedir before reading /proc
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
This commit is contained in:
parent
9e7fc23bd0
commit
53b84732a3
1 changed files with 14 additions and 2 deletions
|
|
@ -258,8 +258,20 @@ class Generator {
|
|||
public static function getHardwareConcurrency(): int {
|
||||
static $width;
|
||||
if (!isset($width)) {
|
||||
if (is_file("/proc/cpuinfo")) {
|
||||
$width = substr_count(file_get_contents("/proc/cpuinfo"), "processor");
|
||||
if (function_exists('ini_get')) {
|
||||
$openBasedir = ini_get('open_basedir');
|
||||
if ($openBasedir == '') {
|
||||
$width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
|
||||
} else {
|
||||
$openBasedirPaths = explode(':', $openBasedir);
|
||||
foreach ($openBasedirPaths as $path) {
|
||||
if (strpos($path, '/proc') === 0 || $path === '/proc/cpuinfo') {
|
||||
$width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
|
||||
} else {
|
||||
$width = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$width = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue