Commit 222c31b3 authored by topjohnwu's avatar topjohnwu

Fix checking order

parent 743c4f55
......@@ -311,30 +311,6 @@ int su_daemon_main(int argc, char **argv) {
optind++;
}
// Check property of root configuration
char *root_prop = getprop(ROOT_ACCESS_PROP);
if (root_prop) {
int prop_status = atoi(root_prop);
switch (prop_status) {
case ROOT_ACCESS_DISABLED:
exit(EXIT_FAILURE);
case ROOT_ACCESS_APPS_ONLY:
if (ctx.from.uid == UID_SHELL)
exit(EXIT_FAILURE);
break;
case ROOT_ACCESS_ADB_ONLY:
if (ctx.from.uid != UID_SHELL)
exit(EXIT_FAILURE);
break;
case ROOT_ACCESS_APPS_AND_ADB:
default:
break;
}
} else {
exit(EXIT_FAILURE);
}
free(root_prop);
// The su_context setup is done, now every error leads to deny
err_handler = deny;
......@@ -349,11 +325,6 @@ int su_daemon_main(int argc, char **argv) {
}
}
// Allow root to start root
if (ctx.from.uid == UID_ROOT) {
allow();
}
// verify superuser is installed
xstat(ctx.user.base_path, &st);
......@@ -370,6 +341,35 @@ int su_daemon_main(int argc, char **argv) {
allow();
}
// Check property of root configuration
char *root_prop = getprop(ROOT_ACCESS_PROP);
if (root_prop) {
int prop_status = atoi(root_prop);
switch (prop_status) {
case ROOT_ACCESS_DISABLED:
exit(EXIT_FAILURE);
case ROOT_ACCESS_APPS_ONLY:
if (ctx.from.uid == UID_SHELL)
exit(EXIT_FAILURE);
break;
case ROOT_ACCESS_ADB_ONLY:
if (ctx.from.uid != UID_SHELL)
exit(EXIT_FAILURE);
break;
case ROOT_ACCESS_APPS_AND_ADB:
default:
break;
}
} else {
exit(EXIT_FAILURE);
}
free(root_prop);
// Allow root to start root
if (ctx.from.uid == UID_ROOT) {
allow();
}
// deny if this is a non owner request and owner mode only
if (ctx.user.multiuser_mode == MULTIUSER_MODE_OWNER_ONLY && ctx.user.android_user_id != 0) {
deny();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment