//go:build !linux package thin import ( "errors" "net" "os" "amadan.net/oficina/equipo/internal/runner" "amadan.net/oficina/equipo/internal/runner/provider" ) var ( errToolSocketPath = errors.New("tool socket path too long") errToolRoot = errors.New("tool socket root is not a directory") ) // A step's tool socket on a Mac: /t//s // (toolsocket_layout.go), dialled by its path. const ( toolDirPrefix = macToolDirPrefix toolSocketName = macToolSocketName ) // toolRoot is the private directory a runner's tool sockets go under, // created 0700 if it is missing: never a link, always this user's. func toolRoot(c runner.Config) (string, error) { root := macToolRoot(c) if err := os.MkdirAll(root, 0700); err != nil { return "", err } info, err := os.Lstat(root) if err != nil { return "", err } if !info.IsDir() { return "", errToolRoot } if info.Mode().Perm() != 0700 { if err := os.Chmod(root, 0700); err != nil { return "", err } } return root, nil } // listenToolSocket binds the socket at path, which must fit a Mac's // sun_path: it is refused, never cut short. func listenToolSocket(_, path string) (*net.UnixListener, error) { if len(path) > provider.MaxDarwinSocketPath { return nil, errToolSocketPath } return net.ListenUnix("unix", &net.UnixAddr{Name: path, Net: "unix"}) }