blob: f702c9a52238ca2208599d479ec00dddb846a002 [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
Jeff Vander Stoep3ca843a2017-10-04 09:42:29 -0700179# Library extension for host-side tests
Jeff Vander Stoepe06e4c12017-10-04 18:15:44 -0700180ifeq ($(HOST_OS),darwin)
Jeff Vander Stoep3ca843a2017-10-04 09:42:29 -0700181SHAREDLIB_EXT=dylib
182else
183SHAREDLIB_EXT=so
184endif
185
Dan Cashman4f9a6482017-04-10 12:27:18 -0700186include $(CLEAR_VARS)
187LOCAL_MODULE := selinux_policy
188LOCAL_MODULE_TAGS := optional
189# Include SELinux policy. We do this here because different modules
190# need to be included based on the value of PRODUCT_FULL_TREBLE. This
191# type of conditional inclusion cannot be done in top-level files such
192# as build/target/product/embedded.mk.
193# This conditional inclusion closely mimics the conditional logic
194# inside init/init.cpp for loading SELinux policy from files.
195ifeq ($(PRODUCT_FULL_TREBLE),true)
196
Dan Cashman4f9a6482017-04-10 12:27:18 -0700197# Use split SELinux policy
198LOCAL_REQUIRED_MODULES += \
199 $(platform_mapping_file) \
200 nonplat_sepolicy.cil \
201 plat_sepolicy.cil \
202 plat_and_mapping_sepolicy.cil.sha256 \
203 secilc \
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -0700204 plat_sepolicy_vers.txt \
Dan Cashman91d398d2017-09-26 12:58:29 -0700205
206ifneq ($(with_asan),true)
207LOCAL_REQUIRED_MODULES += \
208 treble_sepolicy_tests \
209
210endif
Dan Cashman4f9a6482017-04-10 12:27:18 -0700211
212# Include precompiled policy, unless told otherwise
213ifneq ($(PRODUCT_PRECOMPILED_SEPOLICY),false)
214LOCAL_REQUIRED_MODULES += precompiled_sepolicy precompiled_sepolicy.plat_and_mapping.sha256
215endif
Dan Cashman4f9a6482017-04-10 12:27:18 -0700216else
217# Use monolithic SELinux policy
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700218LOCAL_REQUIRED_MODULES += sepolicy
Dan Cashman4f9a6482017-04-10 12:27:18 -0700219endif
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700220
221LOCAL_REQUIRED_MODULES += \
222 nonplat_file_contexts \
Jeff Vander Stoep13fb5ed2017-08-22 13:29:53 -0700223 nonplat_mac_permissions.xml \
224 nonplat_property_contexts \
225 nonplat_seapp_contexts \
Jeff Vander Stoep13fb5ed2017-08-22 13:29:53 -0700226 nonplat_hwservice_contexts \
227 plat_file_contexts \
228 plat_mac_permissions.xml \
229 plat_property_contexts \
230 plat_seapp_contexts \
231 plat_service_contexts \
232 plat_hwservice_contexts \
Dan Cashman91d398d2017-09-26 12:58:29 -0700233 searchpolicy \
Jeff Vander Stoep13fb5ed2017-08-22 13:29:53 -0700234 vndservice_contexts \
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700235
Hung-ying Tyane83f1e52017-09-05 21:51:52 +0800236ifneq ($(PRODUCT_FULL_TREBLE),true)
237LOCAL_REQUIRED_MODULES += nonplat_service_contexts
238endif
239
Dan Cashman91d398d2017-09-26 12:58:29 -0700240ifneq ($(TARGET_BUILD_VARIANT), user)
241LOCAL_REQUIRED_MODULES += \
242 selinux_denial_metadata \
243
244endif
245
246ifneq ($(with_asan),true)
247LOCAL_REQUIRED_MODULES += \
248 sepolicy_tests \
249
250endif
251
Dan Cashman4f9a6482017-04-10 12:27:18 -0700252include $(BUILD_PHONY_PACKAGE)
253
Ying Wang02fb5f32012-01-17 17:51:09 -0800254##################################
dcashman2e00e632016-10-12 14:58:09 -0700255# reqd_policy_mask - a policy.conf file which contains only the bare minimum
256# policy necessary to use checkpolicy. This bare-minimum policy needs to be
257# present in all policy.conf files, but should not necessarily be exported as
258# part of the public policy. The rules generated by reqd_policy_mask will allow
259# the compilation of public policy and subsequent removal of CIL policy that
260# should not be exported.
261
262reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
263$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
264$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800265$(reqd_policy_mask.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700266$(reqd_policy_mask.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700267$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700268$(reqd_policy_mask.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700269$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700270 $(transform-policy-to-conf)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700271# b/37755687
272CHECKPOLICY_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0
273
dcashman2e00e632016-10-12 14:58:09 -0700274reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
275$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
276 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700277 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c \
278 $(POLICYVERS) -o $@ $<
dcashman2e00e632016-10-12 14:58:09 -0700279
dcashman1faa6442016-11-28 07:20:28 -0800280reqd_policy_mask.conf :=
281
282##################################
dcashman2e00e632016-10-12 14:58:09 -0700283# plat_pub_policy - policy that will be exported to be a part of non-platform
284# policy corresponding to this platform version. This is a limited subset of
285# policy that would not compile in checkpolicy on its own. To get around this
286# limitation, add only the required files from private policy, which will
287# generate CIL policy that will then be filtered out by the reqd_policy_mask.
288plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
289$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
290$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800291$(plat_pub_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700292$(plat_pub_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700293$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700294$(plat_pub_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700295$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700296$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700297 $(transform-policy-to-conf)
dcashman2e00e632016-10-12 14:58:09 -0700298plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800299$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
300$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
301$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700302 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700303 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
dcashman1faa6442016-11-28 07:20:28 -0800304 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700305
dcashman1faa6442016-11-28 07:20:28 -0800306plat_pub_policy.conf :=
Dan Cashman1c040272016-12-15 15:28:44 -0800307
dcashman1faa6442016-11-28 07:20:28 -0800308##################################
309include $(CLEAR_VARS)
310
311LOCAL_MODULE := sectxfile_nl
312LOCAL_MODULE_CLASS := ETC
313LOCAL_MODULE_TAGS := optional
314
315# Create a file containing newline only to add between context config files
316include $(BUILD_SYSTEM)/base_rules.mk
317$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700318 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800319 $(hide) echo > $@
320
321built_nl := $(LOCAL_BUILT_MODULE)
322
323#################################
324include $(CLEAR_VARS)
325
326LOCAL_MODULE := plat_sepolicy.cil
327LOCAL_MODULE_CLASS := ETC
328LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800329LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800330
331include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700332
333# plat_policy.conf - A combination of the private and public platform policy
334# which will ship with the device. The platform will always reflect the most
335# recent platform version and is not currently being attributized.
336plat_policy.conf := $(intermediates)/plat_policy.conf
337$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
338$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800339$(plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700340$(plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700341$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700342$(plat_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700343$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700344$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700345 $(transform-policy-to-conf)
dcashmancc39f632016-07-22 13:13:11 -0700346 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
347
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700348$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CIL_FILES := \
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700349 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700350$(LOCAL_BUILT_MODULE): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
351 $(HOST_OUT_EXECUTABLES)/secilc \
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700352 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
dcashman2e00e632016-10-12 14:58:09 -0700353 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700354 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
355 $(POLICYVERS) -o $@ $<
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700356 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
Jeff Vander Stoep74b70712017-10-06 17:06:04 -0700357 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -c $(POLICYVERS) $@ -o /dev/null -f /dev/null
dcashman1faa6442016-11-28 07:20:28 -0800358
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800359built_plat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800360plat_policy.conf :=
361
362#################################
363include $(CLEAR_VARS)
364
Dan Cashman4f9a6482017-04-10 12:27:18 -0700365LOCAL_MODULE := plat_sepolicy_vers.txt
dcashman1faa6442016-11-28 07:20:28 -0800366LOCAL_MODULE_CLASS := ETC
367LOCAL_MODULE_TAGS := optional
Dan Cashman4f9a6482017-04-10 12:27:18 -0700368LOCAL_PROPRIETARY_MODULE := true
369LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
370
371include $(BUILD_SYSTEM)/base_rules.mk
372
373$(LOCAL_BUILT_MODULE) : PRIVATE_PLAT_SEPOL_VERS := $(BOARD_SEPOLICY_VERS)
374$(LOCAL_BUILT_MODULE) :
375 mkdir -p $(dir $@)
376 echo $(PRIVATE_PLAT_SEPOL_VERS) > $@
377
378#################################
379include $(CLEAR_VARS)
380
381LOCAL_MODULE := $(platform_mapping_file)
382LOCAL_MODULE_CLASS := ETC
383LOCAL_MODULE_TAGS := optional
384LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux/mapping
dcashman1faa6442016-11-28 07:20:28 -0800385
386include $(BUILD_SYSTEM)/base_rules.mk
387
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700388current_mapping.cil := $(intermediates)/mapping/$(PLATFORM_SEPOLICY_VERSION).cil
389ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
dcashman1faa6442016-11-28 07:20:28 -0800390# auto-generate the mapping file for current platform policy, since it needs to
391# track platform policy development
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700392$(current_mapping.cil) : PRIVATE_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman1faa6442016-11-28 07:20:28 -0800393$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
394 @mkdir -p $(dir $@)
395 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
396
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700397else # ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
398prebuilt_mapping_files := $(wildcard $(addsuffix /mapping/$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)))
399$(current_mapping.cil) : $(prebuilt_mapping_files)
400 @mkdir -p $(dir $@)
401 cat $^ > $@
Sandeep Patil42f95982017-04-07 14:18:48 -0700402
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700403prebuilt_mapping_files :=
dcashman1faa6442016-11-28 07:20:28 -0800404endif
405
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700406$(LOCAL_BUILT_MODULE): $(current_mapping.cil) $(ACP)
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700407 $(hide) $(ACP) $< $@
dcashman1faa6442016-11-28 07:20:28 -0800408
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800409built_mapping_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800410current_mapping.cil :=
411
412#################################
413include $(CLEAR_VARS)
414
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700415LOCAL_MODULE := plat_and_mapping_sepolicy.cil.sha256
416LOCAL_MODULE_CLASS := ETC
417LOCAL_MODULE_TAGS := optional
418LOCAL_MODULE_PATH = $(TARGET_OUT)/etc/selinux
419
420include $(BUILD_SYSTEM)/base_rules.mk
421
422$(LOCAL_BUILT_MODULE): $(built_plat_cil) $(built_mapping_cil)
423 cat $^ | sha256sum | cut -d' ' -f1 > $@
424
425#################################
426include $(CLEAR_VARS)
427
dcashman1faa6442016-11-28 07:20:28 -0800428LOCAL_MODULE := nonplat_sepolicy.cil
429LOCAL_MODULE_CLASS := ETC
430LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800431LOCAL_PROPRIETARY_MODULE := true
432LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800433
434include $(BUILD_SYSTEM)/base_rules.mk
435
Alex Klyubin55961722017-01-30 18:44:59 -0800436# nonplat_policy.conf - A combination of the non-platform private, vendor and
437# the exported platform policy associated with the version the non-platform
438# policy targets. This needs attributization and to be combined with the
dcashman2e00e632016-10-12 14:58:09 -0700439# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
440# of the reqd_policy_mask files from private policy in order to use checkpolicy.
441nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
442$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
443$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800444$(nonplat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700445$(nonplat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700446$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700447$(nonplat_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700448$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700449$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700450 $(transform-policy-to-conf)
Robert Craig65d4f442013-03-27 06:30:25 -0400451 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500452
dcashman1faa6442016-11-28 07:20:28 -0800453nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
454$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
455$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
456$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
457$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800458 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700459 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
dcashman1faa6442016-11-28 07:20:28 -0800460 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700461
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700462$(LOCAL_BUILT_MODULE) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
463$(LOCAL_BUILT_MODULE) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
464$(LOCAL_BUILT_MODULE) : PRIVATE_DEP_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
465$(LOCAL_BUILT_MODULE) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
466$(HOST_OUT_EXECUTABLES)/version_policy $(HOST_OUT_EXECUTABLES)/secilc \
Jeff Vander Stoep5edd96d2017-04-24 16:46:40 -0700467$(built_plat_cil) $(built_mapping_cil)
dcashman2e00e632016-10-12 14:58:09 -0700468 @mkdir -p $(dir $@)
469 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
Jeff Vander Stoep74b70712017-10-06 17:06:04 -0700470 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -N -c $(POLICYVERS) \
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800471 $(PRIVATE_DEP_CIL_FILES) $@ -o /dev/null -f /dev/null
dcashman2e00e632016-10-12 14:58:09 -0700472
Alex Klyubin193dccd2017-03-07 14:05:57 -0800473built_nonplat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800474nonplat_policy.conf :=
475nonplat_policy_raw :=
476
477#################################
478include $(CLEAR_VARS)
Alex Klyubin193dccd2017-03-07 14:05:57 -0800479
480LOCAL_MODULE := precompiled_sepolicy
481LOCAL_MODULE_CLASS := ETC
482LOCAL_MODULE_TAGS := optional
483LOCAL_PROPRIETARY_MODULE := true
484LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
485
486include $(BUILD_SYSTEM)/base_rules.mk
487
488$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := \
489$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
490$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc \
491$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
Jeff Vander Stoep74b70712017-10-06 17:06:04 -0700492 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -c $(POLICYVERS) \
Alex Klyubin193dccd2017-03-07 14:05:57 -0800493 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
494
495built_precompiled_sepolicy := $(LOCAL_BUILT_MODULE)
496
497#################################
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700498# SHA-256 digest of the plat_sepolicy.cil and mapping_sepolicy.cil files against
499# which precompiled_policy was built.
Alex Klyubin193dccd2017-03-07 14:05:57 -0800500#################################
501include $(CLEAR_VARS)
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700502LOCAL_MODULE := precompiled_sepolicy.plat_and_mapping.sha256
Alex Klyubin193dccd2017-03-07 14:05:57 -0800503LOCAL_MODULE_CLASS := ETC
504LOCAL_MODULE_TAGS := optional
505LOCAL_PROPRIETARY_MODULE := true
506LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
507
508include $(BUILD_SYSTEM)/base_rules.mk
509
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700510$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
511$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_plat_cil) $(built_mapping_cil)
512 cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@
Alex Klyubin193dccd2017-03-07 14:05:57 -0800513
514#################################
515include $(CLEAR_VARS)
Dan Cashman1c040272016-12-15 15:28:44 -0800516# build this target so that we can still perform neverallow checks
dcashman1faa6442016-11-28 07:20:28 -0800517
518LOCAL_MODULE := sepolicy
519LOCAL_MODULE_CLASS := ETC
520LOCAL_MODULE_TAGS := optional
Daniel Cashman65d01342016-12-17 00:53:26 +0000521LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman2e00e632016-10-12 14:58:09 -0700522
dcashman1faa6442016-11-28 07:20:28 -0800523include $(BUILD_SYSTEM)/base_rules.mk
524
dcashman2e00e632016-10-12 14:58:09 -0700525all_cil_files := \
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700526 $(built_plat_cil) \
527 $(built_mapping_cil) \
528 $(built_nonplat_cil)
dcashman2e00e632016-10-12 14:58:09 -0700529
530$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
531$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
532 @mkdir -p $(dir $@)
Jeff Vander Stoep74b70712017-10-06 17:06:04 -0700533 $(hide) $< -m -M true -G -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp -f /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800534 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
535 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
536 echo "==========" 1>&2; \
537 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
538 echo "List of invalid domains:" 1>&2; \
539 cat $@.permissivedomains 1>&2; \
540 exit 1; \
541 fi
542 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800543
Ying Wangd8b122c2012-10-25 19:01:31 -0700544built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700545all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400546
Alex Klyubin84aa7422017-03-10 09:36:07 -0800547#################################
548include $(CLEAR_VARS)
549
550# keep concrete sepolicy for neverallow checks
551
552LOCAL_MODULE := sepolicy.recovery
Alex Klyubinec78c372017-03-10 12:44:16 -0800553LOCAL_MODULE_STEM := sepolicy
Alex Klyubin84aa7422017-03-10 09:36:07 -0800554LOCAL_MODULE_CLASS := ETC
555LOCAL_MODULE_TAGS := optional
Alex Klyubinec78c372017-03-10 12:44:16 -0800556LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
Alex Klyubin84aa7422017-03-10 09:36:07 -0800557
558include $(BUILD_SYSTEM)/base_rules.mk
559
Dan Cashmanc8d45352017-04-11 07:38:48 -0700560sepolicy.recovery.conf := $(intermediates)/sepolicy.recovery.conf
561$(sepolicy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
562$(sepolicy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
563$(sepolicy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
564$(sepolicy.recovery.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
565$(sepolicy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700566$(sepolicy.recovery.conf): PRIVATE_TGT_RECOVERY := -D target_recovery=true
Dan Cashmanc8d45352017-04-11 07:38:48 -0700567$(sepolicy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
568 $(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) \
569 $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700570 $(transform-policy-to-conf)
Dan Cashman1c040272016-12-15 15:28:44 -0800571 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
572
Dan Cashmanc8d45352017-04-11 07:38:48 -0700573$(LOCAL_BUILT_MODULE): $(sepolicy.recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
574 $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Dan Cashman1c040272016-12-15 15:28:44 -0800575 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700576 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c \
577 $(POLICYVERS) -o $@.tmp $<
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800578 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
579 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
580 echo "==========" 1>&2; \
581 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
582 echo "List of invalid domains:" 1>&2; \
583 cat $@.permissivedomains 1>&2; \
584 exit 1; \
585 fi
586 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400587
Dan Cashmanc8d45352017-04-11 07:38:48 -0700588sepolicy.recovery.conf :=
Stephen Smalleye60723a2014-05-29 16:40:15 -0400589
dcashman704741a2014-07-25 19:11:52 -0700590##################################
Alex Klyubin446279a2017-04-06 14:45:50 -0700591# SELinux policy embedded into CTS.
592# CTS checks neverallow rules of this policy against the policy of the device under test.
593##################################
dcashman704741a2014-07-25 19:11:52 -0700594include $(CLEAR_VARS)
595
596LOCAL_MODULE := general_sepolicy.conf
597LOCAL_MODULE_CLASS := ETC
598LOCAL_MODULE_TAGS := tests
599
600include $(BUILD_SYSTEM)/base_rules.mk
601
dcashman704741a2014-07-25 19:11:52 -0700602$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
603$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800604$(LOCAL_BUILT_MODULE): PRIVATE_TGT_ARCH := $(my_target_arch)
Dan Cashman36ee91d2017-07-07 14:59:51 -0700605$(LOCAL_BUILT_MODULE): PRIVATE_WITH_ASAN := false
606$(LOCAL_BUILT_MODULE): PRIVATE_FULL_TREBLE := cts
dcashmancc39f632016-07-22 13:13:11 -0700607$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
608$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
Dan Cashman36ee91d2017-07-07 14:59:51 -0700609 $(transform-policy-to-conf)
dcashman704741a2014-07-25 19:11:52 -0700610 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
611
William Robertsb8769932015-06-29 16:31:23 -0700612##################################
dcashmand225b692016-12-12 09:29:04 -0800613# TODO - remove this. Keep around until we get the filesystem creation stuff taken care of.
614#
William Robertsb8769932015-06-29 16:31:23 -0700615include $(CLEAR_VARS)
616
Richard Hainesc2d01912015-08-06 17:43:52 +0100617LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800618LOCAL_MODULE_CLASS := ETC
619LOCAL_MODULE_TAGS := optional
620LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
621
Stephen Smalley5b340be2012-03-06 11:12:41 -0500622include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800623
William Roberts49693f12016-01-04 12:20:57 -0800624# The file_contexts.bin is built in the following way:
625# 1. Collect all file_contexts files in THIS repository and process them with
626# m4 into a tmp file called file_contexts.local.tmp.
627# 2. Collect all device specific file_contexts files and process them with m4
628# into a tmp file called file_contexts.device.tmp.
629# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
630# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
631# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
632# file_contexts.concat.tmp.
633# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
634# file_contexts.bin.
635#
636# Note: That a newline file is placed between each file_context file found to
637# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800638
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700639local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
640
William Roberts49693f12016-01-04 12:20:57 -0800641ifneq ($(filter address,$(SANITIZE_TARGET)),)
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700642 local_fc_files := $(local_fc_files) $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
William Roberts49693f12016-01-04 12:20:57 -0800643endif
644local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
645
646file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
647$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500648 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800649 $(hide) m4 -s $^ > $@
650
651device_fc_files := $(call build_device_policy, file_contexts)
652device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
653
654file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
655$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
656$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
657 @mkdir -p $(dir $@)
658 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
659
660file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
661$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
662$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
663 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800664 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800665 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
666
667file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
668$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
669 @mkdir -p $(dir $@)
670 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500671
William Roberts3746a0a2015-09-25 10:18:44 -0700672$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800673$(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 +0100674 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800675 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100676 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
677
Robert Craig8b7545b2014-03-20 09:35:08 -0400678built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800679local_fc_files :=
680local_fcfiles_with_nl :=
681device_fc_files :=
682device_fcfiles_with_nl :=
683file_contexts.concat.tmp :=
684file_contexts.device.sorted.tmp :=
685file_contexts.device.tmp :=
686file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700687
Ying Wang02fb5f32012-01-17 17:51:09 -0800688##################################
Dan Cashman91d398d2017-09-26 12:58:29 -0700689ifneq ($(TARGET_BUILD_VARIANT), user)
690include $(CLEAR_VARS)
691
692LOCAL_MODULE := selinux_denial_metadata
693LOCAL_MODULE_CLASS := ETC
694LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
695
696include $(BUILD_SYSTEM)/base_rules.mk
697
698bug_files := $(call build_policy, bug_map, $(LOCAL_PATH) $(PLAT_PRIVATE_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(PLAT_PUBLIC_POLICY))
699
700$(LOCAL_BUILT_MODULE) : $(bug_files)
701 @mkdir -p $(dir $@)
702 cat $^ > $@
703
704bug_files :=
705endif
706##################################
Ying Wang02fb5f32012-01-17 17:51:09 -0800707include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400708
dcashmand225b692016-12-12 09:29:04 -0800709LOCAL_MODULE := plat_file_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400710LOCAL_MODULE_CLASS := ETC
dcashmand225b692016-12-12 09:29:04 -0800711LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700712ifeq ($(PRODUCT_FULL_TREBLE),true)
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800713LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700714else
715LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
716endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400717
718include $(BUILD_SYSTEM)/base_rules.mk
719
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700720local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
dcashmand225b692016-12-12 09:29:04 -0800721ifneq ($(filter address,$(SANITIZE_TARGET)),)
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700722 local_fc_files += $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
dcashmand225b692016-12-12 09:29:04 -0800723endif
Alex Klyubine4665d72017-01-19 19:58:34 -0800724local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400725
Alex Klyubine4665d72017-01-19 19:58:34 -0800726$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl)
dcashmand225b692016-12-12 09:29:04 -0800727$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Alex Klyubine4665d72017-01-19 19:58:34 -0800728$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
729$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
730$(local_fcfiles_with_nl) $(built_sepolicy)
Richard Hainesc2d01912015-08-06 17:43:52 +0100731 @mkdir -p $(dir $@)
Alex Klyubine4665d72017-01-19 19:58:34 -0800732 $(hide) m4 -s $(PRIVATE_FC_FILES) > $@.tmp
733 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
734 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
Richard Hainesc2d01912015-08-06 17:43:52 +0100735
dcashmand225b692016-12-12 09:29:04 -0800736built_plat_fc := $(LOCAL_BUILT_MODULE)
737local_fc_files :=
Alex Klyubine4665d72017-01-19 19:58:34 -0800738local_fcfiles_with_nl :=
dcashmand225b692016-12-12 09:29:04 -0800739
740##################################
741include $(CLEAR_VARS)
742
743LOCAL_MODULE := nonplat_file_contexts
744LOCAL_MODULE_CLASS := ETC
745LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700746ifeq ($(PRODUCT_FULL_TREBLE),true)
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800747LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
Jeff Vander Stoep7a68c5a2017-06-08 13:24:15 -0700748else
749LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
750endif
dcashmand225b692016-12-12 09:29:04 -0800751
752include $(BUILD_SYSTEM)/base_rules.mk
753
754nonplat_fc_files := $(call build_device_policy, file_contexts)
755nonplat_fcfiles_with_nl := $(call add_nl, $(nonplat_fc_files), $(built_nl))
756
757$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(nonplat_fcfiles_with_nl)
758$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
759$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
760$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
Alex Klyubine4665d72017-01-19 19:58:34 -0800761$(nonplat_fcfiles_with_nl) $(built_sepolicy)
dcashmand225b692016-12-12 09:29:04 -0800762 @mkdir -p $(dir $@)
763 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > $@.tmp
764 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
765 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
766
767built_nonplat_fc := $(LOCAL_BUILT_MODULE)
768nonplat_fc_files :=
769nonplat_fcfiles_with_nl :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400770
771##################################
772include $(CLEAR_VARS)
Jeff Vander Stoepb236eb62017-06-13 08:24:17 -0700773
774LOCAL_MODULE := plat_file_contexts.recovery
775LOCAL_MODULE_STEM := plat_file_contexts
776LOCAL_MODULE_CLASS := ETC
777LOCAL_MODULE_TAGS := optional
778LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
779
780include $(BUILD_SYSTEM)/base_rules.mk
781
782$(LOCAL_BUILT_MODULE): $(built_plat_fc)
783 $(hide) cp -f $< $@
784
785##################################
786include $(CLEAR_VARS)
787LOCAL_MODULE := nonplat_file_contexts.recovery
788LOCAL_MODULE_STEM := nonplat_file_contexts
789LOCAL_MODULE_CLASS := ETC
790LOCAL_MODULE_TAGS := optional
791LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
792
793include $(BUILD_SYSTEM)/base_rules.mk
794
795$(LOCAL_BUILT_MODULE): $(built_nonplat_fc)
796 $(hide) cp -f $< $@
797
798##################################
799include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800800LOCAL_MODULE := plat_seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800801LOCAL_MODULE_CLASS := ETC
802LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800803ifeq ($(PRODUCT_FULL_TREBLE),true)
804LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
805else
Ying Wang02fb5f32012-01-17 17:51:09 -0800806LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800807endif
Ying Wang02fb5f32012-01-17 17:51:09 -0800808
William Roberts171a0622012-08-16 10:55:05 -0700809include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800810
Dan Cashman9c038072016-12-22 07:15:18 -0800811plat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts171a0622012-08-16 10:55:05 -0700812
Ying Wangd8b122c2012-10-25 19:01:31 -0700813$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman9c038072016-12-22 07:15:18 -0800814$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(plat_sc_files)
815$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(plat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700816 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700817 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800818
Dan Cashman9c038072016-12-22 07:15:18 -0800819built_plat_sc := $(LOCAL_BUILT_MODULE)
820plat_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400821
Ying Wang02fb5f32012-01-17 17:51:09 -0800822##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400823include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800824LOCAL_MODULE := nonplat_seapp_contexts
Stephen Smalley37712872015-03-12 15:46:36 -0400825LOCAL_MODULE_CLASS := ETC
Dan Cashman9c038072016-12-22 07:15:18 -0800826LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800827ifeq ($(PRODUCT_FULL_TREBLE),true)
828LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
829else
Dan Cashman9c038072016-12-22 07:15:18 -0800830LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800831endif
Stephen Smalley37712872015-03-12 15:46:36 -0400832
833include $(BUILD_SYSTEM)/base_rules.mk
834
Alex Klyubin55961722017-01-30 18:44:59 -0800835nonplat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Dan Cashman1b0a71f2017-05-08 14:26:52 -0700836plat_sc_neverallow_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
Stephen Smalley37712872015-03-12 15:46:36 -0400837
Dan Cashman9c038072016-12-22 07:15:18 -0800838$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
839$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(nonplat_sc_files)
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800840$(LOCAL_BUILT_MODULE): PRIVATE_SC_NEVERALLOW_FILES := $(plat_sc_neverallow_files)
841$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(nonplat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp $(plat_sc_neverallow_files)
Stephen Smalley37712872015-03-12 15:46:36 -0400842 @mkdir -p $(dir $@)
Dan Cashman91d398d2017-09-26 12:58:29 -0700843 $(hide) grep -ihe '^neverallow' $(PRIVATE_SC_NEVERALLOW_FILES) > $@.tmp
Xin Liec6f3932017-03-14 16:51:13 -0700844 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES) $@.tmp
Stephen Smalley37712872015-03-12 15:46:36 -0400845
Dan Cashman9c038072016-12-22 07:15:18 -0800846built_nonplat_sc := $(LOCAL_BUILT_MODULE)
847nonplat_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400848
849##################################
850include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800851LOCAL_MODULE := plat_seapp_neverallows
William Roberts4ee71312015-06-25 11:59:30 -0700852LOCAL_MODULE_CLASS := ETC
853LOCAL_MODULE_TAGS := tests
854
855include $(BUILD_SYSTEM)/base_rules.mk
856
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800857$(LOCAL_BUILT_MODULE): $(plat_sc_neverallow_files)
William Roberts4ee71312015-06-25 11:59:30 -0700858 @mkdir -p $(dir $@)
Dan Cashman91d398d2017-09-26 12:58:29 -0700859 - $(hide) grep -ihe '^neverallow' $< > $@
William Roberts4ee71312015-06-25 11:59:30 -0700860
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800861plat_sc_neverallow_files :=
William Roberts4ee71312015-06-25 11:59:30 -0700862
863##################################
864include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400865
Sandeep Patila86316e2016-12-27 16:08:44 -0800866LOCAL_MODULE := plat_property_contexts
Stephen Smalley124720a2012-04-04 10:11:16 -0400867LOCAL_MODULE_CLASS := ETC
868LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800869
870ifeq ($(PRODUCT_FULL_TREBLE),true)
871LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
872else
Stephen Smalley124720a2012-04-04 10:11:16 -0400873LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800874endif
Stephen Smalley124720a2012-04-04 10:11:16 -0400875
876include $(BUILD_SYSTEM)/base_rules.mk
877
Sandeep Patila86316e2016-12-27 16:08:44 -0800878plat_pcfiles := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts6aabc1c2015-07-30 11:44:26 -0700879
Sandeep Patila86316e2016-12-27 16:08:44 -0800880plat_property_contexts.tmp := $(intermediates)/plat_property_contexts.tmp
881$(plat_property_contexts.tmp): PRIVATE_PC_FILES := $(plat_pcfiles)
882$(plat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
883$(plat_property_contexts.tmp): $(plat_pcfiles)
William Roberts7f81b332015-09-29 13:52:37 -0700884 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000885 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700886$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts4b44d242017-09-22 08:57:25 -0700887$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
888$(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 -0700889 @mkdir -p $(dir $@)
William Roberts4b44d242017-09-22 08:57:25 -0700890 $(hide) $(PRIVATE_FC_SORT) $< $@
dcashman07791552016-12-07 11:27:47 -0800891 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400892
Sandeep Patila86316e2016-12-27 16:08:44 -0800893built_plat_pc := $(LOCAL_BUILT_MODULE)
894plat_pcfiles :=
895plat_property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400896
Stephen Smalley124720a2012-04-04 10:11:16 -0400897##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700898include $(CLEAR_VARS)
Sandeep Patila86316e2016-12-27 16:08:44 -0800899LOCAL_MODULE := nonplat_property_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400900LOCAL_MODULE_CLASS := ETC
Sandeep Patila86316e2016-12-27 16:08:44 -0800901LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800902
903ifeq ($(PRODUCT_FULL_TREBLE),true)
904LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
905else
Sandeep Patila86316e2016-12-27 16:08:44 -0800906LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800907endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400908
Stephen Smalleyc9361732015-03-13 09:36:57 -0400909include $(BUILD_SYSTEM)/base_rules.mk
910
Alex Klyubin55961722017-01-30 18:44:59 -0800911nonplat_pcfiles := $(call build_policy, property_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Sandeep Patil262edc32016-12-27 16:08:44 -0800912
Sandeep Patila86316e2016-12-27 16:08:44 -0800913nonplat_property_contexts.tmp := $(intermediates)/nonplat_property_contexts.tmp
914$(nonplat_property_contexts.tmp): PRIVATE_PC_FILES := $(nonplat_pcfiles)
915$(nonplat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
916$(nonplat_property_contexts.tmp): $(nonplat_pcfiles)
William Robertsdcffd2b2015-09-29 13:52:37 -0700917 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800918 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
919
920
921$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts3949fe22017-09-22 09:58:05 -0700922$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
923$(LOCAL_BUILT_MODULE): $(nonplat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort
Sandeep Patila86316e2016-12-27 16:08:44 -0800924 @mkdir -p $(dir $@)
William Roberts3949fe22017-09-22 09:58:05 -0700925 $(hide) $(PRIVATE_FC_SORT) $< $@
dcashman07791552016-12-07 11:27:47 -0800926 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700927
Sandeep Patila86316e2016-12-27 16:08:44 -0800928built_nonplat_pc := $(LOCAL_BUILT_MODULE)
929nonplat_pcfiles :=
930nonplat_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400931
932##################################
933include $(CLEAR_VARS)
934
Alex Klyubinec78c372017-03-10 12:44:16 -0800935LOCAL_MODULE := plat_property_contexts.recovery
936LOCAL_MODULE_STEM := plat_property_contexts
937LOCAL_MODULE_CLASS := ETC
938LOCAL_MODULE_TAGS := optional
939LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
940
941include $(BUILD_SYSTEM)/base_rules.mk
942
943$(LOCAL_BUILT_MODULE): $(built_plat_pc)
944 $(hide) cp -f $< $@
945
946##################################
947include $(CLEAR_VARS)
Alex Klyubinec78c372017-03-10 12:44:16 -0800948LOCAL_MODULE := nonplat_property_contexts.recovery
949LOCAL_MODULE_STEM := nonplat_property_contexts
950LOCAL_MODULE_CLASS := ETC
951LOCAL_MODULE_TAGS := optional
952LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
953
954include $(BUILD_SYSTEM)/base_rules.mk
955
956$(LOCAL_BUILT_MODULE): $(built_nonplat_pc)
957 $(hide) cp -f $< $@
958
959##################################
960include $(CLEAR_VARS)
961
Sandeep Patila058b562016-12-27 15:10:48 -0800962LOCAL_MODULE := plat_service_contexts
Riley Spahnf90c41f2014-06-05 15:52:02 -0700963LOCAL_MODULE_CLASS := ETC
964LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800965ifeq ($(PRODUCT_FULL_TREBLE),true)
966LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
967else
Riley Spahnf90c41f2014-06-05 15:52:02 -0700968LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800969endif
Riley Spahnf90c41f2014-06-05 15:52:02 -0700970
971include $(BUILD_SYSTEM)/base_rules.mk
972
Sandeep Patila058b562016-12-27 15:10:48 -0800973plat_svcfiles := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700974
Sandeep Patila058b562016-12-27 15:10:48 -0800975plat_service_contexts.tmp := $(intermediates)/plat_service_contexts.tmp
976$(plat_service_contexts.tmp): PRIVATE_SVC_FILES := $(plat_svcfiles)
977$(plat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
978$(plat_service_contexts.tmp): $(plat_svcfiles)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700979 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700980 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700981
982$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila058b562016-12-27 15:10:48 -0800983$(LOCAL_BUILT_MODULE): $(plat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700984 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700985 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800986 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700987
Sandeep Patila058b562016-12-27 15:10:48 -0800988built_plat_svc := $(LOCAL_BUILT_MODULE)
989plat_svcfiles :=
990plat_service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700991
992##################################
Hung-ying Tyane83f1e52017-09-05 21:51:52 +0800993# nonplat_service_contexts is only allowed on non-full-treble devices
994ifneq ($(PRODUCT_FULL_TREBLE),true)
995
rpcraigb19665c2012-07-30 09:33:03 -0400996include $(CLEAR_VARS)
997
Sandeep Patila058b562016-12-27 15:10:48 -0800998LOCAL_MODULE := nonplat_service_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400999LOCAL_MODULE_CLASS := ETC
Sandeep Patila058b562016-12-27 15:10:48 -08001000LOCAL_MODULE_TAGS := optional
Sandeep Patila058b562016-12-27 15:10:48 -08001001LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -04001002
1003include $(BUILD_SYSTEM)/base_rules.mk
1004
Alex Klyubin55961722017-01-30 18:44:59 -08001005nonplat_svcfiles := $(call build_policy, service_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -04001006
Sandeep Patila058b562016-12-27 15:10:48 -08001007nonplat_service_contexts.tmp := $(intermediates)/nonplat_service_contexts.tmp
1008$(nonplat_service_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_svcfiles)
1009$(nonplat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1010$(nonplat_service_contexts.tmp): $(nonplat_svcfiles)
1011 @mkdir -p $(dir $@)
1012 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1013
1014$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1015$(LOCAL_BUILT_MODULE): $(nonplat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -07001016 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -07001017 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -08001018 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -07001019
Sandeep Patila058b562016-12-27 15:10:48 -08001020built_nonplat_svc := $(LOCAL_BUILT_MODULE)
1021nonplat_svcfiles :=
1022nonplat_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -04001023
Hung-ying Tyane83f1e52017-09-05 21:51:52 +08001024endif
1025
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -04001026##################################
1027include $(CLEAR_VARS)
1028
Martijn Coenen3ea47b92017-04-07 16:14:43 -07001029LOCAL_MODULE := plat_hwservice_contexts
1030LOCAL_MODULE_CLASS := ETC
1031LOCAL_MODULE_TAGS := optional
1032ifeq ($(PRODUCT_FULL_TREBLE),true)
1033LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
1034else
1035LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1036endif
1037
1038include $(BUILD_SYSTEM)/base_rules.mk
1039
1040plat_hwsvcfiles := $(call build_policy, hwservice_contexts, $(PLAT_PRIVATE_POLICY))
1041
1042plat_hwservice_contexts.tmp := $(intermediates)/plat_hwservice_contexts.tmp
1043$(plat_hwservice_contexts.tmp): PRIVATE_SVC_FILES := $(plat_hwsvcfiles)
1044$(plat_hwservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1045$(plat_hwservice_contexts.tmp): $(plat_hwsvcfiles)
1046 @mkdir -p $(dir $@)
1047 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1048
1049$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1050$(LOCAL_BUILT_MODULE): $(plat_hwservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1051 @mkdir -p $(dir $@)
1052 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
1053 $(HOST_OUT_EXECUTABLES)/checkfc -e -l $(PRIVATE_SEPOLICY) $@
1054
1055plat_hwsvcfiles :=
1056plat_hwservice_contexts.tmp :=
1057
1058##################################
1059include $(CLEAR_VARS)
1060
1061LOCAL_MODULE := nonplat_hwservice_contexts
1062LOCAL_MODULE_CLASS := ETC
1063LOCAL_MODULE_TAGS := optional
1064ifeq ($(PRODUCT_FULL_TREBLE),true)
1065LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
1066else
1067LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1068endif
1069
1070include $(BUILD_SYSTEM)/base_rules.mk
1071
1072nonplat_hwsvcfiles := $(call build_policy, hwservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1073
1074nonplat_hwservice_contexts.tmp := $(intermediates)/nonplat_hwservice_contexts.tmp
1075$(nonplat_hwservice_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_hwsvcfiles)
1076$(nonplat_hwservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1077$(nonplat_hwservice_contexts.tmp): $(nonplat_hwsvcfiles)
1078 @mkdir -p $(dir $@)
1079 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1080
1081$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1082$(LOCAL_BUILT_MODULE): $(nonplat_hwservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1083 @mkdir -p $(dir $@)
1084 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
1085 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -l $(PRIVATE_SEPOLICY) $@
1086
1087nonplat_hwsvcfiles :=
1088nonplat_hwservice_contexts.tmp :=
1089
1090##################################
1091include $(CLEAR_VARS)
1092
Martijn Coenen6676c232017-03-31 17:29:53 -07001093LOCAL_MODULE := vndservice_contexts
1094LOCAL_MODULE_CLASS := ETC
1095LOCAL_MODULE_TAGS := optional
1096ifeq ($(PRODUCT_FULL_TREBLE),true)
1097LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
1098else
1099LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1100endif
1101
1102include $(BUILD_SYSTEM)/base_rules.mk
1103
1104vnd_svcfiles := $(call build_policy, vndservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1105
1106vndservice_contexts.tmp := $(intermediates)/vndservice_contexts.tmp
1107$(vndservice_contexts.tmp): PRIVATE_SVC_FILES := $(vnd_svcfiles)
1108$(vndservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1109$(vndservice_contexts.tmp): $(vnd_svcfiles)
1110 @mkdir -p $(dir $@)
1111 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1112
1113$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1114$(LOCAL_BUILT_MODULE): $(vndservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1115 @mkdir -p $(dir $@)
1116 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
Martijn Coenenee976622017-04-07 10:08:55 -07001117 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -v $(PRIVATE_SEPOLICY) $@
Martijn Coenen6676c232017-03-31 17:29:53 -07001118
1119vnd_svcfiles :=
1120vndservice_contexts.tmp :=
1121##################################
1122include $(CLEAR_VARS)
1123
dcashman90b3b942016-12-14 13:47:55 -08001124LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -04001125LOCAL_MODULE_CLASS := ETC
1126LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001127LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
rpcraigb19665c2012-07-30 09:33:03 -04001128
William Roberts2c8a55d2012-11-30 14:59:09 -08001129include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -04001130
Geremy Condracd4104e2013-03-26 18:19:12 +00001131# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -08001132plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
1133$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1134$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +00001135 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -07001136 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +00001137
dcashman90b3b942016-12-14 13:47:55 -08001138all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -04001139
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001140# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -08001141all_plat_keys := platform media shared testkey
1142all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001143
dcashman90b3b942016-12-14 13:47:55 -08001144$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
1145$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1146$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +00001147 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -07001148 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -07001149 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +00001150
William Roberts6aabc1c2015-07-30 11:44:26 -07001151all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -08001152all_plat_keys :=
1153plat_mac_perms_keys.tmp :=
1154
1155##################################
1156include $(CLEAR_VARS)
1157
1158LOCAL_MODULE := nonplat_mac_permissions.xml
1159LOCAL_MODULE_CLASS := ETC
1160LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001161LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman90b3b942016-12-14 13:47:55 -08001162
1163include $(BUILD_SYSTEM)/base_rules.mk
1164
1165# Build keys.conf
1166nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
1167$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Alex Klyubin55961722017-01-30 18:44:59 -08001168$(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 -08001169 @mkdir -p $(dir $@)
1170 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
1171
Alex Klyubin55961722017-01-30 18:44:59 -08001172all_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 -08001173
1174$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
1175$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1176$(all_nonplat_mac_perms_files)
1177 @mkdir -p $(dir $@)
1178 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
1179
1180nonplat_mac_perms_keys.tmp :=
1181all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -07001182
Dan Cashman91d398d2017-09-26 12:58:29 -07001183#################################
1184include $(CLEAR_VARS)
1185LOCAL_MODULE := sepolicy_tests
1186LOCAL_MODULE_CLASS := ETC
1187LOCAL_MODULE_TAGS := tests
1188
1189include $(BUILD_SYSTEM)/base_rules.mk
1190
1191sepolicy_tests := $(intermediates)/sepolicy_tests
1192$(sepolicy_tests): PRIVATE_PLAT_FC := $(built_plat_fc)
1193$(sepolicy_tests): PRIVATE_NONPLAT_FC := $(built_nonplat_fc)
1194$(sepolicy_tests): PRIVATE_SEPOLICY := $(built_sepolicy)
1195$(sepolicy_tests): $(HOST_OUT_EXECUTABLES)/sepolicy_tests \
1196$(built_plat_fc) $(built_nonplat_fc) $(built_sepolicy)
1197 @mkdir -p $(dir $@)
Jeff Vander Stoep3ca843a2017-10-04 09:42:29 -07001198 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy_tests -l $(HOST_OUT)/lib64/libsepolwrap.$(SHAREDLIB_EXT) \
1199 -f $(PRIVATE_PLAT_FC) -f $(PRIVATE_NONPLAT_FC) -p $(PRIVATE_SEPOLICY)
Dan Cashman91d398d2017-09-26 12:58:29 -07001200 $(hide) touch $@
1201
rpcraigb19665c2012-07-30 09:33:03 -04001202##################################
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001203ifeq ($(PRODUCT_FULL_TREBLE),true)
1204include $(CLEAR_VARS)
1205# For Treble builds run tests verifying that processes are properly labeled and
Dan Cashman91d398d2017-09-26 12:58:29 -07001206# permissions granted do not violate the treble model. Also ensure that treble
1207# compatibility guarantees are upheld between SELinux version bumps.
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001208LOCAL_MODULE := treble_sepolicy_tests
1209LOCAL_MODULE_CLASS := ETC
1210LOCAL_MODULE_TAGS := tests
1211
1212include $(BUILD_SYSTEM)/base_rules.mk
1213
Dan Cashman91d398d2017-09-26 12:58:29 -07001214# 26.0_plat - the platform policy shipped as part of the 26.0 release. This is
1215# built to enable us to determine the diff between the current policy and the
1216# 26.0 policy, which will be used in tests to make sure that compatibility has
1217# been maintained by our mapping files.
121826.0_PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/prebuilts/api/26.0/public
121926.0_PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/prebuilts/api/26.0/private
122026.0_plat_policy.conf := $(intermediates)/26.0_plat_policy.conf
1221$(26.0_plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
1222$(26.0_plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
1223$(26.0_plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
1224$(26.0_plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
1225$(26.0_plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1226$(26.0_plat_policy.conf): PRIVATE_FULL_TREBLE := true
1227$(26.0_plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
1228$(26.0_PLAT_PUBLIC_POLICY) $(26.0_PLAT_PRIVATE_POLICY))
1229 $(transform-policy-to-conf)
1230 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
1231
1232built_26.0_plat_sepolicy := $(intermediates)/built_26.0_plat_sepolicy
1233$(built_26.0_plat_sepolicy): PRIVATE_ADDITIONAL_CIL_FILES := \
1234 $(call build_policy, technical_debt.cil , $(26.0_PLAT_PRIVATE_POLICY))
1235$(built_26.0_plat_sepolicy): $(26.0_plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
1236 $(HOST_OUT_EXECUTABLES)/secilc \
1237 $(call build_policy, technical_debt.cil, $(26.0_PLAT_PRIVATE_POLICY))
1238 @mkdir -p $(dir $@)
1239 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
1240 $(POLICYVERS) -o $@ $<
1241 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
Jeff Vander Stoep74b70712017-10-06 17:06:04 -07001242 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -c $(POLICYVERS) $@ -o $@ -f /dev/null
Dan Cashman91d398d2017-09-26 12:58:29 -07001243
124426.0_plat_policy.conf :=
1245
1246
1247# 26.0_compat - the current plat_sepolicy.cil built with the compatibility file
1248# targeting the 26.0 SELinux release. This ensures that our policy will build
1249# when used on a device that has non-platform policy targetting the 26.0 release.
125026.0_compat := $(intermediates)/26.0_compat
125126.0_mapping.cil := $(LOCAL_PATH)/private/compat/26.0/26.0.cil
125226.0_mapping.ignore.cil := $(LOCAL_PATH)/private/compat/26.0/26.0.ignore.cil
125326.0_nonplat := $(LOCAL_PATH)/prebuilts/api/26.0/nonplat_sepolicy.cil
1254$(26.0_compat): PRIVATE_CIL_FILES := \
1255$(built_plat_cil) $(26.0_mapping.cil) $(26.0_nonplat)
1256$(26.0_compat): $(HOST_OUT_EXECUTABLES)/secilc \
1257$(built_plat_cil) $(26.0_mapping.cil) $(26.0_nonplat)
Jeff Vander Stoep74b70712017-10-06 17:06:04 -07001258 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -N -c $(POLICYVERS) \
Dan Cashman91d398d2017-09-26 12:58:29 -07001259 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
1260
1261# 26.0_mapping.combined.cil - a combination of the mapping file used when
1262# combining the current platform policy with nonplatform policy based on the
1263# 26.0 policy release and also a special ignored file that exists purely for
1264# these tests.
126526.0_mapping.combined.cil := $(intermediates)/26.0_mapping.combined.cil
1266$(26.0_mapping.combined.cil): $(26.0_mapping.cil) $(26.0_mapping.ignore.cil)
1267 mkdir -p $(dir $@)
1268 cat $^ > $@
1269
1270# plat_sepolicy - the current platform policy only, built into a policy binary.
1271# TODO - this currently excludes partner extensions, but support should be added
1272# to enable partners to add their own compatibility mapping
1273BASE_PLAT_PUBLIC_POLICY := $(filter-out $(BOARD_PLAT_PUBLIC_SEPOLICY_DIR), $(PLAT_PUBLIC_POLICY))
1274BASE_PLAT_PRIVATE_POLICY := $(filter-out $(BOARD_PLAT_PRIVATE_SEPOLICY_DIR), $(PLAT_PRIVATE_POLICY))
1275base_plat_policy.conf := $(intermediates)/base_plat_policy.conf
1276$(base_plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
1277$(base_plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
1278$(base_plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
1279$(base_plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
1280$(base_plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1281$(base_plat_policy.conf): PRIVATE_FULL_TREBLE := true
1282$(base_plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
1283$(BASE_PLAT_PUBLIC_POLICY) $(BASE_PLAT_PRIVATE_POLICY))
1284 $(transform-policy-to-conf)
1285 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
1286
1287built_plat_sepolicy := $(intermediates)/built_plat_sepolicy
1288$(built_plat_sepolicy): PRIVATE_ADDITIONAL_CIL_FILES := \
1289 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(BASE_PLAT_PRIVATE_POLICY))
1290$(built_plat_sepolicy): $(base_plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
1291$(HOST_OUT_EXECUTABLES)/secilc \
1292$(call build_policy, $(sepolicy_build_cil_workaround_files), $(BASE_PLAT_PRIVATE_POLICY))
1293 @mkdir -p $(dir $@)
1294 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
1295 $(POLICYVERS) -o $@ $<
1296 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
Jeff Vander Stoep74b70712017-10-06 17:06:04 -07001297 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -m -M true -G -c $(POLICYVERS) $@ -o $@ -f /dev/null
Dan Cashman91d398d2017-09-26 12:58:29 -07001298
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001299treble_sepolicy_tests := $(intermediates)/treble_sepolicy_tests
1300$(treble_sepolicy_tests): PRIVATE_PLAT_FC := $(built_plat_fc)
1301$(treble_sepolicy_tests): PRIVATE_NONPLAT_FC := $(built_nonplat_fc)
1302$(treble_sepolicy_tests): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman91d398d2017-09-26 12:58:29 -07001303$(treble_sepolicy_tests): PRIVATE_SEPOLICY_OLD := $(built_26.0_plat_sepolicy)
1304$(treble_sepolicy_tests): PRIVATE_COMBINED_MAPPING := $(26.0_mapping.combined.cil)
1305$(treble_sepolicy_tests): PRIVATE_PLAT_SEPOLICY := $(built_plat_sepolicy)
1306ifeq ($(PRODUCT_FULL_TREBLE_OVERRIDE),true)
1307$(treble_sepolicy_tests): PRIVATE_FAKE_TREBLE := --fake-treble
1308else
1309$(treble_sepolicy_tests): PRIVATE_FAKE_TREBLE :=
1310endif
Jeff Vander Stoepa7d2c5b2017-09-23 14:42:50 -07001311$(treble_sepolicy_tests): $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests \
Dan Cashman91d398d2017-09-26 12:58:29 -07001312$(built_plat_fc) $(built_nonplat_fc) $(built_sepolicy) $(built_plat_sepolicy) \
1313$(built_26.0_plat_sepolicy) $(26.0_compat) $(26.0_mapping.combined.cil)
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001314 @mkdir -p $(dir $@)
Jeff Vander Stoepe9777e32017-09-23 15:11:25 -07001315 $(hide) $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests -l \
Jeff Vander Stoep3ca843a2017-10-04 09:42:29 -07001316 $(HOST_OUT)/lib64/libsepolwrap.$(SHAREDLIB_EXT) \
1317 -f $(PRIVATE_PLAT_FC) -f $(PRIVATE_NONPLAT_FC) \
Dan Cashman91d398d2017-09-26 12:58:29 -07001318 -b $(PRIVATE_PLAT_SEPOLICY) -m $(PRIVATE_COMBINED_MAPPING) \
1319 -o $(PRIVATE_SEPOLICY_OLD) -p $(PRIVATE_SEPOLICY) \
1320 $(PRIVATE_FAKE_TREBLE)
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001321 $(hide) touch $@
Dan Cashman91d398d2017-09-26 12:58:29 -07001322
132326.0_PLAT_PUBLIC_POLICY :=
132426.0_PLAT_PRIVATE_POLICY :=
132526.0_compat :=
132626.0_mapping.cil :=
132726.0_mapping.combined.cil :=
132826.0_mapping.ignore.cil :=
132926.0_nonplat :=
1330BASE_PLAT_PUBLIC_POLICY :=
1331BASE_PLAT_PRIVATE_POLICY :=
1332base_plat_policy.conf :=
1333built_26.0_plat_sepolicy :=
1334plat_sepolicy :=
1335
Jeff Vander Stoep1fc06822017-05-31 15:36:07 -07001336endif # ($(PRODUCT_FULL_TREBLE),true)
1337#################################
rpcraig47cd3962012-10-17 21:09:52 -04001338
Dan Cashman1c040272016-12-15 15:28:44 -08001339add_nl :=
William Roberts49693f12016-01-04 12:20:57 -08001340build_device_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001341build_policy :=
dcashmand225b692016-12-12 09:29:04 -08001342built_plat_fc :=
1343built_nonplat_fc :=
Richard Hainesc8801fe2015-12-11 10:39:19 +00001344built_nl :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001345built_plat_cil :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001346built_mapping_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001347built_plat_pc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001348built_nonplat_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001349built_nonplat_pc :=
Dan Cashman9c038072016-12-22 07:15:18 -08001350built_nonplat_sc :=
1351built_plat_sc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001352built_precompiled_sepolicy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001353built_sepolicy :=
Sandeep Patila058b562016-12-27 15:10:48 -08001354built_plat_svc :=
1355built_nonplat_svc :=
Jeff Vander Stoepb8787692017-04-21 15:57:07 -07001356mapping_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001357my_target_arch :=
dcashman1faa6442016-11-28 07:20:28 -08001358plat_pub_policy.cil :=
1359reqd_policy_mask.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -08001360sepolicy_build_files :=
Alex Klyubin7cda44f2017-03-21 14:28:53 -07001361sepolicy_build_cil_workaround_files :=
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001362with_asan :=
Alice Chucdfb06f2012-11-01 11:33:04 -07001363
1364include $(call all-makefiles-under,$(LOCAL_PATH))