Skip to content

Commit f8daaa5

Browse files
committed
Block install without CAN_INSTALL file
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
1 parent 1416ef6 commit f8daaa5

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

config/CAN_INSTALL

Whitespace-only changes.

core/Controller/SetupController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public function run($post) {
6262
$post['dbpass'] = $post['dbpassword'];
6363
}
6464

65+
if (!is_file(\OC::$configDir.'/CAN_INSTALL')) {
66+
$this->displaySetupForbidden();
67+
return;
68+
}
69+
6570
if(isset($post['install']) AND $post['install']=='true') {
6671
// We have to launch the installation process :
6772
$e = $this->setupHelper->install($post);
@@ -79,6 +84,10 @@ public function run($post) {
7984
}
8085
}
8186

87+
private function displaySetupForbidden() {
88+
\OC_Template::printGuestPage('', 'installation_forbidden');
89+
}
90+
8291
public function display($post) {
8392
$defaults = array(
8493
'adminlogin' => '',
@@ -101,6 +110,11 @@ public function finishSetup() {
101110
unlink($this->autoConfigFile);
102111
}
103112
\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
113+
114+
if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
115+
unlink(\OC::$configDir.'/CAN_INSTALL');
116+
}
117+
104118
\OC_Util::redirectToDefaultPage();
105119
}
106120

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="error">
2+
<h2><?php p($l->t('Error')) ?></h2>
3+
<p>
4+
<?php p($l->t('It looks like you are trying to reinstall your Nextcloud. However the file CAN_INSTALL is missing from your config directory. Please create the file CAN_INSTALL in your config folder to continue.')) ?>
5+
</p>
6+
</div>

lib/private/Updater.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ public function upgrade() {
111111
$this->emit('\OC\Updater', 'maintenanceEnabled');
112112
}
113113

114+
// Clear CAN_INSTALL file if not on git
115+
if (\OC_Util::getChannel() !== 'git') {
116+
unlink(\OC::$configDir . '/CAN_INSTALL');
117+
}
118+
114119
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
115120
$currentVersion = implode('.', \OCP\Util::getVersion());
116121

0 commit comments

Comments
 (0)