diff options
| -rw-r--r-- | android/build.gradle | 1 | ||||
| -rw-r--r-- | dist-assets/linux/before-install.sh | 1 | ||||
| -rwxr-xr-x | dist-assets/pkg-scripts/preinstall | 5 | ||||
| -rw-r--r-- | dist-assets/windows/installer.nsh | 35 | ||||
| -rw-r--r-- | gui/tasks/distribution.js | 1 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/cleanup/cleaningops.cpp | 14 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/cleanup/cleaningops.h | 1 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/cleanup/cleanup.cpp | 31 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/cleanup/cleanup.def | 1 |
9 files changed, 88 insertions, 2 deletions
diff --git a/android/build.gradle b/android/build.gradle index e9307b1df6..9bfb4d23c3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -108,5 +108,6 @@ buildscript { task copyExtraAssets(type: Copy) { from "$repoRootPath/dist-assets" include "relays.json" + include "api-ip-address.txt" into extraAssetsDirectory } diff --git a/dist-assets/linux/before-install.sh b/dist-assets/linux/before-install.sh index fc27f787ae..d3f53a1f40 100644 --- a/dist-assets/linux/before-install.sh +++ b/dist-assets/linux/before-install.sh @@ -12,3 +12,4 @@ fi pkill -x "mullvad-gui" || true rm -f /var/cache/mullvad-vpn/relays.json +rm -f /var/cache/mullvad-vpn/api-ip-address.txt diff --git a/dist-assets/pkg-scripts/preinstall b/dist-assets/pkg-scripts/preinstall index e03ca867a8..5b56185a58 100755 --- a/dist-assets/pkg-scripts/preinstall +++ b/dist-assets/pkg-scripts/preinstall @@ -77,9 +77,10 @@ if [ -d "$OLD_CACHE_DIR" ]; then rm -rf "$OLD_CACHE_DIR" fi -# Remove the existing relay list. -# There is a risk that it's incompatible with the format this version wants +# Remove the existing relay and API address cache lists. +# There is a risk that they're incompatible with the format this version wants rm "$NEW_CACHE_DIR/relays.json" || true +rm "$NEW_CACHE_DIR/api-ip-address.txt" || true # Notify the running daemon that we are going to kill it and replace it with a newer version. # This will make the daemon save it's state to a file and then lock the firewall to prevent diff --git a/dist-assets/windows/installer.nsh b/dist-assets/windows/installer.nsh index a8925cd039..93f62f9703 100644 --- a/dist-assets/windows/installer.nsh +++ b/dist-assets/windows/installer.nsh @@ -510,6 +510,40 @@ !define RemoveRelayCache '!insertmacro "RemoveRelayCache"' # +# RemoveApiAddressCache +# +# Call into helper DLL instructing it to remove all API address cache. +# Currently, errors are only logged and not propagated. +# +!macro RemoveApiAddressCache + + log::Log "RemoveApiAddressCache()" + + Push $0 + Push $1 + + cleanup::RemoveApiAddressCache + + Pop $0 + Pop $1 + + ${If} $0 != ${MULLVAD_SUCCESS} + log::Log "Failed to remove address cache: $1" + Goto RemoveApiAddressCache_return + ${EndIf} + + log::Log "RemoveApiAddressCache() completed successfully" + + RemoveApiAddressCache_return: + + Pop $1 + Pop $0 + +!macroend + +!define RemoveApiAddressCache '!insertmacro "RemoveApiAddressCache"' + +# # AddCLIToEnvironPath # # Add "$INSTDIR\resources" to system env PATH, @@ -703,6 +737,7 @@ RMDir /r "$LOCALAPPDATA\mullvad-vpn-updater" ${RemoveRelayCache} + ${RemoveApiAddressCache} ${ExtractTapDriver} ${InstallTapDriver} diff --git a/gui/tasks/distribution.js b/gui/tasks/distribution.js index 56fe2d4318..0623c0b660 100644 --- a/gui/tasks/distribution.js +++ b/gui/tasks/distribution.js @@ -23,6 +23,7 @@ const config = { extraResources: [ { from: distAssets('ca.crt'), to: '.' }, { from: distAssets('relays.json'), to: '.' }, + { from: distAssets('api-ip-address.txt'), to: '.' }, { from: root('CHANGELOG.md'), to: '.' }, ], diff --git a/windows/nsis-plugins/src/cleanup/cleaningops.cpp b/windows/nsis-plugins/src/cleanup/cleaningops.cpp index 8653bb50a9..475c78d8b7 100644 --- a/windows/nsis-plugins/src/cleanup/cleaningops.cpp +++ b/windows/nsis-plugins/src/cleanup/cleaningops.cpp @@ -331,4 +331,18 @@ void RemoveRelayCacheServiceUser() std::filesystem::remove(cacheFile); } +void RemoveApiAddressCacheServiceUser() +{ + const auto localAppData = GetSystemUserLocalAppData(); + const auto mullvadAppData = std::filesystem::path(localAppData).append(L"Mullvad VPN"); + + common::fs::ScopedNativeFileSystem nativeFileSystem; + + common::security::AddAdminToObjectDacl(mullvadAppData, SE_FILE_OBJECT); + + const auto cacheFile = std::filesystem::path(mullvadAppData).append(L"api-ip-address.txt"); + + std::filesystem::remove(cacheFile); +} + } diff --git a/windows/nsis-plugins/src/cleanup/cleaningops.h b/windows/nsis-plugins/src/cleanup/cleaningops.h index 40ce97e81e..057eb305b8 100644 --- a/windows/nsis-plugins/src/cleanup/cleaningops.h +++ b/windows/nsis-plugins/src/cleanup/cleaningops.h @@ -12,5 +12,6 @@ void RemoveSettingsServiceUser(); // Remove only the relay cache, leaving other cache files untouched. // This is useful when updating the app. void RemoveRelayCacheServiceUser(); +void RemoveApiAddressCacheServiceUser(); } diff --git a/windows/nsis-plugins/src/cleanup/cleanup.cpp b/windows/nsis-plugins/src/cleanup/cleanup.cpp index faef07c2f0..528efb2f7a 100644 --- a/windows/nsis-plugins/src/cleanup/cleanup.cpp +++ b/windows/nsis-plugins/src/cleanup/cleanup.cpp @@ -100,3 +100,34 @@ void __declspec(dllexport) NSISCALL RemoveRelayCache pushint(NsisStatus::GENERAL_ERROR); } } + +void __declspec(dllexport) NSISCALL RemoveApiAddressCache +( + HWND hwndParent, + int string_size, + LPTSTR variables, + stack_t **stacktop, + extra_parameters *extra, + ... +) +{ + EXDLL_INIT(); + + try + { + cleaningops::RemoveApiAddressCacheServiceUser(); + + pushstring(L""); + pushint(NsisStatus::SUCCESS); + } + catch (const std::exception &err) + { + pushstring(common::string::ToWide(err.what()).c_str()); + pushint(NsisStatus::GENERAL_ERROR); + } + catch (...) + { + pushstring(L"Unspecified error"); + pushint(NsisStatus::GENERAL_ERROR); + } +} diff --git a/windows/nsis-plugins/src/cleanup/cleanup.def b/windows/nsis-plugins/src/cleanup/cleanup.def index 8752772b8d..779e620691 100644 --- a/windows/nsis-plugins/src/cleanup/cleanup.def +++ b/windows/nsis-plugins/src/cleanup/cleanup.def @@ -5,3 +5,4 @@ EXPORTS RemoveLogsAndCache RemoveSettings RemoveRelayCache +RemoveApiAddressCache |
