1332{
1333 char buf[1024] = { 0 };
1335 char *cert_end = NULL;
1336 FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1337 struct Body *b_enc = NULL;
1338 bool err = false;
1339 int empty, off;
1340 pid_t pid;
1341
1344
1347 if (!fp_out)
1348 {
1350 goto cleanup;
1351 }
1352
1354 if (!fp_smime_err)
1355 {
1357 goto cleanup;
1358 }
1359
1362 if (!fp_tmp)
1363 {
1365 goto cleanup;
1366 }
1367
1368 *certfile = '\0';
1369 for (char *cert_start = certlist; cert_start; cert_start = cert_end)
1370 {
1371 cert_end = strchr(cert_start, ' ');
1372 if (cert_end)
1373 *cert_end = '\0';
1374 if (*cert_start)
1375 {
1378 snprintf(certfile + off, sizeof(certfile) - off, "%s%s/%s",
1379 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1380 }
1381 if (cert_end)
1382 *cert_end++ = ' ';
1383 }
1384
1385
1387 fputc('\n', fp_tmp);
1390
1392 fileno(fp_smime_err),
buf_string(smime_infile), certfile);
1393 if (pid == -1)
1394 {
1396 goto cleanup;
1397 }
1398
1400
1403
1404 fflush(fp_out);
1405 rewind(fp_out);
1406 empty = (fgetc(fp_out) == EOF);
1408
1409 fflush(fp_smime_err);
1410 rewind(fp_smime_err);
1411 while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
1412 {
1413 err = true;
1414 fputs(buf, stdout);
1415 }
1417
1418
1419 if (err)
1421
1422 if (empty)
1423 {
1424
1425 if (!err)
1428 goto cleanup;
1429 }
1430
1442 b_enc->
parts = NULL;
1444
1445cleanup:
1446 if (fp_out)
1447 {
1450 }
1452 if (fp_tmp)
1453 {
1456 }
1459
1460 return b_enc;
1461}
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
void mutt_file_unlink(const char *s)
Delete a file, carefully.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
int mutt_write_mime_body(struct Body *b, FILE *fp, struct ConfigSubset *sub)
Write a MIME part.
static pid_t smime_invoke_encrypt(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 *uids)
Use SMIME to encrypt a file.
String manipulation buffer.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
#define mutt_file_mkstemp()