]> err.no Git - varnish/commitdiff
Make it possible to get core dumps on Linux too
authortfheen <tfheen@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 29 Aug 2008 12:35:00 +0000 (12:35 +0000)
committertfheen <tfheen@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 29 Aug 2008 12:35:00 +0000 (12:35 +0000)
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

index cd6af037c4232c25b5826e62f5bbb0ab9c1d05a3..88aeb7a595bd8a42bd75c56d8f0ea948a90c703c 100644 (file)
 #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);