diff --git a/Android.bp b/Android.bp index 3c99744ab..1ec7570b7 100644 --- a/Android.bp +++ b/Android.bp @@ -845,6 +845,63 @@ sepolicy_vers { vendor: true, } +soong_config_module_type { + name: "precompiled_sepolicy_defaults", + module_type: "prebuilt_defaults", + config_namespace: "ANDROID", + bool_variables: ["BOARD_USES_ODMIMAGE"], + properties: ["vendor", "device_specific"], +} + +precompiled_sepolicy_defaults { + name: "precompiled_sepolicy", + soong_config_variables: { + BOARD_USES_ODMIMAGE: { + device_specific: true, + conditions_default: { + vendor: true, + }, + }, + }, +} + +////////////////////////////////// +// SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against +// which precompiled_policy was built. +////////////////////////////////// +prebuilt_etc { + defaults: ["precompiled_sepolicy"], + name: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256", + filename: "precompiled_sepolicy.plat_sepolicy_and_mapping.sha256", + src: ":plat_sepolicy_and_mapping.sha256_gen", + relative_install_path: "selinux", +} + +////////////////////////////////// +// SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against +// which precompiled_policy was built. +////////////////////////////////// +prebuilt_etc { + defaults: ["precompiled_sepolicy"], + name: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256", + filename: "precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256", + src: ":system_ext_sepolicy_and_mapping.sha256_gen", + relative_install_path: "selinux", +} + +////////////////////////////////// +// SHA-256 digest of the product_sepolicy.cil and product_mapping_file against +// which precompiled_policy was built. +////////////////////////////////// +prebuilt_etc { + defaults: ["precompiled_sepolicy"], + name: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256", + filename: "precompiled_sepolicy.product_sepolicy_and_mapping.sha256", + src: ":product_sepolicy_and_mapping.sha256_gen", + relative_install_path: "selinux", +} + + ////////////////////////////////// // SELinux policy embedded into CTS. // CTS checks neverallow rules of this policy against the policy of the device under test. diff --git a/Android.mk b/Android.mk index 3384af3dd..882f397b2 100644 --- a/Android.mk +++ b/Android.mk @@ -1002,78 +1002,6 @@ all_cil_files := # See system/core/init/selinux.cpp for details. ################################# -################################# -# SHA-256 digest of the plat_sepolicy.cil and plat_mapping_file against -# which precompiled_policy was built. -################################# -include $(CLEAR_VARS) -LOCAL_MODULE := precompiled_sepolicy.plat_sepolicy_and_mapping.sha256 -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 legacy_unencumbered -LOCAL_LICENSE_CONDITIONS := notice unencumbered -LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_TAGS := optional - -ifeq ($(BOARD_USES_ODMIMAGE),true) -LOCAL_MODULE_PATH := $(TARGET_OUT_ODM)/etc/selinux -else -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux -endif - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_plat_cil) $(built_plat_mapping_cil) -$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_plat_cil) $(built_plat_mapping_cil) - cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@ - -################################# -# SHA-256 digest of the system_ext_sepolicy.cil and system_ext_mapping_file against -# which precompiled_policy was built. -################################# -include $(CLEAR_VARS) -LOCAL_MODULE := precompiled_sepolicy.system_ext_sepolicy_and_mapping.sha256 -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 legacy_unencumbered -LOCAL_LICENSE_CONDITIONS := notice unencumbered -LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_TAGS := optional - -ifeq ($(BOARD_USES_ODMIMAGE),true) -LOCAL_MODULE_PATH := $(TARGET_OUT_ODM)/etc/selinux -else -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux -endif - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_system_ext_cil) $(built_system_ext_mapping_cil) -$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_system_ext_cil) $(built_system_ext_mapping_cil) - cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@ - -################################# -# SHA-256 digest of the product_sepolicy.cil and product_mapping_file against -# which precompiled_policy was built. -################################# -include $(CLEAR_VARS) -LOCAL_MODULE := precompiled_sepolicy.product_sepolicy_and_mapping.sha256 -LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 legacy_unencumbered -LOCAL_LICENSE_CONDITIONS := notice unencumbered -LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_TAGS := optional - -ifeq ($(BOARD_USES_ODMIMAGE),true) -LOCAL_MODULE_PATH := $(TARGET_OUT_ODM)/etc/selinux -else -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux -endif - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(built_product_cil) $(built_product_mapping_cil) -$(LOCAL_BUILT_MODULE): $(built_precompiled_sepolicy) $(built_product_cil) $(built_product_mapping_cil) - cat $(PRIVATE_CIL_FILES) | sha256sum | cut -d' ' -f1 > $@ - ################################# include $(CLEAR_VARS) # build this target so that we can still perform neverallow checks