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

Commit b683e4ee authored by Steve Kondik's avatar Steve Kondik Committed by Michael Bestas
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

adb: Fix compilation issue

Change-Id: Ia3284d5b8e428474726f64231f8142cf2474b17f

[mikeioannina] Adapt for O and rebrand prop

Change-Id: Ib880967a72296edfb05b80875fbe18136338a8c5
parent 53fa6072
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -84,6 +84,17 @@ void restart_root_service(int fd, void *cookie) {
            return;
        }

        std::string root_access = android::base::GetProperty("persist.sys.root_access", "0");
        std::string build_type = android::base::GetProperty("ro.build.type", "");
        std::string lineage_version = android::base::GetProperty("ro.lineage.version", "");

        if (!lineage_version.empty() && build_type != "eng" && (std::stoi(root_access) & 2) != 2) {
            WriteFdExactly(fd, "root access is disabled by system setting - "
                    "enable in Settings -> System -> Development options\n");
            adb_close(fd);
            return;
        }

        android::base::SetProperty("service.adb.root", "1");
        WriteFdExactly(fd, "restarting adbd as root\n");
        adb_close(fd);