From: David Shaw Date: Wed, 2 Apr 2003 08:28:24 +0000 (+0000) Subject: Here is the pgp_check_exit patch updated for 1.5.4. This patch adds X-Git-Tag: pre-type-punning-patch~126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d732d6f612db58f8e40f84d0232b75956c3fa849;p=mutt Here is the pgp_check_exit patch updated for 1.5.4. This patch adds 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. --- diff --git a/init.h b/init.h index 6bd74143..10e66ab9 100644 --- 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 9b9c29d3..9d6629c9 100644 --- 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 b0ccd6e0..e61c0e0f 100644 --- 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;