Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-17784/PM-17588] Flatpak & Mac Store SSH Agent #13324

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,17 @@
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()))));

Check warning on line 34 in apps/desktop/desktop_native/core/src/ssh_agent/peercred_unix_listener_stream.rs

View check run for this annotation

Codecov / codecov/patch

apps/desktop/desktop_native/core/src/ssh_agent/peercred_unix_listener_stream.rs#L34

Added line #L34 was not covered by tests
}
},
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()))));

Check warning on line 38 in apps/desktop/desktop_native/core/src/ssh_agent/peercred_unix_listener_stream.rs

View check run for this annotation

Codecov / codecov/patch

apps/desktop/desktop_native/core/src/ssh_agent/peercred_unix_listener_stream.rs#L38

Added line #L38 was not covered by tests
}
};
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())))),

Check warning on line 44 in apps/desktop/desktop_native/core/src/ssh_agent/peercred_unix_listener_stream.rs

View check run for this annotation

Codecov / codecov/patch

apps/desktop/desktop_native/core/src/ssh_agent/peercred_unix_listener_stream.rs#L44

Added line #L44 was not covered by tests
}
}
Poll::Ready(Err(err)) => Poll::Ready(Some(Err(err))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
pub fn process_name(&self) -> &str {
&self.process_name
}

pub fn unknown() -> Self {
Self::new(0, 0, "Unknown application".to_string())
}

Check warning on line 35 in apps/desktop/desktop_native/core/src/ssh_agent/peerinfo/models.rs

View check run for this annotation

Codecov / codecov/patch

apps/desktop/desktop_native/core/src/ssh_agent/peerinfo/models.rs#L33-L35

Added lines #L33 - L35 were not covered by tests
}
20 changes: 15 additions & 5 deletions apps/desktop/desktop_native/core/src/ssh_agent/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,21 @@
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()

Check warning on line 57 in apps/desktop/desktop_native/core/src/ssh_agent/unix.rs

View check run for this annotation

Codecov / codecov/patch

apps/desktop/desktop_native/core/src/ssh_agent/unix.rs#L51-L57

Added lines #L51 - L57 were not covered by tests
} else {
ssh_agent_directory
.join(".var/app/com.bitwarden.desktop/data/.bitwarden-ssh-agent.sock")
.to_str()
.expect("Path should be valid")
.to_owned()

Check warning on line 63 in apps/desktop/desktop_native/core/src/ssh_agent/unix.rs

View check run for this annotation

Codecov / codecov/patch

apps/desktop/desktop_native/core/src/ssh_agent/unix.rs#L59-L63

Added lines #L59 - L63 were not covered by tests
}
}
};

Expand Down
Loading