Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4911b6a1 authored by Steve Kondik's avatar Steve Kondik
Browse files

adbd: Disable "adb root" by system property (2/3)

 * Require persist.sys.root_access=1 on non-eng debuggable builds

Change-Id: Iedab030e81ffb525fed64aed80cf0014f3e07073
parent c9089a8c
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -111,6 +111,8 @@ void restart_root_service(int fd, void *cookie)
{
{
    char buf[100];
    char buf[100];
    char value[PROPERTY_VALUE_MAX];
    char value[PROPERTY_VALUE_MAX];
    char build_type[PROPERTY_VALUE_MAX];
    char cm_version[PROPERTY_VALUE_MAX];


    if (getuid() == 0) {
    if (getuid() == 0) {
        snprintf(buf, sizeof(buf), "adbd is already running as root\n");
        snprintf(buf, sizeof(buf), "adbd is already running as root\n");
@@ -125,6 +127,17 @@ void restart_root_service(int fd, void *cookie)
            return;
            return;
        }
        }


        property_get("persist.sys.root_access", value, "1");
        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");
        property_set("service.adb.root", "1");
        snprintf(buf, sizeof(buf), "restarting adbd as root\n");
        snprintf(buf, sizeof(buf), "restarting adbd as root\n");
        writex(fd, buf, strlen(buf));
        writex(fd, buf, strlen(buf));