From f99098cca406369aeff149bd5e70662de934ec08 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 9 Feb 2009 15:20:17 +0000 Subject: Use prctl to reenable core dumps when we have setuid to a non-root user. svn:r18449 --- src/common/compat.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/common/compat.c') diff --git a/src/common/compat.c b/src/common/compat.c index fa6967289d..23efe0b656 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -83,6 +83,10 @@ #ifdef HAVE_SYS_FILE_H #include #endif +#if defined(HAVE_SYS_PRCTL_H) && defined(__linux__) +/* Only use the linux prctl; the IRIX prctl is totally different */ +#include +#endif #include "log.h" #include "util.h" @@ -1223,6 +1227,18 @@ switch_id(const char *user) } have_already_switched_id = 1; /* mark success so we never try again */ + +#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && defined(HAVE_PRCTL) +#ifdef PR_SET_DUMPABLE + if (pw->pw_uid) { + /* Re-enable core dumps if we're not running as root. */ + log_info(LD_CONFIG, "Re-enabling coredumps"); + if (prctl(PR_SET_DUMPABLE, 1)) { + log_warn(LD_CONFIG, "Unable to re-enable coredumps: %s",strerror(errno)); + } + } +#endif +#endif return 0; #else -- cgit v1.2.3-54-g00ecf