summaryrefslogtreecommitdiffstats
path: root/settings/Controller
diff options
context:
space:
mode:
authorMichael Weimann <mail@michael-weimann.eu>2018-08-09 19:47:55 +0200
committerMichael Weimann <mail@michael-weimann.eu>2018-08-09 19:47:55 +0200
commitb2e60e365dde53e405cb4a1fe9be687d33ec08ef (patch)
tree23ce15eb707048128a7bb2b7665156a8820d59a9 /settings/Controller
parent46d340045da005547a03c9382c98610942dfac1f (diff)
downloadnextcloud-server-b2e60e365dde53e405cb4a1fe9be687d33ec08ef.tar.gz
nextcloud-server-b2e60e365dde53e405cb4a1fe9be687d33ec08ef.zip
Adds a setup check for app directory permissions.
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'settings/Controller')
-rw-r--r--settings/Controller/CheckSetupController.php33
1 files changed, 32 insertions, 1 deletions
diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php
index c706d6e7350..d3b520a7686 100644
--- a/settings/Controller/CheckSetupController.php
+++ b/settings/Controller/CheckSetupController.php
@@ -31,9 +31,11 @@
namespace OC\Settings\Controller;
use bantu\IniGetWrapper\IniGetWrapper;
+use DirectoryIterator;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use GuzzleHttp\Exception\ClientException;
+use OC;
use OC\AppFramework\Http;
use OC\DB\Connection;
use OC\DB\MissingIndexInformation;
@@ -530,6 +532,34 @@ Raw output
}
/**
+ * Iterates through the configured app roots and
+ * tests if the subdirectories are owned by the same user than the current user.
+ *
+ * @return array
+ */
+ protected function getAppDirsWithDifferentOwner(): array {
+ $currentUser = posix_getpwuid(posix_getuid());
+ $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();
+ }
+ }
+ }
+ }
+
+ sort($appDirsWithDifferentOwner);
+ return $appDirsWithDifferentOwner;
+ }
+
+ /**
* @return DataResponse
*/
public function check() {
@@ -565,7 +595,8 @@ Raw output
'isSqliteUsed' => $this->isSqliteUsed(),
'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
'isPhpMailerUsed' => $this->isPhpMailerUsed(),
- 'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin')
+ 'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
+ 'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
]
);
}