mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-06 07:20:47 -05:00
Cleanup database code
This commit is contained in:
@@ -67,7 +67,7 @@ void su_info::check_db() {
|
||||
ssprintf(query, sizeof(query),
|
||||
"SELECT policy, logging, notification FROM policies "
|
||||
"WHERE uid=%d AND (until=0 OR until>%li)", eval_uid, time(nullptr));
|
||||
auto res = db_exec(query, [&](db_row &row) -> bool {
|
||||
bool res = db_exec(query, [&](db_row &row) -> bool {
|
||||
access.policy = (policy_t) parse_int(row["policy"]);
|
||||
access.log = parse_int(row["logging"]);
|
||||
access.notify = parse_int(row["notification"]);
|
||||
@@ -75,7 +75,7 @@ void su_info::check_db() {
|
||||
access.policy, access.log, access.notify);
|
||||
return true;
|
||||
});
|
||||
if (res.check_err())
|
||||
if (!res)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,11 +128,11 @@ bool uid_granted_root(int uid) {
|
||||
ssprintf(query, sizeof(query),
|
||||
"SELECT policy FROM policies WHERE uid=%d AND (until=0 OR until>%li)",
|
||||
uid, time(nullptr));
|
||||
auto res = db_exec(query, [&](db_row &row) -> bool {
|
||||
bool res = db_exec(query, [&](db_row &row) -> bool {
|
||||
granted = parse_int(row["policy"]) == ALLOW;
|
||||
return true;
|
||||
});
|
||||
if (res.check_err())
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
return granted;
|
||||
@@ -142,7 +142,7 @@ void prune_su_access() {
|
||||
cached.reset();
|
||||
vector<bool> app_no_list = get_app_no_list();
|
||||
vector<int> rm_uids;
|
||||
auto res = db_exec("SELECT uid FROM policies", [&](db_row &row) -> bool {
|
||||
bool res = db_exec("SELECT uid FROM policies", [&](db_row &row) -> bool {
|
||||
int uid = parse_int(row["uid"]);
|
||||
int app_id = to_app_id(uid);
|
||||
if (app_id >= AID_APP_START && app_id <= AID_APP_END) {
|
||||
@@ -154,13 +154,13 @@ void prune_su_access() {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (res.check_err())
|
||||
if (!res)
|
||||
return;
|
||||
|
||||
for (int uid : rm_uids) {
|
||||
char query[256];
|
||||
ssprintf(query, sizeof(query), "DELETE FROM policies WHERE uid == %d", uid);
|
||||
db_exec(query).check_err();
|
||||
db_exec(query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user