NeoMutt  2023-05-17-16-g61469c
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 445 of file pgpinvoke.c.

446{
447 char cmd[STR_COMMAND] = { 0 };
448
449 char *personal = NULL;
450
451 struct PgpCommandContext cctx = { 0 };
452
453 const char *const c_pgp_get_keys_command = cs_subset_string(NeoMutt->sub, "pgp_get_keys_command");
454 if (!c_pgp_get_keys_command)
455 return;
456
457 struct Buffer *buf = buf_pool_get();
458 personal = addr->personal;
459 addr->personal = NULL;
460
461 struct Buffer *tmp = buf_pool_get();
462 mutt_addr_to_local(addr);
463 mutt_addr_write(tmp, addr, false);
464 buf_quote_filename(buf, buf_string(tmp), true);
465 buf_pool_release(&tmp);
466
467 addr->personal = personal;
468
469 cctx.ids = buf_string(buf);
470
471 mutt_pgp_command(cmd, sizeof(cmd), &cctx, c_pgp_get_keys_command);
472
473 int fd_null = open("/dev/null", O_RDWR);
474
475 if (!isendwin())
476 mutt_message(_("Fetching PGP key..."));
477
478 if (mutt_system(cmd) != 0)
479 mutt_debug(LL_DEBUG1, "Error running \"%s\"\n", cmd);
480
481 if (!isendwin())
483
484 if (fd_null >= 0)
485 close(fd_null);
486
487 buf_pool_release(&buf);
488}
size_t mutt_addr_write(struct Buffer *buf, struct Address *addr, bool display)
Write a single Address to a buffer.
Definition: address.c:1039
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
Definition: address.c:1331
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:78
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
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:911
#define mutt_message(...)
Definition: logging2.h:86
#define mutt_debug(LEVEL,...)
Definition: logging2.h:84
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.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:73
static void mutt_pgp_command(char *buf, size_t buflen, struct PgpCommandContext *cctx, const char *fmt)
Prepare a PGP Command.
Definition: pgpinvoke.c:186
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:106
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:119
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:52
#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:60
const char * ids
r
Definition: pgpinvoke.c:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function: