Skip to content

Commit

Permalink
Merge pull request #657 from zeenix/upgrade-nix-0.28
Browse files Browse the repository at this point in the history
⬆️  zb: Bump nix to 0.28
  • Loading branch information
zeenix authored Feb 24, 2024
2 parents 55b8b18 + ffd0136 commit e0a6344
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
21 changes: 20 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion zbus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ windows-sys = { version = "0.52", features = [
uds_windows = "1.1.0"

[target.'cfg(unix)'.dependencies]
nix = { version = "0.27", default-features = false, features = [
nix = { version = "0.28", default-features = false, features = [
"socket",
"uio",
"user",
Expand Down
9 changes: 4 additions & 5 deletions zbus/src/connection/socket/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,14 @@ async fn get_unix_peer_creds(fd: &impl AsRawFd) -> io::Result<crate::fdo::Connec

#[cfg(unix)]
fn get_unix_peer_creds_blocking(fd: RawFd) -> io::Result<crate::fdo::ConnectionCredentials> {
// TODO: get this BorrowedFd directly from get_unix_peer_creds(), but this requires a
// 'static lifetime due to the Task.
let fd = unsafe { BorrowedFd::borrow_raw(fd) };

#[cfg(any(target_os = "android", target_os = "linux"))]
{
use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};

// TODO: get this BorrowedFd directly from get_unix_peer_creds(), but this requires a
// 'static lifetime due to the Task.
let fd = unsafe { BorrowedFd::borrow_raw(fd) };

getsockopt(&fd, PeerCredentials)
.map(|creds| {
crate::fdo::ConnectionCredentials::default()
Expand All @@ -353,7 +353,6 @@ fn get_unix_peer_creds_blocking(fd: RawFd) -> io::Result<crate::fdo::ConnectionC
target_os = "netbsd"
))]
{
let fd = fd.as_raw_fd();
let uid = nix::unistd::getpeereid(fd).map(|(uid, _)| uid.into())?;
// FIXME: Handle pid fetching too.
Ok(crate::fdo::ConnectionCredentials::default().set_unix_user_id(uid))
Expand Down

0 comments on commit e0a6344

Please sign in to comment.