Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions libcontainer/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions libcontainer/factory_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions libcontainer/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/setns_init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/standard_init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions notify_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down