summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2020-08-17 15:58:16 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2020-08-18 18:05:38 +0200
commitb3f5c93ecc7ad6f013a087c43f7e91ae33a1efae (patch)
treeef4616caf7d8c1e08a8911b62ea933ca94132144 /pkg
parent748e8829da76394ec956ea6590599fab01b467b7 (diff)
downloadpodman-b3f5c93ecc7ad6f013a087c43f7e91ae33a1efae.tar.gz
podman-b3f5c93ecc7ad6f013a087c43f7e91ae33a1efae.tar.bz2
podman-b3f5c93ecc7ad6f013a087c43f7e91ae33a1efae.zip
abi: fix detection for systemd
create a scope everytime we don't own the current cgroup and we are running on systemd. Closes: https://github.com/containers/podman/issues/6734 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/infra/abi/system.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 71fe478fd..478fac1d5 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -70,8 +70,13 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command)
if err != nil {
return err
}
+
+ initCommand, err := ioutil.ReadFile("/proc/1/comm")
+ // On errors, default to systemd
+ runsUnderSystemd := err != nil || string(initCommand) == "systemd"
+
unitName := fmt.Sprintf("podman-%d.scope", os.Getpid())
- if conf.Engine.CgroupManager == config.SystemdCgroupsManager {
+ if runsUnderSystemd || conf.Engine.CgroupManager == config.SystemdCgroupsManager {
if err := utils.RunUnderSystemdScope(os.Getpid(), "user.slice", unitName); err != nil {
logrus.Warnf("Failed to add podman to systemd sandbox cgroup: %v", err)
}