]>
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 | ||
8e0ef1f9 CP |
26 | include build.conf |
27 | ||
b4cd1533 CP |
28 | # executable paths |
29 | PREFIX := /usr | |
30 | BINDIR := $(PREFIX)/bin | |
31 | SBINDIR := $(PREFIX)/sbin | |
40a1f3db | 32 | CHECKPOLICY := $(BINDIR)/checkpolicy |
fb0a3a98 | 33 | CHECKMODULE := $(BINDIR)/checkmodule |
c767b14c | 34 | SEMODULE := $(SBINDIR)/semodule |
fb0a3a98 | 35 | SEMOD_PKG := $(BINDIR)/semodule_package |
547283e2 | 36 | LOADPOLICY := $(SBINDIR)/load_policy |
b4cd1533 | 37 | SETFILES := $(SBINDIR)/setfiles |
1beba1c6 | 38 | GENHOMEDIRCON := $(SBINDIR)/genhomedircon |
fb0a3a98 | 39 | XMLLINT := $(BINDIR)/xmllint |
8df65f13 | 40 | SECHECK := $(BINDIR)/sechecker |
0447352a | 41 | |
c7b41e95 CP |
42 | CFLAGS := -Wall |
43 | ||
fb0a3a98 | 44 | # policy source layout |
c04f2abe CP |
45 | POLDIR := policy |
46 | MODDIR := $(POLDIR)/modules | |
47 | FLASKDIR := $(POLDIR)/flask | |
48 | SECCLASS := $(FLASKDIR)/security_classes | |
49 | ISIDS := $(FLASKDIR)/initial_sids | |
50 | AVS := $(FLASKDIR)/access_vectors | |
fb0a3a98 CP |
51 | |
52 | # policy building support tools | |
3a80ec29 | 53 | SUPPORT := support |
95db4228 | 54 | GENXML := $(SUPPORT)/segenxml.py |
3a80ec29 | 55 | GENDOC := $(SUPPORT)/sedoctool.py |
c04f2abe | 56 | GENPERM := $(SUPPORT)/genclassperms.py |
254bbc7b | 57 | FCSORT := $(SUPPORT)/fc_sort |
84eb353c | 58 | SETTUN := $(SUPPORT)/set_tunables |
3a80ec29 | 59 | |
fb0a3a98 CP |
60 | # documentation paths |
61 | DOCS = doc | |
62 | POLXML = $(DOCS)/policy.xml | |
63 | XMLDTD = $(DOCS)/policy.dtd | |
64 | LAYERXML = metadata.xml | |
65 | HTMLDIR = $(DOCS)/html | |
66 | DOCTEMPLATE = $(DOCS)/templates | |
67 | ||
68 | # config file paths | |
69 | GLOBALTUN := $(POLDIR)/global_tunables | |
4f9f30c8 | 70 | GLOBALBOOL := $(POLDIR)/global_booleans |
fb0a3a98 CP |
71 | MOD_CONF := $(POLDIR)/modules.conf |
72 | TUNABLES := $(POLDIR)/tunables.conf | |
4f9f30c8 | 73 | BOOLEANS := $(POLDIR)/booleans.conf |
fb0a3a98 CP |
74 | |
75 | # install paths | |
76 | TOPDIR = $(DESTDIR)/etc/selinux | |
77 | INSTALLDIR = $(TOPDIR)/$(NAME) | |
78 | SRCPATH = $(INSTALLDIR)/src | |
79 | USERPATH = $(INSTALLDIR)/users | |
80 | CONTEXTPATH = $(INSTALLDIR)/contexts | |
c767b14c CP |
81 | MODPKGDIR = $(DESTDIR)/usr/share/selinux/$(NAME) |
82 | ||
83 | # compile strict policy if requested. | |
84 | ifneq ($(findstring strict,$(TYPE)),) | |
85 | override M4PARAM += -D strict_policy | |
86 | endif | |
87 | ||
88 | # compile targeted policy if requested. | |
89 | ifneq ($(findstring targeted,$(TYPE)),) | |
90 | override M4PARAM += -D targeted_policy | |
91 | endif | |
b4cd1533 | 92 | |
134191be | 93 | # enable MLS if requested. |
a0824843 | 94 | ifneq ($(findstring -mls,$(TYPE)),) |
134191be | 95 | override M4PARAM += -D enable_mls |
c767b14c CP |
96 | override CHECKPOLICY += -M |
97 | override CHECKMODULE += -M | |
134191be CP |
98 | endif |
99 | ||
a0824843 CP |
100 | # enable MLS if MCS requested. |
101 | ifneq ($(findstring -mcs,$(TYPE)),) | |
102 | override M4PARAM += -D enable_mcs | |
c767b14c CP |
103 | override CHECKPOLICY += -M |
104 | override CHECKMODULE += -M | |
b67488e3 CP |
105 | endif |
106 | ||
25a0c61f CP |
107 | # enable distribution-specific policy |
108 | ifneq ($(DISTRO),) | |
109 | override M4PARAM += -D distro_$(DISTRO) | |
110 | endif | |
111 | ||
b67488e3 | 112 | ifneq ($(OUTPUT_POLICY),) |
c767b14c | 113 | override CHECKPOLICY += -c $(OUTPUT_POLICY) |
b67488e3 CP |
114 | endif |
115 | ||
116 | ifeq ($(NAME),) | |
117 | NAME := $(TYPE) | |
134191be CP |
118 | endif |
119 | ||
142e9f40 CP |
120 | ifeq ($(DIRECT_INITRC),y) |
121 | override M4PARAM += -D direct_sysadm_daemon | |
122 | endif | |
123 | ||
ee7f66b0 CP |
124 | override M4PARAM += -D hide_broken_symptoms |
125 | ||
b4cd1533 | 126 | # determine the policy version and current kernel version if possible |
134191be | 127 | PV := $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ') |
b4cd1533 CP |
128 | KV := $(shell cat /selinux/policyvers) |
129 | ||
130 | # dont print version warnings if we are unable to determine | |
131 | # the currently running kernel's policy version | |
132 | ifeq ($(KV),) | |
134191be | 133 | KV := $(PV) |
b4cd1533 CP |
134 | endif |
135 | ||
fb0a3a98 | 136 | M4SUPPORT = $(wildcard $(POLDIR)/support/*.spt) |
0fbe15dc | 137 | |
c0e4fe2c | 138 | APPCONF := config/appconfig-$(TYPE) |
c9a26b3e | 139 | APPDIR := $(CONTEXTPATH) |
049e11af | 140 | APPFILES := $(addprefix $(APPDIR)/,default_contexts default_type initrc_context failsafe_context userhelper_context removable_context dbus_contexts customizable_types) $(CONTEXTPATH)/files/media |
2926f9c7 | 141 | CONTEXTFILES += $(wildcard $(APPCONF)/*_context*) $(APPCONF)/media |
bdb2fac0 | 142 | USER_FILES := $(POLDIR)/users |
c9a26b3e | 143 | |
57869a68 | 144 | ALL_LAYERS := $(filter-out $(MODDIR)/CVS,$(shell find $(wildcard $(MODDIR)/*) -maxdepth 0 -type d)) |
e12e5738 CP |
145 | |
146 | GENERATED_TE := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te.in))) | |
147 | GENERATED_IF := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.if.in))) | |
148 | GENERATED_FC := $(basename $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.fc.in))) | |
149 | ||
8ae194f6 CP |
150 | # sort here since it removes duplicates, which can happen |
151 | # when a generated file is already generated | |
152 | DETECTED_MODS := $(sort $(foreach dir,$(ALL_LAYERS),$(wildcard $(dir)/*.te)) $(GENERATED_TE)) | |
19db6ba5 | 153 | |
fb0a3a98 | 154 | # modules.conf setting for base module |
e8b3e30a | 155 | MODBASE := base |
fb0a3a98 CP |
156 | |
157 | # modules.conf setting for module | |
e8b3e30a | 158 | MODMOD := module |
fb0a3a98 CP |
159 | |
160 | # extract settings from modules.conf | |
c767b14c CP |
161 | BASE_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODBASE)") print $$1 }' $(MOD_CONF) 2> /dev/null)) |
162 | MOD_MODS := $(addsuffix .te,$(shell awk '/^[[:blank:]]*[[:alpha:]]/{ if ($$3 == "$(MODMOD)") print $$1 }' $(MOD_CONF) 2> /dev/null)) | |
712566ee | 163 | |
b4cd1533 CP |
164 | ######################################## |
165 | # | |
fb0a3a98 | 166 | # Load appropriate rules |
b4cd1533 | 167 | # |
b4cd1533 | 168 | |
fb0a3a98 CP |
169 | ifeq ($(MONOLITHIC),y) |
170 | include Rules.monolithic | |
171 | else | |
172 | include Rules.modular | |
b4cd1533 | 173 | endif |
b4cd1533 | 174 | |
88d14a22 CP |
175 | ######################################## |
176 | # | |
fb0a3a98 | 177 | # Generated files |
b4cd1533 | 178 | # |
f2e4ab3a | 179 | $(MODDIR)/kernel/corenetwork.if: $(MODDIR)/kernel/corenetwork.if.m4 $(MODDIR)/kernel/corenetwork.if.in |
61bbe531 CP |
180 | @echo "#" > $@ |
181 | @echo "# This is a generated file! Instead of modifying this file, the" >> $@ | |
182 | @echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@ | |
183 | @echo "#" >> $@ | |
184 | $(QUIET) cat $(MODDIR)/kernel/corenetwork.if.in >> $@ | |
f2e4ab3a | 185 | $(QUIET) egrep "^[[:blank:]]*network_(interface|node|port)\(.*\)" $(@:.if=.te).in \ |
cf6141a7 | 186 | | m4 -D self_contained_policy $(M4PARAM) $(MODDIR)/kernel/corenetwork.if.m4 - \ |
f2e4ab3a | 187 | | sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@ |
f2e4ab3a CP |
188 | |
189 | $(MODDIR)/kernel/corenetwork.te: $(MODDIR)/kernel/corenetwork.te.m4 $(MODDIR)/kernel/corenetwork.te.in | |
61bbe531 CP |
190 | @echo "#" > $@ |
191 | @echo "# This is a generated file! Instead of modifying this file, the" >> $@ | |
192 | @echo "# $(notdir $@).in or $(notdir $@).m4 file should be modified." >> $@ | |
193 | @echo "#" >> $@ | |
cf6141a7 | 194 | $(QUIET) m4 -D self_contained_policy $(M4PARAM) $^ \ |
61bbe531 | 195 | | sed -e 's/dollarsone/\$$1/g' -e 's/dollarszero/\$$0/g' >> $@ |
f2e4ab3a | 196 | |
84eb353c CP |
197 | ######################################## |
198 | # | |
199 | # Create config files | |
200 | # | |
4f9f30c8 | 201 | conf: $(MOD_CONF) $(BOOLEANS) $(GENERATED_TE) $(GENERATED_IF) $(GENERATED_FC) |
d2d6c8ce | 202 | |
4f9f30c8 CP |
203 | $(MOD_CONF) $(BOOLEANS): $(POLXML) |
204 | @echo "Updating $(MOD_CONF) and $(BOOLEANS)" | |
205 | $(QUIET) cd $(DOCS) && ../$(GENDOC) -t ../$(BOOLEANS) -m ../$(MOD_CONF) -x ../$(POLXML) | |
84eb353c | 206 | |
6d314fd3 CP |
207 | ######################################## |
208 | # | |
209 | # Documentation generation | |
210 | # | |
211 | ||
d2d6c8ce | 212 | # minimal dependencies here, because we don't want to rebuild |
84eb353c | 213 | # this and its dependents every time the dependencies |
19db6ba5 CP |
214 | # change. Also use all .if files here, rather then just the |
215 | # enabled modules. | |
d233bfce | 216 | $(POLXML): $(DETECTED_MODS:.te=.if) $(foreach dir,$(ALL_LAYERS),$(dir)/$(LAYERXML)) |
88c72f44 | 217 | @echo "Creating $@" |
84eb353c | 218 | @mkdir -p tmp |
004db90d | 219 | $(QUIET) echo '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>' > $@ |
95db4228 | 220 | $(QUIET) echo '<!DOCTYPE policy SYSTEM "$(notdir $(XMLDTD))">' >> $@ |
4f9f30c8 | 221 | $(QUIET) $(GENXML) -w -m $(LAYERXML) -t $(GLOBALTUN) -b $(GLOBALBOOL) $(ALL_LAYERS) >> $@ |
0447352a CP |
222 | $(QUIET) if test -x $(XMLLINT) && test -f $(XMLDTD); then \ |
223 | $(XMLLINT) --noout --dtdvalid $(XMLDTD) $@ ;\ | |
004db90d | 224 | fi |
6d314fd3 | 225 | |
12b559a4 | 226 | html: $(POLXML) |
20030ef5 | 227 | @mkdir -p $(HTMLDIR) |
12b559a4 | 228 | $(QUIET) cd $(DOCS) && ../$(GENDOC) -d ../$(HTMLDIR) -T ../$(DOCTEMPLATE) -x ../$(POLXML) |
20030ef5 CP |
229 | $(QUIET) cp $(DOCTEMPLATE)/*.css $(HTMLDIR) |
230 | ||
c9a26b3e CP |
231 | ######################################## |
232 | # | |
233 | # Runtime binary policy patching of users | |
234 | # | |
1fb83a76 | 235 | $(USERPATH)/system.users: $(M4SUPPORT) tmp/generated_definitions.conf $(USER_FILES) |
c9a26b3e CP |
236 | @mkdir -p $(USERPATH) |
237 | @echo "Installing system.users" | |
238 | @echo "# " > tmp/system.users | |
239 | @echo "# Do not edit this file. " >> tmp/system.users | |
240 | @echo "# This file is replaced on reinstalls of this policy." >> tmp/system.users | |
241 | @echo "# Please edit local.users to make local changes." >> tmp/system.users | |
242 | @echo "#" >> tmp/system.users | |
1fb83a76 | 243 | $(QUIET) m4 -D self_contained_policy $(M4PARAM) $^ | \ |
fb2817da CP |
244 | egrep -v "^[[:blank:]]*($$|#)" | \ |
245 | sed -r -e 's/^[[:blank:]]+//' >> tmp/system.users | |
c9a26b3e CP |
246 | $(QUIET) install -m 644 tmp/system.users $@ |
247 | ||
1beba1c6 | 248 | $(USERPATH)/local.users: config/local.users |
c9a26b3e CP |
249 | @mkdir -p $(USERPATH) |
250 | @echo "Installing local.users" | |
c7b41e95 | 251 | $(QUIET) install -b -m 644 $< $@ |
c9a26b3e CP |
252 | |
253 | ######################################## | |
254 | # | |
255 | # Appconfig files | |
256 | # | |
257 | install-appconfig: $(APPFILES) | |
258 | ||
4f9f30c8 | 259 | $(INSTALLDIR)/booleans: $(BOOLEANS) |
1beba1c6 | 260 | @mkdir -p $(INSTALLDIR) |
4f9f30c8 | 261 | $(QUIET) egrep '^[[:blank:]]*[[:alpha:]]' $(BOOLEANS) \ |
1beba1c6 CP |
262 | | sed -e 's/false/0/g' -e 's/true/1/g' > tmp/booleans |
263 | $(QUIET) install -m 644 tmp/booleans $@ | |
264 | ||
2926f9c7 | 265 | $(CONTEXTPATH)/files/media: $(APPCONF)/media |
1beba1c6 CP |
266 | @mkdir -p $(CONTEXTPATH)/files/ |
267 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 268 | |
2926f9c7 | 269 | $(APPDIR)/default_contexts: $(APPCONF)/default_contexts |
1beba1c6 CP |
270 | @mkdir -p $(APPDIR) |
271 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 272 | |
2926f9c7 | 273 | $(APPDIR)/removable_context: $(APPCONF)/removable_context |
1beba1c6 CP |
274 | @mkdir -p $(APPDIR) |
275 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 276 | |
2926f9c7 | 277 | $(APPDIR)/default_type: $(APPCONF)/default_type |
1beba1c6 CP |
278 | @mkdir -p $(APPDIR) |
279 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 280 | |
2926f9c7 | 281 | $(APPDIR)/userhelper_context: $(APPCONF)/userhelper_context |
1beba1c6 CP |
282 | @mkdir -p $(APPDIR) |
283 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 284 | |
2926f9c7 | 285 | $(APPDIR)/initrc_context: $(APPCONF)/initrc_context |
1beba1c6 CP |
286 | @mkdir -p $(APPDIR) |
287 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 288 | |
2926f9c7 | 289 | $(APPDIR)/failsafe_context: $(APPCONF)/failsafe_context |
1beba1c6 CP |
290 | @mkdir -p $(APPDIR) |
291 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 292 | |
2926f9c7 | 293 | $(APPDIR)/dbus_contexts: $(APPCONF)/dbus_contexts |
1beba1c6 CP |
294 | @mkdir -p $(APPDIR) |
295 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 296 | |
2926f9c7 | 297 | $(APPDIR)/users/root: $(APPCONF)/root_default_contexts |
1beba1c6 CP |
298 | @mkdir -p $(APPDIR)/users |
299 | $(QUIET) install -m 644 $< $@ | |
c9a26b3e | 300 | |
c592e52e CP |
301 | ######################################## |
302 | # | |
303 | # Install policy sources | |
304 | # | |
305 | install-src: | |
306 | rm -rf $(SRCPATH)/policy.old | |
307 | -mv $(SRCPATH)/policy $(SRCPATH)/policy.old | |
308 | mkdir -p $(SRCPATH)/policy | |
309 | cp -R . $(SRCPATH)/policy | |
310 | ||
102a59ba CP |
311 | ######################################## |
312 | # | |
313 | # Clean everything | |
314 | # | |
0fbe15dc | 315 | bare: clean |
12b559a4 | 316 | rm -f $(POLXML) |
254bbc7b CP |
317 | rm -f $(SUPPORT)/*.pyc |
318 | rm -f $(FCSORT) | |
19db6ba5 | 319 | rm -f $(MOD_CONF) |
4f9f30c8 | 320 | rm -f $(BOOLEANS) |
20030ef5 | 321 | rm -fR $(HTMLDIR) |
c767b14c CP |
322 | ifneq ($(GENERATED_TE),) |
323 | rm -f $(GENERATED_TE) | |
324 | endif | |
325 | ifneq ($(GENERATED_IF),) | |
326 | rm -f $(GENERATED_IF) | |
327 | endif | |
328 | ifneq ($(GENERATED_FC),) | |
329 | rm -f $(GENERATED_FC) | |
330 | endif | |
0fbe15dc | 331 | |
fb0a3a98 | 332 | .PHONY: install-src install-appconfig conf html bare |