Browse Source

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>
Guillem Jover 12 years ago
parent
commit
e63048c680
2 changed files with 7 additions and 4 deletions
  1. 2 0
      debian/changelog
  2. 5 4
      utils/start-stop-daemon.c

+ 2 - 0
debian/changelog

@@ -58,6 +58,8 @@ dpkg (1.17.14) UNRELEASED; urgency=low
     - Do not exit from the first parent before the pidfile has been created,
       when using --background and --make-pidfile, to avoid the race condition.
       Based on a patch by Nir Soffer <nirs@hyperms.com>. Closes: #686420
+    - Make sure the pidfile is always created with a 022 umask.
+      Reported by Will Conley <willconley3@gmail.com>. Closes: #760222
 
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 5 - 4
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;