Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Makefile for the security policy.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Targets:
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# install - compile and install the policy configuration, and context files.
Chris PeBenito ab58ad
# load    - compile, install, and load the policy configuration.
Chris PeBenito ab58ad
# reload  - compile, install, and load/reload the policy configuration.
Chris PeBenito ab58ad
# relabel - relabel filesystems based on the file contexts configuration.
Chris PeBenito ab58ad
# policy  - compile the policy configuration locally for testing/development.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# The default target is 'install'.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Set to y if MLS is enabled in the policy.
Chris PeBenito ab58ad
MLS=n
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Set to y if MCS is enabled in the policy
Chris PeBenito ab58ad
MCS=y
Chris PeBenito ab58ad
Chris PeBenito ab58ad
FLASKDIR = flask/
Chris PeBenito ab58ad
PREFIX = /usr
Chris PeBenito ab58ad
BINDIR = $(PREFIX)/bin
Chris PeBenito ab58ad
SBINDIR = $(PREFIX)/sbin
Chris PeBenito ab58ad
LOADPOLICY  = $(SBINDIR)/load_policy
Chris PeBenito ab58ad
CHECKPOLICY = $(BINDIR)/checkpolicy
Chris PeBenito ab58ad
GENHOMEDIRCON = $(SBINDIR)/genhomedircon
Chris PeBenito ab58ad
SETFILES = $(SBINDIR)/setfiles
Chris PeBenito ab58ad
VERS := $(shell $(CHECKPOLICY) $(POLICYCOMPAT) -V |cut -f 1 -d ' ')
Chris PeBenito 8967bf
PREVERS := 20
Chris PeBenito ab58ad
KERNVERS := $(shell cat /selinux/policyvers)
Chris PeBenito ab58ad
MLSENABLED := $(shell cat /selinux/mls)
Chris PeBenito ab58ad
POLICYVER := policy.$(VERS)
Chris PeBenito ab58ad
TOPDIR = $(DESTDIR)/etc/selinux
Chris PeBenito ab58ad
TYPE=targeted
Chris PeBenito ab58ad
Chris PeBenito ab58ad
INSTALLDIR = $(TOPDIR)/$(TYPE)
Chris PeBenito ab58ad
POLICYPATH = $(INSTALLDIR)/policy
Chris PeBenito ab58ad
SRCPATH = $(INSTALLDIR)/src
Chris PeBenito ab58ad
USERPATH = $(INSTALLDIR)/users
Chris PeBenito ab58ad
CONTEXTPATH = $(INSTALLDIR)/contexts
Chris PeBenito ab58ad
LOADPATH = $(POLICYPATH)/$(POLICYVER)
Chris PeBenito ab58ad
FCPATH = $(CONTEXTPATH)/files/file_contexts
Chris PeBenito ab58ad
HOMEDIRPATH = $(CONTEXTPATH)/files/homedir_template
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ALL_PROGRAM_MACROS := $(wildcard macros/program/*.te)
Chris PeBenito ab58ad
ALL_MACROS := $(ALL_PROGRAM_MACROS) $(wildcard macros/*.te)
Chris PeBenito ab58ad
ALL_TYPES := $(wildcard types/*.te)
Chris PeBenito ab58ad
ALL_DOMAINS := $(wildcard domains/*.te domains/misc/*.te domains/program/*.te)
Chris PeBenito ab58ad
ALLTEFILES := attrib.te tmp/program_used_flags.te $(ALL_MACROS) $(ALL_TYPES) $(ALL_DOMAINS) assert.te 
Chris PeBenito ab58ad
TE_RBAC_FILES := $(ALLTEFILES) rbac
Chris PeBenito ab58ad
ALL_TUNABLES := $(wildcard tunables/*.tun )
Chris PeBenito ab58ad
USER_FILES := users 
Chris PeBenito ab58ad
POLICYFILES = $(addprefix $(FLASKDIR),security_classes initial_sids access_vectors)
Chris PeBenito ab58ad
ifeq ($(MLS),y)
Chris PeBenito ab58ad
POLICYFILES += mls
Chris PeBenito ab58ad
CHECKPOLMLS += -M
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
ifeq ($(MCS), y)
Chris PeBenito ab58ad
POLICYFILES += mcs
Chris PeBenito ab58ad
CHECKPOLMLS += -M
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
DEFCONTEXTFILES = initial_sid_contexts fs_use genfs_contexts net_contexts
Chris PeBenito ab58ad
POLICYFILES += $(ALL_TUNABLES) $(TE_RBAC_FILES)
Chris PeBenito ab58ad
POLICYFILES += $(USER_FILES)
Chris PeBenito ab58ad
POLICYFILES += constraints
Chris PeBenito ab58ad
POLICYFILES += $(DEFCONTEXTFILES)
Chris PeBenito ab58ad
CONTEXTFILES = $(DEFCONTEXTFILES)
Chris PeBenito ab58ad
POLICY_DIRS = domains domains/program domains/misc macros macros/program
Chris PeBenito ab58ad
Chris PeBenito ab58ad
UNUSED_TE_FILES := $(wildcard domains/program/unused/*.te)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
FC = file_contexts/file_contexts
Chris PeBenito ab58ad
HOMEDIR_TEMPLATE = file_contexts/homedir_template
Chris PeBenito ab58ad
FCFILES=file_contexts/types.fc $(patsubst domains/program/%.te,file_contexts/program/%.fc, $(wildcard domains/program/*.te)) file_contexts/distros.fc $(wildcard file_contexts/misc/*.fc)
Chris PeBenito ab58ad
CONTEXTFILES += $(FCFILES)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
APPDIR=$(CONTEXTPATH)
Chris PeBenito ab58ad
APPFILES = $(addprefix $(APPDIR)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts customizable_types port_types) $(CONTEXTPATH)/files/media
Chris PeBenito ab58ad
CONTEXTFILES += $(wildcard appconfig/*_context*) appconfig/media
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ROOTFILES = $(addprefix $(APPDIR)/users/,root)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
all:  policy
Chris PeBenito ab58ad
Chris PeBenito ab58ad
tmp/valid_fc: $(LOADPATH) $(FC) 
Chris PeBenito ab58ad
ifeq ($(CHECKPOLMLS), -M)
Chris PeBenito ab58ad
ifeq ($(MLSENABLED),1)
Chris PeBenito ab58ad
	@echo "Validating file contexts files ..."	
Chris PeBenito ab58ad
	$(SETFILES) -q -c $(LOADPATH) $(FC)
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
	@touch tmp/valid_fc
Chris PeBenito ab58ad
Chris PeBenito ab58ad
install: $(FCPATH) $(APPFILES) $(ROOTFILES) $(USERPATH)/local.users
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(USERPATH)/system.users: $(ALL_TUNABLES) $(USER_FILES) policy.conf
Chris PeBenito ab58ad
	@mkdir -p $(USERPATH)
Chris PeBenito ab58ad
	@echo "# " > tmp/system.users
Chris PeBenito ab58ad
	@echo "# Do not edit this file. " >> tmp/system.users
Chris PeBenito ab58ad
	@echo "# This file is replaced on reinstalls of this policy." >> tmp/system.users
Chris PeBenito ab58ad
	@echo "# Please edit local.users to make local changes." >> tmp/system.users
Chris PeBenito ab58ad
	@echo "#" >> tmp/system.users
Chris PeBenito ab58ad
	@m4 $(ALL_TUNABLES) tmp/program_used_flags.te $(USER_FILES) | grep -v "^#" >> tmp/system.users
Chris PeBenito ab58ad
	install -m 644 tmp/system.users $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(USERPATH)/local.users: local.users
Chris PeBenito ab58ad
	@mkdir -p $(USERPATH)
Chris PeBenito ab58ad
	install -b -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(CONTEXTPATH)/files/media: appconfig/media
Chris PeBenito ab58ad
	@mkdir -p $(CONTEXTPATH)/files/
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/default_contexts: appconfig/default_contexts
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/removable_context: appconfig/removable_context
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/customizable_types: policy.conf
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	@grep "^type .*customizable" $< | cut -d',' -f1 | cut -d' ' -f2 > tmp/customizable_types
Chris PeBenito ab58ad
	install -m 644 tmp/customizable_types $@ 
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/port_types: policy.conf
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	@grep "^type .*port_type" $< | cut -d',' -f1 | cut -d' ' -f2 > tmp/port_types
Chris PeBenito ab58ad
	install -m 644 tmp/port_types $@ 
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/default_type: appconfig/default_type
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/userhelper_context: appconfig/userhelper_context
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/initrc_context: appconfig/initrc_context
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/failsafe_context: appconfig/failsafe_context
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/dbus_contexts: appconfig/dbus_contexts
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(APPDIR)/users/root: appconfig/root_default_contexts
Chris PeBenito ab58ad
	@mkdir -p $(APPDIR)/users
Chris PeBenito ab58ad
	install -m 644 $< $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(LOADPATH): policy.conf $(CHECKPOLICY) 
Chris PeBenito ab58ad
	@echo "Compiling policy ..."
Chris PeBenito ab58ad
	@mkdir -p $(POLICYPATH)
Chris PeBenito ab58ad
	$(CHECKPOLICY) $(CHECKPOLMLS) -o $@ policy.conf
Chris PeBenito ab58ad
ifneq ($(VERS),$(PREVERS))
Chris PeBenito ab58ad
	$(CHECKPOLICY) $(CHECKPOLMLS) -c $(PREVERS) -o $(POLICYPATH)/policy.$(PREVERS) policy.conf
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Note: Can't use install, so not sure how to deal with mode, user, and group
Chris PeBenito ab58ad
#	other than by default.
Chris PeBenito ab58ad
Chris PeBenito ab58ad
policy: $(POLICYVER)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(POLICYVER):  policy.conf $(FC) $(CHECKPOLICY)
Chris PeBenito ab58ad
	$(CHECKPOLICY) $(CHECKPOLMLS) -o $@ policy.conf
Chris PeBenito ab58ad
ifeq ($(CHECKPOLMLS), -M)
Chris PeBenito ab58ad
ifeq (1, $(MLSENABLED))
Chris PeBenito ab58ad
	@echo "Validating file contexts files ..."
Chris PeBenito ab58ad
	$(SETFILES) -q -c $(POLICYVER) $(FC)
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
Chris PeBenito ab58ad
reload tmp/load: $(LOADPATH) 
Chris PeBenito ab58ad
	@echo "Loading Policy ..."
Chris PeBenito 8967bf
	$(LOADPOLICY)
Chris PeBenito ab58ad
	touch tmp/load
Chris PeBenito ab58ad
Chris PeBenito ab58ad
load: tmp/load $(FCPATH) 
Chris PeBenito ab58ad
Chris PeBenito ab58ad
enableaudit: policy.conf 
Chris PeBenito ab58ad
	grep -v dontaudit policy.conf > policy.audit
Chris PeBenito ab58ad
	mv policy.audit policy.conf
Chris PeBenito ab58ad
Chris PeBenito ab58ad
policy.conf: $(POLICYFILES) $(POLICY_DIRS)
Chris PeBenito ab58ad
	@echo "Building policy.conf ..."
Chris PeBenito ab58ad
	@mkdir -p tmp
Chris PeBenito ab58ad
	m4 $(M4PARAM) -Imacros -s $(POLICYFILES) > $@.tmp
Chris PeBenito ab58ad
	@mv $@.tmp $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
install-src: 
Chris PeBenito ab58ad
	rm -rf $(SRCPATH)/policy.old
Chris PeBenito ab58ad
	-mv $(SRCPATH)/policy $(SRCPATH)/policy.old
Chris PeBenito ab58ad
	@mkdir -p $(SRCPATH)/policy
Chris PeBenito ab58ad
	cp -R . $(SRCPATH)/policy
Chris PeBenito ab58ad
Chris PeBenito ab58ad
tmp/program_used_flags.te: $(wildcard domains/program/*.te) domains/program
Chris PeBenito ab58ad
	@mkdir -p tmp
Chris PeBenito ab58ad
	( cd domains/program/ ; for n in *.te ; do echo "define(\`$$n')"; done ) > $@.tmp
Chris PeBenito ab58ad
	( cd domains/misc/ ; for n in *.te ; do echo "define(\`$$n')"; done ) >> $@.tmp
Chris PeBenito ab58ad
	mv $@.tmp $@
Chris PeBenito ab58ad
Chris PeBenito ab58ad
FILESYSTEMS=`mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs | reiserfs ).*rw/{print $$3}';`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
checklabels: $(SETFILES)
Chris PeBenito ab58ad
	$(SETFILES) -v -n $(FC) $(FILESYSTEMS)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
restorelabels: $(SETFILES)
Chris PeBenito ab58ad
	$(SETFILES) -v $(FC) $(FILESYSTEMS)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
relabel:  $(FC) $(SETFILES)
Chris PeBenito ab58ad
	$(SETFILES) $(FC) $(FILESYSTEMS)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
file_contexts/misc:
Chris PeBenito ab58ad
	@mkdir -p file_contexts/misc
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(FCPATH): tmp/valid_fc $(USERPATH)/system.users  $(APPDIR)/customizable_types $(APPDIR)/port_types
Chris PeBenito ab58ad
	@echo "Installing file contexts files..."
Chris PeBenito ab58ad
	@mkdir -p $(CONTEXTPATH)/files
Chris PeBenito ab58ad
	install -m 644 $(HOMEDIR_TEMPLATE) $(HOMEDIRPATH)
Chris PeBenito ab58ad
	install -m 644 $(FC) $(FCPATH)
Chris PeBenito ab58ad
	@$(GENHOMEDIRCON) -d $(TOPDIR) -t $(TYPE) $(USEPWD)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(FC): $(ALL_TUNABLES) tmp/program_used_flags.te $(FCFILES) domains/program domains/misc file_contexts/program file_contexts/misc users /etc/passwd
Chris PeBenito ab58ad
	@echo "Building file contexts files..."
Chris PeBenito ab58ad
	@m4 $(M4PARAM) $(ALL_TUNABLES) tmp/program_used_flags.te $(FCFILES) > $@.tmp
Chris PeBenito ab58ad
	@grep -v -e HOME -e ROLE -e USER $@.tmp > $@
Chris PeBenito ab58ad
	@grep -e HOME -e ROLE -e USER $@.tmp  > $(HOMEDIR_TEMPLATE)
Chris PeBenito ab58ad
	@-rm $@.tmp
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Create a tags-file for the policy:
Chris PeBenito ab58ad
# we need exuberant ctags; unfortunately it is named differently on different distros, sigh...
Chris PeBenito ab58ad
pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) # taken from make-docs
Chris PeBenito ab58ad
CTAGS := $(call pathsearch,ctags-exuberant) # debian naming scheme
Chris PeBenito ab58ad
ifeq ($(strip $(CTAGS)),)
Chris PeBenito ab58ad
CTAGS := $(call pathsearch,ctags) # suse naming scheme
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
Chris PeBenito ab58ad
tags: $(wildcard *.te types/*.te domains/*.te domains/misc/*.te domains/program/*.te domains/program/unused/*.te macros/*.te macros/program/*.te)
Chris PeBenito ab58ad
	@($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1)
Chris PeBenito ab58ad
	@LC_ALL=C $(CTAGS) --langdef=te --langmap=te:..te \
Chris PeBenito ab58ad
	  --regex-te='/^[ \t]*type[ \t]+(\w+)(,|;)/\1/t,type/' \
Chris PeBenito ab58ad
	  --regex-te='/^[ \t]*typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \
Chris PeBenito ab58ad
	  --regex-te='/^[ \t]*attribute[ \t]+(\w+);/\1/a,attribute/' \
Chris PeBenito ab58ad
	  --regex-te='/^[ \t]*define\(`(\w+)/\1/d,define/' \
Chris PeBenito ab58ad
	  --regex-te='/^[ \t]*bool[ \t]+(\w+)/\1/b,bool/' $^
Chris PeBenito ab58ad
 
Chris PeBenito ab58ad
clean:
Chris PeBenito ab58ad
	rm -f policy.conf $(POLICYVER)
Chris PeBenito ab58ad
	rm -f tags
Chris PeBenito ab58ad
	rm -f tmp/*
Chris PeBenito ab58ad
	rm -f $(FC)
Chris PeBenito ab58ad
	rm -f flask/*.h
Chris PeBenito ab58ad
# for the policy regression tester
Chris PeBenito ab58ad
	find "domains/program/" -maxdepth 1 -type l -exec rm {} \; ; \
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Policy regression tester.
Chris PeBenito ab58ad
# Written by Colin Walters <walters@debian.org>
Chris PeBenito ab58ad
cur_te = $(filter-out %/,$(subst /,/ ,$@))
Chris PeBenito ab58ad
Chris PeBenito ab58ad
TESTED_TE_FILES := $(notdir $(UNUSED_TE_FILES))
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define compute_depends
Chris PeBenito ab58ad
  export TE_DEPENDS_$(1) := $(shell egrep '^#[[:space:]]*Depends: ' domains/program/unused/$(1) | head -1 | sed -e 's/^.*Depends: //')
Chris PeBenito ab58ad
endef
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifeq ($(TE_DEPENDS_DEFINED),)
Chris PeBenito ab58ad
ifeq ($(MAKECMDGOALS),check-all)
Chris PeBenito ab58ad
  GENRULES := $(TESTED_TE_FILES)
Chris PeBenito ab58ad
  export TE_DEPENDS_DEFINED := yes
Chris PeBenito ab58ad
else
Chris PeBenito ab58ad
  # Handle the case where checkunused/blah.te is run directly.
Chris PeBenito ab58ad
  ifneq ($(findstring checkunused/,$(MAKECMDGOALS)),)
Chris PeBenito ab58ad
    GENRULES := $(TESTED_TE_FILES)
Chris PeBenito ab58ad
    export TE_DEPENDS_DEFINED := yes
Chris PeBenito ab58ad
  endif
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Test for a new enough version of GNU Make.
Chris PeBenito ab58ad
$(eval have_eval := yes)
Chris PeBenito ab58ad
ifneq ($(GENRULES),)
Chris PeBenito ab58ad
  ifeq ($(have_eval),)
Chris PeBenito ab58ad
$(error Need GNU Make 3.80 or better!)
Chris PeBenito ab58ad
Need GNU Make 3.80 or better
Chris PeBenito ab58ad
  endif
Chris PeBenito ab58ad
endif
Chris PeBenito ab58ad
$(foreach f,$(GENRULES),$(eval $(call compute_depends,$(f))))
Chris PeBenito ab58ad
Chris PeBenito ab58ad
PHONIES :=
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define compute_presymlinks
Chris PeBenito ab58ad
PHONIES += presymlink/$(1)
Chris PeBenito ab58ad
presymlink/$(1):: $(patsubst %,presymlink/%,$(TE_DEPENDS_$(1)))
Chris PeBenito ab58ad
	@if ! test -L domains/program/$(1); then \
Chris PeBenito ab58ad
	  cd domains/program && ln -s unused/$(1) .; \
Chris PeBenito ab58ad
	fi
Chris PeBenito ab58ad
endef
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Compute dependencies.
Chris PeBenito ab58ad
$(foreach f,$(TESTED_TE_FILES),$(eval $(call compute_presymlinks,$(f))))
Chris PeBenito ab58ad
Chris PeBenito ab58ad
PHONIES += $(patsubst %,checkunused/%,$(TESTED_TE_FILES))
Chris PeBenito ab58ad
$(patsubst %,checkunused/%,$(TESTED_TE_FILES)) :: checkunused/% : 
Chris PeBenito ab58ad
	@$(MAKE) -s clean
Chris PeBenito ab58ad
Chris PeBenito ab58ad
$(patsubst %,checkunused/%,$(TESTED_TE_FILES)) :: checkunused/% : presymlink/%
Chris PeBenito ab58ad
	@if test -n "$(TE_DEPENDS_$(cur_te))"; then \
Chris PeBenito ab58ad
	  echo "Dependencies for $(cur_te): $(TE_DEPENDS_$(cur_te))"; \
Chris PeBenito ab58ad
	fi
Chris PeBenito ab58ad
	@echo "Testing $(cur_te)...";
Chris PeBenito ab58ad
	@if ! make -s policy 1>/dev/null; then \
Chris PeBenito ab58ad
	  echo "Testing $(cur_te)...FAILED"; \
Chris PeBenito ab58ad
	  exit 1; \
Chris PeBenito ab58ad
	fi;
Chris PeBenito ab58ad
	@echo "Testing $(cur_te)...success."; \
Chris PeBenito ab58ad
Chris PeBenito ab58ad
check-all:
Chris PeBenito ab58ad
	@for goal in  $(patsubst %,checkunused/%,$(TESTED_TE_FILES)); do \
Chris PeBenito ab58ad
	  $(MAKE) --no-print-directory $$goal; \
Chris PeBenito ab58ad
	done
Chris PeBenito ab58ad
Chris PeBenito ab58ad
.PHONY: clean $(PHONIES)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
mlsconvert: 
Chris PeBenito ab58ad
	@for file in $(CONTEXTFILES); do \
Chris PeBenito ab58ad
		echo "Converting $$file"; \
Chris PeBenito ab58ad
		sed -e 's/_t\b/_t:s0/g' $$file > $$file.new && \
Chris PeBenito ab58ad
		mv $$file.new $$file; \
Chris PeBenito ab58ad
	done
Chris PeBenito ab58ad
	@for file in $(USER_FILES); do \
Chris PeBenito ab58ad
		echo "Converting $$file"; \
Chris PeBenito ab58ad
		sed -e 's/;/ level s0 range s0 - s15:c0.c255;/' $$file > $$file.new && \
Chris PeBenito ab58ad
		mv $$file.new $$file; \
Chris PeBenito ab58ad
	done
Chris PeBenito ab58ad
	@sed -e '/sid kernel/s/s0/s0 - s15:c0.c255/' initial_sid_contexts > initial_sid_contexts.new && mv initial_sid_contexts.new initial_sid_contexts
Chris PeBenito ab58ad
	@echo "Enabling MLS in the Makefile"
Chris PeBenito ab58ad
	@sed "s/MLS=n/MLS=y/" Makefile > Makefile.new
Chris PeBenito ab58ad
	@mv Makefile.new Makefile
Chris PeBenito ab58ad
	@echo "Done"
Chris PeBenito ab58ad
Chris PeBenito ab58ad
mcsconvert: 
Chris PeBenito ab58ad
	@for file in $(CONTEXTFILES); do \
Chris PeBenito ab58ad
		echo "Converting $$file"; \
Chris PeBenito ab58ad
		sed -e 's/_t\b/_t:s0/g' $$file > $$file.new && \
Chris PeBenito ab58ad
		mv $$file.new $$file; \
Chris PeBenito ab58ad
	done
Chris PeBenito ab58ad
	@for file in $(USER_FILES); do \
Chris PeBenito ab58ad
		echo "Converting $$file"; \
Chris PeBenito ab58ad
		sed -r -e 's/\;/ level s0 range s0;/' $$file | \
Chris PeBenito ab58ad
		sed -r -e 's/(user (user_u|root|system_u).*);/\1 - s0:c0.c255;/' > $$file.new; \
Chris PeBenito ab58ad
		mv $$file.new $$file; \
Chris PeBenito ab58ad
	done
Chris PeBenito ab58ad
	@echo "Enabling MCS in the Makefile"
Chris PeBenito ab58ad
	@sed "s/MCS=y/MCS=y/" Makefile > Makefile.new
Chris PeBenito ab58ad
	@mv Makefile.new Makefile
Chris PeBenito ab58ad
	@echo "Done"
Chris PeBenito ab58ad