1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 21:33:27 +00:00

Fix ssh agent on flatpak and mac app store (#13324)

This commit is contained in:
Bernd Schoolmann
2025-02-25 14:47:08 +01:00
committed by GitHub
parent 240f9f9348
commit d11321e28e
3 changed files with 23 additions and 18 deletions

View File

@@ -31,26 +31,17 @@ impl Stream for PeercredUnixListenerStream {
Ok(peer) => match peer.pid() {
Some(pid) => pid,
None => {
return Poll::Ready(Some(Err(io::Error::new(
io::ErrorKind::Other,
"Failed to get peer PID",
))));
return Poll::Ready(Some(Ok((stream, PeerInfo::unknown()))));
}
},
Err(err) => {
return Poll::Ready(Some(Err(io::Error::new(
io::ErrorKind::Other,
format!("Failed to get peer credentials: {}", err),
))));
Err(_) => {
return Poll::Ready(Some(Ok((stream, PeerInfo::unknown()))));
}
};
let peer_info = peerinfo::gather::get_peer_info(pid as u32);
match peer_info {
Ok(info) => Poll::Ready(Some(Ok((stream, info)))),
Err(err) => Poll::Ready(Some(Err(io::Error::new(
io::ErrorKind::Other,
format!("Failed to get peer info: {}", err),
)))),
Err(_) => Poll::Ready(Some(Ok((stream, PeerInfo::unknown())))),
}
}
Poll::Ready(Err(err)) => Poll::Ready(Some(Err(err))),

View File

@@ -29,4 +29,8 @@ impl PeerInfo {
pub fn process_name(&self) -> &str {
&self.process_name
}
pub fn unknown() -> Self {
Self::new(0, 0, "Unknown application".to_string())
}
}

View File

@@ -47,11 +47,21 @@ impl BitwardenDesktopAgent {
return;
}
};
ssh_agent_directory
.join(".bitwarden-ssh-agent.sock")
.to_str()
.expect("Path should be valid")
.to_owned()
let is_flatpak = std::env::var("container") == Ok("flatpak".to_string());
if !is_flatpak {
ssh_agent_directory
.join(".bitwarden-ssh-agent.sock")
.to_str()
.expect("Path should be valid")
.to_owned()
} else {
ssh_agent_directory
.join(".var/app/com.bitwarden.desktop/data/.bitwarden-ssh-agent.sock")
.to_str()
.expect("Path should be valid")
.to_owned()
}
}
};