cmd/run: Start o.fd.Flatpak.SessionHelper only for old containers
... 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. https://github.com/containers/toolbox/issues/267
This commit is contained in:
		
							parent
							
								
									71b5c8c0a2
								
							
						
					
					
						commit
						82c32bea74
					
				|  | @ -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) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue