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