Skip to content

Commit 42cea2e

Browse files
committed
libct: don't allow to start second init process
By definition, every container has only 1 init (i.e. PID 1) process. Apparently, libcontainer API supported running more than 1 init, and at least one tests mistakenly used it. Let's not allow that, erroring out if we already have init. Doing otherwise _probably_ results in some confusion inside the library. Fix two cases in libct/int which ran two inits inside a container. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent e3e1072 commit 42cea2e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

libcontainer/container_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ func (c *Container) start(process *Process) (retErr error) {
306306
return errors.New("can't start container with SkipDevices set")
307307
}
308308
if process.Init {
309+
if c.initProcessStartTime != 0 {
310+
return errors.New("container already has init process")
311+
}
309312
if err := c.createExecFifo(); err != nil {
310313
return err
311314
}

libcontainer/integration/execin_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func testExecInRlimit(t *testing.T, userns bool) {
115115
// increase process rlimit higher than container rlimit to test per-process limit
116116
{Type: unix.RLIMIT_NOFILE, Hard: 1026, Soft: 1026},
117117
},
118-
Init: true,
119118
}
120119
err = container.Run(ps)
121120
ok(t, err)
@@ -359,7 +358,6 @@ func TestExecInEnvironment(t *testing.T) {
359358
Stdin: buffers.Stdin,
360359
Stdout: buffers.Stdout,
361360
Stderr: buffers.Stderr,
362-
Init: true,
363361
}
364362
err = container.Run(process2)
365363
ok(t, err)

0 commit comments

Comments
 (0)