nsenter

package
v0.0.0-...-c25372c Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CloneFlagsTable = make(map[NSType]int)

CloneFlagsTable is exported so that consumers of this package don't need to define this same table again.

Functions

func NsEnter

func NsEnter(nsList []Namespace, toRun func() error) error

NsEnter executes the passed closure under the given namespace, restoring the original namespace afterwards.

Types

type NSType

type NSType string

NSType defines a namespace type.

const (
	NSTypeCGroup NSType = "cgroup"
	NSTypeIPC    NSType = "ipc"
	NSTypeNet    NSType = "net"
	NSTypePID    NSType = "pid"
	NSTypeUTS    NSType = "uts"
)

List of namespace types. Notice that neither "mnt" nor "user" are listed into this list. Because Golang is multithreaded, we get some errors when trying to switch to those namespaces, getting "invalid argument". The solution is to reexec the current code so that it will call into a C constructor, making sure the namespace can be entered without multithreading issues.

type Namespace

type Namespace struct {
	Path string
	PID  int
	Type NSType
}

Namespace describes a namespace that will be entered.

Jump to

Keyboard shortcuts

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