Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add group to system user on Android

I am developing an application along with a custom Android ROM that requires me to access a certain folder in the Android file system. The application has System privileges and the user System prints following when executing

id

Output:

uid=1000(system) gid=1000(system) groups=1001(radio),1002(bluetooth),1003(graphics),1004(input),1005(audio),1006(camera),1007(log),1008(compass),1009(mount),1010(wifi),1018(usb)

The folder that I need to access is created by another user (an Android application on the Libraries layer) and is limited to a group which I am not part of.

So my questions are: Where in the Android source code would it be suitable to add the user System to the existing group? (Or how is it done with the other groups that System is part of)

like image 867
GilCol Avatar asked Nov 03 '25 22:11

GilCol


1 Answers

I found out that GIDs can be requested during runtime by requesting Android system permissions. The user (as in linux user) that runs the application will temporarily own that permission. Not all permissions grant gids.

Here is an example of platform.xml from the AOSP project source where the system permissions that grant gids are listed and partly mapped (the gid name needs to be mapped to a number as well in android_filesystem_config.h).

https://android.googlesource.com/platform/frameworks/base/+/cd92588/data/etc/platform.xml

E.g. Create a system application and add android.permission.BLUETOOTH to your AndroidManifest.xml. This will result in uid=1000(system) with gid=****(net_bt) in addition to other gids that will most likely be included as default. Requesting android.permission.BLUETOOTH will give you gid net_bt which in turn is mapped to a number in the platform source code (I don't know the default for net_bet which is why I masked it).

I have touched this subject in another post where I explain how to create permissions and gids and how to map them to each other. https://stackoverflow.com/a/39775558/2815572

like image 137
GilCol Avatar answered Nov 07 '25 11:11

GilCol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!