mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Make Stop-Service only request needed privileges when not setting SDDL. (#16663)
* code changes to select permission based on input * make the code more readable
This commit is contained in:
@@ -1756,10 +1756,14 @@ namespace Microsoft.PowerShell.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var access = NativeMethods.SERVICE_CHANGE_CONFIG;
|
||||
if (!string.IsNullOrEmpty(SecurityDescriptorSddl))
|
||||
access |= NativeMethods.WRITE_DAC | NativeMethods.WRITE_OWNER;
|
||||
|
||||
hService = NativeMethods.OpenServiceW(
|
||||
hScManager,
|
||||
Name,
|
||||
NativeMethods.SERVICE_CHANGE_CONFIG | NativeMethods.WRITE_DAC | NativeMethods.WRITE_OWNER
|
||||
access
|
||||
);
|
||||
|
||||
if (hService == IntPtr.Zero)
|
||||
|
||||
Reference in New Issue
Block a user