blob: 1d37c098b86cb6079d95a284aa788e853ab13af7 [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001LOCAL_PATH:= $(call my-dir)
William Robertsf0e0a942012-08-27 15:41:15 -07002
Dan Cashman36ee91d2017-07-07 14:59:51 -07003include $(LOCAL_PATH)/definitions.mk
4
Dan Cashman6f14f6b2017-04-07 16:36:23 -07005# PLATFORM_SEPOLICY_VERSION is a number of the form "NN.m" with "NN" mapping to
6# PLATFORM_SDK_VERSION and "m" as a minor number which allows for SELinux
7# changes independent of PLATFORM_SDK_VERSION. This value will be set to
8# 10000.0 to represent tip-of-tree development that is inherently unstable and
9# thus designed not to work with any shipping vendor policy. This is similar in
10# spirit to how DEFAULT_APP_TARGET_SDK is set.
11# The minor version ('m' component) must be updated every time a platform release
12# is made which breaks compatibility with the previous platform sepolicy version,
13# not just on every increase in PLATFORM_SDK_VERSION. The minor version should
14# be reset to 0 on every bump of the PLATFORM_SDK_VERSION.
Ian Pedowitz4816b8f2017-05-04 00:09:57 +000015sepolicy_major_vers := 26
Dan Cashman6f14f6b2017-04-07 16:36:23 -070016sepolicy_minor_vers := 0
17
18ifneq ($(sepolicy_major_vers), $(PLATFORM_SDK_VERSION))
19$(error sepolicy_major_version does not match PLATFORM_SDK_VERSION, please update.)
20endif
21ifneq (REL,$(PLATFORM_VERSION_CODENAME))
22 sepolicy_major_vers := 10000
23 sepolicy_minor_vers := 0
24endif
25PLATFORM_SEPOLICY_VERSION := $(join $(addsuffix .,$(sepolicy_major_vers)), $(sepolicy_minor_vers))
26sepolicy_major_vers :=
27sepolicy_minor_vers :=
28
Stephen Smalley2dd4e512012-01-04 12:33:27 -050029include $(CLEAR_VARS)
Stephen Smalley2dd4e512012-01-04 12:33:27 -050030# SELinux policy version.
Stephen Smalleyb4f17062015-03-13 10:03:52 -040031# Must be <= /sys/fs/selinux/policyvers reported by the Android kernel.
Stephen Smalley2dd4e512012-01-04 12:33:27 -050032# Must be within the compatibility range reported by checkpolicy -V.
Jeff Vander Stoep3a0ce492015-12-07 08:30:43 -080033POLICYVERS ?= 30
Stephen Smalley2dd4e512012-01-04 12:33:27 -050034
35MLS_SENS=1
36MLS_CATS=1024
37
Stephen Smalleyb4f17062015-03-13 10:03:52 -040038ifdef BOARD_SEPOLICY_REPLACE
39$(error BOARD_SEPOLICY_REPLACE is no longer supported; please remove from your BoardConfig.mk or other .mk file.)
40endif
41
42ifdef BOARD_SEPOLICY_IGNORE
43$(error BOARD_SEPOLICY_IGNORE is no longer supported; please remove from your BoardConfig.mk or other .mk file.)
44endif
Stephen Smalley5b340be2012-03-06 11:12:41 -050045
Stephen Smalley8e0ca882015-04-01 10:14:56 -040046ifdef BOARD_SEPOLICY_UNION
47$(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.)
48endif
Robert Craig6b0ff472014-01-29 13:10:58 -050049
William Robertsd2185582015-07-16 11:28:02 -070050ifdef BOARD_SEPOLICY_M4DEFS
51LOCAL_ADDITIONAL_M4DEFS := $(addprefix -D, $(BOARD_SEPOLICY_M4DEFS))
Dan Cashman36ee91d2017-07-07 14:59:51 -070052else
53LOCAL_ADDITIONAL_M4DEFS :=
William Robertsd2185582015-07-16 11:28:02 -070054endif
55
dcashmancc39f632016-07-22 13:13:11 -070056# sepolicy is now divided into multiple portions:
57# public - policy exported on which non-platform policy developers may write
58# additional policy. types and attributes are versioned and included in
59# delivered non-platform policy, which is to be combined with platform policy.
60# private - platform-only policy required for platform functionality but which
61# is not exported to vendor policy developers and as such may not be assumed
62# to exist.
Alex Klyubin55961722017-01-30 18:44:59 -080063# vendor - vendor-only policy required for vendor functionality. This policy can
64# reference the public policy but cannot reference the private policy. This
65# policy is for components which are produced from the core/non-vendor tree and
66# placed into a vendor partition.
dcashman07791552016-12-07 11:27:47 -080067# mapping - This contains policy statements which map the attributes
dcashmancc39f632016-07-22 13:13:11 -070068# exposed in the public policy of previous versions to the concrete types used
69# in this policy to ensure that policy targeting attributes from public
70# policy from an older platform version continues to work.
71
dcashman2e00e632016-10-12 14:58:09 -070072# build process for device:
dcashmancc39f632016-07-22 13:13:11 -070073# 1) convert policies to CIL:
74# - private + public platform policy to CIL
75# - mapping file to CIL (should already be in CIL form)
76# - non-platform public policy to CIL
77# - non-platform public + private policy to CIL
78# 2) attributize policy
dcashmancc39f632016-07-22 13:13:11 -070079# - run script which takes non-platform public and non-platform combined
80# private + public policy and produces attributized and versioned
81# non-platform policy
82# 3) combine policy files
83# - combine mapping, platform and non-platform policy.
84# - compile output binary policy file
85
86PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/public
Dan Cashman51455fe2017-05-23 14:47:16 -070087ifneq ( ,$(BOARD_PLAT_PUBLIC_SEPOLICY_DIR))
88ifneq (1, $(words $(BOARD_PLAT_PUBLIC_SEPOLICY_DIR)))
89$(error BOARD_PLAT_PUBLIC_SEPOLICY_DIR must only contain one directory)
90else
91PLAT_PUBLIC_POLICY += $(BOARD_PLAT_PUBLIC_SEPOLICY_DIR)
92endif
93endif
dcashmancc39f632016-07-22 13:13:11 -070094PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private
Dan Cashman51455fe2017-05-23 14:47:16 -070095ifneq ( ,$(BOARD_PLAT_PRIVATE_SEPOLICY_DIR))
96ifneq (1, $(words $(BOARD_PLAT_PRIVATE_SEPOLICY_DIR)))
97$(error BOARD_PLAT_PRIVATE_SEPOLICY_DIR must only contain one directory)
98else
99PLAT_PRIVATE_POLICY += $(BOARD_PLAT_PRIVATE_SEPOLICY_DIR)
100endif
101endif
Alex Klyubin55961722017-01-30 18:44:59 -0800102PLAT_VENDOR_POLICY := $(LOCAL_PATH)/vendor
dcashman2e00e632016-10-12 14:58:09 -0700103REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask
104
105# TODO: move to README when doing the README update and finalizing versioning.
Sandeep Patil42f95982017-04-07 14:18:48 -0700106# BOARD_SEPOLICY_VERS must take the format "NN.m" and contain the sepolicy
107# version identifier corresponding to the sepolicy on which the non-platform
108# policy is to be based. If unspecified, this will build against the current
109# public platform policy in tree
dcashman2e00e632016-10-12 14:58:09 -0700110ifndef BOARD_SEPOLICY_VERS
111$(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version)
Sandeep Patil42f95982017-04-07 14:18:48 -0700112# The default platform policy version.
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700113BOARD_SEPOLICY_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman2e00e632016-10-12 14:58:09 -0700114endif
dcashmancc39f632016-07-22 13:13:11 -0700115
Dan Cashman4d24a772017-04-12 14:28:34 -0700116
117platform_mapping_file := $(BOARD_SEPOLICY_VERS).cil
118
dcashmancc39f632016-07-22 13:13:11 -0700119###########################################################
120# Compute policy files to be used in policy build.
121# $(1): files to include
122# $(2): directories in which to find files
123###########################################################
124
125define build_policy
126$(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))
127endef
William Roberts29d14682016-01-04 12:20:57 -0800128
William Roberts49693f12016-01-04 12:20:57 -0800129# Builds paths for all policy files found in BOARD_SEPOLICY_DIRS.
130# $(1): the set of policy name paths to build
Alex Klyubin55961722017-01-30 18:44:59 -0800131build_device_policy = $(call build_policy, $(1), $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts49693f12016-01-04 12:20:57 -0800132
Richard Hainesc8801fe2015-12-11 10:39:19 +0000133# Add a file containing only a newline in-between each policy configuration
134# 'contexts' file. This will allow OEM policy configuration files without a
135# final newline (0x0A) to be built correctly by the m4(1) macro processor.
136# $(1): the set of contexts file names.
137# $(2): the file containing only 0x0A.
138add_nl = $(foreach entry, $(1), $(subst $(entry), $(entry) $(2), $(entry)))
139
dcashman704741a2014-07-25 19:11:52 -0700140sepolicy_build_files := security_classes \
141 initial_sids \
142 access_vectors \
143 global_macros \
Nick Kralevicha17a2662014-11-05 15:30:41 -0800144 neverallow_macros \
dcashman704741a2014-07-25 19:11:52 -0700145 mls_macros \
dcashman2e00e632016-10-12 14:58:09 -0700146 mls_decl \
dcashman704741a2014-07-25 19:11:52 -0700147 mls \
148 policy_capabilities \
149 te_macros \
150 attributes \
Jeff Vander Stoepcbaa2b72015-12-22 10:39:34 -0800151 ioctl_defines \
Jeff Vander Stoepde9b5302015-06-05 15:28:55 -0700152 ioctl_macros \
dcashman704741a2014-07-25 19:11:52 -0700153 *.te \
dcashman2e00e632016-10-12 14:58:09 -0700154 roles_decl \
dcashman704741a2014-07-25 19:11:52 -0700155 roles \
156 users \
157 initial_sid_contexts \
158 fs_use \
159 genfs_contexts \
160 port_contexts
161
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700162# CIL files which contain workarounds for current limitation of human-readable
163# module policy language. These files are appended to the CIL files produced
164# from module language files.
165sepolicy_build_cil_workaround_files := technical_debt.cil
166
Dan Cashman1c040272016-12-15 15:28:44 -0800167my_target_arch := $(TARGET_ARCH)
168ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
169 my_target_arch := mips
170endif
171
Jeff Vander Stoepd2053bd2017-03-15 13:37:35 -0700172intermediates := $(TARGET_OUT_INTERMEDIATES)/ETC/sepolicy_intermediates
173
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700174with_asan := false
175ifneq (,$(filter address,$(SANITIZE_TARGET)))
176 with_asan := true
177endif
178
Dan Cashman4f9a6482017-04-10 12:27:18 -0700179include $(CLEAR_VARS)
180LOCAL_MODULE := selinux_policy
181LOCAL_MODULE_TAGS := optional
182# Include SELinux policy. We do this here because different modules
183# need to be included based on the value of PRODUCT_FULL_TREBLE. This
184# type of conditional inclusion cannot be done in top-level files such
185# as build/target/product/embedded.mk.
186# This conditional inclusion closely mimics the conditional logic
187# inside init/init.cpp for loading SELinux policy from files.
188ifeq ($(PRODUCT_FULL_TREBLE),true)
189
Dan Cashman4f9a6482017-04-10 12:27:18 -0700190# Use split SELinux policy
191LOCAL_REQUIRED_MODULES += \
192 $(platform_mapping_file) \
193 nonplat_sepolicy.cil \
194 plat_sepolicy.cil \
195 plat_and_mapping_sepolicy.cil.sha256 \
196 secilc \
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -0700197 plat_sepolicy_vers.txt \
Dan Cashman91d398d2017-09-26 12:58:29 -0700198
199ifneq ($(with_asan),true)
200LOCAL_REQUIRED_MODULES += \
201 treble_sepolicy_tests \
202
203endif
Dan Cashman4f9a6482017-04-10 12:27:18 -0700204
205# Include precompiled policy, unless told otherwise
206ifneq ($(PRODUCT_PRECOMPILED_SEPOLICY),false)
207LOCAL_REQUIRED_MODULES += precompiled_sepolicy precompiled_sepolicy.plat_and_mapping.sha256
208endif
Dan Cashman4f9a6482017-04-10 12:27:18 -0700209else
210# Use monolithic SELinux policy
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700211LOCAL_REQUIRED_MODULES += sepolicy
Dan Cashman4f9a6482017-04-10 12:27:18 -0700212endif
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700213
214LOCAL_REQUIRED_MODULES += \
215 nonplat_file_contexts \
Jeff Vander Stoep13fb5ed2017-08-22 13:29:53 -0700216 nonplat_mac_permissions.xml \
217 nonplat_property_contexts \
218 nonplat_seapp_contexts \
Jeff Vander Stoep13fb5ed2017-08-22 13:29:53 -0700219 nonplat_hwservice_contexts \
220 plat_file_contexts \
221 plat_mac_permissions.xml \
222 plat_property_contexts \
223 plat_seapp_contexts \
224 plat_service_contexts \
225 plat_hwservice_contexts \
Dan Cashman91d398d2017-09-26 12:58:29 -0700226 searchpolicy \
Jeff Vander Stoep13fb5ed2017-08-22 13:29:53 -0700227 vndservice_contexts \
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700228
Hung-ying Tyane83f1e52017-09-05 21:51:52 +0800229ifneq ($(PRODUCT_FULL_TREBLE),true)
230LOCAL_REQUIRED_MODULES += nonplat_service_contexts
231endif
232
Dan Cashman91d398d2017-09-26 12:58:29 -0700233ifneq ($(TARGET_BUILD_VARIANT), user)
234LOCAL_REQUIRED_MODULES += \
235 selinux_denial_metadata \
236
237endif
238
239ifneq ($(with_asan),true)
240LOCAL_REQUIRED_MODULES += \
241 sepolicy_tests \
242
243endif
244
Dan Cashman4f9a6482017-04-10 12:27:18 -0700245include $(BUILD_PHONY_PACKAGE)
246
Ying Wang02fb5f32012-01-17 17:51:09 -0800247##################################
dcashman2e00e632016-10-12 14:58:09 -0700248# reqd_policy_mask - a policy.conf file which contains only the bare minimum
249# policy necessary to use checkpolicy. This bare-minimum policy needs to be
250# present in all policy.conf files, but should not necessarily be exported as
251# part of the public policy. The rules generated by reqd_policy_mask will allow
252# the compilation of public policy and subsequent removal of CIL policy that
253# should not be exported.
254
255reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
256$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
257$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800258$(reqd_policy_mask.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700259$(reqd_policy_mask.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700260$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700261$(reqd_policy_mask.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700262$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700263 $(transform-policy-to-conf)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700264# b/37755687
265CHECKPOLICY_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0
266
dcashman2e00e632016-10-12 14:58:09 -0700267reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
268$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
269 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700270 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c \
271 $(POLICYVERS) -o $@ $<
dcashman2e00e632016-10-12 14:58:09 -0700272
dcashman1faa6442016-11-28 07:20:28 -0800273reqd_policy_mask.conf :=
274
275##################################
dcashman2e00e632016-10-12 14:58:09 -0700276# plat_pub_policy - policy that will be exported to be a part of non-platform
277# policy corresponding to this platform version. This is a limited subset of
278# policy that would not compile in checkpolicy on its own. To get around this
279# limitation, add only the required files from private policy, which will
280# generate CIL policy that will then be filtered out by the reqd_policy_mask.
281plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
282$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
283$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800284$(plat_pub_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700285$(plat_pub_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700286$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700287$(plat_pub_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700288$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700289$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700290 $(transform-policy-to-conf)
dcashman2e00e632016-10-12 14:58:09 -0700291plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800292$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
293$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
294$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700295 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700296 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
dcashman1faa6442016-11-28 07:20:28 -0800297 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700298
dcashman1faa6442016-11-28 07:20:28 -0800299plat_pub_policy.conf :=
Dan Cashman1c040272016-12-15 15:28:44 -0800300
dcashman1faa6442016-11-28 07:20:28 -0800301##################################
302include $(CLEAR_VARS)
303
304LOCAL_MODULE := sectxfile_nl
305LOCAL_MODULE_CLASS := ETC
306LOCAL_MODULE_TAGS := optional
307
308# Create a file containing newline only to add between context config files
309include $(BUILD_SYSTEM)/base_rules.mk
310$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700311 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800312 $(hide) echo > $@
313
314built_nl := $(LOCAL_BUILT_MODULE)
315
316#################################
317include $(CLEAR_VARS)
318
319LOCAL_MODULE := plat_sepolicy.cil
320LOCAL_MODULE_CLASS := ETC
321LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800322LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800323
324include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700325
326# plat_policy.conf - A combination of the private and public platform policy
327# which will ship with the device. The platform will always reflect the most
328# recent platform version and is not currently being attributized.
329plat_policy.conf := $(intermediates)/plat_policy.conf
330$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
331$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800332$(plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700333$(plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700334$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700335$(plat_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700336$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700337$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700338 $(transform-policy-to-conf)
dcashmancc39f632016-07-22 13:13:11 -0700339 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
340
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700341$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CIL_FILES := \
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700342 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700343$(LOCAL_BUILT_MODULE): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
344 $(HOST_OUT_EXECUTABLES)/secilc \
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700345 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
dcashman2e00e632016-10-12 14:58:09 -0700346 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700347 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
348 $(POLICYVERS) -o $@ $<
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700349 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
Sandeep Patilcfb6f352017-06-14 09:57:43 -0700350 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -c $(POLICYVERS) $@ -o /dev/null -f /dev/null
dcashman1faa6442016-11-28 07:20:28 -0800351
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800352built_plat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800353plat_policy.conf :=
354
355#################################
356include $(CLEAR_VARS)
357
Dan Cashman4f9a6482017-04-10 12:27:18 -0700358LOCAL_MODULE := plat_sepolicy_vers.txt
dcashman1faa6442016-11-28 07:20:28 -0800359LOCAL_MODULE_CLASS := ETC
360LOCAL_MODULE_TAGS := optional
Dan Cashman4f9a6482017-04-10 12:27:18 -0700361LOCAL_PROPRIETARY_MODULE := true
362LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
363
364include $(BUILD_SYSTEM)/base_rules.mk
365
366$(LOCAL_BUILT_MODULE) : PRIVATE_PLAT_SEPOL_VERS := $(BOARD_SEPOLICY_VERS)
367$(LOCAL_BUILT_MODULE) :
368 mkdir -p $(dir $@)
369 echo $(PRIVATE_PLAT_SEPOL_VERS) > $@
370
371#################################
372include $(CLEAR_VARS)
373
374LOCAL_MODULE := $(platform_mapping_file)
375LOCAL_MODULE_CLASS := ETC
376LOCAL_MODULE_TAGS := optional
377LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux/mapping
dcashman1faa6442016-11-28 07:20:28 -0800378
379include $(BUILD_SYSTEM)/base_rules.mk
380
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700381current_mapping.cil := $(intermediates)/mapping/$(PLATFORM_SEPOLICY_VERSION).cil
382ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
dcashman1faa6442016-11-28 07:20:28 -0800383# auto-generate the mapping file for current platform policy, since it needs to
384# track platform policy development
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700385$(current_mapping.cil) : PRIVATE_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman1faa6442016-11-28 07:20:28 -0800386$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
387 @mkdir -p $(dir $@)
388 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
389
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700390else # ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
391prebuilt_mapping_files := $(wildcard $(addsuffix /mapping/$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)))
392$(current_mapping.cil) : $(prebuilt_mapping_files)
393 @mkdir -p $(dir $@)
394 cat $^ > $@
Sandeep Patil42f95982017-04-07 14:18:48 -0700395
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700396prebuilt_mapping_files :=
dcashman1faa6442016-11-28 07:20:28 -0800397endif
398
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700399$(LOCAL_BUILT_MODULE): $(current_mapping.cil) $(ACP)
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700400 $(hide) $(ACP) $< $@
dcashman1faa6442016-11-28 07:20:28 -0800401
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800402built_mapping_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800403current_mapping.cil :=
404
405#################################
406include $(CLEAR_VARS)
407
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700408LOCAL_MODULE := plat_and_mapping_sepolicy.cil.sha256
409LOCAL_MODULE_CLASS := ETC
410LOCAL_MODULE_TAGS := optional
411LOCAL_MODULE_PATH = $(TARGET_OUT)/etc/selinux
412
413include $(BUILD_SYSTEM)/base_rules.mk
414
415$(LOCAL_BUILT_MODULE): $(built_plat_cil) $(built_mapping_cil)
416 cat $^ | sha256sum | cut -d' ' -f1 > $@
417
418#################################
419include $(CLEAR_VARS)
420
dcashman1faa6442016-11-28 07:20:28 -0800421LOCAL_MODULE := nonplat_sepolicy.cil
422LOCAL_MODULE_CLASS := ETC
423LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800424LOCAL_PROPRIETARY_MODULE := true
425LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800426
427include $(BUILD_SYSTEM)/base_rules.mk
428
Alex Klyubin55961722017-01-30 18:44:59 -0800429# nonplat_policy.conf - A combination of the non-platform private, vendor and
430# the exported platform policy associated with the version the non-platform
431# policy targets. This needs attributization and to be combined with the
dcashman2e00e632016-10-12 14:58:09 -0700432# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
433# of the reqd_policy_mask files from private policy in order to use checkpolicy.
434nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
435$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
436$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800437$(nonplat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700438$(nonplat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700439$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700440$(nonplat_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700441$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700442$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700443 $(transform-policy-to-conf)
Robert Craig65d4f442013-03-27 06:30:25 -0400444 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500445
dcashman1faa6442016-11-28 07:20:28 -0800446nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
447$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
448$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
449$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
450$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800451 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700452 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
dcashman1faa6442016-11-28 07:20:28 -0800453 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700454
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700455$(LOCAL_BUILT_MODULE) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
456$(LOCAL_BUILT_MODULE) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
457$(LOCAL_BUILT_MODULE) : PRIVATE_DEP_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
458$(LOCAL_BUILT_MODULE) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
459$(HOST_OUT_EXECUTABLES)/version_policy $(HOST_OUT_EXECUTABLES)/secilc \
Jeff Vander Stoep5edd96d2017-04-24 16:46:40 -0700460$(built_plat_cil) $(built_mapping_cil)
dcashman2e00e632016-10-12 14:58:09 -0700461 @mkdir -p $(dir $@)
462 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700463 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -N -c $(POLICYVERS) \
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800464 $(PRIVATE_DEP_CIL_FILES) $@ -o /dev/null -f /dev/null
dcashman2e00e632016-10-12 14:58:09 -0700465
Alex Klyubin193dccd2017-03-07 14:05:57 -0800466built_nonplat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800467nonplat_policy.conf :=
468nonplat_policy_raw :=
469
470#################################
471include $(CLEAR_VARS)
Alex Klyubin193dccd2017-03-07 14:05:57 -0800472
473LOCAL_MODULE := precompiled_sepolicy
474LOCAL_MODULE_CLASS := ETC
475LOCAL_MODULE_TAGS := optional
476LOCAL_PROPRIETARY_MODULE := true
477LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
478
479include $(BUILD_SYSTEM)/base_rules.mk
480
481$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := \
482$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
483$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc \
484$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
Jeff Vander Stoepac171b42017-04-12 17:01:54 -0700485 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -c $(POLICYVERS) \
Alex Klyubin193dccd2017-03-07 14:05:57 -0800486 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
487
488built_precompiled_sepolicy := $(LOCAL_BUILT_MODULE)
489
490#################################
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700491# SHA-256 digest of the plat_sepolicy.cil and mapping_sepolicy.cil files against
492# which precompiled_policy was built.
Alex Klyubin193dccd2017-03-07 14:05:57 -0800493#################################
494include $(CLEAR_VARS)
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700495LOCAL_MODULE := precompiled_sepolicy.plat_and_mapping.sha256
Alex Klyubin193dccd2017-03-07 14:05:57 -0800496LOCAL_MODULE_CLASS := ETC
497LOCAL_MODULE_TAGS := optional
498LOCAL_PROPRIETARY_MODULE := true
499LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
500
501include $(BUILD_SYSTEM)/base_rules.mk
502
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700503$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
504$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_plat_cil) $(built_mapping_cil)
505 cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@
Alex Klyubin193dccd2017-03-07 14:05:57 -0800506
507#################################
508include $(CLEAR_VARS)
Dan Cashman1c040272016-12-15 15:28:44 -0800509# build this target so that we can still perform neverallow checks
dcashman1faa6442016-11-28 07:20:28 -0800510
511LOCAL_MODULE := sepolicy
512LOCAL_MODULE_CLASS := ETC
513LOCAL_MODULE_TAGS := optional
Daniel Cashman65d01342016-12-17 00:53:26 +0000514LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman2e00e632016-10-12 14:58:09 -0700515
dcashman1faa6442016-11-28 07:20:28 -0800516include $(BUILD_SYSTEM)/base_rules.mk
517
dcashman2e00e632016-10-12 14:58:09 -0700518all_cil_files := \
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700519 $(built_plat_cil) \
520 $(built_mapping_cil) \
521 $(built_nonplat_cil)
dcashman2e00e632016-10-12 14:58:09 -0700522
523$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
524$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
525 @mkdir -p $(dir $@)
Jeff Vander Stoep748cae82017-04-13 14:16:29 -0700526 $(hide) $< -M true -G -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp -f /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800527 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
528 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
529 echo "==========" 1>&2; \
530 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
531 echo "List of invalid domains:" 1>&2; \
532 cat $@.permissivedomains 1>&2; \
533 exit 1; \
534 fi
535 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800536
Ying Wangd8b122c2012-10-25 19:01:31 -0700537built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700538all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400539
Alex Klyubin84aa7422017-03-10 09:36:07 -0800540#################################
541include $(CLEAR_VARS)
542
543# keep concrete sepolicy for neverallow checks
544
545LOCAL_MODULE := sepolicy.recovery
Alex Klyubinec78c372017-03-10 12:44:16 -0800546LOCAL_MODULE_STEM := sepolicy
Alex Klyubin84aa7422017-03-10 09:36:07 -0800547LOCAL_MODULE_CLASS := ETC
548LOCAL_MODULE_TAGS := optional
Alex Klyubinec78c372017-03-10 12:44:16 -0800549LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
Alex Klyubin84aa7422017-03-10 09:36:07 -0800550
551include $(BUILD_SYSTEM)/base_rules.mk
552
Dan Cashmanc8d45352017-04-11 07:38:48 -0700553sepolicy.recovery.conf := $(intermediates)/sepolicy.recovery.conf
554$(sepolicy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
555$(sepolicy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
556$(sepolicy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
557$(sepolicy.recovery.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
558$(sepolicy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700559$(sepolicy.recovery.conf): PRIVATE_TGT_RECOVERY := -D target_recovery=true
Dan Cashmanc8d45352017-04-11 07:38:48 -0700560$(sepolicy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
561 $(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) \
562 $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700563 $(transform-policy-to-conf)
Dan Cashman1c040272016-12-15 15:28:44 -0800564 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
565
Dan Cashmanc8d45352017-04-11 07:38:48 -0700566$(LOCAL_BUILT_MODULE): $(sepolicy.recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
567 $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Dan Cashman1c040272016-12-15 15:28:44 -0800568 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700569 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c \
570 $(POLICYVERS) -o $@.tmp $<
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800571 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
572 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
573 echo "==========" 1>&2; \
574 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
575 echo "List of invalid domains:" 1>&2; \
576 cat $@.permissivedomains 1>&2; \
577 exit 1; \
578 fi
579 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400580
Dan Cashmanc8d45352017-04-11 07:38:48 -0700581sepolicy.recovery.conf :=
Stephen Smalleye60723a2014-05-29 16:40:15 -0400582
dcashman704741a2014-07-25 19:11:52 -0700583##################################
Alex Klyubin446279a2017-04-06 14:45:50 -0700584# SELinux policy embedded into CTS.
585# CTS checks neverallow rules of this policy against the policy of the device under test.
586##################################
dcashman704741a2014-07-25 19:11:52 -0700587include $(CLEAR_VARS)
588
589LOCAL_MODULE := general_sepolicy.conf
590LOCAL_MODULE_CLASS := ETC
591LOCAL_MODULE_TAGS := tests
592
593include $(BUILD_SYSTEM)/base_rules.mk
594
dcashman704741a2014-07-25 19:11:52 -0700595$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
596$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800597$(LOCAL_BUILT_MODULE): PRIVATE_TGT_ARCH := $(my_target_arch)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700598$(LOCAL_BUILT_MODULE): PRIVATE_WITH_ASAN := false
599$(LOCAL_BUILT_MODULE): PRIVATE_FULL_TREBLE := cts
dcashmancc39f632016-07-22 13:13:11 -0700600$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
601$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700602 $(transform-policy-to-conf)
dcashman704741a2014-07-25 19:11:52 -0700603 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
604
William Robertsb8769932015-06-29 16:31:23 -0700605##################################
dcashmand225b692016-12-12 09:29:04 -0800606# TODO - remove this. Keep around until we get the filesystem creation stuff taken care of.
607#
William Robertsb8769932015-06-29 16:31:23 -0700608include $(CLEAR_VARS)
609
Richard Hainesc2d01912015-08-06 17:43:52 +0100610LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800611LOCAL_MODULE_CLASS := ETC
612LOCAL_MODULE_TAGS := optional
613LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
614
Stephen Smalley5b340be2012-03-06 11:12:41 -0500615include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800616
William Roberts49693f12016-01-04 12:20:57 -0800617# The file_contexts.bin is built in the following way:
618# 1. Collect all file_contexts files in THIS repository and process them with
619# m4 into a tmp file called file_contexts.local.tmp.
620# 2. Collect all device specific file_contexts files and process them with m4
621# into a tmp file called file_contexts.device.tmp.
622# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
623# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
624# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
625# file_contexts.concat.tmp.
626# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
627# file_contexts.bin.
628#
629# Note: That a newline file is placed between each file_context file found to
630# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800631
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700632local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
633
William Roberts49693f12016-01-04 12:20:57 -0800634ifneq ($(filter address,$(SANITIZE_TARGET)),)
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700635 local_fc_files := $(local_fc_files) $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
William Roberts49693f12016-01-04 12:20:57 -0800636endif
637local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
638
639file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
640$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500641 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800642 $(hide) m4 -s $^ > $@
643
644device_fc_files := $(call build_device_policy, file_contexts)
645device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
646
647file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
648$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
649$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
650 @mkdir -p $(dir $@)
651 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
652
653file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
654$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
655$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
656 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800657 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800658 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
659
660file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
661$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
662 @mkdir -p $(dir $@)
663 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500664
William Roberts3746a0a2015-09-25 10:18:44 -0700665$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800666$(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 +0100667 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800668 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100669 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
670
Robert Craig8b7545b2014-03-20 09:35:08 -0400671built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800672local_fc_files :=
673local_fcfiles_with_nl :=
674device_fc_files :=
675device_fcfiles_with_nl :=
676file_contexts.concat.tmp :=
677file_contexts.device.sorted.tmp :=
678file_contexts.device.tmp :=
679file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700680
Ying Wang02fb5f32012-01-17 17:51:09 -0800681##################################
Dan Cashman91d398d2017-09-26 12:58:29 -0700682ifneq ($(TARGET_BUILD_VARIANT), user)
683include $(CLEAR_VARS)
684
685LOCAL_MODULE := selinux_denial_metadata
686LOCAL_MODULE_CLASS := ETC
687LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
688
689include $(BUILD_SYSTEM)/base_rules.mk
690
691bug_files := $(call build_policy, bug_map, $(LOCAL_PATH) $(PLAT_PRIVATE_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(PLAT_PUBLIC_POLICY))
692
693$(LOCAL_BUILT_MODULE) : $(bug_files)
694 @mkdir -p $(dir $@)
695 cat $^ > $@
696
697bug_files :=
698endif
699##################################
Ying Wang02fb5f32012-01-17 17:51:09 -0800700include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400701
dcashmand225b692016-12-12 09:29:04 -0800702LOCAL_MODULE := plat_file_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400703LOCAL_MODULE_CLASS := ETC
dcashmand225b692016-12-12 09:29:04 -0800704LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700705ifeq ($(PRODUCT_FULL_TREBLE),true)
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800706LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700707else
708LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
709endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400710
711include $(BUILD_SYSTEM)/base_rules.mk
712
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700713local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
dcashmand225b692016-12-12 09:29:04 -0800714ifneq ($(filter address,$(SANITIZE_TARGET)),)
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700715 local_fc_files += $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
dcashmand225b692016-12-12 09:29:04 -0800716endif
Alex Klyubine4665d72017-01-19 19:58:34 -0800717local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400718
Alex Klyubine4665d72017-01-19 19:58:34 -0800719$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl)
dcashmand225b692016-12-12 09:29:04 -0800720$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Alex Klyubine4665d72017-01-19 19:58:34 -0800721$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
722$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
723$(local_fcfiles_with_nl) $(built_sepolicy)
Richard Hainesc2d01912015-08-06 17:43:52 +0100724 @mkdir -p $(dir $@)
Alex Klyubine4665d72017-01-19 19:58:34 -0800725 $(hide) m4 -s $(PRIVATE_FC_FILES) > $@.tmp
726 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
727 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
Richard Hainesc2d01912015-08-06 17:43:52 +0100728
dcashmand225b692016-12-12 09:29:04 -0800729built_plat_fc := $(LOCAL_BUILT_MODULE)
730local_fc_files :=
Alex Klyubine4665d72017-01-19 19:58:34 -0800731local_fcfiles_with_nl :=
dcashmand225b692016-12-12 09:29:04 -0800732
733##################################
734include $(CLEAR_VARS)
735
736LOCAL_MODULE := nonplat_file_contexts
737LOCAL_MODULE_CLASS := ETC
738LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700739ifeq ($(PRODUCT_FULL_TREBLE),true)
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800740LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700741else
742LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
743endif
dcashmand225b692016-12-12 09:29:04 -0800744
745include $(BUILD_SYSTEM)/base_rules.mk
746
747nonplat_fc_files := $(call build_device_policy, file_contexts)
748nonplat_fcfiles_with_nl := $(call add_nl, $(nonplat_fc_files), $(built_nl))
749
750$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(nonplat_fcfiles_with_nl)
751$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
752$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
753$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
Alex Klyubine4665d72017-01-19 19:58:34 -0800754$(nonplat_fcfiles_with_nl) $(built_sepolicy)
dcashmand225b692016-12-12 09:29:04 -0800755 @mkdir -p $(dir $@)
756 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > $@.tmp
757 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
758 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
759
760built_nonplat_fc := $(LOCAL_BUILT_MODULE)
761nonplat_fc_files :=
762nonplat_fcfiles_with_nl :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400763
764##################################
765include $(CLEAR_VARS)
Jeff Vander Stoepb236eb62017-06-13 08:24:17 -0700766
767LOCAL_MODULE := plat_file_contexts.recovery
768LOCAL_MODULE_STEM := plat_file_contexts
769LOCAL_MODULE_CLASS := ETC
770LOCAL_MODULE_TAGS := optional
771LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
772
773include $(BUILD_SYSTEM)/base_rules.mk
774
775$(LOCAL_BUILT_MODULE): $(built_plat_fc)
776 $(hide) cp -f $< $@
777
778##################################
779include $(CLEAR_VARS)
780LOCAL_MODULE := nonplat_file_contexts.recovery
781LOCAL_MODULE_STEM := nonplat_file_contexts
782LOCAL_MODULE_CLASS := ETC
783LOCAL_MODULE_TAGS := optional
784LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
785
786include $(BUILD_SYSTEM)/base_rules.mk
787
788$(LOCAL_BUILT_MODULE): $(built_nonplat_fc)
789 $(hide) cp -f $< $@
790
791##################################
792include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800793LOCAL_MODULE := plat_seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800794LOCAL_MODULE_CLASS := ETC
795LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800796ifeq ($(PRODUCT_FULL_TREBLE),true)
797LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
798else
Ying Wang02fb5f32012-01-17 17:51:09 -0800799LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800800endif
Ying Wang02fb5f32012-01-17 17:51:09 -0800801
William Roberts171a0622012-08-16 10:55:05 -0700802include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800803
Dan Cashman9c038072016-12-22 07:15:18 -0800804plat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts171a0622012-08-16 10:55:05 -0700805
Ying Wangd8b122c2012-10-25 19:01:31 -0700806$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman9c038072016-12-22 07:15:18 -0800807$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(plat_sc_files)
808$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(plat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700809 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700810 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800811
Dan Cashman9c038072016-12-22 07:15:18 -0800812built_plat_sc := $(LOCAL_BUILT_MODULE)
813plat_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400814
Ying Wang02fb5f32012-01-17 17:51:09 -0800815##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400816include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800817LOCAL_MODULE := nonplat_seapp_contexts
Stephen Smalley37712872015-03-12 15:46:36 -0400818LOCAL_MODULE_CLASS := ETC
Dan Cashman9c038072016-12-22 07:15:18 -0800819LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800820ifeq ($(PRODUCT_FULL_TREBLE),true)
821LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
822else
Dan Cashman9c038072016-12-22 07:15:18 -0800823LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800824endif
Stephen Smalley37712872015-03-12 15:46:36 -0400825
826include $(BUILD_SYSTEM)/base_rules.mk
827
Alex Klyubin55961722017-01-30 18:44:59 -0800828nonplat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700829plat_sc_neverallow_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
Stephen Smalley37712872015-03-12 15:46:36 -0400830
Dan Cashman9c038072016-12-22 07:15:18 -0800831$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
832$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(nonplat_sc_files)
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800833$(LOCAL_BUILT_MODULE): PRIVATE_SC_NEVERALLOW_FILES := $(plat_sc_neverallow_files)
834$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(nonplat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp $(plat_sc_neverallow_files)
Stephen Smalley37712872015-03-12 15:46:36 -0400835 @mkdir -p $(dir $@)
Dan Cashman91d398d2017-09-26 12:58:29 -0700836 $(hide) grep -ihe '^neverallow' $(PRIVATE_SC_NEVERALLOW_FILES) > $@.tmp
Xin Liec6f3932017-03-14 16:51:13 -0700837 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES) $@.tmp
Stephen Smalley37712872015-03-12 15:46:36 -0400838
Dan Cashman9c038072016-12-22 07:15:18 -0800839built_nonplat_sc := $(LOCAL_BUILT_MODULE)
840nonplat_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400841
842##################################
843include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800844LOCAL_MODULE := plat_seapp_neverallows
William Roberts4ee71312015-06-25 11:59:30 -0700845LOCAL_MODULE_CLASS := ETC
846LOCAL_MODULE_TAGS := tests
847
848include $(BUILD_SYSTEM)/base_rules.mk
849
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800850$(LOCAL_BUILT_MODULE): $(plat_sc_neverallow_files)
William Roberts4ee71312015-06-25 11:59:30 -0700851 @mkdir -p $(dir $@)
Dan Cashman91d398d2017-09-26 12:58:29 -0700852 - $(hide) grep -ihe '^neverallow' $< > $@
William Roberts4ee71312015-06-25 11:59:30 -0700853
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800854plat_sc_neverallow_files :=
William Roberts4ee71312015-06-25 11:59:30 -0700855
856##################################
857include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400858
Sandeep Patila86316e2016-12-27 16:08:44 -0800859LOCAL_MODULE := plat_property_contexts
Stephen Smalley124720a2012-04-04 10:11:16 -0400860LOCAL_MODULE_CLASS := ETC
861LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800862
863ifeq ($(PRODUCT_FULL_TREBLE),true)
864LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
865else
Stephen Smalley124720a2012-04-04 10:11:16 -0400866LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800867endif
Stephen Smalley124720a2012-04-04 10:11:16 -0400868
869include $(BUILD_SYSTEM)/base_rules.mk
870
Sandeep Patila86316e2016-12-27 16:08:44 -0800871plat_pcfiles := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts6aabc1c2015-07-30 11:44:26 -0700872
Sandeep Patila86316e2016-12-27 16:08:44 -0800873plat_property_contexts.tmp := $(intermediates)/plat_property_contexts.tmp
874$(plat_property_contexts.tmp): PRIVATE_PC_FILES := $(plat_pcfiles)
875$(plat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
876$(plat_property_contexts.tmp): $(plat_pcfiles)
William Roberts7f81b332015-09-29 13:52:37 -0700877 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000878 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700879$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts4b44d242017-09-22 08:57:25 -0700880$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
881$(LOCAL_BUILT_MODULE): $(plat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort
William Robertsdcffd2b2015-09-29 13:52:37 -0700882 @mkdir -p $(dir $@)
William Roberts4b44d242017-09-22 08:57:25 -0700883 $(hide) $(PRIVATE_FC_SORT) $< $@
dcashman07791552016-12-07 11:27:47 -0800884 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400885
Sandeep Patila86316e2016-12-27 16:08:44 -0800886built_plat_pc := $(LOCAL_BUILT_MODULE)
887plat_pcfiles :=
888plat_property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400889
Stephen Smalley124720a2012-04-04 10:11:16 -0400890##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700891include $(CLEAR_VARS)
Sandeep Patila86316e2016-12-27 16:08:44 -0800892LOCAL_MODULE := nonplat_property_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400893LOCAL_MODULE_CLASS := ETC
Sandeep Patila86316e2016-12-27 16:08:44 -0800894LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800895
896ifeq ($(PRODUCT_FULL_TREBLE),true)
897LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
898else
Sandeep Patila86316e2016-12-27 16:08:44 -0800899LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800900endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400901
Stephen Smalleyc9361732015-03-13 09:36:57 -0400902include $(BUILD_SYSTEM)/base_rules.mk
903
Alex Klyubin55961722017-01-30 18:44:59 -0800904nonplat_pcfiles := $(call build_policy, property_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Sandeep Patil262edc32016-12-27 16:08:44 -0800905
Sandeep Patila86316e2016-12-27 16:08:44 -0800906nonplat_property_contexts.tmp := $(intermediates)/nonplat_property_contexts.tmp
907$(nonplat_property_contexts.tmp): PRIVATE_PC_FILES := $(nonplat_pcfiles)
908$(nonplat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
909$(nonplat_property_contexts.tmp): $(nonplat_pcfiles)
William Robertsdcffd2b2015-09-29 13:52:37 -0700910 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800911 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
912
913
914$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
915$(LOCAL_BUILT_MODULE): $(nonplat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
916 @mkdir -p $(dir $@)
917 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800918 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700919
Sandeep Patila86316e2016-12-27 16:08:44 -0800920built_nonplat_pc := $(LOCAL_BUILT_MODULE)
921nonplat_pcfiles :=
922nonplat_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400923
924##################################
925include $(CLEAR_VARS)
926
Alex Klyubinec78c372017-03-10 12:44:16 -0800927LOCAL_MODULE := plat_property_contexts.recovery
928LOCAL_MODULE_STEM := plat_property_contexts
929LOCAL_MODULE_CLASS := ETC
930LOCAL_MODULE_TAGS := optional
931LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
932
933include $(BUILD_SYSTEM)/base_rules.mk
934
935$(LOCAL_BUILT_MODULE): $(built_plat_pc)
936 $(hide) cp -f $< $@
937
938##################################
939include $(CLEAR_VARS)
Alex Klyubinec78c372017-03-10 12:44:16 -0800940LOCAL_MODULE := nonplat_property_contexts.recovery
941LOCAL_MODULE_STEM := nonplat_property_contexts
942LOCAL_MODULE_CLASS := ETC
943LOCAL_MODULE_TAGS := optional
944LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
945
946include $(BUILD_SYSTEM)/base_rules.mk
947
948$(LOCAL_BUILT_MODULE): $(built_nonplat_pc)
949 $(hide) cp -f $< $@
950
951##################################
952include $(CLEAR_VARS)
953
Sandeep Patila058b562016-12-27 15:10:48 -0800954LOCAL_MODULE := plat_service_contexts
Riley Spahnf90c41f2014-06-05 15:52:02 -0700955LOCAL_MODULE_CLASS := ETC
956LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800957ifeq ($(PRODUCT_FULL_TREBLE),true)
958LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
959else
Riley Spahnf90c41f2014-06-05 15:52:02 -0700960LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800961endif
Riley Spahnf90c41f2014-06-05 15:52:02 -0700962
963include $(BUILD_SYSTEM)/base_rules.mk
964
Sandeep Patila058b562016-12-27 15:10:48 -0800965plat_svcfiles := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700966
Sandeep Patila058b562016-12-27 15:10:48 -0800967plat_service_contexts.tmp := $(intermediates)/plat_service_contexts.tmp
968$(plat_service_contexts.tmp): PRIVATE_SVC_FILES := $(plat_svcfiles)
969$(plat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
970$(plat_service_contexts.tmp): $(plat_svcfiles)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700971 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700972 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700973
974$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila058b562016-12-27 15:10:48 -0800975$(LOCAL_BUILT_MODULE): $(plat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700976 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700977 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800978 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700979
Sandeep Patila058b562016-12-27 15:10:48 -0800980built_plat_svc := $(LOCAL_BUILT_MODULE)
981plat_svcfiles :=
982plat_service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700983
984##################################
Hung-ying Tyane83f1e52017-09-05 21:51:52 +0800985# nonplat_service_contexts is only allowed on non-full-treble devices
986ifneq ($(PRODUCT_FULL_TREBLE),true)
987
rpcraigb19665c2012-07-30 09:33:03 -0400988include $(CLEAR_VARS)
989
Sandeep Patila058b562016-12-27 15:10:48 -0800990LOCAL_MODULE := nonplat_service_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400991LOCAL_MODULE_CLASS := ETC
Sandeep Patila058b562016-12-27 15:10:48 -0800992LOCAL_MODULE_TAGS := optional
Sandeep Patila058b562016-12-27 15:10:48 -0800993LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400994
995include $(BUILD_SYSTEM)/base_rules.mk
996
Alex Klyubin55961722017-01-30 18:44:59 -0800997nonplat_svcfiles := $(call build_policy, service_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400998
Sandeep Patila058b562016-12-27 15:10:48 -0800999nonplat_service_contexts.tmp := $(intermediates)/nonplat_service_contexts.tmp
1000$(nonplat_service_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_svcfiles)
1001$(nonplat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1002$(nonplat_service_contexts.tmp): $(nonplat_svcfiles)
1003 @mkdir -p $(dir $@)
1004 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1005
1006$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1007$(LOCAL_BUILT_MODULE): $(nonplat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -07001008 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -07001009 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -08001010 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -07001011
Sandeep Patila058b562016-12-27 15:10:48 -08001012built_nonplat_svc := $(LOCAL_BUILT_MODULE)
1013nonplat_svcfiles :=
1014nonplat_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -04001015
Hung-ying Tyane83f1e52017-09-05 21:51:52 +08001016endif
1017
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -04001018##################################
1019include $(CLEAR_VARS)
1020
Martijn Coenen3ea47b92017-04-07 16:14:43 -07001021LOCAL_MODULE := plat_hwservice_contexts
1022LOCAL_MODULE_CLASS := ETC
1023LOCAL_MODULE_TAGS := optional
1024ifeq ($(PRODUCT_FULL_TREBLE),true)
1025LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
1026else
1027LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1028endif
1029
1030include $(BUILD_SYSTEM)/base_rules.mk
1031
1032plat_hwsvcfiles := $(call build_policy, hwservice_contexts, $(PLAT_PRIVATE_POLICY))
1033
1034plat_hwservice_contexts.tmp := $(intermediates)/plat_hwservice_contexts.tmp
1035$(plat_hwservice_contexts.tmp): PRIVATE_SVC_FILES := $(plat_hwsvcfiles)
1036$(plat_hwservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1037$(plat_hwservice_contexts.tmp): $(plat_hwsvcfiles)
1038 @mkdir -p $(dir $@)
1039 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1040
1041$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1042$(LOCAL_BUILT_MODULE): $(plat_hwservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1043 @mkdir -p $(dir $@)
1044 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
1045 $(HOST_OUT_EXECUTABLES)/checkfc -e -l $(PRIVATE_SEPOLICY) $@
1046
1047plat_hwsvcfiles :=
1048plat_hwservice_contexts.tmp :=
1049
1050##################################
1051include $(CLEAR_VARS)
1052
1053LOCAL_MODULE := nonplat_hwservice_contexts
1054LOCAL_MODULE_CLASS := ETC
1055LOCAL_MODULE_TAGS := optional
1056ifeq ($(PRODUCT_FULL_TREBLE),true)
1057LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
1058else
1059LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1060endif
1061
1062include $(BUILD_SYSTEM)/base_rules.mk
1063
1064nonplat_hwsvcfiles := $(call build_policy, hwservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1065
1066nonplat_hwservice_contexts.tmp := $(intermediates)/nonplat_hwservice_contexts.tmp
1067$(nonplat_hwservice_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_hwsvcfiles)
1068$(nonplat_hwservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1069$(nonplat_hwservice_contexts.tmp): $(nonplat_hwsvcfiles)
1070 @mkdir -p $(dir $@)
1071 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1072
1073$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1074$(LOCAL_BUILT_MODULE): $(nonplat_hwservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1075 @mkdir -p $(dir $@)
1076 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
1077 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -l $(PRIVATE_SEPOLICY) $@
1078
1079nonplat_hwsvcfiles :=
1080nonplat_hwservice_contexts.tmp :=
1081
1082##################################
1083include $(CLEAR_VARS)
1084
Martijn Coenen6676c232017-03-31 17:29:53 -07001085LOCAL_MODULE := vndservice_contexts
1086LOCAL_MODULE_CLASS := ETC
1087LOCAL_MODULE_TAGS := optional
1088ifeq ($(PRODUCT_FULL_TREBLE),true)
1089LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
1090else
1091LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1092endif
1093
1094include $(BUILD_SYSTEM)/base_rules.mk
1095
1096vnd_svcfiles := $(call build_policy, vndservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1097
1098vndservice_contexts.tmp := $(intermediates)/vndservice_contexts.tmp
1099$(vndservice_contexts.tmp): PRIVATE_SVC_FILES := $(vnd_svcfiles)
1100$(vndservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1101$(vndservice_contexts.tmp): $(vnd_svcfiles)
1102 @mkdir -p $(dir $@)
1103 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1104
1105$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1106$(LOCAL_BUILT_MODULE): $(vndservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1107 @mkdir -p $(dir $@)
1108 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
Martijn Coenenee976622017-04-07 10:08:55 -07001109 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -v $(PRIVATE_SEPOLICY) $@
Martijn Coenen6676c232017-03-31 17:29:53 -07001110
1111vnd_svcfiles :=
1112vndservice_contexts.tmp :=
1113##################################
1114include $(CLEAR_VARS)
1115
dcashman90b3b942016-12-14 13:47:55 -08001116LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -04001117LOCAL_MODULE_CLASS := ETC
1118LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001119LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
rpcraigb19665c2012-07-30 09:33:03 -04001120
William Roberts2c8a55d2012-11-30 14:59:09 -08001121include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -04001122
Geremy Condracd4104e2013-03-26 18:19:12 +00001123# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -08001124plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
1125$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1126$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +00001127 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -07001128 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +00001129
dcashman90b3b942016-12-14 13:47:55 -08001130all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -04001131
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001132# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -08001133all_plat_keys := platform media shared testkey
1134all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001135
dcashman90b3b942016-12-14 13:47:55 -08001136$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
1137$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1138$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +00001139 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -07001140 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -07001141 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +00001142
William Roberts6aabc1c2015-07-30 11:44:26 -07001143all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -08001144all_plat_keys :=
1145plat_mac_perms_keys.tmp :=
1146
1147##################################
1148include $(CLEAR_VARS)
1149
1150LOCAL_MODULE := nonplat_mac_permissions.xml
1151LOCAL_MODULE_CLASS := ETC
1152LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001153LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman90b3b942016-12-14 13:47:55 -08001154
1155include $(BUILD_SYSTEM)/base_rules.mk
1156
1157# Build keys.conf
1158nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
1159$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Alex Klyubin55961722017-01-30 18:44:59 -08001160$(nonplat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
dcashman90b3b942016-12-14 13:47:55 -08001161 @mkdir -p $(dir $@)
1162 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
1163
Alex Klyubin55961722017-01-30 18:44:59 -08001164all_nonplat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
dcashman90b3b942016-12-14 13:47:55 -08001165
1166$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
1167$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1168$(all_nonplat_mac_perms_files)
1169 @mkdir -p $(dir $@)
1170 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
1171
1172nonplat_mac_perms_keys.tmp :=
1173all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -07001174
Dan Cashman91d398d2017-09-26 12:58:29 -07001175#################################
1176include $(CLEAR_VARS)
1177LOCAL_MODULE := sepolicy_tests
1178LOCAL_MODULE_CLASS := ETC
1179LOCAL_MODULE_TAGS := tests
1180
1181include $(BUILD_SYSTEM)/base_rules.mk
1182
1183sepolicy_tests := $(intermediates)/sepolicy_tests
1184$(sepolicy_tests): PRIVATE_PLAT_FC := $(built_plat_fc)
1185$(sepolicy_tests): PRIVATE_NONPLAT_FC := $(built_nonplat_fc)
1186$(sepolicy_tests): PRIVATE_SEPOLICY := $(built_sepolicy)
1187$(sepolicy_tests): $(HOST_OUT_EXECUTABLES)/sepolicy_tests \
1188$(built_plat_fc) $(built_nonplat_fc) $(built_sepolicy)
1189 @mkdir -p $(dir $@)
1190 $(hide) python $(HOST_OUT_EXECUTABLES)/sepolicy_tests -l $(HOST_OUT)/lib64 -f $(PRIVATE_PLAT_FC) -f $(PRIVATE_NONPLAT_FC) -p $(PRIVATE_SEPOLICY)
1191 $(hide) touch $@
1192
rpcraigb19665c2012-07-30 09:33:03 -04001193##################################
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001194ifeq ($(PRODUCT_FULL_TREBLE),true)
1195include $(CLEAR_VARS)
1196# For Treble builds run tests verifying that processes are properly labeled and
Dan Cashman91d398d2017-09-26 12:58:29 -07001197# permissions granted do not violate the treble model. Also ensure that treble
1198# compatibility guarantees are upheld between SELinux version bumps.
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001199LOCAL_MODULE := treble_sepolicy_tests
1200LOCAL_MODULE_CLASS := ETC
1201LOCAL_MODULE_TAGS := tests
1202
1203include $(BUILD_SYSTEM)/base_rules.mk
1204
Dan Cashman91d398d2017-09-26 12:58:29 -07001205# 26.0_plat - the platform policy shipped as part of the 26.0 release. This is
1206# built to enable us to determine the diff between the current policy and the
1207# 26.0 policy, which will be used in tests to make sure that compatibility has
1208# been maintained by our mapping files.
120926.0_PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/prebuilts/api/26.0/public
121026.0_PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/prebuilts/api/26.0/private
121126.0_plat_policy.conf := $(intermediates)/26.0_plat_policy.conf
1212$(26.0_plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
1213$(26.0_plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
1214$(26.0_plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
1215$(26.0_plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
1216$(26.0_plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1217$(26.0_plat_policy.conf): PRIVATE_FULL_TREBLE := true
1218$(26.0_plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
1219$(26.0_PLAT_PUBLIC_POLICY) $(26.0_PLAT_PRIVATE_POLICY))
1220 $(transform-policy-to-conf)
1221 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
1222
1223built_26.0_plat_sepolicy := $(intermediates)/built_26.0_plat_sepolicy
1224$(built_26.0_plat_sepolicy): PRIVATE_ADDITIONAL_CIL_FILES := \
1225 $(call build_policy, technical_debt.cil , $(26.0_PLAT_PRIVATE_POLICY))
1226$(built_26.0_plat_sepolicy): $(26.0_plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
1227 $(HOST_OUT_EXECUTABLES)/secilc \
1228 $(call build_policy, technical_debt.cil, $(26.0_PLAT_PRIVATE_POLICY))
1229 @mkdir -p $(dir $@)
1230 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
1231 $(POLICYVERS) -o $@ $<
1232 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
1233 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -c $(POLICYVERS) $@ -o $@ -f /dev/null
1234
123526.0_plat_policy.conf :=
1236
1237
1238# 26.0_compat - the current plat_sepolicy.cil built with the compatibility file
1239# targeting the 26.0 SELinux release. This ensures that our policy will build
1240# when used on a device that has non-platform policy targetting the 26.0 release.
124126.0_compat := $(intermediates)/26.0_compat
124226.0_mapping.cil := $(LOCAL_PATH)/private/compat/26.0/26.0.cil
124326.0_mapping.ignore.cil := $(LOCAL_PATH)/private/compat/26.0/26.0.ignore.cil
124426.0_nonplat := $(LOCAL_PATH)/prebuilts/api/26.0/nonplat_sepolicy.cil
1245$(26.0_compat): PRIVATE_CIL_FILES := \
1246$(built_plat_cil) $(26.0_mapping.cil) $(26.0_nonplat)
1247$(26.0_compat): $(HOST_OUT_EXECUTABLES)/secilc \
1248$(built_plat_cil) $(26.0_mapping.cil) $(26.0_nonplat)
1249 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -N -c $(POLICYVERS) \
1250 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
1251
1252# 26.0_mapping.combined.cil - a combination of the mapping file used when
1253# combining the current platform policy with nonplatform policy based on the
1254# 26.0 policy release and also a special ignored file that exists purely for
1255# these tests.
125626.0_mapping.combined.cil := $(intermediates)/26.0_mapping.combined.cil
1257$(26.0_mapping.combined.cil): $(26.0_mapping.cil) $(26.0_mapping.ignore.cil)
1258 mkdir -p $(dir $@)
1259 cat $^ > $@
1260
1261# plat_sepolicy - the current platform policy only, built into a policy binary.
1262# TODO - this currently excludes partner extensions, but support should be added
1263# to enable partners to add their own compatibility mapping
1264BASE_PLAT_PUBLIC_POLICY := $(filter-out $(BOARD_PLAT_PUBLIC_SEPOLICY_DIR), $(PLAT_PUBLIC_POLICY))
1265BASE_PLAT_PRIVATE_POLICY := $(filter-out $(BOARD_PLAT_PRIVATE_SEPOLICY_DIR), $(PLAT_PRIVATE_POLICY))
1266base_plat_policy.conf := $(intermediates)/base_plat_policy.conf
1267$(base_plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
1268$(base_plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
1269$(base_plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
1270$(base_plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
1271$(base_plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1272$(base_plat_policy.conf): PRIVATE_FULL_TREBLE := true
1273$(base_plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
1274$(BASE_PLAT_PUBLIC_POLICY) $(BASE_PLAT_PRIVATE_POLICY))
1275 $(transform-policy-to-conf)
1276 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
1277
1278built_plat_sepolicy := $(intermediates)/built_plat_sepolicy
1279$(built_plat_sepolicy): PRIVATE_ADDITIONAL_CIL_FILES := \
1280 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(BASE_PLAT_PRIVATE_POLICY))
1281$(built_plat_sepolicy): $(base_plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
1282$(HOST_OUT_EXECUTABLES)/secilc \
1283$(call build_policy, $(sepolicy_build_cil_workaround_files), $(BASE_PLAT_PRIVATE_POLICY))
1284 @mkdir -p $(dir $@)
1285 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
1286 $(POLICYVERS) -o $@ $<
1287 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
1288 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -c $(POLICYVERS) $@ -o $@ -f /dev/null
1289
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001290treble_sepolicy_tests := $(intermediates)/treble_sepolicy_tests
1291$(treble_sepolicy_tests): PRIVATE_PLAT_FC := $(built_plat_fc)
1292$(treble_sepolicy_tests): PRIVATE_NONPLAT_FC := $(built_nonplat_fc)
1293$(treble_sepolicy_tests): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman91d398d2017-09-26 12:58:29 -07001294$(treble_sepolicy_tests): PRIVATE_SEPOLICY_OLD := $(built_26.0_plat_sepolicy)
1295$(treble_sepolicy_tests): PRIVATE_COMBINED_MAPPING := $(26.0_mapping.combined.cil)
1296$(treble_sepolicy_tests): PRIVATE_PLAT_SEPOLICY := $(built_plat_sepolicy)
1297ifeq ($(PRODUCT_FULL_TREBLE_OVERRIDE),true)
1298$(treble_sepolicy_tests): PRIVATE_FAKE_TREBLE := --fake-treble
1299else
1300$(treble_sepolicy_tests): PRIVATE_FAKE_TREBLE :=
1301endif
Jeff Vander Stoepa7d2c5b2017-09-23 14:42:50 -07001302$(treble_sepolicy_tests): $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests \
Dan Cashman91d398d2017-09-26 12:58:29 -07001303$(built_plat_fc) $(built_nonplat_fc) $(built_sepolicy) $(built_plat_sepolicy) \
1304$(built_26.0_plat_sepolicy) $(26.0_compat) $(26.0_mapping.combined.cil)
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001305 @mkdir -p $(dir $@)
Dan Cashman91d398d2017-09-26 12:58:29 -07001306 $(hide) python $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests -l \
1307 $(HOST_OUT)/lib64 -f $(PRIVATE_PLAT_FC) -f $(PRIVATE_NONPLAT_FC) \
1308 -b $(PRIVATE_PLAT_SEPOLICY) -m $(PRIVATE_COMBINED_MAPPING) \
1309 -o $(PRIVATE_SEPOLICY_OLD) -p $(PRIVATE_SEPOLICY) \
1310 $(PRIVATE_FAKE_TREBLE)
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001311 $(hide) touch $@
Dan Cashman91d398d2017-09-26 12:58:29 -07001312
131326.0_PLAT_PUBLIC_POLICY :=
131426.0_PLAT_PRIVATE_POLICY :=
131526.0_compat :=
131626.0_mapping.cil :=
131726.0_mapping.combined.cil :=
131826.0_mapping.ignore.cil :=
131926.0_nonplat :=
1320BASE_PLAT_PUBLIC_POLICY :=
1321BASE_PLAT_PRIVATE_POLICY :=
1322base_plat_policy.conf :=
1323built_26.0_plat_sepolicy :=
1324plat_sepolicy :=
1325
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001326endif # ($(PRODUCT_FULL_TREBLE),true)
1327#################################
rpcraig47cd3962012-10-17 21:09:52 -04001328
Dan Cashman1c040272016-12-15 15:28:44 -08001329add_nl :=
William Roberts49693f12016-01-04 12:20:57 -08001330build_device_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001331build_policy :=
dcashmand225b692016-12-12 09:29:04 -08001332built_plat_fc :=
1333built_nonplat_fc :=
Richard Hainesc8801fe2015-12-11 10:39:19 +00001334built_nl :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001335built_plat_cil :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001336built_mapping_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001337built_plat_pc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001338built_nonplat_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001339built_nonplat_pc :=
Dan Cashman9c038072016-12-22 07:15:18 -08001340built_nonplat_sc :=
1341built_plat_sc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001342built_precompiled_sepolicy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001343built_sepolicy :=
Sandeep Patila058b562016-12-27 15:10:48 -08001344built_plat_svc :=
1345built_nonplat_svc :=
Jeff Vander Stoepb8787692017-04-21 15:57:07 -07001346mapping_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001347my_target_arch :=
dcashman1faa6442016-11-28 07:20:28 -08001348plat_pub_policy.cil :=
1349reqd_policy_mask.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -08001350sepolicy_build_files :=
Alex Klyubin7cda44f2017-03-21 14:28:53 -07001351sepolicy_build_cil_workaround_files :=
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001352with_asan :=
Alice Chucdfb06f2012-11-01 11:33:04 -07001353
1354include $(call all-makefiles-under,$(LOCAL_PATH))