chore!: drop daemonize crate#372
Open
ethanpailes wants to merge 1 commit into
Open
Conversation
This patch drops teh daemonize crate in favor of our own daemonization implementation. The daemonize crate is apparently unmaintained, so we need to migrate off of it for security. In writing this patch, I realized that libshpool::run was technically unsound (though in practice, no reasonable caller would trigger unsoundness). Unfortunately, to fix it properly I needed to mark the entrypoint `unsafe` and document the required preconditions (can't call from a multi-threaded program in a situation where it might be self-execed to auto-daemonize). Unfortunately this requires a breaking version upgrade.
maxhbooth
reviewed
May 12, 2026
| return Err(anyhow!("redirecting stdin to /dev/null: {}", nix::errno::Errno::last())); | ||
| } | ||
| // Safety: nullfd is valid and newfd need not be open for saftey | ||
| let fd = unsafe { libc::dup2(nullfd, libc::STDOUT_FILENO) }; |
There was a problem hiding this comment.
should you be using nix's dup2 instead? https://docs.rs/nix/latest/nix/unistd/fn.dup2.html
|
|
||
| fn redirect_std_fds_to_null() -> anyhow::Result<()> { | ||
| // Safety: path is a valid null terminated string, O_RDWR is a valid flag. | ||
| let nullfd = unsafe { libc::open(b"/dev/null\0" as *const [u8; 10] as _, libc::O_RDWR) }; |
There was a problem hiding this comment.
Do we need to close nullfd after we finish duping?
|
|
||
| fn redirect_std_fds_to_null() -> anyhow::Result<()> { | ||
| // Safety: path is a valid null terminated string, O_RDWR is a valid flag. | ||
| let nullfd = unsafe { libc::open(b"/dev/null\0" as *const [u8; 10] as _, libc::O_RDWR) }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Link
The nightly
cargo denytests have been failing for a while. This is me attempting to clean them up.AI Policy Ack
Ack
This PR was:
I vibed the tests
Description
This patch drops teh daemonize crate in favor of our own daemonization implementation. The daemonize crate is apparently unmaintained, so we need to migrate off of it for security.
In writing this patch, I realized that libshpool::run was technically unsound (though in practice, no reasonable caller would trigger unsoundness). Unfortunately, to fix it properly I needed to mark the entrypoint
unsafeand document the required preconditions (can't call from a multi-threaded program in a situation where it might be self-execed to auto-daemonize). Unfortunately this requires a breaking version upgrade.