diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-07 19:01:18 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-07 19:03:51 +0900 |
| commit | d23b4dc9e64d3f00e746c65f3038a1a6de44b8f5 (patch) | |
| tree | 46e7f73bc2b06047561588294759ddb8a71184f2 /cmd | |
| parent | 3ce63e95d7691450f7b368e639d984a223a764b1 (diff) | |
hst/dbus: move dbus config struct
This allows holding a xdg-dbus-proxy configuration without importing system/dbus.
It also makes more sense in the project structure since the config struct is part of the hst API however the rest of the implementation is not.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/hakurei/command.go | 13 | ||||
| -rw-r--r-- | cmd/hakurei/print.go | 3 | ||||
| -rw-r--r-- | cmd/hakurei/print_test.go | 3 | ||||
| -rw-r--r-- | cmd/hpkg/app.go | 5 |
4 files changed, 11 insertions, 13 deletions
diff --git a/cmd/hakurei/command.go b/cmd/hakurei/command.go index 45755521..0c2cb53d 100644 --- a/cmd/hakurei/command.go +++ b/cmd/hakurei/command.go @@ -2,6 +2,7 @@ package main import ( "context" + "encoding/json" "errors" "fmt" "io" @@ -213,19 +214,19 @@ func buildCommand(ctx context.Context, msg container.Msg, early *earlyHardeningE if flagDBusConfigSession == "builtin" { config.SessionBus = dbus.NewConfig(flagID, true, flagDBusMpris) } else { - if conf, err := dbus.NewConfigFromFile(flagDBusConfigSession); err != nil { + if f, err := os.Open(flagDBusConfigSession); err != nil { + log.Fatal(err.Error()) + } else if err = json.NewDecoder(f).Decode(&config.SessionBus); err != nil { log.Fatalf("cannot load session bus proxy config from %q: %s", flagDBusConfigSession, err) - } else { - config.SessionBus = conf } } // system bus proxy is optional if flagDBusConfigSystem != "nil" { - if conf, err := dbus.NewConfigFromFile(flagDBusConfigSystem); err != nil { + if f, err := os.Open(flagDBusConfigSystem); err != nil { + log.Fatal(err.Error()) + } else if err = json.NewDecoder(f).Decode(&config.SystemBus); err != nil { log.Fatalf("cannot load system bus proxy config from %q: %s", flagDBusConfigSystem, err) - } else { - config.SystemBus = conf } } diff --git a/cmd/hakurei/print.go b/cmd/hakurei/print.go index c9084a58..1a97b858 100644 --- a/cmd/hakurei/print.go +++ b/cmd/hakurei/print.go @@ -15,7 +15,6 @@ import ( "hakurei.app/hst" "hakurei.app/internal/app" "hakurei.app/internal/app/state" - "hakurei.app/system/dbus" ) func printShowSystem(output io.Writer, short, flagJSON bool) { @@ -140,7 +139,7 @@ func printShowInstance( } } - printDBus := func(c *dbus.Config) { + printDBus := func(c *hst.BusConfig) { t.Printf(" Filter:\t%v\n", c.Filter) if len(c.See) > 0 { t.Printf(" See:\t%q\n", c.See) diff --git a/cmd/hakurei/print_test.go b/cmd/hakurei/print_test.go index a666d251..dcdc0d03 100644 --- a/cmd/hakurei/print_test.go +++ b/cmd/hakurei/print_test.go @@ -7,7 +7,6 @@ import ( "hakurei.app/hst" "hakurei.app/internal/app/state" - "hakurei.app/system/dbus" ) var ( @@ -101,7 +100,7 @@ Filesystem Extra ACL `, false}, - {"config pd dbus see", nil, &hst.Config{SessionBus: &dbus.Config{See: []string{"org.example.test"}}}, false, false, `Error: configuration missing container state! + {"config pd dbus see", nil, &hst.Config{SessionBus: &hst.BusConfig{See: []string{"org.example.test"}}}, false, false, `Error: configuration missing container state! App Identity: 0 diff --git a/cmd/hpkg/app.go b/cmd/hpkg/app.go index a4910aae..da1fd301 100644 --- a/cmd/hpkg/app.go +++ b/cmd/hpkg/app.go @@ -7,7 +7,6 @@ import ( "hakurei.app/container" "hakurei.app/hst" - "hakurei.app/system/dbus" ) type appInfo struct { @@ -37,9 +36,9 @@ type appInfo struct { // passed through to [hst.Config] DirectWayland bool `json:"direct_wayland,omitempty"` // passed through to [hst.Config] - SystemBus *dbus.Config `json:"system_bus,omitempty"` + SystemBus *hst.BusConfig `json:"system_bus,omitempty"` // passed through to [hst.Config] - SessionBus *dbus.Config `json:"session_bus,omitempty"` + SessionBus *hst.BusConfig `json:"session_bus,omitempty"` // passed through to [hst.Config] Enablements *hst.Enablements `json:"enablements,omitempty"` |
