blob: ccb66e5236711a200145cc598e1b4373be1edae9 [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.
Ian Pedowitz4816b8f2017-05-04 00:09:57 +000013sepolicy_major_vers := 26
Dan Cashman6f14f6b2017-04-07 16:36:23 -070014sepolicy_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
Dan Cashman1633da02017-05-23 14:47:16 -070083ifneq ( ,$(BOARD_PLAT_PUBLIC_SEPOLICY_DIR))
84ifneq (1, $(words $(BOARD_PLAT_PUBLIC_SEPOLICY_DIR)))
85$(error BOARD_PLAT_PUBLIC_SEPOLICY_DIR must only contain one directory)
86else
87PLAT_PUBLIC_POLICY += $(BOARD_PLAT_PUBLIC_SEPOLICY_DIR)
88endif
89endif
dcashmancc39f632016-07-22 13:13:11 -070090PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private
Dan Cashman1633da02017-05-23 14:47:16 -070091ifneq ( ,$(BOARD_PLAT_PRIVATE_SEPOLICY_DIR))
92ifneq (1, $(words $(BOARD_PLAT_PRIVATE_SEPOLICY_DIR)))
93$(error BOARD_PLAT_PRIVATE_SEPOLICY_DIR must only contain one directory)
94else
95PLAT_PRIVATE_POLICY += $(BOARD_PLAT_PRIVATE_SEPOLICY_DIR)
96endif
97endif
Alex Klyubin55961722017-01-30 18:44:59 -080098PLAT_VENDOR_POLICY := $(LOCAL_PATH)/vendor
dcashman2e00e632016-10-12 14:58:09 -070099REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask
100
101# TODO: move to README when doing the README update and finalizing versioning.
Sandeep Patil42f95982017-04-07 14:18:48 -0700102# BOARD_SEPOLICY_VERS must take the format "NN.m" and contain the sepolicy
103# version identifier corresponding to the sepolicy on which the non-platform
104# policy is to be based. If unspecified, this will build against the current
105# public platform policy in tree
dcashman2e00e632016-10-12 14:58:09 -0700106ifndef BOARD_SEPOLICY_VERS
107$(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version)
Sandeep Patil42f95982017-04-07 14:18:48 -0700108# The default platform policy version.
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700109BOARD_SEPOLICY_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman2e00e632016-10-12 14:58:09 -0700110endif
dcashmancc39f632016-07-22 13:13:11 -0700111
Dan Cashman4d24a772017-04-12 14:28:34 -0700112
113platform_mapping_file := $(BOARD_SEPOLICY_VERS).cil
114
dcashmancc39f632016-07-22 13:13:11 -0700115###########################################################
116# Compute policy files to be used in policy build.
117# $(1): files to include
118# $(2): directories in which to find files
119###########################################################
120
121define build_policy
122$(foreach type, $(1), $(foreach file, $(addsuffix /$(type), $(2)), $(sort $(wildcard $(file)))))
123endef
William Roberts29d14682016-01-04 12:20:57 -0800124
William Roberts49693f12016-01-04 12:20:57 -0800125# Builds paths for all policy files found in BOARD_SEPOLICY_DIRS.
126# $(1): the set of policy name paths to build
Alex Klyubin55961722017-01-30 18:44:59 -0800127build_device_policy = $(call build_policy, $(1), $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
William Roberts49693f12016-01-04 12:20:57 -0800128
Richard Hainesc8801fe2015-12-11 10:39:19 +0000129# Add a file containing only a newline in-between each policy configuration
130# 'contexts' file. This will allow OEM policy configuration files without a
131# final newline (0x0A) to be built correctly by the m4(1) macro processor.
132# $(1): the set of contexts file names.
133# $(2): the file containing only 0x0A.
134add_nl = $(foreach entry, $(1), $(subst $(entry), $(entry) $(2), $(entry)))
135
dcashman704741a2014-07-25 19:11:52 -0700136sepolicy_build_files := security_classes \
137 initial_sids \
138 access_vectors \
139 global_macros \
Nick Kralevicha17a2662014-11-05 15:30:41 -0800140 neverallow_macros \
dcashman704741a2014-07-25 19:11:52 -0700141 mls_macros \
dcashman2e00e632016-10-12 14:58:09 -0700142 mls_decl \
dcashman704741a2014-07-25 19:11:52 -0700143 mls \
144 policy_capabilities \
145 te_macros \
146 attributes \
Jeff Vander Stoepcbaa2b72015-12-22 10:39:34 -0800147 ioctl_defines \
Jeff Vander Stoepde9b5302015-06-05 15:28:55 -0700148 ioctl_macros \
dcashman704741a2014-07-25 19:11:52 -0700149 *.te \
dcashman2e00e632016-10-12 14:58:09 -0700150 roles_decl \
dcashman704741a2014-07-25 19:11:52 -0700151 roles \
152 users \
153 initial_sid_contexts \
154 fs_use \
155 genfs_contexts \
156 port_contexts
157
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700158# CIL files which contain workarounds for current limitation of human-readable
159# module policy language. These files are appended to the CIL files produced
160# from module language files.
161sepolicy_build_cil_workaround_files := technical_debt.cil
162
Dan Cashman1c040272016-12-15 15:28:44 -0800163my_target_arch := $(TARGET_ARCH)
164ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
165 my_target_arch := mips
166endif
167
Jeff Vander Stoepd2053bd2017-03-15 13:37:35 -0700168intermediates := $(TARGET_OUT_INTERMEDIATES)/ETC/sepolicy_intermediates
169
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700170with_asan := false
171ifneq (,$(filter address,$(SANITIZE_TARGET)))
172 with_asan := true
173endif
174
Dan Cashman4f9a6482017-04-10 12:27:18 -0700175include $(CLEAR_VARS)
176LOCAL_MODULE := selinux_policy
177LOCAL_MODULE_TAGS := optional
178# Include SELinux policy. We do this here because different modules
179# need to be included based on the value of PRODUCT_FULL_TREBLE. This
180# type of conditional inclusion cannot be done in top-level files such
181# as build/target/product/embedded.mk.
182# This conditional inclusion closely mimics the conditional logic
183# inside init/init.cpp for loading SELinux policy from files.
184ifeq ($(PRODUCT_FULL_TREBLE),true)
185
Dan Cashman4f9a6482017-04-10 12:27:18 -0700186# Use split SELinux policy
187LOCAL_REQUIRED_MODULES += \
188 $(platform_mapping_file) \
189 nonplat_sepolicy.cil \
190 plat_sepolicy.cil \
191 plat_and_mapping_sepolicy.cil.sha256 \
192 secilc \
193 nonplat_file_contexts \
194 plat_file_contexts \
195 plat_sepolicy_vers.txt
196
197# Include precompiled policy, unless told otherwise
198ifneq ($(PRODUCT_PRECOMPILED_SEPOLICY),false)
199LOCAL_REQUIRED_MODULES += precompiled_sepolicy precompiled_sepolicy.plat_and_mapping.sha256
200endif
201
202else
203# Use monolithic SELinux policy
204LOCAL_REQUIRED_MODULES += sepolicy \
205 file_contexts.bin
206endif
207include $(BUILD_PHONY_PACKAGE)
208
Ying Wang02fb5f32012-01-17 17:51:09 -0800209##################################
dcashman2e00e632016-10-12 14:58:09 -0700210# reqd_policy_mask - a policy.conf file which contains only the bare minimum
211# policy necessary to use checkpolicy. This bare-minimum policy needs to be
212# present in all policy.conf files, but should not necessarily be exported as
213# part of the public policy. The rules generated by reqd_policy_mask will allow
214# the compilation of public policy and subsequent removal of CIL policy that
215# should not be exported.
216
217reqd_policy_mask.conf := $(intermediates)/reqd_policy_mask.conf
218$(reqd_policy_mask.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
219$(reqd_policy_mask.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800220$(reqd_policy_mask.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700221$(reqd_policy_mask.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700222$(reqd_policy_mask.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
223$(reqd_policy_mask.conf): $(call build_policy, $(sepolicy_build_files), $(REQD_MASK_POLICY))
224 @mkdir -p $(dir $@)
225 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
226 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
227 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800228 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800229 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700230 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700231 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashman2e00e632016-10-12 14:58:09 -0700232 -s $^ > $@
233
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700234# b/37755687
235CHECKPOLICY_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0
236
dcashman2e00e632016-10-12 14:58:09 -0700237reqd_policy_mask.cil := $(intermediates)/reqd_policy_mask.cil
238$(reqd_policy_mask.cil): $(reqd_policy_mask.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy
239 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700240 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -C -M -c \
241 $(POLICYVERS) -o $@ $<
dcashman2e00e632016-10-12 14:58:09 -0700242
dcashman1faa6442016-11-28 07:20:28 -0800243reqd_policy_mask.conf :=
244
245##################################
dcashman2e00e632016-10-12 14:58:09 -0700246# plat_pub_policy - policy that will be exported to be a part of non-platform
247# policy corresponding to this platform version. This is a limited subset of
248# policy that would not compile in checkpolicy on its own. To get around this
249# limitation, add only the required files from private policy, which will
250# generate CIL policy that will then be filtered out by the reqd_policy_mask.
251plat_pub_policy.conf := $(intermediates)/plat_pub_policy.conf
252$(plat_pub_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
253$(plat_pub_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800254$(plat_pub_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700255$(plat_pub_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700256$(plat_pub_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
257$(plat_pub_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700258$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY))
dcashman2e00e632016-10-12 14:58:09 -0700259 @mkdir -p $(dir $@)
260 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
261 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
262 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800263 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800264 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700265 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700266 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashman2e00e632016-10-12 14:58:09 -0700267 -s $^ > $@
268
269plat_pub_policy.cil := $(intermediates)/plat_pub_policy.cil
dcashman1faa6442016-11-28 07:20:28 -0800270$(plat_pub_policy.cil): PRIVATE_POL_CONF := $(plat_pub_policy.conf)
271$(plat_pub_policy.cil): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
272$(plat_pub_policy.cil): $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_pub_policy.conf) $(reqd_policy_mask.cil)
dcashman2e00e632016-10-12 14:58:09 -0700273 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700274 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
dcashman1faa6442016-11-28 07:20:28 -0800275 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700276
dcashman1faa6442016-11-28 07:20:28 -0800277plat_pub_policy.conf :=
Dan Cashman1c040272016-12-15 15:28:44 -0800278
dcashman1faa6442016-11-28 07:20:28 -0800279##################################
280include $(CLEAR_VARS)
281
282LOCAL_MODULE := sectxfile_nl
283LOCAL_MODULE_CLASS := ETC
284LOCAL_MODULE_TAGS := optional
285
286# Create a file containing newline only to add between context config files
287include $(BUILD_SYSTEM)/base_rules.mk
288$(LOCAL_BUILT_MODULE):
dcashman2e00e632016-10-12 14:58:09 -0700289 @mkdir -p $(dir $@)
dcashman1faa6442016-11-28 07:20:28 -0800290 $(hide) echo > $@
291
292built_nl := $(LOCAL_BUILT_MODULE)
293
294#################################
295include $(CLEAR_VARS)
296
297LOCAL_MODULE := plat_sepolicy.cil
298LOCAL_MODULE_CLASS := ETC
299LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800300LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800301
302include $(BUILD_SYSTEM)/base_rules.mk
dcashman2e00e632016-10-12 14:58:09 -0700303
304# plat_policy.conf - A combination of the private and public platform policy
305# which will ship with the device. The platform will always reflect the most
306# recent platform version and is not currently being attributized.
307plat_policy.conf := $(intermediates)/plat_policy.conf
308$(plat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
309$(plat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800310$(plat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700311$(plat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700312$(plat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
313$(plat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
dcashmancc39f632016-07-22 13:13:11 -0700314$(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
315 @mkdir -p $(dir $@)
316 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
317 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
318 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500319 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800320 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700321 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700322 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
dcashmancc39f632016-07-22 13:13:11 -0700323 -s $^ > $@
324 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
325
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700326$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CIL_FILES := \
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700327 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700328$(LOCAL_BUILT_MODULE): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
329 $(HOST_OUT_EXECUTABLES)/secilc \
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700330 $(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
dcashman2e00e632016-10-12 14:58:09 -0700331 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700332 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c \
333 $(POLICYVERS) -o $@ $<
Alex Klyubin7cda44f2017-03-21 14:28:53 -0700334 $(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700335 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -N -c $(POLICYVERS) $@ -o /dev/null -f /dev/null
dcashman1faa6442016-11-28 07:20:28 -0800336
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800337built_plat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800338plat_policy.conf :=
339
340#################################
341include $(CLEAR_VARS)
342
Dan Cashman4f9a6482017-04-10 12:27:18 -0700343LOCAL_MODULE := plat_sepolicy_vers.txt
dcashman1faa6442016-11-28 07:20:28 -0800344LOCAL_MODULE_CLASS := ETC
345LOCAL_MODULE_TAGS := optional
Dan Cashman4f9a6482017-04-10 12:27:18 -0700346LOCAL_PROPRIETARY_MODULE := true
347LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
348
349include $(BUILD_SYSTEM)/base_rules.mk
350
351$(LOCAL_BUILT_MODULE) : PRIVATE_PLAT_SEPOL_VERS := $(BOARD_SEPOLICY_VERS)
352$(LOCAL_BUILT_MODULE) :
353 mkdir -p $(dir $@)
354 echo $(PRIVATE_PLAT_SEPOL_VERS) > $@
355
356#################################
357include $(CLEAR_VARS)
358
359LOCAL_MODULE := $(platform_mapping_file)
360LOCAL_MODULE_CLASS := ETC
361LOCAL_MODULE_TAGS := optional
362LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux/mapping
dcashman1faa6442016-11-28 07:20:28 -0800363
364include $(BUILD_SYSTEM)/base_rules.mk
365
Dan Cashmanf8937002017-05-08 14:26:52 -0700366current_mapping.cil := $(intermediates)/mapping/$(PLATFORM_SEPOLICY_VERSION).cil
367ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
dcashman1faa6442016-11-28 07:20:28 -0800368# auto-generate the mapping file for current platform policy, since it needs to
369# track platform policy development
Dan Cashman6f14f6b2017-04-07 16:36:23 -0700370$(current_mapping.cil) : PRIVATE_VERS := $(PLATFORM_SEPOLICY_VERSION)
dcashman1faa6442016-11-28 07:20:28 -0800371$(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy
372 @mkdir -p $(dir $@)
373 $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@
374
Dan Cashmanf8937002017-05-08 14:26:52 -0700375else # ifeq ($(BOARD_SEPOLICY_VERS), $(PLATFORM_SEPOLICY_VERSION))
376prebuilt_mapping_files := $(wildcard $(addsuffix /mapping/$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)))
377$(current_mapping.cil) : $(prebuilt_mapping_files)
378 @mkdir -p $(dir $@)
379 cat $^ > $@
Sandeep Patil42f95982017-04-07 14:18:48 -0700380
Dan Cashmanf8937002017-05-08 14:26:52 -0700381prebuilt_mapping_files :=
dcashman1faa6442016-11-28 07:20:28 -0800382endif
383
Dan Cashmanf8937002017-05-08 14:26:52 -0700384$(LOCAL_BUILT_MODULE): $(current_mapping.cil) $(ACP)
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700385 $(hide) $(ACP) $< $@
dcashman1faa6442016-11-28 07:20:28 -0800386
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800387built_mapping_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800388current_mapping.cil :=
389
390#################################
391include $(CLEAR_VARS)
392
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700393LOCAL_MODULE := plat_and_mapping_sepolicy.cil.sha256
394LOCAL_MODULE_CLASS := ETC
395LOCAL_MODULE_TAGS := optional
396LOCAL_MODULE_PATH = $(TARGET_OUT)/etc/selinux
397
398include $(BUILD_SYSTEM)/base_rules.mk
399
400$(LOCAL_BUILT_MODULE): $(built_plat_cil) $(built_mapping_cil)
401 cat $^ | sha256sum | cut -d' ' -f1 > $@
402
403#################################
404include $(CLEAR_VARS)
405
dcashman1faa6442016-11-28 07:20:28 -0800406LOCAL_MODULE := nonplat_sepolicy.cil
407LOCAL_MODULE_CLASS := ETC
408LOCAL_MODULE_TAGS := optional
Alex Klyubin052b0bb2017-03-02 12:39:25 -0800409LOCAL_PROPRIETARY_MODULE := true
410LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman1faa6442016-11-28 07:20:28 -0800411
412include $(BUILD_SYSTEM)/base_rules.mk
413
Alex Klyubin55961722017-01-30 18:44:59 -0800414# nonplat_policy.conf - A combination of the non-platform private, vendor and
415# the exported platform policy associated with the version the non-platform
416# policy targets. This needs attributization and to be combined with the
dcashman2e00e632016-10-12 14:58:09 -0700417# platform-provided policy. Like plat_pub_policy.conf, this needs to make use
418# of the reqd_policy_mask files from private policy in order to use checkpolicy.
419nonplat_policy.conf := $(intermediates)/nonplat_policy.conf
420$(nonplat_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
421$(nonplat_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
Dan Cashman1c040272016-12-15 15:28:44 -0800422$(nonplat_policy.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700423$(nonplat_policy.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
dcashman2e00e632016-10-12 14:58:09 -0700424$(nonplat_policy.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
425$(nonplat_policy.conf): $(call build_policy, $(sepolicy_build_files), \
Dan Cashman6bf50e52017-04-12 11:12:17 -0700426$(PLAT_PUBLIC_POLICY) $(REQD_MASK_POLICY) $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Ying Wang02fb5f32012-01-17 17:51:09 -0800427 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -0700428 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
429 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800430 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Jorge Lucangeli Obes84db84e2016-11-18 08:42:35 -0500431 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800432 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700433 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Alex Klyubinf5446eb2017-03-23 14:27:32 -0700434 -D target_full_treble=$(PRODUCT_FULL_TREBLE) \
Nick Kralevich623975f2014-01-11 01:31:03 -0800435 -s $^ > $@
Robert Craig65d4f442013-03-27 06:30:25 -0400436 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500437
dcashman1faa6442016-11-28 07:20:28 -0800438nonplat_policy_raw := $(intermediates)/nonplat_policy_raw.cil
439$(nonplat_policy_raw): PRIVATE_POL_CONF := $(nonplat_policy.conf)
440$(nonplat_policy_raw): PRIVATE_REQD_MASK := $(reqd_policy_mask.cil)
441$(nonplat_policy_raw): $(HOST_OUT_EXECUTABLES)/checkpolicy $(nonplat_policy.conf) \
442$(reqd_policy_mask.cil)
Ying Wang02fb5f32012-01-17 17:51:09 -0800443 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700444 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $< -C -M -c $(POLICYVERS) -o $@.tmp $(PRIVATE_POL_CONF)
dcashman1faa6442016-11-28 07:20:28 -0800445 $(hide) grep -Fxv -f $(PRIVATE_REQD_MASK) $@.tmp > $@
dcashman2e00e632016-10-12 14:58:09 -0700446
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700447$(LOCAL_BUILT_MODULE) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS)
448$(LOCAL_BUILT_MODULE) : PRIVATE_TGT_POL := $(nonplat_policy_raw)
449$(LOCAL_BUILT_MODULE) : PRIVATE_DEP_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
450$(LOCAL_BUILT_MODULE) : $(plat_pub_policy.cil) $(nonplat_policy_raw) \
451$(HOST_OUT_EXECUTABLES)/version_policy $(HOST_OUT_EXECUTABLES)/secilc \
Jeff Vander Stoep5edd96d2017-04-24 16:46:40 -0700452$(built_plat_cil) $(built_mapping_cil)
dcashman2e00e632016-10-12 14:58:09 -0700453 @mkdir -p $(dir $@)
454 $(HOST_OUT_EXECUTABLES)/version_policy -b $< -t $(PRIVATE_TGT_POL) -n $(PRIVATE_VERS) -o $@
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700455 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -N -c $(POLICYVERS) \
Alex Klyubin8f7173b2017-02-25 14:47:53 -0800456 $(PRIVATE_DEP_CIL_FILES) $@ -o /dev/null -f /dev/null
dcashman2e00e632016-10-12 14:58:09 -0700457
Alex Klyubin193dccd2017-03-07 14:05:57 -0800458built_nonplat_cil := $(LOCAL_BUILT_MODULE)
dcashman1faa6442016-11-28 07:20:28 -0800459nonplat_policy.conf :=
460nonplat_policy_raw :=
461
462#################################
463include $(CLEAR_VARS)
Alex Klyubin193dccd2017-03-07 14:05:57 -0800464
465LOCAL_MODULE := precompiled_sepolicy
466LOCAL_MODULE_CLASS := ETC
467LOCAL_MODULE_TAGS := optional
468LOCAL_PROPRIETARY_MODULE := true
469LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
470
471include $(BUILD_SYSTEM)/base_rules.mk
472
473$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := \
474$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
475$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc \
476$(built_plat_cil) $(built_mapping_cil) $(built_nonplat_cil)
Jeff Vander Stoepac171b42017-04-12 17:01:54 -0700477 $(hide) $(HOST_OUT_EXECUTABLES)/secilc -M true -G -c $(POLICYVERS) \
Alex Klyubin193dccd2017-03-07 14:05:57 -0800478 $(PRIVATE_CIL_FILES) -o $@ -f /dev/null
479
480built_precompiled_sepolicy := $(LOCAL_BUILT_MODULE)
481
482#################################
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700483# SHA-256 digest of the plat_sepolicy.cil and mapping_sepolicy.cil files against
484# which precompiled_policy was built.
Alex Klyubin193dccd2017-03-07 14:05:57 -0800485#################################
486include $(CLEAR_VARS)
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700487LOCAL_MODULE := precompiled_sepolicy.plat_and_mapping.sha256
Alex Klyubin193dccd2017-03-07 14:05:57 -0800488LOCAL_MODULE_CLASS := ETC
489LOCAL_MODULE_TAGS := optional
490LOCAL_PROPRIETARY_MODULE := true
491LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
492
493include $(BUILD_SYSTEM)/base_rules.mk
494
Dan Cashman0e9c47c2017-04-04 14:27:41 -0700495$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_plat_cil) $(built_mapping_cil)
496$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_plat_cil) $(built_mapping_cil)
497 cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@
Alex Klyubin193dccd2017-03-07 14:05:57 -0800498
499#################################
500include $(CLEAR_VARS)
Dan Cashman1c040272016-12-15 15:28:44 -0800501# build this target so that we can still perform neverallow checks
dcashman1faa6442016-11-28 07:20:28 -0800502
503LOCAL_MODULE := sepolicy
504LOCAL_MODULE_CLASS := ETC
505LOCAL_MODULE_TAGS := optional
Daniel Cashman65d01342016-12-17 00:53:26 +0000506LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
dcashman2e00e632016-10-12 14:58:09 -0700507
dcashman1faa6442016-11-28 07:20:28 -0800508include $(BUILD_SYSTEM)/base_rules.mk
509
dcashman2e00e632016-10-12 14:58:09 -0700510all_cil_files := \
Jeff Vander Stoepb8787692017-04-21 15:57:07 -0700511 $(built_plat_cil) \
512 $(built_mapping_cil) \
513 $(built_nonplat_cil)
dcashman2e00e632016-10-12 14:58:09 -0700514
515$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(all_cil_files)
516$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(all_cil_files)
517 @mkdir -p $(dir $@)
Jeff Vander Stoep748cae82017-04-13 14:16:29 -0700518 $(hide) $< -M true -G -c $(POLICYVERS) $(PRIVATE_CIL_FILES) -o $@.tmp -f /dev/null
Nick Kralevichbca98ef2016-02-26 20:06:52 -0800519 $(hide) $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $@.tmp permissive > $@.permissivedomains
520 $(hide) if [ "$(TARGET_BUILD_VARIANT)" = "user" -a -s $@.permissivedomains ]; then \
521 echo "==========" 1>&2; \
522 echo "ERROR: permissive domains not allowed in user builds" 1>&2; \
523 echo "List of invalid domains:" 1>&2; \
524 cat $@.permissivedomains 1>&2; \
525 exit 1; \
526 fi
527 $(hide) mv $@.tmp $@
Ying Wang02fb5f32012-01-17 17:51:09 -0800528
Ying Wangd8b122c2012-10-25 19:01:31 -0700529built_sepolicy := $(LOCAL_BUILT_MODULE)
dcashman2e00e632016-10-12 14:58:09 -0700530all_cil_files :=
Stephen Smalley01a58af2012-10-02 12:46:37 -0400531
Alex Klyubin84aa7422017-03-10 09:36:07 -0800532#################################
533include $(CLEAR_VARS)
534
535# keep concrete sepolicy for neverallow checks
536
537LOCAL_MODULE := sepolicy.recovery
Alex Klyubinec78c372017-03-10 12:44:16 -0800538LOCAL_MODULE_STEM := sepolicy
Alex Klyubin84aa7422017-03-10 09:36:07 -0800539LOCAL_MODULE_CLASS := ETC
540LOCAL_MODULE_TAGS := optional
Alex Klyubinec78c372017-03-10 12:44:16 -0800541LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
Alex Klyubin84aa7422017-03-10 09:36:07 -0800542
543include $(BUILD_SYSTEM)/base_rules.mk
544
Dan Cashmanc8d45352017-04-11 07:38:48 -0700545sepolicy.recovery.conf := $(intermediates)/sepolicy.recovery.conf
546$(sepolicy.recovery.conf): PRIVATE_MLS_SENS := $(MLS_SENS)
547$(sepolicy.recovery.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
548$(sepolicy.recovery.conf): PRIVATE_TGT_ARCH := $(my_target_arch)
549$(sepolicy.recovery.conf): PRIVATE_TGT_WITH_ASAN := $(with_asan)
550$(sepolicy.recovery.conf): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
551$(sepolicy.recovery.conf): $(call build_policy, $(sepolicy_build_files), \
552 $(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY) \
553 $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS))
Dan Cashman1c040272016-12-15 15:28:44 -0800554 @mkdir -p $(dir $@)
555 $(hide) m4 $(PRIVATE_ADDITIONAL_M4DEFS) \
556 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
557 -D target_build_variant=$(TARGET_BUILD_VARIANT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800558 -D target_with_dexpreopt=$(WITH_DEXPREOPT) \
Dan Cashman1c040272016-12-15 15:28:44 -0800559 -D target_arch=$(PRIVATE_TGT_ARCH) \
Jeff Vander Stoep74434842017-03-13 12:22:15 -0700560 -D target_with_asan=$(PRIVATE_TGT_WITH_ASAN) \
Dan Cashman1c040272016-12-15 15:28:44 -0800561 -D target_recovery=true \
562 -s $^ > $@
563 $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
564
Dan Cashmanc8d45352017-04-11 07:38:48 -0700565$(LOCAL_BUILT_MODULE): $(sepolicy.recovery.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
566 $(HOST_OUT_EXECUTABLES)/sepolicy-analyze
Dan Cashman1c040272016-12-15 15:28:44 -0800567 @mkdir -p $(dir $@)
Andreas Gampe3ddc78b2017-04-27 17:16:13 -0700568 $(hide) $(CHECKPOLICY_ASAN_OPTIONS) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c \
569 $(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
Dan Cashmanf8937002017-05-08 14:26:52 -0700636local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
637
William Roberts49693f12016-01-04 12:20:57 -0800638ifneq ($(filter address,$(SANITIZE_TARGET)),)
Dan Cashmanf8937002017-05-08 14:26:52 -0700639 local_fc_files := $(local_fc_files) $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
William Roberts49693f12016-01-04 12:20:57 -0800640endif
641local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
642
643file_contexts.local.tmp := $(intermediates)/file_contexts.local.tmp
644$(file_contexts.local.tmp): $(local_fcfiles_with_nl)
Stephen Smalley5b340be2012-03-06 11:12:41 -0500645 @mkdir -p $(dir $@)
William Roberts49693f12016-01-04 12:20:57 -0800646 $(hide) m4 -s $^ > $@
647
648device_fc_files := $(call build_device_policy, file_contexts)
649device_fcfiles_with_nl := $(call add_nl, $(device_fc_files), $(built_nl))
650
651file_contexts.device.tmp := $(intermediates)/file_contexts.device.tmp
652$(file_contexts.device.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
653$(file_contexts.device.tmp): $(device_fcfiles_with_nl)
654 @mkdir -p $(dir $@)
655 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
656
657file_contexts.device.sorted.tmp := $(intermediates)/file_contexts.device.sorted.tmp
658$(file_contexts.device.sorted.tmp): PRIVATE_SEPOLICY := $(built_sepolicy)
659$(file_contexts.device.sorted.tmp): $(file_contexts.device.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/fc_sort $(HOST_OUT_EXECUTABLES)/checkfc
660 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800661 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e $(PRIVATE_SEPOLICY) $<
William Roberts49693f12016-01-04 12:20:57 -0800662 $(hide) $(HOST_OUT_EXECUTABLES)/fc_sort $< $@
663
664file_contexts.concat.tmp := $(intermediates)/file_contexts.concat.tmp
665$(file_contexts.concat.tmp): $(file_contexts.local.tmp) $(file_contexts.device.sorted.tmp)
666 @mkdir -p $(dir $@)
667 $(hide) m4 -s $^ > $@
Stephen Smalley5b340be2012-03-06 11:12:41 -0500668
William Roberts3746a0a2015-09-25 10:18:44 -0700669$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
William Roberts49693f12016-01-04 12:20:57 -0800670$(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 +0100671 @mkdir -p $(dir $@)
dcashman07791552016-12-07 11:27:47 -0800672 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $<
Richard Hainesc2d01912015-08-06 17:43:52 +0100673 $(hide) $(HOST_OUT_EXECUTABLES)/sefcontext_compile -o $@ $<
674
Robert Craig8b7545b2014-03-20 09:35:08 -0400675built_fc := $(LOCAL_BUILT_MODULE)
William Roberts49693f12016-01-04 12:20:57 -0800676local_fc_files :=
677local_fcfiles_with_nl :=
678device_fc_files :=
679device_fcfiles_with_nl :=
680file_contexts.concat.tmp :=
681file_contexts.device.sorted.tmp :=
682file_contexts.device.tmp :=
683file_contexts.local.tmp :=
William Roberts171a0622012-08-16 10:55:05 -0700684
Ying Wang02fb5f32012-01-17 17:51:09 -0800685##################################
686include $(CLEAR_VARS)
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400687
Alex Klyubinec78c372017-03-10 12:44:16 -0800688LOCAL_MODULE := file_contexts.bin.recovery
689LOCAL_MODULE_STEM := file_contexts.bin
690LOCAL_MODULE_CLASS := ETC
691LOCAL_MODULE_TAGS := optional
692LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
693
694include $(BUILD_SYSTEM)/base_rules.mk
695
696$(LOCAL_BUILT_MODULE): $(built_fc)
697 $(hide) cp -f $< $@
698
699##################################
700include $(CLEAR_VARS)
701
dcashmand225b692016-12-12 09:29:04 -0800702LOCAL_MODULE := plat_file_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400703LOCAL_MODULE_CLASS := ETC
dcashmand225b692016-12-12 09:29:04 -0800704LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800705LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400706
707include $(BUILD_SYSTEM)/base_rules.mk
708
Dan Cashmanf8937002017-05-08 14:26:52 -0700709local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
dcashmand225b692016-12-12 09:29:04 -0800710ifneq ($(filter address,$(SANITIZE_TARGET)),)
Dan Cashman5e9451b2017-05-10 17:25:14 -0700711 local_fc_files += $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
dcashmand225b692016-12-12 09:29:04 -0800712endif
Alex Klyubine4665d72017-01-19 19:58:34 -0800713local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400714
Alex Klyubine4665d72017-01-19 19:58:34 -0800715$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl)
dcashmand225b692016-12-12 09:29:04 -0800716$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Alex Klyubine4665d72017-01-19 19:58:34 -0800717$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
718$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
719$(local_fcfiles_with_nl) $(built_sepolicy)
Richard Hainesc2d01912015-08-06 17:43:52 +0100720 @mkdir -p $(dir $@)
Alex Klyubine4665d72017-01-19 19:58:34 -0800721 $(hide) m4 -s $(PRIVATE_FC_FILES) > $@.tmp
722 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
723 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
Richard Hainesc2d01912015-08-06 17:43:52 +0100724
dcashmand225b692016-12-12 09:29:04 -0800725built_plat_fc := $(LOCAL_BUILT_MODULE)
726local_fc_files :=
Alex Klyubine4665d72017-01-19 19:58:34 -0800727local_fcfiles_with_nl :=
dcashmand225b692016-12-12 09:29:04 -0800728
729##################################
730include $(CLEAR_VARS)
731
732LOCAL_MODULE := nonplat_file_contexts
733LOCAL_MODULE_CLASS := ETC
734LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep0cb417a2017-03-08 14:12:54 -0800735LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashmand225b692016-12-12 09:29:04 -0800736
737include $(BUILD_SYSTEM)/base_rules.mk
738
739nonplat_fc_files := $(call build_device_policy, file_contexts)
740nonplat_fcfiles_with_nl := $(call add_nl, $(nonplat_fc_files), $(built_nl))
741
742$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(nonplat_fcfiles_with_nl)
743$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
744$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
745$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
Alex Klyubine4665d72017-01-19 19:58:34 -0800746$(nonplat_fcfiles_with_nl) $(built_sepolicy)
dcashmand225b692016-12-12 09:29:04 -0800747 @mkdir -p $(dir $@)
748 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > $@.tmp
749 $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp
750 $(hide) $(PRIVATE_FC_SORT) $@.tmp $@
751
752built_nonplat_fc := $(LOCAL_BUILT_MODULE)
753nonplat_fc_files :=
754nonplat_fcfiles_with_nl :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400755
756##################################
757include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800758LOCAL_MODULE := plat_seapp_contexts
Ying Wang02fb5f32012-01-17 17:51:09 -0800759LOCAL_MODULE_CLASS := ETC
760LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800761ifeq ($(PRODUCT_FULL_TREBLE),true)
762LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
763else
Ying Wang02fb5f32012-01-17 17:51:09 -0800764LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800765endif
Ying Wang02fb5f32012-01-17 17:51:09 -0800766
William Roberts171a0622012-08-16 10:55:05 -0700767include $(BUILD_SYSTEM)/base_rules.mk
Ying Wang02fb5f32012-01-17 17:51:09 -0800768
Dan Cashman9c038072016-12-22 07:15:18 -0800769plat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts171a0622012-08-16 10:55:05 -0700770
Ying Wangd8b122c2012-10-25 19:01:31 -0700771$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Dan Cashman9c038072016-12-22 07:15:18 -0800772$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(plat_sc_files)
773$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(plat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp
William Robertsf0e0a942012-08-27 15:41:15 -0700774 @mkdir -p $(dir $@)
William Roberts99fe8df2015-06-30 13:53:51 -0700775 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES)
Ying Wang02fb5f32012-01-17 17:51:09 -0800776
Dan Cashman9c038072016-12-22 07:15:18 -0800777built_plat_sc := $(LOCAL_BUILT_MODULE)
778plat_sc_files :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400779
Ying Wang02fb5f32012-01-17 17:51:09 -0800780##################################
Stephen Smalley124720a2012-04-04 10:11:16 -0400781include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800782LOCAL_MODULE := nonplat_seapp_contexts
Stephen Smalley37712872015-03-12 15:46:36 -0400783LOCAL_MODULE_CLASS := ETC
Dan Cashman9c038072016-12-22 07:15:18 -0800784LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800785ifeq ($(PRODUCT_FULL_TREBLE),true)
786LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
787else
Dan Cashman9c038072016-12-22 07:15:18 -0800788LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800789endif
Stephen Smalley37712872015-03-12 15:46:36 -0400790
791include $(BUILD_SYSTEM)/base_rules.mk
792
Alex Klyubin55961722017-01-30 18:44:59 -0800793nonplat_sc_files := $(call build_policy, seapp_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Dan Cashmanf8937002017-05-08 14:26:52 -0700794plat_sc_neverallow_files := $(call build_policy, seapp_contexts, $(PLAT_PRIVATE_POLICY))
Stephen Smalley37712872015-03-12 15:46:36 -0400795
Dan Cashman9c038072016-12-22 07:15:18 -0800796$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
797$(LOCAL_BUILT_MODULE): PRIVATE_SC_FILES := $(nonplat_sc_files)
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800798$(LOCAL_BUILT_MODULE): PRIVATE_SC_NEVERALLOW_FILES := $(plat_sc_neverallow_files)
799$(LOCAL_BUILT_MODULE): $(built_sepolicy) $(nonplat_sc_files) $(HOST_OUT_EXECUTABLES)/checkseapp $(plat_sc_neverallow_files)
Stephen Smalley37712872015-03-12 15:46:36 -0400800 @mkdir -p $(dir $@)
Xin Liec6f3932017-03-14 16:51:13 -0700801 $(hide) grep -ie '^neverallow' $(PRIVATE_SC_NEVERALLOW_FILES) > $@.tmp
802 $(hide) $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $(PRIVATE_SC_FILES) $@.tmp
Stephen Smalley37712872015-03-12 15:46:36 -0400803
Dan Cashman9c038072016-12-22 07:15:18 -0800804built_nonplat_sc := $(LOCAL_BUILT_MODULE)
805nonplat_sc_files :=
Stephen Smalley37712872015-03-12 15:46:36 -0400806
807##################################
808include $(CLEAR_VARS)
Dan Cashman9c038072016-12-22 07:15:18 -0800809LOCAL_MODULE := plat_seapp_neverallows
William Roberts4ee71312015-06-25 11:59:30 -0700810LOCAL_MODULE_CLASS := ETC
811LOCAL_MODULE_TAGS := tests
812
813include $(BUILD_SYSTEM)/base_rules.mk
814
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800815$(LOCAL_BUILT_MODULE): $(plat_sc_neverallow_files)
William Roberts4ee71312015-06-25 11:59:30 -0700816 @mkdir -p $(dir $@)
817 - $(hide) grep -ie '^neverallow' $< > $@
818
Jeff Vander Stoep87ae5f72017-03-06 22:53:09 -0800819plat_sc_neverallow_files :=
William Roberts4ee71312015-06-25 11:59:30 -0700820
821##################################
822include $(CLEAR_VARS)
Stephen Smalley124720a2012-04-04 10:11:16 -0400823
Sandeep Patila86316e2016-12-27 16:08:44 -0800824LOCAL_MODULE := plat_property_contexts
Stephen Smalley124720a2012-04-04 10:11:16 -0400825LOCAL_MODULE_CLASS := ETC
826LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800827
828ifeq ($(PRODUCT_FULL_TREBLE),true)
829LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
830else
Stephen Smalley124720a2012-04-04 10:11:16 -0400831LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800832endif
Stephen Smalley124720a2012-04-04 10:11:16 -0400833
834include $(BUILD_SYSTEM)/base_rules.mk
835
Sandeep Patila86316e2016-12-27 16:08:44 -0800836plat_pcfiles := $(call build_policy, property_contexts, $(PLAT_PRIVATE_POLICY))
William Roberts6aabc1c2015-07-30 11:44:26 -0700837
Sandeep Patila86316e2016-12-27 16:08:44 -0800838plat_property_contexts.tmp := $(intermediates)/plat_property_contexts.tmp
839$(plat_property_contexts.tmp): PRIVATE_PC_FILES := $(plat_pcfiles)
840$(plat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
841$(plat_property_contexts.tmp): $(plat_pcfiles)
William Roberts7f81b332015-09-29 13:52:37 -0700842 @mkdir -p $(dir $@)
Colin Cross9eb6c872015-10-01 21:25:09 +0000843 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700844$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila86316e2016-12-27 16:08:44 -0800845$(LOCAL_BUILT_MODULE): $(plat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
William Robertsdcffd2b2015-09-29 13:52:37 -0700846 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800847 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800848 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
Stephen Smalley124720a2012-04-04 10:11:16 -0400849
Sandeep Patila86316e2016-12-27 16:08:44 -0800850built_plat_pc := $(LOCAL_BUILT_MODULE)
851plat_pcfiles :=
852plat_property_contexts.tmp :=
Robert Craig8b7545b2014-03-20 09:35:08 -0400853
Stephen Smalley124720a2012-04-04 10:11:16 -0400854##################################
Riley Spahnf90c41f2014-06-05 15:52:02 -0700855include $(CLEAR_VARS)
Sandeep Patila86316e2016-12-27 16:08:44 -0800856LOCAL_MODULE := nonplat_property_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400857LOCAL_MODULE_CLASS := ETC
Sandeep Patila86316e2016-12-27 16:08:44 -0800858LOCAL_MODULE_TAGS := optional
Alex Klyubin9d590412017-03-08 13:10:05 -0800859
860ifeq ($(PRODUCT_FULL_TREBLE),true)
861LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
862else
Sandeep Patila86316e2016-12-27 16:08:44 -0800863LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Alex Klyubin9d590412017-03-08 13:10:05 -0800864endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400865
Stephen Smalleyc9361732015-03-13 09:36:57 -0400866include $(BUILD_SYSTEM)/base_rules.mk
867
Alex Klyubin55961722017-01-30 18:44:59 -0800868nonplat_pcfiles := $(call build_policy, property_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Sandeep Patil262edc32016-12-27 16:08:44 -0800869
Sandeep Patila86316e2016-12-27 16:08:44 -0800870nonplat_property_contexts.tmp := $(intermediates)/nonplat_property_contexts.tmp
871$(nonplat_property_contexts.tmp): PRIVATE_PC_FILES := $(nonplat_pcfiles)
872$(nonplat_property_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
873$(nonplat_property_contexts.tmp): $(nonplat_pcfiles)
William Robertsdcffd2b2015-09-29 13:52:37 -0700874 @mkdir -p $(dir $@)
Sandeep Patila86316e2016-12-27 16:08:44 -0800875 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_PC_FILES) > $@
876
877
878$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
879$(LOCAL_BUILT_MODULE): $(nonplat_property_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc
880 @mkdir -p $(dir $@)
881 $(hide) sed -e 's/#.*$$//' -e '/^$$/d' $< | sort -u -o $@
dcashman07791552016-12-07 11:27:47 -0800882 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -p $(PRIVATE_SEPOLICY) $@
William Robertsdcffd2b2015-09-29 13:52:37 -0700883
Sandeep Patila86316e2016-12-27 16:08:44 -0800884built_nonplat_pc := $(LOCAL_BUILT_MODULE)
885nonplat_pcfiles :=
886nonplat_property_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400887
888##################################
889include $(CLEAR_VARS)
890
Alex Klyubinec78c372017-03-10 12:44:16 -0800891LOCAL_MODULE := plat_property_contexts.recovery
892LOCAL_MODULE_STEM := plat_property_contexts
893LOCAL_MODULE_CLASS := ETC
894LOCAL_MODULE_TAGS := optional
895LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
896
897include $(BUILD_SYSTEM)/base_rules.mk
898
899$(LOCAL_BUILT_MODULE): $(built_plat_pc)
900 $(hide) cp -f $< $@
901
902##################################
903include $(CLEAR_VARS)
Alex Klyubinec78c372017-03-10 12:44:16 -0800904LOCAL_MODULE := nonplat_property_contexts.recovery
905LOCAL_MODULE_STEM := nonplat_property_contexts
906LOCAL_MODULE_CLASS := ETC
907LOCAL_MODULE_TAGS := optional
908LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
909
910include $(BUILD_SYSTEM)/base_rules.mk
911
912$(LOCAL_BUILT_MODULE): $(built_nonplat_pc)
913 $(hide) cp -f $< $@
914
915##################################
916include $(CLEAR_VARS)
917
Sandeep Patila058b562016-12-27 15:10:48 -0800918LOCAL_MODULE := plat_service_contexts
Riley Spahnf90c41f2014-06-05 15:52:02 -0700919LOCAL_MODULE_CLASS := ETC
920LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800921ifeq ($(PRODUCT_FULL_TREBLE),true)
922LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
923else
Riley Spahnf90c41f2014-06-05 15:52:02 -0700924LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800925endif
Riley Spahnf90c41f2014-06-05 15:52:02 -0700926
927include $(BUILD_SYSTEM)/base_rules.mk
928
Sandeep Patila058b562016-12-27 15:10:48 -0800929plat_svcfiles := $(call build_policy, service_contexts, $(PLAT_PRIVATE_POLICY))
Riley Spahnf90c41f2014-06-05 15:52:02 -0700930
Sandeep Patila058b562016-12-27 15:10:48 -0800931plat_service_contexts.tmp := $(intermediates)/plat_service_contexts.tmp
932$(plat_service_contexts.tmp): PRIVATE_SVC_FILES := $(plat_svcfiles)
933$(plat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
934$(plat_service_contexts.tmp): $(plat_svcfiles)
Riley Spahnf90c41f2014-06-05 15:52:02 -0700935 @mkdir -p $(dir $@)
William Roberts6aabc1c2015-07-30 11:44:26 -0700936 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
William Roberts7fc865a2015-09-29 14:17:38 -0700937
938$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
Sandeep Patila058b562016-12-27 15:10:48 -0800939$(LOCAL_BUILT_MODULE): $(plat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700940 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700941 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800942 $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
Riley Spahnf90c41f2014-06-05 15:52:02 -0700943
Sandeep Patila058b562016-12-27 15:10:48 -0800944built_plat_svc := $(LOCAL_BUILT_MODULE)
945plat_svcfiles :=
946plat_service_contexts.tmp :=
Riley Spahnf90c41f2014-06-05 15:52:02 -0700947
948##################################
rpcraigb19665c2012-07-30 09:33:03 -0400949include $(CLEAR_VARS)
950
Sandeep Patila058b562016-12-27 15:10:48 -0800951LOCAL_MODULE := nonplat_service_contexts
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400952LOCAL_MODULE_CLASS := ETC
Sandeep Patila058b562016-12-27 15:10:48 -0800953LOCAL_MODULE_TAGS := optional
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800954ifeq ($(PRODUCT_FULL_TREBLE),true)
955LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
956else
Sandeep Patila058b562016-12-27 15:10:48 -0800957LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
Jeff Vander Stoep4e3a4c72017-03-08 22:28:03 -0800958endif
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400959
960include $(BUILD_SYSTEM)/base_rules.mk
961
Alex Klyubin55961722017-01-30 18:44:59 -0800962nonplat_svcfiles := $(call build_policy, service_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400963
Sandeep Patila058b562016-12-27 15:10:48 -0800964nonplat_service_contexts.tmp := $(intermediates)/nonplat_service_contexts.tmp
965$(nonplat_service_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_svcfiles)
966$(nonplat_service_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
967$(nonplat_service_contexts.tmp): $(nonplat_svcfiles)
968 @mkdir -p $(dir $@)
969 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
970
971$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
972$(LOCAL_BUILT_MODULE): $(nonplat_service_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
William Roberts7fc865a2015-09-29 14:17:38 -0700973 @mkdir -p $(dir $@)
William Robertsc9fce3f2016-04-06 11:53:04 -0700974 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
dcashman07791552016-12-07 11:27:47 -0800975 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -s $(PRIVATE_SEPOLICY) $@
William Roberts7fc865a2015-09-29 14:17:38 -0700976
Sandeep Patila058b562016-12-27 15:10:48 -0800977built_nonplat_svc := $(LOCAL_BUILT_MODULE)
978nonplat_svcfiles :=
979nonplat_service_contexts.tmp :=
Stephen Smalley2e0cd5a2015-03-12 17:45:03 -0400980
981##################################
982include $(CLEAR_VARS)
983
Martijn Coenen3ea47b92017-04-07 16:14:43 -0700984LOCAL_MODULE := plat_hwservice_contexts
985LOCAL_MODULE_CLASS := ETC
986LOCAL_MODULE_TAGS := optional
987ifeq ($(PRODUCT_FULL_TREBLE),true)
988LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
989else
990LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
991endif
992
993include $(BUILD_SYSTEM)/base_rules.mk
994
995plat_hwsvcfiles := $(call build_policy, hwservice_contexts, $(PLAT_PRIVATE_POLICY))
996
997plat_hwservice_contexts.tmp := $(intermediates)/plat_hwservice_contexts.tmp
998$(plat_hwservice_contexts.tmp): PRIVATE_SVC_FILES := $(plat_hwsvcfiles)
999$(plat_hwservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1000$(plat_hwservice_contexts.tmp): $(plat_hwsvcfiles)
1001 @mkdir -p $(dir $@)
1002 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1003
1004$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1005$(LOCAL_BUILT_MODULE): $(plat_hwservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1006 @mkdir -p $(dir $@)
1007 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
1008 $(HOST_OUT_EXECUTABLES)/checkfc -e -l $(PRIVATE_SEPOLICY) $@
1009
1010plat_hwsvcfiles :=
1011plat_hwservice_contexts.tmp :=
1012
1013##################################
1014include $(CLEAR_VARS)
1015
1016LOCAL_MODULE := nonplat_hwservice_contexts
1017LOCAL_MODULE_CLASS := ETC
1018LOCAL_MODULE_TAGS := optional
1019ifeq ($(PRODUCT_FULL_TREBLE),true)
1020LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
1021else
1022LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1023endif
1024
1025include $(BUILD_SYSTEM)/base_rules.mk
1026
1027nonplat_hwsvcfiles := $(call build_policy, hwservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1028
1029nonplat_hwservice_contexts.tmp := $(intermediates)/nonplat_hwservice_contexts.tmp
1030$(nonplat_hwservice_contexts.tmp): PRIVATE_SVC_FILES := $(nonplat_hwsvcfiles)
1031$(nonplat_hwservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1032$(nonplat_hwservice_contexts.tmp): $(nonplat_hwsvcfiles)
1033 @mkdir -p $(dir $@)
1034 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1035
1036$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1037$(LOCAL_BUILT_MODULE): $(nonplat_hwservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1038 @mkdir -p $(dir $@)
1039 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
1040 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -l $(PRIVATE_SEPOLICY) $@
1041
1042nonplat_hwsvcfiles :=
1043nonplat_hwservice_contexts.tmp :=
1044
1045##################################
1046include $(CLEAR_VARS)
1047
Martijn Coenen6676c232017-03-31 17:29:53 -07001048LOCAL_MODULE := vndservice_contexts
1049LOCAL_MODULE_CLASS := ETC
1050LOCAL_MODULE_TAGS := optional
1051ifeq ($(PRODUCT_FULL_TREBLE),true)
1052LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
1053else
1054LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
1055endif
1056
1057include $(BUILD_SYSTEM)/base_rules.mk
1058
1059vnd_svcfiles := $(call build_policy, vndservice_contexts, $(PLAT_VENDOR_POLICY) $(BOARD_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
1060
1061vndservice_contexts.tmp := $(intermediates)/vndservice_contexts.tmp
1062$(vndservice_contexts.tmp): PRIVATE_SVC_FILES := $(vnd_svcfiles)
1063$(vndservice_contexts.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1064$(vndservice_contexts.tmp): $(vnd_svcfiles)
1065 @mkdir -p $(dir $@)
1066 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_SVC_FILES) > $@
1067
1068$(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
1069$(LOCAL_BUILT_MODULE): $(vndservice_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc $(ACP)
1070 @mkdir -p $(dir $@)
1071 sed -e 's/#.*$$//' -e '/^$$/d' $< > $@
Martijn Coenenee976622017-04-07 10:08:55 -07001072 $(hide) $(HOST_OUT_EXECUTABLES)/checkfc -e -v $(PRIVATE_SEPOLICY) $@
Martijn Coenen6676c232017-03-31 17:29:53 -07001073
1074vnd_svcfiles :=
1075vndservice_contexts.tmp :=
1076##################################
1077include $(CLEAR_VARS)
1078
dcashman90b3b942016-12-14 13:47:55 -08001079LOCAL_MODULE := plat_mac_permissions.xml
rpcraigb19665c2012-07-30 09:33:03 -04001080LOCAL_MODULE_CLASS := ETC
1081LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001082LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
rpcraigb19665c2012-07-30 09:33:03 -04001083
William Roberts2c8a55d2012-11-30 14:59:09 -08001084include $(BUILD_SYSTEM)/base_rules.mk
rpcraigb19665c2012-07-30 09:33:03 -04001085
Geremy Condracd4104e2013-03-26 18:19:12 +00001086# Build keys.conf
dcashman90b3b942016-12-14 13:47:55 -08001087plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
1088$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
1089$(plat_mac_perms_keys.tmp): $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY))
Geremy Condracd4104e2013-03-26 18:19:12 +00001090 @mkdir -p $(dir $@)
William Robertsd2185582015-07-16 11:28:02 -07001091 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
Geremy Condracd4104e2013-03-26 18:19:12 +00001092
dcashman90b3b942016-12-14 13:47:55 -08001093all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
rpcraigb19665c2012-07-30 09:33:03 -04001094
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001095# Should be synced with keys.conf.
dcashman90b3b942016-12-14 13:47:55 -08001096all_plat_keys := platform media shared testkey
1097all_plat_keys := $(all_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
Shinichiro Hamajief0c14d2016-05-13 16:04:58 +09001098
dcashman90b3b942016-12-14 13:47:55 -08001099$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
1100$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1101$(all_plat_mac_perms_files) $(all_plat_keys)
Geremy Condracd4104e2013-03-26 18:19:12 +00001102 @mkdir -p $(dir $@)
Nick Kralevichc3c90522013-10-25 12:25:36 -07001103 $(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
William Roberts6aabc1c2015-07-30 11:44:26 -07001104 $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
Geremy Condracd4104e2013-03-26 18:19:12 +00001105
William Roberts6aabc1c2015-07-30 11:44:26 -07001106all_mac_perms_files :=
dcashman90b3b942016-12-14 13:47:55 -08001107all_plat_keys :=
1108plat_mac_perms_keys.tmp :=
1109
1110##################################
1111include $(CLEAR_VARS)
1112
1113LOCAL_MODULE := nonplat_mac_permissions.xml
1114LOCAL_MODULE_CLASS := ETC
1115LOCAL_MODULE_TAGS := optional
Jeff Vander Stoepbba9e7b2017-03-10 15:51:23 -08001116LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
dcashman90b3b942016-12-14 13:47:55 -08001117
1118include $(BUILD_SYSTEM)/base_rules.mk
1119
1120# Build keys.conf
1121nonplat_mac_perms_keys.tmp := $(intermediates)/nonplat_keys.tmp
1122$(nonplat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
Alex Klyubin55961722017-01-30 18:44:59 -08001123$(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 -08001124 @mkdir -p $(dir $@)
1125 $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $^ > $@
1126
Alex Klyubin55961722017-01-30 18:44:59 -08001127all_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 -08001128
1129$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_nonplat_mac_perms_files)
1130$(LOCAL_BUILT_MODULE): $(nonplat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
1131$(all_nonplat_mac_perms_files)
1132 @mkdir -p $(dir $@)
1133 $(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
1134
1135nonplat_mac_perms_keys.tmp :=
1136all_nonplat_mac_perms_files :=
William Roberts6aabc1c2015-07-30 11:44:26 -07001137
rpcraigb19665c2012-07-30 09:33:03 -04001138##################################
rpcraig47cd3962012-10-17 21:09:52 -04001139
Dan Cashman1c040272016-12-15 15:28:44 -08001140add_nl :=
William Roberts49693f12016-01-04 12:20:57 -08001141build_device_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001142build_policy :=
dcashmand225b692016-12-12 09:29:04 -08001143built_plat_fc :=
1144built_nonplat_fc :=
Richard Hainesc8801fe2015-12-11 10:39:19 +00001145built_nl :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001146built_plat_cil :=
Alex Klyubin8f7173b2017-02-25 14:47:53 -08001147built_mapping_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001148built_plat_pc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001149built_nonplat_cil :=
Sandeep Patila86316e2016-12-27 16:08:44 -08001150built_nonplat_pc :=
Dan Cashman9c038072016-12-22 07:15:18 -08001151built_nonplat_sc :=
1152built_plat_sc :=
Alex Klyubin193dccd2017-03-07 14:05:57 -08001153built_precompiled_sepolicy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001154built_sepolicy :=
Sandeep Patila058b562016-12-27 15:10:48 -08001155built_plat_svc :=
1156built_nonplat_svc :=
Jeff Vander Stoepb8787692017-04-21 15:57:07 -07001157mapping_policy :=
Dan Cashman1c040272016-12-15 15:28:44 -08001158my_target_arch :=
dcashman1faa6442016-11-28 07:20:28 -08001159plat_pub_policy.cil :=
1160reqd_policy_mask.cil :=
Dan Cashman1c040272016-12-15 15:28:44 -08001161sepolicy_build_files :=
Alex Klyubin7cda44f2017-03-21 14:28:53 -07001162sepolicy_build_cil_workaround_files :=
Jeff Vander Stoep74434842017-03-13 12:22:15 -07001163with_asan :=
Alice Chucdfb06f2012-11-01 11:33:04 -07001164
1165include $(call all-makefiles-under,$(LOCAL_PATH))