Skip to content

Replace unmaintained daemonize with daemonize-next and default the daemon user to nobody - #145

Open
MohibShaikh wants to merge 1 commit into
Tongsuo-Project:mainfrom
MohibShaikh:daemonize-next
Open

MohibShaikh wants to merge 1 commit into
Tongsuo-Project:mainfrom
MohibShaikh:daemonize-next

Conversation

@MohibShaikh

@MohibShaikh MohibShaikh commented Oct 26, 2026 •

Copy link
Copy Markdown

daemonize 0.5 is unmaintained (RUSTSEC-2025-0069). This switches to daemonize-next, which keeps the same API, and fixes the default daemon user.

Changes

  • Cargo.toml: daemonize = { package = "daemonize-next", version = "0.1" }. No call sites change.
  • server.rs: the default daemon_user and daemon_group were "onbody", which doesn't exist. The default user is now nobody, and when daemon_group is empty no group is set, so the daemon gets the user's primary group (nogroup on Debian, where there is no nobody group).
  • server.rs: when daemonizing fails, return the error instead of logging it and starting the server anyway.

Why

With daemonize 0.5, a failed user lookup or pid file lock happens after the fork. The error was only logged, and the server kept running as root. 0.5 also never calls setgroups, so a daemon dropped to daemon_user kept root's supplementary groups.

Proof

rvault server --config with daemon = true, run as root in a rust:latest container where root is also in groups 4 and 27, then reading /proc/<pid>/status of the daemon:

Config main (daemonize 0.5) this PR
daemon_user = "nobody", daemon_group = "nogroup" uid/gid 65534, groups 0 4 27 uid/gid/groups 65534
no daemon_user / daemon_group launcher exits 0, no pid file, server runs as uid 0, gid 0, groups 0 4 27 uid/gid/groups 65534
daemon_user = "no-such-user" launcher exits 0, server runs as uid 0 launcher exits 78: failed to start the daemon: unable to resolve user name to user id "no-such-user"
second instance, same pid file launcher exits 0; the second daemon logs unable to lock pid file and keeps starting until the port bind fails launcher exits 78: unable to lock pid file /tmp/rvw/rusty_vault.pid: ... (another process holds the lock; is the daemon already running?)

CI on a fork, the full workflow, for this branch and for unmodified main on the same day. unix-default-test fails at cargo clippy -- -D warnings on this branch (Ubuntu and macOS) and on main (Ubuntu; main's macOS job was cancelled by fail-fast), with the same 20 errors from newer stable lints (15 redundant reference in format! and 5 others), none in server.rs. Every step before Clippy passes on this branch on both OSes, including cargo test and cargo test --features sync_handler (292 + 19 + 1 each). The Tongsuo, MySQL, sqlx-MySQL and Windows jobs pass on both branches.

daemonize 0.5 is unmaintained (RUSTSEC-2025-0069). daemonize-next keeps its
API, so only the dependency line changes, and it drops root's supplementary
groups when switching user and reports a failed start in the launcher.

The default daemon user and group were "onbody", which does not exist, so
with no daemon_user configured the user lookup failed after the fork, the
error was only logged, and the server kept running as root. Default to
nobody, take the group from the user when daemon_group is empty, and return
the error when daemonizing fails.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants