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.go +37
| @@ -34,6 +34,11 @@ var accountNameRE = regexp.MustCompile(`^[a-z0-9][a-z0-9_-]{1,31}$`) | |||
| 34 | 34 | // starting and ending alphanumeric. | |
| 35 | 35 | var dnsNameRE = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$`) | |
| 36 | 36 | ||
| 37 | // unixAccountRE is the shape of an operating-system account name, which is what | ||
| 38 | // ssh_user names. It is not the roster's rule: a Unix name may start with an | ||
| 39 | // underscore and may be a single character. | ||
| 40 | var unixAccountRE = regexp.MustCompile(`^[a-z_][a-z0-9_-]{0,31}$`) | ||
| 41 | |||
| 37 | 42 | // emailRE is not RFC 5322. It is a check that the value is a single address and | |
| 38 | 43 | // not a list, a display name, or a line of something else that reached the file. | |
| 39 | 44 | var emailRE = regexp.MustCompile(`^[^@\s,;<>"]+@[^@\s,;<>"]+\.[^@\s,;<>"]+$`) | |
| @@ -60,6 +65,38 @@ func (c *Config) Validate() error { | |||
| 60 | 65 | if socket := strings.TrimSpace(c.SSHSocket); socket != "" && !filepath.IsAbs(socket) { | |
| 61 | 66 | add("ssh_socket must be an absolute path, got %q", socket) | |
| 62 | 67 | } | |
| 68 | |||
| 69 | // One switch decides how SSH is served, and each mode owns its requirements. | ||
| 70 | // "socket" means sshd authenticates and this process is reached over a local | ||
| 71 | // socket, so it needs the account sshd runs, the key a job will verify, and a | ||
| 72 | // clone URL with no port. | ||
| 73 | switch c.SSHListen { | ||
| 74 | case SSHListenTCP, SSHListenSocket, SSHListenNone: | ||
| 75 | case "": | ||
| 76 | add(`ssh_listen must be "tcp", "socket", or "none", got an empty value`) | ||
| 77 | default: | ||
| 78 | add(`ssh_listen must be "tcp", "socket", or "none", got %q`, c.SSHListen) | ||
| 79 | } | ||
| 80 | if c.SSHUser == "vole" { | ||
| 81 | add("ssh_user cannot be %q: that is the service account, and the front door must not run as it", c.SSHUser) | ||
| 82 | } | ||
| 83 | if user := strings.TrimSpace(c.SSHUser); user != "" && !unixAccountRE.MatchString(user) { | ||
| 84 | add("ssh_user must be a plain account name such as %q, got %q", "git", c.SSHUser) | ||
| 85 | } | ||
| 86 | if keyFile := strings.TrimSpace(c.SSHPublicHostKeyFile); keyFile != "" && !filepath.IsAbs(keyFile) { | ||
| 87 | add("ssh_public_host_key_file must be an absolute path, got %q", keyFile) | ||
| 88 | } | ||
| 89 | if c.SSHListen == SSHListenSocket { | ||
| 90 | if strings.TrimSpace(c.SSHUser) == "" { | ||
| 91 | add(`ssh_listen = "socket" needs ssh_user: it is the account sshd runs the forced command as`) | ||
| 92 | } | ||
| 93 | if strings.TrimSpace(c.SSHPublicHostKeyFile) == "" { | ||
| 94 | add(`ssh_listen = "socket" needs ssh_public_host_key_file: sshd presents the key a job verifies, not this process`) | ||
| 95 | } | ||
| 96 | if _, port, err := splitAddr("ssh_addr", c.SSHAddr); err == nil && port != 22 { | ||
| 97 | add(`ssh_listen = "socket" serves sshd on port 22, so ssh_addr must not put another port in clone URLs, got %q`, c.SSHAddr) | ||
| 98 | } | ||
| 99 | } | ||
| 63 | 100 | if strings.TrimSpace(c.HTTPSAddr) != "" { | |
| 64 | 101 | if _, _, err := splitAddr("https_addr", c.HTTPSAddr); err != nil { | |
| 65 | 102 | add("%v", err) | |