summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2020-08-26 16:07:14 +0200
committerLinus Färnstrand <linus@mullvad.net>2020-08-26 16:35:24 +0200
commit447902b897e4545efa65f226c52f81172d23d8d8 (patch)
tree657bdd1cbc1f627062df9b5981e52dd560a58638
parent5091f3e4e8483c80fc9bac235eb7a3536df720c1 (diff)
downloadmullvadvpn-447902b897e4545efa65f226c52f81172d23d8d8.tar.xz
mullvadvpn-447902b897e4545efa65f226c52f81172d23d8d8.zip
Run mullvad-setup prepare-restart in preinstall script instead of postinstall
Fixes a leak during upgrade due to mullvad-setup no longer being compatible with old daemon
-rwxr-xr-xdist-assets/pkg-scripts/postinstall2
-rwxr-xr-xdist-assets/pkg-scripts/preinstall11
2 files changed, 10 insertions, 3 deletions
diff --git a/dist-assets/pkg-scripts/postinstall b/dist-assets/pkg-scripts/postinstall
index 40de4cee50..1d8e2956b4 100755
--- a/dist-assets/pkg-scripts/postinstall
+++ b/dist-assets/pkg-scripts/postinstall
@@ -51,8 +51,6 @@ EOM
ZSH_COMPLETIONS_DIR="/usr/local/share/zsh/site-functions/"
FISH_COMPLETIONS_DIR="/usr/local/share/fish/vendor_completions.d/"
-"$INSTALL_DIR/Mullvad VPN.app/Contents/Resources/mullvad-setup" prepare-restart || true
-
pkill -x "Mullvad VPN" || echo "Unable to kill GUI, not running?"
sleep 1
diff --git a/dist-assets/pkg-scripts/preinstall b/dist-assets/pkg-scripts/preinstall
index c07fa0e15d..e03ca867a8 100755
--- a/dist-assets/pkg-scripts/preinstall
+++ b/dist-assets/pkg-scripts/preinstall
@@ -3,6 +3,7 @@
set -eux
LOG_DIR=/var/log/mullvad-vpn
+INSTALL_DIR=$2
mkdir -p $LOG_DIR
chmod 755 $LOG_DIR
@@ -76,4 +77,12 @@ if [ -d "$OLD_CACHE_DIR" ]; then
rm -rf "$OLD_CACHE_DIR"
fi
-rm -f "$NEW_CACHE_DIR/relays.json" || true
+# Remove the existing relay list.
+# There is a risk that it's incompatible with the format this version wants
+rm "$NEW_CACHE_DIR/relays.json" || 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
+# leaks during the upgrade.
+"$INSTALL_DIR/Mullvad VPN.app/Contents/Resources/mullvad-setup" prepare-restart || \
+ echo "Failed to send 'prepare-restart' command to old mullvad-daemon"