mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00: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:
@@ -1020,7 +1020,7 @@ mod desktop {
|
||||
"getent passwd '{}' | awk -F':' '{{print $6}}'",
|
||||
&self.username
|
||||
);
|
||||
self.home = run_cmds(&cmd).unwrap_or(format!("/home/{}", &self.username));
|
||||
self.home = run_cmds_trim_newline(&cmd).unwrap_or(format!("/home/{}", &self.username));
|
||||
}
|
||||
|
||||
fn get_xauth_from_xorg(&mut self) {
|
||||
@@ -1211,6 +1211,29 @@ mod desktop {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_desktop_env() {
|
||||
let mut d = Desktop::default();
|
||||
d.refresh();
|
||||
if d.username == "root" {
|
||||
assert_eq!(d.home, "/root");
|
||||
} else {
|
||||
if !d.username.is_empty() {
|
||||
let home = super::super::get_env_var("HOME");
|
||||
if !home.is_empty() {
|
||||
assert_eq!(d.home, home);
|
||||
} else {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WakeLock(Option<keepawake::AwakeHandle>);
|
||||
|
||||
Reference in New Issue
Block a user