r3145 - trunk/varnish-cache/bin/varnishd

tfheen at projects.linpro.no tfheen at projects.linpro.no
Fri Aug 29 14:35:00 CEST 2008


Author: tfheen
Date: 2008-08-29 14:35:00 +0200 (Fri, 29 Aug 2008)
New Revision: 3145

Modified:
   trunk/varnish-cache/bin/varnishd/mgt_child.c
Log:
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.


Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c	2008-08-29 11:52:26 UTC (rev 3144)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c	2008-08-29 12:35:00 UTC (rev 3145)
@@ -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 @@
 			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);




More information about the varnish-commit mailing list