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 <crosbymichael@gmail.com>
This commit is contained in:
parent
00a0ecf554
commit
957ef9cc73
|
@ -24,7 +24,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/opencontainers/runc/libcontainer"
|
|
||||||
"github.com/opencontainers/runc/libcontainer/utils"
|
"github.com/opencontainers/runc/libcontainer/utils"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
@ -102,13 +101,6 @@ func handleSingle(path string) error {
|
||||||
return err
|
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.
|
// Copy from our stdio to the master fd.
|
||||||
quitChan := make(chan struct{})
|
quitChan := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -163,13 +155,6 @@ func handleNull(path string) error {
|
||||||
return
|
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.
|
// Just do a dumb copy to /dev/null.
|
||||||
devnull, err := os.OpenFile("/dev/null", os.O_RDWR, 0)
|
devnull, err := os.OpenFile("/dev/null", os.O_RDWR, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package libcontainer
|
package libcontainer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
@ -17,57 +15,3 @@ type Console interface {
|
||||||
// Fd returns the fd for the master of the pty.
|
// Fd returns the fd for the master of the pty.
|
||||||
File() *os.File
|
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
|
|
||||||
}
|
|
||||||
|
|
|
@ -218,10 +218,6 @@ type runner struct {
|
||||||
notifySocket *notifySocket
|
notifySocket *notifySocket
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runner) terminalinfo() *libcontainer.TerminalInfo {
|
|
||||||
return libcontainer.NewTerminalInfo(r.container.ID())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *runner) run(config *specs.Process) (int, error) {
|
func (r *runner) run(config *specs.Process) (int, error) {
|
||||||
if err := r.checkTerminal(config); err != nil {
|
if err := r.checkTerminal(config); err != nil {
|
||||||
r.destroy()
|
r.destroy()
|
||||||
|
|
Loading…
Reference in New Issue