teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame 0010-Only-process-regular-files-when-generating-build-ids.patch

Igor Gnatenko 082d5d
From 29f756e3fba09f6a66515970978367829862f35c Mon Sep 17 00:00:00 2001
Panu Matilainen 5b4d98
From: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 5b4d98
Date: Thu, 5 Jan 2017 12:13:54 +0200
Mark Wielaard 284dc3
Subject: [PATCH] Only process regular files when generating build-ids
Panu Matilainen 5b4d98
Panu Matilainen 5b4d98
Versioned shared libraries typically have several symlinks pointing
Panu Matilainen 5b4d98
to them directly and indirectly. When %_build_id_links is set to compat or
Panu Matilainen 5b4d98
separate this causes bogus warnings about duplicate build-ids.
Panu Matilainen 5b4d98
Panu Matilainen 5b4d98
It looks commit bbfe1f86b2e4b5c0bd499d9f3dd9de9c9c20fff2 intends to skip
Panu Matilainen 5b4d98
symlinks since it filters on S_ISREG(), but since uses fstat()
Panu Matilainen 5b4d98
on already open()'ed file it ends up stat()'ing the symlink target.
Panu Matilainen 5b4d98
Flip stat() + open() around and use lstat() instead to fix it.
Igor Gnatenko 082d5d
Igor Gnatenko 082d5d
(cherry picked from commit 1ce844ab263bf49ee6d5145ed09e73f2c17924cc)
Panu Matilainen 5b4d98
---
Panu Matilainen 5b4d98
 build/files.c | 11 +++++------
Panu Matilainen 5b4d98
 1 file changed, 5 insertions(+), 6 deletions(-)
Panu Matilainen 5b4d98
Panu Matilainen 5b4d98
diff --git a/build/files.c b/build/files.c
Igor Gnatenko 082d5d
index 2ede463a1..ca041764f 100644
Panu Matilainen 5b4d98
--- a/build/files.c
Panu Matilainen 5b4d98
+++ b/build/files.c
Panu Matilainen 5b4d98
@@ -1678,11 +1678,10 @@ static int generateBuildIDs(FileList fl)
Panu Matilainen 5b4d98
     int needMain = 0;
Panu Matilainen 5b4d98
     int needDbg = 0;
Panu Matilainen 5b4d98
     for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
Panu Matilainen 5b4d98
-	int fd;
Panu Matilainen 5b4d98
-	fd = open (flp->diskPath, O_RDONLY);
Panu Matilainen 5b4d98
-	if (fd >= 0) {
Panu Matilainen 5b4d98
-	    struct stat sbuf;
Panu Matilainen 5b4d98
-	    if (fstat (fd, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
Panu Matilainen 5b4d98
+	struct stat sbuf;
Panu Matilainen 5b4d98
+	if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
Panu Matilainen 5b4d98
+	    int fd = open (flp->diskPath, O_RDONLY);
Panu Matilainen 5b4d98
+	    if (fd >= 0) {
Panu Matilainen 5b4d98
 		Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
Panu Matilainen 5b4d98
 		if (elf != NULL && elf_kind(elf) == ELF_K_ELF) {
Panu Matilainen 5b4d98
 		    const void *build_id;
Panu Matilainen 5b4d98
@@ -1748,8 +1747,8 @@ static int generateBuildIDs(FileList fl)
Panu Matilainen 5b4d98
 		    }
Panu Matilainen 5b4d98
 		    elf_end (elf);
Panu Matilainen 5b4d98
 		}
Panu Matilainen 5b4d98
+		close (fd);
Panu Matilainen 5b4d98
 	    }
Panu Matilainen 5b4d98
-	    close (fd);
Panu Matilainen 5b4d98
 	}
Panu Matilainen 5b4d98
     }
Panu Matilainen 5b4d98