From 178c8bc28bc7ff5efc63415796c0c79e649b3cd7 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sun, 14 Dec 2025 09:41:28 +0900 Subject: internal/pipewire: handle SecurityContext::Create error This method can result in an error targeting it, so it is handled here. This change also causes a call to Create to also Core::Sync, as it should have done. Signed-off-by: Ophestra --- internal/pipewire/securitycontext.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'internal/pipewire/securitycontext.go') diff --git a/internal/pipewire/securitycontext.go b/internal/pipewire/securitycontext.go index 21123f19..ec19a64a 100644 --- a/internal/pipewire/securitycontext.go +++ b/internal/pipewire/securitycontext.go @@ -111,17 +111,39 @@ func (registry *Registry) GetSecurityContext() (securityContext *SecurityContext } // Create queues a [SecurityContextCreate] message for the PipeWire server. -func (securityContext *SecurityContext) Create(listenFd, closeFd int, props SPADict) error { - if err := securityContext.checkDestroy(); err != nil { - return err +func (securityContext *SecurityContext) Create(listenFd, closeFd int, props SPADict) (err error) { + if err = securityContext.checkDestroy(); err != nil { + return + } + + asCoreError := securityContext.ctx.expectsCoreError(securityContext.ID, &err) + if err != nil { + return } // queued in reverse based on upstream behaviour, unsure why offset := securityContext.ctx.queueFiles(closeFd, listenFd) - return securityContext.ctx.writeMessage( + if err = securityContext.ctx.writeMessage( securityContext.ID, &SecurityContextCreate{ListenFd: offset + 1, CloseFd: offset + 0, Properties: &props}, - ) + ); err != nil { + return + } + if err = securityContext.ctx.GetCore().Sync(); err == nil { + return nil + } + + if coreError := asCoreError(); coreError == nil { + return + } else { + switch syscall.Errno(-coreError.Result) { + case syscall.EPERM: + return &PermissionError{securityContext.ID, coreError.Message} + + default: + return coreError + } + } } // securityContextCloser holds onto resources associated to the security context. -- cgit v1.3.1