Daemon stdio ownership and cover runtime path policies fixed

Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
Alexey
2026-09-30 07:40:01 +03:00
parent 53f131e34d
commit 6fa8da3c43
+5 -3
View File
@@ -9,7 +9,7 @@ use std::os::unix::fs::OpenOptionsExt;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use nix::errno::Errno; use nix::errno::Errno;
use nix::unistd::{self, ForkResult, Gid, Uid, chdir, close, fork, getpid, setsid}; use nix::unistd::{self, ForkResult, Gid, Uid, chdir, fork, getpid, setsid};
use tracing::info; use tracing::info;
// PID file ownership and process-control helpers. // PID file ownership and process-control helpers.
@@ -176,8 +176,10 @@ fn redirect_stdio_to_devnull() -> Result<(), DaemonError> {
} }
} }
if devnull_fd > 2 { // Keep stdio descriptors open; other source descriptors are closed once by File's Drop.
let _ = close(devnull_fd); // Transfer ownership only after all dup2 calls succeed so errors retain RAII cleanup.
if devnull_fd <= 2 {
let _ = std::os::unix::io::IntoRawFd::into_raw_fd(devnull);
} }
Ok(()) Ok(())