Suggestion: File ownership

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Tyxerakias
Junior Member
Junior Member
Posts: 6
Joined: 2011-11-29, 14:45 UTC
Location: London, UK

Suggestion: File ownership

Post by *Tyxerakias »

I didn't see this as a suggestion anywhere, but at the moment one serious drawback in using TC as a root file manager, is the inability to chown. Since we can now chmod, could we please also have chown?
This would put it in the same league as root explorer, and eliminate the need for other root file managers.

Please please consider it! :)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48203
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I couldn't find out how user names are organized on Android, that's why I haven't added that yet. It seems that each app has their own user name (???).
Author of Total Commander
https://www.ghisler.com
Tyxerakias
Junior Member
Junior Member
Posts: 6
Joined: 2011-11-29, 14:45 UTC
Location: London, UK

Post by *Tyxerakias »

ghisler(Author) wrote:I couldn't find out how user names are organized on Android, that's why I haven't added that yet. It seems that each app has their own user name (???).
True, but that doesn't prevent you to do it as root exploer does, i.e. with a long list of numbers.
You have 0 for root, and then, respectively,
1000 to 1017 for system, radio, bluetooth, graphics, input, audio, camera, log, compass, mount, wifi, adb, install, media, dhcp, sdcard_rw, vpn, keystore
2000-2002 for shell, cache and diag,
3001-3005 for net_bt_admin, net_bt, inet, net_raw, net_admin,
9998 for misc,
9999 for nobody,
and then from 10000 to whatever, you have all the app names, app_0 to app_1000 if you have a thousand and one of them.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48203
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks, that info was very useful! Any idea how to get the owner number for a specific app name?
Author of Total Commander
https://www.ghisler.com
SithLord
Junior Member
Junior Member
Posts: 14
Joined: 2010-04-01, 14:32 UTC

Post by *SithLord »

Hi,

Here are the complete and exact list of UIDs and GIDs taken from the source of Busybox, the patched version in use for Android releases.

UID/GID list : (equivalent of /etc/passwd and /etc/group)

Code: Select all

root:0
system:1000
radio:1001
bluetooth:1002
graphics:1003
input:1004
audio:1005
camera:1006
log:1007
compass:1008
mount:1009
wifi:1010
dhcp:1014
adb:1011
install:1012
media:1013
shell:2000
cache:2001
diag:2002
net_bt_admin:3001
net_bt:3002
sdcard_rw:1015
vpn:1016
keystore:1017
inet:3003
net_raw:3004
net_admin:3005
misc:9998
nobody:9999
Every UID maps to its exact GID counterpart. AFAIK and according to patched Busybox sources, there's no UID being member of another group than it's own.

Hope it helps.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48203
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Nice, thanks! Are they the same on all Android versions, or is there a file where they can be read from?

And what about the UIDs of user-installed apps? Any idea on how to get them?
Author of Total Commander
https://www.ghisler.com
Tyxerakias
Junior Member
Junior Member
Posts: 6
Joined: 2011-11-29, 14:45 UTC
Location: London, UK

Post by *Tyxerakias »

ghisler(Author) wrote:Thanks, that info was very useful! Any idea how to get the owner number for a specific app name?
I found this, does it help? :

Code: Select all

        final PackageManager pm = getPackageManager();
        //get a list of installed apps.
        List<ApplicationInfo> packages = pm.getInstalledApplications(
                PackageManager.GET_META_DATA);
        int UID;
        //loop through the list of installed packages and see if the selected
        //app is in the list
        for (ApplicationInfo packageInfo : packages) {
            if(packageInfo.packageName.equals(app_selected)){
                //get the UID for the selected app
                UID = packageInfo.uid;

            }

           //Do whatever with the UID
           Log.i("Check UID", "UID is: " + UID);
I do believe the first bit is the same for all android versions, yes.
And as you can see the list that SithLord gave is identical to mine.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48203
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, that looks exactly like what I need, thanks!
Author of Total Commander
https://www.ghisler.com
Tyxerakias
Junior Member
Junior Member
Posts: 6
Joined: 2011-11-29, 14:45 UTC
Location: London, UK

Post by *Tyxerakias »

Even if it took a while, you never disappoint :)
Thank you very much for the functions in v.2! Really appreciated :)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48203
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks for the help with implementing this!
Author of Total Commander
https://www.ghisler.com
charly_35
Junior Member
Junior Member
Posts: 21
Joined: 2010-03-26, 17:14 UTC
Location: France Rennes 35

Post by *charly_35 »

Hello,
Would it be possible to add the options to the chmod (file property) to be able to set them with sid/gid fonction. Like when doing a "chmod 06755 /system/xbin/su". Thks
Cdlt Charles.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48203
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I will consider it.
Author of Total Commander
https://www.ghisler.com
Post Reply