Update go-runc to abd8eada6a98acdf415d47a8d372dc314494c07f
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
bf036b9d78
commit
911bc57483
2 changed files with 105 additions and 6 deletions
99
vendor/github.com/crosbymichael/go-runc/console.go
generated
vendored
Normal file
99
vendor/github.com/crosbymichael/go-runc/console.go
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
package runc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/docker/docker/pkg/term"
|
||||||
|
"github.com/opencontainers/runc/libcontainer/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewConsoleSocket creates a new unix socket at the provided path to accept a
|
||||||
|
// pty master created by runc for use by the container
|
||||||
|
func NewConsoleSocket(path string) (*ConsoleSocket, error) {
|
||||||
|
l, err := net.Listen("unix", path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ConsoleSocket{
|
||||||
|
l: l,
|
||||||
|
path: path,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConsoleSocket is a unix socket that accepts the pty master created by runc
|
||||||
|
type ConsoleSocket struct {
|
||||||
|
path string
|
||||||
|
l net.Listener
|
||||||
|
}
|
||||||
|
|
||||||
|
// Path returns the path to the unix socket on disk
|
||||||
|
func (c *ConsoleSocket) Path() string {
|
||||||
|
return c.path
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReceiveMaster blocks until the socket receives the pty master
|
||||||
|
func (c *ConsoleSocket) ReceiveMaster() (*Console, error) {
|
||||||
|
conn, err := c.l.Accept()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
unix, ok := conn.(*net.UnixConn)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("received connection which was not a unix socket")
|
||||||
|
}
|
||||||
|
sock, err := unix.File()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
f, err := utils.RecvFd(sock)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &Console{
|
||||||
|
master: f,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close closes the unix socket
|
||||||
|
func (c *ConsoleSocket) Close() error {
|
||||||
|
return c.l.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// WinSize specifies the console size
|
||||||
|
type WinSize struct {
|
||||||
|
// Width of the console
|
||||||
|
Width uint16
|
||||||
|
// Height of the console
|
||||||
|
Height uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
// Console is a pty master
|
||||||
|
type Console struct {
|
||||||
|
master *os.File
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read from the console
|
||||||
|
func (c *Console) Read(b []byte) (int, error) {
|
||||||
|
return c.master.Read(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write writes to the console
|
||||||
|
func (c *Console) Write(b []byte) (int, error) {
|
||||||
|
return c.master.Write(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resize the console
|
||||||
|
func (c *Console) Resize(ws WinSize) error {
|
||||||
|
return term.SetWinsize(c.master.Fd(), &term.Winsize{
|
||||||
|
Width: ws.Width,
|
||||||
|
Height: ws.Height,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the console
|
||||||
|
func (c *Console) Close() error {
|
||||||
|
return c.master.Close()
|
||||||
|
}
|
12
vendor/github.com/crosbymichael/go-runc/runc.go
generated
vendored
12
vendor/github.com/crosbymichael/go-runc/runc.go
generated
vendored
|
@ -67,7 +67,7 @@ type CreateOpts struct {
|
||||||
IO
|
IO
|
||||||
// PidFile is a path to where a pid file should be created
|
// PidFile is a path to where a pid file should be created
|
||||||
PidFile string
|
PidFile string
|
||||||
ConsoleSocket string
|
ConsoleSocket *ConsoleSocket
|
||||||
Detach bool
|
Detach bool
|
||||||
NoPivot bool
|
NoPivot bool
|
||||||
NoNewKeyring bool
|
NoNewKeyring bool
|
||||||
|
@ -107,8 +107,8 @@ func (o *CreateOpts) args() (out []string) {
|
||||||
if o.PidFile != "" {
|
if o.PidFile != "" {
|
||||||
out = append(out, "--pid-file", o.PidFile)
|
out = append(out, "--pid-file", o.PidFile)
|
||||||
}
|
}
|
||||||
if o.ConsoleSocket != "" {
|
if o.ConsoleSocket != nil {
|
||||||
out = append(out, "--console-socket", o.ConsoleSocket)
|
out = append(out, "--console-socket", o.ConsoleSocket.Path())
|
||||||
}
|
}
|
||||||
if o.NoPivot {
|
if o.NoPivot {
|
||||||
out = append(out, "--no-pivot")
|
out = append(out, "--no-pivot")
|
||||||
|
@ -147,7 +147,7 @@ type ExecOpts struct {
|
||||||
Gid int
|
Gid int
|
||||||
Cwd string
|
Cwd string
|
||||||
Tty bool
|
Tty bool
|
||||||
ConsoleSocket string
|
ConsoleSocket *ConsoleSocket
|
||||||
Detach bool
|
Detach bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,8 +156,8 @@ func (o *ExecOpts) args() (out []string) {
|
||||||
if o.Tty {
|
if o.Tty {
|
||||||
out = append(out, "--tty")
|
out = append(out, "--tty")
|
||||||
}
|
}
|
||||||
if o.ConsoleSocket != "" {
|
if o.ConsoleSocket != nil {
|
||||||
out = append(out, "--console-socket", o.ConsoleSocket)
|
out = append(out, "--console-socket", o.ConsoleSocket.Path())
|
||||||
}
|
}
|
||||||
if o.Cwd != "" {
|
if o.Cwd != "" {
|
||||||
out = append(out, "--cwd", o.Cwd)
|
out = append(out, "--cwd", o.Cwd)
|
||||||
|
|
Loading…
Add table
Reference in a new issue