]> granicus.if.org Git - mutt/commitdiff
Disable core dumps before we ask the user for a pass phrase.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 23 Nov 1999 19:17:31 +0000 (19:17 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 23 Nov 1999 19:17:31 +0000 (19:17 +0000)
Suggested by <Stefan.Alfredsson@kau.se>.

acconfig.h
configure.in
doc/PGP-Notes.txt
pgp.c

index 1264494d9cda0c5d0bcb0b7d00fe0a41d4fe7924..ed84a2bef1c024141c6fb08d0dcc7da4fd7368bc 100644 (file)
 /* Define to `int' if <signal.h> doesn't define.  */
 #undef sig_atomic_t
 
+/* define when your system has sys/time.h */
+#undef HAVE_SYS_TIME_H
+
+/* define when your system has sys/resource.h */
+#undef HAVE_SYS_RESOURCE_H
+
+/* define when your system has the setrlimit function */
+#undef HAVE_SETRLIMIT
index 02671df332a6cafdbac91a46c01b435211ac2ef7..9da68e9e72e79f55569590926002d78f90d85f79 100644 (file)
@@ -209,6 +209,9 @@ main ()
 AC_HEADER_STDC
 
 AC_CHECK_HEADERS(stdarg.h sys/ioctl.h sysexits.h)
+AC_CHECK_HEADERS(sys/time.h sys/resource.h)
+
+AC_CHECK_FUNCS(setrlimit)
 
 AC_TYPE_SIGNAL
 
index a5faa654e04593628e8f4dd605f92cbfa1aa2da8..bdf79429879d05fbe904e2fd4705e50004f793ed 100644 (file)
@@ -124,18 +124,6 @@ as well.
 
 
 
-Q: "Isn't there a security problem that mutt leaves the
-    passphrase in memory which will be dumped into core
-    files upon errors?"
-
-Yes, you may consider this a security problem.  To work
-around this, disable core dumps using resource limits.  On
-most systems, this will be the following instruction in
-your shell:
-
-       ulimit -c 0
-
-
 
 
 
diff --git a/pgp.c b/pgp.c
index f533b9e2000f033ee0047d0002385edf19cc3b80..94129f53ae53bc3f162a4591faa33b05f5163329 100644 (file)
--- a/pgp.c
+++ b/pgp.c
 #include <errno.h>
 #include <ctype.h>
 
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+
 #ifdef _PGPPATH
 
 
@@ -51,10 +59,30 @@ void pgp_void_passphrase (void)
   PgpExptime = 0;
 }
 
+# if defined(HAVE_SETRLIMIT) && (!defined(DEBUG))
+
+static void disable_coredumps (void)
+{
+  struct rlimit rl = {0, 0};
+  static short done = 0;
+
+  if (!done)
+  {
+    setrlimit (RLIMIT_CORE, &rl);
+    done = 1;
+  }
+}
+
+# endif /* HAVE_SETRLIMIT */
+
 int pgp_valid_passphrase (void)
 {
   time_t now = time (NULL);
 
+# if defined(HAVE_SETRLIMIT) && (!defined(DEBUG))
+  disable_coredumps ();
+# endif
+
   if (now < PgpExptime) return 1; /* just use the cached copy. */
   pgp_void_passphrase ();