From ae97bc8cdf8e92527a3d6c9a7cb4a9a4f205ef87 Mon Sep 17 00:00:00 2001 From: Jos Kamphorst Date: Thu, 10 Apr 2025 15:00:22 +0200 Subject: [PATCH] When .chown_pid_file(true) is called with only one of the methods .group("groupname") or .user("username"), use the default for the unset user or group. The same behavior as when both were not set. This results in a more predictable behavior in line with the rest of the code. --- daemonize/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemonize/src/lib.rs b/daemonize/src/lib.rs index 4f0f758c6..0dad3b851 100644 --- a/daemonize/src/lib.rs +++ b/daemonize/src/lib.rs @@ -393,8 +393,8 @@ impl Daemonize { let args: Option<(PathBuf, libc::uid_t, libc::gid_t)> = match (self.pid_file, uid, gid) { (Some(pid), Some(uid), Some(gid)) => Some((pid, uid, gid)), - (Some(pid), None, Some(gid)) => Some((pid, libc::uid_t::MAX - 1, gid)), - (Some(pid), Some(uid), None) => Some((pid, uid, libc::gid_t::MAX - 1)), + (Some(pid), None, Some(gid)) => Some((pid, libc::getuid(), gid)), + (Some(pid), Some(uid), None) => Some((pid, uid, libc::getgid())), // Or pid file is not provided, or both user and group _ => None, };