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