michal-grzedzicki / rpms / rpm

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