2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
2005-10-18 15:07:11 +00:00
|
|
|
# Rules and Targets for building modular policies
|
2005-08-18 21:27:20 +00:00
|
|
|
#
|
|
|
|
|
2006-01-12 16:07:59 +00:00
|
|
|
ALL_MODULES := $(BASE_MODS) $(MOD_MODS) $(OFF_MODS)
|
2005-08-18 21:27:20 +00:00
|
|
|
ALL_INTERFACES := $(ALL_MODULES:.te=.if)
|
|
|
|
|
|
|
|
BASE_PKG := base.pp
|
|
|
|
BASE_FC := base.fc
|
|
|
|
|
2005-10-07 18:08:50 +00:00
|
|
|
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
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2005-09-16 13:36:26 +00:00
|
|
|
BASE_PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls $(POLDIR)/mcs
|
2005-08-18 21:27:20 +00:00
|
|
|
BASE_TE_FILES := $(BASE_MODS)
|
2005-10-27 18:43:37 +00:00
|
|
|
BASE_POST_TE_FILES := $(USER_FILES) $(POLDIR)/constraints
|
2005-08-18 21:27:20 +00:00
|
|
|
BASE_FC_FILES := $(BASE_MODS:.te=.fc)
|
|
|
|
|
|
|
|
MOD_MODULES := $(MOD_MODS:.te=.mod)
|
2006-01-12 16:07:59 +00:00
|
|
|
MOD_PKGS := $(MOD_MODS:.te=.pp)
|
2005-08-22 17:07:17 +00:00
|
|
|
|
2005-11-22 22:07:12 +00:00
|
|
|
# policy packages to install
|
|
|
|
INSTPKG := $(addprefix $(MODPKGDIR)/,$(BASE_PKG) $(MOD_PKGS))
|
|
|
|
|
2005-08-22 17:07:17 +00:00
|
|
|
# search layer dirs for source files
|
|
|
|
vpath %.te $(ALL_LAYERS)
|
|
|
|
vpath %.if $(ALL_LAYERS)
|
|
|
|
vpath %.fc $(ALL_LAYERS)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# default action: create all module packages
|
|
|
|
#
|
2005-10-10 21:02:49 +00:00
|
|
|
default: base
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2005-10-21 16:00:24 +00:00
|
|
|
all: base modules
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
base: $(BASE_PKG)
|
|
|
|
|
|
|
|
modules: $(MOD_PKGS)
|
|
|
|
|
2005-11-22 22:07:12 +00:00
|
|
|
install: $(INSTPKG) $(APPFILES)
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Load all configured modules
|
|
|
|
#
|
|
|
|
load: $(INSTPKG) $(APPFILES)
|
|
|
|
@echo "Loading configured modules."
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(SEMODULE) -s $(NAME) -b $(MODPKGDIR)/$(BASE_PKG) $(foreach mod,$(MOD_PKGS),-i $(MODPKGDIR)/$(mod))
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install policy packages
|
|
|
|
#
|
|
|
|
$(MODPKGDIR)/%.pp: %.pp
|
|
|
|
@mkdir -p $(MODPKGDIR)
|
2006-01-23 14:42:37 +00:00
|
|
|
@echo "Installing $(NAME) $(@F) policy package."
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 0644 $^ $(MODPKGDIR)
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Build module packages
|
|
|
|
#
|
|
|
|
tmp/%.mod: $(M4SUPPORT) tmp/generated_definitions.conf tmp/all_interfaces.conf %.te
|
|
|
|
@echo "Compliling $(NAME) $(@F) module"
|
2006-01-26 18:04:57 +00:00
|
|
|
$(call peruser-expansion,$(basename $(@F)),$@.role)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) m4 $(M4PARAM) -s $^ $@.role > $(@:.mod=.tmp)
|
|
|
|
$(verbose) $(CHECKMODULE) -m $(@:.mod=.tmp) -o $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
tmp/%.mod.fc: $(M4SUPPORT) %.fc
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) m4 $(M4PARAM) $(M4SUPPORT) $^ > $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
%.pp: tmp/%.mod tmp/%.mod.fc
|
|
|
|
@echo "Creating $(NAME) $(@F) policy package"
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(SEMOD_PKG) -o $@ -m $< -f $<.fc
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Create a base module package
|
|
|
|
#
|
|
|
|
$(BASE_PKG): tmp/base.mod $(BASE_FC)
|
|
|
|
@echo "Creating $(NAME) base module package"
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(SEMOD_PKG) -o $@ -m tmp/base.mod -f $(BASE_FC)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
tmp/base.mod: base.conf
|
|
|
|
@echo "Compiling $(NAME) base module"
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(CHECKMODULE) $^ -o $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
2005-11-22 22:07:12 +00:00
|
|
|
# Construct a base.conf
|
2005-08-18 21:27:20 +00:00
|
|
|
#
|
|
|
|
base.conf: $(BASE_SECTIONS)
|
2006-01-06 22:51:40 +00:00
|
|
|
@echo "Creating $(NAME) base module base.conf"
|
2005-08-18 21:27:20 +00:00
|
|
|
# checkpolicy can use the #line directives provided by -s for error reporting:
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) m4 -D self_contained_policy $(M4PARAM) -s $^ > tmp/$@.tmp
|
|
|
|
$(verbose) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < tmp/$@.tmp > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
# the ordering of these ocontexts matters:
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) grep ^portcon tmp/$@.tmp >> $@ || true
|
|
|
|
$(verbose) grep ^netifcon tmp/$@.tmp >> $@ || true
|
|
|
|
$(verbose) grep ^nodecon tmp/$@.tmp >> $@ || true
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
tmp/pre_te_files.conf: $(BASE_PRE_TE_FILES)
|
|
|
|
@test -d tmp || mkdir -p tmp
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) cat $^ > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-01-23 14:42:37 +00:00
|
|
|
tmp/generated_definitions.conf: $(BASE_TE_FILES)
|
2005-08-18 21:27:20 +00:00
|
|
|
@test -d tmp || mkdir -p tmp
|
2005-08-22 17:07:17 +00:00
|
|
|
# define all available object classes
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $@
|
2005-09-14 00:30:10 +00:00
|
|
|
# per-userdomain templates
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) echo "define(\`base_per_userdomain_template',\`" >> $@
|
|
|
|
$(verbose) for i in $(patsubst %.te,%,$(BASE_MODS)); do \
|
2005-09-14 00:30:10 +00:00
|
|
|
echo "ifdef(\`""$$i""_per_userdomain_template',\`""$$i""_per_userdomain_template("'$$*'")')" \
|
|
|
|
>> $@ ;\
|
|
|
|
done
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) echo "')" >> $@
|
2005-08-18 21:27:20 +00:00
|
|
|
# define foo.te
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) for i in $(notdir $(BASE_TE_FILES)); do \
|
2005-08-18 21:27:20 +00:00
|
|
|
echo "define(\`$$i')" >> $@ ;\
|
|
|
|
done
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(SETTUN) $(BOOLEANS) >> $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
tmp/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
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
tmp/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
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) cat $^ > $@
|
2006-01-26 18:04:57 +00:00
|
|
|
$(call parse-rolemap,base,$@)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
tmp/post_te_files.conf: $(BASE_POST_TE_FILES)
|
|
|
|
@test -d tmp || mkdir -p tmp
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) cat $^ > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
# 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
|
2006-01-26 20:35:55 +00:00
|
|
|
$(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
|
|
|
|
$(verbose) sed -r -e /^attribute/d -e '/^type /d' -e /^genfscon/d \
|
2005-08-18 21:27:20 +00:00
|
|
|
-e '/^sid /d' -e '/^fs_use_(xattr|task|trans)/d' \
|
|
|
|
< tmp/all_te_files.conf > tmp/only_te_rules.conf
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
2005-11-22 22:07:12 +00:00
|
|
|
# Construct a base.fc
|
2005-08-18 21:27:20 +00:00
|
|
|
#
|
2005-11-22 22:07:12 +00:00
|
|
|
$(BASE_FC): tmp/$(BASE_FC).tmp $(FCSORT)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(FCSORT) $< $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
tmp/$(BASE_FC).tmp: $(M4SUPPORT) tmp/generated_definitions.conf $(BASE_FC_FILES)
|
2005-08-18 21:27:20 +00:00
|
|
|
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
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) m4 $(M4PARAM) $^ > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-01-06 22:51:40 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Remove the dontaudit rules from the base.conf
|
|
|
|
#
|
|
|
|
enableaudit: base.conf
|
|
|
|
@test -d tmp || mkdir -p tmp
|
|
|
|
@echo "Removing dontaudit rules from base.conf"
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) grep -v dontaudit base.conf > tmp/base.audit
|
|
|
|
$(verbose) mv tmp/base.audit base.conf
|
2006-01-06 22:51:40 +00:00
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Appconfig files
|
|
|
|
#
|
|
|
|
$(APPDIR)/customizable_types: base.conf
|
|
|
|
@mkdir -p $(APPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) grep "^type .*customizable" $< | cut -d',' -f1 | cut -d' ' -f2 > tmp/customizable_types
|
|
|
|
$(verbose) install -m 644 tmp/customizable_types $@
|
2005-12-09 15:42:39 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Clean the sources
|
|
|
|
#
|
|
|
|
clean:
|
|
|
|
rm -f base.conf
|
2005-08-22 17:07:17 +00:00
|
|
|
rm -f *.pp
|
2005-09-12 15:17:39 +00:00
|
|
|
rm -f $(BASE_FC)
|
2005-11-22 22:07:12 +00:00
|
|
|
rm -fR tmp
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2005-11-22 22:07:12 +00:00
|
|
|
.PHONY: default all base modules install load clean
|