blob: 2cda6de786719091116b0bc8d361cdf9a97077ee [file] [log] [blame]
Jackeagled3ba2282018-11-17 20:49:22 -07001From 6d89034411393db371fb376931dc6c1b6b114c40 Mon Sep 17 00:00:00 2001
2From: Jackeagle <jackeagle102@gmail.com>
3Date: Sat, 17 Nov 2018 08:24:08 -0700
4Subject: [PATCH 1/9] Revert "verity_tool: Implement status getter"
5
6This reverts commit 385296fd334a854915d41ef556ce7bb981f66bb3.
7
8Change-Id: I8748c6c4ee0158124ad9c4469521be7d1cc02fc6
9---
10 config/BoardConfigBliss.mk | 8 ++--
11 verity_tool/include/verity_tool.h | 15 --------
12 verity_tool/main.cpp | 27 +------------
13 verity_tool/verity_tool.cpp | 63 -------------------------------
14 4 files changed, 6 insertions(+), 107 deletions(-)
15
16diff --git a/config/BoardConfigBliss.mk b/config/BoardConfigBliss.mk
17index 032e061..7ccae1d 100644
18--- a/config/BoardConfigBliss.mk
19+++ b/config/BoardConfigBliss.mk
20@@ -9,8 +9,8 @@ ifeq ($(TARGET_HW_DISK_ENCRYPTION),true)
21 endif
22
23 include vendor/bliss/config/BoardConfigKernel.mk
24-include vendor/bliss/config/BoardConfigSoong.mk
25+include vendor/lineage/config/BoardConfigSoong.mk
26
27-ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
28-include vendor/bliss/config/BoardConfigQcom.mk
29-endif
30+ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
31+include vendor/bliss/config/BoardConfigQcom.mk
32+endif
33diff --git a/verity_tool/include/verity_tool.h b/verity_tool/include/verity_tool.h
34index b81eda1..25a6a7c 100644
35--- a/verity_tool/include/verity_tool.h
36+++ b/verity_tool/include/verity_tool.h
37@@ -18,14 +18,6 @@
38
39 #include <string>
40
41-typedef enum {
42- VERITY_STATE_UNKNOWN,
43- VERITY_STATE_NO_DEVICE,
44- VERITY_STATE_DISABLED,
45- VERITY_STATE_ENABLED,
46- VERITY_STATE_MAX = VERITY_STATE_ENABLED
47-} verity_state_t;
48-
49 /*
50 * Return codes:
51 *
52@@ -35,13 +27,6 @@ typedef enum {
53 bool set_block_device_verity_enabled(const std::string& block_device,
54 bool enable);
55
56-/*
57- * Return codes:
58- *
59- * verity state (unknown, disabled, enabled)
60- */
61-verity_state_t get_verity_state();
62-
63 /*
64 * Return codes:
65 *
66diff --git a/verity_tool/main.cpp b/verity_tool/main.cpp
67index befdafa..f5f026a 100644
68--- a/verity_tool/main.cpp
69+++ b/verity_tool/main.cpp
70@@ -24,23 +24,20 @@ static void print_usage() {
71 printf("veritytool - toggle block device verification\n"
72 " --help show this help\n"
73 " --enable enable dm-verity\n"
74- " --disable disable dm-verity\n"
75- " --show show current dm-verity state\n");
76+ " --disable disable dm-verity\n");
77 }
78
79 int main(int argc, char** argv) {
80 int c, rc;
81 int enable = 0;
82- int show = 0;
83 bool flag_set = false;
84 struct option long_opts[] = {
85 {"disable", no_argument, &enable, 0},
86 {"enable", no_argument, &enable, 1},
87- {"show", no_argument, &show, 1},
88 {NULL, 0, NULL, 0},
89 };
90
91- while ((c = getopt_long(argc, argv, "des", long_opts, NULL)) != -1) {
92+ while ((c = getopt_long(argc, argv, "de", long_opts, NULL)) != -1) {
93 switch (c) {
94 case 0:
95 flag_set = true;
96@@ -56,26 +53,6 @@ int main(int argc, char** argv) {
97 exit(0);
98 }
99
100- if (show) {
101- printf("dm-verity state: ");
102- switch (get_verity_state()) {
103- case VERITY_STATE_NO_DEVICE:
104- printf("NO DEVICE");
105- break;
106- case VERITY_STATE_DISABLED:
107- printf("DISABLED");
108- break;
109- case VERITY_STATE_ENABLED:
110- printf("ENABLED");
111- break;
112- default:
113- printf("UNKNOWN");
114- break;
115- }
116- printf("\n");
117- return 0;
118- }
119-
120 if (!set_verity_enabled(enable)) {
121 printf("Error occurred in set_verity_enable\n");
122 exit(EXIT_FAILURE);
123diff --git a/verity_tool/verity_tool.cpp b/verity_tool/verity_tool.cpp
124index 48e95b6..9575c4c 100644
125--- a/verity_tool/verity_tool.cpp
126+++ b/verity_tool/verity_tool.cpp
127@@ -108,69 +108,6 @@ static std::string get_ab_suffix() {
128 return ab_suffix;
129 }
130
131-verity_state_t get_verity_state() {
132- verity_state_t rc = VERITY_STATE_NO_DEVICE;
133- std::string ab_suffix = get_ab_suffix();
134-
135- // Figure out if we're using VB1.0 or VB2.0 (aka AVB) - by
136- // contract, androidboot.vbmeta.digest is set by the bootloader
137- // when using AVB).
138- bool using_avb = !android::base::GetProperty("ro.boot.vbmeta.digest", "").empty();
139-
140- if (using_avb) {
141- // Yep, the system is using AVB.
142- AvbOps* ops = avb_ops_user_new();
143- if (ops == nullptr) {
144- LOG(ERROR) << "Error getting AVB ops";
145- avb_ops_user_free(ops);
146- return VERITY_STATE_UNKNOWN;
147- }
148- bool verity_enabled;
149- if (!avb_user_verity_get(ops, ab_suffix.c_str(), &verity_enabled)) {
150- LOG(ERROR) << "Error getting verity state";
151- avb_ops_user_free(ops);
152- return VERITY_STATE_UNKNOWN;
153- }
154- rc = verity_enabled ? VERITY_STATE_ENABLED : VERITY_STATE_DISABLED;
155- avb_ops_user_free(ops);
156- } else {
157- // Not using AVB - assume VB1.0.
158-
159- // read all fstab entries at once from all sources
160- struct fstab* fstab = fs_mgr_read_fstab_default();
161- if (!fstab) {
162- LOG(ERROR) << "Failed to read fstab";
163- fs_mgr_free_fstab(fstab);
164- return VERITY_STATE_UNKNOWN;
165- }
166-
167- // Loop through entries looking for ones that vold manages.
168- for (int i = 0; i < fstab->num_entries; i++) {
169- if (fs_mgr_is_verified(&fstab->recs[i])) {
170- std::string block_device = fstab->recs[i].blk_device;
171- fec::io fh(block_device, O_RDONLY);
172- if (!fh) {
173- PLOG(ERROR) << "Could not open block device " << block_device;
174- rc = VERITY_STATE_UNKNOWN;
175- break;
176- }
177-
178- fec_verity_metadata metadata;
179- if (!fh.get_verity_metadata(metadata)) {
180- LOG(ERROR) << "Couldn't find verity metadata!";
181- rc = VERITY_STATE_UNKNOWN;
182- break;
183- }
184-
185- rc = metadata.disabled ? VERITY_STATE_DISABLED : VERITY_STATE_ENABLED;
186- }
187- }
188- fs_mgr_free_fstab(fstab);
189- }
190-
191- return rc;
192-}
193-
194 /* Use AVB to turn verity on/off */
195 static bool set_avb_verity_enabled_state(AvbOps* ops, bool enable_verity) {
196 std::string ab_suffix = get_ab_suffix();
197--
1982.17.1
199