mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Use AsFd to get rid of re-borrowing of zbus Power Key fd
This commit is contained in:
committed by
Ivan Molodetskikh
parent
c8eea8ee9d
commit
137b87bbe5
+1
-4
@@ -2777,8 +2777,6 @@ impl Niri {
|
||||
|
||||
#[cfg(feature = "dbus")]
|
||||
pub fn inhibit_power_key(&mut self) -> anyhow::Result<()> {
|
||||
use std::os::fd::{AsRawFd, BorrowedFd};
|
||||
|
||||
use smithay::reexports::rustix::io::{fcntl_setfd, FdFlags};
|
||||
|
||||
let conn = zbus::blocking::Connection::system()?;
|
||||
@@ -2794,8 +2792,7 @@ impl Niri {
|
||||
let fd: zbus::zvariant::OwnedFd = message.body().deserialize()?;
|
||||
|
||||
// Don't leak the fd to child processes.
|
||||
let borrowed = unsafe { BorrowedFd::borrow_raw(fd.as_raw_fd()) };
|
||||
if let Err(err) = fcntl_setfd(borrowed, FdFlags::CLOEXEC) {
|
||||
if let Err(err) = fcntl_setfd(&fd, FdFlags::CLOEXEC) {
|
||||
warn!("error setting CLOEXEC on inhibit fd: {err:?}");
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user