summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Domonkos <mdomonko@redhat.com>2021-12-07 08:08:37 +0100
committerMichal Domonkos <mdomonko@redhat.com>2022-07-01 10:52:14 +0200
commit86319dc03357c9855ca26281808b945857656a1e (patch)
tree1135717eb0caa8eaaab0239b3335dd7c1141d590
parent29573b65858422686da4834a1632a4c6cc5f9c61 (diff)
downloadrpm-86319dc03357c9855ca26281808b945857656a1e.tar.gz
Skip recorded symlinks in --setperms (RhBug:1900662)
If a package contains a symlink in the buildroot which is declared as a ghost or config file but is a regular file or directory on the system where it's installed, a --setperms call will reset its permissions to those of a symlink (777 on Linux), which almost certainly is not the correct thing to do. To fix that, just skip files that were recorded as symlinks. This is a special case of a general issue in --setperms; since file permission semantics may change depending on the file type, to stay on the safe side, any (ghost or config) file whose type changes after installation should probably be skipped. However, symlinks are the most prominent case here, so let's just focus on that now and avoid adding too much cleverness to a popt alias (this got us into trouble not too long ago, see commits 38c2f6e and 0d83637). We may revisit this in the eventual C implementation. (cherry picked from commit ed07a187734addfa16be9ee922398e4ff9859f53)
-rw-r--r--rpmpopt.in1
1 files changed, 1 insertions, 0 deletions
diff --git a/rpmpopt.in b/rpmpopt.in
index 27d298651..d5a6b140b 100644
--- a/rpmpopt.in
+++ b/rpmpopt.in
@@ -44,6 +44,7 @@ rpm alias --scripts --qf '\
--POPTdesc=$"list install/erase scriptlets from package(s)"
rpm alias --setperms -q --qf '[\[ -L %{FILENAMES:shescape} \] || \
+ \[ -n %{FILELINKTOS:shescape} \] || \
( \[ $((%{FILEFLAGS} & 2#1001000)) != 0 \] && \[ ! -e %{FILENAMES:shescape} \] ) || \
chmod %7{FILEMODES:octal} %{FILENAMES:shescape}\n]' \
--pipe "grep -v \(none\) | grep '^. -L ' | sed 's/chmod .../chmod /' | sh" \