--- main.c.orig Wed Nov 1 19:37:25 2000 +++ main.c Sat Nov 4 11:24:02 2000 @@ -10,6 +10,7 @@ #include "mix3.h" +#include #include #include #include @@ -19,6 +20,24 @@ #include #endif +/* This file has been modified by Brian Salter-Duke to allow the -T + flag needed by mutt with this version. The -T flag, or in keeping + with the verbose nature of mix flags, --output-type2.list, outputs + a list of type 2 reliable remailers. The modifications are very much + of a hack. and are restricted to this file, main.c. + + The Mix directory has to be defined by the environmental variable + MIXPATH or at compile with -DSPOOL. This is more limited than the + ways of finding the Mix directory in mix.c. Messages are left in + the pool, so some way has to be found to send the messages from + the pool unless of course you are running as a remailer when the mix + executable as daemon will send them. This can be done from a mutt + wrapper script as you leave mutt or by a mutt macro such as:- + + macro index \cs "!/path/to/Mix/mix -S\n" + +*******************************************************************/ + static char *largopt(char *p, char *opt, char *name, int *error); static void noarg(char *name, char p); @@ -33,7 +52,7 @@ { int error = 0, deflt = 1, help = 0, readmail = 0, send = -1, sendpool = 0, header = 1, maint = 0, keygen = 0, verbose = 2, sign = 0, encrypt = 0; - int daemon = 0; + int daemon = 0, type_list = 0; #ifdef USE_SOCK int pop3 = 0; @@ -42,16 +61,16 @@ char *filename = NULL; int i; int ret = 0; - char *p, *q; + char *p, *q, *d; char chain[1024] = ""; char nym[LINELEN] = ""; - BUFFER *nymopt, *pseudonym, *attachments; + BUFFER *nymopt, *pseudonym, *attachments, *type2; int numcopies = 0; /* default value set in mix.cfg */ BUFFER *msg, *chainlist, *field, *content; FILE *f; + char mix_dir[PATHMAX]; mix_init(NULL); - msg = buf_new(); chainlist = buf_new(); nymopt = buf_new(); @@ -86,13 +105,15 @@ else if (streq(p, "dummy")) send = MSG_NULL, deflt = 0; else if (streq(p, "remailer")) - maint = 1, deflt = 0; + maint = 1, deflt = 0; else if (streq(p, "generate-key")) keygen = 2, deflt = 0; else if (streq(p, "update-keys")) keygen = 1, deflt = 0; else if (streq(p, "send")) sendpool = 1, deflt = 0; + else if (streq(p, "output-type2.list")) + type_list = 1; else if (streq(p, "read-mail")) readmail = 1, deflt = 0; #ifdef USE_SOCK @@ -161,6 +182,9 @@ case 'M': maint = 1, deflt = 0; break; + case 'T': + type_list = 1; + break; #ifdef USE_SOCK case 'P': pop3 = 1, deflt = 0; @@ -280,6 +304,36 @@ } } + if (type_list) { + ret = 1; + if ((d = getenv("MIXPATH")) != NULL) { + strncpy(mix_dir, d, PATHMAX); + ret = 0; + } +#ifdef SPOOL + if (ret && (strlen(SPOOL) > 0)) { + strncpy(mix_dir, SPOOL, PATHMAX); + ret = 0; + } +#endif + if (ret) { + printf("Mix directory not found"); + goto end; + } else + chdir(mix_dir); + + if ((f = mix_openfile(TYPE2LIST, "r")) != NULL) { + type2 = buf_new(); + buf_read(type2, f); + buf_write(type2,stdout); + buf_free(type2); + } else { + fprintf(stderr, "%s could not be opened \n", TYPE2LIST); + ret = 1; + } + goto end; + } + if (error) { ret = 1; goto end; @@ -307,7 +361,8 @@ "-l, --chain=mix1,mix2,mix3,... specify a remailer chain\n\ -c, --copies=num send num copies to increase reliability\n\ -d, --dummy generate a dummy message\n\ --S, --send send the message(s) in the pool\n" +-S, --send send the message(s) in the pool\n\ +-T, --output-type2.list output the list of keys to stdout\n" #ifdef USE_PGP " --nym-config=yournym generate a new pseudonym\n\ --latency=hours reply chain latency\n\ @@ -376,15 +431,16 @@ if (bufieq(field, "nym")) { strncpy(nym, content->data, sizeof(nym)); } else if (bufieq(field, "chain")) - if (strchr(content->data, ';')) { - i = strchr(content->data, ';') - (char *)content->data; - strncpy(chain, content->data, i); - if (strstr(content->data + i, "copies=") != NULL) { - sscanf(strstr(content->data + i, "copies=") + + { if (strchr(content->data, ';')) { + i = strchr(content->data, ';') - (char *)content->data; + strncpy(chain, content->data, i); + if (strstr(content->data + i, "copies=") != NULL) { + sscanf(strstr(content->data + i, "copies=") + sizeof("copies=") - 1, "%d", &numcopies); - } - } else - strncpy(chain, content->data, sizeof(chain)); + } + } else + strncpy(chain, content->data, sizeof(chain)); + } else { /* line goes into message */ if ((send == MSG_MAIL && bufieq(field, "to")) || (send == MSG_POST && bufieq(field, "newsgroups"))) @@ -556,3 +612,4 @@ { fprintf(stderr, "%s: Missing argument for option -%c\n", name, p); } +