blob: 8ec1ebf2b5d65f973edd82067a5974f835235ba6 [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001LOCAL_PATH:= $(call my-dir)
William Robertsf0e0a942012-08-27 15:41:15 -07002
Dan Cashmanc0713e82017-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 Cashmanc0713e82017-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 Cashman1633da02017-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 Cashman1633da02017-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 \
Dan Cashmanccdd6e12017-06-15 11:18:04 -0700197 plat_sepolicy_vers.txt
198
199ifneq ($(with_asan),true)
200LOCAL_REQUIRED_MODULES += \
Jeff Vander Stoep11d096f2017-06-07 09:59:26 -0700201 treble_sepolicy_tests \
202 sepolicy_tests
Dan Cashmanccdd6e12017-06-15 11:18:04 -0700203endif
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 Stoepf965a0a2017-06-08 13:24:15 -0700211LOCAL_REQUIRED_MODULES += sepolicy
Dan Cashman4f9a6482017-04-10 12:27:18 -0700212endif
Jeff Vander Stoepf965a0a2017-06-08 13:24:15 -0700213
214LOCAL_REQUIRED_MODULES += \
215 nonplat_file_contexts \
216 plat_file_contexts
217
Dan Cashman4f9a6482017-04-10 12:27:18 -0700218include $(BUILD_PHONY_PACKAGE)
219
Ying Wang02fb5f32012-01-17 17:51:09 -0800220##################################
dcashman2e00e632016-10-12 14:58:09 -0700221# reqd_policy_mask - a policy.conf file which contains only the bare minimum
222# policy necessary to use checkpolicy. This bare-minimum policy needs to be
223# present in all policy.conf files, but should not necessarily be exported as
224# part of the public policy. The rules generated by reqd_policy_mask will allow
225# the compilation of public policy and subsequent removal of CIL policy that
226# should not be exported.
227
228reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
229$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
230$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800231$(reqd_policy_mask.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700232$(reqd_policy_mask.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700233$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashmanc0713e82017-07-07 14:59:51 -0700234$(reqd_policy_mask.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700235$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
Dan Cashmanc0713e82017-07-07 14:59:51 -0700236 $(transform-policy-to-conf)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700237# b/37755687
238CHECKPOLICY_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0
239
dcashman2e00e632016-10-12 14:58:09 -0700240reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
241$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
242 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700243 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c \
244 $(POLICYVERS) -o $@ $<
dcashman2e00e632016-10-12 14:58:09 -0700245
dcashman1faa6442016-11-28 07:20:28 -0800246reqd_policy_mask.conf :=
247
248##################################
dcashman2e00e632016-10-12 14:58:09 -0700249# plat_pub_policy - policy that will be exported to be a part of non-platform
250# policy corresponding to this platform version. This is a limited subset of
251# policy that would not compile in checkpolicy on its own. To get around this
252# limitation, add only the required files from private policy, which will
253# generate CIL policy that will then be filtered out by the reqd_policy_mask.
254plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
255$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
256$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800257$(plat_pub_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700258$(plat_pub_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700259$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashmanc0713e82017-07-07 14:59:51 -0700260$(plat_pub_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700261$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700262$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY))
Dan Cashmanc0713e82017-07-07 14:59:51 -0700263 $(transform-policy-to-conf)
dcashman2e00e632016-10-12 14:58:09 -0700264plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800265$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
266$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
267$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700268 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700269 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
dcashman1faa6442016-11-28 07:20:28 -0800270 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700271
dcashman1faa6442016-11-28 07:20:28 -0800272plat_pub_policy.conf :=
Dan Cashman1c040272016-12-15 15:28:44 -0800273
dcashman1faa6442016-11-28 07:20:28 -0800274##################################
275include $(CLEAR_VARS)
276
277LOCAL_MODULE := sectxfile_nl
278LOCAL_MODULE_CLASS := ETC
279LOCAL_MODULE_TAGS := optional
280
281# Create a file containing newline only to add between context config files
282include $(BUILD_SYSTEM)/base_rules.mk
283$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700284 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800285 $(hide) echo > $@
286
287built_nl := $(LOCAL_BUILT_MODULE)
288
289#################################
290include $(CLEAR_VARS)
291
292LOCAL_MODULE := plat_sepolicy.cil
293LOCAL_MODULE_CLASS := ETC
294LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800295LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800296
297include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700298
299# plat_policy.conf - A combination of the private and public platform policy
300# which will ship with the device. The platform will always reflect the most
301# recent platform version and is not currently being attributized.
302plat_policy.conf := $(intermediates)/plat_policy.conf
303$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
304$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800305$(plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700306$(plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700307$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashmanc0713e82017-07-07 14:59:51 -0700308$(plat_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700309$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700310$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
Dan Cashmanc0713e82017-07-07 14:59:51 -0700311 $(transform-policy-to-conf)
dcashmancc39f632016-07-22 13:13:11 -0700312 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
313
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700314$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CIL_FILES := \
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700315 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700316$(LOCAL_BUILT_MODULE): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
317 $(HOST_OUT_EXECUTABLES)/secilc \
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700318 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
dcashman2e00e632016-10-12 14:58:09 -0700319 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700320 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
321 $(POLICYVERS) -o $@ $<
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700322 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
Sandeep Patilcfb6f352017-06-14 09:57:43 -0700323 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -c $(POLICYVERS) $@ -o /dev/null -f /dev/null
dcashman1faa6442016-11-28 07:20:28 -0800324
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800325built_plat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800326plat_policy.conf :=
327
328#################################
329include $(CLEAR_VARS)
330
Dan Cashman4f9a6482017-04-10 12:27:18 -0700331LOCAL_MODULE := plat_sepolicy_vers.txt
dcashman1faa6442016-11-28 07:20:28 -0800332LOCAL_MODULE_CLASS := ETC
333LOCAL_MODULE_TAGS := optional
Dan Cashman4f9a6482017-04-10 12:27:18 -0700334LOCAL_PROPRIETARY_MODULE := true
335LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
336
337include $(BUILD_SYSTEM)/base_rules.mk
338
339$(LOCAL_BUILT_MODULE) : PRIVATE_PLAT_SEPOL_VERS := $(BOARD_SEPOLICY_VERS)
340$(LOCAL_BUILT_MODULE) :
341 mkdir -p $(dir $@)
342 echo $(PRIVATE_PLAT_SEPOL_VERS) > $@
343
344#################################
345include $(CLEAR_VARS)
346
347LOCAL_MODULE := $(platform_mapping_file)
348LOCAL_MODULE_CLASS := ETC
349LOCAL_MODULE_TAGS := optional
350LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux/mapping
dcashman1faa6442016-11-28 07:20:28 -0800351
352include $(BUILD_SYSTEM)/base_rules.mk
353
Dan Cashmanf8937002017-05-08 14:26:52 -0700354current_mapping.cil := $(intermediates)/mapping/$(PLATFORM_SEPOLICY_VERSION).cil
355ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
dcashman1faa6442016-11-28 07:20:28 -0800356# auto-generate the mapping file for current platform policy, since it needs to
357# track platform policy development
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700358$(current_mapping.cil) : PRIVATE_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman1faa6442016-11-28 07:20:28 -0800359$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
360 @mkdir -p $(dir $@)
361 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
362
Dan Cashmanf8937002017-05-08 14:26:52 -0700363else # ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
364prebuilt_mapping_files := $(wildcard $(addsuffix /mapping/$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)))
365$(current_mapping.cil) : $(prebuilt_mapping_files)
366 @mkdir -p $(dir $@)
367 cat $^ > $@
Sandeep Patil42f95982017-04-07 14:18:48 -0700368
Dan Cashmanf8937002017-05-08 14:26:52 -0700369prebuilt_mapping_files :=
dcashman1faa6442016-11-28 07:20:28 -0800370endif
371
Dan Cashmanf8937002017-05-08 14:26:52 -0700372$(LOCAL_BUILT_MODULE): $(current_mapping.cil) $(ACP)
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700373 $(hide) $(ACP) $< $@
dcashman1faa6442016-11-28 07:20:28 -0800374
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800375built_mapping_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800376current_mapping.cil :=
377
378#################################
379include $(CLEAR_VARS)
380
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700381LOCAL_MODULE := plat_and_mapping_sepolicy.cil.sha256
382LOCAL_MODULE_CLASS := ETC
383LOCAL_MODULE_TAGS := optional
384LOCAL_MODULE_PATH = $(TARGET_OUT)/etc/selinux
385
386include $(BUILD_SYSTEM)/base_rules.mk
387
388$(LOCAL_BUILT_MODULE): $(built_plat_cil) $(built_mapping_cil)
389 cat $^ | sha256sum | cut -d' ' -f1 > $@
390
391#################################
392include $(CLEAR_VARS)
393
dcashman1faa6442016-11-28 07:20:28 -0800394LOCAL_MODULE := nonplat_sepolicy.cil
395LOCAL_MODULE_CLASS := ETC
396LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800397LOCAL_PROPRIETARY_MODULE := true
398LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800399
400include $(BUILD_SYSTEM)/base_rules.mk
401
Alex Klyubin55961722017-01-30 18:44:59 -0800402# nonplat_policy.conf - A combination of the non-platform private, vendor and
403# the exported platform policy associated with the version the non-platform
404# policy targets. This needs attributization and to be combined with the
dcashman2e00e632016-10-12 14:58:09 -0700405# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
406# of the reqd_policy_mask files from private policy in order to use checkpolicy.
407nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
408$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
409$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800410$(nonplat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700411$(nonplat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700412$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashmanc0713e82017-07-07 14:59:51 -0700413$(nonplat_policy.conf): PRIVATE_FULL_TREBLE := $(PRODUCT_FULL_TREBLE)
dcashman2e00e632016-10-12 14:58:09 -0700414$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700415$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashmanc0713e82017-07-07 14:59:51 -0700416 $(transform-policy-to-conf)
Robert Craig65d4f442013-03-27 06:30:25 -0400417 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500418
dcashman1faa6442016-11-28 07:20:28 -0800419nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
420$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
421$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
422$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
423$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800424 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700425 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
dcashman1faa6442016-11-28 07:20:28 -0800426 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700427
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700428$(LOCAL_BUILT_MODULE) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
429$(LOCAL_BUILT_MODULE) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
430$(LOCAL_BUILT_MODULE) : PRIVATE_DEP_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
431$(LOCAL_BUILT_MODULE) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
432$(HOST_OUT_EXECUTABLES)/version_policy $(HOST_OUT_EXECUTABLES)/secilc \
Jeff Vander Stoep5edd96d2017-04-24 16:46:40 -0700433$(built_plat_cil) $(built_mapping_cil)
dcashman2e00e632016-10-12 14:58:09 -0700434 @mkdir -p $(dir $@)
435 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700436 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -N -c $(POLICYVERS) \
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800437 $(PRIVATE_DEP_CIL_FILES) $@ -o /dev/null -f /dev/null
dcashman2e00e632016-10-12 14:58:09 -0700438
Alex Klyubin193dccd2017-03-07 14:05:57 -0800439built_nonplat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800440nonplat_policy.conf :=
441nonplat_policy_raw :=
442
443#################################
444include $(CLEAR_VARS)
Alex Klyubin193dccd2017-03-07 14:05:57 -0800445
446LOCAL_MODULE := precompiled_sepolicy
447LOCAL_MODULE_CLASS := ETC
448LOCAL_MODULE_TAGS := optional
449LOCAL_PROPRIETARY_MODULE := true
450LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
451
452include $(BUILD_SYSTEM)/base_rules.mk
453
454$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := \
455$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
456$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc \
457$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
Jeff Vander Stoepac171b42017-04-12 17:01:54 -0700458 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -c $(POLICYVERS) \
Alex Klyubin193dccd2017-03-07 14:05:57 -0800459 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
460
461built_precompiled_sepolicy := $(LOCAL_BUILT_MODULE)
462
463#################################
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700464# SHA-256 digest of the plat_sepolicy.cil and mapping_sepolicy.cil files against
465# which precompiled_policy was built.
Alex Klyubin193dccd2017-03-07 14:05:57 -0800466#################################
467include $(CLEAR_VARS)
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700468LOCAL_MODULE := precompiled_sepolicy.plat_and_mapping.sha256
Alex Klyubin193dccd2017-03-07 14:05:57 -0800469LOCAL_MODULE_CLASS := ETC
470LOCAL_MODULE_TAGS := optional
471LOCAL_PROPRIETARY_MODULE := true
472LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
473
474include $(BUILD_SYSTEM)/base_rules.mk
475
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700476$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
477$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_plat_cil) $(built_mapping_cil)
478 cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@
Alex Klyubin193dccd2017-03-07 14:05:57 -0800479
480#################################
481include $(CLEAR_VARS)
Dan Cashman1c040272016-12-15 15:28:44 -0800482# build this target so that we can still perform neverallow checks
dcashman1faa6442016-11-28 07:20:28 -0800483
484LOCAL_MODULE := sepolicy
485LOCAL_MODULE_CLASS := ETC
486LOCAL_MODULE_TAGS := optional
Daniel Cashman65d01342016-12-17 00:53:26 +0000487LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman2e00e632016-10-12 14:58:09 -0700488
dcashman1faa6442016-11-28 07:20:28 -0800489include $(BUILD_SYSTEM)/base_rules.mk
490
dcashman2e00e632016-10-12 14:58:09 -0700491all_cil_files := \
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700492 $(built_plat_cil) \
493 $(built_mapping_cil) \
494 $(built_nonplat_cil)
dcashman2e00e632016-10-12 14:58:09 -0700495
496$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
497$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
498 @mkdir -p $(dir $@)
Jeff Vander Stoep748cae82017-04-13 14:16:29 -0700499 $(hide) $< -M true -G -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp -f /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800500 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
501 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
502 echo "==========" 1>&2; \
503 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
504 echo "List of invalid domains:" 1>&2; \
505 cat $@.permissivedomains 1>&2; \
506 exit 1; \
507 fi
508 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800509
Ying Wangd8b122c2012-10-25 19:01:31 -0700510built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700511all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400512
Alex Klyubin84aa7422017-03-10 09:36:07 -0800513#################################
514include $(CLEAR_VARS)
515
516# keep concrete sepolicy for neverallow checks
517
518LOCAL_MODULE := sepolicy.recovery
Alex Klyubinec78c372017-03-10 12:44:16 -0800519LOCAL_MODULE_STEM := sepolicy
Alex Klyubin84aa7422017-03-10 09:36:07 -0800520LOCAL_MODULE_CLASS := ETC
521LOCAL_MODULE_TAGS := optional
Alex Klyubinec78c372017-03-10 12:44:16 -0800522LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
Alex Klyubin84aa7422017-03-10 09:36:07 -0800523
524include $(BUILD_SYSTEM)/base_rules.mk
525
Dan Cashmanc8d45352017-04-11 07:38:48 -0700526sepolicy.recovery.conf := $(intermediates)/sepolicy.recovery.conf
527$(sepolicy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
528$(sepolicy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
529$(sepolicy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
530$(sepolicy.recovery.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
531$(sepolicy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Dan Cashmanc0713e82017-07-07 14:59:51 -0700532$(sepolicy.recovery.conf): PRIVATE_TGT_RECOVERY := -D target_recovery=true
Dan Cashmanc8d45352017-04-11 07:38:48 -0700533$(sepolicy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
534 $(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) \
535 $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashmanc0713e82017-07-07 14:59:51 -0700536 $(transform-policy-to-conf)
Dan Cashman1c040272016-12-15 15:28:44 -0800537 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
538
Dan Cashmanc8d45352017-04-11 07:38:48 -0700539$(LOCAL_BUILT_MODULE): $(sepolicy.recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
540 $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Dan Cashman1c040272016-12-15 15:28:44 -0800541 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700542 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c \
543 $(POLICYVERS) -o $@.tmp $<
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800544 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
545 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
546 echo "==========" 1>&2; \
547 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
548 echo "List of invalid domains:" 1>&2; \
549 cat $@.permissivedomains 1>&2; \
550 exit 1; \
551 fi
552 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400553
Dan Cashmanc8d45352017-04-11 07:38:48 -0700554sepolicy.recovery.conf :=
Stephen Smalleye60723a2014-05-29 16:40:15 -0400555
dcashman704741a2014-07-25 19:11:52 -0700556##################################
Alex Klyubin446279a2017-04-06 14:45:50 -0700557# SELinux policy embedded into CTS.
558# CTS checks neverallow rules of this policy against the policy of the device under test.
559##################################
dcashman704741a2014-07-25 19:11:52 -0700560include $(CLEAR_VARS)
561
562LOCAL_MODULE := general_sepolicy.conf
563LOCAL_MODULE_CLASS := ETC
564LOCAL_MODULE_TAGS := tests
565
566include $(BUILD_SYSTEM)/base_rules.mk
567
dcashman704741a2014-07-25 19:11:52 -0700568$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
569$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800570$(LOCAL_BUILT_MODULE): PRIVATE_TGT_ARCH := $(my_target_arch)
Dan Cashmanc0713e82017-07-07 14:59:51 -0700571$(LOCAL_BUILT_MODULE): PRIVATE_WITH_ASAN := false
572$(LOCAL_BUILT_MODULE): PRIVATE_FULL_TREBLE := cts
dcashmancc39f632016-07-22 13:13:11 -0700573$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
574$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
Dan Cashmanc0713e82017-07-07 14:59:51 -0700575 $(transform-policy-to-conf)
dcashman704741a2014-07-25 19:11:52 -0700576 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
577
William Robertsb8769932015-06-29 16:31:23 -0700578##################################
dcashmand225b692016-12-12 09:29:04 -0800579# TODO - remove this. Keep around until we get the filesystem creation stuff taken care of.
580#
William Robertsb8769932015-06-29 16:31:23 -0700581include $(CLEAR_VARS)
582
Richard Hainesc2d01912015-08-06 17:43:52 +0100583LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800584LOCAL_MODULE_CLASS := ETC
585LOCAL_MODULE_TAGS := optional
586LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
587
Stephen Smalley5b340be2012-03-06 11:12:41 -0500588include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800589
William Roberts49693f12016-01-04 12:20:57 -0800590# The file_contexts.bin is built in the following way:
591# 1. Collect all file_contexts files in THIS repository and process them with
592# m4 into a tmp file called file_contexts.local.tmp.
593# 2. Collect all device specific file_contexts files and process them with m4
594# into a tmp file called file_contexts.device.tmp.
595# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
596# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
597# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
598# file_contexts.concat.tmp.
599# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
600# file_contexts.bin.
601#
602# Note: That a newline file is placed between each file_context file found to
603# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800604
Dan Cashmanf8937002017-05-08 14:26:52 -0700605local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
606
William Roberts49693f12016-01-04 12:20:57 -0800607ifneq ($(filter address,$(SANITIZE_TARGET)),)
Dan Cashmanf8937002017-05-08 14:26:52 -0700608 local_fc_files := $(local_fc_files) $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
William Roberts49693f12016-01-04 12:20:57 -0800609endif
610local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
611
612file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
613$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500614 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800615 $(hide) m4 -s $^ > $@
616
617device_fc_files := $(call build_device_policy, file_contexts)
618device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
619
620file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
621$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
622$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
623 @mkdir -p $(dir $@)
624 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
625
626file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
627$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
628$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
629 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800630 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800631 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
632
633file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
634$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
635 @mkdir -p $(dir $@)
636 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500637
William Roberts3746a0a2015-09-25 10:18:44 -0700638$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800639$(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 +0100640 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800641 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100642 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
643
Robert Craig8b7545b2014-03-20 09:35:08 -0400644built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800645local_fc_files :=
646local_fcfiles_with_nl :=
647device_fc_files :=
648device_fcfiles_with_nl :=
649file_contexts.concat.tmp :=
650file_contexts.device.sorted.tmp :=
651file_contexts.device.tmp :=
652file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700653
Ying Wang02fb5f32012-01-17 17:51:09 -0800654##################################
655include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400656
dcashmand225b692016-12-12 09:29:04 -0800657LOCAL_MODULE := plat_file_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400658LOCAL_MODULE_CLASS := ETC
dcashmand225b692016-12-12 09:29:04 -0800659LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepf965a0a2017-06-08 13:24:15 -0700660ifeq ($(PRODUCT_FULL_TREBLE),true)
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800661LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
Jeff Vander Stoepf965a0a2017-06-08 13:24:15 -0700662else
663LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
664endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400665
666include $(BUILD_SYSTEM)/base_rules.mk
667
Dan Cashmanf8937002017-05-08 14:26:52 -0700668local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
dcashmand225b692016-12-12 09:29:04 -0800669ifneq ($(filter address,$(SANITIZE_TARGET)),)
Dan Cashman5e9451b2017-05-10 17:25:14 -0700670 local_fc_files += $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
dcashmand225b692016-12-12 09:29:04 -0800671endif
Alex Klyubine4665d72017-01-19 19:58:34 -0800672local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400673
Alex Klyubine4665d72017-01-19 19:58:34 -0800674$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl)
dcashmand225b692016-12-12 09:29:04 -0800675$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Alex Klyubine4665d72017-01-19 19:58:34 -0800676$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
677$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
678$(local_fcfiles_with_nl) $(built_sepolicy)
Richard Hainesc2d01912015-08-06 17:43:52 +0100679 @mkdir -p $(dir $@)
Alex Klyubine4665d72017-01-19 19:58:34 -0800680 $(hide) m4 -s $(PRIVATE_FC_FILES) > $@.tmp
681 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
682 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
Richard Hainesc2d01912015-08-06 17:43:52 +0100683
dcashmand225b692016-12-12 09:29:04 -0800684built_plat_fc := $(LOCAL_BUILT_MODULE)
685local_fc_files :=
Alex Klyubine4665d72017-01-19 19:58:34 -0800686local_fcfiles_with_nl :=
dcashmand225b692016-12-12 09:29:04 -0800687
688##################################
689include $(CLEAR_VARS)
690
691LOCAL_MODULE := nonplat_file_contexts
692LOCAL_MODULE_CLASS := ETC
693LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepf965a0a2017-06-08 13:24:15 -0700694ifeq ($(PRODUCT_FULL_TREBLE),true)
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800695LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
Jeff Vander Stoepf965a0a2017-06-08 13:24:15 -0700696else
697LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
698endif
dcashmand225b692016-12-12 09:29:04 -0800699
700include $(BUILD_SYSTEM)/base_rules.mk
701
702nonplat_fc_files := $(call build_device_policy, file_contexts)
703nonplat_fcfiles_with_nl := $(call add_nl, $(nonplat_fc_files), $(built_nl))
704
705$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(nonplat_fcfiles_with_nl)
706$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
707$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
708$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
Alex Klyubine4665d72017-01-19 19:58:34 -0800709$(nonplat_fcfiles_with_nl) $(built_sepolicy)
dcashmand225b692016-12-12 09:29:04 -0800710 @mkdir -p $(dir $@)
711 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > $@.tmp
712 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
713 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
714
715built_nonplat_fc := $(LOCAL_BUILT_MODULE)
716nonplat_fc_files :=
717nonplat_fcfiles_with_nl :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400718
719##################################
720include $(CLEAR_VARS)
Jeff Vander Stoepb236eb62017-06-13 08:24:17 -0700721
722LOCAL_MODULE := plat_file_contexts.recovery
723LOCAL_MODULE_STEM := plat_file_contexts
724LOCAL_MODULE_CLASS := ETC
725LOCAL_MODULE_TAGS := optional
726LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
727
728include $(BUILD_SYSTEM)/base_rules.mk
729
730$(LOCAL_BUILT_MODULE): $(built_plat_fc)
731 $(hide) cp -f $< $@
732
733##################################
734include $(CLEAR_VARS)
735LOCAL_MODULE := nonplat_file_contexts.recovery
736LOCAL_MODULE_STEM := nonplat_file_contexts
737LOCAL_MODULE_CLASS := ETC
738LOCAL_MODULE_TAGS := optional
739LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
740
741include $(BUILD_SYSTEM)/base_rules.mk
742
743$(LOCAL_BUILT_MODULE): $(built_nonplat_fc)
744 $(hide) cp -f $< $@
745
746##################################
747include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800748LOCAL_MODULE := plat_seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800749LOCAL_MODULE_CLASS := ETC
750LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800751ifeq ($(PRODUCT_FULL_TREBLE),true)
752LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
753else
Ying Wang02fb5f32012-01-17 17:51:09 -0800754LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800755endif
Ying Wang02fb5f32012-01-17 17:51:09 -0800756
William Roberts171a0622012-08-16 10:55:05 -0700757include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800758
Dan Cashman9c038072016-12-22 07:15:18 -0800759plat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts171a0622012-08-16 10:55:05 -0700760
Ying Wangd8b122c2012-10-25 19:01:31 -0700761$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman9c038072016-12-22 07:15:18 -0800762$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(plat_sc_files)
763$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(plat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700764 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700765 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800766
Dan Cashman9c038072016-12-22 07:15:18 -0800767built_plat_sc := $(LOCAL_BUILT_MODULE)
768plat_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400769
Ying Wang02fb5f32012-01-17 17:51:09 -0800770##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400771include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800772LOCAL_MODULE := nonplat_seapp_contexts
Stephen Smalley37712872015-03-12 15:46:36 -0400773LOCAL_MODULE_CLASS := ETC
Dan Cashman9c038072016-12-22 07:15:18 -0800774LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800775ifeq ($(PRODUCT_FULL_TREBLE),true)
776LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
777else
Dan Cashman9c038072016-12-22 07:15:18 -0800778LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800779endif
Stephen Smalley37712872015-03-12 15:46:36 -0400780
781include $(BUILD_SYSTEM)/base_rules.mk
782
Alex Klyubin55961722017-01-30 18:44:59 -0800783nonplat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Dan Cashmanf8937002017-05-08 14:26:52 -0700784plat_sc_neverallow_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
Stephen Smalley37712872015-03-12 15:46:36 -0400785
Dan Cashman9c038072016-12-22 07:15:18 -0800786$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
787$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(nonplat_sc_files)
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800788$(LOCAL_BUILT_MODULE): PRIVATE_SC_NEVERALLOW_FILES := $(plat_sc_neverallow_files)
789$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(nonplat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp $(plat_sc_neverallow_files)
Stephen Smalley37712872015-03-12 15:46:36 -0400790 @mkdir -p $(dir $@)
Dan Cashmanc234ba32017-06-06 08:15:01 -0700791 $(hide) grep -ihe '^neverallow' $(PRIVATE_SC_NEVERALLOW_FILES) > $@.tmp
Xin Liec6f3932017-03-14 16:51:13 -0700792 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES) $@.tmp
Stephen Smalley37712872015-03-12 15:46:36 -0400793
Dan Cashman9c038072016-12-22 07:15:18 -0800794built_nonplat_sc := $(LOCAL_BUILT_MODULE)
795nonplat_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400796
797##################################
798include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800799LOCAL_MODULE := plat_seapp_neverallows
William Roberts4ee71312015-06-25 11:59:30 -0700800LOCAL_MODULE_CLASS := ETC
801LOCAL_MODULE_TAGS := tests
802
803include $(BUILD_SYSTEM)/base_rules.mk
804
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800805$(LOCAL_BUILT_MODULE): $(plat_sc_neverallow_files)
William Roberts4ee71312015-06-25 11:59:30 -0700806 @mkdir -p $(dir $@)
Dan Cashmanc234ba32017-06-06 08:15:01 -0700807 - $(hide) grep -ihe '^neverallow' $< > $@
William Roberts4ee71312015-06-25 11:59:30 -0700808
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800809plat_sc_neverallow_files :=
William Roberts4ee71312015-06-25 11:59:30 -0700810
811##################################
812include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400813
Sandeep Patila86316e2016-12-27 16:08:44 -0800814LOCAL_MODULE := plat_property_contexts
Stephen Smalley124720a2012-04-04 10:11:16 -0400815LOCAL_MODULE_CLASS := ETC
816LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800817
818ifeq ($(PRODUCT_FULL_TREBLE),true)
819LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
820else
Stephen Smalley124720a2012-04-04 10:11:16 -0400821LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800822endif
Stephen Smalley124720a2012-04-04 10:11:16 -0400823
824include $(BUILD_SYSTEM)/base_rules.mk
825
Sandeep Patila86316e2016-12-27 16:08:44 -0800826plat_pcfiles := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts6aabc1c2015-07-30 11:44:26 -0700827
Sandeep Patila86316e2016-12-27 16:08:44 -0800828plat_property_contexts.tmp := $(intermediates)/plat_property_contexts.tmp
829$(plat_property_contexts.tmp): PRIVATE_PC_FILES := $(plat_pcfiles)
830$(plat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
831$(plat_property_contexts.tmp): $(plat_pcfiles)
William Roberts7f81b332015-09-29 13:52:37 -0700832 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000833 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700834$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila86316e2016-12-27 16:08:44 -0800835$(LOCAL_BUILT_MODULE): $(plat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700836 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800837 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800838 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400839
Sandeep Patila86316e2016-12-27 16:08:44 -0800840built_plat_pc := $(LOCAL_BUILT_MODULE)
841plat_pcfiles :=
842plat_property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400843
Stephen Smalley124720a2012-04-04 10:11:16 -0400844##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700845include $(CLEAR_VARS)
Sandeep Patila86316e2016-12-27 16:08:44 -0800846LOCAL_MODULE := nonplat_property_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400847LOCAL_MODULE_CLASS := ETC
Sandeep Patila86316e2016-12-27 16:08:44 -0800848LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800849
850ifeq ($(PRODUCT_FULL_TREBLE),true)
851LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
852else
Sandeep Patila86316e2016-12-27 16:08:44 -0800853LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800854endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400855
Stephen Smalleyc9361732015-03-13 09:36:57 -0400856include $(BUILD_SYSTEM)/base_rules.mk
857
Alex Klyubin55961722017-01-30 18:44:59 -0800858nonplat_pcfiles := $(call build_policy, property_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Sandeep Patil262edc32016-12-27 16:08:44 -0800859
Sandeep Patila86316e2016-12-27 16:08:44 -0800860nonplat_property_contexts.tmp := $(intermediates)/nonplat_property_contexts.tmp
861$(nonplat_property_contexts.tmp): PRIVATE_PC_FILES := $(nonplat_pcfiles)
862$(nonplat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
863$(nonplat_property_contexts.tmp): $(nonplat_pcfiles)
William Robertsdcffd2b2015-09-29 13:52:37 -0700864 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800865 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
866
867
868$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
869$(LOCAL_BUILT_MODULE): $(nonplat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
870 @mkdir -p $(dir $@)
871 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800872 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700873
Sandeep Patila86316e2016-12-27 16:08:44 -0800874built_nonplat_pc := $(LOCAL_BUILT_MODULE)
875nonplat_pcfiles :=
876nonplat_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400877
878##################################
879include $(CLEAR_VARS)
880
Alex Klyubinec78c372017-03-10 12:44:16 -0800881LOCAL_MODULE := plat_property_contexts.recovery
882LOCAL_MODULE_STEM := plat_property_contexts
883LOCAL_MODULE_CLASS := ETC
884LOCAL_MODULE_TAGS := optional
885LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
886
887include $(BUILD_SYSTEM)/base_rules.mk
888
889$(LOCAL_BUILT_MODULE): $(built_plat_pc)
890 $(hide) cp -f $< $@
891
892##################################
893include $(CLEAR_VARS)
Alex Klyubinec78c372017-03-10 12:44:16 -0800894LOCAL_MODULE := nonplat_property_contexts.recovery
895LOCAL_MODULE_STEM := nonplat_property_contexts
896LOCAL_MODULE_CLASS := ETC
897LOCAL_MODULE_TAGS := optional
898LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
899
900include $(BUILD_SYSTEM)/base_rules.mk
901
902$(LOCAL_BUILT_MODULE): $(built_nonplat_pc)
903 $(hide) cp -f $< $@
904
905##################################
906include $(CLEAR_VARS)
907
Sandeep Patila058b562016-12-27 15:10:48 -0800908LOCAL_MODULE := plat_service_contexts
Riley Spahnf90c41f2014-06-05 15:52:02 -0700909LOCAL_MODULE_CLASS := ETC
910LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800911ifeq ($(PRODUCT_FULL_TREBLE),true)
912LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
913else
Riley Spahnf90c41f2014-06-05 15:52:02 -0700914LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800915endif
Riley Spahnf90c41f2014-06-05 15:52:02 -0700916
917include $(BUILD_SYSTEM)/base_rules.mk
918
Sandeep Patila058b562016-12-27 15:10:48 -0800919plat_svcfiles := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700920
Sandeep Patila058b562016-12-27 15:10:48 -0800921plat_service_contexts.tmp := $(intermediates)/plat_service_contexts.tmp
922$(plat_service_contexts.tmp): PRIVATE_SVC_FILES := $(plat_svcfiles)
923$(plat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
924$(plat_service_contexts.tmp): $(plat_svcfiles)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700925 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700926 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700927
928$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila058b562016-12-27 15:10:48 -0800929$(LOCAL_BUILT_MODULE): $(plat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700930 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700931 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800932 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700933
Sandeep Patila058b562016-12-27 15:10:48 -0800934built_plat_svc := $(LOCAL_BUILT_MODULE)
935plat_svcfiles :=
936plat_service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700937
938##################################
rpcraigb19665c2012-07-30 09:33:03 -0400939include $(CLEAR_VARS)
940
Sandeep Patila058b562016-12-27 15:10:48 -0800941LOCAL_MODULE := nonplat_service_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400942LOCAL_MODULE_CLASS := ETC
Sandeep Patila058b562016-12-27 15:10:48 -0800943LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800944ifeq ($(PRODUCT_FULL_TREBLE),true)
945LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
946else
Sandeep Patila058b562016-12-27 15:10:48 -0800947LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800948endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400949
950include $(BUILD_SYSTEM)/base_rules.mk
951
Alex Klyubin55961722017-01-30 18:44:59 -0800952nonplat_svcfiles := $(call build_policy, service_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400953
Sandeep Patila058b562016-12-27 15:10:48 -0800954nonplat_service_contexts.tmp := $(intermediates)/nonplat_service_contexts.tmp
955$(nonplat_service_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_svcfiles)
956$(nonplat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
957$(nonplat_service_contexts.tmp): $(nonplat_svcfiles)
958 @mkdir -p $(dir $@)
959 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
960
961$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
962$(LOCAL_BUILT_MODULE): $(nonplat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700963 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700964 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800965 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700966
Sandeep Patila058b562016-12-27 15:10:48 -0800967built_nonplat_svc := $(LOCAL_BUILT_MODULE)
968nonplat_svcfiles :=
969nonplat_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400970
971##################################
972include $(CLEAR_VARS)
973
Martijn Coenen3ea47b92017-04-07 16:14:43 -0700974LOCAL_MODULE := plat_hwservice_contexts
975LOCAL_MODULE_CLASS := ETC
976LOCAL_MODULE_TAGS := optional
977ifeq ($(PRODUCT_FULL_TREBLE),true)
978LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
979else
980LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
981endif
982
983include $(BUILD_SYSTEM)/base_rules.mk
984
985plat_hwsvcfiles := $(call build_policy, hwservice_contexts, $(PLAT_PRIVATE_POLICY))
986
987plat_hwservice_contexts.tmp := $(intermediates)/plat_hwservice_contexts.tmp
988$(plat_hwservice_contexts.tmp): PRIVATE_SVC_FILES := $(plat_hwsvcfiles)
989$(plat_hwservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
990$(plat_hwservice_contexts.tmp): $(plat_hwsvcfiles)
991 @mkdir -p $(dir $@)
992 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
993
994$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
995$(LOCAL_BUILT_MODULE): $(plat_hwservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
996 @mkdir -p $(dir $@)
997 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
998 $(HOST_OUT_EXECUTABLES)/checkfc -e -l $(PRIVATE_SEPOLICY) $@
999
1000plat_hwsvcfiles :=
1001plat_hwservice_contexts.tmp :=
1002
1003##################################
1004include $(CLEAR_VARS)
1005
1006LOCAL_MODULE := nonplat_hwservice_contexts
1007LOCAL_MODULE_CLASS := ETC
1008LOCAL_MODULE_TAGS := optional
1009ifeq ($(PRODUCT_FULL_TREBLE),true)
1010LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
1011else
1012LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1013endif
1014
1015include $(BUILD_SYSTEM)/base_rules.mk
1016
1017nonplat_hwsvcfiles := $(call build_policy, hwservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1018
1019nonplat_hwservice_contexts.tmp := $(intermediates)/nonplat_hwservice_contexts.tmp
1020$(nonplat_hwservice_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_hwsvcfiles)
1021$(nonplat_hwservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1022$(nonplat_hwservice_contexts.tmp): $(nonplat_hwsvcfiles)
1023 @mkdir -p $(dir $@)
1024 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1025
1026$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1027$(LOCAL_BUILT_MODULE): $(nonplat_hwservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1028 @mkdir -p $(dir $@)
1029 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
1030 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -l $(PRIVATE_SEPOLICY) $@
1031
1032nonplat_hwsvcfiles :=
1033nonplat_hwservice_contexts.tmp :=
1034
1035##################################
1036include $(CLEAR_VARS)
1037
Martijn Coenen6676c232017-03-31 17:29:53 -07001038LOCAL_MODULE := vndservice_contexts
1039LOCAL_MODULE_CLASS := ETC
1040LOCAL_MODULE_TAGS := optional
1041ifeq ($(PRODUCT_FULL_TREBLE),true)
1042LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
1043else
1044LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1045endif
1046
1047include $(BUILD_SYSTEM)/base_rules.mk
1048
1049vnd_svcfiles := $(call build_policy, vndservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1050
1051vndservice_contexts.tmp := $(intermediates)/vndservice_contexts.tmp
1052$(vndservice_contexts.tmp): PRIVATE_SVC_FILES := $(vnd_svcfiles)
1053$(vndservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1054$(vndservice_contexts.tmp): $(vnd_svcfiles)
1055 @mkdir -p $(dir $@)
1056 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1057
1058$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1059$(LOCAL_BUILT_MODULE): $(vndservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1060 @mkdir -p $(dir $@)
1061 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
Martijn Coenenee976622017-04-07 10:08:55 -07001062 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -v $(PRIVATE_SEPOLICY) $@
Martijn Coenen6676c232017-03-31 17:29:53 -07001063
1064vnd_svcfiles :=
1065vndservice_contexts.tmp :=
1066##################################
1067include $(CLEAR_VARS)
1068
dcashman90b3b942016-12-14 13:47:55 -08001069LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -04001070LOCAL_MODULE_CLASS := ETC
1071LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001072LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
rpcraigb19665c2012-07-30 09:33:03 -04001073
William Roberts2c8a55d2012-11-30 14:59:09 -08001074include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -04001075
Geremy Condracd4104e2013-03-26 18:19:12 +00001076# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -08001077plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
1078$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1079$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +00001080 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -07001081 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +00001082
dcashman90b3b942016-12-14 13:47:55 -08001083all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -04001084
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001085# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -08001086all_plat_keys := platform media shared testkey
1087all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001088
dcashman90b3b942016-12-14 13:47:55 -08001089$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
1090$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1091$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +00001092 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -07001093 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -07001094 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +00001095
William Roberts6aabc1c2015-07-30 11:44:26 -07001096all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -08001097all_plat_keys :=
1098plat_mac_perms_keys.tmp :=
1099
1100##################################
1101include $(CLEAR_VARS)
1102
1103LOCAL_MODULE := nonplat_mac_permissions.xml
1104LOCAL_MODULE_CLASS := ETC
1105LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001106LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman90b3b942016-12-14 13:47:55 -08001107
1108include $(BUILD_SYSTEM)/base_rules.mk
1109
1110# Build keys.conf
1111nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
1112$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Alex Klyubin55961722017-01-30 18:44:59 -08001113$(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 -08001114 @mkdir -p $(dir $@)
1115 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
1116
Alex Klyubin55961722017-01-30 18:44:59 -08001117all_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 -08001118
1119$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
1120$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1121$(all_nonplat_mac_perms_files)
1122 @mkdir -p $(dir $@)
1123 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
1124
1125nonplat_mac_perms_keys.tmp :=
1126all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -07001127
Jeff Vander Stoep11d096f2017-06-07 09:59:26 -07001128#################################
1129include $(CLEAR_VARS)
1130LOCAL_MODULE := sepolicy_tests
1131LOCAL_MODULE_CLASS := ETC
1132LOCAL_MODULE_TAGS := tests
1133
1134include $(BUILD_SYSTEM)/base_rules.mk
1135
1136sepolicy_tests := $(intermediates)/sepolicy_tests
1137$(sepolicy_tests): PRIVATE_PLAT_FC := $(built_plat_fc)
1138$(sepolicy_tests): PRIVATE_NONPLAT_FC := $(built_nonplat_fc)
1139$(sepolicy_tests): PRIVATE_SEPOLICY := $(built_sepolicy)
1140$(sepolicy_tests): $(HOST_OUT_EXECUTABLES)/sepolicy_tests.py \
1141$(built_plat_fc) $(built_nonplat_fc) $(built_sepolicy)
1142 @mkdir -p $(dir $@)
1143 $(hide) python $(HOST_OUT_EXECUTABLES)/sepolicy_tests.py -l $(HOST_OUT)/lib64 -f $(PRIVATE_PLAT_FC) -f $(PRIVATE_NONPLAT_FC) -p $(PRIVATE_SEPOLICY)
1144 $(hide) touch $@
1145
rpcraigb19665c2012-07-30 09:33:03 -04001146##################################
Jeff Vander Stoepe1ddc6d2017-05-31 15:36:07 -07001147ifeq ($(PRODUCT_FULL_TREBLE),true)
1148include $(CLEAR_VARS)
1149# For Treble builds run tests verifying that processes are properly labeled and
Dan Cashmanb04df6e2017-06-13 14:12:31 -07001150# permissions granted do not violate the treble model. Also ensure that treble
1151# compatibility guarantees are upheld between SELinux version bumps.
Jeff Vander Stoepe1ddc6d2017-05-31 15:36:07 -07001152LOCAL_MODULE := treble_sepolicy_tests
1153LOCAL_MODULE_CLASS := ETC
1154LOCAL_MODULE_TAGS := tests
1155
1156include $(BUILD_SYSTEM)/base_rules.mk
1157
Dan Cashmanb04df6e2017-06-13 14:12:31 -07001158# 26.0_compat - the current plat_sepolicy.cil built
1159# with the compatibility file targeting the 26.0
1160# SELinux release.
116126.0_compat := $(intermediates)/26.0_compat
116226.0_mapping_cil := $(LOCAL_PATH)/prebuilts/api/26.0/26.0.cil
116326.0_nonplat := $(LOCAL_PATH)/prebuilts/api/26.0/nonplat_sepolicy.cil
1164$(26.0_compat): PRIVATE_CIL_FILES := \
1165$(built_plat_cil) $(26.0_mapping_cil) $(26.0_nonplat)
1166$(26.0_compat): $(HOST_OUT_EXECUTABLES)/secilc \
1167$(built_plat_cil) $(26.0_mapping_cil) $(26.0_nonplat)
1168 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -N -c $(POLICYVERS) \
1169 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
1170
Jeff Vander Stoepe1ddc6d2017-05-31 15:36:07 -07001171treble_sepolicy_tests := $(intermediates)/treble_sepolicy_tests
1172$(treble_sepolicy_tests): PRIVATE_PLAT_FC := $(built_plat_fc)
1173$(treble_sepolicy_tests): PRIVATE_NONPLAT_FC := $(built_nonplat_fc)
1174$(treble_sepolicy_tests): PRIVATE_SEPOLICY := $(built_sepolicy)
1175$(treble_sepolicy_tests): $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests.py \
Dan Cashmanb04df6e2017-06-13 14:12:31 -07001176$(built_plat_fc) $(built_nonplat_fc) $(built_sepolicy) $(26.0_compat)
Jeff Vander Stoepe1ddc6d2017-05-31 15:36:07 -07001177 @mkdir -p $(dir $@)
1178 $(hide) python $(HOST_OUT_EXECUTABLES)/treble_sepolicy_tests.py -l $(HOST_OUT)/lib64 -f $(PRIVATE_PLAT_FC) -f $(PRIVATE_NONPLAT_FC) -p $(PRIVATE_SEPOLICY)
1179 $(hide) touch $@
Dan Cashmanb04df6e2017-06-13 14:12:31 -07001180
118126.0_compat :=
Jeff Vander Stoepe1ddc6d2017-05-31 15:36:07 -07001182endif # ($(PRODUCT_FULL_TREBLE),true)
1183#################################
rpcraig47cd3962012-10-17 21:09:52 -04001184
Dan Cashman1c040272016-12-15 15:28:44 -08001185add_nl :=
William Roberts49693f12016-01-04 12:20:57 -08001186build_device_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001187build_policy :=
dcashmand225b692016-12-12 09:29:04 -08001188built_plat_fc :=
1189built_nonplat_fc :=
Richard Hainesc8801fe2015-12-11 10:39:19 +00001190built_nl :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001191built_plat_cil :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001192built_mapping_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001193built_plat_pc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001194built_nonplat_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001195built_nonplat_pc :=
Dan Cashman9c038072016-12-22 07:15:18 -08001196built_nonplat_sc :=
1197built_plat_sc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001198built_precompiled_sepolicy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001199built_sepolicy :=
Sandeep Patila058b562016-12-27 15:10:48 -08001200built_plat_svc :=
1201built_nonplat_svc :=
Jeff Vander Stoepb8787692017-04-21 15:57:07 -07001202mapping_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001203my_target_arch :=
dcashman1faa6442016-11-28 07:20:28 -08001204plat_pub_policy.cil :=
1205reqd_policy_mask.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -08001206sepolicy_build_files :=
Alex Klyubin7cda44f2017-03-21 14:28:53 -07001207sepolicy_build_cil_workaround_files :=
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001208with_asan :=
Alice Chucdfb06f2012-11-01 11:33:04 -07001209
1210include $(call all-makefiles-under,$(LOCAL_PATH))