From: tfheen Date: Fri, 29 Aug 2008 12:35:00 +0000 (+0000) Subject: Make it possible to get core dumps on Linux too X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0a2cadc940d23855caf21d2e699533b6b33d0cf;p=varnish 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: svn+ssh://projects.linpro.no/svn/varnish/trunk@3145 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index cd6af037..88aeb7a5 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -50,6 +50,10 @@ #include "compat/setproctitle.h" #endif +#ifdef __linux__ +#include +#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);