mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
elevation: keyboard permission required and remove foreground filter
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -1303,9 +1303,10 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
}
|
||||
}
|
||||
Some(misc::Union::Uac(uac)) => {
|
||||
let keyboard = self.handler.server_keyboard_enabled.read().unwrap().clone();
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
if uac {
|
||||
if uac && keyboard {
|
||||
self.handler.msgbox(
|
||||
"on-uac",
|
||||
"Prompt",
|
||||
@@ -1324,7 +1325,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
let title = "Prompt";
|
||||
let text = "Please wait for confirmation of UAC...";
|
||||
let link = "";
|
||||
if uac {
|
||||
if uac && keyboard {
|
||||
self.handler.msgbox(msgtype, title, text, link);
|
||||
} else {
|
||||
self.handler.cancel_msgbox(&format!(
|
||||
@@ -1335,9 +1336,10 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
}
|
||||
}
|
||||
Some(misc::Union::ForegroundWindowElevated(elevated)) => {
|
||||
let keyboard = self.handler.server_keyboard_enabled.read().unwrap().clone();
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
if elevated {
|
||||
if elevated && keyboard {
|
||||
self.handler.msgbox(
|
||||
"on-foreground-elevated",
|
||||
"Prompt",
|
||||
@@ -1356,7 +1358,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
let title = "Prompt";
|
||||
let text = "elevated_foreground_window_tip";
|
||||
let link = "";
|
||||
if elevated {
|
||||
if elevated && keyboard {
|
||||
self.handler.msgbox(msgtype, title, text, link);
|
||||
} else {
|
||||
self.handler.cancel_msgbox(&format!(
|
||||
@@ -1370,6 +1372,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
if err.is_empty() {
|
||||
self.handler.msgbox("wait-uac", "", "", "");
|
||||
} else {
|
||||
self.handler.cancel_msgbox("wait-uac");
|
||||
self.handler
|
||||
.msgbox("elevation-error", "Elevation Error", &err, "");
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "启动时检查软件更新"),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "请升级专业版服务器到{}或更高版本!"),
|
||||
("pull_group_failed_tip", "获取组信息失败"),
|
||||
("No permission", "没有权限"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "Beim Start auf Softwareaktualisierung prüfen"),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "Bitte aktualisieren Sie RustDesk Server Pro auf die Version {} oder neuer!"),
|
||||
("pull_group_failed_tip", "Aktualisierung der Gruppe fehlgeschlagen"),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "Comprobar actualización al iniciar"),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "¡Por favor, actualiza RustDesk Server Pro a la versión {} o superior"),
|
||||
("pull_group_failed_tip", "No se ha podido refrescar el grupo"),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "Vérifier la disponibilité des mises à jour au démarrage"),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "Veuillez mettre à jour RustDesk Server Pro avec la version {} ou une version plus récente !"),
|
||||
("pull_group_failed_tip", "Échec de l'actualisation du groupe"),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "Periksa pembaruan aplikasi saat sistem dinyalakan."),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "Silahkan perbarui RustDesk Server Pro ke versi {} atau yang lebih baru!"),
|
||||
("pull_group_failed_tip", "Gagal memperbarui grup"),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "All'avvio verifica presenza aggiornamenti programma"),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "Aggiorna RustDesk Server Pro alla versione {} o successiva!"),
|
||||
("pull_group_failed_tip", "Impossibile aggiornare il gruppo"),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("ID Server", "ID serveris"),
|
||||
("Relay Server", "Releja serveris"),
|
||||
("API Server", "API serveris"),
|
||||
("Key", "Atslēga"),
|
||||
("invalid_http", "jāsākas ar http:// vai https://"),
|
||||
("Invalid IP", "Nederīga IP"),
|
||||
("Invalid format", "Nederīgs formāts"),
|
||||
@@ -297,7 +296,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("This file exists, skip or overwrite this file?", "Šis fails pastāv, izlaist vai pārrakstīt šo failu?"),
|
||||
("Quit", "Iziet"),
|
||||
("doc_mac_permission", "https://rustdesk.com/docs/en/manual/mac/#enable-permissions"),
|
||||
("doc_fix_wayland", "https://rustdesk.com/docs/en/manual/linux/#x11-required"),
|
||||
("Help", "Palīdzība"),
|
||||
("Failed", "Neizdevās"),
|
||||
("Succeeded", "Izdevās"),
|
||||
@@ -481,7 +479,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Me", "Es"),
|
||||
("identical_file_tip", "Šis fails ir identisks sesijas failam."),
|
||||
("show_monitors_tip", "Rādīt monitorus rīkjoslā"),
|
||||
("enter_rustdesk_passwd_tip", "Ievadiet RustDesk paroli"),
|
||||
("View Mode", "Skatīšanas režīms"),
|
||||
("login_linux_tip", "Jums ir jāpiesakās attālajā Linux kontā, lai iespējotu X darbvirsmas sesiju"),
|
||||
("verify_rustdesk_password_tip", "Pārbaudīt RustDesk paroli"),
|
||||
@@ -560,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "Startējot pārbaudīt, vai nav programmatūras atjauninājumu"),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "Lūdzu, jauniniet RustDesk Server Pro uz versiju {} vai jaunāku!"),
|
||||
("pull_group_failed_tip", "Neizdevās atsvaidzināt grupu"),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "Sprawdź aktualizacje przy starcie programu"),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "Proszę zaktualizować RustDesk Server Pro do wersji {} lub nowszej!"),
|
||||
("pull_group_failed_tip", "Błąd odświeżania grup"),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", "Проверять обновления программы при запуске"),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", "Обновите RustDesk Server Pro до версии {} или новее!"),
|
||||
("pull_group_failed_tip", "Невозможно обновить группу"),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -557,5 +557,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Check for software update on startup", ""),
|
||||
("upgrade_rustdesk_server_pro_to_{}_tip", ""),
|
||||
("pull_group_failed_tip", ""),
|
||||
("No permission", ""),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -1587,29 +1587,6 @@ pub fn is_elevated(process_id: Option<DWORD>) -> ResultType<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn filter_foreground_window(process_id: DWORD) -> ResultType<bool> {
|
||||
if let Ok(output) = std::process::Command::new("tasklist")
|
||||
.args(vec![
|
||||
"/SVC",
|
||||
"/NH",
|
||||
"/FI",
|
||||
&format!("PID eq {}", process_id),
|
||||
])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.output()
|
||||
{
|
||||
let s = String::from_utf8_lossy(&output.stdout)
|
||||
.to_string()
|
||||
.to_lowercase();
|
||||
Ok(["Taskmgr", "mmc", "regedit"]
|
||||
.iter()
|
||||
.any(|name| s.contains(&name.to_string().to_lowercase())))
|
||||
} else {
|
||||
bail!("run tasklist failed");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_foreground_window_elevated() -> ResultType<bool> {
|
||||
unsafe {
|
||||
let mut process_id: DWORD = 0;
|
||||
@@ -1617,12 +1594,7 @@ pub fn is_foreground_window_elevated() -> ResultType<bool> {
|
||||
if process_id == 0 {
|
||||
bail!("Failed to get processId, errno {}", GetLastError())
|
||||
}
|
||||
let elevated = is_elevated(Some(process_id))?;
|
||||
if elevated {
|
||||
filter_foreground_window(process_id)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
is_elevated(Some(process_id))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2047,12 +2047,18 @@ impl Connection {
|
||||
|
||||
#[cfg(windows)]
|
||||
async fn handle_elevation_request(&mut self, para: portable_client::StartPara) {
|
||||
let mut err = "No need to elevate".to_string();
|
||||
if !crate::platform::is_installed() && !portable_client::running() {
|
||||
err = portable_client::start_portable_service(para)
|
||||
.err()
|
||||
.map_or("".to_string(), |e| e.to_string());
|
||||
let mut err;
|
||||
if !self.keyboard {
|
||||
err = "No permission".to_string();
|
||||
} else {
|
||||
err = "No need to elevate".to_string();
|
||||
if !crate::platform::is_installed() && !portable_client::running() {
|
||||
err = portable_client::start_portable_service(para)
|
||||
.err()
|
||||
.map_or("".to_string(), |e| e.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
let mut misc = Misc::new();
|
||||
misc.set_elevation_response(err);
|
||||
let mut msg = Message::new();
|
||||
@@ -2369,6 +2375,7 @@ impl Connection {
|
||||
if self.portable.is_installed
|
||||
|| self.file_transfer.is_some()
|
||||
|| self.port_forward_socket.is_some()
|
||||
|| !self.keyboard
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user