diff options
author | Graham Bloice <graham.bloice@trihedral.com> | 2020-07-25 14:46:42 +0100 |
---|---|---|
committer | Graham Bloice <graham.bloice@trihedral.com> | 2020-07-25 17:52:01 +0000 |
commit | ac2883f5e8e0a461ba06733294738358eb527b8c (patch) | |
tree | 33286850a1e24f6954c54c1a84167e53821dd8f4 /packaging | |
parent | 4bea0e7c2ebf87c5f3ef8421475c7e31140fdfdc (diff) |
NSIS uninstaller: ensure the uninstaller runs with elevated privileges
The uninstaller should run with elevated privileges to allow deletion
of files from protected directories.
Modifying the uninstall script to require elevation then causes the
uninstaller_installer that creates the uninstaller to also require
elevation which happens at build time so defeat that
by setting the env var __COMPAT_LAYER to "RunAsInvoker" before calling
the uninstaller_installer.
Achieving this from CMake requires a script to call to set the env var
and then calling the executable.
Change-Id: I056931bc4f9b41877b8f31d765d49fee11b54e39
Reviewed-on: https://code.wireshark.org/review/37955
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Diffstat (limited to 'packaging')
-rw-r--r-- | packaging/nsis/CMakeLists.txt | 2 | ||||
-rw-r--r-- | packaging/nsis/makeUninstall.ps1 | 47 | ||||
-rw-r--r-- | packaging/nsis/uninstall.nsi | 1 |
3 files changed, 48 insertions, 2 deletions
diff --git a/packaging/nsis/CMakeLists.txt b/packaging/nsis/CMakeLists.txt index 727c6e2f1b..5496580798 100644 --- a/packaging/nsis/CMakeLists.txt +++ b/packaging/nsis/CMakeLists.txt @@ -191,7 +191,7 @@ macro( ADD_NSIS_UNINSTALLER_TARGET ) ${_nsis_source_dir}/common.nsh COMMAND ${MAKENSIS_EXECUTABLE} ${NSIS_OPTIONS} uninstall.nsi - COMMAND ${DATAFILE_DIR}/uninstall_installer.exe + COMMAND ${POWERSHELL_COMMAND} "${_nsis_source_dir}/makeUninstall.ps1" ${DATAFILE_DIR}/uninstall_installer.exe COMMAND ${CMAKE_COMMAND} -E remove ${DATAFILE_DIR}/uninstall_installer.exe WORKING_DIRECTORY ${_nsis_source_dir} ) diff --git a/packaging/nsis/makeUninstall.ps1 b/packaging/nsis/makeUninstall.ps1 new file mode 100644 index 0000000000..a0e68e5c78 --- /dev/null +++ b/packaging/nsis/makeUninstall.ps1 @@ -0,0 +1,47 @@ +# MakeUninstall.ps1 +# +# Runs the uninstall_installer to create the uninstall.exe that can be signed +# Uses set __COMPAT_LAYER=RunAsInvoker to not request elevation +# +# Copyright 2020 Graham Bloice <graham.bloice@trihedral.com> +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@wireshark.org> +# Copyright 1998 Gerald Combs +# +# SPDX-License-Identifier: GPL-2.0-or-later + +#requires -version 2 + +<# +.SYNOPSIS +Runs the uninstaller_installer without invoking UAC. + +.DESCRIPTION +This script runs the uninstaller_installer that creates uninstall.exe +but without invoking a UAC elevation prompt that is required by the +uninstaller + +.PARAMETER Executable +The path to the uninstaller_installer.exe + +.INPUTS +-Executable Path to the uninstaller installer. + +.OUTPUTS +An unsigned uninstall.exe for signing + +.EXAMPLE +C:\PS> .\makeUninstall.ps1 run\RelWithDebInfo\uninstall_installer.exe +#> + +Param( + [Parameter(Mandatory=$true, Position=0)] + [String] $Executable +) + +# Stop the process requesting elevation, runs as the user +$env:__COMPAT_LAYER = "RunAsInvoker" + +# And run the process +Start-Process $Executable -Wait -NoNewWindow diff --git a/packaging/nsis/uninstall.nsi b/packaging/nsis/uninstall.nsi index b593308a80..c8493ae91b 100644 --- a/packaging/nsis/uninstall.nsi +++ b/packaging/nsis/uninstall.nsi @@ -13,7 +13,6 @@ ${UnStrRep} SetCompress off OutFile "${STAGING_DIR}\uninstall_installer.exe" -RequestExecutionLevel user InstType "un.Default (keep Personal Settings and Npcap)" InstType "un.All (remove all)" |