Dropping root privileges and still generate coredumps
You have to enable core dumps for applications that have their privileges changed:
echo 2 > /proc/sys/fs/suid_dumpable
I advice you to put that in /etc/rc.local
.
For example, here's what I have there:
# This is to enable debugging as a normal user, rather than rootsysctl kernel.yama.ptrace_scope=0# This is a convenient core file pattern # '%e' is the name of the process# '%p' is the pid of processsysctl kernel.core_pattern="/tmp/core.%e.%p"# Enable dump for processes with lowered privilegesecho 2 > /proc/sys/fs/suid_dumpable# Remove limit for the size of core filesulimit -c unlimited
Edit:
You can take a look at this neat library, that allows you to manually write core dumps to a custom file : https://code.google.com/p/google-coredumper/
I believe it's exactly what you need.