From b744778bd52379e50c30afd66f666fa6c98d09d0 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Tue, 27 Sep 2022 07:05:09 -0400 Subject: [PATCH] Boot flags: Write newlines This is to prepare for the new init binary, which is less tolerant than ash. --- src/encfs/encryptionmanager.cpp | 2 +- src/functions.h | 6 +++--- src/settings/koboxsettings.cpp | 4 ++-- src/settings/settings.cpp | 6 +++--- src/splash/alert.cpp | 20 ++++++++++---------- src/widgets/dialogs/generaldialog.cpp | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/encfs/encryptionmanager.cpp b/src/encfs/encryptionmanager.cpp index 7493770..6e615bd 100644 --- a/src/encfs/encryptionmanager.cpp +++ b/src/encfs/encryptionmanager.cpp @@ -261,7 +261,7 @@ void encryptionManager::unlockEncryptedStorage() { std::string unlockTime_str = to_string(currentEpoch); global::encfs::unlockTime = QDateTime::fromTime_t(currentEpoch).toString(); global::encfs::lockdownMessage = "FATAL: 4 invalid passphrase tries, locking down device until " + global::encfs::unlockTime; - string_writeconfig("/external_root/boot/flags/ENCRYPT_LOCK", unlockTime_str); + writeFile("/external_root/boot/flags/ENCRYPT_LOCK", unlockTime_str + "\n"); global::encfs::lockdown = true; setupMessageBoxRan = true; diff --git a/src/functions.h b/src/functions.h index 4c52d51..ab5327f 100644 --- a/src/functions.h +++ b/src/functions.h @@ -826,9 +826,9 @@ namespace { } void installUpdate() { log("Installing update package", "functions"); - string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "true"); - string_writeconfig("/external_root/opt/update/will_update", "true"); - string_writeconfig("/external_root/boot/flags/WILL_UPDATE", "true"); + writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "true\n"); + writeFile("/external_root/opt/update/will_update", "true\n"); + writeFile("/external_root/boot/flags/WILL_UPDATE", "true\n"); reboot(true); } bool getEncFSStatus() { diff --git a/src/settings/koboxsettings.cpp b/src/settings/koboxsettings.cpp index 1a9e45e..12ba9ef 100644 --- a/src/settings/koboxsettings.cpp +++ b/src/settings/koboxsettings.cpp @@ -81,7 +81,7 @@ void koboxSettings::on_checkBox_toggled(bool checked) if(checked == true) { if(not_user_change != true) { log("Enabling KoBox subsystem", className); - string_writeconfig("/external_root/boot/flags/X11_START", "true"); + writeFile("/external_root/boot/flags/X11_START", "true\n"); openSettingsRebootDialog(); } else { @@ -90,7 +90,7 @@ void koboxSettings::on_checkBox_toggled(bool checked) } else { log("Disabling KoBox subsystem", className); - string_writeconfig("/external_root/boot/flags/X11_START", "false"); + writeFile("/external_root/boot/flags/X11_START", "false\n"); openSettingsRebootDialog(); } } diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index d99f1b7..fd6ff55 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -586,9 +586,9 @@ void settings::on_nextBtn_clicked() void settings::on_updateBtn_clicked() { log("'Update' button clicked", className); - string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "true"); - string_writeconfig("/external_root/opt/update/will_update", "true"); - string_writeconfig("/external_root/boot/flags/WILL_UPDATE", "true"); + writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "true\n"); + writeFile("/external_root/opt/update/will_update", "true\n"); + writeFile("/external_root/boot/flags/WILL_UPDATE", "true\n"); QString prog ("/sbin/reboot"); QStringList args; QProcess *proc = new QProcess(); diff --git a/src/splash/alert.cpp b/src/splash/alert.cpp index c5ca678..f4de2ce 100644 --- a/src/splash/alert.cpp +++ b/src/splash/alert.cpp @@ -113,8 +113,8 @@ alert::~alert() void alert::on_continueBtn_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"); + writeFile("/external_root/boot/flags/ALERT", "false\n"); + writeFile("/external_root/boot/flags/ALERT_SIGN", "false\n"); updateReset(); QProcess process; process.startDetached("inkbox", QStringList()); @@ -123,10 +123,10 @@ void alert::on_continueBtn_clicked() void alert::on_resetBtn_clicked() { - // We set the DO_FACTORY_RESET flag and we restart the Kobo + // We set the DO_FACTORY_RESET flag and we restart the device log("Factory reset requested; setting required flags", className); - string_writeconfig("/external_root/boot/flags/DO_FACTORY_RESET", "true"); - string_writeconfig("/external_root/boot/flags/DIAGS_BOOT", "true"); + writeFile("/external_root/boot/flags/DO_FACTORY_RESET", "true\n"); + writeFile("/external_root/boot/flags/DIAGS_BOOT", "true\n"); QString reboot_prog ("/sbin/reboot"); QStringList reboot_args; reboot_args << "no_splash"; @@ -139,18 +139,18 @@ void alert::on_resetBtn_clicked() void alert::on_continue2Btn_clicked() { // We continue anyway and re-set the ALERT flag - string_writeconfig("/external_root/boot/flags/ALERT", "false"); + writeFile("/external_root/boot/flags/ALERT", "false\n"); updateReset(); log("Restarting InkBox", className); if(signatureError == true) { - string_writeconfig("/external_root/boot/flags/ALERT_SIGN", "false"); + writeFile("/external_root/boot/flags/ALERT_SIGN", "false\n"); QProcess process; process.startDetached("inkbox", QStringList()); qApp->quit(); } if(downgradeError == true) { - string_writeconfig("/external_root/boot/flags/ALERT_DOWNGRADE", "false"); + writeFile("/external_root/boot/flags/ALERT_DOWNGRADE", "false\n"); QProcess process; process.startDetached("inkbox", QStringList()); qApp->quit(); @@ -158,8 +158,8 @@ void alert::on_continue2Btn_clicked() } void alert::updateReset() { - string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "false"); - string_writeconfig("/mnt/onboard/onboard/.inkbox/can_update", "false"); + writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "false\n"); + writeFile("/mnt/onboard/onboard/.inkbox/can_update", "false\n"); } void alert::quit() { diff --git a/src/widgets/dialogs/generaldialog.cpp b/src/widgets/dialogs/generaldialog.cpp index c3d0db0..ec527d5 100644 --- a/src/widgets/dialogs/generaldialog.cpp +++ b/src/widgets/dialogs/generaldialog.cpp @@ -292,8 +292,8 @@ void generalDialog::on_okBtn_clicked() // Soft-reset the device // We set a custom boot flag and reboot silently in Diagnostics log("Setting up the device for soft-reset", className); - string_writeconfig("/external_root/boot/flags/DIAGS_BOOT", "true"); - string_writeconfig("/external_root/boot/flags/DO_SOFT_RESET", "true"); + writeFile("/external_root/boot/flags/DIAGS_BOOT", "true\n"); + writeFile("/external_root/boot/flags/DO_SOFT_RESET", "true\n"); reboot(false); qApp->quit(); }