diff options
author | Steve Kondik <shade@chemlab.org> | 2012-01-14 17:04:22 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-17 17:47:21 -0700 |
commit | 0db9d6164e426f7413e546772fbd9f8218366fc2 (patch) | |
tree | c930491ae70688e54e74b43a2653e82e61f58a90 | |
parent | bd7fb2577a22b46d82dd47cf2c5aeeb0237269eb (diff) | |
download | system_core-0db9d6164e426f7413e546772fbd9f8218366fc2.zip system_core-0db9d6164e426f7413e546772fbd9f8218366fc2.tar.gz system_core-0db9d6164e426f7413e546772fbd9f8218366fc2.tar.bz2 |
adbd: Disable "adb root" by system property (2/3)
* Require persist.sys.root_access=1 on non-eng debuggable builds
Change-Id: Iedab030e81ffb525fed64aed80cf0014f3e07073
-rw-r--r-- | adb/services.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/adb/services.cpp b/adb/services.cpp index 1847447..7398797 100644 --- a/adb/services.cpp +++ b/adb/services.cpp @@ -76,6 +76,19 @@ void restart_root_service(int fd, void *cookie) { return; } + char build_type[PROPERTY_VALUE_MAX]; + char cm_version[PROPERTY_VALUE_MAX]; + property_get("persist.sys.root_access", value, "0"); + property_get("ro.build.type", build_type, ""); + property_get("ro.cm.version", cm_version, ""); + + if (strlen(cm_version) > 0 && strcmp(build_type, "eng") != 0 && (atoi(value) & 2) != 2) { + snprintf(buf, sizeof(buf), "root access is disabled by system setting - enable in settings -> development options\n"); + writex(fd, buf, strlen(buf)); + adb_close(fd); + return; + } + property_set("service.adb.root", "1"); WriteFdExactly(fd, "restarting adbd as root\n"); adb_close(fd); |