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.
Serve the front door from vole serve
c5f2c5d49be1d35a0a54fd70029ac9311647194e · Keenan Nemetz · 16d ago · parent e075258f
Serve the front door from vole serve The forced command had nothing to talk to. This gives `vole serve` the local listener, the token it consumes, and the host key a lease now carries. `ssh_listen` decides what serves SSH and is the only switch: "tcp" is the built-in listener on `ssh_addr` (the default, and unchanged), "socket" is the system sshd in front, "none" serves nothing. The socket path stays in `ssh_socket`, which #304 already added, so no value lives in two places. In socket mode `ssh_addr` only names the host and port clone URLs carry, which validation now enforces by refusing another port: the point of the mode is a clone URL with no port, and a leftover 2222 would silently break every link. The local listener speaks the framed protocol from `internal/sshwire` and turns it back into the Session the built-in listener produces, so `handleLocal` calls the same `exec` with the account and key from the token row and the same ACL, credential-scoping, and refusal code runs. A test proves it: every kind of handler — whoami, roster, both git pack services, the admin API, the run queue, release channels, a refused verb, and a job credential that may do less than its account — is driven over both transports and compared byte for byte, status included. A front-door instance has no signer, so `New` no longer creates a private host key it would never present: it reads sshd's public key from `ssh_public_host_key_file` into the same field a lease carries. A missing or unreadable file fails startup rather than handing a job a key that cannot verify its host, and `Serve` refuses outright when there is no host key. The transport's own details: a write larger than a frame is split rather than refused, stdout and stderr share one socket under one lock, expired tokens are swept every thirty seconds and once at startup so a mode switch leaves nothing behind, and the socket is created 0660 with a stale file replaced only after checking that nothing answers on it. `ssh_user` replaces the hardcoded `git` in generated clone URLs, which is what lets a host with another forge's `git` account keep both. Packaging and the sshd drop-in are #306; the documentation and migration are #307.
server/frontdoor_test.go +74
| @@ -0,0 +1,74 @@ | |||
| 1 | package server | ||
| 2 | |||
| 3 | // The front door's socket is created by the service and used by the `git` account | ||
| 4 | // sshd runs, so its mode and its lifecycle are part of the trust boundary. A stale | ||
| 5 | // file must not stop a restart, and a live one must not be stolen. | ||
| 6 | |||
| 7 | import ( | ||
| 8 | "net" | ||
| 9 | "os" | ||
| 10 | "path/filepath" | ||
| 11 | "strings" | ||
| 12 | "testing" | ||
| 13 | ) | ||
| 14 | |||
| 15 | // shortDir returns a directory short enough for a Unix socket path. | ||
| 16 | func shortDir(t *testing.T) string { | ||
| 17 | t.Helper() | ||
| 18 | dir, err := os.MkdirTemp("", "vole-fd-") | ||
| 19 | if err != nil { | ||
| 20 | t.Fatal(err) | ||
| 21 | } | ||
| 22 | t.Cleanup(func() { os.RemoveAll(dir) }) | ||
| 23 | return dir | ||
| 24 | } | ||
| 25 | |||
| 26 | func TestFrontDoorSocketIsPrivateAndReplaceable(t *testing.T) { | ||
| 27 | t.Parallel() | ||
| 28 | path := filepath.Join(shortDir(t), "ssh.sock") | ||
| 29 | |||
| 30 | ln, err := listenFrontDoor(path) | ||
| 31 | if err != nil { | ||
| 32 | t.Fatalf("listen: %v", err) | ||
| 33 | } | ||
| 34 | st, err := os.Stat(path) | ||
| 35 | if err != nil { | ||
| 36 | t.Fatal(err) | ||
| 37 | } | ||
| 38 | // The service account and the `git` group may reach it; nobody else. | ||
| 39 | if got := st.Mode().Perm(); got != 0o660 { | ||
| 40 | t.Errorf("socket mode is %o, want 660", got) | ||
| 41 | } | ||
| 42 | // A second instance must not take a live socket. | ||
| 43 | if second, err := listenFrontDoor(path); err == nil { | ||
| 44 | second.Close() | ||
| 45 | t.Error("a live socket was taken over") | ||
| 46 | } | ||
| 47 | ln.Close() | ||
| 48 | |||
| 49 | // A socket file whose listener is gone is in the way of the next start, and | ||
| 50 | // Close removes it — so make one that survives, the way a killed process would. | ||
| 51 | stale, err := net.ListenUnix("unix", &net.UnixAddr{Name: path, Net: "unix"}) | ||
| 52 | if err != nil { | ||
| 53 | t.Fatalf("stale listen: %v", err) | ||
| 54 | } | ||
| 55 | stale.SetUnlinkOnClose(false) | ||
| 56 | stale.Close() | ||
| 57 | if _, err := os.Stat(path); err != nil { | ||
| 58 | t.Fatalf("the stale socket is missing: %v", err) | ||
| 59 | } | ||
| 60 | replace, err := listenFrontDoor(path) | ||
| 61 | if err != nil { | ||
| 62 | t.Fatalf("a stale socket was not replaced: %v", err) | ||
| 63 | } | ||
| 64 | replace.Close() | ||
| 65 | |||
| 66 | // Something that is not a socket is never removed: it is somebody's file. | ||
| 67 | file := filepath.Join(shortDir(t), "not-a-socket") | ||
| 68 | if err := os.WriteFile(file, []byte("hello"), 0o600); err != nil { | ||
| 69 | t.Fatal(err) | ||
| 70 | } | ||
| 71 | if _, err := listenFrontDoor(file); err == nil || !strings.Contains(err.Error(), "not a socket") { | ||
| 72 | t.Errorf("a regular file was treated as a socket: %v", err) | ||
| 73 | } | ||
| 74 | } | ||