views:

345

answers:

7

I need to be able to write textfiles to the root directory of my Android device (as this related questions explains).

Can I change write permissions for root directory / and if so, how?

I tried pushing a file using adb, but it said file system was read-only =(

Its pretty annoying that I cannot control my own device, that everything is so restricted =(


EDIT 1: This thread has evolved into discussing Sygic Navigation and their API, which seems to be wrong when it comes to the Android platform. I have some other questions that discuss Sygic and their navigation software.

+6  A: 

Only if you have root access.

mbaird
+1  A: 

Not by default. The root filesystem shipped on official Android devices is read-only, and only certain well-constrained areas are writable by applications. There are root exploits for many Android devices available, however, which allow you to do whatever you want to your filesystem.

Andy Ross
Yes, unfortunately "rooting" every device that is to use this solution is probably not an option =( Damn, every single thing I try to do in android doesnt work for this or that reason =(
Ted
+1  A: 

Short answer: No you can't.

Long answer: No you can not, and should not.

Rant:


I am sorry that you may dislike some of the answers you are receiving here, but they are not as you put it 'smart remarks' (well they are smart, but not smart alec).

Instead what you are seeing is other developers, likely with more experience on the platform, giving you genuine warnings and good advice. They are warning you that the path that you are on reflects some poor design decisions.

You stated that:

Im using an external app that I have no control over whatsoever, and according to their API: The application reads and parses the .in file when it's placed in root directory on the mobile device. And there we have the reason why I dont save the file anywhere else and I cannot "review" my design

But commonsware.com is exactly right when they say:

Then stop using that "external app", whatever "external app" means. It clearly isn't an Android APK, as they wouldn't be shipping something that required the ability to write to the root directory.

Additionally, you commented in frustration that:

Yes, unfortunately "rooting" every device that is to use this solution is probably not an option =( Damn, every single thing I try to do in android doesnt work for this or that reason =(

There are so many reasons that the Android OS does not and should not allow every developer and their grandmother to have full control over root/system directories, but instead of listing some off the top of my head I will ask you this (rhetorically):

Why even bother having access control, and permissions, if any piece of software could change those settings whenever it feels like doing so?

I for one would never feel comfortable downloading an application for my smartphone if I knew it could have the ability to thrash about my entire device like a drunken elephant.

I could keep ranting but I will stop myself here...

instanceofTom
Hello... Well, it just dont cut it saying "then dont use the application". At first I thought that you havent read what I wrote about me not having control over the other app, but apparently you did read that. Which makes your answer even more annoying, sorry to say.*NO* I cant just "stop using" that app since at the time being, I have no other to choose from! Why is it so hard for ppl to understand such basic things? Its not "good advice" if you tell someone to stop using the *only* software that might just work! Is that good advice? I think not.
Ted
But Ted, the software isn't the *only* software that *might* work, because it **doesn't** work. I have other things to do than argue this point with you. You will eventually discover that this solution you are trying to hack together just wont cut it, as it requires you to do things that you should not be doing (Unless the company replies to you with another solution). Either that or you will decide to go a route similar to trying to root kit every potential device you want your software to run on, if so good luck. Oh and thanks for the down vote.
instanceofTom
And regarding the down vote: its nothing personal, but I get down-voted all the time for asking "tough" questions that the Linux-fanatics dont like. However, the answer you gave was the typical "no-answer", "smart remark" and fairly arrogant Im afraid. But just to make you happy again, Im removing the down vote, my point is made anyways...
Ted
Upvoted for trying to explain why this should not be done...
Jeff Barger
Jeff: well, this should be done if that is the only option I have! If I have to choose between *not getting the solution out there* (out of pure principle because the objections you have is nothing else than a principle) - or to break the precious principle and deliver something that works, I definately know what I'd choose...
Ted
+2  A: 

the ROOT is called that for a reason, the ROOT user is called that for the same reason. Anyone other than ROOT that owned / would be wrong and violate every UNIX principal of security. You can't do this for a GOOD reason, trying to do this is BAD.

fuzzy lollipop
As I stated before: I dont have a choice. From what I can see from the API Im trying to use, I need to be able to write text files to root.I have contacted the company that has provided the app, but as it stands now...
Ted
Upvoted for trying to explain why this should not be done...
Jeff Barger
See comment below Jeff =)
Ted
Someone downvoted this, i don't know why, upvote.
Anders
I downvoted it, because it's wrong and pedantic. First, almost all deployed software is done via some interaction with the root environment. As it happens, Android specifically (not "every UNIX principle of security") disallows root access. For some good reasons, and some not-so-good reasons. Flaming the poster for wanting to do something useful with his phone is counterproductive, and designing according to rules like this ("don't use root?!") is going to lead to bad software.
Andy Ross
Andy: At least one person who understands my point =)
Ted
that is what sudo is for, telling someone that it is ok to chown ROOT is what is wrong
fuzzy lollipop
Yet android (the platform at hand) doesn't support sudo or root (note spelling: "ROOT" is not a standard user) access, thus the question, thus my response that your answer was missing the point. It's not about unix security models, it's a specific question about how Android (a rather different system, c.f. the ro-mounted root filesystem) implements it's own security model.
Andy Ross
+2  A: 

I've had a quick look at the Sygic API Documentation. It does indeed say that input files come from the root directory. It also says that output files will be placed in the root directory. It even puts "root directory" in bold so you know that they're really serious that this is where the data files go.

As has been discussed, no Android application will have permission to write to this directory on a standard phone, so the Sygic documentation must be wrong. My guess is that this is the behaviour for other platform Sygic runs on but they haven't updated the documentation for Android.

I would hope they accept data via an Intent rather than a file, but without proper documentation is hard to know what you can do.

The API documentation does mention .out and .event files. Perhaps have a look around the file system on your device and see if you can find any. If you can, the .in files probably go in the same directory.

Dave Webb
Thanks Dave, yes I have learned that writing to the root cannot work "out of the box" from all the answers and objections =) I have emailed them with this issue and asked them to clarify the whole thing. I will take a close look to the directories I can access =)
Ted
+1  A: 

You say 'The application reads and parses the .in file when it's placed in root directory on the mobile device.'

I highly doubt this application is able to read the true root directory of your phone. I think it may be the root directory exposed to it over usb mass storage, aka /sdcard/.

sargas
Thanks sargas. I have tried som different locations, none work so far. I am hoping to get an answer from Sygic soon =)
Ted
+3  A: 

If you want to get creative and bypass the (idiotic) / requirement without root privileges, you could use fakechroot, an LD_PRELOAD library from debian.

Edit: this is probably impossible for a java program, due to the way vm instances are forked out. A native program would have to contend with an unhelpful linker (no LD_PRELOAD), but if arbitrary programs can be started, an alternative linker won't need root privileges.

Tobu
+1 I be interested to know if a solution like this will work.
instanceofTom
Hmm, Im not a Linux-guy... so messing around with libraries from Debian seems like out of my area of knowledge unfortunately ;-)I'll give it a upvote for "good idea" and thinking out of the box anyways =)
Ted