1187{
1188 char buf[1024] = { 0 };
1190 char *cert_end = NULL;
1191 FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1192 struct Body *b_enc = NULL;
1193 bool err = false;
1194 int empty, off;
1195 pid_t pid;
1196
1199
1202 if (!fp_out)
1203 {
1205 goto cleanup;
1206 }
1207
1209 if (!fp_smime_err)
1210 {
1212 goto cleanup;
1213 }
1214
1217 if (!fp_tmp)
1218 {
1220 goto cleanup;
1221 }
1222
1223 *certfile = '\0';
1224 for (char *cert_start = certlist; cert_start; cert_start = cert_end)
1225 {
1226 cert_end = strchr(cert_start, ' ');
1227 if (cert_end)
1228 *cert_end = '\0';
1229 if (*cert_start)
1230 {
1233 snprintf(certfile + off, sizeof(certfile) - off, "%s%s/%s",
1234 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1235 }
1236 if (cert_end)
1237 *cert_end++ = ' ';
1238 }
1239
1240
1242 fputc('\n', fp_tmp);
1245
1247 fileno(fp_smime_err),
buf_string(smime_infile), certfile);
1248 if (pid == -1)
1249 {
1251 goto cleanup;
1252 }
1253
1255
1258
1259 fflush(fp_out);
1260 rewind(fp_out);
1261 empty = (fgetc(fp_out) == EOF);
1263
1264 fflush(fp_smime_err);
1265 rewind(fp_smime_err);
1266 while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
1267 {
1268 err = true;
1269 fputs(buf, stdout);
1270 }
1272
1273
1274 if (err)
1276
1277 if (empty)
1278 {
1279
1280 if (!err)
1283 goto cleanup;
1284 }
1285
1297 b_enc->
parts = NULL;
1299
1300cleanup:
1301 if (fp_out)
1302 {
1305 }
1307 if (fp_tmp)
1308 {
1311 }
1314
1315 return b_enc;
1316}
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()