73 char p[256], tmp[256];
85 snprintf(tmp,
sizeof(tmp),
_(
"[-- %s output follows%s --]\n"),
NONULL(app_name), p);
111 #include <sys/resource.h> 115 static void disable_coredumps(
void)
117 struct rlimit rl = { 0, 0 };
118 static bool done =
false;
122 setrlimit(RLIMIT_CORE, &rl);
161 struct Body *pbody = NULL, *tmp_pbody = NULL;
162 struct Body *tmp_smime_pbody = NULL;
163 struct Body *tmp_pgp_pbody = NULL;
164 bool has_retainable_sig =
false;
190 _(
"Inline PGP can't be used with attachments. " 191 "Revert to PGP/MIME?")) !=
MUTT_YES)
194 _(
"Mail not sent: inline PGP can't be used with attachments"));
202 _(
"Inline PGP can't be used with format=flowed. " 203 "Revert to PGP/MIME?"))) !=
MUTT_YES)
206 _(
"Mail not sent: inline PGP can't be used with format=flowed"));
216 puts(
_(
"Invoking PGP..."));
228 _(
"Message can't be sent inline. Revert to using PGP/MIME?")) !=
MUTT_YES)
242 tmp_smime_pbody = e->
body;
244 tmp_pgp_pbody = e->
body;
246 #ifdef CRYPT_BACKEND_GPGME 253 const char *mailbox = NULL;
255 bool free_from =
false;
267 if (((
WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
269 else if (((
WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP))
306 if (
C_Autocrypt && !postpone && (security & SEC_AUTOCRYPT))
314 if (((
WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
320 tmp_smime_pbody = tmp_pbody;
323 if (((
WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP) &&
330 has_retainable_sig =
true;
333 tmp_pgp_pbody = tmp_pbody;
336 if ((
WithCrypto != 0) && (security & APPLICATION_SMIME) && (security & APPLICATION_PGP))
344 if (((
WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
353 if ((tmp_smime_pbody != e->
body) && (tmp_smime_pbody != tmp_pbody))
364 if (((
WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP))
370 if (has_retainable_sig)
382 if (has_retainable_sig)
432 if (((
WithCrypto & APPLICATION_SMIME) != 0) &&
619 bool complain =
false;
653 _(
"S/MIME messages with no hints on content are unsupported"));
661 if ((len > 0) && (*(t + len) ==
'.'))
774 const int c = fgetc(s->
fp_in);
784 if ((c ==
'\n') && !hadcr)
879 puts(
_(
"Trying to extract PGP keys...\n"));
908 puts(
_(
"Trying to extract S/MIME certificates..."));
950 char *self_encrypt = NULL;
1002 if (!oppenc_mode && self_encrypt)
1006 sprintf(*keylist + keylist_size,
" %s", self_encrypt);
1029 char *pgpkeylist = NULL;
1054 for (; a; a = a->
next)
1063 (*signatures)[(*n)++] = a;
1118 bool inconsistent =
false;
1120 struct Body **signatures = NULL;
1123 struct Buffer *tempfile = NULL;
1132 "Unknown multipart/signed protocol %s --]\n\n"),
1137 if (!(a && a->
next))
1138 inconsistent =
true;
1141 switch (signed_type)
1146 inconsistent =
true;
1153 inconsistent =
true;
1161 inconsistent =
true;
1165 inconsistent =
true;
1171 "signature --]\n\n"));
1183 bool goodsig =
true;
1186 for (
int i = 0; i < sigcnt; i++)
1211 "We can't verify %s/%s signatures. --]\n\n"),
1212 TYPE(signatures[i]), signatures[i]->subtype);
1232 _(
"[-- Warning: Can't find any signatures. --]\n\n"));
1259 const char **ppl,
const char **pps)
1261 const char *ps = NULL, *pl = NULL, *phint = NULL;
1262 char *pfcopy = NULL, *s1 = NULL, *s2 = NULL;
1286 if (((
'0' <= c) && (c <=
'9')) || ((
'A' <= c) && (c <=
'F')) ||
1287 ((
'a' <= c) && (c <=
'f')))
1296 if ((c ==
' ') && ((hexdigits % 4) == 0))
1304 pfcopy = (!c && ((hexdigits == 40) || (hexdigits == 32)) ?
mutt_str_dup(pf) : NULL);
1355 if (!strchr(
"0123456789ABCDEFabcdef", *s++))
#define MUTT_CM_DECODE_CRYPT
int mutt_protected_headers_handler(struct Body *a, struct State *s)
Process a protected header - Implements handler_t.
Convenience wrapper for the gui headers.
bool mutt_matches_ignore(const char *s)
Does the string match the ignore list.
const char * crypt_get_fingerprint_or_id(const char *p, const char **pphint, const char **ppl, const char **pps)
Get the fingerprint or long key ID.
int state_printf(struct State *s, const char *fmt,...)
Write a formatted string to the State.
char * mutt_str_skip_whitespace(const char *p)
Find the first non-whitespace character in a string.
#define mutt_buffer_mktemp(buf)
#define MUTT_DISPLAY
Output is displayed to the user.
char * filename
when sending a message, this is the file to which this structure refers
struct Envelope * mime_headers
Memory hole protected headers.
Miscellaneous email parsing routines.
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
The envelope/body of an email.
#define state_puts(STATE, STR)
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
char * crypt_smime_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Wrapper for CryptModuleSpecs::find_keys()
#define TAILQ_FIRST(head)
struct Content * content
Detailed info about the content of the attachment.
struct Body * body
List of MIME parts.
Structs that make up an email.
Autocrypt end-to-end encryption.
#define SEC_NO_FLAGS
No flags are set.
Convenience wrapper for the send headers.
void mutt_message_to_7bit(struct Body *a, FILE *fp, struct ConfigSubset *sub)
Convert an email's MIME parts to 7-bit.
#define mutt_message(...)
int mutt_signed_handler(struct Body *a, struct State *s)
Verify a "multipart/signed" body - Implements handler_t.
struct AddressList bcc
Email's 'Bcc' list.
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Wrapper around crypto functions.
void crypt_pgp_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
#define SEC_ENCRYPT
Email is encrypted.
void crypt_convert_to_7bit(struct Body *a)
Convert an email to 7bit encoding.
bool crypt_smime_valid_passphrase(void)
Wrapper for CryptModuleSpecs::valid_passphrase()
bool mutt_should_hide_protected_subject(struct Email *e)
Should NeoMutt hide the protected subject?
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
bool crypt_is_numerical_keyid(const char *s)
Is this a numerical keyid.
void crypt_forget_passphrase(void)
Forget a passphrase and display a message.
void mutt_file_unlink(const char *s)
Delete a file, carefully.
String manipulation buffer.
bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
char * prefix
String to add to the beginning of each output line.
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
char * mutt_str_dup(const char *str)
Copy a string, safely.
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
LOFF_T offset
offset where the actual data begins
void crypt_pgp_set_sender(const char *sender)
Wrapper for CryptModuleSpecs::set_sender()
bool is_autocrypt
Flag autocrypt-decrypted messages for replying.
struct Body * next
next attachment in the list
#define MUTT_DATE_NOW
Constant representing the 'current time', see: mutt_date_gmtime(), mutt_date_localtime() ...
FILE * fp_out
File to write to.
char * mailbox
Mailbox and host address.
unsigned char C_PgpMimeAuto
Config: Prompt the user to use MIME if inline PGP fails.
#define SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
int crypt_get_keys(struct Email *e, char **keylist, bool oppenc_mode)
Check we have all the keys we need.
int crypt_write_signed(struct Body *a, struct State *s, const char *tempfile)
Write the message body/part.
Shared constants/structs that are private to libconn.
unsigned char C_SmimeEncryptSelf
#define MUTT_CM_NO_FLAGS
No flags are set.
void mutt_addr_free(struct Address **ptr)
Free a single Address.
Container for Accounts, Notifications.
FILE * fp_in
File to read from.
Convenience wrapper for the config headers.
void crypt_smime_set_sender(const char *sender)
Wrapper for CryptModuleSpecs::set_sender()
#define SEC_INLINE
Email has an inline signature.
Some miscellaneous functions.
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
struct Body * crypt_smime_sign_message(struct Body *a, const struct AddressList *from)
Wrapper for CryptModuleSpecs::sign_message()
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
void mutt_prepare_envelope(struct Envelope *env, bool final, struct ConfigSubset *sub)
Prepare an email header.
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient's key is available.
Many unsorted constants and some structs.
struct AddressList from
Email's 'From' list.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
struct Envelope * env
Envelope information.
Convenience wrapper for the core headers.
void crypt_current_time(struct State *s, const char *app_name)
Print the current time.
bool badsig
Bad cryptographic signature (needed to check encrypted s/mime-signatures)
struct AddressList cc
Email's 'Cc' list.
bool C_CryptTimestamp
Config: Add a timestamp to PGP or SMIME output to prevent spoofing.
WHERE bool OptDontHandlePgpKeys
(pseudo) used to extract PGP keys
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
int wraplen
Width to wrap lines to (when flags & MUTT_DISPLAY)
char * C_PgpDefaultKey
Config: Default key to use for PGP operations.
unsigned int encoding
content-transfer-encoding, ContentEncoding
struct Envelope * mutt_env_new(void)
Create a new Envelope.
bool C_SmimeSelfEncrypt
Config: Encrypted messages will also be encrypt to $smime_default_key too.
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
char * subtype
content-type subtype
struct Body * crypt_pgp_encrypt_message(struct Email *e, struct Body *a, char *keylist, int sign, const struct AddressList *from)
Wrapper for CryptModuleSpecs::pgp_encrypt_message()
bool C_CryptUsePka
Config: Use GPGME to use PKA (lookup PGP keys using DNS)
void mutt_param_delete(struct ParameterList *pl, const char *attribute)
Delete a matching Parameter.
bool goodsig
Good cryptographic signature.
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
WHERE short C_Wrap
Config: Width to wrap text in the pager.
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Signing/encryption multiplexor.
void mutt_endwin(void)
Shutdown curses/slang.
LOFF_T length
length (in bytes) of attachment
void crypt_pgp_invoke_import(const char *fname)
Wrapper for CryptModuleSpecs::pgp_invoke_import()
struct Address * mutt_default_from(struct ConfigSubset *sub)
Get a default 'from' Address.
#define CH_NO_FLAGS
No flags are set.
#define MUTT_CM_DECODE
Decode the message body into text/plain.
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
#define MUTT_CM_CHARCONV
Perform character set conversions.
int mutt_protect(struct Email *e, char *keylist, bool postpone)
Encrypt and/or sign a message.
struct Body * parts
parts of a multipart or message/rfc822
#define CH_DISPLAY
Display result to user.
struct Body * crypt_pgp_traditional_encryptsign(struct Body *a, int flags, char *keylist)
Wrapper for CryptModuleSpecs::pgp_traditional_encryptsign()
API for encryption/signing of emails.
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
void state_mark_protected_header(struct State *s)
Write a unique marker around protected headers.
void mutt_body_free(struct Body **ptr)
Free a Body.
WHERE bool OptPgpCheckTrust
(pseudo) used by dlg_select_pgp_key()
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
bool C_PgpRetainableSigs
Config: Create nested multipart/signed or encrypted messages.
static void crypt_fetch_signatures(struct Body ***signatures, struct Body *a, int *n)
Create an array of an emails parts.
#define STAILQ_FOREACH(var, head, field)
char * description
content-description
bool C_PgpStrictEnc
Config: Encode PGP signed messages with quoted-printable (don't unset)
char * C_SmimeDefaultKey
Config: Default key for SMIME operations.
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
#define SEC_BADSIGN
Email has a bad signature.
unsigned int type
content-type primary type, ContentType
bool from
Has a line beginning with "From "?
Type: 'message/*'.
bool mutt_strn_equal(const char *a, const char *b, size_t l)
Check for equality of two strings (to a maximum), safely.
#define SEC_SIGN
Email is signed.
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
void state_attach_puts(struct State *s, const char *t)
Write a string to the state.
Keep track when processing files.
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
struct Body * crypt_smime_build_smime_entity(struct Body *a, char *certlist)
Wrapper for CryptModuleSpecs::smime_build_smime_entity()
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
char * crypt_pgp_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Wrapper for CryptModuleSpecs::find_keys()
const char * mutt_fqdn(bool may_hide_host, const struct ConfigSubset *sub)
Get the Fully-Qualified Domain Name.
void crypt_smime_invoke_import(const char *infile, const char *mailbox)
Wrapper for CryptModuleSpecs::smime_invoke_import()
char * subject
Email's subject.
Type: 'multipart/*'.
enum AutocryptRec mutt_autocrypt_ui_recommendation(struct Email *e, char **keylist)
Get the recommended action for an Email.
Duplicate the structure of an entire email.
int mutt_autocrypt_generate_gossip_list(struct Email *e)
Create the gossip list headers.
unsigned char C_PgpEncryptSelf
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
struct Email * email
Email in the list.
struct Body * crypt_pgp_sign_message(struct Body *a, const struct AddressList *from)
Wrapper for CryptModuleSpecs::sign_message()
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
bool C_PgpSelfEncrypt
Config: Encrypted messages will also be encrypted to $pgp_default_key too.
int crypt_smime_verify_one(struct Body *sigbdy, struct State *s, const char *tempf)
Wrapper for CryptModuleSpecs::verify_one()
bool space
Whitespace at the end of lines?
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailList *el)
Extract keys from a message.
Keep track when processing files.
struct AddressList to
Email's 'To' list.
struct AddressList sender
Email's sender.
int mutt_body_handler(struct Body *b, struct State *s)
Handler for the Body of an email.
char * d_filename
filename to be used for the content-disposition header.
Hundreds of global variables to back the user variables.
Handling of global boolean variables.
struct ConfigSubset * sub
Inherited config items.
long hdr_offset
Offset in stream where the headers begin.
#define TAILQ_EMPTY(head)
#define MUTT_CM_NOHEADER
Don't copy the message header.
Convenience wrapper for the library headers.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
#define TAILQ_HEAD_INITIALIZER(head)
Decide how to display email content.
struct ParameterList parameter
parameters of the content-type
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
#define SEC_GOODSIGN
Email has a valid signature.
#define SEC_PARTSIGN
Not all parts of the email is signed.
Type: 'application/*'.
bool crypt_pgp_valid_passphrase(void)
Wrapper for CryptModuleSpecs::valid_passphrase()
struct Address * C_EnvelopeFromAddress
Config: Manually set the sender for outgoing messages.
void mutt_param_set(struct ParameterList *pl, const char *attribute, const char *value)
Set a Parameter.
char * C_CryptProtectedHeadersSubject
Config: Use this as the subject for encrypted emails.
User answered 'Yes', or assume 'Yes'.
int crypt_pgp_verify_one(struct Body *sigbdy, struct State *s, const char *tempf)
Wrapper for CryptModuleSpecs::verify_one()
bool C_CryptProtectedHeadersWrite
Config: Generate protected header (Memory Hole) for signed and encrypted emails.