Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8fff53622 | ||
|
|
f705902ec3 | ||
|
|
0d36ac0cba | ||
|
|
f1fa432bc8 | ||
|
|
538126d42c | ||
|
|
9c6d3fcb4f | ||
|
|
c230c57139 | ||
|
|
e614de83fc | ||
|
|
e910029f51 |
@@ -418,6 +418,13 @@ class _DesktopTabState extends State<DesktopTab>
|
||||
}
|
||||
}
|
||||
|
||||
// On Linux, GTK destroys the window on a close request unless prevent-close
|
||||
// is on. It is off for the cm and install windows, and onActiveWindowChanged()
|
||||
// turns it off to quit, so the window can no longer be saved or hidden.
|
||||
// https://github.com/rustdesk/rustdesk/issues/16512
|
||||
Future<bool> _isLinuxWindowClosed() async =>
|
||||
isLinux && isMainWindow && !await windowManager.isPreventClose();
|
||||
|
||||
@override
|
||||
void onWindowMoved() {
|
||||
_saveFrame();
|
||||
@@ -465,6 +472,8 @@ class _DesktopTabState extends State<DesktopTab>
|
||||
});
|
||||
}
|
||||
|
||||
if (await _isLinuxWindowClosed()) return;
|
||||
|
||||
await _saveFrame(flush: true);
|
||||
|
||||
// hide window on close
|
||||
@@ -472,6 +481,7 @@ class _DesktopTabState extends State<DesktopTab>
|
||||
if (rustDeskWinManager.getActiveWindows().contains(kMainWindowId)) {
|
||||
await rustDeskWinManager.unregisterActiveWindow(kMainWindowId);
|
||||
}
|
||||
if (await _isLinuxWindowClosed()) return;
|
||||
// macOS specific workaround, the window is not hiding when in fullscreen.
|
||||
if (isMacOS && await windowManager.isFullScreen()) {
|
||||
await windowManager.setFullScreen(false);
|
||||
|
||||
+1
-1
Submodule libs/hbb_common updated: 229b904508...5d52530b63
+33
-3
@@ -68,6 +68,7 @@ use hbb_common::{
|
||||
time::{interval, Duration, Instant},
|
||||
},
|
||||
webrtc::WebRTCStream,
|
||||
websocket::{check_ws, is_ws_endpoint},
|
||||
AddrMangle, ResultType, Stream,
|
||||
};
|
||||
use base::{
|
||||
@@ -266,7 +267,13 @@ async fn race_transports_prefer_webrtc<'a, T: 'a>(
|
||||
}
|
||||
}
|
||||
match others_err.take() {
|
||||
Some(oe) => bail!("WebRTC failed: {}; fallback failed: {}", e, oe),
|
||||
// Report one error, as `select_ok` does: the UI matches and translates
|
||||
// the text whole (e.g. the offline auto-retry), and both legs often
|
||||
// carry the same rendezvous refusal anyway.
|
||||
Some(oe) => {
|
||||
log::warn!("fallback leg also failed: {}", oe);
|
||||
return Err(e);
|
||||
}
|
||||
None if others_fut.is_none() => bail!("WebRTC failed: {}", e),
|
||||
None => webrtc_err = Some(e),
|
||||
}
|
||||
@@ -307,7 +314,10 @@ async fn race_transports_prefer_webrtc<'a, T: 'a>(
|
||||
// it before failing the connection.
|
||||
Some(we) => match held.take() {
|
||||
Some(conn) => return Ok(conn),
|
||||
None => bail!("WebRTC failed: {}; fallback failed: {}", we, e),
|
||||
None => {
|
||||
log::warn!("WebRTC leg also failed: {}", we);
|
||||
return Err(e);
|
||||
}
|
||||
},
|
||||
None if webrtc_fut.is_none() => match held.take() {
|
||||
Some(conn) => return Ok(conn),
|
||||
@@ -1848,8 +1858,11 @@ impl Client {
|
||||
conn_type: ConnType,
|
||||
ipv4: bool,
|
||||
) -> ResultType<Stream> {
|
||||
// The proxy's address family does not constrain the relay target.
|
||||
let relay_server = check_port(relay_server, RELAY_PORT);
|
||||
let use_ws_proxy = Config::is_proxy() && is_ws_endpoint(&check_ws(&relay_server));
|
||||
let mut conn = connect_tcp(
|
||||
ipv4_to_ipv6(check_port(relay_server, RELAY_PORT), ipv4),
|
||||
ipv4_to_ipv6(relay_server, ipv4 || use_ws_proxy),
|
||||
CONNECT_TIMEOUT,
|
||||
)
|
||||
.await
|
||||
@@ -5705,6 +5718,23 @@ mod webrtc_race_tests {
|
||||
assert_eq!(got, "ipv6");
|
||||
assert!(start.elapsed() < Duration::from_secs(5));
|
||||
}
|
||||
|
||||
// Both legs get the same rendezvous refusal; the UI needs the text verbatim, e.g. the
|
||||
// offline auto-retry matches it whole. Either leg may fail last.
|
||||
#[tokio::test]
|
||||
async fn same_failure_on_both_legs_reported_once() {
|
||||
for (webrtc_ms, fallback_ms) in [(10, 20), (20, 10)] {
|
||||
let err = race_transports_prefer_webrtc(
|
||||
err_after(webrtc_ms, "Remote desktop is offline"),
|
||||
vec![err_after(fallback_ms, "Remote desktop is offline")],
|
||||
60_000,
|
||||
NOT_P2P,
|
||||
)
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert_eq!(err.to_string(), "Remote desktop is offline");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
+18
-1
@@ -62,7 +62,7 @@ pub fn get_custom_server_from_string(s: &str) -> ResultType<CustomServer> {
|
||||
* This allows using a ',' (comma) symbol as a final delimiter.
|
||||
*/
|
||||
if s.to_lowercase().contains("host=") {
|
||||
let stripped = &s[s.to_lowercase().find("host=").unwrap_or(0)..s.len()];
|
||||
let stripped = &s[s.to_ascii_lowercase().find("host=").unwrap_or(0)..s.len()];
|
||||
let strs: Vec<&str> = stripped.split(",").collect();
|
||||
let mut host = String::default();
|
||||
let mut key = String::default();
|
||||
@@ -232,4 +232,21 @@ mod test {
|
||||
get_custom_server_from_string("=0nI900VsFHZVBVdIlncwpHS4V0bOZ0dtVldrpVO4JHdCp0YV5WdzUGZzdnYRVjI6ISeltmIsISMuEjLx4SMiojI0N3boJye.exe")
|
||||
.unwrap(), lic);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_filename_license_string_in_non_ascii_path() {
|
||||
// Windows passes the full exe path, and `İ` grows from 2 to 3 bytes when lowercased.
|
||||
assert_eq!(
|
||||
get_custom_server_from_string(
|
||||
r"C:\Users\İsmail\Downloads\rustdesk-host=server.example.net,key=Zm9vYmFyLiwyCg==.exe"
|
||||
)
|
||||
.unwrap(),
|
||||
CustomServer {
|
||||
host: "server.example.net".to_owned(),
|
||||
key: "Zm9vYmFyLiwyCg==".to_owned(),
|
||||
api: "".to_owned(),
|
||||
relay: "".to_owned(),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+32
-32
@@ -781,37 +781,37 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay fallback delay in seconds", "Ritardo fallback relay (secondi)"),
|
||||
("relay-fallback-delay-tip", "Quanto tempo una connessione relay già attiva attende la connessione WebRTC diretta prima di essere usata. Aumentalo per dare a una connessione diretta lenta più tempo per funzionare; diminuiscilo per passare prima al relay sulle reti in cui non è possibile effettuare una connessione diretta. Lascia vuoto per il valore predefinito di 2,5 secondi."),
|
||||
("To start a voice call, enable \"Audio capture\" on the \"Share screen\" page.", "Per avviare una chiamata vocale, attiva nella pagina 'Condividi schermo' la voce 'Cattura audio'."),
|
||||
("Keyboard shortcuts", ""),
|
||||
("Configure shortcuts...", ""),
|
||||
("Enable keyboard shortcuts in remote session", ""),
|
||||
("shortcut-page-description", ""),
|
||||
("shortcut-passthrough-tip", ""),
|
||||
("Pass-through to remote", ""),
|
||||
("Reset to defaults", ""),
|
||||
("shortcut-reset-confirm-tip", ""),
|
||||
("Monitor", ""),
|
||||
("Keyboard", ""),
|
||||
("Toggle fullscreen", ""),
|
||||
("Switch to next display", ""),
|
||||
("Switch to previous display", ""),
|
||||
("Switch to next tab", ""),
|
||||
("Switch to previous tab", ""),
|
||||
("Toggle session recording", ""),
|
||||
("Close tab", ""),
|
||||
("Toggle toolbar", ""),
|
||||
("Toggle input source", ""),
|
||||
("Edit", ""),
|
||||
("Save", ""),
|
||||
("Set shortcut", ""),
|
||||
("shortcut-recording-instruction", ""),
|
||||
("shortcut-recording-press-keys-tip", ""),
|
||||
("shortcut-must-include-modifiers", ""),
|
||||
("shortcut-already-bound-to", ""),
|
||||
("Replace", ""),
|
||||
("Valid", ""),
|
||||
("shortcut-mobile-physical-keyboard-tip", ""),
|
||||
("shortcut-key-not-supported", ""),
|
||||
("On", ""),
|
||||
("Off", ""),
|
||||
("Keyboard shortcuts", "Scorciatoie da tastiera"),
|
||||
("Configure shortcuts...", "Configura scorciatoie..."),
|
||||
("Enable keyboard shortcuts in remote session", "Nella sessione remota abilita scorciatoie da tastiera"),
|
||||
("shortcut-page-description", "Associa una combinazione di tasti a ciascuna azione della sessione riportata di seguito. Ogni associazione deve includere almeno un modificatore."),
|
||||
("shortcut-passthrough-tip", "Quando è attiva, ogni combinazione associata viene inoltrata alla sessione remota. Utile quando un'associazione entra in conflitto con qualcosa di cui hai bisogno nella sessione remota."),
|
||||
("Pass-through to remote", "Passa direttamente al remoto"),
|
||||
("Reset to defaults", "Ripristina impostazioni predefinite"),
|
||||
("shortcut-reset-confirm-tip", "Questo sostituirà tutti le associazioni attuali con quelle predefinite. Vuoi continuare?"),
|
||||
("Monitor", "Monitor"),
|
||||
("Keyboard", "Tastiera"),
|
||||
("Toggle fullscreen", "Attiva/disattiva schermo pieno"),
|
||||
("Switch to next display", "Passa allo schermo successivo"),
|
||||
("Switch to previous display", "Passa allo schermo precedente"),
|
||||
("Switch to next tab", "Passa alla scheda successiva"),
|
||||
("Switch to previous tab", "Passa alla scheda precedente"),
|
||||
("Toggle session recording", "Attiva/disattiva registrazione sessione"),
|
||||
("Close tab", "Chiudi scheda"),
|
||||
("Toggle toolbar", "Attiva/disattiva barra strumenti"),
|
||||
("Toggle input source", "Attiva/disattiva sorgente input"),
|
||||
("Edit", "Modifica"),
|
||||
("Save", "Salva"),
|
||||
("Set shortcut", "Imposta scorciatoia"),
|
||||
("shortcut-recording-instruction", "Premi la combinazione di tasti che vuoi usare."),
|
||||
("shortcut-recording-press-keys-tip", "Premi una combinazione di tasti..."),
|
||||
("shortcut-must-include-modifiers", "Deve includere almeno un modificatore: {}"),
|
||||
("shortcut-already-bound-to", "Già assegnato a"),
|
||||
("Replace", "Sostituisci"),
|
||||
("Valid", "Valido"),
|
||||
("shortcut-mobile-physical-keyboard-tip", "La registrazione richiede una tastiera fisica. Le tastiere software non sono supportate."),
|
||||
("shortcut-key-not-supported", "'{}' non può essere usato come scorciatoia."),
|
||||
("On", "ON"),
|
||||
("Off", "OFF"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
+27
-27
@@ -781,37 +781,37 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("Relay fallback delay in seconds", "Vertraging voordat relay wordt gebruikt in seconden"),
|
||||
("relay-fallback-delay-tip", "Hoe lang een al tot stand gekomen relayverbinding wacht op de directe WebRTC-verbinding voordat deze in plaats daarvan wordt gebruikt. Verhoog de waarde om een trage directe verbinding meer tijd te geven; verlaag deze om op netwerken waar een directe verbinding niet mogelijk is sneller op de relay terug te vallen. Laat leeg voor de standaardwaarde van 2.5 seconden."),
|
||||
("To start a voice call, enable \"Audio capture\" on the \"Share screen\" page.", "Om een spraakgesprek te starten, schakel je \"Audio-opname\" in op de pagina \"Scherm delen\"."),
|
||||
("Keyboard shortcuts", ""),
|
||||
("Configure shortcuts...", ""),
|
||||
("Enable keyboard shortcuts in remote session", ""),
|
||||
("shortcut-page-description", ""),
|
||||
("Keyboard shortcuts", "Sneltoetsen"),
|
||||
("Configure shortcuts...", "Sneltoetsen configureren..."),
|
||||
("Enable keyboard shortcuts in remote session", "Sneltoetsen inschakelen in een sessie op afstand"),
|
||||
("shortcut-page-description", "Beschrijving van sneltoetsenpagina"),
|
||||
("shortcut-passthrough-tip", ""),
|
||||
("Pass-through to remote", ""),
|
||||
("Reset to defaults", ""),
|
||||
("Pass-through to remote", "Doorsturen naar extern apparaat"),
|
||||
("Reset to defaults", "Terugzetten naar standaardinstellingen"),
|
||||
("shortcut-reset-confirm-tip", ""),
|
||||
("Monitor", ""),
|
||||
("Keyboard", ""),
|
||||
("Toggle fullscreen", ""),
|
||||
("Switch to next display", ""),
|
||||
("Switch to previous display", ""),
|
||||
("Switch to next tab", ""),
|
||||
("Switch to previous tab", ""),
|
||||
("Toggle session recording", ""),
|
||||
("Close tab", ""),
|
||||
("Toggle toolbar", ""),
|
||||
("Toggle input source", ""),
|
||||
("Edit", ""),
|
||||
("Save", ""),
|
||||
("Set shortcut", ""),
|
||||
("Monitor", "Monitor"),
|
||||
("Keyboard", "Toetsenbord"),
|
||||
("Toggle fullscreen", "Volledig scherm wisselen"),
|
||||
("Switch to next display", "Wisselen naar volgend scherm"),
|
||||
("Switch to previous display", "Wisselen naar vorig scherm"),
|
||||
("Switch to next tab", "Schakel naar volgende tabblad"),
|
||||
("Switch to previous tab", "Schakel naar vorig tabblad"),
|
||||
("Toggle session recording", "Sessie-opname wisselen"),
|
||||
("Close tab", "Tabblad sluiten"),
|
||||
("Toggle toolbar", "Werkbalk wisselen"),
|
||||
("Toggle input source", "Invoerbron wisselen"),
|
||||
("Edit", "Bewerken"),
|
||||
("Save", "Opslaan"),
|
||||
("Set shortcut", "Sneltoets toewijzen"),
|
||||
("shortcut-recording-instruction", ""),
|
||||
("shortcut-recording-press-keys-tip", ""),
|
||||
("shortcut-must-include-modifiers", ""),
|
||||
("shortcut-already-bound-to", ""),
|
||||
("Replace", ""),
|
||||
("Valid", ""),
|
||||
("shortcut-must-include-modifiers", "Sneltoets moet een combinatietoets bevatten"),
|
||||
("shortcut-already-bound-to", "Sneltoets is al toegewezen aan"),
|
||||
("Replace", "Vervangen"),
|
||||
("Valid", "Geldig"),
|
||||
("shortcut-mobile-physical-keyboard-tip", ""),
|
||||
("shortcut-key-not-supported", ""),
|
||||
("On", ""),
|
||||
("Off", ""),
|
||||
("shortcut-key-not-supported", "Sneltoets wordt niet ondersteund"),
|
||||
("On", "Aan"),
|
||||
("Off", "Uit"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
+33
-33
@@ -780,38 +780,38 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("RustDesk could not load a GStreamer component needed for screen capture ({})", "O RustDesk não conseguiu carregar um componente do GStreamer necessário para a captura de tela ({})."),
|
||||
("Relay fallback delay in seconds", "Atraso antes de recorrer ao retransmissor em segundos"),
|
||||
("relay-fallback-delay-tip", "Tempo que a conexão de retransmissão aguarda pela conexão direta WebRTC. Aumente para dar mais tempo a conexões lentas; diminua para usar o retransmissor mais cedo. Deixe vazio para usar o padrão de 2,5 segundos."),
|
||||
("To start a voice call, enable \"Audio capture\" on the \"Share screen\" page.", "Para iniciar uma chamada de voz, ative \"Captura de áudio\" na página \"Compartilhar Tela\"."),
|
||||
("Keyboard shortcuts", ""),
|
||||
("Configure shortcuts...", ""),
|
||||
("Enable keyboard shortcuts in remote session", ""),
|
||||
("shortcut-page-description", ""),
|
||||
("shortcut-passthrough-tip", ""),
|
||||
("Pass-through to remote", ""),
|
||||
("Reset to defaults", ""),
|
||||
("shortcut-reset-confirm-tip", ""),
|
||||
("Monitor", ""),
|
||||
("Keyboard", ""),
|
||||
("Toggle fullscreen", ""),
|
||||
("Switch to next display", ""),
|
||||
("Switch to previous display", ""),
|
||||
("Switch to next tab", ""),
|
||||
("Switch to previous tab", ""),
|
||||
("Toggle session recording", ""),
|
||||
("Close tab", ""),
|
||||
("Toggle toolbar", ""),
|
||||
("Toggle input source", ""),
|
||||
("Edit", ""),
|
||||
("Save", ""),
|
||||
("Set shortcut", ""),
|
||||
("shortcut-recording-instruction", ""),
|
||||
("shortcut-recording-press-keys-tip", ""),
|
||||
("shortcut-must-include-modifiers", ""),
|
||||
("shortcut-already-bound-to", ""),
|
||||
("Replace", ""),
|
||||
("Valid", ""),
|
||||
("shortcut-mobile-physical-keyboard-tip", ""),
|
||||
("shortcut-key-not-supported", ""),
|
||||
("On", ""),
|
||||
("Off", ""),
|
||||
("To start a voice call, enable \"Audio capture\" on the \"Share screen\" page.", "Para iniciar uma chamada de voz, ative \"Captura de áudio\" na página \"Compartilhar tela\"."),
|
||||
("Keyboard shortcuts", "Atalhos de teclado"),
|
||||
("Configure shortcuts...", "Configurar atalhos..."),
|
||||
("Enable keyboard shortcuts in remote session", "Ativar atalhos de teclado na sessão remota"),
|
||||
("shortcut-page-description", "Associe uma combinação de teclas a cada ação da sessão abaixo. Cada atalho deve incluir pelo menos uma tecla modificadora."),
|
||||
("shortcut-passthrough-tip", "Quando ativado, os atalhos são enviados ao computador remoto, mesmo quando entram em conflito com combinações de teclas necessárias nele."),
|
||||
("Pass-through to remote", "Encaminhar atalhos ao computador remoto"),
|
||||
("Reset to defaults", "Restaurar padrões"),
|
||||
("shortcut-reset-confirm-tip", "Todos os atalhos atuais serão substituídos pelos padrões. Deseja continuar?"),
|
||||
("Monitor", "Monitor"),
|
||||
("Keyboard", "Teclado"),
|
||||
("Toggle fullscreen", "Alternar tela cheia"),
|
||||
("Switch to next display", "Alternar para a próxima tela"),
|
||||
("Switch to previous display", "Alternar para a tela anterior"),
|
||||
("Switch to next tab", "Alternar para a próxima aba"),
|
||||
("Switch to previous tab", "Alternar para a aba anterior"),
|
||||
("Toggle session recording", "Iniciar/parar gravação da sessão"),
|
||||
("Close tab", "Fechar aba"),
|
||||
("Toggle toolbar", "Mostrar/ocultar barra de ferramentas"),
|
||||
("Toggle input source", "Alternar fonte de entrada"),
|
||||
("Edit", "Editar"),
|
||||
("Save", "Salvar"),
|
||||
("Set shortcut", "Definir atalho"),
|
||||
("shortcut-recording-instruction", "Pressione a combinação de teclas que deseja usar."),
|
||||
("shortcut-recording-press-keys-tip", "Pressione uma combinação de teclas..."),
|
||||
("shortcut-must-include-modifiers", "Deve incluir pelo menos uma tecla modificadora: {}"),
|
||||
("shortcut-already-bound-to", "Já atribuído a"),
|
||||
("Replace", "Substituir"),
|
||||
("Valid", "Válido"),
|
||||
("shortcut-mobile-physical-keyboard-tip", "A gravação de atalhos requer um teclado físico. Teclados virtuais não são compatíveis."),
|
||||
("shortcut-key-not-supported", "Não é possível usar \"{}\" como atalho."),
|
||||
("On", "Ativado"),
|
||||
("Off", "Desativado"),
|
||||
].iter().cloned().collect();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
mod directory;
|
||||
|
||||
use super::{
|
||||
installer_shell::{
|
||||
get_system_executable, path_for_cmd_assignment, path_for_cmd_environment,
|
||||
run_elevated_and_wait, trusted_install_environment,
|
||||
BATCH_SHORTCUT_DECODE_FAILURE_EXIT_CODE, CMD_RELATIVE_PATH,
|
||||
WIN7_SHELL_EXECUTE_MAX_PARAMETER_CHARS,
|
||||
},
|
||||
validate_install_app_name, ResultType,
|
||||
};
|
||||
use hbb_common::{
|
||||
anyhow::anyhow,
|
||||
bail, log,
|
||||
sha2::{Digest, Sha256},
|
||||
};
|
||||
@@ -99,10 +103,8 @@ fn verified_install_bootstrap(
|
||||
runner_directory: &Path,
|
||||
) -> ResultType<String> {
|
||||
let source = path_for_cmd_assignment(&script.path)?;
|
||||
let runner = runner_directory.join(format!(
|
||||
"rustdesk_install_{}.bat",
|
||||
uuid::Uuid::new_v4().simple()
|
||||
));
|
||||
let directory = path_for_cmd_assignment(runner_directory)?;
|
||||
let runner = runner_directory.join("install.bat");
|
||||
let runner = path_for_cmd_assignment(&runner)?;
|
||||
let cmd_path = get_system_executable(CMD_RELATIVE_PATH)?;
|
||||
let certutil_path = get_system_executable(CERTUTIL_RELATIVE_PATH)?;
|
||||
@@ -113,13 +115,13 @@ fn verified_install_bootstrap(
|
||||
// Short names preserve headroom under the Windows 7 ShellExecuteExW 2,048
|
||||
// UTF-16-character parameter limit. Paths are stored with delayed expansion
|
||||
// disabled, then expanded indirectly so literal `!` survives: S=source,
|
||||
// R=runner, Q=cmd.exe, H=certutil.exe, F=findstr.exe, C=created flag, E=exit code.
|
||||
// R=runner, Q=cmd.exe, H=certutil.exe, F=findstr.exe, D=directory, E=exit code.
|
||||
Ok(format!(
|
||||
"setlocal DisableDelayedExpansion & set \"S={source}\" & set \"R={runner}\" & \
|
||||
set \"Q={cmd}\" & set \"H={certutil}\" & set \"F={findstr}\" & \
|
||||
set \"C=0\" & set \"E=0\" & setlocal EnableDelayedExpansion & \
|
||||
set \"ERRORLEVEL=\" & set \"D={directory}\" & set \"E=0\" & setlocal EnableDelayedExpansion & \
|
||||
if exist \"!R!\" (set \"E={INSTALL_HANDOFF_RUNNER_EXISTS_EXIT_CODE}\") else (\
|
||||
set \"C=1\" & copy /Y \"!S!\" \"!R!\" > nul || \
|
||||
copy /Y \"!S!\" \"!R!\" > nul || \
|
||||
(set \"E={INSTALL_HANDOFF_COPY_FAILURE_EXIT_CODE}\") & \
|
||||
if \"!E!\"==\"0\" (\"!H!\" -hashfile \"!R!\" SHA256 > \"!R!.hash\" || \
|
||||
set \"E={INSTALL_HANDOFF_HASH_FAILURE_EXIT_CODE}\") & \
|
||||
@@ -127,26 +129,51 @@ fn verified_install_bootstrap(
|
||||
set \"E={INSTALL_HANDOFF_HASH_MISMATCH_EXIT_CODE}\") & \
|
||||
if \"!E!\"==\"0\" (\"!Q!\" /D /E:ON /V:OFF /C \"\"!R!\"\" & \
|
||||
set \"E=!errorlevel!\")) & \
|
||||
if \"!C!\"==\"1\" (rd /s /q \"!R!.dir\" > nul 2>&1 & \
|
||||
del /f /q \"!R!\" \"!R!.*\" > nul 2>&1) & exit /b !E!",
|
||||
rd /s /q \"!D!\" > nul 2>&1 & exit /b !E!",
|
||||
install_hash_pattern(&script.expected_hash),
|
||||
))
|
||||
}
|
||||
|
||||
fn verified_install_parameters(script: &InstallCommandScript) -> ResultType<String> {
|
||||
let system_directory = get_system_executable("")?;
|
||||
Ok(format!(
|
||||
fn verified_install_parameters(
|
||||
script: &InstallCommandScript,
|
||||
directory: &Path,
|
||||
) -> ResultType<String> {
|
||||
let parameters = format!(
|
||||
"/D /E:ON /V:ON /C {}",
|
||||
verified_install_bootstrap(script, &system_directory)?
|
||||
))
|
||||
verified_install_bootstrap(script, directory)?
|
||||
);
|
||||
let length = parameters.encode_utf16().count();
|
||||
if length >= WIN7_SHELL_EXECUTE_MAX_PARAMETER_CHARS {
|
||||
bail!("Elevated command is too long: {length} UTF-16 characters");
|
||||
}
|
||||
Ok(parameters)
|
||||
}
|
||||
|
||||
pub(super) fn run_cmds(cmds: String, show: bool, tip: &str) -> ResultType<()> {
|
||||
validate_install_app_name(&crate::get_app_name())?;
|
||||
let script = write_install_script(cmds)?;
|
||||
let cmd_path = get_system_executable(CMD_RELATIVE_PATH)?;
|
||||
let parameters = verified_install_parameters(&script)?;
|
||||
let exit_code = run_elevated_and_wait(&cmd_path, ¶meters, show)?;
|
||||
let directory = directory::path()?;
|
||||
let parameters = verified_install_parameters(&script, &directory)?;
|
||||
directory::create(&directory)?;
|
||||
let exit_code = run_elevated_and_wait(&cmd_path, ¶meters, show).map_err(|err| {
|
||||
anyhow!(
|
||||
"Installer handoff failed; protected directory may remain at {}: {err}",
|
||||
directory.display()
|
||||
)
|
||||
})?;
|
||||
// Cleanup must not change the result of an installation that already ran.
|
||||
match fs::symlink_metadata(&directory) {
|
||||
Ok(_) => log::warn!(
|
||||
"Protected installer directory may remain at {}",
|
||||
directory.display()
|
||||
),
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
|
||||
Err(err) => log::warn!(
|
||||
"Protected installer directory may remain at {}: {err}",
|
||||
directory.display()
|
||||
),
|
||||
}
|
||||
if exit_code != 0 {
|
||||
bail!(
|
||||
"{tip} failed with elevated exit code {exit_code}: {}",
|
||||
@@ -208,7 +235,7 @@ mod tests {
|
||||
.expect("install script should be created");
|
||||
let bootstrap = verified_install_bootstrap(&script, &runner_dir)
|
||||
.expect("native verifier bootstrap should be generated");
|
||||
assert_native_handoff_structure(&script, &shortcut_commands, &bootstrap);
|
||||
assert_native_handoff_structure(&script, &shortcut_commands, &runner_dir);
|
||||
|
||||
let output = run_install_bootstrap_for_test(&bootstrap);
|
||||
assert!(
|
||||
@@ -218,15 +245,25 @@ mod tests {
|
||||
);
|
||||
assert!(marker.exists(), "verified install script must execute");
|
||||
std::fs::remove_file(&marker).expect("test marker should be removed");
|
||||
assert!(
|
||||
!runner_dir.exists(),
|
||||
"protected runner directory must be removed"
|
||||
);
|
||||
std::fs::create_dir(&runner_dir).expect("runner directory should be created");
|
||||
assert_replaced_install_script_is_rejected(&script, &runner_dir, &marker);
|
||||
std::fs::remove_dir(runner_dir).expect("runner directory should be empty");
|
||||
assert!(
|
||||
!runner_dir.exists(),
|
||||
"failed handoff directory must be removed"
|
||||
);
|
||||
}
|
||||
|
||||
fn assert_native_handoff_structure(
|
||||
script: &InstallCommandScript,
|
||||
shortcut_commands: &str,
|
||||
bootstrap: &str,
|
||||
runner_dir: &Path,
|
||||
) {
|
||||
let bootstrap = verified_install_bootstrap(script, runner_dir)
|
||||
.expect("native verifier bootstrap should be generated");
|
||||
assert!(shortcut_commands.contains("certutil"));
|
||||
assert!(shortcut_commands.contains("-decode"));
|
||||
assert!(!shortcut_commands.to_ascii_lowercase().contains("cscript"));
|
||||
@@ -240,8 +277,8 @@ mod tests {
|
||||
.collect::<Vec<_>>()
|
||||
.join(" *");
|
||||
assert!(bootstrap.contains(&format!("/R /I /X /C:\"{win7_hash_pattern}\"")));
|
||||
let parameters =
|
||||
verified_install_parameters(script).expect("elevated parameters should be generated");
|
||||
let parameters = verified_install_parameters(script, runner_dir)
|
||||
.expect("elevated parameters should be generated");
|
||||
assert!(bootstrap.contains("certutil.exe"));
|
||||
assert!(bootstrap.contains("findstr.exe"));
|
||||
assert!(!bootstrap.to_ascii_lowercase().contains("powershell"));
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
use super::super::{
|
||||
installer_shell::{get_system_executable, path_for_cmd_environment},
|
||||
wide_string,
|
||||
};
|
||||
use hbb_common::{anyhow::anyhow, bail, ResultType};
|
||||
use std::{
|
||||
fs, mem,
|
||||
os::windows::fs::MetadataExt,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use windows::{
|
||||
core::{w, PCWSTR},
|
||||
Win32::{
|
||||
Foundation::{LocalFree, HLOCAL},
|
||||
Security::{
|
||||
Authorization::{
|
||||
ConvertStringSecurityDescriptorToSecurityDescriptorW, SDDL_REVISION_1,
|
||||
},
|
||||
PSECURITY_DESCRIPTOR, SECURITY_ATTRIBUTES,
|
||||
},
|
||||
Storage::FileSystem::{CreateDirectoryW, FILE_ATTRIBUTE_REPARSE_POINT},
|
||||
},
|
||||
};
|
||||
|
||||
pub(super) fn path() -> ResultType<PathBuf> {
|
||||
let system = get_system_executable("")?;
|
||||
let windows = system
|
||||
.parent()
|
||||
.ok_or_else(|| anyhow!("System directory has no parent"))?;
|
||||
let temporary = windows.join("Temp");
|
||||
for parent in temporary.ancestors() {
|
||||
let metadata = fs::symlink_metadata(parent).map_err(|err| {
|
||||
anyhow!(
|
||||
"Failed to inspect installer temporary parent {}: {err}",
|
||||
parent.display()
|
||||
)
|
||||
})?;
|
||||
if !metadata.is_dir() || metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT.0 != 0 {
|
||||
bail!(
|
||||
"Installer temporary parent is not a regular directory: {}",
|
||||
parent.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(temporary.join(format!(
|
||||
"rustdesk-install-{}",
|
||||
uuid::Uuid::new_v4().simple()
|
||||
)))
|
||||
}
|
||||
|
||||
pub(super) fn create(path: &Path) -> ResultType<()> {
|
||||
let wide_path = wide_string(path_for_cmd_environment(path)?);
|
||||
let mut descriptor = PSECURITY_DESCRIPTOR::default();
|
||||
// OWNER RIGHTS removes the ordinary creator's implicit WRITE_DAC permission.
|
||||
// The owner can inspect the ACL, but only Administrators/SYSTEM can modify contents.
|
||||
// https://learn.microsoft.com/windows-server/identity/ad-ds/manage/understand-special-identities-groups#owner-rights
|
||||
unsafe {
|
||||
ConvertStringSecurityDescriptorToSecurityDescriptorW(
|
||||
w!("D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;RC;;;OW)"),
|
||||
SDDL_REVISION_1,
|
||||
&mut descriptor,
|
||||
None,
|
||||
)?;
|
||||
}
|
||||
let attributes = SECURITY_ATTRIBUTES {
|
||||
nLength: mem::size_of::<SECURITY_ATTRIBUTES>() as u32,
|
||||
lpSecurityDescriptor: descriptor.0,
|
||||
bInheritHandle: false.into(),
|
||||
};
|
||||
let result = unsafe { CreateDirectoryW(PCWSTR(wide_path.as_ptr()), Some(&attributes)) };
|
||||
unsafe { LocalFree(Some(HLOCAL(descriptor.0))) };
|
||||
result.map_err(|err| {
|
||||
anyhow!(
|
||||
"Failed to create protected installer directory {}: {err}",
|
||||
path.display()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use winapi::um::winnt::MAXIMUM_ALLOWED;
|
||||
use windows::{
|
||||
core::{Owned, BOOL},
|
||||
Win32::{
|
||||
Foundation::HANDLE,
|
||||
Security::{
|
||||
AccessCheck,
|
||||
Authorization::{GetNamedSecurityInfoW, SE_FILE_OBJECT},
|
||||
DuplicateToken, SecurityImpersonation, DACL_SECURITY_INFORMATION, GENERIC_MAPPING,
|
||||
GROUP_SECURITY_INFORMATION, OWNER_SECURITY_INFORMATION, PRIVILEGE_SET,
|
||||
TOKEN_DUPLICATE, TOKEN_QUERY,
|
||||
},
|
||||
Storage::FileSystem::{
|
||||
FILE_ALL_ACCESS, FILE_GENERIC_EXECUTE, FILE_GENERIC_READ, FILE_GENERIC_WRITE,
|
||||
READ_CONTROL,
|
||||
},
|
||||
System::Threading::{GetCurrentProcess, OpenProcessToken},
|
||||
},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn protected_directory_enforces_creator_permissions() {
|
||||
let elevated =
|
||||
super::super::super::is_elevated(None).expect("creator elevation should be available");
|
||||
// The user-owned parent allows cleanup through DELETE_CHILD. AccessCheck
|
||||
// below checks the child's DACL, not that separate parent permission.
|
||||
let directory = std::env::temp_dir().join(format!(
|
||||
"rustdesk_installer_acl_{}",
|
||||
uuid::Uuid::new_v4().simple()
|
||||
));
|
||||
create(&directory).expect("production directory creation should succeed");
|
||||
let access = creator_directory_access(&directory);
|
||||
fs::remove_dir(&directory).expect("test directory should be removed");
|
||||
let expected = if elevated {
|
||||
FILE_ALL_ACCESS
|
||||
} else {
|
||||
READ_CONTROL
|
||||
};
|
||||
assert_eq!(
|
||||
access.expect("the created directory's access should be checked"),
|
||||
(true, expected.0),
|
||||
"only elevated administrators may modify the protected directory"
|
||||
);
|
||||
}
|
||||
|
||||
fn creator_directory_access(path: &Path) -> ResultType<(bool, u32)> {
|
||||
let wide_path = wide_string(path_for_cmd_environment(path)?);
|
||||
let mut descriptor = PSECURITY_DESCRIPTOR::default();
|
||||
unsafe {
|
||||
GetNamedSecurityInfoW(
|
||||
PCWSTR(wide_path.as_ptr()),
|
||||
SE_FILE_OBJECT,
|
||||
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&mut descriptor,
|
||||
)
|
||||
.ok()?;
|
||||
}
|
||||
let _descriptor = unsafe { Owned::new(HLOCAL(descriptor.0)) };
|
||||
let token = creator_impersonation_token()?;
|
||||
let mapping = GENERIC_MAPPING {
|
||||
GenericRead: FILE_GENERIC_READ.0,
|
||||
GenericWrite: FILE_GENERIC_WRITE.0,
|
||||
GenericExecute: FILE_GENERIC_EXECUTE.0,
|
||||
GenericAll: FILE_ALL_ACCESS.0,
|
||||
};
|
||||
let mut privileges = PRIVILEGE_SET::default();
|
||||
let mut privilege_size = mem::size_of::<PRIVILEGE_SET>() as u32;
|
||||
let mut granted = 0;
|
||||
let mut allowed = BOOL::default();
|
||||
unsafe {
|
||||
AccessCheck(
|
||||
descriptor,
|
||||
*token,
|
||||
MAXIMUM_ALLOWED,
|
||||
&mapping,
|
||||
Some(&mut privileges),
|
||||
&mut privilege_size,
|
||||
&mut granted,
|
||||
&mut allowed,
|
||||
)?;
|
||||
}
|
||||
Ok((allowed.as_bool(), granted))
|
||||
}
|
||||
|
||||
fn creator_impersonation_token() -> ResultType<Owned<HANDLE>> {
|
||||
let mut token = HANDLE::default();
|
||||
unsafe {
|
||||
OpenProcessToken(
|
||||
GetCurrentProcess(),
|
||||
TOKEN_QUERY | TOKEN_DUPLICATE,
|
||||
&mut token,
|
||||
)?
|
||||
};
|
||||
let token = unsafe { Owned::new(token) };
|
||||
let mut impersonation = HANDLE::default();
|
||||
unsafe { DuplicateToken(*token, SecurityImpersonation, &mut impersonation)? };
|
||||
Ok(unsafe { Owned::new(impersonation) })
|
||||
}
|
||||
}
|
||||
+7
-2
@@ -21,7 +21,9 @@ use hbb_common::{
|
||||
rendezvous_proto::*,
|
||||
socket_client,
|
||||
sodiumoxide::crypto::{box_, sign},
|
||||
timeout, tokio, ResultType, Stream,
|
||||
timeout, tokio,
|
||||
websocket::{check_ws, is_ws_endpoint},
|
||||
ResultType, Stream,
|
||||
};
|
||||
use base::message_proto::*;
|
||||
use scrap::camera;
|
||||
@@ -402,8 +404,11 @@ async fn create_relay_connection_(
|
||||
ipv4: bool,
|
||||
meta: ConnectionMeta,
|
||||
) -> ResultType<()> {
|
||||
// The proxy's address family does not constrain the relay target.
|
||||
let relay_server = crate::check_port(relay_server, RELAY_PORT);
|
||||
let use_ws_proxy = Config::is_proxy() && is_ws_endpoint(&check_ws(&relay_server));
|
||||
let mut stream = socket_client::connect_tcp(
|
||||
socket_client::ipv4_to_ipv6(crate::check_port(relay_server, RELAY_PORT), ipv4),
|
||||
socket_client::ipv4_to_ipv6(relay_server, ipv4 || use_ws_proxy),
|
||||
CONNECT_TIMEOUT,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user