[Q] File permissions......permanent change? - Android Q&A, Help & Troubleshooting

I am trying to sync a rostering app between two devices using dropsync.
The .db files that need syncing are in the /data/data/com.blah.blah/databases directory. Using Root explorer I can change the permissions to give full rw permission to others. The two .db files will then upload to the dropsync server.
The problem is that whenever the app is opened and anything modified, the permissions change back to default and thus dropsync can't access the modified .db
Is there anyway to change this or am I wasting my time? what is the 'sticky' box option in RE?

I'm not sure precisely what "sticky" means, but it's not what you want--it doesn't involve persistence or "sticking".
You could try to make the files not owned by the app but set it so the group is the app. Make sure the group can read/write/execute, or whatever it needs. This way, the app can still use the file but won't be able to change its permissions.
Of course, it could see that it doesn't own the file and refuse to run. I'm not sure what sort of checks the program's authors implemented. This also won't work if the file is deleted and created anew--the new file would be owned by the app.

Yeah thanks for that,
I tried the ownership and group swap earlier, and am pretty sure the app re- writes the db.
Don't think is going to work.
cheers

Well its obvious that the app, when opened sets the permissions to the .db files so that they wont be usable by others. The way you describe the problem is more likely to be a file owner problem and not with the permissions. Try to set the app and the files to the same owner and see if that works. You could always make a script that would change the permissions/ownership of the file.

FYI,
The sticky bit is a special part of the permissions mask for a file or directory. When set on a directory, it tells the system to prevent anyone but a containing file's owner from deleting files in that directory. This is handy if you have a directory that's being used by multiple users on a system as scratch space as it prevents people from wiping out others' files.
For files....the behavior isn't defined.
Hope this helps,
- chris

Related

I have a CWM 3.0+ updater-script question

Hello all,
I have written a script to push as file to my TB and it works kind of...I just want to know why it is not functioning as it should.
Here is what I am attempting to do.
Since my HTC weather does not have my city listed and my weather is always way off, I hacked the HTC weather database to add my city. And it works great.
So I wanted to create a weather_update.zip to install using CWM to do all of this for me if I changed roms and to allow others to use it as well.
the file goes into the /data/data/com.htc.provider.weather/files directory.
My script mounts data, pushes the file, changes the appropriate permissions, then unmounts.
It works as intended because I can see the file using adb prior to reboot.
However, after a reboot, the file is overwritten by the original. I can even delete the file completely, reboot and it is rebuilt. So my modified file does not stick.
BUT, if I use root explorer and copy the file to the correct directory and change permissions, my modified file works even after a reboot.
I don't understand why it works one way but not another.
Is there a step I am missing in the updater-script?
Any help would be appreciated....
Thanks,
Scott
UPEngineer said:
Hello all,
I have written a script to push as file to my TB and it works kind of...I just want to know why it is not functioning as it should.
Here is what I am attempting to do.
Since my HTC weather does not have my city listed and my weather is always way off, I hacked the HTC weather database to add my city. And it works great.
So I wanted to create a weather_update.zip to install using CWM to do all of this for me if I changed roms and to allow others to use it as well.
the file goes into the /data/data/com.htc.provider.weather/files directory.
My script mounts data, pushes the file, changes the appropriate permissions, then unmounts.
It works as intended because I can see the file using adb prior to reboot.
However, after a reboot, the file is overwritten by the original. I can even delete the file completely, reboot and it is rebuilt. So my modified file does not stick.
BUT, if I use root explorer and copy the file to the correct directory and change permissions, my modified file works even after a reboot.
I don't understand why it works one way but not another.
Is there a step I am missing in the updater-script?
Any help would be appreciated....
Thanks,
Scott
Click to expand...
Click to collapse
I could be way off base here but wouldn't you have to recursively delete the original to keep it from rebuilding?
dbu said:
I could be way off base here but wouldn't you have to recursively delete the original to keep it from rebuilding?
Click to expand...
Click to collapse
LOL, what I was thinking too, but it doesn't seem to work, unless I am doing it wrong.
If I replace the file and reboot, the original rebuilds.
If I delete the file completely and reboot, the original rebuilds.
If I replace the file using root explorer after phone has booted and then reboot, my modified file sticks.
That is what I can't figure out. Why it sticks after OS has loaded but rebuilds if the same file is placed before reboot.
And I can't figure out where the file is being rebuilt from.
Uggggg.

Lost access to media - ringtones, alarms, notifications and other media files

I have also posted this issue on another general forum, so apologies if this is deemed cross-posting!
My smartphone is running a stock Lollipop C6833_14.5.A.0.242_Customzied Germany.ftf ROM flashed using Flashtool, but is rooted with KingRoot and I have a dual recovery flashed and working properly.
Following that downgrade I found that my phone no longer had either a phone or alarm tone. When I try and change the alarm tone or ringtone or even notifications in settings I am presented with the file explorer. The sound selector shows nothing. File Commander is able to see and access the files, and they do not appear to be corrupted and I also tested them in my media player.
They were not in the SD card media folder, but were in tact in the system/media/audio folder in their respective folders. So I copied all the individual folders within the audio folder across to the corresponding media folder on the SD card. But that did not work either...
After searching various sites for help I managed to find instructions to download and flash Xperia Lollipop Media Sounds.zip, which I tried to do with TWRP recovery, but this failed with an error message I could not read.
I wondered whether if I were to just flash the system file from the same ROM it would restore the media file settings? Any help would be very much appreciated, as I have no way of hearing when I receive incoming calls, and my alarm does not work either. The audio seems to function fine in third party apps, so there is no physical issue as far as I know.
I also read a recommendation to copy the files across while connected to a PC, via USB, but my computer is a Mac and it does not seem to be able to access the SD cards as external drives in the same way as they appear in a PC.
Sony technical support basically told me that the only solution is to use repair within the Sony Bridge for Mac app, but I don't want to lose root, as the latest firmware upgrade is impossible to root. I really need help on this please!
Be aware that you have to set the correct file permissions after moving them to the /audio folder. The ringtones and alarm tones should be in the folder you just wrote, meaning they're on the system partition.
Just long-press or something on the audio-folder (depending on the file explorer you're using), tap "properties", and then set the permissions to 6-4-4, which is RW-R-R, or:
[x] [x] [ ]
[x] [ ] [ ]
[x] [ ] [ ]
Then reboot.
Hi Klaoss, many thanks for replying. However I have checked the permissions. The permissions for the actual files are RW-R-R, but in fact the folder permissions seem to be even more open: drwxr-xr-x, does that sound correct? I am talking about/system/media/audio/alarms, camera, notifications, ringtones and ui, which all have the same permissions.
Uh Oh! I just checked the permissions in the /storage/emulated/0/media/audio folder are non existent! Maybe this is why it is necessary to use the PC to copy the files, in order to retain the file and folder permissions? Is it also something to do with the actual formatting of the SD partition? Thanks for your patience
Just checked mine (on 5.1.1) and it does indeed look like the folders are drwxr-xr-x, while the files themselves are rw-r-r.
Also, yeah you could try that. That might actually work. Just remember to reboot after each change.
Thanks, but to be clear, do the files need to also be in /storage/emulated/0/media/ as well as in the /system/media/audio, or are they superfluous? Because if they are not needed, then I am not going to achieve anything by going to the trouble of copying the files within a PC environment.
Also, is there no way of copying files within Android without losing the permissions?
No idea, but I've always added and removed audio files from the system partition, but I know apps like Zedge and stuff adds them to the list when downloaded, so I'm guessing that 3rd party apps use the media folder on the internal memory, and not on the system partition, which requires root. So I would probably just let that folder alone, and concentrate on the system folder. Check the permissions and see what happens.
Change the permission on one or two files (incl. the folder), reboot and see if the file/files you just edited are showing up in the ringtone list. If yes, then change the permissions on the rest of them.
I have no idea what to change the system folder permissions to...remember that they were set to drwxr-xr-x. I think it is more important to be able to provide access to third party apps, that way I could temporarily choose ringtones etc using those. However I cannot access the permissions for the folder of the internal memory via my file explorer apps, even with full root access. That has to be a contributory factor to the problem. I wonder, would you mind having a look at the permissions for these folders on your device and telling me what they are compared to the system version?
Also, I would like someone else's take on this, would anyone else care to comment please?
OK, same problem, different tack: can anyone please tell me which partition I would need to reflash from a ROM or TWRP backup to restore the system media sounds and settings to original without losing my data or root? Also does it need to be the same ROM version, or can I flash a different ROM, but still a version of Lollipop? For example, could I simply extract the relevant partition from the recent 5.1.1. ROM, or would I then lose root too, or could it come from a 5.0.1 ROM, but slightly different from the one presently installed? I have several TWRP backups, but unfortunately for some reason they included the TA information (ta.mmc.win) which causes a bootloop when I try and reboot the system after flashing, and I have yet to find a way to exclude them from the restore process.

Local file encryption app: watched folder & NO Internet permissions?

I'm looking for an app to encrypt files on my phone. I want the app to use a"watched folder ", automatically encrypting any file I save in there. The app should rename files to random filenames, provide its own file browser to show original filenames of course, and have NO Internet permissions so that I can trust that my local encrypted files couldn't get uploaded by a shady fake encryption app.
These seem commonsense criteria. What app do you use that meets them?
BlaqC said:
I'm looking for an app to encrypt files on my phone. I want the app to use a"watched folder ", automatically encrypting any file I save in there. The app should rename files to random filenames, provide its own file browser to show original filenames of course, and have NO Internet permissions so that I can trust that my local encrypted files couldn't get uploaded by a shady fake encryption app.
These seem commonsense criteria. What app do you use that meets them?
Click to expand...
Click to collapse
Try Andrognito.

Extracting a calendar file from TWRP backup

Before my old device died on me (Motorola), I did a TWRP and TB backup but I forgot to backup the devices internal calendar (using Business Calendar 2). When I restored everything to the new device (Sony) using TB, it didn't restore the calendar entries.
Is there anything I can do to get them back?
*I can't use the TWRP backup in Titanium as it is 8GB and I don't have the space on the internal memory and I can't find a way to point it to an external source.
*I have tried renaming the data.f2fs.win000 file to a ZIP in Windows, going to 'data\data\com.android.providers.calendar\databases\' and copying the calendar.db and calendar.db-journal file to the same place of the new device (backing up then deleting what was there first) but that just caused all calendar apps to FC after restarting.
*I have compared the calendar.db file from the TWRP backup to the original one on the Sony in Notepad and it shows the entries I am missing, so I know I am close, I just can't restore them to the new device.
Is it possible to convert DB to a ICS file or am I looking in completely the wrong place on the backup?
I can't extract the whole 'data\data\com.android.providers.calendar\databases\' folder in Windows, because it moans about the filename length as I thought maybe copying the whole folder instead of the two above files to the new device would solve it.
Any help would be appreciated.
If you copy the db files in then using a file manager change the ownership and group to match the parent directory and also set permissions rw,r,r do you still get a fc?
DestructoS said:
If you copy the db files in then using a file manager change the ownership and group to match the parent directory and also set permissions rw,r,r do you still get a fc?
Click to expand...
Click to collapse
All the folders in the com.android.providers.calendar on the new device are set to 0771, both files in the database folder that I copied across were already 0644. The owner and the group are both set to root, not sure if that is correct or it needs to be set to app_28 which is Calendar Storage.
You will need to change the owner and group to app_28 or the calendar can't write to them. Edit: of course that is if app_28 is your calendar id, check the parent folders to see. Edit 2: As far as I remember folders should also be 775 within data/data.
DestructoS said:
You will need to change the owner and group to app_28 or the calendar can't write to them. Edit: of course that is if app_28 is your calendar id, check the parent folders to see. Edit 2: As far as I remember folders should also be 775 within data/data.
Click to expand...
Click to collapse
Thanks, all sorted!

ADB functions clarification and usage for data transfer/backup on an image disk

Hello xda-developers,
I'm trying to figure out the proper way to transfer app data from an Android image disk. I'm very new to this, so I hope I'm not missing something basic.
Situation. I have a .img disk image file obtained from a .vmdk file via a virtualbox conversion , the latter being created by an Android emulator. I'm trying to recover some app data and transfer that to a new, working, .img disk. The emulator works on Android 4.4.2, if that matters.
What I did. I extracted apks and copied app data folders (com.<devname>.<appname>) from/to the /data/data directory. I did that using a file manager (ES file explorer) or via the cp command, as I found in many tutorials and guides. Others suggested to copy those folders to /Android/data instead, so I did try that as well. These procedures were ineffective, because they both messed up with folders and files permissions. Although cp -ar retains folders/files permissions and ownership, that was of no use after the import into the working image. Those operations were performed on Ubuntu 18.04.
The problem (and a workaround). When the apks are installed, a new uid (in the 10000 group) is generated for them. These values are unknown when I import the data folders, hence they are destroyed at phone boot. A log in /data/system/uiderrors.txt confirms this. The only way I could make it work was to install the apk from scratch, open the app so that the new data folders are created with a proper uid, replace those folders with old ones and manually change ownership and permissions accordingly (for every apk). This turned out to be effective but it's a very tedious and error-prone process.
What am I doing wrong? How do ADB push, pull and backup commands manage folders permissions/ownership and app uids? Could they be useful in my situation? If so, how can I use them on a .img file?
Thank you.

Categories

Resources