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/ssh/session_test.go +11−11
| @@ -14,10 +14,10 @@ import ( | |||
| 14 | 14 | xssh "golang.org/x/crypto/ssh" | |
| 15 | 15 | ) | |
| 16 | 16 | ||
| 17 | // localSession is a Session with nothing behind it. It is the shape a second | ||
| 17 | // memorySession is a Session with nothing behind it. It is the shape a second | ||
| 18 | 18 | // transport will take, kept here so a handler cannot quietly grow a dependency | |
| 19 | 19 | // on a channel it will not have. | |
| 20 | type localSession struct { | ||
| 20 | type memorySession struct { | ||
| 21 | 21 | stdin bytes.Buffer | |
| 22 | 22 | stdout bytes.Buffer | |
| 23 | 23 | stderr bytes.Buffer | |
| @@ -28,15 +28,15 @@ type localSession struct { | |||
| 28 | 28 | closed bool | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | func (s *localSession) Read(p []byte) (int, error) { return s.stdin.Read(p) } | ||
| 32 | func (s *localSession) Write(p []byte) (int, error) { return s.stdout.Write(p) } | ||
| 33 | func (s *localSession) Stderr() io.Writer { return &s.stderr } | ||
| 34 | func (s *localSession) CloseWrite() error { return nil } | ||
| 35 | func (s *localSession) Close() error { s.closed = true; return nil } | ||
| 31 | func (s *memorySession) Read(p []byte) (int, error) { return s.stdin.Read(p) } | ||
| 32 | func (s *memorySession) Write(p []byte) (int, error) { return s.stdout.Write(p) } | ||
| 33 | func (s *memorySession) Stderr() io.Writer { return &s.stderr } | ||
| 34 | func (s *memorySession) CloseWrite() error { return nil } | ||
| 35 | func (s *memorySession) Close() error { s.closed = true; return nil } | ||
| 36 | 36 | ||
| 37 | func (s *localSession) Accept() error { s.accepted = true; return nil } | ||
| 37 | func (s *memorySession) Accept() error { s.accepted = true; return nil } | ||
| 38 | 38 | ||
| 39 | func (s *localSession) Exit(code int) { | ||
| 39 | func (s *memorySession) Exit(code int) { | ||
| 40 | 40 | s.exited, s.code = true, code | |
| 41 | 41 | } | |
| 42 | 42 | ||
| @@ -78,7 +78,7 @@ func TestVerbsRunOnALocalSession(t *testing.T) { | |||
| 78 | 78 | } | |
| 79 | 79 | ||
| 80 | 80 | // The same command with no SSH channel underneath it. | |
| 81 | local := &localSession{} | ||
| 81 | local := &memorySession{} | ||
| 82 | 82 | h.srv.exec(local, command, "writer", "", "127.0.0.1:1") | |
| 83 | 83 | ||
| 84 | 84 | if !local.accepted { | |
| @@ -109,7 +109,7 @@ func TestVerbsRunOnALocalSession(t *testing.T) { | |||
| 109 | 109 | func TestRefusalRunsOnALocalSession(t *testing.T) { | |
| 110 | 110 | t.Parallel() | |
| 111 | 111 | h := newHarness(t) | |
| 112 | local := &localSession{} | ||
| 112 | local := &memorySession{} | ||
| 113 | 113 | h.srv.exec(local, "cat /etc/passwd", "writer", "", "127.0.0.1:1") | |
| 114 | 114 | ||
| 115 | 115 | if !local.accepted || !local.exited { | |