diff options
author | Vincent Petry <vincent@nextcloud.com> | 2021-02-17 11:37:18 +0300 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2021-02-26 12:50:23 +0300 |
commit | 8929ea15a8208577697f68e58bb159cca0e2bba5 (patch) | |
tree | 1a5ac5edddb8c41409b5e73fde4b9628e2bce132 | |
parent | 7c0e1262f8a59dec90bef62a9510da3ae3037329 (diff) |
Disable UI when web updater is disabled in config.php
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
-rw-r--r-- | index.php | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -153,6 +153,8 @@ class Updater { private $updateAvailable = false; /** @var string */ private $requestID = null; + /** @var bool */ + private $disabled = false; /** * Updater constructor @@ -175,6 +177,12 @@ class Updater { require_once $configFileName; $this->configValues = $CONFIG; + if ($this->configValues['upgrade.disable-web'] ?? false) { + // updater disabled + $this->disabled = true; + return; + } + $dataDir = $this->getDataDirectoryLocation(); if(empty($dataDir) || !is_string($dataDir)) { throw new \Exception('Could not read data directory from config.php.'); @@ -211,6 +219,15 @@ class Updater { } /** + * Returns whether the web updater is disabled + * + * @return bool + */ + public function isDisabled() { + return $this->disabled; + } + + /** * Returns current version or "unknown" if this could not be determined. * * @return string @@ -1279,8 +1296,13 @@ ini_set('log_errors', '1'); // Check if the config.php is at the expected place try { $updater = new Updater(__DIR__); + if ($updater->isDisabled()) { + http_response_code(403); + die('Updater is disabled, please use the command line'); + } } catch (\Exception $e) { // logging here is not possible because we don't know the data directory + http_response_code(500); die($e->getMessage()); } |