EncFS repack testing

This commit is contained in:
Nicolas Mailloux 2021-11-14 21:22:58 -05:00
parent 6e095df5cb
commit 0bd233919c
7 changed files with 310 additions and 206 deletions

View file

@ -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();
}
}

View file

@ -39,6 +39,7 @@ private slots:
void setupFailedAuthenticationMessageBox();
void on_acceptBtn_clicked();
void on_usbmsBtn_clicked();
void repackEncryptedStorage();
private:
Ui::encryptionManager *ui;

View file

@ -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

View file

@ -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 ;)
;

View file

@ -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");
}
}

View file

@ -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);

View file

@ -526,8 +526,34 @@
</property>
<item>
<layout class="QGridLayout" name="gridLayout_10">
<item row="19" column="0">
<widget class="Line" name="line_2">
<item row="6" column="0">
<widget class="QLabel" name="softwareLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>System</string>
</property>
</widget>
</item>
<item row="28" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="23" column="0">
<widget class="Line" name="line_10">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
@ -536,8 +562,8 @@
</property>
</widget>
</item>
<item row="22" column="0">
<widget class="QLabel" name="storageEncryptionLabel">
<item row="18" column="0">
<widget class="QLabel" name="securityLabel">
<property name="font">
<font>
<family>Chivo</family>
@ -545,61 +571,17 @@
</font>
</property>
<property name="text">
<string>Storage encryption</string>
<string>Security</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="enableUiScalingCheckBox">
<property name="text">
<string>Enable UI scaling</string>
<item row="19" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
<item row="21" column="0">
<layout class="QGridLayout" name="gridLayout_13">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="setPasscodeBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Set</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="setPasscodeLabel">
<property name="text">
<string>Set a passcode</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="darkModeCheckBox">
<property name="text">
<string>Enable night mode</string>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@ -646,6 +628,169 @@
</item>
</layout>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="enableUiScalingCheckBox">
<property name="text">
<string>Enable UI scaling</string>
</property>
</widget>
</item>
<item row="14" column="0">
<layout class="QGridLayout" name="checkOtaUpdateGridLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="checkOtaUpdateLabel">
<property name="text">
<string>Check for updates</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="checkOtaUpdateBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Check</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<widget class="Line" name="line_9">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="darkModeCheckBox">
<property name="text">
<string>Enable night mode</string>
</property>
</widget>
</item>
<item row="9" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QLabel" name="uiScaleNumberLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="uiScalingSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="uiScalingLabel">
<property name="text">
<string>UI scaling factor</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="21" column="0">
<layout class="QGridLayout" name="gridLayout_13">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="setPasscodeBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Set</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="setPasscodeLabel">
<property name="text">
<string>Set a passcode</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="27" column="0">
<layout class="QGridLayout" name="gridLayout_18">
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</item>
<item row="12" column="0">
<layout class="QGridLayout" name="gridLayout_12">
<property name="bottomMargin">
@ -686,33 +831,10 @@
</item>
</layout>
</item>
<item row="25" column="0">
<layout class="QGridLayout" name="gridLayout_18">
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</item>
<item row="26" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="23" column="0">
<widget class="Line" name="line_10">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="20" column="0">
<widget class="QCheckBox" name="enableLockscreenCheckBox">
<property name="text">
<string>Enable lock screen and passcode</string>
</property>
</widget>
</item>
@ -785,53 +907,23 @@
</item>
</layout>
</item>
<item row="14" column="0">
<layout class="QGridLayout" name="checkOtaUpdateGridLayout">
<property name="bottomMargin">
<number>0</number>
<item row="22" column="0">
<widget class="QLabel" name="storageEncryptionLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<item row="0" column="0">
<widget class="QLabel" name="checkOtaUpdateLabel">
<property name="text">
<string>Check for updates</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="checkOtaUpdateBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Check</string>
</property>
</widget>
</item>
</layout>
<property name="text">
<string>Storage encryption</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="Line" name="line_9">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="24" column="0">
<widget class="QCheckBox" name="enableEncryptedStorageCheckBox">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
@ -878,39 +970,33 @@
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="softwareLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>System</string>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="securityLabel">
<property name="font">
<font>
<family>Chivo</family>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Security</string>
</property>
</widget>
</item>
<item row="9" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="25" column="0">
<layout class="QGridLayout" name="gridLayout_17">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QLabel" name="uiScaleNumberLabel">
<item row="0" column="1">
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="repackLabel">
<property name="text">
<string>Repack</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="repackBtn">
<property name="font">
<font>
<weight>75</weight>
@ -918,58 +1004,12 @@
</font>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="uiScalingSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="uiScalingLabel">
<property name="text">
<string>UI scaling factor</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<string>Repack</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="24" column="0">
<widget class="QCheckBox" name="enableEncryptedStorageCheckBox">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="20" column="0">
<widget class="QCheckBox" name="enableLockscreenCheckBox">
<property name="text">
<string>Enable lock screen and passcode</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>