1214{
1215 char buf[1024] = { 0 };
1217 char *cert_end = NULL;
1218 FILE *fp_smime_in = NULL;
1219 FILE *fp_smime_err = NULL;
1220 FILE *fp_out = NULL;
1221 FILE *fp_tmp = NULL;
1222 struct Body *b_enc = NULL;
1223 bool err = false;
1224 int empty;
1225 int off;
1226 pid_t pid;
1227
1230
1233 if (!fp_out)
1234 {
1236 goto cleanup;
1237 }
1238
1240 if (!fp_smime_err)
1241 {
1243 goto cleanup;
1244 }
1245
1248 if (!fp_tmp)
1249 {
1251 goto cleanup;
1252 }
1253
1254 *certfile = '\0';
1255 for (char *cert_start = certlist; cert_start; cert_start = cert_end)
1256 {
1257 cert_end = strchr(cert_start, ' ');
1258 if (cert_end)
1259 *cert_end = '\0';
1260 if (*cert_start)
1261 {
1264 snprintf(certfile + off, sizeof(certfile) - off, "%s%s/%s",
1265 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1266 }
1267 if (cert_end)
1268 *cert_end++ = ' ';
1269 }
1270
1271
1273 fputc('\n', fp_tmp);
1276
1278 fileno(fp_smime_err),
buf_string(smime_infile), certfile);
1279 if (pid == -1)
1280 {
1282 goto cleanup;
1283 }
1284
1286
1289
1290 fflush(fp_out);
1291 fseek(fp_out, 0, SEEK_SET);
1292 clearerr(fp_out);
1293 empty = (fgetc(fp_out) == EOF);
1295
1296 fflush(fp_smime_err);
1297 fseek(fp_smime_err, 0, SEEK_SET);
1298 clearerr(fp_smime_err);
1299 while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
1300 {
1301 err = true;
1302 fputs(buf, stdout);
1303 }
1305
1306
1307 if (err)
1309
1310 if (empty)
1311 {
1312
1313 if (!err)
1316 goto cleanup;
1317 }
1318
1330 b_enc->
parts = NULL;
1332
1333cleanup:
1334 if (fp_out)
1335 {
1338 }
1340 if (fp_tmp)
1341 {
1344 }
1347
1348 return b_enc;
1349}
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()