|
|
bdce9f |
From 4a627847d36afedfca20026fb763fbb71005b92f Mon Sep 17 00:00:00 2001
|
|
|
bdce9f |
From: Eric Garver <eric@garver.life>
|
|
|
bdce9f |
Date: Mon, 30 Aug 2021 13:24:47 -0400
|
|
|
bdce9f |
Subject: [PATCH 3/3] fix(firewalld): check capng_apply() return code
|
|
|
bdce9f |
|
|
|
bdce9f |
If dropping capabilities is blocked by SELinux, e.g. old selinux-policy,
|
|
|
bdce9f |
then capng_apply() will return non-zero. Also check other things that
|
|
|
bdce9f |
may fail, i.e. capng_update().
|
|
|
bdce9f |
|
|
|
bdce9f |
Fixes: rhbz 1999090
|
|
|
bdce9f |
(cherry picked from commit 36749f512bbcfc55f0e9e46354009073941d7363)
|
|
|
bdce9f |
(cherry picked from commit cf7f3320c78a8b3f2b8f22779c5747f113d25c57)
|
|
|
bdce9f |
---
|
|
|
bdce9f |
src/firewalld.in | 18 ++++++++++--------
|
|
|
bdce9f |
1 file changed, 10 insertions(+), 8 deletions(-)
|
|
|
bdce9f |
|
|
|
bdce9f |
diff --git a/src/firewalld.in b/src/firewalld.in
|
|
|
bdce9f |
index b1c886c6f02f..38331a0b49a9 100755
|
|
|
bdce9f |
--- a/src/firewalld.in
|
|
|
bdce9f |
+++ b/src/firewalld.in
|
|
|
bdce9f |
@@ -140,14 +140,16 @@ def startup(args):
|
|
|
bdce9f |
try:
|
|
|
bdce9f |
import capng
|
|
|
bdce9f |
capng.capng_clear(capng.CAPNG_SELECT_BOTH)
|
|
|
bdce9f |
- capng.capng_update(capng.CAPNG_ADD, capng.CAPNG_EFFECTIVE | capng.CAPNG_PERMITTED | capng.CAPNG_BOUNDING_SET,
|
|
|
bdce9f |
- capng.CAP_NET_ADMIN)
|
|
|
bdce9f |
- capng.capng_update(capng.CAPNG_ADD, capng.CAPNG_EFFECTIVE | capng.CAPNG_PERMITTED | capng.CAPNG_BOUNDING_SET,
|
|
|
bdce9f |
- capng.CAP_NET_RAW)
|
|
|
bdce9f |
- capng.capng_update(capng.CAPNG_ADD, capng.CAPNG_EFFECTIVE | capng.CAPNG_PERMITTED | capng.CAPNG_BOUNDING_SET,
|
|
|
bdce9f |
- capng.CAP_SYS_MODULE)
|
|
|
bdce9f |
- capng.capng_apply(capng.CAPNG_SELECT_BOTH)
|
|
|
bdce9f |
- log.info(log.INFO1, "Dropped Linux capabilities to NET_ADMIN, NET_RAW, SYS_MODULE.")
|
|
|
bdce9f |
+ if capng.capng_update(capng.CAPNG_ADD, capng.CAPNG_EFFECTIVE | capng.CAPNG_PERMITTED | capng.CAPNG_BOUNDING_SET,
|
|
|
bdce9f |
+ capng.CAP_NET_ADMIN) or \
|
|
|
bdce9f |
+ capng.capng_update(capng.CAPNG_ADD, capng.CAPNG_EFFECTIVE | capng.CAPNG_PERMITTED | capng.CAPNG_BOUNDING_SET,
|
|
|
bdce9f |
+ capng.CAP_NET_RAW) or \
|
|
|
bdce9f |
+ capng.capng_update(capng.CAPNG_ADD, capng.CAPNG_EFFECTIVE | capng.CAPNG_PERMITTED | capng.CAPNG_BOUNDING_SET,
|
|
|
bdce9f |
+ capng.CAP_SYS_MODULE) or \
|
|
|
bdce9f |
+ capng.capng_apply(capng.CAPNG_SELECT_BOTH):
|
|
|
bdce9f |
+ log.info(log.INFO1, "libcap-ng failed to drop Linux capabilities.")
|
|
|
bdce9f |
+ else:
|
|
|
bdce9f |
+ log.info(log.INFO1, "Dropped Linux capabilities to NET_ADMIN, NET_RAW, SYS_MODULE.")
|
|
|
bdce9f |
except ImportError:
|
|
|
bdce9f |
pass
|
|
|
bdce9f |
|
|
|
bdce9f |
--
|
|
|
bdce9f |
2.31.1
|
|
|
bdce9f |
|