| 6 |
details. |
details. |
| 7 |
|
|
| 8 |
Command-line based frontend |
Command-line based frontend |
| 9 |
$Id: main.c,v 1.15 2002/08/26 19:38:51 weaselp Exp $ */ |
$Id: main.c,v 1.16 2002/08/27 06:46:13 weaselp Exp $ */ |
| 10 |
|
|
| 11 |
|
|
| 12 |
#include "mix3.h" |
#include "mix3.h" |
| 23 |
|
|
| 24 |
static char *largopt(char *p, char *opt, char *name, int *error); |
static char *largopt(char *p, char *opt, char *name, int *error); |
| 25 |
static void noarg(char *name, char p); |
static void noarg(char *name, char p); |
| 26 |
|
static int check_get_pass(int force); |
| 27 |
|
|
| 28 |
/** main *****************************************************************/ |
/** main *****************************************************************/ |
| 29 |
|
|
| 409 |
} |
} |
| 410 |
|
|
| 411 |
if (f && buf_read(msg, f) != -1) { |
if (f && buf_read(msg, f) != -1) { |
| 412 |
if (readmail == 1) |
if (readmail == 1) { |
| 413 |
|
check_get_pass(1); |
| 414 |
mix_decrypt(msg); |
mix_decrypt(msg); |
| 415 |
else if (readmail == 2) |
} else if (readmail == 2) |
| 416 |
pool_add(msg, "inf"); |
pool_add(msg, "inf"); |
| 417 |
if (send == MSG_MAIL || send == MSG_POST) { |
if (send == MSG_MAIL || send == MSG_POST) { |
| 418 |
BUFFER *sendmsg; |
BUFFER *sendmsg; |
| 554 |
} |
} |
| 555 |
#endif |
#endif |
| 556 |
|
|
| 557 |
if (keygen) |
if (keygen) { |
| 558 |
|
check_get_pass(0); |
| 559 |
keymgt(keygen); |
keymgt(keygen); |
| 560 |
|
} |
| 561 |
if (sendpool) |
if (sendpool) |
| 562 |
mix_send(); |
mix_send(); |
| 563 |
#ifdef USE_SOCK |
#ifdef USE_SOCK |
| 564 |
if (pop3) |
if (pop3) |
| 565 |
pop3get(); |
pop3get(); |
| 566 |
#endif |
#endif |
| 567 |
if (maint) |
if (maint) { |
| 568 |
|
check_get_pass(1); |
| 569 |
mix_regular(0); |
mix_regular(0); |
| 570 |
|
} |
| 571 |
|
|
| 572 |
end: |
end: |
| 573 |
buf_free(field); |
buf_free(field); |
| 579 |
buf_free(attachments); |
buf_free(attachments); |
| 580 |
|
|
| 581 |
if (daemon) { |
if (daemon) { |
| 582 |
BUFFER *pass, *key; |
check_get_pass(1); |
|
pass = buf_new(); |
|
|
key = buf_new(); |
|
|
buf_sets(pass, PASSPHRASE); |
|
|
while (pgpdb_getkey(PK_DECRYPT, PGP_ES_RSA, NULL, NULL, NULL, NULL, |
|
|
NULL, NULL, NULL, pass) < 0 && |
|
|
pgpdb_getkey(PK_DECRYPT, PGP_E_ELG, NULL, NULL, NULL, NULL, |
|
|
NULL, NULL, NULL, pass) < 0 && |
|
|
getv2seckey(NULL, key) < 0) |
|
|
{ |
|
|
user_delpass(); |
|
|
user_pass(pass); |
|
|
strncpy(PASSPHRASE, pass->data, LINELEN); |
|
|
PASSPHRASE[LINELEN-1] = 0; |
|
|
strncpy(ENTEREDPASSPHRASE, pass->data, LINELEN); |
|
|
ENTEREDPASSPHRASE[LINELEN-1] = 0; |
|
|
} |
|
|
user_delpass(); |
|
|
buf_free(pass); |
|
|
buf_free(key); |
|
|
|
|
| 583 |
#ifdef UNIX |
#ifdef UNIX |
| 584 |
if (! nodetach) { |
if (! nodetach) { |
| 585 |
int pid; |
int pid; |
| 629 |
{ |
{ |
| 630 |
fprintf(stderr, "%s: Missing argument for option -%c\n", name, p); |
fprintf(stderr, "%s: Missing argument for option -%c\n", name, p); |
| 631 |
} |
} |
| 632 |
|
|
| 633 |
|
static int check_get_pass(int force) |
| 634 |
|
/* get a passphrase and check against keys |
| 635 |
|
* if force != 0 passphrase must much with some key */ |
| 636 |
|
{ |
| 637 |
|
BUFFER *pass, *pass2, *key; |
| 638 |
|
int n = 0; |
| 639 |
|
|
| 640 |
|
/* FIXME: check if stdin is tty, return if not */ |
| 641 |
|
|
| 642 |
|
pass = buf_new(); |
| 643 |
|
pass2 = buf_new(); |
| 644 |
|
key = buf_new(); |
| 645 |
|
buf_sets(pass, PASSPHRASE); |
| 646 |
|
while (pgpdb_getkey(PK_DECRYPT, PGP_ES_RSA, NULL, NULL, NULL, NULL, |
| 647 |
|
NULL, NULL, NULL, pass) < 0 && |
| 648 |
|
pgpdb_getkey(PK_DECRYPT, PGP_E_ELG, NULL, NULL, NULL, NULL, |
| 649 |
|
NULL, NULL, NULL, pass) < 0 && |
| 650 |
|
getv2seckey(NULL, key) < 0) |
| 651 |
|
{ |
| 652 |
|
user_delpass(); |
| 653 |
|
if (n) |
| 654 |
|
fprintf(stderr, "re-"); |
| 655 |
|
user_pass(pass); |
| 656 |
|
strncpy(PASSPHRASE, pass->data, LINELEN); |
| 657 |
|
PASSPHRASE[LINELEN-1] = 0; |
| 658 |
|
if (!force) { |
| 659 |
|
if (n && buf_eq(pass, pass2)) |
| 660 |
|
break; |
| 661 |
|
buf_set(pass2, pass); |
| 662 |
|
} |
| 663 |
|
n=1; |
| 664 |
|
} |
| 665 |
|
strncpy(ENTEREDPASSPHRASE, pass->data, LINELEN); |
| 666 |
|
ENTEREDPASSPHRASE[LINELEN-1] = 0; |
| 667 |
|
user_delpass(); |
| 668 |
|
buf_free(pass); |
| 669 |
|
buf_free(pass2); |
| 670 |
|
buf_free(key); |
| 671 |
|
return 1; |
| 672 |
|
} |