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