Terminal (beta) always runs as SYSTEM instead of the logged-in user when RustDesk is portable (service installed manually)
Bug description
When connecting to a Windows machine using the Terminal (beta) feature, the shell always runs as SYSTEM if the controlled RustDesk is running in portable mode (a manually installed service pointing to a non-default directory). On an installed (setup.exe) deployment, the terminal correctly runs as the currently logged-on console user. Portable users get no way to obtain a user-context terminal.
Environment
- Controlled side: Windows 11 x64, RustDesk 1.4.9, portable exe +
--service(service runs as LocalSystem), user logged on via console - Connecting side: RustDesk 1.4.9, Terminal (beta) tab
Steps to reproduce
- Run RustDesk portable from a custom folder (e.g.
C:\Tools\rustdesk), install the service (rustdesk.exe --service). - Log on to Windows with a normal user session.
- From another machine, open Terminal (beta) to this machine.
- Run
whoami→ returns the machine account (NT AUTHORITY\SYSTEM), not the logged-on user. Working directory isC:\Windows\System32\config\systemprofile.
Root cause (1.4.9 source)
src/client.rs(handle_login_process, ~line 3580): terminal connections always send empty OS credentials:
let is_terminal = lc.read().unwrap().conn_type.eq(&ConnType::TERMINAL);
let (os_username, os_password) = if is_terminal {
("".to_owned(), "".to_owned()) // terminal: always empty
}
src/server/connection.rs(fill_terminal_user_token, ~line 3688): with empty username, the user token of the active console session is only used whencrate::platform::is_installed()is true; otherwise it falls back toTerminalUserToken::SelfUser(the SYSTEM service). Portable deployments can never reach thehandle_installed_user()path.
Additional limitation: inside the SYSTEM terminal, runas fails with "Access is denied" because CreateProcessWithLogonW cannot be called from a service/session-0 context, so there is no user-level workaround inside the terminal either.
Expected behavior
Terminal sessions should run as the currently logged-on console user on portable deployments as well (i.e., drop or relax the is_installed() gate in fill_terminal_user_token, or expose an OS-login / "run as user" option in the Terminal client UI).
Suggested fix
Either reuse handle_installed_user() (token of the active console session) regardless of install mode, or allow the client to pass os_login credentials for terminal connections (currently hardcoded to empty in src/client.rs).