forge
Explore
Log in

Don't you dare go Hollow

Use `AsFd` to get rid of re-borrowing of zbus Power Key fd

Browse files at this commit

137b87bbe57662e88518eb8a0033b548a0313f33Markus PetterssonParent: c8eea8e
src/niri.rsmodified+1 -4
@@ -2777,8 +2777,6 @@ impl Niri {
2777 2777
2778 #[cfg(feature = "dbus")]2778 #[cfg(feature = "dbus")]
2779 pub fn inhibit_power_key(&mut self) -> anyhow::Result<()> {2779 pub fn inhibit_power_key(&mut self) -> anyhow::Result<()> {
2780- use std::os::fd::{AsRawFd, BorrowedFd};
2781-
2782 use smithay::reexports::rustix::io::{fcntl_setfd, FdFlags};2780 use smithay::reexports::rustix::io::{fcntl_setfd, FdFlags};
2783 2781
2784 let conn = zbus::blocking::Connection::system()?;2782 let conn = zbus::blocking::Connection::system()?;
@@ -2794,8 +2792,7 @@ impl Niri {
2794 let fd: zbus::zvariant::OwnedFd = message.body().deserialize()?;2792 let fd: zbus::zvariant::OwnedFd = message.body().deserialize()?;
2795 2793
2796 // Don't leak the fd to child processes.2794 // Don't leak the fd to child processes.
2797- let borrowed = unsafe { BorrowedFd::borrow_raw(fd.as_raw_fd()) };2795+ if let Err(err) = fcntl_setfd(&fd, FdFlags::CLOEXEC) {
2798- if let Err(err) = fcntl_setfd(borrowed, FdFlags::CLOEXEC) {
2799 warn!("error setting CLOEXEC on inhibit fd: {err:?}");2796 warn!("error setting CLOEXEC on inhibit fd: {err:?}");
2800 };2797 };
2801 2798