PipeWire 1.4.5 |

Loading...
Searching...
No Matches
security-context.h
Go to the documentation of this file.
1/* PipeWire */
2/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef PIPEWIRE_EXT_SECURITY_CONTEXT_H
6#define PIPEWIRE_EXT_SECURITY_CONTEXT_H
7
8#ifdef __cplusplus
9 extern "C" {
10#endif
11
12#include <spa/utils/defs.h>
13
17
22#define PW_TYPE_INTERFACE_SecurityContext PW_TYPE_INFO_INTERFACE_BASE "SecurityContext"
23
24#define PW_SECURITY_CONTEXT_PERM_MASK PW_PERM_RWX
25
26#define PW_VERSION_SECURITY_CONTEXT 3
27 struct pw_security_context;
28
29#ifndef PW_API_SECURITY_CONTEXT
30#define PW_API_SECURITY_CONTEXT static inline
31#endif
32
33#define PW_EXTENSION_MODULE_SECURITY_CONTEXT PIPEWIRE_MODULE_PREFIX "module-security-context"
34
35#define PW_SECURITY_CONTEXT_EVENT_NUM 0
36
37
39 struct pw_security_context_events {
40#define PW_VERSION_SECURITY_CONTEXT_EVENTS 0
41 uint32_t version;
42};
43
44#define PW_SECURITY_CONTEXT_METHOD_ADD_LISTENER 0
45#define PW_SECURITY_CONTEXT_METHOD_CREATE 1
46#define PW_SECURITY_CONTEXT_METHOD_NUM 2
47
49 struct pw_security_context_methods {
50#define PW_VERSION_SECURITY_CONTEXT_METHODS 0
51 uint32_t version;
52
53 int (*add_listener) (void *object,
54 struct spa_hook *listener,
55 const struct pw_security_context_events *events,
56 void *data);
57
64 * listen_fd must be ready to accept new connections when this request is
65 * sent by the client. In other words, the client must call bind(2) and
66 * listen(2) before sending the FD.
67 *
68 * close_fd is a FD closed by the client when PipeWire should stop
69 * accepting new connections on listen_fd.
70 *
71 * PipeWire must continue to accept connections on listen_fd when
72 * the client which created the security context disconnects.
73 *
74 * After sending this request, closing listen_fd and close_fd remains the
75 * only valid operation on them.
76 *
77 * \param listen_fd the fd to listen on for new connections
78 * \param close_fd the fd used to stop listening
79 * \param props extra properties. These will be copied on the client
80 * that connects through this context.
81 *
82 * Some properties to set:
83 *
84 * - pipewire.sec.engine with the engine name.
85 * - pipewire.sec.app-id with the application id, this is an opaque,
86 * engine specific id for an application
87 * - pipewire.sec.instance-id with the instance id, this is an opaque,
88 * engine specific id for a running instance of an application.
89 *
90 * See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md
91 * For a list of engine names and the properties to set.
92 *
93 * This requires X and W permissions on the security_context.
94 */
95 int (*create) (void *object,
96 int listen_fd,
97 int close_fd,
98 const struct spa_dict *props);
99};
100
103 PW_API_SECURITY_CONTEXT int pw_security_context_add_listener(struct pw_security_context *object,
104 struct spa_hook *listener,
105 const struct pw_security_context_events *events,
106 void *data)
107{
108 return spa_api_method_r(int, -ENOTSUP,
109 pw_security_context, (struct spa_interface*)object, add_listener, 0,
110 listener, events, data);
111}
112
115 PW_API_SECURITY_CONTEXT int pw_security_context_create(struct pw_security_context *object,
116 int listen_fd, int close_fd, const struct spa_dict *props)
117{
118 return spa_api_method_r(int, -ENOTSUP,
119 pw_security_context, (struct spa_interface*)object, create, 0,
120 listen_fd, close_fd, props);
121}
122
126
127#ifdef __cplusplus
128} /* extern "C" */
129#endif
130
131#endif /* PIPEWIRE_EXT_SECURITY_CONTEXT_H */
defs.h
spa/utils/defs.h
pw_security_context_create
PW_API_SECURITY_CONTEXT int pw_security_context_create(struct pw_security_context *object, int listen_fd, int close_fd, const struct spa_dict *props)
Create a new security context.
Definition security-context.h:131
PW_API_SECURITY_CONTEXT
#define PW_API_SECURITY_CONTEXT
Definition security-context.h:39
pw_security_context_add_listener
PW_API_SECURITY_CONTEXT int pw_security_context_add_listener(struct pw_security_context *object, struct spa_hook *listener, const struct pw_security_context_events *events, void *data)
Definition security-context.h:119
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
pw_security_context_events
Security Context events
Definition security-context.h:50
pw_security_context_events::version
uint32_t version
Definition security-context.h:53
pw_security_context_methods
Security Context methods
Definition security-context.h:64
pw_security_context_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_security_context_events *events, void *data)
Definition security-context.h:69
pw_security_context_methods::create
int(* create)(void *object, int listen_fd, int close_fd, const struct spa_dict *props)
Create a new security context.
Definition security-context.h:111
pw_security_context
spa_dict
Definition dict.h:51
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_interface
Definition hook.h:148