Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

fix(ipc): never adopt an empty id from the main IPC (#15626)

CHarrisc01300be2015
diff --git a/src/ipc.rs b/src/ipc.rs
index 68c987f4e..01f4cda6e 100644
--- a/src/ipc.rs
+++ b/src/ipc.rs
@@ -1689,19 +1689,24 @@ pub fn clear_trusted_devices() {
}
pub fn get_id() -> String {
+ // An empty id may come from a process that took over the main IPC with a
+ // config scope that has no id yet (e.g. a user GUI that became the server
+ // while the installed service was restarting). Treat it as no answer,
+ // otherwise the empty id is adopted below and wipes the local one.
if let Ok(Some(v)) = get_config("id") {
- // update salt also, so that next time reinstallation not causing first-time auto-login failure
- if let Ok(Some(v2)) = get_config("salt") {
- Config::set_salt(&v2);
- }
- if v != Config::get_id() {
- Config::set_key_confirmed(false);
- Config::set_id(&v);
+ if !v.is_empty() {
+ // update salt also, so that next time reinstallation not causing first-time auto-login failure
+ if let Ok(Some(v2)) = get_config("salt") {
+ Config::set_salt(&v2);
+ }
+ if v != Config::get_id() {
+ Config::set_key_confirmed(false);
+ Config::set_id(&v);
+ }
+ return v;
}
- v
- } else {
- Config::get_id()
}
+ Config::get_id()
}
pub async fn get_rendezvous_server(ms_timeout: u64) -> (String, Vec<String>) {