dcavalca / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone

Blame SOURCES/rpm-4.16.1.3-skip-recorded-symlinks-in-setperms.patch

a5e32e
From 6cdcdd8770d1f0b9ba706dcc1e6392a59dbe3fe5 Mon Sep 17 00:00:00 2001
a5e32e
From: Michal Domonkos <mdomonko@redhat.com>
a5e32e
Date: Tue, 7 Dec 2021 08:08:37 +0100
a5e32e
Subject: [PATCH] Skip recorded symlinks in --setperms (RhBug:1900662)
a5e32e
a5e32e
If a package contains a symlink in the buildroot which is declared as a
a5e32e
ghost or config file but is a regular file or directory on the system
a5e32e
where it's installed, a --setperms call will reset its permissions to
a5e32e
those of a symlink (777 on Linux), which almost certainly is not the
a5e32e
correct thing to do.
a5e32e
a5e32e
To fix that, just skip files that were recorded as symlinks.
a5e32e
a5e32e
This is a special case of a general issue in --setperms; since file
a5e32e
permission semantics may change depending on the file type, to stay on
a5e32e
the safe side, any (ghost or config) file whose type changes after
a5e32e
installation should probably be skipped.  However, symlinks are the most
a5e32e
prominent case here, so let's just focus on that now and avoid adding
a5e32e
too much cleverness to a popt alias (this got us into trouble not too
a5e32e
long ago, see commits 38c2f6e and 0d83637).  We may revisit this in the
a5e32e
eventual C implementation.
a5e32e
---
a5e32e
 rpmpopt.in | 1 +
a5e32e
 1 file changed, 1 insertion(+)
a5e32e
a5e32e
diff --git a/rpmpopt.in b/rpmpopt.in
a5e32e
index 27d298651..d5a6b140b 100644
a5e32e
--- a/rpmpopt.in
a5e32e
+++ b/rpmpopt.in
a5e32e
@@ -44,6 +44,7 @@ rpm	alias --scripts --qf '\
a5e32e
 	--POPTdesc=$"list install/erase scriptlets from package(s)"
a5e32e
 
a5e32e
 rpm	alias --setperms -q --qf '[\[ -L %{FILENAMES:shescape} \] || \
a5e32e
+        \[ -n %{FILELINKTOS:shescape} \] || \
a5e32e
         ( \[ $((%{FILEFLAGS} & 2#1001000)) != 0 \] && \[ ! -e %{FILENAMES:shescape} \] ) || \
a5e32e
         chmod %7{FILEMODES:octal} %{FILENAMES:shescape}\n]' \
a5e32e
 		   --pipe "grep -v \(none\) | grep '^. -L ' | sed 's/chmod .../chmod /' | sh" \
a5e32e
-- 
a5e32e
2.34.1
a5e32e