Pidfiles should be created with permission preventing users from opening
them for reading. When user can open file for reading, he can also flock(2) it, which can lead to confusions. Pointed out by: green
This commit is contained in:
parent
3badacee8c
commit
8b28aef238
@ -100,7 +100,7 @@ The following example shows in which order those functions should be used.
|
||||
struct pidfh *pfh;
|
||||
pid_t otherpid, childpid;
|
||||
|
||||
pfh = pidfile_open("/var/run/daemon.pid", 0644, &otherpid);
|
||||
pfh = pidfile_open("/var/run/daemon.pid", 0600, &otherpid);
|
||||
if (pfh == NULL) {
|
||||
if (errno == EEXIST)
|
||||
errx(EXIT_FAILURE, "Daemon already running, pid: %d.", otherpid);
|
||||
|
@ -72,7 +72,7 @@ open_pidfile(void)
|
||||
int otherpid;
|
||||
|
||||
(void) snprintf(pidfile, sizeof(pidfile), PIDFILE, PIDDIR);
|
||||
pfh = pidfile_open(pidfile, 0644, &otherpid);
|
||||
pfh = pidfile_open(pidfile, 0600, &otherpid);
|
||||
if (pfh == NULL) {
|
||||
if (errno == EEXIST) {
|
||||
snprintf(buf, sizeof(buf),
|
||||
|
@ -467,7 +467,7 @@ main(int argc, char **argv)
|
||||
if (debug == 0) {
|
||||
pid_t otherpid;
|
||||
|
||||
pfh = pidfile_open(pid_file, 0644, &otherpid);
|
||||
pfh = pidfile_open(pid_file, 0600, &otherpid);
|
||||
if (pfh == NULL) {
|
||||
if (errno == EEXIST) {
|
||||
syslog(LOG_ERR, "%s already running, pid: %d",
|
||||
|
@ -275,7 +275,7 @@ main(argc, argv)
|
||||
udp6sock = tcp6sock = 0;
|
||||
|
||||
/* Check that another mountd isn't already running. */
|
||||
pfh = pidfile_open(_PATH_MOUNTDPID, 0644, &otherpid);
|
||||
pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &otherpid);
|
||||
if (pfh == NULL) {
|
||||
if (errno == EEXIST)
|
||||
errx(1, "mountd already running, pid: %d.", otherpid);
|
||||
|
@ -918,7 +918,7 @@ moused(void)
|
||||
logerr(1, "cannot open /dev/consolectl");
|
||||
|
||||
if (!nodaemon && !background) {
|
||||
pfh = pidfile_open(pidfile, 0644, &mpid);
|
||||
pfh = pidfile_open(pidfile, 0600, &mpid);
|
||||
if (pfh == NULL) {
|
||||
if (errno == EEXIST)
|
||||
logerrx(1, "moused already running, pid: %d", mpid);
|
||||
|
@ -97,7 +97,7 @@ main(int argc, char *argv[])
|
||||
if (watchdog_onoff(1) == -1)
|
||||
exit(EX_SOFTWARE);
|
||||
|
||||
pfh = pidfile_open(pidfile, 0644, &otherpid);
|
||||
pfh = pidfile_open(pidfile, 0600, &otherpid);
|
||||
if (pfh == NULL) {
|
||||
if (errno == EEXIST) {
|
||||
errx(EX_SOFTWARE, "%s already running, pid: %d",
|
||||
|
Loading…
Reference in New Issue
Block a user