From 0bd233919c94dedcde9341521862b260fb5d0252 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Sun, 14 Nov 2021 21:22:58 -0500 Subject: [PATCH] EncFS repack testing --- encryptionmanager.cpp | 35 +++- encryptionmanager.h | 1 + functions.h | 4 + generaldialog.cpp | 6 + settings.cpp | 21 ++ settings.h | 1 + settings.ui | 448 +++++++++++++++++++++++------------------- 7 files changed, 310 insertions(+), 206 deletions(-) diff --git a/encryptionmanager.cpp b/encryptionmanager.cpp index 35731e5..40cec56 100644 --- a/encryptionmanager.cpp +++ b/encryptionmanager.cpp @@ -77,7 +77,7 @@ encryptionManager::encryptionManager(QWidget *parent) : ui->hourglassWidget->setCurrentIndex(0); setDefaultWorkDir(); - if(checkconfig(".config/18-encrypted_storage/initial_setup_done") == true) { + if(checkconfig(".config/18-encrypted_storage/initial_setup_done") == true or checkconfig("/run/encfs_repack") == true) { ui->activityWidget->hide(); setupPassphraseDialogMode = 1; QTimer::singleShot(500, this, SLOT(setupPassphraseDialog())); @@ -107,6 +107,7 @@ void encryptionManager::setupPassphraseDialog() { * setupPassphraseDialogMode can be: * 0: Initial setup * 1: Normal behavior + * 2: Repack */ ui->activityWidget->hide(); this->setStyleSheet("background-color: black"); @@ -119,9 +120,12 @@ void encryptionManager::setupPassphraseDialog() { if(setupPassphraseDialogMode == 0) { connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(setupEncryptedStorage())); } - else { + else if(setupPassphraseDialogMode == 1) { connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(unlockEncryptedStorage())); } + else { + connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(repackEncryptedStorage())); + } connect(generalDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString))); generalDialogWindow->show(); } @@ -330,3 +334,30 @@ void encryptionManager::on_usbmsBtn_clicked() usbmsWindow->show(); } +void encryptionManager::repackEncryptedStorage() { + if(global::encfs::cancelSetup == true) { + global::encfs::cancelSetup = false; + quit_restart(); + } + else { + this->setStyleSheet("background-color: white"); + ui->activityWidget->show(); + mkEncfsDirs(); + std::string passphrase = global::encfs::passphrase.toStdString(); + global::encfs::passphrase = ""; + string_writeconfig("/external_root/run/encfs/encrypted_storage_passphrase", passphrase); + string_writeconfig("/opt/ibxd", "encfs_restart\n"); + bool exitStatus; + ui->activityWidget->setCurrentIndex(3); + QTimer * t = new QTimer(this); + t->setInterval(1000); + connect(t, &QTimer::timeout, [&]() { + if(QFile::exists("/external_root/run/encfs_repack_status")) { + exitStatus = checkconfig("/external_root/run/encfs_repack_status"); + QFile::remove("/external_root/run/encfs_repack_status"); + setupExitWidget(exitStatus); + } + } ); + t->start(); + } +} diff --git a/encryptionmanager.h b/encryptionmanager.h index 6e53298..073aca8 100644 --- a/encryptionmanager.h +++ b/encryptionmanager.h @@ -39,6 +39,7 @@ private slots: void setupFailedAuthenticationMessageBox(); void on_acceptBtn_clicked(); void on_usbmsBtn_clicked(); + void repackEncryptedStorage(); private: Ui::encryptionManager *ui; diff --git a/functions.h b/functions.h index d9f55b2..2a68a42 100644 --- a/functions.h +++ b/functions.h @@ -97,6 +97,7 @@ namespace global { inline bool lockdown; inline bool enableStorageEncryptionDialog; inline bool disableStorageEncryptionDialog; + inline bool errorNoBooksInDropboxDialog; } inline QString systemInfoText; inline bool forbidOpenSearchDialog; @@ -626,6 +627,9 @@ namespace { string_writeconfig("/external_root/boot/flags/WILL_UPDATE", "true"); reboot(true); } + bool getEncFSStatus() { + return checkconfig("/run/encfs_mounted"); + } } #endif // FUNCTIONS_H diff --git a/generaldialog.cpp b/generaldialog.cpp index 25c7f24..621c8ee 100644 --- a/generaldialog.cpp +++ b/generaldialog.cpp @@ -150,6 +150,12 @@ generalDialog::generalDialog(QWidget *parent) : ui->bodyLabel->setText("This will delete all the files you have encrypted. Are you sure you want to continue?"); this->adjustSize(); } + else if(global::encfs::errorNoBooksInDropboxDialog == true) { + ui->stackedWidget->setCurrentIndex(1); + ui->headerLabel->setText("Error"); + ui->bodyLabel->setText("Please put books in the 'encfs-dropbox' folder to repack your encrypted storage."); + this->adjustSize(); + } else { // We shouldn't be there ;) ; diff --git a/settings.cpp b/settings.cpp index 154e398..4f3b60f 100644 --- a/settings.cpp +++ b/settings.cpp @@ -34,6 +34,7 @@ settings::settings(QWidget *parent) : ui->checkOtaUpdateBtn->setProperty("type", "borderless"); ui->previousBtn->setProperty("type", "borderless"); ui->nextBtn->setProperty("type", "borderless"); + ui->repackBtn->setProperty("type", "borderless"); ui->aboutBtn->setStyleSheet("font-size: 9pt"); ui->requestLeaseBtn->setStyleSheet("font-size: 9pt"); ui->usbmsBtn->setStyleSheet("font-size: 9pt"); @@ -44,6 +45,7 @@ settings::settings(QWidget *parent) : ui->comboBox->setStyleSheet("font-size: 9pt"); ui->sleepTimeoutComboBox->setStyleSheet("font-size: 9pt"); ui->setPasscodeBtn->setStyleSheet("font-size: 9pt"); + ui->repackBtn->setStyleSheet("font-size: 9pt"); ui->previousBtn->setText(""); ui->previousBtn->setIcon(QIcon(":/resources/chevron-left.png")); @@ -292,6 +294,10 @@ settings::settings(QWidget *parent) : // Next interaction will be by the user enableEncryptedStorageUserChange = true; } + if(getEncFSStatus() == true) { + ui->repackLabel->hide(); + ui->repackBtn->hide(); + } // DPI checkbox string_checkconfig(".config/09-dpi/config"); @@ -934,3 +940,18 @@ void settings::cancelDisableStorageEncryption() { enableEncryptedStorageUserChange = false; ui->enableEncryptedStorageCheckBox->click(); } + +void settings::on_repackBtn_clicked() +{ + QDir dir("/data/onboard/encfs-dropbox"); + if(dir.isEmpty()) { + global::encfs::errorNoBooksInDropboxDialog = true; + generalDialogWindow = new generalDialog(this); + generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose); + generalDialogWindow->show(); + } + else { + string_writeconfig("/external_root/run/encfs_repack", "true"); + } +} + diff --git a/settings.h b/settings.h index d039b69..d426fbd 100644 --- a/settings.h +++ b/settings.h @@ -67,6 +67,7 @@ private slots: void on_enableEncryptedStorageCheckBox_toggled(bool checked); void disableStorageEncryption(); void cancelDisableStorageEncryption(); + void on_repackBtn_clicked(); signals: void showToast(QString messageToDisplay); diff --git a/settings.ui b/settings.ui index a092f25..6591f8d 100644 --- a/settings.ui +++ b/settings.ui @@ -526,8 +526,34 @@ - - + + + + + Chivo + true + + + + System + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + QFrame::Plain @@ -536,8 +562,8 @@ - - + + Chivo @@ -545,61 +571,17 @@ - Storage encryption + Security - - - - Enable UI scaling + + + + QFrame::Plain - - - - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - - - - Set - - - - - - - Set a passcode - - - - - - - - - Enable night mode + + Qt::Horizontal @@ -646,6 +628,169 @@ + + + + Enable UI scaling + + + + + + + 0 + + + + + Check for updates + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + + + + Check + + + + + + + + + QFrame::Plain + + + Qt::Horizontal + + + + + + + Enable night mode + + + + + + + 0 + + + + + + 75 + true + + + + 1 + + + + + + + 0 + + + 2 + + + 1 + + + 1 + + + 0 + + + Qt::Horizontal + + + + + + + UI scaling factor + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + + + + Set + + + + + + + Set a passcode + + + + + + + + + 0 + + + @@ -686,33 +831,10 @@ - - - - 0 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - QFrame::Plain - - - Qt::Horizontal + + + + Enable lock screen and passcode @@ -785,53 +907,23 @@ - - - - 0 + + + + + Chivo + true + - - - - Check for updates - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - - - - Check - - - - + + Storage encryption + + - - - - QFrame::Plain - - - Qt::Horizontal + + + + Enable @@ -878,39 +970,33 @@ - - - - - Chivo - true - - - - System - - - - - - - - Chivo - true - - - - Security - - - - - + + 0 - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Repack + + + + + 75 @@ -918,58 +1004,12 @@ - 1 - - - - - - - 0 - - - 2 - - - 1 - - - 1 - - - 0 - - - Qt::Horizontal - - - - - - - UI scaling factor - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Repack - - - - Enable - - - - - - - Enable lock screen and passcode - - -