2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Rules and Targets for building monolithic policies
|
|
|
|
#
|
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
# determine the policy version and current kernel version if possible
|
|
|
|
pv := $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ')
|
2013-06-06 13:27:40 +00:00
|
|
|
kv := $(shell $(policyvers))
|
2006-08-31 17:28:35 +00:00
|
|
|
|
|
|
|
# dont print version warnings if we are unable to determine
|
|
|
|
# the currently running kernel's policy version
|
|
|
|
ifeq "$(kv)" ""
|
|
|
|
kv := $(pv)
|
|
|
|
endif
|
|
|
|
|
|
|
|
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
|
2006-08-31 17:28:35 +00:00
|
|
|
loadpath = $(policypath)/$(notdir $(polver))
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2009-10-23 15:20:07 +00:00
|
|
|
appfiles += $(installdir)/booleans $(installdir)/seusers $(userpath)/local.users
|
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
|
2006-08-31 17:28:35 +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.
|
2006-08-31 17:28:35 +00:00
|
|
|
all_interfaces := $(all_modules:.te=.if) $(off_mods:.te=.if)
|
|
|
|
all_te_files := $(all_modules)
|
|
|
|
all_fc_files := $(all_modules:.te=.fc)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2014-04-28 14:00:36 +00:00
|
|
|
pre_te_files := $(secclass) $(isids) $(avs) $(ctx_defaults) $(m4support) $(poldir)/mls $(poldir)/mcs $(policycaps)
|
2006-08-31 17:28:35 +00:00
|
|
|
post_te_files := $(user_files) $(poldir)/constraints
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +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-08-31 17:28:35 +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
|
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
policy: $(polver)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2007-03-21 19:40:55 +00:00
|
|
|
install: $(loadpath) $(fcpath) $(appfiles)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
load: $(tmpdir)/load
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
checklabels: $(fcpath)
|
|
|
|
restorelabels: $(fcpath)
|
|
|
|
relabel: $(fcpath)
|
|
|
|
resetlabels: $(fcpath)
|
2006-02-01 13:22:14 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Build a binary policy locally
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
$(polver): $(policy_conf)
|
|
|
|
@echo "Compiling $(NAME) $(polver)"
|
|
|
|
ifneq ($(pv),$(kv))
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo
|
|
|
|
@echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?"
|
|
|
|
@echo
|
|
|
|
endif
|
2014-06-19 14:48:38 +00:00
|
|
|
$(verbose) $(CHECKPOLICY) -U $(UNK_PERMS) $^ -o $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install a binary policy
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
$(loadpath): $(policy_conf)
|
|
|
|
@echo "Compiling and installing $(NAME) $(loadpath)"
|
|
|
|
ifneq ($(pv),$(kv))
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo
|
|
|
|
@echo "WARNING: Policy version mismatch! Is your OUTPUT_POLICY set correctly?"
|
|
|
|
@echo
|
|
|
|
endif
|
2011-10-19 14:59:16 +00:00
|
|
|
@$(INSTALL) -d -m 0755 $(@D)
|
2014-06-19 14:48:38 +00:00
|
|
|
$(verbose) $(CHECKPOLICY) -U $(UNK_PERMS) $^ -o $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Load the binary policy
|
|
|
|
#
|
2007-11-19 20:02:50 +00:00
|
|
|
reload $(tmpdir)/load: $(loadpath) $(fcpath) $(appfiles)
|
2006-08-31 17:28:35 +00:00
|
|
|
@echo "Loading $(NAME) $(loadpath)"
|
|
|
|
$(verbose) $(LOADPOLICY) -q $(loadpath)
|
|
|
|
@touch $(tmpdir)/load
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Construct a monolithic policy.conf
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
$(policy_conf): $(policy_sections)
|
2006-02-15 17:59:58 +00:00
|
|
|
@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-08-31 17:28:35 +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-08-31 17:28:35 +00:00
|
|
|
$(tmpdir)/generated_definitions.conf: $(all_te_files)
|
|
|
|
@test -d $(tmpdir) || mkdir -p $(tmpdir)
|
2006-03-21 20:23:29 +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,$(basename $(notdir $(all_modules))),$@)
|
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: $(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" >> $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2011-10-14 12:52:21 +00:00
|
|
|
$(tmpdir)/all_te_files.conf: $(m4support) $(tmpdir)/generated_definitions.conf $(tmpdir)/all_interfaces.conf $(all_te_files)
|
2006-08-31 17:28:35 +00:00
|
|
|
ifeq "$(strip $(all_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
|
|
|
|
2008-11-05 16:10:46 +00:00
|
|
|
$(tmpdir)/post_te_files.conf: $(m4support) $(tmpdir)/generated_definitions.conf $(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.
|
2014-02-18 23:26:33 +00:00
|
|
|
$(tmpdir)/all_attrs_types.conf: $(tmpdir)/all_te_files.conf
|
|
|
|
$(verbose) $(get_type_attr_decl) $^ | $(SORT) > $@
|
|
|
|
|
|
|
|
$(tmpdir)/all_post.conf: $(tmpdir)/all_te_files.conf $(tmpdir)/post_te_files.conf
|
|
|
|
$(verbose) cat $(tmpdir)/post_te_files.conf > $@
|
2006-03-20 20:54:56 +00:00
|
|
|
# these have to run individually because order matters:
|
2014-02-18 23:26:33 +00:00
|
|
|
$(verbose) $(GREP) '^sid ' $(tmpdir)/all_te_files.conf >> $@ || true
|
|
|
|
$(verbose) $(GREP) '^fs_use_(xattr|task|trans)' $(tmpdir)/all_te_files.conf >> $@ || true
|
|
|
|
$(verbose) $(GREP) ^genfscon $(tmpdir)/all_te_files.conf >> $@ || true
|
|
|
|
$(verbose) $(GREP) ^portcon $(tmpdir)/all_te_files.conf >> $@ || true
|
|
|
|
$(verbose) $(GREP) ^netifcon $(tmpdir)/all_te_files.conf >> $@ || true
|
|
|
|
$(verbose) $(GREP) ^nodecon $(tmpdir)/all_te_files.conf >> $@ || true
|
|
|
|
|
|
|
|
$(tmpdir)/only_te_rules.conf: $(tmpdir)/all_te_files.conf
|
|
|
|
$(verbose) $(comment_move_decl) $^ > $@
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Remove the dontaudit rules from the policy.conf
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
enableaudit: $(policy_conf)
|
|
|
|
@test -d $(tmpdir) || mkdir -p $(tmpdir)
|
|
|
|
@echo "Removing dontaudit rules from $(notdir $(policy_conf))"
|
|
|
|
$(verbose) $(GREP) -v dontaudit $^ > $(tmpdir)/policy.audit
|
|
|
|
$(verbose) mv $(tmpdir)/policy.audit $(policy_conf)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Construct file_contexts
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
$(fc): $(tmpdir)/$(notdir $(fc)).tmp $(fcsort)
|
|
|
|
$(verbose) $(fcsort) $< $@
|
2008-11-11 14:22:57 +00:00
|
|
|
$(verbose) $(GREP) -e HOME -e ROLE -e USER $@ > $(homedir_template)
|
|
|
|
$(verbose) $(SED) -i -e /HOME/d -e /ROLE/d -e /USER/d $@
|
2005-11-22 22:07:12 +00:00
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
$(tmpdir)/$(notdir $(fc)).tmp: $(m4support) $(tmpdir)/generated_definitions.conf $(all_fc_files)
|
|
|
|
ifeq ($(all_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) 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
|
|
|
|
2006-08-31 17:28:35 +00:00
|
|
|
$(homedir_template): $(fc)
|
2006-05-15 15:21:43 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install file_contexts
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
$(fcpath): $(fc) $(loadpath) $(userpath)/system.users
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo "Validating $(NAME) file_contexts."
|
2006-08-31 17:28:35 +00:00
|
|
|
$(verbose) $(SETFILES) -q -c $(loadpath) $(fc)
|
2005-08-18 21:27:20 +00:00
|
|
|
@echo "Installing file_contexts."
|
2011-10-19 14:59:16 +00:00
|
|
|
@$(INSTALL) -d -m 0755 $(@D)
|
|
|
|
$(verbose) $(INSTALL) -m 0644 $(fc) $(fcpath)
|
|
|
|
$(verbose) $(INSTALL) -m 0644 $(homedir_template) $(homedirpath)
|
|
|
|
$(verbose) $(UMASK) 022 ; $(genhomedircon) -d $(topdir) -t $(NAME) $(USEPWD)
|
2006-05-15 15:21:43 +00:00
|
|
|
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
|
|
|
########################################
|
2006-08-07 17:25:09 +00:00
|
|
|
#
|
|
|
|
# Intall netfilter_contexts
|
|
|
|
#
|
2006-08-31 17:28:35 +00:00
|
|
|
$(ncpath): $(net_contexts)
|
2006-08-07 17:25:09 +00:00
|
|
|
@echo "Installing $(NAME) netfilter_contexts."
|
2011-10-19 14:59:16 +00:00
|
|
|
@$(INSTALL) -d -m 0755 $(@D)
|
2006-08-08 21:56:45 +00:00
|
|
|
$(verbose) $(INSTALL) -m 0644 $^ $@
|
2006-08-07 17:25:09 +00:00
|
|
|
|
|
|
|
########################################
|
2005-10-12 19:13:49 +00:00
|
|
|
#
|
|
|
|
# Run policy source checks
|
|
|
|
#
|
2006-08-31 17:28:35 +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-08-31 17:28:35 +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-08-31 17:28:35 +00:00
|
|
|
$(appdir)/customizable_types: $(policy_conf)
|
|
|
|
$(verbose) $(GREP) '^[[:blank:]]*type .*customizable' $< | cut -d';' -f1 | cut -d',' -f1 | cut -d' ' -f2 | $(SORT) -u > $(tmpdir)/customizable_types
|
2011-10-19 14:59:16 +00:00
|
|
|
@$(INSTALL) -d -m 0755 $(@D)
|
|
|
|
$(verbose) $(INSTALL) -m 0644 $(tmpdir)/customizable_types $@
|
2005-12-09 15:42:39 +00:00
|
|
|
|
2009-10-23 15:20:07 +00:00
|
|
|
$(installdir)/seusers: $(seusers)
|
2011-08-12 12:28:37 +00:00
|
|
|
$(verbose) $(M4) $(M4PARAM) $(m4support) $^ | $(GREP) '^[a-z_]' > $(tmpdir)/seusers
|
2011-10-19 14:59:16 +00:00
|
|
|
@$(INSTALL) -d -m 0755 $(@D)
|
|
|
|
$(verbose) $(INSTALL) -m 0644 $(tmpdir)/seusers $@
|
2009-10-23 15:20:07 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Clean the sources
|
|
|
|
#
|
|
|
|
clean:
|
2014-01-16 16:25:42 +00:00
|
|
|
$(verbose) rm -f $(policy_conf)
|
|
|
|
$(verbose) rm -f $(polver)
|
|
|
|
$(verbose) rm -f $(fc)
|
|
|
|
$(verbose) rm -f $(homedir_template)
|
|
|
|
$(verbose) rm -f $(net_contexts)
|
|
|
|
$(verbose) rm -f *.res
|
|
|
|
$(verbose) 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
|