michal-grzedzicki / rpms / rpm

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