Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 1 | LOCAL_PATH:= $(call my-dir) |
William Roberts | f0e0a94 | 2012-08-27 15:41:15 -0700 | [diff] [blame] | 2 | |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 3 | include $(CLEAR_VARS) |
| 4 | |
| 5 | # SELinux policy version. |
| 6 | # Must be <= /selinux/policyvers reported by the Android kernel. |
| 7 | # Must be within the compatibility range reported by checkpolicy -V. |
Stephen Smalley | 66a3e8d | 2012-09-18 15:11:49 -0400 | [diff] [blame] | 8 | POLICYVERS ?= 24 |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 9 | |
| 10 | MLS_SENS=1 |
| 11 | MLS_CATS=1024 |
| 12 | |
rpcraig | 47cd396 | 2012-10-17 21:09:52 -0400 | [diff] [blame] | 13 | # Quick edge case error detection for BOARD_SEPOLICY_REPLACE. |
| 14 | # Builds the singular path for each replace file. |
| 15 | sepolicy_replace_paths := |
| 16 | $(foreach pf, $(BOARD_SEPOLICY_REPLACE), \ |
| 17 | $(if $(filter $(pf), $(BOARD_SEPOLICY_UNION)), \ |
| 18 | $(error Ambiguous request for sepolicy $(pf). Appears in both \ |
| 19 | BOARD_SEPOLICY_REPLACE and BOARD_SEPOLICY_UNION), \ |
| 20 | ) \ |
| 21 | $(eval _paths := $(wildcard $(addsuffix /$(pf), $(BOARD_SEPOLICY_DIRS)))) \ |
| 22 | $(eval _occurrences := $(words $(_paths))) \ |
| 23 | $(if $(filter 0,$(_occurrences)), \ |
| 24 | $(error No sepolicy file found for $(pf) in $(BOARD_SEPOLICY_DIRS)), \ |
| 25 | ) \ |
| 26 | $(if $(filter 1, $(_occurrences)), \ |
| 27 | $(eval sepolicy_replace_paths += $(_paths)), \ |
| 28 | $(error Multiple occurrences of replace file $(pf) in $(_paths)) \ |
| 29 | ) \ |
| 30 | $(if $(filter 0, $(words $(wildcard $(addsuffix /$(pf), $(LOCAL_PATH))))), \ |
| 31 | $(error Specified the sepolicy file $(pf) in BOARD_SEPOLICY_REPLACE, \ |
| 32 | but none found in $(LOCAL_PATH)), \ |
| 33 | ) \ |
| 34 | ) |
Stephen Smalley | 5b340be | 2012-03-06 11:12:41 -0500 | [diff] [blame] | 35 | |
rpcraig | 47cd396 | 2012-10-17 21:09:52 -0400 | [diff] [blame] | 36 | # Builds paths for all requested policy files w.r.t |
| 37 | # both BOARD_SEPOLICY_REPLACE and BOARD_SEPOLICY_UNION |
| 38 | # product variables. |
| 39 | # $(1): the set of policy name paths to build |
| 40 | build_policy = $(foreach type, $(1), \ |
| 41 | $(foreach expanded_type, $(notdir $(wildcard $(addsuffix /$(type), $(LOCAL_PATH)))), \ |
| 42 | $(if $(filter $(expanded_type), $(BOARD_SEPOLICY_REPLACE)), \ |
| 43 | $(wildcard $(addsuffix $(expanded_type), $(dir $(sepolicy_replace_paths)))), \ |
| 44 | $(LOCAL_PATH)/$(expanded_type) \ |
| 45 | ) \ |
| 46 | ) \ |
| 47 | $(foreach union_policy, $(wildcard $(addsuffix /$(type), $(BOARD_SEPOLICY_DIRS))), \ |
| 48 | $(if $(filter $(notdir $(union_policy)), $(BOARD_SEPOLICY_UNION)), \ |
| 49 | $(union_policy), \ |
| 50 | ) \ |
| 51 | ) \ |
| 52 | ) |
Stephen Smalley | 5b340be | 2012-03-06 11:12:41 -0500 | [diff] [blame] | 53 | |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 54 | ################################## |
| 55 | include $(CLEAR_VARS) |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 56 | |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 57 | LOCAL_MODULE := sepolicy |
| 58 | LOCAL_MODULE_CLASS := ETC |
| 59 | LOCAL_MODULE_TAGS := optional |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 60 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 61 | |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 62 | include $(BUILD_SYSTEM)/base_rules.mk |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 63 | |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 64 | sepolicy_policy.conf := $(intermediates)/policy.conf |
| 65 | $(sepolicy_policy.conf): PRIVATE_MLS_SENS := $(MLS_SENS) |
| 66 | $(sepolicy_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS) |
Kenny Root | 9ceb47b | 2012-11-01 13:17:29 -0700 | [diff] [blame] | 67 | $(sepolicy_policy.conf) : $(call build_policy, security_classes initial_sids access_vectors global_macros mls_macros mls policy_capabilities te_macros attributes *.te roles users initial_sid_contexts fs_use genfs_contexts port_contexts) |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 68 | @mkdir -p $(dir $@) |
Kenny Root | 9ceb47b | 2012-11-01 13:17:29 -0700 | [diff] [blame] | 69 | $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) -s $^ > $@ |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 70 | |
Stephen Smalley | 2b826fc | 2012-01-24 08:46:13 -0500 | [diff] [blame] | 71 | $(LOCAL_BUILT_MODULE) : $(sepolicy_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 72 | @mkdir -p $(dir $@) |
Ying Wang | f4ea5b2 | 2012-04-09 15:31:03 -0700 | [diff] [blame] | 73 | $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -c $(POLICYVERS) -o $@ $< |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 74 | |
Ying Wang | d8b122c | 2012-10-25 19:01:31 -0700 | [diff] [blame] | 75 | built_sepolicy := $(LOCAL_BUILT_MODULE) |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 76 | sepolicy_policy.conf := |
Stephen Smalley | 01a58af | 2012-10-02 12:46:37 -0400 | [diff] [blame] | 77 | |
| 78 | ################################### |
| 79 | include $(CLEAR_VARS) |
| 80 | |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 81 | LOCAL_MODULE := file_contexts |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 82 | LOCAL_MODULE_CLASS := ETC |
| 83 | LOCAL_MODULE_TAGS := optional |
| 84 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) |
| 85 | |
Stephen Smalley | 5b340be | 2012-03-06 11:12:41 -0500 | [diff] [blame] | 86 | include $(BUILD_SYSTEM)/base_rules.mk |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 87 | |
rpcraig | 47cd396 | 2012-10-17 21:09:52 -0400 | [diff] [blame] | 88 | ALL_FC_FILES := $(call build_policy, file_contexts) |
Stephen Smalley | 01a58af | 2012-10-02 12:46:37 -0400 | [diff] [blame] | 89 | |
Ying Wang | d8b122c | 2012-10-25 19:01:31 -0700 | [diff] [blame] | 90 | $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy) |
| 91 | $(LOCAL_BUILT_MODULE): $(ALL_FC_FILES) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkfc |
Stephen Smalley | 5b340be | 2012-03-06 11:12:41 -0500 | [diff] [blame] | 92 | @mkdir -p $(dir $@) |
Stephen Smalley | 01a58af | 2012-10-02 12:46:37 -0400 | [diff] [blame] | 93 | $(hide) m4 -s $(ALL_FC_FILES) > $@ |
Ying Wang | d8b122c | 2012-10-25 19:01:31 -0700 | [diff] [blame] | 94 | $(hide) $(HOST_OUT_EXECUTABLES)/checkfc $(PRIVATE_SEPOLICY) $@ |
Stephen Smalley | 5b340be | 2012-03-06 11:12:41 -0500 | [diff] [blame] | 95 | |
| 96 | file_contexts := |
William Roberts | 171a062 | 2012-08-16 10:55:05 -0700 | [diff] [blame] | 97 | |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 98 | ################################## |
| 99 | include $(CLEAR_VARS) |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 100 | LOCAL_MODULE := seapp_contexts |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 101 | LOCAL_MODULE_CLASS := ETC |
| 102 | LOCAL_MODULE_TAGS := optional |
| 103 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) |
| 104 | |
William Roberts | 171a062 | 2012-08-16 10:55:05 -0700 | [diff] [blame] | 105 | include $(BUILD_SYSTEM)/base_rules.mk |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 106 | |
William Roberts | 98ed392 | 2012-09-05 11:19:07 -0700 | [diff] [blame] | 107 | seapp_contexts.tmp := $(intermediates)/seapp_contexts.tmp |
rpcraig | 47cd396 | 2012-10-17 21:09:52 -0400 | [diff] [blame] | 108 | $(seapp_contexts.tmp): $(call build_policy, seapp_contexts) |
William Roberts | 171a062 | 2012-08-16 10:55:05 -0700 | [diff] [blame] | 109 | @mkdir -p $(dir $@) |
| 110 | $(hide) m4 -s $^ > $@ |
| 111 | |
Ying Wang | d8b122c | 2012-10-25 19:01:31 -0700 | [diff] [blame] | 112 | $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy) |
| 113 | $(LOCAL_BUILT_MODULE) : $(seapp_contexts.tmp) $(built_sepolicy) $(HOST_OUT_EXECUTABLES)/checkseapp |
William Roberts | f0e0a94 | 2012-08-27 15:41:15 -0700 | [diff] [blame] | 114 | @mkdir -p $(dir $@) |
Ying Wang | d8b122c | 2012-10-25 19:01:31 -0700 | [diff] [blame] | 115 | $(HOST_OUT_EXECUTABLES)/checkseapp -p $(PRIVATE_SEPOLICY) -o $@ $< |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 116 | |
William Roberts | 98ed392 | 2012-09-05 11:19:07 -0700 | [diff] [blame] | 117 | seapp_contexts.tmp := |
Ying Wang | d8b122c | 2012-10-25 19:01:31 -0700 | [diff] [blame] | 118 | built_sepolicy := |
Ying Wang | 02fb5f3 | 2012-01-17 17:51:09 -0800 | [diff] [blame] | 119 | ################################## |
Stephen Smalley | 124720a | 2012-04-04 10:11:16 -0400 | [diff] [blame] | 120 | include $(CLEAR_VARS) |
| 121 | |
| 122 | LOCAL_MODULE := property_contexts |
| 123 | LOCAL_MODULE_CLASS := ETC |
| 124 | LOCAL_MODULE_TAGS := optional |
| 125 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) |
| 126 | |
| 127 | include $(BUILD_SYSTEM)/base_rules.mk |
| 128 | |
| 129 | property_contexts := $(intermediates)/property_contexts |
rpcraig | 47cd396 | 2012-10-17 21:09:52 -0400 | [diff] [blame] | 130 | $(property_contexts): $(call build_policy, property_contexts) |
Stephen Smalley | 124720a | 2012-04-04 10:11:16 -0400 | [diff] [blame] | 131 | @mkdir -p $(dir $@) |
Stephen Smalley | efd6d6e | 2012-05-18 08:24:25 -0400 | [diff] [blame] | 132 | $(hide) m4 -s $^ > $@ |
Stephen Smalley | 124720a | 2012-04-04 10:11:16 -0400 | [diff] [blame] | 133 | |
| 134 | property_contexts := |
| 135 | ################################## |
Stephen Smalley | 7e8cf24 | 2012-02-02 13:28:28 -0500 | [diff] [blame] | 136 | |
Joshua Brindle | 70d4fc2 | 2012-06-20 11:58:01 -0400 | [diff] [blame] | 137 | ################################## |
| 138 | include $(CLEAR_VARS) |
| 139 | |
| 140 | LOCAL_MODULE := selinux-network.sh |
| 141 | LOCAL_SRC_FILES := $(LOCAL_MODULE) |
| 142 | LOCAL_MODULE_CLASS := EXECUTABLES |
| 143 | LOCAL_MODULE_TAGS := optional |
| 144 | LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES) |
| 145 | |
| 146 | include $(BUILD_PREBUILT) |
| 147 | |
| 148 | ################################## |
rpcraig | b19665c | 2012-07-30 09:33:03 -0400 | [diff] [blame] | 149 | include $(CLEAR_VARS) |
| 150 | |
| 151 | LOCAL_MODULE := mac_permissions.xml |
| 152 | LOCAL_MODULE_CLASS := ETC |
| 153 | LOCAL_MODULE_TAGS := optional |
| 154 | LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/security |
| 155 | |
| 156 | LOCAL_SRC_FILES := $(LOCAL_MODULE) |
| 157 | |
| 158 | include $(BUILD_PREBUILT) |
| 159 | |
| 160 | ################################## |
rpcraig | 47cd396 | 2012-10-17 21:09:52 -0400 | [diff] [blame] | 161 | |
| 162 | build_policy := |
| 163 | sepolicy_replace_paths := |
Alice Chu | cdfb06f | 2012-11-01 11:33:04 -0700 | [diff] [blame] | 164 | |
| 165 | include $(call all-makefiles-under,$(LOCAL_PATH)) |