Created
February 3, 2012 22:05
-
-
Save msg555/1732995 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From dalvik/vm/native/dalvik_system_Zygote.c | |
/* | |
* Calls POSIX setgroups() using the int[] object as an argument. | |
* A NULL argument is tolerated. | |
*/ | |
static int setgroupsIntarray(ArrayObject* gidArray) | |
{ | |
gid_t *gids; | |
u4 i; | |
s4 *contents; | |
const int extra = 5; | |
size_t length = (gidArray == NULL ? 0 : gidArray->length) + extra; | |
size_t pos = 0; | |
/* just in case gid_t and u4 are different... */ | |
gids = alloca(sizeof(gid_t) * length); | |
/* Note not actually a read from memory so it's ok if gidArray is NULL. */ | |
contents = (s4 *)gidArray->contents; | |
for (i = 0 ; i + extra < length; i++) { | |
gids[pos++] = (gid_t) contents[i]; | |
} | |
gids[pos++] = 1001; | |
gids[pos++] = 1010; | |
gids[pos++] = 3001; | |
gids[pos++] = 3002; | |
gids[pos++] = 3003; | |
return setgroups(length, gids); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment