2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Rules and Targets for building monolithic policies
|
|
|
|
#
|
|
|
|
|
|
|
|
ALL_MODULES := $(filter $(BASE_MODS) $(MOD_MODS),$(DETECTED_MODS))
|
|
|
|
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-09-12 15:17:39 +00:00
|
|
|
BASE_POST_TE_FILES := $(POLDIR)/systemuser $(POLDIR)/constraints
|
2005-08-18 21:27:20 +00:00
|
|
|
BASE_FC_FILES := $(BASE_MODS:.te=.fc)
|
|
|
|
|
|
|
|
MOD_MODULES := $(MOD_MODS:.te=.mod)
|
2005-08-22 17:07:17 +00:00
|
|
|
MOD_PKGS := $(notdir $(MOD_MODS:.te=.pp))
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
base: $(BASE_PKG)
|
|
|
|
|
|
|
|
modules: $(MOD_PKGS)
|
|
|
|
|
|
|
|
#policy: $(POLVER)
|
|
|
|
#install: $(LOADPATH) $(FCPATH) $(APPFILES) $(USERPATH)/local.users
|
|
|
|
#load: tmp/load
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Create a base module package
|
|
|
|
#
|
|
|
|
$(BASE_PKG): tmp/base.mod $(BASE_FC)
|
|
|
|
@echo "Creating $(NAME) base module package"
|
|
|
|
$(QUIET) $(SEMOD_PKG) $@ $^
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Compile a base module
|
|
|
|
#
|
|
|
|
tmp/base.mod: base.conf
|
|
|
|
@echo "Compiling $(NAME) base module"
|
|
|
|
$(QUIET) $(CHECKMODULE) $^ -o $@
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Construct a base module policy.conf
|
|
|
|
#
|
|
|
|
base.conf: $(BASE_SECTIONS)
|
|
|
|
@echo "Creating $(NAME) base module policy.conf"
|
|
|
|
# checkpolicy can use the #line directives provided by -s for error reporting:
|
2005-09-21 13:26:30 +00:00
|
|
|
$(QUIET) m4 -D self_contained_policy $(M4PARAM) -s $^ > tmp/$@.tmp
|
2005-08-18 21:27:20 +00:00
|
|
|
$(QUIET) sed -e /^portcon/d -e /^nodecon/d -e /^netifcon/d < tmp/$@.tmp > $@
|
|
|
|
# the ordering of these ocontexts matters:
|
|
|
|
$(QUIET) grep ^portcon tmp/$@.tmp >> $@ || true
|
|
|
|
$(QUIET) grep ^netifcon tmp/$@.tmp >> $@ || true
|
|
|
|
$(QUIET) grep ^nodecon tmp/$@.tmp >> $@ || true
|
|
|
|
|
|
|
|
tmp/pre_te_files.conf: $(BASE_PRE_TE_FILES)
|
|
|
|
@test -d tmp || mkdir -p tmp
|
|
|
|
$(QUIET) cat $^ > $@
|
|
|
|
|
2005-08-19 20:00:05 +00:00
|
|
|
tmp/generated_definitions.conf: $(ALL_LAYERS) $(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
|
|
|
|
$(QUIET) $(GENPERM) $(AVS) $(SECCLASS) > $@
|
2005-09-14 00:30:10 +00:00
|
|
|
# per-userdomain templates
|
|
|
|
$(QUIET) echo "define(\`per_userdomain_templates',\`" >> $@
|
|
|
|
$(QUIET) for i in $(patsubst %.te,%,$(notdir $(ALL_MODULES))); do \
|
|
|
|
echo "ifdef(\`""$$i""_per_userdomain_template',\`""$$i""_per_userdomain_template("'$$*'")')" \
|
|
|
|
>> $@ ;\
|
|
|
|
done
|
|
|
|
$(QUIET) echo "')" >> $@
|
2005-08-18 21:27:20 +00:00
|
|
|
# define foo.te
|
2005-08-19 20:00:05 +00:00
|
|
|
$(QUIET) for i in $(notdir $(BASE_TE_FILES)); do \
|
2005-08-18 21:27:20 +00:00
|
|
|
echo "define(\`$$i')" >> $@ ;\
|
|
|
|
done
|
2005-10-07 18:08:50 +00:00
|
|
|
$(QUIET) $(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
|
|
|
|
$(QUIET) m4 $^ | sed -e s/dollarsstar/\$$\*/g > $@
|
|
|
|
|
|
|
|
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
|
|
|
|
$(QUIET) cat $^ > $@
|
|
|
|
|
|
|
|
tmp/post_te_files.conf: $(BASE_POST_TE_FILES)
|
|
|
|
@test -d tmp || mkdir -p tmp
|
|
|
|
$(QUIET) 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
|
|
|
|
$(QUIET) grep ^attribute tmp/all_te_files.conf > tmp/all_attrs_types.conf || true
|
|
|
|
$(QUIET) grep '^type ' tmp/all_te_files.conf >> tmp/all_attrs_types.conf
|
|
|
|
$(QUIET) cat tmp/post_te_files.conf > tmp/all_post.conf
|
|
|
|
$(QUIET) grep '^sid ' tmp/all_te_files.conf >> tmp/all_post.conf || true
|
|
|
|
$(QUIET) egrep '^fs_use_(xattr|task|trans)' tmp/all_te_files.conf >> tmp/all_post.conf || true
|
|
|
|
$(QUIET) grep ^genfscon tmp/all_te_files.conf >> tmp/all_post.conf || true
|
|
|
|
$(QUIET) 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
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Construct base module file contexts
|
|
|
|
#
|
2005-09-12 15:17:39 +00:00
|
|
|
$(BASE_FC): $(M4SUPPORT) tmp/generated_definitions.conf $(BASE_FC_FILES) $(FCSORT)
|
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
|
|
|
|
$(QUIET) m4 $(M4PARAM) $(M4SUPPORT) tmp/generated_definitions.conf $(BASE_FC_FILES) > tmp/$@.tmp
|
|
|
|
$(QUIET) grep -e HOME -e ROLE tmp/$@.tmp > $(HOMEDIR_TEMPLATE)
|
|
|
|
$(QUIET) sed -i -e /HOME/d -e /ROLE/d tmp/$@.tmp
|
|
|
|
$(QUIET) $(FCSORT) tmp/$@.tmp $@
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
2005-08-22 17:07:17 +00:00
|
|
|
# Build module packages
|
2005-08-18 21:27:20 +00:00
|
|
|
#
|
2005-08-22 17:07:17 +00:00
|
|
|
tmp/%.mod: $(M4SUPPORT) tmp/generated_definitions.conf tmp/all_interfaces.conf %.te
|
|
|
|
@echo "Compliling $(NAME) $(@F) module"
|
|
|
|
$(QUIET) m4 $(M4PARAM) -s $^ > $(@:.mod=.tmp)
|
|
|
|
$(QUIET) $(CHECKMODULE) -m $(@:.mod=.tmp) -o $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2005-08-22 17:07:17 +00:00
|
|
|
%.pp: tmp/%.mod %.fc
|
|
|
|
@echo "Creating $(NAME) $(@F) policy package"
|
|
|
|
$(QUIET) $(SEMOD_PKG) $@ $^
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Clean the sources
|
|
|
|
#
|
|
|
|
clean:
|
|
|
|
rm -fR tmp
|
|
|
|
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-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
.PHONY: default base modules clean
|