Adding New-Service to -SecurityDescriptorSDDL parameter like Set-Service#10483
Adding New-Service to -SecurityDescriptorSDDL parameter like Set-Service#10483adityapatwardhan merged 11 commits intoPowerShell:masterfrom
Conversation
| { | ||
| var rawSecurityDescriptor = new RawSecurityDescriptor(securityDescriptorSddl); | ||
| RawAcl rawDiscretionaryAcl = rawSecurityDescriptor.DiscretionaryAcl ; | ||
| var discretionaryAcl = new DiscretionaryAcl (false, false, rawDiscretionaryAcl); |
There was a problem hiding this comment.
Extra spaces in two lines above.
There was a problem hiding this comment.
Thanks, why didn't CodeFactor catch this ?
There was a problem hiding this comment.
Sometimes it is not predictable :-)
| bool status = NativeMethods.SetServiceObjectSecurity( | ||
| hService, | ||
| SecurityInfos.DiscretionaryAcl, | ||
| securityDescriptorByte); |
There was a problem hiding this comment.
Indentation must be 4 spaces.
There was a problem hiding this comment.
Thanks, why didn't CodeFactor catch this ?
|
@PoshChan please retry static |
| } | ||
| } | ||
|
|
||
| if (!string.IsNullOrEmpty(SecurityDescriptorSddl)) |
There was a problem hiding this comment.
would this work?
service = new ServiceController(Name);
if (!string.IsNullOrEmpty(SecurityDescriptorSddl))
{
SetServiceSecurityDescriptor(service, SecurityDescriptorSddl, hService);
}There was a problem hiding this comment.
That's a parameter, right? Shouldn't we be using if (MyInvocation.BoundParameters.ContainsKey(nameof(SecurityDescriptorSddl))) { ... } for parameters?
There was a problem hiding this comment.
@adityapatwardhan @vexx32 yes, I've used the same way how its implemented for Set-Service. I referred
L1883 if (!string.IsNullOrEmpty(Status)) which is used for -Status parameter in Set-Service.
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Service.Tests.ps1
Show resolved
Hide resolved
|
@kvprasoon Please follow the template and file a doc issue for the new parameter. If it is filed, please paste the link here. |
|
doc changes MicrosoftDocs/PowerShell-Docs#4735 |
|
@kvprasoon Thanks for your contribution! Sorry for delay. |
|
🎉 Handy links: |
PR Summary
This PR is to add
-SecurityDescriptorSDDLparameter toNew-Servicecmdlet so that its in par withSet-Servicein setting sddl for a service.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.