oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package containment
2
3import (
4 "os"
5 "path/filepath"
6 "strconv"
7
8 "golang.org/x/sys/unix"
9)
10
11// bindTool imports exactly the runner-created per-attempt endpoint. Its parent
12// and the authenticating broker stay outside the namespace.
13func (p *mounts) bindTool(path string) error {
14 if filepath.Base(path) != "equipo.sock" {
15 return errMount
16 }
17 parent, e := pin(filepath.Dir(path))
18 if e != nil {
19 return e
20 }
21 defer parent.Close()
22 var stat unix.Stat_t
23 if unix.Fstat(int(parent.Fd()), &stat) != nil || stat.Mode&0777 != 0700 || stat.Uid != uint32(os.Getuid()) {
24 return errMount
25 }
26 fd, e := unix.Openat(int(parent.Fd()), "equipo.sock", oPath|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0)
27 if e != nil {
28 return e
29 }
30 f := os.NewFile(uintptr(fd), path)
31 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()) {
32 f.Close()
33 return errMount
34 }
35 p.args = append(p.args, "--ro-bind-fd", strconv.Itoa(6+len(p.files)), "/tool/equipo.sock")
36 p.files = append(p.files, f)
37 return nil
38}
39