blob: cdfb554224743a9c79acf29c72ba18be07841f66 [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.
Alex Klyubin55961722017-01-30 18:44:59 -080036# vendor - vendor-only policy required for vendor functionality. This policy can
37# reference the public policy but cannot reference the private policy. This
38# policy is for components which are produced from the core/non-vendor tree and
39# placed into a vendor partition.
dcashman07791552016-12-07 11:27:47 -080040# mapping - This contains policy statements which map the attributes
dcashmancc39f632016-07-22 13:13:11 -070041# exposed in the public policy of previous versions to the concrete types used
42# in this policy to ensure that policy targeting attributes from public
43# policy from an older platform version continues to work.
44
dcashman2e00e632016-10-12 14:58:09 -070045# build process for device:
dcashmancc39f632016-07-22 13:13:11 -070046# 1) convert policies to CIL:
47# - private + public platform policy to CIL
48# - mapping file to CIL (should already be in CIL form)
49# - non-platform public policy to CIL
50# - non-platform public + private policy to CIL
51# 2) attributize policy
dcashmancc39f632016-07-22 13:13:11 -070052# - run script which takes non-platform public and non-platform combined
53# private + public policy and produces attributized and versioned
54# non-platform policy
55# 3) combine policy files
56# - combine mapping, platform and non-platform policy.
57# - compile output binary policy file
58
59PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/public
60PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private
Alex Klyubin55961722017-01-30 18:44:59 -080061PLAT_VENDOR_POLICY := $(LOCAL_PATH)/vendor
dcashman2e00e632016-10-12 14:58:09 -070062REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask
63
64# TODO: move to README when doing the README update and finalizing versioning.
65# BOARD_SEPOLICY_VERS should contain the platform version identifier
66# corresponding to the platform on which the non-platform policy is to be
67# based. If unspecified, this will build against the current public platform
68# policy in tree.
69# BOARD_SEPOLICY_VERS_DIR should contain the public platform policy which
70# is associated with the given BOARD_SEPOLICY_VERS. The policy therein will be
71# versioned according to the BOARD_SEPOLICY_VERS identifier and included as
72# part of the non-platform policy to ensure removal of access in future
73# platform policy does not break non-platform policy.
74ifndef BOARD_SEPOLICY_VERS
75$(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version)
76BOARD_SEPOLICY_VERS := current
77BOARD_SEPOLICY_VERS_DIR := $(PLAT_PUBLIC_POLICY)
78else
79ifndef BOARD_SEPOLICY_VERS_DIR
80$(error BOARD_SEPOLICY_VERS_DIR not specified for versioned sepolicy.)
81endif
82endif
dcashmancc39f632016-07-22 13:13:11 -070083
84###########################################################
85# Compute policy files to be used in policy build.
86# $(1): files to include
87# $(2): directories in which to find files
88###########################################################
89
90define build_policy
91$(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))
92endef
William Roberts29d14682016-01-04 12:20:57 -080093
William Roberts49693f12016-01-04 12:20:57 -080094# Builds paths for all policy files found in BOARD_SEPOLICY_DIRS.
95# $(1): the set of policy name paths to build
Alex Klyubin55961722017-01-30 18:44:59 -080096build_device_policy = $(call build_policy, $(1), $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts49693f12016-01-04 12:20:57 -080097
Richard Hainesc8801fe2015-12-11 10:39:19 +000098# Add a file containing only a newline in-between each policy configuration
99# 'contexts' file. This will allow OEM policy configuration files without a
100# final newline (0x0A) to be built correctly by the m4(1) macro processor.
101# $(1): the set of contexts file names.
102# $(2): the file containing only 0x0A.
103add_nl = $(foreach entry, $(1), $(subst $(entry), $(entry) $(2), $(entry)))
104
dcashman704741a2014-07-25 19:11:52 -0700105sepolicy_build_files := security_classes \
106 initial_sids \
107 access_vectors \
108 global_macros \
Nick Kralevicha17a2662014-11-05 15:30:41 -0800109 neverallow_macros \
dcashman704741a2014-07-25 19:11:52 -0700110 mls_macros \
dcashman2e00e632016-10-12 14:58:09 -0700111 mls_decl \
dcashman704741a2014-07-25 19:11:52 -0700112 mls \
113 policy_capabilities \
114 te_macros \
115 attributes \
Jeff Vander Stoepcbaa2b72015-12-22 10:39:34 -0800116 ioctl_defines \
Jeff Vander Stoepde9b5302015-06-05 15:28:55 -0700117 ioctl_macros \
dcashman704741a2014-07-25 19:11:52 -0700118 *.te \
dcashman2e00e632016-10-12 14:58:09 -0700119 roles_decl \
dcashman704741a2014-07-25 19:11:52 -0700120 roles \
121 users \
122 initial_sid_contexts \
123 fs_use \
124 genfs_contexts \
125 port_contexts
126
Dan Cashman1c040272016-12-15 15:28:44 -0800127my_target_arch := $(TARGET_ARCH)
128ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
129 my_target_arch := mips
130endif
131
Ying Wang02fb5f32012-01-17 17:51:09 -0800132##################################
dcashman2e00e632016-10-12 14:58:09 -0700133# reqd_policy_mask - a policy.conf file which contains only the bare minimum
134# policy necessary to use checkpolicy. This bare-minimum policy needs to be
135# present in all policy.conf files, but should not necessarily be exported as
136# part of the public policy. The rules generated by reqd_policy_mask will allow
137# the compilation of public policy and subsequent removal of CIL policy that
138# should not be exported.
139
140reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
141$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
142$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800143$(reqd_policy_mask.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashman2e00e632016-10-12 14:58:09 -0700144$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
145$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
146 @mkdir -p $(dir $@)
147 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
148 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
149 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800150 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800151 -D target_arch=$(PRIVATE_TGT_ARCH) \
dcashman2e00e632016-10-12 14:58:09 -0700152 -s $^ > $@
153
154reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
155$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
156 @mkdir -p $(dir $@)
157 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
158
dcashman1faa6442016-11-28 07:20:28 -0800159reqd_policy_mask.conf :=
160
161##################################
dcashman2e00e632016-10-12 14:58:09 -0700162# plat_pub_policy - policy that will be exported to be a part of non-platform
163# policy corresponding to this platform version. This is a limited subset of
164# policy that would not compile in checkpolicy on its own. To get around this
165# limitation, add only the required files from private policy, which will
166# generate CIL policy that will then be filtered out by the reqd_policy_mask.
167plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
168$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
169$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800170$(plat_pub_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashman2e00e632016-10-12 14:58:09 -0700171$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
172$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
173$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY))
174 @mkdir -p $(dir $@)
175 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
176 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
177 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800178 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800179 -D target_arch=$(PRIVATE_TGT_ARCH) \
dcashman2e00e632016-10-12 14:58:09 -0700180 -s $^ > $@
181
182plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800183$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
184$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
185$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700186 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800187 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
188 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700189
dcashman1faa6442016-11-28 07:20:28 -0800190plat_pub_policy.conf :=
Dan Cashman1c040272016-12-15 15:28:44 -0800191
dcashman1faa6442016-11-28 07:20:28 -0800192##################################
193include $(CLEAR_VARS)
194
195LOCAL_MODULE := sectxfile_nl
196LOCAL_MODULE_CLASS := ETC
197LOCAL_MODULE_TAGS := optional
198
199# Create a file containing newline only to add between context config files
200include $(BUILD_SYSTEM)/base_rules.mk
201$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700202 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800203 $(hide) echo > $@
204
205built_nl := $(LOCAL_BUILT_MODULE)
206
207#################################
208include $(CLEAR_VARS)
209
210LOCAL_MODULE := plat_sepolicy.cil
211LOCAL_MODULE_CLASS := ETC
212LOCAL_MODULE_TAGS := optional
213LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman1faa6442016-11-28 07:20:28 -0800214
215include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700216
217# plat_policy.conf - A combination of the private and public platform policy
218# which will ship with the device. The platform will always reflect the most
219# recent platform version and is not currently being attributized.
220plat_policy.conf := $(intermediates)/plat_policy.conf
221$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
222$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800223$(plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashman2e00e632016-10-12 14:58:09 -0700224$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
225$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700226$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
227 @mkdir -p $(dir $@)
228 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
229 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
230 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500231 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800232 -D target_arch=$(PRIVATE_TGT_ARCH) \
dcashmancc39f632016-07-22 13:13:11 -0700233 -s $^ > $@
234 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
235
dcashman1faa6442016-11-28 07:20:28 -0800236plat_policy_nvr := $(intermediates)/plat_policy_nvr.cil
237$(plat_policy_nvr): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
dcashman2e00e632016-10-12 14:58:09 -0700238 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800239 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
dcashmancc39f632016-07-22 13:13:11 -0700240
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800241$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(plat_policy_nvr)
242$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(plat_policy_nvr)
dcashman1faa6442016-11-28 07:20:28 -0800243 @mkdir -p $(dir $@)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800244 # Strip out neverallow statements. They aren't needed on-device and their presence
245 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
246 # sailfish-eng).
247 grep -v '^(neverallow' $(PRIVATE_CIL_FILES) > $@
248 # Confirm that the resulting policy compiles
249 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) $@ -o /dev/null -f /dev/null
dcashman1faa6442016-11-28 07:20:28 -0800250
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800251built_plat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800252plat_policy.conf :=
253
254#################################
255include $(CLEAR_VARS)
256
257LOCAL_MODULE := mapping_sepolicy.cil
258LOCAL_MODULE_CLASS := ETC
259LOCAL_MODULE_TAGS := optional
260LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman1faa6442016-11-28 07:20:28 -0800261
262include $(BUILD_SYSTEM)/base_rules.mk
263
264# auto-generate the mapping file for current platform policy, since it needs to
265# track platform policy development
266current_mapping.cil := $(intermediates)/mapping/current.cil
267$(current_mapping.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
268$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
269 @mkdir -p $(dir $@)
270 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
271
272ifeq ($(BOARD_SEPOLICY_VERS), current)
273mapping_policy_nvr := $(current_mapping.cil)
274else
275mapping_policy_nvr := $(addsuffix /$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)/mapping)
276endif
277
278$(LOCAL_BUILT_MODULE): $(mapping_policy_nvr)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800279 # Strip out neverallow statements. They aren't needed on-device and their presence
280 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
281 # sailfish-eng).
282 grep -v '^(neverallow' $< > $@
dcashman1faa6442016-11-28 07:20:28 -0800283
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800284built_mapping_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800285current_mapping.cil :=
286
287#################################
288include $(CLEAR_VARS)
289
290LOCAL_MODULE := nonplat_sepolicy.cil
291LOCAL_MODULE_CLASS := ETC
292LOCAL_MODULE_TAGS := optional
293LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman1faa6442016-11-28 07:20:28 -0800294
295include $(BUILD_SYSTEM)/base_rules.mk
296
Alex Klyubin55961722017-01-30 18:44:59 -0800297# nonplat_policy.conf - A combination of the non-platform private, vendor and
298# the exported platform policy associated with the version the non-platform
299# policy targets. This needs attributization and to be combined with the
dcashman2e00e632016-10-12 14:58:09 -0700300# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
301# of the reqd_policy_mask files from private policy in order to use checkpolicy.
302nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
303$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
304$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800305$(nonplat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashman2e00e632016-10-12 14:58:09 -0700306$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
307$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Alex Klyubin55961722017-01-30 18:44:59 -0800308$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Ying Wang02fb5f32012-01-17 17:51:09 -0800309 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700310 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
311 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800312 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500313 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800314 -D target_arch=$(PRIVATE_TGT_ARCH) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800315 -s $^ > $@
Robert Craig65d4f442013-03-27 06:30:25 -0400316 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500317
dcashman1faa6442016-11-28 07:20:28 -0800318nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
319$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
320$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
321$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
322$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800323 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800324 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
325 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700326
dcashman1faa6442016-11-28 07:20:28 -0800327nonplat_policy_nvr := $(intermediates)/nonplat_policy_nvr.cil
328$(nonplat_policy_nvr) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
329$(nonplat_policy_nvr) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
330$(nonplat_policy_nvr) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
dcashman2e00e632016-10-12 14:58:09 -0700331$(HOST_OUT_EXECUTABLES)/version_policy
332 @mkdir -p $(dir $@)
333 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
334
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800335$(LOCAL_BUILT_MODULE): PRIVATE_NONPLAT_CIL_FILES := $(nonplat_policy_nvr)
336$(LOCAL_BUILT_MODULE): PRIVATE_DEP_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
337$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(nonplat_policy_nvr) $(built_plat_cil) \
338$(built_mapping_cil)
dcashman2e00e632016-10-12 14:58:09 -0700339 @mkdir -p $(dir $@)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800340 # Strip out neverallow statements. They aren't needed on-device and their presence
341 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
342 # sailfish-eng).
343 grep -v '^(neverallow' $(PRIVATE_NONPLAT_CIL_FILES) > $@
344 # Confirm that the resulting policy compiles combined with platform and mapping policies
345 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) \
346 $(PRIVATE_DEP_CIL_FILES) $@ -o /dev/null -f /dev/null
dcashman2e00e632016-10-12 14:58:09 -0700347
dcashman1faa6442016-11-28 07:20:28 -0800348nonplat_policy.conf :=
349nonplat_policy_raw :=
350
351#################################
352include $(CLEAR_VARS)
Dan Cashman1c040272016-12-15 15:28:44 -0800353# build this target so that we can still perform neverallow checks
dcashman1faa6442016-11-28 07:20:28 -0800354
355LOCAL_MODULE := sepolicy
356LOCAL_MODULE_CLASS := ETC
357LOCAL_MODULE_TAGS := optional
Daniel Cashman65d01342016-12-17 00:53:26 +0000358LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman2e00e632016-10-12 14:58:09 -0700359
dcashman1faa6442016-11-28 07:20:28 -0800360include $(BUILD_SYSTEM)/base_rules.mk
361
dcashman2e00e632016-10-12 14:58:09 -0700362all_cil_files := \
dcashman1faa6442016-11-28 07:20:28 -0800363 $(plat_policy_nvr) \
364 $(mapping_policy_nvr) \
365 $(nonplat_policy_nvr) \
dcashman2e00e632016-10-12 14:58:09 -0700366
367$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
368$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
369 @mkdir -p $(dir $@)
370 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800371 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
372 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
373 echo "==========" 1>&2; \
374 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
375 echo "List of invalid domains:" 1>&2; \
376 cat $@.permissivedomains 1>&2; \
377 exit 1; \
378 fi
379 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800380
Ying Wangd8b122c2012-10-25 19:01:31 -0700381built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700382all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400383
Stephen Smalleye60723a2014-05-29 16:40:15 -0400384##################################
Dan Cashman1c040272016-12-15 15:28:44 -0800385plat_pub_policy.recovery.conf := $(intermediates)/plat_pub_policy.recovery.conf
386$(plat_pub_policy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
387$(plat_pub_policy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
388$(plat_pub_policy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
389$(plat_pub_policy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
390$(plat_pub_policy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
391$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY))
Stephen Smalleye60723a2014-05-29 16:40:15 -0400392 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700393 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
394 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400395 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500396 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800397 -D target_arch=$(PRIVATE_TGT_ARCH) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400398 -D target_recovery=true \
399 -s $^ > $@
400
Dan Cashman1c040272016-12-15 15:28:44 -0800401plat_pub_policy.recovery.cil := $(intermediates)/plat_pub_policy.recovery.cil
402$(plat_pub_policy.recovery.cil): PRIVATE_POL_CONF := $(plat_pub_policy.recovery.conf)
403$(plat_pub_policy.recovery.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
404$(plat_pub_policy.recovery.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy \
405$(plat_pub_policy.recovery.conf) $(reqd_policy_mask.cil)
Stephen Smalleye60723a2014-05-29 16:40:15 -0400406 @mkdir -p $(dir $@)
Dan Cashman1c040272016-12-15 15:28:44 -0800407 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
408 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
409
410plat_pub_policy.recovery.conf :=
411
412#################################
413include $(CLEAR_VARS)
414
415LOCAL_MODULE := plat_sepolicy.recovery.cil
416LOCAL_MODULE_CLASS := ETC
417LOCAL_MODULE_TAGS := optional
418LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
419
420include $(BUILD_SYSTEM)/base_rules.mk
421
422plat_policy.recovery.conf := $(intermediates)/plat_policy.recovery.conf
423$(plat_policy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
424$(plat_policy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
425$(plat_policy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
426$(plat_policy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
427$(plat_policy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
428$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
429 @mkdir -p $(dir $@)
430 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
431 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
432 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800433 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800434 -D target_arch=$(PRIVATE_TGT_ARCH) \
435 -D target_recovery=true \
436 -s $^ > $@
437 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
438
439plat_policy_nvr.recovery := $(intermediates)/plat_policy_nvr.recovery.cil
440$(plat_policy_nvr.recovery): $(plat_policy.recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
441 @mkdir -p $(dir $@)
442 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
443
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800444$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(plat_policy_nvr.recovery)
445$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(plat_policy_nvr.recovery)
Dan Cashman1c040272016-12-15 15:28:44 -0800446 @mkdir -p $(dir $@)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800447 # Strip out neverallow statements. They aren't needed on-device and their presence
448 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
449 # sailfish-eng).
450 grep -v '^(neverallow' $(PRIVATE_CIL_FILES) > $@
451 # Confirm that the resulting policy compiles
452 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) $@ -o /dev/null -f /dev/null
Dan Cashman1c040272016-12-15 15:28:44 -0800453
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800454built_plat_cil.recovery := $(LOCAL_BUILT_MODULE)
Dan Cashman1c040272016-12-15 15:28:44 -0800455plat_policy.recovery.conf :=
456
457#################################
458include $(CLEAR_VARS)
459
460LOCAL_MODULE := mapping_sepolicy.recovery.cil
461LOCAL_MODULE_CLASS := ETC
462LOCAL_MODULE_TAGS := optional
463LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
464
465include $(BUILD_SYSTEM)/base_rules.mk
466
467# auto-generate the mapping file for current platform policy, since it needs to
468# track platform policy development
469current_mapping.recovery.cil := $(intermediates)/mapping/current.recovery.cil
470$(current_mapping.recovery.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
471$(current_mapping.recovery.cil) : $(plat_pub_policy.recovery.cil) $(HOST_OUT_EXECUTABLES)/version_policy
472 @mkdir -p $(dir $@)
473 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
474
475ifeq ($(BOARD_SEPOLICY_VERS), current)
476mapping_policy_nvr.recovery := $(current_mapping.recovery.cil)
477else
478mapping_policy_nvr.recovery := $(addsuffix /$(BOARD_SEPOLICY_VERS).recovery.cil, \
479$(PLAT_PRIVATE_POLICY)/mapping)
480endif
481
482$(LOCAL_BUILT_MODULE): $(mapping_policy_nvr.recovery)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800483 # Strip out neverallow statements. They aren't needed on-device and their presence
484 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
485 # sailfish-eng).
486 grep -v '^(neverallow' $< > $@
Dan Cashman1c040272016-12-15 15:28:44 -0800487
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800488built_mapping_cil.recovery := $(LOCAL_BUILT_MODULE)
Dan Cashman1c040272016-12-15 15:28:44 -0800489current_mapping.recovery.cil :=
490
491#################################
492include $(CLEAR_VARS)
493
494LOCAL_MODULE := nonplat_sepolicy.recovery.cil
495LOCAL_MODULE_CLASS := ETC
496LOCAL_MODULE_TAGS := optional
497LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
498
499include $(BUILD_SYSTEM)/base_rules.mk
500
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800501# nonplat_policy.recovery.conf - A combination of the non-platform private,
502# vendor and the exported platform policy associated with the version the
503# non-platform policy targets. This needs attributization and to be combined
504# with the platform-provided policy. Like plat_pub_policy.recovery.conf, this
505# needs to make use of the reqd_policy_mask files from private policy in order
506# to use checkpolicy.
Dan Cashman1c040272016-12-15 15:28:44 -0800507nonplat_policy.recovery.conf := $(intermediates)/nonplat_policy.recovery.conf
508$(nonplat_policy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
509$(nonplat_policy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
510$(nonplat_policy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
511$(nonplat_policy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
512$(nonplat_policy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
Alex Klyubin55961722017-01-30 18:44:59 -0800513$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashman1c040272016-12-15 15:28:44 -0800514 @mkdir -p $(dir $@)
515 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
516 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
517 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800518 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800519 -D target_arch=$(PRIVATE_TGT_ARCH) \
520 -D target_recovery=true \
521 -s $^ > $@
522 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
523
524nonplat_policy_raw.recovery := $(intermediates)/nonplat_policy_raw.recovery.cil
525$(nonplat_policy_raw.recovery): PRIVATE_POL_CONF := $(nonplat_policy.recovery.conf)
526$(nonplat_policy_raw.recovery): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
527$(nonplat_policy_raw.recovery): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.recovery.conf) \
528$(reqd_policy_mask.cil)
529 @mkdir -p $(dir $@)
530 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
531 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
532
533nonplat_policy_nvr.recovery := $(intermediates)/nonplat_policy_nvr.recovery.cil
534$(nonplat_policy_nvr.recovery) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
535$(nonplat_policy_nvr.recovery) : PRIVATE_TGT_POL := $(nonplat_policy_raw.recovery)
536$(nonplat_policy_nvr.recovery) : $(plat_pub_policy.recovery.cil) $(nonplat_policy_raw.recovery) \
537$(HOST_OUT_EXECUTABLES)/version_policy
538 @mkdir -p $(dir $@)
539 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
540
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800541$(LOCAL_BUILT_MODULE): PRIVATE_NONPLAT_CIL_FILES := $(nonplat_policy_nvr.recovery)
542$(LOCAL_BUILT_MODULE): PRIVATE_DEP_CIL_FILES := $(built_plat_cil.recovery) \
543$(built_mapping_cil.recovery)
544$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(nonplat_policy_nvr.recovery) \
545$(built_plat_cil.recovery) $(built_mapping_cil.recovery)
Dan Cashman1c040272016-12-15 15:28:44 -0800546 @mkdir -p $(dir $@)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800547 # Strip out neverallow statements. They aren't needed on-device and their presence
548 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
549 # sailfish-eng).
550 grep -v '^(neverallow' $(PRIVATE_NONPLAT_CIL_FILES) > $@
551 # Confirm that the resulting policy compiles combined with platform and mapping policies
552 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) \
553 $(PRIVATE_DEP_CIL_FILES) $@ -o /dev/null -f /dev/null
Dan Cashman1c040272016-12-15 15:28:44 -0800554
555nonplat_policy.recovery.conf :=
556nonplat_policy_raw.recovery :=
557
558##################################
559include $(CLEAR_VARS)
560
561# keep concrete sepolicy for neverallow checks
562
563LOCAL_MODULE := sepolicy.recovery
564LOCAL_MODULE_CLASS := ETC
565LOCAL_MODULE_TAGS := optional
Daniel Cashman65d01342016-12-17 00:53:26 +0000566LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Dan Cashman1c040272016-12-15 15:28:44 -0800567
568include $(BUILD_SYSTEM)/base_rules.mk
569
570all_cil_files.recovery := \
571 $(plat_policy_nvr.recovery) \
572 $(mapping_policy_nvr.recovery) \
573 $(nonplat_policy_nvr.recovery) \
574
575$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files.recovery)
576$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files.recovery)
577 @mkdir -p $(dir $@)
578 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800579 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
580 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
581 echo "==========" 1>&2; \
582 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
583 echo "List of invalid domains:" 1>&2; \
584 cat $@.permissivedomains 1>&2; \
585 exit 1; \
586 fi
587 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400588
Dan Cashman1c040272016-12-15 15:28:44 -0800589all_cil_files.recovery :=
Stephen Smalleye60723a2014-05-29 16:40:15 -0400590
dcashman704741a2014-07-25 19:11:52 -0700591##################################
592include $(CLEAR_VARS)
593
594LOCAL_MODULE := general_sepolicy.conf
595LOCAL_MODULE_CLASS := ETC
596LOCAL_MODULE_TAGS := tests
597
598include $(BUILD_SYSTEM)/base_rules.mk
599
dcashman704741a2014-07-25 19:11:52 -0700600$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
601$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800602$(LOCAL_BUILT_MODULE): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashmancc39f632016-07-22 13:13:11 -0700603$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
604$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
dcashman704741a2014-07-25 19:11:52 -0700605 mkdir -p $(dir $@)
606 $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
607 -D target_build_variant=user \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500608 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800609 -D target_arch=$(PRIVATE_TGT_ARCH) \
dcashman704741a2014-07-25 19:11:52 -0700610 -s $^ > $@
611 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
612
William Robertsb8769932015-06-29 16:31:23 -0700613built_general_sepolicy.conf := $(LOCAL_BUILT_MODULE)
dcashman704741a2014-07-25 19:11:52 -0700614exp_sepolicy_build_files :=
615
616##################################
Stephen Smalley01a58af2012-10-02 12:46:37 -0400617include $(CLEAR_VARS)
618
William Robertsb8769932015-06-29 16:31:23 -0700619LOCAL_MODULE := sepolicy.general
620LOCAL_MODULE_CLASS := ETC
621LOCAL_MODULE_TAGS := tests
622
623include $(BUILD_SYSTEM)/base_rules.mk
624
625$(LOCAL_BUILT_MODULE): PRIVATE_BUILT_SEPOLICY.CONF := $(built_general_sepolicy.conf)
626$(LOCAL_BUILT_MODULE): $(built_general_sepolicy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
627 @mkdir -p $(dir $@)
Nick Kralevich6ef10bd2016-02-29 16:59:33 -0800628 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@ $(PRIVATE_BUILT_SEPOLICY.CONF) > /dev/null
William Robertsb8769932015-06-29 16:31:23 -0700629
630built_general_sepolicy := $(LOCAL_BUILT_MODULE)
dcashmand225b692016-12-12 09:29:04 -0800631
William Robertsb8769932015-06-29 16:31:23 -0700632##################################
dcashmand225b692016-12-12 09:29:04 -0800633# TODO - remove this. Keep around until we get the filesystem creation stuff taken care of.
634#
William Robertsb8769932015-06-29 16:31:23 -0700635include $(CLEAR_VARS)
636
Richard Hainesc2d01912015-08-06 17:43:52 +0100637LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800638LOCAL_MODULE_CLASS := ETC
639LOCAL_MODULE_TAGS := optional
640LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
641
Stephen Smalley5b340be2012-03-06 11:12:41 -0500642include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800643
William Roberts49693f12016-01-04 12:20:57 -0800644# The file_contexts.bin is built in the following way:
645# 1. Collect all file_contexts files in THIS repository and process them with
646# m4 into a tmp file called file_contexts.local.tmp.
647# 2. Collect all device specific file_contexts files and process them with m4
648# into a tmp file called file_contexts.device.tmp.
649# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
650# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
651# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
652# file_contexts.concat.tmp.
653# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
654# file_contexts.bin.
655#
656# Note: That a newline file is placed between each file_context file found to
657# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800658
dcashmancc39f632016-07-22 13:13:11 -0700659local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
William Roberts49693f12016-01-04 12:20:57 -0800660ifneq ($(filter address,$(SANITIZE_TARGET)),)
dcashmancc39f632016-07-22 13:13:11 -0700661 local_fc_files := $(local_fc_files) $(PLAT_PRIVATE_POLICY)/file_contexts_asan
William Roberts49693f12016-01-04 12:20:57 -0800662endif
663local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
664
665file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
666$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500667 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800668 $(hide) m4 -s $^ > $@
669
670device_fc_files := $(call build_device_policy, file_contexts)
671device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
672
673file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
674$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
675$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
676 @mkdir -p $(dir $@)
677 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
678
679file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
680$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
681$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
682 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800683 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800684 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
685
686file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
687$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
688 @mkdir -p $(dir $@)
689 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500690
William Roberts3746a0a2015-09-25 10:18:44 -0700691$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800692$(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 +0100693 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800694 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100695 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
696
Robert Craig8b7545b2014-03-20 09:35:08 -0400697built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800698local_fc_files :=
699local_fcfiles_with_nl :=
700device_fc_files :=
701device_fcfiles_with_nl :=
702file_contexts.concat.tmp :=
703file_contexts.device.sorted.tmp :=
704file_contexts.device.tmp :=
705file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700706
Ying Wang02fb5f32012-01-17 17:51:09 -0800707##################################
708include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400709
dcashmand225b692016-12-12 09:29:04 -0800710LOCAL_MODULE := plat_file_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400711LOCAL_MODULE_CLASS := ETC
dcashmand225b692016-12-12 09:29:04 -0800712LOCAL_MODULE_TAGS := optional
713LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400714
715include $(BUILD_SYSTEM)/base_rules.mk
716
dcashmand225b692016-12-12 09:29:04 -0800717local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
718ifneq ($(filter address,$(SANITIZE_TARGET)),)
719 local_fc_files += $(PLAT_PRIVATE_POLICY)/file_contexts_asan
720endif
Alex Klyubine4665d72017-01-19 19:58:34 -0800721local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400722
Alex Klyubine4665d72017-01-19 19:58:34 -0800723$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl)
dcashmand225b692016-12-12 09:29:04 -0800724$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Alex Klyubine4665d72017-01-19 19:58:34 -0800725$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
726$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
727$(local_fcfiles_with_nl) $(built_sepolicy)
Richard Hainesc2d01912015-08-06 17:43:52 +0100728 @mkdir -p $(dir $@)
Alex Klyubine4665d72017-01-19 19:58:34 -0800729 $(hide) m4 -s $(PRIVATE_FC_FILES) > $@.tmp
730 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
731 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
Richard Hainesc2d01912015-08-06 17:43:52 +0100732
dcashmand225b692016-12-12 09:29:04 -0800733built_plat_fc := $(LOCAL_BUILT_MODULE)
734local_fc_files :=
Alex Klyubine4665d72017-01-19 19:58:34 -0800735local_fcfiles_with_nl :=
dcashmand225b692016-12-12 09:29:04 -0800736
737##################################
738include $(CLEAR_VARS)
739
740LOCAL_MODULE := nonplat_file_contexts
741LOCAL_MODULE_CLASS := ETC
742LOCAL_MODULE_TAGS := optional
743LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
744
745include $(BUILD_SYSTEM)/base_rules.mk
746
747nonplat_fc_files := $(call build_device_policy, file_contexts)
748nonplat_fcfiles_with_nl := $(call add_nl, $(nonplat_fc_files), $(built_nl))
749
750$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(nonplat_fcfiles_with_nl)
751$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
752$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
753$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
Alex Klyubine4665d72017-01-19 19:58:34 -0800754$(nonplat_fcfiles_with_nl) $(built_sepolicy)
dcashmand225b692016-12-12 09:29:04 -0800755 @mkdir -p $(dir $@)
756 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > $@.tmp
757 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
758 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
759
760built_nonplat_fc := $(LOCAL_BUILT_MODULE)
761nonplat_fc_files :=
762nonplat_fcfiles_with_nl :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400763
764##################################
765include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800766LOCAL_MODULE := plat_seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800767LOCAL_MODULE_CLASS := ETC
768LOCAL_MODULE_TAGS := optional
769LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
770
William Roberts171a0622012-08-16 10:55:05 -0700771include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800772
Dan Cashman9c038072016-12-22 07:15:18 -0800773plat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts171a0622012-08-16 10:55:05 -0700774
Ying Wangd8b122c2012-10-25 19:01:31 -0700775$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman9c038072016-12-22 07:15:18 -0800776$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(plat_sc_files)
777$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(plat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700778 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700779 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800780
Dan Cashman9c038072016-12-22 07:15:18 -0800781built_plat_sc := $(LOCAL_BUILT_MODULE)
782plat_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400783
Ying Wang02fb5f32012-01-17 17:51:09 -0800784##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400785include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800786LOCAL_MODULE := nonplat_seapp_contexts
Stephen Smalley37712872015-03-12 15:46:36 -0400787LOCAL_MODULE_CLASS := ETC
Dan Cashman9c038072016-12-22 07:15:18 -0800788LOCAL_MODULE_TAGS := optional
789LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Stephen Smalley37712872015-03-12 15:46:36 -0400790
791include $(BUILD_SYSTEM)/base_rules.mk
792
Alex Klyubin55961722017-01-30 18:44:59 -0800793nonplat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Stephen Smalley37712872015-03-12 15:46:36 -0400794
Dan Cashman9c038072016-12-22 07:15:18 -0800795$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
796$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(nonplat_sc_files)
797$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(nonplat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
Stephen Smalley37712872015-03-12 15:46:36 -0400798 @mkdir -p $(dir $@)
Dan Cashman9c038072016-12-22 07:15:18 -0800799 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Stephen Smalley37712872015-03-12 15:46:36 -0400800
Dan Cashman9c038072016-12-22 07:15:18 -0800801built_nonplat_sc := $(LOCAL_BUILT_MODULE)
802nonplat_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400803
804##################################
805include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800806LOCAL_MODULE := plat_seapp_neverallows
William Roberts4ee71312015-06-25 11:59:30 -0700807LOCAL_MODULE_CLASS := ETC
808LOCAL_MODULE_TAGS := tests
809
810include $(BUILD_SYSTEM)/base_rules.mk
811
dcashmancc39f632016-07-22 13:13:11 -0700812$(LOCAL_BUILT_MODULE): $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
William Roberts4ee71312015-06-25 11:59:30 -0700813 @mkdir -p $(dir $@)
814 - $(hide) grep -ie '^neverallow' $< > $@
815
William Roberts4ee71312015-06-25 11:59:30 -0700816
817##################################
818include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400819
Sandeep Patila86316e2016-12-27 16:08:44 -0800820LOCAL_MODULE := plat_property_contexts
Stephen Smalley124720a2012-04-04 10:11:16 -0400821LOCAL_MODULE_CLASS := ETC
822LOCAL_MODULE_TAGS := optional
Sandeep Patila86316e2016-12-27 16:08:44 -0800823# TODO: Change module path to TARGET_SYSTEM_OUT after b/27805372
Stephen Smalley124720a2012-04-04 10:11:16 -0400824LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
825
826include $(BUILD_SYSTEM)/base_rules.mk
827
Sandeep Patila86316e2016-12-27 16:08:44 -0800828plat_pcfiles := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts6aabc1c2015-07-30 11:44:26 -0700829
Sandeep Patila86316e2016-12-27 16:08:44 -0800830plat_property_contexts.tmp := $(intermediates)/plat_property_contexts.tmp
831$(plat_property_contexts.tmp): PRIVATE_PC_FILES := $(plat_pcfiles)
832$(plat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
833$(plat_property_contexts.tmp): $(plat_pcfiles)
William Roberts7f81b332015-09-29 13:52:37 -0700834 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000835 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700836
837
838$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila86316e2016-12-27 16:08:44 -0800839$(LOCAL_BUILT_MODULE): $(plat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700840 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800841 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800842 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400843
Sandeep Patila86316e2016-12-27 16:08:44 -0800844built_plat_pc := $(LOCAL_BUILT_MODULE)
845plat_pcfiles :=
846plat_property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400847
Stephen Smalley124720a2012-04-04 10:11:16 -0400848##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700849include $(CLEAR_VARS)
850
Sandeep Patila86316e2016-12-27 16:08:44 -0800851LOCAL_MODULE := nonplat_property_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400852LOCAL_MODULE_CLASS := ETC
Sandeep Patila86316e2016-12-27 16:08:44 -0800853LOCAL_MODULE_TAGS := optional
854# TODO: Change module path to TARGET_SYSTEM_OUT after b/27805372
855LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400856
Stephen Smalleyc9361732015-03-13 09:36:57 -0400857include $(BUILD_SYSTEM)/base_rules.mk
858
Alex Klyubin55961722017-01-30 18:44:59 -0800859nonplat_pcfiles := $(call build_policy, property_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Sandeep Patil262edc32016-12-27 16:08:44 -0800860
Sandeep Patila86316e2016-12-27 16:08:44 -0800861nonplat_property_contexts.tmp := $(intermediates)/nonplat_property_contexts.tmp
862$(nonplat_property_contexts.tmp): PRIVATE_PC_FILES := $(nonplat_pcfiles)
863$(nonplat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
864$(nonplat_property_contexts.tmp): $(nonplat_pcfiles)
William Robertsdcffd2b2015-09-29 13:52:37 -0700865 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800866 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
867
868
869$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
870$(LOCAL_BUILT_MODULE): $(nonplat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
871 @mkdir -p $(dir $@)
872 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800873 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700874
Sandeep Patila86316e2016-12-27 16:08:44 -0800875built_nonplat_pc := $(LOCAL_BUILT_MODULE)
876nonplat_pcfiles :=
877nonplat_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400878
879##################################
880include $(CLEAR_VARS)
881
Sandeep Patila058b562016-12-27 15:10:48 -0800882LOCAL_MODULE := plat_service_contexts
Riley Spahnf90c41f2014-06-05 15:52:02 -0700883LOCAL_MODULE_CLASS := ETC
884LOCAL_MODULE_TAGS := optional
Sandeep Patila058b562016-12-27 15:10:48 -0800885# TODO: Change module path to TARGET_SYSTEM_OUT after b/27805372
Riley Spahnf90c41f2014-06-05 15:52:02 -0700886LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
887
888include $(BUILD_SYSTEM)/base_rules.mk
889
Sandeep Patila058b562016-12-27 15:10:48 -0800890plat_svcfiles := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700891
Sandeep Patila058b562016-12-27 15:10:48 -0800892plat_service_contexts.tmp := $(intermediates)/plat_service_contexts.tmp
893$(plat_service_contexts.tmp): PRIVATE_SVC_FILES := $(plat_svcfiles)
894$(plat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
895$(plat_service_contexts.tmp): $(plat_svcfiles)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700896 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700897 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700898
899$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila058b562016-12-27 15:10:48 -0800900$(LOCAL_BUILT_MODULE): $(plat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700901 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700902 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800903 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700904
Sandeep Patila058b562016-12-27 15:10:48 -0800905built_plat_svc := $(LOCAL_BUILT_MODULE)
906plat_svcfiles :=
907plat_service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700908
909##################################
rpcraigb19665c2012-07-30 09:33:03 -0400910include $(CLEAR_VARS)
911
Sandeep Patila058b562016-12-27 15:10:48 -0800912LOCAL_MODULE := nonplat_service_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400913LOCAL_MODULE_CLASS := ETC
Sandeep Patila058b562016-12-27 15:10:48 -0800914LOCAL_MODULE_TAGS := optional
915# TODO: Change module path to TARGET_VENDOR_OUT after b/27805372
916LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400917
918include $(BUILD_SYSTEM)/base_rules.mk
919
Alex Klyubin55961722017-01-30 18:44:59 -0800920nonplat_svcfiles := $(call build_policy, service_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400921
Sandeep Patila058b562016-12-27 15:10:48 -0800922nonplat_service_contexts.tmp := $(intermediates)/nonplat_service_contexts.tmp
923$(nonplat_service_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_svcfiles)
924$(nonplat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
925$(nonplat_service_contexts.tmp): $(nonplat_svcfiles)
926 @mkdir -p $(dir $@)
927 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
928
929$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
930$(LOCAL_BUILT_MODULE): $(nonplat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700931 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700932 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800933 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700934
Sandeep Patila058b562016-12-27 15:10:48 -0800935built_nonplat_svc := $(LOCAL_BUILT_MODULE)
936nonplat_svcfiles :=
937nonplat_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400938
939##################################
940include $(CLEAR_VARS)
941
dcashman90b3b942016-12-14 13:47:55 -0800942LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -0400943LOCAL_MODULE_CLASS := ETC
944LOCAL_MODULE_TAGS := optional
945LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
946
William Roberts2c8a55d2012-11-30 14:59:09 -0800947include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -0400948
Geremy Condracd4104e2013-03-26 18:19:12 +0000949# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -0800950plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
951$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
952$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +0000953 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700954 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +0000955
dcashman90b3b942016-12-14 13:47:55 -0800956all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -0400957
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900958# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -0800959all_plat_keys := platform media shared testkey
960all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900961
dcashman90b3b942016-12-14 13:47:55 -0800962$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
963$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
964$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +0000965 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -0700966 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -0700967 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +0000968
William Roberts6aabc1c2015-07-30 11:44:26 -0700969all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -0800970all_plat_keys :=
971plat_mac_perms_keys.tmp :=
972
973##################################
974include $(CLEAR_VARS)
975
976LOCAL_MODULE := nonplat_mac_permissions.xml
977LOCAL_MODULE_CLASS := ETC
978LOCAL_MODULE_TAGS := optional
979LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
980
981include $(BUILD_SYSTEM)/base_rules.mk
982
983# Build keys.conf
984nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
985$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Alex Klyubin55961722017-01-30 18:44:59 -0800986$(nonplat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
dcashman90b3b942016-12-14 13:47:55 -0800987 @mkdir -p $(dir $@)
988 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
989
Alex Klyubin55961722017-01-30 18:44:59 -0800990all_nonplat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
dcashman90b3b942016-12-14 13:47:55 -0800991
992$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
993$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
994$(all_nonplat_mac_perms_files)
995 @mkdir -p $(dir $@)
996 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
997
998nonplat_mac_perms_keys.tmp :=
999all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -07001000
rpcraigb19665c2012-07-30 09:33:03 -04001001##################################
Robert Craig8b7545b2014-03-20 09:35:08 -04001002include $(CLEAR_VARS)
1003
1004LOCAL_MODULE := selinux_version
1005LOCAL_MODULE_CLASS := ETC
1006LOCAL_MODULE_TAGS := optional
1007LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1008
1009include $(BUILD_SYSTEM)/base_rules.mk
Sandeep Patila86316e2016-12-27 16:08:44 -08001010$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(built_plat_pc) $(built_nonplat_pc) $(built_plat_fc) \
Sandeep Patila058b562016-12-27 15:10:48 -08001011$(buit_nonplat_fc) $(built_plat_sc) $(built_nonplat_sc) $(built_plat_svc) $(built_nonplat_svc)
Robert Craig8b7545b2014-03-20 09:35:08 -04001012 @mkdir -p $(dir $@)
Colin Cross29a463d2015-07-17 13:08:41 -07001013 $(hide) echo -n $(BUILD_FINGERPRINT_FROM_FILE) > $@
Robert Craig8b7545b2014-03-20 09:35:08 -04001014
1015##################################
rpcraig47cd3962012-10-17 21:09:52 -04001016
Dan Cashman1c040272016-12-15 15:28:44 -08001017add_nl :=
William Roberts49693f12016-01-04 12:20:57 -08001018build_device_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001019build_policy :=
dcashmand225b692016-12-12 09:29:04 -08001020built_plat_fc :=
1021built_nonplat_fc :=
William Robertsb8769932015-06-29 16:31:23 -07001022built_general_sepolicy :=
1023built_general_sepolicy.conf :=
Richard Hainesc8801fe2015-12-11 10:39:19 +00001024built_nl :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001025built_plat_cil :=
1026built_plat_cil.recovery :=
1027built_mapping_cil :=
1028built_mapping_cil.recovery :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001029built_plat_pc :=
1030built_nonplat_pc :=
Dan Cashman9c038072016-12-22 07:15:18 -08001031built_nonplat_sc :=
1032built_plat_sc :=
Dan Cashman1c040272016-12-15 15:28:44 -08001033built_sepolicy :=
Sandeep Patila058b562016-12-27 15:10:48 -08001034built_plat_svc :=
1035built_nonplat_svc :=
Dan Cashman1c040272016-12-15 15:28:44 -08001036mapping_policy_nvr :=
1037mapping_policy_nvr.recovery :=
1038my_target_arch :=
1039nonplat_policy_nvr :=
1040nonplat_policy_nvr.recovery :=
1041plat_policy_nvr :=
1042plat_policy_nvr.recovery :=
dcashman1faa6442016-11-28 07:20:28 -08001043plat_pub_policy.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -08001044plat_pub_policy.recovery.cil :=
dcashman1faa6442016-11-28 07:20:28 -08001045reqd_policy_mask.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -08001046sepolicy_build_files :=
Alice Chucdfb06f2012-11-01 11:33:04 -07001047
1048include $(call all-makefiles-under,$(LOCAL_PATH))