Skip to content

Commit 002fda6

Browse files
susnuxAltahrim
authored andcommitted
fix(settings): posix_getpwuid can return false which should not be accessed using array operation
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 4bda299 commit 002fda6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

apps/settings/lib/Settings/Admin/Server.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ public function __construct(
5656
* @return TemplateResponse
5757
*/
5858
public function getForm() {
59+
$ownerConfigFile = fileowner(\OC::$configDir . 'config.php');
60+
$cliBasedCronPossible = function_exists('posix_getpwuid') && $ownerConfigFile !== false;
61+
$cliBasedCronUser = $cliBasedCronPossible ? (posix_getpwuid($ownerConfigFile)['name'] ?? '') : '';
62+
5963
// Background jobs
6064
$this->initialStateService->provideInitialState('backgroundJobsMode', $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'));
6165
$this->initialStateService->provideInitialState('lastCron', $this->appConfig->getValueInt('core', 'lastcron', 0));
6266
$this->initialStateService->provideInitialState('cronMaxAge', $this->cronMaxAge());
6367
$this->initialStateService->provideInitialState('cronErrors', $this->config->getAppValue('core', 'cronErrors'));
64-
$this->initialStateService->provideInitialState('cliBasedCronPossible', function_exists('posix_getpwuid'));
65-
$this->initialStateService->provideInitialState('cliBasedCronUser', function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '');
68+
$this->initialStateService->provideInitialState('cliBasedCronPossible', $cliBasedCronPossible);
69+
$this->initialStateService->provideInitialState('cliBasedCronUser', $cliBasedCronUser);
6670
$this->initialStateService->provideInitialState('backgroundJobsDocUrl', $this->urlGenerator->linkToDocs('admin-background-jobs'));
6771

6872
// Profile page

0 commit comments

Comments
 (0)