-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
Description
In the my-daemon programs (here, I explicitly refer to ch10/my-daemon-v2.c), the syscall to umask(022) should either be used before creating the pidfile, or the permissions of the pidfile need to be set explicitly for the control client to work as described in the book.
Explanation
This is not the case if the root user uses a umask of e.g. 027 per default (via environment or similar), where the pidfile ends up with permissions 640 (rw-r-----), making it impossible for users other than root to use the control client for querying the status of the daemon.
Steps to reproduce:
$ sudo -i
# umask 027
# ./my-daemon-v2
# exit
$ my-daemon
fopen pidfile: Permission denied
$ ls -ld /var/run/my-daemon.pid
-rw-r----- 1 root root 6 Mar 26 08:19 /run/my-daemon.pidReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels