ソースを参照

s-s-d: Change uid after changing gid and initalizing supplementary groups

Closes: #462018
Guillem Jover 18 年 前
コミット
b5841bbaec
共有3 個のファイルを変更した16 個の追加4 個の削除を含む
  1. 5 0
      ChangeLog
  2. 7 0
      debian/changelog
  3. 4 4
      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): Move setuid code after initgroups
+	and setgid.
+
 2008-01-21  Frank Lichtenheld  <djpig@debian.org>
 
 	* configure.ac: Release 1.14.16.1

+ 7 - 0
debian/changelog

@@ -1,3 +1,10 @@
+dpkg (1.14.16.2) UNRELEASED; urgency=low
+
+  * Change uid after changing gid and initializing supplementary groups in
+    start-stop-daemon. Closes: #462018
+
+ -- Guillem Jover <guillem@debian.org>  Tue, 22 Jan 2008 12:52:11 +0200
+
 dpkg (1.14.16.1) unstable; urgency=low
 
   * Add libtimedate-perl to dpkg-dev's Depends and to Build-Depends.

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

@@ -1413,10 +1413,6 @@ main(int argc, char **argv)
 	if (chdir(changedir) < 0)
 		fatal("Unable to chdir() to %s", changedir);
 
-	if (changeuser != NULL && getuid() != (uid_t)runas_uid) {
-		if (setuid(runas_uid))
-			fatal("Unable to set uid to %s", changeuser);
-	}
 	if (changegroup != NULL && *changegroup != '\0' &&
 	    getgid() != (gid_t)runas_gid) {
 		if (!gid_in_current_groups(runas_gid))
@@ -1426,6 +1422,10 @@ main(int argc, char **argv)
 		if (setgid(runas_gid))
 			fatal("Unable to set gid to %d", runas_gid);
 	}
+	if (changeuser != NULL && getuid() != (uid_t)runas_uid) {
+		if (setuid(runas_uid))
+			fatal("Unable to set uid to %s", changeuser);
+	}
 
 	if (background) {
 		/* Continue background setup */