diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-02-04 18:26:07 +0100 |
---|---|---|
committer | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2024-03-13 16:13:03 +0100 |
commit | 002fda62f17f60a59ce023f7fbe4d9d1e6a8905b (patch) | |
tree | 5dd7429de2dd2bec44b41311357ed64002b59883 /apps | |
parent | 4bda299541c198d832ff7a70be58a01505abbd6d (diff) | |
download | nextcloud-server-002fda62f17f60a59ce023f7fbe4d9d1e6a8905b.tar.gz nextcloud-server-002fda62f17f60a59ce023f7fbe4d9d1e6a8905b.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')
-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 d6d36432b42..dc6fc1cd350 100644 --- a/apps/settings/lib/Settings/Admin/Server.php +++ b/apps/settings/lib/Settings/Admin/Server.php @@ -56,13 +56,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', $this->appConfig->getValueInt('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 |