mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 01:42:19 +00:00
Give error for proc_close.
This commit is contained in:
@@ -35,6 +35,8 @@ use phpseclib\Crypt\RSA;
|
|||||||
*/
|
*/
|
||||||
class InstallController extends Controller
|
class InstallController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public const FORBIDDEN_ERROR = 'Internal PHP function "proc_close" is disabled for your installation. Auto-migration is not possible.';
|
||||||
/** @noinspection MagicMethodsValidityInspection */
|
/** @noinspection MagicMethodsValidityInspection */
|
||||||
/** @noinspection PhpMissingParentConstructorInspection */
|
/** @noinspection PhpMissingParentConstructorInspection */
|
||||||
/**
|
/**
|
||||||
@@ -58,6 +60,9 @@ class InstallController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function keys()
|
public function keys()
|
||||||
{
|
{
|
||||||
|
if ($this->hasForbiddenFunctions()) {
|
||||||
|
return response()->json(['error' => true, 'message' => self::FORBIDDEN_ERROR]);
|
||||||
|
}
|
||||||
// create keys manually because for some reason the passport namespace
|
// create keys manually because for some reason the passport namespace
|
||||||
// does not exist
|
// does not exist
|
||||||
$rsa = new RSA();
|
$rsa = new RSA();
|
||||||
@@ -69,13 +74,13 @@ class InstallController extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (file_exists($publicKey) || file_exists($privateKey)) {
|
if (file_exists($publicKey) || file_exists($privateKey)) {
|
||||||
return response()->json(['OK']);
|
return response()->json(['error' => false, 'message' => 'OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents($publicKey, array_get($keys, 'publickey'));
|
file_put_contents($publicKey, array_get($keys, 'publickey'));
|
||||||
file_put_contents($privateKey, array_get($keys, 'privatekey'));
|
file_put_contents($privateKey, array_get($keys, 'privatekey'));
|
||||||
|
|
||||||
return response()->json(['OK']);
|
return response()->json(['error' => false, 'message' => 'OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,11 +88,15 @@ class InstallController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function migrate()
|
public function migrate()
|
||||||
{
|
{
|
||||||
|
if ($this->hasForbiddenFunctions()) {
|
||||||
|
return response()->json(['error' => true, 'message' => self::FORBIDDEN_ERROR]);
|
||||||
|
}
|
||||||
|
|
||||||
Log::debug('Am now calling migrate routine...');
|
Log::debug('Am now calling migrate routine...');
|
||||||
Artisan::call('migrate', ['--seed' => true, '--force' => true]);
|
Artisan::call('migrate', ['--seed' => true, '--force' => true]);
|
||||||
Log::debug(Artisan::output());
|
Log::debug(Artisan::output());
|
||||||
|
|
||||||
return response()->json(['OK']);
|
return response()->json(['error' => false, 'message' => 'OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,11 +104,14 @@ class InstallController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function upgrade()
|
public function upgrade()
|
||||||
{
|
{
|
||||||
|
if ($this->hasForbiddenFunctions()) {
|
||||||
|
return response()->json(['error' => true, 'message' => self::FORBIDDEN_ERROR]);
|
||||||
|
}
|
||||||
Log::debug('Am now calling upgrade database routine...');
|
Log::debug('Am now calling upgrade database routine...');
|
||||||
Artisan::call('firefly:upgrade-database');
|
Artisan::call('firefly:upgrade-database');
|
||||||
Log::debug(Artisan::output());
|
Log::debug(Artisan::output());
|
||||||
|
|
||||||
return response()->json(['OK']);
|
return response()->json(['error' => false, 'message' => 'OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,11 +119,37 @@ class InstallController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function verify()
|
public function verify()
|
||||||
{
|
{
|
||||||
|
if ($this->hasForbiddenFunctions()) {
|
||||||
|
return response()->json(['error' => true, 'message' => self::FORBIDDEN_ERROR]);
|
||||||
|
}
|
||||||
Log::debug('Am now calling verify database routine...');
|
Log::debug('Am now calling verify database routine...');
|
||||||
Artisan::call('firefly:verify');
|
Artisan::call('firefly:verify');
|
||||||
Log::debug(Artisan::output());
|
Log::debug(Artisan::output());
|
||||||
|
|
||||||
return response()->json(['OK']);
|
return response()->json(['error' => false, 'message' => 'OK']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function hasForbiddenFunctions(): bool
|
||||||
|
{
|
||||||
|
$list = ['proc_close'];
|
||||||
|
$forbidden = explode(',', ini_get('disable_functions'));
|
||||||
|
$trimmed = array_map(
|
||||||
|
function (string $value) {
|
||||||
|
return trim($value);
|
||||||
|
}, $forbidden
|
||||||
|
);
|
||||||
|
foreach ($list as $entry) {
|
||||||
|
if (\in_array($entry, $trimmed, true)) {
|
||||||
|
Log::error('Method "%s" is FORBIDDEN, so the console command cannot be executed.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
26
public/js/ff/install/index.js
vendored
26
public/js/ff/install/index.js
vendored
@@ -28,8 +28,13 @@ $(function () {
|
|||||||
|
|
||||||
function startMigration() {
|
function startMigration() {
|
||||||
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up DB...');
|
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up DB...');
|
||||||
$.post(migrateUri, {_token: token}).done(function () {
|
$.post(migrateUri, {_token: token}).done(function (data) {
|
||||||
|
if(data.error === false) {
|
||||||
startPassport();
|
startPassport();
|
||||||
|
} else {
|
||||||
|
displaySoftFail(data.message);
|
||||||
|
}
|
||||||
|
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
$('#status-box').html('<i class="fa fa-warning"></i> Migration failed! See log files :(');
|
$('#status-box').html('<i class="fa fa-warning"></i> Migration failed! See log files :(');
|
||||||
});
|
});
|
||||||
@@ -41,7 +46,12 @@ function startMigration() {
|
|||||||
function startPassport() {
|
function startPassport() {
|
||||||
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up OAuth2...');
|
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Setting up OAuth2...');
|
||||||
$.post(keysUri, {_token: token}).done(function () {
|
$.post(keysUri, {_token: token}).done(function () {
|
||||||
|
if(data.error === false) {
|
||||||
startUpgrade();
|
startUpgrade();
|
||||||
|
} else {
|
||||||
|
displaySoftFail(data.message);
|
||||||
|
}
|
||||||
|
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
$('#status-box').html('<i class="fa fa-warning"></i> OAuth2 failed! See log files :(');
|
$('#status-box').html('<i class="fa fa-warning"></i> OAuth2 failed! See log files :(');
|
||||||
});
|
});
|
||||||
@@ -53,7 +63,11 @@ function startPassport() {
|
|||||||
function startUpgrade() {
|
function startUpgrade() {
|
||||||
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Upgrading database...');
|
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Upgrading database...');
|
||||||
$.post(upgradeUri, {_token: token}).done(function () {
|
$.post(upgradeUri, {_token: token}).done(function () {
|
||||||
|
if(data.error === false) {
|
||||||
startVerify();
|
startVerify();
|
||||||
|
} else {
|
||||||
|
displaySoftFail(data.message);
|
||||||
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
$('#status-box').html('<i class="fa fa-warning"></i> Upgrade failed! See log files :(');
|
$('#status-box').html('<i class="fa fa-warning"></i> Upgrade failed! See log files :(');
|
||||||
});
|
});
|
||||||
@@ -65,7 +79,11 @@ function startUpgrade() {
|
|||||||
function startVerify() {
|
function startVerify() {
|
||||||
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Verify database integrity...');
|
$('#status-box').html('<i class="fa fa-spin fa-spinner"></i> Verify database integrity...');
|
||||||
$.post(verifyUri, {_token: token}).done(function () {
|
$.post(verifyUri, {_token: token}).done(function () {
|
||||||
|
if(data.error === false) {
|
||||||
completeDone();
|
completeDone();
|
||||||
|
} else {
|
||||||
|
displaySoftFail(data.message);
|
||||||
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
$('#status-box').html('<i class="fa fa-warning"></i> Verification failed! See log files :(');
|
$('#status-box').html('<i class="fa fa-warning"></i> Verification failed! See log files :(');
|
||||||
});
|
});
|
||||||
@@ -80,3 +98,9 @@ function completeDone() {
|
|||||||
window.location = homeUri;
|
window.location = homeUri;
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displaySoftFail(message) {
|
||||||
|
$('#status-box').html('<i class="fa fa-warning"></i> ' + message + '<br /><br />Please read the ' +
|
||||||
|
'<a href="http://firefly-iii.readthedocs.io/en/latest/support/faq.html#i-get-an-error-about-proc-close-being-disabled">' +
|
||||||
|
'official documentation</a> about this.');
|
||||||
|
}
|
Reference in New Issue
Block a user