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