NeoMutt  2021-10-29-220-g2b1eec
Teaching an old dog new tricks
DOXYGEN
pgp_invoke_getkeys()

Run a command to download a PGP key. More...

+ Collaboration diagram for pgp_invoke_getkeys():

Functions

void pgp_class_invoke_getkeys (struct Address *addr)
 Implements CryptModuleSpecs::pgp_invoke_getkeys() -. More...
 

Detailed Description

Run a command to download a PGP key.

Parameters
addrAddress to search for

Function Documentation

◆ pgp_class_invoke_getkeys()

void pgp_class_invoke_getkeys ( struct Address addr)

Implements CryptModuleSpecs::pgp_invoke_getkeys() -.

Definition at line 446 of file pgpinvoke.c.

447 {
448  char tmp[1024];
449  char cmd[STR_COMMAND];
450 
451  char *personal = NULL;
452 
453  struct PgpCommandContext cctx = { 0 };
454 
455  const char *const c_pgp_get_keys_command =
456  cs_subset_string(NeoMutt->sub, "pgp_get_keys_command");
457  if (!c_pgp_get_keys_command)
458  return;
459 
460  struct Buffer *buf = mutt_buffer_pool_get();
461  personal = addr->personal;
462  addr->personal = NULL;
463 
464  *tmp = '\0';
465  mutt_addr_to_local(addr);
466  mutt_addr_write(tmp, sizeof(tmp), addr, false);
467  mutt_buffer_quote_filename(buf, tmp, true);
468 
469  addr->personal = personal;
470 
471  cctx.ids = mutt_buffer_string(buf);
472 
473  mutt_pgp_command(cmd, sizeof(cmd), &cctx, c_pgp_get_keys_command);
474 
475  int fd_null = open("/dev/null", O_RDWR);
476 
477  if (!isendwin())
478  mutt_message(_("Fetching PGP key..."));
479 
480  if (mutt_system(cmd) != 0)
481  mutt_debug(LL_DEBUG1, "Error running \"%s\"\n", cmd);
482 
483  if (!isendwin())
485 
486  if (fd_null >= 0)
487  close(fd_null);
488 
490 }
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
Definition: address.c:1351
size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display)
Write a single Address to a buffer.
Definition: address.c:1025
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
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:866
#define mutt_message(...)
Definition: logging.h:86
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
#define _(a)
Definition: message.h:28
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
static void mutt_pgp_command(char *buf, size_t buflen, struct PgpCommandContext *cctx, const char *fmt)
Prepare a PGP Command.
Definition: pgpinvoke.c:173
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 STR_COMMAND
Enough space for a long command line.
Definition: string2.h:35
char * personal
Real name of address.
Definition: address.h:37
String manipulation buffer.
Definition: buffer.h:34
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
Data for a PGP command.
Definition: pgpinvoke.c:59
const char * ids
r
Definition: pgpinvoke.c:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function: