68 char tmp[512] = { 0 };
74 if (c_crypt_timestamp)
83 snprintf(tmp,
sizeof(tmp),
_(
"[-- %s output follows%s --]\n"),
NONULL(app_name), p);
109#include <sys/resource.h>
113static void disable_coredumps(
void)
115 struct rlimit rl = { 0, 0 };
116 static bool done =
false;
120 setrlimit(RLIMIT_CORE, &rl);
159 struct Body *pbody = NULL, *tmp_pbody = NULL;
160 struct Body *tmp_smime_pbody = NULL;
161 struct Body *tmp_pgp_pbody = NULL;
162 bool has_retainable_sig =
false;
172 security &= ~SEC_SIGN;
186 if (
query_quadoption(
_(
"Inline PGP can't be used with attachments. Revert to PGP/MIME?"),
189 mutt_error(
_(
"Mail not sent: inline PGP can't be used with attachments"));
195 if ((
query_quadoption(
_(
"Inline PGP can't be used with format=flowed. Revert to PGP/MIME?"),
198 mutt_error(
_(
"Mail not sent: inline PGP can't be used with format=flowed"));
208 puts(
_(
"Invoking PGP..."));
218 if (
query_quadoption(
_(
"Message can't be sent inline. Revert to using PGP/MIME?"),
233 tmp_smime_pbody = e->
body;
235 tmp_pgp_pbody = e->
body;
237#ifdef CRYPT_BACKEND_GPGME
239 if (sign && c_crypt_use_pka)
245 const char *mailbox = NULL;
247 bool free_from =
false;
257 if (!
mailbox && c_envelope_from_address)
270 if (c_crypt_protected_headers_write)
275 if (c_devel_security)
324 tmp_smime_pbody = tmp_pbody;
335 has_retainable_sig =
true;
338 tmp_pgp_pbody = tmp_pbody;
353 if ((tmp_smime_pbody != e->
body) && (tmp_smime_pbody != tmp_pbody))
370 if (has_retainable_sig)
382 if (has_retainable_sig)
618 bool complain =
false;
653 mutt_message(
_(
"S/MIME messages with no hints on content are unsupported"));
661 if ((len > 0) && (*(t + len) ==
'.'))
740 rc |= u | (w & ~SEC_GOODSIGN);
780 const int c = fgetc(state->
fp_in);
792 if ((c ==
'\n') && !hadcr)
875 struct Email **ep = NULL;
878 struct Email *e = *ep;
898 puts(
_(
"Trying to extract PGP keys...\n"));
911 const char *mbox = NULL;
925 puts(
_(
"Trying to extract S/MIME certificates..."));
968 const char *self_encrypt = NULL;
1007 if (c_pgp_self_encrypt || (c_pgp_encrypt_self ==
MUTT_YES))
1008 self_encrypt = c_pgp_default_key;
1021 if (c_smime_self_encrypt || (c_smime_encrypt_self ==
MUTT_YES))
1022 self_encrypt = c_smime_default_key;
1026 if (!oppenc_mode && self_encrypt)
1030 sprintf(*keylist + keylist_size,
" %s", self_encrypt);
1054 char *pgpkeylist = NULL;
1079 for (; b; b = b->
next)
1090 (*b_sigs)[(*n)++] = b;
1103 const char *
const c_crypt_protected_headers_subject =
1135 bool weed = (display && c_weed);
1136 if (c_devel_security)
1137 weed &= c_crypt_protected_headers_weed;
1139 if (c_devel_security)
1210 if (c_devel_security)
1248 bool inconsistent =
false;
1249 struct Body *top = b_email;
1250 struct Body **signatures = NULL;
1253 struct Buffer *tempfile = NULL;
1255 b_email = b_email->
parts;
1260 state_printf(state,
_(
"[-- Error: Unknown multipart/signed protocol %s --]\n\n"),
1265 if (!(b_email && b_email->
next))
1267 inconsistent =
true;
1271 switch (signed_type)
1277 inconsistent =
true;
1284 inconsistent =
true;
1292 inconsistent =
true;
1296 inconsistent =
true;
1301 state_attach_puts(state,
_(
"[-- Error: Missing or bad-format multipart/signed signature --]\n\n"));
1313 bool goodsig =
true;
1316 for (
int i = 0; i < sigcnt; i++)
1339 state_printf(state,
_(
"[-- Warning: We can't verify %s/%s signatures --]\n\n"),
1340 TYPE(signatures[i]), signatures[i]->subtype);
1386 const char **ppl,
const char **pps)
1388 const char *ps = NULL, *pl = NULL, *phint = NULL;
1389 char *pfcopy = NULL, *s1 = NULL, *s2 = NULL;
1413 if (((
'0' <= c) && (c <=
'9')) || ((
'A' <= c) && (c <=
'F')) ||
1414 ((
'a' <= c) && (c <=
'f')))
1423 if ((c ==
' ') && ((hexdigits % 4) == 0))
1431 pfcopy = (!c && ((hexdigits == 40) || (hexdigits == 32)) ?
mutt_str_dup(pf) : NULL);
1482 if (!strchr(
"0123456789ABCDEFabcdef", *s++))
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
void mutt_addr_free(struct Address **ptr)
Free a single Address.
size_t mutt_addrlist_write(const struct AddressList *al, struct Buffer *buf, bool display)
Write an Address to a buffer.
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
const struct Address * cs_subset_address(const struct ConfigSubset *sub, const char *name)
Get an Address config item by name.
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
GUI display the mailboxes in a side panel.
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Autocrypt end-to-end encryption.
@ AUTOCRYPT_REC_NO
Do no use Autocrypt.
int mutt_autocrypt_generate_gossip_list(struct Email *e)
Create the gossip list headers.
enum AutocryptRec mutt_autocrypt_ui_recommendation(const struct Email *e, char **keylist)
Get the recommended action for an Email.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
enum QuadOption cs_subset_quad(const struct ConfigSubset *sub, const char *name)
Get a quad-value config item by name.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
int mutt_copy_message(FILE *fp_out, struct Email *e, struct Message *msg, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Duplicate the structure of an entire email.
#define MUTT_CM_DECODE
Decode the message body into text/plain.
#define MUTT_CM_CHARCONV
Perform character set conversions.
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
#define CH_DISPLAY
Display result to user.
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
#define MUTT_CM_NO_FLAGS
No flags are set.
#define MUTT_CM_DECODE_CRYPT
#define MUTT_CM_NOHEADER
Don't copy the message header.
#define CH_NO_FLAGS
No flags are set.
Convenience wrapper for the core headers.
static void crypt_fetch_signatures(struct Body ***b_sigs, struct Body *b, int *n)
Create an array of an emails parts.
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
bool crypt_is_numerical_keyid(const char *s)
Is this a numerical keyid.
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
bool mutt_should_hide_protected_subject(struct Email *e)
Should NeoMutt hide the protected subject?
void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailArray *ea)
Extract keys from a message.
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
int mutt_protect(struct Email *e, char *keylist, bool postpone)
Encrypt and/or sign a message.
void crypt_forget_passphrase(void)
Forget a passphrase and display a message.
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.
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
int crypt_write_signed(struct Body *b, struct State *state, const char *tempfile)
Write the message body/part.
int crypt_get_keys(struct Email *e, char **keylist, bool oppenc_mode)
Check we have all the keys we need.
void crypt_current_time(struct State *state, const char *app_name)
Print the current time.
void crypt_convert_to_7bit(struct Body *b)
Convert an email to 7bit encoding.
SecurityFlags mutt_is_application_pgp(const struct Body *b)
Does the message use PGP?
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Signing/encryption multiplexor.
char * crypt_smime_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Wrapper for CryptModuleSpecs::find_keys()
struct Body * crypt_smime_build_smime_entity(struct Body *b, char *certlist)
Wrapper for CryptModuleSpecs::smime_build_smime_entity()
struct Body * crypt_smime_sign_message(struct Body *b, const struct AddressList *from)
Wrapper for CryptModuleSpecs::sign_message()
struct Body * crypt_pgp_traditional_encryptsign(struct Body *b, SecurityFlags flags, char *keylist)
Wrapper for CryptModuleSpecs::pgp_traditional_encryptsign()
char * crypt_pgp_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Wrapper for CryptModuleSpecs::find_keys()
struct Body * crypt_pgp_sign_message(struct Body *b, const struct AddressList *from)
Wrapper for CryptModuleSpecs::sign_message()
bool crypt_smime_valid_passphrase(void)
Wrapper for CryptModuleSpecs::valid_passphrase()
void crypt_pgp_invoke_import(const char *fname)
Wrapper for CryptModuleSpecs::pgp_invoke_import()
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
void crypt_smime_invoke_import(const char *infile, const char *mailbox)
Wrapper for CryptModuleSpecs::smime_invoke_import()
void crypt_pgp_set_sender(const char *sender)
Wrapper for CryptModuleSpecs::set_sender()
void crypt_smime_set_sender(const char *sender)
Wrapper for CryptModuleSpecs::set_sender()
int crypt_smime_verify_one(struct Body *b, struct State *state, const char *tempf)
Wrapper for CryptModuleSpecs::verify_one()
void crypt_pgp_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
bool crypt_pgp_valid_passphrase(void)
Wrapper for CryptModuleSpecs::valid_passphrase()
int crypt_pgp_verify_one(struct Body *b, struct State *state, const char *tempf)
Wrapper for CryptModuleSpecs::verify_one()
struct Body * crypt_pgp_encrypt_message(struct Email *e, struct Body *b, char *keylist, int sign, const struct AddressList *from)
Wrapper for CryptModuleSpecs::pgp_encrypt_message()
Wrapper around crypto functions.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
void mutt_endwin(void)
Shutdown curses.
void mutt_body_free(struct Body **ptr)
Free a Body.
Structs that make up an email.
bool mutt_matches_ignore(const char *s)
Does the string match the ignore list.
int mutt_env_to_intl(struct Envelope *env, const char **tag, char **err)
Convert an Envelope's Address fields to Punycode format.
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
struct Envelope * mutt_env_new(void)
Create a new Envelope.
void mutt_env_set_subject(struct Envelope *env, const char *subj)
Set both subject and real_subj to subj.
bool mutt_file_seek(FILE *fp, LOFF_T offset, int whence)
Wrapper for fseeko with error handling.
void mutt_file_unlink(const char *s)
Delete a file, carefully.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
bool OptDontHandlePgpKeys
(pseudo) used to extract PGP keys
bool OptPgpCheckTrust
(pseudo) used by dlg_pgp()
int mutt_protected_headers_handler(struct Body *b_email, struct State *state)
Handler for protected headers - Implements handler_t -.
int mutt_signed_handler(struct Body *b_email, struct State *state)
Handler for "multipart/signed" - Implements handler_t -.
#define mutt_message(...)
Convenience wrapper for the gui headers.
int mutt_body_handler(struct Body *b, struct State *state)
Handler for the Body of an email.
Decide how to display email content.
void mutt_list_copy_tail(struct ListHead *dst, const struct ListHead *src)
Copy a list into another list.
size_t mutt_list_write(const struct ListHead *h, struct Buffer *buf)
Write a list to a buffer.
#define MUTT_MEM_REALLOC(pptr, n, type)
@ ENC_BASE64
Base-64 encoded text.
@ ENC_QUOTED_PRINTABLE
Quoted-printable text.
@ TYPE_MESSAGE
Type: 'message/*'.
@ TYPE_MULTIPART
Type: 'multipart/*'.
@ TYPE_APPLICATION
Type: 'application/*'.
@ TYPE_TEXT
Type: 'text/*'.
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Convenience wrapper for the library headers.
void state_attach_puts(struct State *state, const char *t)
Write a string to the state.
int state_printf(struct State *state, const char *fmt,...)
Write a formatted string to the State.
void state_mark_protected_header(struct State *state)
Write a unique marker around protected headers.
#define state_puts(STATE, STR)
#define STATE_DISPLAY
Output is displayed to the user.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
char * mutt_str_skip_whitespace(const char *p)
Find the first non-whitespace character in a string.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Many unsorted constants and some structs.
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
#define SEC_INLINE
Email has an inline signature.
#define SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
#define SEC_GOODSIGN
Email has a valid signature.
#define APPLICATION_PGP
Use PGP to encrypt/sign.
#define SEC_BADSIGN
Email has a bad signature.
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
#define SEC_NO_FLAGS
No flags are set.
#define SEC_PARTSIGN
Not all parts of the email is signed.
#define SEC_ENCRYPT
Email is encrypted.
#define SEC_SIGN
Email is signed.
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
void mutt_param_delete(struct ParameterList *pl, const char *attribute)
Delete a matching Parameter.
void mutt_param_set(struct ParameterList *pl, const char *attribute, const char *value)
Set a Parameter.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
QuadOption
Possible values for a quad-option.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
#define TAILQ_FIRST(head)
#define TAILQ_HEAD_INITIALIZER(head)
#define TAILQ_EMPTY(head)
Convenience wrapper for the send headers.
struct Address * mutt_default_from(struct ConfigSubset *sub)
Get a default 'from' Address.
const char * mutt_fqdn(bool may_hide_host, const struct ConfigSubset *sub)
Get the Fully-Qualified Domain Name.
void mutt_prepare_envelope(struct Envelope *env, bool final, struct ConfigSubset *sub)
Prepare an email header.
void mutt_message_to_7bit(struct Body *b, FILE *fp, struct ConfigSubset *sub)
Convert an email's MIME parts to 7-bit.
struct Buffer * mailbox
Mailbox and host address.
char * d_filename
filename to be used for the content-disposition header If NULL, filename is used instead.
struct Body * parts
parts of a multipart or message/rfc822
LOFF_T offset
offset where the actual data begins
bool badsig
Bad cryptographic signature (needed to check encrypted s/mime-signatures)
struct Envelope * mime_headers
Memory hole protected headers.
bool is_autocrypt
Flag autocrypt-decrypted messages for replying.
LOFF_T length
length (in bytes) of attachment
struct ParameterList parameter
Parameters of the content-type.
char * description
content-description
struct Content * content
Detailed info about the content of the attachment.
struct Body * next
next attachment in the list
char * subtype
content-type subtype
unsigned int encoding
content-transfer-encoding, ContentEncoding
bool goodsig
Good cryptographic signature.
long hdr_offset
Offset in stream where the headers begin.
unsigned int type
content-type primary type, ContentType
char * filename
When sending a message, this is the file to which this structure refers.
String manipulation buffer.
bool space
Whitespace at the end of lines?
bool from
Has a line beginning with "From "?
The envelope/body of an email.
struct Envelope * env
Envelope information.
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
struct Body * body
List of MIME parts.
struct AddressList return_path
Return path for the Email.
char *const subject
Email's subject.
struct AddressList to
Email's 'To' list.
struct AddressList reply_to
Email's 'reply-to'.
char * message_id
Message ID.
struct AddressList x_original_to
Email's 'X-Original-to'.
struct AddressList mail_followup_to
Email's 'mail-followup-to'.
struct AddressList cc
Email's 'Cc' list.
struct AddressList sender
Email's sender.
struct ListHead references
message references (in reverse order)
struct ListHead in_reply_to
in-reply-to header content
struct AddressList bcc
Email's 'Bcc' list.
struct AddressList from
Email's 'From' list.
A local copy of an email.
FILE * fp
pointer to the message data
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
Keep track when processing files.
int wraplen
Width to wrap lines to (when flags & STATE_DISPLAY)
StateFlags flags
Flags, e.g. STATE_DISPLAY.
FILE * fp_out
File to write to.
FILE * fp_in
File to read from.
const char * prefix
String to add to the beginning of each output line.