Преглед изворни кода

s-s-d: Abort if the system or compatibility setsid() fails

This requires to check the setpgid() return value in the setsid()
compatibility function.
Guillem Jover пре 12 година
родитељ
комит
877057869d
2 измењених фајлова са 7 додато и 2 уклоњено
  1. 2 0
      debian/changelog
  2. 5 2
      utils/start-stop-daemon.c

+ 2 - 0
debian/changelog

@@ -53,6 +53,8 @@ dpkg (1.17.14) UNRELEASED; urgency=low
     affects error messages from partial or broken .deb packages for example.
     Regression introduced in dpkg 1.17.10. Closes: #759498
   * Remove lpia architecture support.
+  * Improvements and portability fixes to start-stop-daemon:
+    - Abort if the system or compatibility setsid() fails.
 
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 5 - 2
utils/start-stop-daemon.c

@@ -352,7 +352,9 @@ detach_controlling_tty(void)
 static pid_t
 setsid(void)
 {
-	setpgid(0, 0);
+	if (setpgid(0, 0) < 0)
+		return -1:
+
 	detach_controlling_tty();
 
 	return 0;
@@ -374,7 +376,8 @@ daemonize(void)
 		_exit(0);
 
 	/* Create a new session. */
-	setsid();
+	if (setsid() < 0)
+		fatal("cannot set session ID");
 
 	pid = fork();
 	if (pid < 0)