Teaching an old dog new tricks
No Matches

Add a certificate and update index file (externally) More...

+ Collaboration diagram for smime_invoke_import():


void smime_class_invoke_import (const char *infile, const char *mailbox)
 Implements CryptModuleSpecs::smime_invoke_import() -.

Detailed Description

Add a certificate and update index file (externally)

infileFile containing certificate

Function Documentation

◆ smime_class_invoke_import()

void smime_class_invoke_import ( const char *  infile,
const char *  mailbox 

Implements CryptModuleSpecs::smime_invoke_import() -.

Definition at line 1184 of file smime.c.

1186 char *certfile = NULL;
1187 struct Buffer *buf = NULL;
1189 FILE *fp_err = mutt_file_mkstemp();
1190 if (!fp_err)
1191 {
1192 mutt_perror(_("Can't create temporary file"));
1193 goto done;
1194 }
1196 FILE *fp_out = mutt_file_mkstemp();
1197 if (!fp_out)
1198 {
1199 mutt_perror(_("Can't create temporary file"));
1200 goto done;
1201 }
1203 buf = buf_pool_get();
1204 const bool c_smime_ask_cert_label = cs_subset_bool(NeoMutt->sub, "smime_ask_cert_label");
1205 if (c_smime_ask_cert_label)
1206 {
1207 if ((mw_get_field(_("Label for certificate: "), buf, MUTT_COMP_NO_FLAGS,
1208 HC_OTHER, NULL, NULL) != 0) ||
1209 buf_is_empty(buf))
1210 {
1211 goto done;
1212 }
1213 }
1215 mutt_endwin();
1216 certfile = smime_extract_certificate(infile);
1217 if (certfile)
1218 {
1219 mutt_endwin();
1221 const char *const c_smime_import_cert_command = cs_subset_string(NeoMutt->sub, "smime_import_cert_command");
1222 FILE *fp_smime_in = NULL;
1223 pid_t pid = smime_invoke(&fp_smime_in, NULL, NULL, -1, fileno(fp_out),
1224 fileno(fp_err), certfile, NULL, NULL, NULL, NULL,
1225 NULL, NULL, c_smime_import_cert_command);
1226 if (pid == -1)
1227 {
1228 mutt_message(_("Error: unable to create OpenSSL subprocess"));
1229 goto done;
1230 }
1231 fputs(buf_string(buf), fp_smime_in);
1232 fputc('\n', fp_smime_in);
1233 mutt_file_fclose(&fp_smime_in);
1235 filter_wait(pid);
1237 mutt_file_unlink(certfile);
1238 FREE(&certfile);
1239 }
1241 fflush(fp_out);
1242 rewind(fp_out);
1243 fflush(fp_err);
1244 rewind(fp_err);
1246 mutt_file_copy_stream(fp_out, stdout);
1247 mutt_file_copy_stream(fp_err, stdout);
1250 mutt_file_fclose(&fp_out);
1251 mutt_file_fclose(&fp_err);
1252 buf_pool_release(&buf);
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:303
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:93
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
void mutt_endwin(void)
Shutdown curses.
Definition: curs_lib.c:154
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition: file.c:262
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:196
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:218
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition: window.c:275
#define mutt_message(...)
Definition: logging2.h:91
#define mutt_perror(...)
Definition: logging2.h:93
Miscellaneous strings.
Definition: lib.h:54
#define FREE(x)
Definition: memory.h:45
#define _(a)
Definition: message.h:28
No flags are set.
Definition: mutt.h:55
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
static char * smime_extract_certificate(const char *infile)
Extract an SMIME certificate from a file.
Definition: smime.c:1002
static pid_t smime_invoke(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err, int fp_smime_infd, int fp_smime_outfd, int fp_smime_errfd, const char *fname, const char *sig_fname, const char *cryptalg, const char *digestalg, const char *key, const char *certificates, const char *intermediates, const char *format)
Run an SMIME command.
Definition: smime.c:426
String manipulation buffer.
Definition: buffer.h:34
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
#define mutt_file_mkstemp()
Definition: tmp.h:36
+ Here is the call graph for this function: