From 1903d5c910ad1e2dc0a217e3cdf1a5a3e16edef3 Mon Sep 17 00:00:00 2001 From: caszuu Date: Wed, 25 Feb 2026 22:14:23 +0100 Subject: [PATCH] refuse pair enable requests while session is running --- server/main.cpp | 9 +++++++++ tools/wivrnctl/main.cpp | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/server/main.cpp b/server/main.cpp index f78ebf09..8091deed 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -657,6 +657,15 @@ gboolean on_handle_rename_key(WivrnServer * skeleton, GDBusMethodInvocation * in gboolean on_handle_enable_pairing(WivrnServer * skeleton, GDBusMethodInvocation * invocation, gpointer user_data) { + bool server_running = server_watch != 0 or connection_thread; + if (server_running) + { + std::cerr << "Cannot enable pairing while session is active." << pin << std::endl; + g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", "")); + + return G_SOURCE_CONTINUE; + } + set_encryption_state(wivrn_connection::encryption_state::pairing); if (pairing_timeout) diff --git a/tools/wivrnctl/main.cpp b/tools/wivrnctl/main.cpp index f7a66eb8..01d85066 100644 --- a/tools/wivrnctl/main.cpp +++ b/tools/wivrnctl/main.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -196,6 +197,12 @@ void pair(int duration) if (ret < 0) throw std::system_error(-ret, std::system_category(), "Failed to read PIN"); + if (std::string_view(pin) == "") + { + std::cout << "Cannot enable pairing while session is active." << pin << std::endl; + return; + } + std::cout << "PIN: " << pin << std::endl; } }