2

I'm trying to change the Dalvik VM in order to extract an extra file to the dalvik-cache directory when the dex file is being extracted by JarFile.cpp. The problem is when I use open() function I'm getting permission denied!

I'm aware that the permissions of the dalvik-cache are "system system", but I see in it other permissions for u0_a## for dex file.

I can create the dex file in the dalvik-cache but not other types of files. How can that be? What's preventing me on file types to create files?

Community
  • 1
  • 1
AgentK
  • 75
  • 7

1 Answers1

4

Applications do not have permission to create files in /data/dalvik-cache. Neither does dexopt.

The installd command does have permission, so it creates the file entry and passes an open file descriptor as an argument to dexopt.

The only time dexopt directly creates files is on engineering builds, where the initial bootstrap classes are created when the zygote process starts. At that point it's running as root with full capabilities.

To create an additional file you'd need to modify installd.

fadden
  • 51,356
  • 5
  • 116
  • 166
  • Thanks for the reply. How can I create the file whenever an app starts (so I can delete it after I'm doe with it)? And not just on install? – AgentK May 20 '14 at 14:44
  • You can't create it there. By the time the app VM is running it doesn't have permission to do so. Of course, if you can install a modified copy of libdvm.so, you can also just change the file permissions on the directory to 777 (assuming you're not worried about security). – fadden May 20 '14 at 14:47
  • I am worried about security ;) I have access to the whole source code of both the FS and the kernel. Probably then, I'll use the app directory with the same permissions to hold the file. I will need to find the spot to do so. – AgentK May 20 '14 at 14:52
  • Utilizing su for modifications could be a solution. With root access, you can work in /data/dalvik-cache/ – sweisgerber.dev Jan 22 '16 at 10:43