|
|
@ -80,6 +80,7 @@ for submission to a mail submission agent.\n"); |
|
|
|
puts("\ |
|
|
|
Cryptography options:\n\ |
|
|
|
-s, --sign Sign the message.\n\ |
|
|
|
-E, --encrypt RECP Encrypt for the specified recipient.\n\ |
|
|
|
"); |
|
|
|
|
|
|
|
printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT); |
|
|
@ -115,7 +116,7 @@ typedef struct fmail_ctx |
|
|
|
size_t att_count; |
|
|
|
const char *footer; |
|
|
|
magic_t magic_ctx; |
|
|
|
gpgme_ctx_t signing_ctx; |
|
|
|
gpgme_ctx_t crypto_ctx; |
|
|
|
FILE *input; |
|
|
|
} fmail_ctx_t; |
|
|
|
|
|
|
@ -534,11 +535,13 @@ main(int argc, char *argv[]) |
|
|
|
char c, with_useragent, with_date; |
|
|
|
string_buffer_t *headers; |
|
|
|
fmail_ctx_t ctx; |
|
|
|
int do_sign, do_encrypt; |
|
|
|
|
|
|
|
struct option options[] = { |
|
|
|
{ "help", 0, NULL, 'h' }, |
|
|
|
{ "version", 0, NULL, 'v' }, |
|
|
|
{ "sign", 0, NULL, 's' }, |
|
|
|
{ "encrypt", 1, NULL, 'E' }, |
|
|
|
{ "attach", 1, NULL, 'a' }, |
|
|
|
{ "edit", 0, NULL, 'e' }, |
|
|
|
{ "footer", 1, NULL, 'f' }, |
|
|
@ -556,17 +559,17 @@ main(int argc, char *argv[]) |
|
|
|
setlocale(LC_ALL, ""); |
|
|
|
srand(time(NULL)); |
|
|
|
|
|
|
|
with_useragent = with_date = 0; |
|
|
|
with_useragent = with_date = do_sign = do_encrypt = 0; |
|
|
|
|
|
|
|
headers = sb_new(0); |
|
|
|
ctx.signing_ctx = NULL; |
|
|
|
ctx.crypto_ctx = NULL; |
|
|
|
ctx.magic_ctx = initialize_magic(); |
|
|
|
ctx.attachments = NULL; |
|
|
|
ctx.att_count = 0; |
|
|
|
ctx.footer = NULL; |
|
|
|
ctx.input = stdin; |
|
|
|
|
|
|
|
while ( (c = getopt_long(argc, argv, "hvsa:ef:H:F:T:C:S:UD", |
|
|
|
while ( (c = getopt_long(argc, argv, "hvsE:a:ef:H:F:T:C:S:UD", |
|
|
|
options, NULL)) != -1 ) { |
|
|
|
switch ( c ) { |
|
|
|
case 'h': |
|
|
@ -582,8 +585,11 @@ main(int argc, char *argv[]) |
|
|
|
break; |
|
|
|
|
|
|
|
case 's': |
|
|
|
if ( ! ctx.signing_ctx ) |
|
|
|
ctx.signing_ctx = initialize_gpgme(); |
|
|
|
do_sign = 1; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'E': |
|
|
|
do_encrypt = 1; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'a': |
|
|
@ -630,6 +636,11 @@ main(int argc, char *argv[]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ( do_sign && do_encrypt ) |
|
|
|
errx(EXIT_FAILURE, "encrypt and sign is not currently supported"); |
|
|
|
if ( do_sign || do_encrypt ) |
|
|
|
ctx.crypto_ctx = initialize_gpgme(); |
|
|
|
|
|
|
|
/* Generate automatic headers */ |
|
|
|
if ( with_date ) |
|
|
|
sb_addf(headers, "Date: %s\r\n", rfc2822_date()); |
|
|
@ -646,15 +657,15 @@ main(int argc, char *argv[]) |
|
|
|
/* Write all headers. */ |
|
|
|
fprintf(stdout, "%s", sb_get(headers)); |
|
|
|
|
|
|
|
if ( ctx.signing_ctx ) { |
|
|
|
if ( do_sign ) { |
|
|
|
FILE *tmp = tmpfile(); |
|
|
|
|
|
|
|
process_text_body(&ctx, tmp); |
|
|
|
fseek(tmp, 0, SEEK_SET); |
|
|
|
sign_stream(ctx.signing_ctx, tmp, stdout); |
|
|
|
sign_stream(ctx.crypto_ctx, tmp, stdout); |
|
|
|
|
|
|
|
fclose(tmp); |
|
|
|
gpgme_release(ctx.signing_ctx); |
|
|
|
gpgme_release(ctx.crypto_ctx); |
|
|
|
} |
|
|
|
else |
|
|
|
process_text_body(&ctx, stdout); |
|
|
|