Explorar o código

s-s-d: Behave the same way whether --chuid gets a user name or a uid

Otherwise it was failing to setup the default group for the user if it
had not been specified and the HOME environment variable.

Closes: #368000
Guillem Jover %!s(int64=17) %!d(string=hai) anos
pai
achega
5ea9550838
Modificáronse 3 ficheiros con 15 adicións e 2 borrados
  1. 6 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 7 2
      utils/start-stop-daemon.c

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2009-01-10  Guillem Jover  <guillem@debian.org>
+
+	* utils/start-stop-daemon.c (main): If changeuser is a uid, call
+	getpwuid to get the passwd entry and do the same setup as if it is
+	a username.
+
 2009-01-07  Guillem Jover  <guillem@debian.org>
 
 	* man/dpkg-deb.1: Document that -x will modify the extraction

+ 2 - 0
debian/changelog

@@ -48,6 +48,8 @@ dpkg (1.15.0) UNRELEASED; urgency=low
     is TERM not KILL. Closes: #507568
   * Warn in dpkg-deb man page that -x will modify the extraction directory
     permissions. Closes: #502496
+  * Make start-stop-daemon behave the same way whether --chuid gets a user
+    name or a uid. Closes: #368000
 
   [ Raphael Hertzog ]
   * Enhance dpkg-shlibdeps's error message when a library can't be found to

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

@@ -1267,8 +1267,13 @@ main(int argc, char **argv)
 			fatal("group `%s' not found\n", changegroup);
 		runas_gid = gr->gr_gid;
 	}
-	if (changeuser && sscanf(changeuser, "%d", &runas_uid) != 1) {
-		struct passwd *pw = getpwnam(changeuser);
+	if (changeuser) {
+		struct passwd *pw;
+
+		if (sscanf(changeuser, "%d", &runas_uid) == 1)
+			pw = getpwuid(runas_uid);
+		else
+			pw = getpwnam(changeuser);
 		if (!pw)
 			fatal("user `%s' not found\n", changeuser);
 		runas_uid = pw->pw_uid;