NeoMutt
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
pgpinvoke.c File Reference

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

#include "config.h"
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.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 "globals.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 -.
 
static void mutt_pgp_command (char *buf, size_t buflen, struct PgpCommandContext *cctx, const char *fmt)
 Prepare a PGP Command.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
void pgp_class_invoke_import (const char *fname)
 Implements CryptModuleSpecs::pgp_invoke_import() -.
 
void pgp_class_invoke_getkeys (struct Address *addr)
 Implements CryptModuleSpecs::pgp_invoke_getkeys() -.
 
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.
 
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.
 
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.
 

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
See also
pgp_command_format_str()

Definition at line 187 of file pgpinvoke.c.

189{
190 mutt_expando_format(buf, buflen, 0, buflen, NONULL(fmt), pgp_command_format_str,
191 (intptr_t) cctx, MUTT_FORMAT_NO_FLAGS);
192 mutt_debug(LL_DEBUG2, "%s\n", buf);
193}
#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:80
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:745
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
#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 214 of file pgpinvoke.c.

218{
219 struct PgpCommandContext cctx = { 0 };
220 char cmd[STR_COMMAND] = { 0 };
221
222 if (!format || (*format == '\0'))
223 return (pid_t) -1;
224
226 cctx.fname = fname;
227 cctx.sig_fname = sig_fname;
228 const char *const c_pgp_sign_as = cs_subset_string(NeoMutt->sub, "pgp_sign_as");
229 const char *const c_pgp_default_key = cs_subset_string(NeoMutt->sub, "pgp_default_key");
230 if (c_pgp_sign_as)
231 cctx.signas = c_pgp_sign_as;
232 else
233 cctx.signas = c_pgp_default_key;
234 cctx.ids = ids;
235
236 mutt_pgp_command(cmd, sizeof(cmd), &cctx, format);
237
238 return filter_create_fd(cmd, fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in,
239 fd_pgp_out, fd_pgp_err, EnvList);
240}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
pid_t filter_create_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr, char **envlist)
Run a command on a pipe (optionally connect stdin/stdout)
Definition: filter.c:61
char ** EnvList
Private copy of the environment variables.
Definition: globals.c:85
static void mutt_pgp_command(char *buf, size_t buflen, struct PgpCommandContext *cctx, const char *fmt)
Prepare a PGP Command.
Definition: pgpinvoke.c:187
#define STR_COMMAND
Enough space for a long command line.
Definition: string2.h:35
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
Data for a PGP command.
Definition: pgpinvoke.c:61
bool need_passphrase
p
Definition: pgpinvoke.c:62
const char * signas
a
Definition: pgpinvoke.c:65
const char * fname
f
Definition: pgpinvoke.c:63
const char * ids
r
Definition: pgpinvoke.c:66
const char * sig_fname
s
Definition: pgpinvoke.c:64
+ 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 264 of file pgpinvoke.c.

267{
268 const char *const c_pgp_decode_command = cs_subset_string(NeoMutt->sub, "pgp_decode_command");
269 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out, fd_pgp_err,
270 need_passphrase, fname, NULL, NULL, c_pgp_decode_command);
271}
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:214
+ 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 289 of file pgpinvoke.c.

292{
293 const char *const c_pgp_verify_command = cs_subset_string(NeoMutt->sub, "pgp_verify_command");
294 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
295 fd_pgp_err, false, fname, sig_fname, NULL, c_pgp_verify_command);
296}
+ 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 313 of file pgpinvoke.c.

315{
316 const char *const c_pgp_decrypt_command = cs_subset_string(NeoMutt->sub, "pgp_decrypt_command");
317 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
318 fd_pgp_err, true, fname, NULL, NULL, c_pgp_decrypt_command);
319}
+ 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 336 of file pgpinvoke.c.

338{
339 const char *const c_pgp_sign_command = cs_subset_string(NeoMutt->sub, "pgp_sign_command");
340 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
341 fd_pgp_err, true, fname, NULL, NULL, c_pgp_sign_command);
342}
+ 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 361 of file pgpinvoke.c.

364{
365 if (sign)
366 {
367 const char *const c_pgp_encrypt_sign_command = cs_subset_string(NeoMutt->sub, "pgp_encrypt_sign_command");
368 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
369 fd_pgp_err, true, fname, NULL, uids, c_pgp_encrypt_sign_command);
370 }
371 else
372 {
373 const char *const c_pgp_encrypt_only_command = cs_subset_string(NeoMutt->sub, "pgp_encrypt_only_command");
374 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
375 fd_pgp_err, false, fname, NULL, uids, c_pgp_encrypt_only_command);
376 }
377}
+ 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 396 of file pgpinvoke.c.

399{
400 if (flags & SEC_ENCRYPT)
401 {
402 const char *const c_pgp_encrypt_only_command = cs_subset_string(NeoMutt->sub, "pgp_encrypt_only_command");
403 const char *const c_pgp_encrypt_sign_command = cs_subset_string(NeoMutt->sub, "pgp_encrypt_sign_command");
404 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
405 fd_pgp_err, (flags & SEC_SIGN), fname, NULL, uids,
406 (flags & SEC_SIGN) ? c_pgp_encrypt_sign_command : c_pgp_encrypt_only_command);
407 }
408 else
409 {
410 const char *const c_pgp_clear_sign_command = cs_subset_string(NeoMutt->sub, "pgp_clear_sign_command");
411 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
412 fd_pgp_err, true, fname, NULL, NULL, c_pgp_clear_sign_command);
413 }
414}
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:79
#define SEC_SIGN
Email is signed.
Definition: lib.h:80
+ 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 506 of file pgpinvoke.c.

508{
509 const char *const c_pgp_export_command = cs_subset_string(NeoMutt->sub, "pgp_export_command");
510 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
511 fd_pgp_err, false, NULL, NULL, uids, c_pgp_export_command);
512}
+ 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 529 of file pgpinvoke.c.

531{
532 const char *const c_pgp_verify_key_command = cs_subset_string(NeoMutt->sub, "pgp_verify_key_command");
533 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
534 fd_pgp_err, false, NULL, NULL, uids, c_pgp_verify_key_command);
535}
+ 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 553 of file pgpinvoke.c.

556{
557 struct Buffer *uids = buf_pool_get();
558 struct Buffer *quoted = buf_pool_get();
559
560 struct ListNode *np = NULL;
561 STAILQ_FOREACH(np, hints, entries)
562 {
563 buf_quote_filename(quoted, (char *) np->data, true);
564 buf_addstr(uids, buf_string(quoted));
565 if (STAILQ_NEXT(np, entries))
566 buf_addch(uids, ' ');
567 }
568
569 const char *const c_pgp_list_pubring_command = cs_subset_string(NeoMutt->sub, "pgp_list_pubring_command");
570 const char *const c_pgp_list_secring_command = cs_subset_string(NeoMutt->sub, "pgp_list_secring_command");
571 pid_t rc = pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in,
572 fd_pgp_out, fd_pgp_err, 0, NULL, NULL, buf_string(uids),
573 (keyring == PGP_SECRING) ? c_pgp_list_secring_command :
574 c_pgp_list_pubring_command);
575
576 buf_pool_release(&uids);
577 buf_pool_release(&quoted);
578 return rc;
579}
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:253
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:238
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:93
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:936
@ PGP_SECRING
Secret keys.
Definition: pgpkey.h:40
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
#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: