]>
Commit | Line | Data |
---|---|---|
88d14a22 CP |
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 | # | |
b4cd1533 | 17 | # |
8e0ef1f9 | 18 | # Please see build.conf for policy build options. |
b4cd1533 CP |
19 | # |
20 | ||
b4cd1533 CP |
21 | ######################################## |
22 | # | |
b67488e3 | 23 | # NO OPTIONS BELOW HERE |
b4cd1533 CP |
24 | # |
25 | ||
c9f20d5b CP |
26 | # Include the local build.conf if it exists, otherwise |
27 | # include the configuration of the root directory. | |
1a7175a8 CP |
28 | include build.conf |
29 | ||
30 | ifdef LOCAL_ROOT | |
31 | -include $(LOCAL_ROOT)/build.conf | |
c9f20d5b | 32 | endif |
8e0ef1f9 | 33 | |
120988c4 CP |
34 | # refpolicy version |
35 | VERSION = $(shell cat VERSION) | |
36 | ||
c9f20d5b | 37 | ifdef LOCAL_ROOT |
5b45ffb0 | 38 | BUILDDIR := $(LOCAL_ROOT)/ |
c9f20d5b CP |
39 | TMPDIR := $(LOCAL_ROOT)/tmp |
40 | TAGS := $(LOCAL_ROOT)/tags | |
41 | else | |
5b45ffb0 CP |
42 | TMPDIR := tmp |
43 | TAGS := tags | |
c9f20d5b CP |
44 | endif |
45 | ||
b4cd1533 | 46 | # executable paths |
120988c4 CP |
47 | BINDIR := /usr/bin |
48 | SBINDIR := /usr/sbin | |
40a1f3db | 49 | CHECKPOLICY := $(BINDIR)/checkpolicy |
fb0a3a98 | 50 | CHECKMODULE := $(BINDIR)/checkmodule |
c767b14c | 51 | SEMODULE := $(SBINDIR)/semodule |
fb0a3a98 | 52 | SEMOD_PKG := $(BINDIR)/semodule_package |
547283e2 | 53 | LOADPOLICY := $(SBINDIR)/load_policy |
b4cd1533 | 54 | SETFILES := $(SBINDIR)/setfiles |
1beba1c6 | 55 | GENHOMEDIRCON := $(SBINDIR)/genhomedircon |
fb0a3a98 | 56 | XMLLINT := $(BINDIR)/xmllint |
8df65f13 | 57 | SECHECK := $(BINDIR)/sechecker |
0447352a | 58 | |
0e686f1f CP |
59 | # interpreters and aux tools |
60 | AWK ?= gawk | |
61 | GREP ?= egrep | |
62 | M4 ?= m4 | |
63 | PYTHON ?= python | |
64 | SED ?= sed | |
f62f4c79 | 65 | SORT ?= LC_ALL=C sort |
0e686f1f CP |
66 | |
67 | CFLAGS += -Wall | |
c7b41e95 | 68 | |
fb0a3a98 | 69 | # policy source layout |
5b45ffb0 | 70 | POLDIR := policy |
c04f2abe CP |
71 | MODDIR := $(POLDIR)/modules |
72 | FLASKDIR := $(POLDIR)/flask | |
73 | SECCLASS := $(FLASKDIR)/security_classes | |
74 | ISIDS := $(FLASKDIR)/initial_sids | |
75 | AVS := $(FLASKDIR)/access_vectors | |
fb0a3a98 | 76 | |
c9f20d5b CP |
77 | # local source layout |
78 | ifdef LOCAL_ROOT | |
79 | LOCAL_POLDIR := $(LOCAL_ROOT)/policy | |
80 | LOCAL_MODDIR := $(LOCAL_POLDIR)/modules | |
81 | endif | |
82 | ||
fb0a3a98 | 83 | # policy building support tools |
5b45ffb0 | 84 | SUPPORT := support |
0e686f1f CP |
85 | GENXML := $(PYTHON) $(SUPPORT)/segenxml.py |
86 | GENDOC := $(PYTHON) $(SUPPORT)/sedoctool.py | |
87 | GENPERM := $(PYTHON) $(SUPPORT)/genclassperms.py | |
c9f20d5b | 88 | FCSORT := $(TMPDIR)/fc_sort |
d6cf05b3 | 89 | SETBOOLS := $(AWK) -f $(SUPPORT)/set_bools_tuns.awk |
3abd5ee8 CP |
90 | get_type_attr_decl := $(SED) -r -f $(SUPPORT)/get_type_attr_decl.sed |
91 | comment_move_decl := $(SED) -r -f $(SUPPORT)/comment_move_decl.sed | |
3a80ec29 | 92 | |
fb0a3a98 | 93 | # documentation paths |
5b45ffb0 | 94 | DOCS := doc |
fb0a3a98 CP |
95 | XMLDTD = $(DOCS)/policy.dtd |
96 | LAYERXML = metadata.xml | |
fb0a3a98 | 97 | DOCTEMPLATE = $(DOCS)/templates |
5bd1a703 | 98 | DOCFILES = $(DOCS)/Makefile.example $(addprefix $(DOCS)/,example.te example.if example.fc) |
fb0a3a98 | 99 | |
c9f20d5b CP |
100 | ifndef LOCAL_ROOT |
101 | POLXML = $(DOCS)/policy.xml | |
3d598062 CP |
102 | TUNXML = $(DOCS)/global_tunables.xml |
103 | BOOLXML = $(DOCS)/global_booleans.xml | |
c9f20d5b CP |
104 | HTMLDIR = $(DOCS)/html |
105 | else | |
106 | POLXML = $(LOCAL_ROOT)/doc/policy.xml | |
3d598062 CP |
107 | TUNXML = $(LOCAL_ROOT)/doc/global_tunables.xml |
108 | BOOLXML = $(LOCAL_ROOT)/doc/global_booleans.xml | |
c9f20d5b CP |
109 | HTMLDIR = $(LOCAL_ROOT)/doc/html |
110 | endif | |
111 | ||
fb0a3a98 | 112 | # config file paths |
120988c4 CP |
113 | GLOBALTUN = $(POLDIR)/global_tunables |
114 | GLOBALBOOL = $(POLDIR)/global_booleans | |
120988c4 | 115 | TUNABLES = $(POLDIR)/tunables.conf |
120988c4 | 116 | ROLEMAP = $(POLDIR)/rolemap |
90b331fa | 117 | USER_FILES := $(POLDIR)/users |
fb0a3a98 | 118 | |
c9f20d5b CP |
119 | # local config file paths |
120 | ifndef LOCAL_ROOT | |
121 | MOD_CONF = $(POLDIR)/modules.conf | |
122 | BOOLEANS = $(POLDIR)/booleans.conf | |
123 | else | |
124 | MOD_CONF = $(LOCAL_POLDIR)/modules.conf | |
125 | BOOLEANS = $(LOCAL_POLDIR)/booleans.conf | |
126 | endif | |
127 | ||
fb0a3a98 | 128 | # install paths |
120988c4 CP |
129 | PKGNAME ?= refpolicy-$(VERSION) |
130 | PREFIX = $(DESTDIR)/usr | |
131 | TOPDIR = $(DESTDIR)/etc/selinux | |
132 | INSTALLDIR = $(TOPDIR)/$(NAME) | |
133 | SRCPATH = $(INSTALLDIR)/src | |
134 | USERPATH = $(INSTALLDIR)/users | |
135 | CONTEXTPATH = $(INSTALLDIR)/contexts | |
136 | FCPATH = $(CONTEXTPATH)/files/file_contexts | |
137 | SHAREDIR = $(PREFIX)/share/selinux | |
138 | MODPKGDIR = $(SHAREDIR)/$(NAME) | |
d6cf05b3 | 139 | HEADERDIR = $(MODPKGDIR)/include |
120988c4 | 140 | DOCSDIR = $(PREFIX)/share/doc/$(PKGNAME) |
c767b14c CP |
141 | |
142 | # compile strict policy if requested. | |
143 | ifneq ($(findstring strict,$(TYPE)),) | |
3f026a90 | 144 | M4PARAM += -D strict_policy |
c767b14c CP |
145 | endif |
146 | ||
147 | # compile targeted policy if requested. | |
148 | ifneq ($(findstring targeted,$(TYPE)),) | |
3f026a90 | 149 | M4PARAM += -D targeted_policy |
c767b14c | 150 | endif |
b4cd1533 | 151 | |
134191be | 152 | # enable MLS if requested. |
a0824843 | 153 | ifneq ($(findstring -mls,$(TYPE)),) |
3f026a90 CP |
154 | M4PARAM += -D enable_mls |
155 | CHECKPOLICY += -M | |
156 | CHECKMODULE += -M | |
134191be CP |
157 | endif |
158 | ||
a0824843 CP |
159 | # enable MLS if MCS requested. |
160 | ifneq ($(findstring -mcs,$(TYPE)),) | |
3f026a90 CP |
161 | M4PARAM += -D enable_mcs |
162 | CHECKPOLICY += -M | |
163 | CHECKMODULE += -M | |
b67488e3 CP |
164 | endif |
165 | ||
25a0c61f CP |
166 | # enable distribution-specific policy |
167 | ifneq ($(DISTRO),) | |
3f026a90 | 168 | M4PARAM += -D distro_$(DISTRO) |
25a0c61f CP |
169 | endif |
170 | ||
b07eaef9 CP |
171 | # enable polyinstantiation |
172 | ifeq ($(POLY),y) | |
3f026a90 | 173 | M4PARAM += -D enable_polyinstantiation |
b07eaef9 CP |
174 | endif |
175 | ||
b67488e3 | 176 | ifneq ($(OUTPUT_POLICY),) |
3f026a90 | 177 | CHECKPOLICY += -c $(OUTPUT_POLICY) |
b67488e3 CP |
178 | endif |
179 | ||
3f026a90 CP |
180 | # if not set, use the type as the name. |
181 | NAME ?= $(TYPE) | |
134191be | 182 | |
142e9f40 | 183 | ifeq ($(DIRECT_INITRC),y) |
3f026a90 | 184 | M4PARAM += -D direct_sysadm_daemon |
142e9f40 CP |
185 | endif |
186 | ||
9b3756bf CP |
187 | ifeq ($(QUIET),y) |
188 | verbose = @ | |
189 | endif | |
190 | ||
3f026a90 | 191 | M4PARAM += -D hide_broken_symptoms |
ee7f66b0 | 192 | |
37227dcd CP |
193 | # we need exuberant ctags; unfortunately it is named |
194 | # differently on different distros | |
195 | ifeq ($(DISTRO),debian) | |
196 | CTAGS := ctags-exuberant | |
197 | endif | |
198 | ||
199 | ifeq ($(DISTRO),gentoo) | |
200 | CTAGS := exuberant-ctags | |
201 | endif | |
202 | ||
a4fae7fa | 203 | CTAGS ?= ctags |
37227dcd | 204 | |
b4cd1533 | 205 | # determine the policy version and current kernel version if possible |
134191be | 206 | PV := $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ') |
b4cd1533 CP |
207 | KV := $(shell cat /selinux/policyvers) |
208 | ||
209 | # dont print version warnings if we are unable to determine | |
210 | # the currently running kernel's policy version | |
211 | ifeq ($(KV),) | |
134191be | 212 | KV := $(PV) |
b4cd1533 CP |
213 | endif |
214 | ||
c9f20d5b | 215 | M4SUPPORT = $(wildcard $(POLDIR)/support/*.spt $(LOCAL_POLDIR)/support/*.spt) |
0fbe15dc | 216 | |
5b45ffb0 | 217 | APPCONF := config/appconfig-$(TYPE) |
ace3688a | 218 | SEUSERS := $(APPCONF)/seusers |
c9a26b3e | 219 | APPDIR := $(CONTEXTPATH) |
049e11af | 220 | APPFILES := $(addprefix $(APPDIR)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts customizable_types) $(CONTEXTPATH)/files/media |
2926f9c7 | 221 | CONTEXTFILES += $(wildcard $(APPCONF)/*_context*) $(APPCONF)/media |
c9a26b3e | 222 | |
57869a68 | 223 | ALL_LAYERS := $(filter-out $(MODDIR)/CVS,$(shell find $(wildcard $(MODDIR)/*) -maxdepth 0 -type d)) |
c9f20d5b | 224 | ifdef LOCAL_ROOT |
e2680fb4 | 225 | ALL_LAYERS += $(filter-out $(LOCAL_MODDIR)/CVS,$(shell find $(wildcard $(LOCAL_MODDIR)/*) -maxdepth 0 -type d)) |
c9f20d5b | 226 | endif |
e12e5738 CP |
227 | |
228 | GENERATED_TE := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te.in))) | |
229 | GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in))) | |
230 | GENERATED_FC := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.fc.in))) | |
231 | ||
8ae194f6 CP |
232 | # sort here since it removes duplicates, which can happen |
233 | # when a generated file is already generated | |
234 | DETECTED_MODS := $(sort $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te)) $(GENERATED_TE)) | |
19db6ba5 | 235 | |
fb0a3a98 | 236 | # modules.conf setting for base module |
e8b3e30a | 237 | MODBASE := base |
fb0a3a98 | 238 | |
e0a9001b | 239 | # modules.conf setting for loadable module |
e8b3e30a | 240 | MODMOD := module |
fb0a3a98 | 241 | |
e0a9001b CP |
242 | # modules.conf setting for unused module |
243 | MODUNUSED := off | |
244 | ||
c9f20d5b | 245 | # test for module overrides from command line |
87e73c5f CP |
246 | MOD_TEST = $(filter $(APPS_OFF), $(APPS_BASE) $(APPS_MODS)) |
247 | MOD_TEST += $(filter $(APPS_MODS), $(APPS_BASE)) | |
c9f20d5b | 248 | ifneq ($(strip $(MOD_TEST)),) |
3abd5ee8 | 249 | $(error Applications must be base, module, or off, and not in more than one list! $(strip $(MOD_TEST)) found in multiple lists!) |
c9f20d5b CP |
250 | endif |
251 | ||
fb0a3a98 | 252 | # extract settings from modules.conf |
87e73c5f CP |
253 | BASE_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null))) |
254 | MOD_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null))) | |
255 | OFF_MODS := $(addsuffix .te,$(sort $(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODUNUSED)") print $$1 }' $(MOD_CONF) 2> /dev/null))) | |
256 | ||
257 | # add module overrides from command line | |
258 | BASE_MODS += $(APPS_BASE) | |
259 | MOD_MODS += $(APPS_MODS) | |
260 | OFF_MODS += $(APPS_OFF) | |
261 | ||
262 | # add modules not in modules.conf to the off list | |
263 | OFF_MODS += $(filter-out $(BASE_MODS) $(MOD_MODS),$(notdir $(DETECTED_MODS))) | |
712566ee | 264 | |
90b331fa | 265 | # filesystems to be used in labeling targets |
120988c4 CP |
266 | FILESYSTEMS = $(shell mount | grep -v "context=" | egrep -v '\((|.*,)bind(,.*|)\)' | awk '/(ext[23]| xfs| jfs).*rw/{print $$3}';) |
267 | ||
4ace0fa5 CP |
268 | ######################################## |
269 | # | |
270 | # Functions | |
271 | # | |
272 | ||
273 | # parse-rolemap modulename,outputfile | |
274 | define parse-rolemap | |
9b3756bf | 275 | $(verbose) m4 $(M4PARAM) $(ROLEMAP) | \ |
4ace0fa5 CP |
276 | awk '/^[[:blank:]]*[A-Za-z]/{ print "gen_require(type " $$3 "; role " $$1 ";)\n$1_per_userdomain_template(" $$2 "," $$3 "," $$1 ")" }' >> $2 |
277 | endef | |
278 | ||
279 | # peruser-expansion modulename,outputfile | |
280 | define peruser-expansion | |
9b3756bf | 281 | $(verbose) echo "ifdef(\`""$1""_per_userdomain_template',\`" > $2 |
4ace0fa5 | 282 | $(call parse-rolemap,$1,$2) |
9b3756bf | 283 | $(verbose) echo "')" >> $2 |
4ace0fa5 CP |
284 | endef |
285 | ||
b4cd1533 CP |
286 | ######################################## |
287 | # | |
fb0a3a98 | 288 | # Load appropriate rules |
b4cd1533 | 289 | # |
b4cd1533 | 290 | |
fb0a3a98 | 291 | ifeq ($(MONOLITHIC),y) |
5b45ffb0 | 292 | include Rules.monolithic |
fb0a3a98 | 293 | else |
5b45ffb0 | 294 | include Rules.modular |
b4cd1533 | 295 | endif |
b4cd1533 | 296 | |
88d14a22 CP |
297 | ######################################## |
298 | # | |
fb0a3a98 | 299 | # Generated files |
b4cd1533 | 300 | # |
c9f20d5b CP |
301 | # NOTE: There is no "local" version of these files. |
302 | # | |
fffba0ba CP |
303 | generate: $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC) |
304 | ||
f2e4ab3a | 305 | $(MODDIR)/kernel/corenetwork.if: $(MODDIR)/kernel/corenetwork.if.m4 $(MODDIR)/kernel/corenetwork.if.in |
61bbe531 CP |
306 | @echo "#" > $@ |
307 | @echo "# This is a generated file! Instead of modifying this file, the" >> $@ | |
308 | @echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@ | |
309 | @echo "#" >> $@ | |
9b3756bf CP |
310 | $(verbose) cat $(MODDIR)/kernel/corenetwork.if.in >> $@ |
311 | $(verbose) egrep "^[[:blank:]]*network_(interface|node|port)\(.*\)" $(@:.if=.te).in \ | |
cf6141a7 | 312 | | m4 -D self_contained_policy $(M4PARAM) $(MODDIR)/kernel/corenetwork.if.m4 - \ |
f2e4ab3a | 313 | | sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@ |
f2e4ab3a CP |
314 | |
315 | $(MODDIR)/kernel/corenetwork.te: $(MODDIR)/kernel/corenetwork.te.m4 $(MODDIR)/kernel/corenetwork.te.in | |
61bbe531 CP |
316 | @echo "#" > $@ |
317 | @echo "# This is a generated file! Instead of modifying this file, the" >> $@ | |
318 | @echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@ | |
319 | @echo "#" >> $@ | |
9b3756bf | 320 | $(verbose) m4 -D self_contained_policy $(M4PARAM) $^ \ |
61bbe531 | 321 | | sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@ |
f2e4ab3a | 322 | |
84eb353c CP |
323 | ######################################## |
324 | # | |
325 | # Create config files | |
326 | # | |
4f9f30c8 | 327 | conf: $(MOD_CONF) $(BOOLEANS) $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC) |
d2d6c8ce | 328 | |
4f9f30c8 CP |
329 | $(MOD_CONF) $(BOOLEANS): $(POLXML) |
330 | @echo "Updating $(MOD_CONF) and $(BOOLEANS)" | |
13a4943d | 331 | $(verbose) $(GENDOC) -b $(BOOLEANS) -m $(MOD_CONF) -x $(POLXML) |
84eb353c | 332 | |
c9f20d5b CP |
333 | ######################################## |
334 | # | |
335 | # Generate the fc_sort program | |
336 | # | |
337 | $(FCSORT) : $(SUPPORT)/fc_sort.c | |
fffba0ba | 338 | $(verbose) $(CC) $(CFLAGS) $(SUPPORT)/fc_sort.c -o $(FCSORT) |
c9f20d5b | 339 | |
6d314fd3 CP |
340 | ######################################## |
341 | # | |
342 | # Documentation generation | |
343 | # | |
344 | ||
d2d6c8ce | 345 | # minimal dependencies here, because we don't want to rebuild |
84eb353c | 346 | # this and its dependents every time the dependencies |
19db6ba5 CP |
347 | # change. Also use all .if files here, rather then just the |
348 | # enabled modules. | |
1a7175a8 | 349 | xml: $(POLXML) |
d233bfce | 350 | $(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML)) |
1a7175a8 | 351 | @echo "Creating $(@F)" |
c9f20d5b CP |
352 | @test -d $(dir $(POLXML)) || mkdir -p $(dir $(POLXML)) |
353 | @test -d $(TMPDIR) || mkdir -p $(TMPDIR) | |
9b3756bf CP |
354 | $(verbose) echo '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' > $@ |
355 | $(verbose) echo '<!DOCTYPE policy SYSTEM "$(notdir $(XMLDTD))">' >> $@ | |
3d598062 | 356 | $(verbose) $(GENXML) -m $(LAYERXML) -t $(GLOBALTUN) -b $(GLOBALBOOL) -o $(DOCS) $(ALL_LAYERS) >> $@ |
9b3756bf | 357 | $(verbose) if test -x $(XMLLINT) && test -f $(XMLDTD); then \ |
c9f20d5b | 358 | $(XMLLINT) --noout --path $(dir $(XMLDTD)) --dtdvalid $(XMLDTD) $@ ;\ |
004db90d | 359 | fi |
6d314fd3 | 360 | |
3d598062 CP |
361 | $(TUNXML) $(BOOLXML): $(POLXML) |
362 | ||
c9f20d5b | 363 | html $(TMPDIR)/html: $(POLXML) |
2de03f30 | 364 | @echo "Building html interface reference documentation in $(HTMLDIR)" |
c9f20d5b | 365 | @test -d $(HTMLDIR) || mkdir -p $(HTMLDIR) |
81a18f87 | 366 | @test -d $(TMPDIR) || mkdir -p $(TMPDIR) |
0e686f1f | 367 | $(verbose) $(GENDOC) -d $(HTMLDIR) -T $(DOCTEMPLATE) -x $(POLXML) |
9b3756bf | 368 | $(verbose) cp $(DOCTEMPLATE)/*.css $(HTMLDIR) |
c9f20d5b | 369 | @touch $(TMPDIR)/html |
20030ef5 | 370 | |
c9a26b3e CP |
371 | ######################################## |
372 | # | |
373 | # Runtime binary policy patching of users | |
374 | # | |
c9f20d5b CP |
375 | $(USERPATH)/system.users: $(M4SUPPORT) $(TMPDIR)/generated_definitions.conf $(USER_FILES) |
376 | @mkdir -p $(TMPDIR) | |
c9a26b3e CP |
377 | @mkdir -p $(USERPATH) |
378 | @echo "Installing system.users" | |
c9f20d5b CP |
379 | @echo "# " > $(TMPDIR)/system.users |
380 | @echo "# Do not edit this file. " >> $(TMPDIR)/system.users | |
381 | @echo "# This file is replaced on reinstalls of this policy." >> $(TMPDIR)/system.users | |
382 | @echo "# Please edit local.users to make local changes." >> $(TMPDIR)/system.users | |
383 | @echo "#" >> $(TMPDIR)/system.users | |
9b3756bf | 384 | $(verbose) m4 -D self_contained_policy $(M4PARAM) $^ | sed -r -e 's/^[[:blank:]]+//' \ |
c9f20d5b CP |
385 | -e '/^[[:blank:]]*($$|#)/d' >> $(TMPDIR)/system.users |
386 | $(verbose) install -m 644 $(TMPDIR)/system.users $@ | |
c9a26b3e | 387 | |
1beba1c6 | 388 | $(USERPATH)/local.users: config/local.users |
c9a26b3e CP |
389 | @mkdir -p $(USERPATH) |
390 | @echo "Installing local.users" | |
9b3756bf | 391 | $(verbose) install -b -m 644 $< $@ |
c9a26b3e CP |
392 | |
393 | ######################################## | |
394 | # | |
395 | # Appconfig files | |
396 | # | |
397 | install-appconfig: $(APPFILES) | |
398 | ||
4f9f30c8 | 399 | $(INSTALLDIR)/booleans: $(BOOLEANS) |
c9f20d5b | 400 | @mkdir -p $(TMPDIR) |
1beba1c6 | 401 | @mkdir -p $(INSTALLDIR) |
9b3756bf | 402 | $(verbose) sed -r -e 's/false/0/g' -e 's/true/1/g' \ |
c9f20d5b CP |
403 | -e '/^[[:blank:]]*($$|#)/d' $(BOOLEANS) | sort > $(TMPDIR)/booleans |
404 | $(verbose) install -m 644 $(TMPDIR)/booleans $@ | |
1beba1c6 | 405 | |
2926f9c7 | 406 | $(CONTEXTPATH)/files/media: $(APPCONF)/media |
1beba1c6 | 407 | @mkdir -p $(CONTEXTPATH)/files/ |
9b3756bf | 408 | $(verbose) install -m 644 $< $@ |
c9a26b3e | 409 | |
2926f9c7 | 410 | $(APPDIR)/default_contexts: $(APPCONF)/default_contexts |
1beba1c6 | 411 | @mkdir -p $(APPDIR) |
9b3756bf | 412 | $(verbose) install -m 644 $< $@ |
c9a26b3e | 413 | |
2926f9c7 | 414 | $(APPDIR)/removable_context: $(APPCONF)/removable_context |
1beba1c6 | 415 | @mkdir -p $(APPDIR) |
9b3756bf | 416 | $(verbose) install -m 644 $< $@ |
c9a26b3e | 417 | |
2926f9c7 | 418 | $(APPDIR)/default_type: $(APPCONF)/default_type |
1beba1c6 | 419 | @mkdir -p $(APPDIR) |
9b3756bf | 420 | $(verbose) install -m 644 $< $@ |
c9a26b3e | 421 | |
2926f9c7 | 422 | $(APPDIR)/userhelper_context: $(APPCONF)/userhelper_context |
1beba1c6 | 423 | @mkdir -p $(APPDIR) |
9b3756bf | 424 | $(verbose) install -m 644 $< $@ |
c9a26b3e | 425 | |
2926f9c7 | 426 | $(APPDIR)/initrc_context: $(APPCONF)/initrc_context |
1beba1c6 | 427 | @mkdir -p $(APPDIR) |
9b3756bf | 428 | $(verbose) install -m 644 $< $@ |
c9a26b3e | 429 | |
2926f9c7 | 430 | $(APPDIR)/failsafe_context: $(APPCONF)/failsafe_context |
1beba1c6 | 431 | @mkdir -p $(APPDIR) |
9b3756bf | 432 | $(verbose) install -m 644 $< $@ |
c9a26b3e | 433 | |
2926f9c7 | 434 | $(APPDIR)/dbus_contexts: $(APPCONF)/dbus_contexts |
1beba1c6 | 435 | @mkdir -p $(APPDIR) |
9b3756bf | 436 | $(verbose) install -m 644 $< $@ |
c9a26b3e | 437 | |
2926f9c7 | 438 | $(APPDIR)/users/root: $(APPCONF)/root_default_contexts |
1beba1c6 | 439 | @mkdir -p $(APPDIR)/users |
9b3756bf CP |
440 | $(verbose) install -m 644 $< $@ |
441 | ||
442 | ######################################## | |
443 | # | |
444 | # Install policy headers | |
445 | # | |
3d598062 | 446 | install-headers: $(TUNXML) $(BOOLXML) |
120988c4 | 447 | @mkdir -p $(HEADERDIR) |
1a7175a8 | 448 | @echo "Installing $(TYPE) policy headers." |
3d598062 | 449 | $(verbose) install -m 644 $(TUNXML) $(BOOLXML) $(HEADERDIR) |
885b83ec CP |
450 | $(verbose) m4 $(M4PARAM) $(ROLEMAP) > $(HEADERDIR)/$(notdir $(ROLEMAP)) |
451 | $(verbose) mkdir -p $(HEADERDIR)/support | |
d6cf05b3 | 452 | $(verbose) install -m 644 $(M4SUPPORT) $(word $(words $(GENXML)),$(GENXML)) $(XMLDTD) $(HEADERDIR)/support |
885b83ec CP |
453 | $(verbose) $(GENPERM) $(AVS) $(SECCLASS) > $(HEADERDIR)/support/all_perms.spt |
454 | $(verbose) for i in $(notdir $(ALL_LAYERS)); do \ | |
455 | mkdir -p $(HEADERDIR)/$$i ;\ | |
456 | install -m 644 $(MODDIR)/$$i/*.if \ | |
457 | $(MODDIR)/$$i/metadata.xml \ | |
458 | $(HEADERDIR)/$$i ;\ | |
459 | done | |
0f27d98d CP |
460 | $(verbose) echo "TYPE ?= $(TYPE)" > $(HEADERDIR)/build.conf |
461 | $(verbose) echo "NAME ?= $(NAME)" >> $(HEADERDIR)/build.conf | |
885b83ec | 462 | ifneq "$(DISTRO)" "" |
0f27d98d | 463 | $(verbose) echo "DISTRO ?= $(DISTRO)" >> $(HEADERDIR)/build.conf |
885b83ec | 464 | endif |
0f27d98d CP |
465 | $(verbose) echo "MONOLITHIC ?= n" >> $(HEADERDIR)/build.conf |
466 | $(verbose) echo "DIRECT_INITRC ?= $(DIRECT_INITRC)" >> $(HEADERDIR)/build.conf | |
467 | $(verbose) echo "POLY ?= $(POLY)" >> $(HEADERDIR)/build.conf | |
885b83ec | 468 | $(verbose) install -m 644 $(SUPPORT)/Makefile.devel $(HEADERDIR)/Makefile |
c9a26b3e | 469 | |
120988c4 CP |
470 | ######################################## |
471 | # | |
472 | # Install policy documentation | |
473 | # | |
c9f20d5b | 474 | install-docs: $(TMPDIR)/html |
120988c4 CP |
475 | @mkdir -p $(DOCSDIR)/html |
476 | @echo "Installing policy documentation" | |
5bd1a703 | 477 | $(verbose) install -m 644 $(DOCFILES) $(DOCSDIR) |
120988c4 CP |
478 | $(verbose) install -m 644 $(wildcard $(HTMLDIR)/*) $(DOCSDIR)/html |
479 | ||
c592e52e CP |
480 | ######################################## |
481 | # | |
482 | # Install policy sources | |
483 | # | |
484 | install-src: | |
485 | rm -rf $(SRCPATH)/policy.old | |
486 | -mv $(SRCPATH)/policy $(SRCPATH)/policy.old | |
487 | mkdir -p $(SRCPATH)/policy | |
488 | cp -R . $(SRCPATH)/policy | |
489 | ||
37227dcd CP |
490 | ######################################## |
491 | # | |
492 | # Generate tags file | |
493 | # | |
c9f20d5b CP |
494 | tags: $(TAGS) |
495 | $(TAGS): | |
37227dcd | 496 | @($(CTAGS) --version | grep -q Exuberant) || (echo ERROR: Need exuberant-ctags to function!; exit 1) |
c9f20d5b | 497 | @LC_ALL=C $(CTAGS) -f $(TAGS) --langdef=te --langmap=te:..te.if.spt \ |
37227dcd CP |
498 | --regex-te='/^type[ \t]+(\w+)(,|;)/\1/t,type/' \ |
499 | --regex-te='/^typealias[ \t]+\w+[ \t+]+alias[ \t]+(\w+);/\1/t,type/' \ | |
500 | --regex-te='/^attribute[ \t]+(\w+);/\1/a,attribute/' \ | |
501 | --regex-te='/^[ \t]*define\(`(\w+)/\1/d,define/' \ | |
502 | --regex-te='/^[ \t]*interface\(`(\w+)/\1/i,interface/' \ | |
503 | --regex-te='/^[ \t]*bool[ \t]+(\w+)/\1/b,bool/' policy/modules/*/*.{if,te} policy/support/*.spt | |
504 | ||
120988c4 CP |
505 | ######################################## |
506 | # | |
507 | # Filesystem labeling | |
508 | # | |
509 | checklabels: | |
510 | @echo "Checking labels on filesystem types: ext2 ext3 xfs jfs" | |
511 | @if test -z "$(FILESYSTEMS)"; then \ | |
512 | echo "No filesystems with extended attributes found!" ;\ | |
513 | false ;\ | |
514 | fi | |
515 | $(verbose) $(SETFILES) -v -n $(FCPATH) $(FILESYSTEMS) | |
516 | ||
517 | restorelabels: | |
518 | @echo "Restoring labels on filesystem types: ext2 ext3 xfs jfs" | |
519 | @if test -z "$(FILESYSTEMS)"; then \ | |
520 | echo "No filesystems with extended attributes found!" ;\ | |
521 | false ;\ | |
522 | fi | |
523 | $(verbose) $(SETFILES) -v $(FCPATH) $(FILESYSTEMS) | |
524 | ||
525 | relabel: | |
526 | @echo "Relabeling filesystem types: ext2 ext3 xfs jfs" | |
527 | @if test -z "$(FILESYSTEMS)"; then \ | |
528 | echo "No filesystems with extended attributes found!" ;\ | |
529 | false ;\ | |
530 | fi | |
531 | $(verbose) $(SETFILES) $(FCPATH) $(FILESYSTEMS) | |
532 | ||
533 | resetlabels: | |
534 | @echo "Resetting labels on filesystem types: ext2 ext3 xfs jfs" | |
535 | @if test -z "$(FILESYSTEMS)"; then \ | |
536 | echo "No filesystems with extended attributes found!" ;\ | |
537 | false ;\ | |
538 | fi | |
539 | $(verbose) $(SETFILES) -F $(FCPATH) $(FILESYSTEMS) | |
540 | ||
102a59ba CP |
541 | ######################################## |
542 | # | |
543 | # Clean everything | |
544 | # | |
0fbe15dc | 545 | bare: clean |
12b559a4 | 546 | rm -f $(POLXML) |
3d598062 CP |
547 | rm -f $(TUNXML) |
548 | rm -f $(BOOLXML) | |
19db6ba5 | 549 | rm -f $(MOD_CONF) |
4f9f30c8 | 550 | rm -f $(BOOLEANS) |
20030ef5 | 551 | rm -fR $(HTMLDIR) |
c9f20d5b CP |
552 | rm -f $(TAGS) |
553 | # don't remove these files if we're given a local root | |
554 | ifndef LOCAL_ROOT | |
555 | rm -f $(FCSORT) | |
556 | rm -f $(SUPPORT)/*.pyc | |
c767b14c CP |
557 | ifneq ($(GENERATED_TE),) |
558 | rm -f $(GENERATED_TE) | |
559 | endif | |
560 | ifneq ($(GENERATED_IF),) | |
561 | rm -f $(GENERATED_IF) | |
562 | endif | |
563 | ifneq ($(GENERATED_FC),) | |
564 | rm -f $(GENERATED_FC) | |
565 | endif | |
c9f20d5b | 566 | endif |
0fbe15dc | 567 | |
1a7175a8 | 568 | .PHONY: install-src install-appconfig generate xml conf html bare tags |
b8c79823 CP |
569 | .SUFFIXES: |
570 | .SUFFIXES: .c |