diff --git a/src/cmd/run.go b/src/cmd/run.go index 412e3fe..17c0624 100644 --- a/src/cmd/run.go +++ b/src/cmd/run.go @@ -209,7 +209,7 @@ func runCommand(container string, } } - if _, err := utils.CallFlatpakSessionHelper(); err != nil { + if err := callFlatpakSessionHelper(container); err != nil { return err } @@ -367,6 +367,37 @@ func runHelp(cmd *cobra.Command, args []string) { } } +func callFlatpakSessionHelper(container string) error { + logrus.Debugf("Inspecting mounts of container %s", container) + + info, err := podman.Inspect("container", container) + if err != nil { + return fmt.Errorf("failed to inspect entry point of container %s", container) + } + + var needsFlatpakSessionHelper bool + + mounts := info["Mounts"].([]interface{}) + for _, mount := range mounts { + destination := mount.(map[string]interface{})["Destination"].(string) + if destination == "/run/host/monitor" { + logrus.Debug("Requires org.freedesktop.Flatpak.SessionHelper") + needsFlatpakSessionHelper = true + break + } + } + + if !needsFlatpakSessionHelper { + return nil + } + + if _, err := utils.CallFlatpakSessionHelper(); err != nil { + return err + } + + return nil +} + func getEntryPointAndPID(container string) (string, int, error) { logrus.Debugf("Inspecting entry point of container %s", container)