aboutsummaryrefslogtreecommitdiffhomepage
path: root/system/dispatcher.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-06 14:25:19 +0900
committerOphestra <cat@gensokyo.uk>2025-09-06 14:25:19 +0900
commit05db06c87b743b2e1eb0e8158476ba2a24962967 (patch)
tree373e6d37f9ed93ec42b0739e1e98ebc18cb02fa2 /system/dispatcher.go
parente603b688ca6d023b783e58f3876430ea73dd21a6 (diff)
system/dbus: use syscall dispatcher
This allows dbus op methods and builder to be instrumented. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/dispatcher.go')
-rw-r--r--system/dispatcher.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/system/dispatcher.go b/system/dispatcher.go
index c483c818..c896de57 100644
--- a/system/dispatcher.go
+++ b/system/dispatcher.go
@@ -1,6 +1,9 @@
package system
-import "hakurei.app/system/acl"
+import (
+ "hakurei.app/system/acl"
+ "hakurei.app/system/dbus"
+)
// syscallDispatcher provides methods that make state-dependent system calls as part of their behaviour.
// syscallDispatcher is embedded in [I], so all methods must be unexported.
@@ -13,6 +16,18 @@ type syscallDispatcher interface {
// aclUpdate provides [acl.Update].
aclUpdate(name string, uid int, perms ...acl.Perm) error
+ // dbusAddress provides [dbus.Address].
+ dbusAddress() (session, system string)
+ // dbusFinalise provides [dbus.Finalise].
+ dbusFinalise(sessionBus, systemBus dbus.ProxyPair, session, system *dbus.Config) (final *dbus.Final, err error)
+ // dbusProxyStart provides the Start method of [dbus.Proxy].
+ dbusProxyStart(proxy *dbus.Proxy) error
+ // dbusProxyClose provides the Close method of [dbus.Proxy].
+ dbusProxyClose(proxy *dbus.Proxy)
+ // dbusProxyWait provides the Wait method of [dbus.Proxy].
+ dbusProxyWait(proxy *dbus.Proxy) error
+
+ isVerbose() bool
verbose(v ...any)
verbosef(format string, v ...any)
}
@@ -26,5 +41,18 @@ func (k direct) aclUpdate(name string, uid int, perms ...acl.Perm) error {
return acl.Update(name, uid, perms...)
}
+func (k direct) dbusAddress() (session, system string) {
+ return dbus.Address()
+}
+
+func (k direct) dbusFinalise(sessionBus, systemBus dbus.ProxyPair, session, system *dbus.Config) (final *dbus.Final, err error) {
+ return dbus.Finalise(sessionBus, systemBus, session, system)
+}
+
+func (k direct) dbusProxyStart(proxy *dbus.Proxy) error { return proxy.Start() }
+func (k direct) dbusProxyClose(proxy *dbus.Proxy) { proxy.Close() }
+func (k direct) dbusProxyWait(proxy *dbus.Proxy) error { return proxy.Wait() }
+
+func (k direct) isVerbose() bool { return msg.IsVerbose() }
func (direct) verbose(v ...any) { msg.Verbose(v...) }
func (direct) verbosef(format string, v ...any) { msg.Verbosef(format, v...) }