aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-02-09 15:20:17 +0000
committerNick Mathewson <nickm@torproject.org>2009-02-09 15:20:17 +0000
commitf99098cca406369aeff149bd5e70662de934ec08 (patch)
tree66f8afee80134ab251508953e952256eedced225 /src/common/compat.c
parentf95ab837929d0b70ecc87e052f58a2038408c54b (diff)
downloadtor-f99098cca406369aeff149bd5e70662de934ec08.tar
tor-f99098cca406369aeff149bd5e70662de934ec08.tar.gz
Use prctl to reenable core dumps when we have setuid to a non-root user.
svn:r18449
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index fa6967289..23efe0b65 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -83,6 +83,10 @@
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
+#if defined(HAVE_SYS_PRCTL_H) && defined(__linux__)
+/* Only use the linux prctl; the IRIX prctl is totally different */
+#include <sys/prctl.h>
+#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