Просмотр исходного кода

s-s-d: Fix segfault when using --group w/o --chuid

As a side effect, using --group alone works for the first time in years.
Closes: #462072
Guillem Jover лет назад: 18
Родитель
Сommit
00f6e12340
3 измененных файлов с 11 добавлено и 3 удалено
  1. 5 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 3 3
      utils/start-stop-daemon.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-01-22  Guillem Jover  <guillem@debian.org>
+
+	* utils/start-stop-daemon.c (main): Only call initgroups if changeuser
+	is not NULL.
+
 2008-01-22  Guillem Jover  <guillem@debian.org>
 
 	* utils/start-stop-daemon.c (gid_in_current_groups): Remove function.

+ 3 - 0
debian/changelog

@@ -8,6 +8,9 @@ dpkg (1.14.16.3) UNRELEASED; urgency=low
   [ Guillem Jover ]
   * Make start-stop-daemon set the supplementary groups if the real user or
     group are different than the ones we should switch to. Closes: #462075
+  * Fix segfault in start-stop-daemon when using --group w/o --chuid (as
+    a side effect, using --group alone works for the first time in years).
+    Closes: #462072
 
  -- Raphael Hertzog <hertzog@debian.org>  Tue, 22 Jan 2008 18:15:42 +0100
 

+ 3 - 3
utils/start-stop-daemon.c

@@ -1400,7 +1400,8 @@ main(int argc, char **argv)
 		if (rgid != (gid_t)runas_gid)
 			if (setgid(runas_gid))
 				fatal("Unable to set gid to %d", runas_gid);
-
+	}
+	if (changeuser != NULL) {
 		/* We assume that if our real user and group are the same as
 		 * the ones we should switch to, the supplementary groups
 		 * will be already in place. */
@@ -1408,8 +1409,7 @@ main(int argc, char **argv)
 			if (initgroups(changeuser, runas_gid))
 				fatal("Unable to set initgroups() with gid %d",
 				      runas_gid);
-	}
-	if (changeuser != NULL) {
+
 		if (ruid != (uid_t)runas_uid)
 			if (setuid(runas_uid))
 				fatal("Unable to set uid to %s", changeuser);