From ed811896edb629627434490f609bca22a95c9487 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 25 Sep 2017 11:58:12 -0400 Subject: [PATCH 1/2] Update console dep to 84eeaae905fa414d03e07bcd6c8d This change removes the ClearONLCR from the console package providing a console with the default settings from the console package. Signed-off-by: Michael Crosby --- vendor.conf | 2 +- .../github.com/containerd/console/console.go | 10 ++++-- .../containerd/console/console_unix.go | 36 +++++++++++-------- .../containerd/console/console_windows.go | 8 ++--- .../github.com/containerd/console/tc_unix.go | 17 +++++---- 5 files changed, 44 insertions(+), 29 deletions(-) diff --git a/vendor.conf b/vendor.conf index abb7383d5..0bf7d7480 100644 --- a/vendor.conf +++ b/vendor.conf @@ -1,6 +1,6 @@ github.com/coreos/go-systemd 48702e0da86bd25e76cfef347e2adeb434a0d0a6 github.com/containerd/go-runc b3c048c028ddd789c6f9510c597f8b9c62f25359 -github.com/containerd/console b28c739c79ce69d017e3691ad3664568d68e95c6 +github.com/containerd/console 84eeaae905fa414d03e07bcd6c8d3f19e7cf180e github.com/containerd/cgroups 5933ab4dc4f7caa3a73a1dc141bd11f42b5c9163 github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788 github.com/docker/go-metrics 8fd5772bf1584597834c6f7961a530f06cbfbb87 diff --git a/vendor/github.com/containerd/console/console.go b/vendor/github.com/containerd/console/console.go index 6f1cca966..bf2798fda 100644 --- a/vendor/github.com/containerd/console/console.go +++ b/vendor/github.com/containerd/console/console.go @@ -44,7 +44,13 @@ type WinSize struct { // Current returns the current processes console func Current() Console { - return newMaster(os.Stdin) + c, err := ConsoleFromFile(os.Stdin) + if err != nil { + // stdin should always be a console for the design + // of this function + panic(err) + } + return c } // ConsoleFromFile returns a console using the provided file @@ -52,5 +58,5 @@ func ConsoleFromFile(f *os.File) (Console, error) { if err := checkConsole(f); err != nil { return nil, err } - return newMaster(f), nil + return newMaster(f) } diff --git a/vendor/github.com/containerd/console/console_unix.go b/vendor/github.com/containerd/console/console_unix.go index 008de54ac..118c8c3ab 100644 --- a/vendor/github.com/containerd/console/console_unix.go +++ b/vendor/github.com/containerd/console/console_unix.go @@ -16,9 +16,6 @@ func NewPty() (Console, string, error) { if err != nil { return nil, "", err } - if err := saneTerminal(f); err != nil { - return nil, "", err - } slave, err := ptsname(f) if err != nil { return nil, "", err @@ -26,9 +23,11 @@ func NewPty() (Console, string, error) { if err := unlockpt(f); err != nil { return nil, "", err } - return &master{ - f: f, - }, slave, nil + m, err := newMaster(f) + if err != nil { + return nil, "", err + } + return m, slave, nil } type master struct { @@ -72,9 +71,6 @@ func (m *master) getCurrent() (unix.Termios, error) { if err := tcget(m.f.Fd(), &termios); err != nil { return unix.Termios{}, err } - if m.original == nil { - m.original = &termios - } return termios, nil } @@ -118,17 +114,29 @@ func checkConsole(f *os.File) error { return nil } -func newMaster(f *os.File) Console { - return &master{ +func newMaster(f *os.File) (Console, error) { + m := &master{ f: f, } + t, err := m.getCurrent() + if err != nil { + return nil, err + } + m.original = &t + return m, nil } -// SaneTerminal sets the necessary tty_ioctl(4)s to ensure that a pty pair +// ClearONLCR sets the necessary tty_ioctl(4)s to ensure that a pty pair // created by us acts normally. In particular, a not-very-well-known default of // Linux unix98 ptys is that they have +onlcr by default. While this isn't a // problem for terminal emulators, because we relay data from the terminal we // also relay that funky line discipline. -func SaneTerminal(f *os.File) error { - return saneTerminal(f) +func ClearONLCR(fd uintptr) error { + return setONLCR(fd, false) +} + +// SetONLCR sets the necessary tty_ioctl(4)s to ensure that a pty pair +// created by us acts as intended for a terminal emulator. +func SetONLCR(fd uintptr) error { + return setONLCR(fd, true) } diff --git a/vendor/github.com/containerd/console/console_windows.go b/vendor/github.com/containerd/console/console_windows.go index 6c874d3e6..d78a0b841 100644 --- a/vendor/github.com/containerd/console/console_windows.go +++ b/vendor/github.com/containerd/console/console_windows.go @@ -190,13 +190,11 @@ func checkConsole(f *os.File) error { return nil } -func newMaster(f *os.File) Console { +func newMaster(f *os.File) (Console, error) { if f != os.Stdin && f != os.Stdout && f != os.Stderr { - panic("creating a console from a file is not supported on windows") + return nil, errors.New("creating a console from a file is not supported on windows") } - m := &master{} m.initStdios() - - return m + return m, nil } diff --git a/vendor/github.com/containerd/console/tc_unix.go b/vendor/github.com/containerd/console/tc_unix.go index 94dee9716..df7dcb933 100644 --- a/vendor/github.com/containerd/console/tc_unix.go +++ b/vendor/github.com/containerd/console/tc_unix.go @@ -3,8 +3,6 @@ package console import ( - "os" - "golang.org/x/sys/unix" ) @@ -49,14 +47,19 @@ func tcswinsz(fd uintptr, ws WinSize) error { return unix.IoctlSetWinsize(int(fd), unix.TIOCSWINSZ, &uws) } -func saneTerminal(f *os.File) error { +func setONLCR(fd uintptr, enable bool) error { var termios unix.Termios - if err := tcget(f.Fd(), &termios); err != nil { + if err := tcget(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) + if enable { + // Set +onlcr so we can act like a real terminal + termios.Oflag |= unix.ONLCR + } else { + // Set -onlcr so we don't have to deal with \r. + termios.Oflag &^= unix.ONLCR + } + return tcset(fd, &termios) } func cfmakeraw(t unix.Termios) unix.Termios { From cf2c4609bdc2165a52138bd47a8c9ac76cb1d0ed Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 26 Sep 2017 10:21:21 -0400 Subject: [PATCH 2/2] Bump runc with console change for ONLCR Signed-off-by: Michael Crosby --- .travis.yml | 2 +- RUNC.md | 2 +- vendor.conf | 2 +- vendor/github.com/opencontainers/runc/vendor.conf | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 760071043..8d0ac7839 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ install: - wget https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip -O /tmp/protoc-3.3.0-linux-x86_64.zip - sudo unzip -o -d /usr/local /tmp/protoc-3.3.0-linux-x86_64.zip - go get -u github.com/vbatts/git-validation - - sudo wget https://github.com/crosbymichael/runc/releases/download/ctd-5/runc -O /bin/runc; sudo chmod +x /bin/runc + - sudo wget https://github.com/crosbymichael/runc/releases/download/ctd-6/runc -O /bin/runc; sudo chmod +x /bin/runc - wget https://github.com/xemul/criu/archive/v3.0.tar.gz -O /tmp/criu.tar.gz - tar -C /tmp/ -zxf /tmp/criu.tar.gz - cd /tmp/criu-3.0 && sudo make install-criu diff --git a/RUNC.md b/RUNC.md index 17fefaf6f..9390fd842 100644 --- a/RUNC.md +++ b/RUNC.md @@ -2,7 +2,7 @@ containerd is built with OCI support and with support for advanced features prov We depend on a specific `runc` version when dealing with advanced features. You should have a specific runc build for development. The current supported runc commit is: -RUNC_COMMIT = 593914b8bd5448a93f7c3e4902a03408b6d5c0ce +RUNC_COMMIT = 0351df1c5a66838d0c392b4ac4cf9450de844e2d For more information on how to clone and build runc see the runc Building [documentation](https://github.com/opencontainers/runc#building). diff --git a/vendor.conf b/vendor.conf index 0bf7d7480..80fffc24d 100644 --- a/vendor.conf +++ b/vendor.conf @@ -16,7 +16,7 @@ github.com/docker/go-units v0.3.1 github.com/gogo/protobuf d2e1ade2d719b78fe5b061b4c18a9f7111b5bdc8 github.com/golang/protobuf 5a0f697c9ed9d68fef0116532c6e05cfeae00e55 github.com/opencontainers/runtime-spec v1.0.0 -github.com/opencontainers/runc 593914b8bd5448a93f7c3e4902a03408b6d5c0ce +github.com/opencontainers/runc 0351df1c5a66838d0c392b4ac4cf9450de844e2d github.com/sirupsen/logrus v1.0.0 github.com/containerd/btrfs cc52c4dea2ce11a44e6639e561bb5c2af9ada9e3 github.com/stretchr/testify v1.1.4 diff --git a/vendor/github.com/opencontainers/runc/vendor.conf b/vendor/github.com/opencontainers/runc/vendor.conf index 574a01a4b..1266ee485 100644 --- a/vendor/github.com/opencontainers/runc/vendor.conf +++ b/vendor/github.com/opencontainers/runc/vendor.conf @@ -18,9 +18,8 @@ github.com/golang/protobuf 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8 github.com/docker/docker 0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d github.com/docker/go-units v0.2.0 github.com/urfave/cli d53eb991652b1d438abdd34ce4bfa3ef1539108e -golang.org/x/sys 0e0164865330d5cf1c00247be08330bf96e2f87c https://github.com/golang/sys +golang.org/x/sys 7ddbeae9ae08c6a06a59597f0c9edbc5ff2444ce https://github.com/golang/sys # console dependencies -github.com/containerd/console 2ce1c681f3c3c0dfa7d0af289428d36567c9a6bc -github.com/Azure/go-ansiterm fa152c58bc15761d0200cb75fe958b89a9d4888e +github.com/containerd/console 84eeaae905fa414d03e07bcd6c8d3f19e7cf180e github.com/pkg/errors v0.8.0