aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/securitycontext.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-29 16:08:31 +0900
committerOphestra <cat@gensokyo.uk>2025-11-29 16:46:39 +0900
commitde3fc7ba381988c06fdbb0be8446b8e8d2e75af4 (patch)
tree10a00dee1a050b59b45ed8c8a875855fb471d169 /internal/pipewire/securitycontext.go
parent5a5c4705dd47c7e27f49526b4ccf0d4c7c1bab5a (diff)
internal/pipewire: implement SecurityContext::Create
This is finally the thing we are after. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/securitycontext.go')
-rw-r--r--internal/pipewire/securitycontext.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/internal/pipewire/securitycontext.go b/internal/pipewire/securitycontext.go
new file mode 100644
index 00000000..849dc958
--- /dev/null
+++ b/internal/pipewire/securitycontext.go
@@ -0,0 +1,69 @@
+package pipewire
+
+/* pipewire/extensions/security-context.h */
+
+const (
+ PW_TYPE_INTERFACE_SecurityContext = PW_TYPE_INFO_INTERFACE_BASE + "SecurityContext"
+ PW_SECURITY_CONTEXT_PERM_MASK = PW_PERM_RWX
+ PW_VERSION_SECURITY_CONTEXT = 3
+
+ PW_EXTENSION_MODULE_SECURITY_CONTEXT = PIPEWIRE_MODULE_PREFIX + "module-security-context"
+)
+
+const (
+ PW_SECURITY_CONTEXT_EVENT_NUM = iota
+
+ PW_VERSION_SECURITY_CONTEXT_EVENTS = 0
+)
+
+const (
+ PW_SECURITY_CONTEXT_METHOD_ADD_LISTENER = iota
+ PW_SECURITY_CONTEXT_METHOD_CREATE
+ PW_SECURITY_CONTEXT_METHOD_NUM
+
+ PW_VERSION_SECURITY_CONTEXT_METHODS = 0
+)
+
+// SecurityContextCreate is sent to create a new security context.
+//
+// Creates a new security context with a socket listening FD.
+// PipeWire will accept new client connections on listen_fd.
+//
+// listen_fd must be ready to accept new connections when this
+// request is sent by the client. In other words, the client must
+// call bind(2) and listen(2) before sending the FD.
+//
+// close_fd is a FD closed by the client when PipeWire should stop
+// accepting new connections on listen_fd.
+//
+// PipeWire must continue to accept connections on listen_fd when
+// the client which created the security context disconnects.
+//
+// After sending this request, closing listen_fd and close_fd
+// remains the only valid operation on them.
+type SecurityContextCreate struct {
+ // The offset in the SCM_RIGHTS msg_control message to
+ // the fd to listen on for new connections.
+ ListenFd Fd
+ // The offset in the SCM_RIGHTS msg_control message to
+ // the fd used to stop listening.
+ CloseFd Fd
+
+ // Extra properties. These will be copied on the client
+ // that connects through this context.
+ Properties *SPADict `json:"props"`
+}
+
+// Size satisfies [KnownSize] with a value computed at runtime.
+func (c *SecurityContextCreate) Size() Word {
+ return SizePrefix +
+ Size(SizeFd) +
+ Size(SizeFd) +
+ c.Properties.Size()
+}
+
+// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
+func (c *SecurityContextCreate) MarshalBinary() ([]byte, error) { return Marshal(c) }
+
+// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
+func (c *SecurityContextCreate) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) }