blob: c24329a5284501568f0bdd6ddbb9aecffa78e169 [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001LOCAL_PATH:= $(call my-dir)
William Robertsf0e0a942012-08-27 15:41:15 -07002
Stephen Smalley2dd4e512012-01-04 12:33:27 -05003include $(CLEAR_VARS)
4
5# SELinux policy version.
Stephen Smalleyb4f17062015-03-13 10:03:52 -04006# Must be <= /sys/fs/selinux/policyvers reported by the Android kernel.
Stephen Smalley2dd4e512012-01-04 12:33:27 -05007# Must be within the compatibility range reported by checkpolicy -V.
Jeff Vander Stoep3a0ce492015-12-07 08:30:43 -08008POLICYVERS ?= 30
Stephen Smalley2dd4e512012-01-04 12:33:27 -05009
10MLS_SENS=1
11MLS_CATS=1024
12
Stephen Smalleyb4f17062015-03-13 10:03:52 -040013ifdef BOARD_SEPOLICY_REPLACE
14$(error BOARD_SEPOLICY_REPLACE is no longer supported; please remove from your BoardConfig.mk or other .mk file.)
15endif
16
17ifdef BOARD_SEPOLICY_IGNORE
18$(error BOARD_SEPOLICY_IGNORE is no longer supported; please remove from your BoardConfig.mk or other .mk file.)
19endif
Stephen Smalley5b340be2012-03-06 11:12:41 -050020
Stephen Smalley8e0ca882015-04-01 10:14:56 -040021ifdef BOARD_SEPOLICY_UNION
22$(warning BOARD_SEPOLICY_UNION is no longer required - all files found in BOARD_SEPOLICY_DIRS are implicitly unioned; please remove from your BoardConfig.mk or other .mk file.)
23endif
Robert Craig6b0ff472014-01-29 13:10:58 -050024
William Robertsd2185582015-07-16 11:28:02 -070025ifdef BOARD_SEPOLICY_M4DEFS
26LOCAL_ADDITIONAL_M4DEFS := $(addprefix -D, $(BOARD_SEPOLICY_M4DEFS))
27endif
28
dcashmancc39f632016-07-22 13:13:11 -070029# sepolicy is now divided into multiple portions:
30# public - policy exported on which non-platform policy developers may write
31# additional policy. types and attributes are versioned and included in
32# delivered non-platform policy, which is to be combined with platform policy.
33# private - platform-only policy required for platform functionality but which
34# is not exported to vendor policy developers and as such may not be assumed
35# to exist.
dcashman07791552016-12-07 11:27:47 -080036# mapping - This contains policy statements which map the attributes
dcashmancc39f632016-07-22 13:13:11 -070037# exposed in the public policy of previous versions to the concrete types used
38# in this policy to ensure that policy targeting attributes from public
39# policy from an older platform version continues to work.
40
dcashman2e00e632016-10-12 14:58:09 -070041# build process for device:
dcashmancc39f632016-07-22 13:13:11 -070042# 1) convert policies to CIL:
43# - private + public platform policy to CIL
44# - mapping file to CIL (should already be in CIL form)
45# - non-platform public policy to CIL
46# - non-platform public + private policy to CIL
47# 2) attributize policy
dcashmancc39f632016-07-22 13:13:11 -070048# - run script which takes non-platform public and non-platform combined
49# private + public policy and produces attributized and versioned
50# non-platform policy
51# 3) combine policy files
52# - combine mapping, platform and non-platform policy.
53# - compile output binary policy file
54
55PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/public
56PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private
dcashman2e00e632016-10-12 14:58:09 -070057REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask
58
59# TODO: move to README when doing the README update and finalizing versioning.
60# BOARD_SEPOLICY_VERS should contain the platform version identifier
61# corresponding to the platform on which the non-platform policy is to be
62# based. If unspecified, this will build against the current public platform
63# policy in tree.
64# BOARD_SEPOLICY_VERS_DIR should contain the public platform policy which
65# is associated with the given BOARD_SEPOLICY_VERS. The policy therein will be
66# versioned according to the BOARD_SEPOLICY_VERS identifier and included as
67# part of the non-platform policy to ensure removal of access in future
68# platform policy does not break non-platform policy.
69ifndef BOARD_SEPOLICY_VERS
70$(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version)
71BOARD_SEPOLICY_VERS := current
72BOARD_SEPOLICY_VERS_DIR := $(PLAT_PUBLIC_POLICY)
73else
74ifndef BOARD_SEPOLICY_VERS_DIR
75$(error BOARD_SEPOLICY_VERS_DIR not specified for versioned sepolicy.)
76endif
77endif
dcashmancc39f632016-07-22 13:13:11 -070078
79###########################################################
80# Compute policy files to be used in policy build.
81# $(1): files to include
82# $(2): directories in which to find files
83###########################################################
84
85define build_policy
86$(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))
87endef
William Roberts29d14682016-01-04 12:20:57 -080088
William Roberts49693f12016-01-04 12:20:57 -080089# Builds paths for all policy files found in BOARD_SEPOLICY_DIRS.
90# $(1): the set of policy name paths to build
dcashmancc39f632016-07-22 13:13:11 -070091build_device_policy = $(call build_policy, $(1), $(BOARD_SEPOLICY_DIRS))
William Roberts49693f12016-01-04 12:20:57 -080092
Richard Hainesc8801fe2015-12-11 10:39:19 +000093# Add a file containing only a newline in-between each policy configuration
94# 'contexts' file. This will allow OEM policy configuration files without a
95# final newline (0x0A) to be built correctly by the m4(1) macro processor.
96# $(1): the set of contexts file names.
97# $(2): the file containing only 0x0A.
98add_nl = $(foreach entry, $(1), $(subst $(entry), $(entry) $(2), $(entry)))
99
dcashman704741a2014-07-25 19:11:52 -0700100sepolicy_build_files := security_classes \
101 initial_sids \
102 access_vectors \
103 global_macros \
Nick Kralevicha17a2662014-11-05 15:30:41 -0800104 neverallow_macros \
dcashman704741a2014-07-25 19:11:52 -0700105 mls_macros \
dcashman2e00e632016-10-12 14:58:09 -0700106 mls_decl \
dcashman704741a2014-07-25 19:11:52 -0700107 mls \
108 policy_capabilities \
109 te_macros \
110 attributes \
Jeff Vander Stoepcbaa2b72015-12-22 10:39:34 -0800111 ioctl_defines \
Jeff Vander Stoepde9b5302015-06-05 15:28:55 -0700112 ioctl_macros \
dcashman704741a2014-07-25 19:11:52 -0700113 *.te \
dcashman2e00e632016-10-12 14:58:09 -0700114 roles_decl \
dcashman704741a2014-07-25 19:11:52 -0700115 roles \
116 users \
117 initial_sid_contexts \
118 fs_use \
119 genfs_contexts \
120 port_contexts
121
Ying Wang02fb5f32012-01-17 17:51:09 -0800122##################################
123include $(CLEAR_VARS)
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500124
Richard Hainesc8801fe2015-12-11 10:39:19 +0000125LOCAL_MODULE := sectxfile_nl
126LOCAL_MODULE_CLASS := ETC
127LOCAL_MODULE_TAGS := optional
128
129# Create a file containing newline only to add between context config files
130include $(BUILD_SYSTEM)/base_rules.mk
William Robertscb1ab982015-12-14 07:54:28 -0800131$(LOCAL_BUILT_MODULE):
Richard Hainesc8801fe2015-12-11 10:39:19 +0000132 @mkdir -p $(dir $@)
133 $(hide) echo > $@
134
135built_nl := $(LOCAL_BUILT_MODULE)
136
137#################################
138include $(CLEAR_VARS)
139
Ying Wang02fb5f32012-01-17 17:51:09 -0800140LOCAL_MODULE := sepolicy
141LOCAL_MODULE_CLASS := ETC
142LOCAL_MODULE_TAGS := optional
Ying Wang02fb5f32012-01-17 17:51:09 -0800143LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Douglas Leung5807d1d2016-07-28 15:49:31 -0700144LOCAL_TARGET_ARCH := $(TARGET_ARCH)
145
146# Set LOCAL_TARGET_ARCH to mips for mips and mips64.
147ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
148 LOCAL_TARGET_ARCH := mips
149endif
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500150
Ying Wang02fb5f32012-01-17 17:51:09 -0800151include $(BUILD_SYSTEM)/base_rules.mk
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500152
dcashman2e00e632016-10-12 14:58:09 -0700153# reqd_policy_mask - a policy.conf file which contains only the bare minimum
154# policy necessary to use checkpolicy. This bare-minimum policy needs to be
155# present in all policy.conf files, but should not necessarily be exported as
156# part of the public policy. The rules generated by reqd_policy_mask will allow
157# the compilation of public policy and subsequent removal of CIL policy that
158# should not be exported.
159
160reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
161$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
162$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
163$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
164$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
165 @mkdir -p $(dir $@)
166 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
167 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
168 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
169 -s $^ > $@
170
171reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
172$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
173 @mkdir -p $(dir $@)
174 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
175
176# plat_pub_policy - policy that will be exported to be a part of non-platform
177# policy corresponding to this platform version. This is a limited subset of
178# policy that would not compile in checkpolicy on its own. To get around this
179# limitation, add only the required files from private policy, which will
180# generate CIL policy that will then be filtered out by the reqd_policy_mask.
181plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
182$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
183$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
184$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
185$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
186$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY))
187 @mkdir -p $(dir $@)
188 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
189 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
190 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
191 -s $^ > $@
192
193plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
194$(plat_pub_policy.cil): $(plat_pub_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
195 @mkdir -p $(dir $@)
196 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
197
198pruned_plat_pub_policy.cil := $(intermediates)/pruned_plat_pub_policy.cil
199$(pruned_plat_pub_policy.cil): $(reqd_policy_mask.cil) $(plat_pub_policy.cil)
200 @mkdir -p $(dir $@)
201 $(hide) grep -Fxv -f $^ > $@
202
203# plat_policy.conf - A combination of the private and public platform policy
204# which will ship with the device. The platform will always reflect the most
205# recent platform version and is not currently being attributized.
206plat_policy.conf := $(intermediates)/plat_policy.conf
207$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
208$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
209$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
210$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700211$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
212 @mkdir -p $(dir $@)
213 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
214 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
215 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700216 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500217 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500218 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
dcashmancc39f632016-07-22 13:13:11 -0700219 -s $^ > $@
220 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
221
dcashman2e00e632016-10-12 14:58:09 -0700222plat_policy.cil := $(intermediates)/plat_policy.cil
223$(plat_policy.cil): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
224 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800225 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
dcashmancc39f632016-07-22 13:13:11 -0700226
dcashman2e00e632016-10-12 14:58:09 -0700227# nonplat_policy.conf - A combination of the non-platform private and the
228# exported platform policy associated with the version the non-platform policy
229# targets. This needs attributization and to be combined with the
230# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
231# of the reqd_policy_mask files from private policy in order to use checkpolicy.
232nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
233$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
234$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
235$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
236$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
237$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY) $(BOARD_SEPOLICY_DIRS))
Ying Wang02fb5f32012-01-17 17:51:09 -0800238 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700239 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
240 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800241 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700242 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500243 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500244 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Douglas Leung5807d1d2016-07-28 15:49:31 -0700245 -D target_arch=$(LOCAL_TARGET_ARCH) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800246 -s $^ > $@
Robert Craig65d4f442013-03-27 06:30:25 -0400247 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500248
dcashman2e00e632016-10-12 14:58:09 -0700249nonplat_policy.cil := $(intermediates)/nonplat_policy.cil
250$(nonplat_policy.cil): $(nonplat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
Ying Wang02fb5f32012-01-17 17:51:09 -0800251 @mkdir -p $(dir $@)
dcashman2e00e632016-10-12 14:58:09 -0700252 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
253
254pruned_nonplat_policy.cil := $(intermediates)/pruned_nonplat_policy.cil
255$(pruned_nonplat_policy.cil): $(reqd_policy_mask.cil) $(nonplat_policy.cil)
256 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800257 $(hide) grep -Fxv -f $^ > $@
dcashman2e00e632016-10-12 14:58:09 -0700258
259vers_nonplat_policy.cil := $(intermediates)/vers_nonplat_policy.cil
260$(vers_nonplat_policy.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
261$(vers_nonplat_policy.cil) : PRIVATE_TGT_POL := $(pruned_nonplat_policy.cil)
262$(vers_nonplat_policy.cil) : $(pruned_plat_pub_policy.cil) $(pruned_nonplat_policy.cil) \
263$(HOST_OUT_EXECUTABLES)/version_policy
264 @mkdir -p $(dir $@)
265 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
266
267# auto-generate the mapping file for current platform policy, since it needs to
268# track platform policy development
269current_mapping.cil := $(intermediates)/mapping/current.cil
270$(current_mapping.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
271$(current_mapping.cil) : $(pruned_plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
272 @mkdir -p $(dir $@)
273 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
274
275ifeq ($(BOARD_SEPOLICY_VERS), current)
276mapping.cil := $(current_mapping.cil)
277else
278mapping.cil := $(addsuffix /$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)/mapping)
279endif
280
281all_cil_files := \
282 $(plat_policy.cil) \
283 $(vers_nonplat_policy.cil) \
284 $(mapping.cil)
285
286$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
287$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
288 @mkdir -p $(dir $@)
289 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800290 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
291 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
292 echo "==========" 1>&2; \
293 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
294 echo "List of invalid domains:" 1>&2; \
295 cat $@.permissivedomains 1>&2; \
296 exit 1; \
297 fi
298 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800299
Ying Wangd8b122c2012-10-25 19:01:31 -0700300built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700301reqd_policy_mask.conf :=
302reqd_policy_mask.cil :=
303plat_pub_policy.conf :=
304plat_pub_policy.cil :=
305pruned_plat_pub_policy.cil :=
306plat_policy.conf :=
307plat_policy.cil :=
308nonplat_policy.conf :=
309nonplat_policy.cil :=
310pruned_nonplat_policy.cil :=
311vers_nonplat_policy.cil :=
312current_mapping.cil :=
313mapping.cil :=
314all_cil_files :=
Ying Wang02fb5f32012-01-17 17:51:09 -0800315sepolicy_policy.conf :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400316
Stephen Smalleye60723a2014-05-29 16:40:15 -0400317##################################
318include $(CLEAR_VARS)
319
320LOCAL_MODULE := sepolicy.recovery
321LOCAL_MODULE_CLASS := ETC
322LOCAL_MODULE_TAGS := eng
323
324include $(BUILD_SYSTEM)/base_rules.mk
325
326sepolicy_policy_recovery.conf := $(intermediates)/policy_recovery.conf
327$(sepolicy_policy_recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
328$(sepolicy_policy_recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
William Robertsd2185582015-07-16 11:28:02 -0700329$(sepolicy_policy_recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
dcashmancc39f632016-07-22 13:13:11 -0700330$(sepolicy_policy_recovery.conf): $(call build_policy, $(sepolicy_build_files), \
331$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Stephen Smalleye60723a2014-05-29 16:40:15 -0400332 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700333 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
334 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400335 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700336 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500337 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500338 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400339 -D target_recovery=true \
340 -s $^ > $@
341
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800342$(LOCAL_BUILT_MODULE): $(sepolicy_policy_recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Stephen Smalleye60723a2014-05-29 16:40:15 -0400343 @mkdir -p $(dir $@)
Nick Kralevich6ef10bd2016-02-29 16:59:33 -0800344 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@.tmp $< > /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800345 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
346 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
347 echo "==========" 1>&2; \
348 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
349 echo "List of invalid domains:" 1>&2; \
350 cat $@.permissivedomains 1>&2; \
351 exit 1; \
352 fi
353 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400354
355built_sepolicy_recovery := $(LOCAL_BUILT_MODULE)
356sepolicy_policy_recovery.conf :=
357
dcashman704741a2014-07-25 19:11:52 -0700358##################################
359include $(CLEAR_VARS)
360
361LOCAL_MODULE := general_sepolicy.conf
362LOCAL_MODULE_CLASS := ETC
363LOCAL_MODULE_TAGS := tests
364
365include $(BUILD_SYSTEM)/base_rules.mk
366
dcashman704741a2014-07-25 19:11:52 -0700367$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
368$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
dcashmancc39f632016-07-22 13:13:11 -0700369$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
370$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
dcashman704741a2014-07-25 19:11:52 -0700371 mkdir -p $(dir $@)
372 $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
373 -D target_build_variant=user \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700374 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500375 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500376 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
dcashman704741a2014-07-25 19:11:52 -0700377 -s $^ > $@
378 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
379
William Robertsb8769932015-06-29 16:31:23 -0700380built_general_sepolicy.conf := $(LOCAL_BUILT_MODULE)
dcashman704741a2014-07-25 19:11:52 -0700381exp_sepolicy_build_files :=
382
383##################################
Stephen Smalley01a58af2012-10-02 12:46:37 -0400384include $(CLEAR_VARS)
385
William Robertsb8769932015-06-29 16:31:23 -0700386LOCAL_MODULE := sepolicy.general
387LOCAL_MODULE_CLASS := ETC
388LOCAL_MODULE_TAGS := tests
389
390include $(BUILD_SYSTEM)/base_rules.mk
391
392$(LOCAL_BUILT_MODULE): PRIVATE_BUILT_SEPOLICY.CONF := $(built_general_sepolicy.conf)
393$(LOCAL_BUILT_MODULE): $(built_general_sepolicy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
394 @mkdir -p $(dir $@)
Nick Kralevich6ef10bd2016-02-29 16:59:33 -0800395 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@ $(PRIVATE_BUILT_SEPOLICY.CONF) > /dev/null
William Robertsb8769932015-06-29 16:31:23 -0700396
397built_general_sepolicy := $(LOCAL_BUILT_MODULE)
398##################################
399include $(CLEAR_VARS)
400
Richard Hainesc2d01912015-08-06 17:43:52 +0100401LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800402LOCAL_MODULE_CLASS := ETC
403LOCAL_MODULE_TAGS := optional
404LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
405
Stephen Smalley5b340be2012-03-06 11:12:41 -0500406include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800407
William Roberts49693f12016-01-04 12:20:57 -0800408# The file_contexts.bin is built in the following way:
409# 1. Collect all file_contexts files in THIS repository and process them with
410# m4 into a tmp file called file_contexts.local.tmp.
411# 2. Collect all device specific file_contexts files and process them with m4
412# into a tmp file called file_contexts.device.tmp.
413# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
414# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
415# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
416# file_contexts.concat.tmp.
417# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
418# file_contexts.bin.
419#
420# Note: That a newline file is placed between each file_context file found to
421# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800422
dcashmancc39f632016-07-22 13:13:11 -0700423local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
William Roberts49693f12016-01-04 12:20:57 -0800424ifneq ($(filter address,$(SANITIZE_TARGET)),)
dcashmancc39f632016-07-22 13:13:11 -0700425 local_fc_files := $(local_fc_files) $(PLAT_PRIVATE_POLICY)/file_contexts_asan
William Roberts49693f12016-01-04 12:20:57 -0800426endif
427local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
428
429file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
430$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500431 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800432 $(hide) m4 -s $^ > $@
433
434device_fc_files := $(call build_device_policy, file_contexts)
435device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
436
437file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
438$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
439$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
440 @mkdir -p $(dir $@)
441 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
442
443file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
444$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
445$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
446 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800447 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800448 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
449
450file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
451$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
452 @mkdir -p $(dir $@)
453 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500454
William Roberts3746a0a2015-09-25 10:18:44 -0700455$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800456$(LOCAL_BUILT_MODULE): $(file_contexts.concat.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/sefcontext_compile $(HOST_OUT_EXECUTABLES)/checkfc
Richard Hainesc2d01912015-08-06 17:43:52 +0100457 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800458 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100459 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
460
Robert Craig8b7545b2014-03-20 09:35:08 -0400461built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800462local_fc_files :=
463local_fcfiles_with_nl :=
464device_fc_files :=
465device_fcfiles_with_nl :=
466file_contexts.concat.tmp :=
467file_contexts.device.sorted.tmp :=
468file_contexts.device.tmp :=
469file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700470
Ying Wang02fb5f32012-01-17 17:51:09 -0800471##################################
472include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400473
Richard Hainesc2d01912015-08-06 17:43:52 +0100474LOCAL_MODULE := general_file_contexts.bin
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400475LOCAL_MODULE_CLASS := ETC
476LOCAL_MODULE_TAGS := tests
477
478include $(BUILD_SYSTEM)/base_rules.mk
479
Richard Hainesc2d01912015-08-06 17:43:52 +0100480general_file_contexts.tmp := $(intermediates)/general_file_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700481$(general_file_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, file_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400482 @mkdir -p $(dir $@)
483 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400484
William Roberts3746a0a2015-09-25 10:18:44 -0700485$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
486$(LOCAL_BUILT_MODULE): $(general_file_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/sefcontext_compile $(HOST_OUT_EXECUTABLES)/checkfc
Richard Hainesc2d01912015-08-06 17:43:52 +0100487 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800488 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100489 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
490
491general_file_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400492
493##################################
494include $(CLEAR_VARS)
Ying Wang02fb5f32012-01-17 17:51:09 -0800495LOCAL_MODULE := seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800496LOCAL_MODULE_CLASS := ETC
497LOCAL_MODULE_TAGS := optional
498LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
499
William Roberts171a0622012-08-16 10:55:05 -0700500include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800501
dcashmancc39f632016-07-22 13:13:11 -0700502all_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts171a0622012-08-16 10:55:05 -0700503
Ying Wangd8b122c2012-10-25 19:01:31 -0700504$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts81e1f902015-06-03 21:57:47 -0700505$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(all_sc_files)
506$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(all_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700507 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700508 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800509
Robert Craig8b7545b2014-03-20 09:35:08 -0400510built_sc := $(LOCAL_BUILT_MODULE)
William Roberts81e1f902015-06-03 21:57:47 -0700511all_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400512
Ying Wang02fb5f32012-01-17 17:51:09 -0800513##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400514include $(CLEAR_VARS)
Stephen Smalley37712872015-03-12 15:46:36 -0400515LOCAL_MODULE := general_seapp_contexts
516LOCAL_MODULE_CLASS := ETC
517LOCAL_MODULE_TAGS := tests
518
519include $(BUILD_SYSTEM)/base_rules.mk
520
dcashmancc39f632016-07-22 13:13:11 -0700521all_sc_files := $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
Stephen Smalley37712872015-03-12 15:46:36 -0400522
William Robertsb8769932015-06-29 16:31:23 -0700523$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
William Roberts81e1f902015-06-03 21:57:47 -0700524$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILE := $(all_sc_files)
William Robertsb8769932015-06-29 16:31:23 -0700525$(LOCAL_BUILT_MODULE): $(built_general_sepolicy) $(all_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
Stephen Smalley37712872015-03-12 15:46:36 -0400526 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700527 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILE)
Stephen Smalley37712872015-03-12 15:46:36 -0400528
William Roberts81e1f902015-06-03 21:57:47 -0700529all_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400530
531##################################
532include $(CLEAR_VARS)
William Roberts4ee71312015-06-25 11:59:30 -0700533LOCAL_MODULE := general_seapp_neverallows
534LOCAL_MODULE_CLASS := ETC
535LOCAL_MODULE_TAGS := tests
536
537include $(BUILD_SYSTEM)/base_rules.mk
538
dcashmancc39f632016-07-22 13:13:11 -0700539$(LOCAL_BUILT_MODULE): $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
William Roberts4ee71312015-06-25 11:59:30 -0700540 @mkdir -p $(dir $@)
541 - $(hide) grep -ie '^neverallow' $< > $@
542
William Roberts4ee71312015-06-25 11:59:30 -0700543
544##################################
545include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400546
547LOCAL_MODULE := property_contexts
548LOCAL_MODULE_CLASS := ETC
549LOCAL_MODULE_TAGS := optional
550LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
551
552include $(BUILD_SYSTEM)/base_rules.mk
553
dcashmancc39f632016-07-22 13:13:11 -0700554all_pc_files := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Richard Hainesc8801fe2015-12-11 10:39:19 +0000555all_pcfiles_with_nl := $(call add_nl, $(all_pc_files), $(built_nl))
William Roberts6aabc1c2015-07-30 11:44:26 -0700556
William Robertsdcffd2b2015-09-29 13:52:37 -0700557property_contexts.tmp := $(intermediates)/property_contexts.tmp
Richard Hainesc8801fe2015-12-11 10:39:19 +0000558$(property_contexts.tmp): PRIVATE_PC_FILES := $(all_pcfiles_with_nl)
William Robertsdcffd2b2015-09-29 13:52:37 -0700559$(property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
William Roberts46749752015-12-28 15:26:20 -0800560$(property_contexts.tmp): $(all_pcfiles_with_nl)
William Roberts7f81b332015-09-29 13:52:37 -0700561 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000562 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700563
564
565$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts371918c2016-04-06 11:40:08 -0700566$(LOCAL_BUILT_MODULE): $(property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700567 @mkdir -p $(dir $@)
William Roberts371918c2016-04-06 11:40:08 -0700568 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800569 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400570
Robert Craig8b7545b2014-03-20 09:35:08 -0400571built_pc := $(LOCAL_BUILT_MODULE)
William Roberts6aabc1c2015-07-30 11:44:26 -0700572all_pc_files :=
William Roberts46749752015-12-28 15:26:20 -0800573all_pcfiles_with_nl :=
William Robertsdcffd2b2015-09-29 13:52:37 -0700574property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400575
Stephen Smalley124720a2012-04-04 10:11:16 -0400576##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700577include $(CLEAR_VARS)
578
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400579LOCAL_MODULE := general_property_contexts
580LOCAL_MODULE_CLASS := ETC
581LOCAL_MODULE_TAGS := tests
582
Stephen Smalleyc9361732015-03-13 09:36:57 -0400583include $(BUILD_SYSTEM)/base_rules.mk
584
William Robertsdcffd2b2015-09-29 13:52:37 -0700585general_property_contexts.tmp := $(intermediates)/general_property_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700586$(general_property_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, property_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400587 @mkdir -p $(dir $@)
588 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400589
William Robertsdcffd2b2015-09-29 13:52:37 -0700590$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
591$(LOCAL_BUILT_MODULE): $(general_property_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
592 @mkdir -p $(dir $@)
William Roberts371918c2016-04-06 11:40:08 -0700593 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800594 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700595
596general_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400597
598##################################
599include $(CLEAR_VARS)
600
Riley Spahnf90c41f2014-06-05 15:52:02 -0700601LOCAL_MODULE := service_contexts
602LOCAL_MODULE_CLASS := ETC
603LOCAL_MODULE_TAGS := optional
604LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
605
606include $(BUILD_SYSTEM)/base_rules.mk
607
dcashmancc39f632016-07-22 13:13:11 -0700608all_svc_files := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Richard Hainesc8801fe2015-12-11 10:39:19 +0000609all_svcfiles_with_nl := $(call add_nl, $(all_svc_files), $(built_nl))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700610
William Roberts7fc865a2015-09-29 14:17:38 -0700611service_contexts.tmp := $(intermediates)/service_contexts.tmp
Richard Hainesc8801fe2015-12-11 10:39:19 +0000612$(service_contexts.tmp): PRIVATE_SVC_FILES := $(all_svcfiles_with_nl)
William Roberts7fc865a2015-09-29 14:17:38 -0700613$(service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
William Roberts46749752015-12-28 15:26:20 -0800614$(service_contexts.tmp): $(all_svcfiles_with_nl)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700615 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700616 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700617
618$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
619$(LOCAL_BUILT_MODULE): $(service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
620 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700621 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800622 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700623
624built_svc := $(LOCAL_BUILT_MODULE)
William Roberts6aabc1c2015-07-30 11:44:26 -0700625all_svc_files :=
William Roberts46749752015-12-28 15:26:20 -0800626all_svcfiles_with_nl :=
William Roberts7fc865a2015-09-29 14:17:38 -0700627service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700628
629##################################
rpcraigb19665c2012-07-30 09:33:03 -0400630include $(CLEAR_VARS)
631
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400632LOCAL_MODULE := general_service_contexts
633LOCAL_MODULE_CLASS := ETC
634LOCAL_MODULE_TAGS := tests
635
636include $(BUILD_SYSTEM)/base_rules.mk
637
William Roberts7fc865a2015-09-29 14:17:38 -0700638general_service_contexts.tmp := $(intermediates)/general_service_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700639$(general_service_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, service_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400640 @mkdir -p $(dir $@)
641 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400642
William Roberts7fc865a2015-09-29 14:17:38 -0700643$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
644$(LOCAL_BUILT_MODULE): $(general_service_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
645 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700646 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800647 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700648
649general_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400650
651##################################
652include $(CLEAR_VARS)
653
Robert Craig7f2392e2013-03-27 08:35:39 -0400654LOCAL_MODULE := mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -0400655LOCAL_MODULE_CLASS := ETC
656LOCAL_MODULE_TAGS := optional
657LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
658
William Roberts2c8a55d2012-11-30 14:59:09 -0800659include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -0400660
Geremy Condracd4104e2013-03-26 18:19:12 +0000661# Build keys.conf
662mac_perms_keys.tmp := $(intermediates)/keys.tmp
William Robertsd2185582015-07-16 11:28:02 -0700663$(mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
dcashmancc39f632016-07-22 13:13:11 -0700664$(mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Geremy Condracd4104e2013-03-26 18:19:12 +0000665 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700666 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +0000667
dcashmancc39f632016-07-22 13:13:11 -0700668all_mac_perms_files := $(call build_policy, $(LOCAL_MODULE), $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
rpcraigb19665c2012-07-30 09:33:03 -0400669
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900670# Should be synced with keys.conf.
671all_keys := platform media shared testkey
672all_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
673
William Roberts6aabc1c2015-07-30 11:44:26 -0700674$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_mac_perms_files)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900675$(LOCAL_BUILT_MODULE): $(mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py $(all_mac_perms_files) $(all_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +0000676 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -0700677 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -0700678 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +0000679
Robert Craig7f2392e2013-03-27 08:35:39 -0400680mac_perms_keys.tmp :=
William Roberts6aabc1c2015-07-30 11:44:26 -0700681all_mac_perms_files :=
682
rpcraigb19665c2012-07-30 09:33:03 -0400683##################################
Robert Craig8b7545b2014-03-20 09:35:08 -0400684include $(CLEAR_VARS)
685
686LOCAL_MODULE := selinux_version
687LOCAL_MODULE_CLASS := ETC
688LOCAL_MODULE_TAGS := optional
689LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
690
691include $(BUILD_SYSTEM)/base_rules.mk
William Robertsda52e852015-06-27 07:22:34 -0700692$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(built_pc) $(built_fc) $(built_sc) $(built_svc)
Robert Craig8b7545b2014-03-20 09:35:08 -0400693 @mkdir -p $(dir $@)
Colin Cross29a463d2015-07-17 13:08:41 -0700694 $(hide) echo -n $(BUILD_FINGERPRINT_FROM_FILE) > $@
Robert Craig8b7545b2014-03-20 09:35:08 -0400695
696##################################
rpcraig47cd3962012-10-17 21:09:52 -0400697
698build_policy :=
William Roberts49693f12016-01-04 12:20:57 -0800699build_device_policy :=
dcashman704741a2014-07-25 19:11:52 -0700700sepolicy_build_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400701built_sepolicy :=
William Roberts50a478e2015-12-28 16:19:54 -0800702built_sepolicy_recovery :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400703built_sc :=
704built_fc :=
705built_pc :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700706built_svc :=
William Robertsb8769932015-06-29 16:31:23 -0700707built_general_sepolicy :=
708built_general_sepolicy.conf :=
Richard Hainesc8801fe2015-12-11 10:39:19 +0000709built_nl :=
William Roberts50a478e2015-12-28 16:19:54 -0800710add_nl :=
Alice Chucdfb06f2012-11-01 11:33:04 -0700711
712include $(call all-makefiles-under,$(LOCAL_PATH))