Native allow unknown uids from Java

This commit is contained in:
M66B 2016-01-25 09:44:17 +01:00
parent d96e9ec3d4
commit cf1263c309
2 changed files with 7 additions and 6 deletions

View File

@ -798,10 +798,11 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
}
private int[] getAllowedUids(List<Rule> listAllowed) {
int[] uid = new int[listAllowed.size() + 1];
uid[0] = 0; // Allow root (DNS, etc)
int[] uid = new int[listAllowed.size() + 2];
uid[0] = -1; // Allow unknown
uid[1] = 0; // Allow root (DNS, etc)
for (int i = 0; i < listAllowed.size(); i++)
uid[i + 1] = listAllowed.get(i).info.applicationInfo.uid;
uid[i + 2] = listAllowed.get(i).info.applicationInfo.uid;
return uid;
}

View File

@ -256,7 +256,7 @@ void check_allowed(const struct arguments *args) {
if (!u->stop) {
int found = 0;
for (int i = 0; i < args->ucount; i++)
if (u->uid < 0 || u->uid == args->uids[i]) {
if (u->uid == args->uids[i]) {
found = 1;
break;
}
@ -273,7 +273,7 @@ void check_allowed(const struct arguments *args) {
if (t->state != TCP_TIME_WAIT && t->state != TCP_CLOSE) {
int found = 0;
for (int i = 0; i < args->ucount; i++)
if (t->uid < 0 || t->uid == args->uids[i]) {
if (t->uid == args->uids[i]) {
found = 1;
break;
}
@ -1020,7 +1020,7 @@ void handle_ip(const struct arguments *args, const uint8_t *buffer, const size_t
jboolean allowed = (jboolean) !syn;
if (syn && args->filter) {
for (int i = 0; i < args->ucount; i++)
if (uid < 0 || uid == args->uids[i]) {
if (uid == args->uids[i]) {
allowed = 1;
break;
}