commit:     3f7c372e6212f0ab402c6bbd833dd80d1fb50e22
Author:     Christian Göttsche <cgzones <AT> googlemail <DOT> com>
AuthorDate: Tue Mar 22 17:10:11 2022 +0000
Commit:     Jason Zaman <perfinion <AT> gentoo <DOT> org>
CommitDate: Thu Mar 31 02:40:53 2022 +0000
URL:        
https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=3f7c372e

Rules.monolithic: add target to generate CIL policy

Add a Makefile target to generate a CIL policy, useful for debugging,
introspection or testing.

Signed-off-by: Christian Göttsche <cgzones <AT> googlemail.com>
Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org>

 Rules.monolithic | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/Rules.monolithic b/Rules.monolithic
index e369f8f3..d6d0e6f2 100644
--- a/Rules.monolithic
+++ b/Rules.monolithic
@@ -25,6 +25,7 @@ endif
 polbinpath := $(shell $(binary_policy_path))
 
 policy_conf = $(builddir)policy.conf
+policy_cil = $(builddir)policy.cil
 fc = $(builddir)file_contexts
 polver = $(builddir)policy.$(pv)
 homedir_template = $(builddir)homedir_template
@@ -83,6 +84,19 @@ ifneq ($(pv),$(kv))
 endif
        $(verbose) $(CHECKPOLICY) -U $(UNK_PERMS) -S -O -E $^ -o $@
 
+########################################
+#
+# Build a CIL policy locally
+#
+$(policy_cil): $(policy_conf)
+       @echo "Compiling $(NAME) $(policy_cil)"
+ifneq ($(pv),$(kv))
+       @echo
+       @echo "WARNING: Policy version mismatch (policy:$(pv) kernel:$(kv))!  
Is your OUTPUT_POLICY set correctly?"
+       @echo
+endif
+       $(verbose) $(CHECKPOLICY) -C -U $(UNK_PERMS) -S -O -E $^ -o $@
+
 ########################################
 #
 # Install a binary policy
@@ -261,6 +275,7 @@ $(installdir)/seusers: $(seusers)
 clean:
        $(verbose) rm -f $(policy_conf)
        $(verbose) rm -f $(polver)
+       $(verbose) rm -f $(policy_cil)
        $(verbose) rm -f $(fc)
        $(verbose) rm -f $(homedir_template)
        $(verbose) rm -f $(net_contexts) $(net_contexts_nft)

Reply via email to