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->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);
|
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) {
|
if(global::battery::showCriticalBatteryAlert == true) {
|
||||||
global::battery::showCriticalBatteryAlert = false;
|
global::battery::showCriticalBatteryAlert = false;
|
||||||
ui->stackedWidget->setVisible(false);
|
ui->stackedWidget->setVisible(false);
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QDateTime>
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
encryptionManager::encryptionManager(QWidget *parent) :
|
encryptionManager::encryptionManager(QWidget *parent) :
|
||||||
|
@ -26,8 +28,8 @@ encryptionManager::encryptionManager(QWidget *parent) :
|
||||||
ui->successDescriptionLabel->setStyleSheet("font-size: 9pt");
|
ui->successDescriptionLabel->setStyleSheet("font-size: 9pt");
|
||||||
ui->failureLabel->setStyleSheet("font-size: 15pt");
|
ui->failureLabel->setStyleSheet("font-size: 15pt");
|
||||||
ui->failureDescriptionLabel->setStyleSheet("font-size: 9pt");
|
ui->failureDescriptionLabel->setStyleSheet("font-size: 9pt");
|
||||||
ui->setupContinueBtn->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("font-size: 10pt; padding: 10px; font-weight: bold; background: lightGrey");
|
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->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");
|
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) {
|
if(checkconfig(".config/18-encrypted_storage/initial_setup_done") == true) {
|
||||||
ui->activityWidget->hide();
|
ui->activityWidget->hide();
|
||||||
setupPassphraseDialogMode = 1;
|
setupPassphraseDialogMode = 1;
|
||||||
QTimer::singleShot(1000, this, SLOT(setupPassphraseDialog()));
|
QTimer::singleShot(500, this, SLOT(setupPassphraseDialog()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,28 +136,34 @@ void encryptionManager::showToast(QString messageToDisplay) {
|
||||||
void encryptionManager::setupEncryptedStorage() {
|
void encryptionManager::setupEncryptedStorage() {
|
||||||
this->setStyleSheet("background-color: white");
|
this->setStyleSheet("background-color: white");
|
||||||
ui->activityWidget->show();
|
ui->activityWidget->show();
|
||||||
mkEncfsDirs();
|
if(global::encfs::cancelSetup == true) {
|
||||||
std::string bootstrapPassphrase = global::encfs::passphrase.toStdString();
|
global::encfs::cancelSetup = false;
|
||||||
global::encfs::passphrase = "";
|
ui->activityWidget->setCurrentIndex(0);
|
||||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_create", "true");
|
}
|
||||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox");
|
else {
|
||||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
|
mkEncfsDirs();
|
||||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
|
std::string bootstrapPassphrase = global::encfs::passphrase.toStdString();
|
||||||
setDefaultWorkDir();
|
global::encfs::passphrase = "";
|
||||||
string_writeconfig(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted");
|
string_writeconfig("/external_root/run/encfs/encrypted_storage_create", "true");
|
||||||
string_writeconfig("/opt/ibxd", "encfs_restart\n");
|
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox");
|
||||||
bool exitStatus;
|
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
|
||||||
ui->activityWidget->setCurrentIndex(3);
|
string_writeconfig("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
|
||||||
QTimer * t = new QTimer(this);
|
setDefaultWorkDir();
|
||||||
t->setInterval(1000);
|
string_writeconfig(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted");
|
||||||
connect(t, &QTimer::timeout, [&]() {
|
string_writeconfig("/opt/ibxd", "encfs_restart\n");
|
||||||
if(QFile::exists("/external_root/run/encrypted_storage_bootstrap_setup")) {
|
bool exitStatus;
|
||||||
exitStatus = checkconfig("/external_root/run/encrypted_storage_bootstrap_setup");
|
ui->activityWidget->setCurrentIndex(3);
|
||||||
QFile::remove("/external_root/run/encrypted_storage_bootstrap_setup");
|
QTimer * t = new QTimer(this);
|
||||||
setupExitWidget(exitStatus);
|
t->setInterval(1000);
|
||||||
}
|
connect(t, &QTimer::timeout, [&]() {
|
||||||
} );
|
if(QFile::exists("/external_root/run/encrypted_storage_bootstrap_setup")) {
|
||||||
t->start();
|
exitStatus = checkconfig("/external_root/run/encrypted_storage_bootstrap_setup");
|
||||||
|
QFile::remove("/external_root/run/encrypted_storage_bootstrap_setup");
|
||||||
|
setupExitWidget(exitStatus);
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
t->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void encryptionManager::unlockEncryptedStorage() {
|
void encryptionManager::unlockEncryptedStorage() {
|
||||||
|
@ -170,13 +178,64 @@ void encryptionManager::unlockEncryptedStorage() {
|
||||||
string_writeconfig("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
|
string_writeconfig("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
|
||||||
string_writeconfig("/opt/ibxd", "encfs_restart\n");
|
string_writeconfig("/opt/ibxd", "encfs_restart\n");
|
||||||
bool exitStatus;
|
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);
|
ui->activityWidget->setCurrentIndex(3);
|
||||||
QTimer * t = new QTimer(this);
|
QTimer * t = new QTimer(this);
|
||||||
t->setInterval(1000);
|
t->setInterval(1000);
|
||||||
connect(t, &QTimer::timeout, [&]() {
|
connect(t, &QTimer::timeout, [&]() {
|
||||||
if(QFile::exists("/external_root/run/encfs_mounted")) {
|
if(QFile::exists("/external_root/run/encfs_mounted")) {
|
||||||
exitStatus = checkconfig("/external_root/run/encfs_mounted");
|
exitStatus = checkconfig("/external_root/run/encfs_mounted");
|
||||||
quit_restart();
|
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();
|
t->start();
|
||||||
|
@ -221,3 +280,9 @@ void encryptionManager::on_failureContinueBtn_clicked()
|
||||||
quit_restart();
|
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 "generaldialog.h"
|
||||||
#include "toast.h"
|
#include "toast.h"
|
||||||
#include "hourglassanimationwidget.h"
|
#include "hourglassanimationwidget.h"
|
||||||
|
#include "alert.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class encryptionManager;
|
class encryptionManager;
|
||||||
|
@ -19,6 +20,8 @@ public:
|
||||||
~encryptionManager();
|
~encryptionManager();
|
||||||
bool setupExitWidgetRan = false;
|
bool setupExitWidgetRan = false;
|
||||||
int setupPassphraseDialogMode;
|
int setupPassphraseDialogMode;
|
||||||
|
bool setupMessageBoxRan = false;
|
||||||
|
int passphraseTries;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_setupContinueBtn_clicked();
|
void on_setupContinueBtn_clicked();
|
||||||
|
@ -33,12 +36,14 @@ private slots:
|
||||||
void on_failureContinueBtn_clicked();
|
void on_failureContinueBtn_clicked();
|
||||||
void setupPassphraseDialog();
|
void setupPassphraseDialog();
|
||||||
void unlockEncryptedStorage();
|
void unlockEncryptedStorage();
|
||||||
|
void setupFailedAuthenticationMessageBox();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::encryptionManager *ui;
|
Ui::encryptionManager *ui;
|
||||||
generalDialog * generalDialogWindow;
|
generalDialog * generalDialogWindow;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
hourglassAnimationWidget * hourglassAnimationWidgetWindow;
|
hourglassAnimationWidget * hourglassAnimationWidgetWindow;
|
||||||
|
alert * alertWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENCRYPTIONMANAGER_H
|
#endif // ENCRYPTIONMANAGER_H
|
||||||
|
|
|
@ -91,6 +91,10 @@ namespace global {
|
||||||
}
|
}
|
||||||
namespace encfs {
|
namespace encfs {
|
||||||
inline QString passphrase;
|
inline QString passphrase;
|
||||||
|
inline QString unlockTime;
|
||||||
|
inline bool cancelSetup;
|
||||||
|
inline bool cancelUnlock;
|
||||||
|
inline bool lockdown;
|
||||||
}
|
}
|
||||||
inline QString systemInfoText;
|
inline QString systemInfoText;
|
||||||
inline bool forbidOpenSearchDialog;
|
inline bool forbidOpenSearchDialog;
|
||||||
|
|
|
@ -186,6 +186,11 @@ void generalDialog::on_cancelBtn_clicked()
|
||||||
global::keyboard::keyboardDialog = false;
|
global::keyboard::keyboardDialog = false;
|
||||||
global::keyboard::keyboardText = "";
|
global::keyboard::keyboardText = "";
|
||||||
}
|
}
|
||||||
|
else if(global::keyboard::encfsDialog == true) {
|
||||||
|
global::keyboard::encfsDialog = false;
|
||||||
|
global::encfs::cancelSetup = true;
|
||||||
|
global::keyboard::keyboardText = "";
|
||||||
|
}
|
||||||
generalDialog::close();
|
generalDialog::close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,7 +446,7 @@ void generalDialog::setupKeyboardDialog() {
|
||||||
ui->cancelBtn->setText("Cancel");
|
ui->cancelBtn->setText("Cancel");
|
||||||
}
|
}
|
||||||
else if(global::keyboard::encfsDialog == true) {
|
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->okBtn->setText("OK");
|
||||||
ui->cancelBtn->setText("Cancel");
|
ui->cancelBtn->setText("Cancel");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,15 @@ hourglassAnimationWidget::hourglassAnimationWidget(QWidget *parent) :
|
||||||
float stdIconWidth;
|
float stdIconWidth;
|
||||||
float stdIconHeight;
|
float stdIconHeight;
|
||||||
{
|
{
|
||||||
stdIconWidth = sW / 1.60;
|
stdIconWidth = sW / 1.80;
|
||||||
stdIconHeight = sH / 1.60;
|
stdIconHeight = sH / 1.80;
|
||||||
QPixmap pixmap(":/resources/hourglass-top.png");
|
QPixmap pixmap(":/resources/hourglass-top.png");
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||||
ui->hourglassTopLabel->setPixmap(scaledPixmap);
|
ui->hourglassTopLabel->setPixmap(scaledPixmap);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
stdIconWidth = sW / 1.60;
|
stdIconWidth = sW / 1.80;
|
||||||
stdIconHeight = sH / 1.60;
|
stdIconHeight = sH / 1.80;
|
||||||
QPixmap pixmap(":/resources/hourglass-bottom.png");
|
QPixmap pixmap(":/resources/hourglass-bottom.png");
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||||
ui->hourglassBottomLabel->setPixmap(scaledPixmap);
|
ui->hourglassBottomLabel->setPixmap(scaledPixmap);
|
||||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Loading…
Reference in a new issue