App that can change permissions on files using chmod.

312 views
Skip to first unread message

Yuri Andronachi

unread,
Oct 15, 2014, 4:19:13 AM10/15/14
to android-...@googlegroups.com
Hello.

I'm making a system for special usages basing on android ICS 4.0.4.
I'm trying to change permission for files (for example a file was downloaded by an app and i want its permission change to 777).
C++ function chmod is not working.
So how can i make this working.

Thank you.

Yuri Andronachi

unread,
Oct 15, 2014, 9:47:25 AM10/15/14
to android-...@googlegroups.com
I've found that even if app is compiled with android system and is located in syspem/app folder it's still run ass some other then root user. So how to start an app as root?

simone.mutti

unread,
Oct 15, 2014, 11:05:05 AM10/15/14
to android-...@googlegroups.com
Hi Yuri,

it depends on where is the file. If the file resides on the internal sdcard, you can't change the permissions (also if you are root) due to security limitations. The internal sdcard is mounted as FUSE file system and it manages permissions for the files stored. However, if the file resides in the private app folder (i.e., /data/data/app_name/files) the chmod should work. 

Furthermore, let me say that put 777 for a file is never a good idea :) If you need to share the file among apps maybe you can consider the use of a ContentProvider.

hope this help.
Simone

simone.mutti

unread,
Oct 15, 2014, 6:05:11 PM10/15/14
to android-...@googlegroups.com
Hi Yuri,

what do you mean with "some other then root user"? (e.g., system user, install user). As far as I know the system app doesn't run as root but as system user.
In order to run an app as root you need a) root the device b) to include the "libsuperuser"[1] (or similar) library in your app and c) use the Shell.SU.run(command) in order to run a command as root (i.e., run the app as root).

Best,
Simone

Christopher Tate

unread,
Oct 15, 2014, 6:06:26 PM10/15/14
to android-...@googlegroups.com
Almost nothing in Android runs as the root user.  This is deliberate.  In general, if you think you need to run something as the superuser then you have not correctly designed your ACLs and information protection regime.

Why do you think something needs to run as root?

--
christopher tate


On Wed, Oct 15, 2014 at 6:47 AM, Yuri Andronachi <andro...@gmail.com> wrote:
I've found that even if app is compiled with android system and is located in syspem/app folder it's still run ass some other then root user. So how to start an app as root?

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.

Yuri Andronachi

unread,
Oct 27, 2014, 8:22:45 AM10/27/14
to android-...@googlegroups.com
Hi Simone.

I've tried calling su with Process.Exec before and it worked fine. Until we've found that Exec method hangs up without exiting it. I could be some bug somewhere in native code. But still that is a bad approach.
Better will be to change some android code platform mechanics so our app will be recognized as root and we could manipulate any file in the system. Since users on our devices will have access to only one our apk it will be fine for now.

Christopher, well you know those clients, they want it working, and want it now. They dont want to hear that we need time and make changes to the system. So we need a tool to manipulate system files to make changes after release. And the fastest way will be root permission for our apk. Like i said, users experience will be minimized, because devices are prepared for special uses only.
Reply all
Reply to author
Forward
0 new messages