From d0a2cadc940d23855caf21d2e699533b6b33d0cf Mon Sep 17 00:00:00 2001 From: tfheen Date: Fri, 29 Aug 2008 12:35:00 +0000 Subject: [PATCH] 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 --- varnish-cache/bin/varnishd/mgt_child.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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); -- 2.39.5