]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use prctl to reenable core dumps when we have setuid to a non-root user.
authorNick Mathewson <nickm@torproject.org>
Mon, 9 Feb 2009 15:20:17 +0000 (15:20 +0000)
committerNick Mathewson <nickm@torproject.org>
Mon, 9 Feb 2009 15:20:17 +0000 (15:20 +0000)
svn:r18449

ChangeLog
configure.in
src/common/compat.c

index 23ceaea4e9cbd972d67cef7810d9bdeda95b8145..306eacb41613fc712389cc299fa1afc00526dd87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
 Changes in version 0.2.1.13-????? - 2009-0?-??
+  o Minor features:
+    - On Linux, use the prctl call to re-enable core dumps when the user
+      is option is set.
 
 
 Changes in version 0.2.1.12-alpha - 2009-02-08
index 22a47b90681a143c589d9b7d226da79f54aa1831..8610c3a5245e3fa46260393e278ca2f483c74bc5 100644 (file)
@@ -196,7 +196,7 @@ dnl -------------------------------------------------------------------
 dnl Check for functions before libevent, since libevent-1.2 apparently
 dnl exports strlcpy without defining it in a header.
 
-AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull getaddrinfo localtime_r gmtime_r memmem strtok_r writev readv flock)
+AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit strlcat strlcpy strtoull getaddrinfo localtime_r gmtime_r memmem strtok_r writev readv flock prctl)
 
 using_custom_malloc=no
 if test x$enable_openbsd_malloc = xyes ; then
@@ -328,7 +328,7 @@ AC_CHECK_HEADERS(netdb.h sys/ioctl.h sys/socket.h arpa/inet.h netinet/in.h pwd.h
 
 dnl These headers are not essential
 
-AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h limits.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h inttypes.h utime.h sys/utime.h sys/mman.h netinet/in6.h malloc.h sys/syslimits.h malloc/malloc.h linux/types.h sys/file.h malloc_np.h)
+AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h limits.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h inttypes.h utime.h sys/utime.h sys/mman.h netinet/in6.h malloc.h sys/syslimits.h malloc/malloc.h linux/types.h sys/file.h malloc_np.h sys/prctl.h)
 
 TOR_CHECK_PROTOTYPE(malloc_good_size, HAVE_MALLOC_GOOD_SIZE_PROTOTYPE,
 [#ifdef HAVE_MALLOC_H
index fa6967289da375881ed7f8e72056b83ae8b2cfb4..23efe0b65604dcc033ef3f6473d1211cee61ff76 100644 (file)
 #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