Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Heap dump permissions

The java heap dumps generated in a Linux Machine (and most probably Unix machines as well) have restricted access. The heap can only be read by the owner of the process (ACL mask is set to 600). I understand that this is for security reasons. However, I was not able to find any documentation referencing or explaining the behavior. Can anyone point me to the documentation (if any)? Also, is there any way to override this behavior?

like image 926
Abhilash Koneri Avatar asked Oct 04 '12 18:10

Abhilash Koneri


1 Answers

If you are interested in deep JVM internals, you can check the source code for OpenJDK.

Here is a link for the HeapDumper service: http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/9b0ca45cd756/src/share/vm/services/heapDumper.cpp

If you dig in, you'll see JVM is creating binary files with S_IREAD | S_IWRITE

 4373 // create binary file, rewriting existing file if required
 4374 int os::create_binary_file(const char* path, bool rewrite_existing) {
 4375   int oflags = O_WRONLY | O_CREAT;
 4376   if (!rewrite_existing) {
 4377     oflags |= O_EXCL;
 4378   }
 4379   return ::open64(path, oflags, S_IREAD | S_IWRITE);
 4380 }
like image 178
fglez Avatar answered Oct 03 '22 22:10

fglez