blob: 4e52c1f2f72fecab400436d1d88a05fd26759d1d [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001LOCAL_PATH:= $(call my-dir)
William Robertsf0e0a942012-08-27 15:41:15 -07002
Stephen Smalley2dd4e512012-01-04 12:33:27 -05003include $(CLEAR_VARS)
4
5# SELinux policy version.
Stephen Smalleyb4f17062015-03-13 10:03:52 -04006# Must be <= /sys/fs/selinux/policyvers reported by the Android kernel.
Stephen Smalley2dd4e512012-01-04 12:33:27 -05007# Must be within the compatibility range reported by checkpolicy -V.
Jeff Vander Stoep3a0ce492015-12-07 08:30:43 -08008POLICYVERS ?= 30
Stephen Smalley2dd4e512012-01-04 12:33:27 -05009
10MLS_SENS=1
11MLS_CATS=1024
12
Stephen Smalleyb4f17062015-03-13 10:03:52 -040013ifdef BOARD_SEPOLICY_REPLACE
14$(error BOARD_SEPOLICY_REPLACE is no longer supported; please remove from your BoardConfig.mk or other .mk file.)
15endif
16
17ifdef BOARD_SEPOLICY_IGNORE
18$(error BOARD_SEPOLICY_IGNORE is no longer supported; please remove from your BoardConfig.mk or other .mk file.)
19endif
Stephen Smalley5b340be2012-03-06 11:12:41 -050020
Stephen Smalley8e0ca882015-04-01 10:14:56 -040021ifdef BOARD_SEPOLICY_UNION
22$(warning BOARD_SEPOLICY_UNION is no longer required - all files found in BOARD_SEPOLICY_DIRS are implicitly unioned; please remove from your BoardConfig.mk or other .mk file.)
23endif
Robert Craig6b0ff472014-01-29 13:10:58 -050024
William Robertsd2185582015-07-16 11:28:02 -070025ifdef BOARD_SEPOLICY_M4DEFS
26LOCAL_ADDITIONAL_M4DEFS := $(addprefix -D, $(BOARD_SEPOLICY_M4DEFS))
27endif
28
dcashmancc39f632016-07-22 13:13:11 -070029# sepolicy is now divided into multiple portions:
30# public - policy exported on which non-platform policy developers may write
31# additional policy. types and attributes are versioned and included in
32# delivered non-platform policy, which is to be combined with platform policy.
33# private - platform-only policy required for platform functionality but which
34# is not exported to vendor policy developers and as such may not be assumed
35# to exist.
dcashman07791552016-12-07 11:27:47 -080036# mapping - This contains policy statements which map the attributes
dcashmancc39f632016-07-22 13:13:11 -070037# exposed in the public policy of previous versions to the concrete types used
38# in this policy to ensure that policy targeting attributes from public
39# policy from an older platform version continues to work.
40
dcashman2e00e632016-10-12 14:58:09 -070041# build process for device:
dcashmancc39f632016-07-22 13:13:11 -070042# 1) convert policies to CIL:
43# - private + public platform policy to CIL
44# - mapping file to CIL (should already be in CIL form)
45# - non-platform public policy to CIL
46# - non-platform public + private policy to CIL
47# 2) attributize policy
dcashmancc39f632016-07-22 13:13:11 -070048# - run script which takes non-platform public and non-platform combined
49# private + public policy and produces attributized and versioned
50# non-platform policy
51# 3) combine policy files
52# - combine mapping, platform and non-platform policy.
53# - compile output binary policy file
54
55PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/public
56PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private
dcashman2e00e632016-10-12 14:58:09 -070057REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask
58
59# TODO: move to README when doing the README update and finalizing versioning.
60# BOARD_SEPOLICY_VERS should contain the platform version identifier
61# corresponding to the platform on which the non-platform policy is to be
62# based. If unspecified, this will build against the current public platform
63# policy in tree.
64# BOARD_SEPOLICY_VERS_DIR should contain the public platform policy which
65# is associated with the given BOARD_SEPOLICY_VERS. The policy therein will be
66# versioned according to the BOARD_SEPOLICY_VERS identifier and included as
67# part of the non-platform policy to ensure removal of access in future
68# platform policy does not break non-platform policy.
69ifndef BOARD_SEPOLICY_VERS
70$(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version)
71BOARD_SEPOLICY_VERS := current
72BOARD_SEPOLICY_VERS_DIR := $(PLAT_PUBLIC_POLICY)
73else
74ifndef BOARD_SEPOLICY_VERS_DIR
75$(error BOARD_SEPOLICY_VERS_DIR not specified for versioned sepolicy.)
76endif
77endif
dcashmancc39f632016-07-22 13:13:11 -070078
79###########################################################
80# Compute policy files to be used in policy build.
81# $(1): files to include
82# $(2): directories in which to find files
83###########################################################
84
85define build_policy
86$(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))
87endef
William Roberts29d14682016-01-04 12:20:57 -080088
William Roberts49693f12016-01-04 12:20:57 -080089# Builds paths for all policy files found in BOARD_SEPOLICY_DIRS.
90# $(1): the set of policy name paths to build
dcashmancc39f632016-07-22 13:13:11 -070091build_device_policy = $(call build_policy, $(1), $(BOARD_SEPOLICY_DIRS))
William Roberts49693f12016-01-04 12:20:57 -080092
Richard Hainesc8801fe2015-12-11 10:39:19 +000093# Add a file containing only a newline in-between each policy configuration
94# 'contexts' file. This will allow OEM policy configuration files without a
95# final newline (0x0A) to be built correctly by the m4(1) macro processor.
96# $(1): the set of contexts file names.
97# $(2): the file containing only 0x0A.
98add_nl = $(foreach entry, $(1), $(subst $(entry), $(entry) $(2), $(entry)))
99
dcashman704741a2014-07-25 19:11:52 -0700100sepolicy_build_files := security_classes \
101 initial_sids \
102 access_vectors \
103 global_macros \
Nick Kralevicha17a2662014-11-05 15:30:41 -0800104 neverallow_macros \
dcashman704741a2014-07-25 19:11:52 -0700105 mls_macros \
dcashman2e00e632016-10-12 14:58:09 -0700106 mls_decl \
dcashman704741a2014-07-25 19:11:52 -0700107 mls \
108 policy_capabilities \
109 te_macros \
110 attributes \
Jeff Vander Stoepcbaa2b72015-12-22 10:39:34 -0800111 ioctl_defines \
Jeff Vander Stoepde9b5302015-06-05 15:28:55 -0700112 ioctl_macros \
dcashman704741a2014-07-25 19:11:52 -0700113 *.te \
dcashman2e00e632016-10-12 14:58:09 -0700114 roles_decl \
dcashman704741a2014-07-25 19:11:52 -0700115 roles \
116 users \
117 initial_sid_contexts \
118 fs_use \
119 genfs_contexts \
120 port_contexts
121
Ying Wang02fb5f32012-01-17 17:51:09 -0800122##################################
dcashman2e00e632016-10-12 14:58:09 -0700123# reqd_policy_mask - a policy.conf file which contains only the bare minimum
124# policy necessary to use checkpolicy. This bare-minimum policy needs to be
125# present in all policy.conf files, but should not necessarily be exported as
126# part of the public policy. The rules generated by reqd_policy_mask will allow
127# the compilation of public policy and subsequent removal of CIL policy that
128# should not be exported.
129
130reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
131$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
132$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
133$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
134$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
135 @mkdir -p $(dir $@)
136 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
137 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
138 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
139 -s $^ > $@
140
141reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
142$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
143 @mkdir -p $(dir $@)
144 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
145
dcashman1faa6442016-11-28 07:20:28 -0800146reqd_policy_mask.conf :=
147
148##################################
dcashman2e00e632016-10-12 14:58:09 -0700149# plat_pub_policy - policy that will be exported to be a part of non-platform
150# policy corresponding to this platform version. This is a limited subset of
151# policy that would not compile in checkpolicy on its own. To get around this
152# limitation, add only the required files from private policy, which will
153# generate CIL policy that will then be filtered out by the reqd_policy_mask.
154plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
155$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
156$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
157$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
158$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
159$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY))
160 @mkdir -p $(dir $@)
161 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
162 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
163 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
164 -s $^ > $@
165
166plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800167$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
168$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
169$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700170 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800171 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
172 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700173
dcashman1faa6442016-11-28 07:20:28 -0800174plat_pub_policy.conf :=
175##################################
176include $(CLEAR_VARS)
177
178LOCAL_MODULE := sectxfile_nl
179LOCAL_MODULE_CLASS := ETC
180LOCAL_MODULE_TAGS := optional
181
182# Create a file containing newline only to add between context config files
183include $(BUILD_SYSTEM)/base_rules.mk
184$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700185 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800186 $(hide) echo > $@
187
188built_nl := $(LOCAL_BUILT_MODULE)
189
190#################################
191include $(CLEAR_VARS)
192
193LOCAL_MODULE := plat_sepolicy.cil
194LOCAL_MODULE_CLASS := ETC
195LOCAL_MODULE_TAGS := optional
196LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
197LOCAL_TARGET_ARCH := $(TARGET_ARCH)
198
199# Set LOCAL_TARGET_ARCH to mips for mips and mips64.
200ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
201 LOCAL_TARGET_ARCH := mips
202endif
203
204include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700205
206# plat_policy.conf - A combination of the private and public platform policy
207# which will ship with the device. The platform will always reflect the most
208# recent platform version and is not currently being attributized.
209plat_policy.conf := $(intermediates)/plat_policy.conf
210$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
211$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
212$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
213$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700214$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
215 @mkdir -p $(dir $@)
216 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
217 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
218 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700219 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500220 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500221 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
dcashmancc39f632016-07-22 13:13:11 -0700222 -s $^ > $@
223 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
224
dcashman1faa6442016-11-28 07:20:28 -0800225plat_policy_nvr := $(intermediates)/plat_policy_nvr.cil
226$(plat_policy_nvr): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
dcashman2e00e632016-10-12 14:58:09 -0700227 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800228 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
dcashmancc39f632016-07-22 13:13:11 -0700229
dcashman1faa6442016-11-28 07:20:28 -0800230$(LOCAL_BUILT_MODULE): $(plat_policy_nvr)
231 @mkdir -p $(dir $@)
232 grep -v neverallow $< > $@
233
234plat_policy.conf :=
235
236#################################
237include $(CLEAR_VARS)
238
239LOCAL_MODULE := mapping_sepolicy.cil
240LOCAL_MODULE_CLASS := ETC
241LOCAL_MODULE_TAGS := optional
242LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
243LOCAL_TARGET_ARCH := $(TARGET_ARCH)
244
245# Set LOCAL_TARGET_ARCH to mips for mips and mips64.
246ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
247 LOCAL_TARGET_ARCH := mips
248endif
249
250include $(BUILD_SYSTEM)/base_rules.mk
251
252# auto-generate the mapping file for current platform policy, since it needs to
253# track platform policy development
254current_mapping.cil := $(intermediates)/mapping/current.cil
255$(current_mapping.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
256$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
257 @mkdir -p $(dir $@)
258 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
259
260ifeq ($(BOARD_SEPOLICY_VERS), current)
261mapping_policy_nvr := $(current_mapping.cil)
262else
263mapping_policy_nvr := $(addsuffix /$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)/mapping)
264endif
265
266$(LOCAL_BUILT_MODULE): $(mapping_policy_nvr)
267 grep -v neverallow $< > $@
268
269current_mapping.cil :=
270
271#################################
272include $(CLEAR_VARS)
273
274LOCAL_MODULE := nonplat_sepolicy.cil
275LOCAL_MODULE_CLASS := ETC
276LOCAL_MODULE_TAGS := optional
277LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
278LOCAL_TARGET_ARCH := $(TARGET_ARCH)
279
280# Set LOCAL_TARGET_ARCH to mips for mips and mips64.
281ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
282 LOCAL_TARGET_ARCH := mips
283endif
284
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)
295$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
296$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
297$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY) $(BOARD_SEPOLICY_DIRS))
Ying Wang02fb5f32012-01-17 17:51:09 -0800298 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700299 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
300 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800301 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700302 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500303 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500304 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Douglas Leung5807d1d2016-07-28 15:49:31 -0700305 -D target_arch=$(LOCAL_TARGET_ARCH) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800306 -s $^ > $@
Robert Craig65d4f442013-03-27 06:30:25 -0400307 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500308
dcashman1faa6442016-11-28 07:20:28 -0800309nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
310$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
311$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
312$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
313$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800314 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800315 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
316 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700317
dcashman1faa6442016-11-28 07:20:28 -0800318nonplat_policy_nvr := $(intermediates)/nonplat_policy_nvr.cil
319$(nonplat_policy_nvr) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
320$(nonplat_policy_nvr) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
321$(nonplat_policy_nvr) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
dcashman2e00e632016-10-12 14:58:09 -0700322$(HOST_OUT_EXECUTABLES)/version_policy
323 @mkdir -p $(dir $@)
324 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
325
dcashman1faa6442016-11-28 07:20:28 -0800326$(LOCAL_BUILT_MODULE): $(nonplat_policy_nvr)
dcashman2e00e632016-10-12 14:58:09 -0700327 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800328 grep -v neverallow $< > $@
dcashman2e00e632016-10-12 14:58:09 -0700329
dcashman1faa6442016-11-28 07:20:28 -0800330nonplat_policy.conf :=
331nonplat_policy_raw :=
332
333#################################
334include $(CLEAR_VARS)
335# TODO: keep the built sepolicy around for now until we're ready to switch over.
336
337LOCAL_MODULE := sepolicy
338LOCAL_MODULE_CLASS := ETC
339LOCAL_MODULE_TAGS := optional
340LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
341LOCAL_TARGET_ARCH := $(TARGET_ARCH)
342
343# Set LOCAL_TARGET_ARCH to mips for mips and mips64.
344ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
345 LOCAL_TARGET_ARCH := mips
dcashman2e00e632016-10-12 14:58:09 -0700346endif
347
dcashman1faa6442016-11-28 07:20:28 -0800348include $(BUILD_SYSTEM)/base_rules.mk
349
dcashman2e00e632016-10-12 14:58:09 -0700350all_cil_files := \
dcashman1faa6442016-11-28 07:20:28 -0800351 $(plat_policy_nvr) \
352 $(mapping_policy_nvr) \
353 $(nonplat_policy_nvr) \
dcashman2e00e632016-10-12 14:58:09 -0700354
355$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
356$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
357 @mkdir -p $(dir $@)
358 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800359 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
360 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
361 echo "==========" 1>&2; \
362 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
363 echo "List of invalid domains:" 1>&2; \
364 cat $@.permissivedomains 1>&2; \
365 exit 1; \
366 fi
367 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800368
Ying Wangd8b122c2012-10-25 19:01:31 -0700369built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700370all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400371
Stephen Smalleye60723a2014-05-29 16:40:15 -0400372##################################
373include $(CLEAR_VARS)
374
375LOCAL_MODULE := sepolicy.recovery
376LOCAL_MODULE_CLASS := ETC
377LOCAL_MODULE_TAGS := eng
378
379include $(BUILD_SYSTEM)/base_rules.mk
380
381sepolicy_policy_recovery.conf := $(intermediates)/policy_recovery.conf
382$(sepolicy_policy_recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
383$(sepolicy_policy_recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
William Robertsd2185582015-07-16 11:28:02 -0700384$(sepolicy_policy_recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
dcashmancc39f632016-07-22 13:13:11 -0700385$(sepolicy_policy_recovery.conf): $(call build_policy, $(sepolicy_build_files), \
386$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Stephen Smalleye60723a2014-05-29 16:40:15 -0400387 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700388 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
389 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400390 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700391 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500392 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500393 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400394 -D target_recovery=true \
395 -s $^ > $@
396
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800397$(LOCAL_BUILT_MODULE): $(sepolicy_policy_recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Stephen Smalleye60723a2014-05-29 16:40:15 -0400398 @mkdir -p $(dir $@)
Nick Kralevich6ef10bd2016-02-29 16:59:33 -0800399 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@.tmp $< > /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800400 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
401 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
402 echo "==========" 1>&2; \
403 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
404 echo "List of invalid domains:" 1>&2; \
405 cat $@.permissivedomains 1>&2; \
406 exit 1; \
407 fi
408 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400409
410built_sepolicy_recovery := $(LOCAL_BUILT_MODULE)
411sepolicy_policy_recovery.conf :=
412
dcashman704741a2014-07-25 19:11:52 -0700413##################################
414include $(CLEAR_VARS)
415
416LOCAL_MODULE := general_sepolicy.conf
417LOCAL_MODULE_CLASS := ETC
418LOCAL_MODULE_TAGS := tests
419
420include $(BUILD_SYSTEM)/base_rules.mk
421
dcashman704741a2014-07-25 19:11:52 -0700422$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
423$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
dcashmancc39f632016-07-22 13:13:11 -0700424$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
425$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
dcashman704741a2014-07-25 19:11:52 -0700426 mkdir -p $(dir $@)
427 $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
428 -D target_build_variant=user \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700429 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500430 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500431 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
dcashman704741a2014-07-25 19:11:52 -0700432 -s $^ > $@
433 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
434
William Robertsb8769932015-06-29 16:31:23 -0700435built_general_sepolicy.conf := $(LOCAL_BUILT_MODULE)
dcashman704741a2014-07-25 19:11:52 -0700436exp_sepolicy_build_files :=
437
438##################################
Stephen Smalley01a58af2012-10-02 12:46:37 -0400439include $(CLEAR_VARS)
440
William Robertsb8769932015-06-29 16:31:23 -0700441LOCAL_MODULE := sepolicy.general
442LOCAL_MODULE_CLASS := ETC
443LOCAL_MODULE_TAGS := tests
444
445include $(BUILD_SYSTEM)/base_rules.mk
446
447$(LOCAL_BUILT_MODULE): PRIVATE_BUILT_SEPOLICY.CONF := $(built_general_sepolicy.conf)
448$(LOCAL_BUILT_MODULE): $(built_general_sepolicy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
449 @mkdir -p $(dir $@)
Nick Kralevich6ef10bd2016-02-29 16:59:33 -0800450 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@ $(PRIVATE_BUILT_SEPOLICY.CONF) > /dev/null
William Robertsb8769932015-06-29 16:31:23 -0700451
452built_general_sepolicy := $(LOCAL_BUILT_MODULE)
453##################################
454include $(CLEAR_VARS)
455
Richard Hainesc2d01912015-08-06 17:43:52 +0100456LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800457LOCAL_MODULE_CLASS := ETC
458LOCAL_MODULE_TAGS := optional
459LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
460
Stephen Smalley5b340be2012-03-06 11:12:41 -0500461include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800462
William Roberts49693f12016-01-04 12:20:57 -0800463# The file_contexts.bin is built in the following way:
464# 1. Collect all file_contexts files in THIS repository and process them with
465# m4 into a tmp file called file_contexts.local.tmp.
466# 2. Collect all device specific file_contexts files and process them with m4
467# into a tmp file called file_contexts.device.tmp.
468# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
469# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
470# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
471# file_contexts.concat.tmp.
472# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
473# file_contexts.bin.
474#
475# Note: That a newline file is placed between each file_context file found to
476# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800477
dcashmancc39f632016-07-22 13:13:11 -0700478local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
William Roberts49693f12016-01-04 12:20:57 -0800479ifneq ($(filter address,$(SANITIZE_TARGET)),)
dcashmancc39f632016-07-22 13:13:11 -0700480 local_fc_files := $(local_fc_files) $(PLAT_PRIVATE_POLICY)/file_contexts_asan
William Roberts49693f12016-01-04 12:20:57 -0800481endif
482local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
483
484file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
485$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500486 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800487 $(hide) m4 -s $^ > $@
488
489device_fc_files := $(call build_device_policy, file_contexts)
490device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
491
492file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
493$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
494$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
495 @mkdir -p $(dir $@)
496 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
497
498file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
499$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
500$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
501 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800502 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800503 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
504
505file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
506$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
507 @mkdir -p $(dir $@)
508 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500509
William Roberts3746a0a2015-09-25 10:18:44 -0700510$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800511$(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 +0100512 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800513 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100514 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
515
Robert Craig8b7545b2014-03-20 09:35:08 -0400516built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800517local_fc_files :=
518local_fcfiles_with_nl :=
519device_fc_files :=
520device_fcfiles_with_nl :=
521file_contexts.concat.tmp :=
522file_contexts.device.sorted.tmp :=
523file_contexts.device.tmp :=
524file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700525
Ying Wang02fb5f32012-01-17 17:51:09 -0800526##################################
527include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400528
Richard Hainesc2d01912015-08-06 17:43:52 +0100529LOCAL_MODULE := general_file_contexts.bin
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400530LOCAL_MODULE_CLASS := ETC
531LOCAL_MODULE_TAGS := tests
532
533include $(BUILD_SYSTEM)/base_rules.mk
534
Richard Hainesc2d01912015-08-06 17:43:52 +0100535general_file_contexts.tmp := $(intermediates)/general_file_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700536$(general_file_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, file_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400537 @mkdir -p $(dir $@)
538 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400539
William Roberts3746a0a2015-09-25 10:18:44 -0700540$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
541$(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 +0100542 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800543 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100544 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
545
546general_file_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400547
548##################################
549include $(CLEAR_VARS)
Ying Wang02fb5f32012-01-17 17:51:09 -0800550LOCAL_MODULE := seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800551LOCAL_MODULE_CLASS := ETC
552LOCAL_MODULE_TAGS := optional
553LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
554
William Roberts171a0622012-08-16 10:55:05 -0700555include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800556
dcashmancc39f632016-07-22 13:13:11 -0700557all_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts171a0622012-08-16 10:55:05 -0700558
Ying Wangd8b122c2012-10-25 19:01:31 -0700559$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts81e1f902015-06-03 21:57:47 -0700560$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(all_sc_files)
561$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(all_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700562 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700563 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800564
Robert Craig8b7545b2014-03-20 09:35:08 -0400565built_sc := $(LOCAL_BUILT_MODULE)
William Roberts81e1f902015-06-03 21:57:47 -0700566all_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400567
Ying Wang02fb5f32012-01-17 17:51:09 -0800568##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400569include $(CLEAR_VARS)
Stephen Smalley37712872015-03-12 15:46:36 -0400570LOCAL_MODULE := general_seapp_contexts
571LOCAL_MODULE_CLASS := ETC
572LOCAL_MODULE_TAGS := tests
573
574include $(BUILD_SYSTEM)/base_rules.mk
575
dcashmancc39f632016-07-22 13:13:11 -0700576all_sc_files := $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
Stephen Smalley37712872015-03-12 15:46:36 -0400577
William Robertsb8769932015-06-29 16:31:23 -0700578$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
William Roberts81e1f902015-06-03 21:57:47 -0700579$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILE := $(all_sc_files)
William Robertsb8769932015-06-29 16:31:23 -0700580$(LOCAL_BUILT_MODULE): $(built_general_sepolicy) $(all_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
Stephen Smalley37712872015-03-12 15:46:36 -0400581 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700582 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILE)
Stephen Smalley37712872015-03-12 15:46:36 -0400583
William Roberts81e1f902015-06-03 21:57:47 -0700584all_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400585
586##################################
587include $(CLEAR_VARS)
William Roberts4ee71312015-06-25 11:59:30 -0700588LOCAL_MODULE := general_seapp_neverallows
589LOCAL_MODULE_CLASS := ETC
590LOCAL_MODULE_TAGS := tests
591
592include $(BUILD_SYSTEM)/base_rules.mk
593
dcashmancc39f632016-07-22 13:13:11 -0700594$(LOCAL_BUILT_MODULE): $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
William Roberts4ee71312015-06-25 11:59:30 -0700595 @mkdir -p $(dir $@)
596 - $(hide) grep -ie '^neverallow' $< > $@
597
William Roberts4ee71312015-06-25 11:59:30 -0700598
599##################################
600include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400601
602LOCAL_MODULE := property_contexts
603LOCAL_MODULE_CLASS := ETC
604LOCAL_MODULE_TAGS := optional
605LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
606
607include $(BUILD_SYSTEM)/base_rules.mk
608
dcashmancc39f632016-07-22 13:13:11 -0700609all_pc_files := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Richard Hainesc8801fe2015-12-11 10:39:19 +0000610all_pcfiles_with_nl := $(call add_nl, $(all_pc_files), $(built_nl))
William Roberts6aabc1c2015-07-30 11:44:26 -0700611
William Robertsdcffd2b2015-09-29 13:52:37 -0700612property_contexts.tmp := $(intermediates)/property_contexts.tmp
Richard Hainesc8801fe2015-12-11 10:39:19 +0000613$(property_contexts.tmp): PRIVATE_PC_FILES := $(all_pcfiles_with_nl)
William Robertsdcffd2b2015-09-29 13:52:37 -0700614$(property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
William Roberts46749752015-12-28 15:26:20 -0800615$(property_contexts.tmp): $(all_pcfiles_with_nl)
William Roberts7f81b332015-09-29 13:52:37 -0700616 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000617 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700618
619
620$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts371918c2016-04-06 11:40:08 -0700621$(LOCAL_BUILT_MODULE): $(property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700622 @mkdir -p $(dir $@)
William Roberts371918c2016-04-06 11:40:08 -0700623 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800624 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400625
Robert Craig8b7545b2014-03-20 09:35:08 -0400626built_pc := $(LOCAL_BUILT_MODULE)
William Roberts6aabc1c2015-07-30 11:44:26 -0700627all_pc_files :=
William Roberts46749752015-12-28 15:26:20 -0800628all_pcfiles_with_nl :=
William Robertsdcffd2b2015-09-29 13:52:37 -0700629property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400630
Stephen Smalley124720a2012-04-04 10:11:16 -0400631##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700632include $(CLEAR_VARS)
633
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400634LOCAL_MODULE := general_property_contexts
635LOCAL_MODULE_CLASS := ETC
636LOCAL_MODULE_TAGS := tests
637
Stephen Smalleyc9361732015-03-13 09:36:57 -0400638include $(BUILD_SYSTEM)/base_rules.mk
639
William Robertsdcffd2b2015-09-29 13:52:37 -0700640general_property_contexts.tmp := $(intermediates)/general_property_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700641$(general_property_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, property_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400642 @mkdir -p $(dir $@)
643 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400644
William Robertsdcffd2b2015-09-29 13:52:37 -0700645$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
646$(LOCAL_BUILT_MODULE): $(general_property_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
647 @mkdir -p $(dir $@)
William Roberts371918c2016-04-06 11:40:08 -0700648 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800649 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700650
651general_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400652
653##################################
654include $(CLEAR_VARS)
655
Riley Spahnf90c41f2014-06-05 15:52:02 -0700656LOCAL_MODULE := service_contexts
657LOCAL_MODULE_CLASS := ETC
658LOCAL_MODULE_TAGS := optional
659LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
660
661include $(BUILD_SYSTEM)/base_rules.mk
662
dcashmancc39f632016-07-22 13:13:11 -0700663all_svc_files := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Richard Hainesc8801fe2015-12-11 10:39:19 +0000664all_svcfiles_with_nl := $(call add_nl, $(all_svc_files), $(built_nl))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700665
William Roberts7fc865a2015-09-29 14:17:38 -0700666service_contexts.tmp := $(intermediates)/service_contexts.tmp
Richard Hainesc8801fe2015-12-11 10:39:19 +0000667$(service_contexts.tmp): PRIVATE_SVC_FILES := $(all_svcfiles_with_nl)
William Roberts7fc865a2015-09-29 14:17:38 -0700668$(service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
William Roberts46749752015-12-28 15:26:20 -0800669$(service_contexts.tmp): $(all_svcfiles_with_nl)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700670 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700671 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700672
673$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
674$(LOCAL_BUILT_MODULE): $(service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
675 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700676 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800677 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700678
679built_svc := $(LOCAL_BUILT_MODULE)
William Roberts6aabc1c2015-07-30 11:44:26 -0700680all_svc_files :=
William Roberts46749752015-12-28 15:26:20 -0800681all_svcfiles_with_nl :=
William Roberts7fc865a2015-09-29 14:17:38 -0700682service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700683
684##################################
rpcraigb19665c2012-07-30 09:33:03 -0400685include $(CLEAR_VARS)
686
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400687LOCAL_MODULE := general_service_contexts
688LOCAL_MODULE_CLASS := ETC
689LOCAL_MODULE_TAGS := tests
690
691include $(BUILD_SYSTEM)/base_rules.mk
692
William Roberts7fc865a2015-09-29 14:17:38 -0700693general_service_contexts.tmp := $(intermediates)/general_service_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700694$(general_service_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, service_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400695 @mkdir -p $(dir $@)
696 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400697
William Roberts7fc865a2015-09-29 14:17:38 -0700698$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
699$(LOCAL_BUILT_MODULE): $(general_service_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
700 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700701 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800702 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700703
704general_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400705
706##################################
707include $(CLEAR_VARS)
708
dcashman90b3b942016-12-14 13:47:55 -0800709LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -0400710LOCAL_MODULE_CLASS := ETC
711LOCAL_MODULE_TAGS := optional
712LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
713
William Roberts2c8a55d2012-11-30 14:59:09 -0800714include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -0400715
Geremy Condracd4104e2013-03-26 18:19:12 +0000716# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -0800717plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
718$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
719$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +0000720 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700721 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +0000722
dcashman90b3b942016-12-14 13:47:55 -0800723all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -0400724
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900725# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -0800726all_plat_keys := platform media shared testkey
727all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900728
dcashman90b3b942016-12-14 13:47:55 -0800729$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
730$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
731$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +0000732 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -0700733 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -0700734 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +0000735
William Roberts6aabc1c2015-07-30 11:44:26 -0700736all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -0800737all_plat_keys :=
738plat_mac_perms_keys.tmp :=
739
740##################################
741include $(CLEAR_VARS)
742
743LOCAL_MODULE := nonplat_mac_permissions.xml
744LOCAL_MODULE_CLASS := ETC
745LOCAL_MODULE_TAGS := optional
746LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
747
748include $(BUILD_SYSTEM)/base_rules.mk
749
750# Build keys.conf
751nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
752$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
753$(nonplat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
754 @mkdir -p $(dir $@)
755 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
756
757all_nonplat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
758
759$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
760$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
761$(all_nonplat_mac_perms_files)
762 @mkdir -p $(dir $@)
763 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
764
765nonplat_mac_perms_keys.tmp :=
766all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -0700767
rpcraigb19665c2012-07-30 09:33:03 -0400768##################################
Robert Craig8b7545b2014-03-20 09:35:08 -0400769include $(CLEAR_VARS)
770
771LOCAL_MODULE := selinux_version
772LOCAL_MODULE_CLASS := ETC
773LOCAL_MODULE_TAGS := optional
774LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
775
776include $(BUILD_SYSTEM)/base_rules.mk
William Robertsda52e852015-06-27 07:22:34 -0700777$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(built_pc) $(built_fc) $(built_sc) $(built_svc)
Robert Craig8b7545b2014-03-20 09:35:08 -0400778 @mkdir -p $(dir $@)
Colin Cross29a463d2015-07-17 13:08:41 -0700779 $(hide) echo -n $(BUILD_FINGERPRINT_FROM_FILE) > $@
Robert Craig8b7545b2014-03-20 09:35:08 -0400780
781##################################
rpcraig47cd3962012-10-17 21:09:52 -0400782
783build_policy :=
William Roberts49693f12016-01-04 12:20:57 -0800784build_device_policy :=
dcashman704741a2014-07-25 19:11:52 -0700785sepolicy_build_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400786built_sepolicy :=
William Roberts50a478e2015-12-28 16:19:54 -0800787built_sepolicy_recovery :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400788built_sc :=
789built_fc :=
790built_pc :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700791built_svc :=
William Robertsb8769932015-06-29 16:31:23 -0700792built_general_sepolicy :=
793built_general_sepolicy.conf :=
Richard Hainesc8801fe2015-12-11 10:39:19 +0000794built_nl :=
William Roberts50a478e2015-12-28 16:19:54 -0800795add_nl :=
dcashman1faa6442016-11-28 07:20:28 -0800796plat_pub_policy.cil :=
797reqd_policy_mask.cil :=
Alice Chucdfb06f2012-11-01 11:33:04 -0700798
799include $(call all-makefiles-under,$(LOCAL_PATH))