mirror of
https://github.com/containers/podman.git
synced 2025-12-02 02:58:03 +08:00
Update vendor or containers/buildah
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
10
vendor/github.com/containers/buildah/chroot/pty_ptmx.go
generated
vendored
10
vendor/github.com/containers/buildah/chroot/pty_ptmx.go
generated
vendored
@@ -18,28 +18,28 @@ func getPtyDescriptors() (int, int, error) {
|
||||
// Create a pseudo-terminal -- open a copy of the master side.
|
||||
controlFd, err := unix.Open("/dev/ptmx", os.O_RDWR, 0600)
|
||||
if err != nil {
|
||||
return -1, -1, fmt.Errorf("error opening PTY master using /dev/ptmx: %v", err)
|
||||
return -1, -1, fmt.Errorf("opening PTY master using /dev/ptmx: %v", err)
|
||||
}
|
||||
// Set the kernel's lock to "unlocked".
|
||||
locked := 0
|
||||
if result, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(controlFd), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&locked))); int(result) == -1 {
|
||||
return -1, -1, fmt.Errorf("error unlocking PTY descriptor: %v", err)
|
||||
return -1, -1, fmt.Errorf("unlocking PTY descriptor: %v", err)
|
||||
}
|
||||
// Get a handle for the other end.
|
||||
ptyFd, _, err := unix.Syscall(unix.SYS_IOCTL, uintptr(controlFd), unix.TIOCGPTPEER, unix.O_RDWR|unix.O_NOCTTY)
|
||||
if int(ptyFd) == -1 {
|
||||
if errno, isErrno := err.(syscall.Errno); !isErrno || (errno != syscall.EINVAL && errno != syscall.ENOTTY) {
|
||||
return -1, -1, fmt.Errorf("error getting PTY descriptor: %v", err)
|
||||
return -1, -1, fmt.Errorf("getting PTY descriptor: %v", err)
|
||||
}
|
||||
// EINVAL means the kernel's too old to understand TIOCGPTPEER. Try TIOCGPTN.
|
||||
ptyN, err := unix.IoctlGetInt(controlFd, unix.TIOCGPTN)
|
||||
if err != nil {
|
||||
return -1, -1, fmt.Errorf("error getting PTY number: %v", err)
|
||||
return -1, -1, fmt.Errorf("getting PTY number: %v", err)
|
||||
}
|
||||
ptyName := fmt.Sprintf("/dev/pts/%d", ptyN)
|
||||
fd, err := unix.Open(ptyName, unix.O_RDWR|unix.O_NOCTTY, 0620)
|
||||
if err != nil {
|
||||
return -1, -1, fmt.Errorf("error opening PTY %q: %v", ptyName, err)
|
||||
return -1, -1, fmt.Errorf("opening PTY %q: %v", ptyName, err)
|
||||
}
|
||||
ptyFd = uintptr(fd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user