From 249aae1f053e16d258658052defa73a8bb9bae24 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 30 Sep 2021 12:42:28 +0200 Subject: [PATCH] drop fd_change_cloexec from proxmox-rest-server Signed-off-by: Wolfgang Bumiller --- proxmox-rest-server/src/daemon.rs | 2 +- proxmox-rest-server/src/lib.rs | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/proxmox-rest-server/src/daemon.rs b/proxmox-rest-server/src/daemon.rs index 9d48ecd2..0501ad4c 100644 --- a/proxmox-rest-server/src/daemon.rs +++ b/proxmox-rest-server/src/daemon.rs @@ -16,7 +16,7 @@ use nix::unistd::{fork, ForkResult}; use proxmox::tools::io::{ReadExt, WriteExt}; use proxmox::tools::fd::Fd; -use crate::fd_change_cloexec; +use pbs_tools::fd::fd_change_cloexec; #[link(name = "systemd")] extern "C" { diff --git a/proxmox-rest-server/src/lib.rs b/proxmox-rest-server/src/lib.rs index fc952f2b..da52c673 100644 --- a/proxmox-rest-server/src/lib.rs +++ b/proxmox-rest-server/src/lib.rs @@ -1,4 +1,3 @@ -use std::os::unix::io::RawFd; use std::sync::atomic::{Ordering, AtomicBool}; use anyhow::{bail, format_err, Error}; @@ -135,16 +134,6 @@ pub fn fail_on_shutdown() -> Result<(), Error> { Ok(()) } -/// Helper to set/clear the FD_CLOEXEC flag on file descriptors -pub fn fd_change_cloexec(fd: RawFd, on: bool) -> Result<(), Error> { - use nix::fcntl::{fcntl, FdFlag, F_GETFD, F_SETFD}; - let mut flags = FdFlag::from_bits(fcntl(fd, F_GETFD)?) - .ok_or_else(|| format_err!("unhandled file flags"))?; // nix crate is stupid this way... - flags.set(FdFlag::FD_CLOEXEC, on); - fcntl(fd, F_SETFD(flags))?; - Ok(()) -} - /// safe wrapper for `nix::sys::socket::socketpair` defaulting to `O_CLOEXEC` and guarding the file /// descriptors. pub fn socketpair() -> Result<(Fd, Fd), Error> {