merge external modules makefile changes

This commit is contained in:
Chris PeBenito 2006-02-15 17:59:58 +00:00
parent 24a63797d7
commit c9f20d5b0b
3 changed files with 225 additions and 149 deletions

View File

@ -23,11 +23,31 @@
# NO OPTIONS BELOW HERE # 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 # refpolicy version
VERSION = $(shell cat 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 # executable paths
BINDIR := /usr/bin BINDIR := /usr/bin
SBINDIR := /usr/sbin SBINDIR := /usr/sbin
@ -52,38 +72,57 @@ SH ?= sh
CFLAGS += -Wall CFLAGS += -Wall
# policy source layout # policy source layout
POLDIR := policy POLDIR := $(ROOT)/policy
MODDIR := $(POLDIR)/modules MODDIR := $(POLDIR)/modules
FLASKDIR := $(POLDIR)/flask FLASKDIR := $(POLDIR)/flask
SECCLASS := $(FLASKDIR)/security_classes SECCLASS := $(FLASKDIR)/security_classes
ISIDS := $(FLASKDIR)/initial_sids ISIDS := $(FLASKDIR)/initial_sids
AVS := $(FLASKDIR)/access_vectors 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 # policy building support tools
SUPPORT := support SUPPORT := $(ROOT)/support
GENXML := $(PYTHON) $(SUPPORT)/segenxml.py GENXML := $(PYTHON) $(SUPPORT)/segenxml.py
GENDOC := $(PYTHON) $(SUPPORT)/sedoctool.py GENDOC := $(PYTHON) $(SUPPORT)/sedoctool.py
GENPERM := $(PYTHON) $(SUPPORT)/genclassperms.py GENPERM := $(PYTHON) $(SUPPORT)/genclassperms.py
FCSORT := $(SUPPORT)/fc_sort FCSORT := $(TMPDIR)/fc_sort
SETTUN := $(SH) $(SUPPORT)/set_tunables SETTUN := $(SH) $(SUPPORT)/set_tunables
# documentation paths # documentation paths
DOCS = doc DOCS = $(ROOT)/doc
POLXML = $(DOCS)/policy.xml
XMLDTD = $(DOCS)/policy.dtd XMLDTD = $(DOCS)/policy.dtd
LAYERXML = metadata.xml LAYERXML = metadata.xml
HTMLDIR = $(DOCS)/html
DOCTEMPLATE = $(DOCS)/templates DOCTEMPLATE = $(DOCS)/templates
DOCFILES = $(DOCS)/Makefile.example $(addprefix $(DOCS)/,example.te example.if example.fc) 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 # config file paths
GLOBALTUN = $(POLDIR)/global_tunables GLOBALTUN = $(POLDIR)/global_tunables
GLOBALBOOL = $(POLDIR)/global_booleans GLOBALBOOL = $(POLDIR)/global_booleans
MOD_CONF = $(POLDIR)/modules.conf
TUNABLES = $(POLDIR)/tunables.conf TUNABLES = $(POLDIR)/tunables.conf
BOOLEANS = $(POLDIR)/booleans.conf
ROLEMAP = $(POLDIR)/rolemap 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 # install paths
PKGNAME ?= refpolicy-$(VERSION) PKGNAME ?= refpolicy-$(VERSION)
PREFIX = $(DESTDIR)/usr PREFIX = $(DESTDIR)/usr
@ -171,7 +210,7 @@ ifeq ($(KV),)
KV := $(PV) KV := $(PV)
endif endif
M4SUPPORT = $(wildcard $(POLDIR)/support/*.spt) M4SUPPORT = $(wildcard $(POLDIR)/support/*.spt $(LOCAL_POLDIR)/support/*.spt)
APPCONF := config/appconfig-$(TYPE) APPCONF := config/appconfig-$(TYPE)
APPDIR := $(CONTEXTPATH) APPDIR := $(CONTEXTPATH)
@ -180,6 +219,9 @@ CONTEXTFILES += $(wildcard $(APPCONF)/*_context*) $(APPCONF)/media
USER_FILES := $(POLDIR)/users USER_FILES := $(POLDIR)/users
ALL_LAYERS := $(filter-out $(MODDIR)/CVS,$(shell find $(wildcard $(MODDIR)/*) -maxdepth 0 -type d)) 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_TE := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te.in)))
GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in))) GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in)))
@ -198,10 +240,17 @@ MODMOD := module
# modules.conf setting for unused module # modules.conf setting for unused module
MODUNUSED := off 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 # extract settings from modules.conf
BASE_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") 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,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)) 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,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null)) 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 to be labeled
FILESYSTEMS = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';) 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) ifeq ($(MONOLITHIC),y)
include Rules.monolithic include $(ROOT)/Rules.monolithic
else else
include Rules.modular include $(ROOT)/Rules.modular
endif endif
######################################## ########################################
# #
# Generated files # 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 $(MODDIR)/kernel/corenetwork.if: $(MODDIR)/kernel/corenetwork.if.m4 $(MODDIR)/kernel/corenetwork.if.in
@echo "#" > $@ @echo "#" > $@
@echo "# This is a generated file! Instead of modifying this file, the" >> $@ @echo "# This is a generated file! Instead of modifying this file, the" >> $@
@ -267,6 +318,13 @@ $(MOD_CONF) $(BOOLEANS): $(POLXML)
@echo "Updating $(MOD_CONF) and $(BOOLEANS)" @echo "Updating $(MOD_CONF) and $(BOOLEANS)"
$(verbose) $(GENDOC) -t $(BOOLEANS) -m $(MOD_CONF) -x $(POLXML) $(verbose) $(GENDOC) -t $(BOOLEANS) -m $(MOD_CONF) -x $(POLXML)
########################################
#
# Generate the fc_sort program
#
$(FCSORT) : $(SUPPORT)/fc_sort.c
$(CC) $(CFLAGS) $(SUPPORT)/fc_sort.c -o $(FCSORT)
######################################## ########################################
# #
# Documentation generation # Documentation generation
@ -278,36 +336,38 @@ $(MOD_CONF) $(BOOLEANS): $(POLXML)
# enabled modules. # enabled modules.
$(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML)) $(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML))
@echo "Creating $@" @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 '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' > $@
$(verbose) echo '<!DOCTYPE policy SYSTEM "$(notdir $(XMLDTD))">' >> $@ $(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 \ $(verbose) if test -x $(XMLLINT) && test -f $(XMLDTD); then \
$(XMLLINT) --noout --dtdvalid $(XMLDTD) $@ ;\ $(XMLLINT) --noout --path $(dir $(XMLDTD)) --dtdvalid $(XMLDTD) $@ ;\
fi fi
html tmp/html: $(POLXML) html $(TMPDIR)/html: $(POLXML)
@echo "Building html interface reference documentation in $(HTMLDIR)" @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) $(GENDOC) -d $(HTMLDIR) -T $(DOCTEMPLATE) -x $(POLXML)
$(verbose) cp $(DOCTEMPLATE)/*.css $(HTMLDIR) $(verbose) cp $(DOCTEMPLATE)/*.css $(HTMLDIR)
@touch tmp/html @touch $(TMPDIR)/html
######################################## ########################################
# #
# Runtime binary policy patching of users # 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) @mkdir -p $(USERPATH)
@echo "Installing system.users" @echo "Installing system.users"
@echo "# " > tmp/system.users @echo "# " > $(TMPDIR)/system.users
@echo "# Do not edit this file. " >> tmp/system.users @echo "# Do not edit this file. " >> $(TMPDIR)/system.users
@echo "# This file is replaced on reinstalls of this policy." >> tmp/system.users @echo "# This file is replaced on reinstalls of this policy." >> $(TMPDIR)/system.users
@echo "# Please edit local.users to make local changes." >> tmp/system.users @echo "# Please edit local.users to make local changes." >> $(TMPDIR)/system.users
@echo "#" >> tmp/system.users @echo "#" >> $(TMPDIR)/system.users
$(verbose) m4 -D self_contained_policy $(M4PARAM) $^ | sed -r -e 's/^[[:blank:]]+//' \ $(verbose) m4 -D self_contained_policy $(M4PARAM) $^ | sed -r -e 's/^[[:blank:]]+//' \
-e '/^[[:blank:]]*($$|#)/d' >> tmp/system.users -e '/^[[:blank:]]*($$|#)/d' >> $(TMPDIR)/system.users
$(verbose) install -m 644 tmp/system.users $@ $(verbose) install -m 644 $(TMPDIR)/system.users $@
$(USERPATH)/local.users: config/local.users $(USERPATH)/local.users: config/local.users
@mkdir -p $(USERPATH) @mkdir -p $(USERPATH)
@ -321,10 +381,11 @@ $(USERPATH)/local.users: config/local.users
install-appconfig: $(APPFILES) install-appconfig: $(APPFILES)
$(INSTALLDIR)/booleans: $(BOOLEANS) $(INSTALLDIR)/booleans: $(BOOLEANS)
@mkdir -p $(TMPDIR)
@mkdir -p $(INSTALLDIR) @mkdir -p $(INSTALLDIR)
$(verbose) sed -r -e 's/false/0/g' -e 's/true/1/g' \ $(verbose) sed -r -e 's/false/0/g' -e 's/true/1/g' \
-e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > tmp/booleans -e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > $(TMPDIR)/booleans
$(verbose) install -m 644 tmp/booleans $@ $(verbose) install -m 644 $(TMPDIR)/booleans $@
$(CONTEXTPATH)/files/media: $(APPCONF)/media $(CONTEXTPATH)/files/media: $(APPCONF)/media
@mkdir -p $(CONTEXTPATH)/files/ @mkdir -p $(CONTEXTPATH)/files/
@ -366,10 +427,10 @@ $(APPDIR)/users/root: $(APPCONF)/root_default_contexts
# #
# Install policy headers # Install policy headers
# #
install-headers: doc/policy.xml install-headers: $(POLXML)
@mkdir -p $(HEADERDIR) @mkdir -p $(HEADERDIR)
@echo "Installing policy headers" @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) m4 $(M4PARAM) $(ROLEMAP) > $(HEADERDIR)/$(notdir $(ROLEMAP))
$(verbose) mkdir -p $(HEADERDIR)/support $(verbose) mkdir -p $(HEADERDIR)/support
$(verbose) install -m 644 $(M4SUPPORT) $(GENXML) $(XMLDTD) $(HEADERDIR)/support $(verbose) install -m 644 $(M4SUPPORT) $(GENXML) $(XMLDTD) $(HEADERDIR)/support
@ -394,7 +455,7 @@ endif
# #
# Install policy documentation # Install policy documentation
# #
install-docs: tmp/html install-docs: $(TMPDIR)/html
@mkdir -p $(DOCSDIR)/html @mkdir -p $(DOCSDIR)/html
@echo "Installing policy documentation" @echo "Installing policy documentation"
$(verbose) install -m 644 $(DOCFILES) $(DOCSDIR) $(verbose) install -m 644 $(DOCFILES) $(DOCSDIR)
@ -414,9 +475,10 @@ install-src:
# #
# Generate tags file # Generate tags file
# #
tags: tags: $(TAGS)
$(TAGS):
@($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1) @($(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='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \
--regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \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/' \ --regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \
@ -466,12 +528,14 @@ resetlabels:
# #
bare: clean bare: clean
rm -f $(POLXML) rm -f $(POLXML)
rm -f $(SUPPORT)/*.pyc
rm -f $(FCSORT)
rm -f $(MOD_CONF) rm -f $(MOD_CONF)
rm -f $(BOOLEANS) rm -f $(BOOLEANS)
rm -fR $(HTMLDIR) 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),) ifneq ($(GENERATED_TE),)
rm -f $(GENERATED_TE) rm -f $(GENERATED_TE)
endif endif
@ -481,6 +545,7 @@ endif
ifneq ($(GENERATED_FC),) ifneq ($(GENERATED_FC),)
rm -f $(GENERATED_FC) rm -f $(GENERATED_FC)
endif endif
endif
.PHONY: install-src install-appconfig conf html bare tags .PHONY: install-src install-appconfig conf html bare tags
.SUFFIXES: .SUFFIXES:

View File

@ -6,10 +6,12 @@
ALL_MODULES := $(BASE_MODS) $(MOD_MODS) $(OFF_MODS) ALL_MODULES := $(BASE_MODS) $(MOD_MODS) $(OFF_MODS)
ALL_INTERFACES := $(ALL_MODULES:.te=.if) ALL_INTERFACES := $(ALL_MODULES:.te=.if)
BASE_PKG := base.pp BASE_PKG := $(BUILDDIR)/base.pp
BASE_FC := base.fc 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_PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls $(POLDIR)/mcs
BASE_TE_FILES := $(BASE_MODS) BASE_TE_FILES := $(BASE_MODS)
@ -17,15 +19,15 @@ BASE_POST_TE_FILES := $(USER_FILES) $(POLDIR)/constraints
BASE_FC_FILES := $(BASE_MODS:.te=.fc) BASE_FC_FILES := $(BASE_MODS:.te=.fc)
MOD_MODULES := $(MOD_MODS:.te=.mod) 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 # 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 # search layer dirs for source files
vpath %.te $(ALL_LAYERS) vpath %.te $(ALL_LAYERS) $(LOCAL_LAYERS)
vpath %.if $(ALL_LAYERS) vpath %.if $(ALL_LAYERS) $(LOCAL_LAYERS)
vpath %.fc $(ALL_LAYERS) vpath %.fc $(ALL_LAYERS) $(LOCAL_LAYERS)
.SECONDARY: .SECONDARY:
@ -49,13 +51,13 @@ install: $(INSTPKG) $(APPFILES)
# #
load: $(INSTPKG) $(APPFILES) load: $(INSTPKG) $(APPFILES)
@echo "Loading configured modules." @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 # Install policy packages
# #
$(MODPKGDIR)/%.pp: %.pp $(MODPKGDIR)/%.pp: $(BUILDDIR)/%.pp
@mkdir -p $(MODPKGDIR) @mkdir -p $(MODPKGDIR)
@echo "Installing $(NAME) $(@F) policy package." @echo "Installing $(NAME) $(@F) policy package."
$(verbose) install -m 0644 $^ $(MODPKGDIR) $(verbose) install -m 0644 $^ $(MODPKGDIR)
@ -64,28 +66,32 @@ $(MODPKGDIR)/%.pp: %.pp
# #
# Build module packages # 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" @echo "Compliling $(NAME) $(@F) module"
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(call peruser-expansion,$(basename $(@F)),$@.role) $(call peruser-expansion,$(basename $(@F)),$@.role)
$(verbose) m4 $(M4PARAM) -s $^ $@.role > $(@:.mod=.tmp) $(verbose) m4 $(M4PARAM) -s $^ $@.role > $(@:.mod=.tmp)
$(verbose) $(CHECKMODULE) -m $(@:.mod=.tmp) -o $@ $(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) $^ > $@ $(verbose) m4 $(M4PARAM) $(M4SUPPORT) $^ > $@
%.pp: tmp/%.mod tmp/%.mod.fc $(BUILDDIR)/%.pp: $(TMPDIR)/%.mod $(TMPDIR)/%.mod.fc
@echo "Creating $(NAME) $(@F) policy package" @echo "Creating $(NAME) $(@F) policy package"
@test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
$(verbose) $(SEMOD_PKG) -o $@ -m $< -f $<.fc $(verbose) $(SEMOD_PKG) -o $@ -m $< -f $<.fc
######################################## ########################################
# #
# Create a base module package # Create a base module package
# #
$(BASE_PKG): tmp/base.mod $(BASE_FC) $(BASE_PKG): $(BASE_MOD) $(BASE_FC)
@echo "Creating $(NAME) base module package" @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" @echo "Compiling $(NAME) base module"
$(verbose) $(CHECKMODULE) $^ -o $@ $(verbose) $(CHECKMODULE) $^ -o $@
@ -93,22 +99,24 @@ tmp/base.mod: base.conf
# #
# Construct a base.conf # Construct a base.conf
# #
base.conf: $(BASE_SECTIONS) $(BASE_CONF): $(BASE_SECTIONS)
@echo "Creating $(NAME) base module base.conf" @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: # checkpolicy can use the #line directives provided by -s for error reporting:
$(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > tmp/$@.tmp $(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > $(TMPDIR)/$(@F).tmp
$(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < tmp/$@.tmp > $@ $(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < $(TMPDIR)/$(@F).tmp > $@
# the ordering of these ocontexts matters: # the ordering of these ocontexts matters:
$(verbose) grep ^portcon tmp/$@.tmp >> $@ || true $(verbose) grep ^portcon $(TMPDIR)/$(@F).tmp >> $@ || true
$(verbose) grep ^netifcon tmp/$@.tmp >> $@ || true $(verbose) grep ^netifcon $(TMPDIR)/$(@F).tmp >> $@ || true
$(verbose) grep ^nodecon tmp/$@.tmp >> $@ || true $(verbose) grep ^nodecon $(TMPDIR)/$(@F).tmp >> $@ || true
tmp/pre_te_files.conf: $(BASE_PRE_TE_FILES) $(TMPDIR)/pre_te_files.conf: $(BASE_PRE_TE_FILES)
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@ $(verbose) cat $^ > $@
tmp/generated_definitions.conf: $(BASE_TE_FILES) $(TMPDIR)/generated_definitions.conf: $(BASE_TE_FILES)
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
# define all available object classes # define all available object classes
$(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $@ $(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $@
# per-userdomain templates # per-userdomain templates
@ -124,81 +132,82 @@ tmp/generated_definitions.conf: $(BASE_TE_FILES)
done done
$(verbose) $(SETTUN) $(BOOLEANS) >> $@ $(verbose) $(SETTUN) $(BOOLEANS) >> $@
tmp/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES) $(TMPDIR)/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
ifeq ($(ALL_INTERFACES),) ifeq ($(ALL_INTERFACES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf") $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif endif
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@ $(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),) ifeq ($(BASE_TE_FILES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf") $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif endif
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@ $(verbose) cat $^ > $@
$(call parse-rolemap,base,$@) $(call parse-rolemap,base,$@)
tmp/post_te_files.conf: $(BASE_POST_TE_FILES) $(TMPDIR)/post_te_files.conf: $(BASE_POST_TE_FILES)
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@ $(verbose) cat $^ > $@
# extract attributes and put them first. extract post te stuff # extract attributes and put them first. extract post te stuff
# like genfscon and put last. portcon, nodecon, and netifcon # like genfscon and put last. portcon, nodecon, and netifcon
# is delayed since they are generated by m4 # 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 $(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 tmp/all_te_files.conf > tmp/all_attrs_types.conf || true @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) grep '^type ' tmp/all_te_files.conf >> tmp/all_attrs_types.conf $(verbose) grep ^attribute $(TMPDIR)/all_te_files.conf > $(TMPDIR)/all_attrs_types.conf || true
$(verbose) cat tmp/post_te_files.conf > tmp/all_post.conf $(verbose) grep '^type ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_attrs_types.conf
$(verbose) grep '^sid ' tmp/all_te_files.conf >> tmp/all_post.conf || true $(verbose) cat $(TMPDIR)/post_te_files.conf > $(TMPDIR)/all_post.conf
$(verbose) egrep '^fs_use_(xattr|task|trans)' tmp/all_te_files.conf >> tmp/all_post.conf || true $(verbose) grep '^sid ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
$(verbose) grep ^genfscon tmp/all_te_files.conf >> tmp/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 \ $(verbose) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
-e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/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 # Construct a base.fc
# #
$(BASE_FC): tmp/$(BASE_FC).tmp $(FCSORT) $(BASE_FC): $(TMPDIR)/$(notdir $(BASE_FC)).tmp $(FCSORT)
$(verbose) $(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),) ifeq ($(BASE_FC_FILES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf") $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif endif
@echo "Creating $(NAME) base module file contexts." @echo "Creating $(NAME) base module file contexts."
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $(M4PARAM) $^ > $@ $(verbose) m4 $(M4PARAM) $^ > $@
######################################## ########################################
# #
# Remove the dontaudit rules from the base.conf # Remove the dontaudit rules from the base.conf
# #
enableaudit: base.conf enableaudit: $(BASE_CONF)
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
@echo "Removing dontaudit rules from base.conf" @echo "Removing dontaudit rules from $(BASE_CONF)"
$(verbose) grep -v dontaudit base.conf > tmp/base.audit $(verbose) grep -v dontaudit $(BASE_CONF) > $(TMPDIR)/base.audit
$(verbose) mv tmp/base.audit base.conf $(verbose) mv $(TMPDIR)/base.audit $(BASE_CONF)
######################################## ########################################
# #
# Appconfig files # Appconfig files
# #
$(APPDIR)/customizable_types: base.conf $(APPDIR)/customizable_types: $(BASE_CONF)
@mkdir -p $(APPDIR) @mkdir -p $(APPDIR)
$(verbose) grep "^type .*customizable" $< | cut -d',' -f1 | cut -d' ' -f2 > tmp/customizable_types $(verbose) grep "^type .*customizable" $< | cut -d',' -f1 | cut -d' ' -f2 > $(TMPDIR)/customizable_types
$(verbose) install -m 644 tmp/customizable_types $@ $(verbose) install -m 644 $(TMPDIR)/customizable_types $@
######################################## ########################################
# #
# Clean the sources # Clean the sources
# #
clean: clean:
rm -f base.conf rm -f $(BASE_CONF)
rm -f *.pp
rm -f $(BASE_FC) rm -f $(BASE_FC)
rm -fR tmp rm -f $(BUILDDIR)/*.pp
rm -fR $(TMPDIR)
.PHONY: default all base modules install load clean .PHONY: default all base modules install load clean

View File

@ -3,14 +3,16 @@
# Rules and Targets for building monolithic policies # 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 # install paths
POLICYPATH = $(INSTALLDIR)/policy POLICYPATH = $(INSTALLDIR)/policy
LOADPATH = $(POLICYPATH)/$(POLVER) LOADPATH = $(POLICYPATH)/$(POLVER)
HOMEDIRPATH = $(CONTEXTPATH)/files/homedir_template HOMEDIRPATH = $(CONTEXTPATH)/files/homedir_template
FC := file_contexts
POLVER := policy.$(PV)
APPFILES += $(INSTALLDIR)/booleans APPFILES += $(INSTALLDIR)/booleans
# for monolithic policy use all base and module to create policy # 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 PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls $(POLDIR)/mcs
POST_TE_FILES := $(USER_FILES) $(POLDIR)/constraints 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 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
HOMEDIR_TEMPLATE = homedir_template
# search layer dirs for source files # search layer dirs for source files
vpath %.te $(ALL_LAYERS) vpath %.te $(ALL_LAYERS) $(LOCAL_LAYERS)
vpath %.if $(ALL_LAYERS) vpath %.if $(ALL_LAYERS) $(LOCAL_LAYERS)
vpath %.fc $(ALL_LAYERS) vpath %.fc $(ALL_LAYERS) $(LOCAL_LAYERS)
######################################## ########################################
# #
@ -42,7 +42,7 @@ policy: $(POLVER)
install: $(LOADPATH) $(FCPATH) $(APPFILES) $(USERPATH)/local.users install: $(LOADPATH) $(FCPATH) $(APPFILES) $(USERPATH)/local.users
load: tmp/load load: $(TMPDIR)/load
checklabels: $(FCPATH) checklabels: $(FCPATH)
restorelabels: $(FCPATH) restorelabels: $(FCPATH)
@ -53,20 +53,20 @@ resetlabels: $(FCPATH)
# #
# Build a binary policy locally # Build a binary policy locally
# #
$(POLVER): policy.conf $(POLVER): $(POLICY_CONF)
@echo "Compiling $(NAME) $(POLVER)" @echo "Compiling $(NAME) $(POLVER)"
ifneq ($(PV),$(KV)) ifneq ($(PV),$(KV))
@echo @echo
@echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?" @echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?"
@echo @echo
endif endif
$(verbose) $(CHECKPOLICY) $^ -o $@ $(verbose) $(CHECKPOLICY) $^ -o $(BUILDDIR)/$@
######################################## ########################################
# #
# Install a binary policy # Install a binary policy
# #
$(LOADPATH): policy.conf $(LOADPATH): $(POLICY_CONF)
@mkdir -p $(POLICYPATH) @mkdir -p $(POLICYPATH)
@echo "Compiling and installing $(NAME) $(LOADPATH)" @echo "Compiling and installing $(NAME) $(LOADPATH)"
ifneq ($(PV),$(KV)) ifneq ($(PV),$(KV))
@ -80,32 +80,34 @@ endif
# #
# Load the binary policy # Load the binary policy
# #
reload tmp/load: $(LOADPATH) $(FCPATH) $(APPFILES) reload $(TMPDIR)/load: $(LOADPATH) $(FCPATH) $(APPFILES)
@echo "Loading $(NAME) $(LOADPATH)" @echo "Loading $(NAME) $(LOADPATH)"
$(verbose) $(LOADPOLICY) -q $(LOADPATH) $(verbose) $(LOADPOLICY) -q $(LOADPATH)
@touch tmp/load @touch $(TMPDIR)/load
######################################## ########################################
# #
# Construct a monolithic policy.conf # Construct a monolithic policy.conf
# #
policy.conf: $(POLICY_SECTIONS) $(POLICY_CONF): $(POLICY_SECTIONS)
@echo "Creating $(NAME) policy.conf" @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: # checkpolicy can use the #line directives provided by -s for error reporting:
$(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > tmp/$@.tmp $(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > $(TMPDIR)/$(@F).tmp
$(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < tmp/$@.tmp > $@ $(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < $(TMPDIR)/$(@F).tmp > $@
# the ordering of these ocontexts matters: # the ordering of these ocontexts matters:
$(verbose) grep ^portcon tmp/$@.tmp >> $@ || true $(verbose) grep ^portcon $(TMPDIR)/$(@F).tmp >> $@ || true
$(verbose) grep ^netifcon tmp/$@.tmp >> $@ || true $(verbose) grep ^netifcon $(TMPDIR)/$(@F).tmp >> $@ || true
$(verbose) grep ^nodecon tmp/$@.tmp >> $@ || true $(verbose) grep ^nodecon $(TMPDIR)/$(@F).tmp >> $@ || true
tmp/pre_te_files.conf: $(PRE_TE_FILES) $(TMPDIR)/pre_te_files.conf: $(PRE_TE_FILES)
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@ $(verbose) cat $^ > $@
tmp/generated_definitions.conf: $(ALL_TE_FILES) $(TMPDIR)/generated_definitions.conf: $(ALL_LAYERS) $(ALL_TE_FILES)
# per-userdomain templates: # per-userdomain templates:
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) echo "define(\`base_per_userdomain_template',\`" > $@ $(verbose) echo "define(\`base_per_userdomain_template',\`" > $@
$(verbose) for i in $(patsubst %.te,%,$(notdir $(ALL_MODULES))); do \ $(verbose) for i in $(patsubst %.te,%,$(notdir $(ALL_MODULES))); do \
echo "ifdef(\`""$$i""_per_userdomain_template',\`""$$i""_per_userdomain_template("'$$*'")')" \ echo "ifdef(\`""$$i""_per_userdomain_template',\`""$$i""_per_userdomain_template("'$$*'")')" \
@ -118,64 +120,64 @@ tmp/generated_definitions.conf: $(ALL_TE_FILES)
done done
$(verbose) $(SETTUN) $(BOOLEANS) >> $@ $(verbose) $(SETTUN) $(BOOLEANS) >> $@
tmp/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES) $(TMPDIR)/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
ifeq ($(ALL_INTERFACES),) ifeq ($(ALL_INTERFACES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf") $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif endif
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@ $(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),) ifeq ($(ALL_TE_FILES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf") $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif endif
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@ $(verbose) cat $^ > $@
$(call parse-rolemap,base,$@) $(call parse-rolemap,base,$@)
tmp/post_te_files.conf: $(POST_TE_FILES) $(TMPDIR)/post_te_files.conf: $(POST_TE_FILES)
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) cat $^ > $@ $(verbose) cat $^ > $@
# extract attributes and put them first. extract post te stuff # extract attributes and put them first. extract post te stuff
# like genfscon and put last. portcon, nodecon, and netifcon # like genfscon and put last. portcon, nodecon, and netifcon
# is delayed since they are generated by m4 # 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 $(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 tmp/all_te_files.conf > tmp/all_attrs_types.conf || true $(verbose) grep ^attribute $(TMPDIR)/all_te_files.conf > $(TMPDIR)/all_attrs_types.conf || true
$(verbose) grep '^type ' tmp/all_te_files.conf >> tmp/all_attrs_types.conf $(verbose) grep '^type ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_attrs_types.conf
$(verbose) cat tmp/post_te_files.conf > tmp/all_post.conf $(verbose) cat $(TMPDIR)/post_te_files.conf > $(TMPDIR)/all_post.conf
$(verbose) grep '^sid ' tmp/all_te_files.conf >> tmp/all_post.conf || true $(verbose) grep '^sid ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
$(verbose) egrep '^fs_use_(xattr|task|trans)' tmp/all_te_files.conf >> tmp/all_post.conf || true $(verbose) egrep '^fs_use_(xattr|task|trans)' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
$(verbose) grep ^genfscon tmp/all_te_files.conf >> tmp/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 \ $(verbose) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
-e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/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 # Remove the dontaudit rules from the policy.conf
# #
enableaudit: policy.conf enableaudit: $(POLICY_CONF)
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
@echo "Removing dontaudit rules from policy.conf" @echo "Removing dontaudit rules from $(notdir $(POLICY_CONF))"
$(verbose) grep -v dontaudit policy.conf > tmp/policy.audit $(verbose) grep -v dontaudit @^ > $(TMPDIR)/policy.audit
$(verbose) mv tmp/policy.audit policy.conf $(verbose) mv $(TMPDIR)/policy.audit $(POLICY_CONF)
######################################## ########################################
# #
# Construct file_contexts # Construct file_contexts
# #
$(FC): tmp/$(FC).tmp $(FCSORT) $(FC): $(TMPDIR)/$(notdir $(FC)).tmp $(FCSORT)
$(verbose) $(FCSORT) $< $@ $(verbose) $(FCSORT) $< $@
$(verbose) grep -e HOME -e ROLE $@ > $(HOMEDIR_TEMPLATE) $(verbose) grep -e HOME -e ROLE $@ > $(HOMEDIR_TEMPLATE)
$(verbose) sed -i -e /HOME/d -e /ROLE/d $@ $(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),) ifeq ($(ALL_FC_FILES),)
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf") $(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
endif endif
@echo "Creating $(NAME) file_contexts." @echo "Creating $(NAME) file_contexts."
@test -d tmp || mkdir -p tmp @test -d $(TMPDIR) || mkdir -p $(TMPDIR)
$(verbose) m4 $(M4PARAM) $^ > $@ $(verbose) m4 $(M4PARAM) $^ > $@
######################################## ########################################
@ -195,11 +197,11 @@ $(FCPATH): $(FC) $(LOADPATH) $(USERPATH)/system.users
# #
# Run policy source checks # Run policy source checks
# #
check: policy.conf $(FC) check: $(POLICY_CONF) $(FC)
$(SECHECK) -s --profile=development --policy=policy.conf --fcfile=$(FC) > $@.res $(SECHECK) -s --profile=development --policy=$(POLICY_CONF) --fcfile=$(FC) > $(BUILDDIR)/$@.res
longcheck: policy.conf $(FC) longcheck: $(POLICY_CONF) $(FC)
$(SECHECK) -s --profile=all --policy=policy.conf --fcfile=$(FC) > $@.res $(SECHECK) -s --profile=all --policy=$(POLICY_CONF) --fcfile=$(FC) > $(BUILDDIR)/$@.res
######################################## ########################################
# #
@ -215,11 +217,11 @@ $(APPDIR)/customizable_types: policy.conf
# Clean the sources # Clean the sources
# #
clean: clean:
rm -f policy.conf rm -f $(POLICY_CONF)
rm -f policy.$(PV) rm -f $(BUILDDIR)/policy.$(PV)
rm -f $(FC) rm -f $(FC)
rm -f $(HOMEDIR_TEMPLATE) rm -f $(HOMEDIR_TEMPLATE)
rm -f *.res rm -f *.res
rm -fR tmp rm -fR $(TMPDIR)
.PHONY: default policy install load reload enableaudit checklabels restorelabels relabel check longcheck clean .PHONY: default policy install load reload enableaudit checklabels restorelabels relabel check longcheck clean