diff --git a/go.mod b/go.mod index e0464db35..5d9219c47 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 github.com/blang/semver v3.5.1+incompatible github.com/cpuguy83/go-md2man v1.0.10 - github.com/creack/pty v1.1.23 + github.com/creack/pty v1.1.24 github.com/docker/cli v27.3.1+incompatible github.com/docker/docker v27.3.1+incompatible github.com/fatih/color v1.18.0 diff --git a/go.sum b/go.sum index e6c15b1fe..72d3e58c0 100644 --- a/go.sum +++ b/go.sum @@ -370,8 +370,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/creack/pty v1.1.23 h1:4M6+isWdcStXEf15G/RbrMPOQj1dZ7HPZCGwE4kOeP0= -github.com/creack/pty v1.1.23/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= +github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= +github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/cyberphone/json-canonicalization v0.0.0-20231011164504-785e29786b46 h1:2Dx4IHfC1yHWI12AxQDJM1QbRCDfk6M+blLzlZCXdrc= github.com/cyberphone/json-canonicalization v0.0.0-20231011164504-785e29786b46/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= diff --git a/vendor/github.com/creack/pty/pty_unsupported.go b/vendor/github.com/creack/pty/pty_unsupported.go index c771020fa..0971dc74e 100644 --- a/vendor/github.com/creack/pty/pty_unsupported.go +++ b/vendor/github.com/creack/pty/pty_unsupported.go @@ -1,5 +1,5 @@ -//go:build !linux && !darwin && !freebsd && !dragonfly && !netbsd && !openbsd && !solaris -// +build !linux,!darwin,!freebsd,!dragonfly,!netbsd,!openbsd,!solaris +//go:build !linux && !darwin && !freebsd && !dragonfly && !netbsd && !openbsd && !solaris && !zos +// +build !linux,!darwin,!freebsd,!dragonfly,!netbsd,!openbsd,!solaris,!zos package pty diff --git a/vendor/github.com/creack/pty/pty_zos.go b/vendor/github.com/creack/pty/pty_zos.go new file mode 100644 index 000000000..18e61e196 --- /dev/null +++ b/vendor/github.com/creack/pty/pty_zos.go @@ -0,0 +1,141 @@ +//go:build zos +// +build zos + +package pty + +import ( + "os" + "runtime" + "syscall" + "unsafe" +) + +const ( + SYS_UNLOCKPT = 0x37B + SYS_GRANTPT = 0x37A + SYS_POSIX_OPENPT = 0xC66 + SYS_FCNTL = 0x18C + SYS___PTSNAME_A = 0x718 + + SETCVTON = 1 + + O_NONBLOCK = 0x04 + + F_SETFL = 4 + F_CONTROL_CVT = 13 +) + +type f_cnvrt struct { + Cvtcmd int32 + Pccsid int16 + Fccsid int16 +} + +func open() (pty, tty *os.File, err error) { + ptmxfd, err := openpt(os.O_RDWR | syscall.O_NOCTTY) + if err != nil { + return nil, nil, err + } + + // Needed for z/OS so that the characters are not garbled if ptyp* is untagged + cvtreq := f_cnvrt{Cvtcmd: SETCVTON, Pccsid: 0, Fccsid: 1047} + if _, err = fcntl(uintptr(ptmxfd), F_CONTROL_CVT, uintptr(unsafe.Pointer(&cvtreq))); err != nil { + return nil, nil, err + } + + p := os.NewFile(uintptr(ptmxfd), "/dev/ptmx") + if p == nil { + return nil, nil, err + } + + // In case of error after this point, make sure we close the ptmx fd. + defer func() { + if err != nil { + _ = p.Close() // Best effort. + } + }() + + sname, err := ptsname(ptmxfd) + if err != nil { + return nil, nil, err + } + + _, err = grantpt(ptmxfd) + if err != nil { + return nil, nil, err + } + + if _, err = unlockpt(ptmxfd); err != nil { + return nil, nil, err + } + + ptsfd, err := syscall.Open(sname, os.O_RDWR|syscall.O_NOCTTY, 0) + if err != nil { + return nil, nil, err + } + + if _, err = fcntl(uintptr(ptsfd), F_CONTROL_CVT, uintptr(unsafe.Pointer(&cvtreq))); err != nil { + return nil, nil, err + } + + t := os.NewFile(uintptr(ptsfd), sname) + if err != nil { + return nil, nil, err + } + + return p, t, nil +} + +func openpt(oflag int) (fd int, err error) { + r0, _, e1 := runtime.CallLeFuncWithErr(runtime.GetZosLibVec()+SYS_POSIX_OPENPT<<4, uintptr(oflag)) + fd = int(r0) + if e1 != 0 { + err = syscall.Errno(e1) + } + return +} + +func fcntl(fd uintptr, cmd int, arg uintptr) (val int, err error) { + r0, _, e1 := runtime.CallLeFuncWithErr(runtime.GetZosLibVec()+SYS_FCNTL<<4, uintptr(fd), uintptr(cmd), arg) + val = int(r0) + if e1 != 0 { + err = syscall.Errno(e1) + } + return +} + +func ptsname(fd int) (name string, err error) { + r0, _, e1 := runtime.CallLeFuncWithPtrReturn(runtime.GetZosLibVec()+SYS___PTSNAME_A<<4, uintptr(fd)) + name = u2s(unsafe.Pointer(r0)) + if e1 != 0 { + err = syscall.Errno(e1) + } + return +} + +func grantpt(fildes int) (rc int, err error) { + r0, _, e1 := runtime.CallLeFuncWithErr(runtime.GetZosLibVec()+SYS_GRANTPT<<4, uintptr(fildes)) + rc = int(r0) + if e1 != 0 { + err = syscall.Errno(e1) + } + return +} + +func unlockpt(fildes int) (rc int, err error) { + r0, _, e1 := runtime.CallLeFuncWithErr(runtime.GetZosLibVec()+SYS_UNLOCKPT<<4, uintptr(fildes)) + rc = int(r0) + if e1 != 0 { + err = syscall.Errno(e1) + } + return +} + +func u2s(cstr unsafe.Pointer) string { + str := (*[1024]uint8)(cstr) + i := 0 + for str[i] != 0 { + i++ + } + return string(str[:i]) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 173a4ddfb..bc98a02e8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -486,7 +486,7 @@ github.com/coreos/go-oidc/v3/oidc # github.com/cpuguy83/go-md2man v1.0.10 ## explicit; go 1.12 github.com/cpuguy83/go-md2man/md2man -# github.com/creack/pty v1.1.23 +# github.com/creack/pty v1.1.24 ## explicit; go 1.18 github.com/creack/pty # github.com/cyberphone/json-canonicalization v0.0.0-20231011164504-785e29786b46