diff options
author | Michael Weimann <mail@michael-weimann.eu> | 2018-08-09 19:48:55 +0200 |
---|---|---|
committer | Michael Weimann <mail@michael-weimann.eu> | 2018-08-09 19:49:01 +0200 |
commit | 3f790bb85b3544680f4af2e3e005d736a5aff8a0 (patch) | |
tree | e7ce6422d05867d4ff4433f856f563e3fd66d227 /settings | |
parent | ebcfe33d0d0233dceaa80ad3a44126dee480eb97 (diff) | |
download | nextcloud-server-3f790bb85b3544680f4af2e3e005d736a5aff8a0.tar.gz nextcloud-server-3f790bb85b3544680f4af2e3e005d736a5aff8a0.zip |
Excludes not writable app roots from the directory permission check
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'settings')
-rw-r--r-- | settings/Controller/CheckSetupController.php | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php index d3b520a7686..e6c88b6f7ca 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -542,16 +542,11 @@ Raw output $appDirsWithDifferentOwner = []; foreach (OC::$APPSROOTS as $appRoot) { - $appsPath = $appRoot['path']; - $appsDir = new DirectoryIterator($appRoot['path']); - foreach ($appsDir as $fileInfo) { - if ($fileInfo->isDir() && !$fileInfo->isDot()) { - $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename(); - $appDirUser = posix_getpwuid(fileowner($absAppPath)); - if ($appDirUser !== $currentUser) { - $appDirsWithDifferentOwner[] = $absAppPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename(); - } - } + if ($appRoot['writable'] === true) { + $appDirsWithDifferentOwner = array_merge( + $appDirsWithDifferentOwner, + $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot) + ); } } @@ -560,6 +555,31 @@ Raw output } /** + * Tests if the directories for one apps directory are writable by the current user. + * + * @param array $currentUser The current user + * @param array $appRoot The app root config + * @return string[] The none writable directory paths inside the app root + */ + private function getAppDirsWithDifferentOwnerForAppRoot(array $currentUser, array $appRoot): array { + $appDirsWithDifferentOwner = []; + $appsPath = $appRoot['path']; + $appsDir = new DirectoryIterator($appRoot['path']); + + foreach ($appsDir as $fileInfo) { + if ($fileInfo->isDir() && !$fileInfo->isDot()) { + $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename(); + $appDirUser = posix_getpwuid(fileowner($absAppPath)); + if ($appDirUser !== $currentUser) { + $appDirsWithDifferentOwner[] = $absAppPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename(); + } + } + } + + return $appDirsWithDifferentOwner; + } + + /** * @return DataResponse */ public function check() { |