From b151a47d1becb1c4d4c1c1e44c1217163d491cc4 Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Tue, 4 Aug 2020 15:12:59 +0200 Subject: [PATCH] tests/e2e: Update github.com/creack/pty v1.1.7 -> v1.1.11 The fix is needed to mitigate consequences of https://github.com/golang/go/issues/29458 "golang breaking change" that causes following test failures on etcd end: --- FAIL: TestCtlV2Set (0.00s) ctl_v2_test.go:552: could not start etcd process cluster (fork/exec ../../bin/etcd: Setctty set but Ctty not valid in child) --- FAIL: TestCtlV2SetQuorum (0.00s) ctl_v2_test.go:552: could not start etcd process cluster (fork/exec ../../bin/etcd: Setctty set but Ctty not valid in child) --- FAIL: TestCtlV2SetClientTLS (0.00s) ctl_v2_test.go:552: could not start etcd process cluster (fork/exec ../../bin/etcd: Setctty set but Ctty not valid in child) --- go.mod | 2 +- go.sum | 2 + pkg/expect/expect.go | 1 + vendor/github.com/creack/pty/Dockerfile.riscv | 2 +- vendor/github.com/creack/pty/go.mod | 4 ++ vendor/github.com/creack/pty/run.go | 41 +++++++++++++------ .../creack/pty/test_crosscompile.sh | 2 +- .../creack/pty/ztypes_freebsd_arm64.go | 13 ++++++ ...bsd_386.go => ztypes_openbsd_32bit_int.go} | 4 +- .../creack/pty/ztypes_openbsd_amd64.go | 13 ------ vendor/modules.txt | 2 +- 11 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 vendor/github.com/creack/pty/go.mod create mode 100644 vendor/github.com/creack/pty/ztypes_freebsd_arm64.go rename vendor/github.com/creack/pty/{ztypes_openbsd_386.go => ztypes_openbsd_32bit_int.go} (61%) delete mode 100644 vendor/github.com/creack/pty/ztypes_openbsd_amd64.go diff --git a/go.mod b/go.mod index 67669b5c9..69723c32b 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa github.com/coreos/go-semver v0.2.0 github.com/coreos/go-systemd/v22 v22.0.0 - github.com/creack/pty v1.1.7 + github.com/creack/pty v1.1.11 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4 github.com/etcd-io/gofail v0.0.0-20190801230047-ad7f989257ca diff --git a/go.sum b/go.sum index 188099353..3491e1397 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,8 @@ github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQa github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= +github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/pkg/expect/expect.go b/pkg/expect/expect.go index 2e32eb526..b5c571e9b 100644 --- a/pkg/expect/expect.go +++ b/pkg/expect/expect.go @@ -13,6 +13,7 @@ // limitations under the License. // Package expect implements a small expect-style interface +// TODO(ptab): Consider migration to https://github.com/google/goexpect. package expect import ( diff --git a/vendor/github.com/creack/pty/Dockerfile.riscv b/vendor/github.com/creack/pty/Dockerfile.riscv index 476d8f11a..adfdf82c8 100644 --- a/vendor/github.com/creack/pty/Dockerfile.riscv +++ b/vendor/github.com/creack/pty/Dockerfile.riscv @@ -1,4 +1,4 @@ -FROM golang:1.12 +FROM golang:1.13 # Clone and complie a riscv compatible version of the go compiler. RUN git clone https://review.gerrithub.io/riscv/riscv-go /riscv-go diff --git a/vendor/github.com/creack/pty/go.mod b/vendor/github.com/creack/pty/go.mod new file mode 100644 index 000000000..e48decaf4 --- /dev/null +++ b/vendor/github.com/creack/pty/go.mod @@ -0,0 +1,4 @@ +module github.com/creack/pty + +go 1.13 + diff --git a/vendor/github.com/creack/pty/run.go b/vendor/github.com/creack/pty/run.go index 959be26b2..b07942514 100644 --- a/vendor/github.com/creack/pty/run.go +++ b/vendor/github.com/creack/pty/run.go @@ -11,6 +11,8 @@ import ( // Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, // and c.Stderr, calls c.Start, and returns the File of the tty's // corresponding pty. +// +// Starts the process in a new session and sets the controlling terminal. func Start(c *exec.Cmd) (pty *os.File, err error) { return StartWithSize(c, nil) } @@ -19,16 +21,35 @@ func Start(c *exec.Cmd) (pty *os.File, err error) { // and c.Stderr, calls c.Start, and returns the File of the tty's // corresponding pty. // -// This will resize the pty to the specified size before starting the command +// This will resize the pty to the specified size before starting the command. +// Starts the process in a new session and sets the controlling terminal. func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) { + if c.SysProcAttr == nil { + c.SysProcAttr = &syscall.SysProcAttr{} + } + c.SysProcAttr.Setsid = true + c.SysProcAttr.Setctty = true + return StartWithAttrs(c, sz, c.SysProcAttr) +} + +// StartWithAttrs assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, +// and c.Stderr, calls c.Start, and returns the File of the tty's +// corresponding pty. +// +// This will resize the pty to the specified size before starting the command if a size is provided. +// The `attrs` parameter overrides the one set in c.SysProcAttr. +// +// This should generally not be needed. Used in some edge cases where it is needed to create a pty +// without a controlling terminal. +func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (pty *os.File, err error) { pty, tty, err := Open() if err != nil { return nil, err } defer tty.Close() + if sz != nil { - err = Setsize(pty, sz) - if err != nil { + if err := Setsize(pty, sz); err != nil { pty.Close() return nil, err } @@ -42,15 +63,11 @@ func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) { if c.Stdin == nil { c.Stdin = tty } - if c.SysProcAttr == nil { - c.SysProcAttr = &syscall.SysProcAttr{} - } - c.SysProcAttr.Setctty = true - c.SysProcAttr.Setsid = true - c.SysProcAttr.Ctty = int(tty.Fd()) - err = c.Start() - if err != nil { - pty.Close() + + c.SysProcAttr = attrs + + if err := c.Start(); err != nil { + _ = pty.Close() return nil, err } return pty, err diff --git a/vendor/github.com/creack/pty/test_crosscompile.sh b/vendor/github.com/creack/pty/test_crosscompile.sh index f0b1dcac0..c4b9e3734 100644 --- a/vendor/github.com/creack/pty/test_crosscompile.sh +++ b/vendor/github.com/creack/pty/test_crosscompile.sh @@ -29,7 +29,7 @@ cross linux amd64 386 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips6 cross darwin amd64 386 arm arm64 cross freebsd amd64 386 arm cross netbsd amd64 386 arm -cross openbsd amd64 386 +cross openbsd amd64 386 arm arm64 cross dragonfly amd64 cross solaris amd64 diff --git a/vendor/github.com/creack/pty/ztypes_freebsd_arm64.go b/vendor/github.com/creack/pty/ztypes_freebsd_arm64.go new file mode 100644 index 000000000..4418139b2 --- /dev/null +++ b/vendor/github.com/creack/pty/ztypes_freebsd_arm64.go @@ -0,0 +1,13 @@ +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0xff +) + +type fiodgnameArg struct { + Len int32 + Buf *byte +} diff --git a/vendor/github.com/creack/pty/ztypes_openbsd_386.go b/vendor/github.com/creack/pty/ztypes_openbsd_32bit_int.go similarity index 61% rename from vendor/github.com/creack/pty/ztypes_openbsd_386.go rename to vendor/github.com/creack/pty/ztypes_openbsd_32bit_int.go index ccb3aab9a..d7cab4a2a 100644 --- a/vendor/github.com/creack/pty/ztypes_openbsd_386.go +++ b/vendor/github.com/creack/pty/ztypes_openbsd_32bit_int.go @@ -1,5 +1,5 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_openbsd.go +// +build openbsd +// +build 386 amd64 arm arm64 package pty diff --git a/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go b/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go deleted file mode 100644 index e67051688..000000000 --- a/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go +++ /dev/null @@ -1,13 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_openbsd.go - -package pty - -type ptmget struct { - Cfd int32 - Sfd int32 - Cn [16]int8 - Sn [16]int8 -} - -var ioctl_PTMGET = 0x40287401 diff --git a/vendor/modules.txt b/vendor/modules.txt index e58f81a57..498345f73 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -13,7 +13,7 @@ github.com/coreos/go-semver/semver ## explicit github.com/coreos/go-systemd/v22/daemon github.com/coreos/go-systemd/v22/journal -# github.com/creack/pty v1.1.7 +# github.com/creack/pty v1.1.11 ## explicit github.com/creack/pty # github.com/dgrijalva/jwt-go v3.2.0+incompatible