mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Device lockdown after 4 passphrase tries
This commit is contained in:
parent
997e62aed7
commit
d8d3176587
7 changed files with 122 additions and 31 deletions
12
alert.cpp
12
alert.cpp
|
@ -52,6 +52,18 @@ alert::alert(QWidget *parent) :
|
|||
ui->messageLabel->setText("An error occured during the update process.\nThe update package's version is lower than the actual installed version.");
|
||||
ui->stackedWidget->setCurrentIndex(1);
|
||||
}
|
||||
if(global::encfs::lockdown == true) {
|
||||
ui->stackedWidget->setVisible(false);
|
||||
ui->stackedWidget->deleteLater();
|
||||
QPixmap pixmap(":/resources/alert.png");
|
||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||
ui->alertIconLabel->setPixmap(scaledPixmap);
|
||||
|
||||
ui->warningLabel->setText("Fatal error");
|
||||
ui->securityLabel->setText("Device lockdown");
|
||||
QString message = "Due to multiple incorrect passphrase attempts, this device is locked down until\n" + global::encfs::unlockTime + "\nand won't boot.";
|
||||
ui->messageLabel->setText(message);
|
||||
}
|
||||
if(global::battery::showCriticalBatteryAlert == true) {
|
||||
global::battery::showCriticalBatteryAlert = false;
|
||||
ui->stackedWidget->setVisible(false);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include <QMessageBox>
|
||||
#include <QDateTime>
|
||||
#include "functions.h"
|
||||
|
||||
encryptionManager::encryptionManager(QWidget *parent) :
|
||||
|
@ -26,8 +28,8 @@ encryptionManager::encryptionManager(QWidget *parent) :
|
|||
ui->successDescriptionLabel->setStyleSheet("font-size: 9pt");
|
||||
ui->failureLabel->setStyleSheet("font-size: 15pt");
|
||||
ui->failureDescriptionLabel->setStyleSheet("font-size: 9pt");
|
||||
ui->setupContinueBtn->setStyleSheet("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey");
|
||||
ui->setupAbortBtn->setStyleSheet("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey");
|
||||
ui->setupContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold");
|
||||
ui->setupAbortBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold");
|
||||
ui->exitSuccessBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold");
|
||||
ui->failureContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold");
|
||||
|
||||
|
@ -66,7 +68,7 @@ encryptionManager::encryptionManager(QWidget *parent) :
|
|||
if(checkconfig(".config/18-encrypted_storage/initial_setup_done") == true) {
|
||||
ui->activityWidget->hide();
|
||||
setupPassphraseDialogMode = 1;
|
||||
QTimer::singleShot(1000, this, SLOT(setupPassphraseDialog()));
|
||||
QTimer::singleShot(500, this, SLOT(setupPassphraseDialog()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,6 +136,11 @@ void encryptionManager::showToast(QString messageToDisplay) {
|
|||
void encryptionManager::setupEncryptedStorage() {
|
||||
this->setStyleSheet("background-color: white");
|
||||
ui->activityWidget->show();
|
||||
if(global::encfs::cancelSetup == true) {
|
||||
global::encfs::cancelSetup = false;
|
||||
ui->activityWidget->setCurrentIndex(0);
|
||||
}
|
||||
else {
|
||||
mkEncfsDirs();
|
||||
std::string bootstrapPassphrase = global::encfs::passphrase.toStdString();
|
||||
global::encfs::passphrase = "";
|
||||
|
@ -156,6 +163,7 @@ void encryptionManager::setupEncryptedStorage() {
|
|||
}
|
||||
} );
|
||||
t->start();
|
||||
}
|
||||
}
|
||||
|
||||
void encryptionManager::unlockEncryptedStorage() {
|
||||
|
@ -170,14 +178,65 @@ void encryptionManager::unlockEncryptedStorage() {
|
|||
string_writeconfig("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
|
||||
string_writeconfig("/opt/ibxd", "encfs_restart\n");
|
||||
bool exitStatus;
|
||||
|
||||
string_checkconfig_ro("/inkbox/encryptedStoragePassphraseTries");
|
||||
if(checkconfig_str_val.isEmpty()) {
|
||||
passphraseTries = 0;
|
||||
}
|
||||
else {
|
||||
passphraseTries = checkconfig_str_val.toInt();
|
||||
passphraseTries++;
|
||||
}
|
||||
|
||||
ui->activityWidget->setCurrentIndex(3);
|
||||
QTimer * t = new QTimer(this);
|
||||
t->setInterval(1000);
|
||||
connect(t, &QTimer::timeout, [&]() {
|
||||
if(QFile::exists("/external_root/run/encfs_mounted")) {
|
||||
exitStatus = checkconfig("/external_root/run/encfs_mounted");
|
||||
if(exitStatus == false) {
|
||||
if(setupMessageBoxRan == false) {
|
||||
int delay = 0;
|
||||
if(passphraseTries <= 3) {
|
||||
if(passphraseTries == 0) {
|
||||
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "0");
|
||||
delay = 5000;
|
||||
}
|
||||
else if(passphraseTries == 1) {
|
||||
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "1");
|
||||
delay = 10000;
|
||||
}
|
||||
else if(passphraseTries == 2) {
|
||||
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "2");
|
||||
delay = 20000;
|
||||
}
|
||||
else if(passphraseTries >= 3) {
|
||||
string_writeconfig("/inkbox/encryptedStoragePassphraseTries", "3");
|
||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||
currentEpoch += 86400;
|
||||
global::encfs::unlockTime = QDateTime::fromTime_t(currentEpoch).toString();
|
||||
std::string unlockTime_str = global::encfs::unlockTime.toStdString();
|
||||
qDebug() << "FATAL: 4 invalid passphrase tries, locking down device until " + global::encfs::unlockTime;
|
||||
string_writeconfig("/external_root/boot/flags/ENCRYPT_LOCK", unlockTime_str);
|
||||
global::encfs::lockdown = true;
|
||||
setupMessageBoxRan = true;
|
||||
|
||||
alertWindow = new alert();
|
||||
alertWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
alertWindow->showFullScreen();
|
||||
}
|
||||
|
||||
if(passphraseTries <= 2) {
|
||||
QTimer::singleShot(delay, this, SLOT(setupFailedAuthenticationMessageBox()));
|
||||
setupMessageBoxRan = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
quit_restart();
|
||||
}
|
||||
}
|
||||
} );
|
||||
t->start();
|
||||
}
|
||||
|
@ -221,3 +280,9 @@ void encryptionManager::on_failureContinueBtn_clicked()
|
|||
quit_restart();
|
||||
}
|
||||
|
||||
void encryptionManager::setupFailedAuthenticationMessageBox() {
|
||||
ui->activityWidget->hide();
|
||||
QMessageBox::critical(this, tr("Invalid argument"), tr("Invalid passphrase. Please try again."));
|
||||
QFile::remove("/external_root/run/encfs_mounted");
|
||||
quit_restart();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "generaldialog.h"
|
||||
#include "toast.h"
|
||||
#include "hourglassanimationwidget.h"
|
||||
#include "alert.h"
|
||||
|
||||
namespace Ui {
|
||||
class encryptionManager;
|
||||
|
@ -19,6 +20,8 @@ public:
|
|||
~encryptionManager();
|
||||
bool setupExitWidgetRan = false;
|
||||
int setupPassphraseDialogMode;
|
||||
bool setupMessageBoxRan = false;
|
||||
int passphraseTries;
|
||||
|
||||
private slots:
|
||||
void on_setupContinueBtn_clicked();
|
||||
|
@ -33,12 +36,14 @@ private slots:
|
|||
void on_failureContinueBtn_clicked();
|
||||
void setupPassphraseDialog();
|
||||
void unlockEncryptedStorage();
|
||||
void setupFailedAuthenticationMessageBox();
|
||||
|
||||
private:
|
||||
Ui::encryptionManager *ui;
|
||||
generalDialog * generalDialogWindow;
|
||||
toast * toastWindow;
|
||||
hourglassAnimationWidget * hourglassAnimationWidgetWindow;
|
||||
alert * alertWindow;
|
||||
};
|
||||
|
||||
#endif // ENCRYPTIONMANAGER_H
|
||||
|
|
|
@ -91,6 +91,10 @@ namespace global {
|
|||
}
|
||||
namespace encfs {
|
||||
inline QString passphrase;
|
||||
inline QString unlockTime;
|
||||
inline bool cancelSetup;
|
||||
inline bool cancelUnlock;
|
||||
inline bool lockdown;
|
||||
}
|
||||
inline QString systemInfoText;
|
||||
inline bool forbidOpenSearchDialog;
|
||||
|
|
|
@ -186,6 +186,11 @@ void generalDialog::on_cancelBtn_clicked()
|
|||
global::keyboard::keyboardDialog = false;
|
||||
global::keyboard::keyboardText = "";
|
||||
}
|
||||
else if(global::keyboard::encfsDialog == true) {
|
||||
global::keyboard::encfsDialog = false;
|
||||
global::encfs::cancelSetup = true;
|
||||
global::keyboard::keyboardText = "";
|
||||
}
|
||||
generalDialog::close();
|
||||
}
|
||||
}
|
||||
|
@ -441,7 +446,7 @@ void generalDialog::setupKeyboardDialog() {
|
|||
ui->cancelBtn->setText("Cancel");
|
||||
}
|
||||
else if(global::keyboard::encfsDialog == true) {
|
||||
ui->headerLabel->setText("Enter a new encryption key");
|
||||
ui->headerLabel->setText("Enter your encrypted storage's passphrase");
|
||||
ui->okBtn->setText("OK");
|
||||
ui->cancelBtn->setText("Cancel");
|
||||
}
|
||||
|
|
|
@ -18,15 +18,15 @@ hourglassAnimationWidget::hourglassAnimationWidget(QWidget *parent) :
|
|||
float stdIconWidth;
|
||||
float stdIconHeight;
|
||||
{
|
||||
stdIconWidth = sW / 1.60;
|
||||
stdIconHeight = sH / 1.60;
|
||||
stdIconWidth = sW / 1.80;
|
||||
stdIconHeight = sH / 1.80;
|
||||
QPixmap pixmap(":/resources/hourglass-top.png");
|
||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||
ui->hourglassTopLabel->setPixmap(scaledPixmap);
|
||||
}
|
||||
{
|
||||
stdIconWidth = sW / 1.60;
|
||||
stdIconHeight = sH / 1.60;
|
||||
stdIconWidth = sW / 1.80;
|
||||
stdIconHeight = sH / 1.80;
|
||||
QPixmap pixmap(":/resources/hourglass-bottom.png");
|
||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||
ui->hourglassBottomLabel->setPixmap(scaledPixmap);
|
||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Loading…
Reference in a new issue