get core dumps on Linux

Peter Waechtler peter at helios.de
Tue Apr 27 09:40:15 GMT 2004


The problem described in the nice SAMBA-HOWTO-Collection
that one does not get a core dump on Linux for programs that
did switch uid can be circumvented in user space.
I added the following code snippets to our SMB fileserver PCShare.

I tried to convince the great dictator^H^H^H Linus but failed;)
http://marc.theaimsgroup.com/?l=linux-kernel&m=108266468032187&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=108274739619516&w=2

BTW, the kill() in the sighandler is for SIGABRT - SEGV and BUS
will return to the faulting instruction and immediatly trap again but
not when sending a "kill -11" or likewise.

#if defined(__linux__)
#include <sys/prctl.h>

static void fatal_sighandler(int signum)
{
	/* ensure the core dump is owned by root, but Linux has a flaw here */
	seteuid(0);
        prctl(PR_SET_DUMPABLE,1,0,0,0);
        signal(signum, SIG_DFL);
        kill(getpid(),signum);
}
#endif

#if defined(__linux__)
        signal(SIGSEGV, fatal_sighandler);
        signal(SIGABRT, fatal_sighandler);
        signal(SIGBUS, fatal_sighandler);
#endif




More information about the samba-technical mailing list