diff options
| author | Odd Stranne <odd@mullvad.net> | 2020-12-09 11:47:49 +0100 |
|---|---|---|
| committer | Odd Stranne <odd@mullvad.net> | 2021-07-02 16:31:31 +0200 |
| commit | 79f52b5adc0d965e1688bb1253a6c782bf74f03f (patch) | |
| tree | cf25f0170db48d6b227e0b8bf644ac580a937831 | |
| parent | 9f7e03cff7606e66fc5de321964f3b5b54377a27 (diff) | |
| download | mullvadvpn-79f52b5adc0d965e1688bb1253a6c782bf74f03f.tar.xz mullvadvpn-79f52b5adc0d965e1688bb1253a6c782bf74f03f.zip | |
Update installer/uninstaller to manage split tunneling driver
| -rw-r--r-- | dist-assets/windows/installer.nsh | 196 |
1 files changed, 194 insertions, 2 deletions
diff --git a/dist-assets/windows/installer.nsh b/dist-assets/windows/installer.nsh index 8e2c85ac8f..8ed028c461 100644 --- a/dist-assets/windows/installer.nsh +++ b/dist-assets/windows/installer.nsh @@ -28,9 +28,12 @@ !define PATCH_MISSING 2 # Return codes from driverlogic -!define DL_ADAPTER_NOT_FOUND -2 -!define DL_GENERAL_ERROR -1 !define DL_GENERAL_SUCCESS 0 +!define DL_GENERAL_ERROR 1 +!define DL_ST_DRIVER_NONE_INSTALLED 2 +!define DL_ST_DRIVER_SAME_VERSION_INSTALLED 3 +!define DL_ST_DRIVER_OLDER_VERSION_INSTALLED 4 +!define DL_ST_DRIVER_NEWER_VERSION_INSTALLED 5 # Log targets !define LOG_INSTALL 0 @@ -162,6 +165,28 @@ !define InstallWin7Hotfix '!insertmacro "InstallWin7Hotfix"' # +# ExtractSplitTunnelDriver +# +# Extract split tunnel driver and associated files into $TEMP\mullvad-split-tunnel +# +!macro ExtractSplitTunnelDriver + + SetOutPath "$TEMP\mullvad-split-tunnel" + + ${If} ${AtLeastWin10} + File "${BUILD_RESOURCES_DIR}\binaries\x86_64-pc-windows-msvc\split-tunnel\win10\*" + ${Else} + File "${BUILD_RESOURCES_DIR}\binaries\x86_64-pc-windows-msvc\split-tunnel\legacy\*" + File "${BUILD_RESOURCES_DIR}\binaries\x86_64-pc-windows-msvc\split-tunnel\meta\mullvad-ev.cer" + ${EndIf} + + File "${BUILD_RESOURCES_DIR}\..\windows\driverlogic\bin\x64-Release\driverlogic.exe" + +!macroend + +!define ExtractSplitTunnelDriver '!insertmacro "ExtractSplitTunnelDriver"' + +# # RemoveWintun # # Try to remove Wintun @@ -295,6 +320,162 @@ !define InstallService '!insertmacro "InstallService"' # +# InstallSplitTunnelDriverCert +# +# Install driver certificate in trusted publishers store +# +!macro InstallSplitTunnelDriverCert + + ${IfNot} ${AtLeastWin10} + log::Log "Adding Split Tunnel driver certificate to certificate store" + + nsExec::ExecToStack '"$SYSDIR\certutil.exe" -f -addstore TrustedPublisher "$TEMP\mullvad-split-tunnel\mullvad-ev.cer"' + Pop $0 + Pop $1 + + ${If} $0 != 0 + StrCpy $R0 "Failed to add trusted publisher certificate: error $0" + log::LogWithDetails $R0 $1 + ${EndIf} + ${EndIf} + +!macroend + +!define InstallSplitTunnelDriverCert '!insertmacro "InstallSplitTunnelDriverCert"' + +# +# InstallSplitTunnelDriver +# +# Install split tunnel driver +# +# Returns: 0 in $R0 on success, otherwise an error message in $R0 +# +!macro InstallSplitTunnelDriver + + log::Log "InstallSplitTunnelDriver()" + + Push $0 + Push $1 + + log::Log "Searching for and evaluating already installed Split Tunneling driver" + nsExec::ExecToStack '"$TEMP\mullvad-split-tunnel\driverlogic.exe" st-evaluate "$TEMP\mullvad-split-tunnel\mullvad-split-tunnel.inf"' + + Pop $0 + Pop $1 + + ${If} $0 == ${DL_ST_DRIVER_NONE_INSTALLED} + log::Log "No currently installed Split Tunneling driver" + Goto InstallSplitTunnelDriver_new_install + ${OrIf} $0 == ${DL_ST_DRIVER_SAME_VERSION_INSTALLED} + log::Log "Up-to-date Split Tunneling driver already installed" + Goto InstallSplitTunnelDriver_success + ${OrIf} $0 == ${DL_ST_DRIVER_OLDER_VERSION_INSTALLED} + log::Log "An older version of the Split Tunneling driver is installed" + Goto InstallSplitTunnelDriver_force_install + ${OrIf} $0 == ${DL_ST_DRIVER_NEWER_VERSION_INSTALLED} + log::Log "A newer version of the Split Tunneling driver is installed" + Goto InstallSplitTunnelDriver_force_install + ${Else} + IntFmt $0 "0x%X" $0 + StrCpy $R0 "Failed to search for and evaluate driver: error $0" + log::LogWithDetails $R0 $1 + Goto InstallSplitTunnelDriver_return + ${EndIf} + + InstallSplitTunnelDriver_new_install: + + ${InstallSplitTunnelDriverCert} + + log::Log "Installing Split Tunneling driver" + nsExec::ExecToStack '"$TEMP\mullvad-split-tunnel\driverlogic.exe" st-new-install "$TEMP\mullvad-split-tunnel\mullvad-split-tunnel.inf"' + + Pop $0 + Pop $1 + + ${If} $0 != ${DL_GENERAL_SUCCESS} + IntFmt $0 "0x%X" $0 + StrCpy $R0 "Failed to install driver: error $0" + log::LogWithDetails $R0 $1 + Goto InstallSplitTunnelDriver_return + ${EndIf} + + Goto InstallSplitTunnelDriver_success + + InstallSplitTunnelDriver_force_install: + + # + # Would be possible to check driver state here and warn the user if driver is engaged. + # + + log::Log "Installing Split Tunneling driver" + nsExec::ExecToStack '"$TEMP\mullvad-split-tunnel\driverlogic.exe" st-force-install "$TEMP\mullvad-split-tunnel\mullvad-split-tunnel.inf"' + + Pop $0 + Pop $1 + + ${If} $0 != ${DL_GENERAL_SUCCESS} + IntFmt $0 "0x%X" $0 + StrCpy $R0 "Failed to install driver: error $0" + log::LogWithDetails $R0 $1 + Goto InstallSplitTunnelDriver_return + ${EndIf} + + InstallSplitTunnelDriver_success: + + log::Log "InstallSplitTunnelDriver() completed successfully" + + Push 0 + Pop $R0 + + InstallSplitTunnelDriver_return: + + Pop $1 + Pop $0 + +!macroend + +!define InstallSplitTunnelDriver '!insertmacro "InstallSplitTunnelDriver"' + +# +# RemoveSplitTunnelDriver +# +# Reset and remove split tunnel driver +# +!macro RemoveSplitTunnelDriver + + log::Log "RemoveSplitTunnelDriver()" + + Push $0 + Push $1 + + log::Log "Removing Split Tunneling driver" + nsExec::ExecToStack '"$TEMP\mullvad-split-tunnel\driverlogic.exe" st-remove' + + Pop $0 + Pop $1 + + ${If} $0 != ${DL_GENERAL_SUCCESS} + IntFmt $0 "0x%X" $0 + StrCpy $R0 "Failed to remove driver: error $0" + log::LogWithDetails $R0 $1 + Goto RemoveSplitTunnelDriver_return + ${EndIf} + + log::Log "RemoveSplitTunnelDriver() completed successfully" + + Push 0 + Pop $R0 + + RemoveSplitTunnelDriver_return: + + Pop $1 + Pop $0 + +!macroend + +!define RemoveSplitTunnelDriver '!insertmacro "RemoveSplitTunnelDriver"' + +# # InstallTrayIcon # # Create or update registry entry for tray icon. @@ -747,6 +928,14 @@ ${EndIf} ${EndIf} + ${ExtractSplitTunnelDriver} + ${InstallSplitTunnelDriver} + + ${If} $R0 != 0 + MessageBox MB_OK "$R0" + Goto customInstall_abort_installation + ${EndIf} + ${InstallService} ${If} $R0 != 0 @@ -1048,6 +1237,9 @@ ${ExtractWintun} ${RemoveWintun} + ${ExtractSplitTunnelDriver} + ${RemoveSplitTunnelDriver} + log::SetLogTarget ${LOG_VOID} ${RemoveLogsAndCache} |
