Chris PeBenito 88d14a2
#
Chris PeBenito 88d14a2
# Makefile for the security policy.
Chris PeBenito 88d14a2
#
Chris PeBenito 88d14a2
# Targets:
Chris PeBenito 88d14a2
# 
Chris PeBenito 88d14a2
# install       - compile and install the policy configuration, and context files.
Chris PeBenito 88d14a2
# load          - compile, install, and load the policy configuration.
Chris PeBenito 88d14a2
# reload        - compile, install, and load/reload the policy configuration.
Chris PeBenito 88d14a2
# relabel       - relabel filesystems based on the file contexts configuration.
Chris PeBenito 88d14a2
# checklabels   - check filesystems against the file context configuration
Chris PeBenito 88d14a2
# restorelabels - check filesystems against the file context configuration
Chris PeBenito 88d14a2
#                 and restore the label of files with incorrect labels
Chris PeBenito 88d14a2
# policy        - compile the policy configuration locally for testing/development.
Chris PeBenito 88d14a2
#
Chris PeBenito 88d14a2
# The default target is 'policy'.
Chris PeBenito 88d14a2
#
Chris PeBenito b4cd153
#
Chris PeBenito 8e0ef1f
# Please see build.conf for policy build options.
Chris PeBenito b4cd153
#
Chris PeBenito b4cd153
Chris PeBenito b4cd153
########################################
Chris PeBenito b4cd153
#
Chris PeBenito b67488e
# NO OPTIONS BELOW HERE
Chris PeBenito b4cd153
#
Chris PeBenito b4cd153
Chris PeBenito 8e0ef1f
include build.conf
Chris PeBenito 8e0ef1f
Chris PeBenito 120988c
# refpolicy version
Chris PeBenito 120988c
VERSION = $(shell cat VERSION)
Chris PeBenito 120988c
Chris PeBenito b4cd153
# executable paths
Chris PeBenito 120988c
BINDIR := /usr/bin
Chris PeBenito 120988c
SBINDIR := /usr/sbin
Chris PeBenito 40a1f3d
CHECKPOLICY := $(BINDIR)/checkpolicy
Chris PeBenito fb0a3a9
CHECKMODULE := $(BINDIR)/checkmodule
Chris PeBenito c767b14
SEMODULE := $(SBINDIR)/semodule
Chris PeBenito fb0a3a9
SEMOD_PKG := $(BINDIR)/semodule_package
Chris PeBenito 547283e
LOADPOLICY := $(SBINDIR)/load_policy
Chris PeBenito b4cd153
SETFILES := $(SBINDIR)/setfiles
Chris PeBenito 1beba1c
GENHOMEDIRCON := $(SBINDIR)/genhomedircon
Chris PeBenito fb0a3a9
XMLLINT := $(BINDIR)/xmllint
Chris PeBenito 8df65f1
SECHECK := $(BINDIR)/sechecker
Chris PeBenito 0447352
Chris PeBenito c7b41e9
CFLAGS := -Wall
Chris PeBenito c7b41e9
Chris PeBenito fb0a3a9
# policy source layout
Chris PeBenito c04f2ab
POLDIR := policy
Chris PeBenito c04f2ab
MODDIR := $(POLDIR)/modules
Chris PeBenito c04f2ab
FLASKDIR := $(POLDIR)/flask
Chris PeBenito c04f2ab
SECCLASS := $(FLASKDIR)/security_classes
Chris PeBenito c04f2ab
ISIDS := $(FLASKDIR)/initial_sids
Chris PeBenito c04f2ab
AVS := $(FLASKDIR)/access_vectors
Chris PeBenito fb0a3a9
Chris PeBenito fb0a3a9
# policy building support tools
Chris PeBenito 3a80ec2
SUPPORT := support
Chris PeBenito 95db422
GENXML := $(SUPPORT)/segenxml.py
Chris PeBenito 3a80ec2
GENDOC := $(SUPPORT)/sedoctool.py
Chris PeBenito c04f2ab
GENPERM := $(SUPPORT)/genclassperms.py
Chris PeBenito 254bbc7
FCSORT := $(SUPPORT)/fc_sort
Chris PeBenito 84eb353
SETTUN := $(SUPPORT)/set_tunables
Chris PeBenito 3a80ec2
Chris PeBenito fb0a3a9
# documentation paths
Chris PeBenito fb0a3a9
DOCS = doc
Chris PeBenito fb0a3a9
POLXML = $(DOCS)/policy.xml
Chris PeBenito fb0a3a9
XMLDTD = $(DOCS)/policy.dtd
Chris PeBenito fb0a3a9
LAYERXML = metadata.xml
Chris PeBenito fb0a3a9
HTMLDIR = $(DOCS)/html
Chris PeBenito fb0a3a9
DOCTEMPLATE = $(DOCS)/templates
Chris PeBenito 120988c
DEVMAKEFILE = $(SUPPORT)/Makefile.devel
Chris PeBenito 120988c
EXAMPLEMOD = $(addprefix $(DOCS)/,example.te example.if example.fc)
Chris PeBenito fb0a3a9
Chris PeBenito fb0a3a9
# config file paths
Chris PeBenito 120988c
GLOBALTUN = $(POLDIR)/global_tunables
Chris PeBenito 120988c
GLOBALBOOL = $(POLDIR)/global_booleans
Chris PeBenito 120988c
MOD_CONF = $(POLDIR)/modules.conf
Chris PeBenito 120988c
TUNABLES = $(POLDIR)/tunables.conf
Chris PeBenito 120988c
BOOLEANS = $(POLDIR)/booleans.conf
Chris PeBenito 120988c
ROLEMAP = $(POLDIR)/rolemap
Chris PeBenito fb0a3a9
Chris PeBenito fb0a3a9
# install paths
Chris PeBenito 120988c
PKGNAME ?= refpolicy-$(VERSION)
Chris PeBenito 120988c
PREFIX = $(DESTDIR)/usr
Chris PeBenito 120988c
TOPDIR = $(DESTDIR)/etc/selinux
Chris PeBenito 120988c
INSTALLDIR = $(TOPDIR)/$(NAME)
Chris PeBenito 120988c
SRCPATH = $(INSTALLDIR)/src
Chris PeBenito 120988c
USERPATH = $(INSTALLDIR)/users
Chris PeBenito 120988c
CONTEXTPATH = $(INSTALLDIR)/contexts
Chris PeBenito 120988c
FCPATH = $(CONTEXTPATH)/files/file_contexts
Chris PeBenito 120988c
SHAREDIR = $(PREFIX)/share/selinux
Chris PeBenito 120988c
MODPKGDIR = $(SHAREDIR)/$(NAME)
Chris PeBenito 120988c
HEADERDIR = $(SHAREDIR)/refpolicy/include
Chris PeBenito 120988c
DOCSDIR = $(PREFIX)/share/doc/$(PKGNAME)
Chris PeBenito c767b14
Chris PeBenito c767b14
# compile strict policy if requested.
Chris PeBenito c767b14
ifneq ($(findstring strict,$(TYPE)),)
Chris PeBenito 3f026a9
	M4PARAM += -D strict_policy
Chris PeBenito c767b14
endif
Chris PeBenito c767b14
Chris PeBenito c767b14
# compile targeted policy if requested.
Chris PeBenito c767b14
ifneq ($(findstring targeted,$(TYPE)),)
Chris PeBenito 3f026a9
	M4PARAM += -D targeted_policy
Chris PeBenito c767b14
endif
Chris PeBenito b4cd153
Chris PeBenito 134191b
# enable MLS if requested.
Chris PeBenito a082484
ifneq ($(findstring -mls,$(TYPE)),)
Chris PeBenito 3f026a9
	M4PARAM += -D enable_mls
Chris PeBenito 3f026a9
	CHECKPOLICY += -M
Chris PeBenito 3f026a9
	CHECKMODULE += -M
Chris PeBenito 134191b
endif
Chris PeBenito 134191b
Chris PeBenito a082484
# enable MLS if MCS requested.
Chris PeBenito a082484
ifneq ($(findstring -mcs,$(TYPE)),)
Chris PeBenito 3f026a9
	M4PARAM += -D enable_mcs
Chris PeBenito 3f026a9
	CHECKPOLICY += -M
Chris PeBenito 3f026a9
	CHECKMODULE += -M
Chris PeBenito b67488e
endif
Chris PeBenito b67488e
Chris PeBenito 25a0c61
# enable distribution-specific policy
Chris PeBenito 25a0c61
ifneq ($(DISTRO),)
Chris PeBenito 3f026a9
	M4PARAM += -D distro_$(DISTRO)
Chris PeBenito 25a0c61
endif
Chris PeBenito 25a0c61
Chris PeBenito b07eaef
# enable polyinstantiation
Chris PeBenito b07eaef
ifeq ($(POLY),y)
Chris PeBenito 3f026a9
	M4PARAM += -D enable_polyinstantiation
Chris PeBenito b07eaef
endif
Chris PeBenito b07eaef
Chris PeBenito b67488e
ifneq ($(OUTPUT_POLICY),)
Chris PeBenito 3f026a9
	CHECKPOLICY += -c $(OUTPUT_POLICY)
Chris PeBenito b67488e
endif
Chris PeBenito b67488e
Chris PeBenito 3f026a9
# if not set, use the type as the name.
Chris PeBenito 3f026a9
NAME ?= $(TYPE)
Chris PeBenito 134191b
Chris PeBenito 142e9f4
ifeq ($(DIRECT_INITRC),y)
Chris PeBenito 3f026a9
	M4PARAM += -D direct_sysadm_daemon
Chris PeBenito 142e9f4
endif
Chris PeBenito 142e9f4
Chris PeBenito 9b3756b
ifeq ($(QUIET),y)
Chris PeBenito 9b3756b
	verbose = @
Chris PeBenito 9b3756b
endif
Chris PeBenito 9b3756b
Chris PeBenito 3f026a9
M4PARAM += -D hide_broken_symptoms
Chris PeBenito ee7f66b
Chris PeBenito 37227dc
# we need exuberant ctags; unfortunately it is named
Chris PeBenito 37227dc
# differently on different distros
Chris PeBenito 37227dc
ifeq ($(DISTRO),debian)
Chris PeBenito 37227dc
	CTAGS := ctags-exuberant
Chris PeBenito 37227dc
endif
Chris PeBenito 37227dc
Chris PeBenito 37227dc
ifeq ($(DISTRO),gentoo)
Chris PeBenito 37227dc
	CTAGS := exuberant-ctags	
Chris PeBenito 37227dc
endif
Chris PeBenito 37227dc
Chris PeBenito a4fae7f
CTAGS ?= ctags
Chris PeBenito 37227dc
Chris PeBenito b4cd153
# determine the policy version and current kernel version if possible
Chris PeBenito 134191b
PV := $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ')
Chris PeBenito b4cd153
KV := $(shell cat /selinux/policyvers)
Chris PeBenito b4cd153
Chris PeBenito b4cd153
# dont print version warnings if we are unable to determine
Chris PeBenito b4cd153
# the currently running kernel's policy version
Chris PeBenito b4cd153
ifeq ($(KV),)
Chris PeBenito 134191b
	KV := $(PV)
Chris PeBenito b4cd153
endif
Chris PeBenito b4cd153
Chris PeBenito fb0a3a9
M4SUPPORT = $(wildcard $(POLDIR)/support/*.spt)
Chris PeBenito 0fbe15d
Chris PeBenito c0e4fe2
APPCONF := config/appconfig-$(TYPE)
Chris PeBenito c9a26b3
APPDIR := $(CONTEXTPATH)
Chris PeBenito 049e11a
APPFILES := $(addprefix $(APPDIR)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts customizable_types) $(CONTEXTPATH)/files/media
Chris PeBenito 2926f9c
CONTEXTFILES += $(wildcard $(APPCONF)/*_context*) $(APPCONF)/media
Chris PeBenito bdb2fac
USER_FILES := $(POLDIR)/users
Chris PeBenito c9a26b3
Chris PeBenito 57869a6
ALL_LAYERS := $(filter-out $(MODDIR)/CVS,$(shell find $(wildcard $(MODDIR)/*) -maxdepth 0 -type d))
Chris PeBenito e12e573
Chris PeBenito e12e573
GENERATED_TE := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te.in)))
Chris PeBenito e12e573
GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in)))
Chris PeBenito e12e573
GENERATED_FC := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.fc.in)))
Chris PeBenito e12e573
Chris PeBenito 8ae194f
# sort here since it removes duplicates, which can happen
Chris PeBenito 8ae194f
# when a generated file is already generated
Chris PeBenito 8ae194f
DETECTED_MODS := $(sort $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te)) $(GENERATED_TE))
Chris PeBenito 19db6ba
Chris PeBenito fb0a3a9
# modules.conf setting for base module
Chris PeBenito e8b3e30
MODBASE := base
Chris PeBenito fb0a3a9
Chris PeBenito e0a9001
# modules.conf setting for loadable module
Chris PeBenito e8b3e30
MODMOD := module
Chris PeBenito fb0a3a9
Chris PeBenito e0a9001
# modules.conf setting for unused module
Chris PeBenito e0a9001
MODUNUSED := off
Chris PeBenito e0a9001
Chris PeBenito fb0a3a9
# extract settings from modules.conf
Chris PeBenito c767b14
BASE_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null))
Chris PeBenito c767b14
MOD_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null))
Chris PeBenito e0a9001
OFF_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null))
Chris PeBenito 712566e
Chris PeBenito 120988c
# filesystems to be labeled
Chris PeBenito 120988c
FILESYSTEMS = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';)
Chris PeBenito 120988c
Chris PeBenito b4cd153
########################################
Chris PeBenito b4cd153
#
Chris PeBenito 4ace0fa
# Functions
Chris PeBenito 4ace0fa
#
Chris PeBenito 4ace0fa
Chris PeBenito 4ace0fa
# parse-rolemap modulename,outputfile
Chris PeBenito 4ace0fa
define parse-rolemap
Chris PeBenito 9b3756b
	$(verbose) m4 $(M4PARAM) $(ROLEMAP) | \
Chris PeBenito 4ace0fa
		awk '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_userdomain_template(" $$2 "," $$3 "," $$1 ")" }' >> $2
Chris PeBenito 4ace0fa
endef
Chris PeBenito 4ace0fa
Chris PeBenito 4ace0fa
# peruser-expansion modulename,outputfile
Chris PeBenito 4ace0fa
define peruser-expansion
Chris PeBenito 9b3756b
	$(verbose) echo "ifdef(\`""$1""_per_userdomain_template',\`" > $2
Chris PeBenito 4ace0fa
	$(call parse-rolemap,$1,$2)
Chris PeBenito 9b3756b
	$(verbose) echo "')" >> $2
Chris PeBenito 4ace0fa
endef
Chris PeBenito 4ace0fa
Chris PeBenito 4ace0fa
########################################
Chris PeBenito 4ace0fa
#
Chris PeBenito fb0a3a9
# Load appropriate rules
Chris PeBenito b4cd153
#
Chris PeBenito b4cd153
Chris PeBenito fb0a3a9
ifeq ($(MONOLITHIC),y)
Chris PeBenito fb0a3a9
	include Rules.monolithic
Chris PeBenito fb0a3a9
else
Chris PeBenito fb0a3a9
	include Rules.modular
Chris PeBenito b4cd153
endif
Chris PeBenito b4cd153
Chris PeBenito b4cd153
########################################
Chris PeBenito b4cd153
#
Chris PeBenito fb0a3a9
# Generated files
Chris PeBenito 88d14a2
#
Chris PeBenito f2e4ab3
$(MODDIR)/kernel/corenetwork.if: $(MODDIR)/kernel/corenetwork.if.m4 $(MODDIR)/kernel/corenetwork.if.in
Chris PeBenito 61bbe53
	@echo "#" > $@
Chris PeBenito 61bbe53
	@echo "# This is a generated file!  Instead of modifying this file, the" >> $@
Chris PeBenito 61bbe53
	@echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
Chris PeBenito 61bbe53
	@echo "#" >> $@
Chris PeBenito 9b3756b
	$(verbose) cat $(MODDIR)/kernel/corenetwork.if.in >> $@
Chris PeBenito 9b3756b
	$(verbose) egrep "^[[:blank:]]*network_(interface|node|port)\(.*\)" $(@:.if=.te).in \
Chris PeBenito cf6141a
		| m4 -D self_contained_policy $(M4PARAM) $(MODDIR)/kernel/corenetwork.if.m4 - \
Chris PeBenito f2e4ab3
		| sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
Chris PeBenito f2e4ab3
Chris PeBenito f2e4ab3
$(MODDIR)/kernel/corenetwork.te: $(MODDIR)/kernel/corenetwork.te.m4 $(MODDIR)/kernel/corenetwork.te.in
Chris PeBenito 61bbe53
	@echo "#" > $@
Chris PeBenito 61bbe53
	@echo "# This is a generated file!  Instead of modifying this file, the" >> $@
Chris PeBenito 61bbe53
	@echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
Chris PeBenito 61bbe53
	@echo "#" >> $@
Chris PeBenito 9b3756b
	$(verbose) m4 -D self_contained_policy $(M4PARAM) $^ \
Chris PeBenito 61bbe53
		| sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
Chris PeBenito f2e4ab3
Chris PeBenito b4cd153
########################################
Chris PeBenito b4cd153
#
Chris PeBenito 84eb353
# Create config files
Chris PeBenito 84eb353
#
Chris PeBenito 4f9f30c
conf: $(MOD_CONF) $(BOOLEANS) $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC)
Chris PeBenito d2d6c8c
Chris PeBenito 4f9f30c
$(MOD_CONF) $(BOOLEANS): $(POLXML)
Chris PeBenito 4f9f30c
	@echo "Updating $(MOD_CONF) and $(BOOLEANS)"
Chris PeBenito 9b3756b
	$(verbose) cd $(DOCS) && ../$(GENDOC) -t ../$(BOOLEANS) -m ../$(MOD_CONF) -x ../$(POLXML)
Chris PeBenito 84eb353
Chris PeBenito 84eb353
########################################
Chris PeBenito 84eb353
#
Chris PeBenito 6d314fd
# Documentation generation
Chris PeBenito 6d314fd
#
Chris PeBenito 6d314fd
Chris PeBenito d2d6c8c
# minimal dependencies here, because we don't want to rebuild 
Chris PeBenito 84eb353
# this and its dependents every time the dependencies
Chris PeBenito 19db6ba
# change.  Also use all .if files here, rather then just the
Chris PeBenito 19db6ba
# enabled modules.
Chris PeBenito d233bfc
$(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML))
Chris PeBenito 88c72f4
	@echo "Creating $@"
Chris PeBenito 84eb353
	@mkdir -p tmp
Chris PeBenito 9b3756b
	$(verbose) echo '' > $@
Chris PeBenito 9b3756b
	$(verbose) echo '' >> $@
Chris PeBenito 9b3756b
	$(verbose) $(GENXML) -w -m $(LAYERXML) -t $(GLOBALTUN) -b $(GLOBALBOOL) $(ALL_LAYERS) >> $@
Chris PeBenito 9b3756b
	$(verbose) if test -x $(XMLLINT) && test -f $(XMLDTD); then \
Chris PeBenito 0447352
		$(XMLLINT) --noout --dtdvalid $(XMLDTD) $@ ;\
Chris PeBenito 004db90
	fi
Chris PeBenito 6d314fd
Chris PeBenito 120988c
html tmp/html: $(POLXML)
Chris PeBenito 2de03f3
	@echo "Building html interface reference documentation in $(HTMLDIR)"
Chris PeBenito 20030ef
	@mkdir -p $(HTMLDIR)
Chris PeBenito 9b3756b
	$(verbose) cd $(DOCS) && ../$(GENDOC) -d ../$(HTMLDIR) -T ../$(DOCTEMPLATE) -x ../$(POLXML)
Chris PeBenito 9b3756b
	$(verbose) cp $(DOCTEMPLATE)/*.css $(HTMLDIR)
Chris PeBenito 120988c
	@touch tmp/html
Chris PeBenito 20030ef
Chris PeBenito c9a26b3
########################################
Chris PeBenito c9a26b3
#
Chris PeBenito c9a26b3
# Runtime binary policy patching of users
Chris PeBenito c9a26b3
#
Chris PeBenito 1fb83a7
$(USERPATH)/system.users: $(M4SUPPORT) tmp/generated_definitions.conf $(USER_FILES)
Chris PeBenito c9a26b3
	@mkdir -p $(USERPATH)
Chris PeBenito c9a26b3
	@echo "Installing system.users"
Chris PeBenito c9a26b3
	@echo "# " > tmp/system.users
Chris PeBenito c9a26b3
	@echo "# Do not edit this file. " >> tmp/system.users
Chris PeBenito c9a26b3
	@echo "# This file is replaced on reinstalls of this policy." >> tmp/system.users
Chris PeBenito c9a26b3
	@echo "# Please edit local.users to make local changes." >> tmp/system.users
Chris PeBenito c9a26b3
	@echo "#" >> tmp/system.users
Chris PeBenito 9b3756b
	$(verbose) m4 -D self_contained_policy $(M4PARAM) $^ | sed -r -e 's/^[[:blank:]]+//' \
Chris PeBenito 7dca64f
		-e '/^[[:blank:]]*($$|#)/d' >> tmp/system.users
Chris PeBenito 9b3756b
	$(verbose) install -m 644 tmp/system.users $@
Chris PeBenito c9a26b3
Chris PeBenito 1beba1c
$(USERPATH)/local.users: config/local.users
Chris PeBenito c9a26b3
	@mkdir -p $(USERPATH)
Chris PeBenito c9a26b3
	@echo "Installing local.users"
Chris PeBenito 9b3756b
	$(verbose) install -b -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito c9a26b3
########################################
Chris PeBenito c9a26b3
#
Chris PeBenito c9a26b3
# Appconfig files
Chris PeBenito c9a26b3
#
Chris PeBenito c9a26b3
install-appconfig: $(APPFILES)
Chris PeBenito c9a26b3
Chris PeBenito 4f9f30c
$(INSTALLDIR)/booleans: $(BOOLEANS)
Chris PeBenito 1beba1c
	@mkdir -p $(INSTALLDIR)
Chris PeBenito 9b3756b
	$(verbose) sed -r -e 's/false/0/g' -e 's/true/1/g' \
Chris PeBenito 7dca64f
		-e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > tmp/booleans
Chris PeBenito 9b3756b
	$(verbose) install -m 644 tmp/booleans $@
Chris PeBenito 1beba1c
Chris PeBenito 2926f9c
$(CONTEXTPATH)/files/media: $(APPCONF)/media
Chris PeBenito 1beba1c
	@mkdir -p $(CONTEXTPATH)/files/
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito 2926f9c
$(APPDIR)/default_contexts: $(APPCONF)/default_contexts
Chris PeBenito 1beba1c
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito 2926f9c
$(APPDIR)/removable_context: $(APPCONF)/removable_context
Chris PeBenito 1beba1c
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito 2926f9c
$(APPDIR)/default_type: $(APPCONF)/default_type
Chris PeBenito 1beba1c
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito 2926f9c
$(APPDIR)/userhelper_context: $(APPCONF)/userhelper_context
Chris PeBenito 1beba1c
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito 2926f9c
$(APPDIR)/initrc_context: $(APPCONF)/initrc_context
Chris PeBenito 1beba1c
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito 2926f9c
$(APPDIR)/failsafe_context: $(APPCONF)/failsafe_context
Chris PeBenito 1beba1c
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito 2926f9c
$(APPDIR)/dbus_contexts: $(APPCONF)/dbus_contexts
Chris PeBenito 1beba1c
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b3
Chris PeBenito 2926f9c
$(APPDIR)/users/root: $(APPCONF)/root_default_contexts
Chris PeBenito 1beba1c
	@mkdir -p $(APPDIR)/users
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $< $@
Chris PeBenito 9b3756b
Chris PeBenito 9b3756b
########################################
Chris PeBenito 9b3756b
#
Chris PeBenito 9b3756b
# Install policy headers
Chris PeBenito 9b3756b
#
Chris PeBenito 120988c
install-headers: $(DETECTED_MODS:.te=.if) $(ROLEMAP) $(M4SUPPORT)
Chris PeBenito 120988c
	@mkdir -p $(HEADERDIR)
Chris PeBenito 120988c
	@echo "Installing policy headers"
Chris PeBenito 9b3756b
	$(verbose) install -m 644 $^ $(HEADERDIR)
Chris PeBenito 9b3756b
	$(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $(HEADERDIR)/all_perms.spt
Chris PeBenito c9a26b3
Chris PeBenito c592e52
########################################
Chris PeBenito c592e52
#
Chris PeBenito 120988c
# Install policy documentation
Chris PeBenito 120988c
#
Chris PeBenito 120988c
install-docs: $(DEVMAKEFILE) $(EXAMPLEMOD) build.conf tmp/html
Chris PeBenito 120988c
	@mkdir -p $(DOCSDIR)/html
Chris PeBenito 120988c
	@echo "Installing policy documentation"
Chris PeBenito 120988c
	$(verbose) install -m 644 $(DEVMAKEFILE) $(EXAMPLEMOD) $(DOCSDIR)
Chris PeBenito 120988c
	$(verbose) install -m 644 build.conf $(DOCSDIR)/build.conf.example
Chris PeBenito 120988c
	$(verbose) install -m 644 $(wildcard $(HTMLDIR)/*) $(DOCSDIR)/html
Chris PeBenito 120988c
Chris PeBenito 120988c
########################################
Chris PeBenito 120988c
#
Chris PeBenito c592e52
# Install policy sources
Chris PeBenito c592e52
#
Chris PeBenito c592e52
install-src:
Chris PeBenito c592e52
	rm -rf $(SRCPATH)/policy.old
Chris PeBenito c592e52
	-mv $(SRCPATH)/policy $(SRCPATH)/policy.old
Chris PeBenito c592e52
	mkdir -p $(SRCPATH)/policy
Chris PeBenito c592e52
	cp -R . $(SRCPATH)/policy
Chris PeBenito c592e52
Chris PeBenito 102a59b
########################################
Chris PeBenito 102a59b
#
Chris PeBenito 37227dc
# Generate tags file
Chris PeBenito 37227dc
#
Chris PeBenito 37227dc
tags:
Chris PeBenito 37227dc
	@($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1)
Chris PeBenito 37227dc
	@LC_ALL=C $(CTAGS) --langdef=te --langmap=te:..te.if.spt \
Chris PeBenito 37227dc
	 --regex-te='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \
Chris PeBenito 37227dc
	 --regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \
Chris PeBenito 37227dc
	 --regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \
Chris PeBenito 37227dc
	 --regex-te='/^[ \t]*define\(`(\w+)/\1/d,define/' \
Chris PeBenito 37227dc
	 --regex-te='/^[ \t]*interface\(`(\w+)/\1/i,interface/' \
Chris PeBenito 37227dc
	 --regex-te='/^[ \t]*bool[ \t]+(\w+)/\1/b,bool/' policy/modules/*/*.{if,te} policy/support/*.spt
Chris PeBenito 37227dc
Chris PeBenito 37227dc
########################################
Chris PeBenito 37227dc
#
Chris PeBenito 120988c
# Filesystem labeling
Chris PeBenito 120988c
#
Chris PeBenito 120988c
checklabels:
Chris PeBenito 120988c
	@echo "Checking labels on filesystem types: ext2 ext3 xfs jfs"
Chris PeBenito 120988c
	@if test -z "$(FILESYSTEMS)"; then \
Chris PeBenito 120988c
		echo "No filesystems with extended attributes found!" ;\
Chris PeBenito 120988c
		false ;\
Chris PeBenito 120988c
	fi
Chris PeBenito 120988c
	$(verbose) $(SETFILES) -v -n $(FCPATH) $(FILESYSTEMS)
Chris PeBenito 120988c
Chris PeBenito 120988c
restorelabels:
Chris PeBenito 120988c
	@echo "Restoring labels on filesystem types: ext2 ext3 xfs jfs"
Chris PeBenito 120988c
	@if test -z "$(FILESYSTEMS)"; then \
Chris PeBenito 120988c
		echo "No filesystems with extended attributes found!" ;\
Chris PeBenito 120988c
		false ;\
Chris PeBenito 120988c
	fi
Chris PeBenito 120988c
	$(verbose) $(SETFILES) -v $(FCPATH) $(FILESYSTEMS)
Chris PeBenito 120988c
Chris PeBenito 120988c
relabel:
Chris PeBenito 120988c
	@echo "Relabeling filesystem types: ext2 ext3 xfs jfs"
Chris PeBenito 120988c
	@if test -z "$(FILESYSTEMS)"; then \
Chris PeBenito 120988c
		echo "No filesystems with extended attributes found!" ;\
Chris PeBenito 120988c
		false ;\
Chris PeBenito 120988c
	fi
Chris PeBenito 120988c
	$(verbose) $(SETFILES) $(FCPATH) $(FILESYSTEMS)
Chris PeBenito 120988c
Chris PeBenito 120988c
resetlabels:
Chris PeBenito 120988c
	@echo "Resetting labels on filesystem types: ext2 ext3 xfs jfs"
Chris PeBenito 120988c
	@if test -z "$(FILESYSTEMS)"; then \
Chris PeBenito 120988c
		echo "No filesystems with extended attributes found!" ;\
Chris PeBenito 120988c
		false ;\
Chris PeBenito 120988c
	fi
Chris PeBenito 120988c
	$(verbose) $(SETFILES) -F $(FCPATH) $(FILESYSTEMS)
Chris PeBenito 120988c
Chris PeBenito 120988c
########################################
Chris PeBenito 120988c
#
Chris PeBenito 102a59b
# Clean everything
Chris PeBenito 102a59b
#
Chris PeBenito 0fbe15d
bare: clean
Chris PeBenito 12b559a
	rm -f $(POLXML)
Chris PeBenito 254bbc7
	rm -f $(SUPPORT)/*.pyc
Chris PeBenito 254bbc7
	rm -f $(FCSORT)
Chris PeBenito 19db6ba
	rm -f $(MOD_CONF)
Chris PeBenito 4f9f30c
	rm -f $(BOOLEANS)
Chris PeBenito 20030ef
	rm -fR $(HTMLDIR)
Chris PeBenito 37227dc
	rm -f tags
Chris PeBenito c767b14
ifneq ($(GENERATED_TE),)
Chris PeBenito c767b14
	rm -f $(GENERATED_TE)
Chris PeBenito c767b14
endif
Chris PeBenito c767b14
ifneq ($(GENERATED_IF),)
Chris PeBenito c767b14
	rm -f $(GENERATED_IF)
Chris PeBenito c767b14
endif
Chris PeBenito c767b14
ifneq ($(GENERATED_FC),)
Chris PeBenito c767b14
	rm -f $(GENERATED_FC)
Chris PeBenito c767b14
endif
Chris PeBenito 0fbe15d
Chris PeBenito 37227dc
.PHONY: install-src install-appconfig conf html bare tags
Chris PeBenito b8c7982
.SUFFIXES:
Chris PeBenito b8c7982
.SUFFIXES: .c