dcavalca / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone

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

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