Sfoglia il codice sorgente

dpkg-statoverride: Fallback to printing #<id> if db lookup fails

This allows it to gracefully handle uid and gid not present on the
password databases, when storing on the overrides db, in a similar way
as the perl implementation was behaving.

Spotted-by: Raphaël Hertzog <hertzog@debian.org>
Guillem Jover 16 anni fa
parent
commit
c644793d5c
1 ha cambiato i file con 10 aggiunte e 6 eliminazioni
  1. 10 6
      src/statcmd.c

+ 10 - 6
src/statcmd.c

@@ -194,14 +194,18 @@ statdb_node_print(FILE *out, struct filenamenode *file)
 		return;
 
 	pw = getpwuid(filestat->uid);
-	if (pw == NULL)
-		ohshite(_("error getting user name for uid %d"), filestat->uid);
+	if (pw)
+		fprintf(out, "%s ", pw->pw_name);
+	else
+		fprintf(out, "#%d ", filestat->uid);
+
 	gr = getgrgid(filestat->gid);
-	if (gr == NULL)
-		ohshite(_("error getting group name for gid %d"), filestat->gid);
+	if (gr)
+		fprintf(out, "%s ", gr->gr_name);
+	else
+		fprintf(out, "#%d ", filestat->gid);
 
-	fprintf(out, "%s %s %o %s\n", pw->pw_name, gr->gr_name, filestat->mode,
-	        file->name);
+	fprintf(out, "%o %s\n", filestat->mode, file->name);
 }
 
 static void