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:
Pawel Jakub Dawidek 2005-09-16 11:24:28 +00:00
parent 3badacee8c
commit 8b28aef238
6 changed files with 6 additions and 6 deletions

View File

@ -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);

View File

@ -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),

View File

@ -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",

View File

@ -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);

View File

@ -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);

View File

@ -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",