From 2682b7d4b6833c45422bc1678c4922518baf8c77 Mon Sep 17 00:00:00 2001 From: TBC Dev Date: Wed, 3 Jun 2020 01:36:02 +0800 Subject: [PATCH 1/2] Fix corrupted pidfiles by truncating on open() --- src/platform/linux.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index bc075c3..31236cd 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -85,7 +85,7 @@ pub fn daemonize + Sized>(pid_file: T) -> Result { // create the pid file let pid_fd = map_err!( - open(path_c.as_ptr(), libc::O_WRONLY | libc::O_CREAT, 0o666), + open(path_c.as_ptr(), libc::O_WRONLY | libc::O_TRUNC | libc::O_CREAT, 0o666), ErrorKind::OpenPidfile(io::Error::last_os_error()) )?; From 27b8e81da231d60d7dfcf5ab8355df48a876467d Mon Sep 17 00:00:00 2001 From: TBC Dev Date: Wed, 3 Jun 2020 01:36:22 +0800 Subject: [PATCH 2/2] Create pidfiles with mode 0644 --- src/platform/linux.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 31236cd..782e075 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -85,7 +85,7 @@ pub fn daemonize + Sized>(pid_file: T) -> Result { // create the pid file let pid_fd = map_err!( - open(path_c.as_ptr(), libc::O_WRONLY | libc::O_TRUNC | libc::O_CREAT, 0o666), + open(path_c.as_ptr(), libc::O_WRONLY | libc::O_TRUNC | libc::O_CREAT, 0o644), ErrorKind::OpenPidfile(io::Error::last_os_error()) )?;