26 Feb 18:52
Re: GnuPG, mutt, and exit codes
David Shaw <dshaw <at> jabberwocky.com>
2003-02-26 17:52:24 GMT
2003-02-26 17:52:24 GMT
On Wed, Feb 26, 2003 at 11:16:02AM +0100, Thomas Roessler wrote: > On 2003-02-25 18:48:25 -0500, David Shaw wrote: > > > GnuPG does set a non-zero exit code when it fails. Is there some > > reason that mutt doesn't check it? Here's a patch. > > I'm not entirely sure any more, but this rings some bell in the back > of my mind that old PGP versions may return "failure" exit codes > when encryption succeeds, but the recipients' keys weren't > completely valid. So, yes, I think there was some reason for doing > it this way. Hmm. I wouldn't want to break things for old versions. Here's an updated patch that adds an $pgp_check_exit option, enabled by default. > (On the other hand -- who uses PGP 2.6 any more?) Judging by the email I get about interoperability, a very small, but VERY vocal group.. David
? autom4te-2.53.cache
? stamp-h1
Index: init.h
===================================================================
RCS file: /home/roessler/cvs/mutt/init.h,v
retrieving revision 3.34
diff -u -r3.34 init.h
--- init.h 13 Feb 2003 09:55:02 -0000 3.34
+++ init.h 26 Feb 2003 17:48:30 -0000
@@ -1328,6 +1328,14 @@
** 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
Index: mutt.h
===================================================================
RCS file: /home/roessler/cvs/mutt/mutt.h,v
retrieving revision 3.14
diff -u -r3.14 mutt.h
--- mutt.h 30 Jan 2003 23:54:30 -0000 3.14
+++ mutt.h 26 Feb 2003 17:48:30 -0000
@@ -434,6 +434,7 @@
OPTASKCERTLABEL,
OPTSDEFAULTDECRYPTKEY,
OPTPGPIGNORESUB,
+ OPTPGPCHECKEXIT,
OPTPGPLONGIDS,
OPTPGPAUTOTRAD,
#if 0
Index: pgp.c
===================================================================
RCS file: /home/roessler/cvs/mutt/pgp.c,v
retrieving revision 3.23
diff -u -r3.23 pgp.c
--- pgp.c 13 Feb 2003 09:50:00 -0000 3.23
+++ pgp.c 26 Feb 2003 17:48:31 -0000
@@ -945,7 +945,9 @@
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 @@
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 @@
}
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 @@
FILE *pgpout = NULL, *pgperr = NULL, *pgpin = NULL;
FILE *fp;
- int empty;
+ int empty = 0;
int err;
char buff[STRING];
@@ -1351,7 +1356,8 @@
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 @@
rewind (pgpout);
rewind (pgperr);
- empty = (fgetc (pgpout) == EOF);
+ if(!empty)
+ empty = (fgetc (pgpout) == EOF);
fclose (pgpout);
err = 0;
RSS Feed