From 841cbc0cc669f800f43f4b16d2673ef03b6132e5 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Tue, 23 Nov 1999 19:17:31 +0000 Subject: [PATCH] Disable core dumps before we ask the user for a pass phrase. Suggested by . --- acconfig.h | 8 ++++++++ configure.in | 3 +++ doc/PGP-Notes.txt | 12 ------------ pgp.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/acconfig.h b/acconfig.h index 1264494d9..ed84a2bef 100644 --- a/acconfig.h +++ b/acconfig.h @@ -156,3 +156,11 @@ /* Define to `int' if 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 diff --git a/configure.in b/configure.in index 02671df33..9da68e9e7 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/doc/PGP-Notes.txt b/doc/PGP-Notes.txt index a5faa654e..bdf794298 100644 --- a/doc/PGP-Notes.txt +++ b/doc/PGP-Notes.txt @@ -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 f533b9e20..94129f53a 100644 --- a/pgp.c +++ b/pgp.c @@ -39,6 +39,14 @@ #include #include +#ifdef HAVE_SYS_RESOURCE_H +# include +#endif + +#ifdef HAVE_SYS_TIME_H +# include +#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 (); -- 2.40.0