Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Adjust behaviour in case the apps folder is not writable … #28601

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -995,7 +995,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();
}