summaryrefslogtreecommitdiff
path: root/src/protocols/SecurityContext.hpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-10-06 14:07:07 +0100
committerVaxry <vaxry@vaxry.net>2024-10-06 14:07:07 +0100
commitda86aac0f5c5c3604351961b901f62cdf7186a10 (patch)
treecffe015c9899d699d401301018a430b5ab39e8a7 /src/protocols/SecurityContext.hpp
parent0c7a7e2d569eeed9d6025f3eef4ea0690d90845d (diff)
security-context: implement protocol
fixes #7318
Diffstat (limited to 'src/protocols/SecurityContext.hpp')
-rw-r--r--src/protocols/SecurityContext.hpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/protocols/SecurityContext.hpp b/src/protocols/SecurityContext.hpp
new file mode 100644
index 00000000..bcbb69b2
--- /dev/null
+++ b/src/protocols/SecurityContext.hpp
@@ -0,0 +1,83 @@
+#pragma once
+
+#include <memory>
+#include <vector>
+#include <cstdint>
+#include "WaylandProtocol.hpp"
+#include "security-context-v1.hpp"
+
+class CSecurityContext {
+ public:
+ CSecurityContext(SP<CWpSecurityContextV1> resource_, int listenFD_, int closeFD_);
+ ~CSecurityContext();
+
+ bool good();
+
+ std::string sandboxEngine, appID, instanceID;
+ int listenFD = -1, closeFD = -1;
+
+ void onListen(uint32_t mask);
+ void onClose(uint32_t mask);
+
+ private:
+ SP<CWpSecurityContextV1> resource;
+
+ wl_event_source * listenSource = nullptr, *closeSource = nullptr;
+
+ bool committed = false;
+};
+
+class CSecurityContextManagerResource {
+ public:
+ CSecurityContextManagerResource(SP<CWpSecurityContextManagerV1> resource_);
+
+ bool good();
+
+ private:
+ SP<CWpSecurityContextManagerV1> resource;
+};
+
+class CSecurityContextSandboxedClient {
+ public:
+ static SP<CSecurityContextSandboxedClient> create(int clientFD);
+ ~CSecurityContextSandboxedClient();
+
+ void onDestroy();
+
+ wl_listener destroyListener;
+
+ private:
+ CSecurityContextSandboxedClient(int clientFD);
+
+ wl_client* client = nullptr;
+
+ friend class CSecurityContextProtocol;
+ friend class CSecurityContext;
+};
+
+class CSecurityContextProtocol : public IWaylandProtocol {
+ public:
+ CSecurityContextProtocol(const wl_interface* iface, const int& ver, const std::string& name);
+
+ virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
+
+ bool isClientSandboxed(const wl_client* client);
+
+ private:
+ void destroyResource(CSecurityContextManagerResource* resource);
+
+ void destroyContext(CSecurityContext* context);
+
+ //
+ std::vector<SP<CSecurityContextManagerResource>> m_vManagers;
+ std::vector<SP<CSecurityContext>> m_vContexts;
+ std::vector<SP<CSecurityContextSandboxedClient>> m_vSandboxedClients;
+
+ friend class CSecurityContextManagerResource;
+ friend class CSecurityContext;
+ friend class CSecurityContextSandboxedClient;
+};
+
+namespace PROTO {
+ inline UP<CSecurityContextProtocol> securityContext;
+}; \ No newline at end of file