diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-02-09 15:20:17 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-02-09 15:20:17 +0000 |
commit | f99098cca406369aeff149bd5e70662de934ec08 (patch) | |
tree | 66f8afee80134ab251508953e952256eedced225 /src | |
parent | f95ab837929d0b70ecc87e052f58a2038408c54b (diff) | |
download | tor-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')
-rw-r--r-- | src/common/compat.c | 16 |
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 |