-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Windows] Create service utils #15114
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- enumDependentServices now returns an empty slice and no error if there are no dependent services - add tests that use least priviledge to: - open SC manager - create a service - open a service handle - list dependent services - delete services
clarkb7
reviewed
Jan 17, 2023
clarkb7
reviewed
Jan 17, 2023
- Add another test verification step for the order in which services are returned in ListDependentServices
iglendd
reviewed
Jan 18, 2023
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.
I wonder if we have other places in Agent where SCM is used and we probably can switch to this new code.
- Include service name in more logging statements - Remove unneeded "else"
- as I was re-reading, I found that the "m" and "s" variables were confusing to keep track of, so I updated them to better reflect what they held
- include service name in logging
- use Go return conventions
iglendd
approved these changes
Jan 18, 2023
clarkb7
approved these changes
Jan 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR creates a file that exposes utilities to interact with Windows services via the Service Control Manager (SCM). It wraps
OpenSCManager
andOpenService
to allow the caller to specify thedesiredAccess
rights (as opposed to the Go package that usesALL_ACCESS
). This will allow agent code to use least-privilege accesses when working with Windows services.Motivation
The motivation is to enable least-privileges SCM interactions from one place in the agent repo.
Additional Notes
ListDependentServices
function will list first, second, third, ... level dependenciesgo\pkg\mod\golang.org\x\sys@v0.4.0\windows\svc\mgr\mgr_test.go
. Assuming this is fine, because in the above issue the answerer suggested copying code directly from the packageenumDependentServices
to the Go package, when that is merged, we should update our code to use that functionPossible Drawbacks / Trade-offs
Describe how to test/QA your changes
Reviewer's Checklist
Triage
milestone is set.major_change
label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.changelog/no-changelog
label has been applied.qa/skip-qa
label is not applied.team/..
label has been applied, indicating the team(s) that should QA this change.need-change/operator
andneed-change/helm
labels have been applied.k8s/<min-version>
label, indicating the lowest Kubernetes version compatible with this feature.