mirror of
https://github.com/telemt/telemt.git
synced 2026-10-07 01:45:58 +03:00
Daemon stdio ownership and cover runtime path policies fixed
Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
+5
-3
@@ -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(())
|
||||||
|
|||||||
Reference in New Issue
Block a user