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)
|
|
|
|
|
2006-02-16 17:11:58 +00:00
|
|
|
BASE_PKG := $(BUILDDIR)base.pp
|
|
|
|
BASE_FC := $(BUILDDIR)base.fc
|
|
|
|
BASE_CONF := $(BUILDDIR)base.conf
|
2006-02-15 17:59:58 +00:00
|
|
|
BASE_MOD := $(TMPDIR)/base.mod
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-15 19:46:20 +00:00
|
|
|
USERS_EXTRA := $(TMPDIR)/users_extra
|
|
|
|
|
2006-03-20 20:54:56 +00:00
|
|
|
BASE_SECTIONS := $(TMPDIR)/pre_te_files.conf $(TMPDIR)/all_attrs_types.conf $(TMPDIR)/global_bools.conf $(TMPDIR)/only_te_rules.conf $(TMPDIR)/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-02-16 17:11:58 +00:00
|
|
|
MOD_PKGS := $(addprefix $(BUILDDIR),$(notdir $(MOD_MODS:.te=.pp)))
|
2005-08-22 17:07:17 +00:00
|
|
|
|
2005-11-22 22:07:12 +00:00
|
|
|
# policy packages to install
|
2006-02-15 17:59:58 +00:00
|
|
|
INSTPKG := $(addprefix $(MODPKGDIR)/,$(notdir $(BASE_PKG)) $(MOD_PKGS))
|
2005-11-22 22:07:12 +00:00
|
|
|
|
2005-08-22 17:07:17 +00:00
|
|
|
# search layer dirs for source files
|
2006-02-15 18:35:02 +00:00
|
|
|
vpath %.te $(ALL_LAYERS)
|
|
|
|
vpath %.if $(ALL_LAYERS)
|
|
|
|
vpath %.fc $(ALL_LAYERS)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-05-26 14:33:44 +00:00
|
|
|
# broken in make 3.81:
|
|
|
|
#.SECONDARY:
|
2006-02-13 22:00:58 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# default action: create all module packages
|
|
|
|
#
|
2006-02-15 21:35:27 +00:00
|
|
|
default: policy
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-15 21:35:27 +00:00
|
|
|
all policy: base modules
|
2005-10-21 16:00:24 +00:00
|
|
|
|
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-02-15 17:59:58 +00:00
|
|
|
$(verbose) $(SEMODULE) -s $(NAME) -b $(MODPKGDIR)/$(notdir $(BASE_PKG)) $(foreach mod,$(MOD_PKGS),-i $(MODPKGDIR)/$(mod))
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install policy packages
|
|
|
|
#
|
2006-02-16 17:11:58 +00:00
|
|
|
$(MODPKGDIR)/%.pp: $(BUILDDIR)%.pp
|
2005-11-22 22:07:12 +00:00
|
|
|
@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
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/%.mod: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(TMPDIR)/all_interfaces.conf %.te
|
2005-11-22 22:07:12 +00:00
|
|
|
@echo "Compliling $(NAME) $(@F) module"
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-01-26 18:04:57 +00:00
|
|
|
$(call peruser-expansion,$(basename $(@F)),$@.role)
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(M4) $(M4PARAM) -s $^ $@.role > $(@:.mod=.tmp)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(CHECKMODULE) -m $(@:.mod=.tmp) -o $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/%.mod.fc: $(M4SUPPORT) %.fc
|
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(M4) $(M4PARAM) $(M4SUPPORT) $^ > $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
2006-02-16 17:11:58 +00:00
|
|
|
$(BUILDDIR)%.pp: $(TMPDIR)/%.mod $(TMPDIR)/%.mod.fc
|
2005-11-22 22:07:12 +00:00
|
|
|
@echo "Creating $(NAME) $(@F) policy package"
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
|
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
|
|
|
|
#
|
2006-08-07 17:25:09 +00:00
|
|
|
$(BASE_PKG): $(BASE_MOD) $(BASE_FC) $(USERS_EXTRA) $(SEUSERS) $(net_contexts)
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo "Creating $(NAME) base module package"
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
|
2006-08-07 17:25:09 +00:00
|
|
|
$(verbose) $(SEMOD_PKG) -o $@ -m $(BASE_MOD) -f $(BASE_FC) -u $(USERS_EXTRA) -s $(SEUSERS) -n $(net_contexts)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
$(BASE_MOD): $(BASE_CONF)
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo "Compiling $(NAME) base module"
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(CHECKMODULE) $^ -o $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-15 19:46:20 +00:00
|
|
|
$(USERS_EXTRA): $(M4SUPPORT) $(USER_FILES)
|
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
|
|
$(verbose) $(M4) $(M4PARAM) -D users_extra $^ | \
|
|
|
|
$(SED) -r -n -e 's/^[[:blank:]]*//g' -e '/^user/p' > $@
|
|
|
|
|
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
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(BASE_CONF): $(BASE_SECTIONS)
|
2006-02-17 14:21:05 +00:00
|
|
|
@echo "Creating $(NAME) base module $(@F)"
|
2006-03-20 20:54:56 +00:00
|
|
|
@test -d $(@D) || mkdir -p $(@D)
|
|
|
|
$(verbose) cat $^ > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-03-20 20:54:56 +00:00
|
|
|
$(TMPDIR)/pre_te_files.conf: M4PARAM += -D self_contained_policy
|
2006-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/pre_te_files.conf: $(BASE_PRE_TE_FILES)
|
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(M4) $(M4PARAM) $^ > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/generated_definitions.conf: $(BASE_TE_FILES)
|
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
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 "')" >> $@
|
2006-02-16 17:11:58 +00:00
|
|
|
$(verbose) test -f $(BOOLEANS) && $(SETBOOLS) $(BOOLEANS) >> $@ || true
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-03-20 20:54:56 +00:00
|
|
|
$(TMPDIR)/global_bools.conf: M4PARAM += -D self_contained_policy
|
|
|
|
$(TMPDIR)/global_bools.conf: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(GLOBALBOOL) $(GLOBALTUN)
|
|
|
|
$(verbose) $(M4) $(M4PARAM) $^ > $@
|
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/all_interfaces.conf: $(M4SUPPORT) $(ALL_INTERFACES)
|
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-05-02 14:34:32 +00:00
|
|
|
@echo "ifdef(\`__if_error',\`m4exit(1)')" > $(TMPDIR)/iferror.m4
|
2006-03-20 20:54:56 +00:00
|
|
|
@echo "divert(-1)" > $@
|
2006-05-02 14:34:32 +00:00
|
|
|
$(verbose) $(M4) $^ $(TMPDIR)/iferror.m4 >> $(TMPDIR)/$(@F).tmp
|
|
|
|
$(verbose) $(SED) -e s/dollarsstar/\$$\*/g $(TMPDIR)/$(@F).tmp >> $@
|
2006-03-20 20:54:56 +00:00
|
|
|
@echo "divert" >> $@
|
|
|
|
|
|
|
|
$(TMPDIR)/rolemap.conf: M4PARAM += -D self_contained_policy
|
|
|
|
$(TMPDIR)/rolemap.conf: $(ROLEMAP)
|
|
|
|
$(call parse-rolemap,base,$@)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-03-20 20:54:56 +00:00
|
|
|
$(TMPDIR)/all_te_files.conf: M4PARAM += -D self_contained_policy
|
|
|
|
$(TMPDIR)/all_te_files.conf: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(TMPDIR)/all_interfaces.conf $(BASE_TE_FILES) $(TMPDIR)/rolemap.conf
|
2006-06-28 13:55:52 +00:00
|
|
|
ifeq "$(strip $(BASE_TE_FILES))" ""
|
2005-08-18 21:27:20 +00:00
|
|
|
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
|
|
|
|
endif
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(M4) $(M4PARAM) -s $^ > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-03-20 20:54:56 +00:00
|
|
|
$(TMPDIR)/post_te_files.conf: M4PARAM += -D self_contained_policy
|
|
|
|
$(TMPDIR)/post_te_files.conf: $(M4SUPPORT) $(BASE_POST_TE_FILES)
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(M4) $(M4PARAM) $^ > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
# extract attributes and put them first. extract post te stuff
|
2006-03-20 20:54:56 +00:00
|
|
|
# like genfscon and put last.
|
2006-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/all_attrs_types.conf $(TMPDIR)/only_te_rules.conf $(TMPDIR)/all_post.conf: $(TMPDIR)/all_te_files.conf $(TMPDIR)/post_te_files.conf
|
2006-03-21 18:14:48 +00:00
|
|
|
$(verbose) $(get_type_attr_decl) $(TMPDIR)/all_te_files.conf | $(SORT) > $(TMPDIR)/all_attrs_types.conf
|
2006-02-15 17:59:58 +00:00
|
|
|
$(verbose) cat $(TMPDIR)/post_te_files.conf > $(TMPDIR)/all_post.conf
|
2006-03-20 20:54:56 +00:00
|
|
|
# these have to run individually because order matters:
|
|
|
|
$(verbose) $(GREP) '^sid ' $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
|
|
|
|
$(verbose) $(GREP) '^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) $(GREP) ^portcon $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
|
|
|
|
$(verbose) $(GREP) ^netifcon $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
|
|
|
|
$(verbose) $(GREP) ^nodecon $(TMPDIR)/all_te_files.conf >> $(TMPDIR)/all_post.conf || true
|
|
|
|
$(verbose) $(comment_move_decl) $(TMPDIR)/all_te_files.conf > $(TMPDIR)/only_te_rules.conf
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
2005-11-22 22:07:12 +00:00
|
|
|
# Construct a base.fc
|
2005-08-18 21:27:20 +00:00
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(BASE_FC): $(TMPDIR)/$(notdir $(BASE_FC)).tmp $(FCSORT)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(FCSORT) $< $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/$(notdir $(BASE_FC)).tmp: $(M4SUPPORT) $(TMPDIR)/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."
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-03-20 20:54:56 +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
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
enableaudit: $(BASE_CONF)
|
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-02-17 14:21:05 +00:00
|
|
|
@echo "Removing dontaudit rules from $(^F)"
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(GREP) -v dontaudit $(BASE_CONF) > $(TMPDIR)/base.audit
|
2006-02-15 17:59:58 +00:00
|
|
|
$(verbose) mv $(TMPDIR)/base.audit $(BASE_CONF)
|
2006-01-06 22:51:40 +00:00
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Appconfig files
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(APPDIR)/customizable_types: $(BASE_CONF)
|
2005-12-09 15:42:39 +00:00
|
|
|
@mkdir -p $(APPDIR)
|
2006-04-19 15:25:22 +00:00
|
|
|
$(verbose) $(GREP) '^[[:blank:]]*type .*customizable' $< | cut -d';' -f1 | cut -d',' -f1 | cut -d' ' -f2 | $(SORT) -u > $(TMPDIR)/customizable_types
|
2006-02-15 17:59:58 +00:00
|
|
|
$(verbose) install -m 644 $(TMPDIR)/customizable_types $@
|
2005-12-09 15:42:39 +00:00
|
|
|
|
2006-05-02 20:14:41 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Validate linking and expanding of modules
|
|
|
|
#
|
|
|
|
validate: $(BASE_PKG) $(MOD_PKGS)
|
|
|
|
@echo "Validating policy linking."
|
|
|
|
$(verbose) $(SEMOD_LNK) -o $(TMPDIR)/test.lnk $^
|
|
|
|
$(verbose) $(SEMOD_EXP) $(TMPDIR)/test.lnk $(TMPDIR)/policy.bin
|
|
|
|
@echo "Success."
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Clean the sources
|
|
|
|
#
|
|
|
|
clean:
|
2006-02-15 17:59:58 +00:00
|
|
|
rm -f $(BASE_CONF)
|
2005-09-12 15:17:39 +00:00
|
|
|
rm -f $(BASE_FC)
|
2006-02-16 17:11:58 +00:00
|
|
|
rm -f $(BUILDDIR)*.pp
|
2006-05-25 15:14:19 +00:00
|
|
|
rm -f $(net_contexts)
|
2006-02-15 17:59:58 +00:00
|
|
|
rm -fR $(TMPDIR)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-05-02 20:14:41 +00:00
|
|
|
.PHONY: default all policy base modules install load clean validate
|