All checks were successful
		
		
	
	Test / Create distribution (push) Successful in 33s
				
			Test / Sandbox (push) Successful in 2m6s
				
			Test / Hakurei (push) Successful in 3m3s
				
			Test / Sandbox (race detector) (push) Successful in 3m56s
				
			Test / Hpkg (push) Successful in 3m58s
				
			Test / Hakurei (race detector) (push) Successful in 4m42s
				
			Test / Flake checks (push) Successful in 1m28s
				
			This also improves readability of test cases. Signed-off-by: Ophestra <cat@gensokyo.uk>
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package app
 | |
| 
 | |
| import (
 | |
| 	"encoding/gob"
 | |
| 
 | |
| 	"hakurei.app/container/fhs"
 | |
| 	"hakurei.app/hst"
 | |
| 	"hakurei.app/system/acl"
 | |
| 	"hakurei.app/system/dbus"
 | |
| )
 | |
| 
 | |
| func init() { gob.Register(new(spDBusOp)) }
 | |
| 
 | |
| // spDBusOp maintains an xdg-dbus-proxy instance for the container.
 | |
| // Runs after spRuntimeOp.
 | |
| type spDBusOp struct {
 | |
| 	// Whether to bind the system bus socket. Populated during toSystem.
 | |
| 	ProxySystem bool
 | |
| }
 | |
| 
 | |
| func (s *spDBusOp) toSystem(state *outcomeStateSys) error {
 | |
| 	if state.et&hst.EDBus == 0 {
 | |
| 		return errNotEnabled
 | |
| 	}
 | |
| 
 | |
| 	if state.sessionBus == nil {
 | |
| 		state.sessionBus = dbus.NewConfig(state.appId, true, true)
 | |
| 	}
 | |
| 
 | |
| 	// downstream socket paths
 | |
| 	sessionPath, systemPath := state.instance().Append("bus"), state.instance().Append("system_bus_socket")
 | |
| 
 | |
| 	var sessionBus, systemBus dbus.ProxyPair
 | |
| 	sessionBus[0], systemBus[0] = state.k.dbusAddress()
 | |
| 	sessionBus[1], systemBus[1] = sessionPath.String(), systemPath.String()
 | |
| 	if err := state.sys.ProxyDBus(state.sessionBus, state.systemBus, sessionBus, systemBus); err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 
 | |
| 	state.sys.UpdatePerm(sessionPath, acl.Read, acl.Write)
 | |
| 	if state.systemBus != nil {
 | |
| 		s.ProxySystem = true
 | |
| 		state.sys.UpdatePerm(systemPath, acl.Read, acl.Write)
 | |
| 	}
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| func (s *spDBusOp) toContainer(state *outcomeStateParams) error {
 | |
| 	sessionInner := state.runtimeDir.Append("bus")
 | |
| 	state.env["DBUS_SESSION_BUS_ADDRESS"] = "unix:path=" + sessionInner.String()
 | |
| 	state.params.Bind(state.instancePath().Append("bus"), sessionInner, 0)
 | |
| 	if s.ProxySystem {
 | |
| 		systemInner := fhs.AbsVar.Append("run/dbus/system_bus_socket")
 | |
| 		state.env["DBUS_SYSTEM_BUS_ADDRESS"] = "unix:path=" + systemInner.String()
 | |
| 		state.params.Bind(state.instancePath().Append("system_bus_socket"), systemInner, 0)
 | |
| 	}
 | |
| 	return nil
 | |
| }
 |