diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-02-04 18:26:07 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-03-13 16:14:34 +0000 |
commit | fbedb87a55732a37965a3807e9063d3c9e84d2af (patch) | |
tree | 412bfc756ec8434907f4fbf5595f44eb22e23b1f /apps/settings/lib | |
parent | 69264c8ff19cbad21a85580f87ab4d2f9fa9447b (diff) | |
download | nextcloud-server-fbedb87a55732a37965a3807e9063d3c9e84d2af.tar.gz nextcloud-server-fbedb87a55732a37965a3807e9063d3c9e84d2af.zip |
fix(settings): `posix_getpwuid` can return `false` which should not be accessed using array operation
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/settings/lib')
-rw-r--r-- | apps/settings/lib/Settings/Admin/Server.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/apps/settings/lib/Settings/Admin/Server.php b/apps/settings/lib/Settings/Admin/Server.php index 0d8ef00a1fd..939429d6e51 100644 --- a/apps/settings/lib/Settings/Admin/Server.php +++ b/apps/settings/lib/Settings/Admin/Server.php @@ -67,13 +67,17 @@ class Server implements IDelegatedSettings { * @return TemplateResponse */ public function getForm() { + $ownerConfigFile = fileowner(\OC::$configDir . 'config.php'); + $cliBasedCronPossible = function_exists('posix_getpwuid') && $ownerConfigFile !== false; + $cliBasedCronUser = $cliBasedCronPossible ? (posix_getpwuid($ownerConfigFile)['name'] ?? '') : ''; + // Background jobs $this->initialStateService->provideInitialState('backgroundJobsMode', $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax')); $this->initialStateService->provideInitialState('lastCron', (int)$this->config->getAppValue('core', 'lastcron', '0')); $this->initialStateService->provideInitialState('cronMaxAge', $this->cronMaxAge()); $this->initialStateService->provideInitialState('cronErrors', $this->config->getAppValue('core', 'cronErrors')); - $this->initialStateService->provideInitialState('cliBasedCronPossible', function_exists('posix_getpwuid')); - $this->initialStateService->provideInitialState('cliBasedCronUser', function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : ''); + $this->initialStateService->provideInitialState('cliBasedCronPossible', $cliBasedCronPossible); + $this->initialStateService->provideInitialState('cliBasedCronUser', $cliBasedCronUser); $this->initialStateService->provideInitialState('backgroundJobsDocUrl', $this->urlGenerator->linkToDocs('admin-background-jobs')); // Profile page |