]> granicus.if.org Git - mutt/commitdiff
Here is the pgp_check_exit patch updated for 1.5.4. This patch adds
authorDavid Shaw <dshaw@jabberwocky.com>
Wed, 2 Apr 2003 08:28:24 +0000 (08:28 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Wed, 2 Apr 2003 08:28:24 +0000 (08:28 +0000)
the pgp_check_exit option (enabled by default) that causes mutt to
check the exit code of the PGP subprocess.  A non-zero exit code means
that the subprocess failed and mutt will not continue to send the
message.

This is needed as in certain cases, PGP or GnuPG can fail to
completely process a document (say, if the gpg.conf file is mangled,
which is how I discovered the problem).  Without an exit code check,
mutt will continue anyway and send the half processed file.

init.h
mutt.h
pgp.c

diff --git a/init.h b/init.h
index 6bd74143b6456f89a4ce393f43a5cdfa34ea4777..10e66ab9ef423a1d68b7f71540c9df546fdfaa79 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1335,6 +1335,14 @@ struct option_t MuttVars[] = {
   ** even for bad signatures.
   ** (PGP only)
   */ 
+  { "pgp_check_exit",  DT_BOOL, R_NONE, OPTPGPCHECKEXIT, 1 },
+  /*
+  ** .pp
+  ** If set, mutt will check the exit code of the PGP subprocess when
+  ** signing or encrypting.  A non-zero exit code means that the
+  ** subprocess failed.
+  ** (PGP only)
+  */
   { "pgp_long_ids",    DT_BOOL, R_NONE, OPTPGPLONGIDS, 0 },
   /*
   ** .pp
diff --git a/mutt.h b/mutt.h
index 9b9c29d38161b639a737779d55c9ae207ecab09b..9d6629c9c7e0a1422411a4a91b2d52cd372f474f 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -435,6 +435,7 @@ enum
   OPTASKCERTLABEL,
   OPTSDEFAULTDECRYPTKEY,
   OPTPGPIGNORESUB,
+  OPTPGPCHECKEXIT,
   OPTPGPLONGIDS,
   OPTPGPAUTOTRAD,
 #if 0
diff --git a/pgp.c b/pgp.c
index b0ccd6e047ff56b925e300a8d9c1293226d81d28..e61c0e0f5fd000711b6993b9f414f437bca0c01b 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -945,7 +945,9 @@ BODY *pgp_sign_message (BODY *a)
     fputs (buffer, stdout);
   }
 
-  mutt_wait_filter (thepid);
+  if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
+    empty=1;
+
   fclose (pgperr);
   fclose (pgpout);
   unlink (signedfile);
@@ -1128,7 +1130,7 @@ BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   FILE *pgpin, *pgperr, *fpout, *fptmp;
   BODY *t;
   int err = 0;
-  int empty;
+  int empty = 0;
   pid_t thepid;
   
   mutt_mktemp (tempfile);
@@ -1183,12 +1185,15 @@ BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   }
   fclose(pgpin);
   
-  mutt_wait_filter (thepid);
+  if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
+    empty=1;
+
   unlink(pgpinfile);
   
   fflush (fpout);
   rewind (fpout);
-  empty = (fgetc (fpout) == EOF);
+  if(!empty)
+    empty = (fgetc (fpout) == EOF);
   fclose (fpout);
 
   fflush (pgperr);
@@ -1254,7 +1259,7 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   FILE *pgpout = NULL, *pgperr = NULL, *pgpin = NULL;
   FILE *fp;
 
-  int empty;
+  int empty = 0;
   int err;
 
   char buff[STRING];
@@ -1351,7 +1356,8 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
     fprintf (pgpin, "%s\n", PgpPass);
   fclose (pgpin);
 
-  mutt_wait_filter (thepid);
+  if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
+    empty=1;
 
   mutt_unlink (pgpinfile);
 
@@ -1361,7 +1367,8 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   rewind (pgpout);
   rewind (pgperr);
   
-  empty = (fgetc (pgpout) == EOF);
+  if(!empty)
+    empty = (fgetc (pgpout) == EOF);
   fclose (pgpout);
   
   err = 0;