From 4e41cda27ed4176005082436cb35878335e63fae Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 6 Oct 2024 15:08:26 +0100 Subject: [PATCH] security-context: close client fds after disconnect --- src/protocols/SecurityContext.cpp | 7 ++++--- src/protocols/SecurityContext.hpp | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/protocols/SecurityContext.cpp b/src/protocols/SecurityContext.cpp index b93ef448..b42c3a97 100644 --- a/src/protocols/SecurityContext.cpp +++ b/src/protocols/SecurityContext.cpp @@ -14,8 +14,8 @@ static int onCloseFdEvent(int fd, uint32_t mask, void* data) { return 0; } -SP CSecurityContextSandboxedClient::create(int clientFD) { - auto p = SP(new CSecurityContextSandboxedClient(clientFD)); +SP CSecurityContextSandboxedClient::create(int clientFD_) { + auto p = SP(new CSecurityContextSandboxedClient(clientFD_)); if (!p->client) return nullptr; return p; @@ -26,7 +26,7 @@ static void onSecurityContextClientDestroy(wl_listener* l, void* d) { client->onDestroy(); } -CSecurityContextSandboxedClient::CSecurityContextSandboxedClient(int clientFD) { +CSecurityContextSandboxedClient::CSecurityContextSandboxedClient(int clientFD_) : clientFD(clientFD_) { client = wl_client_create(g_pCompositor->m_sWLDisplay, clientFD); if (!client) return; @@ -37,6 +37,7 @@ CSecurityContextSandboxedClient::CSecurityContextSandboxedClient(int clientFD) { CSecurityContextSandboxedClient::~CSecurityContextSandboxedClient() { wl_list_remove(&destroyListener.link); + close(clientFD); } void CSecurityContextSandboxedClient::onDestroy() { diff --git a/src/protocols/SecurityContext.hpp b/src/protocols/SecurityContext.hpp index bcbb69b2..76313bcf 100644 --- a/src/protocols/SecurityContext.hpp +++ b/src/protocols/SecurityContext.hpp @@ -47,9 +47,10 @@ class CSecurityContextSandboxedClient { wl_listener destroyListener; private: - CSecurityContextSandboxedClient(int clientFD); + CSecurityContextSandboxedClient(int clientFD_); - wl_client* client = nullptr; + wl_client* client = nullptr; + int clientFD = -1; friend class CSecurityContextProtocol; friend class CSecurityContext;