NeoMutt  2024-03-23-23-gec7045
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h File Reference

Support of Mixmaster anonymous remailer. More...

#include "remailer.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mix_send_message (struct ListHead *chain, const char *tempfile)
 Send an email via Mixmaster.
 
int mix_check_message (struct Email *e)
 Safety-check the message before passing it to mixmaster.
 
void dlg_mixmaster (struct ListHead *chainhead)
 Create a Mixmaster chain -.
 

Detailed Description

Support of Mixmaster anonymous remailer.

Authors
  • Pietro Cerutti
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file lib.h.

Function Documentation

◆ mix_send_message()

int mix_send_message ( struct ListHead *  chain,
const char *  tempfile 
)

Send an email via Mixmaster.

Parameters
chainString list of hosts
tempfileTemporary file containing email
Return values
-1Error
>=0Success (Mixmaster's return code)

Definition at line 101 of file mixmaster.c.

102{
103 int i = 0;
104 struct Buffer *cmd = buf_pool_get();
105 struct Buffer *cd_quoted = buf_pool_get();
106
107 const char *const c_mixmaster = cs_subset_string(NeoMutt->sub, "mixmaster");
108 buf_printf(cmd, "cat %s | %s -m ", tempfile, c_mixmaster);
109
110 struct ListNode *np = NULL;
111 STAILQ_FOREACH(np, chain, entries)
112 {
113 buf_addstr(cmd, (i != 0) ? "," : " -l ");
114 buf_quote_filename(cd_quoted, (char *) np->data, true);
115 buf_addstr(cmd, buf_string(cd_quoted));
116 i = 1;
117 }
118
119 mutt_endwin();
120
121 i = mutt_system(cmd->data);
122 if (i != 0)
123 {
124 fprintf(stderr, _("Error sending message, child exited %d\n"), i);
125 if (!OptNoCurses)
126 {
128 mutt_error(_("Error sending message"));
129 }
130 }
131
132 buf_pool_release(&cmd);
133 buf_pool_release(&cd_quoted);
134 unlink(tempfile);
135 return i;
136}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:178
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:243
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:97
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition: curs_lib.c:175
void mutt_endwin(void)
Shutdown curses.
Definition: curs_lib.c:153
void buf_quote_filename(struct Buffer *buf, const char *filename, bool add_outer)
Quote a filename to survive the shell's quoting rules.
Definition: file.c:974
bool OptNoCurses
(pseudo) when sending in batch mode
Definition: globals.c:72
#define mutt_error(...)
Definition: logging2.h:92
#define _(a)
Definition: message.h:28
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:51
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
String manipulation buffer.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:37
A List node for strings.
Definition: list.h:35
char * data
String.
Definition: list.h:36
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mix_check_message()

int mix_check_message ( struct Email e)

Safety-check the message before passing it to mixmaster.

Parameters
eEmail
Return values
0Success
-1Error

Definition at line 50 of file mixmaster.c.

51{
52 bool need_hostname = false;
53
54 if (!TAILQ_EMPTY(&e->env->cc) || !TAILQ_EMPTY(&e->env->bcc))
55 {
56 mutt_error(_("Mixmaster doesn't accept Cc or Bcc headers"));
57 return -1;
58 }
59
60 /* When using mixmaster, we MUST qualify any addresses since
61 * the message will be delivered through remote systems.
62 *
63 * use_domain won't be respected at this point, hidden_host will.
64 */
65
66 struct Address *a = NULL;
67 TAILQ_FOREACH(a, &e->env->to, entries)
68 {
69 if (!a->group && !buf_find_char(a->mailbox, '@'))
70 {
71 need_hostname = true;
72 break;
73 }
74 }
75
76 if (need_hostname)
77 {
78 const char *fqdn = mutt_fqdn(true, NeoMutt->sub);
79 if (!fqdn)
80 {
81 mutt_error(_("Please set the hostname variable to a proper value when using mixmaster"));
82 return -1;
83 }
84
85 /* Cc and Bcc are empty at this point. */
86 mutt_addrlist_qualify(&e->env->to, fqdn);
89 }
90
91 return 0;
92}
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
Definition: address.c:680
const char * buf_find_char(const struct Buffer *buf, const char c)
Return a pointer to a char found in the buffer.
Definition: buffer.c:672
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
#define TAILQ_EMPTY(head)
Definition: queue.h:721
const char * mutt_fqdn(bool may_hide_host, const struct ConfigSubset *sub)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:706
An email address.
Definition: address.h:36
bool group
Group mailbox?
Definition: address.h:39
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
struct Envelope * env
Envelope information.
Definition: email.h:68
struct AddressList to
Email's 'To' list.
Definition: envelope.h:60
struct AddressList reply_to
Email's 'reply-to'.
Definition: envelope.h:64
struct AddressList mail_followup_to
Email's 'mail-followup-to'.
Definition: envelope.h:65
struct AddressList cc
Email's 'Cc' list.
Definition: envelope.h:61
struct AddressList bcc
Email's 'Bcc' list.
Definition: envelope.h:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function: