NeoMutt  2025-01-09-117-gace867
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 <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 "expando/lib.h"
#include "expando_command.h"
#include "mutt_logging.h"
#include "pgpkey.h"
#include "protos.h"
#include "pgp.h"
+ Include dependency graph for pgpinvoke.c:

Go to the source code of this file.

Functions

static void mutt_pgp_command (struct Buffer *buf, struct PgpCommandContext *cctx, const struct Expando *exp)
 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 struct Expando *exp)
 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)
 Import a key from a message into the user's public key ring - Implements CryptModuleSpecs::pgp_invoke_import() -.
 
void pgp_class_invoke_getkeys (struct Address *addr)
 Run a command to download a PGP key - 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
  • Richard Russon
  • Pietro Cerutti
  • Tóth János

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 ( struct Buffer buf,
struct PgpCommandContext cctx,
const struct Expando exp 
)
static

Prepare a PGP Command.

Parameters
bufBuffer for the result
cctxData to pass to the formatter
expExpando to use

Definition at line 60 of file pgpinvoke.c.

62{
64 mutt_debug(LL_DEBUG2, "%s\n", buf_string(buf));
65}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
int expando_render(const struct Expando *exp, const struct ExpandoRenderCallback *erc, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando + data into a string.
Definition: expando.c:118
const struct ExpandoRenderCallback PgpCommandRenderCallbacks[]
Callbacks for PGP Command Expandos.
#define mutt_debug(LEVEL,...)
Definition: logging2.h:90
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:45
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: render.h:33
size_t dsize
Length of data.
Definition: buffer.h:39
+ 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 struct Expando exp 
)
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]expExpando 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 86 of file pgpinvoke.c.

90{
91 struct PgpCommandContext cctx = { 0 };
92
93 if (!exp)
94 return (pid_t) -1;
95
97 cctx.fname = fname;
98 cctx.sig_fname = sig_fname;
99 const char *const c_pgp_sign_as = cs_subset_string(NeoMutt->sub, "pgp_sign_as");
100 const char *const c_pgp_default_key = cs_subset_string(NeoMutt->sub, "pgp_default_key");
101 if (c_pgp_sign_as)
102 cctx.signas = c_pgp_sign_as;
103 else
104 cctx.signas = c_pgp_default_key;
105 cctx.ids = ids;
106
107 struct Buffer *cmd = buf_pool_get();
108 mutt_pgp_command(cmd, &cctx, exp);
109
110 pid_t pid = filter_create_fd(buf_string(cmd), fp_pgp_in, fp_pgp_out, fp_pgp_err,
111 fd_pgp_in, fd_pgp_out, fd_pgp_err, NeoMutt->env);
112 buf_pool_release(&cmd);
113 return pid;
114}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
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:62
static void mutt_pgp_command(struct Buffer *buf, struct PgpCommandContext *cctx, const struct Expando *exp)
Prepare a PGP Command.
Definition: pgpinvoke.c:60
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
String manipulation buffer.
Definition: buffer.h:36
Container for Accounts, Notifications.
Definition: neomutt.h:43
char ** env
Private copy of the environment variables.
Definition: neomutt.h:55
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:47
Data for a PGP command.
Definition: pgp.h:43
bool need_passphrase
p
Definition: pgp.h:44
const char * signas
a
Definition: pgp.h:47
const char * fname
f
Definition: pgp.h:45
const char * ids
r
Definition: pgp.h:48
const char * sig_fname
s
Definition: pgp.h:46
+ 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 132 of file pgpinvoke.c.

135{
136 const struct Expando *c_pgp_decode_command = cs_subset_expando(NeoMutt->sub, "pgp_decode_command");
137 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out, fd_pgp_err,
138 need_passphrase, fname, NULL, NULL, c_pgp_decode_command);
139}
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
Definition: config_type.c:361
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 struct Expando *exp)
Run a PGP command.
Definition: pgpinvoke.c:86
Parsed Expando trees.
Definition: expando.h:41
+ 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 157 of file pgpinvoke.c.

160{
161 const struct Expando *c_pgp_verify_command = cs_subset_expando(NeoMutt->sub, "pgp_verify_command");
162 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
163 fd_pgp_err, false, fname, sig_fname, NULL, c_pgp_verify_command);
164}
+ 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 181 of file pgpinvoke.c.

183{
184 const struct Expando *c_pgp_decrypt_command = cs_subset_expando(NeoMutt->sub, "pgp_decrypt_command");
185 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
186 fd_pgp_err, true, fname, NULL, NULL, c_pgp_decrypt_command);
187}
+ 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 204 of file pgpinvoke.c.

206{
207 const struct Expando *c_pgp_sign_command = cs_subset_expando(NeoMutt->sub, "pgp_sign_command");
208 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
209 fd_pgp_err, true, fname, NULL, NULL, c_pgp_sign_command);
210}
+ 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 229 of file pgpinvoke.c.

232{
233 if (sign)
234 {
235 const struct Expando *c_pgp_encrypt_sign_command = cs_subset_expando(NeoMutt->sub, "pgp_encrypt_sign_command");
236 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
237 fd_pgp_err, true, fname, NULL, uids, c_pgp_encrypt_sign_command);
238 }
239 else
240 {
241 const struct Expando *c_pgp_encrypt_only_command = cs_subset_expando(NeoMutt->sub, "pgp_encrypt_only_command");
242 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
243 fd_pgp_err, false, fname, NULL, uids, c_pgp_encrypt_only_command);
244 }
245}
+ 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 264 of file pgpinvoke.c.

267{
268 if (flags & SEC_ENCRYPT)
269 {
270 const struct Expando *c_pgp_encrypt_only_command = cs_subset_expando(NeoMutt->sub, "pgp_encrypt_only_command");
271 const struct Expando *c_pgp_encrypt_sign_command = cs_subset_expando(NeoMutt->sub, "pgp_encrypt_sign_command");
272 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
273 fd_pgp_err, (flags & SEC_SIGN), fname, NULL, uids,
274 (flags & SEC_SIGN) ? c_pgp_encrypt_sign_command : c_pgp_encrypt_only_command);
275 }
276 else
277 {
278 const struct Expando *c_pgp_clear_sign_command = cs_subset_expando(NeoMutt->sub, "pgp_clear_sign_command");
279 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
280 fd_pgp_err, true, fname, NULL, NULL, c_pgp_clear_sign_command);
281 }
282}
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:84
#define SEC_SIGN
Email is signed.
Definition: lib.h:85
+ 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 374 of file pgpinvoke.c.

376{
377 const struct Expando *c_pgp_export_command = cs_subset_expando(NeoMutt->sub, "pgp_export_command");
378 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
379 fd_pgp_err, false, NULL, NULL, uids, c_pgp_export_command);
380}
+ 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 397 of file pgpinvoke.c.

399{
400 const struct Expando *c_pgp_verify_key_command = cs_subset_expando(NeoMutt->sub, "pgp_verify_key_command");
401 return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in, fd_pgp_out,
402 fd_pgp_err, false, NULL, NULL, uids, c_pgp_verify_key_command);
403}
+ 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 421 of file pgpinvoke.c.

424{
425 struct Buffer *uids = buf_pool_get();
426 struct Buffer *quoted = buf_pool_get();
427
428 struct ListNode *np = NULL;
429 STAILQ_FOREACH(np, hints, entries)
430 {
431 buf_quote_filename(quoted, (char *) np->data, true);
432 buf_addstr(uids, buf_string(quoted));
433 if (STAILQ_NEXT(np, entries))
434 buf_addch(uids, ' ');
435 }
436
437 const struct Expando *c_pgp_list_pubring_command = cs_subset_expando(NeoMutt->sub, "pgp_list_pubring_command");
438 const struct Expando *c_pgp_list_secring_command = cs_subset_expando(NeoMutt->sub, "pgp_list_secring_command");
439 pid_t rc = pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, fd_pgp_in,
440 fd_pgp_out, fd_pgp_err, 0, NULL, NULL, buf_string(uids),
441 (keyring == PGP_SECRING) ? c_pgp_list_secring_command :
442 c_pgp_list_pubring_command);
443
444 buf_pool_release(&uids);
445 buf_pool_release(&quoted);
446 return rc;
447}
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:241
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:226
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:810
@ PGP_SECRING
Secret keys.
Definition: pgpkey.h:40
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:390
#define STAILQ_NEXT(elm, field)
Definition: queue.h:439
A List node for strings.
Definition: list.h:37
char * data
String.
Definition: list.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function: