internal/system: integrate PipeWire SecurityContext
All checks were successful
Test / Create distribution (push) Successful in 29s
Test / Sandbox (race detector) (push) Successful in 42s
Test / Sandbox (push) Successful in 43s
Test / Hakurei (push) Successful in 47s
Test / Hakurei (race detector) (push) Successful in 46s
Test / Hpkg (push) Successful in 43s
Test / Flake checks (push) Successful in 1m32s

Tests for this Op happens to be the best out of everything due to the robust infrastructure offered by internal/pipewire.

This is now ready to use in internal/outcome for implementing #26.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-12-07 17:39:34 +09:00
parent 1b17ccda91
commit 093e30c788
4 changed files with 632 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ import (
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/dbus"
"hakurei.app/internal/pipewire"
"hakurei.app/internal/xcb"
)
@@ -245,8 +246,16 @@ func (k *kstub) mkdir(name string, perm os.FileMode) error {
func (k *kstub) chmod(name string, mode os.FileMode) error {
k.Helper()
return k.Expects("chmod").Error(
stub.CheckArg(k.Stub, "name", name, 0),
expect := k.Expects("chmod")
// translate ignored name
nameVal := any(name)
if _, ok := expect.Args[0].(ignoreValue); ok {
nameVal = ignoreValue{}
}
return expect.Error(
stub.CheckArgReflect(k.Stub, "name", nameVal, 0),
stub.CheckArg(k.Stub, "mode", mode, 1))
}
@@ -273,8 +282,16 @@ func (k *kstub) println(v ...any) {
func (k *kstub) aclUpdate(name string, uid int, perms ...acl.Perm) error {
k.Helper()
return k.Expects("aclUpdate").Error(
stub.CheckArg(k.Stub, "name", name, 0),
expect := k.Expects("aclUpdate")
// translate ignored name
nameVal := any(name)
if _, ok := expect.Args[0].(ignoreValue); ok {
nameVal = ignoreValue{}
}
return expect.Error(
stub.CheckArgReflect(k.Stub, "name", nameVal, 0),
stub.CheckArg(k.Stub, "uid", uid, 1),
stub.CheckArgReflect(k.Stub, "perms", perms, 2))
}
@@ -288,6 +305,12 @@ func (k *kstub) waylandNew(displayPath, bindPath *check.Absolute, appID, instanc
stub.CheckArg(k.Stub, "instanceID", instanceID, 3))
}
func (k *kstub) pipewireConnect() (*pipewire.Context, error) {
k.Helper()
expect := k.Expects("pipewireConnect")
return expect.Ret.(func() *pipewire.Context)(), expect.Error()
}
func (k *kstub) xcbChangeHosts(mode xcb.HostMode, family xcb.Family, address string) error {
k.Helper()
return k.Expects("xcbChangeHosts").Error(
@@ -387,7 +410,18 @@ func (k *kstub) Verbose(v ...any) {
func (k *kstub) Verbosef(format string, v ...any) {
k.Helper()
if k.Expects("verbosef").Error(
expect := k.Expects("verbosef")
// translate ignores in v
if want, ok := expect.Args[1].([]any); ok && len(v) == len(want) {
for i, a := range want {
if _, ok = a.(ignoreValue); ok {
v[i] = ignoreValue{}
}
}
}
if expect.Error(
stub.CheckArg(k.Stub, "format", format, 0),
stub.CheckArgReflect(k.Stub, "v", v, 1)) != nil {
k.FailNow()