Skip to content

Commit 957ef9c

Browse files
committed
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 <[email protected]>
1 parent 00a0ecf commit 957ef9c

File tree

3 files changed

+0
-75
lines changed

3 files changed

+0
-75
lines changed

contrib/cmd/recvtty/recvtty.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"os"
2525
"strings"
2626

27-
"github.com/opencontainers/runc/libcontainer"
2827
"github.com/opencontainers/runc/libcontainer/utils"
2928
"github.com/urfave/cli"
3029
)
@@ -102,13 +101,6 @@ func handleSingle(path string) error {
102101
return err
103102
}
104103

105-
// Print the file descriptor tag.
106-
ti, err := libcontainer.GetTerminalInfo(master.Name())
107-
if err != nil {
108-
return err
109-
}
110-
fmt.Printf("[recvtty] received masterfd: container '%s'\n", ti.ContainerID)
111-
112104
// Copy from our stdio to the master fd.
113105
quitChan := make(chan struct{})
114106
go func() {
@@ -163,13 +155,6 @@ func handleNull(path string) error {
163155
return
164156
}
165157

166-
// Print the file descriptor tag.
167-
ti, err := libcontainer.GetTerminalInfo(master.Name())
168-
if err != nil {
169-
bail(err)
170-
}
171-
fmt.Printf("[recvtty] received masterfd: container '%s'\n", ti.ContainerID)
172-
173158
// Just do a dumb copy to /dev/null.
174159
devnull, err := os.OpenFile("/dev/null", os.O_RDWR, 0)
175160
if err != nil {

libcontainer/console.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package libcontainer
22

33
import (
4-
"encoding/json"
5-
"fmt"
64
"io"
75
"os"
86
)
@@ -17,57 +15,3 @@ type Console interface {
1715
// Fd returns the fd for the master of the pty.
1816
File() *os.File
1917
}
20-
21-
const (
22-
TerminalInfoVersion uint32 = 201610041
23-
TerminalInfoType uint8 = 'T'
24-
)
25-
26-
// TerminalInfo is the structure which is passed as the non-ancillary data
27-
// in the sendmsg(2) call when runc is run with --console-socket. It
28-
// contains some information about the container which the console master fd
29-
// relates to (to allow for consumers to use a single unix socket to handle
30-
// multiple containers). This structure will probably move to runtime-spec
31-
// at some point. But for now it lies in libcontainer.
32-
type TerminalInfo struct {
33-
// Version of the API.
34-
Version uint32 `json:"version"`
35-
36-
// Type of message (future proofing).
37-
Type uint8 `json:"type"`
38-
39-
// Container contains the ID of the container.
40-
ContainerID string `json:"container_id"`
41-
}
42-
43-
func (ti *TerminalInfo) String() string {
44-
encoded, err := json.Marshal(*ti)
45-
if err != nil {
46-
panic(err)
47-
}
48-
return string(encoded)
49-
}
50-
51-
func NewTerminalInfo(containerId string) *TerminalInfo {
52-
return &TerminalInfo{
53-
Version: TerminalInfoVersion,
54-
Type: TerminalInfoType,
55-
ContainerID: containerId,
56-
}
57-
}
58-
59-
func GetTerminalInfo(encoded string) (*TerminalInfo, error) {
60-
ti := new(TerminalInfo)
61-
if err := json.Unmarshal([]byte(encoded), ti); err != nil {
62-
return nil, err
63-
}
64-
65-
if ti.Type != TerminalInfoType {
66-
return nil, fmt.Errorf("terminal info: incorrect type in payload (%q): %q", TerminalInfoType, ti.Type)
67-
}
68-
if ti.Version != TerminalInfoVersion {
69-
return nil, fmt.Errorf("terminal info: incorrect version in payload (%q): %q", TerminalInfoVersion, ti.Version)
70-
}
71-
72-
return ti, nil
73-
}

utils_linux.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ type runner struct {
218218
notifySocket *notifySocket
219219
}
220220

221-
func (r *runner) terminalinfo() *libcontainer.TerminalInfo {
222-
return libcontainer.NewTerminalInfo(r.container.ID())
223-
}
224-
225221
func (r *runner) run(config *specs.Process) (int, error) {
226222
if err := r.checkTerminal(config); err != nil {
227223
r.destroy()

0 commit comments

Comments
 (0)