oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package thin
2
3import (
4 "net"
5 "os"
6 "path/filepath"
7 "strconv"
8
9 "golang.org/x/sys/unix"
10
11 "amadan.net/oficina/equipo/internal/runner"
12)
13
14// A step's tool socket on Linux: <state dir>/coord-tool-*/equipo.sock.
15const (
16 toolDirPrefix = "coord-tool-"
17 toolSocketName = "equipo.sock"
18)
19
20// toolRoot is the private directory a runner's tool sockets go under.
21func toolRoot(c runner.Config) (string, error) { return c.StateDir, nil }
22
23// listenToolSocket binds the socket through its directory's descriptor,
24// as the egress proxy does: a Unix socket's path holds 107 bytes, and a
25// runner's state directory can leave less room than that (2026-11-22,
26// the staging suite under a long TMPDIR failed most coordinator starts).
27// The socket is still created at path.
28func listenToolSocket(dir, path string) (*net.UnixListener, error) {
29 fd, err := unix.Open(dir, unix.O_RDONLY|unix.O_DIRECTORY|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0)
30 if err != nil {
31 return nil, &os.PathError{Op: "open", Path: dir, Err: err}
32 }
33 defer unix.Close(fd)
34 return net.ListenUnix("unix", &net.UnixAddr{Name: "/proc/self/fd/" + strconv.Itoa(fd) + "/" + filepath.Base(path), Net: "unix"})
35}
36