Skip to content
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
5 changes: 5 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,11 @@
*/
'memcache.locking' => '\\OC\\Memcache\\Redis',

/**
* Disable the web based updater
*/
'upgrade.disable-web' => false,

/**
* Set this ownCloud instance to debugging mode
*
Expand Down
10 changes: 9 additions & 1 deletion core/ajax/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@
// need to send an initial message to force-init the event source,
// which will then trigger its own CSRF check and produces its own CSRF error
// message
$eventSource->send('success', (string)$l->t('Preparing update'));
//$eventSource->send('success', (string)$l->t('Preparing update'));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: WTF


if (OC::checkUpgrade(false)) {

$config = \OC::$server->getSystemConfig();
if ($config->getValue('upgrade.disable-web', true)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: WTF

$eventSource->send('failure', (string)$l->t('Updates need to be installed. Please use the command line updater.'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DeepDiver1975 Also make the message more clear: "Web based update is disabled. Please use the command line tool to upgrade" ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only gets displayed if a malicious user tries to trigger the update, even though the web UI already says it must be done via occ. Doesn't need to be pretty IMHO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only gets displayed if a malicious user tries to trigger the update, even though the web UI already says it must be done via occ. Doesn't need to be pretty IMHO

I was hugely confused, what has gone wrong. Better be more clear than to throw badly worded messages.

$eventSource->close();
exit();
}

// if a user is currently logged in, their session must be ignored to
// avoid side effects
\OC_User::setIncognitoMode(true);
Expand Down
14 changes: 14 additions & 0 deletions core/templates/update.use-cli.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="update" data-productname="<?php p($_['productName']) ?>" data-version="<?php p($_['version']) ?>">
<div class="updateOverview">
<h2 class="title"><?php p($l->t('Update needed')) ?></h2>
<div class="infogroup">
<?php if ($_['tooBig']) {
p($l->t('Please use the command line updater because you have a big instance.'));
} else {
p($l->t('Please use the command line updater because automatic updating is disabled in the config.php.'));
} ?><br><br>
<?php
print_unescaped($l->t('For help, see the <a target="_blank" rel="noreferrer" href="%s">documentation</a>.', [link_to_docs('admin-cli-upgrade')])); ?><br><br>
</div>
</div>
</div>
46 changes: 34 additions & 12 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,27 +337,49 @@ public static function checkUpgrade($showTemplate = true) {
*/
private static function printUpgradePage() {
$systemConfig = \OC::$server->getSystemConfig();

$disableWebUpdater = $systemConfig->getValue('upgrade.disable-web', false);
$tooBig = false;
if (!$disableWebUpdater) {
// count users
$stats = \OC::$server->getUserManager()->countUsers();
$totalUsers = array_sum($stats);
$tooBig = ($totalUsers > 50);
}
if ($disableWebUpdater || $tooBig) {
// send http status 503
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 120');

// render error page
$template = new OC_Template('', 'update.use-cli', 'guest');
$template->assign('productName', 'ownCloud'); // for now
$template->assign('version', OC_Util::getVersionString());
$template->assign('tooBig', $tooBig);

$template->printPage();
die();
}

// check whether this is a core update or apps update
$installedVersion = $systemConfig->getValue('version', '0.0.0');
$currentVersion = implode('.', \OCP\Util::getVersion());

// if not a core upgrade, then it's apps upgrade
$isAppsOnlyUpgrade = (version_compare($currentVersion, $installedVersion, '='));

$oldTheme = $systemConfig->getValue('theme');
$systemConfig->setValue('theme', '');
\OCP\Util::addScript('config'); // needed for web root
\OCP\Util::addScript('update');
\OCP\Util::addStyle('update');

// check whether this is a core update or apps update
$installedVersion = $systemConfig->getValue('version', '0.0.0');
$currentVersion = implode('.', \OCP\Util::getVersion());

$appManager = \OC::$server->getAppManager();

$tmpl = new OC_Template('', 'update.admin', 'guest');
$tmpl->assign('version', OC_Util::getVersionString());

// if not a core upgrade, then it's apps upgrade
if (version_compare($currentVersion, $installedVersion, '=')) {
$tmpl->assign('isAppsOnlyUpgrade', true);
} else {
$tmpl->assign('isAppsOnlyUpgrade', false);
}
$tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade);

// get third party apps
$ocVersion = \OCP\Util::getVersion();
Expand Down Expand Up @@ -423,7 +445,7 @@ private static function getSessionLifeTime() {
}

public static function loadAppClassPaths() {
foreach (OC_APP::getEnabledApps() as $app) {
foreach (OC_App::getEnabledApps() as $app) {
$appPath = OC_App::getAppPath($app);
if ($appPath === false) {
continue;
Expand Down