blob: bd2927177b4a08178b2d2301a3ab7ecb0d6e959b [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
Dan Cashman1c040272016-12-15 15:28:44 -0800122my_target_arch := $(TARGET_ARCH)
123ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
124 my_target_arch := mips
125endif
126
Ying Wang02fb5f32012-01-17 17:51:09 -0800127##################################
dcashman2e00e632016-10-12 14:58:09 -0700128# reqd_policy_mask - a policy.conf file which contains only the bare minimum
129# policy necessary to use checkpolicy. This bare-minimum policy needs to be
130# present in all policy.conf files, but should not necessarily be exported as
131# part of the public policy. The rules generated by reqd_policy_mask will allow
132# the compilation of public policy and subsequent removal of CIL policy that
133# should not be exported.
134
135reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
136$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
137$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800138$(reqd_policy_mask.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashman2e00e632016-10-12 14:58:09 -0700139$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
140$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
141 @mkdir -p $(dir $@)
142 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
143 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
144 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800145 -D target_build_treble=$(ENABLE_TREBLE) \
146 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
147 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
148 -D target_arch=$(PRIVATE_TGT_ARCH) \
dcashman2e00e632016-10-12 14:58:09 -0700149 -s $^ > $@
150
151reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
152$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
153 @mkdir -p $(dir $@)
154 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
155
dcashman1faa6442016-11-28 07:20:28 -0800156reqd_policy_mask.conf :=
157
158##################################
dcashman2e00e632016-10-12 14:58:09 -0700159# plat_pub_policy - policy that will be exported to be a part of non-platform
160# policy corresponding to this platform version. This is a limited subset of
161# policy that would not compile in checkpolicy on its own. To get around this
162# limitation, add only the required files from private policy, which will
163# generate CIL policy that will then be filtered out by the reqd_policy_mask.
164plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
165$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
166$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800167$(plat_pub_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashman2e00e632016-10-12 14:58:09 -0700168$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
169$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
170$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY))
171 @mkdir -p $(dir $@)
172 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
173 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
174 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800175 -D target_build_treble=$(ENABLE_TREBLE) \
176 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
177 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
178 -D target_arch=$(PRIVATE_TGT_ARCH) \
dcashman2e00e632016-10-12 14:58:09 -0700179 -s $^ > $@
180
181plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800182$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
183$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
184$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700185 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800186 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
187 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700188
dcashman1faa6442016-11-28 07:20:28 -0800189plat_pub_policy.conf :=
Dan Cashman1c040272016-12-15 15:28:44 -0800190
dcashman1faa6442016-11-28 07:20:28 -0800191##################################
192include $(CLEAR_VARS)
193
194LOCAL_MODULE := sectxfile_nl
195LOCAL_MODULE_CLASS := ETC
196LOCAL_MODULE_TAGS := optional
197
198# Create a file containing newline only to add between context config files
199include $(BUILD_SYSTEM)/base_rules.mk
200$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700201 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800202 $(hide) echo > $@
203
204built_nl := $(LOCAL_BUILT_MODULE)
205
206#################################
207include $(CLEAR_VARS)
208
209LOCAL_MODULE := plat_sepolicy.cil
210LOCAL_MODULE_CLASS := ETC
211LOCAL_MODULE_TAGS := optional
212LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman1faa6442016-11-28 07:20:28 -0800213
214include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700215
216# plat_policy.conf - A combination of the private and public platform policy
217# which will ship with the device. The platform will always reflect the most
218# recent platform version and is not currently being attributized.
219plat_policy.conf := $(intermediates)/plat_policy.conf
220$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
221$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800222$(plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashman2e00e632016-10-12 14:58:09 -0700223$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
224$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700225$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
226 @mkdir -p $(dir $@)
227 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
228 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
229 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700230 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500231 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500232 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Dan Cashman1c040272016-12-15 15:28:44 -0800233 -D target_arch=$(PRIVATE_TGT_ARCH) \
dcashmancc39f632016-07-22 13:13:11 -0700234 -s $^ > $@
235 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
236
dcashman1faa6442016-11-28 07:20:28 -0800237plat_policy_nvr := $(intermediates)/plat_policy_nvr.cil
238$(plat_policy_nvr): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
dcashman2e00e632016-10-12 14:58:09 -0700239 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800240 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
dcashmancc39f632016-07-22 13:13:11 -0700241
dcashman1faa6442016-11-28 07:20:28 -0800242$(LOCAL_BUILT_MODULE): $(plat_policy_nvr)
243 @mkdir -p $(dir $@)
244 grep -v neverallow $< > $@
245
246plat_policy.conf :=
247
248#################################
249include $(CLEAR_VARS)
250
251LOCAL_MODULE := mapping_sepolicy.cil
252LOCAL_MODULE_CLASS := ETC
253LOCAL_MODULE_TAGS := optional
254LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman1faa6442016-11-28 07:20:28 -0800255
256include $(BUILD_SYSTEM)/base_rules.mk
257
258# auto-generate the mapping file for current platform policy, since it needs to
259# track platform policy development
260current_mapping.cil := $(intermediates)/mapping/current.cil
261$(current_mapping.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
262$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
263 @mkdir -p $(dir $@)
264 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
265
266ifeq ($(BOARD_SEPOLICY_VERS), current)
267mapping_policy_nvr := $(current_mapping.cil)
268else
269mapping_policy_nvr := $(addsuffix /$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)/mapping)
270endif
271
272$(LOCAL_BUILT_MODULE): $(mapping_policy_nvr)
273 grep -v neverallow $< > $@
274
275current_mapping.cil :=
276
277#################################
278include $(CLEAR_VARS)
279
280LOCAL_MODULE := nonplat_sepolicy.cil
281LOCAL_MODULE_CLASS := ETC
282LOCAL_MODULE_TAGS := optional
283LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman1faa6442016-11-28 07:20:28 -0800284
285include $(BUILD_SYSTEM)/base_rules.mk
286
dcashman2e00e632016-10-12 14:58:09 -0700287# nonplat_policy.conf - A combination of the non-platform private and the
288# exported platform policy associated with the version the non-platform policy
289# targets. This needs attributization and to be combined with the
290# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
291# of the reqd_policy_mask files from private policy in order to use checkpolicy.
292nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
293$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
294$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800295$(nonplat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashman2e00e632016-10-12 14:58:09 -0700296$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
297$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
298$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY) $(BOARD_SEPOLICY_DIRS))
Ying Wang02fb5f32012-01-17 17:51:09 -0800299 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700300 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
301 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800302 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700303 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500304 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500305 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Dan Cashman1c040272016-12-15 15:28:44 -0800306 -D target_arch=$(PRIVATE_TGT_ARCH) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800307 -s $^ > $@
Robert Craig65d4f442013-03-27 06:30:25 -0400308 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500309
dcashman1faa6442016-11-28 07:20:28 -0800310nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
311$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
312$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
313$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
314$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800315 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800316 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
317 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700318
dcashman1faa6442016-11-28 07:20:28 -0800319nonplat_policy_nvr := $(intermediates)/nonplat_policy_nvr.cil
320$(nonplat_policy_nvr) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
321$(nonplat_policy_nvr) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
322$(nonplat_policy_nvr) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
dcashman2e00e632016-10-12 14:58:09 -0700323$(HOST_OUT_EXECUTABLES)/version_policy
324 @mkdir -p $(dir $@)
325 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
326
dcashman1faa6442016-11-28 07:20:28 -0800327$(LOCAL_BUILT_MODULE): $(nonplat_policy_nvr)
dcashman2e00e632016-10-12 14:58:09 -0700328 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800329 grep -v neverallow $< > $@
dcashman2e00e632016-10-12 14:58:09 -0700330
dcashman1faa6442016-11-28 07:20:28 -0800331nonplat_policy.conf :=
332nonplat_policy_raw :=
333
334#################################
335include $(CLEAR_VARS)
Dan Cashman1c040272016-12-15 15:28:44 -0800336# build this target so that we can still perform neverallow checks
dcashman1faa6442016-11-28 07:20:28 -0800337
338LOCAL_MODULE := sepolicy
339LOCAL_MODULE_CLASS := ETC
340LOCAL_MODULE_TAGS := optional
341LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman2e00e632016-10-12 14:58:09 -0700342
dcashman1faa6442016-11-28 07:20:28 -0800343include $(BUILD_SYSTEM)/base_rules.mk
344
dcashman2e00e632016-10-12 14:58:09 -0700345all_cil_files := \
dcashman1faa6442016-11-28 07:20:28 -0800346 $(plat_policy_nvr) \
347 $(mapping_policy_nvr) \
348 $(nonplat_policy_nvr) \
dcashman2e00e632016-10-12 14:58:09 -0700349
350$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
351$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
352 @mkdir -p $(dir $@)
353 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800354 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
355 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
356 echo "==========" 1>&2; \
357 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
358 echo "List of invalid domains:" 1>&2; \
359 cat $@.permissivedomains 1>&2; \
360 exit 1; \
361 fi
362 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800363
Ying Wangd8b122c2012-10-25 19:01:31 -0700364built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700365all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400366
Stephen Smalleye60723a2014-05-29 16:40:15 -0400367##################################
Dan Cashman1c040272016-12-15 15:28:44 -0800368plat_pub_policy.recovery.conf := $(intermediates)/plat_pub_policy.recovery.conf
369$(plat_pub_policy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
370$(plat_pub_policy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
371$(plat_pub_policy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
372$(plat_pub_policy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
373$(plat_pub_policy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
374$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY))
Stephen Smalleye60723a2014-05-29 16:40:15 -0400375 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700376 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
377 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400378 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700379 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500380 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500381 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Dan Cashman1c040272016-12-15 15:28:44 -0800382 -D target_arch=$(PRIVATE_TGT_ARCH) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400383 -D target_recovery=true \
384 -s $^ > $@
385
Dan Cashman1c040272016-12-15 15:28:44 -0800386plat_pub_policy.recovery.cil := $(intermediates)/plat_pub_policy.recovery.cil
387$(plat_pub_policy.recovery.cil): PRIVATE_POL_CONF := $(plat_pub_policy.recovery.conf)
388$(plat_pub_policy.recovery.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
389$(plat_pub_policy.recovery.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy \
390$(plat_pub_policy.recovery.conf) $(reqd_policy_mask.cil)
Stephen Smalleye60723a2014-05-29 16:40:15 -0400391 @mkdir -p $(dir $@)
Dan Cashman1c040272016-12-15 15:28:44 -0800392 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
393 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
394
395plat_pub_policy.recovery.conf :=
396
397#################################
398include $(CLEAR_VARS)
399
400LOCAL_MODULE := plat_sepolicy.recovery.cil
401LOCAL_MODULE_CLASS := ETC
402LOCAL_MODULE_TAGS := optional
403LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
404
405include $(BUILD_SYSTEM)/base_rules.mk
406
407plat_policy.recovery.conf := $(intermediates)/plat_policy.recovery.conf
408$(plat_policy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
409$(plat_policy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
410$(plat_policy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
411$(plat_policy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
412$(plat_policy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
413$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
414 @mkdir -p $(dir $@)
415 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
416 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
417 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
418 -D target_build_treble=$(ENABLE_TREBLE) \
419 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
420 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
421 -D target_arch=$(PRIVATE_TGT_ARCH) \
422 -D target_recovery=true \
423 -s $^ > $@
424 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
425
426plat_policy_nvr.recovery := $(intermediates)/plat_policy_nvr.recovery.cil
427$(plat_policy_nvr.recovery): $(plat_policy.recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
428 @mkdir -p $(dir $@)
429 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
430
431$(LOCAL_BUILT_MODULE): $(plat_policy_nvr.recovery)
432 @mkdir -p $(dir $@)
433 grep -v neverallow $< > $@
434
435plat_policy.recovery.conf :=
436
437#################################
438include $(CLEAR_VARS)
439
440LOCAL_MODULE := mapping_sepolicy.recovery.cil
441LOCAL_MODULE_CLASS := ETC
442LOCAL_MODULE_TAGS := optional
443LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
444
445include $(BUILD_SYSTEM)/base_rules.mk
446
447# auto-generate the mapping file for current platform policy, since it needs to
448# track platform policy development
449current_mapping.recovery.cil := $(intermediates)/mapping/current.recovery.cil
450$(current_mapping.recovery.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
451$(current_mapping.recovery.cil) : $(plat_pub_policy.recovery.cil) $(HOST_OUT_EXECUTABLES)/version_policy
452 @mkdir -p $(dir $@)
453 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
454
455ifeq ($(BOARD_SEPOLICY_VERS), current)
456mapping_policy_nvr.recovery := $(current_mapping.recovery.cil)
457else
458mapping_policy_nvr.recovery := $(addsuffix /$(BOARD_SEPOLICY_VERS).recovery.cil, \
459$(PLAT_PRIVATE_POLICY)/mapping)
460endif
461
462$(LOCAL_BUILT_MODULE): $(mapping_policy_nvr.recovery)
463 grep -v neverallow $< > $@
464
465current_mapping.recovery.cil :=
466
467#################################
468include $(CLEAR_VARS)
469
470LOCAL_MODULE := nonplat_sepolicy.recovery.cil
471LOCAL_MODULE_CLASS := ETC
472LOCAL_MODULE_TAGS := optional
473LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
474
475include $(BUILD_SYSTEM)/base_rules.mk
476
477nonplat_policy.recovery.conf := $(intermediates)/nonplat_policy.recovery.conf
478$(nonplat_policy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
479$(nonplat_policy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
480$(nonplat_policy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
481$(nonplat_policy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
482$(nonplat_policy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
483$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY) $(BOARD_SEPOLICY_DIRS))
484 @mkdir -p $(dir $@)
485 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
486 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
487 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
488 -D target_build_treble=$(ENABLE_TREBLE) \
489 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
490 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
491 -D target_arch=$(PRIVATE_TGT_ARCH) \
492 -D target_recovery=true \
493 -s $^ > $@
494 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
495
496nonplat_policy_raw.recovery := $(intermediates)/nonplat_policy_raw.recovery.cil
497$(nonplat_policy_raw.recovery): PRIVATE_POL_CONF := $(nonplat_policy.recovery.conf)
498$(nonplat_policy_raw.recovery): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
499$(nonplat_policy_raw.recovery): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.recovery.conf) \
500$(reqd_policy_mask.cil)
501 @mkdir -p $(dir $@)
502 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
503 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
504
505nonplat_policy_nvr.recovery := $(intermediates)/nonplat_policy_nvr.recovery.cil
506$(nonplat_policy_nvr.recovery) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
507$(nonplat_policy_nvr.recovery) : PRIVATE_TGT_POL := $(nonplat_policy_raw.recovery)
508$(nonplat_policy_nvr.recovery) : $(plat_pub_policy.recovery.cil) $(nonplat_policy_raw.recovery) \
509$(HOST_OUT_EXECUTABLES)/version_policy
510 @mkdir -p $(dir $@)
511 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
512
513$(LOCAL_BUILT_MODULE): $(nonplat_policy_nvr.recovery)
514 @mkdir -p $(dir $@)
515 grep -v neverallow $< > $@
516
517nonplat_policy.recovery.conf :=
518nonplat_policy_raw.recovery :=
519
520##################################
521include $(CLEAR_VARS)
522
523# keep concrete sepolicy for neverallow checks
524
525LOCAL_MODULE := sepolicy.recovery
526LOCAL_MODULE_CLASS := ETC
527LOCAL_MODULE_TAGS := optional
528LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
529
530include $(BUILD_SYSTEM)/base_rules.mk
531
532all_cil_files.recovery := \
533 $(plat_policy_nvr.recovery) \
534 $(mapping_policy_nvr.recovery) \
535 $(nonplat_policy_nvr.recovery) \
536
537$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files.recovery)
538$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files.recovery)
539 @mkdir -p $(dir $@)
540 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800541 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
542 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
543 echo "==========" 1>&2; \
544 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
545 echo "List of invalid domains:" 1>&2; \
546 cat $@.permissivedomains 1>&2; \
547 exit 1; \
548 fi
549 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400550
Dan Cashman1c040272016-12-15 15:28:44 -0800551all_cil_files.recovery :=
Stephen Smalleye60723a2014-05-29 16:40:15 -0400552
dcashman704741a2014-07-25 19:11:52 -0700553##################################
554include $(CLEAR_VARS)
555
556LOCAL_MODULE := general_sepolicy.conf
557LOCAL_MODULE_CLASS := ETC
558LOCAL_MODULE_TAGS := tests
559
560include $(BUILD_SYSTEM)/base_rules.mk
561
dcashman704741a2014-07-25 19:11:52 -0700562$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
563$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800564$(LOCAL_BUILT_MODULE): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashmancc39f632016-07-22 13:13:11 -0700565$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
566$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
dcashman704741a2014-07-25 19:11:52 -0700567 mkdir -p $(dir $@)
568 $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
569 -D target_build_variant=user \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700570 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500571 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500572 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Dan Cashman1c040272016-12-15 15:28:44 -0800573 -D target_arch=$(PRIVATE_TGT_ARCH) \
dcashman704741a2014-07-25 19:11:52 -0700574 -s $^ > $@
575 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
576
William Robertsb8769932015-06-29 16:31:23 -0700577built_general_sepolicy.conf := $(LOCAL_BUILT_MODULE)
dcashman704741a2014-07-25 19:11:52 -0700578exp_sepolicy_build_files :=
579
580##################################
Stephen Smalley01a58af2012-10-02 12:46:37 -0400581include $(CLEAR_VARS)
582
William Robertsb8769932015-06-29 16:31:23 -0700583LOCAL_MODULE := sepolicy.general
584LOCAL_MODULE_CLASS := ETC
585LOCAL_MODULE_TAGS := tests
586
587include $(BUILD_SYSTEM)/base_rules.mk
588
589$(LOCAL_BUILT_MODULE): PRIVATE_BUILT_SEPOLICY.CONF := $(built_general_sepolicy.conf)
590$(LOCAL_BUILT_MODULE): $(built_general_sepolicy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
591 @mkdir -p $(dir $@)
Nick Kralevich6ef10bd2016-02-29 16:59:33 -0800592 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@ $(PRIVATE_BUILT_SEPOLICY.CONF) > /dev/null
William Robertsb8769932015-06-29 16:31:23 -0700593
594built_general_sepolicy := $(LOCAL_BUILT_MODULE)
595##################################
596include $(CLEAR_VARS)
597
Richard Hainesc2d01912015-08-06 17:43:52 +0100598LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800599LOCAL_MODULE_CLASS := ETC
600LOCAL_MODULE_TAGS := optional
601LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
602
Stephen Smalley5b340be2012-03-06 11:12:41 -0500603include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800604
William Roberts49693f12016-01-04 12:20:57 -0800605# The file_contexts.bin is built in the following way:
606# 1. Collect all file_contexts files in THIS repository and process them with
607# m4 into a tmp file called file_contexts.local.tmp.
608# 2. Collect all device specific file_contexts files and process them with m4
609# into a tmp file called file_contexts.device.tmp.
610# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
611# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
612# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
613# file_contexts.concat.tmp.
614# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
615# file_contexts.bin.
616#
617# Note: That a newline file is placed between each file_context file found to
618# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800619
dcashmancc39f632016-07-22 13:13:11 -0700620local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
William Roberts49693f12016-01-04 12:20:57 -0800621ifneq ($(filter address,$(SANITIZE_TARGET)),)
dcashmancc39f632016-07-22 13:13:11 -0700622 local_fc_files := $(local_fc_files) $(PLAT_PRIVATE_POLICY)/file_contexts_asan
William Roberts49693f12016-01-04 12:20:57 -0800623endif
624local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
625
626file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
627$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500628 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800629 $(hide) m4 -s $^ > $@
630
631device_fc_files := $(call build_device_policy, file_contexts)
632device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
633
634file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
635$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
636$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
637 @mkdir -p $(dir $@)
638 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
639
640file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
641$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
642$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
643 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800644 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800645 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
646
647file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
648$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
649 @mkdir -p $(dir $@)
650 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500651
William Roberts3746a0a2015-09-25 10:18:44 -0700652$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800653$(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 +0100654 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800655 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100656 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
657
Robert Craig8b7545b2014-03-20 09:35:08 -0400658built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800659local_fc_files :=
660local_fcfiles_with_nl :=
661device_fc_files :=
662device_fcfiles_with_nl :=
663file_contexts.concat.tmp :=
664file_contexts.device.sorted.tmp :=
665file_contexts.device.tmp :=
666file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700667
Ying Wang02fb5f32012-01-17 17:51:09 -0800668##################################
669include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400670
Richard Hainesc2d01912015-08-06 17:43:52 +0100671LOCAL_MODULE := general_file_contexts.bin
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400672LOCAL_MODULE_CLASS := ETC
673LOCAL_MODULE_TAGS := tests
674
675include $(BUILD_SYSTEM)/base_rules.mk
676
Richard Hainesc2d01912015-08-06 17:43:52 +0100677general_file_contexts.tmp := $(intermediates)/general_file_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700678$(general_file_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, file_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400679 @mkdir -p $(dir $@)
680 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400681
William Roberts3746a0a2015-09-25 10:18:44 -0700682$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
683$(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 +0100684 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800685 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100686 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
687
688general_file_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400689
690##################################
691include $(CLEAR_VARS)
Ying Wang02fb5f32012-01-17 17:51:09 -0800692LOCAL_MODULE := seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800693LOCAL_MODULE_CLASS := ETC
694LOCAL_MODULE_TAGS := optional
695LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
696
William Roberts171a0622012-08-16 10:55:05 -0700697include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800698
dcashmancc39f632016-07-22 13:13:11 -0700699all_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts171a0622012-08-16 10:55:05 -0700700
Ying Wangd8b122c2012-10-25 19:01:31 -0700701$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts81e1f902015-06-03 21:57:47 -0700702$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(all_sc_files)
703$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(all_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700704 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700705 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800706
Robert Craig8b7545b2014-03-20 09:35:08 -0400707built_sc := $(LOCAL_BUILT_MODULE)
William Roberts81e1f902015-06-03 21:57:47 -0700708all_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400709
Ying Wang02fb5f32012-01-17 17:51:09 -0800710##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400711include $(CLEAR_VARS)
Stephen Smalley37712872015-03-12 15:46:36 -0400712LOCAL_MODULE := general_seapp_contexts
713LOCAL_MODULE_CLASS := ETC
714LOCAL_MODULE_TAGS := tests
715
716include $(BUILD_SYSTEM)/base_rules.mk
717
dcashmancc39f632016-07-22 13:13:11 -0700718all_sc_files := $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
Stephen Smalley37712872015-03-12 15:46:36 -0400719
William Robertsb8769932015-06-29 16:31:23 -0700720$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
William Roberts81e1f902015-06-03 21:57:47 -0700721$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILE := $(all_sc_files)
William Robertsb8769932015-06-29 16:31:23 -0700722$(LOCAL_BUILT_MODULE): $(built_general_sepolicy) $(all_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
Stephen Smalley37712872015-03-12 15:46:36 -0400723 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700724 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILE)
Stephen Smalley37712872015-03-12 15:46:36 -0400725
William Roberts81e1f902015-06-03 21:57:47 -0700726all_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400727
728##################################
729include $(CLEAR_VARS)
William Roberts4ee71312015-06-25 11:59:30 -0700730LOCAL_MODULE := general_seapp_neverallows
731LOCAL_MODULE_CLASS := ETC
732LOCAL_MODULE_TAGS := tests
733
734include $(BUILD_SYSTEM)/base_rules.mk
735
dcashmancc39f632016-07-22 13:13:11 -0700736$(LOCAL_BUILT_MODULE): $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
William Roberts4ee71312015-06-25 11:59:30 -0700737 @mkdir -p $(dir $@)
738 - $(hide) grep -ie '^neverallow' $< > $@
739
William Roberts4ee71312015-06-25 11:59:30 -0700740
741##################################
742include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400743
744LOCAL_MODULE := property_contexts
745LOCAL_MODULE_CLASS := ETC
746LOCAL_MODULE_TAGS := optional
747LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
748
749include $(BUILD_SYSTEM)/base_rules.mk
750
dcashmancc39f632016-07-22 13:13:11 -0700751all_pc_files := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Richard Hainesc8801fe2015-12-11 10:39:19 +0000752all_pcfiles_with_nl := $(call add_nl, $(all_pc_files), $(built_nl))
William Roberts6aabc1c2015-07-30 11:44:26 -0700753
William Robertsdcffd2b2015-09-29 13:52:37 -0700754property_contexts.tmp := $(intermediates)/property_contexts.tmp
Richard Hainesc8801fe2015-12-11 10:39:19 +0000755$(property_contexts.tmp): PRIVATE_PC_FILES := $(all_pcfiles_with_nl)
William Robertsdcffd2b2015-09-29 13:52:37 -0700756$(property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
William Roberts46749752015-12-28 15:26:20 -0800757$(property_contexts.tmp): $(all_pcfiles_with_nl)
William Roberts7f81b332015-09-29 13:52:37 -0700758 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000759 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700760
761
762$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts371918c2016-04-06 11:40:08 -0700763$(LOCAL_BUILT_MODULE): $(property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700764 @mkdir -p $(dir $@)
William Roberts371918c2016-04-06 11:40:08 -0700765 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800766 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400767
Robert Craig8b7545b2014-03-20 09:35:08 -0400768built_pc := $(LOCAL_BUILT_MODULE)
William Roberts6aabc1c2015-07-30 11:44:26 -0700769all_pc_files :=
William Roberts46749752015-12-28 15:26:20 -0800770all_pcfiles_with_nl :=
William Robertsdcffd2b2015-09-29 13:52:37 -0700771property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400772
Stephen Smalley124720a2012-04-04 10:11:16 -0400773##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700774include $(CLEAR_VARS)
775
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400776LOCAL_MODULE := general_property_contexts
777LOCAL_MODULE_CLASS := ETC
778LOCAL_MODULE_TAGS := tests
779
Stephen Smalleyc9361732015-03-13 09:36:57 -0400780include $(BUILD_SYSTEM)/base_rules.mk
781
William Robertsdcffd2b2015-09-29 13:52:37 -0700782general_property_contexts.tmp := $(intermediates)/general_property_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700783$(general_property_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, property_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400784 @mkdir -p $(dir $@)
785 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400786
William Robertsdcffd2b2015-09-29 13:52:37 -0700787$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
788$(LOCAL_BUILT_MODULE): $(general_property_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
789 @mkdir -p $(dir $@)
William Roberts371918c2016-04-06 11:40:08 -0700790 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800791 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700792
793general_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400794
795##################################
796include $(CLEAR_VARS)
797
Riley Spahnf90c41f2014-06-05 15:52:02 -0700798LOCAL_MODULE := service_contexts
799LOCAL_MODULE_CLASS := ETC
800LOCAL_MODULE_TAGS := optional
801LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
802
803include $(BUILD_SYSTEM)/base_rules.mk
804
dcashmancc39f632016-07-22 13:13:11 -0700805all_svc_files := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Richard Hainesc8801fe2015-12-11 10:39:19 +0000806all_svcfiles_with_nl := $(call add_nl, $(all_svc_files), $(built_nl))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700807
William Roberts7fc865a2015-09-29 14:17:38 -0700808service_contexts.tmp := $(intermediates)/service_contexts.tmp
Richard Hainesc8801fe2015-12-11 10:39:19 +0000809$(service_contexts.tmp): PRIVATE_SVC_FILES := $(all_svcfiles_with_nl)
William Roberts7fc865a2015-09-29 14:17:38 -0700810$(service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
William Roberts46749752015-12-28 15:26:20 -0800811$(service_contexts.tmp): $(all_svcfiles_with_nl)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700812 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700813 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700814
815$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
816$(LOCAL_BUILT_MODULE): $(service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
817 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700818 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800819 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700820
821built_svc := $(LOCAL_BUILT_MODULE)
William Roberts6aabc1c2015-07-30 11:44:26 -0700822all_svc_files :=
William Roberts46749752015-12-28 15:26:20 -0800823all_svcfiles_with_nl :=
William Roberts7fc865a2015-09-29 14:17:38 -0700824service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700825
826##################################
rpcraigb19665c2012-07-30 09:33:03 -0400827include $(CLEAR_VARS)
828
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400829LOCAL_MODULE := general_service_contexts
830LOCAL_MODULE_CLASS := ETC
831LOCAL_MODULE_TAGS := tests
832
833include $(BUILD_SYSTEM)/base_rules.mk
834
William Roberts7fc865a2015-09-29 14:17:38 -0700835general_service_contexts.tmp := $(intermediates)/general_service_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700836$(general_service_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, service_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400837 @mkdir -p $(dir $@)
838 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400839
William Roberts7fc865a2015-09-29 14:17:38 -0700840$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
841$(LOCAL_BUILT_MODULE): $(general_service_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
842 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700843 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800844 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700845
846general_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400847
848##################################
849include $(CLEAR_VARS)
850
dcashman90b3b942016-12-14 13:47:55 -0800851LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -0400852LOCAL_MODULE_CLASS := ETC
853LOCAL_MODULE_TAGS := optional
854LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
855
William Roberts2c8a55d2012-11-30 14:59:09 -0800856include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -0400857
Geremy Condracd4104e2013-03-26 18:19:12 +0000858# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -0800859plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
860$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
861$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +0000862 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700863 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +0000864
dcashman90b3b942016-12-14 13:47:55 -0800865all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -0400866
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900867# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -0800868all_plat_keys := platform media shared testkey
869all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900870
dcashman90b3b942016-12-14 13:47:55 -0800871$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
872$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
873$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +0000874 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -0700875 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -0700876 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +0000877
William Roberts6aabc1c2015-07-30 11:44:26 -0700878all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -0800879all_plat_keys :=
880plat_mac_perms_keys.tmp :=
881
882##################################
883include $(CLEAR_VARS)
884
885LOCAL_MODULE := nonplat_mac_permissions.xml
886LOCAL_MODULE_CLASS := ETC
887LOCAL_MODULE_TAGS := optional
888LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
889
890include $(BUILD_SYSTEM)/base_rules.mk
891
892# Build keys.conf
893nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
894$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
895$(nonplat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
896 @mkdir -p $(dir $@)
897 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
898
899all_nonplat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
900
901$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
902$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
903$(all_nonplat_mac_perms_files)
904 @mkdir -p $(dir $@)
905 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
906
907nonplat_mac_perms_keys.tmp :=
908all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -0700909
rpcraigb19665c2012-07-30 09:33:03 -0400910##################################
Robert Craig8b7545b2014-03-20 09:35:08 -0400911include $(CLEAR_VARS)
912
913LOCAL_MODULE := selinux_version
914LOCAL_MODULE_CLASS := ETC
915LOCAL_MODULE_TAGS := optional
916LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
917
918include $(BUILD_SYSTEM)/base_rules.mk
William Robertsda52e852015-06-27 07:22:34 -0700919$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(built_pc) $(built_fc) $(built_sc) $(built_svc)
Robert Craig8b7545b2014-03-20 09:35:08 -0400920 @mkdir -p $(dir $@)
Colin Cross29a463d2015-07-17 13:08:41 -0700921 $(hide) echo -n $(BUILD_FINGERPRINT_FROM_FILE) > $@
Robert Craig8b7545b2014-03-20 09:35:08 -0400922
923##################################
rpcraig47cd3962012-10-17 21:09:52 -0400924
Dan Cashman1c040272016-12-15 15:28:44 -0800925add_nl :=
William Roberts49693f12016-01-04 12:20:57 -0800926build_device_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -0800927build_policy :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400928built_fc :=
William Robertsb8769932015-06-29 16:31:23 -0700929built_general_sepolicy :=
930built_general_sepolicy.conf :=
Richard Hainesc8801fe2015-12-11 10:39:19 +0000931built_nl :=
Dan Cashman1c040272016-12-15 15:28:44 -0800932built_pc :=
933built_sc :=
934built_sepolicy :=
935built_svc :=
936mapping_policy_nvr :=
937mapping_policy_nvr.recovery :=
938my_target_arch :=
939nonplat_policy_nvr :=
940nonplat_policy_nvr.recovery :=
941plat_policy_nvr :=
942plat_policy_nvr.recovery :=
dcashman1faa6442016-11-28 07:20:28 -0800943plat_pub_policy.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -0800944plat_pub_policy.recovery.cil :=
dcashman1faa6442016-11-28 07:20:28 -0800945reqd_policy_mask.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -0800946sepolicy_build_files :=
Alice Chucdfb06f2012-11-01 11:33:04 -0700947
948include $(call all-makefiles-under,$(LOCAL_PATH))