aboutsummaryrefslogtreecommitdiffhomepage
path: root/dbus/config.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-09-09 21:13:00 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-09-09 21:13:00 +0900
commit20c0e66d8fa68dc113019da819f2c441d778dc60 (patch)
tree53297200c36bf74693907f5c994fb0b573c37ecc /dbus/config.go
parente5918ba3b3e2ed55f15a0ee750bc290a1dd571ed (diff)
dbus/config: seal with session and system bus proxy
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'dbus/config.go')
-rw-r--r--dbus/config.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/dbus/config.go b/dbus/config.go
index 5bbaa5cf..dafcbaea 100644
--- a/dbus/config.go
+++ b/dbus/config.go
@@ -1,5 +1,10 @@
package dbus
+import (
+ "errors"
+ "strings"
+)
+
type Config struct {
// See set 'see' policy for NAME (--see=NAME)
See []string `json:"see"`
@@ -17,7 +22,7 @@ type Config struct {
Filter bool `json:"filter"`
}
-func (c *Config) Args(address, path string) (args []string) {
+func (c *Config) Args(bus [2]string) (args []string) {
argc := 2 + len(c.See) + len(c.Talk) + len(c.Own) + len(c.Call) + len(c.Broadcast)
if c.Log {
argc++
@@ -27,7 +32,7 @@ func (c *Config) Args(address, path string) (args []string) {
}
args = make([]string, 0, argc)
- args = append(args, address, path)
+ args = append(args, bus[0], bus[1])
for _, name := range c.See {
args = append(args, "--see="+name)
}
@@ -53,6 +58,23 @@ func (c *Config) Args(address, path string) (args []string) {
return
}
+func (c *Config) buildSeal(seal *strings.Builder, bus [2]string) error {
+ for _, arg := range c.Args(bus) {
+ // reject argument strings containing null
+ for _, b := range arg {
+ if b == '\x00' {
+ return errors.New("argument contains null")
+ }
+ }
+
+ // write null terminated argument
+ seal.WriteString(arg)
+ seal.WriteByte('\x00')
+ }
+
+ return nil
+}
+
// NewConfig returns a reference to a Config struct with optional defaults.
// If id is an empty string own defaults are omitted.
func NewConfig(id string, defaults, mpris bool) (c *Config) {