2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Rules and Targets for building monolithic policies
|
|
|
|
#
|
|
|
|
|
2006-02-16 17:11:58 +00:00
|
|
|
POLICY_CONF = $(BUILDDIR)policy.conf
|
|
|
|
FC = $(BUILDDIR)file_contexts
|
|
|
|
POLVER = $(BUILDDIR)policy.$(PV)
|
|
|
|
HOMEDIR_TEMPLATE = $(BUILDDIR)homedir_template
|
2006-02-15 17:59:58 +00:00
|
|
|
|
2006-03-20 20:54:56 +00:00
|
|
|
M4PARAM += -D self_contained_policy
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
# install paths
|
|
|
|
POLICYPATH = $(INSTALLDIR)/policy
|
2006-02-16 17:11:58 +00:00
|
|
|
LOADPATH = $(POLICYPATH)/$(notdir $(POLVER))
|
2005-08-18 21:27:20 +00:00
|
|
|
HOMEDIRPATH = $(CONTEXTPATH)/files/homedir_template
|
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
APPFILES += $(INSTALLDIR)/booleans
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2005-11-22 22:07:12 +00:00
|
|
|
# for monolithic policy use all base and module to create policy
|
2005-11-25 15:55:04 +00:00
|
|
|
ALL_MODULES := $(strip $(BASE_MODS) $(MOD_MODS))
|
2006-03-27 15:43:20 +00:00
|
|
|
# off module interfaces included to make sure all interfaces are expanded.
|
|
|
|
ALL_INTERFACES := $(ALL_MODULES:.te=.if) $(OFF_MODS:.te=.if)
|
2005-08-18 21:27:20 +00:00
|
|
|
ALL_TE_FILES := $(ALL_MODULES)
|
|
|
|
ALL_FC_FILES := $(ALL_MODULES:.te=.fc)
|
|
|
|
|
2005-09-16 13:36:26 +00:00
|
|
|
PRE_TE_FILES := $(SECCLASS) $(ISIDS) $(AVS) $(M4SUPPORT) $(POLDIR)/mls $(POLDIR)/mcs
|
2005-12-06 14:35:58 +00:00
|
|
|
POST_TE_FILES := $(USER_FILES) $(POLDIR)/constraints
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-03-20 20:54:56 +00:00
|
|
|
POLICY_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-11-22 22:07:12 +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-11-22 22:07:12 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# default action: build policy locally
|
|
|
|
#
|
|
|
|
default: policy
|
|
|
|
|
|
|
|
policy: $(POLVER)
|
|
|
|
|
|
|
|
install: $(LOADPATH) $(FCPATH) $(APPFILES) $(USERPATH)/local.users
|
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
load: $(TMPDIR)/load
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-01 13:22:14 +00:00
|
|
|
checklabels: $(FCPATH)
|
|
|
|
restorelabels: $(FCPATH)
|
|
|
|
relabel: $(FCPATH)
|
|
|
|
resetlabels: $(FCPATH)
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Build a binary policy locally
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(POLVER): $(POLICY_CONF)
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo "Compiling $(NAME) $(POLVER)"
|
|
|
|
ifneq ($(PV),$(KV))
|
|
|
|
@echo
|
|
|
|
@echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?"
|
|
|
|
@echo
|
|
|
|
endif
|
2006-02-16 17:11:58 +00:00
|
|
|
$(verbose) $(CHECKPOLICY) $^ -o $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install a binary policy
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(LOADPATH): $(POLICY_CONF)
|
2005-08-18 21:27:20 +00:00
|
|
|
@mkdir -p $(POLICYPATH)
|
|
|
|
@echo "Compiling and installing $(NAME) $(LOADPATH)"
|
|
|
|
ifneq ($(PV),$(KV))
|
|
|
|
@echo
|
|
|
|
@echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?"
|
|
|
|
@echo
|
|
|
|
endif
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(CHECKPOLICY) $^ -o $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Load the binary policy
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
reload $(TMPDIR)/load: $(LOADPATH) $(FCPATH) $(APPFILES)
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo "Loading $(NAME) $(LOADPATH)"
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(LOADPOLICY) -q $(LOADPATH)
|
2006-02-15 17:59:58 +00:00
|
|
|
@touch $(TMPDIR)/load
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Construct a monolithic policy.conf
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(POLICY_CONF): $(POLICY_SECTIONS)
|
|
|
|
@echo "Creating $(NAME) $(@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-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/pre_te_files.conf: $(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-16 16:45:56 +00:00
|
|
|
$(TMPDIR)/generated_definitions.conf: $(ALL_TE_FILES)
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-03-21 20:23:29 +00:00
|
|
|
# define all available object classes
|
|
|
|
$(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $@
|
|
|
|
# per-userdomain templates:
|
|
|
|
$(verbose) echo "define(\`base_per_userdomain_template',\`" >> $@
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(foreach mod,$(basename $(notdir $(ALL_MODULES))), \
|
|
|
|
echo "ifdef(\`""$(mod)""_per_userdomain_template',\`""$(mod)""_per_userdomain_template("'$$*'")')" >> $@ ;)
|
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: $(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)
|
2005-08-18 21:27:20 +00:00
|
|
|
ifeq ($(ALL_INTERFACES),)
|
|
|
|
$(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-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" >> $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-03-20 20:54:56 +00:00
|
|
|
$(TMPDIR)/rolemap.conf: $(ROLEMAP)
|
|
|
|
$(call parse-rolemap,base,$@)
|
|
|
|
|
|
|
|
$(TMPDIR)/all_te_files.conf: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(TMPDIR)/all_interfaces.conf $(ALL_TE_FILES) $(TMPDIR)/rolemap.conf
|
2005-08-18 21:27:20 +00:00
|
|
|
ifeq ($(ALL_TE_FILES),)
|
|
|
|
$(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: $(M4SUPPORT) $(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
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Remove the dontaudit rules from the policy.conf
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
enableaudit: $(POLICY_CONF)
|
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
|
|
|
@echo "Removing dontaudit rules from $(notdir $(POLICY_CONF))"
|
2006-06-12 15:42:13 +00:00
|
|
|
$(verbose) $(GREP) -v dontaudit $^ > $(TMPDIR)/policy.audit
|
2006-02-15 17:59:58 +00:00
|
|
|
$(verbose) mv $(TMPDIR)/policy.audit $(POLICY_CONF)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Construct file_contexts
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(FC): $(TMPDIR)/$(notdir $(FC)).tmp $(FCSORT)
|
2006-04-07 15:16:49 +00:00
|
|
|
$(verbose) $(FCSORT) $< $@
|
2006-03-20 20:54:56 +00:00
|
|
|
$(verbose) $(GREP) -e HOME -e ROLE $@ > $(HOMEDIR_TEMPLATE)
|
|
|
|
$(verbose) $(SED) -i -e /HOME/d -e /ROLE/d $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
$(TMPDIR)/$(notdir $(FC)).tmp: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(ALL_FC_FILES)
|
2005-08-18 21:27:20 +00:00
|
|
|
ifeq ($(ALL_FC_FILES),)
|
|
|
|
$(error No enabled modules! $(notdir $(MOD_CONF)) may need to be generated by using "make conf")
|
|
|
|
endif
|
|
|
|
@echo "Creating $(NAME) 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-05-15 15:21:43 +00:00
|
|
|
$(HOMEDIR_TEMPLATE): $(FC)
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install file_contexts
|
|
|
|
#
|
|
|
|
$(FCPATH): $(FC) $(LOADPATH) $(USERPATH)/system.users
|
|
|
|
@echo "Validating $(NAME) file_contexts."
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) $(SETFILES) -q -c $(LOADPATH) $(FC)
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo "Installing file_contexts."
|
|
|
|
@mkdir -p $(CONTEXTPATH)/files
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $(FC) $(FCPATH)
|
|
|
|
$(verbose) install -m 644 $(HOMEDIR_TEMPLATE) $(HOMEDIRPATH)
|
2006-05-15 15:21:43 +00:00
|
|
|
$(verbose) $(genhomedircon) -d $(TOPDIR) -t $(NAME) $(USEPWD)
|
|
|
|
ifeq "$(DISTRO)" "rhel4"
|
|
|
|
# Setfiles in RHEL4 does not look at file_contexts.homedirs.
|
|
|
|
$(verbose) cat $@.homedirs >> $@
|
|
|
|
# Delete the file_contexts.homedirs in case the toolchain has
|
|
|
|
# been updated, to prevent duplicate match errors.
|
|
|
|
$(verbose) rm -f $@.homedirs
|
2006-04-07 15:01:10 +00:00
|
|
|
endif
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2005-10-12 19:13:49 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Run policy source checks
|
|
|
|
#
|
2006-02-16 17:11:58 +00:00
|
|
|
check: $(BUILDDIR)check.res
|
|
|
|
$(BUILDDIR)check.res: $(POLICY_CONF) $(FC)
|
|
|
|
$(SECHECK) -s --profile=development --policy=$(POLICY_CONF) --fcfile=$(FC) > $@
|
2005-10-12 19:13:49 +00:00
|
|
|
|
2006-02-16 17:11:58 +00:00
|
|
|
longcheck: $(BUILDDIR)longcheck.res
|
|
|
|
$(BUILDDIR)longcheck.res: $(POLICY_CONF) $(FC)
|
|
|
|
$(SECHECK) -s --profile=all --policy=$(POLICY_CONF) --fcfile=$(FC) > $@
|
2005-10-12 19:13:49 +00:00
|
|
|
|
2005-12-09 15:42:39 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Appconfig files
|
|
|
|
#
|
2006-03-15 15:15:45 +00:00
|
|
|
$(APPDIR)/customizable_types: $(POLICY_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-21 15:42:45 +00:00
|
|
|
$(verbose) install -m 644 $(TMPDIR)/customizable_types $@
|
2005-12-09 15:42:39 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Clean the sources
|
|
|
|
#
|
|
|
|
clean:
|
2006-02-15 17:59:58 +00:00
|
|
|
rm -f $(POLICY_CONF)
|
2006-02-16 17:11:58 +00:00
|
|
|
rm -f $(POLVER)
|
2005-08-18 21:27:20 +00:00
|
|
|
rm -f $(FC)
|
2005-11-22 22:07:12 +00:00
|
|
|
rm -f $(HOMEDIR_TEMPLATE)
|
2006-05-25 15:14:19 +00:00
|
|
|
rm -f $(net_contexts)
|
2005-10-12 19:13:49 +00:00
|
|
|
rm -f *.res
|
2006-02-15 17:59:58 +00:00
|
|
|
rm -fR $(TMPDIR)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2005-10-12 19:13:49 +00:00
|
|
|
.PHONY: default policy install load reload enableaudit checklabels restorelabels relabel check longcheck clean
|