From 5b02c77400e8551199fefdbc36b1eb3ff86374dc Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 14 Oct 2020 12:28:26 -0700 Subject: [PATCH] ams: fix updater misbehavior before 0.15.0 releases --- .../ams_mitm/source/amsmitm_initialization.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/stratosphere/ams_mitm/source/amsmitm_initialization.cpp b/stratosphere/ams_mitm/source/amsmitm_initialization.cpp index 405a43cc1..6ed3acd0b 100644 --- a/stratosphere/ams_mitm/source/amsmitm_initialization.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_initialization.cpp @@ -64,6 +64,10 @@ namespace ams::mitm { /* Emummc file protection. */ FsFile g_emummc_file; + /* Maintain exclusive access to the fusee-secondary archive. */ + FsFile g_secondary_file; + FsFile g_sept_payload_file; + constexpr inline bool IsHexadecimal(const char *str) { while (*str) { if (std::isxdigit(static_cast(*str))) { @@ -129,6 +133,15 @@ namespace ams::mitm { R_ABORT_UNLESS(fsFileWrite(&g_bis_key_file, 0, bis_keys, sizeof(bis_keys), FsWriteOption_Flush)); /* NOTE: g_bis_key_file is intentionally not closed here. This prevents any other process from opening it. */ } + + /* Open a reference to the fusee-secondary archive. */ + /* As upcoming/current atmosphere releases will contain more than one zip which users much choose between, */ + /* maintaining an open reference prevents cleanly the issue of "automatic" updaters selecting the incorrect */ + /* zip, and encourages good updating hygiene -- atmosphere should not be updated on SD while HOS is alive. */ + { + R_ABORT_UNLESS(mitm::fs::OpenSdFile(std::addressof(g_secondary_file), "/atmosphere/fusee-secondary.bin", ams::fs::OpenMode_ReadWrite)); + R_ABORT_UNLESS(mitm::fs::OpenSdFile(std::addressof(g_sept_payload_file), "/sept/payload.bin", ams::fs::OpenMode_ReadWrite)); + } } /* Initialization implementation */