package containment import ( "os" "path/filepath" "strconv" "golang.org/x/sys/unix" ) // bindTool imports exactly the runner-created per-attempt endpoint. Its parent // and the authenticating broker stay outside the namespace. func (p *mounts) bindTool(path string) error { if filepath.Base(path) != "equipo.sock" { return errMount } parent, e := pin(filepath.Dir(path)) if e != nil { return e } defer parent.Close() var stat unix.Stat_t if unix.Fstat(int(parent.Fd()), &stat) != nil || stat.Mode&0777 != 0700 || stat.Uid != uint32(os.Getuid()) { return errMount } fd, e := unix.Openat(int(parent.Fd()), "equipo.sock", oPath|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0) if e != nil { return e } f := os.NewFile(uintptr(fd), path) if unix.Fstat(int(f.Fd()), &stat) != nil || stat.Mode&unix.S_IFMT != unix.S_IFSOCK || stat.Mode&0777 != 0600 || stat.Uid != uint32(os.Getuid()) { f.Close() return errMount } p.args = append(p.args, "--ro-bind-fd", strconv.Itoa(6+len(p.files)), "/tool/equipo.sock") p.files = append(p.files, f) return nil }