teknoraver / rpms / rpm

Forked from rpms/rpm 3 months ago
Clone

Blame SOURCES/0001-Remove-capabilities-instead-of-setting-empty-caps-vi.patch

83a7c7
From b4178c979fff344a1c5142a305f274dd9aff8f45 Mon Sep 17 00:00:00 2001
83a7c7
From: Markus Linnala <markus.linnala@gmail.com>
83a7c7
Date: Sun, 28 Oct 2018 14:59:52 +0200
83a7c7
Subject: [PATCH] Remove capabilities instead of setting empty caps via.
83a7c7
 --setcaps
83a7c7
83a7c7
If a file in a package does not have any capabilities rpm --setcaps should
83a7c7
remove capabilities of the file. Prior to this patch capabilities of the file
83a7c7
were set as empty.
83a7c7
83a7c7
Empty capabilities mean more than no capabilities. A file with no capabilities
83a7c7
can inherit capabilities, but file with empty capabilities can not.
83a7c7
83a7c7
When ever package does not have any capabilities set %|FILECAPS? is false.
83a7c7
If some files have capabilities, %|FILECAPS? is true but %{FILECAPS} is ''
83a7c7
when the file does not have capabilities and '= <capstring>' when there is some.
83a7c7
83a7c7
Reported and patch created by Markus Linnala
83a7c7
Commit message edited by Pavlina Moravcova Varekova and Florian Festi.
83a7c7
83a7c7
Fixes #585
83a7c7
Fixes #586
83a7c7
---
83a7c7
 rpmpopt.in | 9 +++++++--
83a7c7
 1 file changed, 7 insertions(+), 2 deletions(-)
83a7c7
83a7c7
diff --git a/rpmpopt.in b/rpmpopt.in
83a7c7
index 42d3416a3..557050a24 100644
83a7c7
--- a/rpmpopt.in
83a7c7
+++ b/rpmpopt.in
83a7c7
@@ -57,8 +57,13 @@ rpm	alias --setugids -q --qf \
83a7c7
 	--POPTdesc=$"set user/group ownership of files in a package"
83a7c7
 
83a7c7
 rpm	alias --setcaps -q --qf \
83a7c7
-	"[\[ -f %{FILENAMES:shescape} -a ! -L %{FILENAMES:shescape} \] \
83a7c7
-	    && setcap %|FILECAPS?{%{FILECAPS:shescape}}:{''}| %{FILENAMES:shescape}\n]" \
83a7c7
+        "[if \[ -f %{FILENAMES:shescape} -a ! -L %{FILENAMES:shescape} \]; then\n\
83a7c7
+%|FILECAPS?{  if \[ -n %{FILECAPS:shescape} \]; then\n\
83a7c7
+    setcap %{FILECAPS:shescape} %{FILENAMES:shescape}\n\
83a7c7
+  el}:{  }|if \[ -n \"\$(getcap %{FILENAMES:shescape})\" \]; then\n\
83a7c7
+    setcap -r %{FILENAMES:shescape}\n\
83a7c7
+  fi\n\
83a7c7
+fi\n]" \
83a7c7
 	--pipe "sh" \
83a7c7
 	--POPTdesc=$"set capabilities of files in a package"
83a7c7
 
83a7c7
-- 
83a7c7
2.21.0
83a7c7