summaryrefslogtreecommitdiffhomepage
path: root/windows
diff options
context:
space:
mode:
authorEmīls Piņķis <emils@mullvad.net>2019-06-11 21:07:48 +0100
committerEmīls Piņķis <emils@mullvad.net>2019-06-11 21:07:48 +0100
commitd4a6e0b411b72f9e14eb6caee6c91dd31b612acf (patch)
tree750fc0eca4e50b85df82491ee129dc59e0596c20 /windows
parent63ebe7ac2f4602bcd1cf9439c6ba5fe177ef028e (diff)
parent3f1a27e0581d54ec20ae40ee5ce9296626f6c578 (diff)
downloadmullvadvpn-d4a6e0b411b72f9e14eb6caee6c91dd31b612acf.tar.xz
mullvadvpn-d4a6e0b411b72f9e14eb6caee6c91dd31b612acf.zip
Merge branch 'installer-remove-relay-list'
Diffstat (limited to 'windows')
-rw-r--r--windows/nsis-plugins/src/cleanup/cleaningops.cpp14
-rw-r--r--windows/nsis-plugins/src/cleanup/cleaningops.h5
-rw-r--r--windows/nsis-plugins/src/cleanup/cleanup.cpp38
-rw-r--r--windows/nsis-plugins/src/cleanup/cleanup.def1
4 files changed, 57 insertions, 1 deletions
diff --git a/windows/nsis-plugins/src/cleanup/cleaningops.cpp b/windows/nsis-plugins/src/cleanup/cleaningops.cpp
index 3a0764d91c..dec5ec198f 100644
--- a/windows/nsis-plugins/src/cleanup/cleaningops.cpp
+++ b/windows/nsis-plugins/src/cleanup/cleaningops.cpp
@@ -272,4 +272,18 @@ void RemoveSettingsServiceUser()
RemoveDirectoryW(std::wstring(L"\\\\?\\").append(mullvadAppData).c_str());
}
+void RemoveRelayCacheServiceUser()
+{
+ const auto localAppData = GetSystemUserLocalAppData();
+ const auto mullvadAppData = std::experimental::filesystem::path(localAppData).append(L"Mullvad VPN");
+
+ common::fs::ScopedNativeFileSystem nativeFileSystem;
+
+ common::security::AddAdminToObjectDacl(mullvadAppData, SE_FILE_OBJECT);
+
+ const auto cacheFile = std::experimental::filesystem::path(mullvadAppData).append(L"relays.json");
+
+ std::experimental::filesystem::remove(cacheFile);
+}
+
}
diff --git a/windows/nsis-plugins/src/cleanup/cleaningops.h b/windows/nsis-plugins/src/cleanup/cleaningops.h
index 219d4333de..40ce97e81e 100644
--- a/windows/nsis-plugins/src/cleanup/cleaningops.h
+++ b/windows/nsis-plugins/src/cleanup/cleaningops.h
@@ -7,7 +7,10 @@ void RemoveLogsCacheCurrentUser();
void RemoveLogsCacheOtherUsers();
void RemoveLogsServiceUser();
void RemoveCacheServiceUser();
-
void RemoveSettingsServiceUser();
+// Remove only the relay cache, leaving other cache files untouched.
+// This is useful when updating the app.
+void RemoveRelayCacheServiceUser();
+
}
diff --git a/windows/nsis-plugins/src/cleanup/cleanup.cpp b/windows/nsis-plugins/src/cleanup/cleanup.cpp
index c7890d60b7..ea8d59ac79 100644
--- a/windows/nsis-plugins/src/cleanup/cleanup.cpp
+++ b/windows/nsis-plugins/src/cleanup/cleanup.cpp
@@ -1,5 +1,6 @@
#include <stdafx.h>
#include "cleaningops.h"
+#include <libcommon/string.h>
#include <windows.h>
#include <nsis/pluginapi.h>
#include <functional>
@@ -79,3 +80,40 @@ void __declspec(dllexport) NSISCALL RemoveSettings
pushint(RemoveSettingsStatus::GENERAL_ERROR);
}
}
+
+enum class RemoveRelayCacheStatus
+{
+ GENERAL_ERROR = 0,
+ SUCCESS
+};
+
+void __declspec(dllexport) NSISCALL RemoveRelayCache
+(
+ HWND hwndParent,
+ int string_size,
+ LPTSTR variables,
+ stack_t **stacktop,
+ extra_parameters *extra,
+ ...
+)
+{
+ EXDLL_INIT();
+
+ try
+ {
+ cleaningops::RemoveRelayCacheServiceUser();
+
+ pushstring(L"");
+ pushint(RemoveRelayCacheStatus::SUCCESS);
+ }
+ catch (const std::exception &err)
+ {
+ pushstring(common::string::ToWide(err.what()).c_str());
+ pushint(RemoveRelayCacheStatus::GENERAL_ERROR);
+ }
+ catch (...)
+ {
+ pushstring(L"Unspecified error");
+ pushint(RemoveRelayCacheStatus::GENERAL_ERROR);
+ }
+}
diff --git a/windows/nsis-plugins/src/cleanup/cleanup.def b/windows/nsis-plugins/src/cleanup/cleanup.def
index 590d311b7a..8752772b8d 100644
--- a/windows/nsis-plugins/src/cleanup/cleanup.def
+++ b/windows/nsis-plugins/src/cleanup/cleanup.def
@@ -4,3 +4,4 @@ EXPORTS
RemoveLogsAndCache
RemoveSettings
+RemoveRelayCache