From febee50a6e25630e471f2d3f5044044edde4db31 Mon Sep 17 00:00:00 2001 From: RustDesk <71636191+rustdesk@users.noreply.github.com> Date: Sun, 15 Nov 2026 11:20:09 +0800 Subject: [PATCH] fix: subscribe clipboard services from permission switches only after authorization (#17065) * Subscribe clipboard services from permission switches only after authorization Permission toggles in the accept window reach the connection before the peer is authorized. The keyboard, clipboard and file switches subscribed the clipboard services at once, so anything the host copied while the window was open was sent to a peer that had not been accepted. Subscribe only once authorized, as the audio switch does; on authorization try_sub_monitor_services subscribes from the recorded values. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq * Say "until authorized" in the permission switch comment The switch arrives after the login request, so "before login" was inaccurate. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq --------- Co-authored-by: Claude Opus 5.5 --- src/server/connection.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/server/connection.rs b/src/server/connection.rs index 4b2eec880..25bbfab26 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -805,7 +805,8 @@ impl Connection { if &name == "keyboard" { conn.keyboard = enabled; conn.send_permission(Permission::Keyboard, enabled).await; - if let Some(s) = conn.server.upgrade() { + // Until authorized, only record the value; try_sub_monitor_services subscribes from it. + if let Some(s) = conn.server.upgrade().filter(|_| conn.authorized) { s.write().unwrap().subscribe( super::clipboard_service::NAME, conn.inner.clone(), conn.can_sub_clipboard_service()); @@ -822,7 +823,7 @@ impl Connection { } else if &name == "clipboard" { conn.clipboard = enabled; conn.send_permission(Permission::Clipboard, enabled).await; - if let Some(s) = conn.server.upgrade() { + if let Some(s) = conn.server.upgrade().filter(|_| conn.authorized) { s.write().unwrap().subscribe( super::clipboard_service::NAME, conn.inner.clone(), conn.can_sub_clipboard_service()); @@ -853,7 +854,7 @@ impl Connection { conn.try_empty_file_clipboard(); } #[cfg(feature = "unix-file-copy-paste")] - if let Some(s) = conn.server.upgrade() { + if let Some(s) = conn.server.upgrade().filter(|_| conn.authorized) { s.write().unwrap().subscribe( super::clipboard_service::FILE_NAME, conn.inner.clone(),