summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
authorMichael Weimann <mail@michael-weimann.eu>2018-08-20 20:46:11 +0200
committerMichael Weimann <mail@michael-weimann.eu>2018-08-20 20:46:23 +0200
commit2bab916c535173ac723f50fecb33518db3f293d5 (patch)
tree7496981d6756638837ef4c45e0c2e5691d4c32c2 /settings
parentce1e213760a0ac03e91daf6ebc08f401da27b8bc (diff)
parent6d749bf0215c4f155d402620544e669c0cce37ec (diff)
downloadnextcloud-server-2bab916c535173ac723f50fecb33518db3f293d5.tar.gz
nextcloud-server-2bab916c535173ac723f50fecb33518db3f293d5.zip
Adds license to files. Updates the branch.
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'settings')
-rw-r--r--settings/Controller/CheckSetupController.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php
index a64d131648b..747e60c7cb2 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;
@@ -535,6 +537,54 @@ 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) {
+ if ($appRoot['writable'] === true) {
+ $appDirsWithDifferentOwner = array_merge(
+ $appDirsWithDifferentOwner,
+ $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot)
+ );
+ }
+ }
+
+ sort($appDirsWithDifferentOwner);
+ return $appDirsWithDifferentOwner;
+ }
+
+ /**
+ * 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() {
@@ -572,6 +622,7 @@ Raw output
'isPhpMailerUsed' => $this->isPhpMailerUsed(),
'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
+ 'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
]
);
}