1192{
1193 char buf[1024] = { 0 };
1195 char *cert_end = NULL;
1196 FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1197 struct Body *b_enc = NULL;
1198 bool err = false;
1199 int empty, off;
1200 pid_t pid;
1201
1204
1207 if (!fp_out)
1208 {
1210 goto cleanup;
1211 }
1212
1214 if (!fp_smime_err)
1215 {
1217 goto cleanup;
1218 }
1219
1222 if (!fp_tmp)
1223 {
1225 goto cleanup;
1226 }
1227
1228 *certfile = '\0';
1229 for (char *cert_start = certlist; cert_start; cert_start = cert_end)
1230 {
1231 cert_end = strchr(cert_start, ' ');
1232 if (cert_end)
1233 *cert_end = '\0';
1234 if (*cert_start)
1235 {
1238 snprintf(certfile + off, sizeof(certfile) - off, "%s%s/%s",
1239 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1240 }
1241 if (cert_end)
1242 *cert_end++ = ' ';
1243 }
1244
1245
1247 fputc('\n', fp_tmp);
1250
1252 fileno(fp_smime_err),
buf_string(smime_infile), certfile);
1253 if (pid == -1)
1254 {
1256 goto cleanup;
1257 }
1258
1260
1263
1264 fflush(fp_out);
1265 rewind(fp_out);
1266 empty = (fgetc(fp_out) == EOF);
1268
1269 fflush(fp_smime_err);
1270 rewind(fp_smime_err);
1271 while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
1272 {
1273 err = true;
1274 fputs(buf, stdout);
1275 }
1277
1278
1279 if (err)
1281
1282 if (empty)
1283 {
1284
1285 if (!err)
1288 goto cleanup;
1289 }
1290
1302 b_enc->
parts = NULL;
1304
1305cleanup:
1306 if (fp_out)
1307 {
1310 }
1312 if (fp_tmp)
1313 {
1316 }
1319
1320 return b_enc;
1321}
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()