dcavalca / rpms / rpm

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