Compare commits

..
Author SHA1 Message Date
rustdeskandClaude Opus 5.5 d8fff53622 fix(client): report one error when both WebRTC race legs fail
Both legs of race_transports_prefer_webrtc send their own punch request
to the same rendezvous server for the same peer, so a refusal there
(offline, unknown ID, key mismatch, a server-supplied other_failure)
fails both with the same text. Joining them as "WebRTC failed: X;
fallback failed: X" showed it twice and broke the UI's whole-string
matching: the offline auto-retry needs exactly "Remote desktop is
offline", the message box translates the text as one string, and
check_if_retry hides the retry button for any text containing "failed".

Return the error of the leg that failed last, as select_ok did before
the race existed, and log the other one once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WS1HTjp6UQuG43KEcQPq1R
2026-10-15 19:15:07 +08:00
fufesou f705902ec3 fix(windows): move installer scripts into protected temp directories (#16554)
* fix(windows): move installer scripts into protected temp directories

Create a private directory under Windows Temp with its final DACL in
CreateDirectoryW. Grant Administrators and SYSTEM full access and use
OWNER RIGHTS to suppress the ordinary creator's implicit WRITE_DAC.

Keep the existing elevated system-cmd copy and SHA-256 verification flow.
Keep auxiliary files in the same directory, report cleanup failures, and
check command length before creating the directory.

This avoids PowerShell, helper executables, and application startup or DLL
linking changes. The Windows Temp parent must retain its standard protection
against deletion by unprivileged users. UAC cancellation can leave an empty
protected directory; the error reports its path.

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(windows): preserve installer results when cleanup fails

Keep the original installer exit code and report remaining temporary directories or inspection errors as warnings with their paths. Include the directory path in creation errors.

Restore the existing handoff assertions in a separate test module, add a locked-directory regression for successful and failed installers, and remove the unrelated ERRORLEVEL environment change.

Validation: scoped formatting and whitespace checks passed. Native cmd probes reproduced the failure before the fix and preserved both exit codes afterwards. No project build or Rust test execution was performed.
Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(windows): clarify installer cleanup warnings

Describe protected directories as possibly remaining when cleanup cannot be verified. Remove the cleanup-only test added during review while retaining existing handoff coverage.

Signed-off-by: fufesou <linlong1266@gmail.com>

* test(windows): keep installer handoff tests inline

Restore the inline test module and original helper order to reduce the diff against master. Keep the directory cleanup assertions and original bootstrap checks.

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(windows): include paths in installer directory check errors

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(windows): clear inherited ERRORLEVEL before installation

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(windows): avoid duplicate directory error messages

Signed-off-by: fufesou <linlong1266@gmail.com>

* test(windows): verify installer directory permissions

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-10-15 17:33:35 +08:00
RustDeskandClaude Opus 5.5 0d36ac0cba fix(linux): stop using the window in onWindowClose once GTK destroyed it (#16561)
On Linux, GTK destroys the window on a close request unless prevent-close
is on. When the main window is the last active one, onActiveWindowChanged()
turns prevent-close off and calls close(), yet onWindowClose() still went
on to hide() the destroyed window, and the close event that close() emits
re-entered onWindowClose() to save the frame through isMaximized(). The cm
and install windows never turn prevent-close on, so their window is always
gone by the time onWindowClose() runs.

With window_manager before cf4aef05 those calls segfaulted in
gtk_window_is_maximized; since then they fail with an unhandled
PlatformException(window_destroyed). Return early in both places instead.
Other platforms and sub windows keep the old path.

Fixes #16512


Claude-Session: https://claude.ai/code/session_01WS1HTjp6UQuG43KEcQPq1R

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 15:33:42 +08:00
RustDeskandClaude Opus 5.5 f1fa432bc8 Fix fdroid bridge version (#16560)
* fix(fdroid): generate the bridge with the Flutter version bridge.yml uses

#15139 moved the bridge Flutter version from bridge.yml's env into its
job matrix, so build_fdroid.sh read `.env.FLUTTER_VERSION` as "null".
The F-Droid recipe worked around that by pinning it to 3.24.5, which
equals ANDROID_FLUTTER_VERSION, and the script only generated the bridge
when the two versions differed, so the build failed on the missing
src/bridge_generated.rs.

Read the version from the default bridge-artifact matrix entry (3.22.3),
and always generate the bridge: the build needs it whether or not the
two Flutter versions match.

Fixes #16549

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(fdroid): keep the recipe's version sed from overriding the bridge Flutter

The F-Droid recipe works around the old "null" read with
`sed 's/${FLUTTER_BRIDGE_VERSION}/<version>/'`, and its auto-update
copies that line into every new version. The 1.5.0 recipe pinned 3.24.5
and then 3.47.7, but flutter_rust_bridge codegen only works with the
Flutter version bridge.yml uses (3.22.3). Pass the unbraced variable to
prepare_flutter so that sed no longer matches the call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(fdroid): raise the Gradle heap for the AGP 8 build

#15603 moved the Android build to Gradle 8.11.1 / AGP 8.10.1 with
compileSdk 36 and desugaring. The first F-Droid 1.5.0 build got past the
bridge and the Rust library, then failed in assembleRelease with "Gradle
build daemon has been stopped: since the JVM garbage collector is
thrashing", because gradle.properties still caps the heap at 1 GiB. CI
has long raised it to 2g; do the same here. A recipe that already
rewrites the -Xmx1024M setting keeps its own value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 14:42:39 +08:00
Maison da Silva 538126d42c Update Portuguese translations for keyboard shortcuts (#16555) 2026-10-15 12:06:47 +08:00
bovirus 9c6d3fcb4f Update Italian language (#16551)
* Update Italian language

* Update Italian language
2026-10-15 12:06:36 +08:00
Alex Rijckaert c230c57139 Update Dutch translation (#16540) 2026-10-15 12:05:52 +08:00
Leo Camus e614de83fc fix: read host= from an exe path with non-ASCII characters (#16556)
get_custom_server_from_string located "host=" in s.to_lowercase() and
sliced s with that byte index. Lowercasing can change a character's byte
length ("İ" is 2 bytes, "i̇" is 3), and on Windows the string is the full
exe path, so a profile such as C:\Users\İsmail shifted the slice past the
"h" and host came back empty. The client then fell back to the default
rendezvous server.

"host=" is ASCII, so search s.to_ascii_lowercase(), which keeps byte
offsets.
2026-10-15 10:30:06 +08:00
21pages e910029f51 feat: use the configured proxy for WebSocket connections (#16386)
* feat: add opt-in WebSocket proxy support

Add a WebSocket proxy option to the proxy dialog and custom client settings.
Keep WebSocket connections direct by default and use the configured proxy
without direct fallback when enabled.

Preserve relay targets regardless of the proxy address family and restart
connections when the option changes. Update hbb_common for proxy support.

Signed-off-by: 21pages <sunboeasy@gmail.com>

* update hbb_common

Signed-off-by: 21pages <sunboeasy@gmail.com>

* fix: remove WebSocket proxy opt-in

* chore: restore proxy settings UI and translations

* fix: update hbb_common for proxy read progress

* fix: update hbb_common proxy connections and IPv6 parsing

* fix: update hbb_common WebSocket local address

* update to rustdesk/hbb_common

Signed-off-by: 21pages <sunboeasy@gmail.com>

---------

Signed-off-by: 21pages <sunboeasy@gmail.com>
2026-10-14 22:49:35 +08:00
10 changed files with 404 additions and 120 deletions
@@ -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);
+33 -3
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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();
}
+58 -21
View File
@@ -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, &parameters, show)?;
let directory = directory::path()?;
let parameters = verified_install_parameters(&script, &directory)?;
directory::create(&directory)?;
let exit_code = run_elevated_and_wait(&cmd_path, &parameters, 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
View File
@@ -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?;