NeoMutt  2021-10-29-43-g6b8931
Teaching an old dog new tricks
DOXYGEN
pgpinvoke.c File Reference

Wrapper around calls to external PGP program. More...

#include "config.h"
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "pgpinvoke.h"
#include "lib.h"
#include "format_flags.h"
#include "mutt_logging.h"
#include "muttlib.h"
#include "pgpkey.h"
#include "protos.h"
#include "pgp.h"
+ Include dependency graph for pgpinvoke.c:

Go to the source code of this file.

Data Structures

struct  PgpCommandContext
 Data for a PGP command. More...
 

Functions

static const char * pgp_command_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 a PGP command string - Implements format_t -. More...
 
static void mutt_pgp_command (char *buf, size_t buflen, struct PgpCommandContext *cctx, const char *fmt)
 Prepare a PGP Command. More...
 
static pid_t pgp_invoke (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int fd_pgp_in, int fd_pgp_out, int fd_pgp_err, bool need_passphrase, const char *fname, const char *sig_fname, const char *ids, const char *format)
 Run a PGP command. More...
 
pid_t pgp_invoke_decode (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 *fname, bool need_passphrase)
 Use PGP to decode a message. More...
 
pid_t pgp_invoke_verify (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 *fname, const char *sig_fname)
 Use PGP to verify a message. More...
 
pid_t pgp_invoke_decrypt (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 *fname)
 Use PGP to decrypt a file. More...
 
pid_t pgp_invoke_sign (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 *fname)
 Use PGP to sign a file. More...
 
pid_t pgp_invoke_encrypt (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 *fname, const char *uids, bool sign)
 Use PGP to encrypt a file. More...
 
pid_t pgp_invoke_traditional (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 *fname, const char *uids, SecurityFlags flags)
 Use PGP to create in inline-signed message. More...
 
void pgp_class_invoke_import (const char *fname)
 Implements CryptModuleSpecs::pgp_invoke_import() -. More...
 
void pgp_class_invoke_getkeys (struct Address *addr)
 Implements CryptModuleSpecs::pgp_invoke_getkeys() -. More...
 
pid_t pgp_invoke_export (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 export a key from the user's keyring. More...
 
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. More...
 
pid_t pgp_invoke_list_keys (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int fd_pgp_in, int fd_pgp_out, int fd_pgp_err, enum PgpRing keyring, struct ListHead *hints)
 Find matching PGP Keys. More...
 

Detailed Description

Wrapper around calls to external PGP program.

Authors
  • Thomas Roessler
  • Pietro Cerutti

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 pgpinvoke.c.

Function Documentation

◆ mutt_pgp_command()

static void mutt_pgp_command ( char *  buf,
size_t  buflen,
struct PgpCommandContext cctx,
const char *  fmt 
)
static

Prepare a PGP Command.

Parameters
bufBuffer for the result
buflenLength of buffer
cctxData to pass to the formatter
fmtprintf-like formatting string

Definition at line 173 of file pgpinvoke.c.

175 {
176  mutt_expando_format(buf, buflen, 0, buflen, NONULL(fmt), pgp_command_format_str,
177  (intptr_t) cctx, MUTT_FORMAT_NO_FLAGS);
178  mutt_debug(LL_DEBUG2, "%s\n", buf);
179 }
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
static const char * pgp_command_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 a PGP command string - Implements format_t -.
Definition: pgpinvoke.c:78
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
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
#define NONULL(x)
Definition: string2.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke()

static pid_t pgp_invoke ( FILE **  fp_pgp_in,
FILE **  fp_pgp_out,
FILE **  fp_pgp_err,
int  fd_pgp_in,
int  fd_pgp_out,
int  fd_pgp_err,
bool  need_passphrase,
const char *  fname,
const char *  sig_fname,
const char *  ids,
const char *  format 
)
static

Run a PGP command.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]need_passphraseIs a passphrase needed?
[in]fnameFilename to pass to the command
[in]sig_fnameSignature filename to pass to the command
[in]idsList of IDs/fingerprints, space separated
[in]formatprintf-like format string
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 200 of file pgpinvoke.c.

204 {
205  struct PgpCommandContext cctx = { 0 };
206  char cmd[STR_COMMAND];
207 
208  if (!format || (*format == '\0'))
209  return (pid_t) -1;
210 
212  cctx.fname = fname;
213  cctx.sig_fname = sig_fname;
214  const char *const c_pgp_sign_as =
215  cs_subset_string(NeoMutt->sub, "pgp_sign_as");
216  const char *const c_pgp_default_key =
217  cs_subset_string(NeoMutt->sub, "pgp_default_key");
218  if (c_pgp_sign_as)
219  cctx.signas = c_pgp_sign_as;
220  else
221  cctx.signas = c_pgp_default_key;
222  cctx.ids = ids;
223 
224  mutt_pgp_command(cmd, sizeof(cmd), &cctx, format);
225 
226  return filter_create_fd(cmd, fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in,
227  fd_pgp_out, fd_pgp_err);
228 }
pid_t filter_create_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr)
Run a command on a pipe (optionally connect stdin/stdout)
Definition: filter.c:61
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
static void mutt_pgp_command(char *buf, size_t buflen, struct PgpCommandContext *cctx, const char *fmt)
Prepare a PGP Command.
Definition: pgpinvoke.c:173
#define STR_COMMAND
Enough space for a long command line.
Definition: string2.h:35
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
bool need_passphrase
p
Definition: pgpinvoke.c:60
const char * signas
a
Definition: pgpinvoke.c:63
const char * fname
f
Definition: pgpinvoke.c:61
const char * ids
r
Definition: pgpinvoke.c:64
const char * sig_fname
s
Definition: pgpinvoke.c:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_decode()

pid_t pgp_invoke_decode ( 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 *  fname,
bool  need_passphrase 
)

Use PGP to decode a message.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]fnameFilename to pass to the command
[in]need_passphraseIs a passphrase needed?
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 252 of file pgpinvoke.c.

255 {
256  const char *const c_pgp_decode_command =
257  cs_subset_string(NeoMutt->sub, "pgp_decode_command");
258  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out, fd_pgp_err,
259  need_passphrase, fname, NULL, NULL, c_pgp_decode_command);
260 }
static pid_t pgp_invoke(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int fd_pgp_in, int fd_pgp_out, int fd_pgp_err, bool need_passphrase, const char *fname, const char *sig_fname, const char *ids, const char *format)
Run a PGP command.
Definition: pgpinvoke.c:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_verify()

pid_t pgp_invoke_verify ( 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 *  fname,
const char *  sig_fname 
)

Use PGP to verify a message.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]fnameFilename to pass to the command
[in]sig_fnameSignature filename to pass to the command
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 278 of file pgpinvoke.c.

281 {
282  const char *const c_pgp_verify_command =
283  cs_subset_string(NeoMutt->sub, "pgp_verify_command");
284  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
285  fd_pgp_err, false, fname, sig_fname, NULL, c_pgp_verify_command);
286 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_decrypt()

pid_t pgp_invoke_decrypt ( 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 *  fname 
)

Use PGP to decrypt a file.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]fnameFilename to pass to the command
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 303 of file pgpinvoke.c.

305 {
306  const char *const c_pgp_decrypt_command =
307  cs_subset_string(NeoMutt->sub, "pgp_decrypt_command");
308  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
309  fd_pgp_err, true, fname, NULL, NULL, c_pgp_decrypt_command);
310 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_sign()

pid_t pgp_invoke_sign ( 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 *  fname 
)

Use PGP to sign a file.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]fnameFilename to pass to the command
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 327 of file pgpinvoke.c.

329 {
330  const char *const c_pgp_sign_command =
331  cs_subset_string(NeoMutt->sub, "pgp_sign_command");
332  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
333  fd_pgp_err, true, fname, NULL, NULL, c_pgp_sign_command);
334 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_encrypt()

pid_t pgp_invoke_encrypt ( 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 *  fname,
const char *  uids,
bool  sign 
)

Use PGP to encrypt a file.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]fnameFilename to pass to the command
[in]uidsList of IDs/fingerprints, space separated
[in]signIf true, also sign the file
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 353 of file pgpinvoke.c.

356 {
357  if (sign)
358  {
359  const char *const c_pgp_encrypt_sign_command =
360  cs_subset_string(NeoMutt->sub, "pgp_encrypt_sign_command");
361  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
362  fd_pgp_err, true, fname, NULL, uids, c_pgp_encrypt_sign_command);
363  }
364  else
365  {
366  const char *const c_pgp_encrypt_only_command =
367  cs_subset_string(NeoMutt->sub, "pgp_encrypt_only_command");
368  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
369  fd_pgp_err, false, fname, NULL, uids, c_pgp_encrypt_only_command);
370  }
371 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_traditional()

pid_t pgp_invoke_traditional ( 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 *  fname,
const char *  uids,
SecurityFlags  flags 
)

Use PGP to create in inline-signed message.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]fnameFilename to pass to the command
[in]uidsList of IDs/fingerprints, space separated
[in]flagsFlags, see SecurityFlags
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 390 of file pgpinvoke.c.

393 {
394  if (flags & SEC_ENCRYPT)
395  {
396  const char *const c_pgp_encrypt_only_command =
397  cs_subset_string(NeoMutt->sub, "pgp_encrypt_only_command");
398  const char *const c_pgp_encrypt_sign_command =
399  cs_subset_string(NeoMutt->sub, "pgp_encrypt_sign_command");
400  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
401  fd_pgp_err, (flags & SEC_SIGN), fname, NULL, uids,
402  (flags & SEC_SIGN) ? c_pgp_encrypt_sign_command : c_pgp_encrypt_only_command);
403  }
404  else
405  {
406  const char *const c_pgp_clear_sign_command =
407  cs_subset_string(NeoMutt->sub, "pgp_clear_sign_command");
408  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
409  fd_pgp_err, true, fname, NULL, NULL, c_pgp_clear_sign_command);
410  }
411 }
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:75
#define SEC_SIGN
Email is signed.
Definition: lib.h:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_export()

pid_t pgp_invoke_export ( 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 export a key from the user's keyring.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]uidsList of IDs/fingerprints, space separated
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 507 of file pgpinvoke.c.

509 {
510  const char *const c_pgp_export_command =
511  cs_subset_string(NeoMutt->sub, "pgp_export_command");
512  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
513  fd_pgp_err, false, NULL, NULL, uids, c_pgp_export_command);
514 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_verify_key()

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.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]uidsList of IDs/fingerprints, space separated
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 531 of file pgpinvoke.c.

533 {
534  const char *const c_pgp_verify_key_command =
535  cs_subset_string(NeoMutt->sub, "pgp_verify_key_command");
536  return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
537  fd_pgp_err, false, NULL, NULL, uids, c_pgp_verify_key_command);
538 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pgp_invoke_list_keys()

pid_t pgp_invoke_list_keys ( FILE **  fp_pgp_in,
FILE **  fp_pgp_out,
FILE **  fp_pgp_err,
int  fd_pgp_in,
int  fd_pgp_out,
int  fd_pgp_err,
enum PgpRing  keyring,
struct ListHead *  hints 
)

Find matching PGP Keys.

Parameters
[out]fp_pgp_instdin for the command, or NULL (OPTIONAL)
[out]fp_pgp_outstdout for the command, or NULL (OPTIONAL)
[out]fp_pgp_errstderr for the command, or NULL (OPTIONAL)
[in]fd_pgp_instdin for the command, or -1 (OPTIONAL)
[in]fd_pgp_outstdout for the command, or -1 (OPTIONAL)
[in]fd_pgp_errstderr for the command, or -1 (OPTIONAL)
[in]keyringKeyring type, e.g. PGP_SECRING
[in]hintsMatch keys to these strings
Return values
numPID of the created process
-1Error creating pipes or forking
Note
fp_pgp_in has priority over fd_pgp_in. Likewise fp_pgp_out and fp_pgp_err.

Definition at line 556 of file pgpinvoke.c.

559 {
560  struct Buffer *uids = mutt_buffer_pool_get();
561  struct Buffer *quoted = mutt_buffer_pool_get();
562 
563  struct ListNode *np = NULL;
564  STAILQ_FOREACH(np, hints, entries)
565  {
566  mutt_buffer_quote_filename(quoted, (char *) np->data, true);
567  mutt_buffer_addstr(uids, mutt_buffer_string(quoted));
568  if (STAILQ_NEXT(np, entries))
569  mutt_buffer_addch(uids, ' ');
570  }
571 
572  const char *const c_pgp_list_pubring_command =
573  cs_subset_string(NeoMutt->sub, "pgp_list_pubring_command");
574  const char *const c_pgp_list_secring_command =
575  cs_subset_string(NeoMutt->sub, "pgp_list_secring_command");
576  pid_t rc = pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
577  fd_pgp_err, 0, NULL, NULL, mutt_buffer_string(uids),
578  (keyring == PGP_SECRING) ? c_pgp_list_secring_command :
579  c_pgp_list_pubring_command);
580 
582  mutt_buffer_pool_release(&quoted);
583  return rc;
584 }
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
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
@ PGP_SECRING
Secret keys.
Definition: pgpkey.h:40
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
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define STAILQ_NEXT(elm, field)
Definition: queue.h:400
String manipulation buffer.
Definition: buffer.h:34
A List node for strings.
Definition: list.h:35
char * data
String.
Definition: list.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function: