diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2018-11-05 20:02:50 +0100 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2018-11-07 16:10:33 +0100 |
commit | 11c5b0237b799ad61b53d67817af673a3d286f25 (patch) | |
tree | d4154e4ba60c49b8a273b1e93714db135f1e588b | |
parent | 9150d69087aed8f52b169eaf556159cc8b1d26d3 (diff) | |
download | podman-11c5b0237b799ad61b53d67817af673a3d286f25.tar.gz podman-11c5b0237b799ad61b53d67817af673a3d286f25.tar.bz2 podman-11c5b0237b799ad61b53d67817af673a3d286f25.zip |
rootless: don't bind mount /sys/fs/cgroup/systemd in systemd mode
it is not writeable by non-root users so there is no point in having
access to it from a container.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r-- | libpod/container_internal_linux.go | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 7bf2c71ca..dc829ca55 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -360,19 +360,23 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro g.AddMount(tmpfsMnt) } - cgroupPath, err := c.CGroupPath() - if err != nil { - return err - } - sourcePath := filepath.Join("/sys/fs/cgroup/systemd", cgroupPath) + // rootless containers have no write access to /sys/fs/cgroup, so don't + // add any mount into the container. + if !rootless.IsRootless() { + cgroupPath, err := c.CGroupPath() + if err != nil { + return err + } + sourcePath := filepath.Join("/sys/fs/cgroup/systemd", cgroupPath) - systemdMnt := spec.Mount{ - Destination: "/sys/fs/cgroup/systemd", - Type: "bind", - Source: sourcePath, - Options: []string{"bind", "private"}, + systemdMnt := spec.Mount{ + Destination: "/sys/fs/cgroup/systemd", + Type: "bind", + Source: sourcePath, + Options: []string{"bind", "private"}, + } + g.AddMount(systemdMnt) } - g.AddMount(systemdMnt) return nil } |