Skip to content

Commit

Permalink
fix check_process on mac since normal user can not get system's
Browse files Browse the repository at this point in the history
process's command line arguments
  • Loading branch information
rustdesk committed Apr 9, 2024
1 parent f34a8ef commit ea1d4ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/server/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ea1d4ad

Please sign in to comment.