Skip to content

Commit 931885e

Browse files
author
Vincent Petry
authored
Merge pull request #28601 from owncloud/stable10-fa75a5aa9303a5d93ac38785acd73e4d2aa9dc62
[stable10] Adjust behaviour in case the apps folder is not writable …
2 parents 754a791 + f314da2 commit 931885e

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

lib/private/App/AppManager.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,18 @@ class AppManager implements IAppManager {
5858

5959
/** @var \OCP\IUserSession */
6060
private $userSession;
61-
6261
/** @var \OCP\IAppConfig */
6362
private $appConfig;
64-
6563
/** @var \OCP\IGroupManager */
6664
private $groupManager;
67-
6865
/** @var \OCP\ICacheFactory */
6966
private $memCacheFactory;
70-
7167
/** @var string[] $appId => $enabled */
7268
private $installedAppsCache;
73-
7469
/** @var string[] */
7570
private $shippedApps;
76-
7771
/** @var string[] */
7872
private $alwaysEnabled;
79-
8073
/** @var EventDispatcherInterface */
8174
private $dispatcher;
8275

@@ -212,6 +205,7 @@ public function isInstalled($appId) {
212205
* Enable an app for every user
213206
*
214207
* @param string $appId
208+
* @throws \Exception
215209
*/
216210
public function enableApp($appId) {
217211
if(OC_App::getAppPath($appId) === false) {
@@ -430,4 +424,18 @@ public function readAppPackage($path) {
430424
Files::rmdirr($appCodeDir);
431425
return $appInfo;
432426
}
427+
428+
/**
429+
* Indicates if app installation is supported. Usually it is but in certain
430+
* environments it is disallowed because of hardening. In a clustered setup
431+
* apps need to be installed on each cluster node which is out of scope of
432+
* ownCloud itself.
433+
*
434+
* @return bool
435+
* @since 10.0.3
436+
*/
437+
public function canInstall() {
438+
$appsFolder = OC_App::getInstallPath();
439+
return $appsFolder !== null && is_writable($appsFolder) && is_readable($appsFolder);
440+
}
433441
}

lib/private/Installer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ public static function installApp( $data = []) {
9191

9292
$info = self::checkAppsIntegrity($data, $extractDir, $path);
9393
$appId = OC_App::cleanAppId($info['id']);
94-
$basedir = OC_App::getInstallPath().'/'.$appId;
94+
$appsFolder = OC_App::getInstallPath();
95+
96+
if ($appsFolder === null || !is_writable($appsFolder)) {
97+
throw new \Exception('Apps folder is not writable');
98+
}
99+
$basedir = "$appsFolder/$appId";
95100
//check if the destination directory already exists
96101
if(is_dir($basedir)) {
97102
OC_Helper::rmdirr($extractDir);

lib/private/legacy/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ private static function adjustVersionParts($version1, $version2) {
995995
* This means that it's possible to specify "requiremin" => 6
996996
* and "requiremax" => 6 and it will still match ownCloud 6.0.3.
997997
*
998-
* @param string $ocVersion ownCloud version to check against
998+
* @param string|array $ocVersion ownCloud version to check against
999999
* @param array $appInfo app info (from xml)
10001000
*
10011001
* @return boolean true if compatible, otherwise false

lib/public/App/IAppManager.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,14 @@ public function getAllApps();
156156
*/
157157
public function readAppPackage($path);
158158

159+
/**
160+
* Indicates if app installation is supported. Usually it is but in certain
161+
* environments it is disallowed because of hardening. In a clustered setup
162+
* apps need to be installed on each cluster node which is out of scope of
163+
* ownCloud itself.
164+
*
165+
* @return bool
166+
* @since 10.0.3
167+
*/
168+
public function canInstall();
159169
}

0 commit comments

Comments
 (0)