Fix for #4136 connection to linux refused by using wrong Xauthority file.

This PR handles comments of review for PR #4165.
This commit is contained in:
Awalon 2023-04-23 23:58:04 +02:00
parent 028767da8b
commit dcc9337f86
No known key found for this signature in database
GPG Key ID: 73C00BFA11FDC12E
2 changed files with 29 additions and 40 deletions

View File

@ -328,13 +328,12 @@ fn patch(path: PathBuf) -> PathBuf {
.to_string() .to_string()
.trim() .trim()
.to_owned(); .to_owned();
if home_dir.is_empty() { if !home_dir.is_empty() {
return format!("/home/{user}").into();
} else {
log::info!("config::patch: got home dir from: {}", home_dir); log::info!("config::patch: got home dir from: {}", home_dir);
return home_dir.into(); return home_dir.into();
} }
} }
return format!("/home/{user}").into();
} }
} }
} }

View File

@ -455,7 +455,8 @@ pub fn get_user_home_by_name(username: &str) -> Option<PathBuf> {
return match get_user_by_name(username) { return match get_user_by_name(username) {
None => { None => {
log::debug!("no uid found for user: {}", username); log::debug!("no uid found for user: {}", username);
None } None
}
Some(user) => { Some(user) => {
log::debug!("user '{:?}' (uid {:?}) with home dir: {:?}", user.uid(), user.name(), user.home_dir()); log::debug!("user '{:?}' (uid {:?}) with home dir: {:?}", user.uid(), user.name(), user.home_dir());
let home = user.home_dir(); let home = user.home_dir();
@ -866,7 +867,6 @@ mod desktop {
for line in output.lines() { for line in output.lines() {
let mut auth_found = false; let mut auth_found = false;
if let Some(pid) = line.split_whitespace().nth(1) {
for v in line.split_whitespace() { for v in line.split_whitespace() {
if v == "-auth" { if v == "-auth" {
log::debug!("- auth parameter detected"); log::debug!("- auth parameter detected");
@ -900,16 +900,6 @@ mod desktop {
return; return;
} }
} }
// get from environment variable if parameter wasn't found
let xauth = get_env_from_pid("XAUTHORITY", pid);
if !xauth.is_empty() {
if Path::new(&xauth).exists() {
log::debug!("+ auth file from environment detected: {}", xauth);
self.xauth = xauth;
};
}
}
} }
} }
log::debug!("- auth file detected by Xorg: {}", self.xauth); log::debug!("- auth file detected by Xorg: {}", self.xauth);