|
Chris PeBenito |
fb0a3a |
########################################
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
c38127 |
# Rules and Targets for building modular policies
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
e0a900 |
ALL_MODULES := $(BASE_MODS) $(MOD_MODS) $(OFF_MODS)
|
|
Chris PeBenito |
fb0a3a |
ALL_INTERFACES := $(ALL_MODULES:.te=.if)
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
c9f20d |
BASE_PKG := $(BUILDDIR)/base.pp
|
|
Chris PeBenito |
c9f20d |
BASE_FC := $(BUILDDIR)/base.fc
|
|
Chris PeBenito |
c9f20d |
BASE_CONF := $(BUILDDIR)/base.conf
|
|
Chris PeBenito |
c9f20d |
BASE_MOD := $(TMPDIR)/base.mod
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
90b331 |
USERS_EXTRA := $(TMPDIR)/users_extra
|
|
Chris PeBenito |
90b331 |
|
|
Chris PeBenito |
c9f20d |
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
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
a08248 |
BASE_PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls $(POLDIR)/mcs
|
|
Chris PeBenito |
fb0a3a |
BASE_TE_FILES := $(BASE_MODS)
|
|
Chris PeBenito |
2f33cd |
BASE_POST_TE_FILES := $(USER_FILES) $(POLDIR)/constraints
|
|
Chris PeBenito |
fb0a3a |
BASE_FC_FILES := $(BASE_MODS:.te=.fc)
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
fb0a3a |
MOD_MODULES := $(MOD_MODS:.te=.mod)
|
|
Chris PeBenito |
c9f20d |
MOD_PKGS := $(addprefix $(BUILDDIR)/,$(notdir $(MOD_MODS:.te=.pp)))
|
|
Chris PeBenito |
c04f2a |
|
|
Chris PeBenito |
c767b1 |
# policy packages to install
|
|
Chris PeBenito |
c9f20d |
INSTPKG := $(addprefix $(MODPKGDIR)/,$(notdir $(BASE_PKG)) $(MOD_PKGS))
|
|
Chris PeBenito |
c767b1 |
|
|
Chris PeBenito |
c04f2a |
# search layer dirs for source files
|
|
Chris PeBenito |
e2680f |
vpath %.te $(ALL_LAYERS)
|
|
Chris PeBenito |
e2680f |
vpath %.if $(ALL_LAYERS)
|
|
Chris PeBenito |
e2680f |
vpath %.fc $(ALL_LAYERS)
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
e60b98 |
.SECONDARY:
|
|
Chris PeBenito |
e60b98 |
|
|
Chris PeBenito |
fb0a3a |
########################################
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
fb0a3a |
# default action: create all module packages
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
ddb9aa |
default: policy
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
ddb9aa |
all policy: base modules
|
|
Chris PeBenito |
06a536 |
|
|
Chris PeBenito |
fb0a3a |
base: $(BASE_PKG)
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
fb0a3a |
modules: $(MOD_PKGS)
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
c767b1 |
install: $(INSTPKG) $(APPFILES)
|
|
Chris PeBenito |
c767b1 |
|
|
Chris PeBenito |
c767b1 |
########################################
|
|
Chris PeBenito |
c767b1 |
#
|
|
Chris PeBenito |
c767b1 |
# Load all configured modules
|
|
Chris PeBenito |
c767b1 |
#
|
|
Chris PeBenito |
c767b1 |
load: $(INSTPKG) $(APPFILES)
|
|
Chris PeBenito |
c767b1 |
@echo "Loading configured modules."
|
|
Chris PeBenito |
c9f20d |
$(verbose) $(SEMODULE) -s $(NAME) -b $(MODPKGDIR)/$(notdir $(BASE_PKG)) $(foreach mod,$(MOD_PKGS),-i $(MODPKGDIR)/$(mod))
|
|
Chris PeBenito |
c767b1 |
|
|
Chris PeBenito |
c767b1 |
########################################
|
|
Chris PeBenito |
c767b1 |
#
|
|
Chris PeBenito |
c767b1 |
# Install policy packages
|
|
Chris PeBenito |
c767b1 |
#
|
|
Chris PeBenito |
c9f20d |
$(MODPKGDIR)/%.pp: $(BUILDDIR)/%.pp
|
|
Chris PeBenito |
c767b1 |
@mkdir -p $(MODPKGDIR)
|
|
Chris PeBenito |
6b1c8e |
@echo "Installing $(NAME) $(@F) policy package."
|
|
Chris PeBenito |
9b3756 |
$(verbose) install -m 0644 $^ $(MODPKGDIR)
|
|
Chris PeBenito |
c767b1 |
|
|
Chris PeBenito |
c767b1 |
########################################
|
|
Chris PeBenito |
c767b1 |
#
|
|
Chris PeBenito |
c767b1 |
# Build module packages
|
|
Chris PeBenito |
c767b1 |
#
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/%.mod: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(TMPDIR)/all_interfaces.conf %.te
|
|
Chris PeBenito |
c767b1 |
@echo "Compliling $(NAME) $(@F) module"
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
4ace0f |
$(call peruser-expansion,$(basename $(@F)),$@.role)
|
|
Chris PeBenito |
9b3756 |
$(verbose) m4 $(M4PARAM) -s $^ $@.role > $(@:.mod=.tmp)
|
|
Chris PeBenito |
9b3756 |
$(verbose) $(CHECKMODULE) -m $(@:.mod=.tmp) -o $@
|
|
Chris PeBenito |
c767b1 |
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/%.mod.fc: $(M4SUPPORT) %.fc
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
9b3756 |
$(verbose) m4 $(M4PARAM) $(M4SUPPORT) $^ > $@
|
|
Chris PeBenito |
c767b1 |
|
|
Chris PeBenito |
c9f20d |
$(BUILDDIR)/%.pp: $(TMPDIR)/%.mod $(TMPDIR)/%.mod.fc
|
|
Chris PeBenito |
c767b1 |
@echo "Creating $(NAME) $(@F) policy package"
|
|
Chris PeBenito |
c9f20d |
@test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
|
|
Chris PeBenito |
9b3756 |
$(verbose) $(SEMOD_PKG) -o $@ -m $< -f $<.fc
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
fb0a3a |
########################################
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
fb0a3a |
# Create a base module package
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
ace368 |
$(BASE_PKG): $(BASE_MOD) $(BASE_FC) $(USERS_EXTRA) $(SEUSERS)
|
|
Chris PeBenito |
fb0a3a |
@echo "Creating $(NAME) base module package"
|
|
Chris PeBenito |
c9f20d |
@test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
|
|
Chris PeBenito |
ace368 |
$(verbose) $(SEMOD_PKG) -o $@ -m $(BASE_MOD) -f $(BASE_FC) -u $(USERS_EXTRA) -s $(SEUSERS)
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
c9f20d |
$(BASE_MOD): $(BASE_CONF)
|
|
Chris PeBenito |
fb0a3a |
@echo "Compiling $(NAME) base module"
|
|
Chris PeBenito |
9b3756 |
$(verbose) $(CHECKMODULE) $^ -o $@
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
90b331 |
$(USERS_EXTRA): $(M4SUPPORT) $(USER_FILES)
|
|
Chris PeBenito |
90b331 |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
90b331 |
$(verbose) $(M4) $(M4PARAM) -D users_extra $^ | \
|
|
Chris PeBenito |
90b331 |
$(SED) -r -n -e 's/^[[:blank:]]*//g' -e '/^user/p' > $@
|
|
Chris PeBenito |
90b331 |
|
|
Chris PeBenito |
fb0a3a |
########################################
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
c767b1 |
# Construct a base.conf
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
c9f20d |
$(BASE_CONF): $(BASE_SECTIONS)
|
|
Chris PeBenito |
c9f20d |
@echo "Creating $(NAME) base module $(BASE_CONF)"
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
c9f20d |
@test -d $(dir $(BASE_CONF)) || mkdir -p $(dir $(BASE_CONF))
|
|
Chris PeBenito |
fb0a3a |
# checkpolicy can use the #line directives provided by -s for error reporting:
|
|
Chris PeBenito |
c9f20d |
$(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > $(TMPDIR)/$(@F).tmp
|
|
Chris PeBenito |
c9f20d |
$(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < $(TMPDIR)/$(@F).tmp > $@
|
|
Chris PeBenito |
fb0a3a |
# the ordering of these ocontexts matters:
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep ^portcon $(TMPDIR)/$(@F).tmp >> $@ || true
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep ^netifcon $(TMPDIR)/$(@F).tmp >> $@ || true
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep ^nodecon $(TMPDIR)/$(@F).tmp >> $@ || true
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/pre_te_files.conf: $(BASE_PRE_TE_FILES)
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
9b3756 |
$(verbose) cat $^ > $@
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/generated_definitions.conf: $(BASE_TE_FILES)
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
c04f2a |
# define all available object classes
|
|
Chris PeBenito |
9b3756 |
$(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $@
|
|
Chris PeBenito |
71fe0f |
# per-userdomain templates
|
|
Chris PeBenito |
9b3756 |
$(verbose) echo "define(\`base_per_userdomain_template',\`" >> $@
|
|
Chris PeBenito |
9b3756 |
$(verbose) for i in $(patsubst %.te,%,$(BASE_MODS)); do \
|
|
Chris PeBenito |
71fe0f |
echo "ifdef(\`""$$i""_per_userdomain_template',\`""$$i""_per_userdomain_template("'$$*'")')" \
|
|
Chris PeBenito |
71fe0f |
>> $@ ;\
|
|
Chris PeBenito |
71fe0f |
done
|
|
Chris PeBenito |
9b3756 |
$(verbose) echo "')" >> $@
|
|
Chris PeBenito |
fb0a3a |
# define foo.te
|
|
Chris PeBenito |
9b3756 |
$(verbose) for i in $(notdir $(BASE_TE_FILES)); do \
|
|
Chris PeBenito |
fb0a3a |
echo "define(\`$$i')" >> $@ ;\
|
|
Chris PeBenito |
fb0a3a |
done
|
|
Chris PeBenito |
d6cf05 |
$(verbose) test -f $(BOOLEANS) && $(SETBOOLS) $(BOOLEANS) >> $@
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
|
|
Chris PeBenito |
fb0a3a |
ifeq ($(ALL_INTERFACES),)
|
|
Chris PeBenito |
fb0a3a |
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
|
|
Chris PeBenito |
fb0a3a |
endif
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
9b3756 |
$(verbose) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/all_te_files.conf: $(BASE_TE_FILES)
|
|
Chris PeBenito |
fb0a3a |
ifeq ($(BASE_TE_FILES),)
|
|
Chris PeBenito |
fb0a3a |
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
|
|
Chris PeBenito |
fb0a3a |
endif
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
9b3756 |
$(verbose) cat $^ > $@
|
|
Chris PeBenito |
4ace0f |
$(call parse-rolemap,base,$@)
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/post_te_files.conf: $(BASE_POST_TE_FILES)
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
9b3756 |
$(verbose) cat $^ > $@
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
fb0a3a |
# extract attributes and put them first. extract post te stuff
|
|
Chris PeBenito |
fb0a3a |
# like genfscon and put last. portcon, nodecon, and netifcon
|
|
Chris PeBenito |
fb0a3a |
# is delayed since they are generated by m4
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/all_attrs_types.conf $(TMPDIR)/only_te_rules.conf $(TMPDIR)/all_post.conf: $(TMPDIR)/all_te_files.conf $(TMPDIR)/post_te_files.conf
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep ^attribute $(TMPDIR)/all_te_files.conf > $(TMPDIR)/all_attrs_types.conf || true
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep '^type ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_attrs_types.conf
|
|
Chris PeBenito |
c9f20d |
$(verbose) cat $(TMPDIR)/post_te_files.conf > $(TMPDIR)/all_post.conf
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep '^sid ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
|
|
Chris PeBenito |
c9f20d |
$(verbose) egrep '^fs_use_(xattr|task|trans)' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep ^genfscon $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
|
|
Chris PeBenito |
9b3756 |
$(verbose) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
|
|
Chris PeBenito |
fb0a3a |
-e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/d' \
|
|
Chris PeBenito |
c9f20d |
< $(TMPDIR)/all_te_files.conf > $(TMPDIR)/only_te_rules.conf
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
fb0a3a |
########################################
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
c767b1 |
# Construct a base.fc
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
c9f20d |
$(BASE_FC): $(TMPDIR)/$(notdir $(BASE_FC)).tmp $(FCSORT)
|
|
Chris PeBenito |
9b3756 |
$(verbose) $(FCSORT) $< $@
|
|
Chris PeBenito |
c767b1 |
|
|
Chris PeBenito |
c9f20d |
$(TMPDIR)/$(notdir $(BASE_FC)).tmp: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(BASE_FC_FILES)
|
|
Chris PeBenito |
fb0a3a |
ifeq ($(BASE_FC_FILES),)
|
|
Chris PeBenito |
fb0a3a |
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
|
|
Chris PeBenito |
fb0a3a |
endif
|
|
Chris PeBenito |
fb0a3a |
@echo "Creating $(NAME) base module file contexts."
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
9b3756 |
$(verbose) m4 $(M4PARAM) $^ > $@
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
fb0a3a |
########################################
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
bf080a |
# Remove the dontaudit rules from the base.conf
|
|
Chris PeBenito |
bf080a |
#
|
|
Chris PeBenito |
c9f20d |
enableaudit: $(BASE_CONF)
|
|
Chris PeBenito |
c9f20d |
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
Chris PeBenito |
c9f20d |
@echo "Removing dontaudit rules from $(BASE_CONF)"
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep -v dontaudit $(BASE_CONF) > $(TMPDIR)/base.audit
|
|
Chris PeBenito |
c9f20d |
$(verbose) mv $(TMPDIR)/base.audit $(BASE_CONF)
|
|
Chris PeBenito |
bf080a |
|
|
Chris PeBenito |
bf080a |
########################################
|
|
Chris PeBenito |
bf080a |
#
|
|
Chris PeBenito |
049e11 |
# Appconfig files
|
|
Chris PeBenito |
049e11 |
#
|
|
Chris PeBenito |
c9f20d |
$(APPDIR)/customizable_types: $(BASE_CONF)
|
|
Chris PeBenito |
049e11 |
@mkdir -p $(APPDIR)
|
|
Chris PeBenito |
c9f20d |
$(verbose) grep "^type .*customizable" $< | cut -d',' -f1 | cut -d' ' -f2 > $(TMPDIR)/customizable_types
|
|
Chris PeBenito |
c9f20d |
$(verbose) install -m 644 $(TMPDIR)/customizable_types $@
|
|
Chris PeBenito |
049e11 |
|
|
Chris PeBenito |
049e11 |
########################################
|
|
Chris PeBenito |
049e11 |
#
|
|
Chris PeBenito |
fb0a3a |
# Clean the sources
|
|
Chris PeBenito |
fb0a3a |
#
|
|
Chris PeBenito |
fb0a3a |
clean:
|
|
Chris PeBenito |
c9f20d |
rm -f $(BASE_CONF)
|
|
Chris PeBenito |
712566 |
rm -f $(BASE_FC)
|
|
Chris PeBenito |
c9f20d |
rm -f $(BUILDDIR)/*.pp
|
|
Chris PeBenito |
c9f20d |
rm -fR $(TMPDIR)
|
|
Chris PeBenito |
fb0a3a |
|
|
Chris PeBenito |
ddb9aa |
.PHONY: default all policy base modules install load clean
|