blob: 0cd642caf25641e3c585b15ac9ad8857ad416851 [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001LOCAL_PATH:= $(call my-dir)
William Robertsf0e0a942012-08-27 15:41:15 -07002
Dan Cashman6f14f6b2017-04-07 16:36:23 -07003# PLATFORM_SEPOLICY_VERSION is a number of the form "NN.m" with "NN" mapping to
4# PLATFORM_SDK_VERSION and "m" as a minor number which allows for SELinux
5# changes independent of PLATFORM_SDK_VERSION. This value will be set to
6# 10000.0 to represent tip-of-tree development that is inherently unstable and
7# thus designed not to work with any shipping vendor policy. This is similar in
8# spirit to how DEFAULT_APP_TARGET_SDK is set.
9# The minor version ('m' component) must be updated every time a platform release
10# is made which breaks compatibility with the previous platform sepolicy version,
11# not just on every increase in PLATFORM_SDK_VERSION. The minor version should
12# be reset to 0 on every bump of the PLATFORM_SDK_VERSION.
13sepolicy_major_vers := 25
14sepolicy_minor_vers := 0
15
16ifneq ($(sepolicy_major_vers), $(PLATFORM_SDK_VERSION))
17$(error sepolicy_major_version does not match PLATFORM_SDK_VERSION, please update.)
18endif
19ifneq (REL,$(PLATFORM_VERSION_CODENAME))
20 sepolicy_major_vers := 10000
21 sepolicy_minor_vers := 0
22endif
23PLATFORM_SEPOLICY_VERSION := $(join $(addsuffix .,$(sepolicy_major_vers)), $(sepolicy_minor_vers))
24sepolicy_major_vers :=
25sepolicy_minor_vers :=
26
Stephen Smalley2dd4e512012-01-04 12:33:27 -050027include $(CLEAR_VARS)
Stephen Smalley2dd4e512012-01-04 12:33:27 -050028# SELinux policy version.
Stephen Smalleyb4f17062015-03-13 10:03:52 -040029# Must be <= /sys/fs/selinux/policyvers reported by the Android kernel.
Stephen Smalley2dd4e512012-01-04 12:33:27 -050030# Must be within the compatibility range reported by checkpolicy -V.
Jeff Vander Stoep3a0ce492015-12-07 08:30:43 -080031POLICYVERS ?= 30
Stephen Smalley2dd4e512012-01-04 12:33:27 -050032
33MLS_SENS=1
34MLS_CATS=1024
35
Stephen Smalleyb4f17062015-03-13 10:03:52 -040036ifdef BOARD_SEPOLICY_REPLACE
37$(error BOARD_SEPOLICY_REPLACE is no longer supported; please remove from your BoardConfig.mk or other .mk file.)
38endif
39
40ifdef BOARD_SEPOLICY_IGNORE
41$(error BOARD_SEPOLICY_IGNORE is no longer supported; please remove from your BoardConfig.mk or other .mk file.)
42endif
Stephen Smalley5b340be2012-03-06 11:12:41 -050043
Stephen Smalley8e0ca882015-04-01 10:14:56 -040044ifdef BOARD_SEPOLICY_UNION
45$(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.)
46endif
Robert Craig6b0ff472014-01-29 13:10:58 -050047
William Robertsd2185582015-07-16 11:28:02 -070048ifdef BOARD_SEPOLICY_M4DEFS
49LOCAL_ADDITIONAL_M4DEFS := $(addprefix -D, $(BOARD_SEPOLICY_M4DEFS))
50endif
51
dcashmancc39f632016-07-22 13:13:11 -070052# sepolicy is now divided into multiple portions:
53# public - policy exported on which non-platform policy developers may write
54# additional policy. types and attributes are versioned and included in
55# delivered non-platform policy, which is to be combined with platform policy.
56# private - platform-only policy required for platform functionality but which
57# is not exported to vendor policy developers and as such may not be assumed
58# to exist.
Alex Klyubin55961722017-01-30 18:44:59 -080059# vendor - vendor-only policy required for vendor functionality. This policy can
60# reference the public policy but cannot reference the private policy. This
61# policy is for components which are produced from the core/non-vendor tree and
62# placed into a vendor partition.
dcashman07791552016-12-07 11:27:47 -080063# mapping - This contains policy statements which map the attributes
dcashmancc39f632016-07-22 13:13:11 -070064# exposed in the public policy of previous versions to the concrete types used
65# in this policy to ensure that policy targeting attributes from public
66# policy from an older platform version continues to work.
67
dcashman2e00e632016-10-12 14:58:09 -070068# build process for device:
dcashmancc39f632016-07-22 13:13:11 -070069# 1) convert policies to CIL:
70# - private + public platform policy to CIL
71# - mapping file to CIL (should already be in CIL form)
72# - non-platform public policy to CIL
73# - non-platform public + private policy to CIL
74# 2) attributize policy
dcashmancc39f632016-07-22 13:13:11 -070075# - run script which takes non-platform public and non-platform combined
76# private + public policy and produces attributized and versioned
77# non-platform policy
78# 3) combine policy files
79# - combine mapping, platform and non-platform policy.
80# - compile output binary policy file
81
82PLAT_PUBLIC_POLICY := $(LOCAL_PATH)/public
83PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private
Alex Klyubin55961722017-01-30 18:44:59 -080084PLAT_VENDOR_POLICY := $(LOCAL_PATH)/vendor
dcashman2e00e632016-10-12 14:58:09 -070085REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask
86
87# TODO: move to README when doing the README update and finalizing versioning.
Sandeep Patil42f95982017-04-07 14:18:48 -070088# BOARD_SEPOLICY_VERS must take the format "NN.m" and contain the sepolicy
89# version identifier corresponding to the sepolicy on which the non-platform
90# policy is to be based. If unspecified, this will build against the current
91# public platform policy in tree
dcashman2e00e632016-10-12 14:58:09 -070092ifndef BOARD_SEPOLICY_VERS
93$(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version)
Sandeep Patil42f95982017-04-07 14:18:48 -070094# The default platform policy version.
Dan Cashman6f14f6b2017-04-07 16:36:23 -070095BOARD_SEPOLICY_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman2e00e632016-10-12 14:58:09 -070096endif
dcashmancc39f632016-07-22 13:13:11 -070097
98###########################################################
99# Compute policy files to be used in policy build.
100# $(1): files to include
101# $(2): directories in which to find files
102###########################################################
103
104define build_policy
105$(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))
106endef
William Roberts29d14682016-01-04 12:20:57 -0800107
William Roberts49693f12016-01-04 12:20:57 -0800108# Builds paths for all policy files found in BOARD_SEPOLICY_DIRS.
109# $(1): the set of policy name paths to build
Alex Klyubin55961722017-01-30 18:44:59 -0800110build_device_policy = $(call build_policy, $(1), $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts49693f12016-01-04 12:20:57 -0800111
Richard Hainesc8801fe2015-12-11 10:39:19 +0000112# Add a file containing only a newline in-between each policy configuration
113# 'contexts' file. This will allow OEM policy configuration files without a
114# final newline (0x0A) to be built correctly by the m4(1) macro processor.
115# $(1): the set of contexts file names.
116# $(2): the file containing only 0x0A.
117add_nl = $(foreach entry, $(1), $(subst $(entry), $(entry) $(2), $(entry)))
118
dcashman704741a2014-07-25 19:11:52 -0700119sepolicy_build_files := security_classes \
120 initial_sids \
121 access_vectors \
122 global_macros \
Nick Kralevicha17a2662014-11-05 15:30:41 -0800123 neverallow_macros \
dcashman704741a2014-07-25 19:11:52 -0700124 mls_macros \
dcashman2e00e632016-10-12 14:58:09 -0700125 mls_decl \
dcashman704741a2014-07-25 19:11:52 -0700126 mls \
127 policy_capabilities \
128 te_macros \
129 attributes \
Jeff Vander Stoepcbaa2b72015-12-22 10:39:34 -0800130 ioctl_defines \
Jeff Vander Stoepde9b5302015-06-05 15:28:55 -0700131 ioctl_macros \
dcashman704741a2014-07-25 19:11:52 -0700132 *.te \
dcashman2e00e632016-10-12 14:58:09 -0700133 roles_decl \
dcashman704741a2014-07-25 19:11:52 -0700134 roles \
135 users \
136 initial_sid_contexts \
137 fs_use \
138 genfs_contexts \
139 port_contexts
140
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700141# CIL files which contain workarounds for current limitation of human-readable
142# module policy language. These files are appended to the CIL files produced
143# from module language files.
144sepolicy_build_cil_workaround_files := technical_debt.cil
145
Dan Cashman1c040272016-12-15 15:28:44 -0800146my_target_arch := $(TARGET_ARCH)
147ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
148 my_target_arch := mips
149endif
150
Jeff Vander Stoepd2053bd2017-03-15 13:37:35 -0700151intermediates := $(TARGET_OUT_INTERMEDIATES)/ETC/sepolicy_intermediates
152
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700153with_asan := false
154ifneq (,$(filter address,$(SANITIZE_TARGET)))
155 with_asan := true
156endif
157
Dan Cashman4f9a6482017-04-10 12:27:18 -0700158include $(CLEAR_VARS)
159LOCAL_MODULE := selinux_policy
160LOCAL_MODULE_TAGS := optional
161# Include SELinux policy. We do this here because different modules
162# need to be included based on the value of PRODUCT_FULL_TREBLE. This
163# type of conditional inclusion cannot be done in top-level files such
164# as build/target/product/embedded.mk.
165# This conditional inclusion closely mimics the conditional logic
166# inside init/init.cpp for loading SELinux policy from files.
167ifeq ($(PRODUCT_FULL_TREBLE),true)
168
169platform_mapping_file := $(BOARD_SEPOLICY_VERS).cil
170
171# Use split SELinux policy
172LOCAL_REQUIRED_MODULES += \
173 $(platform_mapping_file) \
174 nonplat_sepolicy.cil \
175 plat_sepolicy.cil \
176 plat_and_mapping_sepolicy.cil.sha256 \
177 secilc \
178 nonplat_file_contexts \
179 plat_file_contexts \
180 plat_sepolicy_vers.txt
181
182# Include precompiled policy, unless told otherwise
183ifneq ($(PRODUCT_PRECOMPILED_SEPOLICY),false)
184LOCAL_REQUIRED_MODULES += precompiled_sepolicy precompiled_sepolicy.plat_and_mapping.sha256
185endif
186
187else
188# Use monolithic SELinux policy
189LOCAL_REQUIRED_MODULES += sepolicy \
190 file_contexts.bin
191endif
192include $(BUILD_PHONY_PACKAGE)
193
Ying Wang02fb5f32012-01-17 17:51:09 -0800194##################################
dcashman2e00e632016-10-12 14:58:09 -0700195# reqd_policy_mask - a policy.conf file which contains only the bare minimum
196# policy necessary to use checkpolicy. This bare-minimum policy needs to be
197# present in all policy.conf files, but should not necessarily be exported as
198# part of the public policy. The rules generated by reqd_policy_mask will allow
199# the compilation of public policy and subsequent removal of CIL policy that
200# should not be exported.
201
202reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
203$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
204$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800205$(reqd_policy_mask.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700206$(reqd_policy_mask.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700207$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
208$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
209 @mkdir -p $(dir $@)
210 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
211 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
212 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800213 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800214 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700215 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700216 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashman2e00e632016-10-12 14:58:09 -0700217 -s $^ > $@
218
219reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
220$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
221 @mkdir -p $(dir $@)
222 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
223
dcashman1faa6442016-11-28 07:20:28 -0800224reqd_policy_mask.conf :=
225
226##################################
dcashman2e00e632016-10-12 14:58:09 -0700227# plat_pub_policy - policy that will be exported to be a part of non-platform
228# policy corresponding to this platform version. This is a limited subset of
229# policy that would not compile in checkpolicy on its own. To get around this
230# limitation, add only the required files from private policy, which will
231# generate CIL policy that will then be filtered out by the reqd_policy_mask.
232plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
233$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
234$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800235$(plat_pub_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700236$(plat_pub_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700237$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
238$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700239$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY))
dcashman2e00e632016-10-12 14:58:09 -0700240 @mkdir -p $(dir $@)
241 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
242 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
243 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800244 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800245 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700246 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700247 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashman2e00e632016-10-12 14:58:09 -0700248 -s $^ > $@
249
250plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800251$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
252$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
253$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700254 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800255 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
256 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700257
dcashman1faa6442016-11-28 07:20:28 -0800258plat_pub_policy.conf :=
Dan Cashman1c040272016-12-15 15:28:44 -0800259
dcashman1faa6442016-11-28 07:20:28 -0800260##################################
261include $(CLEAR_VARS)
262
263LOCAL_MODULE := sectxfile_nl
264LOCAL_MODULE_CLASS := ETC
265LOCAL_MODULE_TAGS := optional
266
267# Create a file containing newline only to add between context config files
268include $(BUILD_SYSTEM)/base_rules.mk
269$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700270 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800271 $(hide) echo > $@
272
273built_nl := $(LOCAL_BUILT_MODULE)
274
275#################################
276include $(CLEAR_VARS)
277
278LOCAL_MODULE := plat_sepolicy.cil
279LOCAL_MODULE_CLASS := ETC
280LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800281LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800282
283include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700284
285# plat_policy.conf - A combination of the private and public platform policy
286# which will ship with the device. The platform will always reflect the most
287# recent platform version and is not currently being attributized.
288plat_policy.conf := $(intermediates)/plat_policy.conf
289$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
290$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800291$(plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700292$(plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700293$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
294$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700295$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
296 @mkdir -p $(dir $@)
297 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
298 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
299 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500300 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800301 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700302 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700303 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashmancc39f632016-07-22 13:13:11 -0700304 -s $^ > $@
305 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
306
dcashman1faa6442016-11-28 07:20:28 -0800307plat_policy_nvr := $(intermediates)/plat_policy_nvr.cil
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700308$(plat_policy_nvr): PRIVATE_ADDITIONAL_CIL_FILES := \
309 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
310$(plat_policy_nvr): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
311 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
dcashman2e00e632016-10-12 14:58:09 -0700312 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800313 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700314 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
dcashmancc39f632016-07-22 13:13:11 -0700315
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800316$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(plat_policy_nvr)
317$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(plat_policy_nvr)
dcashman1faa6442016-11-28 07:20:28 -0800318 @mkdir -p $(dir $@)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800319 # Strip out neverallow statements. They aren't needed on-device and their presence
320 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
321 # sailfish-eng).
322 grep -v '^(neverallow' $(PRIVATE_CIL_FILES) > $@
323 # Confirm that the resulting policy compiles
324 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) $@ -o /dev/null -f /dev/null
dcashman1faa6442016-11-28 07:20:28 -0800325
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800326built_plat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800327plat_policy.conf :=
328
329#################################
330include $(CLEAR_VARS)
331
Dan Cashman4f9a6482017-04-10 12:27:18 -0700332LOCAL_MODULE := plat_sepolicy_vers.txt
dcashman1faa6442016-11-28 07:20:28 -0800333LOCAL_MODULE_CLASS := ETC
334LOCAL_MODULE_TAGS := optional
Dan Cashman4f9a6482017-04-10 12:27:18 -0700335LOCAL_PROPRIETARY_MODULE := true
336LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
337
338include $(BUILD_SYSTEM)/base_rules.mk
339
340$(LOCAL_BUILT_MODULE) : PRIVATE_PLAT_SEPOL_VERS := $(BOARD_SEPOLICY_VERS)
341$(LOCAL_BUILT_MODULE) :
342 mkdir -p $(dir $@)
343 echo $(PRIVATE_PLAT_SEPOL_VERS) > $@
344
345#################################
Dan Cashman552fb532017-04-12 14:04:17 -0700346ifeq ($(PRODUCT_FULL_TREBLE),true)
Dan Cashman4f9a6482017-04-10 12:27:18 -0700347include $(CLEAR_VARS)
348
349LOCAL_MODULE := $(platform_mapping_file)
350LOCAL_MODULE_CLASS := ETC
351LOCAL_MODULE_TAGS := optional
352LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux/mapping
dcashman1faa6442016-11-28 07:20:28 -0800353
354include $(BUILD_SYSTEM)/base_rules.mk
355
356# 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 -0700358current_mapping.cil := $(intermediates)/mapping/$(PLATFORM_SEPOLICY_VERSION).cil
359$(current_mapping.cil) : PRIVATE_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman1faa6442016-11-28 07:20:28 -0800360$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
361 @mkdir -p $(dir $@)
362 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
363
Sandeep Patil42f95982017-04-07 14:18:48 -0700364
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700365ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
dcashman1faa6442016-11-28 07:20:28 -0800366mapping_policy_nvr := $(current_mapping.cil)
367else
368mapping_policy_nvr := $(addsuffix /$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)/mapping)
369endif
370
371$(LOCAL_BUILT_MODULE): $(mapping_policy_nvr)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800372 # Strip out neverallow statements. They aren't needed on-device and their presence
373 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
374 # sailfish-eng).
375 grep -v '^(neverallow' $< > $@
dcashman1faa6442016-11-28 07:20:28 -0800376
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800377built_mapping_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800378current_mapping.cil :=
379
Dan Cashman552fb532017-04-12 14:04:17 -0700380endif # ifeq ($(PRODUCT_FULL_TREBLE),true)
dcashman1faa6442016-11-28 07:20:28 -0800381#################################
382include $(CLEAR_VARS)
383
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700384LOCAL_MODULE := plat_and_mapping_sepolicy.cil.sha256
385LOCAL_MODULE_CLASS := ETC
386LOCAL_MODULE_TAGS := optional
387LOCAL_MODULE_PATH = $(TARGET_OUT)/etc/selinux
388
389include $(BUILD_SYSTEM)/base_rules.mk
390
391$(LOCAL_BUILT_MODULE): $(built_plat_cil) $(built_mapping_cil)
392 cat $^ | sha256sum | cut -d' ' -f1 > $@
393
394#################################
395include $(CLEAR_VARS)
396
dcashman1faa6442016-11-28 07:20:28 -0800397LOCAL_MODULE := nonplat_sepolicy.cil
398LOCAL_MODULE_CLASS := ETC
399LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800400LOCAL_PROPRIETARY_MODULE := true
401LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800402
403include $(BUILD_SYSTEM)/base_rules.mk
404
Alex Klyubin55961722017-01-30 18:44:59 -0800405# nonplat_policy.conf - A combination of the non-platform private, vendor and
406# the exported platform policy associated with the version the non-platform
407# policy targets. This needs attributization and to be combined with the
dcashman2e00e632016-10-12 14:58:09 -0700408# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
409# of the reqd_policy_mask files from private policy in order to use checkpolicy.
410nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
411$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
412$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800413$(nonplat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700414$(nonplat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700415$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
416$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700417$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Ying Wang02fb5f32012-01-17 17:51:09 -0800418 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700419 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
420 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800421 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500422 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800423 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700424 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700425 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800426 -s $^ > $@
Robert Craig65d4f442013-03-27 06:30:25 -0400427 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500428
dcashman1faa6442016-11-28 07:20:28 -0800429nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
430$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
431$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
432$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
433$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800434 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800435 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
436 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700437
dcashman1faa6442016-11-28 07:20:28 -0800438nonplat_policy_nvr := $(intermediates)/nonplat_policy_nvr.cil
439$(nonplat_policy_nvr) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
440$(nonplat_policy_nvr) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
441$(nonplat_policy_nvr) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
dcashman2e00e632016-10-12 14:58:09 -0700442$(HOST_OUT_EXECUTABLES)/version_policy
443 @mkdir -p $(dir $@)
444 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
445
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800446$(LOCAL_BUILT_MODULE): PRIVATE_NONPLAT_CIL_FILES := $(nonplat_policy_nvr)
447$(LOCAL_BUILT_MODULE): PRIVATE_DEP_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
448$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(nonplat_policy_nvr) $(built_plat_cil) \
449$(built_mapping_cil)
dcashman2e00e632016-10-12 14:58:09 -0700450 @mkdir -p $(dir $@)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800451 # Strip out neverallow statements. They aren't needed on-device and their presence
452 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
453 # sailfish-eng).
454 grep -v '^(neverallow' $(PRIVATE_NONPLAT_CIL_FILES) > $@
455 # Confirm that the resulting policy compiles combined with platform and mapping policies
456 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) \
457 $(PRIVATE_DEP_CIL_FILES) $@ -o /dev/null -f /dev/null
dcashman2e00e632016-10-12 14:58:09 -0700458
Alex Klyubin193dccd2017-03-07 14:05:57 -0800459built_nonplat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800460nonplat_policy.conf :=
461nonplat_policy_raw :=
462
463#################################
464include $(CLEAR_VARS)
Alex Klyubin193dccd2017-03-07 14:05:57 -0800465
466LOCAL_MODULE := precompiled_sepolicy
467LOCAL_MODULE_CLASS := ETC
468LOCAL_MODULE_TAGS := optional
469LOCAL_PROPRIETARY_MODULE := true
470LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
471
472include $(BUILD_SYSTEM)/base_rules.mk
473
474$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := \
475$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
476$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc \
477$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
478 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) \
479 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
480
481built_precompiled_sepolicy := $(LOCAL_BUILT_MODULE)
482
483#################################
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700484# SHA-256 digest of the plat_sepolicy.cil and mapping_sepolicy.cil files against
485# which precompiled_policy was built.
Alex Klyubin193dccd2017-03-07 14:05:57 -0800486#################################
487include $(CLEAR_VARS)
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700488LOCAL_MODULE := precompiled_sepolicy.plat_and_mapping.sha256
Alex Klyubin193dccd2017-03-07 14:05:57 -0800489LOCAL_MODULE_CLASS := ETC
490LOCAL_MODULE_TAGS := optional
491LOCAL_PROPRIETARY_MODULE := true
492LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
493
494include $(BUILD_SYSTEM)/base_rules.mk
495
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700496$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
497$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_plat_cil) $(built_mapping_cil)
498 cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@
Alex Klyubin193dccd2017-03-07 14:05:57 -0800499
500#################################
501include $(CLEAR_VARS)
Dan Cashman1c040272016-12-15 15:28:44 -0800502# build this target so that we can still perform neverallow checks
dcashman1faa6442016-11-28 07:20:28 -0800503
504LOCAL_MODULE := sepolicy
505LOCAL_MODULE_CLASS := ETC
506LOCAL_MODULE_TAGS := optional
Daniel Cashman65d01342016-12-17 00:53:26 +0000507LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman2e00e632016-10-12 14:58:09 -0700508
dcashman1faa6442016-11-28 07:20:28 -0800509include $(BUILD_SYSTEM)/base_rules.mk
510
dcashman2e00e632016-10-12 14:58:09 -0700511all_cil_files := \
dcashman1faa6442016-11-28 07:20:28 -0800512 $(plat_policy_nvr) \
513 $(mapping_policy_nvr) \
514 $(nonplat_policy_nvr) \
dcashman2e00e632016-10-12 14:58:09 -0700515
516$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
517$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
518 @mkdir -p $(dir $@)
William Roberts5d0c2e42017-03-23 11:26:29 -0700519 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp -f /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800520 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
521 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
522 echo "==========" 1>&2; \
523 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
524 echo "List of invalid domains:" 1>&2; \
525 cat $@.permissivedomains 1>&2; \
526 exit 1; \
527 fi
528 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800529
Ying Wangd8b122c2012-10-25 19:01:31 -0700530built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700531all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400532
Alex Klyubin84aa7422017-03-10 09:36:07 -0800533#################################
534include $(CLEAR_VARS)
535
536# keep concrete sepolicy for neverallow checks
537
538LOCAL_MODULE := sepolicy.recovery
Alex Klyubinec78c372017-03-10 12:44:16 -0800539LOCAL_MODULE_STEM := sepolicy
Alex Klyubin84aa7422017-03-10 09:36:07 -0800540LOCAL_MODULE_CLASS := ETC
541LOCAL_MODULE_TAGS := optional
Alex Klyubinec78c372017-03-10 12:44:16 -0800542LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
Alex Klyubin84aa7422017-03-10 09:36:07 -0800543
544include $(BUILD_SYSTEM)/base_rules.mk
545
Dan Cashmanc8d45352017-04-11 07:38:48 -0700546sepolicy.recovery.conf := $(intermediates)/sepolicy.recovery.conf
547$(sepolicy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
548$(sepolicy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
549$(sepolicy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
550$(sepolicy.recovery.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
551$(sepolicy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
552$(sepolicy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
553 $(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) \
554 $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashman1c040272016-12-15 15:28:44 -0800555 @mkdir -p $(dir $@)
556 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
557 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
558 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800559 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800560 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700561 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Dan Cashman1c040272016-12-15 15:28:44 -0800562 -D target_recovery=true \
563 -s $^ > $@
564 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
565
Dan Cashmanc8d45352017-04-11 07:38:48 -0700566$(LOCAL_BUILT_MODULE): $(sepolicy.recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
567 $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Dan Cashman1c040272016-12-15 15:28:44 -0800568 @mkdir -p $(dir $@)
Dan Cashmanc8d45352017-04-11 07:38:48 -0700569 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@.tmp $<
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800570 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
571 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
572 echo "==========" 1>&2; \
573 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
574 echo "List of invalid domains:" 1>&2; \
575 cat $@.permissivedomains 1>&2; \
576 exit 1; \
577 fi
578 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400579
Dan Cashmanc8d45352017-04-11 07:38:48 -0700580sepolicy.recovery.conf :=
Stephen Smalleye60723a2014-05-29 16:40:15 -0400581
dcashman704741a2014-07-25 19:11:52 -0700582##################################
Alex Klyubin446279a2017-04-06 14:45:50 -0700583# SELinux policy embedded into CTS.
584# CTS checks neverallow rules of this policy against the policy of the device under test.
585##################################
dcashman704741a2014-07-25 19:11:52 -0700586include $(CLEAR_VARS)
587
588LOCAL_MODULE := general_sepolicy.conf
589LOCAL_MODULE_CLASS := ETC
590LOCAL_MODULE_TAGS := tests
591
592include $(BUILD_SYSTEM)/base_rules.mk
593
dcashman704741a2014-07-25 19:11:52 -0700594$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
595$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800596$(LOCAL_BUILT_MODULE): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashmancc39f632016-07-22 13:13:11 -0700597$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
598$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
dcashman704741a2014-07-25 19:11:52 -0700599 mkdir -p $(dir $@)
600 $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
601 -D target_build_variant=user \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500602 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800603 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700604 -D target_with_asan=false \
Alex Klyubin446279a2017-04-06 14:45:50 -0700605 -D target_full_treble=cts \
dcashman704741a2014-07-25 19:11:52 -0700606 -s $^ > $@
607 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
608
William Robertsb8769932015-06-29 16:31:23 -0700609##################################
dcashmand225b692016-12-12 09:29:04 -0800610# TODO - remove this. Keep around until we get the filesystem creation stuff taken care of.
611#
William Robertsb8769932015-06-29 16:31:23 -0700612include $(CLEAR_VARS)
613
Richard Hainesc2d01912015-08-06 17:43:52 +0100614LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800615LOCAL_MODULE_CLASS := ETC
616LOCAL_MODULE_TAGS := optional
617LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
618
Stephen Smalley5b340be2012-03-06 11:12:41 -0500619include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800620
William Roberts49693f12016-01-04 12:20:57 -0800621# The file_contexts.bin is built in the following way:
622# 1. Collect all file_contexts files in THIS repository and process them with
623# m4 into a tmp file called file_contexts.local.tmp.
624# 2. Collect all device specific file_contexts files and process them with m4
625# into a tmp file called file_contexts.device.tmp.
626# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
627# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
628# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
629# file_contexts.concat.tmp.
630# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
631# file_contexts.bin.
632#
633# Note: That a newline file is placed between each file_context file found to
634# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800635
dcashmancc39f632016-07-22 13:13:11 -0700636local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
William Roberts49693f12016-01-04 12:20:57 -0800637ifneq ($(filter address,$(SANITIZE_TARGET)),)
dcashmancc39f632016-07-22 13:13:11 -0700638 local_fc_files := $(local_fc_files) $(PLAT_PRIVATE_POLICY)/file_contexts_asan
William Roberts49693f12016-01-04 12:20:57 -0800639endif
640local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
641
642file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
643$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500644 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800645 $(hide) m4 -s $^ > $@
646
647device_fc_files := $(call build_device_policy, file_contexts)
648device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
649
650file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
651$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
652$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
653 @mkdir -p $(dir $@)
654 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
655
656file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
657$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
658$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
659 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800660 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800661 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
662
663file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
664$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
665 @mkdir -p $(dir $@)
666 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500667
William Roberts3746a0a2015-09-25 10:18:44 -0700668$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800669$(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 +0100670 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800671 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100672 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
673
Robert Craig8b7545b2014-03-20 09:35:08 -0400674built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800675local_fc_files :=
676local_fcfiles_with_nl :=
677device_fc_files :=
678device_fcfiles_with_nl :=
679file_contexts.concat.tmp :=
680file_contexts.device.sorted.tmp :=
681file_contexts.device.tmp :=
682file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700683
Ying Wang02fb5f32012-01-17 17:51:09 -0800684##################################
685include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400686
Alex Klyubinec78c372017-03-10 12:44:16 -0800687LOCAL_MODULE := file_contexts.bin.recovery
688LOCAL_MODULE_STEM := file_contexts.bin
689LOCAL_MODULE_CLASS := ETC
690LOCAL_MODULE_TAGS := optional
691LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
692
693include $(BUILD_SYSTEM)/base_rules.mk
694
695$(LOCAL_BUILT_MODULE): $(built_fc)
696 $(hide) cp -f $< $@
697
698##################################
699include $(CLEAR_VARS)
700
dcashmand225b692016-12-12 09:29:04 -0800701LOCAL_MODULE := plat_file_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400702LOCAL_MODULE_CLASS := ETC
dcashmand225b692016-12-12 09:29:04 -0800703LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800704LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400705
706include $(BUILD_SYSTEM)/base_rules.mk
707
dcashmand225b692016-12-12 09:29:04 -0800708local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
709ifneq ($(filter address,$(SANITIZE_TARGET)),)
710 local_fc_files += $(PLAT_PRIVATE_POLICY)/file_contexts_asan
711endif
Alex Klyubine4665d72017-01-19 19:58:34 -0800712local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400713
Alex Klyubine4665d72017-01-19 19:58:34 -0800714$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl)
dcashmand225b692016-12-12 09:29:04 -0800715$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Alex Klyubine4665d72017-01-19 19:58:34 -0800716$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
717$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
718$(local_fcfiles_with_nl) $(built_sepolicy)
Richard Hainesc2d01912015-08-06 17:43:52 +0100719 @mkdir -p $(dir $@)
Alex Klyubine4665d72017-01-19 19:58:34 -0800720 $(hide) m4 -s $(PRIVATE_FC_FILES) > $@.tmp
721 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
722 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
Richard Hainesc2d01912015-08-06 17:43:52 +0100723
dcashmand225b692016-12-12 09:29:04 -0800724built_plat_fc := $(LOCAL_BUILT_MODULE)
725local_fc_files :=
Alex Klyubine4665d72017-01-19 19:58:34 -0800726local_fcfiles_with_nl :=
dcashmand225b692016-12-12 09:29:04 -0800727
728##################################
729include $(CLEAR_VARS)
730
731LOCAL_MODULE := nonplat_file_contexts
732LOCAL_MODULE_CLASS := ETC
733LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800734LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashmand225b692016-12-12 09:29:04 -0800735
736include $(BUILD_SYSTEM)/base_rules.mk
737
738nonplat_fc_files := $(call build_device_policy, file_contexts)
739nonplat_fcfiles_with_nl := $(call add_nl, $(nonplat_fc_files), $(built_nl))
740
741$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(nonplat_fcfiles_with_nl)
742$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
743$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
744$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
Alex Klyubine4665d72017-01-19 19:58:34 -0800745$(nonplat_fcfiles_with_nl) $(built_sepolicy)
dcashmand225b692016-12-12 09:29:04 -0800746 @mkdir -p $(dir $@)
747 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > $@.tmp
748 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
749 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
750
751built_nonplat_fc := $(LOCAL_BUILT_MODULE)
752nonplat_fc_files :=
753nonplat_fcfiles_with_nl :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400754
755##################################
756include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800757LOCAL_MODULE := plat_seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800758LOCAL_MODULE_CLASS := ETC
759LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800760ifeq ($(PRODUCT_FULL_TREBLE),true)
761LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
762else
Ying Wang02fb5f32012-01-17 17:51:09 -0800763LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800764endif
Ying Wang02fb5f32012-01-17 17:51:09 -0800765
William Roberts171a0622012-08-16 10:55:05 -0700766include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800767
Dan Cashman9c038072016-12-22 07:15:18 -0800768plat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts171a0622012-08-16 10:55:05 -0700769
Ying Wangd8b122c2012-10-25 19:01:31 -0700770$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman9c038072016-12-22 07:15:18 -0800771$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(plat_sc_files)
772$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(plat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700773 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700774 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800775
Dan Cashman9c038072016-12-22 07:15:18 -0800776built_plat_sc := $(LOCAL_BUILT_MODULE)
777plat_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400778
Ying Wang02fb5f32012-01-17 17:51:09 -0800779##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400780include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800781LOCAL_MODULE := nonplat_seapp_contexts
Stephen Smalley37712872015-03-12 15:46:36 -0400782LOCAL_MODULE_CLASS := ETC
Dan Cashman9c038072016-12-22 07:15:18 -0800783LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800784ifeq ($(PRODUCT_FULL_TREBLE),true)
785LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
786else
Dan Cashman9c038072016-12-22 07:15:18 -0800787LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800788endif
Stephen Smalley37712872015-03-12 15:46:36 -0400789
790include $(BUILD_SYSTEM)/base_rules.mk
791
Alex Klyubin55961722017-01-30 18:44:59 -0800792nonplat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800793plat_sc_neverallow_files := $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
Stephen Smalley37712872015-03-12 15:46:36 -0400794
Dan Cashman9c038072016-12-22 07:15:18 -0800795$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
796$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(nonplat_sc_files)
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800797$(LOCAL_BUILT_MODULE): PRIVATE_SC_NEVERALLOW_FILES := $(plat_sc_neverallow_files)
798$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(nonplat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp $(plat_sc_neverallow_files)
Stephen Smalley37712872015-03-12 15:46:36 -0400799 @mkdir -p $(dir $@)
Xin Liec6f3932017-03-14 16:51:13 -0700800 $(hide) grep -ie '^neverallow' $(PRIVATE_SC_NEVERALLOW_FILES) > $@.tmp
801 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES) $@.tmp
Stephen Smalley37712872015-03-12 15:46:36 -0400802
Dan Cashman9c038072016-12-22 07:15:18 -0800803built_nonplat_sc := $(LOCAL_BUILT_MODULE)
804nonplat_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400805
806##################################
807include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800808LOCAL_MODULE := plat_seapp_neverallows
William Roberts4ee71312015-06-25 11:59:30 -0700809LOCAL_MODULE_CLASS := ETC
810LOCAL_MODULE_TAGS := tests
811
812include $(BUILD_SYSTEM)/base_rules.mk
813
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800814$(LOCAL_BUILT_MODULE): $(plat_sc_neverallow_files)
William Roberts4ee71312015-06-25 11:59:30 -0700815 @mkdir -p $(dir $@)
816 - $(hide) grep -ie '^neverallow' $< > $@
817
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800818plat_sc_neverallow_files :=
William Roberts4ee71312015-06-25 11:59:30 -0700819
820##################################
821include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400822
Sandeep Patila86316e2016-12-27 16:08:44 -0800823LOCAL_MODULE := plat_property_contexts
Stephen Smalley124720a2012-04-04 10:11:16 -0400824LOCAL_MODULE_CLASS := ETC
825LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800826
827ifeq ($(PRODUCT_FULL_TREBLE),true)
828LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
829else
Stephen Smalley124720a2012-04-04 10:11:16 -0400830LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800831endif
Stephen Smalley124720a2012-04-04 10:11:16 -0400832
833include $(BUILD_SYSTEM)/base_rules.mk
834
Sandeep Patila86316e2016-12-27 16:08:44 -0800835plat_pcfiles := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts6aabc1c2015-07-30 11:44:26 -0700836
Sandeep Patila86316e2016-12-27 16:08:44 -0800837plat_property_contexts.tmp := $(intermediates)/plat_property_contexts.tmp
838$(plat_property_contexts.tmp): PRIVATE_PC_FILES := $(plat_pcfiles)
839$(plat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
840$(plat_property_contexts.tmp): $(plat_pcfiles)
William Roberts7f81b332015-09-29 13:52:37 -0700841 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000842 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700843$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila86316e2016-12-27 16:08:44 -0800844$(LOCAL_BUILT_MODULE): $(plat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700845 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800846 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800847 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400848
Sandeep Patila86316e2016-12-27 16:08:44 -0800849built_plat_pc := $(LOCAL_BUILT_MODULE)
850plat_pcfiles :=
851plat_property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400852
Stephen Smalley124720a2012-04-04 10:11:16 -0400853##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700854include $(CLEAR_VARS)
Sandeep Patila86316e2016-12-27 16:08:44 -0800855LOCAL_MODULE := nonplat_property_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400856LOCAL_MODULE_CLASS := ETC
Sandeep Patila86316e2016-12-27 16:08:44 -0800857LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800858
859ifeq ($(PRODUCT_FULL_TREBLE),true)
860LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
861else
Sandeep Patila86316e2016-12-27 16:08:44 -0800862LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800863endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400864
Stephen Smalleyc9361732015-03-13 09:36:57 -0400865include $(BUILD_SYSTEM)/base_rules.mk
866
Alex Klyubin55961722017-01-30 18:44:59 -0800867nonplat_pcfiles := $(call build_policy, property_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Sandeep Patil262edc32016-12-27 16:08:44 -0800868
Sandeep Patila86316e2016-12-27 16:08:44 -0800869nonplat_property_contexts.tmp := $(intermediates)/nonplat_property_contexts.tmp
870$(nonplat_property_contexts.tmp): PRIVATE_PC_FILES := $(nonplat_pcfiles)
871$(nonplat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
872$(nonplat_property_contexts.tmp): $(nonplat_pcfiles)
William Robertsdcffd2b2015-09-29 13:52:37 -0700873 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800874 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
875
876
877$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
878$(LOCAL_BUILT_MODULE): $(nonplat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
879 @mkdir -p $(dir $@)
880 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800881 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700882
Sandeep Patila86316e2016-12-27 16:08:44 -0800883built_nonplat_pc := $(LOCAL_BUILT_MODULE)
884nonplat_pcfiles :=
885nonplat_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400886
887##################################
888include $(CLEAR_VARS)
889
Alex Klyubinec78c372017-03-10 12:44:16 -0800890LOCAL_MODULE := plat_property_contexts.recovery
891LOCAL_MODULE_STEM := plat_property_contexts
892LOCAL_MODULE_CLASS := ETC
893LOCAL_MODULE_TAGS := optional
894LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
895
896include $(BUILD_SYSTEM)/base_rules.mk
897
898$(LOCAL_BUILT_MODULE): $(built_plat_pc)
899 $(hide) cp -f $< $@
900
901##################################
902include $(CLEAR_VARS)
Alex Klyubinec78c372017-03-10 12:44:16 -0800903LOCAL_MODULE := nonplat_property_contexts.recovery
904LOCAL_MODULE_STEM := nonplat_property_contexts
905LOCAL_MODULE_CLASS := ETC
906LOCAL_MODULE_TAGS := optional
907LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
908
909include $(BUILD_SYSTEM)/base_rules.mk
910
911$(LOCAL_BUILT_MODULE): $(built_nonplat_pc)
912 $(hide) cp -f $< $@
913
914##################################
915include $(CLEAR_VARS)
916
Sandeep Patila058b562016-12-27 15:10:48 -0800917LOCAL_MODULE := plat_service_contexts
Riley Spahnf90c41f2014-06-05 15:52:02 -0700918LOCAL_MODULE_CLASS := ETC
919LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800920ifeq ($(PRODUCT_FULL_TREBLE),true)
921LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
922else
Riley Spahnf90c41f2014-06-05 15:52:02 -0700923LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800924endif
Riley Spahnf90c41f2014-06-05 15:52:02 -0700925
926include $(BUILD_SYSTEM)/base_rules.mk
927
Sandeep Patila058b562016-12-27 15:10:48 -0800928plat_svcfiles := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700929
Sandeep Patila058b562016-12-27 15:10:48 -0800930plat_service_contexts.tmp := $(intermediates)/plat_service_contexts.tmp
931$(plat_service_contexts.tmp): PRIVATE_SVC_FILES := $(plat_svcfiles)
932$(plat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
933$(plat_service_contexts.tmp): $(plat_svcfiles)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700934 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700935 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700936
937$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila058b562016-12-27 15:10:48 -0800938$(LOCAL_BUILT_MODULE): $(plat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700939 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700940 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800941 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700942
Sandeep Patila058b562016-12-27 15:10:48 -0800943built_plat_svc := $(LOCAL_BUILT_MODULE)
944plat_svcfiles :=
945plat_service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700946
947##################################
rpcraigb19665c2012-07-30 09:33:03 -0400948include $(CLEAR_VARS)
949
Sandeep Patila058b562016-12-27 15:10:48 -0800950LOCAL_MODULE := nonplat_service_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400951LOCAL_MODULE_CLASS := ETC
Sandeep Patila058b562016-12-27 15:10:48 -0800952LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800953ifeq ($(PRODUCT_FULL_TREBLE),true)
954LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
955else
Sandeep Patila058b562016-12-27 15:10:48 -0800956LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800957endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400958
959include $(BUILD_SYSTEM)/base_rules.mk
960
Alex Klyubin55961722017-01-30 18:44:59 -0800961nonplat_svcfiles := $(call build_policy, service_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400962
Sandeep Patila058b562016-12-27 15:10:48 -0800963nonplat_service_contexts.tmp := $(intermediates)/nonplat_service_contexts.tmp
964$(nonplat_service_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_svcfiles)
965$(nonplat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
966$(nonplat_service_contexts.tmp): $(nonplat_svcfiles)
967 @mkdir -p $(dir $@)
968 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
969
970$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
971$(LOCAL_BUILT_MODULE): $(nonplat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700972 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700973 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800974 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700975
Sandeep Patila058b562016-12-27 15:10:48 -0800976built_nonplat_svc := $(LOCAL_BUILT_MODULE)
977nonplat_svcfiles :=
978nonplat_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400979
980##################################
981include $(CLEAR_VARS)
982
Martijn Coenen6676c232017-03-31 17:29:53 -0700983LOCAL_MODULE := vndservice_contexts
984LOCAL_MODULE_CLASS := ETC
985LOCAL_MODULE_TAGS := optional
986ifeq ($(PRODUCT_FULL_TREBLE),true)
987LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
988else
989LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
990endif
991
992include $(BUILD_SYSTEM)/base_rules.mk
993
994vnd_svcfiles := $(call build_policy, vndservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
995
996vndservice_contexts.tmp := $(intermediates)/vndservice_contexts.tmp
997$(vndservice_contexts.tmp): PRIVATE_SVC_FILES := $(vnd_svcfiles)
998$(vndservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
999$(vndservice_contexts.tmp): $(vnd_svcfiles)
1000 @mkdir -p $(dir $@)
1001 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1002
1003$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1004$(LOCAL_BUILT_MODULE): $(vndservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1005 @mkdir -p $(dir $@)
1006 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
Martijn Coenenee976622017-04-07 10:08:55 -07001007 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -v $(PRIVATE_SEPOLICY) $@
Martijn Coenen6676c232017-03-31 17:29:53 -07001008
1009vnd_svcfiles :=
1010vndservice_contexts.tmp :=
1011##################################
1012include $(CLEAR_VARS)
1013
dcashman90b3b942016-12-14 13:47:55 -08001014LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -04001015LOCAL_MODULE_CLASS := ETC
1016LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001017LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
rpcraigb19665c2012-07-30 09:33:03 -04001018
William Roberts2c8a55d2012-11-30 14:59:09 -08001019include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -04001020
Geremy Condracd4104e2013-03-26 18:19:12 +00001021# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -08001022plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
1023$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1024$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +00001025 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -07001026 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +00001027
dcashman90b3b942016-12-14 13:47:55 -08001028all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -04001029
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001030# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -08001031all_plat_keys := platform media shared testkey
1032all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001033
dcashman90b3b942016-12-14 13:47:55 -08001034$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
1035$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1036$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +00001037 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -07001038 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -07001039 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +00001040
William Roberts6aabc1c2015-07-30 11:44:26 -07001041all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -08001042all_plat_keys :=
1043plat_mac_perms_keys.tmp :=
1044
1045##################################
1046include $(CLEAR_VARS)
1047
1048LOCAL_MODULE := nonplat_mac_permissions.xml
1049LOCAL_MODULE_CLASS := ETC
1050LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001051LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman90b3b942016-12-14 13:47:55 -08001052
1053include $(BUILD_SYSTEM)/base_rules.mk
1054
1055# Build keys.conf
1056nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
1057$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Alex Klyubin55961722017-01-30 18:44:59 -08001058$(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 -08001059 @mkdir -p $(dir $@)
1060 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
1061
Alex Klyubin55961722017-01-30 18:44:59 -08001062all_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 -08001063
1064$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
1065$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1066$(all_nonplat_mac_perms_files)
1067 @mkdir -p $(dir $@)
1068 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
1069
1070nonplat_mac_perms_keys.tmp :=
1071all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -07001072
rpcraigb19665c2012-07-30 09:33:03 -04001073##################################
rpcraig47cd3962012-10-17 21:09:52 -04001074
Dan Cashman1c040272016-12-15 15:28:44 -08001075add_nl :=
William Roberts49693f12016-01-04 12:20:57 -08001076build_device_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001077build_policy :=
dcashmand225b692016-12-12 09:29:04 -08001078built_plat_fc :=
1079built_nonplat_fc :=
Richard Hainesc8801fe2015-12-11 10:39:19 +00001080built_nl :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001081built_plat_cil :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001082built_mapping_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001083built_plat_pc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001084built_nonplat_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001085built_nonplat_pc :=
Dan Cashman9c038072016-12-22 07:15:18 -08001086built_nonplat_sc :=
1087built_plat_sc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001088built_precompiled_sepolicy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001089built_sepolicy :=
Sandeep Patila058b562016-12-27 15:10:48 -08001090built_plat_svc :=
1091built_nonplat_svc :=
Dan Cashman1c040272016-12-15 15:28:44 -08001092mapping_policy_nvr :=
Dan Cashman1c040272016-12-15 15:28:44 -08001093my_target_arch :=
1094nonplat_policy_nvr :=
Dan Cashman1c040272016-12-15 15:28:44 -08001095plat_policy_nvr :=
dcashman1faa6442016-11-28 07:20:28 -08001096plat_pub_policy.cil :=
1097reqd_policy_mask.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -08001098sepolicy_build_files :=
Alex Klyubin7cda44f2017-03-21 14:28:53 -07001099sepolicy_build_cil_workaround_files :=
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001100with_asan :=
Alice Chucdfb06f2012-11-01 11:33:04 -07001101
1102include $(call all-makefiles-under,$(LOCAL_PATH))