diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-09-12 19:04:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-12 19:04:07 +0200 |
commit | 8c3349bc08b6f4e48751f61dd342cbf9828eca85 (patch) | |
tree | a9f5e374cb1060a0ef6577436b6bf24b783764c3 /utils/utils_supported.go | |
parent | 2de49870861be00cbd92108a1642796170a0aad1 (diff) | |
parent | 7e88bf7fd0207783e8feecb7ec7206df96897f4e (diff) | |
download | podman-8c3349bc08b6f4e48751f61dd342cbf9828eca85.tar.gz podman-8c3349bc08b6f4e48751f61dd342cbf9828eca85.tar.bz2 podman-8c3349bc08b6f4e48751f61dd342cbf9828eca85.zip |
Merge pull request #3959 from giuseppe/rootless-use-systemd-scope
rootless: automatically create a systemd scope
Diffstat (limited to 'utils/utils_supported.go')
-rw-r--r-- | utils/utils_supported.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/utils/utils_supported.go b/utils/utils_supported.go index 8b0ba4438..8bc232179 100644 --- a/utils/utils_supported.go +++ b/utils/utils_supported.go @@ -3,6 +3,8 @@ package utils import ( + "github.com/containers/libpod/pkg/cgroups" + "github.com/containers/libpod/pkg/rootless" systemdDbus "github.com/coreos/go-systemd/dbus" "github.com/godbus/dbus" ) @@ -10,9 +12,19 @@ import ( // RunUnderSystemdScope adds the specified pid to a systemd scope func RunUnderSystemdScope(pid int, slice string, unitName string) error { var properties []systemdDbus.Property - conn, err := systemdDbus.New() - if err != nil { - return err + var conn *systemdDbus.Conn + var err error + + if rootless.IsRootless() { + conn, err = cgroups.GetUserConnection(rootless.GetRootlessUID()) + if err != nil { + return err + } + } else { + conn, err = systemdDbus.New() + if err != nil { + return err + } } properties = append(properties, systemdDbus.PropSlice(slice)) properties = append(properties, newProp("PIDs", []uint32{uint32(pid)})) |