diff --git a/containerd-shim/main.go b/containerd-shim/main.go index 64aec33..50ed461 100644 --- a/containerd-shim/main.go +++ b/containerd-shim/main.go @@ -10,7 +10,7 @@ import ( "syscall" "github.com/containerd/containerd/osutils" - "github.com/crosbymichael/console" + "github.com/containerd/console" ) func writeMessage(f *os.File, level string, err error) { diff --git a/containerd-shim/process.go b/containerd-shim/process.go index 45951a1..a9cdd4b 100644 --- a/containerd-shim/process.go +++ b/containerd-shim/process.go @@ -17,8 +17,8 @@ import ( "github.com/containerd/containerd/osutils" "github.com/containerd/containerd/specs" - "github.com/crosbymichael/console" - runc "github.com/crosbymichael/go-runc" + "github.com/containerd/console" + runc "github.com/containerd/go-runc" ) var errRuntime = errors.New("shim: runtime execution error") diff --git a/containerd-shim/process_linux.go b/containerd-shim/process_linux.go index c271493..eed0c62 100644 --- a/containerd-shim/process_linux.go +++ b/containerd-shim/process_linux.go @@ -10,8 +10,8 @@ import ( "time" "github.com/containerd/containerd/osutils" - "github.com/crosbymichael/console" - runc "github.com/crosbymichael/go-runc" + "github.com/containerd/console" + runc "github.com/containerd/go-runc" "github.com/tonistiigi/fifo" "golang.org/x/net/context" ) diff --git a/ctr/container.go b/ctr/container.go index 86398d5..8b0d107 100644 --- a/ctr/container.go +++ b/ctr/container.go @@ -18,7 +18,7 @@ import ( "github.com/containerd/containerd/api/grpc/types" "github.com/containerd/containerd/specs" - "github.com/crosbymichael/console" + "github.com/containerd/console" "github.com/golang/protobuf/ptypes" "github.com/urfave/cli" netcontext "golang.org/x/net/context" diff --git a/hack/vendor.sh b/hack/vendor.sh index b35bd1c..a792b09 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -31,8 +31,8 @@ clone git github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 clone git github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 clone git github.com/go-check/check a625211d932a2a643d0d17352095f03fb7774663 https://github.com/cpuguy83/check.git -clone git github.com/crosbymichael/console 8ea0f623ee22736eec36b4ec87664b1d82cf9d15 -clone git github.com/crosbymichael/go-runc 980b32fc0fe2280022206962a536657010d9e072 +clone git github.com/containerd/console a3863895279f5104533fd999c1babf80faffd98c +clone git github.com/containerd/go-runc 5fe4d8cb7fdc0fae5f5a7f4f1d65a565032401b2 # dependencies of docker/pkg/listeners clone git github.com/docker/go-connections v0.2.0 diff --git a/vendor/src/github.com/crosbymichael/console/.travis.yml b/vendor/src/github.com/containerd/console/.travis.yml similarity index 100% rename from vendor/src/github.com/crosbymichael/console/.travis.yml rename to vendor/src/github.com/containerd/console/.travis.yml diff --git a/vendor/src/github.com/crosbymichael/console/LICENSE b/vendor/src/github.com/containerd/console/LICENSE similarity index 100% rename from vendor/src/github.com/crosbymichael/console/LICENSE rename to vendor/src/github.com/containerd/console/LICENSE diff --git a/vendor/src/github.com/crosbymichael/console/README.md b/vendor/src/github.com/containerd/console/README.md similarity index 91% rename from vendor/src/github.com/crosbymichael/console/README.md rename to vendor/src/github.com/containerd/console/README.md index b2e38bb..3881cd4 100644 --- a/vendor/src/github.com/crosbymichael/console/README.md +++ b/vendor/src/github.com/containerd/console/README.md @@ -1,6 +1,6 @@ # console -[![Build Status](https://travis-ci.org/crosbymichael/console.svg?branch=master)](https://travis-ci.org/crosbymichael/console) +[![Build Status](https://travis-ci.org/containerd/console.svg?branch=master)](https://travis-ci.org/containerd/console) Golang package for dealing with consoles. Light on deps and a simple API. diff --git a/vendor/src/github.com/crosbymichael/console/console.go b/vendor/src/github.com/containerd/console/console.go similarity index 91% rename from vendor/src/github.com/crosbymichael/console/console.go rename to vendor/src/github.com/containerd/console/console.go index a1d392c..08d255d 100644 --- a/vendor/src/github.com/crosbymichael/console/console.go +++ b/vendor/src/github.com/containerd/console/console.go @@ -20,6 +20,8 @@ type Console interface { ResizeFrom(Console) error // SetRaw sets the console in raw mode SetRaw() error + // DisableEcho disables echo on the console + DisableEcho() error // Reset restores the console to its orignal state Reset() error // Size returns the window size of the console @@ -28,12 +30,12 @@ type Console interface { // WinSize specifies the window size of the console type WinSize struct { - // Width of the console - Width uint16 // Height of the console Height uint16 - x uint16 - y uint16 + // Width of the console + Width uint16 + x uint16 + y uint16 } // Current returns the current processes console diff --git a/vendor/src/github.com/crosbymichael/console/console_unix.go b/vendor/src/github.com/containerd/console/console_unix.go similarity index 75% rename from vendor/src/github.com/crosbymichael/console/console_unix.go rename to vendor/src/github.com/containerd/console/console_unix.go index a259150..fb27011 100644 --- a/vendor/src/github.com/crosbymichael/console/console_unix.go +++ b/vendor/src/github.com/containerd/console/console_unix.go @@ -1,3 +1,5 @@ +// +build darwin freebsd linux + package console // #include @@ -34,8 +36,8 @@ func NewPty() (Console, string, error) { } type master struct { - f *os.File - termios *unix.Termios + f *os.File + original *unix.Termios } func (m *master) Read(b []byte) (int, error) { @@ -67,23 +69,42 @@ func (m *master) ResizeFrom(c Console) error { } func (m *master) Reset() error { - if m.termios == nil { + if m.original == nil { return nil } - return tcset(m.f.Fd(), m.termios) + return tcset(m.f.Fd(), m.original) +} + +func (m *master) getCurrent() (unix.Termios, error) { + var termios unix.Termios + if err := tcget(m.f.Fd(), &termios); err != nil { + return unix.Termios{}, err + } + if m.original == nil { + m.original = &termios + } + return termios, nil } func (m *master) SetRaw() error { - m.termios = &unix.Termios{} - if err := tcget(m.f.Fd(), m.termios); err != nil { + rawState, err := m.getCurrent() + if err != nil { return err } - rawState := *m.termios C.cfmakeraw((*C.struct_termios)(unsafe.Pointer(&rawState))) rawState.Oflag = rawState.Oflag | C.OPOST return tcset(m.f.Fd(), &rawState) } +func (m *master) DisableEcho() error { + rawState, err := m.getCurrent() + if err != nil { + return err + } + rawState.Lflag = rawState.Lflag &^ unix.ECHO + return tcset(m.f.Fd(), &rawState) +} + func (m *master) Size() (WinSize, error) { var ws WinSize if err := ioctl( diff --git a/vendor/src/github.com/crosbymichael/console/console_windows.go b/vendor/src/github.com/containerd/console/console_windows.go similarity index 93% rename from vendor/src/github.com/crosbymichael/console/console_windows.go rename to vendor/src/github.com/containerd/console/console_windows.go index 0dcefff..8d133ea 100644 --- a/vendor/src/github.com/crosbymichael/console/console_windows.go +++ b/vendor/src/github.com/containerd/console/console_windows.go @@ -126,6 +126,18 @@ func (m *master) ResizeFrom(c Console) error { return ErrNotImplemented } +func (m *master) DisableEcho() error { + mode := m.inMode &^ winterm.ENABLE_ECHO_INPUT + mode |= winterm.ENABLE_PROCESSED_INPUT + mode |= winterm.ENABLE_LINE_INPUT + + if err := winterm.SetConsoleMode(m.in, mode); err != nil { + return errors.Wrap(err, "unable to set console to disable echo") + } + + return nil +} + func (m *master) Close() error { return nil } diff --git a/vendor/src/github.com/crosbymichael/console/tc_unix.go b/vendor/src/github.com/containerd/console/tc_darwin.go similarity index 98% rename from vendor/src/github.com/crosbymichael/console/tc_unix.go rename to vendor/src/github.com/containerd/console/tc_darwin.go index d2c481b..d86c315 100644 --- a/vendor/src/github.com/crosbymichael/console/tc_unix.go +++ b/vendor/src/github.com/containerd/console/tc_darwin.go @@ -1,5 +1,3 @@ -// +build !linux - package console import ( diff --git a/vendor/src/github.com/containerd/console/tc_freebsd.go b/vendor/src/github.com/containerd/console/tc_freebsd.go new file mode 100644 index 0000000..478f60a --- /dev/null +++ b/vendor/src/github.com/containerd/console/tc_freebsd.go @@ -0,0 +1,51 @@ +package console + +import ( + "fmt" + "os" + "unsafe" + + "golang.org/x/sys/unix" +) + +func tcget(fd uintptr, p *unix.Termios) error { + return ioctl(fd, unix.TIOCGETA, uintptr(unsafe.Pointer(p))) +} + +func tcset(fd uintptr, p *unix.Termios) error { + return ioctl(fd, unix.TIOCSETA, uintptr(unsafe.Pointer(p))) +} + +func ioctl(fd, flag, data uintptr) error { + if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, flag, data); err != 0 { + return err + } + return nil +} + +// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. +// unlockpt should be called before opening the slave side of a pty. +// This does not exist on FreeBSD, it does not allocate controlling terminals on open +func unlockpt(f *os.File) error { + return nil +} + +// ptsname retrieves the name of the first available pts for the given master. +func ptsname(f *os.File) (string, error) { + var n int32 + if err := ioctl(f.Fd(), unix.TIOCGPTN, uintptr(unsafe.Pointer(&n))); err != nil { + return "", err + } + return fmt.Sprintf("/dev/pts/%d", n), nil +} + +func saneTerminal(f *os.File) error { + // Go doesn't have a wrapper for any of the termios ioctls. + var termios unix.Termios + if err := tcget(f.Fd(), &termios); err != nil { + return err + } + // Set -onlcr so we don't have to deal with \r. + termios.Oflag &^= unix.ONLCR + return tcset(f.Fd(), &termios) +} diff --git a/vendor/src/github.com/crosbymichael/console/tc_linux.go b/vendor/src/github.com/containerd/console/tc_linux.go similarity index 100% rename from vendor/src/github.com/crosbymichael/console/tc_linux.go rename to vendor/src/github.com/containerd/console/tc_linux.go diff --git a/vendor/src/github.com/crosbymichael/go-runc/.travis.yml b/vendor/src/github.com/containerd/go-runc/.travis.yml similarity index 100% rename from vendor/src/github.com/crosbymichael/go-runc/.travis.yml rename to vendor/src/github.com/containerd/go-runc/.travis.yml diff --git a/vendor/src/github.com/crosbymichael/go-runc/LICENSE b/vendor/src/github.com/containerd/go-runc/LICENSE similarity index 100% rename from vendor/src/github.com/crosbymichael/go-runc/LICENSE rename to vendor/src/github.com/containerd/go-runc/LICENSE diff --git a/vendor/src/github.com/crosbymichael/go-runc/README.md b/vendor/src/github.com/containerd/go-runc/README.md similarity index 87% rename from vendor/src/github.com/crosbymichael/go-runc/README.md rename to vendor/src/github.com/containerd/go-runc/README.md index bf57843..2629773 100644 --- a/vendor/src/github.com/crosbymichael/go-runc/README.md +++ b/vendor/src/github.com/containerd/go-runc/README.md @@ -1,6 +1,6 @@ # go-runc -[![Build Status](https://travis-ci.org/crosbymichael/go-runc.svg?branch=master)](https://travis-ci.org/crosbymichael/go-runc) +[![Build Status](https://travis-ci.org/containerd/go-runc.svg?branch=master)](https://travis-ci.org/containerd/go-runc) This is a package for consuming the [runc](https://github.com/opencontainers/runc) binary in your Go applications. @@ -11,7 +11,7 @@ or greater. ## Docs -Docs can be found at [godoc.org](https://godoc.org/github.com/crosbymichael/go-runc). +Docs can be found at [godoc.org](https://godoc.org/github.com/containerd/go-runc). ## LICENSE - MIT diff --git a/vendor/src/github.com/crosbymichael/go-runc/console.go b/vendor/src/github.com/containerd/go-runc/console.go similarity index 98% rename from vendor/src/github.com/crosbymichael/go-runc/console.go rename to vendor/src/github.com/containerd/go-runc/console.go index ee22964..d84bd9f 100644 --- a/vendor/src/github.com/crosbymichael/go-runc/console.go +++ b/vendor/src/github.com/containerd/go-runc/console.go @@ -9,7 +9,7 @@ import ( "os" "path/filepath" - "github.com/crosbymichael/console" + "github.com/containerd/console" "github.com/opencontainers/runc/libcontainer/utils" ) diff --git a/vendor/src/github.com/crosbymichael/go-runc/container.go b/vendor/src/github.com/containerd/go-runc/container.go similarity index 100% rename from vendor/src/github.com/crosbymichael/go-runc/container.go rename to vendor/src/github.com/containerd/go-runc/container.go diff --git a/vendor/src/github.com/crosbymichael/go-runc/events.go b/vendor/src/github.com/containerd/go-runc/events.go similarity index 100% rename from vendor/src/github.com/crosbymichael/go-runc/events.go rename to vendor/src/github.com/containerd/go-runc/events.go diff --git a/vendor/src/github.com/crosbymichael/go-runc/io.go b/vendor/src/github.com/containerd/go-runc/io.go similarity index 100% rename from vendor/src/github.com/crosbymichael/go-runc/io.go rename to vendor/src/github.com/containerd/go-runc/io.go diff --git a/vendor/src/github.com/crosbymichael/go-runc/monitor.go b/vendor/src/github.com/containerd/go-runc/monitor.go similarity index 100% rename from vendor/src/github.com/crosbymichael/go-runc/monitor.go rename to vendor/src/github.com/containerd/go-runc/monitor.go diff --git a/vendor/src/github.com/crosbymichael/go-runc/runc.go b/vendor/src/github.com/containerd/go-runc/runc.go similarity index 100% rename from vendor/src/github.com/crosbymichael/go-runc/runc.go rename to vendor/src/github.com/containerd/go-runc/runc.go diff --git a/vendor/src/github.com/crosbymichael/go-runc/utils.go b/vendor/src/github.com/containerd/go-runc/utils.go similarity index 100% rename from vendor/src/github.com/crosbymichael/go-runc/utils.go rename to vendor/src/github.com/containerd/go-runc/utils.go