Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the group id of a file on rooted android device?

Tags:

android

root

I am trying to give access to a file I have written in one app to another app. chgrp is not available in the adb shell (command 'chgrp' not found) I have installed BusyBox but in order to get access to chgrp.

For example I use the command chown app_79 file.txt and it works. But when I try chgrp app_79 file.txt it always returns something like chgrp: unknown group app_79

I Googled a bunch and found that most linux systems have a file /etc/group which stores the group information for that system, but it is not present in Android.

like image 743
Matt Avatar asked Jul 11 '12 20:07

Matt


3 Answers

Using the builtin tools, rather than busybox, it would be

chown uid.gid filename

Probably with these id's having to be numeric as Matt pointed out.

like image 121
Chris Stratton Avatar answered Nov 04 '22 19:11

Chris Stratton


Use busybox chown uid.gid file.txt and specify UID and GID as numbers instead of names. app_79 likely corresponds to ID 10079 (to be sure you may recheck it with busybox ls -l -n /data/data):

busybox chown 10079.10079 file.txt
like image 24
Idolon Avatar answered Nov 04 '22 18:11

Idolon


Found some information here about how some group ids are hardcoded. I also had previous knowledge that /data/system/packages.list and /data/system/packages.xml contained the UIDs of apps, which are all something like 10000+x. What I now know is that x is the number that comes after "app_" when you ls -l.

So, the weird thing is you can chgrp 10079 file.txt but you cannot chgrp app_79 file.txt.

Hope this helps someone.

like image 4
Matt Avatar answered Nov 04 '22 18:11

Matt