drop fd_change_cloexec from proxmox-rest-server

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-09-30 12:42:28 +02:00
parent 0d5d15c9d1
commit 8735247f29
3 changed files with 2 additions and 13 deletions

View File

@ -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" {

View File

@ -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> {

View File

@ -152,7 +152,7 @@ async fn termproxy(cmd: Option<String>, rpcenv: &mut dyn RpcEnvironment) -> Resu
move |worker| async move {
// move inside the worker so that it survives and does not close the port
// remove CLOEXEC from listenere so that we can reuse it in termproxy
proxmox_rest_server::fd_change_cloexec(listener.as_raw_fd(), false)?;
pbs_tools::fd::fd_change_cloexec(listener.as_raw_fd(), false)?;
let mut arguments: Vec<&str> = Vec::new();
let fd_string = listener.as_raw_fd().to_string();