Skip to content
Closed
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
9 changes: 8 additions & 1 deletion libpod/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func bindPorts(ports []ocicni.PortMapping) ([]*os.File, error) {
return files, nil
}

func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string, restoreOptions *ContainerCheckpointOptions) (err error) {
func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string, restoreOptions *ContainerCheckpointOptions, parentNs *os.File) (err error) {
var stderrBuf bytes.Buffer

runtimeDir, err := util.GetRootlessRuntimeDir()
Expand Down Expand Up @@ -301,6 +301,9 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string, res
args = append(args, "--restore-arg", "--tcp-established")
}
}
if parentNs != nil {
args = append(args, "--exit-command-namespace", "5")
}

logrus.WithFields(logrus.Fields{
"args": args,
Expand Down Expand Up @@ -329,6 +332,10 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string, res
cmd.Env = append(cmd.Env, fmt.Sprintf("_LIBPOD_ROOTLESS_UID=%s", os.Getenv("_LIBPOD_ROOTLESS_UID")))
cmd.Env = append(cmd.Env, fmt.Sprintf("HOME=%s", os.Getenv("HOME")))

if parentNs != nil {
cmd.ExtraFiles = append(cmd.ExtraFiles, parentNs)
}

if r.reservePorts && !ctr.config.NetMode.IsSlirp4netns() {
ports, err := bindPorts(ctr.config.PortMappings)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions libpod/oci_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func newPipe() (parent *os.File, child *os.File, err error) {
func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string, restoreOptions *ContainerCheckpointOptions) (err error) {
if ctr.state.UserNSRoot == "" {
// no need of an intermediate mount ns
return r.createOCIContainer(ctr, cgroupParent, restoreOptions)
return r.createOCIContainer(ctr, cgroupParent, restoreOptions, nil)
}
var wg sync.WaitGroup
wg.Add(1)
Expand Down Expand Up @@ -123,7 +123,7 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string, restor
}
}

err = r.createOCIContainer(ctr, cgroupParent, restoreOptions)
err = r.createOCIContainer(ctr, cgroupParent, restoreOptions, fd)
}()
wg.Wait()

Expand Down