summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorJorge Lucangeli Obes <jorgelo@google.com>2016-02-24 22:13:09 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-02-24 22:13:09 +0000
commitd458730b649a044268807d1458867e3c1d0577b2 (patch)
tree63233eda01e58b2b8baf8051d2e2762a3fc0fb77 /adb
parent21dd6feb1cca28192d9ad3a19fb126657970fc78 (diff)
parent4d186ad96447df8d0d39235fb9b3f2022767aefe (diff)
downloadcore-d458730b649a044268807d1458867e3c1d0577b2.tar.gz
core-d458730b649a044268807d1458867e3c1d0577b2.tar.bz2
core-d458730b649a044268807d1458867e3c1d0577b2.zip
Merge "adbd: Remove explicit capability bounding set code."
Diffstat (limited to 'adb')
-rw-r--r--adb/daemon/main.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index 4721e2fbb..7f40b96b2 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -43,24 +43,15 @@
static const char* root_seclabel = nullptr;
-static void drop_capabilities_bounding_set_if_needed() {
-#ifdef ALLOW_ADBD_ROOT
+static void drop_capabilities_bounding_set_if_needed(struct minijail *j) {
+#if defined(ALLOW_ADBD_ROOT)
char value[PROPERTY_VALUE_MAX];
property_get("ro.debuggable", value, "");
if (strcmp(value, "1") == 0) {
return;
}
#endif
- for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) {
- if (i == CAP_SETUID || i == CAP_SETGID) {
- // CAP_SETUID CAP_SETGID needed by /system/bin/run-as
- continue;
- }
-
- if (prctl(PR_CAPBSET_DROP, i, 0, 0, 0) == -1) {
- PLOG(FATAL) << "Could not drop capabilities";
- }
- }
+ minijail_capbset_drop(j, CAP_TO_MASK(CAP_SETUID) | CAP_TO_MASK(CAP_SETGID));
}
static bool should_drop_privileges() {
@@ -131,7 +122,7 @@ static void drop_privileges(int server_port) {
// Don't listen on a port (default 5037) if running in secure mode.
// Don't run as root if running in secure mode.
if (should_drop_privileges()) {
- drop_capabilities_bounding_set_if_needed();
+ drop_capabilities_bounding_set_if_needed(jail.get());
minijail_change_gid(jail.get(), AID_SHELL);
minijail_change_uid(jail.get(), AID_SHELL);