system/dbus: dump buffer internally
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / Sandbox (push) Successful in 2m32s
Test / Hpkg (push) Successful in 4m13s
Test / Sandbox (race detector) (push) Successful in 4m49s
Test / Hakurei (race detector) (push) Successful in 5m31s
Test / Hakurei (push) Successful in 2m11s
Test / Flake checks (push) Successful in 1m28s
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / Sandbox (push) Successful in 2m32s
Test / Hpkg (push) Successful in 4m13s
Test / Sandbox (race detector) (push) Successful in 4m49s
Test / Hakurei (race detector) (push) Successful in 5m31s
Test / Hakurei (push) Successful in 2m11s
Test / Flake checks (push) Successful in 1m28s
This should have been an implementation detail and should not be up to the caller to call it. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
a5f0aa3f30
commit
9462af08f3
@ -52,8 +52,6 @@ type outcome struct {
|
||||
// initial [hst.Config] gob stream for state data;
|
||||
// this is prepared ahead of time as config is clobbered during seal creation
|
||||
ct io.WriterTo
|
||||
// dump dbus proxy message buffer
|
||||
dbusMsg func()
|
||||
|
||||
user hsuUser
|
||||
sys *system.I
|
||||
@ -548,13 +546,11 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, config *hst.C
|
||||
sessionPath, systemPath := share.instance().Append("bus"), share.instance().Append("system_bus_socket")
|
||||
|
||||
// configure dbus proxy
|
||||
if f, err := k.sys.ProxyDBus(
|
||||
if err := k.sys.ProxyDBus(
|
||||
config.SessionBus, config.SystemBus,
|
||||
sessionPath, systemPath,
|
||||
); err != nil {
|
||||
return err
|
||||
} else {
|
||||
k.dbusMsg = f
|
||||
}
|
||||
|
||||
// share proxy sockets
|
||||
|
@ -134,9 +134,6 @@ func (ms mainState) beforeExit(isFault bool) {
|
||||
perror(err, "close wayland security context")
|
||||
}
|
||||
}
|
||||
if ms.k.dbusMsg != nil {
|
||||
ms.k.dbusMsg()
|
||||
}
|
||||
}
|
||||
|
||||
if ms.uintptr&mainNeedsRevert != 0 {
|
||||
|
@ -22,7 +22,7 @@ var (
|
||||
|
||||
// MustProxyDBus calls ProxyDBus and panics if an error is returned.
|
||||
func (sys *I) MustProxyDBus(sessionPath *container.Absolute, session *dbus.Config, systemPath *container.Absolute, system *dbus.Config) *I {
|
||||
if _, err := sys.ProxyDBus(session, system, sessionPath, systemPath); err != nil {
|
||||
if err := sys.ProxyDBus(session, system, sessionPath, systemPath); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return sys
|
||||
@ -31,12 +31,12 @@ func (sys *I) MustProxyDBus(sessionPath *container.Absolute, session *dbus.Confi
|
||||
|
||||
// ProxyDBus finalises configuration ahead of time and starts xdg-dbus-proxy via [dbus] and terminates it on revert.
|
||||
// This [Op] is always [Process] scoped.
|
||||
func (sys *I) ProxyDBus(session, system *dbus.Config, sessionPath, systemPath *container.Absolute) (func(), error) {
|
||||
func (sys *I) ProxyDBus(session, system *dbus.Config, sessionPath, systemPath *container.Absolute) error {
|
||||
d := new(dbusProxyOp)
|
||||
|
||||
// session bus is required as otherwise this is effectively a very expensive noop
|
||||
if session == nil {
|
||||
return nil, newOpErrorMessage("dbus", ErrDBusConfig,
|
||||
return newOpErrorMessage("dbus", ErrDBusConfig,
|
||||
"attempted to create message bus proxy args without session bus config", false)
|
||||
}
|
||||
|
||||
@ -49,10 +49,10 @@ func (sys *I) ProxyDBus(session, system *dbus.Config, sessionPath, systemPath *c
|
||||
d.out = &linePrefixWriter{println: log.Println, prefix: "(dbus) ", buf: new(strings.Builder)}
|
||||
if final, err := sys.dbusFinalise(sessionBus, systemBus, session, system); err != nil {
|
||||
if errors.Is(err, syscall.EINVAL) {
|
||||
return nil, newOpErrorMessage("dbus", err,
|
||||
return newOpErrorMessage("dbus", err,
|
||||
"message bus proxy configuration contains NUL byte", false)
|
||||
}
|
||||
return nil, newOpErrorMessage("dbus", err,
|
||||
return newOpErrorMessage("dbus", err,
|
||||
fmt.Sprintf("cannot finalise message bus proxy: %v", err), false)
|
||||
} else {
|
||||
if sys.msg.IsVerbose() {
|
||||
@ -69,7 +69,7 @@ func (sys *I) ProxyDBus(session, system *dbus.Config, sessionPath, systemPath *c
|
||||
}
|
||||
|
||||
sys.ops = append(sys.ops, d)
|
||||
return d.out.Dump, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// dbusProxyOp implements [I.ProxyDBus].
|
||||
@ -108,6 +108,10 @@ func (d *dbusProxyOp) revert(sys *I, _ *Criteria) error {
|
||||
exitMessage := "message bus proxy exit"
|
||||
defer func() { sys.msg.Verbose(exitMessage) }()
|
||||
|
||||
if d.out != nil {
|
||||
d.out.Dump()
|
||||
}
|
||||
|
||||
err := sys.dbusProxyWait(d.proxy)
|
||||
if errors.Is(err, context.Canceled) {
|
||||
exitMessage = "message bus proxy canceled upstream"
|
||||
|
@ -82,10 +82,8 @@ func TestDBusProxyOp(t *testing.T) {
|
||||
Op: "dbus", Err: ErrDBusConfig,
|
||||
Msg: "attempted to create message bus proxy args without session bus config",
|
||||
}
|
||||
if f, err := sys.ProxyDBus(nil, new(dbus.Config), nil, nil); !reflect.DeepEqual(err, wantErr) {
|
||||
if err := sys.ProxyDBus(nil, new(dbus.Config), nil, nil); !reflect.DeepEqual(err, wantErr) {
|
||||
t.Errorf("ProxyDBus: error = %v, want %v", err, wantErr)
|
||||
} else if f != nil {
|
||||
t.Errorf("ProxyDBus: f = %p", f)
|
||||
}
|
||||
}, nil, stub.Expect{}},
|
||||
|
||||
@ -120,7 +118,7 @@ func TestDBusProxyOp(t *testing.T) {
|
||||
Op: "dbus", Err: stub.UniqueError(0),
|
||||
Msg: "cannot finalise message bus proxy: unique error 0 injected by the test suite",
|
||||
}
|
||||
if f, err := sys.ProxyDBus(
|
||||
if err := sys.ProxyDBus(
|
||||
&dbus.Config{
|
||||
// use impossible value here as an implicit assert that it goes through the stub
|
||||
Talk: []string{"session\x00"}, Filter: true,
|
||||
@ -131,8 +129,6 @@ func TestDBusProxyOp(t *testing.T) {
|
||||
m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"),
|
||||
m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket")); !reflect.DeepEqual(err, wantErr) {
|
||||
t.Errorf("ProxyDBus: error = %v", err)
|
||||
} else if f != nil {
|
||||
t.Errorf("ProxyDBus: f = %p", f)
|
||||
}
|
||||
}, nil, stub.Expect{Calls: []stub.Call{
|
||||
call("dbusAddress", stub.ExpectArgs{}, [2]string{"unix:path=/run/user/1000/bus", "unix:path=/run/dbus/system_bus_socket"}, nil),
|
||||
|
Loading…
x
Reference in New Issue
Block a user