2005-04-19 13:53:51 +00:00
|
|
|
#
|
|
|
|
# Makefile for the security policy.
|
|
|
|
#
|
|
|
|
# Targets:
|
|
|
|
#
|
|
|
|
# install - compile and install the policy configuration, and context files.
|
|
|
|
# load - compile, install, and load the policy configuration.
|
|
|
|
# reload - compile, install, and load/reload the policy configuration.
|
|
|
|
# relabel - relabel filesystems based on the file contexts configuration.
|
|
|
|
# checklabels - check filesystems against the file context configuration
|
|
|
|
# restorelabels - check filesystems against the file context configuration
|
|
|
|
# and restore the label of files with incorrect labels
|
|
|
|
# policy - compile the policy configuration locally for testing/development.
|
|
|
|
#
|
|
|
|
# The default target is 'policy'.
|
|
|
|
#
|
2005-04-14 20:18:17 +00:00
|
|
|
#
|
2005-12-01 19:04:57 +00:00
|
|
|
# Please see build.conf for policy build options.
|
2005-04-14 20:18:17 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
2005-06-06 18:13:38 +00:00
|
|
|
# NO OPTIONS BELOW HERE
|
2005-04-14 20:18:17 +00:00
|
|
|
#
|
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
# Include the local build.conf if it exists, otherwise
|
|
|
|
# include the configuration of the root directory.
|
2006-02-17 14:26:39 +00:00
|
|
|
include build.conf
|
|
|
|
|
|
|
|
ifdef LOCAL_ROOT
|
|
|
|
-include $(LOCAL_ROOT)/build.conf
|
2006-02-15 17:59:58 +00:00
|
|
|
endif
|
2005-12-01 19:04:57 +00:00
|
|
|
|
2006-02-01 13:22:14 +00:00
|
|
|
# refpolicy version
|
|
|
|
VERSION = $(shell cat VERSION)
|
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
ifdef LOCAL_ROOT
|
2006-02-16 17:11:58 +00:00
|
|
|
BUILDDIR := $(LOCAL_ROOT)/
|
2006-02-15 17:59:58 +00:00
|
|
|
TMPDIR := $(LOCAL_ROOT)/tmp
|
|
|
|
TAGS := $(LOCAL_ROOT)/tags
|
|
|
|
else
|
2006-02-16 17:11:58 +00:00
|
|
|
TMPDIR := tmp
|
|
|
|
TAGS := tags
|
2006-02-15 17:59:58 +00:00
|
|
|
endif
|
|
|
|
|
2005-04-14 20:18:17 +00:00
|
|
|
# executable paths
|
2006-02-01 13:22:14 +00:00
|
|
|
BINDIR := /usr/bin
|
|
|
|
SBINDIR := /usr/sbin
|
2005-10-24 22:29:30 +00:00
|
|
|
CHECKPOLICY := $(BINDIR)/checkpolicy
|
2005-08-18 21:27:20 +00:00
|
|
|
CHECKMODULE := $(BINDIR)/checkmodule
|
2005-11-22 22:07:12 +00:00
|
|
|
SEMODULE := $(SBINDIR)/semodule
|
2005-08-18 21:27:20 +00:00
|
|
|
SEMOD_PKG := $(BINDIR)/semodule_package
|
2006-05-02 20:14:41 +00:00
|
|
|
SEMOD_LNK := $(BINDIR)/semodule_link
|
|
|
|
SEMOD_EXP := $(BINDIR)/semodule_expand
|
2005-05-24 20:44:31 +00:00
|
|
|
LOADPOLICY := $(SBINDIR)/load_policy
|
2005-04-14 20:18:17 +00:00
|
|
|
SETFILES := $(SBINDIR)/setfiles
|
2005-08-18 21:27:20 +00:00
|
|
|
XMLLINT := $(BINDIR)/xmllint
|
2005-10-12 19:13:49 +00:00
|
|
|
SECHECK := $(BINDIR)/sechecker
|
2005-06-01 19:01:00 +00:00
|
|
|
|
2006-02-13 20:06:05 +00:00
|
|
|
# interpreters and aux tools
|
|
|
|
AWK ?= gawk
|
|
|
|
GREP ?= egrep
|
|
|
|
M4 ?= m4
|
|
|
|
PYTHON ?= python
|
|
|
|
SED ?= sed
|
2006-03-21 18:14:48 +00:00
|
|
|
SORT ?= LC_ALL=C sort
|
2006-02-13 20:06:05 +00:00
|
|
|
|
|
|
|
CFLAGS += -Wall
|
2005-06-15 14:08:18 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
# policy source layout
|
2006-02-16 17:11:58 +00:00
|
|
|
POLDIR := policy
|
2005-08-22 17:07:17 +00:00
|
|
|
MODDIR := $(POLDIR)/modules
|
|
|
|
FLASKDIR := $(POLDIR)/flask
|
|
|
|
SECCLASS := $(FLASKDIR)/security_classes
|
|
|
|
ISIDS := $(FLASKDIR)/initial_sids
|
|
|
|
AVS := $(FLASKDIR)/access_vectors
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
# local source layout
|
|
|
|
ifdef LOCAL_ROOT
|
|
|
|
LOCAL_POLDIR := $(LOCAL_ROOT)/policy
|
|
|
|
LOCAL_MODDIR := $(LOCAL_POLDIR)/modules
|
|
|
|
endif
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
# policy building support tools
|
2006-02-16 17:11:58 +00:00
|
|
|
SUPPORT := support
|
2006-02-13 20:06:05 +00:00
|
|
|
GENXML := $(PYTHON) $(SUPPORT)/segenxml.py
|
|
|
|
GENDOC := $(PYTHON) $(SUPPORT)/sedoctool.py
|
|
|
|
GENPERM := $(PYTHON) $(SUPPORT)/genclassperms.py
|
2006-02-15 17:59:58 +00:00
|
|
|
FCSORT := $(TMPDIR)/fc_sort
|
2006-02-15 18:27:23 +00:00
|
|
|
SETBOOLS := $(AWK) -f $(SUPPORT)/set_bools_tuns.awk
|
2006-03-20 20:54:56 +00:00
|
|
|
get_type_attr_decl := $(SED) -r -f $(SUPPORT)/get_type_attr_decl.sed
|
|
|
|
comment_move_decl := $(SED) -r -f $(SUPPORT)/comment_move_decl.sed
|
2006-05-15 15:21:43 +00:00
|
|
|
# use our own genhomedircon to make sure we have a known usable one,
|
|
|
|
# so policycoreutils updates are not required (RHEL4)
|
|
|
|
genhomedircon := $(PYTHON) $(SUPPORT)/genhomedircon
|
2005-06-07 18:35:18 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
# documentation paths
|
2006-02-16 17:11:58 +00:00
|
|
|
DOCS := doc
|
2005-08-18 21:27:20 +00:00
|
|
|
XMLDTD = $(DOCS)/policy.dtd
|
|
|
|
LAYERXML = metadata.xml
|
|
|
|
DOCTEMPLATE = $(DOCS)/templates
|
2006-02-01 13:46:05 +00:00
|
|
|
DOCFILES = $(DOCS)/Makefile.example $(addprefix $(DOCS)/,example.te example.if example.fc)
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
ifndef LOCAL_ROOT
|
|
|
|
POLXML = $(DOCS)/policy.xml
|
2006-02-16 20:41:57 +00:00
|
|
|
TUNXML = $(DOCS)/global_tunables.xml
|
|
|
|
BOOLXML = $(DOCS)/global_booleans.xml
|
2006-02-15 17:59:58 +00:00
|
|
|
HTMLDIR = $(DOCS)/html
|
|
|
|
else
|
|
|
|
POLXML = $(LOCAL_ROOT)/doc/policy.xml
|
2006-02-16 20:41:57 +00:00
|
|
|
TUNXML = $(LOCAL_ROOT)/doc/global_tunables.xml
|
|
|
|
BOOLXML = $(LOCAL_ROOT)/doc/global_booleans.xml
|
2006-02-15 17:59:58 +00:00
|
|
|
HTMLDIR = $(LOCAL_ROOT)/doc/html
|
|
|
|
endif
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
# config file paths
|
2006-02-01 13:22:14 +00:00
|
|
|
GLOBALTUN = $(POLDIR)/global_tunables
|
|
|
|
GLOBALBOOL = $(POLDIR)/global_booleans
|
|
|
|
TUNABLES = $(POLDIR)/tunables.conf
|
|
|
|
ROLEMAP = $(POLDIR)/rolemap
|
2006-02-15 19:46:20 +00:00
|
|
|
USER_FILES := $(POLDIR)/users
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
# local config file paths
|
|
|
|
ifndef LOCAL_ROOT
|
|
|
|
MOD_CONF = $(POLDIR)/modules.conf
|
|
|
|
BOOLEANS = $(POLDIR)/booleans.conf
|
|
|
|
else
|
|
|
|
MOD_CONF = $(LOCAL_POLDIR)/modules.conf
|
|
|
|
BOOLEANS = $(LOCAL_POLDIR)/booleans.conf
|
|
|
|
endif
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
# install paths
|
2006-02-01 13:22:14 +00:00
|
|
|
PKGNAME ?= refpolicy-$(VERSION)
|
|
|
|
PREFIX = $(DESTDIR)/usr
|
|
|
|
TOPDIR = $(DESTDIR)/etc/selinux
|
|
|
|
INSTALLDIR = $(TOPDIR)/$(NAME)
|
|
|
|
SRCPATH = $(INSTALLDIR)/src
|
|
|
|
USERPATH = $(INSTALLDIR)/users
|
|
|
|
CONTEXTPATH = $(INSTALLDIR)/contexts
|
|
|
|
FCPATH = $(CONTEXTPATH)/files/file_contexts
|
|
|
|
SHAREDIR = $(PREFIX)/share/selinux
|
|
|
|
MODPKGDIR = $(SHAREDIR)/$(NAME)
|
2006-02-15 18:27:23 +00:00
|
|
|
HEADERDIR = $(MODPKGDIR)/include
|
2006-02-01 13:22:14 +00:00
|
|
|
DOCSDIR = $(PREFIX)/share/doc/$(PKGNAME)
|
2005-11-22 22:07:12 +00:00
|
|
|
|
|
|
|
# compile strict policy if requested.
|
|
|
|
ifneq ($(findstring strict,$(TYPE)),)
|
2006-01-25 19:29:55 +00:00
|
|
|
M4PARAM += -D strict_policy
|
2005-11-22 22:07:12 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# compile targeted policy if requested.
|
|
|
|
ifneq ($(findstring targeted,$(TYPE)),)
|
2006-01-25 19:29:55 +00:00
|
|
|
M4PARAM += -D targeted_policy
|
2005-11-22 22:07:12 +00:00
|
|
|
endif
|
2005-04-14 20:18:17 +00:00
|
|
|
|
2005-06-01 15:40:37 +00:00
|
|
|
# enable MLS if requested.
|
2005-09-16 13:36:26 +00:00
|
|
|
ifneq ($(findstring -mls,$(TYPE)),)
|
2006-01-25 19:29:55 +00:00
|
|
|
M4PARAM += -D enable_mls
|
|
|
|
CHECKPOLICY += -M
|
|
|
|
CHECKMODULE += -M
|
2005-06-01 15:40:37 +00:00
|
|
|
endif
|
|
|
|
|
2005-09-16 13:36:26 +00:00
|
|
|
# enable MLS if MCS requested.
|
|
|
|
ifneq ($(findstring -mcs,$(TYPE)),)
|
2006-01-25 19:29:55 +00:00
|
|
|
M4PARAM += -D enable_mcs
|
|
|
|
CHECKPOLICY += -M
|
|
|
|
CHECKMODULE += -M
|
2005-06-06 18:13:38 +00:00
|
|
|
endif
|
|
|
|
|
2005-07-13 18:08:12 +00:00
|
|
|
# enable distribution-specific policy
|
|
|
|
ifneq ($(DISTRO),)
|
2006-01-25 19:29:55 +00:00
|
|
|
M4PARAM += -D distro_$(DISTRO)
|
2005-07-13 18:08:12 +00:00
|
|
|
endif
|
|
|
|
|
2006-03-31 14:28:45 +00:00
|
|
|
# rhel4 also implies redhat
|
|
|
|
ifeq "$(DISTRO)" "rhel4"
|
|
|
|
M4PARAM += -D distro_redhat
|
|
|
|
endif
|
|
|
|
|
2006-01-10 21:03:16 +00:00
|
|
|
# enable polyinstantiation
|
|
|
|
ifeq ($(POLY),y)
|
2006-01-25 19:29:55 +00:00
|
|
|
M4PARAM += -D enable_polyinstantiation
|
2006-01-10 21:03:16 +00:00
|
|
|
endif
|
|
|
|
|
2005-06-06 18:13:38 +00:00
|
|
|
ifneq ($(OUTPUT_POLICY),)
|
2006-01-25 19:29:55 +00:00
|
|
|
CHECKPOLICY += -c $(OUTPUT_POLICY)
|
2005-06-06 18:13:38 +00:00
|
|
|
endif
|
|
|
|
|
2006-01-25 19:29:55 +00:00
|
|
|
# if not set, use the type as the name.
|
|
|
|
NAME ?= $(TYPE)
|
2005-06-01 15:40:37 +00:00
|
|
|
|
2005-09-21 14:49:41 +00:00
|
|
|
ifeq ($(DIRECT_INITRC),y)
|
2006-01-25 19:29:55 +00:00
|
|
|
M4PARAM += -D direct_sysadm_daemon
|
2005-09-21 14:49:41 +00:00
|
|
|
endif
|
|
|
|
|
2006-01-26 20:35:55 +00:00
|
|
|
ifeq ($(QUIET),y)
|
|
|
|
verbose = @
|
|
|
|
endif
|
|
|
|
|
2006-01-25 19:29:55 +00:00
|
|
|
M4PARAM += -D hide_broken_symptoms
|
2005-10-24 22:49:26 +00:00
|
|
|
|
2006-01-25 18:30:27 +00:00
|
|
|
# we need exuberant ctags; unfortunately it is named
|
|
|
|
# differently on different distros
|
|
|
|
ifeq ($(DISTRO),debian)
|
|
|
|
CTAGS := ctags-exuberant
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(DISTRO),gentoo)
|
|
|
|
CTAGS := exuberant-ctags
|
|
|
|
endif
|
|
|
|
|
2006-01-25 19:02:48 +00:00
|
|
|
CTAGS ?= ctags
|
2006-01-25 18:30:27 +00:00
|
|
|
|
2005-04-14 20:18:17 +00:00
|
|
|
# determine the policy version and current kernel version if possible
|
2005-06-01 15:40:37 +00:00
|
|
|
PV := $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ')
|
2005-04-14 20:18:17 +00:00
|
|
|
KV := $(shell cat /selinux/policyvers)
|
|
|
|
|
|
|
|
# dont print version warnings if we are unable to determine
|
|
|
|
# the currently running kernel's policy version
|
|
|
|
ifeq ($(KV),)
|
2005-06-01 15:40:37 +00:00
|
|
|
KV := $(PV)
|
2005-04-14 20:18:17 +00:00
|
|
|
endif
|
|
|
|
|
2006-04-11 18:23:53 +00:00
|
|
|
M4SUPPORT := $(wildcard $(POLDIR)/support/*.spt)
|
|
|
|
ifdef LOCAL_ROOT
|
|
|
|
M4SUPPORT += $(wildcard $(LOCAL_POLDIR)/support/*.spt)
|
|
|
|
endif
|
2005-06-07 15:11:47 +00:00
|
|
|
|
2006-02-16 17:11:58 +00:00
|
|
|
APPCONF := config/appconfig-$(TYPE)
|
2006-02-15 21:58:41 +00:00
|
|
|
SEUSERS := $(APPCONF)/seusers
|
2005-05-25 20:58:09 +00:00
|
|
|
APPDIR := $(CONTEXTPATH)
|
2005-12-09 15:42:39 +00:00
|
|
|
APPFILES := $(addprefix $(APPDIR)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts customizable_types) $(CONTEXTPATH)/files/media
|
2005-06-01 17:27:56 +00:00
|
|
|
CONTEXTFILES += $(wildcard $(APPCONF)/*_context*) $(APPCONF)/media
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-20 18:40:44 +00:00
|
|
|
ALL_LAYERS := $(filter-out $(MODDIR)/CVS,$(shell find $(wildcard $(MODDIR)/*) -maxdepth 0 -type d))
|
2006-02-15 17:59:58 +00:00
|
|
|
ifdef LOCAL_ROOT
|
2006-02-15 18:35:02 +00:00
|
|
|
ALL_LAYERS += $(filter-out $(LOCAL_MODDIR)/CVS,$(shell find $(wildcard $(LOCAL_MODDIR)/*) -maxdepth 0 -type d))
|
2006-02-15 17:59:58 +00:00
|
|
|
endif
|
2005-06-08 22:14:26 +00:00
|
|
|
|
|
|
|
GENERATED_TE := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te.in)))
|
|
|
|
GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in)))
|
|
|
|
GENERATED_FC := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.fc.in)))
|
|
|
|
|
2005-06-14 18:39:55 +00:00
|
|
|
# sort here since it removes duplicates, which can happen
|
|
|
|
# when a generated file is already generated
|
|
|
|
DETECTED_MODS := $(sort $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te)) $(GENERATED_TE))
|
2005-06-28 17:31:18 +00:00
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
# modules.conf setting for base module
|
2005-07-05 19:42:11 +00:00
|
|
|
MODBASE := base
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-01-12 16:07:59 +00:00
|
|
|
# modules.conf setting for loadable module
|
2005-07-05 19:42:11 +00:00
|
|
|
MODMOD := module
|
2005-08-18 21:27:20 +00:00
|
|
|
|
2006-01-12 16:07:59 +00:00
|
|
|
# modules.conf setting for unused module
|
|
|
|
MODUNUSED := off
|
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
# test for module overrides from command line
|
2006-03-06 15:20:12 +00:00
|
|
|
MOD_TEST = $(filter $(APPS_OFF), $(APPS_BASE) $(APPS_MODS))
|
|
|
|
MOD_TEST += $(filter $(APPS_MODS), $(APPS_BASE))
|
2006-02-15 17:59:58 +00:00
|
|
|
ifneq ($(strip $(MOD_TEST)),)
|
2006-03-20 20:54:56 +00:00
|
|
|
$(error Applications must be base, module, or off, and not in more than one list! $(strip $(MOD_TEST)) found in multiple lists!)
|
2006-02-15 17:59:58 +00:00
|
|
|
endif
|
|
|
|
|
2006-04-11 18:23:53 +00:00
|
|
|
# add on suffix to modules specified on command line
|
|
|
|
CMDLINE_BASE := $(addsuffix .te,$(APPS_BASE))
|
|
|
|
CMDLINE_MODS := $(addsuffix .te,$(APPS_MODS))
|
|
|
|
CMDLINE_OFF := $(addsuffix .te,$(APPS_OFF))
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
# extract settings from modules.conf
|
2006-04-11 18:23:53 +00:00
|
|
|
MOD_CONF_BASE := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
|
|
|
|
MOD_CONF_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
|
|
|
|
MOD_CONF_OFF := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null)))
|
|
|
|
|
|
|
|
BASE_MODS := $(CMDLINE_BASE)
|
|
|
|
MOD_MODS := $(CMDLINE_MODS)
|
|
|
|
OFF_MODS := $(CMDLINE_OFF)
|
2006-03-06 15:20:12 +00:00
|
|
|
|
2006-04-11 18:23:53 +00:00
|
|
|
BASE_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_BASE))
|
|
|
|
MOD_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_MODS))
|
|
|
|
OFF_MODS += $(filter-out $(CMDLINE_OFF) $(CMDLINE_BASE) $(CMDLINE_MODS), $(MOD_CONF_OFF))
|
2006-03-06 15:20:12 +00:00
|
|
|
|
|
|
|
# add modules not in modules.conf to the off list
|
2006-04-11 18:23:53 +00:00
|
|
|
OFF_MODS += $(filter-out $(BASE_MODS) $(MOD_MODS) $(OFF_MODS),$(notdir $(DETECTED_MODS)))
|
2005-09-12 15:17:39 +00:00
|
|
|
|
2006-02-15 19:46:20 +00:00
|
|
|
# filesystems to be used in labeling targets
|
2006-02-01 13:22:14 +00:00
|
|
|
FILESYSTEMS = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';)
|
|
|
|
|
2006-01-26 18:04:57 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Functions
|
|
|
|
#
|
|
|
|
|
|
|
|
# parse-rolemap modulename,outputfile
|
|
|
|
define parse-rolemap
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) m4 $(M4PARAM) $(ROLEMAP) | \
|
2006-01-26 18:04:57 +00:00
|
|
|
awk '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_userdomain_template(" $$2 "," $$3 "," $$1 ")" }' >> $2
|
|
|
|
endef
|
|
|
|
|
|
|
|
# peruser-expansion modulename,outputfile
|
|
|
|
define peruser-expansion
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) echo "ifdef(\`""$1""_per_userdomain_template',\`" > $2
|
2006-01-26 18:04:57 +00:00
|
|
|
$(call parse-rolemap,$1,$2)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) echo "')" >> $2
|
2006-01-26 18:04:57 +00:00
|
|
|
endef
|
|
|
|
|
2005-04-14 20:18:17 +00:00
|
|
|
########################################
|
|
|
|
#
|
2005-08-18 21:27:20 +00:00
|
|
|
# Load appropriate rules
|
2005-04-14 20:18:17 +00:00
|
|
|
#
|
|
|
|
|
2005-08-18 21:27:20 +00:00
|
|
|
ifeq ($(MONOLITHIC),y)
|
2006-02-16 17:11:58 +00:00
|
|
|
include Rules.monolithic
|
2005-08-18 21:27:20 +00:00
|
|
|
else
|
2006-02-16 17:11:58 +00:00
|
|
|
include Rules.modular
|
2005-04-14 20:18:17 +00:00
|
|
|
endif
|
|
|
|
|
2005-04-19 13:53:51 +00:00
|
|
|
########################################
|
|
|
|
#
|
2005-08-18 21:27:20 +00:00
|
|
|
# Generated files
|
2005-04-14 20:18:17 +00:00
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
# NOTE: There is no "local" version of these files.
|
|
|
|
#
|
2006-02-16 22:25:09 +00:00
|
|
|
generate: $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC)
|
|
|
|
|
2005-06-08 21:46:39 +00:00
|
|
|
$(MODDIR)/kernel/corenetwork.if: $(MODDIR)/kernel/corenetwork.if.m4 $(MODDIR)/kernel/corenetwork.if.in
|
2005-06-13 18:40:08 +00:00
|
|
|
@echo "#" > $@
|
|
|
|
@echo "# This is a generated file! Instead of modifying this file, the" >> $@
|
|
|
|
@echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
|
|
|
|
@echo "#" >> $@
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) cat $(MODDIR)/kernel/corenetwork.if.in >> $@
|
|
|
|
$(verbose) egrep "^[[:blank:]]*network_(interface|node|port)\(.*\)" $(@:.if=.te).in \
|
2005-10-21 13:11:17 +00:00
|
|
|
| m4 -D self_contained_policy $(M4PARAM) $(MODDIR)/kernel/corenetwork.if.m4 - \
|
2005-06-08 21:46:39 +00:00
|
|
|
| sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
|
|
|
|
|
|
|
|
$(MODDIR)/kernel/corenetwork.te: $(MODDIR)/kernel/corenetwork.te.m4 $(MODDIR)/kernel/corenetwork.te.in
|
2005-06-13 18:40:08 +00:00
|
|
|
@echo "#" > $@
|
|
|
|
@echo "# This is a generated file! Instead of modifying this file, the" >> $@
|
|
|
|
@echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@
|
|
|
|
@echo "#" >> $@
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) m4 -D self_contained_policy $(M4PARAM) $^ \
|
2005-06-13 18:40:08 +00:00
|
|
|
| sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@
|
2005-06-08 21:46:39 +00:00
|
|
|
|
2005-06-08 13:44:23 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Create config files
|
|
|
|
#
|
2005-10-07 18:08:50 +00:00
|
|
|
conf: $(MOD_CONF) $(BOOLEANS) $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC)
|
2005-06-14 15:54:55 +00:00
|
|
|
|
2005-10-07 18:08:50 +00:00
|
|
|
$(MOD_CONF) $(BOOLEANS): $(POLXML)
|
|
|
|
@echo "Updating $(MOD_CONF) and $(BOOLEANS)"
|
2006-03-02 23:39:28 +00:00
|
|
|
$(verbose) $(GENDOC) -b $(BOOLEANS) -m $(MOD_CONF) -x $(POLXML)
|
2005-06-08 13:44:23 +00:00
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Generate the fc_sort program
|
|
|
|
#
|
|
|
|
$(FCSORT) : $(SUPPORT)/fc_sort.c
|
2006-02-16 22:25:09 +00:00
|
|
|
$(verbose) $(CC) $(CFLAGS) $(SUPPORT)/fc_sort.c -o $(FCSORT)
|
2006-02-15 17:59:58 +00:00
|
|
|
|
2005-05-18 20:58:13 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Documentation generation
|
|
|
|
#
|
|
|
|
|
2005-06-14 15:54:55 +00:00
|
|
|
# minimal dependencies here, because we don't want to rebuild
|
2005-06-08 13:44:23 +00:00
|
|
|
# this and its dependents every time the dependencies
|
2005-06-28 17:31:18 +00:00
|
|
|
# change. Also use all .if files here, rather then just the
|
|
|
|
# enabled modules.
|
2006-02-17 14:26:39 +00:00
|
|
|
xml: $(POLXML)
|
2005-06-29 16:54:13 +00:00
|
|
|
$(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML))
|
2006-02-17 14:26:39 +00:00
|
|
|
@echo "Creating $(@F)"
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(dir $(POLXML)) || mkdir -p $(dir $(POLXML))
|
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) echo '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' > $@
|
|
|
|
$(verbose) echo '<!DOCTYPE policy SYSTEM "$(notdir $(XMLDTD))">' >> $@
|
2006-05-10 18:09:08 +00:00
|
|
|
$(verbose) $(GENXML) -w -m $(LAYERXML) -t $(GLOBALTUN) -b $(GLOBALBOOL) -o $(DOCS) $(ALL_LAYERS) >> $@
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) if test -x $(XMLLINT) && test -f $(XMLDTD); then \
|
2006-02-15 17:59:58 +00:00
|
|
|
$(XMLLINT) --noout --path $(dir $(XMLDTD)) --dtdvalid $(XMLDTD) $@ ;\
|
2005-06-01 18:34:34 +00:00
|
|
|
fi
|
2005-05-18 20:58:13 +00:00
|
|
|
|
2006-02-16 20:41:57 +00:00
|
|
|
$(TUNXML) $(BOOLXML): $(POLXML)
|
|
|
|
|
2006-02-15 17:59:58 +00:00
|
|
|
html $(TMPDIR)/html: $(POLXML)
|
2006-01-18 22:30:01 +00:00
|
|
|
@echo "Building html interface reference documentation in $(HTMLDIR)"
|
2006-02-15 17:59:58 +00:00
|
|
|
@test -d $(HTMLDIR) || mkdir -p $(HTMLDIR)
|
2006-02-15 18:30:12 +00:00
|
|
|
@test -d $(TMPDIR) || mkdir -p $(TMPDIR)
|
2006-02-13 20:06:05 +00:00
|
|
|
$(verbose) $(GENDOC) -d $(HTMLDIR) -T $(DOCTEMPLATE) -x $(POLXML)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) cp $(DOCTEMPLATE)/*.css $(HTMLDIR)
|
2006-02-15 17:59:58 +00:00
|
|
|
@touch $(TMPDIR)/html
|
2005-06-09 19:02:52 +00:00
|
|
|
|
2005-05-25 20:58:09 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Runtime binary policy patching of users
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
$(USERPATH)/system.users: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(USER_FILES)
|
|
|
|
@mkdir -p $(TMPDIR)
|
2005-05-25 20:58:09 +00:00
|
|
|
@mkdir -p $(USERPATH)
|
|
|
|
@echo "Installing system.users"
|
2006-02-15 17:59:58 +00:00
|
|
|
@echo "# " > $(TMPDIR)/system.users
|
|
|
|
@echo "# Do not edit this file. " >> $(TMPDIR)/system.users
|
|
|
|
@echo "# This file is replaced on reinstalls of this policy." >> $(TMPDIR)/system.users
|
|
|
|
@echo "# Please edit local.users to make local changes." >> $(TMPDIR)/system.users
|
|
|
|
@echo "#" >> $(TMPDIR)/system.users
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) m4 -D self_contained_policy $(M4PARAM) $^ | sed -r -e 's/^[[:blank:]]+//' \
|
2006-02-15 17:59:58 +00:00
|
|
|
-e '/^[[:blank:]]*($$|#)/d' >> $(TMPDIR)/system.users
|
|
|
|
$(verbose) install -m 644 $(TMPDIR)/system.users $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-14 18:13:55 +00:00
|
|
|
$(USERPATH)/local.users: config/local.users
|
2005-05-25 20:58:09 +00:00
|
|
|
@mkdir -p $(USERPATH)
|
|
|
|
@echo "Installing local.users"
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -b -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Appconfig files
|
|
|
|
#
|
|
|
|
install-appconfig: $(APPFILES)
|
|
|
|
|
2005-10-07 18:08:50 +00:00
|
|
|
$(INSTALLDIR)/booleans: $(BOOLEANS)
|
2006-02-15 17:59:58 +00:00
|
|
|
@mkdir -p $(TMPDIR)
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(INSTALLDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) sed -r -e 's/false/0/g' -e 's/true/1/g' \
|
2006-02-15 17:59:58 +00:00
|
|
|
-e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > $(TMPDIR)/booleans
|
|
|
|
$(verbose) install -m 644 $(TMPDIR)/booleans $@
|
2005-06-14 18:13:55 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(CONTEXTPATH)/files/media: $(APPCONF)/media
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(CONTEXTPATH)/files/
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(APPDIR)/default_contexts: $(APPCONF)/default_contexts
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(APPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(APPDIR)/removable_context: $(APPCONF)/removable_context
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(APPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(APPDIR)/default_type: $(APPCONF)/default_type
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(APPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(APPDIR)/userhelper_context: $(APPCONF)/userhelper_context
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(APPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(APPDIR)/initrc_context: $(APPCONF)/initrc_context
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(APPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(APPDIR)/failsafe_context: $(APPCONF)/failsafe_context
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(APPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(APPDIR)/dbus_contexts: $(APPCONF)/dbus_contexts
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(APPDIR)
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2005-06-01 17:27:56 +00:00
|
|
|
$(APPDIR)/users/root: $(APPCONF)/root_default_contexts
|
2005-06-14 18:13:55 +00:00
|
|
|
@mkdir -p $(APPDIR)/users
|
2006-01-26 20:35:55 +00:00
|
|
|
$(verbose) install -m 644 $< $@
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install policy headers
|
|
|
|
#
|
2006-02-16 20:41:57 +00:00
|
|
|
install-headers: $(TUNXML) $(BOOLXML)
|
2006-02-01 13:22:14 +00:00
|
|
|
@mkdir -p $(HEADERDIR)
|
2006-02-17 14:26:39 +00:00
|
|
|
@echo "Installing $(TYPE) policy headers."
|
2006-02-16 20:41:57 +00:00
|
|
|
$(verbose) install -m 644 $(TUNXML) $(BOOLXML) $(HEADERDIR)
|
2006-02-10 18:41:53 +00:00
|
|
|
$(verbose) m4 $(M4PARAM) $(ROLEMAP) > $(HEADERDIR)/$(notdir $(ROLEMAP))
|
|
|
|
$(verbose) mkdir -p $(HEADERDIR)/support
|
2006-02-15 18:27:23 +00:00
|
|
|
$(verbose) install -m 644 $(M4SUPPORT) $(word $(words $(GENXML)),$(GENXML)) $(XMLDTD) $(HEADERDIR)/support
|
2006-02-10 18:41:53 +00:00
|
|
|
$(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $(HEADERDIR)/support/all_perms.spt
|
|
|
|
$(verbose) for i in $(notdir $(ALL_LAYERS)); do \
|
|
|
|
mkdir -p $(HEADERDIR)/$$i ;\
|
|
|
|
install -m 644 $(MODDIR)/$$i/*.if \
|
|
|
|
$(MODDIR)/$$i/metadata.xml \
|
|
|
|
$(HEADERDIR)/$$i ;\
|
|
|
|
done
|
2006-02-27 16:23:39 +00:00
|
|
|
$(verbose) echo "TYPE ?= $(TYPE)" > $(HEADERDIR)/build.conf
|
|
|
|
$(verbose) echo "NAME ?= $(NAME)" >> $(HEADERDIR)/build.conf
|
2006-02-10 18:41:53 +00:00
|
|
|
ifneq "$(DISTRO)" ""
|
2006-02-27 16:23:39 +00:00
|
|
|
$(verbose) echo "DISTRO ?= $(DISTRO)" >> $(HEADERDIR)/build.conf
|
2006-02-10 18:41:53 +00:00
|
|
|
endif
|
2006-02-27 16:23:39 +00:00
|
|
|
$(verbose) echo "MONOLITHIC ?= n" >> $(HEADERDIR)/build.conf
|
|
|
|
$(verbose) echo "DIRECT_INITRC ?= $(DIRECT_INITRC)" >> $(HEADERDIR)/build.conf
|
|
|
|
$(verbose) echo "POLY ?= $(POLY)" >> $(HEADERDIR)/build.conf
|
2006-02-10 18:41:53 +00:00
|
|
|
$(verbose) install -m 644 $(SUPPORT)/Makefile.devel $(HEADERDIR)/Makefile
|
2005-05-25 20:58:09 +00:00
|
|
|
|
2006-02-01 13:22:14 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install policy documentation
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
install-docs: $(TMPDIR)/html
|
2006-02-01 13:22:14 +00:00
|
|
|
@mkdir -p $(DOCSDIR)/html
|
|
|
|
@echo "Installing policy documentation"
|
2006-02-01 13:46:05 +00:00
|
|
|
$(verbose) install -m 644 $(DOCFILES) $(DOCSDIR)
|
2006-02-01 13:22:14 +00:00
|
|
|
$(verbose) install -m 644 $(wildcard $(HTMLDIR)/*) $(DOCSDIR)/html
|
|
|
|
|
2005-06-15 14:14:20 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Install policy sources
|
|
|
|
#
|
|
|
|
install-src:
|
|
|
|
rm -rf $(SRCPATH)/policy.old
|
|
|
|
-mv $(SRCPATH)/policy $(SRCPATH)/policy.old
|
|
|
|
mkdir -p $(SRCPATH)/policy
|
|
|
|
cp -R . $(SRCPATH)/policy
|
|
|
|
|
2006-01-25 18:30:27 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Generate tags file
|
|
|
|
#
|
2006-02-15 17:59:58 +00:00
|
|
|
tags: $(TAGS)
|
|
|
|
$(TAGS):
|
2006-01-25 18:30:27 +00:00
|
|
|
@($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1)
|
2006-02-15 17:59:58 +00:00
|
|
|
@LC_ALL=C $(CTAGS) -f $(TAGS) --langdef=te --langmap=te:..te.if.spt \
|
2006-01-25 18:30:27 +00:00
|
|
|
--regex-te='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \
|
|
|
|
--regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \
|
|
|
|
--regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \
|
|
|
|
--regex-te='/^[ \t]*define\(`(\w+)/\1/d,define/' \
|
|
|
|
--regex-te='/^[ \t]*interface\(`(\w+)/\1/i,interface/' \
|
|
|
|
--regex-te='/^[ \t]*bool[ \t]+(\w+)/\1/b,bool/' policy/modules/*/*.{if,te} policy/support/*.spt
|
|
|
|
|
2006-02-01 13:22:14 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Filesystem labeling
|
|
|
|
#
|
|
|
|
checklabels:
|
|
|
|
@echo "Checking labels on filesystem types: ext2 ext3 xfs jfs"
|
|
|
|
@if test -z "$(FILESYSTEMS)"; then \
|
|
|
|
echo "No filesystems with extended attributes found!" ;\
|
|
|
|
false ;\
|
|
|
|
fi
|
|
|
|
$(verbose) $(SETFILES) -v -n $(FCPATH) $(FILESYSTEMS)
|
|
|
|
|
|
|
|
restorelabels:
|
|
|
|
@echo "Restoring labels on filesystem types: ext2 ext3 xfs jfs"
|
|
|
|
@if test -z "$(FILESYSTEMS)"; then \
|
|
|
|
echo "No filesystems with extended attributes found!" ;\
|
|
|
|
false ;\
|
|
|
|
fi
|
|
|
|
$(verbose) $(SETFILES) -v $(FCPATH) $(FILESYSTEMS)
|
|
|
|
|
|
|
|
relabel:
|
|
|
|
@echo "Relabeling filesystem types: ext2 ext3 xfs jfs"
|
|
|
|
@if test -z "$(FILESYSTEMS)"; then \
|
|
|
|
echo "No filesystems with extended attributes found!" ;\
|
|
|
|
false ;\
|
|
|
|
fi
|
|
|
|
$(verbose) $(SETFILES) $(FCPATH) $(FILESYSTEMS)
|
|
|
|
|
|
|
|
resetlabels:
|
|
|
|
@echo "Resetting labels on filesystem types: ext2 ext3 xfs jfs"
|
|
|
|
@if test -z "$(FILESYSTEMS)"; then \
|
|
|
|
echo "No filesystems with extended attributes found!" ;\
|
|
|
|
false ;\
|
|
|
|
fi
|
|
|
|
$(verbose) $(SETFILES) -F $(FCPATH) $(FILESYSTEMS)
|
|
|
|
|
2005-06-15 15:45:54 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Clean everything
|
|
|
|
#
|
2005-06-07 15:11:47 +00:00
|
|
|
bare: clean
|
2005-06-13 12:55:56 +00:00
|
|
|
rm -f $(POLXML)
|
2006-02-16 20:41:57 +00:00
|
|
|
rm -f $(TUNXML)
|
|
|
|
rm -f $(BOOLXML)
|
2005-06-28 17:31:18 +00:00
|
|
|
rm -f $(MOD_CONF)
|
2005-10-07 18:08:50 +00:00
|
|
|
rm -f $(BOOLEANS)
|
2005-06-09 19:02:52 +00:00
|
|
|
rm -fR $(HTMLDIR)
|
2006-02-15 17:59:58 +00:00
|
|
|
rm -f $(TAGS)
|
|
|
|
# don't remove these files if we're given a local root
|
|
|
|
ifndef LOCAL_ROOT
|
|
|
|
rm -f $(FCSORT)
|
|
|
|
rm -f $(SUPPORT)/*.pyc
|
2005-11-22 22:07:12 +00:00
|
|
|
ifneq ($(GENERATED_TE),)
|
|
|
|
rm -f $(GENERATED_TE)
|
|
|
|
endif
|
|
|
|
ifneq ($(GENERATED_IF),)
|
|
|
|
rm -f $(GENERATED_IF)
|
|
|
|
endif
|
|
|
|
ifneq ($(GENERATED_FC),)
|
|
|
|
rm -f $(GENERATED_FC)
|
|
|
|
endif
|
2006-02-15 17:59:58 +00:00
|
|
|
endif
|
2005-06-07 15:11:47 +00:00
|
|
|
|
2006-02-17 14:26:39 +00:00
|
|
|
.PHONY: install-src install-appconfig generate xml conf html bare tags
|
2006-01-11 20:50:01 +00:00
|
|
|
.SUFFIXES:
|
|
|
|
.SUFFIXES: .c
|