diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-08 04:57:22 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-08 04:57:22 +0900 |
| commit | 9b507715d42f74c3f18fe817c2464abfca1b0182 (patch) | |
| tree | c3d8ee5ef6809aaf3174bd6ecb00b8115261897e /system/dbus/config.go | |
| parent | 12ab7ea3b465a130933efd9e7fe044f3636dc6ed (diff) | |
hst/dbus: validate interface strings
This is relocated to hst to validate early.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/dbus/config.go')
| -rw-r--r-- | system/dbus/config.go | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/system/dbus/config.go b/system/dbus/config.go index 2aeb3bb7..2a09ee90 100644 --- a/system/dbus/config.go +++ b/system/dbus/config.go @@ -1,74 +1,12 @@ package dbus import ( - "strings" - "hakurei.app/hst" ) // ProxyPair is an upstream dbus address and a downstream socket path. type ProxyPair [2]string -// interfacesAll returns an iterator over all interfaces specified in c. -func interfacesAll(c *hst.BusConfig) func(yield func(string) bool) { - return func(yield func(string) bool) { - for _, iface := range c.See { - if !yield(iface) { - return - } - } - for _, iface := range c.Talk { - if !yield(iface) { - return - } - } - for _, iface := range c.Own { - if !yield(iface) { - return - } - } - - for iface := range c.Call { - if !yield(iface) { - return - } - } - for iface := range c.Broadcast { - if !yield(iface) { - return - } - } - } -} - -// checkInterfaces checks [hst.BusConfig] for invalid interfaces based on an undocumented check in xdg-dbus-error, -// returning [BadInterfaceError] if one is encountered. -func checkInterfaces(c *hst.BusConfig, segment string) error { - for iface := range interfacesAll(c) { - /* - xdg-dbus-proxy fails without output when this condition is not met: - char *dot = strrchr (filter->interface, '.'); - if (dot != NULL) - { - *dot = 0; - if (strcmp (dot + 1, "*") != 0) - filter->member = g_strdup (dot + 1); - } - - trim ".*" since they are removed before searching for '.': - if (g_str_has_suffix (name, ".*")) - { - name[strlen (name) - 2] = 0; - wildcard = TRUE; - } - */ - if strings.IndexByte(strings.TrimSuffix(iface, ".*"), '.') == -1 { - return &BadInterfaceError{iface, segment} - } - } - return nil -} - // Args returns the xdg-dbus-proxy arguments equivalent of [hst.BusConfig]. func Args(c *hst.BusConfig, bus ProxyPair) (args []string) { argc := 2 + len(c.See) + len(c.Talk) + len(c.Own) + len(c.Call) + len(c.Broadcast) |
