Commit c901be35 authored by Werner Koch's avatar Werner Koch

- To cleanup the pgp/smime code and prepare for other backends.

 - Support gpg-agent by not asking for a passphrase
 - autconf cleanups.

This is just a start and probably we need a couple of other things to
do. One drawback is that the help menu does always list all crypto
realted stuff even when configured for no crypto at all.  Same goes
for the configure options but I consider thsi a feature: It allows to
use the same .muttrc for different versions of mutt - at least during
development, this is an advantage.  This all might be fixed but
requires some changes to the configuration system.

Note, the use of the WithCrypto macro - it enables the compiler to do
dead-code-elimination depending on the configured backend.  This is
better readable than all the nested ifdefs.  I did some short tests
and it seems to work, althoug mutt's size does not change largely when
compiled w/o crypto.

cryptglue.c is new as a warpper to all crypto calls; some are still in
crypt.c but they should eventually also be wrapped.  We don't use
function pointers to keep a path to use dlopen or runtime configured
backends.  crypt.h is also new and replaces pgp.h and smime.h in most
files (except for the backend).



2003-01-06  Werner Koch  <wk@gnupg.org>

	* crypt.c (crypt_valid_passphrase): Detect gpg-agent and don't ask
	for the passphrase.
	* pgp.c (pgp_decrypt_part, pgp_application_pgp_handler)
	(pgp_sign_message, pgp_encrypt_message)
	(pgp_traditional_encryptsign): Make sure that we never ever send
	the passphrase if the gpg-agent has been detected.  Likewise.

	* acconfig.h: Removed all remaining stuff as AC_TEMPLATEs to
	configure.in. BTW, we should consider to rename configure.in to
	configure.ac.

2003-01-04  Werner Koch  <wk@gnupg.org>

        Replaced the use of HAVE_PGP and HAVE_SMIME by a more readable
	and extendable solution.

	* pgplib.h: Moved enum pgp_ring and KEYFLAGS_* to
	* crypt.h: here.
	* smime.c (mutt_is_application_smime): Moved to
	* crypt.c (mutt_is_application_smime): here.
	* pgp.c (mutt_is_application_pgp): Moved to
	* crypt.c (mutt_is_application_pgp): here.
	* pgp.c (pgp_is_multipart_encrypted): Removed. Merged code with
	* crypt.c (mutt_is_multipart_encrypted): this.

	* mutt.h: Protect against double inclusion.

	* pgplib.h (struct pgp_keyinfo): Remove the typedef to pgp_key_t.
	* crypt.h (pgp_key_t): Declare the typedef here.  NOTE:  This is
	now a pointer.  Changed all usages accordingly.

	* configure.in: Replace HAVE_PGP and HAVE_SMIME by the new
	CRYPT_BACKEND macros.  Always include all OPS.*.
	(LIBOBJ): Replaced by AC_LIBOBJ as required by newer autoconfs.
	* Makefile.am (EXTRA_mutt_SOURCES): Move crypt.c to mutt_SOURCES.
	(mutt_SOURCES): Add cryptglue.c
	(EXTRA_DIST): Add crypt.h

	* pgp.h, pgplib.h, smime.h: Use the header only when the
	approriate backend has been configured.
	* pgp.c, pgpkey.c, smime.c: Build only if the approriate
	CRYPT_BACKEND_ macro is defined.
	* pgp.h, smime.h, global.h: Moved all variable declarations to
	global.h because they are now always defined.

	* sort.h: Always define PgpSortKey, although it does not belong to
	here.

	* keymap.h: Unconditionally include all PGP and SMIME stuff.
	* mutt.h: Ditto.
	* protos.h: Ditto.

	* init.h (HAVE_SMIME): Unconditionally include all crypto related
	definitions.  Mark the doc entries with "(Crypto/PGP/SMIME only)".

	* globals.h: Replace gpg.h and smime.h by crypt.h.

	* functions.h: Always include all crypto commands.

	* copy.h: Unconditionally define the crypto related M_CM_

	* pgplib.h: Move APPLICATION_PGP and PGP* to crypt.h and include
	it.
	* smime.h: Move APPLICATION_SMIME and SMIME* to crypt.h and
	include it.
	* mutt_crypt.h (ENCRYPT,SIGN,GOODSIGN, BADSIGN): Move to crypt.h.

	* crypt.c: Replaced pgp.h and smime.h header by crypt.h.  Always
	include all functions but shortcut them depending on WITHCRYPTO.
        All over the place use WITHCRYPTO instead of ifdefs.  Replaced all
	direct calls of the backend fucntions by twrapper functions
	defined in cryptglue.c
	(crypt_get_keys): Removed prototypes.
	* pgp.h (pgp_findKeys): New prototype.
	* smime.h (smime_findKeys): New prototype.
	* cryptglue.c: New.
	* crypt.h: New.
	* mutt_crypt.h: Moved all crypt_* prototypes to gcrypt.h.
	Unconditionally use this file.

	* init.c: Replaced pgp.h and smime.h header by crypt.h.
	(parse_set): Use WITHCRYPTO instead of ifdefs.
	(mutt_var_value_complete): Ditto.

	* sendlib.c: Replaced pgp.h and smime.h header by crypt.h.
	(write_as_text_part): Now one macro using WITHCRYPTO.
	(mutt_write_mime_body): Use WITHCRYPTO instead of ifdefs.
	(mutt_make_message_attach): Ditto.
	(mutt_write_fcc): Ditto.

	* send.c: Replaced pgp.h and smime.h header by crypt.h.
	(include_forward): Use WITHCRYPTO and validate passphrases for pgp
	and smime.
	(include_reply): Ditto.
	(generate_body): Use WITHCRYPTO instead of ifdefs.
	(ci_send_message): Ditto.

	* recvattach.c: Replaced pgp.h and smime.h header by crypt.h.
	(mutt_gen_attach_list): Use WITHCRYPTO instead of ifdefs.
	(mutt_attach_display_loop): Ditto
	(mutt_view_attachments): Ditto.

	* postpone.c: Replaced pgp.h and smime.h header by crypt.h.
	(mutt_get_postponed): Use WITHCRYPTO instead of ifdefs.
	(mutt_parse_crypt_hdr): Always include and use WITHCRYPTO instead
	of ifdefs.
	(mutt_prepare_template): Use WITHCRYPTO instead of ifdefs.

	* pop.c: Removed pgp.h and smime.h.
	(pop_fetch_message): Use WITHCRYPTO instead of ifdefs.

	* pattern.c: Replaced pgp.h and smime.h header by crypt.h.
	(Flags): Always include the crypto flags.
	(msg_search): Use WITHCRYPTO instead of ifdefs.
	(mutt_pattern_exec): Ditto.

	* parse.c: Removed pgp.h and smime.h.
	(mutt_parse_mime_message): Use WITHCRYPTO instead of ifdefs.

	* pager.c: Replaced pgp.h and smime.h header by crypt.h.
	(mutt_pager): Use WITHCRYPTO instead of ifdefs.

	* mx.c: Removed smime.h and pgp.h.
	(mx_update_context): Use WITHCRYPTO instead of ifdefs.

	* muttlib.c: Replaced pgp.h and smime.h header by crypt.h.
	(mutt_needs_mailcap): Use WITHCRYPTO. Note, that there used to be
	an error when PGP was not configured so that TYPEAPPLICATION was
	not recognized for SMIME.
	(mutt_is_text_part): Use WITHCRYPTO instead of ifdefs.

	* main.c: Include crypt.h.
	(show_version): Remove HAVE_PGP and HAVE_SMIME.  Add
	CRYPT_BACKEND_CLASSIC_PGP, CRYPT_BACKEND_CLASSIC_SMIME.

	* keymap.c: Include crypt.h so that we can test WITHCRYPTO.
	(Menus): Always include pgp and smime.
	(km_init): Create smime and pgp bindings depending on WITHCRYPTO.
	(km_get_table): Return OpPgp depending on WITHCRYPTO.

	* hook.c (mutt_parse_hook): Use WITHCRYPTO instead of ifdefs.
	(mutt_crypt_hook): Always include.

	* headers.c: Replaced pgp.h and smime.h header by crypt.h.
	(mutt_edit_headers): Use WITHCRYPTO instead of ifdefs

	* hdrline.c: Replaced pgp.h and smime.h header by crypt.h.
	(hdr_format_str): Use WITHCRYPTO.

	* handler.c: Replaced pgp.h and smime.h header by crypt.h.
	(mutt_can_decode): Use WITHCRYPTO instead of ifdefs.
	(mutt_can_decode): Application/smime is now also checked when PGP
	support is not configured.
	(mutt_body_handler): Use WITHCRYPTO

	* curs_main.c: Replaced pgp.h and smime.h header by crypt.h.
	(mutt_index_menu): Shortcut crypto only operations depending on
	WITHCRYPTO.

	* copy.c: Replaced pgp.h and smime.h header by crypt.h.
	(_mutt_copy_message):

	* compose.c: Replaced pgp.h and smime.h header by crypt.h.
	(enum): Always include HDR_CRYPT and HDR_CRYPTINFO.
	(redraw_crypt_lines): Always include this fnc but shortcut it
	depending on WITHCRYPT.  Draw lines depending on the configured
	crypto support.
	(pgp_send_menu): Always include this one.  Call wrapper functions.
	(smime_send_menu): Likewise.
	(draw_envelope): Use WITHCRYPTO instead of ifdefs.
	(mutt_compose_menu): Allow pgp/smime commands only when configured.

	* commands.c: Replaced pgp.h and smime.h header by crypt.h.
	(mutt_display_message,pipe_msg, _mutt_pipe_message)
	(set_copy_flags, mutt_save_message, mutt_edit_content_type)
	(_mutt_check_traditional_pgp): Use pgp wrapper.

	* attach.c (mutt_view_attachment): Removed HAVE_GPG and HAVE_SMIME
	and replaced by global variable WITHCRYPTO.  Replaced pgp and
	smime header by crypt.h.x
parent e6f3bd25
......@@ -18,6 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.c
bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ @SMIMEAUX_TARGET@
mutt_SOURCES = $(BUILT_SOURCES) \
addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
crypt.c cryptglue.c \
commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
......@@ -58,21 +59,21 @@ CPPFLAGS=@CPPFLAGS@ -I$(includedir)
EXTRA_mutt_SOURCES = account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c \
mutt_tunnel.c pop.c pop_auth.c pop_lib.c crypt.c smime.c pgp.c pgpinvoke.c pgpkey.c \
mutt_tunnel.c pop.c pop_auth.c pop_lib.c smime.c pgp.c pgpinvoke.c pgpkey.c \
pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \
browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c pgppacket.c
EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
configure acconfig.h account.h \
attach.h buffy.h charset.h copy.h dotlock.h functions.h gen_defs \
globals.h hash.h history.h init.h keymap.h \
globals.h hash.h history.h init.h keymap.h crypt.h \
mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.h \
mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h \
rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare \
_regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
makedoc.c stamp-doc-rc README.SSL crypt.h smime.h\
makedoc.c stamp-doc-rc README.SSL smime.h\
muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
ChangeLog.old mkchangelog.sh cvslog2changelog.pl
......
/*
* Define if you have problems with mutt not detecting new/old mailboxes
* over NFS. Some NFS implementations incorrectly cache the attributes
* of small files.
*/
#undef NFS_ATTRIBUTE_HACK
/*
* Is mail spooled to the user's home directory? If defined, MAILPATH should
* be set to the filename of the spool mailbox relative the the home
* directory.
* use: configure --with-homespool=FILE
*/
#undef HOMESPOOL
/* program to use for shell commands */
#define EXECSHELL "/bin/sh"
/* Enable exact regeneration of email addresses as parsed? NOTE: this requires
significant more memory when defined. */
#undef EXACT_ADDRESS
/* Define to `int' if <signal.h> doesn't define. */
#undef sig_atomic_t
......
......@@ -27,14 +27,7 @@
#include "mailbox.h"
#include "copy.h"
#include "mx.h"
#ifdef HAVE_PGP
#include "pgp.h"
#endif
#ifdef HAVE_SMIME
#include "smime.h"
#endif
#include "mutt_crypt.h"
#include <ctype.h>
#include <stdlib.h>
......@@ -416,11 +409,9 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
int unlink_tempfile = 0;
is_message = mutt_is_message_type(a->type, a->subtype);
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
if (WithCrypto && is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
!crypt_valid_passphrase(a->hdr->security))
return (rc);
#endif /* HAVE_PGP || HAVE_SMIME */
use_mailcap = (flag == M_MAILCAP ||
(flag == M_REGULAR && mutt_needs_mailcap (a)));
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
......
......@@ -26,6 +26,7 @@
#include "copy.h"
#include "mx.h"
#include "pager.h"
#include "mutt_crypt.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
......@@ -38,19 +39,6 @@
#include "buffy.h"
#endif
#ifdef HAVE_PGP
#include "pgp.h"
#endif
#ifdef HAVE_SMIME
#include "smime.h"
#endif
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
......@@ -81,16 +69,13 @@ int mutt_display_message (HEADER *cur)
mutt_parse_mime_message (Context, cur);
mutt_message_hook (Context, cur, M_MESSAGEHOOK);
#if defined (HAVE_PGP) || defined (HAVE_SMIME)
/* see if PGP is needed for this message. if so, we should exit curses */
if (cur->security)
/* see if crytpo is needed for this message. if so, we should exit curses */
if (WithCrypto && cur->security)
{
if (cur->security & ENCRYPT)
{
#ifdef HAVE_SMIME
if (cur->security & APPLICATION_SMIME)
smime_getkeys (cur->env);
#endif
crypt_smime_getkeys (cur->env);
if(!crypt_valid_passphrase(cur->security))
return 0;
......@@ -108,22 +93,17 @@ int mutt_display_message (HEADER *cur)
if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT)
{
#ifdef HAVE_PGP
if (cur->security & APPLICATION_PGP)
{
if (cur->env->from)
pgp_invoke_getkeys (cur->env->from);
mutt_message _("Invoking PGP...");
crypt_pgp_invoke_getkeys (cur->env->from);
crypt_invoke_message (APPLICATION_PGP);
}
#endif
#ifdef HAVE_SMIME
if (cur->security & APPLICATION_SMIME)
mutt_message _("Invoking OpenSSL...");
#endif
crypt_invoke_message (APPLICATION_SMIME);
}
#endif /* defined (HAVE_PGP) || defined (HAVE_SMIME) */
mutt_mktemp (tempfile);
......@@ -178,25 +158,26 @@ int mutt_display_message (HEADER *cur)
safe_fclose (&fpfilterout); /* XXX - check result? */
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
/* update crypto information for this message */
cur->security |= crypt_query (cur->content);
if (WithCrypto)
{
/* update crypto information for this message */
cur->security |= crypt_query (cur->content);
/* Remove color cache for this message, in case there
are color patterns for both ~g and ~V */
cur->pair = 0;
#endif
/* Remove color cache for this message, in case there
are color patterns for both ~g and ~V */
cur->pair = 0;
}
if (builtin)
{
pager_t info;
#ifdef HAVE_SMIME
if (cur->security & APPLICATION_SMIME && (cmflags & M_CM_VERIFY))
if (WithCrypto
&& (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY))
{
if (cur->security & GOODSIGN)
{
if (!smime_verify_sender(cur))
if (!crypt_smime_verify_sender(cur))
mutt_message ( _("S/MIME signature successfully verified."));
else
mutt_error ( _("S/MIME certificate owner does not match sender."));
......@@ -204,14 +185,12 @@ int mutt_display_message (HEADER *cur)
else if (cur->security & SIGN || cur->security & BADSIGN)
mutt_error ( _("S/MIME signature could NOT be verified."));
}
#endif
#ifdef HAVE_PGP
if ((cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
if (WithCrypto
&& (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
mutt_message ((cur->security & GOODSIGN) ?
_("PGP signature successfully verified.") :
_("PGP signature could NOT be verified."));
#endif
/* Invoke the builtin pager */
memset (&info, 0, sizeof (pager_t));
......@@ -328,15 +307,12 @@ void pipe_msg (HEADER *h, FILE *fp, int decode, int print)
pipe_set_flags (decode, print, &cmflags, &chflags);
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (decode && h->security & ENCRYPT)
{
if(!crypt_valid_passphrase(h->security))
return;
endwin ();
}
#endif
if (WithCrypto && decode && h->security & ENCRYPT)
{
if(!crypt_valid_passphrase(h->security))
return;
endwin ();
}
if (decode)
mutt_parse_mime_message (Context, h);
......@@ -369,15 +345,13 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
mutt_message_hook (Context, h, M_MESSAGEHOOK);
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (decode)
if (WithCrypto && decode)
{
mutt_parse_mime_message (Context, h);
if(h->security & ENCRYPT && !crypt_valid_passphrase(h->security))
return 1;
}
mutt_endwin (NULL);
#endif
if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
{
......@@ -392,11 +366,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
else
{ /* handle tagged messages */
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (decode)
if (WithCrypto && decode)
{
for (i = 0; i < Context->vcount; i++)
if(Context->hdrs[Context->v2r[i]]->tagged)
......@@ -408,7 +378,6 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
return 1;
}
}
#endif
if (split)
{
......@@ -626,30 +595,24 @@ static void set_copy_flags (HEADER *hdr, int decode, int decrypt, int *cmflags,
*cmflags = 0;
*chflags = CH_UPDATE_LEN;
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (!decode && decrypt && (hdr->security & ENCRYPT))
if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT))
{
#ifdef HAVE_PGP
if (mutt_is_multipart_encrypted(hdr->content))
if ((WithCrypto & APPLICATION_PGP)
&& mutt_is_multipart_encrypted(hdr->content))
{
*chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
*cmflags = M_CM_DECODE_PGP;
}
else if (mutt_is_application_pgp (hdr->content) & ENCRYPT)
else if ((WithCrypto & APPLICATION_PGP)
&& mutt_is_application_pgp (hdr->content) & ENCRYPT)
decode = 1;
#endif
#if defined(HAVE_PGP) && defined(HAVE_SMIME)
else
#endif
#ifdef HAVE_SMIME
if (mutt_is_application_smime(hdr->content) & ENCRYPT)
else if ((WithCrypto & APPLICATION_SMIME)
&& mutt_is_application_smime(hdr->content) & ENCRYPT)
{
*chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
*cmflags = M_CM_DECODE_SMIME;
}
#endif
}
#endif /* defined(HAVE_PGP) || defined(HAVE_SMIME) */
if (decode)
{
......@@ -690,9 +653,7 @@ int mutt_save_message (HEADER *h, int delete,
int decode, int decrypt, int *redraw)
{
int i, need_buffy_cleanup;
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
int need_passphrase = 0, app=0;
#endif
char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
CONTEXT ctx;
struct stat st;
......@@ -716,10 +677,11 @@ int mutt_save_message (HEADER *h, int delete,
if (h)
{
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (WithCrypto)
{
need_passphrase = h->security & ENCRYPT;
app = h->security;
#endif
}
mutt_message_hook (Context, h, M_MESSAGEHOOK);
mutt_default_save (buf, sizeof (buf), h);
}
......@@ -741,10 +703,11 @@ int mutt_save_message (HEADER *h, int delete,
{
mutt_message_hook (Context, h, M_MESSAGEHOOK);
mutt_default_save (buf, sizeof (buf), h);
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
need_passphrase = h->security & ENCRYPT;
app = h->security;
#endif
if (WithCrypto)
{
need_passphrase = h->security & ENCRYPT;
app = h->security;
}
h = NULL;
}
}
......@@ -778,10 +741,9 @@ int mutt_save_message (HEADER *h, int delete,
if (!mutt_save_confirm (buf, &st))
return -1;
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (need_passphrase && (decode || decrypt) && !crypt_valid_passphrase(app))
if (WithCrypto && need_passphrase && (decode || decrypt)
&& !crypt_valid_passphrase(app))
return -1;
#endif
mutt_message (_("Copying to %s..."), buf);
......@@ -933,19 +895,16 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
mutt_parse_part (fp, b);
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (h)
if (WithCrypto && h)
{
if (h->content == b)
h->security = 0;
h->security |= crypt_query (b);
}
#endif
}
#ifdef HAVE_PGP
static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
{
MESSAGE *msg;
......@@ -954,7 +913,7 @@ static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
mutt_parse_mime_message (Context, h);
if ((msg = mx_open_message (Context, h->msgno)) == NULL)
return 0;
if (pgp_check_traditional (msg->fp, h->content, 0))
if (crypt_pgp_check_traditional (msg->fp, h->content, 0))
{
h->security = crypt_query (h->content);
*redraw |= REDRAW_FULL;
......@@ -981,4 +940,4 @@ int mutt_check_traditional_pgp (HEADER *h, int *redraw)
return rv;
}
#endif
......@@ -58,10 +58,8 @@ enum
HDR_MIX,
#endif
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
HDR_CRYPT,
HDR_CRYPTINFO,
#endif
HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
};
......@@ -102,38 +100,27 @@ static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
#ifdef HAVE_SMIME
#include "smime.h"
#endif
#ifdef HAVE_PGP
#include "pgp.h"
#endif
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
#include "mutt_crypt.h"
static void redraw_crypt_lines (HEADER *msg)
{
#ifdef HAVE_SMIME
int off = 0;
#endif
#if defined(HAVE_PGP) && defined(HAVE_SMIME)
if (!msg->security)
mvaddstr (HDR_CRYPT, 0, "Security: ");
else if (msg->security & APPLICATION_SMIME)
if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_SMIME))
{
if (!msg->security)
mvaddstr (HDR_CRYPT, 0, "Security: ");
else if (msg->security & APPLICATION_SMIME)
mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
else if (msg->security & APPLICATION_PGP)
mvaddstr (HDR_CRYPT, 0, " PGP: ");
}
else if ((WithCrypto & APPLICATION_SMIME))
mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
else if (msg->security & APPLICATION_PGP)
else if ((WithCrypto & APPLICATION_PGP))
mvaddstr (HDR_CRYPT, 0, " PGP: ");
#else
#ifdef HAVE_SMIME
mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
#endif
#ifdef HAVE_PGP
mvaddstr (HDR_CRYPT, 0, " PGP: ");
#endif
#endif
else
return;
if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN))
addstr (_("Sign, Encrypt"));
......@@ -147,31 +134,33 @@ static void redraw_crypt_lines (HEADER *msg)
move (HDR_CRYPTINFO, 0);
clrtoeol ();
#ifdef HAVE_PGP
if (msg->security & APPLICATION_PGP && msg->security & SIGN)
if ((WithCrypto & APPLICATION_PGP)
&& msg->security & APPLICATION_PGP && msg->security & SIGN)
printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
#endif
#ifdef HAVE_SMIME
if (msg->security & APPLICATION_SMIME && msg->security & SIGN) {
if ((WithCrypto & APPLICATION_SMIME)
&& msg->security & APPLICATION_SMIME && msg->security & SIGN) {
printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
}
if (msg->security & APPLICATION_SMIME && (msg->security & ENCRYPT)) {
if ((WithCrypto & APPLICATION_SMIME)
&& msg->security & APPLICATION_SMIME && (msg->security & ENCRYPT)) {
mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
NONULL(SmimeCryptAlg));
off = 20;
}
#endif
}
#endif /* defined(HAVE_PGP) || defined(HAVE_SMIME) */
#ifdef HAVE_PGP
static int pgp_send_menu (HEADER *msg, int *redraw)
{
pgp_key_t *p;
pgp_key_t p;
char input_signas[SHORT_STRING];
if (!(WithCrypto & APPLICATION_PGP))
return msg->security;
switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "),
_("esabf")))
{
......@@ -184,18 +173,19 @@ static int pgp_send_menu (HEADER *msg, int *redraw)
break;
case 3: /* sign (a)s */
unset_option(OPTPGPCHECKTRUST);
if ((p = pgp_ask_for_key (_("Sign as: "), NULL, KEYFLAG_CANSIGN, PGP_PUBRING)))
if ((p = crypt_pgp_ask_for_key (_("Sign as: "), NULL,
KEYFLAG_CANSIGN, PGP_PUBRING)))
{
snprintf (input_signas, sizeof (input_signas), "0x%s", pgp_keyid (p));
snprintf (input_signas, sizeof (input_signas), "0x%s",
crypt_pgp_keyid (p));
mutt_str_replace (&PgpSignAs, input_signas);
pgp_free_key (&p);
crypt_pgp_free_key (&p);
msg->security |= PGPSIGN;
pgp_void_passphrase (); /* probably need a different passphrase */
crypt_pgp_void_passphrase (); /* probably need a different passphrase */
}
else
{
......@@ -218,15 +208,15 @@ static int pgp_send_menu (HEADER *msg, int *redraw)
redraw_crypt_lines (msg);
return (msg->security);
}
#endif /* HAVE_PGP */
#ifdef HAVE_SMIME
static int smime_send_menu (HEADER *msg, int *redraw)
{
char *p;
char *p;
if (!(WithCrypto & APPLICATION_SMIME))
return msg->security;
switch (mutt_multi_choice (_("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (f)orget it? "),
_("eswabf")))
......@@ -270,14 +260,14 @@ static int smime_send_menu (HEADER *msg, int *redraw)
case 4: /* sign (a)s */
if ((p = smime_ask_for_key (_("Sign as: "), NULL, 0))) {
if ((p = crypt_smime_ask_for_key (_("Sign as: "), NULL, 0))) {
p[mutt_strlen (p)-1] = '\0';
mutt_str_replace (&SmimeDefaultKey, p);
msg->security |= SMIMESIGN;
/* probably need a different passphrase */
smime_void_passphrase ();
crypt_smime_void_passphrase ();
}
else
msg->security &= ~SMIMESIGN;
......@@ -298,7 +288,7 @@ static int smime_send_menu (HEADER *msg, int *redraw)
redraw_crypt_lines (msg);
return (msg->security);
}
#endif /* HAVE_SMIME */
#ifdef MIXMASTER
......@@ -332,7 +322,7 @@ static void redraw_mix_line (LIST *chain)
c += mutt_strlen (t) + 2;
}
}
#endif
#endif /* MIXMASTER */
static int
check_attachments(ATTACHPTR **idx, short idxlen)
......@@ -390,12 +380,8 @@ static void draw_envelope (HEADER *msg, char *fcc)
mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
mutt_paddstr (W, fcc);
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
redraw_crypt_lines (msg);
#endif /* HAVE_PGP || HAVE_SMIE */
if (WithCrypto)
redraw_crypt_lines (msg);
#ifdef MIXMASTER
redraw_mix_line (msg->chain);
......@@ -735,9 +721,9 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
#ifdef HAVE_PGP
case OP_COMPOSE_ATTACH_KEY:
if (!(WithCrypto & APPLICATION_PGP))
break;
if (idxlen == idxmax)
{
safe_realloc ((void **) &idx, sizeof (ATTACHPTR *) * (idxmax += 5));
......@@ -745,7 +731,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
}
idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
if ((idx[idxlen]->content = pgp_make_key_attachment(NULL)) != NULL)
if ((idx[idxlen]->content = crypt_pgp_make_key_attachment(NULL)) != NULL)
{
idx[idxlen]->level = (idxlen > 0) ? idx[idxlen-1]->level : 0;
......@@ -769,8 +755,6 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
}
break;
#endif
case OP_COMPOSE_ATTACH_FILE:
......@@ -1310,11 +1294,11 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
#ifdef HAVE_PGP
case OP_COMPOSE_PGP_MENU:
#ifdef HAVE_SMIME
if (msg->security & APPLICATION_SMIME)
if (!(WithCrypto & APPLICATION_PGP))
break;
if ((WithCrypto & APPLICATION_SMIME)
&& msg->security & APPLICATION_SMIME)
{
if (mutt_yesorno (_("S/MIME already selected. Clear & continue ? "),
M_YES) == M_NO)
......@@ -1324,27 +1308,22 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
}
msg->security = 0;
}
#endif /* HAVE_SMIME */
msg->security = pgp_send_menu (msg, &menu->redraw);
redraw_crypt_lines (msg);
break;
#endif /* HAVE_PGP */
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
case OP_FORGET_PASSPHRASE:
crypt_forget_passphrase ();
break;
#endif /* HAVE_(PGP||SMIME) */
#ifdef HAVE_SMIME
case OP_COMPOSE_SMIME_MENU:
if (!(WithCrypto & APPLICATION_SMIME))
break;
#ifdef HAVE_PGP
if (msg->security & APPLICATION_PGP)
if ((WithCrypto & APPLICATION_PGP)
&& msg->security & APPLICATION_PGP)
{
if (mutt_yesorno (_("PGP already selected. Clear & continue ? "),
M_YES) == M_NO)
......@@ -1354,13 +1333,10 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
}
msg->security = 0;
}
#endif /* HAVE_pgp */
msg->security = smime_send_menu(msg, &menu->redraw);
redraw_crypt_lines (msg);
break;
#endif /* HAVE_SMIME */
#ifdef MIXMASTER
case OP_COMPOSE_MIX:
......@@ -1398,3 +1374,4 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
return (r);
}
......@@ -56,6 +56,34 @@ fi
AC_SUBST(DEBUGGER)
# The following templates should be used with newer automakes
# instead of acconfig.h
#
#AH_TEMPLATE([sig_atomic_t],
# [/* Define to `int' if <signal.h> doesn't define.])
#AH_TEMPLATE([HAVE_START_COLOR],
# [Define if you have start_color, as a function or macro.])
#AH_TEMPLATE([HAVE_TYPEAHEAD],
# [Define if you have typeahead, as a function or macro.])
#AH_TEMPLATE([HAVE_BKGDSET],
# [Define if you have bkgdset, as a function or macro.])
#AH_TEMPLATE([HAVE_CURS_SET],
# [Define if you have curs_set, as a function or macro.])
#AH_TEMPLATE([HAVE_META],
# [Define if you have meta, as a function or macro.])
#AH_TEMPLATE([HAVE_USE_DEFAULT_COLORS],
# [Define if you have use_default_colors, as a function or macro.])
#AH_TEMPLATE([HAVE_RESIZETERM],
# [Define if you have resizeterm, as a function or macro.])
#AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T],
# [Some systems declare sig_atomic_t as volatile, some others -- no.
# This define will have value `sig_atomic_t' or
# `volatile sig_atomic_t' accordingly.])
#AH_TEMPLATE([ICONV_NONTRANS],
# [Define as 1 if iconv() only converts exactly and we should treat
# all return values other than (size_t)(-1) as equivalent.])
ac_aux_path_sendmail=/usr/sbin:/usr/lib
AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$ac_aux_path_sendmail)
AC_DEFINE_UNQUOTED(SENDMAIL,"$ac_cv_path_SENDMAIL",[ Where to find sendmail on your system. ])
......@@ -73,10 +101,10 @@ else
])
if test x$have_pgp != xno ; then
AC_DEFINE(HAVE_PGP,1,[ Define if you want PGP support. ])
AC_DEFINE(CRYPT_BACKEND_CLASSIC_PGP,1,
[ Define if you want classic PGP support. ])
PGPAUX_TARGET="pgpring pgpewrap"
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgplib.o gnupgparse.o pgpmicalg.o pgppacket.o"
OPS="$OPS \$(srcdir)/OPS.PGP"
fi
AC_ARG_ENABLE(smime, [ --disable-smime Disable SMIME support],
......@@ -86,17 +114,12 @@ else
])
if test x$have_smime != xno ; then
AC_DEFINE(HAVE_SMIME,1,[ Define if you want S/MIME support. ])
AC_DEFINE(CRYPT_BACKEND_CLASSIC_SMIME,1,
[ Define if you want clasic S/MIME support. ])
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o "
OPS="$OPS \$(srcdir)/OPS.SMIME"
SMIMEAUX_TARGET="smime_keys"