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: svn+ssh://projects.linpro.no/svn/varnish/trunk@3145
d4fa192b-c00b-0410-8231-
f00ffab90ce4
#include "compat/setproctitle.h"
#endif
+#ifdef __linux__
+#include <sys/prctl.h>
+#endif
+
#include "heritage.h"
#include "mgt.h"
#include "cli.h"
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);