summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe MacDonald <joe_macdonald@mentor.com>2019-11-24 20:26:41 -0500
committerJoe MacDonald <joe_macdonald@mentor.com>2019-12-09 09:27:47 -0500
commit4dde95212d8e5effeea5ffece5dbda59c7d4336d (patch)
tree082ee65093db1dabef30e6e8fc04443ed060d015
parent5fd3c5b71edb99659aeb5cb5903088d84517382e (diff)
downloadmeta-selinux-4dde95212d8e5effeea5ffece5dbda59c7d4336d.tar.gz
support policy module configuration at recipe level
On highly storage-limited machines it may be beneficial to completely remove some or all non-essential policy modules. refpolicy already supports this with the 'no' option in modules.conf, so we'll just expose this feature (with an appropriate warning) at the recipe-level. Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
-rw-r--r--recipes-security/refpolicy/refpolicy-minimum_2.20190201.bb10
-rw-r--r--recipes-security/refpolicy/refpolicy-minimum_git.bb11
-rw-r--r--recipes-security/refpolicy/refpolicy_common.inc10
3 files changed, 31 insertions, 0 deletions
diff --git a/recipes-security/refpolicy/refpolicy-minimum_2.20190201.bb b/recipes-security/refpolicy/refpolicy-minimum_2.20190201.bb
index 40abe35..01c9fc0 100644
--- a/recipes-security/refpolicy/refpolicy-minimum_2.20190201.bb
+++ b/recipes-security/refpolicy/refpolicy-minimum_2.20190201.bb
@@ -44,6 +44,16 @@ EXTRA_POLICY_MODULES += "mta"
44# hostname_t, ping_t, netutils_t) from modules: 44# hostname_t, ping_t, netutils_t) from modules:
45EXTRA_POLICY_MODULES += "modutils consoletype hostname netutils" 45EXTRA_POLICY_MODULES += "modutils consoletype hostname netutils"
46 46
47# Add specific policy modules here that should be purged from the system
48# policy. Purged modules will not be built and will not be installed on the
49# target. To use them at some later time you must specifically build and load
50# the modules by hand on the target.
51#
52# USE WITH CARE! With this feature it is easy to break your policy by purging
53# core modules (eg. userdomain)
54#
55# PURGE_POLICY_MODULES += "xdg xen"
56
47POLICY_MODULES_MIN = "${CORE_POLICY_MODULES} ${EXTRA_POLICY_MODULES}" 57POLICY_MODULES_MIN = "${CORE_POLICY_MODULES} ${EXTRA_POLICY_MODULES}"
48 58
49# re-write the same func from refpolicy_common.inc 59# re-write the same func from refpolicy_common.inc
diff --git a/recipes-security/refpolicy/refpolicy-minimum_git.bb b/recipes-security/refpolicy/refpolicy-minimum_git.bb
index 40abe35..3b3ca15 100644
--- a/recipes-security/refpolicy/refpolicy-minimum_git.bb
+++ b/recipes-security/refpolicy/refpolicy-minimum_git.bb
@@ -44,6 +44,17 @@ EXTRA_POLICY_MODULES += "mta"
44# hostname_t, ping_t, netutils_t) from modules: 44# hostname_t, ping_t, netutils_t) from modules:
45EXTRA_POLICY_MODULES += "modutils consoletype hostname netutils" 45EXTRA_POLICY_MODULES += "modutils consoletype hostname netutils"
46 46
47# Add specific policy modules here that should be purged from the system
48# policy. Purged modules will not be built and will not be installed on the
49# target. To use them at some later time you must specifically build and load
50# the modules by hand on the target.
51#
52# USE WITH CARE! With this feature it is easy to break your policy by purging
53# core modules (eg. userdomain)
54#
55# PURGE_POLICY_MODULES += "xdg xen"
56
57
47POLICY_MODULES_MIN = "${CORE_POLICY_MODULES} ${EXTRA_POLICY_MODULES}" 58POLICY_MODULES_MIN = "${CORE_POLICY_MODULES} ${EXTRA_POLICY_MODULES}"
48 59
49# re-write the same func from refpolicy_common.inc 60# re-write the same func from refpolicy_common.inc
diff --git a/recipes-security/refpolicy/refpolicy_common.inc b/recipes-security/refpolicy/refpolicy_common.inc
index 137ccee..2d9ace5 100644
--- a/recipes-security/refpolicy/refpolicy_common.inc
+++ b/recipes-security/refpolicy/refpolicy_common.inc
@@ -122,8 +122,18 @@ python __anonymous () {
122 d.setVar('DEFAULT_ENFORCING', 'permissive') 122 d.setVar('DEFAULT_ENFORCING', 'permissive')
123} 123}
124 124
125disable_policy_modules () {
126 for module in ${PURGE_POLICY_MODULES} ; do
127 sed -i "s/^\(\<${module}\>\) *= *.*$/\1 = off/" ${S}/policy/modules.conf
128 done
129}
130
125do_compile() { 131do_compile() {
132 if [ -f "${WORKDIR}/modules.conf" ] ; then
133 cp -f ${WORKDIR}/modules.conf ${S}/policy/modules.conf
134 fi
126 oe_runmake conf 135 oe_runmake conf
136 disable_policy_modules
127 oe_runmake policy 137 oe_runmake policy
128} 138}
129 139