Skip to content
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: CreateService ignores ErrorControl type #43094

Closed
maja42 opened this issue Dec 9, 2020 · 3 comments
Closed

x/sys/windows/svc/mgr: CreateService ignores ErrorControl type #43094

maja42 opened this issue Dec 9, 2020 · 3 comments

Comments

@maja42
Copy link

maja42 commented Dec 9, 2020

go1.15

What did you do?

I created a new windows service using CreateService. You can pass a service configuration which includes the filed ErrorControl. It supports the following values:

	ErrorCritical = windows.SERVICE_ERROR_CRITICAL
	ErrorIgnore   = windows.SERVICE_ERROR_IGNORE
	ErrorNormal   = windows.SERVICE_ERROR_NORMAL
	ErrorSevere   = windows.SERVICE_ERROR_SEVERE

I tried to create a windows service with ErrorIgnore, which has the underlying uint32-value 0 - which is also go's zero-value.
CreateService sees that value, assumes that it's not populated, and replaces it with ErrorNormal (1).

There is no workaround (that I can see) to configure ErrorIgnore with the go API.
The only option is to install the service and then edit the registry-key at r\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<service> with the name ErrorControl.

What did you expect to see?

I expect the service to have the correct ErrorControl type.
If this can't be fixed due to backwards compatibility reasons, at least the goDoc should mention the issue and provide an alternative way of configuring this.

@gopherbot gopherbot added this to the Unreleased milestone Dec 9, 2020
@mengzhuo
Copy link
Contributor

mengzhuo commented Dec 9, 2020

It seems to be no other way to pass ServiceIgnore into CreateService right?

https://github.com/golang/sys/blob/master/windows/svc/mgr/mgr.go#L117-L125

Kindly CC @zx2c4

@gopherbot
Copy link

Change https://golang.org/cl/276572 mentions this issue: windows: check ErrorControl while CreateService

@zx2c4
Copy link
Contributor

zx2c4 commented Dec 9, 2020

Thanks for the patch. I've followed up on gerrit.

@golang golang locked and limited conversation to collaborators Dec 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants