package thin import ( "net" "os" "path/filepath" "strconv" "golang.org/x/sys/unix" "amadan.net/oficina/equipo/internal/runner" ) // A step's tool socket on Linux: /coord-tool-*/equipo.sock. const ( toolDirPrefix = "coord-tool-" toolSocketName = "equipo.sock" ) // toolRoot is the private directory a runner's tool sockets go under. func toolRoot(c runner.Config) (string, error) { return c.StateDir, nil } // listenToolSocket binds the socket through its directory's descriptor, // as the egress proxy does: a Unix socket's path holds 107 bytes, and a // runner's state directory can leave less room than that (2026-11-22, // the staging suite under a long TMPDIR failed most coordinator starts). // The socket is still created at path. func listenToolSocket(dir, path string) (*net.UnixListener, error) { fd, err := unix.Open(dir, unix.O_RDONLY|unix.O_DIRECTORY|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0) if err != nil { return nil, &os.PathError{Op: "open", Path: dir, Err: err} } defer unix.Close(fd) return net.ListenUnix("unix", &net.UnixAddr{Name: "/proc/self/fd/" + strconv.Itoa(fd) + "/" + filepath.Base(path), Net: "unix"}) }