summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-11-07 08:58:33 -0800
committerGitHub <noreply@github.com>2018-11-07 08:58:33 -0800
commit1e4e33b41f1ce11b031d92b7800915714c504602 (patch)
tree3fbd1e8bdba25ae3ddc03c1abd6dad9c597b7bc0 /libpod
parent90662c2fa3c4069dcf34c01dd3011a20cecde6ee (diff)
parentf813881b81ca669119bd7ac0c313c4f3198228c2 (diff)
downloadpodman-1e4e33b41f1ce11b031d92b7800915714c504602.tar.gz
podman-1e4e33b41f1ce11b031d92b7800915714c504602.tar.bz2
podman-1e4e33b41f1ce11b031d92b7800915714c504602.zip
Merge pull request #1761 from giuseppe/rootless-systemd
rootless: don't bind mount /sys/fs/cgroup/systemd in systemd mode
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go34
1 files changed, 23 insertions, 11 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 7bf2c71ca..d89eefd3b 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -360,19 +360,31 @@ 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)
+ } else {
+ systemdMnt := spec.Mount{
+ Destination: "/sys/fs/cgroup/systemd",
+ Type: "bind",
+ Source: "/sys/fs/cgroup/systemd",
+ Options: []string{"bind", "nodev", "noexec", "nosuid"},
+ }
+ g.AddMount(systemdMnt)
}
- g.AddMount(systemdMnt)
return nil
}