-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Adding New-Service to -SecurityDescriptorSDDL parameter like Set-Service #10483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
{ | ||
var rawSecurityDescriptor = new RawSecurityDescriptor(securityDescriptorSddl); | ||
RawAcl rawDiscretionaryAcl = rawSecurityDescriptor.DiscretionaryAcl ; | ||
var discretionaryAcl = new DiscretionaryAcl (false, false, rawDiscretionaryAcl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra spaces in two lines above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, why didn't CodeFactor catch this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes it is not predictable :-)
bool status = NativeMethods.SetServiceObjectSecurity( | ||
hService, | ||
SecurityInfos.DiscretionaryAcl, | ||
securityDescriptorByte); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation must be 4 spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, why didn't CodeFactor catch this ?
@PoshChan please retry static |
@@ -2273,8 +2294,14 @@ protected override void BeginProcessing() | |||
} | |||
} | |||
|
|||
if (!string.IsNullOrEmpty(SecurityDescriptorSddl)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this work?
service = new ServiceController(Name);
if (!string.IsNullOrEmpty(SecurityDescriptorSddl))
{
SetServiceSecurityDescriptor(service, SecurityDescriptorSddl, hService);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
-SecurityDescriptorSDDL
parameter toNew-Service
cmdlet so that its in par withSet-Service
in setting sddl for a service.PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.