Bug#21723: Should be able to dump core after setuid() under Linux

In many cases, binaries can no longer dump core after calling setuid().

Where the PR_SET_DUMPABLE macro is set, use the prctl() system call 
to tell the kernel that it's allowed to dump the core of the server.
parent dc406f2d
......@@ -776,6 +776,7 @@ AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \
sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \
unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \
sys/ioctl.h malloc.h sys/malloc.h sys/ipc.h sys/shm.h linux/config.h \
sys/prctl.h \
sys/resource.h sys/param.h)
#--------------------------------------------------------------------
......
......@@ -32,6 +32,9 @@
#ifdef HAVE_NDBCLUSTER_DB
#include "ha_ndbcluster.h"
#endif
#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
#ifdef HAVE_INNOBASE_DB
#define OPT_INNODB_DEFAULT 1
......@@ -1365,6 +1368,15 @@ static struct passwd *check_user(const char *user)
err:
sql_print_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user);
unireg_abort(1);
#ifdef PR_SET_DUMPABLE
if (test_flags & TEST_CORE_ON_SIGNAL)
{
/* inform kernel that process is dumpable */
(void) prctl(PR_SET_DUMPABLE, 1);
}
#endif
#endif
return NULL;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment