mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-26 06:31:03 +03:00
Fix. Linux, run_cmds, trim new line (#7579)
* Fix. Linux, run_cmds, trim new line Signed-off-by: fufesou <shuanglongchen@yeah.net> * add tests Signed-off-by: fufesou <shuanglongchen@yeah.net> --------- Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -406,10 +406,12 @@ fn patch(path: PathBuf) -> PathBuf {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
if _tmp == "/root" {
|
||||
if let Ok(user) = crate::platform::linux::run_cmds("whoami") {
|
||||
if let Ok(user) = crate::platform::linux::run_cmds_trim_newline("whoami") {
|
||||
if user != "root" {
|
||||
let cmd = format!("getent passwd '{}' | awk -F':' '{{print $6}}'", user);
|
||||
if let Ok(output) = crate::platform::linux::run_cmds(&cmd) {
|
||||
if let Ok(output) =
|
||||
crate::platform::linux::run_cmds_trim_newline(&cmd)
|
||||
{
|
||||
return output.into();
|
||||
}
|
||||
return format!("/home/{user}").into();
|
||||
|
||||
Reference in New Issue
Block a user