On Tuesday, August 9, 2011 7:17:30 AM UTC-4, Mark Murphy (a Commons Guy) 
wrote:
>
> > Has this been done for security reasons ?
>
> Probably.
>
Unlikely, as it can be done with the ndk, and we are repeatedly told that 
the ndk does not have special permissions.  Most likely they just didn't 
bother implementing support in javaj for something that wasn't envisioned as 
needed.

> > Which means if an application downloads some bytes and writes to
> > a file created through the below code
> >
> > File destination = new File ("/sdcard/myfile.txt");
> >
> > there is no way to change permissions of 'myfile.txt' to 777 ?
>
> First, nobody uses /sdcard, since it is wrong. Use
> Environment.getExternalStorageDirectory().
>
> Second, nobody bothers to try to change Linux file permissions on
> external storage, since for the vast majority of current devices,
> that's FAT32 (vfat in Linux-ese), and file permissions do not matter
> much on that filesystem.
>
However, on internal storage where permissions matter, the java file 
creation tools do let you set the permissions to some extent (ie, various 
android presets, but not full unix bit-level control)

> > There is a 'Runtime' facility provided through java.lang, but I'm
> > skeptical
> > whether to use this or not. Runtime would only work on rooted devices
> > right?
>
> More importantly, you cannot reliably change permission bits that way 
> either.
>
The runtime facility does not require root, though it's perhaps not 
future-proof since it's not officially supported.  It's also needlessly 
roundabout.

A better way to do it would be to invoke an ndk subroutine through jni which 
uses the chmod() syscall.  There's nothing even slightly improper about 
doing that. 

first place. I have no idea what you think "change the permission of
> lcd device file permission", but it  has nothing to do with the
> Android SDK.
>
This may be the only "real problem" - the device files are certainly not 
owned by application users, and so cannot have their permissions changed by 
one.   (_That_ might be the reason the task would require an ability to 
execute a stand alone program as root)

Ordinary files owned by an application user id and residing on a filesystem 
where it is meaningful can however have their permission bits changed.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to