diff --git a/libcontainer/README.md b/libcontainer/README.md index 13eee49d4b9..658eb43139a 100644 --- a/libcontainer/README.md +++ b/libcontainer/README.md @@ -45,7 +45,7 @@ Then to create a container you first have to initialize an instance of a factory that will handle the creation and initialization for a container. ```go -factory, err := libcontainer.New("/var/lib/container", libcontainer.Cgroupfs, libcontainer.InitArgs(os.Args[0], "init")) +factory, err := libcontainer.New("/var/lib/container", libcontainer.InitArgs(os.Args[0], "init")) if err != nil { logrus.Fatal(err) return diff --git a/libcontainer/configs/config.go b/libcontainer/configs/config.go index c1b4a0041c2..7cf2fb65751 100644 --- a/libcontainer/configs/config.go +++ b/libcontainer/configs/config.go @@ -83,9 +83,6 @@ type Syscall struct { Args []*Arg `json:"args"` } -// TODO Windows. Many of these fields should be factored out into those parts -// which are common across platforms, and those which are platform specific. - // Config defines configuration options for executing a process inside a contained environment. type Config struct { // NoPivotRoot will use MS_MOVE and a chroot to jail the process into the container's rootfs diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index f6877b7429f..261f5a9f45f 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -665,7 +665,7 @@ func (c *linuxContainer) newInitConfig(process *Process) *initConfig { Cwd: process.Cwd, Capabilities: process.Capabilities, PassedFilesCount: len(process.ExtraFiles), - ContainerId: c.ID(), + ContainerID: c.ID(), NoNewPrivileges: c.config.NoNewPrivileges, RootlessEUID: c.config.RootlessEUID, RootlessCgroups: c.config.RootlessCgroups, diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go index 9b74329ba10..1ddc7a5db0c 100644 --- a/libcontainer/factory_linux.go +++ b/libcontainer/factory_linux.go @@ -400,14 +400,14 @@ func NewgidmapPath(newgidmapPath string) func(*LinuxFactory) error { } func parseMountFds() ([]int, error) { - fdsJson := os.Getenv("_LIBCONTAINER_MOUNT_FDS") - if fdsJson == "" { + fdsJSON := os.Getenv("_LIBCONTAINER_MOUNT_FDS") + if fdsJSON == "" { // Always return the nil slice if no fd is present. return nil, nil } var mountFds []int - if err := json.Unmarshal([]byte(fdsJson), &mountFds); err != nil { + if err := json.Unmarshal([]byte(fdsJSON), &mountFds); err != nil { return nil, fmt.Errorf("Error unmarshalling _LIBCONTAINER_MOUNT_FDS: %w", err) } diff --git a/libcontainer/init_linux.go b/libcontainer/init_linux.go index 1e5c394c3e0..8e8d3abd93d 100644 --- a/libcontainer/init_linux.go +++ b/libcontainer/init_linux.go @@ -60,7 +60,7 @@ type initConfig struct { Config *configs.Config `json:"config"` Networks []*network `json:"network"` PassedFilesCount int `json:"passed_files_count"` - ContainerId string `json:"containerid"` + ContainerID string `json:"containerid"` Rlimits []configs.Rlimit `json:"rlimits"` CreateConsole bool `json:"create_console"` ConsoleWidth uint16 `json:"console_width"` @@ -87,7 +87,7 @@ func newContainerInit(t initType, pipe *os.File, consoleSocket *os.File, fifoFd, case initSetns: // mountFds must be nil in this case. We don't mount while doing runc exec. if mountFds != nil { - return nil, errors.New("mountFds must be nil. Can't mount while doing runc exec.") + return nil, errors.New("mountFds must be nil; can't mount from exec") } return &linuxSetnsInit{ diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go index e025445d330..97f28a1ab30 100644 --- a/libcontainer/process_linux.go +++ b/libcontainer/process_linux.go @@ -192,7 +192,7 @@ func (p *setnsProcess) start() (retErr error) { Metadata: p.config.Config.Seccomp.ListenerMetadata, State: specs.State{ Version: specs.Version, - ID: p.config.ContainerId, + ID: p.config.ContainerID, Status: specs.StateRunning, Pid: p.initProcessPid, Bundle: bundle, diff --git a/libcontainer/setns_init_linux.go b/libcontainer/setns_init_linux.go index 09ab552b3d1..da31110aeee 100644 --- a/libcontainer/setns_init_linux.go +++ b/libcontainer/setns_init_linux.go @@ -26,7 +26,7 @@ type linuxSetnsInit struct { } func (l *linuxSetnsInit) getSessionRingName() string { - return "_ses." + l.config.ContainerId + return "_ses." + l.config.ContainerID } func (l *linuxSetnsInit) Init() error { diff --git a/libcontainer/standard_init_linux.go b/libcontainer/standard_init_linux.go index 585a04fa080..1a9c4979c26 100644 --- a/libcontainer/standard_init_linux.go +++ b/libcontainer/standard_init_linux.go @@ -42,7 +42,7 @@ func (l *linuxStandardInit) getSessionRingParams() (string, uint32, uint32) { // Create a unique per session container name that we can join in setns; // However, other containers can also join it. - return "_ses." + l.config.ContainerId, 0xffffffff, newperms + return "_ses." + l.config.ContainerID, 0xffffffff, newperms } func (l *linuxStandardInit) Init() error { diff --git a/notify_socket.go b/notify_socket.go index 76aa27ca518..9dde506c3e1 100644 --- a/notify_socket.go +++ b/notify_socket.go @@ -91,12 +91,12 @@ func notifySocketStart(context *cli.Context, notifySocketHost, id string) (*noti return notifySocket, nil } -func (n *notifySocket) waitForContainer(container libcontainer.Container) error { - s, err := container.State() +func (s *notifySocket) waitForContainer(container libcontainer.Container) error { + state, err := container.State() if err != nil { return err } - return n.run(s.InitProcessPid) + return s.run(state.InitProcessPid) } func (n *notifySocket) run(pid1 int) error {