1354{
1355 char buf[1024], certfile[
PATH_MAX];
1356 char *cert_end = NULL;
1357 FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1358 struct Body *t = NULL;
1359 int err = 0, empty, off;
1360 pid_t pid;
1361
1364
1367 if (!fp_out)
1368 {
1370 goto cleanup;
1371 }
1372
1374 if (!fp_smime_err)
1375 {
1377 goto cleanup;
1378 }
1379
1382 if (!fp_tmp)
1383 {
1385 goto cleanup;
1386 }
1387
1388 *certfile = '\0';
1389 for (char *cert_start = certlist; cert_start; cert_start = cert_end)
1390 {
1391 cert_end = strchr(cert_start, ' ');
1392 if (cert_end)
1393 *cert_end = '\0';
1394 if (*cert_start)
1395 {
1398 snprintf(certfile + off, sizeof(certfile) - off, "%s%s/%s",
1399 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1400 }
1401 if (cert_end)
1402 *cert_end++ = ' ';
1403 }
1404
1405
1407 fputc('\n', fp_tmp);
1410
1412 fileno(fp_smime_err),
1414 if (pid == -1)
1415 {
1417 goto cleanup;
1418 }
1419
1421
1424
1425 fflush(fp_out);
1426 rewind(fp_out);
1427 empty = (fgetc(fp_out) == EOF);
1429
1430 fflush(fp_smime_err);
1431 rewind(fp_smime_err);
1432 while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
1433 {
1434 err = 1;
1435 fputs(buf, stdout);
1436 }
1438
1439
1440 if (err)
1442
1443 if (empty)
1444 {
1445
1446 if (err == 0)
1449 goto cleanup;
1450 }
1451
1465
1466cleanup:
1467 if (fp_out)
1468 {
1471 }
1473 if (fp_tmp)
1474 {
1477 }
1480
1481 return t;
1482}
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer's string.
static const char * mutt_buffer_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.
#define mutt_file_mkstemp()
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.
#define mutt_buffer_mktemp(buf)
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from 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.