changing OWNERSHIP of a file copied to device - android

When I copy a file from assets to the device, it copies just fine. The only problem is ownership. The file is ending up with the owner being 'app_59', and I need it to be 'system'. When I adb push a file, it goes as 'system'. I tried chown, I tried chmod 0777 the file, I just cannot seem to do it! Can anyone help :(

An application can't write something as the system user. That would be a serious violation of security. Also production devices do not provide root access from the shell, so it is not possible to push something to the device as anything besides the shell user; I assume you are doing your push on to the emulator, which is a very different environment in this regard (shell can run as root), so not applicable to a real device.

Related

Is there any adb command to install Apps to /sdcard?

We all know that Android install apps in /data/app and app's data in /data/data.
I wonder if is possible to "ask" to the system to install the app in /sdcard instead, or on a custom path there.
I know that this isn't good for security reasons, but having the dex/libs accessible without root would be usefull for creating a (sort-of) sandbox.
I'm talking about normal "apk" apps (not just dex files that can be booted with dalvikvm command).
adb install -s will tell the system you want to install the application to the sdcard.
However, I'm not sure this is actually what you want. It creates an encrypted container on the sdcard, so it's not actually accessible in the way that you want.
So essentially, no, it's not possible. For exactly the reason you already mentioned (security).

On Rooted phone read /data/data/****/**.db

I'm making an app that read messages from Whatsapp, Viber, mails, etc. and groups it so you can read all that one person said to you in just one App.
To do this I'm trying to read the *.db files each App has on /data/data directory but have encountered two problems.
Since I'm new to programing for rooted phones I don't know how this works and have not found a good tutorial or any documentation. Do you have any that I could read to understand?
Once I know how to access /data/data with root, how can I read the *.db without making a copy. Many other topics say that I should copy the *.db file to a folder and read it there, but wouldn't it be a lot more simple to just read it from where it is?
Apps, regardless of whether the phone is rooted or not, can only ever read files that they themselves own, or that are public (e.g., on a SD card). This is because while the phone may be rooted, the apps themselves do not gain root access.
Instead, on your phone, you have an executable named su lets apps run root commands. However, by default, it refuses to let any app run any root commands. When you root your phone, you replace this executable by a new, modified version that lets approved apps run root commands. It is by using these root commands that you can gain indirect root access to the system.
Now, since you only have indirect root access for your app, you cannot just read any file from the file system. But if you run a root command to copy it to your own, private directory, where you do have permission to read it, your app can directly read it from there.
(Note: you can technically read files without copying them first, by using the su executable, but unless there's a real reason why you can't copy first, and you actually know what you're doing, you probably shouldn't even bother because it's rarely worth the trouble anyways, especially not for sqlite databases.)
For details about how to run root commands with su, see this link (which Gumbo posted in the comments above).

Change user and group of android app files to replicate issue user is having

I have an android app on the market and one of my users has reported a problem which nobody else has had (at least as far as I am aware of). They've told me what they did and what settings they had used as well as android version they are using so I am trying to replicate it as much as possible.
I install the original app before the update (when everything was working fine) and set up in the same way as the user said they had. I have then gone into the shell and gone into /data/data/com.mycompany.myapp/ and checked the databases and shared_prefs folder to check the ownership and both files were set up to be and the user and group are both set up to be app_36. I then pulled all the contents onto my development PC so that I have the database and prefs file.
I have then uninstall the original and installed the new version of the app by using adb installcom.mycompany.myappI then upload the databases and prefs file usingadb push`` and then viewed the permissions of the file using the adb shell and can see that they are now owned by root so the app can't access those file. I have then tried, from the adb shell doing the following:
adb shell
cd com.mycompany.myapp/shared_prefs
chown app_36:app_36 prefs.xml
This would work in normal linux changing the user and group to be app_36 but its saying that there is no user app_36:app_36. However, if I do chown app_36 prefs.xml it then changes the owner fine but I can't change the group.
To change the group I've use chgrp app_36 prefs.xml but it then says chgrp not found.
How can I change the user and the group so that I can copy the files over and replicate the issue my user is having.
Thanks for any help you can provide.
use dot as a delimiter:
chown app_36.app_36 prefs.xml

Android root access

I have a Google Nexus 7, and I've been developing on it. Only recently, however, have I become unable to access the /data/ directory using the file browser in eclipse. The device was never rooted, but now since I upgraded it, I believe that I have lost access to this. Is there any way to get eclipse to use the "run-as" command to access my app's data directory? How come I have suddenly lost access to this?
Is the only option left to root the device?
Thanks
Is there any way to get eclipse to use the "run-as" command to access my app's data directory?
There is nothing for you to run "as" that would help here, AFAIK.
How come I have suddenly lost access to this?
You should not have had access to it in the first place. If you did, that was a security flaw in the device, perhaps fixed by a firmware upgrade.
Is the only option left to root the device?
You could not browse the /data/ directory on production hardware. For example, you can browse /data/ on the emulator.
I am able to given root permission by installing apk.
http://gadgets.ndtv.com/mobiles/features/how-to-root-nokia-x-and-get-access-to-google-play-store-and-google-now-508391

Android : how to remount /system to read write without root

I heard of file called vold.fstab in /etc..can modifying that be of any help??i want to be able to remount as a common user.
Or is it possible to give specific permission to just run remount command as user??like is there a setting where certain command access can be set to particular users other than just root user??
No. It is not possible unless you install a custom android build which, for all practical purposes, lacks a security model - or use a local privilege escalation attack to obtain a temporary root shell to issue commands from.
Even if you were to let non-root users remount the filesystem, they wouldn't be able to actually change much of anything on it as they would lack the necessary file/directory permissions, so literally fulfilling your question would be pointless.
Likely what you want to do is install an at least somewhat secured tool for obtaining a root shell when needed - ie, "root" your phone. That would let you both remount the filesystem, and make changes to it, but would hopefully prevent/discourage other random code on your device from doing so.

Categories

Resources