dcavalca / rpms / rpm

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