mountConsole bind-mounts the provided pty on top of /dev/console so programs that operate on /dev/console operate on the correct container pty.
(peerPty *os.File)
| 138 | // mountConsole bind-mounts the provided pty on top of /dev/console so programs |
| 139 | // that operate on /dev/console operate on the correct container pty. |
| 140 | func mountConsole(peerPty *os.File) error { |
| 141 | console, err := os.OpenFile("/dev/console", unix.O_NOFOLLOW|unix.O_CREAT|unix.O_CLOEXEC, 0o666) |
| 142 | if err != nil { |
| 143 | return fmt.Errorf("create /dev/console mount target: %w", err) |
| 144 | } |
| 145 | defer console.Close() |
| 146 | |
| 147 | dstFd, closer := utils.ProcThreadSelfFd(console.Fd()) |
| 148 | defer closer() |
| 149 | |
| 150 | mntSrc := &mountSource{ |
| 151 | Type: mountSourcePlain, |
| 152 | file: peerPty, |
| 153 | } |
| 154 | return mountViaFds(peerPty.Name(), mntSrc, "/dev/console", dstFd, "bind", unix.MS_BIND, "") |
| 155 | } |
| 156 | |
| 157 | // dupStdio replaces stdio with the given peerPty. |
| 158 | func dupStdio(peerPty *os.File) error { |
no test coverage detected
searching dependent graphs…