blob: 520914553fc59aa0101f1deaf7229f7c09297f80 [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.
36# mapping - TODO. This contains policy statements which map the attributes
37# exposed in the public policy of previous versions to the concrete types used
38# in this policy to ensure that policy targeting attributes from public
39# policy from an older platform version continues to work.
40
dcashman2e00e632016-10-12 14:58:09 -070041# build process for device:
dcashmancc39f632016-07-22 13:13:11 -070042# 1) convert policies to CIL:
43# - private + public platform policy to CIL
44# - mapping file to CIL (should already be in CIL form)
45# - non-platform public policy to CIL
46# - non-platform public + private policy to CIL
47# 2) attributize policy
dcashmancc39f632016-07-22 13:13:11 -070048# - run script which takes non-platform public and non-platform combined
49# private + public policy and produces attributized and versioned
50# non-platform policy
51# 3) combine policy files
52# - combine mapping, platform and non-platform policy.
53# - compile output binary policy file
54
55PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/public
56PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private
dcashman2e00e632016-10-12 14:58:09 -070057REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask
58
59# TODO: move to README when doing the README update and finalizing versioning.
60# BOARD_SEPOLICY_VERS should contain the platform version identifier
61# corresponding to the platform on which the non-platform policy is to be
62# based. If unspecified, this will build against the current public platform
63# policy in tree.
64# BOARD_SEPOLICY_VERS_DIR should contain the public platform policy which
65# is associated with the given BOARD_SEPOLICY_VERS. The policy therein will be
66# versioned according to the BOARD_SEPOLICY_VERS identifier and included as
67# part of the non-platform policy to ensure removal of access in future
68# platform policy does not break non-platform policy.
69ifndef BOARD_SEPOLICY_VERS
70$(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version)
71BOARD_SEPOLICY_VERS := current
72BOARD_SEPOLICY_VERS_DIR := $(PLAT_PUBLIC_POLICY)
73else
74ifndef BOARD_SEPOLICY_VERS_DIR
75$(error BOARD_SEPOLICY_VERS_DIR not specified for versioned sepolicy.)
76endif
77endif
dcashmancc39f632016-07-22 13:13:11 -070078
79###########################################################
80# Compute policy files to be used in policy build.
81# $(1): files to include
82# $(2): directories in which to find files
83###########################################################
84
85define build_policy
86$(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))
87endef
William Roberts29d14682016-01-04 12:20:57 -080088
William Roberts49693f12016-01-04 12:20:57 -080089# Builds paths for all policy files found in BOARD_SEPOLICY_DIRS.
90# $(1): the set of policy name paths to build
dcashmancc39f632016-07-22 13:13:11 -070091build_device_policy = $(call build_policy, $(1), $(BOARD_SEPOLICY_DIRS))
William Roberts49693f12016-01-04 12:20:57 -080092
Richard Hainesc8801fe2015-12-11 10:39:19 +000093# Add a file containing only a newline in-between each policy configuration
94# 'contexts' file. This will allow OEM policy configuration files without a
95# final newline (0x0A) to be built correctly by the m4(1) macro processor.
96# $(1): the set of contexts file names.
97# $(2): the file containing only 0x0A.
98add_nl = $(foreach entry, $(1), $(subst $(entry), $(entry) $(2), $(entry)))
99
dcashman704741a2014-07-25 19:11:52 -0700100sepolicy_build_files := security_classes \
101 initial_sids \
102 access_vectors \
103 global_macros \
Nick Kralevicha17a2662014-11-05 15:30:41 -0800104 neverallow_macros \
dcashman704741a2014-07-25 19:11:52 -0700105 mls_macros \
dcashman2e00e632016-10-12 14:58:09 -0700106 mls_decl \
dcashman704741a2014-07-25 19:11:52 -0700107 mls \
108 policy_capabilities \
109 te_macros \
110 attributes \
Jeff Vander Stoepcbaa2b72015-12-22 10:39:34 -0800111 ioctl_defines \
Jeff Vander Stoepde9b5302015-06-05 15:28:55 -0700112 ioctl_macros \
dcashman704741a2014-07-25 19:11:52 -0700113 *.te \
dcashman2e00e632016-10-12 14:58:09 -0700114 roles_decl \
dcashman704741a2014-07-25 19:11:52 -0700115 roles \
116 users \
117 initial_sid_contexts \
118 fs_use \
119 genfs_contexts \
120 port_contexts
121
Ying Wang02fb5f32012-01-17 17:51:09 -0800122##################################
123include $(CLEAR_VARS)
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500124
Richard Hainesc8801fe2015-12-11 10:39:19 +0000125LOCAL_MODULE := sectxfile_nl
126LOCAL_MODULE_CLASS := ETC
127LOCAL_MODULE_TAGS := optional
128
129# Create a file containing newline only to add between context config files
130include $(BUILD_SYSTEM)/base_rules.mk
William Robertscb1ab982015-12-14 07:54:28 -0800131$(LOCAL_BUILT_MODULE):
Richard Hainesc8801fe2015-12-11 10:39:19 +0000132 @mkdir -p $(dir $@)
133 $(hide) echo > $@
134
135built_nl := $(LOCAL_BUILT_MODULE)
136
137#################################
138include $(CLEAR_VARS)
139
Ying Wang02fb5f32012-01-17 17:51:09 -0800140LOCAL_MODULE := sepolicy
141LOCAL_MODULE_CLASS := ETC
142LOCAL_MODULE_TAGS := optional
Ying Wang02fb5f32012-01-17 17:51:09 -0800143LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Douglas Leung5807d1d2016-07-28 15:49:31 -0700144LOCAL_TARGET_ARCH := $(TARGET_ARCH)
145
146# Set LOCAL_TARGET_ARCH to mips for mips and mips64.
147ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
148 LOCAL_TARGET_ARCH := mips
149endif
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500150
Ying Wang02fb5f32012-01-17 17:51:09 -0800151include $(BUILD_SYSTEM)/base_rules.mk
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500152
dcashman2e00e632016-10-12 14:58:09 -0700153# reqd_policy_mask - a policy.conf file which contains only the bare minimum
154# policy necessary to use checkpolicy. This bare-minimum policy needs to be
155# present in all policy.conf files, but should not necessarily be exported as
156# part of the public policy. The rules generated by reqd_policy_mask will allow
157# the compilation of public policy and subsequent removal of CIL policy that
158# should not be exported.
159
160reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
161$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
162$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
163$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
164$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
165 @mkdir -p $(dir $@)
166 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
167 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
168 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
169 -s $^ > $@
170
171reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
172$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
173 @mkdir -p $(dir $@)
174 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
175
176# plat_pub_policy - policy that will be exported to be a part of non-platform
177# policy corresponding to this platform version. This is a limited subset of
178# policy that would not compile in checkpolicy on its own. To get around this
179# limitation, add only the required files from private policy, which will
180# generate CIL policy that will then be filtered out by the reqd_policy_mask.
181plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
182$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
183$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
184$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
185$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
186$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY))
187 @mkdir -p $(dir $@)
188 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
189 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
190 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
191 -s $^ > $@
192
193plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
194$(plat_pub_policy.cil): $(plat_pub_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
195 @mkdir -p $(dir $@)
196 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
197
198pruned_plat_pub_policy.cil := $(intermediates)/pruned_plat_pub_policy.cil
199$(pruned_plat_pub_policy.cil): $(reqd_policy_mask.cil) $(plat_pub_policy.cil)
200 @mkdir -p $(dir $@)
201 $(hide) grep -Fxv -f $^ > $@
202
203# plat_policy.conf - A combination of the private and public platform policy
204# which will ship with the device. The platform will always reflect the most
205# recent platform version and is not currently being attributized.
206plat_policy.conf := $(intermediates)/plat_policy.conf
207$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
208$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
209$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
210$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700211$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
212 @mkdir -p $(dir $@)
213 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
214 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
215 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700216 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500217 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500218 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
dcashmancc39f632016-07-22 13:13:11 -0700219 -s $^ > $@
220 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
221
dcashman2e00e632016-10-12 14:58:09 -0700222plat_policy.cil := $(intermediates)/plat_policy.cil
223$(plat_policy.cil): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
224 @mkdir -p $(dir $@)
225 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@.tmp $<
226 $(hide) grep -v neverallow $@.tmp > $@
dcashmancc39f632016-07-22 13:13:11 -0700227
dcashman2e00e632016-10-12 14:58:09 -0700228# nonplat_policy.conf - A combination of the non-platform private and the
229# exported platform policy associated with the version the non-platform policy
230# targets. This needs attributization and to be combined with the
231# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
232# of the reqd_policy_mask files from private policy in order to use checkpolicy.
233nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
234$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
235$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
236$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
237$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
238$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY) $(BOARD_SEPOLICY_DIRS))
Ying Wang02fb5f32012-01-17 17:51:09 -0800239 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700240 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
241 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800242 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700243 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500244 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500245 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Douglas Leung5807d1d2016-07-28 15:49:31 -0700246 -D target_arch=$(LOCAL_TARGET_ARCH) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800247 -s $^ > $@
Robert Craig65d4f442013-03-27 06:30:25 -0400248 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500249
dcashman2e00e632016-10-12 14:58:09 -0700250nonplat_policy.cil := $(intermediates)/nonplat_policy.cil
251$(nonplat_policy.cil): $(nonplat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
Ying Wang02fb5f32012-01-17 17:51:09 -0800252 @mkdir -p $(dir $@)
dcashman2e00e632016-10-12 14:58:09 -0700253 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
254
255pruned_nonplat_policy.cil := $(intermediates)/pruned_nonplat_policy.cil
256$(pruned_nonplat_policy.cil): $(reqd_policy_mask.cil) $(nonplat_policy.cil)
257 @mkdir -p $(dir $@)
258 $(hide) grep -Fxv -f $^ | grep -v neverallow > $@
259
260vers_nonplat_policy.cil := $(intermediates)/vers_nonplat_policy.cil
261$(vers_nonplat_policy.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
262$(vers_nonplat_policy.cil) : PRIVATE_TGT_POL := $(pruned_nonplat_policy.cil)
263$(vers_nonplat_policy.cil) : $(pruned_plat_pub_policy.cil) $(pruned_nonplat_policy.cil) \
264$(HOST_OUT_EXECUTABLES)/version_policy
265 @mkdir -p $(dir $@)
266 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
267
268# auto-generate the mapping file for current platform policy, since it needs to
269# track platform policy development
270current_mapping.cil := $(intermediates)/mapping/current.cil
271$(current_mapping.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
272$(current_mapping.cil) : $(pruned_plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
273 @mkdir -p $(dir $@)
274 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
275
276ifeq ($(BOARD_SEPOLICY_VERS), current)
277mapping.cil := $(current_mapping.cil)
278else
279mapping.cil := $(addsuffix /$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)/mapping)
280endif
281
282all_cil_files := \
283 $(plat_policy.cil) \
284 $(vers_nonplat_policy.cil) \
285 $(mapping.cil)
286
287$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
288$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
289 @mkdir -p $(dir $@)
290 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800291 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
292 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
293 echo "==========" 1>&2; \
294 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
295 echo "List of invalid domains:" 1>&2; \
296 cat $@.permissivedomains 1>&2; \
297 exit 1; \
298 fi
299 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800300
Ying Wangd8b122c2012-10-25 19:01:31 -0700301built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700302reqd_policy_mask.conf :=
303reqd_policy_mask.cil :=
304plat_pub_policy.conf :=
305plat_pub_policy.cil :=
306pruned_plat_pub_policy.cil :=
307plat_policy.conf :=
308plat_policy.cil :=
309nonplat_policy.conf :=
310nonplat_policy.cil :=
311pruned_nonplat_policy.cil :=
312vers_nonplat_policy.cil :=
313current_mapping.cil :=
314mapping.cil :=
315all_cil_files :=
Ying Wang02fb5f32012-01-17 17:51:09 -0800316sepolicy_policy.conf :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400317
Stephen Smalleye60723a2014-05-29 16:40:15 -0400318##################################
319include $(CLEAR_VARS)
320
321LOCAL_MODULE := sepolicy.recovery
322LOCAL_MODULE_CLASS := ETC
323LOCAL_MODULE_TAGS := eng
324
325include $(BUILD_SYSTEM)/base_rules.mk
326
327sepolicy_policy_recovery.conf := $(intermediates)/policy_recovery.conf
328$(sepolicy_policy_recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
329$(sepolicy_policy_recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
William Robertsd2185582015-07-16 11:28:02 -0700330$(sepolicy_policy_recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
dcashmancc39f632016-07-22 13:13:11 -0700331$(sepolicy_policy_recovery.conf): $(call build_policy, $(sepolicy_build_files), \
332$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Stephen Smalleye60723a2014-05-29 16:40:15 -0400333 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700334 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
335 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400336 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700337 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500338 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500339 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
Stephen Smalleye60723a2014-05-29 16:40:15 -0400340 -D target_recovery=true \
341 -s $^ > $@
342
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800343$(LOCAL_BUILT_MODULE): $(sepolicy_policy_recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Stephen Smalleye60723a2014-05-29 16:40:15 -0400344 @mkdir -p $(dir $@)
Nick Kralevich6ef10bd2016-02-29 16:59:33 -0800345 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@.tmp $< > /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800346 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
347 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
348 echo "==========" 1>&2; \
349 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
350 echo "List of invalid domains:" 1>&2; \
351 cat $@.permissivedomains 1>&2; \
352 exit 1; \
353 fi
354 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400355
356built_sepolicy_recovery := $(LOCAL_BUILT_MODULE)
357sepolicy_policy_recovery.conf :=
358
dcashman704741a2014-07-25 19:11:52 -0700359##################################
360include $(CLEAR_VARS)
361
362LOCAL_MODULE := general_sepolicy.conf
363LOCAL_MODULE_CLASS := ETC
364LOCAL_MODULE_TAGS := tests
365
366include $(BUILD_SYSTEM)/base_rules.mk
367
dcashman704741a2014-07-25 19:11:52 -0700368$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
369$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
dcashmancc39f632016-07-22 13:13:11 -0700370$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
371$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
dcashman704741a2014-07-25 19:11:52 -0700372 mkdir -p $(dir $@)
373 $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
374 -D target_build_variant=user \
Jeff Vander Stoepd733d162016-10-19 13:55:21 -0700375 -D target_build_treble=$(ENABLE_TREBLE) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500376 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Jorge Lucangeli Obes28994342016-11-21 11:54:19 -0500377 -D target_with_dexpreopt_pic=$(WITH_DEXPREOPT_PIC) \
dcashman704741a2014-07-25 19:11:52 -0700378 -s $^ > $@
379 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
380
William Robertsb8769932015-06-29 16:31:23 -0700381built_general_sepolicy.conf := $(LOCAL_BUILT_MODULE)
dcashman704741a2014-07-25 19:11:52 -0700382exp_sepolicy_build_files :=
383
384##################################
Stephen Smalley01a58af2012-10-02 12:46:37 -0400385include $(CLEAR_VARS)
386
William Robertsb8769932015-06-29 16:31:23 -0700387LOCAL_MODULE := sepolicy.general
388LOCAL_MODULE_CLASS := ETC
389LOCAL_MODULE_TAGS := tests
390
391include $(BUILD_SYSTEM)/base_rules.mk
392
393$(LOCAL_BUILT_MODULE): PRIVATE_BUILT_SEPOLICY.CONF := $(built_general_sepolicy.conf)
394$(LOCAL_BUILT_MODULE): $(built_general_sepolicy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
395 @mkdir -p $(dir $@)
Nick Kralevich6ef10bd2016-02-29 16:59:33 -0800396 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@ $(PRIVATE_BUILT_SEPOLICY.CONF) > /dev/null
William Robertsb8769932015-06-29 16:31:23 -0700397
398built_general_sepolicy := $(LOCAL_BUILT_MODULE)
399##################################
400include $(CLEAR_VARS)
401
Richard Hainesc2d01912015-08-06 17:43:52 +0100402LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800403LOCAL_MODULE_CLASS := ETC
404LOCAL_MODULE_TAGS := optional
405LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
406
Stephen Smalley5b340be2012-03-06 11:12:41 -0500407include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800408
William Roberts49693f12016-01-04 12:20:57 -0800409# The file_contexts.bin is built in the following way:
410# 1. Collect all file_contexts files in THIS repository and process them with
411# m4 into a tmp file called file_contexts.local.tmp.
412# 2. Collect all device specific file_contexts files and process them with m4
413# into a tmp file called file_contexts.device.tmp.
414# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
415# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
416# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
417# file_contexts.concat.tmp.
418# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
419# file_contexts.bin.
420#
421# Note: That a newline file is placed between each file_context file found to
422# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800423
dcashmancc39f632016-07-22 13:13:11 -0700424local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
William Roberts49693f12016-01-04 12:20:57 -0800425ifneq ($(filter address,$(SANITIZE_TARGET)),)
dcashmancc39f632016-07-22 13:13:11 -0700426 local_fc_files := $(local_fc_files) $(PLAT_PRIVATE_POLICY)/file_contexts_asan
William Roberts49693f12016-01-04 12:20:57 -0800427endif
428local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
429
430file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
431$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500432 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800433 $(hide) m4 -s $^ > $@
434
435device_fc_files := $(call build_device_policy, file_contexts)
436device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
437
438file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
439$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
440$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
441 @mkdir -p $(dir $@)
442 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
443
444file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
445$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
446$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
447 @mkdir -p $(dir $@)
dcashman2e00e632016-10-12 14:58:09 -0700448 # TODO: fix with attributized types $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800449 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
450
451file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
452$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
453 @mkdir -p $(dir $@)
454 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500455
William Roberts3746a0a2015-09-25 10:18:44 -0700456$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800457$(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 +0100458 @mkdir -p $(dir $@)
dcashman2e00e632016-10-12 14:58:09 -0700459 # TODO: fix with attributized types $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100460 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
461
Robert Craig8b7545b2014-03-20 09:35:08 -0400462built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800463local_fc_files :=
464local_fcfiles_with_nl :=
465device_fc_files :=
466device_fcfiles_with_nl :=
467file_contexts.concat.tmp :=
468file_contexts.device.sorted.tmp :=
469file_contexts.device.tmp :=
470file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700471
Ying Wang02fb5f32012-01-17 17:51:09 -0800472##################################
473include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400474
Richard Hainesc2d01912015-08-06 17:43:52 +0100475LOCAL_MODULE := general_file_contexts.bin
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400476LOCAL_MODULE_CLASS := ETC
477LOCAL_MODULE_TAGS := tests
478
479include $(BUILD_SYSTEM)/base_rules.mk
480
Richard Hainesc2d01912015-08-06 17:43:52 +0100481general_file_contexts.tmp := $(intermediates)/general_file_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700482$(general_file_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, file_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400483 @mkdir -p $(dir $@)
484 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400485
William Roberts3746a0a2015-09-25 10:18:44 -0700486$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
487$(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 +0100488 @mkdir -p $(dir $@)
dcashman2e00e632016-10-12 14:58:09 -0700489 # TODO: fix with attributized types $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100490 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
491
492general_file_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400493
494##################################
495include $(CLEAR_VARS)
Ying Wang02fb5f32012-01-17 17:51:09 -0800496LOCAL_MODULE := seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800497LOCAL_MODULE_CLASS := ETC
498LOCAL_MODULE_TAGS := optional
499LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
500
William Roberts171a0622012-08-16 10:55:05 -0700501include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800502
dcashmancc39f632016-07-22 13:13:11 -0700503all_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts171a0622012-08-16 10:55:05 -0700504
Ying Wangd8b122c2012-10-25 19:01:31 -0700505$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts81e1f902015-06-03 21:57:47 -0700506$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(all_sc_files)
507$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(all_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700508 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700509 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800510
Robert Craig8b7545b2014-03-20 09:35:08 -0400511built_sc := $(LOCAL_BUILT_MODULE)
William Roberts81e1f902015-06-03 21:57:47 -0700512all_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400513
Ying Wang02fb5f32012-01-17 17:51:09 -0800514##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400515include $(CLEAR_VARS)
Stephen Smalley37712872015-03-12 15:46:36 -0400516LOCAL_MODULE := general_seapp_contexts
517LOCAL_MODULE_CLASS := ETC
518LOCAL_MODULE_TAGS := tests
519
520include $(BUILD_SYSTEM)/base_rules.mk
521
dcashmancc39f632016-07-22 13:13:11 -0700522all_sc_files := $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
Stephen Smalley37712872015-03-12 15:46:36 -0400523
William Robertsb8769932015-06-29 16:31:23 -0700524$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
William Roberts81e1f902015-06-03 21:57:47 -0700525$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILE := $(all_sc_files)
William Robertsb8769932015-06-29 16:31:23 -0700526$(LOCAL_BUILT_MODULE): $(built_general_sepolicy) $(all_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
Stephen Smalley37712872015-03-12 15:46:36 -0400527 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700528 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILE)
Stephen Smalley37712872015-03-12 15:46:36 -0400529
William Roberts81e1f902015-06-03 21:57:47 -0700530all_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400531
532##################################
533include $(CLEAR_VARS)
William Roberts4ee71312015-06-25 11:59:30 -0700534LOCAL_MODULE := general_seapp_neverallows
535LOCAL_MODULE_CLASS := ETC
536LOCAL_MODULE_TAGS := tests
537
538include $(BUILD_SYSTEM)/base_rules.mk
539
dcashmancc39f632016-07-22 13:13:11 -0700540$(LOCAL_BUILT_MODULE): $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
William Roberts4ee71312015-06-25 11:59:30 -0700541 @mkdir -p $(dir $@)
542 - $(hide) grep -ie '^neverallow' $< > $@
543
William Roberts4ee71312015-06-25 11:59:30 -0700544
545##################################
546include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400547
548LOCAL_MODULE := property_contexts
549LOCAL_MODULE_CLASS := ETC
550LOCAL_MODULE_TAGS := optional
551LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
552
553include $(BUILD_SYSTEM)/base_rules.mk
554
dcashmancc39f632016-07-22 13:13:11 -0700555all_pc_files := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Richard Hainesc8801fe2015-12-11 10:39:19 +0000556all_pcfiles_with_nl := $(call add_nl, $(all_pc_files), $(built_nl))
William Roberts6aabc1c2015-07-30 11:44:26 -0700557
William Robertsdcffd2b2015-09-29 13:52:37 -0700558property_contexts.tmp := $(intermediates)/property_contexts.tmp
Richard Hainesc8801fe2015-12-11 10:39:19 +0000559$(property_contexts.tmp): PRIVATE_PC_FILES := $(all_pcfiles_with_nl)
William Robertsdcffd2b2015-09-29 13:52:37 -0700560$(property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
William Roberts46749752015-12-28 15:26:20 -0800561$(property_contexts.tmp): $(all_pcfiles_with_nl)
William Roberts7f81b332015-09-29 13:52:37 -0700562 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000563 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700564
565
566$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts371918c2016-04-06 11:40:08 -0700567$(LOCAL_BUILT_MODULE): $(property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700568 @mkdir -p $(dir $@)
William Roberts371918c2016-04-06 11:40:08 -0700569 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman2e00e632016-10-12 14:58:09 -0700570 # TODO: fix with attributized types $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400571
Robert Craig8b7545b2014-03-20 09:35:08 -0400572built_pc := $(LOCAL_BUILT_MODULE)
William Roberts6aabc1c2015-07-30 11:44:26 -0700573all_pc_files :=
William Roberts46749752015-12-28 15:26:20 -0800574all_pcfiles_with_nl :=
William Robertsdcffd2b2015-09-29 13:52:37 -0700575property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400576
Stephen Smalley124720a2012-04-04 10:11:16 -0400577##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700578include $(CLEAR_VARS)
579
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400580LOCAL_MODULE := general_property_contexts
581LOCAL_MODULE_CLASS := ETC
582LOCAL_MODULE_TAGS := tests
583
Stephen Smalleyc9361732015-03-13 09:36:57 -0400584include $(BUILD_SYSTEM)/base_rules.mk
585
William Robertsdcffd2b2015-09-29 13:52:37 -0700586general_property_contexts.tmp := $(intermediates)/general_property_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700587$(general_property_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, property_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400588 @mkdir -p $(dir $@)
589 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400590
William Robertsdcffd2b2015-09-29 13:52:37 -0700591$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
592$(LOCAL_BUILT_MODULE): $(general_property_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
593 @mkdir -p $(dir $@)
William Roberts371918c2016-04-06 11:40:08 -0700594 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman2e00e632016-10-12 14:58:09 -0700595 # TODO: fix with attributized types $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700596
597general_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400598
599##################################
600include $(CLEAR_VARS)
601
Riley Spahnf90c41f2014-06-05 15:52:02 -0700602LOCAL_MODULE := service_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_svc_files := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Richard Hainesc8801fe2015-12-11 10:39:19 +0000610all_svcfiles_with_nl := $(call add_nl, $(all_svc_files), $(built_nl))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700611
William Roberts7fc865a2015-09-29 14:17:38 -0700612service_contexts.tmp := $(intermediates)/service_contexts.tmp
Richard Hainesc8801fe2015-12-11 10:39:19 +0000613$(service_contexts.tmp): PRIVATE_SVC_FILES := $(all_svcfiles_with_nl)
William Roberts7fc865a2015-09-29 14:17:38 -0700614$(service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
William Roberts46749752015-12-28 15:26:20 -0800615$(service_contexts.tmp): $(all_svcfiles_with_nl)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700616 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700617 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700618
619$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
620$(LOCAL_BUILT_MODULE): $(service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
621 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700622 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman2e00e632016-10-12 14:58:09 -0700623 # TODO: fix with attributized types$(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700624
625built_svc := $(LOCAL_BUILT_MODULE)
William Roberts6aabc1c2015-07-30 11:44:26 -0700626all_svc_files :=
William Roberts46749752015-12-28 15:26:20 -0800627all_svcfiles_with_nl :=
William Roberts7fc865a2015-09-29 14:17:38 -0700628service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700629
630##################################
rpcraigb19665c2012-07-30 09:33:03 -0400631include $(CLEAR_VARS)
632
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400633LOCAL_MODULE := general_service_contexts
634LOCAL_MODULE_CLASS := ETC
635LOCAL_MODULE_TAGS := tests
636
637include $(BUILD_SYSTEM)/base_rules.mk
638
William Roberts7fc865a2015-09-29 14:17:38 -0700639general_service_contexts.tmp := $(intermediates)/general_service_contexts.tmp
dcashmancc39f632016-07-22 13:13:11 -0700640$(general_service_contexts.tmp): $(addprefix $(PLAT_PRIVATE_POLICY)/, service_contexts)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400641 @mkdir -p $(dir $@)
642 $(hide) m4 -s $< > $@
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400643
William Roberts7fc865a2015-09-29 14:17:38 -0700644$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_general_sepolicy)
645$(LOCAL_BUILT_MODULE): $(general_service_contexts.tmp) $(built_general_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
646 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700647 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman2e00e632016-10-12 14:58:09 -0700648 # TODO: fix with attributized types $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700649
650general_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400651
652##################################
653include $(CLEAR_VARS)
654
Robert Craig7f2392e2013-03-27 08:35:39 -0400655LOCAL_MODULE := mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -0400656LOCAL_MODULE_CLASS := ETC
657LOCAL_MODULE_TAGS := optional
658LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security
659
William Roberts2c8a55d2012-11-30 14:59:09 -0800660include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -0400661
Geremy Condracd4104e2013-03-26 18:19:12 +0000662# Build keys.conf
663mac_perms_keys.tmp := $(intermediates)/keys.tmp
William Robertsd2185582015-07-16 11:28:02 -0700664$(mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
dcashmancc39f632016-07-22 13:13:11 -0700665$(mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
Geremy Condracd4104e2013-03-26 18:19:12 +0000666 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700667 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +0000668
dcashmancc39f632016-07-22 13:13:11 -0700669all_mac_perms_files := $(call build_policy, $(LOCAL_MODULE), $(PLAT_PRIVATE_POLICY) $(BOARD_SEPOLICY_DIRS))
rpcraigb19665c2012-07-30 09:33:03 -0400670
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900671# Should be synced with keys.conf.
672all_keys := platform media shared testkey
673all_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
674
William Roberts6aabc1c2015-07-30 11:44:26 -0700675$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_mac_perms_files)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +0900676$(LOCAL_BUILT_MODULE): $(mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py $(all_mac_perms_files) $(all_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +0000677 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -0700678 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -0700679 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +0000680
Robert Craig7f2392e2013-03-27 08:35:39 -0400681mac_perms_keys.tmp :=
William Roberts6aabc1c2015-07-30 11:44:26 -0700682all_mac_perms_files :=
683
rpcraigb19665c2012-07-30 09:33:03 -0400684##################################
Robert Craig8b7545b2014-03-20 09:35:08 -0400685include $(CLEAR_VARS)
686
687LOCAL_MODULE := selinux_version
688LOCAL_MODULE_CLASS := ETC
689LOCAL_MODULE_TAGS := optional
690LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
691
692include $(BUILD_SYSTEM)/base_rules.mk
William Robertsda52e852015-06-27 07:22:34 -0700693$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(built_pc) $(built_fc) $(built_sc) $(built_svc)
Robert Craig8b7545b2014-03-20 09:35:08 -0400694 @mkdir -p $(dir $@)
Colin Cross29a463d2015-07-17 13:08:41 -0700695 $(hide) echo -n $(BUILD_FINGERPRINT_FROM_FILE) > $@
Robert Craig8b7545b2014-03-20 09:35:08 -0400696
697##################################
rpcraig47cd3962012-10-17 21:09:52 -0400698
699build_policy :=
William Roberts49693f12016-01-04 12:20:57 -0800700build_device_policy :=
dcashman704741a2014-07-25 19:11:52 -0700701sepolicy_build_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400702built_sepolicy :=
William Roberts50a478e2015-12-28 16:19:54 -0800703built_sepolicy_recovery :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400704built_sc :=
705built_fc :=
706built_pc :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700707built_svc :=
William Robertsb8769932015-06-29 16:31:23 -0700708built_general_sepolicy :=
709built_general_sepolicy.conf :=
Richard Hainesc8801fe2015-12-11 10:39:19 +0000710built_nl :=
William Roberts50a478e2015-12-28 16:19:54 -0800711add_nl :=
Alice Chucdfb06f2012-11-01 11:33:04 -0700712
713include $(call all-makefiles-under,$(LOCAL_PATH))