internal/outcome: expose pipewire via pipewire-pulse
All checks were successful
Test / Create distribution (push) Successful in 28s
Test / Sandbox (push) Successful in 42s
Test / Hakurei (push) Successful in 3m20s
Test / Hpkg (push) Successful in 2m13s
Test / Sandbox (race detector) (push) Successful in 4m25s
Test / Hakurei (race detector) (push) Successful in 3m21s
Test / Flake checks (push) Successful in 1m30s
All checks were successful
Test / Create distribution (push) Successful in 28s
Test / Sandbox (push) Successful in 42s
Test / Hakurei (push) Successful in 3m20s
Test / Hpkg (push) Successful in 2m13s
Test / Sandbox (race detector) (push) Successful in 4m25s
Test / Hakurei (race detector) (push) Successful in 3m21s
Test / Flake checks (push) Successful in 1m30s
This no longer exposes the pipewire socket to the container, and instead mediates access via pipewire-pulse. This makes insecure parts of the protocol inaccessible as explained in the doc comment in hst. Closes #29. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -15,9 +15,11 @@ import (
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/container/fhs"
|
||||
"hakurei.app/container/seccomp"
|
||||
"hakurei.app/container/std"
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/internal/pipewire"
|
||||
"hakurei.app/message"
|
||||
)
|
||||
|
||||
@@ -266,6 +268,79 @@ func shimEntrypoint(k syscallDispatcher) {
|
||||
// bounds and default enforced in finalise.go
|
||||
z.WaitDelay = state.Shim.WaitDelay
|
||||
|
||||
if stateParams.pipewirePulsePath != nil {
|
||||
zpw := container.NewCommand(ctx, msg, stateParams.pipewirePulsePath, pipewirePulseName)
|
||||
zpw.Hostname = "hakurei-" + pipewirePulseName
|
||||
zpw.SeccompFlags |= seccomp.AllowMultiarch
|
||||
zpw.SeccompPresets |= std.PresetStrict
|
||||
zpw.Env = []string{
|
||||
// pipewire SecurityContext socket path
|
||||
pipewire.Remote + "=" + stateParams.instancePath().Append("pipewire").String(),
|
||||
// pipewire-pulse socket directory path
|
||||
envXDGRuntimeDir + "=" + sp.String(),
|
||||
}
|
||||
if msg.IsVerbose() {
|
||||
zpw.Stdin, zpw.Stdout, zpw.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||
}
|
||||
zpw.
|
||||
Bind(fhs.AbsRoot, fhs.AbsRoot, 0).
|
||||
Bind(sp.unwrap(), sp.unwrap(), std.BindWritable).
|
||||
Proc(fhs.AbsProc).Dev(fhs.AbsDev, true)
|
||||
socketPath := sp.unwrap().Append("pulse", "native")
|
||||
innerSocketPath := stateParams.runtimeDir.Append("pulse", "native")
|
||||
|
||||
if err := k.containerStart(zpw); err != nil {
|
||||
sp.destroy()
|
||||
printMessageError(func(v ...any) { k.fatal(fmt.Sprintln(v...)) },
|
||||
"cannot start "+pipewirePulseName+" container:", err)
|
||||
}
|
||||
if err := k.containerServe(zpw); err != nil {
|
||||
sp.destroy()
|
||||
printMessageError(func(v ...any) { k.fatal(fmt.Sprintln(v...)) },
|
||||
"cannot configure "+pipewirePulseName+" container:", err)
|
||||
}
|
||||
|
||||
done := make(chan error, 1)
|
||||
k.new(func(k syscallDispatcher, msg message.Msg) { done <- k.containerWait(zpw) })
|
||||
|
||||
socketTimer := time.NewTimer(shimPipeWireTimeout)
|
||||
for {
|
||||
select {
|
||||
case <-socketTimer.C:
|
||||
sp.destroy()
|
||||
k.fatal(pipewirePulseName + " exceeded deadline before socket appeared")
|
||||
break
|
||||
|
||||
case err := <-done:
|
||||
var exitError *exec.ExitError
|
||||
if !errors.As(err, &exitError) {
|
||||
msg.Verbosef("cannot wait: %v", err)
|
||||
k.exit(127)
|
||||
}
|
||||
sp.destroy()
|
||||
k.fatal(pipewirePulseName + " " + exitError.ProcessState.String())
|
||||
break
|
||||
|
||||
default:
|
||||
if _, err := k.stat(socketPath.String()); err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
sp.destroy()
|
||||
k.fatal(err)
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(500 * time.Microsecond)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
z.Bind(socketPath, innerSocketPath, 0)
|
||||
z.Env = append(z.Env, "PULSE_SERVER=unix:"+innerSocketPath.String())
|
||||
}
|
||||
|
||||
if err := k.containerStart(z); err != nil {
|
||||
var f func(v ...any)
|
||||
if logger := msg.GetLogger(); logger != nil {
|
||||
|
||||
Reference in New Issue
Block a user