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