blob: 2b2c0c865df3ced5f4be581c804bbff767cb4a50 [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 -070092# BOARD_SEPOLICY_VERS_DIR should contain the public platform policy which
93# is associated with the given BOARD_SEPOLICY_VERS. The policy therein will be
94# versioned according to the BOARD_SEPOLICY_VERS identifier and included as
95# part of the non-platform policy to ensure removal of access in future
96# platform policy does not break non-platform policy.
97ifndef BOARD_SEPOLICY_VERS
98$(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version)
Sandeep Patil42f95982017-04-07 14:18:48 -070099# The default platform policy version.
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700100BOARD_SEPOLICY_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman2e00e632016-10-12 14:58:09 -0700101BOARD_SEPOLICY_VERS_DIR := $(PLAT_PUBLIC_POLICY)
102else
103ifndef BOARD_SEPOLICY_VERS_DIR
104$(error BOARD_SEPOLICY_VERS_DIR not specified for versioned sepolicy.)
105endif
106endif
dcashmancc39f632016-07-22 13:13:11 -0700107
108###########################################################
109# Compute policy files to be used in policy build.
110# $(1): files to include
111# $(2): directories in which to find files
112###########################################################
113
114define build_policy
115$(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))
116endef
William Roberts29d14682016-01-04 12:20:57 -0800117
William Roberts49693f12016-01-04 12:20:57 -0800118# Builds paths for all policy files found in BOARD_SEPOLICY_DIRS.
119# $(1): the set of policy name paths to build
Alex Klyubin55961722017-01-30 18:44:59 -0800120build_device_policy = $(call build_policy, $(1), $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts49693f12016-01-04 12:20:57 -0800121
Richard Hainesc8801fe2015-12-11 10:39:19 +0000122# Add a file containing only a newline in-between each policy configuration
123# 'contexts' file. This will allow OEM policy configuration files without a
124# final newline (0x0A) to be built correctly by the m4(1) macro processor.
125# $(1): the set of contexts file names.
126# $(2): the file containing only 0x0A.
127add_nl = $(foreach entry, $(1), $(subst $(entry), $(entry) $(2), $(entry)))
128
dcashman704741a2014-07-25 19:11:52 -0700129sepolicy_build_files := security_classes \
130 initial_sids \
131 access_vectors \
132 global_macros \
Nick Kralevicha17a2662014-11-05 15:30:41 -0800133 neverallow_macros \
dcashman704741a2014-07-25 19:11:52 -0700134 mls_macros \
dcashman2e00e632016-10-12 14:58:09 -0700135 mls_decl \
dcashman704741a2014-07-25 19:11:52 -0700136 mls \
137 policy_capabilities \
138 te_macros \
139 attributes \
Jeff Vander Stoepcbaa2b72015-12-22 10:39:34 -0800140 ioctl_defines \
Jeff Vander Stoepde9b5302015-06-05 15:28:55 -0700141 ioctl_macros \
dcashman704741a2014-07-25 19:11:52 -0700142 *.te \
dcashman2e00e632016-10-12 14:58:09 -0700143 roles_decl \
dcashman704741a2014-07-25 19:11:52 -0700144 roles \
145 users \
146 initial_sid_contexts \
147 fs_use \
148 genfs_contexts \
149 port_contexts
150
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700151# CIL files which contain workarounds for current limitation of human-readable
152# module policy language. These files are appended to the CIL files produced
153# from module language files.
154sepolicy_build_cil_workaround_files := technical_debt.cil
155
Dan Cashman1c040272016-12-15 15:28:44 -0800156my_target_arch := $(TARGET_ARCH)
157ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
158 my_target_arch := mips
159endif
160
Jeff Vander Stoepd2053bd2017-03-15 13:37:35 -0700161intermediates := $(TARGET_OUT_INTERMEDIATES)/ETC/sepolicy_intermediates
162
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700163with_asan := false
164ifneq (,$(filter address,$(SANITIZE_TARGET)))
165 with_asan := true
166endif
167
Dan Cashman4f9a6482017-04-10 12:27:18 -0700168include $(CLEAR_VARS)
169LOCAL_MODULE := selinux_policy
170LOCAL_MODULE_TAGS := optional
171# Include SELinux policy. We do this here because different modules
172# need to be included based on the value of PRODUCT_FULL_TREBLE. This
173# type of conditional inclusion cannot be done in top-level files such
174# as build/target/product/embedded.mk.
175# This conditional inclusion closely mimics the conditional logic
176# inside init/init.cpp for loading SELinux policy from files.
177ifeq ($(PRODUCT_FULL_TREBLE),true)
178
179platform_mapping_file := $(BOARD_SEPOLICY_VERS).cil
180
181# Use split SELinux policy
182LOCAL_REQUIRED_MODULES += \
183 $(platform_mapping_file) \
184 nonplat_sepolicy.cil \
185 plat_sepolicy.cil \
186 plat_and_mapping_sepolicy.cil.sha256 \
187 secilc \
188 nonplat_file_contexts \
189 plat_file_contexts \
190 plat_sepolicy_vers.txt
191
192# Include precompiled policy, unless told otherwise
193ifneq ($(PRODUCT_PRECOMPILED_SEPOLICY),false)
194LOCAL_REQUIRED_MODULES += precompiled_sepolicy precompiled_sepolicy.plat_and_mapping.sha256
195endif
196
197else
198# Use monolithic SELinux policy
199LOCAL_REQUIRED_MODULES += sepolicy \
200 file_contexts.bin
201endif
202include $(BUILD_PHONY_PACKAGE)
203
Ying Wang02fb5f32012-01-17 17:51:09 -0800204##################################
dcashman2e00e632016-10-12 14:58:09 -0700205# reqd_policy_mask - a policy.conf file which contains only the bare minimum
206# policy necessary to use checkpolicy. This bare-minimum policy needs to be
207# present in all policy.conf files, but should not necessarily be exported as
208# part of the public policy. The rules generated by reqd_policy_mask will allow
209# the compilation of public policy and subsequent removal of CIL policy that
210# should not be exported.
211
212reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
213$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
214$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800215$(reqd_policy_mask.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700216$(reqd_policy_mask.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700217$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
218$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
219 @mkdir -p $(dir $@)
220 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
221 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
222 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800223 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800224 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700225 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700226 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashman2e00e632016-10-12 14:58:09 -0700227 -s $^ > $@
228
229reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
230$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
231 @mkdir -p $(dir $@)
232 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c $(POLICYVERS) -o $@ $<
233
dcashman1faa6442016-11-28 07:20:28 -0800234reqd_policy_mask.conf :=
235
236##################################
dcashman2e00e632016-10-12 14:58:09 -0700237# plat_pub_policy - policy that will be exported to be a part of non-platform
238# policy corresponding to this platform version. This is a limited subset of
239# policy that would not compile in checkpolicy on its own. To get around this
240# limitation, add only the required files from private policy, which will
241# generate CIL policy that will then be filtered out by the reqd_policy_mask.
242plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
243$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
244$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800245$(plat_pub_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700246$(plat_pub_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700247$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
248$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
249$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY))
250 @mkdir -p $(dir $@)
251 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
252 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
253 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800254 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800255 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700256 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700257 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashman2e00e632016-10-12 14:58:09 -0700258 -s $^ > $@
259
260plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800261$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
262$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
263$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700264 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800265 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
266 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700267
dcashman1faa6442016-11-28 07:20:28 -0800268plat_pub_policy.conf :=
Dan Cashman1c040272016-12-15 15:28:44 -0800269
dcashman1faa6442016-11-28 07:20:28 -0800270##################################
271include $(CLEAR_VARS)
272
273LOCAL_MODULE := sectxfile_nl
274LOCAL_MODULE_CLASS := ETC
275LOCAL_MODULE_TAGS := optional
276
277# Create a file containing newline only to add between context config files
278include $(BUILD_SYSTEM)/base_rules.mk
279$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700280 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800281 $(hide) echo > $@
282
283built_nl := $(LOCAL_BUILT_MODULE)
284
285#################################
286include $(CLEAR_VARS)
287
288LOCAL_MODULE := plat_sepolicy.cil
289LOCAL_MODULE_CLASS := ETC
290LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800291LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800292
293include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700294
295# plat_policy.conf - A combination of the private and public platform policy
296# which will ship with the device. The platform will always reflect the most
297# recent platform version and is not currently being attributized.
298plat_policy.conf := $(intermediates)/plat_policy.conf
299$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
300$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800301$(plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700302$(plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700303$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
304$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700305$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
306 @mkdir -p $(dir $@)
307 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
308 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
309 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500310 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800311 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700312 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700313 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashmancc39f632016-07-22 13:13:11 -0700314 -s $^ > $@
315 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
316
dcashman1faa6442016-11-28 07:20:28 -0800317plat_policy_nvr := $(intermediates)/plat_policy_nvr.cil
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700318$(plat_policy_nvr): PRIVATE_ADDITIONAL_CIL_FILES := \
319 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
320$(plat_policy_nvr): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
321 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
dcashman2e00e632016-10-12 14:58:09 -0700322 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800323 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700324 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
dcashmancc39f632016-07-22 13:13:11 -0700325
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800326$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(plat_policy_nvr)
327$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(plat_policy_nvr)
dcashman1faa6442016-11-28 07:20:28 -0800328 @mkdir -p $(dir $@)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800329 # Strip out neverallow statements. They aren't needed on-device and their presence
330 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
331 # sailfish-eng).
332 grep -v '^(neverallow' $(PRIVATE_CIL_FILES) > $@
333 # Confirm that the resulting policy compiles
334 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) $@ -o /dev/null -f /dev/null
dcashman1faa6442016-11-28 07:20:28 -0800335
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800336built_plat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800337plat_policy.conf :=
338
339#################################
340include $(CLEAR_VARS)
341
Dan Cashman4f9a6482017-04-10 12:27:18 -0700342LOCAL_MODULE := plat_sepolicy_vers.txt
dcashman1faa6442016-11-28 07:20:28 -0800343LOCAL_MODULE_CLASS := ETC
344LOCAL_MODULE_TAGS := optional
Dan Cashman4f9a6482017-04-10 12:27:18 -0700345LOCAL_PROPRIETARY_MODULE := true
346LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
347
348include $(BUILD_SYSTEM)/base_rules.mk
349
350$(LOCAL_BUILT_MODULE) : PRIVATE_PLAT_SEPOL_VERS := $(BOARD_SEPOLICY_VERS)
351$(LOCAL_BUILT_MODULE) :
352 mkdir -p $(dir $@)
353 echo $(PRIVATE_PLAT_SEPOL_VERS) > $@
354
355#################################
356include $(CLEAR_VARS)
357
358LOCAL_MODULE := $(platform_mapping_file)
359LOCAL_MODULE_CLASS := ETC
360LOCAL_MODULE_TAGS := optional
361LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux/mapping
dcashman1faa6442016-11-28 07:20:28 -0800362
363include $(BUILD_SYSTEM)/base_rules.mk
364
365# auto-generate the mapping file for current platform policy, since it needs to
366# track platform policy development
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700367current_mapping.cil := $(intermediates)/mapping/$(PLATFORM_SEPOLICY_VERSION).cil
368$(current_mapping.cil) : PRIVATE_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman1faa6442016-11-28 07:20:28 -0800369$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
370 @mkdir -p $(dir $@)
371 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
372
Sandeep Patil42f95982017-04-07 14:18:48 -0700373
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700374ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
dcashman1faa6442016-11-28 07:20:28 -0800375mapping_policy_nvr := $(current_mapping.cil)
376else
377mapping_policy_nvr := $(addsuffix /$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)/mapping)
378endif
379
380$(LOCAL_BUILT_MODULE): $(mapping_policy_nvr)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800381 # Strip out neverallow statements. They aren't needed on-device and their presence
382 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
383 # sailfish-eng).
384 grep -v '^(neverallow' $< > $@
dcashman1faa6442016-11-28 07:20:28 -0800385
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800386built_mapping_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800387current_mapping.cil :=
388
389#################################
390include $(CLEAR_VARS)
391
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700392LOCAL_MODULE := plat_and_mapping_sepolicy.cil.sha256
393LOCAL_MODULE_CLASS := ETC
394LOCAL_MODULE_TAGS := optional
395LOCAL_MODULE_PATH = $(TARGET_OUT)/etc/selinux
396
397include $(BUILD_SYSTEM)/base_rules.mk
398
399$(LOCAL_BUILT_MODULE): $(built_plat_cil) $(built_mapping_cil)
400 cat $^ | sha256sum | cut -d' ' -f1 > $@
401
402#################################
403include $(CLEAR_VARS)
404
dcashman1faa6442016-11-28 07:20:28 -0800405LOCAL_MODULE := nonplat_sepolicy.cil
406LOCAL_MODULE_CLASS := ETC
407LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800408LOCAL_PROPRIETARY_MODULE := true
409LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800410
411include $(BUILD_SYSTEM)/base_rules.mk
412
Alex Klyubin55961722017-01-30 18:44:59 -0800413# nonplat_policy.conf - A combination of the non-platform private, vendor and
414# the exported platform policy associated with the version the non-platform
415# policy targets. This needs attributization and to be combined with the
dcashman2e00e632016-10-12 14:58:09 -0700416# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
417# of the reqd_policy_mask files from private policy in order to use checkpolicy.
418nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
419$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
420$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800421$(nonplat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700422$(nonplat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700423$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
424$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Alex Klyubin55961722017-01-30 18:44:59 -0800425$(BOARD_SEPOLICY_VERS_DIR) $(REQD_MASK_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Ying Wang02fb5f32012-01-17 17:51:09 -0800426 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700427 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
428 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800429 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500430 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800431 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700432 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700433 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800434 -s $^ > $@
Robert Craig65d4f442013-03-27 06:30:25 -0400435 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500436
dcashman1faa6442016-11-28 07:20:28 -0800437nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
438$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
439$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
440$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
441$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800442 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800443 $(hide) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
444 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700445
dcashman1faa6442016-11-28 07:20:28 -0800446nonplat_policy_nvr := $(intermediates)/nonplat_policy_nvr.cil
447$(nonplat_policy_nvr) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
448$(nonplat_policy_nvr) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
449$(nonplat_policy_nvr) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
dcashman2e00e632016-10-12 14:58:09 -0700450$(HOST_OUT_EXECUTABLES)/version_policy
451 @mkdir -p $(dir $@)
452 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
453
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800454$(LOCAL_BUILT_MODULE): PRIVATE_NONPLAT_CIL_FILES := $(nonplat_policy_nvr)
455$(LOCAL_BUILT_MODULE): PRIVATE_DEP_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
456$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(nonplat_policy_nvr) $(built_plat_cil) \
457$(built_mapping_cil)
dcashman2e00e632016-10-12 14:58:09 -0700458 @mkdir -p $(dir $@)
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800459 # Strip out neverallow statements. They aren't needed on-device and their presence
460 # significantly slows down on-device compilation (e.g., from 400 ms to 6,400 ms on
461 # sailfish-eng).
462 grep -v '^(neverallow' $(PRIVATE_NONPLAT_CIL_FILES) > $@
463 # Confirm that the resulting policy compiles combined with platform and mapping policies
464 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) \
465 $(PRIVATE_DEP_CIL_FILES) $@ -o /dev/null -f /dev/null
dcashman2e00e632016-10-12 14:58:09 -0700466
Alex Klyubin193dccd2017-03-07 14:05:57 -0800467built_nonplat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800468nonplat_policy.conf :=
469nonplat_policy_raw :=
470
471#################################
472include $(CLEAR_VARS)
Alex Klyubin193dccd2017-03-07 14:05:57 -0800473
474LOCAL_MODULE := precompiled_sepolicy
475LOCAL_MODULE_CLASS := ETC
476LOCAL_MODULE_TAGS := optional
477LOCAL_PROPRIETARY_MODULE := true
478LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
479
480include $(BUILD_SYSTEM)/base_rules.mk
481
482$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := \
483$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
484$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc \
485$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
486 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -c $(POLICYVERS) \
487 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
488
489built_precompiled_sepolicy := $(LOCAL_BUILT_MODULE)
490
491#################################
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700492# SHA-256 digest of the plat_sepolicy.cil and mapping_sepolicy.cil files against
493# which precompiled_policy was built.
Alex Klyubin193dccd2017-03-07 14:05:57 -0800494#################################
495include $(CLEAR_VARS)
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700496LOCAL_MODULE := precompiled_sepolicy.plat_and_mapping.sha256
Alex Klyubin193dccd2017-03-07 14:05:57 -0800497LOCAL_MODULE_CLASS := ETC
498LOCAL_MODULE_TAGS := optional
499LOCAL_PROPRIETARY_MODULE := true
500LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
501
502include $(BUILD_SYSTEM)/base_rules.mk
503
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700504$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
505$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_plat_cil) $(built_mapping_cil)
506 cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@
Alex Klyubin193dccd2017-03-07 14:05:57 -0800507
508#################################
509include $(CLEAR_VARS)
Dan Cashman1c040272016-12-15 15:28:44 -0800510# build this target so that we can still perform neverallow checks
dcashman1faa6442016-11-28 07:20:28 -0800511
512LOCAL_MODULE := sepolicy
513LOCAL_MODULE_CLASS := ETC
514LOCAL_MODULE_TAGS := optional
Daniel Cashman65d01342016-12-17 00:53:26 +0000515LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman2e00e632016-10-12 14:58:09 -0700516
dcashman1faa6442016-11-28 07:20:28 -0800517include $(BUILD_SYSTEM)/base_rules.mk
518
dcashman2e00e632016-10-12 14:58:09 -0700519all_cil_files := \
dcashman1faa6442016-11-28 07:20:28 -0800520 $(plat_policy_nvr) \
521 $(mapping_policy_nvr) \
522 $(nonplat_policy_nvr) \
dcashman2e00e632016-10-12 14:58:09 -0700523
524$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
525$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
526 @mkdir -p $(dir $@)
William Roberts5d0c2e42017-03-23 11:26:29 -0700527 $(hide) $< -M true -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp -f /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800528 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
529 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
530 echo "==========" 1>&2; \
531 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
532 echo "List of invalid domains:" 1>&2; \
533 cat $@.permissivedomains 1>&2; \
534 exit 1; \
535 fi
536 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800537
Ying Wangd8b122c2012-10-25 19:01:31 -0700538built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700539all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400540
Alex Klyubin84aa7422017-03-10 09:36:07 -0800541#################################
542include $(CLEAR_VARS)
543
544# keep concrete sepolicy for neverallow checks
545
546LOCAL_MODULE := sepolicy.recovery
Alex Klyubinec78c372017-03-10 12:44:16 -0800547LOCAL_MODULE_STEM := sepolicy
Alex Klyubin84aa7422017-03-10 09:36:07 -0800548LOCAL_MODULE_CLASS := ETC
549LOCAL_MODULE_TAGS := optional
Alex Klyubinec78c372017-03-10 12:44:16 -0800550LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
Alex Klyubin84aa7422017-03-10 09:36:07 -0800551
552include $(BUILD_SYSTEM)/base_rules.mk
553
Dan Cashmanc8d45352017-04-11 07:38:48 -0700554sepolicy.recovery.conf := $(intermediates)/sepolicy.recovery.conf
555$(sepolicy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
556$(sepolicy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
557$(sepolicy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
558$(sepolicy.recovery.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
559$(sepolicy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
560$(sepolicy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
561 $(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) \
562 $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashman1c040272016-12-15 15:28:44 -0800563 @mkdir -p $(dir $@)
564 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
565 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
566 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800567 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800568 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700569 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Dan Cashman1c040272016-12-15 15:28:44 -0800570 -D target_recovery=true \
571 -s $^ > $@
572 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
573
Dan Cashmanc8d45352017-04-11 07:38:48 -0700574$(LOCAL_BUILT_MODULE): $(sepolicy.recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
575 $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Dan Cashman1c040272016-12-15 15:28:44 -0800576 @mkdir -p $(dir $@)
Dan Cashmanc8d45352017-04-11 07:38:48 -0700577 $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@.tmp $<
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800578 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
579 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
580 echo "==========" 1>&2; \
581 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
582 echo "List of invalid domains:" 1>&2; \
583 cat $@.permissivedomains 1>&2; \
584 exit 1; \
585 fi
586 $(hide) mv $@.tmp $@
Stephen Smalleye60723a2014-05-29 16:40:15 -0400587
Dan Cashmanc8d45352017-04-11 07:38:48 -0700588sepolicy.recovery.conf :=
Stephen Smalleye60723a2014-05-29 16:40:15 -0400589
dcashman704741a2014-07-25 19:11:52 -0700590##################################
Alex Klyubin446279a2017-04-06 14:45:50 -0700591# SELinux policy embedded into CTS.
592# CTS checks neverallow rules of this policy against the policy of the device under test.
593##################################
dcashman704741a2014-07-25 19:11:52 -0700594include $(CLEAR_VARS)
595
596LOCAL_MODULE := general_sepolicy.conf
597LOCAL_MODULE_CLASS := ETC
598LOCAL_MODULE_TAGS := tests
599
600include $(BUILD_SYSTEM)/base_rules.mk
601
dcashman704741a2014-07-25 19:11:52 -0700602$(LOCAL_BUILT_MODULE): PRIVATE_MLS_SENS := $(MLS_SENS)
603$(LOCAL_BUILT_MODULE): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800604$(LOCAL_BUILT_MODULE): PRIVATE_TGT_ARCH := $(my_target_arch)
dcashmancc39f632016-07-22 13:13:11 -0700605$(LOCAL_BUILT_MODULE): $(call build_policy, $(sepolicy_build_files), \
606$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
dcashman704741a2014-07-25 19:11:52 -0700607 mkdir -p $(dir $@)
608 $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
609 -D target_build_variant=user \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500610 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800611 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700612 -D target_with_asan=false \
Alex Klyubin446279a2017-04-06 14:45:50 -0700613 -D target_full_treble=cts \
dcashman704741a2014-07-25 19:11:52 -0700614 -s $^ > $@
615 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
616
William Robertsb8769932015-06-29 16:31:23 -0700617##################################
dcashmand225b692016-12-12 09:29:04 -0800618# TODO - remove this. Keep around until we get the filesystem creation stuff taken care of.
619#
William Robertsb8769932015-06-29 16:31:23 -0700620include $(CLEAR_VARS)
621
Richard Hainesc2d01912015-08-06 17:43:52 +0100622LOCAL_MODULE := file_contexts.bin
Ying Wang02fb5f32012-01-17 17:51:09 -0800623LOCAL_MODULE_CLASS := ETC
624LOCAL_MODULE_TAGS := optional
625LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
626
Stephen Smalley5b340be2012-03-06 11:12:41 -0500627include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800628
William Roberts49693f12016-01-04 12:20:57 -0800629# The file_contexts.bin is built in the following way:
630# 1. Collect all file_contexts files in THIS repository and process them with
631# m4 into a tmp file called file_contexts.local.tmp.
632# 2. Collect all device specific file_contexts files and process them with m4
633# into a tmp file called file_contexts.device.tmp.
634# 3. Run checkfc -e (allow no device fc entries ie empty) and fc_sort on
635# file_contexts.device.tmp and output to file_contexts.device.sorted.tmp.
636# 4. Concatenate file_contexts.local.tmp and file_contexts.device.tmp into
637# file_contexts.concat.tmp.
638# 5. Run checkfc and sefcontext_compile on file_contexts.concat.tmp to produce
639# file_contexts.bin.
640#
641# Note: That a newline file is placed between each file_context file found to
642# ensure a proper build when an fc file is missing an ending newline.
William Roberts29d14682016-01-04 12:20:57 -0800643
dcashmancc39f632016-07-22 13:13:11 -0700644local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
William Roberts49693f12016-01-04 12:20:57 -0800645ifneq ($(filter address,$(SANITIZE_TARGET)),)
dcashmancc39f632016-07-22 13:13:11 -0700646 local_fc_files := $(local_fc_files) $(PLAT_PRIVATE_POLICY)/file_contexts_asan
William Roberts49693f12016-01-04 12:20:57 -0800647endif
648local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
649
650file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
651$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500652 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800653 $(hide) m4 -s $^ > $@
654
655device_fc_files := $(call build_device_policy, file_contexts)
656device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
657
658file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
659$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
660$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
661 @mkdir -p $(dir $@)
662 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
663
664file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
665$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
666$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
667 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800668 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800669 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
670
671file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
672$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
673 @mkdir -p $(dir $@)
674 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500675
William Roberts3746a0a2015-09-25 10:18:44 -0700676$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800677$(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 +0100678 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800679 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100680 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
681
Robert Craig8b7545b2014-03-20 09:35:08 -0400682built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800683local_fc_files :=
684local_fcfiles_with_nl :=
685device_fc_files :=
686device_fcfiles_with_nl :=
687file_contexts.concat.tmp :=
688file_contexts.device.sorted.tmp :=
689file_contexts.device.tmp :=
690file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700691
Ying Wang02fb5f32012-01-17 17:51:09 -0800692##################################
693include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400694
Alex Klyubinec78c372017-03-10 12:44:16 -0800695LOCAL_MODULE := file_contexts.bin.recovery
696LOCAL_MODULE_STEM := file_contexts.bin
697LOCAL_MODULE_CLASS := ETC
698LOCAL_MODULE_TAGS := optional
699LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
700
701include $(BUILD_SYSTEM)/base_rules.mk
702
703$(LOCAL_BUILT_MODULE): $(built_fc)
704 $(hide) cp -f $< $@
705
706##################################
707include $(CLEAR_VARS)
708
dcashmand225b692016-12-12 09:29:04 -0800709LOCAL_MODULE := plat_file_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400710LOCAL_MODULE_CLASS := ETC
dcashmand225b692016-12-12 09:29:04 -0800711LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800712LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400713
714include $(BUILD_SYSTEM)/base_rules.mk
715
dcashmand225b692016-12-12 09:29:04 -0800716local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts
717ifneq ($(filter address,$(SANITIZE_TARGET)),)
718 local_fc_files += $(PLAT_PRIVATE_POLICY)/file_contexts_asan
719endif
Alex Klyubine4665d72017-01-19 19:58:34 -0800720local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400721
Alex Klyubine4665d72017-01-19 19:58:34 -0800722$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl)
dcashmand225b692016-12-12 09:29:04 -0800723$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Alex Klyubine4665d72017-01-19 19:58:34 -0800724$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
725$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
726$(local_fcfiles_with_nl) $(built_sepolicy)
Richard Hainesc2d01912015-08-06 17:43:52 +0100727 @mkdir -p $(dir $@)
Alex Klyubine4665d72017-01-19 19:58:34 -0800728 $(hide) m4 -s $(PRIVATE_FC_FILES) > $@.tmp
729 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
730 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
Richard Hainesc2d01912015-08-06 17:43:52 +0100731
dcashmand225b692016-12-12 09:29:04 -0800732built_plat_fc := $(LOCAL_BUILT_MODULE)
733local_fc_files :=
Alex Klyubine4665d72017-01-19 19:58:34 -0800734local_fcfiles_with_nl :=
dcashmand225b692016-12-12 09:29:04 -0800735
736##################################
737include $(CLEAR_VARS)
738
739LOCAL_MODULE := nonplat_file_contexts
740LOCAL_MODULE_CLASS := ETC
741LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800742LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashmand225b692016-12-12 09:29:04 -0800743
744include $(BUILD_SYSTEM)/base_rules.mk
745
746nonplat_fc_files := $(call build_device_policy, file_contexts)
747nonplat_fcfiles_with_nl := $(call add_nl, $(nonplat_fc_files), $(built_nl))
748
749$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(nonplat_fcfiles_with_nl)
750$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
751$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
752$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
Alex Klyubine4665d72017-01-19 19:58:34 -0800753$(nonplat_fcfiles_with_nl) $(built_sepolicy)
dcashmand225b692016-12-12 09:29:04 -0800754 @mkdir -p $(dir $@)
755 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > $@.tmp
756 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
757 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
758
759built_nonplat_fc := $(LOCAL_BUILT_MODULE)
760nonplat_fc_files :=
761nonplat_fcfiles_with_nl :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400762
763##################################
764include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800765LOCAL_MODULE := plat_seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800766LOCAL_MODULE_CLASS := ETC
767LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800768ifeq ($(PRODUCT_FULL_TREBLE),true)
769LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
770else
Ying Wang02fb5f32012-01-17 17:51:09 -0800771LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800772endif
Ying Wang02fb5f32012-01-17 17:51:09 -0800773
William Roberts171a0622012-08-16 10:55:05 -0700774include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800775
Dan Cashman9c038072016-12-22 07:15:18 -0800776plat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts171a0622012-08-16 10:55:05 -0700777
Ying Wangd8b122c2012-10-25 19:01:31 -0700778$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman9c038072016-12-22 07:15:18 -0800779$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(plat_sc_files)
780$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(plat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700781 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700782 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800783
Dan Cashman9c038072016-12-22 07:15:18 -0800784built_plat_sc := $(LOCAL_BUILT_MODULE)
785plat_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400786
Ying Wang02fb5f32012-01-17 17:51:09 -0800787##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400788include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800789LOCAL_MODULE := nonplat_seapp_contexts
Stephen Smalley37712872015-03-12 15:46:36 -0400790LOCAL_MODULE_CLASS := ETC
Dan Cashman9c038072016-12-22 07:15:18 -0800791LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800792ifeq ($(PRODUCT_FULL_TREBLE),true)
793LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
794else
Dan Cashman9c038072016-12-22 07:15:18 -0800795LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800796endif
Stephen Smalley37712872015-03-12 15:46:36 -0400797
798include $(BUILD_SYSTEM)/base_rules.mk
799
Alex Klyubin55961722017-01-30 18:44:59 -0800800nonplat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800801plat_sc_neverallow_files := $(addprefix $(PLAT_PRIVATE_POLICY)/, seapp_contexts)
Stephen Smalley37712872015-03-12 15:46:36 -0400802
Dan Cashman9c038072016-12-22 07:15:18 -0800803$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
804$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(nonplat_sc_files)
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800805$(LOCAL_BUILT_MODULE): PRIVATE_SC_NEVERALLOW_FILES := $(plat_sc_neverallow_files)
806$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(nonplat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp $(plat_sc_neverallow_files)
Stephen Smalley37712872015-03-12 15:46:36 -0400807 @mkdir -p $(dir $@)
Xin Liec6f3932017-03-14 16:51:13 -0700808 $(hide) grep -ie '^neverallow' $(PRIVATE_SC_NEVERALLOW_FILES) > $@.tmp
809 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES) $@.tmp
Stephen Smalley37712872015-03-12 15:46:36 -0400810
Dan Cashman9c038072016-12-22 07:15:18 -0800811built_nonplat_sc := $(LOCAL_BUILT_MODULE)
812nonplat_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400813
814##################################
815include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800816LOCAL_MODULE := plat_seapp_neverallows
William Roberts4ee71312015-06-25 11:59:30 -0700817LOCAL_MODULE_CLASS := ETC
818LOCAL_MODULE_TAGS := tests
819
820include $(BUILD_SYSTEM)/base_rules.mk
821
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800822$(LOCAL_BUILT_MODULE): $(plat_sc_neverallow_files)
William Roberts4ee71312015-06-25 11:59:30 -0700823 @mkdir -p $(dir $@)
824 - $(hide) grep -ie '^neverallow' $< > $@
825
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800826plat_sc_neverallow_files :=
William Roberts4ee71312015-06-25 11:59:30 -0700827
828##################################
829include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400830
Sandeep Patila86316e2016-12-27 16:08:44 -0800831LOCAL_MODULE := plat_property_contexts
Stephen Smalley124720a2012-04-04 10:11:16 -0400832LOCAL_MODULE_CLASS := ETC
833LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800834
835ifeq ($(PRODUCT_FULL_TREBLE),true)
836LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
837else
Stephen Smalley124720a2012-04-04 10:11:16 -0400838LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800839endif
Stephen Smalley124720a2012-04-04 10:11:16 -0400840
841include $(BUILD_SYSTEM)/base_rules.mk
842
Sandeep Patila86316e2016-12-27 16:08:44 -0800843plat_pcfiles := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts6aabc1c2015-07-30 11:44:26 -0700844
Sandeep Patila86316e2016-12-27 16:08:44 -0800845plat_property_contexts.tmp := $(intermediates)/plat_property_contexts.tmp
846$(plat_property_contexts.tmp): PRIVATE_PC_FILES := $(plat_pcfiles)
847$(plat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
848$(plat_property_contexts.tmp): $(plat_pcfiles)
William Roberts7f81b332015-09-29 13:52:37 -0700849 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000850 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700851$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila86316e2016-12-27 16:08:44 -0800852$(LOCAL_BUILT_MODULE): $(plat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700853 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800854 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800855 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400856
Sandeep Patila86316e2016-12-27 16:08:44 -0800857built_plat_pc := $(LOCAL_BUILT_MODULE)
858plat_pcfiles :=
859plat_property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400860
Stephen Smalley124720a2012-04-04 10:11:16 -0400861##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700862include $(CLEAR_VARS)
Sandeep Patila86316e2016-12-27 16:08:44 -0800863LOCAL_MODULE := nonplat_property_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400864LOCAL_MODULE_CLASS := ETC
Sandeep Patila86316e2016-12-27 16:08:44 -0800865LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800866
867ifeq ($(PRODUCT_FULL_TREBLE),true)
868LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
869else
Sandeep Patila86316e2016-12-27 16:08:44 -0800870LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800871endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400872
Stephen Smalleyc9361732015-03-13 09:36:57 -0400873include $(BUILD_SYSTEM)/base_rules.mk
874
Alex Klyubin55961722017-01-30 18:44:59 -0800875nonplat_pcfiles := $(call build_policy, property_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Sandeep Patil262edc32016-12-27 16:08:44 -0800876
Sandeep Patila86316e2016-12-27 16:08:44 -0800877nonplat_property_contexts.tmp := $(intermediates)/nonplat_property_contexts.tmp
878$(nonplat_property_contexts.tmp): PRIVATE_PC_FILES := $(nonplat_pcfiles)
879$(nonplat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
880$(nonplat_property_contexts.tmp): $(nonplat_pcfiles)
William Robertsdcffd2b2015-09-29 13:52:37 -0700881 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800882 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
883
884
885$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
886$(LOCAL_BUILT_MODULE): $(nonplat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
887 @mkdir -p $(dir $@)
888 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800889 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700890
Sandeep Patila86316e2016-12-27 16:08:44 -0800891built_nonplat_pc := $(LOCAL_BUILT_MODULE)
892nonplat_pcfiles :=
893nonplat_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400894
895##################################
896include $(CLEAR_VARS)
897
Alex Klyubinec78c372017-03-10 12:44:16 -0800898LOCAL_MODULE := plat_property_contexts.recovery
899LOCAL_MODULE_STEM := plat_property_contexts
900LOCAL_MODULE_CLASS := ETC
901LOCAL_MODULE_TAGS := optional
902LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
903
904include $(BUILD_SYSTEM)/base_rules.mk
905
906$(LOCAL_BUILT_MODULE): $(built_plat_pc)
907 $(hide) cp -f $< $@
908
909##################################
910include $(CLEAR_VARS)
Alex Klyubinec78c372017-03-10 12:44:16 -0800911LOCAL_MODULE := nonplat_property_contexts.recovery
912LOCAL_MODULE_STEM := nonplat_property_contexts
913LOCAL_MODULE_CLASS := ETC
914LOCAL_MODULE_TAGS := optional
915LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
916
917include $(BUILD_SYSTEM)/base_rules.mk
918
919$(LOCAL_BUILT_MODULE): $(built_nonplat_pc)
920 $(hide) cp -f $< $@
921
922##################################
923include $(CLEAR_VARS)
924
Sandeep Patila058b562016-12-27 15:10:48 -0800925LOCAL_MODULE := plat_service_contexts
Riley Spahnf90c41f2014-06-05 15:52:02 -0700926LOCAL_MODULE_CLASS := ETC
927LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800928ifeq ($(PRODUCT_FULL_TREBLE),true)
929LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
930else
Riley Spahnf90c41f2014-06-05 15:52:02 -0700931LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800932endif
Riley Spahnf90c41f2014-06-05 15:52:02 -0700933
934include $(BUILD_SYSTEM)/base_rules.mk
935
Sandeep Patila058b562016-12-27 15:10:48 -0800936plat_svcfiles := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700937
Sandeep Patila058b562016-12-27 15:10:48 -0800938plat_service_contexts.tmp := $(intermediates)/plat_service_contexts.tmp
939$(plat_service_contexts.tmp): PRIVATE_SVC_FILES := $(plat_svcfiles)
940$(plat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
941$(plat_service_contexts.tmp): $(plat_svcfiles)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700942 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700943 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700944
945$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila058b562016-12-27 15:10:48 -0800946$(LOCAL_BUILT_MODULE): $(plat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700947 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700948 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800949 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700950
Sandeep Patila058b562016-12-27 15:10:48 -0800951built_plat_svc := $(LOCAL_BUILT_MODULE)
952plat_svcfiles :=
953plat_service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700954
955##################################
rpcraigb19665c2012-07-30 09:33:03 -0400956include $(CLEAR_VARS)
957
Sandeep Patila058b562016-12-27 15:10:48 -0800958LOCAL_MODULE := nonplat_service_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400959LOCAL_MODULE_CLASS := ETC
Sandeep Patila058b562016-12-27 15:10:48 -0800960LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800961ifeq ($(PRODUCT_FULL_TREBLE),true)
962LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
963else
Sandeep Patila058b562016-12-27 15:10:48 -0800964LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800965endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400966
967include $(BUILD_SYSTEM)/base_rules.mk
968
Alex Klyubin55961722017-01-30 18:44:59 -0800969nonplat_svcfiles := $(call build_policy, service_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400970
Sandeep Patila058b562016-12-27 15:10:48 -0800971nonplat_service_contexts.tmp := $(intermediates)/nonplat_service_contexts.tmp
972$(nonplat_service_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_svcfiles)
973$(nonplat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
974$(nonplat_service_contexts.tmp): $(nonplat_svcfiles)
975 @mkdir -p $(dir $@)
976 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
977
978$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
979$(LOCAL_BUILT_MODULE): $(nonplat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700980 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700981 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800982 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700983
Sandeep Patila058b562016-12-27 15:10:48 -0800984built_nonplat_svc := $(LOCAL_BUILT_MODULE)
985nonplat_svcfiles :=
986nonplat_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400987
988##################################
989include $(CLEAR_VARS)
990
Martijn Coenen6676c232017-03-31 17:29:53 -0700991LOCAL_MODULE := vndservice_contexts
992LOCAL_MODULE_CLASS := ETC
993LOCAL_MODULE_TAGS := optional
994ifeq ($(PRODUCT_FULL_TREBLE),true)
995LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
996else
997LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
998endif
999
1000include $(BUILD_SYSTEM)/base_rules.mk
1001
1002vnd_svcfiles := $(call build_policy, vndservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1003
1004vndservice_contexts.tmp := $(intermediates)/vndservice_contexts.tmp
1005$(vndservice_contexts.tmp): PRIVATE_SVC_FILES := $(vnd_svcfiles)
1006$(vndservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1007$(vndservice_contexts.tmp): $(vnd_svcfiles)
1008 @mkdir -p $(dir $@)
1009 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1010
1011$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1012$(LOCAL_BUILT_MODULE): $(vndservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1013 @mkdir -p $(dir $@)
1014 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
Martijn Coenenee976622017-04-07 10:08:55 -07001015 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -v $(PRIVATE_SEPOLICY) $@
Martijn Coenen6676c232017-03-31 17:29:53 -07001016
1017vnd_svcfiles :=
1018vndservice_contexts.tmp :=
1019##################################
1020include $(CLEAR_VARS)
1021
dcashman90b3b942016-12-14 13:47:55 -08001022LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -04001023LOCAL_MODULE_CLASS := ETC
1024LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001025LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
rpcraigb19665c2012-07-30 09:33:03 -04001026
William Roberts2c8a55d2012-11-30 14:59:09 -08001027include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -04001028
Geremy Condracd4104e2013-03-26 18:19:12 +00001029# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -08001030plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
1031$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1032$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +00001033 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -07001034 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +00001035
dcashman90b3b942016-12-14 13:47:55 -08001036all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -04001037
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001038# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -08001039all_plat_keys := platform media shared testkey
1040all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001041
dcashman90b3b942016-12-14 13:47:55 -08001042$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
1043$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1044$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +00001045 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -07001046 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -07001047 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +00001048
William Roberts6aabc1c2015-07-30 11:44:26 -07001049all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -08001050all_plat_keys :=
1051plat_mac_perms_keys.tmp :=
1052
1053##################################
1054include $(CLEAR_VARS)
1055
1056LOCAL_MODULE := nonplat_mac_permissions.xml
1057LOCAL_MODULE_CLASS := ETC
1058LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001059LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman90b3b942016-12-14 13:47:55 -08001060
1061include $(BUILD_SYSTEM)/base_rules.mk
1062
1063# Build keys.conf
1064nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
1065$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Alex Klyubin55961722017-01-30 18:44:59 -08001066$(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 -08001067 @mkdir -p $(dir $@)
1068 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
1069
Alex Klyubin55961722017-01-30 18:44:59 -08001070all_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 -08001071
1072$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
1073$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1074$(all_nonplat_mac_perms_files)
1075 @mkdir -p $(dir $@)
1076 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
1077
1078nonplat_mac_perms_keys.tmp :=
1079all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -07001080
rpcraigb19665c2012-07-30 09:33:03 -04001081##################################
rpcraig47cd3962012-10-17 21:09:52 -04001082
Dan Cashman1c040272016-12-15 15:28:44 -08001083add_nl :=
William Roberts49693f12016-01-04 12:20:57 -08001084build_device_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001085build_policy :=
dcashmand225b692016-12-12 09:29:04 -08001086built_plat_fc :=
1087built_nonplat_fc :=
Richard Hainesc8801fe2015-12-11 10:39:19 +00001088built_nl :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001089built_plat_cil :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001090built_mapping_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001091built_plat_pc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001092built_nonplat_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001093built_nonplat_pc :=
Dan Cashman9c038072016-12-22 07:15:18 -08001094built_nonplat_sc :=
1095built_plat_sc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001096built_precompiled_sepolicy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001097built_sepolicy :=
Sandeep Patila058b562016-12-27 15:10:48 -08001098built_plat_svc :=
1099built_nonplat_svc :=
Dan Cashman1c040272016-12-15 15:28:44 -08001100mapping_policy_nvr :=
Dan Cashman1c040272016-12-15 15:28:44 -08001101my_target_arch :=
1102nonplat_policy_nvr :=
Dan Cashman1c040272016-12-15 15:28:44 -08001103plat_policy_nvr :=
dcashman1faa6442016-11-28 07:20:28 -08001104plat_pub_policy.cil :=
1105reqd_policy_mask.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -08001106sepolicy_build_files :=
Alex Klyubin7cda44f2017-03-21 14:28:53 -07001107sepolicy_build_cil_workaround_files :=
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001108with_asan :=
Alice Chucdfb06f2012-11-01 11:33:04 -07001109
1110include $(call all-makefiles-under,$(LOCAL_PATH))