Skip to content

Commit

Permalink
cmd/run: Start o.fd.Flatpak.SessionHelper only for old containers
Browse files Browse the repository at this point in the history
... that were created to have a bind mount at /run/host/monitor. Newly
created containers no longer need org.freedesktop.Flatpak.SessionHelper
and hence the D-Bus service doesn't need to be started for them.

#267
  • Loading branch information
debarshiray committed Oct 26, 2020
1 parent 71b5c8c commit 82c32be
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func runCommand(container string,
}
}

if _, err := utils.CallFlatpakSessionHelper(); err != nil {
if err := callFlatpakSessionHelper(container); err != nil {
return err
}

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 82c32be

Please sign in to comment.