Revert "adbd: lessen security constraints when the device is unlocked"
This reverts commit f1d3dbc32f18d9b3604da03bc043c1b4cc3f5a35.
With the following changes to move /sbin/adbd to /system/bin/adbd,
we don't need this workaround anymore.
https://android-review.googlesource.com/#/q/topic:move-adbd-to-system+(status:open+OR+status:merged)
Bug: 63313955
Bug: 63381692
Bug: 64822208
Test: 'adb root' works in VTS for a non-A/B device (userdebug GSI + user boot.img)
Change-Id: Ic1249d6abd7d6e6e7380a661df16d25447853a48
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index e0629ab..1c94298 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -49,23 +49,17 @@
static const char* root_seclabel = nullptr;
-static inline bool is_device_unlocked() {
- return "orange" == android::base::GetProperty("ro.boot.verifiedbootstate", "");
-}
-
static void drop_capabilities_bounding_set_if_needed(struct minijail *j) {
- if (ALLOW_ADBD_ROOT || is_device_unlocked()) {
- if (__android_log_is_debuggable()) {
- return;
- }
+#if defined(ALLOW_ADBD_ROOT)
+ if (__android_log_is_debuggable()) {
+ return;
}
+#endif
minijail_capbset_drop(j, CAP_TO_MASK(CAP_SETUID) | CAP_TO_MASK(CAP_SETGID));
}
static bool should_drop_privileges() {
- // "adb root" not allowed, always drop privileges.
- if (!ALLOW_ADBD_ROOT && !is_device_unlocked()) return true;
-
+#if defined(ALLOW_ADBD_ROOT)
// The properties that affect `adb root` and `adb unroot` are ro.secure and
// ro.debuggable. In this context the names don't make the expected behavior
// particularly obvious.
@@ -95,6 +89,9 @@
}
return drop;
+#else
+ return true; // "adb root" not allowed, always drop privileges.
+#endif // ALLOW_ADBD_ROOT
}
static void drop_privileges(int server_port) {
@@ -161,10 +158,7 @@
// descriptor will always be open.
adbd_cloexec_auth_socket();
- // Respect ro.adb.secure in userdebug/eng builds (ALLOW_ADBD_NO_AUTH), or when the
- // device is unlocked.
- if ((ALLOW_ADBD_NO_AUTH || is_device_unlocked()) &&
- !android::base::GetBoolProperty("ro.adb.secure", false)) {
+ if (ALLOW_ADBD_NO_AUTH && !android::base::GetBoolProperty("ro.adb.secure", false)) {
auth_required = false;
}