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-08-31 17:28:35 +00:00
|
|
|
all_modules := $(base_mods) $(mod_mods) $(off_mods)
|
|
|
|
all_interfaces := $(all_modules:.te=.if)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
base_pkg := $(builddir)base.pp
|
|
|
|
base_fc := $(builddir)base.fc
|
|
|
|
base_conf := $(builddir)base.conf
|
|
|
|
base_mod := $(tmpdir)/base.mod
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
users_extra := $(tmpdir)/users_extra
|
2006-02-15 19:46:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +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
|
|
|
|
2008-04-18 14:21:01 +00:00
|
|
|
base_pre_te_files := $(secclass) $(isids) $(avs) $(m4support) $(poldir)/mls $(poldir)/mcs $(policycaps)
|
2006-08-31 17:28:35 +00:00
|
|
|
base_te_files := $(base_mods)
|
|
|
|
base_post_te_files := $(user_files) $(poldir)/constraints
|
|
|
|
base_fc_files := $(base_mods:.te=.fc)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +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-08-31 17:28:35 +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-08-31 17:28:35 +00:00
|
|
|
vpath %.te $(all_layers)
|
|
|
|
vpath %.if $(all_layers)
|
|
|
|
vpath %.fc $(all_layers)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2007-12-17 20:17:34 +00:00
|
|
|
.SECONDARY: $(addprefix $(tmpdir)/,$(mod_pkgs:.pp=.mod)) $(addprefix $(tmpdir)/,$(mod_pkgs:.pp=.mod.fc))
|
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
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
base: $(base_pkg)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
modules: $(mod_pkgs)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
install: $(instpkg) $(appfiles)
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Load all configured modules
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
load: $(instpkg) $(appfiles)
|
2006-10-10 15:09:59 +00:00
|
|
|
# make sure two directories exist since they are not
|
|
|
|
# created by semanage
|
|
|
|
@mkdir -p $(policypath) $(dir $(fcpath))
|
2005-11-22 22:07:12 +00:00
|
|
|
@echo "Loading configured modules."
|
2006-08-31 17:28:35 +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-08-31 17:28:35 +00:00
|
|
|
$(modpkgdir)/%.pp: $(builddir)%.pp
|
|
|
|
@mkdir -p $(modpkgdir)
|
2006-01-23 14:42:37 +00:00
|
|
|
@echo "Installing $(NAME) $(@F) policy package."
|
2006-08-31 17:28:35 +00:00
|
|
|
$(verbose) $(INSTALL) -m 0644 $^ $(modpkgdir)
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Build module packages
|
|
|
|
#
|
2006-08-31 17:28:35 +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-08-31 17:28:35 +00:00
|
|
|
@test -d $(tmpdir) || mkdir -p $(tmpdir)
|
2006-09-06 22:07:25 +00:00
|
|
|
$(call perrole-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-08-31 17:28:35 +00:00
|
|
|
$(tmpdir)/%.mod.fc: $(m4support) %.fc
|
|
|
|
@test -d $(tmpdir) || mkdir -p $(tmpdir)
|
|
|
|
$(verbose) $(M4) $(M4PARAM) $(m4support) $^ > $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
$(builddir)%.pp: $(tmpdir)/%.mod $(tmpdir)/%.mod.fc
|
2005-11-22 22:07:12 +00:00
|
|
|
@echo "Creating $(NAME) $(@F) policy package"
|
2006-08-31 17:28:35 +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
|
|
|
|
#
|
2007-03-21 19:40:55 +00:00
|
|
|
$(base_pkg): $(base_mod) $(base_fc) $(users_extra) $(tmpdir)/seusers
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo "Creating $(NAME) base module package"
|
2006-08-31 17:28:35 +00:00
|
|
|
@test -d $(builddir) || mkdir -p $(builddir)
|
2007-03-21 19:40:55 +00:00
|
|
|
$(verbose) $(SEMOD_PKG) -o $@ -m $(base_mod) -f $(base_fc) -u $(users_extra) -s $(tmpdir)/seusers
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2007-09-27 13:41:09 +00:00
|
|
|
ifneq "$(UNK_PERMS)" ""
|
|
|
|
$(base_mod): CHECKMODULE += -U $(UNK_PERMS)
|
|
|
|
endif
|
2006-08-31 17:28:35 +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-10-04 17:25:34 +00:00
|
|
|
$(tmpdir)/seusers: $(seusers)
|
|
|
|
@mkdir -p $(tmpdir)
|
|
|
|
$(verbose) $(M4) $(M4PARAM) $(m4support) $^ | $(GREP) '^[a-z_]' > $@
|
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
$(users_extra): $(m4support) $(user_files)
|
|
|
|
@test -d $(tmpdir) || mkdir -p $(tmpdir)
|
2006-02-15 19:46:20 +00:00
|
|
|
$(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-08-31 17:28:35 +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-08-31 17:28:35 +00:00
|
|
|
$(tmpdir)/pre_te_files.conf: M4PARAM += -D self_contained_policy
|
|
|
|
$(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
|
|
|
|
2008-05-26 14:53:22 +00:00
|
|
|
$(tmpdir)/generated_definitions.conf:
|
2006-08-31 17:28:35 +00:00
|
|
|
@test -d $(tmpdir) || mkdir -p $(tmpdir)
|
2005-08-22 17:07:17 +00:00
|
|
|
# define all available object classes
|
2006-08-31 17:28:35 +00:00
|
|
|
$(verbose) $(genperm) $(avs) $(secclass) > $@
|
2006-09-06 22:07:25 +00:00
|
|
|
$(verbose) $(call create-base-per-role-tmpl,$(patsubst %.te,%,$(base_mods)),$@)
|
2006-08-31 17:28:35 +00:00
|
|
|
$(verbose) test -f $(booleans) && $(setbools) $(booleans) >> $@ || true
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
$(tmpdir)/global_bools.conf: M4PARAM += -D self_contained_policy
|
|
|
|
$(tmpdir)/global_bools.conf: $(m4support) $(tmpdir)/generated_definitions.conf $(globalbool) $(globaltun)
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(M4) $(M4PARAM) $^ > $@
|
|
|
|
|
2008-03-06 20:17:46 +00:00
|
|
|
$(tmpdir)/all_interfaces.conf: $(m4support) $(all_interfaces) $(m4iferror)
|
2006-08-31 17:28:35 +00:00
|
|
|
@test -d $(tmpdir) || mkdir -p $(tmpdir)
|
2006-03-20 20:54:56 +00:00
|
|
|
@echo "divert(-1)" > $@
|
2008-03-06 20:17:46 +00:00
|
|
|
$(verbose) $(M4) $^ >> $(tmpdir)/$(@F).tmp
|
2006-08-31 17:28:35 +00:00
|
|
|
$(verbose) $(SED) -e s/dollarsstar/\$$\*/g $(tmpdir)/$(@F).tmp >> $@
|
2006-03-20 20:54:56 +00:00
|
|
|
@echo "divert" >> $@
|
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
$(tmpdir)/rolemap.conf: M4PARAM += -D self_contained_policy
|
|
|
|
$(tmpdir)/rolemap.conf: $(rolemap)
|
2007-09-21 15:06:58 +00:00
|
|
|
$(verbose) echo "" > $@
|
2006-03-20 20:54:56 +00:00
|
|
|
$(call parse-rolemap,base,$@)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +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
|
|
|
|
ifeq "$(strip $(base_te_files))" ""
|
|
|
|
$(error No enabled modules! $(notdir $(mod_conf)) may need to be generated by using "make conf")
|
2005-08-18 21:27:20 +00:00
|
|
|
endif
|
2006-08-31 17:28:35 +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-08-31 17:28:35 +00:00
|
|
|
$(tmpdir)/post_te_files.conf: M4PARAM += -D self_contained_policy
|
2008-11-05 16:10:46 +00:00
|
|
|
$(tmpdir)/post_te_files.conf: $(m4support) $(tmpdir)/generated_definitions.conf $(base_post_te_files)
|
2006-08-31 17:28:35 +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-08-31 17:28:35 +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
|
|
|
|
$(verbose) $(get_type_attr_decl) $(tmpdir)/all_te_files.conf | $(SORT) > $(tmpdir)/all_attrs_types.conf
|
|
|
|
$(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:
|
2006-08-31 17:28:35 +00:00
|
|
|
$(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-08-31 17:28:35 +00:00
|
|
|
$(base_fc): $(tmpdir)/$(notdir $(base_fc)).tmp $(fcsort)
|
|
|
|
$(verbose) $(fcsort) $< $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
$(tmpdir)/$(notdir $(base_fc)).tmp: $(m4support) $(tmpdir)/generated_definitions.conf $(base_fc_files)
|
|
|
|
ifeq ($(base_fc_files),)
|
|
|
|
$(error No enabled modules! $(notdir $(mod_conf)) may need to be generated by using "make conf")
|
2005-08-18 21:27:20 +00:00
|
|
|
endif
|
|
|
|
@echo "Creating $(NAME) base module file contexts."
|
2006-08-31 17:28:35 +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
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Appconfig files
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
$(appdir)/customizable_types: $(base_conf)
|
|
|
|
@mkdir -p $(appdir)
|
|
|
|
$(verbose) $(GREP) '^[[:blank:]]*type .*customizable' $< | cut -d';' -f1 | cut -d',' -f1 | cut -d' ' -f2 | $(SORT) -u > $(tmpdir)/customizable_types
|
|
|
|
$(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
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
validate: $(base_pkg) $(mod_pkgs)
|
2006-05-02 20:14:41 +00:00
|
|
|
@echo "Validating policy linking."
|
2006-08-31 17:28:35 +00:00
|
|
|
$(verbose) $(SEMOD_LNK) -o $(tmpdir)/test.lnk $^
|
|
|
|
$(verbose) $(SEMOD_EXP) $(tmpdir)/test.lnk $(tmpdir)/policy.bin
|
2006-05-02 20:14:41 +00:00
|
|
|
@echo "Success."
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Clean the sources
|
|
|
|
#
|
|
|
|
clean:
|
2006-08-31 17:28:35 +00:00
|
|
|
rm -f $(base_conf)
|
|
|
|
rm -f $(base_fc)
|
|
|
|
rm -f $(builddir)*.pp
|
2006-05-25 15:14:19 +00:00
|
|
|
rm -f $(net_contexts)
|
2006-08-31 17:28:35 +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
|