NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
remailer.h File Reference
#include <stddef.h>
#include <stdint.h>
+ Include dependency graph for remailer.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Remailer
 A Mixmaster remailer. More...
 
struct  MixChain
 A Mixmaster chain. More...
 

Macros

#define MAX_MIXES   19
 
#define MIX_CAP_NO_FLAGS   0
 No flags are set. More...
 
#define MIX_CAP_COMPRESS   (1 << 0)
 
#define MIX_CAP_MIDDLEMAN   (1 << 1)
 
#define MIX_CAP_NEWSPOST   (1 << 2)
 
#define MIX_CAP_NEWSMAIL   (1 << 3)
 

Typedefs

typedef uint8_t MixCapFlags
 Flags, e.g. MIX_CAP_NO_FLAGS. More...
 

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_select_mixmaster_chain (struct MuttWindow *win, struct ListHead *chainhead, int cols)
 Create a Mixmaster chain. More...
 

Variables

char * C_MixEntryFormat
 Config: (mixmaster) printf-like format string for the mixmaster chain. More...
 
char * C_Mixmaster
 Config: (mixmaster) External command to route a mixmaster message. 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 remailer.h.

Macro Definition Documentation

◆ MAX_MIXES

#define MAX_MIXES   19

Definition at line 38 of file remailer.h.

◆ MIX_CAP_NO_FLAGS

#define MIX_CAP_NO_FLAGS   0

No flags are set.

Definition at line 41 of file remailer.h.

◆ MIX_CAP_COMPRESS

#define MIX_CAP_COMPRESS   (1 << 0)

Definition at line 42 of file remailer.h.

◆ MIX_CAP_MIDDLEMAN

#define MIX_CAP_MIDDLEMAN   (1 << 1)

Definition at line 43 of file remailer.h.

◆ MIX_CAP_NEWSPOST

#define MIX_CAP_NEWSPOST   (1 << 2)

Definition at line 44 of file remailer.h.

◆ MIX_CAP_NEWSMAIL

#define MIX_CAP_NEWSMAIL   (1 << 3)

Definition at line 45 of file remailer.h.

Typedef Documentation

◆ MixCapFlags

typedef uint8_t MixCapFlags

Flags, e.g. MIX_CAP_NO_FLAGS.

Definition at line 40 of file remailer.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 846 of file remailer.c.

847 {
848  int i = 0;
849  struct Buffer *cmd = mutt_buffer_pool_get();
850  struct Buffer *cd_quoted = mutt_buffer_pool_get();
851 
852  mutt_buffer_printf(cmd, "cat %s | %s -m ", tempfile, C_Mixmaster);
853 
854  struct ListNode *np = NULL;
855  STAILQ_FOREACH(np, chain, entries)
856  {
857  mutt_buffer_addstr(cmd, (i != 0) ? "," : " -l ");
858  mutt_buffer_quote_filename(cd_quoted, (char *) np->data, true);
859  mutt_buffer_addstr(cmd, mutt_buffer_string(cd_quoted));
860  i = 1;
861  }
862 
863  mutt_endwin();
864 
865  i = mutt_system(cmd->data);
866  if (i != 0)
867  {
868  fprintf(stderr, _("Error sending message, child exited %d\n"), i);
869  if (!OptNoCurses)
870  {
872  mutt_error(_("Error sending message"));
873  }
874  }
875 
877  mutt_buffer_pool_release(&cd_quoted);
878  unlink(tempfile);
879  return i;
880 }
+ 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 794 of file remailer.c.

795 {
796  bool need_hostname = false;
797 
798  if (!TAILQ_EMPTY(&e->env->cc) || !TAILQ_EMPTY(&e->env->bcc))
799  {
800  mutt_error(_("Mixmaster doesn't accept Cc or Bcc headers"));
801  return -1;
802  }
803 
804  /* When using mixmaster, we MUST qualify any addresses since
805  * the message will be delivered through remote systems.
806  *
807  * use_domain won't be respected at this point, hidden_host will.
808  */
809 
810  struct Address *a = NULL;
811  TAILQ_FOREACH(a, &e->env->to, entries)
812  {
813  if (!a->group && !strchr(a->mailbox, '@'))
814  {
815  need_hostname = true;
816  break;
817  }
818  }
819 
820  if (need_hostname)
821  {
822  const char *fqdn = mutt_fqdn(true, NeoMutt->sub);
823  if (!fqdn)
824  {
825  mutt_error(_("Please set the hostname variable to a proper value when "
826  "using mixmaster"));
827  return -1;
828  }
829 
830  /* Cc and Bcc are empty at this point. */
831  mutt_addrlist_qualify(&e->env->to, fqdn);
832  mutt_addrlist_qualify(&e->env->reply_to, fqdn);
834  }
835 
836  return 0;
837 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_select_mixmaster_chain()

void dlg_select_mixmaster_chain ( struct MuttWindow win,
struct ListHead *  chainhead,
int  cols 
)

Create a Mixmaster chain.

Parameters
winWindow
chainheadList of chain links
colsNumber of screen columns

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

Definition at line 574 of file remailer.c.

575 {
576  int c_cur = 0, c_old = 0;
577  bool c_redraw = true;
578  size_t ttll = 0;
579 
580  struct Coord *coords = NULL;
581 
582  struct Menu *menu = NULL;
583  bool loop = true;
584 
585  char *t = NULL;
586 
587  struct Remailer **type2_list = mix_type2_list(&ttll);
588  if (!type2_list)
589  {
590  mutt_error(_("Can't get mixmaster's type2.list"));
591  return;
592  }
593 
594  struct MixChain *chain = mutt_mem_calloc(1, sizeof(struct MixChain));
595 
596  struct ListNode *p = NULL;
597  STAILQ_FOREACH(p, chainhead, entries)
598  {
599  mix_chain_add(chain, p->data, type2_list);
600  }
601  mutt_list_free(chainhead);
602 
603  /* safety check */
604  for (int i = 0; i < chain->cl; i++)
605  {
606  if (chain->ch[i] >= ttll)
607  chain->ch[i] = 0;
608  }
609 
610  mix_screen_coordinates(win, type2_list, &coords, chain, 0);
611 
612  menu = mutt_menu_new(MENU_MIX);
614  dlg->help_data = RemailerHelp;
615  dlg->help_menu = MENU_MIX;
616 
617  menu->max = ttll;
618  menu->make_entry = mix_make_entry;
619  menu->tag = NULL;
620  menu->title = _("Select a remailer chain");
621  menu->mdata = type2_list;
622  menu->pagelen = MIX_VOFFSET - 1;
624 
625  while (loop)
626  {
627  if (menu->pagelen != MIX_VOFFSET - 1)
628  {
629  menu->pagelen = MIX_VOFFSET - 1;
630  menu->redraw = REDRAW_FULL;
631  }
632 
633  if (c_redraw)
634  {
635  mix_redraw_head(menu->win_index, chain);
636  mix_redraw_chain(menu->win_index, type2_list, coords, chain, c_cur);
637  c_redraw = false;
638  }
639  else if (c_cur != c_old)
640  {
641  mix_redraw_ce(menu->win_index, type2_list, coords, chain, c_old, false);
642  mix_redraw_ce(menu->win_index, type2_list, coords, chain, c_cur, true);
643  }
644 
645  c_old = c_cur;
646 
647  const int op = mutt_menu_loop(menu);
648  switch (op)
649  {
650  case OP_REDRAW:
651  {
652  menu_redraw_status(menu);
653  mix_redraw_head(menu->win_index, chain);
654  mix_screen_coordinates(menu->win_index, type2_list, &coords, chain, 0);
655  mix_redraw_chain(menu->win_index, type2_list, coords, chain, c_cur);
656  menu->pagelen = MIX_VOFFSET - 1;
657  break;
658  }
659 
660  case OP_EXIT:
661  {
662  chain->cl = 0;
663  loop = false;
664  break;
665  }
666 
667  case OP_MIX_USE:
668  {
669  if (!chain->cl)
670  {
671  chain->cl++;
672  chain->ch[0] = menu->current;
673  mix_screen_coordinates(menu->win_index, type2_list, &coords, chain, c_cur);
674  c_redraw = true;
675  }
676 
677  if (chain->cl && chain->ch[chain->cl - 1] &&
678  (type2_list[chain->ch[chain->cl - 1]]->caps & MIX_CAP_MIDDLEMAN))
679  {
680  mutt_error(
681  _("Error: %s can't be used as the final remailer of a chain"),
682  type2_list[chain->ch[chain->cl - 1]]->shortname);
683  }
684  else
685  {
686  loop = false;
687  }
688  break;
689  }
690 
691  case OP_GENERIC_SELECT_ENTRY:
692  case OP_MIX_APPEND:
693  {
694  if ((chain->cl < MAX_MIXES) && (c_cur < chain->cl))
695  c_cur++;
696  }
697  /* fallthrough */
698  case OP_MIX_INSERT:
699  {
700  if (chain->cl < MAX_MIXES)
701  {
702  chain->cl++;
703  for (int i = chain->cl - 1; i > c_cur; i--)
704  chain->ch[i] = chain->ch[i - 1];
705 
706  chain->ch[c_cur] = menu->current;
707  mix_screen_coordinates(menu->win_index, type2_list, &coords, chain, c_cur);
708  c_redraw = true;
709  }
710  else
711  {
712  /* L10N The '%d' here hard-coded to 19 */
713  mutt_error(_("Mixmaster chains are limited to %d elements"), MAX_MIXES);
714  }
715 
716  break;
717  }
718 
719  case OP_MIX_DELETE:
720  {
721  if (chain->cl)
722  {
723  chain->cl--;
724 
725  for (int i = c_cur; i < chain->cl; i++)
726  chain->ch[i] = chain->ch[i + 1];
727 
728  if ((c_cur == chain->cl) && c_cur)
729  c_cur--;
730 
731  mix_screen_coordinates(menu->win_index, type2_list, &coords, chain, c_cur);
732  c_redraw = true;
733  }
734  else
735  {
736  mutt_error(_("The remailer chain is already empty"));
737  }
738  break;
739  }
740 
741  case OP_MIX_CHAIN_PREV:
742  {
743  if (c_cur)
744  c_cur--;
745  else
746  mutt_error(_("You already have the first chain element selected"));
747 
748  break;
749  }
750 
751  case OP_MIX_CHAIN_NEXT:
752  {
753  if (chain->cl && (c_cur < chain->cl - 1))
754  c_cur++;
755  else
756  mutt_error(_("You already have the last chain element selected"));
757 
758  break;
759  }
760  }
761  }
762 
763  mutt_menu_pop_current(menu);
764  mutt_menu_free(&menu);
766 
767  /* construct the remailer list */
768 
769  if (chain->cl)
770  {
771  for (int i = 0; i < chain->cl; i++)
772  {
773  const int j = chain->ch[i];
774  if (j != 0)
775  t = type2_list[j]->shortname;
776  else
777  t = "*";
778 
779  mutt_list_insert_tail(chainhead, mutt_str_dup(t));
780  }
781  }
782 
783  mix_type2_list_free(&type2_list);
784  FREE(&coords);
785  FREE(&chain);
786 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_MixEntryFormat

char* C_MixEntryFormat

Config: (mixmaster) printf-like format string for the mixmaster chain.

Definition at line 58 of file remailer.c.

◆ C_Mixmaster

char* C_Mixmaster

Config: (mixmaster) External command to route a mixmaster message.

Definition at line 59 of file remailer.c.

Remailer
A Mixmaster remailer.
Definition: remailer.h:50
mutt_endwin
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:572
MixChain::ch
int ch[MAX_MIXES]
Definition: remailer.h:65
Envelope::bcc
struct AddressList bcc
Email's 'Bcc' list.
Definition: envelope.h:60
dialog_create_simple_index
struct MuttWindow * dialog_create_simple_index(struct Menu *menu, enum WindowType type)
Create a simple index Dialog.
Definition: dialog.c:165
mix_chain_add
static int mix_chain_add(struct MixChain *chain, const char *s, struct Remailer **type2_list)
Add a host to the chain.
Definition: remailer.c:536
mutt_mem_calloc
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
_
#define _(a)
Definition: message.h:28
mutt_system
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:51
mutt_addrlist_qualify
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
Definition: address.c:650
ListNode
A List node for strings.
Definition: list.h:34
Buffer
String manipulation buffer.
Definition: buffer.h:33
MAX_MIXES
#define MAX_MIXES
Definition: remailer.h:38
mix_type2_list
static struct Remailer ** mix_type2_list(size_t *l)
parse the type2.list as given by mixmaster -T
Definition: remailer.c:181
MixChain::cl
size_t cl
Definition: remailer.h:64
MuttWindow
A division of the screen.
Definition: mutt_window.h:115
TAILQ_EMPTY
#define TAILQ_EMPTY(head)
Definition: queue.h:714
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
FREE
#define FREE(x)
Definition: memory.h:40
mutt_menu_new
struct Menu * mutt_menu_new(enum MenuType type)
Create a new Menu.
Definition: menu.c:956
MuttWindow::help_menu
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:134
OptNoCurses
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:48
Menu::make_entry
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Format a item for a menu.
Definition: mutt_menu.h:88
mutt_buffer_pool_release
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
menu_redraw_status
void menu_redraw_status(struct Menu *menu)
Force the redraw of the status bar.
Definition: menu.c:365
mutt_list_insert_tail
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:64
STAILQ_FOREACH
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
RemailerHelp
static const struct Mapping RemailerHelp[]
Help Bar for the Mixmaster dialog.
Definition: remailer.c:75
mix_redraw_ce
static void mix_redraw_ce(struct MuttWindow *win, struct Remailer **type2_list, struct Coord *coords, struct MixChain *chain, int i, bool selected)
Redraw the Remailer chain.
Definition: remailer.c:338
Envelope::reply_to
struct AddressList reply_to
Email's 'reply-to'.
Definition: envelope.h:62
mix_redraw_chain
static void mix_redraw_chain(struct MuttWindow *win, struct Remailer **type2_list, struct Coord *coords, struct MixChain *chain, int cur)
Redraw the chain on screen.
Definition: remailer.c:367
mutt_any_key_to_continue
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition: curs_lib.c:605
Envelope::cc
struct AddressList cc
Email's 'Cc' list.
Definition: envelope.h:59
mutt_menu_push_current
void mutt_menu_push_current(struct Menu *menu)
Add a new Menu to the stack.
Definition: menu.c:1015
mutt_buffer_pool_get
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
Address::group
bool group
Group mailbox?
Definition: address.h:38
REDRAW_FULL
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
Menu::pagelen
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
Remailer::shortname
char * shortname
Definition: remailer.h:53
mix_type2_list_free
static void mix_type2_list_free(struct Remailer ***ttlp)
Free a Remailer List.
Definition: remailer.c:271
Envelope::to
struct AddressList to
Email's 'To' list.
Definition: envelope.h:58
Email::env
struct Envelope * env
Envelope information.
Definition: email.h:90
Menu::tag
int(* tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:107
Menu::title
const char * title
Title of this menu.
Definition: mutt_menu.h:54
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
MuttWindow::help_data
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:135
mutt_menu_loop
int mutt_menu_loop(struct Menu *menu)
Menu event loop.
Definition: menu.c:1309
Address::mailbox
char * mailbox
Mailbox and host address.
Definition: address.h:37
mutt_menu_pop_current
void mutt_menu_pop_current(struct Menu *menu)
Remove a Menu from the stack.
Definition: menu.c:1027
C_Mixmaster
char * C_Mixmaster
Config: (mixmaster) External command to route a mixmaster message.
Definition: remailer.c:59
mix_redraw_head
static void mix_redraw_head(struct MuttWindow *win, struct MixChain *chain)
Redraw the Chain info.
Definition: remailer.c:385
Menu::mdata
void * mdata
Extra data for the current menu.
Definition: mutt_menu.h:55
MIX_CAP_MIDDLEMAN
#define MIX_CAP_MIDDLEMAN
Definition: remailer.h:43
Menu::max
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
mix_screen_coordinates
static void mix_screen_coordinates(struct MuttWindow *win, struct Remailer **type2_list, struct Coord **coordsp, struct MixChain *chain, int i)
Get the screen coordinates to place a chain.
Definition: remailer.c:289
NeoMutt
Container for Accounts, Notifications.
Definition: neomutt.h:36
Coord
Screen coordinates.
Definition: remailer.c:68
MIX_VOFFSET
#define MIX_VOFFSET
Definition: remailer.c:62
Menu::redraw
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
ListNode::data
char * data
String.
Definition: list.h:36
MENU_MIX
@ MENU_MIX
Create/edit a Mixmaster chain.
Definition: keymap.h:91
NeoMutt::sub
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
mutt_buffer_addstr
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
dialog_destroy_simple_index
void dialog_destroy_simple_index(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: dialog.c:209
Menu::current
int current
Current entry.
Definition: mutt_menu.h:56
mutt_buffer_quote_filename
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:836
mutt_fqdn
const char * mutt_fqdn(bool may_hide_host, const struct ConfigSubset *sub)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:1182
Buffer::data
char * data
Pointer to data.
Definition: buffer.h:35
Envelope::mail_followup_to
struct AddressList mail_followup_to
Email's 'mail-followup-to'.
Definition: envelope.h:63
mutt_buffer_printf
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
MixChain
A Mixmaster chain.
Definition: remailer.h:62
Menu::win_index
struct MuttWindow * win_index
Definition: mutt_menu.h:63
mutt_list_free
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
Menu
GUI selectable list of items.
Definition: mutt_menu.h:52
WT_DLG_REMAILER
@ WT_DLG_REMAILER
Remailer Dialog, dlg_select_mixmaster_chain()
Definition: mutt_window.h:88
Address
An email address.
Definition: address.h:34
mutt_menu_free
void mutt_menu_free(struct Menu **ptr)
Destroy a menu.
Definition: menu.c:972
mix_make_entry
static void mix_make_entry(struct Menu *menu, char *buf, size_t buflen, int num)
Format a menu item for the mixmaster chain list - Implements Menu::make_entry()
Definition: remailer.c:520
mutt_error
#define mutt_error(...)
Definition: logging.h:84