mirror of
https://github.com/containers/podman.git
synced 2025-12-01 02:27:13 +08:00
vendor: update buildah to latest main
Includes one breaking change for the flag as BuildOutputs now accept a slice. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
63
vendor/github.com/containers/buildah/chroot/pty_posix.go
generated
vendored
63
vendor/github.com/containers/buildah/chroot/pty_posix.go
generated
vendored
@@ -1,63 +0,0 @@
|
||||
//go:build freebsd && cgo
|
||||
|
||||
package chroot
|
||||
|
||||
// #include <fcntl.h>
|
||||
// #include <stdlib.h>
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func openpt() (int, error) {
|
||||
fd, err := C.posix_openpt(C.O_RDWR)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
if _, err := C.grantpt(fd); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return int(fd), nil
|
||||
}
|
||||
|
||||
func ptsname(fd int) (string, error) {
|
||||
path, err := C.ptsname(C.int(fd))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return C.GoString(path), nil
|
||||
}
|
||||
|
||||
func unlockpt(fd int) error {
|
||||
if _, err := C.unlockpt(C.int(fd)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getPtyDescriptors() (int, int, error) {
|
||||
// Create a pseudo-terminal and open the control side
|
||||
controlFd, err := openpt()
|
||||
if err != nil {
|
||||
logrus.Errorf("error opening PTY control side using posix_openpt: %v", err)
|
||||
return -1, -1, err
|
||||
}
|
||||
if err = unlockpt(controlFd); err != nil {
|
||||
logrus.Errorf("error unlocking PTY: %v", err)
|
||||
return -1, -1, err
|
||||
}
|
||||
// Get a handle for the other end.
|
||||
ptyName, err := ptsname(controlFd)
|
||||
if err != nil {
|
||||
logrus.Errorf("error getting PTY name: %v", err)
|
||||
return -1, -1, err
|
||||
}
|
||||
ptyFd, err := unix.Open(ptyName, unix.O_RDWR, 0)
|
||||
if err != nil {
|
||||
logrus.Errorf("error opening PTY: %v", err)
|
||||
return -1, -1, err
|
||||
}
|
||||
return controlFd, ptyFd, nil
|
||||
}
|
||||
46
vendor/github.com/containers/buildah/chroot/pty_ptmx.go
generated
vendored
46
vendor/github.com/containers/buildah/chroot/pty_ptmx.go
generated
vendored
@@ -1,46 +0,0 @@
|
||||
//go:build linux
|
||||
|
||||
package chroot
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// Open a PTY using the /dev/ptmx device. The main advantage of using
|
||||
// this instead of posix_openpt is that it avoids cgo.
|
||||
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, 0o600)
|
||||
if err != nil {
|
||||
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("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("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("getting PTY number: %v", err)
|
||||
}
|
||||
ptyName := fmt.Sprintf("/dev/pts/%d", ptyN)
|
||||
fd, err := unix.Open(ptyName, unix.O_RDWR|unix.O_NOCTTY, 0o620)
|
||||
if err != nil {
|
||||
return -1, -1, fmt.Errorf("opening PTY %q: %v", ptyName, err)
|
||||
}
|
||||
ptyFd = uintptr(fd)
|
||||
}
|
||||
return controlFd, int(ptyFd), nil
|
||||
}
|
||||
11
vendor/github.com/containers/buildah/chroot/pty_unsupported.go
generated
vendored
11
vendor/github.com/containers/buildah/chroot/pty_unsupported.go
generated
vendored
@@ -1,11 +0,0 @@
|
||||
//go:build !linux && !(freebsd && cgo)
|
||||
|
||||
package chroot
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
func getPtyDescriptors() (int, int, error) {
|
||||
return -1, -1, errors.New("getPtyDescriptors not supported on this platform")
|
||||
}
|
||||
3
vendor/github.com/containers/buildah/chroot/run_common.go
generated
vendored
3
vendor/github.com/containers/buildah/chroot/run_common.go
generated
vendored
@@ -18,6 +18,7 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/containers/buildah/bind"
|
||||
"github.com/containers/buildah/internal/pty"
|
||||
"github.com/containers/buildah/util"
|
||||
"github.com/containers/storage/pkg/ioutils"
|
||||
"github.com/containers/storage/pkg/reexec"
|
||||
@@ -217,7 +218,7 @@ func runUsingChrootMain() {
|
||||
var stderr io.Writer
|
||||
fdDesc := make(map[int]string)
|
||||
if options.Spec.Process.Terminal {
|
||||
ptyMasterFd, ptyFd, err := getPtyDescriptors()
|
||||
ptyMasterFd, ptyFd, err := pty.GetPtyDescriptors()
|
||||
if err != nil {
|
||||
logrus.Errorf("error opening PTY descriptors: %v", err)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user