teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0743-test-ignore-IAB-capabilities-in-test-execute.patch

da2bf9
From 68c487956659bb0bc3e04be4c8f0687d46d23248 Mon Sep 17 00:00:00 2001
da2bf9
From: Frantisek Sumsal <frantisek@sumsal.cz>
da2bf9
Date: Mon, 9 Mar 2020 11:00:58 +0100
da2bf9
Subject: [PATCH] test: ignore IAB capabilities in `test-execute`
da2bf9
da2bf9
libcap v2.33 introduces a new capability set called IAB[0] which is shown
da2bf9
in the output of `capsh --print` and interferes with the test checks. Let's
da2bf9
drop the IAB set from the output, for now, to mitigate this.
da2bf9
da2bf9
This could be (and probably should be) replaced in the future by the
da2bf9
newly introduced testing options[1][2] in libcap v2.32, namely:
da2bf9
    --has-p=xxx
da2bf9
    --has-i=xxx
da2bf9
    --has-a=xxx
da2bf9
da2bf9
but this needs to wait until the respective libcap version gets a wider
da2bf9
adoption. Until then, let's stick with the relatively ugly sed.
da2bf9
da2bf9
Fixes: #15046
da2bf9
da2bf9
[0] https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=943b011b5e53624eb9cab4e96c1985326e077cdd
da2bf9
[1] https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=588d0439cb6495b03f0ab9f213f0b6b339e7d4b7
da2bf9
[2] https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=e7709bbc1c4712f2ddfc6e6f42892928a8a03782
da2bf9
da2bf9
(cherry picked from commit e9cdcbed77971da3cb0b98b3eb91081142c91eb7)
da2bf9
da2bf9
Related: #2017033
da2bf9
---
da2bf9
 test/test-execute/exec-capabilityboundingset-invert.service   | 4 ++--
da2bf9
 .../exec-privatedevices-no-capability-mknod.service           | 4 ++--
da2bf9
 .../exec-privatedevices-no-capability-sys-rawio.service       | 4 ++--
da2bf9
 .../exec-privatedevices-yes-capability-mknod.service          | 4 ++--
da2bf9
 .../exec-privatedevices-yes-capability-sys-rawio.service      | 4 ++--
da2bf9
 .../exec-protectkernelmodules-no-capabilities.service         | 4 ++--
da2bf9
 .../exec-protectkernelmodules-yes-capabilities.service        | 4 ++--
da2bf9
 7 files changed, 14 insertions(+), 14 deletions(-)
da2bf9
da2bf9
diff --git a/test/test-execute/exec-capabilityboundingset-invert.service b/test/test-execute/exec-capabilityboundingset-invert.service
da2bf9
index 5f37427603..4486f6c25d 100644
da2bf9
--- a/test/test-execute/exec-capabilityboundingset-invert.service
da2bf9
+++ b/test/test-execute/exec-capabilityboundingset-invert.service
da2bf9
@@ -2,7 +2,7 @@
da2bf9
 Description=Test for CapabilityBoundingSet
da2bf9
 
da2bf9
 [Service]
da2bf9
-# sed: remove dropped capabilities (cap_xxx-[epi]) from the output
da2bf9
-ExecStart=/bin/sh -x -c '! capsh --print | sed -r "s/[^ ]+?\-[epi]+//g" | grep "^Bounding set .*cap_chown"'
da2bf9
+# sed: remove dropped (cap_xxx-[epi]) and IAB capabilities from the output
da2bf9
+ExecStart=/bin/sh -x -c '! capsh --print | sed -re "s/[^ ]+?\-[epi]+//g" -e '/IAB/d' | grep "^Bounding set .*cap_chown"'
da2bf9
 Type=oneshot
da2bf9
 CapabilityBoundingSet=~CAP_CHOWN
da2bf9
diff --git a/test/test-execute/exec-privatedevices-no-capability-mknod.service b/test/test-execute/exec-privatedevices-no-capability-mknod.service
da2bf9
index 4d61d9ffaa..8f135be0b5 100644
da2bf9
--- a/test/test-execute/exec-privatedevices-no-capability-mknod.service
da2bf9
+++ b/test/test-execute/exec-privatedevices-no-capability-mknod.service
da2bf9
@@ -3,6 +3,6 @@ Description=Test CAP_MKNOD capability for PrivateDevices=no
da2bf9
 
da2bf9
 [Service]
da2bf9
 PrivateDevices=no
da2bf9
-# sed: remove dropped capabilities (cap_xxx-[epi]) from the output
da2bf9
-ExecStart=/bin/sh -x -c 'capsh --print | sed -r "s/[^ ]+?\-[epi]+//g" | grep cap_mknod'
da2bf9
+# sed: remove dropped (cap_xxx-[epi]) and IAB capabilities from the output
da2bf9
+ExecStart=/bin/sh -x -c 'capsh --print | sed -re "s/[^ ]+?\-[epi]+//g" -e '/IAB/d' | grep cap_mknod'
da2bf9
 Type=oneshot
da2bf9
diff --git a/test/test-execute/exec-privatedevices-no-capability-sys-rawio.service b/test/test-execute/exec-privatedevices-no-capability-sys-rawio.service
da2bf9
index f7f7a16736..30ce549254 100644
da2bf9
--- a/test/test-execute/exec-privatedevices-no-capability-sys-rawio.service
da2bf9
+++ b/test/test-execute/exec-privatedevices-no-capability-sys-rawio.service
da2bf9
@@ -3,6 +3,6 @@ Description=Test CAP_SYS_RAWIO capability for PrivateDevices=no
da2bf9
 
da2bf9
 [Service]
da2bf9
 PrivateDevices=no
da2bf9
-# sed: remove dropped capabilities (cap_xxx-[epi]) from the output
da2bf9
-ExecStart=/bin/sh -x -c 'capsh --print | sed -r "s/[^ ]+?\-[epi]+//g" | grep cap_sys_rawio'
da2bf9
+# sed: remove dropped (cap_xxx-[epi]) and IAB capabilities from the output
da2bf9
+ExecStart=/bin/sh -x -c 'capsh --print | sed -re "s/[^ ]+?\-[epi]+//g" -e '/IAB/d' | grep cap_sys_rawio'
da2bf9
 Type=oneshot
da2bf9
diff --git a/test/test-execute/exec-privatedevices-yes-capability-mknod.service b/test/test-execute/exec-privatedevices-yes-capability-mknod.service
da2bf9
index 5bcace0845..b98cfb5c7e 100644
da2bf9
--- a/test/test-execute/exec-privatedevices-yes-capability-mknod.service
da2bf9
+++ b/test/test-execute/exec-privatedevices-yes-capability-mknod.service
da2bf9
@@ -3,6 +3,6 @@ Description=Test CAP_MKNOD capability for PrivateDevices=yes
da2bf9
 
da2bf9
 [Service]
da2bf9
 PrivateDevices=yes
da2bf9
-# sed: remove dropped capabilities (cap_xxx-[epi]) from the output
da2bf9
-ExecStart=/bin/sh -x -c '! capsh --print | sed -r "s/[^ ]+?\-[epi]+//g" | grep cap_mknod'
da2bf9
+# sed: remove dropped (cap_xxx-[epi]) and IAB capabilities from the output
da2bf9
+ExecStart=/bin/sh -x -c '! capsh --print | sed -re "s/[^ ]+?\-[epi]+//g" -e '/IAB/d' | grep cap_mknod'
da2bf9
 Type=oneshot
da2bf9
diff --git a/test/test-execute/exec-privatedevices-yes-capability-sys-rawio.service b/test/test-execute/exec-privatedevices-yes-capability-sys-rawio.service
da2bf9
index a246f950c1..5b0c0700f2 100644
da2bf9
--- a/test/test-execute/exec-privatedevices-yes-capability-sys-rawio.service
da2bf9
+++ b/test/test-execute/exec-privatedevices-yes-capability-sys-rawio.service
da2bf9
@@ -3,6 +3,6 @@ Description=Test CAP_SYS_RAWIO capability for PrivateDevices=yes
da2bf9
 
da2bf9
 [Service]
da2bf9
 PrivateDevices=yes
da2bf9
-# sed: remove dropped capabilities (cap_xxx-[epi]) from the output
da2bf9
-ExecStart=/bin/sh -x -c '! capsh --print | sed -r "s/[^ ]+?\-[epi]+//g" | grep cap_sys_rawio'
da2bf9
+# sed: remove dropped (cap_xxx-[epi]) and IAB capabilities from the output
da2bf9
+ExecStart=/bin/sh -x -c '! capsh --print | sed -re "s/[^ ]+?\-[epi]+//g" -e '/IAB/d' | grep cap_sys_rawio'
da2bf9
 Type=oneshot
da2bf9
diff --git a/test/test-execute/exec-protectkernelmodules-no-capabilities.service b/test/test-execute/exec-protectkernelmodules-no-capabilities.service
da2bf9
index 8d7e2b52d4..1b73656305 100644
da2bf9
--- a/test/test-execute/exec-protectkernelmodules-no-capabilities.service
da2bf9
+++ b/test/test-execute/exec-protectkernelmodules-no-capabilities.service
da2bf9
@@ -3,6 +3,6 @@ Description=Test CAP_SYS_MODULE ProtectKernelModules=no
da2bf9
 
da2bf9
 [Service]
da2bf9
 ProtectKernelModules=no
da2bf9
-# sed: remove dropped capabilities (cap_xxx-[epi]) from the output
da2bf9
-ExecStart=/bin/sh -x -c 'capsh --print | sed -r "s/[^ ]+?\-[epi]+//g" | grep cap_sys_module'
da2bf9
+# sed: remove dropped (cap_xxx-[epi]) and IAB capabilities from the output
da2bf9
+ExecStart=/bin/sh -x -c 'capsh --print | sed -re "s/[^ ]+?\-[epi]+//g" -e '/IAB/d' | grep cap_sys_module'
da2bf9
 Type=oneshot
da2bf9
diff --git a/test/test-execute/exec-protectkernelmodules-yes-capabilities.service b/test/test-execute/exec-protectkernelmodules-yes-capabilities.service
da2bf9
index fe2ae208dd..e43e72733c 100644
da2bf9
--- a/test/test-execute/exec-protectkernelmodules-yes-capabilities.service
da2bf9
+++ b/test/test-execute/exec-protectkernelmodules-yes-capabilities.service
da2bf9
@@ -3,6 +3,6 @@ Description=Test CAP_SYS_MODULE for ProtectKernelModules=yes
da2bf9
 
da2bf9
 [Service]
da2bf9
 ProtectKernelModules=yes
da2bf9
-# sed: remove dropped capabilities (cap_xxx-[epi]) from the output
da2bf9
-ExecStart=/bin/sh -x -c '! capsh --print | sed -r "s/[^ ]+?\-[epi]+//g" | grep cap_sys_module'
da2bf9
+# sed: remove dropped (cap_xxx-[epi]) and IAB capabilities from the output
da2bf9
+ExecStart=/bin/sh -x -c '! capsh --print | sed -re "s/[^ ]+?\-[epi]+//g" -e '/IAB/d' | grep cap_sys_module'
da2bf9
 Type=oneshot