malmond / rpms / rpm

Forked from rpms/rpm 4 years ago
Clone

Blame SOURCES/rpm-4.13.x-writable-tmp-dir.patch

5523e9
commit c707ab26362e795d3f9dba4eb87dc7ed99a28bcb
5523e9
Author: Robin Lee <cheeselee@fedoraproject.org>
5523e9
Date:   Sat Apr 8 21:21:39 2017 +0800
5523e9
5523e9
    Fix non-standard inherented modes of directories in debuginfo
5523e9
    
5523e9
    In case that binary compiled from source generated in /tmp, a
5523e9
    /usr/src/debug/tmp directory will be created with the same mode as
5523e9
    /tmp, a.k.a 777, which should be avoided.
5523e9
    
5523e9
    Fixes: rhbz#641022
5523e9
5523e9
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
5523e9
old mode 100644
5523e9
new mode 100755
5523e9
index 547dbd9..6f38e19
5523e9
--- a/scripts/find-debuginfo.sh
5523e9
+++ b/scripts/find-debuginfo.sh
5523e9
@@ -396,9 +396,10 @@
5523e9
   mkdir -p "${RPM_BUILD_ROOT}/usr/src/debug"
5523e9
   LC_ALL=C sort -z -u "$SOURCEFILE" | grep -E -v -z '(<internal>|<built-in>)$' |
5523e9
   (cd "$RPM_BUILD_DIR"; cpio -pd0mL "${RPM_BUILD_ROOT}/usr/src/debug")
5523e9
-  # stupid cpio creates new directories in mode 0700, fixup
5523e9
+  # stupid cpio creates new directories in mode 0700,
5523e9
+  # and non-standard modes may be inherented from original directories, fixup
5523e9
   find "${RPM_BUILD_ROOT}/usr/src/debug" -type d -print0 |
5523e9
-  xargs --no-run-if-empty -0 chmod a+rx
5523e9
+  xargs --no-run-if-empty -0 chmod 0755
5523e9
 fi
5523e9
 
5523e9
 if [ -d "${RPM_BUILD_ROOT}/usr/lib" -o -d "${RPM_BUILD_ROOT}/usr/src" ]; then
5523e9
5523e9
commit e795899780337dea751d85db8f381eff3fe75275
5523e9
Author: Mark Wielaard <mark@klomp.org>
5523e9
Date:   Fri Apr 21 17:33:26 2017 +0200
5523e9
5523e9
    debugedit: Only output comp_dir under build dir (once).
5523e9
    
5523e9
    The fix for rhbz#444310 (commit c1a5eb - Include empty CU current dirs)
5523e9
    was a little greedy. It would also include comp_dirs outside the build
5523e9
    root. Those are unnecessary and we don't have a good way to store them.
5523e9
    Such dirs (e.g. /tmp) would then show up at the root of /usr/src/debug.
5523e9
    
5523e9
    Fix this by including only comp_dirs under base_dir. Also only output
5523e9
    all dirs once (during phase zero) and don't output empty dirs (which
5523e9
    was harmless but would produce a warning from cpio).
5523e9
    
5523e9
    This still includes all empty dirs from the original rhbz#444310
5523e9
    nodir testcase and it is an alternative fix for rhbz#641022
5523e9
    (commit c707ab).
5523e9
    
5523e9
    Both fixes are necessary in case of an unexpected mode for a directory
5523e9
    actually in the build root that we want to include in the source list.
5523e9
    
5523e9
    Signed-off-by: Mark Wielaard <mark@klomp.org>
5523e9
5523e9
diff --git a/tools/debugedit.c b/tools/debugedit.c
5523e9
index 8444e03..bf11513 100644
5523e9
--- a/tools/debugedit.c
5523e9
+++ b/tools/debugedit.c
5523e9
@@ -926,27 +926,27 @@
5523e9
   /* Ensure the CU current directory will exist even if only empty.  Source
5523e9
      filenames possibly located in its parent directories refer relatively to
5523e9
      it and the debugger (GDB) cannot safely optimize out the missing
5523e9
-     CU current dir subdirectories.  */
5523e9
-  if (comp_dir && list_file_fd != -1)
5523e9
+     CU current dir subdirectories.  Only do this once in phase one. And
5523e9
+     only do this for dirs under our build/base_dir.  Don't output the
5523e9
+     empty string (in case the comp_dir == base_dir).  */
5523e9
+  if (phase == 0 && base_dir && comp_dir && list_file_fd != -1)
5523e9
     {
5523e9
-      char *p;
5523e9
-      size_t size;
5523e9
 
5523e9
-      if (base_dir && has_prefix (comp_dir, base_dir))
5523e9
-	p = comp_dir + strlen (base_dir);
5523e9
-      else if (dest_dir && has_prefix (comp_dir, dest_dir))
5523e9
-	p = comp_dir + strlen (dest_dir);
5523e9
-      else
5523e9
-	p = comp_dir;
5523e9
-
5523e9
-      size = strlen (p) + 1;
5523e9
-      while (size > 0)
5523e9
+      if (has_prefix (comp_dir, base_dir))
5523e9
 	{
5523e9
-	  ssize_t ret = write (list_file_fd, p, size);
5523e9
-	  if (ret == -1)
5523e9
-	    break;
5523e9
-	  size -= ret;
5523e9
-	  p += ret;
5523e9
+	  char *p = comp_dir + strlen (base_dir);
5523e9
+	  if (p[0] != '\0')
5523e9
+	    {
5523e9
+	      size_t size = strlen (p) + 1;
5523e9
+	      while (size > 0)
5523e9
+		{
5523e9
+		  ssize_t ret = write (list_file_fd, p, size);
5523e9
+		  if (ret == -1)
5523e9
+		    break;
5523e9
+		  size -= ret;
5523e9
+		  p += ret;
5523e9
+		}
5523e9
+	    }
5523e9
 	}
5523e9
     }
5523e9