summaryrefslogtreecommitdiff
path: root/utils/start-stop-daemon.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2014-09-09 15:40:45 +0200
committerGuillem Jover <guillem@debian.org>2014-10-06 00:40:44 +0200
commite63048c680f151026237f2411e2bfebe2722f73d (patch)
tree7026fea36f61603baeabc561c246a7e5070bfa37 /utils/start-stop-daemon.c
parent29778da537e2ff1a0f032db33dde43413b7345ef (diff)
downloaddpkg-e63048c680f151026237f2411e2bfebe2722f73d.tar.gz
s-s-d: Make sure the pidfile is always created with a 022 umask
Although this got partially corrected with the fix for the background and pidfile creation bug, it still migth happen that the parent had a too restrictive umask. Closes: #760222 Reported-by: Will Conley <willconley3@gmail.com>
Diffstat (limited to 'utils/start-stop-daemon.c')
-rw-r--r--utils/start-stop-daemon.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 7fd8d8f87..706e90011 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -447,6 +447,11 @@ daemonize(void)
if (pid < 0)
fatal("unable to do second fork");
else if (pid) { /* Second parent. */
+ /* Set a default umask for dumb programs, which might get
+ * overridden by the --umask option later on, so that we get
+ * a defined umask when creating the pidfille. */
+ umask(022);
+
if (mpidfile && pidfile != NULL)
/* User wants _us_ to make the pidfile. */
write_pidfile(pidfile, pid);
@@ -1866,10 +1871,6 @@ do_start(int argc, char **argv)
fatal("unable to set uid to %s", changeuser);
}
- /* Set a default umask for dumb programs. */
- if (background && umask_value < 0)
- umask(022);
-
if (background && close_io) {
int i;