Alert message if downgrade is attempted

This commit is contained in:
Nicolas Mailloux 2021-04-06 16:08:03 -04:00
parent 3a806fa17c
commit af4f9b57c5
2 changed files with 23 additions and 5 deletions

View file

@ -29,12 +29,19 @@ alert::alert(QWidget *parent) :
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
// Checking if the update's signature is untrusted
// Checking if the update's signature is untrusted. The signature error will always take precedence over the downgrade one (c.f. update.sh script)
if(checkconfig("/external_root/boot/flags/ALERT_SIGN") == true) {
signatureError = true;
ui->securityLabel->setText("Failed to update InkBox.");
ui->messageLabel->setText("The digital signature of the update is untrusted.\nFor security reasons, it cannot be installed.");
ui->stackedWidget->setCurrentIndex(1);
}
if(checkconfig("/external_root/boot/flags/ALERT_DOWNGRADE") == true) {
downgradeError = true;
ui->securityLabel->setText("Failed to update InkBox.");
ui->messageLabel->setText("An error occured during the update process.\nThe update provided is lower than the actual installed version.");
ui->stackedWidget->setCurrentIndex(1);
}
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 16pt}");
ui->messageLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 9pt}");
@ -79,8 +86,17 @@ void alert::on_continue2Btn_clicked()
{
// We continue anyway and re-set the ALERT flag
string_writeconfig("/external_root/boot/flags/ALERT", "false");
string_writeconfig("/external_root/boot/flags/ALERT_SIGN", "false");
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
if(signatureError == true) {
string_writeconfig("/external_root/boot/flags/ALERT_SIGN", "false");
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}
if(downgradeError == true) {
string_writeconfig("/external_root/boot/flags/ALERT_DOWNGRADE", "false");
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}
}

View file

@ -16,6 +16,8 @@ class alert : public QWidget
public:
explicit alert(QWidget *parent = nullptr);
~alert();
bool signatureError = false;
bool downgradeError = false;
private slots:
void on_continueBtn_clicked();