mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 14:13:58 +08:00
549f508d5b
This changes the namespace configuration on the config to include the name of the namespace along with an optional path. This path is used to point to a file of another namespace for the namespace so that it can be joined in place of the empty, initialized namespace. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
39 lines
912 B
Go
39 lines
912 B
Go
// +build linux
|
|
|
|
package namespaces
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
|
|
"github.com/docker/libcontainer"
|
|
)
|
|
|
|
type initError struct {
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
|
|
func (i initError) Error() string {
|
|
return i.Message
|
|
}
|
|
|
|
// New returns a newly initialized Pipe for communication between processes
|
|
func newInitPipe() (parent *os.File, child *os.File, err error) {
|
|
fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM|syscall.SOCK_CLOEXEC, 0)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
return os.NewFile(uintptr(fds[1]), "parent"), os.NewFile(uintptr(fds[0]), "child"), nil
|
|
}
|
|
|
|
// GetNamespaceFlags parses the container's Namespaces options to set the correct
|
|
// flags on clone, unshare, and setns
|
|
func GetNamespaceFlags(namespaces []libcontainer.Namespace) (flag int) {
|
|
for _, v := range namespaces {
|
|
if ns := GetNamespace(v.Name); ns != nil {
|
|
flag |= ns.Value
|
|
}
|
|
}
|
|
return flag
|
|
}
|