From 957ef9cc739b181f62afa80110dc3628dbe53b42 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 3 Mar 2017 10:35:14 -0800 Subject: [PATCH] Remove terminal info This maybe a nice extra but it adds complication to the usecase. The contract is listen on the socket and you get an fd to the pty master and that is that. Signed-off-by: Michael Crosby --- contrib/cmd/recvtty/recvtty.go | 15 --------- libcontainer/console.go | 56 ---------------------------------- utils_linux.go | 4 --- 3 files changed, 75 deletions(-) diff --git a/contrib/cmd/recvtty/recvtty.go b/contrib/cmd/recvtty/recvtty.go index 196b3283..177a8935 100644 --- a/contrib/cmd/recvtty/recvtty.go +++ b/contrib/cmd/recvtty/recvtty.go @@ -24,7 +24,6 @@ import ( "os" "strings" - "github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer/utils" "github.com/urfave/cli" ) @@ -102,13 +101,6 @@ func handleSingle(path string) error { return err } - // Print the file descriptor tag. - ti, err := libcontainer.GetTerminalInfo(master.Name()) - if err != nil { - return err - } - fmt.Printf("[recvtty] received masterfd: container '%s'\n", ti.ContainerID) - // Copy from our stdio to the master fd. quitChan := make(chan struct{}) go func() { @@ -163,13 +155,6 @@ func handleNull(path string) error { return } - // Print the file descriptor tag. - ti, err := libcontainer.GetTerminalInfo(master.Name()) - if err != nil { - bail(err) - } - fmt.Printf("[recvtty] received masterfd: container '%s'\n", ti.ContainerID) - // Just do a dumb copy to /dev/null. devnull, err := os.OpenFile("/dev/null", os.O_RDWR, 0) if err != nil { diff --git a/libcontainer/console.go b/libcontainer/console.go index d19043f4..917acc70 100644 --- a/libcontainer/console.go +++ b/libcontainer/console.go @@ -1,8 +1,6 @@ package libcontainer import ( - "encoding/json" - "fmt" "io" "os" ) @@ -17,57 +15,3 @@ type Console interface { // Fd returns the fd for the master of the pty. File() *os.File } - -const ( - TerminalInfoVersion uint32 = 201610041 - TerminalInfoType uint8 = 'T' -) - -// TerminalInfo is the structure which is passed as the non-ancillary data -// in the sendmsg(2) call when runc is run with --console-socket. It -// contains some information about the container which the console master fd -// relates to (to allow for consumers to use a single unix socket to handle -// multiple containers). This structure will probably move to runtime-spec -// at some point. But for now it lies in libcontainer. -type TerminalInfo struct { - // Version of the API. - Version uint32 `json:"version"` - - // Type of message (future proofing). - Type uint8 `json:"type"` - - // Container contains the ID of the container. - ContainerID string `json:"container_id"` -} - -func (ti *TerminalInfo) String() string { - encoded, err := json.Marshal(*ti) - if err != nil { - panic(err) - } - return string(encoded) -} - -func NewTerminalInfo(containerId string) *TerminalInfo { - return &TerminalInfo{ - Version: TerminalInfoVersion, - Type: TerminalInfoType, - ContainerID: containerId, - } -} - -func GetTerminalInfo(encoded string) (*TerminalInfo, error) { - ti := new(TerminalInfo) - if err := json.Unmarshal([]byte(encoded), ti); err != nil { - return nil, err - } - - if ti.Type != TerminalInfoType { - return nil, fmt.Errorf("terminal info: incorrect type in payload (%q): %q", TerminalInfoType, ti.Type) - } - if ti.Version != TerminalInfoVersion { - return nil, fmt.Errorf("terminal info: incorrect version in payload (%q): %q", TerminalInfoVersion, ti.Version) - } - - return ti, nil -} diff --git a/utils_linux.go b/utils_linux.go index 230578c8..dcf156c8 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -218,10 +218,6 @@ type runner struct { notifySocket *notifySocket } -func (r *runner) terminalinfo() *libcontainer.TerminalInfo { - return libcontainer.NewTerminalInfo(r.container.ID()) -} - func (r *runner) run(config *specs.Process) (int, error) { if err := r.checkTerminal(config); err != nil { r.destroy()