mirror of
https://github.com/bitwarden/browser
synced 2026-02-05 11:13:44 +00:00
Rewrite pid matching
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
/// High level composition of the other modules, to provide an interface that can be exported to
|
||||
/// NAPI.
|
||||
pub mod agent;
|
||||
/// Known hosts scans and parses the hosts from a users home directory, that the user has
|
||||
/// previously connected to and has trusted.
|
||||
pub mod knownhosts;
|
||||
/// In-memory storage for SSH keys. They are held in the desktop_native module while the agent is unlocked.
|
||||
pub mod memory;
|
||||
/// Parsing and serialization of the SSH agent protocol messages, and handling of requests
|
||||
pub mod protocol;
|
||||
/// SSH agent allows various transport mechanisms - Unix sockets, Windows named pipes, Putty's shared memory.
|
||||
/// This module implements these transport mechanisms.
|
||||
pub mod transport;
|
||||
|
||||
@@ -68,27 +68,17 @@ impl Stream for UnixListenerStream {
|
||||
) -> Poll<Option<io::Result<(UnixStream, PeerInfo)>>> {
|
||||
match self.inner.poll_accept(cx) {
|
||||
Poll::Ready(Ok((stream, _))) => {
|
||||
let pid = match stream.peer_cred() {
|
||||
Ok(peer) => match peer.pid() {
|
||||
Some(pid) => pid,
|
||||
None => {
|
||||
return Poll::Ready(Some(Ok((
|
||||
stream,
|
||||
PeerInfo::unknown(PeerType::UnixSocket),
|
||||
))));
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
return Poll::Ready(Some(Ok((
|
||||
stream,
|
||||
PeerInfo::unknown(PeerType::UnixSocket),
|
||||
))))
|
||||
}
|
||||
let pid = stream
|
||||
.peer_cred()
|
||||
.ok()
|
||||
.and_then(|peer| peer.pid().and_then(|pid| u32::try_from(pid).ok()));
|
||||
|
||||
let peer_info = match pid {
|
||||
Some(pid) => PeerInfo::new(pid, PeerType::UnixSocket),
|
||||
None => PeerInfo::unknown(PeerType::UnixSocket),
|
||||
};
|
||||
Poll::Ready(Some(Ok((
|
||||
stream,
|
||||
PeerInfo::new(pid as u32, PeerType::UnixSocket),
|
||||
))))
|
||||
|
||||
Poll::Ready(Some(Ok((stream, peer_info))))
|
||||
}
|
||||
Poll::Ready(Err(err)) => Poll::Ready(Some(Err(err))),
|
||||
Poll::Pending => Poll::Pending,
|
||||
|
||||
Reference in New Issue
Block a user