1385{
1386 char buf[1024], certfile[
PATH_MAX];
1387 char *cert_end = NULL;
1388 FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1389 struct Body *t = NULL;
1390 int err = 0, empty, off;
1391 pid_t pid;
1392
1395
1398 if (!fp_out)
1399 {
1401 goto cleanup;
1402 }
1403
1405 if (!fp_smime_err)
1406 {
1408 goto cleanup;
1409 }
1410
1413 if (!fp_tmp)
1414 {
1416 goto cleanup;
1417 }
1418
1419 *certfile = '\0';
1420 for (char *cert_start = certlist; cert_start; cert_start = cert_end)
1421 {
1422 cert_end = strchr(cert_start, ' ');
1423 if (cert_end)
1424 *cert_end = '\0';
1425 if (*cert_start)
1426 {
1429 snprintf(certfile + off, sizeof(certfile) - off, "%s%s/%s",
1430 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1431 }
1432 if (cert_end)
1433 *cert_end++ = ' ';
1434 }
1435
1436
1438 fputc('\n', fp_tmp);
1441
1443 fileno(fp_smime_err),
buf_string(smime_infile), certfile);
1444 if (pid == -1)
1445 {
1447 goto cleanup;
1448 }
1449
1451
1454
1455 fflush(fp_out);
1456 rewind(fp_out);
1457 empty = (fgetc(fp_out) == EOF);
1459
1460 fflush(fp_smime_err);
1461 rewind(fp_smime_err);
1462 while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
1463 {
1464 err = 1;
1465 fputs(buf, stdout);
1466 }
1468
1469
1470 if (err)
1472
1473 if (empty)
1474 {
1475
1476 if (err == 0)
1479 goto cleanup;
1480 }
1481
1495
1496cleanup:
1497 if (fp_out)
1498 {
1501 }
1503 if (fp_tmp)
1504 {
1507 }
1510
1511 return t;
1512}
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.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
void mutt_file_unlink(const char *s)
Delete a file, carefully.
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 *a, 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()