internal/system: remove ineffectual join reverting wayland
Some checks failed
Test / Create distribution (push) Successful in 40s
Test / Sandbox (push) Failing after 1m18s
Test / Hakurei (push) Failing after 1m55s
Test / Hakurei (race detector) (push) Failing after 2m24s
Test / Hpkg (push) Failing after 2m28s
Test / Sandbox (race detector) (push) Failing after 4m1s
Test / Flake checks (push) Has been skipped

Removing the pathname socket used to be handled separately, now it is done during the Close call.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-12-07 00:31:04 +09:00
parent 3cb58b4b72
commit 3ebb6c6f75
3 changed files with 10 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
package system package system
import ( import (
"io"
"log" "log"
"os" "os"
"reflect" "reflect"
@@ -13,7 +14,6 @@ import (
"hakurei.app/hst" "hakurei.app/hst"
"hakurei.app/internal/acl" "hakurei.app/internal/acl"
"hakurei.app/internal/dbus" "hakurei.app/internal/dbus"
"hakurei.app/internal/wayland"
"hakurei.app/internal/xcb" "hakurei.app/internal/xcb"
) )
@@ -270,9 +270,9 @@ func (k *kstub) aclUpdate(name string, uid int, perms ...acl.Perm) error {
stub.CheckArgReflect(k.Stub, "perms", perms, 2)) stub.CheckArgReflect(k.Stub, "perms", perms, 2))
} }
func (k *kstub) waylandNew(displayPath, bindPath *check.Absolute, appID, instanceID string) (*wayland.SecurityContext, error) { func (k *kstub) waylandNew(displayPath, bindPath *check.Absolute, appID, instanceID string) (io.Closer, error) {
k.Helper() k.Helper()
return nil, k.Expects("waylandNew").Error( return io.NopCloser(nil), k.Expects("waylandNew").Error(
stub.CheckArgReflect(k.Stub, "displayPath", displayPath, 0), stub.CheckArgReflect(k.Stub, "displayPath", displayPath, 0),
stub.CheckArgReflect(k.Stub, "bindPath", bindPath, 1), stub.CheckArgReflect(k.Stub, "bindPath", bindPath, 1),
stub.CheckArg(k.Stub, "appID", appID, 2), stub.CheckArg(k.Stub, "appID", appID, 2),

View File

@@ -3,11 +3,11 @@ package system
import ( import (
"errors" "errors"
"fmt" "fmt"
"io"
"hakurei.app/container/check" "hakurei.app/container/check"
"hakurei.app/hst" "hakurei.app/hst"
"hakurei.app/internal/acl" "hakurei.app/internal/acl"
"hakurei.app/internal/wayland"
) )
// Wayland maintains a wayland socket with security-context-v1 attached via [wayland]. // Wayland maintains a wayland socket with security-context-v1 attached via [wayland].
@@ -21,7 +21,7 @@ func (sys *I) Wayland(dst, src *check.Absolute, appID, instanceID string) *I {
// waylandOp implements [I.Wayland]. // waylandOp implements [I.Wayland].
type waylandOp struct { type waylandOp struct {
ctx *wayland.SecurityContext ctx io.Closer
dst, src *check.Absolute dst, src *check.Absolute
appID, instanceID string appID, instanceID string
} }
@@ -53,17 +53,11 @@ func (w *waylandOp) apply(sys *I) (err error) {
} }
func (w *waylandOp) revert(sys *I, _ *Criteria) error { func (w *waylandOp) revert(sys *I, _ *Criteria) error {
var (
hangupErr error
removeErr error
)
sys.msg.Verbosef("hanging up wayland socket on %q", w.dst)
if w.ctx != nil { if w.ctx != nil {
hangupErr = w.ctx.Close() sys.msg.Verbosef("hanging up wayland socket on %q", w.dst)
return newOpError("wayland", w.ctx.Close(), true)
} }
return nil
return newOpError("wayland", errors.Join(hangupErr, removeErr), true)
} }
func (w *waylandOp) Is(o Op) bool { func (w *waylandOp) Is(o Op) bool {

View File

@@ -1,7 +1,6 @@
package system package system
import ( import (
"errors"
"os" "os"
"testing" "testing"
@@ -22,7 +21,7 @@ func TestWaylandOp(t *testing.T) {
call("waylandNew", stub.ExpectArgs{m("/run/user/1971/wayland-0"), m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"), "org.chromium.Chromium", "ebf083d1b175911782d413369b64ce7c"}, nil, nil), call("waylandNew", stub.ExpectArgs{m("/run/user/1971/wayland-0"), m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"), "org.chromium.Chromium", "ebf083d1b175911782d413369b64ce7c"}, nil, nil),
call("verbosef", stub.ExpectArgs{"wayland pathname socket on %q via %q", []any{m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"), m("/run/user/1971/wayland-0")}}, nil, nil), call("verbosef", stub.ExpectArgs{"wayland pathname socket on %q via %q", []any{m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"), m("/run/user/1971/wayland-0")}}, nil, nil),
call("chmod", stub.ExpectArgs{"/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland", os.FileMode(0)}, nil, stub.UniqueError(3)), call("chmod", stub.ExpectArgs{"/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland", os.FileMode(0)}, nil, stub.UniqueError(3)),
}, &OpError{Op: "wayland", Err: errors.Join(stub.UniqueError(3), os.ErrInvalid)}, nil, nil}, }, &OpError{Op: "wayland", Err: stub.UniqueError(3)}, nil, nil},
{"aclUpdate", 0xbeef, 0xff, &waylandOp{nil, {"aclUpdate", 0xbeef, 0xff, &waylandOp{nil,
m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"), m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"),
@@ -34,7 +33,7 @@ func TestWaylandOp(t *testing.T) {
call("verbosef", stub.ExpectArgs{"wayland pathname socket on %q via %q", []any{m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"), m("/run/user/1971/wayland-0")}}, nil, nil), call("verbosef", stub.ExpectArgs{"wayland pathname socket on %q via %q", []any{m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"), m("/run/user/1971/wayland-0")}}, nil, nil),
call("chmod", stub.ExpectArgs{"/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland", os.FileMode(0)}, nil, nil), call("chmod", stub.ExpectArgs{"/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland", os.FileMode(0)}, nil, nil),
call("aclUpdate", stub.ExpectArgs{"/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland", 0xbeef, []acl.Perm{acl.Read, acl.Write, acl.Execute}}, nil, stub.UniqueError(2)), call("aclUpdate", stub.ExpectArgs{"/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland", 0xbeef, []acl.Perm{acl.Read, acl.Write, acl.Execute}}, nil, stub.UniqueError(2)),
}, &OpError{Op: "wayland", Err: errors.Join(stub.UniqueError(2), os.ErrInvalid)}, nil, nil}, }, &OpError{Op: "wayland", Err: stub.UniqueError(2)}, nil, nil},
{"success", 0xbeef, 0xff, &waylandOp{nil, {"success", 0xbeef, 0xff, &waylandOp{nil,
m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"), m("/tmp/hakurei.1971/ebf083d1b175911782d413369b64ce7c/wayland"),