summaryrefslogtreecommitdiff
path: root/utils/utils_supported.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-04-22 16:01:31 -0500
committerbaude <bbaude@redhat.com>2019-04-30 15:28:39 -0500
commit0b6bb6a3d3c3c15b9c6629a6949a616a30b0478a (patch)
treeee8d23d62036f815a759c3aac41f1ac616c4188f /utils/utils_supported.go
parentb5af10ce5a51f8ac2c7f7b101006412287d17b68 (diff)
downloadpodman-0b6bb6a3d3c3c15b9c6629a6949a616a30b0478a.tar.gz
podman-0b6bb6a3d3c3c15b9c6629a6949a616a30b0478a.tar.bz2
podman-0b6bb6a3d3c3c15b9c6629a6949a616a30b0478a.zip
enable podman-remote on windows
build a podman-remote binary for windows that allows users to use the remote client on windows and interact with podman on linux system. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'utils/utils_supported.go')
-rw-r--r--utils/utils_supported.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/utils/utils_supported.go b/utils/utils_supported.go
new file mode 100644
index 000000000..8b0ba4438
--- /dev/null
+++ b/utils/utils_supported.go
@@ -0,0 +1,39 @@
+// +build linux darwin
+
+package utils
+
+import (
+ systemdDbus "github.com/coreos/go-systemd/dbus"
+ "github.com/godbus/dbus"
+)
+
+// 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
+ }
+ properties = append(properties, systemdDbus.PropSlice(slice))
+ properties = append(properties, newProp("PIDs", []uint32{uint32(pid)}))
+ properties = append(properties, newProp("Delegate", true))
+ properties = append(properties, newProp("DefaultDependencies", false))
+ ch := make(chan string)
+ _, err = conn.StartTransientUnit(unitName, "replace", properties, ch)
+ if err != nil {
+ return err
+ }
+ defer conn.Close()
+
+ // Block until job is started
+ <-ch
+
+ return nil
+}
+
+func newProp(name string, units interface{}) systemdDbus.Property {
+ return systemdDbus.Property{
+ Name: name,
+ Value: dbus.MakeVariant(units),
+ }
+}