Chris PeBenito 88d14a
#
Chris PeBenito 88d14a
# Makefile for the security policy.
Chris PeBenito 88d14a
#
Chris PeBenito 88d14a
# Targets:
Chris PeBenito 88d14a
# 
Chris PeBenito 88d14a
# install       - compile and install the policy configuration, and context files.
Chris PeBenito 88d14a
# load          - compile, install, and load the policy configuration.
Chris PeBenito 88d14a
# reload        - compile, install, and load/reload the policy configuration.
Chris PeBenito 88d14a
# relabel       - relabel filesystems based on the file contexts configuration.
Chris PeBenito 88d14a
# checklabels   - check filesystems against the file context configuration
Chris PeBenito 88d14a
# restorelabels - check filesystems against the file context configuration
Chris PeBenito 88d14a
#                 and restore the label of files with incorrect labels
Chris PeBenito 88d14a
# policy        - compile the policy configuration locally for testing/development.
Chris PeBenito 88d14a
#
Chris PeBenito 88d14a
# The default target is 'policy'.
Chris PeBenito 88d14a
#
Chris PeBenito b4cd15
#
Chris PeBenito 8e0ef1
# Please see build.conf for policy build options.
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito b4cd15
########################################
Chris PeBenito b4cd15
#
Chris PeBenito b67488
# NO OPTIONS BELOW HERE
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito c9f20d
# Include the local build.conf if it exists, otherwise
Chris PeBenito c9f20d
# include the configuration of the root directory.
Chris PeBenito 1a7175
include build.conf
Chris PeBenito 1a7175
Chris PeBenito 1a7175
ifdef LOCAL_ROOT
Chris PeBenito 1a7175
	-include $(LOCAL_ROOT)/build.conf
Chris PeBenito c9f20d
endif
Chris PeBenito 8e0ef1
Chris PeBenito 120988
# refpolicy version
Chris PeBenito 120988
VERSION = $(shell cat VERSION)
Chris PeBenito 120988
Chris PeBenito c9f20d
ifdef LOCAL_ROOT
Chris PeBenito 5b45ff
BUILDDIR := $(LOCAL_ROOT)/
Chris PeBenito c9f20d
TMPDIR := $(LOCAL_ROOT)/tmp
Chris PeBenito c9f20d
TAGS := $(LOCAL_ROOT)/tags
Chris PeBenito c9f20d
else
Chris PeBenito 5b45ff
TMPDIR := tmp
Chris PeBenito 5b45ff
TAGS := tags
Chris PeBenito c9f20d
endif
Chris PeBenito c9f20d
Chris PeBenito b4cd15
# executable paths
Chris PeBenito 906f10
BINDIR ?= /usr/bin
Chris PeBenito 906f10
SBINDIR ?= /usr/sbin
Chris PeBenito e2ae08
ifdef TEST_TOOLCHAIN
Chris PeBenito e2ae08
tc_bindir := env LD_LIBRARY_PATH="$(TEST_TOOLCHAIN)/lib" $(TEST_TOOLCHAIN)$(BINDIR)
Chris PeBenito e2ae08
tc_sbindir := env LD_LIBRARY_PATH="$(TEST_TOOLCHAIN)/lib" $(TEST_TOOLCHAIN)$(SBINDIR)
Chris PeBenito e2ae08
else
Chris PeBenito e2ae08
tc_bindir := $(BINDIR)
Chris PeBenito e2ae08
tc_sbindir := $(SBINDIR)
Chris PeBenito e2ae08
endif
Chris PeBenito e2ae08
CHECKPOLICY ?= $(tc_bindir)/checkpolicy
Chris PeBenito e2ae08
CHECKMODULE ?= $(tc_bindir)/checkmodule
Chris PeBenito e2ae08
SEMODULE ?= $(tc_sbindir)/semodule
Chris PeBenito e2ae08
SEMOD_PKG ?= $(tc_bindir)/semodule_package
Chris PeBenito e2ae08
SEMOD_LNK ?= $(tc_bindir)/semodule_link
Chris PeBenito e2ae08
SEMOD_EXP ?= $(tc_bindir)/semodule_expand
Chris PeBenito e2ae08
LOADPOLICY ?= $(tc_sbindir)/load_policy
Chris PeBenito e2ae08
SETFILES ?= $(tc_sbindir)/setfiles
Chris PeBenito 906f10
XMLLINT ?= $(BINDIR)/xmllint
Chris PeBenito 906f10
SECHECK ?= $(BINDIR)/sechecker
Chris PeBenito 044735
Chris PeBenito 0e686f
# interpreters and aux tools
Chris PeBenito 0e686f
AWK ?= gawk
Chris PeBenito 0e686f
GREP ?= egrep
Chris PeBenito 0e686f
M4 ?= m4
Chris PeBenito 0e686f
PYTHON ?= python
Chris PeBenito 0e686f
SED ?= sed
Chris PeBenito f62f4c
SORT ?= LC_ALL=C sort
Chris PeBenito 0e686f
Chris PeBenito 0e686f
CFLAGS += -Wall
Chris PeBenito c7b41e
Chris PeBenito fb0a3a
# policy source layout
Chris PeBenito 5b45ff
POLDIR := policy
Chris PeBenito c04f2a
MODDIR := $(POLDIR)/modules
Chris PeBenito c04f2a
FLASKDIR := $(POLDIR)/flask
Chris PeBenito c04f2a
SECCLASS := $(FLASKDIR)/security_classes
Chris PeBenito c04f2a
ISIDS := $(FLASKDIR)/initial_sids
Chris PeBenito c04f2a
AVS := $(FLASKDIR)/access_vectors
Chris PeBenito fb0a3a
Chris PeBenito c9f20d
# local source layout
Chris PeBenito c9f20d
ifdef LOCAL_ROOT
Chris PeBenito c9f20d
LOCAL_POLDIR := $(LOCAL_ROOT)/policy
Chris PeBenito c9f20d
LOCAL_MODDIR := $(LOCAL_POLDIR)/modules
Chris PeBenito c9f20d
endif
Chris PeBenito c9f20d
Chris PeBenito fb0a3a
# policy building support tools
Chris PeBenito 5b45ff
SUPPORT := support
Chris PeBenito 0e686f
GENXML := $(PYTHON) $(SUPPORT)/segenxml.py
Chris PeBenito 0e686f
GENDOC := $(PYTHON) $(SUPPORT)/sedoctool.py
Chris PeBenito 0e686f
GENPERM := $(PYTHON) $(SUPPORT)/genclassperms.py
Chris PeBenito c9f20d
FCSORT := $(TMPDIR)/fc_sort
Chris PeBenito d6cf05
SETBOOLS := $(AWK) -f $(SUPPORT)/set_bools_tuns.awk
Chris PeBenito 3abd5e
get_type_attr_decl := $(SED) -r -f $(SUPPORT)/get_type_attr_decl.sed
Chris PeBenito 3abd5e
comment_move_decl := $(SED) -r -f $(SUPPORT)/comment_move_decl.sed
Chris PeBenito 6962bb
gennetfilter := $(PYTHON) $(SUPPORT)/gennetfilter.py
Chris PeBenito fc47b3
# use our own genhomedircon to make sure we have a known usable one,
Chris PeBenito fc47b3
# so policycoreutils updates are not required (RHEL4)
Chris PeBenito fc47b3
genhomedircon := $(PYTHON) $(SUPPORT)/genhomedircon
Chris PeBenito 3a80ec
Chris PeBenito fb0a3a
# documentation paths
Chris PeBenito 5b45ff
DOCS := doc
Chris PeBenito fb0a3a
XMLDTD = $(DOCS)/policy.dtd
Chris PeBenito fb0a3a
LAYERXML = metadata.xml
Chris PeBenito fb0a3a
DOCTEMPLATE = $(DOCS)/templates
Chris PeBenito 5bd1a7
DOCFILES = $(DOCS)/Makefile.example $(addprefix $(DOCS)/,example.te example.if example.fc)
Chris PeBenito fb0a3a
Chris PeBenito c9f20d
ifndef LOCAL_ROOT
Chris PeBenito c9f20d
POLXML = $(DOCS)/policy.xml
Chris PeBenito 3d5980
TUNXML = $(DOCS)/global_tunables.xml
Chris PeBenito 3d5980
BOOLXML = $(DOCS)/global_booleans.xml
Chris PeBenito c9f20d
HTMLDIR = $(DOCS)/html
Chris PeBenito c9f20d
else
Chris PeBenito c9f20d
POLXML = $(LOCAL_ROOT)/doc/policy.xml
Chris PeBenito 3d5980
TUNXML = $(LOCAL_ROOT)/doc/global_tunables.xml
Chris PeBenito 3d5980
BOOLXML = $(LOCAL_ROOT)/doc/global_booleans.xml
Chris PeBenito c9f20d
HTMLDIR = $(LOCAL_ROOT)/doc/html
Chris PeBenito c9f20d
endif
Chris PeBenito c9f20d
Chris PeBenito fb0a3a
# config file paths
Chris PeBenito 120988
GLOBALTUN = $(POLDIR)/global_tunables
Chris PeBenito 120988
GLOBALBOOL = $(POLDIR)/global_booleans
Chris PeBenito 120988
TUNABLES = $(POLDIR)/tunables.conf
Chris PeBenito 120988
ROLEMAP = $(POLDIR)/rolemap
Chris PeBenito 90b331
USER_FILES := $(POLDIR)/users
Chris PeBenito fb0a3a
Chris PeBenito c9f20d
# local config file paths
Chris PeBenito c9f20d
ifndef LOCAL_ROOT
Chris PeBenito c9f20d
MOD_CONF = $(POLDIR)/modules.conf
Chris PeBenito c9f20d
BOOLEANS = $(POLDIR)/booleans.conf
Chris PeBenito c9f20d
else
Chris PeBenito c9f20d
MOD_CONF = $(LOCAL_POLDIR)/modules.conf
Chris PeBenito c9f20d
BOOLEANS = $(LOCAL_POLDIR)/booleans.conf
Chris PeBenito c9f20d
endif
Chris PeBenito c9f20d
Chris PeBenito fb0a3a
# install paths
Chris PeBenito 120988
PKGNAME ?= refpolicy-$(VERSION)
Chris PeBenito 120988
PREFIX = $(DESTDIR)/usr
Chris PeBenito 120988
TOPDIR = $(DESTDIR)/etc/selinux
Chris PeBenito 120988
INSTALLDIR = $(TOPDIR)/$(NAME)
Chris PeBenito 120988
SRCPATH = $(INSTALLDIR)/src
Chris PeBenito 120988
USERPATH = $(INSTALLDIR)/users
Chris PeBenito 120988
CONTEXTPATH = $(INSTALLDIR)/contexts
Chris PeBenito 120988
FCPATH = $(CONTEXTPATH)/files/file_contexts
Chris PeBenito 120988
SHAREDIR = $(PREFIX)/share/selinux
Chris PeBenito 120988
MODPKGDIR = $(SHAREDIR)/$(NAME)
Chris PeBenito d6cf05
HEADERDIR = $(MODPKGDIR)/include
Chris PeBenito 120988
DOCSDIR = $(PREFIX)/share/doc/$(PKGNAME)
Chris PeBenito c767b1
Chris PeBenito c767b1
# compile strict policy if requested.
Chris PeBenito c767b1
ifneq ($(findstring strict,$(TYPE)),)
Chris PeBenito 3f026a
	M4PARAM += -D strict_policy
Chris PeBenito c767b1
endif
Chris PeBenito c767b1
Chris PeBenito c767b1
# compile targeted policy if requested.
Chris PeBenito c767b1
ifneq ($(findstring targeted,$(TYPE)),)
Chris PeBenito 3f026a
	M4PARAM += -D targeted_policy
Chris PeBenito c767b1
endif
Chris PeBenito b4cd15
Chris PeBenito 134191
# enable MLS if requested.
Chris PeBenito a08248
ifneq ($(findstring -mls,$(TYPE)),)
Chris PeBenito 3f026a
	M4PARAM += -D enable_mls
Chris PeBenito 3f026a
	CHECKPOLICY += -M
Chris PeBenito 3f026a
	CHECKMODULE += -M
Chris PeBenito 6962bb
	gennetfilter += -m
Chris PeBenito 134191
endif
Chris PeBenito 134191
Chris PeBenito a08248
# enable MLS if MCS requested.
Chris PeBenito a08248
ifneq ($(findstring -mcs,$(TYPE)),)
Chris PeBenito 3f026a
	M4PARAM += -D enable_mcs
Chris PeBenito 3f026a
	CHECKPOLICY += -M
Chris PeBenito 3f026a
	CHECKMODULE += -M
Chris PeBenito 6962bb
	gennetfilter += -c
Chris PeBenito b67488
endif
Chris PeBenito b67488
Chris PeBenito 25a0c6
# enable distribution-specific policy
Chris PeBenito 25a0c6
ifneq ($(DISTRO),)
Chris PeBenito 3f026a
	M4PARAM += -D distro_$(DISTRO)
Chris PeBenito 25a0c6
endif
Chris PeBenito 25a0c6
Chris PeBenito 2f1a8f
# rhel4 also implies redhat
Chris PeBenito 2f1a8f
ifeq "$(DISTRO)" "rhel4"
Chris PeBenito 2f1a8f
	M4PARAM += -D distro_redhat
Chris PeBenito 2f1a8f
endif
Chris PeBenito 2f1a8f
Chris PeBenito b07eae
# enable polyinstantiation
Chris PeBenito b07eae
ifeq ($(POLY),y)
Chris PeBenito 3f026a
	M4PARAM += -D enable_polyinstantiation
Chris PeBenito b07eae
endif
Chris PeBenito b07eae
Chris PeBenito b67488
ifneq ($(OUTPUT_POLICY),)
Chris PeBenito 3f026a
	CHECKPOLICY += -c $(OUTPUT_POLICY)
Chris PeBenito b67488
endif
Chris PeBenito b67488
Chris PeBenito 3f026a
# if not set, use the type as the name.
Chris PeBenito 3f026a
NAME ?= $(TYPE)
Chris PeBenito 134191
Chris PeBenito 142e9f
ifeq ($(DIRECT_INITRC),y)
Chris PeBenito 3f026a
	M4PARAM += -D direct_sysadm_daemon
Chris PeBenito 142e9f
endif
Chris PeBenito 142e9f
Chris PeBenito 9b3756
ifeq ($(QUIET),y)
Chris PeBenito 9b3756
	verbose = @
Chris PeBenito 9b3756
endif
Chris PeBenito 9b3756
Chris PeBenito 3f026a
M4PARAM += -D hide_broken_symptoms
Chris PeBenito ee7f66
Chris PeBenito 37227d
# we need exuberant ctags; unfortunately it is named
Chris PeBenito 37227d
# differently on different distros
Chris PeBenito 37227d
ifeq ($(DISTRO),debian)
Chris PeBenito 37227d
	CTAGS := ctags-exuberant
Chris PeBenito 37227d
endif
Chris PeBenito 37227d
Chris PeBenito 37227d
ifeq ($(DISTRO),gentoo)
Chris PeBenito 37227d
	CTAGS := exuberant-ctags	
Chris PeBenito 37227d
endif
Chris PeBenito 37227d
Chris PeBenito a4fae7
CTAGS ?= ctags
Chris PeBenito 37227d
Chris PeBenito b4cd15
# determine the policy version and current kernel version if possible
Chris PeBenito 134191
PV := $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ')
Chris PeBenito b4cd15
KV := $(shell cat /selinux/policyvers)
Chris PeBenito b4cd15
Chris PeBenito b4cd15
# dont print version warnings if we are unable to determine
Chris PeBenito b4cd15
# the currently running kernel's policy version
Chris PeBenito b4cd15
ifeq ($(KV),)
Chris PeBenito 134191
	KV := $(PV)
Chris PeBenito b4cd15
endif
Chris PeBenito b4cd15
Chris PeBenito 201445
M4SUPPORT := $(wildcard $(POLDIR)/support/*.spt)
Chris PeBenito 201445
ifdef LOCAL_ROOT
Chris PeBenito 201445
M4SUPPORT += $(wildcard $(LOCAL_POLDIR)/support/*.spt)
Chris PeBenito 201445
endif
Chris PeBenito 0fbe15
Chris PeBenito 5b45ff
APPCONF := config/appconfig-$(TYPE)
Chris PeBenito ace368
SEUSERS := $(APPCONF)/seusers
Chris PeBenito c9a26b
APPDIR := $(CONTEXTPATH)
Chris PeBenito 049e11
APPFILES := $(addprefix $(APPDIR)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts customizable_types) $(CONTEXTPATH)/files/media
Chris PeBenito 2926f9
CONTEXTFILES += $(wildcard $(APPCONF)/*_context*) $(APPCONF)/media
Chris PeBenito 6962bb
net_contexts := $(BUILDDIR)net_contexts
Chris PeBenito c9a26b
Chris PeBenito 57869a
ALL_LAYERS := $(filter-out $(MODDIR)/CVS,$(shell find $(wildcard $(MODDIR)/*) -maxdepth 0 -type d))
Chris PeBenito c9f20d
ifdef LOCAL_ROOT
Chris PeBenito e2680f
ALL_LAYERS += $(filter-out $(LOCAL_MODDIR)/CVS,$(shell find $(wildcard $(LOCAL_MODDIR)/*) -maxdepth 0 -type d))
Chris PeBenito c9f20d
endif
Chris PeBenito e12e57
Chris PeBenito e12e57
GENERATED_TE := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te.in)))
Chris PeBenito e12e57
GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in)))
Chris PeBenito e12e57
GENERATED_FC := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.fc.in)))
Chris PeBenito e12e57
Chris PeBenito 8ae194
# sort here since it removes duplicates, which can happen
Chris PeBenito 8ae194
# when a generated file is already generated
Chris PeBenito 8ae194
DETECTED_MODS := $(sort $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te)) $(GENERATED_TE))
Chris PeBenito 19db6b
Chris PeBenito fb0a3a
# modules.conf setting for base module
Chris PeBenito e8b3e3
MODBASE := base
Chris PeBenito fb0a3a
Chris PeBenito e0a900
# modules.conf setting for loadable module
Chris PeBenito e8b3e3
MODMOD := module
Chris PeBenito fb0a3a
Chris PeBenito e0a900
# modules.conf setting for unused module
Chris PeBenito e0a900
MODUNUSED := off
Chris PeBenito e0a900
Chris PeBenito c9f20d
# test for module overrides from command line
Chris PeBenito 87e73c
MOD_TEST = $(filter $(APPS_OFF), $(APPS_BASE) $(APPS_MODS))
Chris PeBenito 87e73c
MOD_TEST += $(filter $(APPS_MODS), $(APPS_BASE))
Chris PeBenito c9f20d
ifneq ($(strip $(MOD_TEST)),)
Chris PeBenito 3abd5e
        $(error Applications must be base, module, or off, and not in more than one list! $(strip $(MOD_TEST)) found in multiple lists!)
Chris PeBenito c9f20d
endif
Chris PeBenito c9f20d
Chris PeBenito 201445
# add on suffix to modules specified on command line
Chris PeBenito 201445
CMDLINE_BASE := $(addsuffix .te,$(APPS_BASE))
Chris PeBenito 201445
CMDLINE_MODS := $(addsuffix .te,$(APPS_MODS))
Chris PeBenito 201445
CMDLINE_OFF := $(addsuffix .te,$(APPS_OFF))
Chris PeBenito 201445
Chris PeBenito fb0a3a
# extract settings from modules.conf
Chris PeBenito 201445
MOD_CONF_BASE := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
Chris PeBenito 201445
MOD_CONF_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
Chris PeBenito 201445
MOD_CONF_OFF := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
Chris PeBenito 201445
Chris PeBenito 201445
BASE_MODS := $(CMDLINE_BASE)
Chris PeBenito 201445
MOD_MODS := $(CMDLINE_MODS)
Chris PeBenito 201445
OFF_MODS := $(CMDLINE_OFF)
Chris PeBenito 87e73c
Chris PeBenito 201445
BASE_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_BASE))
Chris PeBenito 201445
MOD_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_MODS))
Chris PeBenito 201445
OFF_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_OFF))
Chris PeBenito 87e73c
Chris PeBenito 87e73c
# add modules not in modules.conf to the off list
Chris PeBenito 201445
OFF_MODS += $(filter-out $(BASE_MODS) $(MOD_MODS) $(OFF_MODS),$(notdir $(DETECTED_MODS)))
Chris PeBenito 712566
Chris PeBenito 90b331
# filesystems to be used in labeling targets
Chris PeBenito 120988
FILESYSTEMS = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';)
Chris PeBenito 120988
Chris PeBenito b4cd15
########################################
Chris PeBenito b4cd15
#
Chris PeBenito 4ace0f
# Functions
Chris PeBenito 4ace0f
#
Chris PeBenito 4ace0f
Chris PeBenito 4ace0f
# parse-rolemap modulename,outputfile
Chris PeBenito 4ace0f
define parse-rolemap
Chris PeBenito 9b3756
	$(verbose) m4 $(M4PARAM) $(ROLEMAP) | \
Chris PeBenito 4ace0f
		awk '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_userdomain_template(" $$2 "," $$3 "," $$1 ")" }' >> $2
Chris PeBenito 4ace0f
endef
Chris PeBenito 4ace0f
Chris PeBenito 4ace0f
# peruser-expansion modulename,outputfile
Chris PeBenito 4ace0f
define peruser-expansion
Chris PeBenito 9b3756
	$(verbose) echo "ifdef(\`""$1""_per_userdomain_template',\`" > $2
Chris PeBenito 4ace0f
	$(call parse-rolemap,$1,$2)
Chris PeBenito 9b3756
	$(verbose) echo "')" >> $2
Chris PeBenito 4ace0f
endef
Chris PeBenito 4ace0f
Chris PeBenito 4ace0f
########################################
Chris PeBenito 4ace0f
#
Chris PeBenito fb0a3a
# Load appropriate rules
Chris PeBenito b4cd15
#
Chris PeBenito b4cd15
Chris PeBenito fb0a3a
ifeq ($(MONOLITHIC),y)
Chris PeBenito 5b45ff
	include Rules.monolithic
Chris PeBenito fb0a3a
else
Chris PeBenito 5b45ff
	include Rules.modular
Chris PeBenito b4cd15
endif
Chris PeBenito b4cd15
Chris PeBenito b4cd15
########################################
Chris PeBenito b4cd15
#
Chris PeBenito fb0a3a
# Generated files
Chris PeBenito 88d14a
#
Chris PeBenito c9f20d
# NOTE: There is no "local" version of these files.
Chris PeBenito c9f20d
#
Chris PeBenito fffba0
generate: $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC)
Chris PeBenito fffba0
Chris PeBenito f2e4ab
$(MODDIR)/kernel/corenetwork.if: $(MODDIR)/kernel/corenetwork.if.m4 $(MODDIR)/kernel/corenetwork.if.in
Chris PeBenito 61bbe5
	@echo "#" > $@
Chris PeBenito 61bbe5
	@echo "# This is a generated file!  Instead of modifying this file, the" >> $@
Chris PeBenito 61bbe5
	@echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
Chris PeBenito 61bbe5
	@echo "#" >> $@
Chris PeBenito 9b3756
	$(verbose) cat $(MODDIR)/kernel/corenetwork.if.in >> $@
Chris PeBenito e37158
	$(verbose) egrep "^[[:blank:]]*network_(interface|node|port|packet)\(.*\)" $(@:.if=.te).in \
Chris PeBenito cf6141
		| m4 -D self_contained_policy $(M4PARAM) $(MODDIR)/kernel/corenetwork.if.m4 - \
Chris PeBenito f2e4ab
		| sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
Chris PeBenito f2e4ab
Chris PeBenito f2e4ab
$(MODDIR)/kernel/corenetwork.te: $(MODDIR)/kernel/corenetwork.te.m4 $(MODDIR)/kernel/corenetwork.te.in
Chris PeBenito 61bbe5
	@echo "#" > $@
Chris PeBenito 61bbe5
	@echo "# This is a generated file!  Instead of modifying this file, the" >> $@
Chris PeBenito 61bbe5
	@echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
Chris PeBenito 61bbe5
	@echo "#" >> $@
Chris PeBenito 9b3756
	$(verbose) m4 -D self_contained_policy $(M4PARAM) $^ \
Chris PeBenito 61bbe5
		| sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
Chris PeBenito f2e4ab
Chris PeBenito b4cd15
########################################
Chris PeBenito b4cd15
#
Chris PeBenito 6962bb
# Network packet labeling
Chris PeBenito 6962bb
#
Chris PeBenito 6962bb
$(net_contexts): $(MODDIR)/kernel/corenetwork.te.in
Chris PeBenito 6962bb
	@echo "Creating netfilter network labeling rules"
Chris PeBenito 6962bb
	$(verbose) $(gennetfilter) $^ > $@
Chris PeBenito 6962bb
Chris PeBenito 6962bb
########################################
Chris PeBenito 6962bb
#
Chris PeBenito 84eb35
# Create config files
Chris PeBenito 84eb35
#
Chris PeBenito 4f9f30
conf: $(MOD_CONF) $(BOOLEANS) $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC)
Chris PeBenito d2d6c8
Chris PeBenito 4f9f30
$(MOD_CONF) $(BOOLEANS): $(POLXML)
Chris PeBenito 4f9f30
	@echo "Updating $(MOD_CONF) and $(BOOLEANS)"
Chris PeBenito 13a494
	$(verbose) $(GENDOC) -b $(BOOLEANS) -m $(MOD_CONF) -x $(POLXML)
Chris PeBenito 84eb35
Chris PeBenito 84eb35
########################################
Chris PeBenito 84eb35
#
Chris PeBenito c9f20d
# Generate the fc_sort program
Chris PeBenito c9f20d
#
Chris PeBenito c9f20d
$(FCSORT) : $(SUPPORT)/fc_sort.c
Chris PeBenito fffba0
	$(verbose) $(CC) $(CFLAGS) $(SUPPORT)/fc_sort.c -o $(FCSORT)
Chris PeBenito c9f20d
Chris PeBenito c9f20d
########################################
Chris PeBenito c9f20d
#
Chris PeBenito 6d314f
# Documentation generation
Chris PeBenito 6d314f
#
Chris PeBenito 6d314f
Chris PeBenito d2d6c8
# minimal dependencies here, because we don't want to rebuild 
Chris PeBenito 84eb35
# this and its dependents every time the dependencies
Chris PeBenito 19db6b
# change.  Also use all .if files here, rather then just the
Chris PeBenito 19db6b
# enabled modules.
Chris PeBenito 1a7175
xml: $(POLXML)
Chris PeBenito d233bf
$(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML))
Chris PeBenito 1a7175
	@echo "Creating $(@F)"
Chris PeBenito c9f20d
	@test -d $(dir $(POLXML)) || mkdir -p $(dir $(POLXML))
Chris PeBenito c9f20d
	@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
Chris PeBenito 9b3756
	$(verbose) echo '' > $@
Chris PeBenito 9b3756
	$(verbose) echo '' >> $@
Chris PeBenito ac9db9
	$(verbose) $(GENXML) -w -m $(LAYERXML) -t $(GLOBALTUN) -b $(GLOBALBOOL) -o $(DOCS) $(ALL_LAYERS) >> $@
Chris PeBenito 9b3756
	$(verbose) if test -x $(XMLLINT) && test -f $(XMLDTD); then \
Chris PeBenito c9f20d
		$(XMLLINT) --noout --path $(dir $(XMLDTD)) --dtdvalid $(XMLDTD) $@ ;\
Chris PeBenito 004db9
	fi
Chris PeBenito 6d314f
Chris PeBenito 3d5980
$(TUNXML) $(BOOLXML): $(POLXML)
Chris PeBenito 3d5980
Chris PeBenito c9f20d
html $(TMPDIR)/html: $(POLXML)
Chris PeBenito 2de03f
	@echo "Building html interface reference documentation in $(HTMLDIR)"
Chris PeBenito c9f20d
	@test -d $(HTMLDIR) || mkdir -p $(HTMLDIR)
Chris PeBenito 81a18f
	@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
Chris PeBenito 0e686f
	$(verbose) $(GENDOC) -d $(HTMLDIR) -T $(DOCTEMPLATE) -x $(POLXML)
Chris PeBenito 9b3756
	$(verbose) cp $(DOCTEMPLATE)/*.css $(HTMLDIR)
Chris PeBenito c9f20d
	@touch $(TMPDIR)/html
Chris PeBenito 20030e
Chris PeBenito c9a26b
########################################
Chris PeBenito c9a26b
#
Chris PeBenito c9a26b
# Runtime binary policy patching of users
Chris PeBenito c9a26b
#
Chris PeBenito c9f20d
$(USERPATH)/system.users: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(USER_FILES)
Chris PeBenito c9f20d
	@mkdir -p $(TMPDIR)
Chris PeBenito c9a26b
	@mkdir -p $(USERPATH)
Chris PeBenito c9a26b
	@echo "Installing system.users"
Chris PeBenito c9f20d
	@echo "# " > $(TMPDIR)/system.users
Chris PeBenito c9f20d
	@echo "# Do not edit this file. " >> $(TMPDIR)/system.users
Chris PeBenito c9f20d
	@echo "# This file is replaced on reinstalls of this policy." >> $(TMPDIR)/system.users
Chris PeBenito c9f20d
	@echo "# Please edit local.users to make local changes." >> $(TMPDIR)/system.users
Chris PeBenito c9f20d
	@echo "#" >> $(TMPDIR)/system.users
Chris PeBenito 9b3756
	$(verbose) m4 -D self_contained_policy $(M4PARAM) $^ | sed -r -e 's/^[[:blank:]]+//' \
Chris PeBenito c9f20d
		-e '/^[[:blank:]]*($$|#)/d' >> $(TMPDIR)/system.users
Chris PeBenito c9f20d
	$(verbose) install -m 644 $(TMPDIR)/system.users $@
Chris PeBenito c9a26b
Chris PeBenito 1beba1
$(USERPATH)/local.users: config/local.users
Chris PeBenito c9a26b
	@mkdir -p $(USERPATH)
Chris PeBenito c9a26b
	@echo "Installing local.users"
Chris PeBenito 9b3756
	$(verbose) install -b -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito c9a26b
########################################
Chris PeBenito c9a26b
#
Chris PeBenito c9a26b
# Appconfig files
Chris PeBenito c9a26b
#
Chris PeBenito c9a26b
install-appconfig: $(APPFILES)
Chris PeBenito c9a26b
Chris PeBenito 4f9f30
$(INSTALLDIR)/booleans: $(BOOLEANS)
Chris PeBenito c9f20d
	@mkdir -p $(TMPDIR)
Chris PeBenito 1beba1
	@mkdir -p $(INSTALLDIR)
Chris PeBenito 9b3756
	$(verbose) sed -r -e 's/false/0/g' -e 's/true/1/g' \
Chris PeBenito c9f20d
		-e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > $(TMPDIR)/booleans
Chris PeBenito c9f20d
	$(verbose) install -m 644 $(TMPDIR)/booleans $@
Chris PeBenito 1beba1
Chris PeBenito 2926f9
$(CONTEXTPATH)/files/media: $(APPCONF)/media
Chris PeBenito 1beba1
	@mkdir -p $(CONTEXTPATH)/files/
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito 2926f9
$(APPDIR)/default_contexts: $(APPCONF)/default_contexts
Chris PeBenito 1beba1
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito 2926f9
$(APPDIR)/removable_context: $(APPCONF)/removable_context
Chris PeBenito 1beba1
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito 2926f9
$(APPDIR)/default_type: $(APPCONF)/default_type
Chris PeBenito 1beba1
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito 2926f9
$(APPDIR)/userhelper_context: $(APPCONF)/userhelper_context
Chris PeBenito 1beba1
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito 2926f9
$(APPDIR)/initrc_context: $(APPCONF)/initrc_context
Chris PeBenito 1beba1
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito 2926f9
$(APPDIR)/failsafe_context: $(APPCONF)/failsafe_context
Chris PeBenito 1beba1
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito 2926f9
$(APPDIR)/dbus_contexts: $(APPCONF)/dbus_contexts
Chris PeBenito 1beba1
	@mkdir -p $(APPDIR)
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito c9a26b
Chris PeBenito 2926f9
$(APPDIR)/users/root: $(APPCONF)/root_default_contexts
Chris PeBenito 1beba1
	@mkdir -p $(APPDIR)/users
Chris PeBenito 9b3756
	$(verbose) install -m 644 $< $@
Chris PeBenito 9b3756
Chris PeBenito 9b3756
########################################
Chris PeBenito 9b3756
#
Chris PeBenito 9b3756
# Install policy headers
Chris PeBenito 9b3756
#
Chris PeBenito 3d5980
install-headers: $(TUNXML) $(BOOLXML)
Chris PeBenito 120988
	@mkdir -p $(HEADERDIR)
Chris PeBenito 1a7175
	@echo "Installing $(TYPE) policy headers."
Chris PeBenito 3d5980
	$(verbose) install -m 644 $(TUNXML) $(BOOLXML) $(HEADERDIR)
Chris PeBenito 885b83
	$(verbose) m4 $(M4PARAM) $(ROLEMAP) > $(HEADERDIR)/$(notdir $(ROLEMAP))
Chris PeBenito 885b83
	$(verbose) mkdir -p $(HEADERDIR)/support
Chris PeBenito d6cf05
	$(verbose) install -m 644 $(M4SUPPORT) $(word $(words $(GENXML)),$(GENXML)) $(XMLDTD) $(HEADERDIR)/support
Chris PeBenito 885b83
	$(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $(HEADERDIR)/support/all_perms.spt
Chris PeBenito 885b83
	$(verbose) for i in $(notdir $(ALL_LAYERS)); do \
Chris PeBenito 885b83
		mkdir -p $(HEADERDIR)/$$i ;\
Chris PeBenito 885b83
		install -m 644 $(MODDIR)/$$i/*.if \
Chris PeBenito 885b83
			$(MODDIR)/$$i/metadata.xml \
Chris PeBenito 885b83
			$(HEADERDIR)/$$i ;\
Chris PeBenito 885b83
	done
Chris PeBenito 0f27d9
	$(verbose) echo "TYPE ?= $(TYPE)" > $(HEADERDIR)/build.conf
Chris PeBenito 0f27d9
	$(verbose) echo "NAME ?= $(NAME)" >> $(HEADERDIR)/build.conf
Chris PeBenito 885b83
ifneq "$(DISTRO)" ""
Chris PeBenito 0f27d9
	$(verbose) echo "DISTRO ?= $(DISTRO)" >> $(HEADERDIR)/build.conf
Chris PeBenito 885b83
endif
Chris PeBenito 0f27d9
	$(verbose) echo "MONOLITHIC ?= n" >> $(HEADERDIR)/build.conf
Chris PeBenito 0f27d9
	$(verbose) echo "DIRECT_INITRC ?= $(DIRECT_INITRC)" >> $(HEADERDIR)/build.conf
Chris PeBenito 0f27d9
	$(verbose) echo "POLY ?= $(POLY)" >> $(HEADERDIR)/build.conf
Chris PeBenito 885b83
	$(verbose) install -m 644 $(SUPPORT)/Makefile.devel $(HEADERDIR)/Makefile
Chris PeBenito c9a26b
Chris PeBenito c592e5
########################################
Chris PeBenito c592e5
#
Chris PeBenito 120988
# Install policy documentation
Chris PeBenito 120988
#
Chris PeBenito c9f20d
install-docs: $(TMPDIR)/html
Chris PeBenito 120988
	@mkdir -p $(DOCSDIR)/html
Chris PeBenito 120988
	@echo "Installing policy documentation"
Chris PeBenito 5bd1a7
	$(verbose) install -m 644 $(DOCFILES) $(DOCSDIR)
Chris PeBenito 120988
	$(verbose) install -m 644 $(wildcard $(HTMLDIR)/*) $(DOCSDIR)/html
Chris PeBenito 120988
Chris PeBenito 120988
########################################
Chris PeBenito 120988
#
Chris PeBenito c592e5
# Install policy sources
Chris PeBenito c592e5
#
Chris PeBenito c592e5
install-src:
Chris PeBenito c592e5
	rm -rf $(SRCPATH)/policy.old
Chris PeBenito c592e5
	-mv $(SRCPATH)/policy $(SRCPATH)/policy.old
Chris PeBenito c592e5
	mkdir -p $(SRCPATH)/policy
Chris PeBenito c592e5
	cp -R . $(SRCPATH)/policy
Chris PeBenito c592e5
Chris PeBenito 102a59
########################################
Chris PeBenito 102a59
#
Chris PeBenito 37227d
# Generate tags file
Chris PeBenito 37227d
#
Chris PeBenito c9f20d
tags: $(TAGS)
Chris PeBenito c9f20d
$(TAGS):
Chris PeBenito 37227d
	@($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1)
Chris PeBenito c9f20d
	@LC_ALL=C $(CTAGS) -f $(TAGS) --langdef=te --langmap=te:..te.if.spt \
Chris PeBenito 37227d
	 --regex-te='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \
Chris PeBenito 37227d
	 --regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \
Chris PeBenito 37227d
	 --regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \
Chris PeBenito 37227d
	 --regex-te='/^[ \t]*define\(`(\w+)/\1/d,define/' \
Chris PeBenito 37227d
	 --regex-te='/^[ \t]*interface\(`(\w+)/\1/i,interface/' \
Chris PeBenito 37227d
	 --regex-te='/^[ \t]*bool[ \t]+(\w+)/\1/b,bool/' policy/modules/*/*.{if,te} policy/support/*.spt
Chris PeBenito 37227d
Chris PeBenito 37227d
########################################
Chris PeBenito 37227d
#
Chris PeBenito 120988
# Filesystem labeling
Chris PeBenito 120988
#
Chris PeBenito 120988
checklabels:
Chris PeBenito 120988
	@echo "Checking labels on filesystem types: ext2 ext3 xfs jfs"
Chris PeBenito 120988
	@if test -z "$(FILESYSTEMS)"; then \
Chris PeBenito 120988
		echo "No filesystems with extended attributes found!" ;\
Chris PeBenito 120988
		false ;\
Chris PeBenito 120988
	fi
Chris PeBenito 120988
	$(verbose) $(SETFILES) -v -n $(FCPATH) $(FILESYSTEMS)
Chris PeBenito 120988
Chris PeBenito 120988
restorelabels:
Chris PeBenito 120988
	@echo "Restoring labels on filesystem types: ext2 ext3 xfs jfs"
Chris PeBenito 120988
	@if test -z "$(FILESYSTEMS)"; then \
Chris PeBenito 120988
		echo "No filesystems with extended attributes found!" ;\
Chris PeBenito 120988
		false ;\
Chris PeBenito 120988
	fi
Chris PeBenito 120988
	$(verbose) $(SETFILES) -v $(FCPATH) $(FILESYSTEMS)
Chris PeBenito 120988
Chris PeBenito 120988
relabel:
Chris PeBenito 120988
	@echo "Relabeling filesystem types: ext2 ext3 xfs jfs"
Chris PeBenito 120988
	@if test -z "$(FILESYSTEMS)"; then \
Chris PeBenito 120988
		echo "No filesystems with extended attributes found!" ;\
Chris PeBenito 120988
		false ;\
Chris PeBenito 120988
	fi
Chris PeBenito 120988
	$(verbose) $(SETFILES) $(FCPATH) $(FILESYSTEMS)
Chris PeBenito 120988
Chris PeBenito 120988
resetlabels:
Chris PeBenito 120988
	@echo "Resetting labels on filesystem types: ext2 ext3 xfs jfs"
Chris PeBenito 120988
	@if test -z "$(FILESYSTEMS)"; then \
Chris PeBenito 120988
		echo "No filesystems with extended attributes found!" ;\
Chris PeBenito 120988
		false ;\
Chris PeBenito 120988
	fi
Chris PeBenito 120988
	$(verbose) $(SETFILES) -F $(FCPATH) $(FILESYSTEMS)
Chris PeBenito 120988
Chris PeBenito 120988
########################################
Chris PeBenito 120988
#
Chris PeBenito 102a59
# Clean everything
Chris PeBenito 102a59
#
Chris PeBenito 0fbe15
bare: clean
Chris PeBenito 12b559
	rm -f $(POLXML)
Chris PeBenito 3d5980
	rm -f $(TUNXML)
Chris PeBenito 3d5980
	rm -f $(BOOLXML)
Chris PeBenito 19db6b
	rm -f $(MOD_CONF)
Chris PeBenito 4f9f30
	rm -f $(BOOLEANS)
Chris PeBenito 20030e
	rm -fR $(HTMLDIR)
Chris PeBenito c9f20d
	rm -f $(TAGS)
Chris PeBenito c9f20d
# don't remove these files if we're given a local root
Chris PeBenito c9f20d
ifndef LOCAL_ROOT
Chris PeBenito c9f20d
	rm -f $(FCSORT)
Chris PeBenito c9f20d
	rm -f $(SUPPORT)/*.pyc
Chris PeBenito c767b1
ifneq ($(GENERATED_TE),)
Chris PeBenito c767b1
	rm -f $(GENERATED_TE)
Chris PeBenito c767b1
endif
Chris PeBenito c767b1
ifneq ($(GENERATED_IF),)
Chris PeBenito c767b1
	rm -f $(GENERATED_IF)
Chris PeBenito c767b1
endif
Chris PeBenito c767b1
ifneq ($(GENERATED_FC),)
Chris PeBenito c767b1
	rm -f $(GENERATED_FC)
Chris PeBenito c767b1
endif
Chris PeBenito c9f20d
endif
Chris PeBenito 0fbe15
Chris PeBenito 1a7175
.PHONY: install-src install-appconfig generate xml conf html bare tags
Chris PeBenito b8c798
.SUFFIXES:
Chris PeBenito b8c798
.SUFFIXES: .c