mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'master' into keyboard
This commit is contained in:
@@ -173,7 +173,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
crate::start_os_service();
|
||||
return None;
|
||||
} else if args[0] == "--server" {
|
||||
log::info!("start --server");
|
||||
log::info!("start --server with user {}", crate::username());
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
crate::start_server(true);
|
||||
|
||||
@@ -56,7 +56,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Too frequent", "Zu häufig"),
|
||||
("Cancel", "Abbrechen"),
|
||||
("Skip", "Überspringen"),
|
||||
("Close", "Sitzung beenden"),
|
||||
("Close", "Schließen"),
|
||||
("Retry", "Erneut versuchen"),
|
||||
("OK", "OK"),
|
||||
("Password Required", "Passwort erforderlich"),
|
||||
@@ -358,7 +358,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Unpin menubar", "Menüleiste lösen"),
|
||||
("Recording", "Aufnahme"),
|
||||
("Directory", "Verzeichnis"),
|
||||
("Automatically record incoming sessions", "Automatische Aufzeichnung eingehender Sitzungen"),
|
||||
("Automatically record incoming sessions", "Eingehende Sitzungen automatisch aufzeichnen"),
|
||||
("Change", "Ändern"),
|
||||
("Start session recording", "Sitzungsaufzeichnung starten"),
|
||||
("Stop session recording", "Sitzungsaufzeichnung beenden"),
|
||||
@@ -398,7 +398,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Hide connection management window", "Fenster zur Verwaltung der Verbindung verstecken"),
|
||||
("hide_cm_tip", "Dies ist nur möglich, wenn der Zugriff nur über ein permanentes Passwort erfolgt."), // Sehr unklar. Muss noch angepasst werden. Original: Allow hiding only if accepting sessions via password and using pernament passw"),
|
||||
("wayland_experiment_tip", ""),
|
||||
("Right click to select tabs", ""),
|
||||
("Add to Address Book", ""),
|
||||
("Right click to select tabs", "Register mit rechtem Mausklick auswählen"),
|
||||
("Add to Address Book", "Zum Adressbuch hinzufügen"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Transfer File", "Transferir archivo"),
|
||||
("Connect", "Conectar"),
|
||||
("Recent Sessions", "Sesiones recientes"),
|
||||
("Address Book", "Directorio"),
|
||||
("Address Book", "Libreta de direcciones"),
|
||||
("Confirmation", "Confirmación"),
|
||||
("TCP Tunneling", "Túnel TCP"),
|
||||
("Remove", "Quitar"),
|
||||
|
||||
@@ -179,7 +179,8 @@ fn set_x11_env(uid: &str) {
|
||||
log::info!("uid of seat0: {}", uid);
|
||||
let gdm = format!("/run/user/{}/gdm/Xauthority", uid);
|
||||
let mut auth = get_env_tries("XAUTHORITY", uid, 10);
|
||||
if auth.is_empty() {
|
||||
// auth is another user's when uid = 0, https://github.com/rustdesk/rustdesk/issues/2468
|
||||
if auth.is_empty() || uid == "0" {
|
||||
auth = if std::path::Path::new(&gdm).exists() {
|
||||
gdm
|
||||
} else {
|
||||
|
||||
@@ -439,6 +439,7 @@ extern "C" {
|
||||
fn win32_disable_lowlevel_keyboard(hwnd: HWND);
|
||||
fn win_stop_system_key_propagate(v: BOOL);
|
||||
fn is_win_down() -> BOOL;
|
||||
fn is_local_system() -> BOOL;
|
||||
}
|
||||
|
||||
extern "system" {
|
||||
@@ -718,10 +719,10 @@ pub fn set_share_rdp(enable: bool) {
|
||||
}
|
||||
|
||||
pub fn get_active_username() -> String {
|
||||
let name = crate::username();
|
||||
if name != "SYSTEM" {
|
||||
return name;
|
||||
if !is_root() {
|
||||
return crate::username();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn get_active_user(path: *mut u16, n: u32, rdp: BOOL) -> u32;
|
||||
}
|
||||
@@ -757,7 +758,8 @@ pub fn is_prelogin() -> bool {
|
||||
}
|
||||
|
||||
pub fn is_root() -> bool {
|
||||
crate::username() == "SYSTEM"
|
||||
// https://stackoverflow.com/questions/4023586/correct-way-to-find-out-if-a-service-is-running-as-the-system-user
|
||||
unsafe { is_local_system() == TRUE }
|
||||
}
|
||||
|
||||
pub fn lock_screen() {
|
||||
|
||||
@@ -379,7 +379,9 @@ impl RendezvousMediator {
|
||||
)
|
||||
.await?;
|
||||
let local_addr = socket.local_addr();
|
||||
allow_err!(socket_client::connect_tcp(peer_addr, local_addr, 300).await);
|
||||
// key important here for punch hole to tell my gateway incoming peer is safe.
|
||||
// it can not be async here, because local_addr can not be reused, we must close the connection before use it again.
|
||||
allow_err!(socket_client::connect_tcp(peer_addr, local_addr, 30).await);
|
||||
socket
|
||||
};
|
||||
let mut msg_out = Message::new();
|
||||
|
||||
42
src/tray.rs
42
src/tray.rs
@@ -88,6 +88,9 @@ pub fn start_tray() {
|
||||
/// This function will block current execution, show the tray icon and handle events.
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn start_tray() {
|
||||
use std::time::Duration;
|
||||
|
||||
use glib::{clone, Continue};
|
||||
use gtk::traits::{GtkMenuItemExt, MenuShellExt, WidgetExt};
|
||||
|
||||
info!("configuring tray");
|
||||
@@ -106,9 +109,9 @@ pub fn start_tray() {
|
||||
crate::client::translate("Stop service".to_owned())
|
||||
};
|
||||
let menu_item_service = gtk::MenuItem::with_label(label.as_str());
|
||||
menu_item_service.connect_activate(move |item| {
|
||||
menu_item_service.connect_activate(move |_| {
|
||||
let _lock = crate::ui_interface::SENDER.lock().unwrap();
|
||||
update_tray_service_item(item);
|
||||
change_service_state();
|
||||
});
|
||||
menu.append(&menu_item_service);
|
||||
// show tray item
|
||||
@@ -116,6 +119,16 @@ pub fn start_tray() {
|
||||
appindicator.set_menu(&mut menu);
|
||||
// start event loop
|
||||
info!("Setting tray event loop");
|
||||
// check the connection status for every second
|
||||
glib::timeout_add_local(
|
||||
Duration::from_secs(1),
|
||||
clone!(@strong menu_item_service as item => move || {
|
||||
let _lock = crate::ui_interface::SENDER.lock().unwrap();
|
||||
update_tray_service_item(&item);
|
||||
// continue to trigger the next status check
|
||||
Continue(true)
|
||||
}),
|
||||
);
|
||||
gtk::main();
|
||||
} else {
|
||||
error!("Tray process exit now");
|
||||
@@ -123,17 +136,25 @@ pub fn start_tray() {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn change_service_state() {
|
||||
if is_service_stoped() {
|
||||
debug!("Now try to start service");
|
||||
crate::ipc::set_option("stop-service", "");
|
||||
} else {
|
||||
debug!("Now try to stop service");
|
||||
crate::ipc::set_option("stop-service", "Y");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[inline]
|
||||
fn update_tray_service_item(item: >k::MenuItem) {
|
||||
use gtk::traits::GtkMenuItemExt;
|
||||
|
||||
if is_service_stoped() {
|
||||
debug!("Now try to start service");
|
||||
item.set_label(&crate::client::translate("Stop service".to_owned()));
|
||||
crate::ipc::set_option("stop-service", "");
|
||||
} else {
|
||||
debug!("Now try to stop service");
|
||||
item.set_label(&crate::client::translate("Start Service".to_owned()));
|
||||
crate::ipc::set_option("stop-service", "Y");
|
||||
} else {
|
||||
item.set_label(&crate::client::translate("Stop service".to_owned()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,10 +210,10 @@ pub fn make_tray() {
|
||||
match mode {
|
||||
dark_light::Mode::Dark => {
|
||||
icon_path = "mac-tray-light.png";
|
||||
},
|
||||
}
|
||||
dark_light::Mode::Light => {
|
||||
icon_path = "mac-tray-dark.png";
|
||||
},
|
||||
}
|
||||
}
|
||||
if let Ok(mut tray) = TrayItem::new(&crate::get_app_name(), icon_path) {
|
||||
tray.add_label(&format!(
|
||||
@@ -211,4 +232,3 @@ pub fn make_tray() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -588,4 +588,44 @@ extern "C"
|
||||
stop_system_key_propagate = v;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/4023586/correct-way-to-find-out-if-a-service-is-running-as-the-system-user
|
||||
BOOL is_local_system()
|
||||
{
|
||||
HANDLE hToken;
|
||||
UCHAR bTokenUser[sizeof(TOKEN_USER) + 8 + 4 * SID_MAX_SUB_AUTHORITIES];
|
||||
PTOKEN_USER pTokenUser = (PTOKEN_USER)bTokenUser;
|
||||
ULONG cbTokenUser;
|
||||
SID_IDENTIFIER_AUTHORITY siaNT = SECURITY_NT_AUTHORITY;
|
||||
PSID pSystemSid;
|
||||
BOOL bSystem;
|
||||
|
||||
// open process token
|
||||
if (!OpenProcessToken(GetCurrentProcess(),
|
||||
TOKEN_QUERY,
|
||||
&hToken))
|
||||
return FALSE;
|
||||
|
||||
// retrieve user SID
|
||||
if (!GetTokenInformation(hToken, TokenUser, pTokenUser,
|
||||
sizeof(bTokenUser), &cbTokenUser))
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CloseHandle(hToken);
|
||||
|
||||
// allocate LocalSystem well-known SID
|
||||
if (!AllocateAndInitializeSid(&siaNT, 1, SECURITY_LOCAL_SYSTEM_RID,
|
||||
0, 0, 0, 0, 0, 0, 0, &pSystemSid))
|
||||
return FALSE;
|
||||
|
||||
// compare the user SID from the token with the LocalSystem SID
|
||||
bSystem = EqualSid(pTokenUser->User.Sid, pSystemSid);
|
||||
|
||||
FreeSid(pSystemSid);
|
||||
|
||||
return bSystem;
|
||||
}
|
||||
|
||||
} // end of extern "C"
|
||||
Reference in New Issue
Block a user