NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
dlgpgp.c
Go to the documentation of this file.
1 
70 #include "config.h"
71 #include <ctype.h>
72 #include <locale.h>
73 #include <stdbool.h>
74 #include <stdio.h>
75 #include <stdlib.h>
76 #include <unistd.h>
77 #include "private.h"
78 #include "mutt/lib.h"
79 #include "address/lib.h"
80 #include "config/lib.h"
81 #include "core/lib.h"
82 #include "gui/lib.h"
83 #include "lib.h"
84 #include "menu/lib.h"
85 #include "pager/lib.h"
86 #include "question/lib.h"
87 #include "format_flags.h"
88 #include "mutt_logging.h"
89 #include "muttlib.h"
90 #include "opcodes.h"
91 #include "options.h"
92 #include "pgp.h"
93 #include "pgpinvoke.h"
94 #include "pgpkey.h"
95 #include "pgplib.h"
96 
98 static const struct Mapping PgpHelp[] = {
99  // clang-format off
100  { N_("Exit"), OP_EXIT },
101  { N_("Select"), OP_GENERIC_SELECT_ENTRY },
102  { N_("Check key"), OP_VERIFY_KEY },
103  { N_("Help"), OP_HELP },
104  { NULL, 0 },
105  // clang-format on
106 };
107 
111 struct PgpEntry
112 {
113  size_t num;
114  struct PgpUid *uid;
115 };
116 
117 static const char trust_flags[] = "?- +";
118 
127 static int pgp_compare_key_address(const void *a, const void *b)
128 {
129  struct PgpUid const *const *s = (struct PgpUid const *const *) a;
130  struct PgpUid const *const *t = (struct PgpUid const *const *) b;
131 
132  int r = mutt_istr_cmp((*s)->addr, (*t)->addr);
133  if (r != 0)
134  return (r > 0);
135 
136  return mutt_istr_cmp(pgp_fpr_or_lkeyid((*s)->parent), pgp_fpr_or_lkeyid((*t)->parent)) > 0;
137 }
138 
147 static int pgp_compare_address_qsort(const void *a, const void *b)
148 {
149  const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
150  return (c_pgp_sort_keys & SORT_REVERSE) ? !pgp_compare_key_address(a, b) :
152 }
153 
162 static int pgp_compare_key_date(const void *a, const void *b)
163 {
164  struct PgpUid const *const *s = (struct PgpUid const *const *) a;
165  struct PgpUid const *const *t = (struct PgpUid const *const *) b;
166 
167  int r = ((*s)->parent->gen_time - (*t)->parent->gen_time);
168  if (r != 0)
169  return r > 0;
170  return mutt_istr_cmp((*s)->addr, (*t)->addr) > 0;
171 }
172 
181 static int pgp_compare_date_qsort(const void *a, const void *b)
182 {
183  const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
184  return (c_pgp_sort_keys & SORT_REVERSE) ? !pgp_compare_key_date(a, b) :
185  pgp_compare_key_date(a, b);
186 }
187 
196 static int pgp_compare_keyid(const void *a, const void *b)
197 {
198  struct PgpUid const *const *s = (struct PgpUid const *const *) a;
199  struct PgpUid const *const *t = (struct PgpUid const *const *) b;
200 
201  int r = mutt_istr_cmp(pgp_fpr_or_lkeyid((*s)->parent), pgp_fpr_or_lkeyid((*t)->parent));
202  if (r != 0)
203  return (r > 0);
204  return mutt_istr_cmp((*s)->addr, (*t)->addr) > 0;
205 }
206 
215 static int pgp_compare_keyid_qsort(const void *a, const void *b)
216 {
217  const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
218  return (c_pgp_sort_keys & SORT_REVERSE) ? !pgp_compare_keyid(a, b) :
219  pgp_compare_keyid(a, b);
220 }
221 
233 static int pgp_compare_key_trust(const void *a, const void *b)
234 {
235  struct PgpUid const *const *s = (struct PgpUid const *const *) a;
236  struct PgpUid const *const *t = (struct PgpUid const *const *) b;
237 
238  int r = (((*s)->parent->flags & KEYFLAG_RESTRICTIONS) -
239  ((*t)->parent->flags & KEYFLAG_RESTRICTIONS));
240  if (r != 0)
241  return r > 0;
242  r = ((*s)->trust - (*t)->trust);
243  if (r != 0)
244  return r < 0;
245  r = ((*s)->parent->keylen - (*t)->parent->keylen);
246  if (r != 0)
247  return r < 0;
248  r = ((*s)->parent->gen_time - (*t)->parent->gen_time);
249  if (r != 0)
250  return r < 0;
251  r = mutt_istr_cmp((*s)->addr, (*t)->addr);
252  if (r != 0)
253  return r > 0;
254  return mutt_istr_cmp(pgp_fpr_or_lkeyid((*s)->parent), pgp_fpr_or_lkeyid((*t)->parent)) > 0;
255 }
256 
265 static int pgp_compare_trust_qsort(const void *a, const void *b)
266 {
267  const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
268  return (c_pgp_sort_keys & SORT_REVERSE) ? !pgp_compare_key_trust(a, b) :
269  pgp_compare_key_trust(a, b);
270 }
271 
280 {
281  static char buf[3];
282 
283  if (!(flags & KEYFLAG_CANENCRYPT))
284  buf[0] = '-';
285  else if (flags & KEYFLAG_PREFER_SIGNING)
286  buf[0] = '.';
287  else
288  buf[0] = 'e';
289 
290  if (!(flags & KEYFLAG_CANSIGN))
291  buf[1] = '-';
292  else if (flags & KEYFLAG_PREFER_ENCRYPTION)
293  buf[1] = '.';
294  else
295  buf[1] = 's';
296 
297  buf[2] = '\0';
298 
299  return buf;
300 }
301 
308 {
309  if (flags & KEYFLAG_REVOKED)
310  return 'R';
311  if (flags & KEYFLAG_EXPIRED)
312  return 'X';
313  if (flags & KEYFLAG_DISABLED)
314  return 'd';
315  if (flags & KEYFLAG_CRITICAL)
316  return 'c';
317 
318  return ' ';
319 }
320 
343 static const char *pgp_entry_format_str(char *buf, size_t buflen, size_t col, int cols,
344  char op, const char *src, const char *prec,
345  const char *if_str, const char *else_str,
346  intptr_t data, MuttFormatFlags flags)
347 {
348  char fmt[128];
349  bool optional = (flags & MUTT_FORMAT_OPTIONAL);
350 
351  struct PgpEntry *entry = (struct PgpEntry *) data;
352  struct PgpUid *uid = entry->uid;
353  struct PgpKeyInfo *key = uid->parent;
354  struct PgpKeyInfo *pkey = pgp_principal_key(key);
355 
356  if (isupper((unsigned char) op))
357  key = pkey;
358 
359  KeyFlags kflags = key->flags | (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags;
360 
361  switch (tolower(op))
362  {
363  case 'a':
364  if (!optional)
365  {
366  snprintf(fmt, sizeof(fmt), "%%%ss", prec);
367  snprintf(buf, buflen, fmt, key->algorithm);
368  }
369  break;
370  case 'c':
371  if (!optional)
372  {
373  snprintf(fmt, sizeof(fmt), "%%%ss", prec);
374  snprintf(buf, buflen, fmt, pgp_key_abilities(kflags));
375  }
376  else if (!(kflags & KEYFLAG_ABILITIES))
377  optional = false;
378  break;
379  case 'f':
380  if (!optional)
381  {
382  snprintf(fmt, sizeof(fmt), "%%%sc", prec);
383  snprintf(buf, buflen, fmt, pgp_flags(kflags));
384  }
385  else if (!(kflags & KEYFLAG_RESTRICTIONS))
386  optional = false;
387  break;
388  case 'k':
389  if (!optional)
390  {
391  snprintf(fmt, sizeof(fmt), "%%%ss", prec);
392  snprintf(buf, buflen, fmt, pgp_this_keyid(key));
393  }
394  break;
395  case 'l':
396  if (!optional)
397  {
398  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
399  snprintf(buf, buflen, fmt, key->keylen);
400  }
401  break;
402  case 'n':
403  if (!optional)
404  {
405  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
406  snprintf(buf, buflen, fmt, entry->num);
407  }
408  break;
409  case 't':
410  if (!optional)
411  {
412  snprintf(fmt, sizeof(fmt), "%%%sc", prec);
413  snprintf(buf, buflen, fmt, trust_flags[uid->trust & 0x03]);
414  }
415  else if (!(uid->trust & 0x03))
416  {
417  /* undefined trust */
418  optional = false;
419  }
420  break;
421  case 'u':
422  if (!optional)
423  {
424  snprintf(fmt, sizeof(fmt), "%%%ss", prec);
425  snprintf(buf, buflen, fmt, NONULL(uid->addr));
426  }
427  break;
428  case '[':
429 
430  {
431  char buf2[128];
432  bool do_locales = true;
433  size_t len;
434 
435  char *p = buf;
436 
437  const char *cp = src;
438  if (*cp == '!')
439  {
440  do_locales = false;
441  cp++;
442  }
443 
444  len = buflen - 1;
445  while ((len > 0) && (*cp != ']'))
446  {
447  if (*cp == '%')
448  {
449  cp++;
450  if (len >= 2)
451  {
452  *p++ = '%';
453  *p++ = *cp;
454  len -= 2;
455  }
456  else
457  break; /* not enough space */
458  cp++;
459  }
460  else
461  {
462  *p++ = *cp++;
463  len--;
464  }
465  }
466  *p = '\0';
467 
468  if (!do_locales)
469  setlocale(LC_TIME, "C");
470  mutt_date_localtime_format(buf2, sizeof(buf2), buf, key->gen_time);
471  if (!do_locales)
472  setlocale(LC_TIME, "");
473 
474  snprintf(fmt, sizeof(fmt), "%%%ss", prec);
475  snprintf(buf, buflen, fmt, buf2);
476  if (len > 0)
477  src = cp + 1;
478  break;
479  }
480  default:
481  *buf = '\0';
482  }
483 
484  if (optional)
485  {
486  mutt_expando_format(buf, buflen, col, cols, if_str, pgp_entry_format_str,
487  data, MUTT_FORMAT_NO_FLAGS);
488  }
489  else if (flags & MUTT_FORMAT_OPTIONAL)
490  {
491  mutt_expando_format(buf, buflen, col, cols, else_str, pgp_entry_format_str,
492  data, MUTT_FORMAT_NO_FLAGS);
493  }
494 
495  /* We return the format string, unchanged */
496  return src;
497 }
498 
502 static void pgp_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
503 {
504  struct PgpUid **key_table = menu->mdata;
505  struct PgpEntry entry;
506 
507  entry.uid = key_table[line];
508  entry.num = line + 1;
509 
510  const char *const c_pgp_entry_format =
511  cs_subset_string(NeoMutt->sub, "pgp_entry_format");
512  mutt_expando_format(buf, buflen, 0, menu->win->state.cols,
513  NONULL(c_pgp_entry_format), pgp_entry_format_str,
514  (intptr_t) &entry, MUTT_FORMAT_ARROWCURSOR);
515 }
516 
522 static void pgp_key_table_free(struct Menu *menu, void **ptr)
523 {
524  FREE(ptr);
525 }
526 
531 {
532  if ((nc->event_type != NT_CONFIG) || !nc->global_data || !nc->event_data)
533  return -1;
534 
535  struct EventConfig *ev_c = nc->event_data;
536 
537  if (!mutt_str_equal(ev_c->name, "pgp_entry_format") &&
538  !mutt_str_equal(ev_c->name, "pgp_sort_keys"))
539  {
540  return 0;
541  }
542 
543  struct Menu *menu = nc->global_data;
545  mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
546 
547  return 0;
548 }
549 
558 {
559  if ((nc->event_type != NT_WINDOW) || !nc->global_data || !nc->event_data)
560  return -1;
561 
562  if (nc->event_subtype != NT_WINDOW_DELETE)
563  return 0;
564 
565  struct MuttWindow *win_menu = nc->global_data;
566  struct EventWindow *ev_w = nc->event_data;
567  if (ev_w->win != win_menu)
568  return 0;
569 
570  struct Menu *menu = win_menu->wdata;
571 
574 
575  mutt_debug(LL_DEBUG5, "window delete done\n");
576  return 0;
577 }
578 
587  struct Address *p, const char *s)
588 {
589  struct PgpUid **key_table = NULL;
590  struct Menu *menu = NULL;
591  int i;
592  bool done = false;
593  char buf[1024], tmpbuf[256];
594  struct PgpKeyInfo *kp = NULL;
595  struct PgpUid *a = NULL;
596  struct Buffer *tempfile = NULL;
597 
598  bool unusable = false;
599 
600  int keymax = 0;
601 
602  const bool c_pgp_show_unusable =
603  cs_subset_bool(NeoMutt->sub, "pgp_show_unusable");
604  for (i = 0, kp = keys; kp; kp = kp->next)
605  {
606  if (!c_pgp_show_unusable && (kp->flags & KEYFLAG_CANTUSE))
607  {
608  unusable = true;
609  continue;
610  }
611 
612  for (a = kp->address; a; a = a->next)
613  {
614  if (!c_pgp_show_unusable && (a->flags & KEYFLAG_CANTUSE))
615  {
616  unusable = true;
617  continue;
618  }
619 
620  if (i == keymax)
621  {
622  keymax += 5;
623  mutt_mem_realloc(&key_table, sizeof(struct PgpUid *) * keymax);
624  }
625 
626  key_table[i++] = a;
627  }
628  }
629 
630  if ((i == 0) && unusable)
631  {
632  mutt_error(_("All matching keys are expired, revoked, or disabled"));
633  return NULL;
634  }
635 
636  int (*f)(const void *, const void *);
637  const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_sort_keys");
638  switch (c_pgp_sort_keys & SORT_MASK)
639  {
640  case SORT_ADDRESS:
642  break;
643  case SORT_DATE:
645  break;
646  case SORT_KEYID:
648  break;
649  case SORT_TRUST:
650  default:
652  break;
653  }
654  qsort(key_table, i, sizeof(struct PgpUid *), f);
655 
656  struct MuttWindow *dlg = simple_dialog_new(MENU_PGP, WT_DLG_PGP, PgpHelp);
657 
658  menu = dlg->wdata;
659  menu->max = i;
660  menu->make_entry = pgp_make_entry;
661  menu->mdata = key_table;
663 
664  struct MuttWindow *win_menu = menu->win;
665 
666  // NT_COLOR is handled by the SimpleDialog
669 
670  if (p)
671  snprintf(buf, sizeof(buf), _("PGP keys matching <%s>"), p->mailbox);
672  else
673  snprintf(buf, sizeof(buf), _("PGP keys matching \"%s\""), s);
674 
675  struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
676  sbar_set_title(sbar, buf);
677 
678  kp = NULL;
679 
681 
682  while (!done)
683  {
684  switch (menu_loop(menu))
685  {
686  case OP_VERIFY_KEY:
687  {
688  FILE *fp_null = fopen("/dev/null", "w");
689  if (!fp_null)
690  {
691  mutt_perror(_("Can't open /dev/null"));
692  break;
693  }
694  tempfile = mutt_buffer_pool_get();
695  mutt_buffer_mktemp(tempfile);
696  FILE *fp_tmp = mutt_file_fopen(mutt_buffer_string(tempfile), "w");
697  if (!fp_tmp)
698  {
699  mutt_perror(_("Can't create temporary file"));
700  mutt_file_fclose(&fp_null);
701  mutt_buffer_pool_release(&tempfile);
702  break;
703  }
704 
705  mutt_message(_("Invoking PGP..."));
706 
707  const int index = menu_get_index(menu);
708  struct PgpUid *cur_key = key_table[index];
709  snprintf(tmpbuf, sizeof(tmpbuf), "0x%s",
711 
712  pid_t pid = pgp_invoke_verify_key(NULL, NULL, NULL, -1, fileno(fp_tmp),
713  fileno(fp_null), tmpbuf);
714  if (pid == -1)
715  {
716  mutt_perror(_("Can't create filter"));
717  unlink(mutt_buffer_string(tempfile));
718  mutt_file_fclose(&fp_tmp);
719  mutt_file_fclose(&fp_null);
720  }
721 
722  filter_wait(pid);
723  mutt_file_fclose(&fp_tmp);
724  mutt_file_fclose(&fp_null);
726  char title[1024];
727  snprintf(title, sizeof(title), _("Key ID: 0x%s"),
728  pgp_keyid(pgp_principal_key(cur_key->parent)));
729 
730  struct PagerData pdata = { 0 };
731  struct PagerView pview = { &pdata };
732 
733  pdata.fname = mutt_buffer_string(tempfile);
734 
735  pview.banner = title;
736  pview.flags = MUTT_PAGER_NO_FLAGS;
737  pview.mode = PAGER_MODE_OTHER;
738 
739  mutt_do_pager(&pview, NULL);
740  mutt_buffer_pool_release(&tempfile);
742  break;
743  }
744 
745  case OP_VIEW_ID:
746  {
747  const int index = menu_get_index(menu);
748  struct PgpUid *cur_key = key_table[index];
749  mutt_message("%s", NONULL(cur_key->addr));
750  break;
751  }
752 
753  case OP_GENERIC_SELECT_ENTRY:
754  {
755  /* XXX make error reporting more verbose */
756 
757  const int index = menu_get_index(menu);
758  struct PgpUid *cur_key = key_table[index];
759  if (OptPgpCheckTrust)
760  {
761  if (!pgp_key_is_valid(cur_key->parent))
762  {
763  mutt_error(_("This key can't be used: expired/disabled/revoked"));
764  break;
765  }
766  }
767 
768  if (OptPgpCheckTrust && (!pgp_id_is_valid(cur_key) || !pgp_id_is_strong(cur_key)))
769  {
770  const char *str = "";
771  char buf2[1024];
772 
773  if (cur_key->flags & KEYFLAG_CANTUSE)
774  {
775  str = _("ID is expired/disabled/revoked. Do you really want to use "
776  "the key?");
777  }
778  else
779  {
780  switch (cur_key->trust & 0x03)
781  {
782  case 0:
783  str = _("ID has undefined validity. Do you really want to use "
784  "the key?");
785  break;
786  case 1:
787  str = _("ID is not valid. Do you really want to use the key?");
788  break;
789  case 2:
790  str = _("ID is only marginally valid. Do you really want to "
791  "use the key?");
792  break;
793  }
794  }
795 
796  snprintf(buf2, sizeof(buf2), "%s", str);
797 
798  if (mutt_yesorno(buf2, MUTT_NO) != MUTT_YES)
799  {
801  break;
802  }
803  }
804 
805  kp = cur_key->parent;
806  done = true;
807  break;
808  }
809 
810  case OP_EXIT:
811 
812  kp = NULL;
813  done = true;
814  break;
815  }
816  }
817 
818  simple_dialog_free(&dlg);
819  return kp;
820 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
Convenience wrapper for the gui headers.
#define KEYFLAG_PREFER_ENCRYPTION
Key&#39;s owner prefers encryption.
Definition: lib.h:133
struct PgpKeyInfo * next
Definition: pgplib.h:57
int mutt_istr_cmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:580
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:550
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:74
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string -.
Definition: muttlib.c:780
uint8_t MuttFormatFlags
Flags for mutt_expando_format(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: format_flags.h:29
#define NONULL(x)
Definition: string2.h:37
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:691
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:165
Definition: lib.h:67
Data passed to a notification function.
Definition: observer.h:39
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
static char * pgp_key_abilities(KeyFlags flags)
Turn PGP key abilities into a string.
Definition: dlgpgp.c:279
PGP key management routines.
struct PgpUid * next
Definition: pgplib.h:40
PGP encryption menu.
Definition: type.h:55
An Event that happened to a Window.
Definition: mutt_window.h:215
#define mutt_error(...)
Definition: logging.h:88
size_t num
Definition: dlgpgp.c:113
static const char trust_flags[]
Definition: dlgpgp.c:117
char * pgp_keyid(struct PgpKeyInfo *k)
Get the ID of the main (parent) key.
Definition: pgp.c:197
static char pgp_flags(KeyFlags flags)
Turn PGP key flags into a string.
Definition: dlgpgp.c:307
NeoMutt Logging.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
Pgp Dialog, dlg_select_pgp_key()
Definition: mutt_window.h:88
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: format_flags.h:35
A config-change event.
Definition: subset.h:69
String manipulation buffer.
Definition: buffer.h:33
static int pgp_compare_address_qsort(const void *a, const void *b)
Compare the addresses of two PGP keys.
Definition: dlgpgp.c:147
Paged view into some data.
Definition: lib.h:154
#define _(a)
Definition: message.h:28
Sort by email address.
Definition: sort2.h:54
Window is about to be deleted.
Definition: mutt_window.h:206
An email address.
Definition: address.h:35
PGP User ID.
Definition: pgplib.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:38
KeyFlags flags
Definition: pgplib.h:51
bool pgp_key_is_valid(struct PgpKeyInfo *k)
Is a PGP key valid?
Definition: pgpkey.c:101
#define KEYFLAG_ABILITIES
Definition: lib.h:139
static int pgp_compare_date_qsort(const void *a, const void *b)
Compare the dates of two PGP keys.
Definition: dlgpgp.c:181
Wrapper around calls to external PGP program.
Shared constants/structs that are private to libconn.
Flags to control mutt_expando_format()
All user-callable functions.
#define mutt_perror(...)
Definition: logging.h:89
Container for Accounts, Notifications.
Definition: neomutt.h:36
static int pgp_key_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t.
Definition: dlgpgp.c:557
struct PgpKeyInfo * pgp_principal_key(struct PgpKeyInfo *key)
Get the main (parent) PGP key.
Definition: pgpkey.c:89
#define KEYFLAG_CANENCRYPT
Key is suitable for encryption.
Definition: lib.h:125
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
#define KEYFLAG_PREFER_SIGNING
Key&#39;s owner prefers signing.
Definition: lib.h:134
Convenience wrapper for the config headers.
char * addr
Definition: pgplib.h:36
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:105
Email Address Handling.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:43
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
Some miscellaneous functions.
Information about a PGP key.
Definition: pgplib.h:46
Data to be displayed by PagerView.
Definition: lib.h:143
static int pgp_compare_keyid(const void *a, const void *b)
Compare Key IDs and addresses for sorting.
Definition: dlgpgp.c:196
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
static void pgp_key_table_free(struct Menu *menu, void **ptr)
Free the key table - Implements Menu::mdata_free() -.
Definition: dlgpgp.c:522
short trust
Definition: pgplib.h:37
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
Convenience wrapper for the core headers.
An entry in a PGP key menu.
Definition: dlgpgp.c:111
short keylen
Definition: pgplib.h:52
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:112
static int pgp_compare_trust_qsort(const void *a, const void *b)
Compare the trust levels of two PGP keys.
Definition: dlgpgp.c:265
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:189
#define KEYFLAG_EXPIRED
Key is expired.
Definition: lib.h:128
void * global_data
Data from notify_observer_add()
Definition: observer.h:45
#define KEYFLAG_CANTUSE
Definition: lib.h:136
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
enum PagerMode mode
Pager mode.
Definition: lib.h:157
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:292
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
struct PgpKeyInfo * dlg_select_pgp_key(struct PgpKeyInfo *keys, struct Address *p, const char *s)
Let the user select a key to use.
Definition: dlgpgp.c:586
Sort by encryption key&#39;s trust level.
Definition: sort2.h:56
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
void * mdata
Private data.
Definition: lib.h:155
uint16_t KeyFlags
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.
Definition: lib.h:122
int mutt_do_pager(struct PagerView *pview, struct Email *e)
Display some page-able text to the user (help or attachment)
Definition: do_pager.c:120
struct PgpUid * address
Definition: pgplib.h:50
pid_t pgp_invoke_verify_key(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int fd_pgp_in, int fd_pgp_out, int fd_pgp_err, const char *uids)
Use PGP to verify a key.
Definition: pgpinvoke.c:531
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
Ask the user a question.
#define KEYFLAG_DISABLED
Key is marked disabled.
Definition: lib.h:130
WHERE bool OptPgpCheckTrust
(pseudo) used by dlg_select_pgp_key()
Definition: options.h:48
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:221
struct PgpKeyInfo * parent
Definition: pgplib.h:39
PagerFlags flags
Additional settings to tweak pager&#39;s function.
Definition: lib.h:158
static int pgp_compare_key_trust(const void *a, const void *b)
Compare the trust of keys for sorting.
Definition: dlgpgp.c:233
#define KEYFLAG_CANSIGN
Key is suitable for signing.
Definition: lib.h:124
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
struct PgpUid * uid
Definition: dlgpgp.c:114
#define KEYFLAG_RESTRICTIONS
Definition: lib.h:137
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: question.c:180
PGP sign, encrypt, check routines.
int max
Number of entries in the menu.
Definition: lib.h:71
void * event_data
Data from notify_send()
Definition: observer.h:44
char * pgp_fpr_or_lkeyid(struct PgpKeyInfo *k)
Get the fingerprint or long keyid.
Definition: pgp.c:227
static const char * pgp_entry_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Format an entry on the PGP key selection menu - Implements format_t -Expando Description %n Number %...
Definition: dlgpgp.c:343
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:170
const char * algorithm
Definition: pgplib.h:55
#define KEYFLAG_CRITICAL
Key is marked critical.
Definition: lib.h:132
bool pgp_id_is_valid(struct PgpUid *uid)
Is a PGP key valid.
Definition: pgpkey.c:130
Misc PGP helper routines.
static int pgp_key_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: dlgpgp.c:530
#define mutt_message(...)
Definition: logging.h:87
#define FREE(x)
Definition: memory.h:40
static int pgp_compare_keyid_qsort(const void *a, const void *b)
Compare key IDs.
Definition: dlgpgp.c:215
Mapping between user-readable string and a constant.
Definition: mapping.h:31
static void pgp_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the pgp key list - Implements Menu::make_entry() -.
Definition: dlgpgp.c:502
char * pgp_this_keyid(struct PgpKeyInfo *k)
Get the ID of this key.
Definition: pgp.c:184
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
bool pgp_id_is_strong(struct PgpUid *uid)
Is a PGP key strong?
Definition: pgpkey.c:117
#define MUTT_FORMAT_OPTIONAL
Allow optional field processing.
Definition: format_flags.h:33
Sort by the encryption key&#39;s ID.
Definition: sort2.h:55
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:228
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:128
static int pgp_compare_key_address(const void *a, const void *b)
Compare Key addresses and IDs for sorting.
Definition: dlgpgp.c:127
Handling of global boolean variables.
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
const char * fname
Name of the file to read.
Definition: lib.h:148
static int pgp_compare_key_date(const void *a, const void *b)
Compare Key dates for sorting.
Definition: dlgpgp.c:162
Sort by the date the email was sent.
Definition: sort2.h:43
Log at debug level 5.
Definition: logging.h:44
Convenience wrapper for the library headers.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:589
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:79
#define MUTT_PAGER_NO_FLAGS
No flags are set.
Definition: lib.h:54
const char * banner
Title to display in status bar.
Definition: lib.h:159
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
GUI display a file/email/help in a viewport with paging.
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:135
void * wdata
Private data.
Definition: mutt_window.h:145
#define N_(a)
Definition: message.h:32
const char * name
Name of config item that changed.
Definition: subset.h:72
#define KEYFLAG_REVOKED
Key is revoked.
Definition: lib.h:129
#define SORT_MASK
Mask for the sort id.
Definition: sort2.h:78
int flags
Definition: pgplib.h:38
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
time_t gen_time
Definition: pgplib.h:53