summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-08-12 11:08:02 +0200
committerDavid Lönnhager <david.l@mullvad.net>2020-08-13 13:34:43 +0200
commit1a293e8167561105d3ef0194f180e72fa367caea (patch)
tree3dd475ef87e1b9f9c551f7882713b4536a41c24e
parent8425b66001f7f09e6666942a5a2ef848f95a122c (diff)
downloadmullvadvpn-1a293e8167561105d3ef0194f180e72fa367caea.tar.xz
mullvadvpn-1a293e8167561105d3ef0194f180e72fa367caea.zip
Skip migration if settings path is overridden
-rw-r--r--Cargo.lock1
-rw-r--r--mullvad-daemon/Cargo.toml1
-rw-r--r--mullvad-daemon/src/settings.rs8
3 files changed, 10 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 2897fa5ecb..dc75be1503 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1386,6 +1386,7 @@ dependencies = [
"chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"duct 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
"err-derive 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"fern 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml
index 0ebffd12ea..a33f808ec2 100644
--- a/mullvad-daemon/Cargo.toml
+++ b/mullvad-daemon/Cargo.toml
@@ -56,6 +56,7 @@ ctrlc = "3.0"
duct = "0.13"
windows-service = "0.3"
winapi = { version = "0.3", features = ["errhandlingapi", "handleapi", "libloaderapi", "ntlsa", "synchapi", "tlhelp32", "winbase", "winerror", "winuser"] }
+dirs = "2.0"
[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs
index afa90cfce8..5c20938ef4 100644
--- a/mullvad-daemon/src/settings.rs
+++ b/mullvad-daemon/src/settings.rs
@@ -293,6 +293,9 @@ mod windows {
#[error(display = "Unable to find settings directory")]
FindSettings(#[error(source)] mullvad_paths::Error),
+ #[error(display = "Unable to find local appdata directory")]
+ FindAppData,
+
#[error(display = "Migration was aborted to avoid overwriting current settings")]
SettingsExist,
@@ -310,6 +313,11 @@ mod windows {
let destination_settings_dir =
mullvad_paths::settings_dir().map_err(Error::FindSettings)?;
+ let system_appdata_dir = dirs::data_local_dir().ok_or(Error::FindAppData)?;
+ if !destination_settings_dir.starts_with(system_appdata_dir) {
+ return Err(Error::NothingToMigrate);
+ }
+
let settings_path = destination_settings_dir.join(super::SETTINGS_FILE);
if settings_path.exists() {
return Err(Error::SettingsExist);