rootless: join both userns and mount namespace with --pod

When --pod is specified then join both the user and mount namespace
for the pod so we can initialize the storage.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2019-01-11 11:51:21 +01:00
parent b3e7be7a0b
commit c4f054f102

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -785,11 +786,15 @@ func joinOrCreateRootlessUserNamespace(createConfig *cc.CreateConfig, runtime *l
if s != libpod.ContainerStateRunning && s != libpod.ContainerStatePaused { if s != libpod.ContainerStateRunning && s != libpod.ContainerStatePaused {
continue continue
} }
pid, err := prevCtr.PID() data, err := ioutil.ReadFile(prevCtr.Config().ConmonPidFile)
if err != nil { if err != nil {
return false, -1, err return false, -1, errors.Wrapf(err, "cannot read conmon PID file %q", prevCtr.Config().ConmonPidFile)
} }
return rootless.JoinNS(uint(pid)) conmonPid, err := strconv.Atoi(string(data))
if err != nil {
return false, -1, errors.Wrapf(err, "cannot parse PID %q", data)
}
return rootless.JoinDirectUserAndMountNS(uint(conmonPid))
} }
} }