-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
x/sys/windows/svc/mgr: Service.Control() should return valid svc.Status on certain errors #59015
Comments
I am able to work around this by calling windows.ControlService() directly: var t windows.SERVICE_STATUS
err := windows.ControlService(s.Handle, windows.SERVICE_CONTROL_STOP, &t) This has the expected behaviour and fills in |
cc @golang/windows |
Thank you @craig65535 for filling the issue. I agree there is a bug in this code. I suggest we update returned Would you like to contribute the fix as per https://go.dev/doc/contribute ? Maybe even add new test for it. Alex |
@alexbrainman Sorry for the delayed response. I'll look into contributing. |
Change https://go.dev/cl/484895 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?windows/amd64
What did you do?
On a given *mgr.Service (
s
), in a state likeStopPending
that does not accept controls, try:What did you expect to see?
err
should bewindows.ERROR_INVALID_SERVICE_CONTROL
, andstatus
should be filled in with the service's current state and set of accepted commands. This is the behaviour described forControlService
:This behaviour is useful because checking the service state independently of controlling it is a TOCTOU bug.
What did you see instead?
err
is correctly set towindows.ERROR_INVALID_SERVICE_CONTROL
, butstatus
is unset.The text was updated successfully, but these errors were encountered: