diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-29 02:33:10 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-29 06:11:47 +0900 |
| commit | 46cd3a28c83e93b5d66c52d06a8366c11910d5c0 (patch) | |
| tree | 6e25c5078b5cd9de78b7a6c9b253f1132358812b /system/dbus | |
| parent | ad1bc6794f0053c3e63eab408a0d530d53e8b51c (diff) | |
container: remove global msg
This frees all container instances of side effects.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/dbus')
| -rw-r--r-- | system/dbus/dbus_test.go | 9 | ||||
| -rw-r--r-- | system/dbus/export_test.go | 6 | ||||
| -rw-r--r-- | system/dbus/proc.go | 4 | ||||
| -rw-r--r-- | system/dbus/proc_test.go | 4 | ||||
| -rw-r--r-- | system/dbus/proxy.go | 6 |
5 files changed, 16 insertions, 13 deletions
diff --git a/system/dbus/dbus_test.go b/system/dbus/dbus_test.go index 9d969ba8..2599ef8f 100644 --- a/system/dbus/dbus_test.go +++ b/system/dbus/dbus_test.go @@ -11,6 +11,7 @@ import ( "testing" "time" + "hakurei.app/container" "hakurei.app/helper" "hakurei.app/system/dbus" ) @@ -92,9 +93,9 @@ func testProxyFinaliseStartWaitCloseString(t *testing.T, useSandbox bool) { t.Run("invalid start", func(t *testing.T) { if !useSandbox { - p = dbus.NewDirect(t.Context(), nil, nil) + p = dbus.NewDirect(t.Context(), container.NewMsg(nil), nil, nil) } else { - p = dbus.New(t.Context(), nil, nil) + p = dbus.New(t.Context(), container.NewMsg(nil), nil, nil) } if err := p.Start(); !errors.Is(err, syscall.ENOTRECOVERABLE) { @@ -127,9 +128,9 @@ func testProxyFinaliseStartWaitCloseString(t *testing.T, useSandbox bool) { defer cancel() output := new(strings.Builder) if !useSandbox { - p = dbus.NewDirect(ctx, final, output) + p = dbus.NewDirect(ctx, container.NewMsg(nil), final, output) } else { - p = dbus.New(ctx, final, output) + p = dbus.New(ctx, container.NewMsg(nil), final, output) } t.Run("invalid wait", func(t *testing.T) { diff --git a/system/dbus/export_test.go b/system/dbus/export_test.go index 574a4a73..b1dc365f 100644 --- a/system/dbus/export_test.go +++ b/system/dbus/export_test.go @@ -3,11 +3,13 @@ package dbus import ( "context" "io" + + "hakurei.app/container" ) // NewDirect returns a new instance of [Proxy] with its sandbox disabled. -func NewDirect(ctx context.Context, final *Final, output io.Writer) *Proxy { - p := New(ctx, final, output) +func NewDirect(ctx context.Context, msg container.Msg, final *Final, output io.Writer) *Proxy { + p := New(ctx, msg, final, output) p.useSandbox = false return p } diff --git a/system/dbus/proc.go b/system/dbus/proc.go index 7c982824..24f8c40b 100644 --- a/system/dbus/proc.go +++ b/system/dbus/proc.go @@ -52,14 +52,14 @@ func (p *Proxy) Start() error { } var libPaths []*container.Absolute - if entries, err := ldd.Exec(ctx, toolPath.String()); err != nil { + if entries, err := ldd.Exec(ctx, p.msg, toolPath.String()); err != nil { return err } else { libPaths = ldd.Path(entries) } p.helper = helper.New( - ctx, toolPath, "xdg-dbus-proxy", + ctx, p.msg, toolPath, "xdg-dbus-proxy", p.final, true, argF, func(z *container.Container) { z.SeccompFlags |= seccomp.AllowMultiarch diff --git a/system/dbus/proc_test.go b/system/dbus/proc_test.go index 5e93ace2..8b41c04c 100644 --- a/system/dbus/proc_test.go +++ b/system/dbus/proc_test.go @@ -6,12 +6,10 @@ import ( "hakurei.app/container" "hakurei.app/helper" - "hakurei.app/internal" - "hakurei.app/internal/hlog" ) func TestMain(m *testing.M) { - container.TryArgv0(hlog.Output{}, hlog.Prepare, internal.InstallOutput) + container.TryArgv0(nil) helper.InternalHelperStub() os.Exit(m.Run()) } diff --git a/system/dbus/proxy.go b/system/dbus/proxy.go index 2f625f68..a83bc9c3 100644 --- a/system/dbus/proxy.go +++ b/system/dbus/proxy.go @@ -7,6 +7,7 @@ import ( "sync" "syscall" + "hakurei.app/container" "hakurei.app/helper" ) @@ -27,6 +28,7 @@ func (e *BadInterfaceError) Error() string { type Proxy struct { helper helper.Helper ctx context.Context + msg container.Msg cancel context.CancelCauseFunc cause func() error @@ -107,6 +109,6 @@ func Finalise(sessionBus, systemBus ProxyPair, session, system *Config) (final * } // New returns a new instance of [Proxy]. -func New(ctx context.Context, final *Final, output io.Writer) *Proxy { - return &Proxy{name: ProxyName, ctx: ctx, final: final, output: output, useSandbox: true} +func New(ctx context.Context, msg container.Msg, final *Final, output io.Writer) *Proxy { + return &Proxy{name: ProxyName, ctx: ctx, msg: msg, final: final, output: output, useSandbox: true} } |
