From ea1d4adfa6e9152cd2b0ab6f9f37bf632c2cc1b2 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Tue, 9 Apr 2024 19:33:39 +0800 Subject: [PATCH] fix check_process on mac since normal user can not get system's process's command line arguments --- src/common.rs | 8 +++++++- src/server/connection.rs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common.rs b/src/common.rs index e57aefe5c..e74302031 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1240,8 +1240,14 @@ pub async fn get_next_nonkeyexchange_msg( None } +#[allow(unused_mut)] #[cfg(not(any(target_os = "android", target_os = "ios")))] -pub fn check_process(arg: &str, same_uid: bool) -> bool { +pub fn check_process(arg: &str, mut same_uid: bool) -> bool { + #[cfg(target_os = "macos")] + if !crate::platform::is_root() { + log::warn!("Can not get other process's command line arguments on macos without root"); + same_uid = true; + } use hbb_common::sysinfo::System; let mut sys = System::new(); sys.refresh_processes(); diff --git a/src/server/connection.rs b/src/server/connection.rs index f5bc16482..ead9d22de 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -958,7 +958,7 @@ impl Connection { } #[cfg(not(any(target_os = "android", target_os = "ios")))] if crate::is_server() && Config::get_option("allow-only-conn-window-open") == "Y" { - if !crate::check_process("", false) { + if !crate::check_process("", !crate::platform::is_root()) { self.send_login_error("The main window is not open").await; return false; }