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.

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.

forge/config/validate_test.go +54

@@ -20,6 +20,24 @@ func TestDefaultsAreValid(t *testing.T) {
20 20 }
21 21 }
22 22
23 // TestAFrontDoorConfigurationIsValid is the other half: the settings the socket
24 // mode requires are enough, and nothing about the front door is rejected when it
25 // is fully configured.
26 func TestAFrontDoorConfigurationIsValid(t *testing.T) {
27 t.Parallel()
28 cfg, err := Load("")
29 if err != nil {
30 t.Fatal(err)
31 }
32 cfg.SSHListen = SSHListenSocket
33 cfg.SSHAddr = "0.0.0.0:22"
34 cfg.SSHPublicHostKeyFile = "/etc/ssh/ssh_host_ed25519_key.pub"
35 cfg.SSHUser = "vole-git"
36 if err := cfg.Validate(); err != nil {
37 t.Fatalf("a complete front door does not validate:\n%v", err)
38 }
39 }
40
23 41 func TestValidationRefusesUnsafeCombinations(t *testing.T) {
24 42 t.Parallel()
25 43 cases := []struct {
@@ -27,6 +45,42 @@ func TestValidationRefusesUnsafeCombinations(t *testing.T) {
27 45 tweak func(*Config)
28 46 want string
29 47 }{
48 {
49 name: "an unknown ssh mode",
50 tweak: func(c *Config) { c.SSHListen = "ftp" },
51 want: `ssh_listen must be "tcp", "socket", or "none"`,
52 },
53 {
54 name: "a front door with nothing for a job to verify",
55 tweak: func(c *Config) {
56 c.SSHListen = SSHListenSocket
57 c.SSHAddr = "0.0.0.0:22"
58 },
59 want: `ssh_listen = "socket" needs ssh_public_host_key_file`,
60 },
61 {
62 name: "a front door with a port in its clone URLs",
63 tweak: func(c *Config) {
64 c.SSHListen = SSHListenSocket
65 c.SSHPublicHostKeyFile = "/etc/ssh/ssh_host_ed25519_key.pub"
66 },
67 want: `ssh_addr must not put another port in clone URLs`,
68 },
69 {
70 name: "the service account as the ssh account",
71 tweak: func(c *Config) { c.SSHUser = "vole" },
72 want: "ssh_user cannot be",
73 },
74 {
75 name: "an ssh account name that is not an account name",
76 tweak: func(c *Config) { c.SSHUser = "Git User" },
77 want: "ssh_user must be a plain account name",
78 },
79 {
80 name: "a relative public host key",
81 tweak: func(c *Config) { c.SSHPublicHostKeyFile = "ssh_host_ed25519_key.pub" },
82 want: "ssh_public_host_key_file must be an absolute path",
83 },
30 84 {
31 85 // sshd runs the forced command from its own working directory, so a
32 86 // relative socket path would point at a file nobody created.