Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Run the forge as a Windows service

9cbfa891425adaa3e2769d1b3f88d5f211190dc6 · Keenan Nemetz · 2d ago · parent 33cbbc9d

Run the forge as a Windows service

The Windows server ran from a scheduled task because a process started from an
SSH session dies with it, and nothing told the service manager what state the
forge was in. This makes `serve` a real service and gives it the commands to
install itself.

The binary now speaks the SCM: `svc.IsWindowsService` decides, `svc.Run` is
entered before any work so a slow instance is a pending state rather than a
dispatcher timeout, and a Stop or Shutdown cancels the same context an interrupt
cancels, which is what lets the drain finish. The service reports running before
the listeners are up, so a bind failure arrives as a nonzero exit and the
recovery actions installed with it restart the forge; start and stop failures
also go to the Application event log, because a service has no stderr.

`vole service install|uninstall|start|stop|status` manages the registration with
no wrapper and no second definition: auto start with the standard delay, a
description, three restarts as recovery, and the virtual account
`NT SERVICE\Vole` with a restricted SID. Install also prepares what that account
needs — the data directory and everything already in it, the log directory, and
read access to the configuration — through `secure.HardenFor`, a new Windows-only
helper that writes a protected access list for principals the running process is
not. An instance initialized by a person is readable by the service afterwards,
which is the upgrade case, not only the fresh one.

`serve --log-file` is the file sink the service needs, opened through the secret
store so it is not readable by everyone; the console keeps stderr.

The command exists off Windows too and answers that services are the platform's
business, so the generated reference is the same everywhere.

Verified on the Server Core 2022 guest (full record on the issue): install,
start, status, stop, uninstall; the data directory, database, key, and log
granted only to the service account, SYSTEM, and Administrators; HTTP 200
through the forwarded port; admin CLI and git push over Vole's SSH listener; a
reboot brought the forge back with no login; and a second install refuses with a
clear message. The Windows-only unit tests (`stateName`, `lookupSID`) pass there
too, and `vole workflow run verify` passes locally.

Part of 01M8SE6PR5N7M3X48SMAGA8Z18. Packaging, Authenticode, and winget are
01M8SE6GWX1DGYPY6H9YC142C2.

internal/secure/acl_windows_test.go +6−2

@@ -107,7 +107,11 @@ func TestHardenDirProtectsFilesCreatedInside(t *testing.T) {
107 107 }
108 108 // A directory that still inherits would follow its parent if the parent were
109 109 // opened later, so HardenDir has to own the list rather than share it.
110 if err := verifyACL(dir, true); err != nil {
110 trusted, err := trustedPrincipals()
111 if err != nil {
112 t.Fatal(err)
113 }
114 if err := verifyACLFor(dir, true, trusted.all, trusted.user); err != nil {
111 115 t.Fatalf("the directory still inherits: %v", err)
112 116 }
113 117
@@ -121,7 +125,7 @@ func TestHardenDirProtectsFilesCreatedInside(t *testing.T) {
121 125 // The file inherits from a protected directory, which is the arrangement that
122 126 // makes protection reach files nobody has opened yet; the flag belongs to the
123 127 // directory.
124 if err := verifyACL(file, false); err != nil {
128 if err := VerifyACL(file); err != nil {
125 129 t.Fatalf("the file's inherited access list is not restricted: %v", err)
126 130 }
127 131 }