From a3dfed3551de431307036008791828d021643049 Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Thu, 26 May 2022 17:43:13 +0800 Subject: [PATCH] fix: neuron daemon lock file permission problem --- src/daemon.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/daemon.c b/src/daemon.c index ed52b5cf..8c7ec5e6 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -30,6 +30,8 @@ #include #include +#include "neuron/log.h" + #include "daemon.h" void daemonize() @@ -100,9 +102,12 @@ int neuron_already_running() int ret = -1; ssize_t size = -1; + umask(0); fd = open(NEURON_DAEMON_LOCK_FNAME, O_RDWR | O_CREAT, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (fd < 0) { + log_error("cannot open %s reason: %s\n", NEURON_DAEMON_LOCK_FNAME, + strerror(errno)); exit(1); } @@ -113,6 +118,8 @@ int neuron_already_running() close(fd); return 1; } + log_error("cannot lock %s reason: %s\n", NEURON_DAEMON_LOCK_FNAME, + strerror(errno)); exit(1); }