NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference

Support of Mixmaster anonymous remailer. More...

+ 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. More...
 
int mix_check_message (struct Email *e)
 Safety-check the message before passing it to mixmaster. More...
 
void dlg_mixmaster (struct ListHead *chainhead)
 Create a Mixmaster chain. More...
 

Detailed Description

Support of Mixmaster anonymous remailer.

Authors
  • Thomas Roessler

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 102 of file mixmaster.c.

103{
104 int i = 0;
105 struct Buffer *cmd = mutt_buffer_pool_get();
106 struct Buffer *cd_quoted = mutt_buffer_pool_get();
107
108 const char *const c_mixmaster = cs_subset_string(NeoMutt->sub, "mixmaster");
109 mutt_buffer_printf(cmd, "cat %s | %s -m ", tempfile, c_mixmaster);
110
111 struct ListNode *np = NULL;
112 STAILQ_FOREACH(np, chain, entries)
113 {
114 mutt_buffer_addstr(cmd, (i != 0) ? "," : " -l ");
115 mutt_buffer_quote_filename(cd_quoted, (char *) np->data, true);
116 mutt_buffer_addstr(cmd, mutt_buffer_string(cd_quoted));
117 i = 1;
118 }
119
120 mutt_endwin();
121
122 i = mutt_system(cmd->data);
123 if (i != 0)
124 {
125 fprintf(stderr, _("Error sending message, child exited %d\n"), i);
126 if (!OptNoCurses)
127 {
129 mutt_error(_("Error sending message"));
130 }
131 }
132
134 mutt_buffer_pool_release(&cd_quoted);
135 unlink(tempfile);
136 return i;
137}
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:233
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:168
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition: curs_lib.c:387
void mutt_endwin(void)
Shutdown curses.
Definition: curs_lib.c:354
void mutt_buffer_quote_filename(struct Buffer *buf, const char *filename, bool add_outer)
Quote a filename to survive the shell's quoting rules.
Definition: file.c:891
#define mutt_error(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:53
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
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:34
char * data
Pointer to data.
Definition: buffer.h:35
A List node for strings.
Definition: list.h:35
char * data
String.
Definition: list.h:36
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ 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 51 of file mixmaster.c.

52{
53 bool need_hostname = false;
54
55 if (!TAILQ_EMPTY(&e->env->cc) || !TAILQ_EMPTY(&e->env->bcc))
56 {
57 mutt_error(_("Mixmaster doesn't accept Cc or Bcc headers"));
58 return -1;
59 }
60
61 /* When using mixmaster, we MUST qualify any addresses since
62 * the message will be delivered through remote systems.
63 *
64 * use_domain won't be respected at this point, hidden_host will.
65 */
66
67 struct Address *a = NULL;
68 TAILQ_FOREACH(a, &e->env->to, entries)
69 {
70 if (!a->group && !strchr(a->mailbox, '@'))
71 {
72 need_hostname = true;
73 break;
74 }
75 }
76
77 if (need_hostname)
78 {
79 const char *fqdn = mutt_fqdn(true, NeoMutt->sub);
80 if (!fqdn)
81 {
82 mutt_error(_("Please set the hostname variable to a proper value when using mixmaster"));
83 return -1;
84 }
85
86 /* Cc and Bcc are empty at this point. */
87 mutt_addrlist_qualify(&e->env->to, fqdn);
90 }
91
92 return 0;
93}
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
Definition: address.c:650
#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:698
An email address.
Definition: address.h:36
bool group
Group mailbox?
Definition: address.h:39
char * mailbox
Mailbox and host address.
Definition: address.h:38
struct Envelope * env
Envelope information.
Definition: email.h:66
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:

◆ dlg_mixmaster()

void dlg_mixmaster ( struct ListHead *  chainhead)

Create a Mixmaster chain.

Parameters
chainheadList of chain links

Ask the user to select Mixmaster hosts to create a chain.

Definition at line 186 of file dlg_mixmaster.c.

187{
188 struct MixmasterPrivateData priv = { 0 };
189
190 struct RemailerArray ra = remailer_get_hosts();
191 if (ARRAY_EMPTY(&ra))
192 {
193 mutt_error(_("Can't get mixmaster's type2.list"));
194 return;
195 }
196
197 struct MuttWindow *dlg = mix_dlg_new(&priv, &ra);
198
199 win_chain_init(priv.win_chain, chainhead, &ra);
200 mutt_list_free(chainhead);
201
202 dialog_push(dlg);
203
204 // ---------------------------------------------------------------------------
205 // Event Loop
206 int op = OP_NULL;
207 int rc = FR_UNKNOWN;
208 do
209 {
211 window_redraw(NULL);
212
213 op = km_dokey(MENU_MIX);
214 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
215 if (op < 0)
216 continue;
217 if (op == OP_NULL)
218 {
220 continue;
221 }
223
224 rc = mix_function_dispatcher(dlg, op);
225
226 if (rc == FR_UNKNOWN)
227 rc = menu_function_dispatcher(priv.win_hosts, op);
228 if (rc == FR_UNKNOWN)
229 rc = global_function_dispatcher(NULL, op);
230 } while ((rc != FR_DONE) && (rc != FR_NO_ACTION));
231 // ---------------------------------------------------------------------------
232
233 /* construct the remailer list */
234 if (rc == FR_DONE)
235 win_chain_extract(priv.win_chain, chainhead);
236
237 dialog_pop();
238 mutt_window_free(&dlg);
239
241}
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:73
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
Definition: dialog.c:103
void dialog_pop(void)
Hide a Window from the user.
Definition: dialog.c:137
@ FR_DONE
Exit the Dialog.
Definition: dispatcher.h:35
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
static struct MuttWindow * mix_dlg_new(struct MixmasterPrivateData *priv, struct RemailerArray *ra)
Create a new Mixmaster Remailer Dialog.
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
int mix_function_dispatcher(struct MuttWindow *win, int op)
Perform a Mixmaster function - Implements function_dispatcher_t -.
Definition: functions.c:140
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:201
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:46
struct RemailerArray remailer_get_hosts(void)
Parse the type2.list as given by mixmaster -T.
Definition: remailer.c:114
void remailer_clear_hosts(struct RemailerArray *ra)
Clear a Remailer List.
Definition: remailer.c:205
Private state data for the Mixmaster.
Definition: private_data.h:30
struct MuttWindow * win_chain
Chain Window.
Definition: private_data.h:32
struct MuttWindow * win_hosts
Hosts Window.
Definition: private_data.h:31
@ MENU_MIX
Create/edit a Mixmaster chain.
Definition: type.h:52
int win_chain_extract(struct MuttWindow *win, struct ListHead *chain)
Extract the Chain list data.
Definition: win_chain.c:233
void win_chain_init(struct MuttWindow *win, struct ListHead *chain, struct RemailerArray *ra)
Initialise the Chain list Window.
Definition: win_chain.c:207
+ Here is the call graph for this function:
+ Here is the caller graph for this function: