1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 06:13:38 +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() { Ok(peer) => match peer.pid() {
Some(pid) => pid, Some(pid) => pid,
None => { None => {
return Poll::Ready(Some(Err(io::Error::new( return Poll::Ready(Some(Ok((stream, PeerInfo::unknown()))));
io::ErrorKind::Other,
"Failed to get peer PID",
))));
} }
}, },
Err(err) => { Err(_) => {
return Poll::Ready(Some(Err(io::Error::new( return Poll::Ready(Some(Ok((stream, PeerInfo::unknown()))));
io::ErrorKind::Other,
format!("Failed to get peer credentials: {}", err),
))));
} }
}; };
let peer_info = peerinfo::gather::get_peer_info(pid as u32); let peer_info = peerinfo::gather::get_peer_info(pid as u32);
match peer_info { match peer_info {
Ok(info) => Poll::Ready(Some(Ok((stream, info)))), Ok(info) => Poll::Ready(Some(Ok((stream, info)))),
Err(err) => Poll::Ready(Some(Err(io::Error::new( Err(_) => Poll::Ready(Some(Ok((stream, PeerInfo::unknown())))),
io::ErrorKind::Other,
format!("Failed to get peer info: {}", err),
)))),
} }
} }
Poll::Ready(Err(err)) => Poll::Ready(Some(Err(err))), Poll::Ready(Err(err)) => Poll::Ready(Some(Err(err))),

View File

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

View File

@@ -47,11 +47,21 @@ impl BitwardenDesktopAgent {
return; return;
} }
}; };
ssh_agent_directory
.join(".bitwarden-ssh-agent.sock") let is_flatpak = std::env::var("container") == Ok("flatpak".to_string());
.to_str() if !is_flatpak {
.expect("Path should be valid") ssh_agent_directory
.to_owned() .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()
}
} }
}; };