X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-crypt%2Fpgp.c;h=8db2a5df982998ee15c16a23943056da0182455d;hp=e27fba71da3e30ffade1ccd4e34a73b3e3f40e4f;hb=75147b39ee208b0e6257bc483d96b20b1f5a7995;hpb=81efbf8081bad2eed7ad07209b301ca35fe183e8 diff --git a/lib-crypt/pgp.c b/lib-crypt/pgp.c index e27fba7..8db2a5d 100644 --- a/lib-crypt/pgp.c +++ b/lib-crypt/pgp.c @@ -167,7 +167,7 @@ static void pgp_copy_clearsigned (FILE * fpin, STATE * s, char *charset) rewind (fpin); - fc = fgetconv_open (fpin, charset, Charset, M_ICONV_HOOK_FROM); + fc = fgetconv_open (fpin, charset, MCharset.charset, M_ICONV_HOOK_FROM); for (complete = 1, armor_header = 1; fgetconvs (buf, sizeof (buf), fc) != NULL; @@ -266,7 +266,7 @@ 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 */ - tmpfp = m_tempfile(tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL); + tmpfp = m_tempfile(tmpfname, sizeof(tmpfname), NONULL(MCore.tmpdir), NULL); if (tmpfp == NULL) { mutt_perror (tmpfname); return (-1); @@ -295,7 +295,7 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) /* Invoke PGP if needed */ if (!clearsign || (s->flags & M_VERIFY)) { - pgpout = m_tempfile(outfile, sizeof(outfile), NONULL(Tempdir), NULL); + pgpout = m_tempfile(outfile, sizeof(outfile), NONULL(MCore.tmpdir), NULL); if (pgpout == NULL) { mutt_perror (outfile); return (-1); @@ -394,7 +394,7 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) rewind (pgpout); state_set_prefix (s); - fc = fgetconv_open (pgpout, "utf-8", Charset, 0); + fc = fgetconv_open (pgpout, "utf-8", MCharset.charset, 0); while ((c = fgetconv (fc)) != EOF) state_prefix_putc (c, s); fgetconv_close (&fc); @@ -454,6 +454,7 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, char tempfile[_POSIX_PATH_MAX]; char buf[HUGE_STRING]; FILE *tfp; + int tempfd; short sgn = 0; short enc = 0; @@ -465,14 +466,14 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, if (tagged_only && !b->tagged) return 0; - mutt_mktemp (tempfile); - if (mutt_decode_save_attachment (fp, b, tempfile, 0, 0) != 0) { + tempfd = m_tempfd(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); + if (mutt_decode_save_attachment (fp, b, tempfd, 0) != 0) { unlink (tempfile); return 0; } - if ((tfp = fopen (tempfile, "r")) == NULL) { - unlink (tempfile); + if (!(tfp = fopen(tempfile, "r"))) { + unlink(tempfile); return 0; } @@ -547,7 +548,7 @@ int pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempfile) mutt_copy_bytes (s->fpin, fp, sigbdy->length); m_fclose(&fp); - pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(MCore.tmpdir), NULL); if (pgperr == NULL) { mutt_perror (pgperrfile); unlink (sigfile); @@ -593,7 +594,7 @@ static void pgp_extract_keys_from_attachment (FILE * fp, BODY * top) FILE *tempfp; char tempfname[_POSIX_PATH_MAX]; - tempfp = m_tempfile(tempfname, sizeof(tempfname), NONULL(Tempdir), NULL); + tempfp = m_tempfile(tempfname, sizeof(tempfname), NONULL(MCore.tmpdir), NULL); if (tempfp == NULL) { mutt_perror (_("Can't create temporary file")); return; @@ -608,8 +609,10 @@ static void pgp_extract_keys_from_attachment (FILE * fp, BODY * top) m_fclose(&tempfp); - pgp_invoke_import (tempfname); - mutt_any_key_to_continue (NULL); + if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_import)) { + (CRYPT_MOD_CALL (PGP, pgp_invoke_import)) (fname); + mutt_any_key_to_continue (NULL); + } mutt_unlink (tempfname); } @@ -648,14 +651,14 @@ BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p) pid_t thepid; int rv; - pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(MCore.tmpdir), NULL); if (!pgperr) { mutt_perror (pgperrfile); return NULL; } unlink (pgperrfile); - pgptmp = m_tempfile(pgptmpfile, sizeof(pgptmpfile), NONULL(Tempdir), NULL); + pgptmp = m_tempfile(pgptmpfile, sizeof(pgptmpfile), NONULL(MCore.tmpdir), NULL); if (!pgptmp) { mutt_perror (pgptmpfile); m_fclose(&pgperr); @@ -695,7 +698,7 @@ BODY *pgp_decrypt_part (BODY * a, STATE * s, FILE * fpout, BODY * p) while (fgets (buf, sizeof (buf) - 1, pgpout) != NULL) { len = m_strlen(buf); if (len > 1 && buf[len - 2] == '\r') - strcpy (buf + len - 2, "\n"); /* __STRCPY_CHECKED__ */ + m_strcpy(buf + len - 2, len - 2, "\n"); fputs (buf, fpout); } @@ -756,7 +759,7 @@ int pgp_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, BODY ** cur) p_clear(&s, 1); s.fpin = fpin; - *fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + *fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (*fpout == NULL) { mutt_perror (_("Can't create temporary file")); return (-1); @@ -797,7 +800,7 @@ int pgp_encrypted_handler (BODY * a, STATE * s) */ a = a->next; - fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (fpout == NULL) { if (s->flags & M_DISPLAY) state_attach_puts (_ @@ -867,12 +870,12 @@ BODY *pgp_sign_message (BODY * a) convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */ - fp = m_tempfile(sigfile, sizeof(sigfile), NONULL(Tempdir), NULL); + fp = m_tempfile(sigfile, sizeof(sigfile), NONULL(MCore.tmpdir), NULL); if (fp == NULL) { return (NULL); } - sfp = m_tempfile(signedfile, sizeof(signedfile), NONULL(Tempdir), NULL); + sfp = m_tempfile(signedfile, sizeof(signedfile), NONULL(MCore.tmpdir), NULL); if (sfp == NULL) { mutt_perror (signedfile); m_fclose(&fp); @@ -1022,8 +1025,7 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) last = &((*last)->next); } - if (fqdn) - rfc822_qualify (tmp, fqdn); + rfc822_qualify (tmp, fqdn); address_list_uniq(tmp); @@ -1048,8 +1050,7 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) /* check for e-mail address */ if ((t = strchr (keyID, '@')) && (addr = rfc822_parse_adrlist (NULL, keyID))) { - if (fqdn) - rfc822_qualify (addr, fqdn); + rfc822_qualify (addr, fqdn); q = addr; } else @@ -1087,7 +1088,7 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) bypass_selection: keylist_size += m_strlen(keyID) + 4; p_realloc(&keylist, keylist_size); - sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */ + sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", keyID); keylist_used = m_strlen(keylist); @@ -1113,13 +1114,13 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) int empty = 0; pid_t thepid; - fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + fpout = m_tempfile(tempfile, sizeof(tempfile), NONULL(MCore.tmpdir), NULL); if (fpout == NULL) { mutt_perror (_("Can't create temporary file")); return (NULL); } - pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(MCore.tmpdir), NULL); if (pgperr == NULL) { mutt_perror (pgperrfile); m_fclose(&fpout); @@ -1128,7 +1129,7 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign) } unlink (pgperrfile); - fptmp = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(Tempdir), NULL); + fptmp = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(MCore.tmpdir), NULL); if (fptmp == NULL) { mutt_perror (pgpinfile); m_fclose(&fpout); @@ -1252,7 +1253,7 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) return NULL; } - pgpin = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(Tempdir), NULL); + pgpin = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(MCore.tmpdir), NULL); if (pgpin == NULL) { mutt_perror (pgpinfile); m_fclose(&fp); @@ -1269,7 +1270,7 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) if (a->noconv) from_charset = body_charset; else - from_charset = Charset; + from_charset = MCharset.charset; if (!charset_is_us_ascii (body_charset)) { int c; @@ -1293,8 +1294,8 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) m_fclose(&fp); m_fclose(&pgpin); - pgpout = m_tempfile(pgpoutfile, sizeof(pgpoutfile), NONULL(Tempdir), NULL); - pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL); + pgpout = m_tempfile(pgpoutfile, sizeof(pgpoutfile), NONULL(MCore.tmpdir), NULL); + pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(MCore.tmpdir), NULL); if (pgpout == NULL || pgperr == NULL) { mutt_perror (pgpout ? pgperrfile : pgpoutfile); m_fclose(&pgpin); @@ -1388,7 +1389,7 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist) int pgp_send_menu (HEADER * msg, int *redraw) { pgp_key_t p; - char input_signas[SHORT_STRING]; + char input_signas[STRING]; char prompt[LONG_STRING]; @@ -1426,11 +1427,6 @@ int pgp_send_menu (HEADER * msg, int *redraw) crypt_pgp_void_passphrase (); /* probably need a different passphrase */ } -#if 0 - else { - msg->security &= ~SIGN; - } -#endif *redraw = REDRAW_FULL; break;