From 237bdc6a97c0dd455da99c16e6b3b7cac4c79e86 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 2 Sep 2022 16:12:42 -0500 Subject: Add WixCanRestart and make wixstdba elevate for restart when required. Fixes 5499 --- .../Manual/BafThmutilTesting/BafThmUtilTesting.cpp | 2 +- .../burn/TestData/Manual/BundleA/ManualTests.txt | 54 ++++++++++++++++++++-- .../burn/TestData/Manual/BundleC/BundleC.wixproj | 18 ++++++++ src/test/burn/TestData/Manual/BundleC/BundleC.wxs | 15 ++++++ .../Manual/PackagePerUser/PackagePerUser.wixproj | 9 ++++ 5 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 src/test/burn/TestData/Manual/BundleC/BundleC.wixproj create mode 100644 src/test/burn/TestData/Manual/BundleC/BundleC.wxs create mode 100644 src/test/burn/TestData/Manual/PackagePerUser/PackagePerUser.wixproj (limited to 'src/test') diff --git a/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp b/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp index c619dbd6..a2b8e041 100644 --- a/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp +++ b/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp @@ -477,7 +477,7 @@ static HRESULT LogUserSid() TOKEN_USER* pTokenUser = NULL; LPWSTR sczSid = NULL; - hr = ProcTokenUser(::GetCurrentProcess(), &pTokenUser); + hr = ProcGetTokenInformation(::GetCurrentProcess(), TokenUser, reinterpret_cast(&pTokenUser)); BalExitOnFailure(hr, "Failed to get user from process token."); if (!::ConvertSidToStringSidW(pTokenUser->User.Sid, &sczSid)) diff --git a/src/test/burn/TestData/Manual/BundleA/ManualTests.txt b/src/test/burn/TestData/Manual/BundleA/ManualTests.txt index d432f94a..b8c6e74d 100644 --- a/src/test/burn/TestData/Manual/BundleA/ManualTests.txt +++ b/src/test/burn/TestData/Manual/BundleA/ManualTests.txt @@ -94,11 +94,12 @@ CanRestartFromUnelevatedPerMachineBundleWithoutShutdownPrivilege 2. Click Install. 3. Verify that the UAC prompt came up and accept elevation. 4. Click OK on the OnExecuteBegin message box. -5. Click Restart. -6. The machine should restart. -7. Login to the machine. -8. Verify that the bundle did not automatically start running. -9. Look in the bundle log and verify that the restart request didn't cause any errors, and that it logged messages that look like (the process id for w005 must match the elevated i400 and i401): +5. Verify the Restart button doesn't have the UAC shield and then click it. +6. Verify that there was no UAC prompt. +7. The machine should restart. +8. Login to the machine. +9. Verify that the bundle did not automatically start running. +10. Look in the bundle log and verify that the restart request didn't cause any errors, and that it logged messages that look like (the process id for w005 must match the elevated i400 and i401): [0DDC:0448]w005: Restarting computer... [1228:18CC]i400: Received system request to shut down the process: allowed: Yes, elevated: No, critical: No, logoff: No, close app: No @@ -107,4 +108,47 @@ CanRestartFromUnelevatedPerMachineBundleWithoutShutdownPrivilege [0DDC:0954]i401: Received result of system request to shut down the process: closing: Yes, elevated: Yes, critical: No, logoff: No, close app: No ======================================= +(11. Uninstall the bundle) + +CanRestartFromUnelevatedPerUserBundleWithoutShutdownPrivilege + + Note: Requires different User Rights Assignment settings from CanLogRestartFailure - Only Administrators should have the shutdown privilege. Users should not have it. + +1. Run BundleC.exe unelevated with the command line EXEEXITCODE=3010. +2. Click Install. +3. Verify the Restart button has the UAC shield and then click it. +4. Verify that the UAC prompt came up and accept elevation. +5. The machine should restart. +6. Login to the machine. +7. Verify that the bundle did not automatically start running. +8. Look in the bundle log and verify that the restart request didn't cause any errors, and that it logged messages that look like (the process id for w005 must match the elevated i400 and i401): + +[0DDC:0448]w005: Restarting computer... +[1228:18CC]i400: Received system request to shut down the process: allowed: Yes, elevated: No, critical: No, logoff: No, close app: No +[1228:18CC]i401: Received result of system request to shut down the process: closing: Yes, elevated: No, critical: No, logoff: No, close app: No +[0DDC:0954]i400: Received system request to shut down the process: allowed: Yes, elevated: Yes, critical: No, logoff: No, close app: No +[0DDC:0954]i401: Received result of system request to shut down the process: closing: Yes, elevated: Yes, critical: No, logoff: No, close app: No +======================================= + +(9. Uninstall the bundle) + +CanRestartFromUnelevatedPerUserBundleWithShutdownPrivilege + + Note: Requires different User Rights Assignment settings from CanLogRestartFailure - Administrators and Users should have the shutdown privilege. + +1. Run BundleC.exe unelevated with the command line EXEEXITCODE=3010. +2. Click Install. +3. Verify that there was no UAC prompt. +4. Verify the Restart button doesn't have the UAC shield and then click it. +5. Verify that there was no UAC prompt. +6. The machine should restart. +7. Login to the machine. +8. Verify that the bundle did not automatically start running. +9. Look in the bundle log and verify that the restart request didn't cause any errors, and that it logged messages that look like (there should be no elevated i400 and i401 and the process id for w005 must match): + +[1228:0448]w005: Restarting computer... +[1228:18CC]i400: Received system request to shut down the process: allowed: Yes, elevated: No, critical: No, logoff: No, close app: No +[1228:18CC]i401: Received result of system request to shut down the process: closing: Yes, elevated: No, critical: No, logoff: No, close app: No +======================================= + (10. Uninstall the bundle) diff --git a/src/test/burn/TestData/Manual/BundleC/BundleC.wixproj b/src/test/burn/TestData/Manual/BundleC/BundleC.wixproj new file mode 100644 index 00000000..eabd529c --- /dev/null +++ b/src/test/burn/TestData/Manual/BundleC/BundleC.wixproj @@ -0,0 +1,18 @@ + + + + Bundle + hyperlinkLicense + {5CAE82BB-A2F3-4994-9BA8-4ACEAFAE7738} + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/Manual/BundleC/BundleC.wxs b/src/test/burn/TestData/Manual/BundleC/BundleC.wxs new file mode 100644 index 00000000..aadcd8b2 --- /dev/null +++ b/src/test/burn/TestData/Manual/BundleC/BundleC.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/src/test/burn/TestData/Manual/PackagePerUser/PackagePerUser.wixproj b/src/test/burn/TestData/Manual/PackagePerUser/PackagePerUser.wixproj new file mode 100644 index 00000000..0efa4d63 --- /dev/null +++ b/src/test/burn/TestData/Manual/PackagePerUser/PackagePerUser.wixproj @@ -0,0 +1,9 @@ + + + + {F7FBAC90-07A6-4DEB-A9C5-E267EDDA28EF} + + + + + \ No newline at end of file -- cgit v1.2.3-55-g6feb