| 1 |
# |
|---|
| 2 |
# Makefile for the security policy. |
|---|
| 3 |
# |
|---|
| 4 |
# Targets: |
|---|
| 5 |
# |
|---|
| 6 |
# install - compile and install the policy configuration, and context files. |
|---|
| 7 |
# load - compile, install, and load the policy configuration. |
|---|
| 8 |
# reload - compile, install, and load/reload the policy configuration. |
|---|
| 9 |
# relabel - relabel filesystems based on the file contexts configuration. |
|---|
| 10 |
# checklabels - check filesystems against the file context configuration |
|---|
| 11 |
# restorelabels - check filesystems against the file context configuration |
|---|
| 12 |
# and restore the label of files with incorrect labels |
|---|
| 13 |
# policy - compile the policy configuration locally for testing/development. |
|---|
| 14 |
# |
|---|
| 15 |
# The default target is 'policy'. |
|---|
| 16 |
# |
|---|
| 17 |
# |
|---|
| 18 |
# Please see build.conf for policy build options. |
|---|
| 19 |
# |
|---|
| 20 |
|
|---|
| 21 |
######################################## |
|---|
| 22 |
# |
|---|
| 23 |
# NO OPTIONS BELOW HERE |
|---|
| 24 |
# |
|---|
| 25 |
|
|---|
| 26 |
# Include the local build.conf if it exists, otherwise |
|---|
| 27 |
# include the configuration of the root directory. |
|---|
| 28 |
include build.conf |
|---|
| 29 |
|
|---|
| 30 |
ifdef LOCAL_ROOT |
|---|
| 31 |
-include $(LOCAL_ROOT)/build.conf |
|---|
| 32 |
endif |
|---|
| 33 |
|
|---|
| 34 |
# refpolicy version |
|---|
| 35 |
version = $(shell cat VERSION) |
|---|
| 36 |
|
|---|
| 37 |
ifdef LOCAL_ROOT |
|---|
| 38 |
builddir := $(LOCAL_ROOT)/ |
|---|
| 39 |
tmpdir := $(LOCAL_ROOT)/tmp |
|---|
| 40 |
tags := $(LOCAL_ROOT)/tags |
|---|
| 41 |
else |
|---|
| 42 |
tmpdir := tmp |
|---|
| 43 |
tags := tags |
|---|
| 44 |
endif |
|---|
| 45 |
|
|---|
| 46 |
# executable paths |
|---|
| 47 |
BINDIR ?= /usr/bin |
|---|
| 48 |
SBINDIR ?= /usr/sbin |
|---|
| 49 |
ifdef TEST_TOOLCHAIN |
|---|
| 50 |
tc_usrbindir := env LD_LIBRARY_PATH="$(TEST_TOOLCHAIN)/lib" $(TEST_TOOLCHAIN)$(BINDIR) |
|---|
| 51 |
tc_usrsbindir := env LD_LIBRARY_PATH="$(TEST_TOOLCHAIN)/lib" $(TEST_TOOLCHAIN)$(SBINDIR) |
|---|
| 52 |
tc_sbindir := env LD_LIBRARY_PATH="$(TEST_TOOLCHAIN)/lib" $(TEST_TOOLCHAIN)/sbin |
|---|
| 53 |
else |
|---|
| 54 |
tc_usrbindir := $(BINDIR) |
|---|
| 55 |
tc_usrsbindir := $(SBINDIR) |
|---|
| 56 |
tc_sbindir := /sbin |
|---|
| 57 |
endif |
|---|
| 58 |
CHECKPOLICY ?= $(tc_usrbindir)/checkpolicy |
|---|
| 59 |
CHECKMODULE ?= $(tc_usrbindir)/checkmodule |
|---|
| 60 |
SEMODULE ?= $(tc_usrsbindir)/semodule |
|---|
| 61 |
SEMOD_PKG ?= $(tc_usrbindir)/semodule_package |
|---|
| 62 |
SEMOD_LNK ?= $(tc_usrbindir)/semodule_link |
|---|
| 63 |
SEMOD_EXP ?= $(tc_usrbindir)/semodule_expand |
|---|
| 64 |
LOADPOLICY ?= $(tc_usrsbindir)/load_policy |
|---|
| 65 |
SETFILES ?= $(tc_sbindir)/setfiles |
|---|
| 66 |
XMLLINT ?= $(BINDIR)/xmllint |
|---|
| 67 |
SECHECK ?= $(BINDIR)/sechecker |
|---|
| 68 |
|
|---|
| 69 |
# interpreters and aux tools |
|---|
| 70 |
AWK ?= gawk |
|---|
| 71 |
GREP ?= egrep |
|---|
| 72 |
INSTALL ?= install |
|---|
| 73 |
M4 ?= m4 |
|---|
| 74 |
PYTHON ?= python |
|---|
| 75 |
SED ?= sed |
|---|
| 76 |
SORT ?= LC_ALL=C sort |
|---|
| 77 |
|
|---|
| 78 |
CFLAGS += -Wall |
|---|
| 79 |
|
|---|
| 80 |
# policy source layout |
|---|
| 81 |
poldir := policy |
|---|
| 82 |
moddir := $(poldir)/modules |
|---|
| 83 |
flaskdir := $(poldir)/flask |
|---|
| 84 |
secclass := $(flaskdir)/security_classes |
|---|
| 85 |
isids := $(flaskdir)/initial_sids |
|---|
| 86 |
avs := $(flaskdir)/access_vectors |
|---|
| 87 |
|
|---|
| 88 |
# local source layout |
|---|
| 89 |
ifdef LOCAL_ROOT |
|---|
| 90 |
local_poldir := $(LOCAL_ROOT)/policy |
|---|
| 91 |
local_moddir := $(local_poldir)/modules |
|---|
| 92 |
endif |
|---|
| 93 |
|
|---|
| 94 |
# policy building support tools |
|---|
| 95 |
support := support |
|---|
| 96 |
genxml := $(PYTHON) -E $(support)/segenxml.py |
|---|
| 97 |
gendoc := $(PYTHON) -E $(support)/sedoctool.py |
|---|
| 98 |
genperm := $(PYTHON) -E $(support)/genclassperms.py |
|---|
| 99 |
fcsort := $(tmpdir)/fc_sort |
|---|
| 100 |
setbools := $(AWK) -f $(support)/set_bools_tuns.awk |
|---|
| 101 |
get_type_attr_decl := $(SED) -r -f $(support)/get_type_attr_decl.sed |
|---|
| 102 |
comment_move_decl := $(SED) -r -f $(support)/comment_move_decl.sed |
|---|
| 103 |
gennetfilter := $(PYTHON) -E $(support)/gennetfilter.py |
|---|
| 104 |
m4iferror := $(support)/iferror.m4 |
|---|
| 105 |
# use our own genhomedircon to make sure we have a known usable one, |
|---|
| 106 |
# so policycoreutils updates are not required (RHEL4) |
|---|
| 107 |
genhomedircon := $(PYTHON) -E $(support)/genhomedircon |
|---|
| 108 |
|
|---|
| 109 |
# documentation paths |
|---|
| 110 |
docs := doc |
|---|
| 111 |
xmldtd = $(docs)/policy.dtd |
|---|
| 112 |
metaxml = metadata.xml |
|---|
| 113 |
doctemplate = $(docs)/templates |
|---|
| 114 |
docfiles = $(docs)/Makefile.example $(addprefix $(docs)/,example.te example.if example.fc) |
|---|
| 115 |
|
|---|
| 116 |
ifndef LOCAL_ROOT |
|---|
| 117 |
polxml = $(docs)/policy.xml |
|---|
| 118 |
tunxml = $(docs)/global_tunables.xml |
|---|
| 119 |
boolxml = $(docs)/global_booleans.xml |
|---|
| 120 |
htmldir = $(docs)/html |
|---|
| 121 |
else |
|---|
| 122 |
polxml = $(LOCAL_ROOT)/doc/policy.xml |
|---|
| 123 |
tunxml = $(LOCAL_ROOT)/doc/global_tunables.xml |
|---|
| 124 |
boolxml = $(LOCAL_ROOT)/doc/global_booleans.xml |
|---|
| 125 |
htmldir = $(LOCAL_ROOT)/doc/html |
|---|
| 126 |
endif |
|---|
| 127 |
|
|---|
| 128 |
# config file paths |
|---|
| 129 |
globaltun = $(poldir)/global_tunables |
|---|
| 130 |
globalbool = $(poldir)/global_booleans |
|---|
| 131 |
rolemap = $(poldir)/rolemap |
|---|
| 132 |
user_files := $(poldir)/users |
|---|
| 133 |
policycaps := $(poldir)/policy_capabilities |
|---|
| 134 |
|
|---|
| 135 |
# local config file paths |
|---|
| 136 |
ifndef LOCAL_ROOT |
|---|
| 137 |
mod_conf = $(poldir)/modules.conf |
|---|
| 138 |
booleans = $(poldir)/booleans.conf |
|---|
| 139 |
tunables = $(poldir)/tunables.conf |
|---|
| 140 |
else |
|---|
| 141 |
mod_conf = $(local_poldir)/modules.conf |
|---|
| 142 |
booleans = $(local_poldir)/booleans.conf |
|---|
| 143 |
tunables = $(local_poldir)/tunables.conf |
|---|
| 144 |
endif |
|---|
| 145 |
|
|---|
| 146 |
# install paths |
|---|
| 147 |
PKGNAME ?= refpolicy-$(version) |
|---|
| 148 |
prefix = $(DESTDIR)/usr |
|---|
| 149 |
topdir = $(DESTDIR)/etc/selinux |
|---|
| 150 |
installdir = $(topdir)/$(strip $(NAME)) |
|---|
| 151 |
srcpath = $(installdir)/src |
|---|
| 152 |
userpath = $(installdir)/users |
|---|
| 153 |
policypath = $(installdir)/policy |
|---|
| 154 |
contextpath = $(installdir)/contexts |
|---|
| 155 |
homedirpath = $(contextpath)/files/homedir_template |
|---|
| 156 |
fcpath = $(contextpath)/files/file_contexts |
|---|
| 157 |
ncpath = $(contextpath)/netfilter_contexts |
|---|
| 158 |
sharedir = $(prefix)/share/selinux |
|---|
| 159 |
modpkgdir = $(sharedir)/$(strip $(NAME)) |
|---|
| 160 |
headerdir = $(modpkgdir)/include |
|---|
| 161 |
docsdir = $(prefix)/share/doc/$(PKGNAME) |
|---|
| 162 |
|
|---|
| 163 |
# enable MLS if requested. |
|---|
| 164 |
ifeq "$(TYPE)" "mls" |
|---|
| 165 |
M4PARAM += -D enable_mls |
|---|
| 166 |
CHECKPOLICY += -M |
|---|
| 167 |
CHECKMODULE += -M |
|---|
| 168 |
gennetfilter += -m |
|---|
| 169 |
endif |
|---|
| 170 |
|
|---|
| 171 |
# enable MLS if MCS requested. |
|---|
| 172 |
ifeq "$(TYPE)" "mcs" |
|---|
| 173 |
M4PARAM += -D enable_mcs |
|---|
| 174 |
CHECKPOLICY += -M |
|---|
| 175 |
CHECKMODULE += -M |
|---|
| 176 |
gennetfilter += -c |
|---|
| 177 |
endif |
|---|
| 178 |
|
|---|
| 179 |
# enable distribution-specific policy |
|---|
| 180 |
ifneq ($(DISTRO),) |
|---|
| 181 |
M4PARAM += -D distro_$(DISTRO) |
|---|
| 182 |
endif |
|---|
| 183 |
|
|---|
| 184 |
# rhel4 also implies redhat |
|---|
| 185 |
ifeq "$(DISTRO)" "rhel4" |
|---|
| 186 |
M4PARAM += -D distro_redhat |
|---|
| 187 |
endif |
|---|
| 188 |
|
|---|
| 189 |
ifeq "$(DISTRO)" "ubuntu" |
|---|
| 190 |
M4PARAM += -D distro_debian |
|---|
| 191 |
endif |
|---|
| 192 |
|
|---|
| 193 |
ifneq ($(OUTPUT_POLICY),) |
|---|
| 194 |
CHECKPOLICY += -c $(OUTPUT_POLICY) |
|---|
| 195 |
endif |
|---|
| 196 |
|
|---|
| 197 |
# if not set, use the type as the name. |
|---|
| 198 |
NAME ?= $(TYPE) |
|---|
| 199 |
|
|---|
| 200 |
# default unknown permissions setting |
|---|
| 201 |
#UNK_PERMS ?= deny |
|---|
| 202 |
|
|---|
| 203 |
ifeq ($(DIRECT_INITRC),y) |
|---|
| 204 |
M4PARAM += -D direct_sysadm_daemon |
|---|
| 205 |
endif |
|---|
| 206 |
|
|---|
| 207 |
ifeq "$(UBAC)" "y" |
|---|
| 208 |
M4PARAM += -D enable_ubac |
|---|
| 209 |
endif |
|---|
| 210 |
|
|---|
| 211 |
# default MLS/MCS sensitivity and category settings. |
|---|
| 212 |
MLS_SENS ?= 16 |
|---|
| 213 |
MLS_CATS ?= 256 |
|---|
| 214 |
MCS_CATS ?= 256 |
|---|
| 215 |
|
|---|
| 216 |
ifeq ($(QUIET),y) |
|---|
| 217 |
verbose = @ |
|---|
| 218 |
endif |
|---|
| 219 |
|
|---|
| 220 |
M4PARAM += -D mls_num_sens=$(MLS_SENS) -D mls_num_cats=$(MLS_CATS) -D mcs_num_cats=$(MCS_CATS) -D hide_broken_symptoms |
|---|
| 221 |
|
|---|
| 222 |
# we need exuberant ctags; unfortunately it is named |
|---|
| 223 |
# differently on different distros |
|---|
| 224 |
ifeq ($(DISTRO),debian) |
|---|
| 225 |
CTAGS := ctags-exuberant |
|---|
| 226 |
endif |
|---|
| 227 |
|
|---|
| 228 |
ifeq ($(DISTRO),gentoo) |
|---|
| 229 |
CTAGS := exuberant-ctags |
|---|
| 230 |
endif |
|---|
| 231 |
|
|---|
| 232 |
CTAGS ?= ctags |
|---|
| 233 |
|
|---|
| 234 |
m4support := $(wildcard $(poldir)/support/*.spt) |
|---|
| 235 |
ifdef LOCAL_ROOT |
|---|
| 236 |
m4support += $(wildcard $(local_poldir)/support/*.spt) |
|---|
| 237 |
endif |
|---|
| 238 |
|
|---|
| 239 |
appconf := config/appconfig-$(TYPE) |
|---|
| 240 |
seusers := $(appconf)/seusers |
|---|
| 241 |
appdir := $(contextpath) |
|---|
| 242 |
user_default_contexts := $(wildcard config/appconfig-$(TYPE)/*_default_contexts) |
|---|
| 243 |
user_default_contexts_names := $(addprefix $(contextpath)/users/,$(subst _default_contexts,,$(notdir $(user_default_contexts)))) |
|---|
| 244 |
appfiles := $(addprefix $(appdir)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts x_contexts customizable_types securetty_types) $(contextpath)/files/media $(user_default_contexts_names) |
|---|
| 245 |
net_contexts := $(builddir)net_contexts |
|---|
| 246 |
|
|---|
| 247 |
all_layers := $(shell find $(wildcard $(moddir)/*) -maxdepth 0 -type d) |
|---|
| 248 |
ifdef LOCAL_ROOT |
|---|
| 249 |
all_layers += $(shell find $(wildcard $(local_moddir)/*) -maxdepth 0 -type d) |
|---|
| 250 |
endif |
|---|
| 251 |
|
|---|
| 252 |
generated_te := $(basename $(foreach dir,$(all_layers),$(wildcard $(dir)/*.te.in))) |
|---|
| 253 |
generated_if := $(basename $(foreach dir,$(all_layers),$(wildcard $(dir)/*.if.in))) |
|---|
| 254 |
generated_fc := $(basename $(foreach dir,$(all_layers),$(wildcard $(dir)/*.fc.in))) |
|---|
| 255 |
|
|---|
| 256 |
# sort here since it removes duplicates, which can happen |
|---|
| 257 |
# when a generated file is already generated |
|---|
| 258 |
detected_mods := $(sort $(foreach dir,$(all_layers),$(wildcard $(dir)/*.te)) $(generated_te)) |
|---|
| 259 |
|
|---|
| 260 |
modxml := $(addprefix $(tmpdir)/, $(detected_mods:.te=.xml)) |
|---|
| 261 |
layerxml := $(sort $(addprefix $(tmpdir)/, $(notdir $(addsuffix .xml,$(all_layers))))) |
|---|
| 262 |
layer_names := $(sort $(notdir $(all_layers))) |
|---|
| 263 |
all_metaxml = $(call detect-metaxml, $(layer_names)) |
|---|
| 264 |
|
|---|
| 265 |
# modules.conf setting for base module |
|---|
| 266 |
configbase := base |
|---|
| 267 |
|
|---|
| 268 |
# modules.conf setting for loadable module |
|---|
| 269 |
configmod := module |
|---|
| 270 |
|
|---|
| 271 |
# modules.conf setting for unused module |
|---|
| 272 |
configoff := off |
|---|
| 273 |
|
|---|
| 274 |
# test for module overrides from command line |
|---|
| 275 |
mod_test = $(filter $(APPS_OFF), $(APPS_BASE) $(APPS_MODS)) |
|---|
| 276 |
mod_test += $(filter $(APPS_MODS), $(APPS_BASE)) |
|---|
| 277 |
ifneq "$(strip $(mod_test))" "" |
|---|
| 278 |
$(error Applications must be base, module, or off, and not in more than one list! $(strip $(mod_test)) found in multiple lists!) |
|---|
| 279 |
endif |
|---|
| 280 |
|
|---|
| 281 |
# add on suffix to modules specified on command line |
|---|
| 282 |
cmdline_base := $(addsuffix .te,$(APPS_BASE)) |
|---|
| 283 |
cmdline_mods := $(addsuffix .te,$(APPS_MODS)) |
|---|
| 284 |
cmdline_off := $(addsuffix .te,$(APPS_OFF)) |
|---|
| 285 |
|
|---|
| 286 |
# extract settings from modules.conf |
|---|
| 287 |
mod_conf_base := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(configbase)") print $$1 }' $(mod_conf) 2> /dev/null))) |
|---|
| 288 |
mod_conf_mods := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(configmod)") print $$1 }' $(mod_conf) 2> /dev/null))) |
|---|
| 289 |
mod_conf_off := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(configoff)") print $$1 }' $(mod_conf) 2> /dev/null))) |
|---|
| 290 |
|
|---|
| 291 |
base_mods := $(cmdline_base) |
|---|
| 292 |
mod_mods := $(cmdline_mods) |
|---|
| 293 |
off_mods := $(cmdline_off) |
|---|
| 294 |
|
|---|
| 295 |
base_mods += $(filter-out $(cmdline_off) $(cmdline_base) $(cmdline_mods), $(mod_conf_base)) |
|---|
| 296 |
mod_mods += $(filter-out $(cmdline_off) $(cmdline_base) $(cmdline_mods), $(mod_conf_mods)) |
|---|
| 297 |
off_mods += $(filter-out $(cmdline_off) $(cmdline_base) $(cmdline_mods), $(mod_conf_off)) |
|---|
| 298 |
|
|---|
| 299 |
# add modules not in modules.conf to the off list |
|---|
| 300 |
off_mods += $(filter-out $(base_mods) $(mod_mods) $(off_mods),$(notdir $(detected_mods))) |
|---|
| 301 |
|
|---|
| 302 |
# filesystems to be used in labeling targets |
|---|
| 303 |
filesystems = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';) |
|---|
| 304 |
|
|---|
| 305 |
######################################## |
|---|
| 306 |
# |
|---|
| 307 |
# Functions |
|---|
| 308 |
# |
|---|
| 309 |
|
|---|
| 310 |
# parse-rolemap-compat modulename,outputfile |
|---|
| 311 |
define parse-rolemap-compat |
|---|
| 312 |
$(verbose) $(M4) $(M4PARAM) $(rolemap) | \ |
|---|
| 313 |
$(AWK) '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_userdomain_template(" $$2 "," $$3 "," $$1 ")" }' >> $2 |
|---|
| 314 |
endef |
|---|
| 315 |
|
|---|
| 316 |
# parse-rolemap modulename,outputfile |
|---|
| 317 |
define parse-rolemap |
|---|
| 318 |
$(verbose) $(M4) $(M4PARAM) $(rolemap) | \ |
|---|
| 319 |
$(AWK) '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_role_template(" $$2 "," $$3 "," $$1 ")" }' >> $2 |
|---|
| 320 |
endef |
|---|
| 321 |
|
|---|
| 322 |
# perrole-expansion modulename,outputfile |
|---|
| 323 |
define perrole-expansion |
|---|
| 324 |
$(verbose) echo "ifdef(\`""$1""_per_role_template',\`" > $2 |
|---|
| 325 |
$(call parse-rolemap,$1,$2) |
|---|
| 326 |
$(verbose) echo "')" >> $2 |
|---|
| 327 |
|
|---|
| 328 |
$(verbose) echo "ifdef(\`""$1""_per_userdomain_template',\`" >> $2 |
|---|
| 329 |
$(verbose) echo "errprint(\`Warning: per_userdomain_templates have been renamed to per_role_templates (""$1""_per_userdomain_template)'__endline__)" >> $2 |
|---|
| 330 |
$(call parse-rolemap-compat,$1,$2) |
|---|
| 331 |
$(verbose) echo "')" >> $2 |
|---|
| 332 |
endef |
|---|
| 333 |
|
|---|
| 334 |
# create-base-per-role-tmpl modulenames,outputfile |
|---|
| 335 |
define create-base-per-role-tmpl |
|---|
| 336 |
$(verbose) echo "define(\`base_per_role_template',\`" >> $2 |
|---|
| 337 |
|
|---|
| 338 |
$(verbose) for i in $1; do \ |
|---|
| 339 |
echo "ifdef(\`""$$i""_per_role_template',\`""$$i""_per_role_template("'$$*'")')" \ |
|---|
| 340 |
>> $2 ;\ |
|---|
| 341 |
done |
|---|
| 342 |
|
|---|
| 343 |
$(verbose) for i in $1; do \ |
|---|
| 344 |
echo "ifdef(\`""$$i""_per_userdomain_template',\`" >> $2 ;\ |
|---|
| 345 |
echo "errprint(\`Warning: per_userdomain_templates have been renamed to per_role_templates (""$$i""_per_userdomain_template)'__endline__)" >> $2 ;\ |
|---|
| 346 |
echo """$$i""_per_userdomain_template("'$$*'")')" >> $2 ;\ |
|---|
| 347 |
done |
|---|
| 348 |
$(verbose) echo "')" >> $@ |
|---|
| 349 |
|
|---|
| 350 |
endef |
|---|
| 351 |
|
|---|
| 352 |
# detect-metaxml layer_names |
|---|
| 353 |
ifdef LOCAL_ROOT |
|---|
| 354 |
define detect-metaxml |
|---|
| 355 |
$(shell for i in $1; do \ |
|---|
| 356 |
if [ -d $(moddir)/$$i -a -d $(local_moddir)/$$i ]; then \ |
|---|
| 357 |
if [ -f $(local_moddir)/$$i/$(metaxml) ]; then \ |
|---|
| 358 |
echo $(local_moddir)/$$i/$(metaxml) ;\ |
|---|
| 359 |
else \ |
|---|
| 360 |
echo $(moddir)/$$i/$(metaxml) ;\ |
|---|
| 361 |
fi \ |
|---|
| 362 |
elif [ -d $(local_moddir)/$$i ]; then |
|---|
| 363 |
echo $(local_moddir)/$$i/$(metaxml) ;\ |
|---|
| 364 |
else \ |
|---|
| 365 |
echo $(moddir)/$$i/$(metaxml) ;\ |
|---|
| 366 |
fi \ |
|---|
| 367 |
done ) |
|---|
| 368 |
endef |
|---|
| 369 |
else |
|---|
| 370 |
define detect-metaxml |
|---|
| 371 |
$(shell for i in $1; do echo $(moddir)/$$i/$(metaxml); done) |
|---|
| 372 |
endef |
|---|
| 373 |
endif |
|---|
| 374 |
|
|---|
| 375 |
######################################## |
|---|
| 376 |
# |
|---|
| 377 |
# Load appropriate rules |
|---|
| 378 |
# |
|---|
| 379 |
|
|---|
| 380 |
ifeq ($(MONOLITHIC),y) |
|---|
| 381 |
include Rules.monolithic |
|---|
| 382 |
else |
|---|
| 383 |
include Rules.modular |
|---|
| 384 |
endif |
|---|
| 385 |
|
|---|
| 386 |
######################################## |
|---|
| 387 |
# |
|---|
| 388 |
# Generated files |
|---|
| 389 |
# |
|---|
| 390 |
# NOTE: There is no "local" version of these files. |
|---|
| 391 |
# |
|---|
| 392 |
generate: $(generated_te) $(generated_if) $(generated_fc) |
|---|
| 393 |
|
|---|
| 394 |
$(moddir)/kernel/corenetwork.if: $(moddir)/kernel/corenetwork.te.in $(moddir)/kernel/corenetwork.if.m4 $(moddir)/kernel/corenetwork.if.in |
|---|
| 395 |
@echo "#" > $@ |
|---|
| 396 |
@echo "# This is a generated file! Instead of modifying this file, the" >> $@ |
|---|
| 397 |
@echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@ |
|---|
| 398 |
@echo "#" >> $@ |
|---|
| 399 |
$(verbose) cat $@.in >> $@ |
|---|
| 400 |
$(verbose) $(GREP) "^[[:blank:]]*network_(interface|node|port|packet)\(.*\)" $< \ |
|---|
| 401 |
| $(M4) -D self_contained_policy $(M4PARAM) $@.m4 - \ |
|---|
| 402 |
| $(SED) -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@ |
|---|
| 403 |
|
|---|
| 404 |
$(moddir)/kernel/corenetwork.te: $(moddir)/kernel/corenetwork.te.m4 $(moddir)/kernel/corenetwork.te.in |
|---|
| 405 |
@echo "#" > $@ |
|---|
| 406 |
@echo "# This is a generated file! Instead of modifying this file, the" >> $@ |
|---|
| 407 |
@echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@ |
|---|
| 408 |
@echo "#" >> $@ |
|---|
| 409 |
$(verbose) $(M4) -D self_contained_policy $(M4PARAM) $^ \ |
|---|
| 410 |
| $(SED) -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@ |
|---|
| 411 |
|
|---|
| 412 |
######################################## |
|---|
| 413 |
# |
|---|
| 414 |
# Network packet labeling |
|---|
| 415 |
# |
|---|
| 416 |
$(net_contexts): $(moddir)/kernel/corenetwork.te.in |
|---|
| 417 |
@echo "Creating netfilter network labeling rules" |
|---|
| 418 |
$(verbose) $(gennetfilter) $^ > $@ |
|---|
| 419 |
|
|---|
| 420 |
######################################## |
|---|
| 421 |
# |
|---|
| 422 |
# Create config files |
|---|
| 423 |
# |
|---|
| 424 |
conf: $(mod_conf) $(booleans) $(generated_te) $(generated_if) $(generated_fc) |
|---|
| 425 |
|
|---|
| 426 |
$(mod_conf) $(booleans): $(polxml) |
|---|
| 427 |
@echo "Updating $(mod_conf) and $(booleans)" |
|---|
| 428 |
$(verbose) $(gendoc) -b $(booleans) -m $(mod_conf) -x $(polxml) |
|---|
| 429 |
|
|---|
| 430 |
######################################## |
|---|
| 431 |
# |
|---|
| 432 |
# Generate the fc_sort program |
|---|
| 433 |
# |
|---|
| 434 |
$(fcsort) : $(support)/fc_sort.c |
|---|
| 435 |
$(verbose) $(CC) $(CFLAGS) $^ -o $@ |
|---|
| 436 |
|
|---|
| 437 |
######################################## |
|---|
| 438 |
# |
|---|
| 439 |
# Documentation generation |
|---|
| 440 |
# |
|---|
| 441 |
$(layerxml): %.xml: $(all_metaxml) $(filter $(addprefix $(moddir)/, $(notdir $*))%, $(detected_mods)) $(subst .te,.if, $(filter $(addprefix $(moddir)/, $(notdir $*))%, $(detected_mods))) |
|---|
| 442 |
@test -d $(tmpdir) || mkdir -p $(tmpdir) |
|---|
| 443 |
$(verbose) cat $(filter %$(notdir $*)/$(metaxml), $(all_metaxml)) > $@ |
|---|
| 444 |
$(verbose) for i in $(basename $(filter $(addprefix $(moddir)/, $(notdir $*))%, $(detected_mods))); do $(genxml) -w -m $$i >> $@; done |
|---|
| 445 |
ifdef LOCAL_ROOT |
|---|
| 446 |
$(verbose) for i in $(basename $(filter $(addprefix $(local_moddir)/, $(notdir $*))%, $(detected_mods))); do $(genxml) -w -m $$i >> $@; done |
|---|
| 447 |
endif |
|---|
| 448 |
|
|---|
| 449 |
$(tunxml): $(globaltun) |
|---|
| 450 |
$(verbose) $(genxml) -w -t $< > $@ |
|---|
| 451 |
|
|---|
| 452 |
$(boolxml): $(globalbool) |
|---|
| 453 |
$(verbose) $(genxml) -w -b $< > $@ |
|---|
| 454 |
|
|---|
| 455 |
$(polxml): $(layerxml) $(tunxml) $(boolxml) |
|---|
| 456 |
@echo "Creating $(@F)" |
|---|
| 457 |
@test -d $(dir $(polxml)) || mkdir -p $(dir $(polxml)) |
|---|
| 458 |
@test -d $(tmpdir) || mkdir -p $(tmpdir) |
|---|
| 459 |
$(verbose) echo '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' > $@ |
|---|
| 460 |
$(verbose) echo '<!DOCTYPE policy SYSTEM "$(notdir $(xmldtd))">' >> $@ |
|---|
| 461 |
$(verbose) echo '<policy>' >> $@ |
|---|
| 462 |
$(verbose) for i in $(basename $(notdir $(layerxml))); do echo "<layer name=\"$$i\">" >> $@; cat $(tmpdir)/$$i.xml >> $@; echo "</layer>" >> $@; done |
|---|
| 463 |
$(verbose) cat $(tunxml) $(boolxml) >> $@ |
|---|
| 464 |
$(verbose) echo '</policy>' >> $@ |
|---|
| 465 |
$(verbose) if test -x $(XMLLINT) && test -f $(xmldtd); then \ |
|---|
| 466 |
$(XMLLINT) --noout --path $(dir $(xmldtd)) --dtdvalid $(xmldtd) $@ ;\ |
|---|
| 467 |
fi |
|---|
| 468 |
|
|---|
| 469 |
xml: $(polxml) |
|---|
| 470 |
|
|---|
| 471 |
html $(tmpdir)/html: $(polxml) |
|---|
| 472 |
@echo "Building html interface reference documentation in $(htmldir)" |
|---|
| 473 |
@test -d $(htmldir) || mkdir -p $(htmldir) |
|---|
| 474 |
@test -d $(tmpdir) || mkdir -p $(tmpdir) |
|---|
| 475 |
$(verbose) $(gendoc) -d $(htmldir) -T $(doctemplate) -x $(polxml) |
|---|
| 476 |
$(verbose) cp $(doctemplate)/*.css $(htmldir) |
|---|
| 477 |
@touch $(tmpdir)/html |
|---|
| 478 |
|
|---|
| 479 |
######################################## |
|---|
| 480 |
# |
|---|
| 481 |
# Runtime binary policy patching of users |
|---|
| 482 |
# |
|---|
| 483 |
$(userpath)/system.users: $(m4support) $(tmpdir)/generated_definitions.conf $(user_files) |
|---|
| 484 |
@mkdir -p $(tmpdir) |
|---|
| 485 |
@mkdir -p $(userpath) |
|---|
| 486 |
@echo "Installing system.users" |
|---|
| 487 |
@echo "# " > $(tmpdir)/system.users |
|---|
| 488 |
@echo "# Do not edit this file. " >> $(tmpdir)/system.users |
|---|
| 489 |
@echo "# This file is replaced on reinstalls of this policy." >> $(tmpdir)/system.users |
|---|
| 490 |
@echo "# Please edit local.users to make local changes." >> $(tmpdir)/system.users |
|---|
| 491 |
@echo "#" >> $(tmpdir)/system.users |
|---|
| 492 |
$(verbose) $(M4) -D self_contained_policy $(M4PARAM) $^ | $(SED) -r -e 's/^[[:blank:]]+//' \ |
|---|
| 493 |
-e '/^[[:blank:]]*($$|#)/d' >> $(tmpdir)/system.users |
|---|
| 494 |
$(verbose) $(INSTALL) -m 644 $(tmpdir)/system.users $@ |
|---|
| 495 |
|
|---|
| 496 |
$(userpath)/local.users: config/local.users |
|---|
| 497 |
@mkdir -p $(userpath) |
|---|
| 498 |
@echo "Installing local.users" |
|---|
| 499 |
$(verbose) $(INSTALL) -b -m 644 $< $@ |
|---|
| 500 |
|
|---|
| 501 |
######################################## |
|---|
| 502 |
# |
|---|
| 503 |
# Build Appconfig files |
|---|
| 504 |
# |
|---|
| 505 |
$(tmpdir)/initrc_context: $(appconf)/initrc_context |
|---|
| 506 |
@mkdir -p $(tmpdir) |
|---|
| 507 |
$(verbose) $(M4) $(M4PARAM) $(m4support) $^ | $(GREP) '^[a-z]' > $@ |
|---|
| 508 |
|
|---|
| 509 |
######################################## |
|---|
| 510 |
# |
|---|
| 511 |
# Install Appconfig files |
|---|
| 512 |
# |
|---|
| 513 |
install-appconfig: $(appfiles) |
|---|
| 514 |
|
|---|
| 515 |
$(installdir)/booleans: $(booleans) |
|---|
| 516 |
@mkdir -p $(tmpdir) |
|---|
| 517 |
@mkdir -p $(installdir) |
|---|
| 518 |
$(verbose) $(SED) -r -e 's/false/0/g' -e 's/true/1/g' \ |
|---|
| 519 |
-e '/^[[:blank:]]*($$|#)/d' $(booleans) | $(SORT) > $(tmpdir)/booleans |
|---|
| 520 |
$(verbose) $(INSTALL) -m 644 $(tmpdir)/booleans $@ |
|---|
| 521 |
|
|---|
| 522 |
$(contextpath)/files/media: $(appconf)/media |
|---|
| 523 |
@mkdir -p $(contextpath)/files/ |
|---|
| 524 |
$(verbose) $(INSTALL) -m 644 $< $@ |
|---|
| 525 |
|
|---|
| 526 |
$(contextpath)/users/%: $(appconf)/%_default_contexts |
|---|
| 527 |
@mkdir -p $(appdir)/users |
|---|
| 528 |
$(verbose) $(INSTALL) -m 644 $^ $@ |
|---|
| 529 |
|
|---|
| 530 |
$(appdir)/%: $(appconf)/% |
|---|
| 531 |
@mkdir -p $(appdir) |
|---|
| 532 |
$(verbose) $(INSTALL) -m 644 $< $@ |
|---|
| 533 |
|
|---|
| 534 |
######################################## |
|---|
| 535 |
# |
|---|
| 536 |
# Install policy headers |
|---|
| 537 |
# |
|---|
| 538 |
install-headers: $(layerxml) $(tunxml) $(boolxml) |
|---|
| 539 |
@mkdir -p $(headerdir) |
|---|
| 540 |
@echo "Installing $(TYPE) policy headers." |
|---|
| 541 |
$(verbose) $(INSTALL) -m 644 $^ $(headerdir) |
|---|
| 542 |
$(verbose) $(M4) $(M4PARAM) $(rolemap) > $(headerdir)/$(notdir $(rolemap)) |
|---|
| 543 |
$(verbose) mkdir -p $(headerdir)/support |
|---|
| 544 |
$(verbose) $(INSTALL) -m 644 $(m4support) $(word $(words $(genxml)),$(genxml)) $(xmldtd) $(headerdir)/support |
|---|
| 545 |
$(verbose) $(genperm) $(avs) $(secclass) > $(headerdir)/support/all_perms.spt |
|---|
| 546 |
$(verbose) for i in $(notdir $(all_layers)); do \ |
|---|
| 547 |
mkdir -p $(headerdir)/$$i ;\ |
|---|
| 548 |
$(INSTALL) -m 644 $(moddir)/$$i/*.if $(headerdir)/$$i ;\ |
|---|
| 549 |
done |
|---|
| 550 |
$(verbose) echo "TYPE ?= $(TYPE)" > $(headerdir)/build.conf |
|---|
| 551 |
$(verbose) echo "NAME ?= $(NAME)" >> $(headerdir)/build.conf |
|---|
| 552 |
ifneq "$(DISTRO)" "" |
|---|
| 553 |
$(verbose) echo "DISTRO ?= $(DISTRO)" >> $(headerdir)/build.conf |
|---|
| 554 |
endif |
|---|
| 555 |
$(verbose) echo "MONOLITHIC ?= n" >> $(headerdir)/build.conf |
|---|
| 556 |
$(verbose) echo "DIRECT_INITRC ?= $(DIRECT_INITRC)" >> $(headerdir)/build.conf |
|---|
| 557 |
$(verbose) echo "override UBAC := $(UBAC)" >> $(headerdir)/build.conf |
|---|
| 558 |
$(verbose) echo "override MLS_SENS := $(MLS_SENS)" >> $(headerdir)/build.conf |
|---|
| 559 |
$(verbose) echo "override MLS_CATS := $(MLS_CATS)" >> $(headerdir)/build.conf |
|---|
| 560 |
$(verbose) echo "override MCS_CATS := $(MCS_CATS)" >> $(headerdir)/build.conf |
|---|
| 561 |
$(verbose) $(INSTALL) -m 644 $(support)/Makefile.devel $(headerdir)/Makefile |
|---|
| 562 |
|
|---|
| 563 |
######################################## |
|---|
| 564 |
# |
|---|
| 565 |
# Install policy documentation |
|---|
| 566 |
# |
|---|
| 567 |
install-docs: $(tmpdir)/html |
|---|
| 568 |
@mkdir -p $(docsdir)/html |
|---|
| 569 |
@echo "Installing policy documentation" |
|---|
| 570 |
$(verbose) $(INSTALL) -m 644 $(docfiles) $(docsdir) |
|---|
| 571 |
$(verbose) $(INSTALL) -m 644 $(wildcard $(htmldir)/*) $(docsdir)/html |
|---|
| 572 |
|
|---|
| 573 |
######################################## |
|---|
| 574 |
# |
|---|
| 575 |
# Install policy sources |
|---|
| 576 |
# |
|---|
| 577 |
install-src: |
|---|
| 578 |
rm -rf $(srcpath)/policy.old |
|---|
| 579 |
-mv $(srcpath)/policy $(srcpath)/policy.old |
|---|
| 580 |
mkdir -p $(srcpath)/policy |
|---|
| 581 |
cp -R . $(srcpath)/policy |
|---|
| 582 |
|
|---|
| 583 |
######################################## |
|---|
| 584 |
# |
|---|
| 585 |
# Generate tags file |
|---|
| 586 |
# |
|---|
| 587 |
tags: $(tags) |
|---|
| 588 |
$(tags): |
|---|
| 589 |
@($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1) |
|---|
| 590 |
@LC_ALL=C $(CTAGS) -f $(tags) --langdef=te --langmap=te:..te.if.spt \ |
|---|
| 591 |
--regex-te='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \ |
|---|
| 592 |
--regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \ |
|---|
| 593 |
--regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \ |
|---|
| 594 |
--regex-te='/^[ \t]*define\(`(\w+)/\1/d,define/' \ |
|---|
| 595 |
--regex-te='/^[ \t]*interface\(`(\w+)/\1/i,interface/' \ |
|---|
| 596 |
--regex-te='/^[ \t]*template\(`(\w+)/\1/i,template/' \ |
|---|
| 597 |
--regex-te='/^[ \t]*bool[ \t]+(\w+)/\1/b,bool/' policy/modules/*/*.{if,te} policy/support/*.spt |
|---|
| 598 |
|
|---|
| 599 |
######################################## |
|---|
| 600 |
# |
|---|
| 601 |
# Filesystem labeling |
|---|
| 602 |
# |
|---|
| 603 |
checklabels: |
|---|
| 604 |
@echo "Checking labels on filesystem types: ext2 ext3 xfs jfs" |
|---|
| 605 |
@if test -z "$(filesystems)"; then \ |
|---|
| 606 |
echo "No filesystems with extended attributes found!" ;\ |
|---|
| 607 |
false ;\ |
|---|
| 608 |
fi |
|---|
| 609 |
$(verbose) $(SETFILES) -v -n $(fcpath) $(filesystems) |
|---|
| 610 |
|
|---|
| 611 |
restorelabels: |
|---|
| 612 |
@echo "Restoring labels on filesystem types: ext2 ext3 xfs jfs" |
|---|
| 613 |
@if test -z "$(filesystems)"; then \ |
|---|
| 614 |
echo "No filesystems with extended attributes found!" ;\ |
|---|
| 615 |
false ;\ |
|---|
| 616 |
fi |
|---|
| 617 |
$(verbose) $(SETFILES) -v $(fcpath) $(filesystems) |
|---|
| 618 |
|
|---|
| 619 |
relabel: |
|---|
| 620 |
@echo "Relabeling filesystem types: ext2 ext3 xfs jfs" |
|---|
| 621 |
@if test -z "$(filesystems)"; then \ |
|---|
| 622 |
echo "No filesystems with extended attributes found!" ;\ |
|---|
| 623 |
false ;\ |
|---|
| 624 |
fi |
|---|
| 625 |
$(verbose) $(SETFILES) $(fcpath) $(filesystems) |
|---|
| 626 |
|
|---|
| 627 |
resetlabels: |
|---|
| 628 |
@echo "Resetting labels on filesystem types: ext2 ext3 xfs jfs" |
|---|
| 629 |
@if test -z "$(filesystems)"; then \ |
|---|
| 630 |
echo "No filesystems with extended attributes found!" ;\ |
|---|
| 631 |
false ;\ |
|---|
| 632 |
fi |
|---|
| 633 |
$(verbose) $(SETFILES) -F $(fcpath) $(filesystems) |
|---|
| 634 |
|
|---|
| 635 |
######################################## |
|---|
| 636 |
# |
|---|
| 637 |
# Clean everything |
|---|
| 638 |
# |
|---|
| 639 |
bare: clean |
|---|
| 640 |
rm -f $(polxml) |
|---|
| 641 |
rm -f $(layerxml) |
|---|
| 642 |
rm -f $(modxml) |
|---|
| 643 |
rm -f $(tunxml) |
|---|
| 644 |
rm -f $(boolxml) |
|---|
| 645 |
rm -f $(mod_conf) |
|---|
| 646 |
rm -f $(booleans) |
|---|
| 647 |
rm -fR $(htmldir) |
|---|
| 648 |
rm -f $(tags) |
|---|
| 649 |
# don't remove these files if we're given a local root |
|---|
| 650 |
ifndef LOCAL_ROOT |
|---|
| 651 |
rm -f $(fcsort) |
|---|
| 652 |
rm -f $(support)/*.pyc |
|---|
| 653 |
ifneq ($(generated_te),) |
|---|
| 654 |
rm -f $(generated_te) |
|---|
| 655 |
endif |
|---|
| 656 |
ifneq ($(generated_if),) |
|---|
| 657 |
rm -f $(generated_if) |
|---|
| 658 |
endif |
|---|
| 659 |
ifneq ($(generated_fc),) |
|---|
| 660 |
rm -f $(generated_fc) |
|---|
| 661 |
endif |
|---|
| 662 |
endif |
|---|
| 663 |
|
|---|
| 664 |
.PHONY: install-src install-appconfig install-headers generate xml conf html bare tags |
|---|
| 665 |
.SUFFIXES: |
|---|
| 666 |
.SUFFIXES: .c |
|---|