Commit 0ce742c4 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Make it possible to get core dumps on Linux too

When starting as root and then setuid-ing, we need to set the dumpable
bit to get core dumps on Linux.  Do so.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3145 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent b3b8e222
......@@ -50,6 +50,10 @@
#include "compat/setproctitle.h"
#endif
#ifdef __linux__
#include <sys/prctl.h>
#endif
#include "heritage.h"
#include "mgt.h"
#include "cli.h"
......@@ -283,6 +287,15 @@ start_child(struct cli *cli)
XXXAZ(setuid(params->uid));
}
/* On Linux >= 2.4, you need to set the dumpable flag
to get core dumps after you have done a setuid. */
#ifdef __linux__
if (prctl(PR_SET_DUMPABLE, 1) != 0) {
printf("Could not set dumpable bit. Core dumps turned "
"off\n");
}
#endif
/* Redirect stdin/out/err */
AZ(close(STDIN_FILENO));
assert(open("/dev/null", O_RDONLY) == STDIN_FILENO);
......
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