X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-crypt%2Fpgp.c;h=ea63f2c76eb33833e0589e0352bacef8d8deb146;hp=038ba8112ef3ce22fb19f68cce0cb21e0be8e756;hb=9ed7a487e3a922f2cbb222961c2c9710c3a65f91;hpb=1ffe18af5bf2fda6f7dc86c514b56c6a82ec3040 diff --git a/lib-crypt/pgp.c b/lib-crypt/pgp.c index 038ba81..ea63f2c 100644 --- a/lib-crypt/pgp.c +++ b/lib-crypt/pgp.c @@ -17,51 +17,26 @@ * a message. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif +#include -#include -#include -#include -#include -#include +#ifdef HAVE_SYS_RESOURCE_H +# include +#endif #include +#include #include #include +#include +#include -#include "mutt.h" #include "handler.h" #include "pgp.h" #include "copy.h" #include "attach.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_LOCALE_H -#include -#endif - -#ifdef HAVE_SYS_TIME_H -# include -#endif - -#ifdef HAVE_SYS_RESOURCE_H -# include -#endif - #include "crypt.h" -#include "mutt_menu.h" char PgpPass[LONG_STRING]; @@ -148,15 +123,12 @@ static int pgp_copy_checksig (FILE * fpin, FILE * fpout) if (PgpGoodSign.pattern) { char *line = NULL; int lineno = 0; - size_t linelen; + ssize_t linelen; while ((line = mutt_read_line (line, &linelen, fpin, &lineno)) != NULL) { if (regexec (PgpGoodSign.rx, line, 0, NULL, 0) == 0) { - debug_print (2, ("\"%s\" matches regexp.\n", line)); rv = 0; } - else - debug_print (2, ("\"%s\" doesn't match regexp.\n", line)); if (strncmp (line, "[GNUPG:] ", 9) == 0) continue; @@ -166,7 +138,6 @@ static int pgp_copy_checksig (FILE * fpin, FILE * fpout) p_delete(&line); } else { - debug_print (2, ("No pattern.\n")); mutt_copy_stream (fpin, fpout); rv = 1; } @@ -192,7 +163,7 @@ static void pgp_copy_clearsigned (FILE * fpin, STATE * s, char *charset) char buf[HUGE_STRING]; short complete, armor_header; - FGETCONV *fc; + fgetconv_t *fc; rewind (fpin); @@ -295,8 +266,8 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) have_any_sigs = have_any_sigs || (clearsign && (s->flags & M_VERIFY)); /* Copy PGP material to temporary file */ - mutt_mktemp (tmpfname); - if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL) { + tmpfp = m_tempfile(tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL); + if (tmpfp == NULL) { mutt_perror (tmpfname); return (-1); } @@ -324,16 +295,16 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) /* Invoke PGP if needed */ if (!clearsign || (s->flags & M_VERIFY)) { - mutt_mktemp (outfile); - if ((pgpout = safe_fopen (outfile, "w+")) == NULL) { - mutt_perror (tmpfname); + pgpout = m_tempfile(outfile, sizeof(outfile), NONULL(Tempdir), NULL); + if (pgpout == NULL) { + mutt_perror (outfile); return (-1); } if ((thepid = pgp_invoke_decode (&pgpin, NULL, &pgperr, -1, fileno (pgpout), -1, tmpfname, needpass)) == -1) { - safe_fclose (&pgpout); + m_fclose(&pgpout); maybe_goodsig = 0; pgpin = NULL; pgperr = NULL; @@ -351,14 +322,14 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) fprintf (pgpin, "%s\n", PgpPass); } - safe_fclose (&pgpin); + m_fclose(&pgpin); if (s->flags & M_DISPLAY) { crypt_current_time (s, "PGP"); rc = pgp_copy_checksig (pgperr, s->fpout); } - safe_fclose (&pgperr); + m_fclose(&pgperr); rv = mutt_wait_filter (thepid); if (s->flags & M_DISPLAY) { @@ -419,8 +390,7 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) pgp_copy_clearsigned (tmpfp, s, body_charset); } else if (pgpout) { - FGETCONV *fc; - int c; + fgetconv_t *fc; rewind (pgpout); state_set_prefix (s); @@ -460,11 +430,11 @@ out: m->goodsig = (maybe_goodsig && have_any_sigs); if (tmpfp) { - safe_fclose (&tmpfp); + m_fclose(&tmpfp); mutt_unlink (tmpfname); } if (pgpout) { - safe_fclose (&pgpout); + m_fclose(&pgpout); mutt_unlink (outfile); } @@ -516,7 +486,7 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, key = 1; } } - safe_fclose (&tfp); + m_fclose(&tfp); unlink (tempfile); if (!enc && !sgn && !key) @@ -524,13 +494,13 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, /* fix the content type */ - mutt_set_parameter ("format", "fixed", &b->parameter); + parameter_setval(&b->parameter, "format", "fixed"); if (enc) - mutt_set_parameter ("x-action", "pgp-encrypted", &b->parameter); + parameter_setval(&b->parameter, "x-action", "pgp-encrypted"); else if (sgn) - mutt_set_parameter ("x-action", "pgp-signed", &b->parameter); + parameter_setval(&b->parameter, "x-action", "pgp-signed"); else if (key) - mutt_set_parameter ("x-action", "pgp-keys", &b->parameter); + parameter_setval(&b->parameter, "x-action", "pgp-keys"); return 1; } @@ -575,10 +545,10 @@ int pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempfile) fseeko (s->fpin, sigbdy->offset, 0); mutt_copy_bytes (s->fpin, fp, sigbdy->length); - fclose (fp); + m_fclose(&fp); - mutt_mktemp (pgperrfile); - if (!(pgperr = safe_fopen (pgperrfile, "w+"))) { + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + if (pgperr == NULL) { mutt_perror (pgperrfile); unlink (sigfile); return -1; @@ -593,7 +563,7 @@ int pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempfile) badsig = 0; - safe_fclose (&pgpout); + m_fclose(&pgpout); fflush (pgperr); rewind (pgperr); @@ -602,88 +572,29 @@ int pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempfile) if ((rv = mutt_wait_filter (thepid))) badsig = -1; - - debug_print (1, ("mutt_wait_filter returned %d.\n", rv)); } - safe_fclose (&pgperr); + m_fclose(&pgperr); state_attach_puts (_("[-- End of PGP output --]\n\n"), s); mutt_unlink (sigfile); mutt_unlink (pgperrfile); - debug_print (1, ("returning %d.\n", badsig)); - return badsig; } /* Extract pgp public keys from messages or attachments */ -void pgp_extract_keys_from_messages (HEADER * h) -{ - int i; - char tempfname[_POSIX_PATH_MAX]; - FILE *fpout; - - if (h) { - mutt_parse_mime_message (Context, h); - if (h->security & PGPENCRYPT && !pgp_valid_passphrase ()) - return; - } - - mutt_mktemp (tempfname); - if (!(fpout = safe_fopen (tempfname, "w"))) { - mutt_perror (tempfname); - return; - } - - set_option (OPTDONTHANDLEPGPKEYS); - - if (!h) { - for (i = 0; i < Context->vcount; i++) { - if (Context->hdrs[Context->v2r[i]]->tagged) { - mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]); - if (Context->hdrs[Context->v2r[i]]->security & PGPENCRYPT - && !pgp_valid_passphrase ()) { - fclose (fpout); - goto bailout; - } - mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]], - M_CM_DECODE | M_CM_CHARCONV, 0); - } - } - } - else { - mutt_parse_mime_message (Context, h); - if (h->security & PGPENCRYPT && !pgp_valid_passphrase ()) { - fclose (fpout); - goto bailout; - } - mutt_copy_message (fpout, Context, h, M_CM_DECODE | M_CM_CHARCONV, 0); - } - - fclose (fpout); - mutt_endwin (NULL); - pgp_invoke_import (tempfname); - mutt_any_key_to_continue (NULL); - -bailout: - - mutt_unlink (tempfname); - unset_option (OPTDONTHANDLEPGPKEYS); - -} - static void pgp_extract_keys_from_attachment (FILE * fp, BODY * top) { STATE s; FILE *tempfp; char tempfname[_POSIX_PATH_MAX]; - mutt_mktemp (tempfname); - if (!(tempfp = safe_fopen (tempfname, "w"))) { + tempfp = m_tempfile(tempfname, sizeof(tempfname), NONULL(Tempdir), NULL); + if (tempfp == NULL) { mutt_perror (tempfname); return; } @@ -695,7 +606,7 @@ static void pgp_extract_keys_from_attachment (FILE * fp, BODY * top) mutt_body_handler (top, &s); - fclose (tempfp); + m_fclose(&tempfp); pgp_invoke_import (tempfname); mutt_any_key_to_continue (NULL); @@ -737,17 +648,17 @@ BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p) pid_t thepid; int rv; - mutt_mktemp (pgperrfile); - if ((pgperr = safe_fopen (pgperrfile, "w+")) == NULL) { + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + if (pgperr == NULL) { mutt_perror (pgperrfile); return NULL; } unlink (pgperrfile); - mutt_mktemp (pgptmpfile); - if ((pgptmp = safe_fopen (pgptmpfile, "w")) == NULL) { + pgptmp = m_tempfile(pgptmpfile, sizeof(pgptmpfile), NONULL(Tempdir), NULL); + if (!pgptmp == NULL) { mutt_perror (pgptmpfile); - fclose (pgperr); + m_fclose(&pgperr); return NULL; } @@ -757,11 +668,11 @@ BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p) fseeko (s->fpin, a->offset, 0); mutt_copy_bytes (s->fpin, pgptmp, a->length); - fclose (pgptmp); + m_fclose(&pgptmp); if ((thepid = pgp_invoke_decrypt (&pgpin, &pgpout, NULL, -1, -1, fileno (pgperr), pgptmpfile)) == -1) { - fclose (pgperr); + m_fclose(&pgperr); unlink (pgptmpfile); if (s->flags & M_DISPLAY) state_attach_puts (_ @@ -776,7 +687,7 @@ BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p) if (!pgp_use_gpg_agent ()) fputs (PgpPass, pgpin); fputc ('\n', pgpin); - fclose (pgpin); + m_fclose(&pgpin); /* Read the output from PGP, and make sure to change CRLF to LF, otherwise * read_mime_header has a hard time parsing the message. @@ -788,7 +699,7 @@ BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p) fputs (buf, fpout); } - fclose (pgpout); + m_fclose(&pgpout); rv = mutt_wait_filter (thepid); mutt_unlink (pgptmpfile); @@ -801,7 +712,7 @@ BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p) p->goodsig = 0; state_attach_puts (_("[-- End of PGP output --]\n\n"), s); } - fclose (pgperr); + m_fclose(&pgperr); fflush (fpout); rewind (fpout); @@ -845,8 +756,8 @@ int pgp_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur) p_clear(&s, 1); s.fpin = fpin; - mutt_mktemp (tempfile); - if ((*fpout = safe_fopen (tempfile, "w+")) == NULL) { + *fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + if (*fpout == NULL) { mutt_perror (tempfile); return (-1); } @@ -886,8 +797,8 @@ int pgp_encrypted_handler (BODY * a, STATE * s) */ a = a->next; - mutt_mktemp (tempfile); - if ((fpout = safe_fopen (tempfile, "w+")) == NULL) { + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + if (fpout == NULL) { if (s->flags & M_DISPLAY) state_attach_puts (_ ("[-- Error: could not create temporary file! --]\n"), @@ -924,7 +835,7 @@ int pgp_encrypted_handler (BODY * a, STATE * s) state_attach_puts (_("[-- End of PGP/MIME encrypted data --]\n"), s); } - mutt_free_body (&tattach); + body_list_wipe(&tattach); /* clear 'Invoking...' message, since there's no error */ mutt_message _("PGP message successfully decrypted."); } else { @@ -933,7 +844,7 @@ int pgp_encrypted_handler (BODY * a, STATE * s) rc = -1; } - fclose (fpout); + m_fclose(&fpout); mutt_unlink (tempfile); return (rc); @@ -956,15 +867,15 @@ BODY *pgp_sign_message (BODY * a) convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */ - mutt_mktemp (sigfile); - if ((fp = safe_fopen (sigfile, "w")) == NULL) { + fp = m_tempfile(sigfile, sizeof(sigfile), NONULL(Tempdir), NULL); + if (fp == NULL) { return (NULL); } - mutt_mktemp (signedfile); - if ((sfp = safe_fopen (signedfile, "w")) == NULL) { + sfp = m_tempfile(signedfile, sizeof(signedfile), NONULL(Tempdir), NULL); + if (sfp == NULL) { mutt_perror (signedfile); - fclose (fp); + m_fclose(&fp); unlink (sigfile); return NULL; } @@ -972,13 +883,13 @@ BODY *pgp_sign_message (BODY * a) mutt_write_mime_header (a, sfp); fputc ('\n', sfp); mutt_write_mime_body (a, sfp); - fclose (sfp); + m_fclose(&sfp); if ((thepid = pgp_invoke_sign (&pgpin, &pgpout, &pgperr, -1, -1, -1, signedfile)) == -1) { mutt_perror (_("Can't open PGP subprocess!")); - fclose (fp); + m_fclose(&fp); unlink (sigfile); unlink (signedfile); return NULL; @@ -987,7 +898,7 @@ BODY *pgp_sign_message (BODY * a) if (!pgp_use_gpg_agent ()) fputs (PgpPass, pgpin); fputc ('\n', pgpin); - fclose (pgpin); + m_fclose(&pgpin); /* * Read back the PGP signature. Also, change MESSAGE=>SIGNATURE as @@ -1013,11 +924,11 @@ BODY *pgp_sign_message (BODY * a) if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT)) empty = 1; - fclose (pgperr); - fclose (pgpout); + m_fclose(&pgperr); + m_fclose(&pgpout); unlink (signedfile); - if (fclose (fp) != 0) { + if (m_fclose(&fp) != 0) { mutt_perror ("fclose"); unlink (sigfile); return (NULL); @@ -1033,21 +944,21 @@ BODY *pgp_sign_message (BODY * a) return (NULL); /* fatal error while signing */ } - t = mutt_new_body (); + t = body_new(); t->type = TYPEMULTIPART; t->subtype = m_strdup("signed"); t->encoding = ENC7BIT; t->use_disp = 0; t->disposition = DISPINLINE; - mutt_generate_boundary (&t->parameter); - mutt_set_parameter ("protocol", "application/pgp-signature", &t->parameter); - mutt_set_parameter ("micalg", pgp_micalg (sigfile), &t->parameter); + parameter_set_boundary(&t->parameter); + parameter_setval(&t->parameter, "protocol", "application/pgp-signature"); + parameter_setval(&t->parameter, "micalg", pgp_micalg (sigfile)); t->parts = a; a = t; - t->parts->next = mutt_new_body (); + t->parts->next = body_new(); t = t->parts->next; t->type = TYPEAPPLICATION; t->subtype = m_strdup("pgp-signature"); @@ -1079,7 +990,8 @@ static short is_numerical_keyid (const char *s) */ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) { - char *keyID, *keylist = NULL, *t; + char *keylist = NULL, *t; + const char *keyID; size_t keylist_size = 0; size_t keylist_used = 0; address_t *tmp = NULL, *addr = NULL; @@ -1113,7 +1025,7 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) if (fqdn) rfc822_qualify (tmp, fqdn); - tmp = mutt_remove_duplicates (tmp); + address_list_uniq(tmp); for (p = tmp; p; p = p->next) { char buf[LONG_STRING]; @@ -1145,8 +1057,8 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) } else if (r == -1) { p_delete(&keylist); - address_delete (&tmp); - address_delete (&addr); + address_list_wipe(&tmp); + address_list_wipe(&addr); return NULL; } } @@ -1162,8 +1074,8 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) if ((key = pgp_ask_for_key (buf, q->mailbox, KEYFLAG_CANENCRYPT, PGP_PUBRING)) == NULL) { p_delete(&keylist); - address_delete (&tmp); - address_delete (&addr); + address_list_wipe(&tmp); + address_list_wipe(&addr); return NULL; } } @@ -1180,10 +1092,10 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) keylist_used = m_strlen(keylist); pgp_free_key (&key); - address_delete (&addr); + address_list_wipe(&addr); } - address_delete (&tmp); + address_list_wipe(&tmp); return (keylist); } @@ -1201,27 +1113,28 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) int empty = 0; pid_t thepid; - mutt_mktemp (tempfile); - if ((fpout = safe_fopen (tempfile, "w+")) == NULL) { + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + if (fpout == NULL) { mutt_perror (tempfile); return (NULL); } - mutt_mktemp (pgperrfile); - if ((pgperr = safe_fopen (pgperrfile, "w+")) == NULL) { + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + if (pgperr == NULL) { mutt_perror (pgperrfile); + m_fclose(&fpout); unlink (tempfile); - fclose (fpout); return NULL; } unlink (pgperrfile); - mutt_mktemp (pgpinfile); - if ((fptmp = safe_fopen (pgpinfile, "w")) == NULL) { + fptmp = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(Tempdir), NULL); + if (fptmp == NULL) { mutt_perror (pgpinfile); + m_fclose(&fpout); unlink (tempfile); - fclose (fpout); - fclose (pgperr); + m_fclose(&pgperr); + unlink (pgperrfile); return NULL; } @@ -1231,12 +1144,12 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) mutt_write_mime_header (a, fptmp); fputc ('\n', fptmp); mutt_write_mime_body (a, fptmp); - fclose (fptmp); + m_fclose(&fptmp); if ((thepid = pgp_invoke_encrypt (&pgpin, NULL, NULL, -1, fileno (fpout), fileno (pgperr), pgpinfile, keylist, sign)) == -1) { - fclose (pgperr); + m_fclose(&pgperr); unlink (pgpinfile); return (NULL); } @@ -1246,7 +1159,7 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) fputs (PgpPass, pgpin); fputc ('\n', pgpin); } - fclose (pgpin); + m_fclose(&pgpin); if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT)) empty = 1; @@ -1257,7 +1170,7 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) rewind (fpout); if (!empty) empty = (fgetc (fpout) == EOF); - fclose (fpout); + m_fclose(&fpout); fflush (pgperr); rewind (pgperr); @@ -1265,7 +1178,7 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) err = 1; fputs (buf, stdout); } - fclose (pgperr); + m_fclose(&pgperr); /* pause if there is any error output from PGP */ if (err) @@ -1279,22 +1192,22 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) return (NULL); } - t = mutt_new_body (); + t = body_new(); t->type = TYPEMULTIPART; t->subtype = m_strdup("encrypted"); t->encoding = ENC7BIT; t->use_disp = 0; t->disposition = DISPINLINE; - mutt_generate_boundary (&t->parameter); - mutt_set_parameter ("protocol", "application/pgp-encrypted", &t->parameter); + parameter_set_boundary(&t->parameter); + parameter_setval(&t->parameter, "protocol", "application/pgp-encrypted"); - t->parts = mutt_new_body (); + t->parts = body_new(); t->parts->type = TYPEAPPLICATION; t->parts->subtype = m_strdup("pgp-encrypted"); t->parts->encoding = ENC7BIT; - t->parts->next = mutt_new_body (); + t->parts->next = body_new(); t->parts->next->type = TYPEAPPLICATION; t->parts->next->subtype = m_strdup("octet-stream"); t->parts->next->encoding = ENC7BIT; @@ -1339,10 +1252,10 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) return NULL; } - mutt_mktemp (pgpinfile); - if ((pgpin = safe_fopen (pgpinfile, "w")) == NULL) { + pgpin = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(Tempdir), NULL); + if (pgpin == NULL) { mutt_perror (pgpinfile); - fclose (fp); + m_fclose(&fp); return NULL; } @@ -1358,9 +1271,9 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) else from_charset = Charset; - if (!mutt_is_us_ascii (body_charset)) { + if (!charset_is_us_ascii (body_charset)) { int c; - FGETCONV *fc; + fgetconv_t *fc; if (flags & ENCRYPT) send_charset = "us-ascii"; @@ -1377,19 +1290,19 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) send_charset = "us-ascii"; mutt_copy_stream (fp, pgpin); } - safe_fclose (&fp); - fclose (pgpin); + m_fclose(&fp); + m_fclose(&pgpin); - mutt_mktemp (pgpoutfile); - mutt_mktemp (pgperrfile); - if ((pgpout = safe_fopen (pgpoutfile, "w+")) == NULL || - (pgperr = safe_fopen (pgperrfile, "w+")) == NULL) { + pgpout = m_tempfile(pgpoutfile, sizeof(pgpoutfile), NONULL(Tempdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + if (pgpout == NULL || pgperr == NULL) { mutt_perror (pgpout ? pgperrfile : pgpoutfile); + m_fclose(&pgpin); unlink (pgpinfile); - if (pgpout) { - fclose (pgpout); - unlink (pgpoutfile); - } + m_fclose(&pgpout); + unlink (pgpoutfile); + m_fclose(&pgperr); + unlink(pgperrfile); return NULL; } @@ -1400,8 +1313,8 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) pgpinfile, keylist, flags)) == -1) { mutt_perror (_("Can't invoke PGP")); - fclose (pgpout); - fclose (pgperr); + m_fclose(&pgpout); + m_fclose(&pgperr); mutt_unlink (pgpinfile); unlink (pgpoutfile); return NULL; @@ -1411,7 +1324,7 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) *PgpPass = 0; if (flags & SIGN) fprintf (pgpin, "%s\n", PgpPass); - fclose (pgpin); + m_fclose(&pgpin); if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT)) empty = 1; @@ -1426,7 +1339,7 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) if (!empty) empty = (fgetc (pgpout) == EOF); - fclose (pgpout); + m_fclose(&pgpout); err = 0; @@ -1435,7 +1348,7 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) fputs (buff, stdout); } - fclose (pgperr); + m_fclose(&pgperr); if (err) mutt_any_key_to_continue (NULL); @@ -1447,30 +1360,19 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) return NULL; } - b = mutt_new_body (); + b = body_new(); b->encoding = ENC7BIT; b->type = TYPETEXT; b->subtype = m_strdup("plain"); - mutt_set_parameter ("x-action", - flags & ENCRYPT ? "pgp-encrypted" : "pgp-signed", - &b->parameter); - mutt_set_parameter ("charset", send_charset, &b->parameter); + parameter_setval(&b->parameter, "x-action", + flags & ENCRYPT ? "pgp-encrypted" : "pgp-signed"); + parameter_setval(&b->parameter, "charset", send_charset); b->filename = m_strdup(pgpoutfile); -#if 0 - /* The following is intended to give a clue to some completely brain-dead - * "mail environments" which are typically used by large corporations. - */ - - b->d_filename = m_strdup("msg.pgp"); - b->use_disp = 1; - -#endif - b->disposition = DISPINLINE; b->unlink = 1;