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.

Give a hand-run instance the file modes and socket directory Linux packaging provides

8f24ae1f8c7873da346344c2686b02aac6df781b · Keenan Nemetz · 12d ago · parent a4a6d1e9

Give a hand-run instance the file modes and socket directory Linux packaging provides

Three things a Vole forge gets from its Linux package are missing when it runs
on macOS, and all three are silent.

The systemd unit sets UMask=0027. launchd has no equivalent, so SQLite, git, the
CI spool, and the ACME client would create group- and world-readable files. The
data directory is 0700, so it is contained, but the defence is the unit's today.
internal/secure.Restrict sets the umask in the long-running commands instead: a
packaged Linux install already has it, and setting it where the unit did is
harmless.

The front-door socket lives in /run/vole, which exists because tmpfiles.d and the
post-install script create it. A hand-run instance has nothing to do that, so
`ssh_listen = "socket"` failed with ENOENT before any clone could try. The
listener now creates the directory (0750) when it is missing and warns that the
sshd account still needs access to it. An existing directory is untouched: its
group and setgid bit are the installer's decision.

macOS puts /var behind a symlink to /private/var, so the same config file reached
two ways compared unequal and `vole admin init` printed a --config hint it did
not need. The comparison resolves symlinks on the directory, which also works for
a file that does not exist yet.

Closes: 01M7ZVF0E8YXKD6A8TNX1MW8B3

server/server.go +40

@@ -9,6 +9,7 @@ import (
9 9 "net"
10 10 "net/http"
11 11 "os"
12 "path/filepath"
12 13 "strconv"
13 14 "strings"
14 15 "time"
@@ -426,6 +427,18 @@ func (s *Server) sshListener() (net.Listener, error) {
426 427 case config.SSHListenNone:
427 428 return nil, nil
428 429 case config.SSHListenSocket:
430 created, err := ensureFrontDoorDir(s.Cfg.SSHSocket)
431 if err != nil {
432 return nil, err
433 }
434 if created {
435 // The account sshd runs the forced command as is not this one, so a
436 // directory private to the service account is not enough. Say so at the
437 // moment it matters rather than at the first clone.
438 s.Log.Warn("created the front-door socket directory; the sshd account needs access to it",
439 "dir", filepath.Dir(s.Cfg.SSHSocket),
440 "hint", "give the directory the group both accounts share, or see docs/deploy/index.md")
441 }
429 442 return listenFrontDoor(s.Cfg.SSHSocket)
430 443 default:
431 444 ln, err := net.Listen("tcp", s.Cfg.SSHAddr)
@@ -436,6 +449,33 @@ func (s *Server) sshListener() (net.Listener, error) {
436 449 }
437 450 }
438 451
452 // ensureFrontDoorDir creates the directory the front-door socket lives in when it
453 // is missing, and reports whether it had to. A packaged Linux install creates it
454 // with the group both accounts share; a hand-run instance, including one on
455 // macOS, has nothing to do that, and failing with ENOENT tells the operator
456 // nothing. An existing directory is left exactly as it is: its group and its
457 // setgid bit are the installer's decision, not this process's.
458 func ensureFrontDoorDir(socket string) (bool, error) {
459 dir := filepath.Dir(socket)
460 if dir == "." || dir == string(filepath.Separator) {
461 return false, nil
462 }
463 st, err := os.Stat(dir)
464 switch {
465 case err == nil:
466 if !st.IsDir() {
467 return false, fmt.Errorf("ssh socket directory %s is not a directory", dir)
468 }
469 return false, nil
470 case !os.IsNotExist(err):
471 return false, fmt.Errorf("ssh socket directory %s: %w", dir, err)
472 }
473 if err := os.MkdirAll(dir, 0o750); err != nil {
474 return false, fmt.Errorf("ssh socket directory %s: %w", dir, err)
475 }
476 return true, nil
477 }
478
439 479 // listenFrontDoor opens the Unix socket the forced command connects to.
440 480 //
441 481 // A socket file outlives the process that made it, so a stale one is removed —