Browse Source

dpkg-statoverride: Do not accept unknown user or group names on --add

Cherry picked from commit 5c58085b746d234066ea94d386182cfc72c612ba.

We should not allow adding user or group names to the database that do
not exist in the system passwd database, as the main dpkg program uses
strict parsing and will fail with an unrecoverable fatal error if it
cannot find a matching name for a uid/gid.

Regression introduced in commit e4d6db177fad401ddc8432cf0e2c64e4fcf7bc0d,
where we went from too strict to too lax parsing.

Closes: #775124
Guillem Jover 11 years ago
parent
commit
caf11a3487
2 changed files with 6 additions and 6 deletions
  1. 2 0
      debian/changelog
  2. 4 6
      src/statcmd.c

+ 2 - 0
debian/changelog

@@ -101,6 +101,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
   * Add a new dpkg-buildflags sanitize feature area:
     - Add new “address”, “thread”, “leak” and “undefined” features, all
       disabled by default. Closes: #760741
+  * Do not accept unknown user or group names on «dpkg-statoverride --add».
+    Regression introduced in dpkg 1.17.11. Closes: #775124
 
   [ Raphaël Hertzog ]
   * Drop myself from Uploaders.

+ 4 - 6
src/statcmd.c

@@ -123,14 +123,12 @@ statdb_node_new(const char *user, const char *group, const char *mode)
 
 	filestat->uid = statdb_parse_uid(user);
 	if (filestat->uid == (uid_t)-1)
-		filestat->uname = nfstrsave(user);
-	else
-		filestat->uname = NULL;
+		ohshit(_("user '%s' does not exist"), user);
+	filestat->uname = NULL;
 	filestat->gid = statdb_parse_gid(group);
 	if (filestat->gid == (gid_t)-1)
-		filestat->gname = nfstrsave(group);
-	else
-		filestat->gname = NULL;
+		ohshit(_("group '%s' does not exist"), group);
+	filestat->gname = NULL;
 	filestat->mode = statdb_parse_mode(mode);
 
 	return filestat;