[selinux-policy: 1208/3172] merge external modules makefile changes
Daniel J Walsh
dwalsh at fedoraproject.org
Thu Oct 7 20:49:21 UTC 2010
commit c9f20d5b0b5d525a078d3c7d9f638185c9daef95
Author: Chris PeBenito <cpebenito at tresys.com>
Date: Wed Feb 15 17:59:58 2006 +0000
merge external modules makefile changes
refpolicy/Makefile | 143 ++++++++++++++++++++++++++++++++------------
refpolicy/Rules.modular | 119 ++++++++++++++++++++-----------------
refpolicy/Rules.monolithic | 112 +++++++++++++++++-----------------
3 files changed, 225 insertions(+), 149 deletions(-)
---
diff --git a/refpolicy/Makefile b/refpolicy/Makefile
index 7e6228b..7501870 100644
--- a/refpolicy/Makefile
+++ b/refpolicy/Makefile
@@ -23,11 +23,31 @@
# NO OPTIONS BELOW HERE
#
-include build.conf
+# Top level directory - so make can be run from outside
+# of the tree (if this is overridden on the command line)
+ROOT ?= .
+
+# Include the local build.conf if it exists, otherwise
+# include the configuration of the root directory.
+ifndef LOCAL_ROOT
+ include $(ROOT)/build.conf
+else
+ include $(LOCAL_ROOT)/build.conf
+endif
# refpolicy version
VERSION = $(shell cat VERSION)
+ifdef LOCAL_ROOT
+BUILDDIR := $(LOCAL_ROOT)
+TMPDIR := $(LOCAL_ROOT)/tmp
+TAGS := $(LOCAL_ROOT)/tags
+else
+BUILDDIR := $(ROOT)
+TMPDIR := $(ROOT)/tmp
+TAGS := $(ROOT)/tags
+endif
+
# executable paths
BINDIR := /usr/bin
SBINDIR := /usr/sbin
@@ -52,38 +72,57 @@ SH ?= sh
CFLAGS += -Wall
# policy source layout
-POLDIR := policy
+POLDIR := $(ROOT)/policy
MODDIR := $(POLDIR)/modules
FLASKDIR := $(POLDIR)/flask
SECCLASS := $(FLASKDIR)/security_classes
ISIDS := $(FLASKDIR)/initial_sids
AVS := $(FLASKDIR)/access_vectors
+# local source layout
+ifdef LOCAL_ROOT
+LOCAL_POLDIR := $(LOCAL_ROOT)/policy
+LOCAL_MODDIR := $(LOCAL_POLDIR)/modules
+endif
+
# policy building support tools
-SUPPORT := support
+SUPPORT := $(ROOT)/support
GENXML := $(PYTHON) $(SUPPORT)/segenxml.py
GENDOC := $(PYTHON) $(SUPPORT)/sedoctool.py
GENPERM := $(PYTHON) $(SUPPORT)/genclassperms.py
-FCSORT := $(SUPPORT)/fc_sort
+FCSORT := $(TMPDIR)/fc_sort
SETTUN := $(SH) $(SUPPORT)/set_tunables
# documentation paths
-DOCS = doc
-POLXML = $(DOCS)/policy.xml
+DOCS = $(ROOT)/doc
XMLDTD = $(DOCS)/policy.dtd
LAYERXML = metadata.xml
-HTMLDIR = $(DOCS)/html
DOCTEMPLATE = $(DOCS)/templates
DOCFILES = $(DOCS)/Makefile.example $(addprefix $(DOCS)/,example.te example.if example.fc)
+ifndef LOCAL_ROOT
+POLXML = $(DOCS)/policy.xml
+HTMLDIR = $(DOCS)/html
+else
+POLXML = $(LOCAL_ROOT)/doc/policy.xml
+HTMLDIR = $(LOCAL_ROOT)/doc/html
+endif
+
# config file paths
GLOBALTUN = $(POLDIR)/global_tunables
GLOBALBOOL = $(POLDIR)/global_booleans
-MOD_CONF = $(POLDIR)/modules.conf
TUNABLES = $(POLDIR)/tunables.conf
-BOOLEANS = $(POLDIR)/booleans.conf
ROLEMAP = $(POLDIR)/rolemap
+# local config file paths
+ifndef LOCAL_ROOT
+MOD_CONF = $(POLDIR)/modules.conf
+BOOLEANS = $(POLDIR)/booleans.conf
+else
+MOD_CONF = $(LOCAL_POLDIR)/modules.conf
+BOOLEANS = $(LOCAL_POLDIR)/booleans.conf
+endif
+
# install paths
PKGNAME ?= refpolicy-$(VERSION)
PREFIX = $(DESTDIR)/usr
@@ -171,7 +210,7 @@ ifeq ($(KV),)
KV := $(PV)
endif
-M4SUPPORT = $(wildcard $(POLDIR)/support/*.spt)
+M4SUPPORT = $(wildcard $(POLDIR)/support/*.spt $(LOCAL_POLDIR)/support/*.spt)
APPCONF := config/appconfig-$(TYPE)
APPDIR := $(CONTEXTPATH)
@@ -180,6 +219,9 @@ CONTEXTFILES += $(wildcard $(APPCONF)/*_context*) $(APPCONF)/media
USER_FILES := $(POLDIR)/users
ALL_LAYERS := $(filter-out $(MODDIR)/CVS,$(shell find $(wildcard $(MODDIR)/*) -maxdepth 0 -type d))
+ifdef LOCAL_ROOT
+LOCAL_LAYERS := $(filter-out $(LOCAL_MODDIR)/CVS,$(shell find $(wildcard $(LOCAL_MODDIR)/*) -maxdepth 0 -type d))
+endif
GENERATED_TE := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te.in)))
GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in)))
@@ -198,10 +240,17 @@ MODMOD := module
# modules.conf setting for unused module
MODUNUSED := off
+# test for module overrides from command line
+MOD_TEST = $(filter $(APPS_OFF), $(APPS_ON) $(APPS_MODS))
+MOD_TEST += $(filter $(APPS_MODS), $(APPS_ON))
+ifneq ($(strip $(MOD_TEST)),)
+ $(error Applications must be on, module, or off, and not in more than one list! $(strip $(MOD_TEST)) found in multiple lists!)
+endif
+
# extract settings from modules.conf
-BASE_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null))
-MOD_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null))
-OFF_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null))
+BASE_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null) $(APPS_ON)))
+MOD_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null) $(APPS_MODS)))
+OFF_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null) $(APPS_OFF)))
# filesystems to be labeled
FILESYSTEMS = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';)
@@ -230,15 +279,17 @@ endef
#
ifeq ($(MONOLITHIC),y)
- include Rules.monolithic
+ include $(ROOT)/Rules.monolithic
else
- include Rules.modular
+ include $(ROOT)/Rules.modular
endif
########################################
#
# Generated files
#
+# NOTE: There is no "local" version of these files.
+#
$(MODDIR)/kernel/corenetwork.if: $(MODDIR)/kernel/corenetwork.if.m4 $(MODDIR)/kernel/corenetwork.if.in
@echo "#" > $@
@echo "# This is a generated file! Instead of modifying this file, the" >> $@
@@ -269,6 +320,13 @@ $(MOD_CONF) $(BOOLEANS): $(POLXML)
########################################
#
+# Generate the fc_sort program
+#
+$(FCSORT) : $(SUPPORT)/fc_sort.c
+ $(CC) $(CFLAGS) $(SUPPORT)/fc_sort.c -o $(FCSORT)
+
+########################################
+#
# Documentation generation
#
@@ -278,36 +336,38 @@ $(MOD_CONF) $(BOOLEANS): $(POLXML)
# enabled modules.
$(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML))
@echo "Creating $@"
- @mkdir -p tmp
+ @test -d $(dir $(POLXML)) || mkdir -p $(dir $(POLXML))
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) echo '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' > $@
$(verbose) echo '<!DOCTYPE policy SYSTEM "$(notdir $(XMLDTD))">' >> $@
- $(verbose) $(GENXML) -m $(LAYERXML) -t $(GLOBALTUN) -b $(GLOBALBOOL) -o tmp $(ALL_LAYERS) >> $@
+ $(verbose) $(GENXML) -m $(LAYERXML) -t $(GLOBALTUN) -b $(GLOBALBOOL) -o $(TMPDIR) $(ALL_LAYERS) $(LOCAL_LAYERS) >> $@
$(verbose) if test -x $(XMLLINT) && test -f $(XMLDTD); then \
- $(XMLLINT) --noout --dtdvalid $(XMLDTD) $@ ;\
+ $(XMLLINT) --noout --path $(dir $(XMLDTD)) --dtdvalid $(XMLDTD) $@ ;\
fi
-html tmp/html: $(POLXML)
+html $(TMPDIR)/html: $(POLXML)
@echo "Building html interface reference documentation in $(HTMLDIR)"
- @mkdir -p $(HTMLDIR)
+ @test -d $(HTMLDIR) || mkdir -p $(HTMLDIR)
$(verbose) $(GENDOC) -d $(HTMLDIR) -T $(DOCTEMPLATE) -x $(POLXML)
$(verbose) cp $(DOCTEMPLATE)/*.css $(HTMLDIR)
- @touch tmp/html
+ @touch $(TMPDIR)/html
########################################
#
# Runtime binary policy patching of users
#
-$(USERPATH)/system.users: $(M4SUPPORT) tmp/generated_definitions.conf $(USER_FILES)
+$(USERPATH)/system.users: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(USER_FILES)
+ @mkdir -p $(TMPDIR)
@mkdir -p $(USERPATH)
@echo "Installing system.users"
- @echo "# " > tmp/system.users
- @echo "# Do not edit this file. " >> tmp/system.users
- @echo "# This file is replaced on reinstalls of this policy." >> tmp/system.users
- @echo "# Please edit local.users to make local changes." >> tmp/system.users
- @echo "#" >> tmp/system.users
+ @echo "# " > $(TMPDIR)/system.users
+ @echo "# Do not edit this file. " >> $(TMPDIR)/system.users
+ @echo "# This file is replaced on reinstalls of this policy." >> $(TMPDIR)/system.users
+ @echo "# Please edit local.users to make local changes." >> $(TMPDIR)/system.users
+ @echo "#" >> $(TMPDIR)/system.users
$(verbose) m4 -D self_contained_policy $(M4PARAM) $^ | sed -r -e 's/^[[:blank:]]+//' \
- -e '/^[[:blank:]]*($$|#)/d' >> tmp/system.users
- $(verbose) install -m 644 tmp/system.users $@
+ -e '/^[[:blank:]]*($$|#)/d' >> $(TMPDIR)/system.users
+ $(verbose) install -m 644 $(TMPDIR)/system.users $@
$(USERPATH)/local.users: config/local.users
@mkdir -p $(USERPATH)
@@ -321,10 +381,11 @@ $(USERPATH)/local.users: config/local.users
install-appconfig: $(APPFILES)
$(INSTALLDIR)/booleans: $(BOOLEANS)
+ @mkdir -p $(TMPDIR)
@mkdir -p $(INSTALLDIR)
$(verbose) sed -r -e 's/false/0/g' -e 's/true/1/g' \
- -e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > tmp/booleans
- $(verbose) install -m 644 tmp/booleans $@
+ -e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > $(TMPDIR)/booleans
+ $(verbose) install -m 644 $(TMPDIR)/booleans $@
$(CONTEXTPATH)/files/media: $(APPCONF)/media
@mkdir -p $(CONTEXTPATH)/files/
@@ -366,10 +427,10 @@ $(APPDIR)/users/root: $(APPCONF)/root_default_contexts
#
# Install policy headers
#
-install-headers: doc/policy.xml
+install-headers: $(POLXML)
@mkdir -p $(HEADERDIR)
@echo "Installing policy headers"
- $(verbose) install -m 644 tmp/global_{tunables,booleans}.xml $(HEADERDIR)
+ $(verbose) install -m 644 $(TMPDIR)/global_{tunables,booleans}.xml $(HEADERDIR)
$(verbose) m4 $(M4PARAM) $(ROLEMAP) > $(HEADERDIR)/$(notdir $(ROLEMAP))
$(verbose) mkdir -p $(HEADERDIR)/support
$(verbose) install -m 644 $(M4SUPPORT) $(GENXML) $(XMLDTD) $(HEADERDIR)/support
@@ -394,7 +455,7 @@ endif
#
# Install policy documentation
#
-install-docs: tmp/html
+install-docs: $(TMPDIR)/html
@mkdir -p $(DOCSDIR)/html
@echo "Installing policy documentation"
$(verbose) install -m 644 $(DOCFILES) $(DOCSDIR)
@@ -414,9 +475,10 @@ install-src:
#
# Generate tags file
#
-tags:
+tags: $(TAGS)
+$(TAGS):
@($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1)
- @LC_ALL=C $(CTAGS) --langdef=te --langmap=te:..te.if.spt \
+ @LC_ALL=C $(CTAGS) -f $(TAGS) --langdef=te --langmap=te:..te.if.spt \
--regex-te='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \
--regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \
--regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \
@@ -466,12 +528,14 @@ resetlabels:
#
bare: clean
rm -f $(POLXML)
- rm -f $(SUPPORT)/*.pyc
- rm -f $(FCSORT)
rm -f $(MOD_CONF)
rm -f $(BOOLEANS)
rm -fR $(HTMLDIR)
- rm -f tags
+ rm -f $(TAGS)
+# don't remove these files if we're given a local root
+ifndef LOCAL_ROOT
+ rm -f $(FCSORT)
+ rm -f $(SUPPORT)/*.pyc
ifneq ($(GENERATED_TE),)
rm -f $(GENERATED_TE)
endif
@@ -481,6 +545,7 @@ endif
ifneq ($(GENERATED_FC),)
rm -f $(GENERATED_FC)
endif
+endif
.PHONY: install-src install-appconfig conf html bare tags
.SUFFIXES:
diff --git a/refpolicy/Rules.modular b/refpolicy/Rules.modular
index 959cc29..5ac2fe4 100644
--- a/refpolicy/Rules.modular
+++ b/refpolicy/Rules.modular
@@ -6,10 +6,12 @@
ALL_MODULES := $(BASE_MODS) $(MOD_MODS) $(OFF_MODS)
ALL_INTERFACES := $(ALL_MODULES:.te=.if)
-BASE_PKG := base.pp
-BASE_FC := base.fc
+BASE_PKG := $(BUILDDIR)/base.pp
+BASE_FC := $(BUILDDIR)/base.fc
+BASE_CONF := $(BUILDDIR)/base.conf
+BASE_MOD := $(TMPDIR)/base.mod
-BASE_SECTIONS := tmp/pre_te_files.conf tmp/generated_definitions.conf tmp/all_interfaces.conf tmp/all_attrs_types.conf $(GLOBALBOOL) $(GLOBALTUN) tmp/only_te_rules.conf tmp/all_post.conf
+BASE_SECTIONS := $(TMPDIR)/pre_te_files.conf $(TMPDIR)/generated_definitions.conf $(TMPDIR)/all_interfaces.conf $(TMPDIR)/all_attrs_types.conf $(GLOBALBOOL) $(GLOBALTUN) $(TMPDIR)/only_te_rules.conf $(TMPDIR)/all_post.conf
BASE_PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls $(POLDIR)/mcs
BASE_TE_FILES := $(BASE_MODS)
@@ -17,15 +19,15 @@ BASE_POST_TE_FILES := $(USER_FILES) $(POLDIR)/constraints
BASE_FC_FILES := $(BASE_MODS:.te=.fc)
MOD_MODULES := $(MOD_MODS:.te=.mod)
-MOD_PKGS := $(MOD_MODS:.te=.pp)
+MOD_PKGS := $(addprefix $(BUILDDIR)/,$(notdir $(MOD_MODS:.te=.pp)))
# policy packages to install
-INSTPKG := $(addprefix $(MODPKGDIR)/,$(BASE_PKG) $(MOD_PKGS))
+INSTPKG := $(addprefix $(MODPKGDIR)/,$(notdir $(BASE_PKG)) $(MOD_PKGS))
# search layer dirs for source files
-vpath %.te $(ALL_LAYERS)
-vpath %.if $(ALL_LAYERS)
-vpath %.fc $(ALL_LAYERS)
+vpath %.te $(ALL_LAYERS) $(LOCAL_LAYERS)
+vpath %.if $(ALL_LAYERS) $(LOCAL_LAYERS)
+vpath %.fc $(ALL_LAYERS) $(LOCAL_LAYERS)
.SECONDARY:
@@ -49,13 +51,13 @@ install: $(INSTPKG) $(APPFILES)
#
load: $(INSTPKG) $(APPFILES)
@echo "Loading configured modules."
- $(verbose) $(SEMODULE) -s $(NAME) -b $(MODPKGDIR)/$(BASE_PKG) $(foreach mod,$(MOD_PKGS),-i $(MODPKGDIR)/$(mod))
+ $(verbose) $(SEMODULE) -s $(NAME) -b $(MODPKGDIR)/$(notdir $(BASE_PKG)) $(foreach mod,$(MOD_PKGS),-i $(MODPKGDIR)/$(mod))
########################################
#
# Install policy packages
#
-$(MODPKGDIR)/%.pp: %.pp
+$(MODPKGDIR)/%.pp: $(BUILDDIR)/%.pp
@mkdir -p $(MODPKGDIR)
@echo "Installing $(NAME) $(@F) policy package."
$(verbose) install -m 0644 $^ $(MODPKGDIR)
@@ -64,28 +66,32 @@ $(MODPKGDIR)/%.pp: %.pp
#
# Build module packages
#
-tmp/%.mod: $(M4SUPPORT) tmp/generated_definitions.conf tmp/all_interfaces.conf %.te
+$(TMPDIR)/%.mod: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(TMPDIR)/all_interfaces.conf %.te
@echo "Compliling $(NAME) $(@F) module"
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(call peruser-expansion,$(basename $(@F)),$@.role)
$(verbose) m4 $(M4PARAM) -s $^ $@.role > $(@:.mod=.tmp)
$(verbose) $(CHECKMODULE) -m $(@:.mod=.tmp) -o $@
-tmp/%.mod.fc: $(M4SUPPORT) %.fc
+$(TMPDIR)/%.mod.fc: $(M4SUPPORT) %.fc
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $(M4PARAM) $(M4SUPPORT) $^ > $@
-%.pp: tmp/%.mod tmp/%.mod.fc
+$(BUILDDIR)/%.pp: $(TMPDIR)/%.mod $(TMPDIR)/%.mod.fc
@echo "Creating $(NAME) $(@F) policy package"
+ @test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
$(verbose) $(SEMOD_PKG) -o $@ -m $< -f $<.fc
########################################
#
# Create a base module package
#
-$(BASE_PKG): tmp/base.mod $(BASE_FC)
+$(BASE_PKG): $(BASE_MOD) $(BASE_FC)
@echo "Creating $(NAME) base module package"
- $(verbose) $(SEMOD_PKG) -o $@ -m tmp/base.mod -f $(BASE_FC)
+ @test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
+ $(verbose) $(SEMOD_PKG) -o $@ -m $(BASE_MOD) -f $(BASE_FC)
-tmp/base.mod: base.conf
+$(BASE_MOD): $(BASE_CONF)
@echo "Compiling $(NAME) base module"
$(verbose) $(CHECKMODULE) $^ -o $@
@@ -93,22 +99,24 @@ tmp/base.mod: base.conf
#
# Construct a base.conf
#
-base.conf: $(BASE_SECTIONS)
- @echo "Creating $(NAME) base module base.conf"
+$(BASE_CONF): $(BASE_SECTIONS)
+ @echo "Creating $(NAME) base module $(BASE_CONF)"
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
+ @test -d $(dir $(BASE_CONF)) || mkdir -p $(dir $(BASE_CONF))
# checkpolicy can use the #line directives provided by -s for error reporting:
- $(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > tmp/$@.tmp
- $(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < tmp/$@.tmp > $@
+ $(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > $(TMPDIR)/$(@F).tmp
+ $(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < $(TMPDIR)/$(@F).tmp > $@
# the ordering of these ocontexts matters:
- $(verbose) grep ^portcon tmp/$@.tmp >> $@ || true
- $(verbose) grep ^netifcon tmp/$@.tmp >> $@ || true
- $(verbose) grep ^nodecon tmp/$@.tmp >> $@ || true
+ $(verbose) grep ^portcon $(TMPDIR)/$(@F).tmp >> $@ || true
+ $(verbose) grep ^netifcon $(TMPDIR)/$(@F).tmp >> $@ || true
+ $(verbose) grep ^nodecon $(TMPDIR)/$(@F).tmp >> $@ || true
-tmp/pre_te_files.conf: $(BASE_PRE_TE_FILES)
- @test -d tmp || mkdir -p tmp
+$(TMPDIR)/pre_te_files.conf: $(BASE_PRE_TE_FILES)
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@
-tmp/generated_definitions.conf: $(BASE_TE_FILES)
- @test -d tmp || mkdir -p tmp
+$(TMPDIR)/generated_definitions.conf: $(BASE_TE_FILES)
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
# define all available object classes
$(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $@
# per-userdomain templates
@@ -124,81 +132,82 @@ tmp/generated_definitions.conf: $(BASE_TE_FILES)
done
$(verbose) $(SETTUN) $(BOOLEANS) >> $@
-tmp/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
+$(TMPDIR)/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
ifeq ($(ALL_INTERFACES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif
- @test -d tmp || mkdir -p tmp
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@
-tmp/all_te_files.conf: $(BASE_TE_FILES)
+$(TMPDIR)/all_te_files.conf: $(BASE_TE_FILES)
ifeq ($(BASE_TE_FILES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif
- @test -d tmp || mkdir -p tmp
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@
$(call parse-rolemap,base,$@)
-tmp/post_te_files.conf: $(BASE_POST_TE_FILES)
- @test -d tmp || mkdir -p tmp
+$(TMPDIR)/post_te_files.conf: $(BASE_POST_TE_FILES)
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@
# extract attributes and put them first. extract post te stuff
# like genfscon and put last. portcon, nodecon, and netifcon
# is delayed since they are generated by m4
-tmp/all_attrs_types.conf tmp/only_te_rules.conf tmp/all_post.conf: tmp/all_te_files.conf tmp/post_te_files.conf
- $(verbose) grep ^attribute tmp/all_te_files.conf > tmp/all_attrs_types.conf || true
- $(verbose) grep '^type ' tmp/all_te_files.conf >> tmp/all_attrs_types.conf
- $(verbose) cat tmp/post_te_files.conf > tmp/all_post.conf
- $(verbose) grep '^sid ' tmp/all_te_files.conf >> tmp/all_post.conf || true
- $(verbose) egrep '^fs_use_(xattr|task|trans)' tmp/all_te_files.conf >> tmp/all_post.conf || true
- $(verbose) grep ^genfscon tmp/all_te_files.conf >> tmp/all_post.conf || true
+$(TMPDIR)/all_attrs_types.conf $(TMPDIR)/only_te_rules.conf $(TMPDIR)/all_post.conf: $(TMPDIR)/all_te_files.conf $(TMPDIR)/post_te_files.conf
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
+ $(verbose) grep ^attribute $(TMPDIR)/all_te_files.conf > $(TMPDIR)/all_attrs_types.conf || true
+ $(verbose) grep '^type ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_attrs_types.conf
+ $(verbose) cat $(TMPDIR)/post_te_files.conf > $(TMPDIR)/all_post.conf
+ $(verbose) grep '^sid ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
+ $(verbose) egrep '^fs_use_(xattr|task|trans)' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
+ $(verbose) grep ^genfscon $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
$(verbose) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
-e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/d' \
- < tmp/all_te_files.conf > tmp/only_te_rules.conf
+ < $(TMPDIR)/all_te_files.conf > $(TMPDIR)/only_te_rules.conf
########################################
#
# Construct a base.fc
#
-$(BASE_FC): tmp/$(BASE_FC).tmp $(FCSORT)
+$(BASE_FC): $(TMPDIR)/$(notdir $(BASE_FC)).tmp $(FCSORT)
$(verbose) $(FCSORT) $< $@
-tmp/$(BASE_FC).tmp: $(M4SUPPORT) tmp/generated_definitions.conf $(BASE_FC_FILES)
+$(TMPDIR)/$(notdir $(BASE_FC)).tmp: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(BASE_FC_FILES)
ifeq ($(BASE_FC_FILES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif
@echo "Creating $(NAME) base module file contexts."
- @test -d tmp || mkdir -p tmp
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $(M4PARAM) $^ > $@
########################################
#
# Remove the dontaudit rules from the base.conf
#
-enableaudit: base.conf
- @test -d tmp || mkdir -p tmp
- @echo "Removing dontaudit rules from base.conf"
- $(verbose) grep -v dontaudit base.conf > tmp/base.audit
- $(verbose) mv tmp/base.audit base.conf
+enableaudit: $(BASE_CONF)
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
+ @echo "Removing dontaudit rules from $(BASE_CONF)"
+ $(verbose) grep -v dontaudit $(BASE_CONF) > $(TMPDIR)/base.audit
+ $(verbose) mv $(TMPDIR)/base.audit $(BASE_CONF)
########################################
#
# Appconfig files
#
-$(APPDIR)/customizable_types: base.conf
+$(APPDIR)/customizable_types: $(BASE_CONF)
@mkdir -p $(APPDIR)
- $(verbose) grep "^type .*customizable" $< | cut -d',' -f1 | cut -d' ' -f2 > tmp/customizable_types
- $(verbose) install -m 644 tmp/customizable_types $@
+ $(verbose) grep "^type .*customizable" $< | cut -d',' -f1 | cut -d' ' -f2 > $(TMPDIR)/customizable_types
+ $(verbose) install -m 644 $(TMPDIR)/customizable_types $@
########################################
#
# Clean the sources
#
clean:
- rm -f base.conf
- rm -f *.pp
+ rm -f $(BASE_CONF)
rm -f $(BASE_FC)
- rm -fR tmp
+ rm -f $(BUILDDIR)/*.pp
+ rm -fR $(TMPDIR)
.PHONY: default all base modules install load clean
diff --git a/refpolicy/Rules.monolithic b/refpolicy/Rules.monolithic
index 3d12093..b345ed4 100644
--- a/refpolicy/Rules.monolithic
+++ b/refpolicy/Rules.monolithic
@@ -3,14 +3,16 @@
# Rules and Targets for building monolithic policies
#
+POLICY_CONF = $(BUILDDIR)/policy.conf
+FC = $(BUILDDIR)/file_contexts
+POLVER = policy.$(PV)
+HOMEDIR_TEMPLATE = $(BUILDDIR)/homedir_template
+
# install paths
POLICYPATH = $(INSTALLDIR)/policy
LOADPATH = $(POLICYPATH)/$(POLVER)
HOMEDIRPATH = $(CONTEXTPATH)/files/homedir_template
-FC := file_contexts
-POLVER := policy.$(PV)
-
APPFILES += $(INSTALLDIR)/booleans
# for monolithic policy use all base and module to create policy
@@ -23,14 +25,12 @@ ALL_FC_FILES := $(ALL_MODULES:.te=.fc)
PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls $(POLDIR)/mcs
POST_TE_FILES := $(USER_FILES) $(POLDIR)/constraints
-POLICY_SECTIONS := tmp/pre_te_files.conf tmp/generated_definitions.conf tmp/all_interfaces.conf tmp/all_attrs_types.conf $(GLOBALBOOL) $(GLOBALTUN) tmp/only_te_rules.conf tmp/all_post.conf
-
-HOMEDIR_TEMPLATE = homedir_template
+POLICY_SECTIONS := $(TMPDIR)/pre_te_files.conf $(TMPDIR)/generated_definitions.conf $(TMPDIR)/all_interfaces.conf $(TMPDIR)/all_attrs_types.conf $(GLOBALBOOL) $(GLOBALTUN) $(TMPDIR)/only_te_rules.conf $(TMPDIR)/all_post.conf
# search layer dirs for source files
-vpath %.te $(ALL_LAYERS)
-vpath %.if $(ALL_LAYERS)
-vpath %.fc $(ALL_LAYERS)
+vpath %.te $(ALL_LAYERS) $(LOCAL_LAYERS)
+vpath %.if $(ALL_LAYERS) $(LOCAL_LAYERS)
+vpath %.fc $(ALL_LAYERS) $(LOCAL_LAYERS)
########################################
#
@@ -42,7 +42,7 @@ policy: $(POLVER)
install: $(LOADPATH) $(FCPATH) $(APPFILES) $(USERPATH)/local.users
-load: tmp/load
+load: $(TMPDIR)/load
checklabels: $(FCPATH)
restorelabels: $(FCPATH)
@@ -53,20 +53,20 @@ resetlabels: $(FCPATH)
#
# Build a binary policy locally
#
-$(POLVER): policy.conf
+$(POLVER): $(POLICY_CONF)
@echo "Compiling $(NAME) $(POLVER)"
ifneq ($(PV),$(KV))
@echo
@echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?"
@echo
endif
- $(verbose) $(CHECKPOLICY) $^ -o $@
+ $(verbose) $(CHECKPOLICY) $^ -o $(BUILDDIR)/$@
########################################
#
# Install a binary policy
#
-$(LOADPATH): policy.conf
+$(LOADPATH): $(POLICY_CONF)
@mkdir -p $(POLICYPATH)
@echo "Compiling and installing $(NAME) $(LOADPATH)"
ifneq ($(PV),$(KV))
@@ -80,32 +80,34 @@ endif
#
# Load the binary policy
#
-reload tmp/load: $(LOADPATH) $(FCPATH) $(APPFILES)
+reload $(TMPDIR)/load: $(LOADPATH) $(FCPATH) $(APPFILES)
@echo "Loading $(NAME) $(LOADPATH)"
$(verbose) $(LOADPOLICY) -q $(LOADPATH)
- @touch tmp/load
+ @touch $(TMPDIR)/load
########################################
#
# Construct a monolithic policy.conf
#
-policy.conf: $(POLICY_SECTIONS)
- @echo "Creating $(NAME) policy.conf"
+$(POLICY_CONF): $(POLICY_SECTIONS)
+ @echo "Creating $(NAME) $(@F)"
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
+ @test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
# checkpolicy can use the #line directives provided by -s for error reporting:
- $(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > tmp/$@.tmp
- $(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < tmp/$@.tmp > $@
+ $(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > $(TMPDIR)/$(@F).tmp
+ $(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < $(TMPDIR)/$(@F).tmp > $@
# the ordering of these ocontexts matters:
- $(verbose) grep ^portcon tmp/$@.tmp >> $@ || true
- $(verbose) grep ^netifcon tmp/$@.tmp >> $@ || true
- $(verbose) grep ^nodecon tmp/$@.tmp >> $@ || true
+ $(verbose) grep ^portcon $(TMPDIR)/$(@F).tmp >> $@ || true
+ $(verbose) grep ^netifcon $(TMPDIR)/$(@F).tmp >> $@ || true
+ $(verbose) grep ^nodecon $(TMPDIR)/$(@F).tmp >> $@ || true
-tmp/pre_te_files.conf: $(PRE_TE_FILES)
- @test -d tmp || mkdir -p tmp
+$(TMPDIR)/pre_te_files.conf: $(PRE_TE_FILES)
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@
-tmp/generated_definitions.conf: $(ALL_TE_FILES)
+$(TMPDIR)/generated_definitions.conf: $(ALL_LAYERS) $(ALL_TE_FILES)
# per-userdomain templates:
- @test -d tmp || mkdir -p tmp
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) echo "define(\`base_per_userdomain_template',\`" > $@
$(verbose) for i in $(patsubst %.te,%,$(notdir $(ALL_MODULES))); do \
echo "ifdef(\`""$$i""_per_userdomain_template',\`""$$i""_per_userdomain_template("'$$*'")')" \
@@ -118,64 +120,64 @@ tmp/generated_definitions.conf: $(ALL_TE_FILES)
done
$(verbose) $(SETTUN) $(BOOLEANS) >> $@
-tmp/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
+$(TMPDIR)/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
ifeq ($(ALL_INTERFACES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif
- @test -d tmp || mkdir -p tmp
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@
-tmp/all_te_files.conf: $(ALL_TE_FILES)
+$(TMPDIR)/all_te_files.conf: $(ALL_TE_FILES)
ifeq ($(ALL_TE_FILES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif
- @test -d tmp || mkdir -p tmp
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@
$(call parse-rolemap,base,$@)
-tmp/post_te_files.conf: $(POST_TE_FILES)
- @test -d tmp || mkdir -p tmp
+$(TMPDIR)/post_te_files.conf: $(POST_TE_FILES)
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@
# extract attributes and put them first. extract post te stuff
# like genfscon and put last. portcon, nodecon, and netifcon
# is delayed since they are generated by m4
-tmp/all_attrs_types.conf tmp/only_te_rules.conf tmp/all_post.conf: tmp/all_te_files.conf tmp/post_te_files.conf
- $(verbose) grep ^attribute tmp/all_te_files.conf > tmp/all_attrs_types.conf || true
- $(verbose) grep '^type ' tmp/all_te_files.conf >> tmp/all_attrs_types.conf
- $(verbose) cat tmp/post_te_files.conf > tmp/all_post.conf
- $(verbose) grep '^sid ' tmp/all_te_files.conf >> tmp/all_post.conf || true
- $(verbose) egrep '^fs_use_(xattr|task|trans)' tmp/all_te_files.conf >> tmp/all_post.conf || true
- $(verbose) grep ^genfscon tmp/all_te_files.conf >> tmp/all_post.conf || true
+$(TMPDIR)/all_attrs_types.conf $(TMPDIR)/only_te_rules.conf $(TMPDIR)/all_post.conf: $(TMPDIR)/all_te_files.conf $(TMPDIR)/post_te_files.conf
+ $(verbose) grep ^attribute $(TMPDIR)/all_te_files.conf > $(TMPDIR)/all_attrs_types.conf || true
+ $(verbose) grep '^type ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_attrs_types.conf
+ $(verbose) cat $(TMPDIR)/post_te_files.conf > $(TMPDIR)/all_post.conf
+ $(verbose) grep '^sid ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
+ $(verbose) egrep '^fs_use_(xattr|task|trans)' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
+ $(verbose) grep ^genfscon $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
$(verbose) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
-e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/d' \
- < tmp/all_te_files.conf > tmp/only_te_rules.conf
+ < $(TMPDIR)/all_te_files.conf > $(TMPDIR)/only_te_rules.conf
########################################
#
# Remove the dontaudit rules from the policy.conf
#
-enableaudit: policy.conf
- @test -d tmp || mkdir -p tmp
- @echo "Removing dontaudit rules from policy.conf"
- $(verbose) grep -v dontaudit policy.conf > tmp/policy.audit
- $(verbose) mv tmp/policy.audit policy.conf
+enableaudit: $(POLICY_CONF)
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
+ @echo "Removing dontaudit rules from $(notdir $(POLICY_CONF))"
+ $(verbose) grep -v dontaudit @^ > $(TMPDIR)/policy.audit
+ $(verbose) mv $(TMPDIR)/policy.audit $(POLICY_CONF)
########################################
#
# Construct file_contexts
#
-$(FC): tmp/$(FC).tmp $(FCSORT)
+$(FC): $(TMPDIR)/$(notdir $(FC)).tmp $(FCSORT)
$(verbose) $(FCSORT) $< $@
$(verbose) grep -e HOME -e ROLE $@ > $(HOMEDIR_TEMPLATE)
$(verbose) sed -i -e /HOME/d -e /ROLE/d $@
-tmp/$(FC).tmp: $(M4SUPPORT) tmp/generated_definitions.conf $(ALL_FC_FILES)
+$(TMPDIR)/$(notdir $(FC)).tmp: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(ALL_FC_FILES)
ifeq ($(ALL_FC_FILES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif
@echo "Creating $(NAME) file_contexts."
- @test -d tmp || mkdir -p tmp
+ @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $(M4PARAM) $^ > $@
########################################
@@ -195,11 +197,11 @@ $(FCPATH): $(FC) $(LOADPATH) $(USERPATH)/system.users
#
# Run policy source checks
#
-check: policy.conf $(FC)
- $(SECHECK) -s --profile=development --policy=policy.conf --fcfile=$(FC) > $@.res
+check: $(POLICY_CONF) $(FC)
+ $(SECHECK) -s --profile=development --policy=$(POLICY_CONF) --fcfile=$(FC) > $(BUILDDIR)/$@.res
-longcheck: policy.conf $(FC)
- $(SECHECK) -s --profile=all --policy=policy.conf --fcfile=$(FC) > $@.res
+longcheck: $(POLICY_CONF) $(FC)
+ $(SECHECK) -s --profile=all --policy=$(POLICY_CONF) --fcfile=$(FC) > $(BUILDDIR)/$@.res
########################################
#
@@ -215,11 +217,11 @@ $(APPDIR)/customizable_types: policy.conf
# Clean the sources
#
clean:
- rm -f policy.conf
- rm -f policy.$(PV)
+ rm -f $(POLICY_CONF)
+ rm -f $(BUILDDIR)/policy.$(PV)
rm -f $(FC)
rm -f $(HOMEDIR_TEMPLATE)
rm -f *.res
- rm -fR tmp
+ rm -fR $(TMPDIR)
.PHONY: default policy install load reload enableaudit checklabels restorelabels relabel check longcheck clean
More information about the scm-commits
mailing list