richardphibel / rpms / rpm

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