diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-11-19 01:37:02 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-11-19 01:37:02 +0100 |
| commit | b72f29cd885c2e9c02b27f72cd93683aba253e8d (patch) | |
| tree | 2ae9c173dd125573d34f0d0eb1e8638110390fe5 /windows | |
| parent | e3f66f7dc55fb68efbb605b21aa66336ea653c7a (diff) | |
| parent | 2c6cd3a4797821984e1c212803890276b0ef3626 (diff) | |
| download | mullvadvpn-b72f29cd885c2e9c02b27f72cd93683aba253e8d.tar.xz mullvadvpn-b72f29cd885c2e9c02b27f72cd93683aba253e8d.zip | |
Merge branch 'update-api-ip-cache'
Diffstat (limited to 'windows')
| -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 |
4 files changed, 47 insertions, 0 deletions
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 |
