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

Commit 1af18c3c authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Fix build."

parents 8e16a7e2 4c9d24a3
Loading
Loading
Loading
Loading
+12 −6
Original line number Original line Diff line number Diff line
@@ -1272,23 +1272,29 @@ static bool should_drop_privileges() {
        return false;
        return false;
    }
    }


    // Don't run as root if ro.secure is set...
    property_get("ro.secure", value, "1");
    property_get("ro.secure", value, "1");
    bool ro_secure = (strcmp(value, "1") == 0);
    bool ro_secure = (strcmp(value, "1") == 0);


    // ... except we allow running as root in userdebug builds if the
    // Drop privileges if ro.secure is set...
    // service.adb.root property has been set by the "adb root" command
    bool drop = ro_secure;

    property_get("ro.debuggable", value, "");
    property_get("ro.debuggable", value, "");
    bool ro_debuggable = (strcmp(value, "1") == 0);
    bool ro_debuggable = (strcmp(value, "1") == 0);

    property_get("service.adb.root", value, "");
    property_get("service.adb.root", value, "");
    bool adb_root = (strcmp(value, "1") == 0);
    bool adb_root = (strcmp(value, "1") == 0);
    bool adb_unroot = (strcmp(value, "0") == 0);
    bool adb_unroot = (strcmp(value, "0") == 0);

    // ...except "adb root" lets you keep privileges in a debuggable build.
    if (ro_debuggable && adb_root) {
        drop = false;
    }

    // ...and "adb unroot" lets you explicitly drop privileges.
    if (adb_unroot) {
    if (adb_unroot) {
        return true; // The user explicitly wants us to drop privileges.
        drop = true;
    }
    }


    return ro_secure || !ro_debuggable;
    return drop;
#else
#else
    return true; // "adb root" not allowed, always drop privileges.
    return true; // "adb root" not allowed, always drop privileges.
#endif /* ALLOW_ADBD_ROOT */
#endif /* ALLOW_ADBD_ROOT */