ipc

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ipc provides communication between parent and child processes that setup Drop sandbox. The communication is via a Unix domain socket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewParentChildSocket

func NewParentChildSocket() (*ParentEnd, *ChildEnd, error)

NewParentChildSocket creates an anonymous socket that parent uses to send arguments to the child, which also signals to the child that parent has already setup networking.

Types

type ChildArgs

type ChildArgs struct {
	EnvId    string
	Paths    *jailfs.Paths
	Config   *config.Config
	ExecArgs []string
}

ChildArgs contains arguments needed by both parent and child that the parent constructs and sends to the child.

Note for future extensions: unexported fields or interface types if included within ChildArgs chierarchy will not be encoded and sent (encoding/gob limitation).

type ChildEnd

type ChildEnd struct {
	// Public, so parent process can pass it to the executed child as
	// ExtraFiles
	Socket *os.File
}

func NewChildEnd

func NewChildEnd(fd uintptr) *ChildEnd

func (*ChildEnd) Close

func (c *ChildEnd) Close() error

func (*ChildEnd) RecvChildArgs

func (c *ChildEnd) RecvChildArgs() (*ChildArgs, error)

RecvChildArgs receives arguments sent by the parent process to the child. The function blocks until the arguments are available.

type ParentEnd

type ParentEnd struct {
	// contains filtered or unexported fields
}

func NewParentEnd

func NewParentEnd(fd uintptr) *ParentEnd

func (*ParentEnd) Close

func (p *ParentEnd) Close() error

func (*ParentEnd) SendChildArgs

func (p *ParentEnd) SendChildArgs(args ChildArgs) error

SendChildArgs serializes and sends to the child all the necessary arguments and configuration options obtained by the parent from command line and from config files.

Parent sends the arguments after all the necessary setup needed by the child is finished (network setup is done), so the child can assume that after the arguments are received, a sandboxed process can be launched.

type PtyReceiver added in v0.1.8

type PtyReceiver struct {
	// contains filtered or unexported fields
}

PtyReceiver is created by the parent process to receive parent's descriptor of a sandboxed pseudoterminal. Parent process uses this descriptor to stream input and output between the sandboxed and the original terminal.

Unlike the parent-child socket pair, this uses a named Unix domain socket so it can also receive the descriptor from runsc, which connects to and sends the pseudoterminal master over a named socket passed via --console-socket and does not support an unnamed socket pair.

func NewPtyReceiver added in v0.1.8

func NewPtyReceiver(path string) (*PtyReceiver, error)

NewPtyReceiver creates a named Unix domain socket and listens on it.

It is OK for the sender (the child, or runsc via --console-socket) to connect to the socket and send the descriptor before the parent calls RecvPty.

func (*PtyReceiver) Close added in v0.1.8

func (p *PtyReceiver) Close()

Close closes the listening socket and removes it from the filesystem.

func (*PtyReceiver) RecvPty added in v0.1.8

func (p *PtyReceiver) RecvPty() (*os.File, error)

RecvPty waits for the child to connect to the named Unix domain socket and to send file descriptor of the parent's end of the pseudoterminal.

type PtySender added in v0.1.8

type PtySender struct {
	// contains filtered or unexported fields
}

PtySender is created by the child process to send parent's descriptor of a sandboxed pseudoterminal.

func NewPtySender added in v0.1.8

func NewPtySender(path string) (*PtySender, error)

NewPtySender connects to the named Unix domain socket the parent listens on (path).

func (*PtySender) Close added in v0.1.8

func (p *PtySender) Close()

Close closes the sender's end of the socket.

func (*PtySender) SendPty added in v0.1.8

func (p *PtySender) SendPty(f *os.File) error

SendPty sends f, the descriptor of the parent's end of the pseudoterminal. The parent uses this descriptor to stream input and output between the sandboxed and the original terminal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL