Skip to content

Commit

Permalink
Adjust behaviour in case the apps folder is not writable - refs ownc…
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Aug 3, 2017
1 parent b5a2f86 commit fa75a5a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
22 changes: 15 additions & 7 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,18 @@ class AppManager implements IAppManager {

/** @var \OCP\IUserSession */
private $userSession;

/** @var \OCP\IAppConfig */
private $appConfig;

/** @var \OCP\IGroupManager */
private $groupManager;

/** @var \OCP\ICacheFactory */
private $memCacheFactory;

/** @var string[] $appId => $enabled */
private $installedAppsCache;

/** @var string[] */
private $shippedApps;

/** @var string[] */
private $alwaysEnabled;

/** @var EventDispatcherInterface */
private $dispatcher;

Expand Down Expand Up @@ -212,6 +205,7 @@ public function isInstalled($appId) {
* Enable an app for every user
*
* @param string $appId
* @throws \Exception
*/
public function enableApp($appId) {
if(OC_App::getAppPath($appId) === false) {
Expand Down Expand Up @@ -430,4 +424,18 @@ public function readAppPackage($path) {
Files::rmdirr($appCodeDir);
return $appInfo;
}

/**
* Indicates if app installation is supported. Usually it is but in certain
* environments it is disallowed because of hardening. In a clustered setup
* apps need to be installed on each cluster node which is out of scope of
* ownCloud itself.
*
* @return bool
* @since 10.0.3
*/
public function canInstall() {
$appsFolder = OC_App::getInstallPath();
return $appsFolder !== null && is_writable($appsFolder) && is_readable($appsFolder);
}
}
7 changes: 6 additions & 1 deletion lib/private/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ public static function installApp( $data = []) {

$info = self::checkAppsIntegrity($data, $extractDir, $path);
$appId = OC_App::cleanAppId($info['id']);
$basedir = OC_App::getInstallPath().'/'.$appId;
$appsFolder = OC_App::getInstallPath();

if ($appsFolder === null || !is_writable($appsFolder)) {
throw new \Exception('Apps folder is not writable');
}
$basedir = "$appsFolder/$appId";
//check if the destination directory already exists
if(is_dir($basedir)) {
OC_Helper::rmdirr($extractDir);
Expand Down
2 changes: 1 addition & 1 deletion lib/private/legacy/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ private static function adjustVersionParts($version1, $version2) {
* This means that it's possible to specify "requiremin" => 6
* and "requiremax" => 6 and it will still match ownCloud 6.0.3.
*
* @param string $ocVersion ownCloud version to check against
* @param string|array $ocVersion ownCloud version to check against
* @param array $appInfo app info (from xml)
*
* @return boolean true if compatible, otherwise false
Expand Down
10 changes: 10 additions & 0 deletions lib/public/App/IAppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,14 @@ public function getAllApps();
*/
public function readAppPackage($path);

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

0 comments on commit fa75a5a

Please sign in to comment.