multi: replace btcsuite/winsvc with golang.org/x/sys/windows/svc
What changed, and why it matters
This commit swaps out an old, unmaintained Windows service helper library for the modern, officially maintained Go equivalent. The main practical effects are that btcd can now be compiled for Windows on ARM64 computers, and the Windows service installer is slightly more robust about reporting startup failures. There is no direct fix for an active security vulnerability in the diff itself.
Treat as a routine maintenance/portability improvement. Reviewers should verify that windows/amd64 and windows/arm64 service install/start/stop still work as expected, and that the ErrorControl change does not produce unexpected event-log noise. No urgent security deployment is indicated by this commit alone.
Security signals we found
Dependency on stale/unmaintained Windows service library removed
New dependency is the officially maintained golang.org/x/sys module already present in the build
Windows service creation now sets ErrorControl to ErrorNormal, improving failure visibility
No memory-safety, cryptographic, or network-boundary changes visible in the diff
Evidence from the diff
The change replaces github.com/btcsuite/winsvc (a 2013/2014 fork of code.google.com/p/winsvc containing 386/amd64 assembly service-control callbacks) with golang.org/x/sys/windows/svc. This removes the architecture-specific assembly blocker, enabling windows/arm64 builds. The API is nearly identical; the only call-site changes are import paths, a variadic call to service.Start(os.Args…), and setting mgr.Config.ErrorControl to mgr.ErrorNormal so Windows logs boot-time start failures. The old library is removed from go.mod/go.sum.
Changed components
service_windows.gogo.modgo.sumInspect captured patch +10 / −11
### go.mod
@@ -14,7 +14,6 @@ require (
github.com/btcsuite/btclog v1.0.0
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792
- github.com/btcsuite/winsvc v1.0.0
github.com/davecgh/go-spew v1.1.1
github.com/decred/dcrd/lru v1.1.3
github.com/gorilla/websocket v1.5.3
### go.sum
@@ -22,8 +22,6 @@ github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JG
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
-github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk=
-github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
### service_windows.go
@@ -10,9 +10,9 @@ import (
"path/filepath"
"time"
- "github.com/btcsuite/winsvc/eventlog"
- "github.com/btcsuite/winsvc/mgr"
- "github.com/btcsuite/winsvc/svc"
+ "golang.org/x/sys/windows/svc"
+ "golang.org/x/sys/windows/svc/eventlog"
+ "golang.org/x/sys/windows/svc/mgr"
)
const (
@@ -48,7 +48,7 @@ func logServiceStartOfDay(srvr *server) {
// updates and launching btcdMain.
type btcdService struct{}
-// Execute is the main entry point the winsvc package calls when receiving
+// Execute is the main entry point the svc package calls when receiving
// information from the Windows service control manager. It launches the
// long-running btcdMain (which is the real meat of btcd), handles service
// change requests, and notifies the service control manager of changes.
@@ -141,10 +141,12 @@ func installService() error {
return fmt.Errorf("service %s already exists", svcName)
}
- // Install the service.
+ // Install the service. The zero ErrorControl is ErrorIgnore, so set
+ // ErrorNormal to have Windows log a failure to start at boot.
service, err = serviceManager.CreateService(svcName, exePath, mgr.Config{
- DisplayName: svcDisplayName,
- Description: svcDesc,
+ DisplayName: svcDisplayName,
+ Description: svcDesc,
+ ErrorControl: mgr.ErrorNormal,
})
if err != nil {
return err
@@ -197,7 +199,7 @@ func startService() error {
}
defer service.Close()
- err = service.Start(os.Args)
+ err = service.Start(os.Args...)
if err != nil {
return fmt.Errorf("could not start service: %v", err)
}Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.