Skip to content

Commit dfe38a9

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 <kolyshkin@gmail.com>
1 parent 64f3c17 commit dfe38a9

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

libcontainer/container_linux.go

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

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)